Back

Sanskar

Keen Learner and Exp... • 5d

Day 18 of learning python as a beginner. Topic: match case and modular programming. Some suggested me to use match case instead of my usual if else statements as match case are more readable and appears more clear and organised. At that time I was juggling with modular programming which took me a day or two to understand and now using those two things I tried to create a social media platform (not exactly what you think but can say a basic platform). match cases are just like if else statements but are more readable and scalable than the if else. It was first introduced in python 3.10 and is refered as structural pattern matching. on the other hand modular programming is just breaking a bigger code into smaller reusable blocks and then importing those blocks in a single main.py file. I first tried to create a basic authentication (not from database of course) which will save and verify user's credential when he/she enters it and allow user to write a post, view it, edit it, and delete it once the authentication is done. I decided to make credentials.txt file human readable also and therefore all the data is store in "Username: xyz, Password: xyz" format and that's why it was important for the program to remove this "Username:" and "space" so that it checks only the thing which is needed and therefore I used .replace to replace all those unnecessary decoration. Then I use match cases to compare the credentials saved in the credentails.txt file (note that there is a feature of sing up and login so here I am talking about the login as only already signed up people have their information saved). then I use match cases for calling functions (I have used match cases in almost every place where I used to use if else statements). I used modular programming to break the code into two bocks first of authentication and second of all the main features which I called in my main.py where I assembled all the blocks and created the result. I would really appreciate your suggestions and challenges which will help me develope a more deeper understanding and also improve my code. And here's my code and its result.

Reply
3

More like this

Recommendations from Medial

Image Description
Image Description

Arpit Shukla

Helping people achie... • 1m

Why are we still coding in programming languages when plain but exact English statements should be used to define what functions and methods should do. Just a vision: 1. Let everyone (not only developers) write modular functions with plain English d

See More
8 Replies
14

Sanskar

Keen Learner and Exp... • 7d

Day 16 of learning python as a beginner. Topic: modular programming. A lot of amazing people suggested me that I must learn to use main.py as it will help in creating a clean resuable code. Therefore I have created my basic calculator in the modula

See More
Reply
1

AI Engineer

AI Deep Explorer | f... • 3m

10 python basic level questions 1. How do natural language problem-solving habits affect the transition to programming's precision? 2. How does "problem-solving" in programming integrate mathematical, engineering, and scientific thinking? 3. Can

See More
Reply
11
Image Description

BHUKYA GOVARDHAN NAIK

Co-Founder & CEO @ E... • 13d

I started a startup about manufacturing construction materials like bricks, paver blocks, drainage cover panels with innovative designs and interlock blocks Now the my question is, how can I start manufacturing can you guide me... The comment space

See More
1 Reply
4

Medial User

Hey I am on Medial • 5m

I want to start a paver blocks making business. that's attracts government to buy blocks for tendor works for roads and other construction. can any one tell me is it worth it.

Reply
1
3
Image Description
Image Description

prashant chaudhary

Hey I am on Medial • 8m

I have an established modular furniture factory in Greater Noida, where we can make modular kitchens and wardrobes. i want a person who can scale up this business, investment is not required. I want a person who has zeal to do something in life.

8 Replies
3
11

Rahul Talekar

Keep learning • 11m

Developers here and who are learning/finding programming niche have you considered games programming specifically graphics programming. Recently I looked into it and stuff we can do is crazy, it is like a perfect combination of Art , programming and

See More
Reply
6

Lalit Chaudhary

Fullstack developer • 19d

Authentication isn't just about logging in it's about trust, control, and elegance. Over the past few days, I’ve been diving deep into building a full-stack authentication system using: ✅ NextAuth.js ✅ Prisma ORM + MongoDB ✅ Google & GitHub OAut

See More
Reply
1
Image Description
Image Description

Havish Gupta

Figuring Out • 9m

Well for most companies Moral and Vission statements are just statements with no real use of it in business. I saw a video where the speaker said that if your organization have these statements, then you should be making hire and fire and yes or no

See More
3 Replies
6

Download the medial app to read full posts, comements and news.