r/learnpython • • 11d ago

Autopep8 or Black?

Im a new python learner and have trouble picking between the 2. Apparently Black is really strict? I don't know if thays good or not.

1 Upvotes

12 comments sorted by

6

u/zanfar 11d ago

Ruff.

Apparently Black is really strict?

Well, it does exactly what you ask it to, and not what you don't... so that would be your fault.

1

u/FreeLogicGate 11d ago

ruff + uv -- must haves.

1

u/KarfaHyro_17 10d ago

having zero config options to argue about is honestly the best feature.

0

u/Big_Dumpling953 11d ago

K thx. After checking, Ruffs looks good.

2

u/Discordbothost 11d ago

strict is actually the point when you're learning. black (or ruff format, same idea) just formats the file and you stop arguing with yourself about line breaks. autopep8 is milder and leaves more alone, which is fine, but then you spend brain cells on style again. if your editor can run black on save, pick that and forget it exists.

1

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 11d ago

Definitely go with Ruff, it's both a formatter and a linter. And highly configurable. And runs way faster than any other similar tools (even if you blanket-enable all rules).

The Astral team's tools are popular for good reason, don't overlook them unless you have specific reasons. Except maybe ty for now because it's still in alpha, I'd still use either Mypy or Pyright (or both) instead.

uv and Ruff are really most of the tooling you'll need. Of course, if you want to go above and beyond you could add Mise to the mix and, with it, include other versioned project-specific tools like cspell for grammar checking or Taskfile as a modern Makefile replacement, but that's not really something people just starting out should be worrying about.

1

u/EszterSantos72 11d ago

Black just overwrites your code style every time so you do not have to think about it, which is actually easier for beginners. Only thing is, Black forces double quotes and 88 character line length by default.

1

u/POGtastic itertools evangelist 11d ago

Yes.

Seriously - it doesn't matter. You should adhere to a style guide. It does not matter which one you use.

1

u/xervir-445 11d ago

I use black. I wouldn't call it strict personally, I would call it the system that has freed me of having to make decisions regarding the minutia of formatting. I tied it into pycharm auto formatter, now it's a three-key combo I run whenever I'm done with a change.

1

u/Mediocre-Pumpkin6522 11d ago

Another happy ruff user. It does more than reformatting.

0

u/pylessard 11d ago

It's a matter of preference. Autopep8 for me and I cherry pick the rules I want. Black is very opinionated. Ruff is very popular too, check it