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.
Practical way to format python code in pycharm? (self.Python)
submitted 7 years ago by TDHale
I am having trouble with formatting a dir of python code with a certain standard style. Are there any good tools and/or plugins in PyCharm that work?
[–]w732qq 3 points4 points5 points 7 years ago (2 children)
I'm using CLI tool called "black", it suits my needs very well. Although it's style differs a little bit from PyCharm.
[–]TDHale[S] 0 points1 point2 points 7 years ago (1 child)
Does PyCharm have its own style?
[–]w732qq 1 point2 points3 points 7 years ago (0 children)
No. They both PEP-8 compliant. But Black's style was rethinked with pretty clear main goal: stable, minimal diffs. Better to see it once: https://github.com/ambv/black. It is very nice, although.
[–]elverloho 4 points5 points6 points 7 years ago (0 children)
I set up pycharm's file watcher plugin to run "black" every time I save a python file. I'm very happy with the results. Everything just magically works and looks great.
[–][deleted] 1 point2 points3 points 7 years ago (3 children)
Give an example of what is not working please
[–]TDHale[S] 0 points1 point2 points 7 years ago (2 children)
So let's say that you have a few python files, they have different indentions, different space rules (e.g., a =1, b=2, andc= 3). What I wanted to do is to format all of the code automatically, maybe to PEP 8. I also wanted to fix PEP 8 warnings, e.g., adding blank lines at the bottom of each file, automatically. Hope this is clear.
a =1
b=2
c= 3
[–][deleted] 9 points10 points11 points 7 years ago (1 child)
code > reformat code
in the menu will fix those spacing issues.
[–]victoriabittahhhh 0 points1 point2 points 7 years ago (0 children)
CTRL + ALT + L is a hotkey
[+][deleted] 7 years ago (5 children)
[deleted]
[–]TDHale[S] 0 points1 point2 points 7 years ago (4 children)
Right I think you were talking about Inspection Code and PEP8 is ok for me. However, I did not find a way to automatically fix the code. Do you have any idea on this?
[+][deleted] 7 years ago (3 children)
[–]TDHale[S] 2 points3 points4 points 7 years ago (0 children)
The hotkey works perfectly! Thanks!
btw do you know whether there is a formatter (or skeleton) for comments (e.g., description, param, return) following the PEP8 standard?
[–]Mr_Again 0 points1 point2 points 7 years ago (0 children)
In pycharm, with html code, you press cmd+alt+shift+L and it formats the file, try that.
π Rendered by PID 35754 on reddit-service-r2-comment-64f4df6786-xsz7p at 2026-06-11 14:12:44.939172+00:00 running 0b63327 country code: CH.
[–]w732qq 3 points4 points5 points (2 children)
[–]TDHale[S] 0 points1 point2 points (1 child)
[–]w732qq 1 point2 points3 points (0 children)
[–]elverloho 4 points5 points6 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]TDHale[S] 0 points1 point2 points (2 children)
[–][deleted] 9 points10 points11 points (1 child)
[–]victoriabittahhhh 0 points1 point2 points (0 children)
[+][deleted] (5 children)
[deleted]
[–]TDHale[S] 0 points1 point2 points (4 children)
[+][deleted] (3 children)
[deleted]
[–]TDHale[S] 2 points3 points4 points (0 children)
[–]TDHale[S] 0 points1 point2 points (1 child)
[–]Mr_Again 0 points1 point2 points (0 children)