Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 30 KB, 640x640, e2ff84312bc6cc22e9cc721711300dc3.png [View same] [iqdb] [saucenao] [google] [report]
66200549 No.66200549 [Reply] [Original] [archived.moe] [rbt]

What are your thoughts on PEP 8?

>> No.66200811

bamp

>> No.66200840

It's good and every language should have an equivalent

>> No.66200916
File: 18 KB, 250x238, smug pepe.jpg [View same] [iqdb] [saucenao] [google] [report]
66200916

>>66200549
pep 8
pep8
pepe

>> No.66200945

>>66200916
you stole my post motherfucker

>> No.66200953

>>66200549
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.

>> No.66201323
File: 61 KB, 736x736, me.jpg [View same] [iqdb] [saucenao] [google] [report]
66201323

>>66200549
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.

>> No.66201342

>>66200549
Arch Linux should follow it and link python correctly to python2.

>> No.66201801

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

>> No.66201993

>>66200549
80 characters is silly in the age of 16:9 monitors.

>> No.66202070

>>66200549
>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

>> No.66202086

>>66201323
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

>> No.66202090

>Use spaces
It's immediately wrong.

>> No.66202093

>>66200945
>>>plebbit.net

>> No.66202182

>>66200549
I like it. I have vim set to enforce it (minus the 80 char line limit) when editing python

>> No.66202186
File: 428 KB, 728x810, 1527381551843.png [View same] [iqdb] [saucenao] [google] [report]
66202186

>>66200549
>4 spaces instead of tab

>> No.66202207

>>66202186
Spaces are always better than tab characters.

>> No.66202255

>>66200549
Pylint and flake8 have different opinions in where a closing parens on it's own line should be and it's really annoying.

>> No.66202284

>>66202255
They do? I've always used flake8 for everything. How do they differ?

>> No.66202286
File: 253 KB, 600x632, 1527173488709.png [View same] [iqdb] [saucenao] [google] [report]
66202286

>>66202207
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?

>> No.66202336

>>66202286
>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.

>> No.66202366

>>66202286
Emacs

>> No.66202504

>>66200549
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.

>> No.66202575

Has Python adequate OOP yet?
No?

Bye.

>> No.66202631

>>66202575
Literally this. Its like they spent all their time designing ways to iterate lists and dictionaires rather than create real object oriented features.

>> No.66202665

>>66202207
>>66202336
Smart tabs are superior to either spaces only or tabs only.

>> No.66202804

>>66202575
>>66202631
I saw that Python doesn't have private members for objects, is that right? Sounded so bad, what else is missing?

>> No.66202815

>>66200916
he cute

>> No.66202858

>>66202804
Constants

>> No.66202866
File: 648 KB, 676x3840, 1487702801145.jpg [View same] [iqdb] [saucenao] [google] [report]
66202866

>>66202804
It doesn't have switch/case

>> No.66202995

>>66202866
>It doesn't have switch/case
Good

>> No.66203035

>>66202866
That's irrelevant

>> No.66203190

>>66202995
>>66203035
case analysis is a very common thing
fuck python and that guido fagot who didn't read his SICP

>> No.66203202

>>66203190
>hurr i want if else but with a different name

>> No.66203246

>>66202804
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.

>> No.66203261
File: 1019 KB, 500x373, dangling mouse.gif [View same] [iqdb] [saucenao] [google] [report]
66203261

>>66202866
>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

>> No.66203274

>>66201323
>pic
is that her eternal life she'll forever be in?

>> No.66203304

>>66203202
write a compiler in le pyton you webdev fagot, kys

>> No.66203342

>>66203304
Show me where you need a switch instead of if else to make a compiler

>> No.66203349

>>66200549
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.

>> No.66203350

>>66203190
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)

>> No.66203382

>>66202866
>>66202995
switch/case is good only if you don't fall through by default

>> No.66203396

>>66200549
gofmt is better. No need to argue with idiots.

>> No.66203397

>>66203349
>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.

>> No.66203412
File: 33 KB, 600x617, 1524338072223.jpg [View same] [iqdb] [saucenao] [google] [report]
66203412

>>66201323
the only excuse to use anything significantly beyond 80 is for descriptive but not silly variable name lengths

>> No.66203415

>>66203382
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.

>> No.66203424

>>66203190
Any language with first class functions or something reasonably close can implement a switch statement by doing something like this:

Map<String, Function> 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.

>> No.66203427
File: 288 KB, 478x360, 1522189050237.png [View same] [iqdb] [saucenao] [google] [report]
66203427

>>66202070
go fuck yourself with that attitude.

>> No.66203454

>>66203304
https://github.com/ShivamSarodia/ShivyC

>> No.66203460

>>66203350
>>66203424
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!

>> No.66203479

>>66202804
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?

>> No.66203504

>>66203454
Quick skim makes my eyes bleed. As expected from """beautiful""" """pythonic""" """code""". Go read real compiler source: https://github.com/AbsInt/CompCert

>> No.66203509
File: 101 KB, 1628x859, 543543645.png [View same] [iqdb] [saucenao] [google] [report]
66203509

Fucking disgusting.

This is the only coding style I will ever need.

>> No.66203516

>>66202804
>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.

>> No.66203527
File: 99 KB, 600x450, football-goal-dollie-736-p.jpg [View same] [iqdb] [saucenao] [google] [report]
66203527

>>66203504

>> No.66203539

>>66202804
>>66202575

t.java pajeets

>> No.66203540

>>66203527
I ___never____ said it is not possible in pyton. It's just torturous because guido is an asshole

>> No.66203559

>>66203415
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.

>> No.66203579

>>66203540
Ah yes. The lack of switch statements makes writing a compiler nearly impossible. Fucking retard.

>> No.66203596

PEP 8 is the leading reason why Python is a joke language

>> No.66203602

>>66201323
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.

>> No.66203604

>>66203579
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

>> No.66203605

>>66202866
>He doesn't use superior dicts

>> No.66203739
File: 44 KB, 1024x576, 1527958050360.jpg [View same] [iqdb] [saucenao] [google] [report]
66203739

>>66203304
>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.

>> No.66203774

>>66203739
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.

>> No.66203828

its a good idea

too bad python is one of the faggiest programming languages in existence

>> No.66203891
File: 15 KB, 182x240, .jpg [View same] [iqdb] [saucenao] [google] [report]
66203891

>>66202575
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.

>> No.66203912

>>66203415
>t.brainlet who doesn't grok pattern matching

>> No.66203945
File: 1009 KB, 1469x1900, unworthy_by_marreeps-db6jt0i.png [View same] [iqdb] [saucenao] [google] [report]
66203945

>>66203774
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.

>> No.66203985

>>66203891
This man knows what's up.

>> No.66204021

>>66203828
>too bad python is one of the faggiest programming languages in existence
Develop this, please.

>> No.66204037

>>66203891
>The only modern language to do it properly came out of fucking japan
Which one?

>> No.66204076

>>66204037
he's talking about ruby (a hint to just how clueless he is)

>> No.66204084

>>66204021
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.

>> No.66204090

>>66204037
ruby

>> No.66204109

>>66203891
Why does it matter if a language does OOP properly when 99% of programmers can't do OOP properly?

>> No.66204117

>>66204076
>t. butthurt python fag

>> No.66204122

Theres a million ways to do retard shit the "pythonic" way but no real "pythonic" OO

>> No.66204133

>>66204109
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.

>> No.66204136

>>66204117
Cool ass-umption, fag. Ruby doesn't have a metaobject protocol. And you're a Smalltalker?

>> No.66204168
File: 36 KB, 800x567, python_multitasking.jpg [View same] [iqdb] [saucenao] [google] [report]
66204168

>>66200549
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

>> No.66204180

>>66204136
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.

>> No.66204188

>>66204168
Why dont you just have your editor change back and forth

>> No.66204190

>>66204136
>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

>> No.66204203

>>66204190
Buzzword? Go read The Art of the Metaobject Protocol. Go read Alan Kay on OOP. Fuck off.

>> No.66204266
File: 132 KB, 800x600, tumblr_p83lkroMIg1sd1xkuo2_1280.png [View same] [iqdb] [saucenao] [google] [report]
66204266

>>66204180
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
http://ergoemacs.org/emacs/Matz_Ruby_how_emacs_changed_my_life.html

>> No.66204289
File: 168 KB, 640x360, burmese.jpg [View same] [iqdb] [saucenao] [google] [report]
66204289

>>66204188
That's exactly what I do.

pip install autopep8

>> No.66204321

>>66204266
> 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?

>> No.66204323
File: 70 KB, 1170x742, 1507035047508.jpg [View same] [iqdb] [saucenao] [google] [report]
66204323

>>66204203
>please accept my appeal to authority because I have no idea what I'm talking about

>> No.66204330

>>66204323
You're the retard here calling a MOP a buzzword. Kill yourself.

>> No.66204342

>>66202575
does it need it?

>> No.66204481

>>66202575
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.

>> No.66204545

>>66204084
Python implements the useful parts of OO and throws away the shit. If you havent noticed yet, people are done with OO in general.

>> No.66204623
File: 121 KB, 620x355, nMd3pDG.png [View same] [iqdb] [saucenao] [google] [report]
66204623

>>66204321
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.

>> No.66205216

>>66202631
>ways to iterate lists and dictionaires
Isn't that the reason people use Python?

>> No.66205740

>>66204136
>Cool ass-umption, fag. Ruby doesn't have a metaobject protocol
>>66204330
>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.

>> No.66205770
File: 33 KB, 750x731, ede.jpg [View same] [iqdb] [saucenao] [google] [report]
66205770

>>66200840
Every fucking language has a style specification name one that doesnt

>> No.66207294

>>66205770
I knew projects have style guides but not that there are hard specs.
Also, I don't believe Tcl has an official style spec

>> No.66208228

Tab, shift tab, auto format, etc. who cares. That's how I feel about style guides.

>> No.66209146

>>66204481
>What test does Python fail
take the length of a collection/enumerable

>> No.66209167

>>66204545
>implements the useful parts of OO and throws away the shit
>len() exists
wew

>> No.66209395

>>66209146
Is this bait?

>> No.66209429

>>66209395
len()

>> No.66209847

ITT: people who don't realize that PEP8 explicitly tells you to ignore it in certain cases

>> No.66209898

>>66209429
What are you trying to say? If you think the syntax of a method call matters, you don't know anything about OOP.

len(foo)
foo.len()
foo.len
foo len
foo.send('len')
(len foo)

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action