What are your thoughts on PEP 8?
What are your thoughts on PEP 8?
Other urls found in this thread:
github.com
github.com
ergoemacs.org
twitter.com
bamp
It's good and every language should have an equivalent
pep 8
pep8
pepe
you stole my post motherfucker
A little overbearing. Better to just take most of it and ignore certain parts.
It also focuses way too much on syntactical style and not enough on structural.
80 character limit is almost always wrong.
In my work and personal projects I keep it to 100 chars.
However recently I've been reading some source code where they go over 200 characters per line, and that shit is pretty aesthetic imo.
Arch Linux should follow it and link python correctly to python2.
It's mostly good, but the 80 char limit is overbearing.
Being dynamically typed, I like to give my variables in python descriptive names, sometimes requiring over 80 characters for a line to avoid disgusting line breaks
80 characters is silly in the age of 16:9 monitors.
>a language thats supposed to be clear and obvious needing a style guide to explain idioms
that says a lot about Python compared to other languages that have absolutely no need for a style guide
It's more common for 120 to be the standard now, since that gives you roughly two codebases side-by-side on a 1920x1080 monitor
>Use spaces
It's immediately wrong.
>>>plebbit.net
I like it. I have vim set to enforce it (minus the 80 char line limit) when editing python
>4 spaces instead of tab
Spaces are always better than tab characters.
Pylint and flake8 have different opinions in where a closing parens on it's own line should be and it's really annoying.
They do? I've always used flake8 for everything. How do they differ?
i'm inexperienced and to me it seems like more hassle to mess with spaces than with tabs if i need to edit source. why are spaces better?
>it seems like more hassle to mess with spaces than with tabs
How? It's not like you stop using the tab key, it just inserts a number of spaces instead of a tab character. Same for backspace: you can have it delete a number of spaces at a time if that's your thing.
Personally I have tab insert 2 spaces (unless the project or language mandates 4), and have backspace only delete 1 at a time.
Spaces are better in general because your alignment doesn't get fucked whenever someone opens the file in an editor with a different tabwidth set.
Emacs
Tabs are superior to spaces. I agree with everything else though and try to follow it as best I can. Especially the 80 char limit, I follow that rule religiously and get disgusted every time I see a line longer than that.
Has Python adequate OOP yet?
No?
Bye.
Literally this. Its like they spent all their time designing ways to iterate lists and dictionaires rather than create real object oriented features.
Smart tabs are superior to either spaces only or tabs only.
I saw that Python doesn't have private members for objects, is that right? Sounded so bad, what else is missing?
he cute
Constants
It doesn't have switch/case
>It doesn't have switch/case
Good
That's irrelevant
case analysis is a very common thing
fuck python and that guido fagot who didn't read his SICP
>hurr i want if else but with a different name
No, but the standard is to prefix things with _ if they're supposed to be treated as private.
If having actual private members is a hard requirement for OOP, then by that logic any language with reflection is no longer OOP.
>mfw two thuggy nogs will never accost me in public, pin me, apply makeup, put me in a skirt, and turn me into a pretty girl
>pic
is that her eternal life she'll forever be in?
write a compiler in le pyton you webdev fagot, kys
Show me where you need a switch instead of if else to make a compiler
Python and PEP 8 convinced me that languages should be opinionated about styling. If a language has defined the preferred styling then all the editors can just ship the preferred styling configuration and everybody can just go with that without silly arguments about whitespaces or such and diverge for a reason if the project needs it. I like the approach golang has taken.
As for PEP 8 itself I think that 80 chars isn't enough. It's cool to have that punch card reference but it gets in the way too often and would force you to make silly looking line breaks to appease the linter. Personally I'm going with 120 chads.
Match (ala Scala, F#, Rut, etc) is the appropriate syntactical tool for that. Switch/case is a tiny amount of sugar over gotos and labels, and implicit fallthrough is a cancerous bug-landmine. Lacking match statements, simple if/elseif chains are the next best thing.
Switch statements should only be used if fallthrough is a logical necessity for the problem (hint: it pretty much never is)
switch/case is good only if you don't fall through by default
gofmt is better. No need to argue with idiots.
>editors can just ship the preferred styling configuration and everybody can just go with that without silly arguments about whitespaces or such
If a language tries to ship a style choice that I don't like, I'm going to override it. Thankfully so far they've all lined up with my preferred style choices, but if PEP8 required tabs instead of spaces for some fucked up reason, I'd still use spaces.
the only excuse to use anything significantly beyond 80 is for descriptive but not silly variable name lengths
switch/case without implicit fallthrough is exactly the same as if/elseif and is just a less powerful match.
There is no good use for switch statements.
Any language with first class functions or something reasonably close can implement a switch statement by doing something like this:
Map switch = {
'foo': do_action_a,
'bar': do_action_b
...
}
switch['foo'].run()
Switches usually get compiled into something like that anyway, using either a hashtable as above, or an array if you're switching over numerical values or equivalent.
go fuck yourself with that attitude.
I didn't say it literally has to be C style switch statement, I said case analysis which in its most general form indeed is ML style pattern matching but what would guido know about that!
Python just shoves the policing of private methods and attributes to the software developers. The convention dictates that you should name private methods and attributes starting with an underscore so if you as a developer call something starting with _ from outside the object you're doing a hack and the upstream doesn't guarantee any kind of support for what you're doing.
Still, it is allowed. You, the developer, know what you doing... right?
Quick skim makes my eyes bleed. As expected from """beautiful""" """pythonic""" """code""". Go read real compiler source: github.com
Fucking disgusting.
This is the only coding style I will ever need.
>implying any language has private members when faced with a desperate programmer wielding assembly.
Python just doesn't get in your way when there's a fire.
t.java pajeets
I ___never____ said it is not possible in pyton. It's just torturous because guido is an asshole
It looks nicer and readable in when there are a lot of cases.
You do have 'for' and 'while' for loops even though you could implement either with the other. Still both are clearly more readable depending on the case.
Ah yes. The lack of switch statements makes writing a compiler nearly impossible. Fucking retard.
PEP 8 is the leading reason why Python is a joke language
Welcome in 2018, where you can set your editor to soft wrap words. Character limit is *always* wrong, it may make code hard to read when you need to scan text to look where if statement ends and where block begins.
read that again
>I ___never____ said it is not possible in pyton.
which means I never said it is not possible
i.e. I have not said that it is impossible
>He doesn't use superior dicts
>waah waah every language must be a compiler-dev language
people like you are the reason C and it's ilk get memed to hell.
Shove your Arrays[][][][][][][][], {{{{{{braces}}}}}} and %*symbols#;& up your ass. I blame you people for infecting Fortran into the perverse chimera that it is today just as much as I blame a lot of Python's ugliness on you. F77 was the superior language for numerics, and it still is.
gay shit. write a compiler in ocaml. a much nicer experience than writing one in python because the language actually has well thought out means of abstraction.
its a good idea
too bad python is one of the faggiest programming languages in existence
Very few languages actually do OOP properly.
Java cant. Python cant. ObjC cant. C++ cant.
Why was the best OOP language written 46 years ago? The only modern language to do it properly came out of fucking japan.
>t.brainlet who doesn't grok pattern matching
I would of course not use Python for such a matter. Neither would I use it for numerics.
All I am saying is get out of your glass house before you start throwing rocks;
Go write a working, readable, convergent lanczos-algorithm for N-dim. direct product spaces, then we can talk about abstraction.
This man knows what's up.
>too bad python is one of the faggiest programming languages in existence
Develop this, please.
>The only modern language to do it properly came out of fucking japan
Which one?
he's talking about ruby (a hint to just how clueless he is)
Its inconsistent as fuck. Half the time it tries to be OO, then the other half of the time, its not. Its not particularly good at anything, and merely gets along by the fact that it has a metric shitload of libs for it.
ruby
Why does it matter if a language does OOP properly when 99% of programmers can't do OOP properly?
>t. butthurt python fag
Theres a million ways to do retard shit the "pythonic" way but no real "pythonic" OO
Its indicative of the rest of the language being inconsistent. If the language devs themselves cant adhere to a paradigm, then how the fuck do you expect anyone to use the language to adhere to it.
This is why things like Erlang, Elixir, and Haskell (and other functional languages) are so fucking great. They actually display some consistency.
Cool ass-umption, fag. Ruby doesn't have a metaobject protocol. And you're a Smalltalker?
I knew I'm getting into a strict schoolteacher kinda slap my hands with a meterstick kinda situation with Python. But I still insist on two-space indents, not four-space.
two-space indents
At one point I was. I wrote ruby for the last 10 or so years, but I've largely extracted myself from doing it professionally. Ruby is wonderful to write, and if you have a competent team, great to work with. But you always get some fucking pajeet in there who writes ruby like he writes python or java, and it becomes a gigantic shit-fest.
I've moved to Elixir and LFE, and occasionally pure Erlang, because functional programming seems immune to poo-in-loos.
Why dont you just have your editor change back and forth
>Ruby doesn't have a metaobject protocol
>using vague-ass buzzwords as terminology
care to back that up with an actual example of what that is? because its pretty obvious youre talking out your ass
Buzzword? Go read The Art of the Metaobject Protocol. Go read Alan Kay on OOP. Fuck off.
not the same guy, but having looked into ruby a while ago I must say it has some really sweet things to offer. You really see the inspiration it took from CLisp and Elisp.
For those unaware
ergoemacs.org
That's exactly what I do.
pip install autopep8
> 75 lines that are "slides" about how Emacs changed his life.
> footnote about how Ruby is like emacs
Did you read this between googling it and sending it to me?
>please accept my appeal to authority because I have no idea what I'm talking about
You're the retard here calling a MOP a buzzword. Kill yourself.
does it need it?
How can I tell if a language has "adequate" OOP features? What test does Python fail?
> need private
I never saw the point of the "private" / "protected" / "public" labels on object properties. Only justification I've had so far is "it keeps strangers you will never meet from using your code in stupid ways," but you can't stop people from doing stupid things. Just don't document class properties that you want programmers not to use, and if they do something you didn't tell them to do, that's on their heads. If a carpenter comes to me saying this screwdriver is terrible at driving nails, I'm not going to put protection around the handle to prevent stupid people from using it like a hammer, I should just say "grab it by the handle, use it to turn screws," and that's all.
Python implements the useful parts of OO and throws away the shit. If you havent noticed yet, people are done with OO in general.
I read that like two weeks ago, and come on, with that context you need no further confirmation to see the parallels. Once you know that guy had a lot of history with Emacs Ruby's (e/c)lisp-isms are blatant even to someone having looked at ruby for no more than 15 minutes.
>ways to iterate lists and dictionaires
Isn't that the reason people use Python?
>Cool ass-umption, fag. Ruby doesn't have a metaobject protocol
>You're the retard here calling a MOP a buzzword. Kill yourself
I really want to apologize, I am actually very humbled by your knowledge level, I have no right to even speak with you. The fact that you know what MOP is means automatically puts you on a much higher intelligence level than me. You probably didnt even need to be taught that at university, I'll bet you read that on wikipedia and immediately understood what it means by using your great depth of understanding of technical topics. Thank you for telling me to fuck off and kill myself because Im not worthy to even speak to someone as mentally gifted as you are. The fact that you want leave this conversation is for my benefit, I would only embarrass myself even attempting to speak with someone at your level of intelligence.
Every fucking language has a style specification name one that doesnt
I knew projects have style guides but not that there are hard specs.
Also, I don't believe Tcl has an official style spec
Tab, shift tab, auto format, etc. who cares. That's how I feel about style guides.
>What test does Python fail
take the length of a collection/enumerable