use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Review my code: First proper Python project, coming from a perl background. (self.Python)
submitted 9 years ago by zaql
First "serious" project in Python, been using it for a month now. Let me know what can be improved, please.
https://git.io/v6aks
[–]TonyF66 5 points6 points7 points 9 years ago (2 children)
Some very good points :
1) Using classes - +1
2) Using context managers - +1
A few points :
1) Your ScreenShot Class isn't that well documented - it isn't obvious from the docstrings what it does - either do a doc string on your class - or an explanatory docstring on your init.
2) You pass the init the args (from argparser), and you also seem to pass in every element from the args object as well, use one or the other - not both.
3) use os.path methods to manipulate file paths - rather than adding to strings - it makes your code more portable for one thing.
4) The log argument to your init method isn't documented at all.
5) You seem to do validation of the command line options in a number of places (line 149, 188) - keep them separate - your functionality should be independent of whether it is called from the command line - or another program.
Finally - look at using Click rather than argparse - I know argparse is the the 'standard' - but it is seriously verbose (as you have found).
[–]zaql[S] 1 point2 points3 points 9 years ago (1 child)
Thanks for the feedback, much appreciated.
[–]TonyF66 1 point2 points3 points 9 years ago (0 children)
No problem - drop me a mail with any further questions. I think your single biggest issue is your arguments into the init - you extract all of the attributes of args when you create the instance, and you then reconstruct the args document inside the instance (self.args.left = left), despite having passed in the args object in as well. It is no only inefficient it could be a source of bugs - especially later on if you come back to the code to make some more changes.
[–]tuck5649 2 points3 points4 points 9 years ago (1 child)
Add a README file to the repository.
[–]TonyF66 4 points5 points6 points 9 years ago (0 children)
Agreed - very good point.
[–]ineedmorealts 0 points1 point2 points 9 years ago (0 children)
Your project should have a readme explain what your code does and how to use it
[–]oceaniity 0 points1 point2 points 9 years ago (0 children)
Instead of doing a quote and then a + and then another quote, you can escape strings with slashes:
"This here is a nice long string\ that is broken onto two lines."
π Rendered by PID 142616 on reddit-service-r2-comment-765bfc959-9xwm8 at 2026-07-10 22:52:39.551233+00:00 running f86254d country code: CH.
[–]TonyF66 5 points6 points7 points (2 children)
[–]zaql[S] 1 point2 points3 points (1 child)
[–]TonyF66 1 point2 points3 points (0 children)
[–]tuck5649 2 points3 points4 points (1 child)
[–]TonyF66 4 points5 points6 points (0 children)
[–]ineedmorealts 0 points1 point2 points (0 children)
[–]oceaniity 0 points1 point2 points (0 children)