Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The Zen of Python is a LIE

Name: Anonymous 2009-12-13 3:09

Flat is better than nested.

Is that why implementing function decorators involves returning nested functions? Or context managers require blocks, so opening two files in a class method starts me off 4 levels deep?

Python code is incredibly nested. Modules in any moderately complex Python framework go quite deep, because Python programmers apparently refused to put more than a dozen functions in a module. Witness os, os.path, shutil, dircache, io, etc. for the most basic of file manipulation.

Namespaces are one honking great idea -- let's do more of those!

...which directly contradicts flat vs. nested. That explains all the fucking modules.

Beautiful is better than ugly. / Readability counts.

What's with all the fucking underscores? Why are built-in methods like __init__() done this way instead of just claiming init()? Plenty of languages do this; Objective-C comes to mind. Why is a *leading underscore* the way the interpreter enforces encapsulation?

Why is the syntax for list and dict comprehensions so ass backwards? How is it even possible that you can nest them, so that [(i,f) for i in nums for f in fruit] is valid Python? And there aren't even any filters there!

Although practicality beats purity.

...according the language designers' twisted definitions of those words. People aren't asking for proper lambdas for 'purity' reasons; they are just fucking practical! The current lambdas are so crippled as to be nearly unusable, but they want to keep the language 'pure' from pervasive anonymous functions.

Another great example is the interpreter itself. In order to keep the language 'pure', basically everything is a mutable dict, including the contents of modules; this means in order to call any named function, you have to lock its module to make sure no other thread is modifying it. Hence the GIL, and the general impossibility of making Python run fast.

There should be one-- and preferably only one --obvious way to do it.

You mean like how you have to call super(self.__class__, self).__init__(*args, **kwargs) even if you inherit directly from object, in case your class is used in a multiple inheritance tree and needs to construct the next class in the mro? Yeah that's pretty fucking obvious. Don't forget to take variable keyword arguments and pop the ones you want.

How about the fact that you have to create a blank file called __init__.py in a folder to make it a module? Is that fucking obvious? Who the fuck thought that was a good idea?

Although that way may not be obvious at first unless you're Dutch.

A continuation of the above; the whole syntax of the language violates the 'one way' rule. Why is there a different syntax for certain specific class methods? For instance you implement X.__len__() so that your class can be used as len(x). Why the fuck don't you just implement X.len() to do x.len(), like all the other class methods?

Why is it x.sort() and sorted(x)? Why couldn't it just be x.sort() and x.sorted(), or vice versa? The behaviour can still be the same folks, where x.sort() returns None and x.sorted() returns a copy; this is purely syntactic. Even C++ is not this confused about standard method call syntax, and it's the only other language I can think of that allows both.

Explicit is better than implicit.

I've generally found this to be the biggest lie of all. A common idiom for libraries and tools in Python is to masquerade as a built-in class. You often get a 'file-like' object, or a 'dict-like' object from a callback. And it behaves *almost* like the real thing, but there's always a gotcha. They are fucking full of 'em. Sometimes they don't implement context managers. Sometimes you have to 'flush' them. But one thing is for sure, you will always fucking stumble upon a gotcha; some magic behavior that there was no possible way for you to have known about.

Name: Anonymous 2009-12-14 6:26

seems to come from people who have finally realized that Perl is an awful hack, and then try to move on to other languages, but somehow manage to keep writing Perl.

Cool making shit up, bro.

I especially like how you seem to know those people previously wrote in Perl and that they "finally realized" that Perl is an awful hack. And when you say "people," you only mean one person. And when you mean one person, you actually meant what you think that is in order to validate you opinion that is not based on facts, but rather, biased opinions.

Name: Anonymous 2009-12-14 8:15

>>41
Fine, they probably never realized that Perl is an awful hack, that was my words. They still use Perl idioms in Python and it's fucking ugly. And your last sentence is completely unparsable. Just like Perl.

Name: Anonymous 2009-12-14 9:51

>>40
As opposed to those that write C in every language? It seems the shittiness of a language is easily discovered by watching adepts struggle at foreign idioms.

Name: Anonymous 2009-12-14 10:53

>>43
*cough*
Lisp

Name: Anonymous 2009-12-14 14:33

>>44
A quote comes to mind, which I am too lazy to google for the exact phrasing, but it is something like, "I contend we are both atheists. When you understand why you have denied every other god, you will understand why I deny yours."

Upon hearing this, your anus is haxed.

Name: sage 2009-12-14 14:40

>>43
Blaming the language for noob/blub coders
1/10 IHBT

Name: Anonymous 2009-12-14 14:57

>>42
I for one embrace the awfulness of Perl's hackery. If you do not do the same with Python, why do you use it?

>>46
I do that with C++. With a straight face too.

Name: Anonymous 2009-12-14 15:09

Name: Anonymous 2009-12-14 15:12

>>1
Flat is better
I agree.

Name: Anonymous 2009-12-14 15:16

>>49
I know I write Python because of the tsurupettan

Name: Anonymous 2009-12-15 3:32

>>50
HAX MY FLAT CHEST

Name: Anonymous 2010-12-17 1:18

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-02-03 4:06

Name: Anonymous 2011-02-17 20:21

that's cool and all, but check my doubles over there

Name: 威哥王 2011-05-04 5:49

Name: 女性用媚薬 2011-05-04 5:49

Name: Anonymous 2011-09-19 14:41

Dear diary,
Today OP was making sense.

Flat is better than nested.

Nestable is better than flat. Python has a defect known as statements.

Beautiful is better than ugly.

The __lol__ underscore stuff is about not using names you might want to use for your own methods. I think it's passable.

Although practicality beats purity.

People aren't asking for proper lambdas for 'purity' reasons; they are just fucking practical!

So true.

There should be one-- and preferably only one --obvious way to do it.

OP is pointing out two of my minor gripes with Python. super and multiple inheritance altogether: Python should support single inheritance and mixins. Multiple inheritance, MRO, having fucked it up at first, etc. is all unnecessary complexity.

I hate the overcomplication and mess in site, distutils, setup.py, eggs, the 123987 third-party distutils and all that.

Although that way may not be obvious at first unless you're Dutch.

For instance you implement X.__len__() so that your class can be used as len(x). Why the fuck don't you just implement X.len() to do x.len(), like all the other class methods?

len is a generic function that queries for your __len__ method. Rather than making a ".len()" protocol standard, the bearded FP hater went for a less intrusive .__len__() protocol and a generic function to call it because __len__ is fucking uncomfortable, and I believe not all objects really implemented __len__ in the old times.

Explicit is better than implicit.

Python is rather explicit, compare others.

>>4
1. Make Scheme-like dynamic compiler for CPython bytecode with special syntax for property access and tail call elimination
2. Add simple wrappers and standard library for most common stuff; probably can't get cudders well optimized though so don't count on programs being that Scheme-like
3. Automatically solve: inflexible syntax, stupid lambda, gripes with standard library, demands for tail call elimination, macros, decent DSLs. Also get Scheme with great object system.
4. Kick copious amounts of ass.

>>11
is full of "right" too.

>>37
No, whoever does 1/0 to raise an error is a fucking faggot and probably writes Python like he writes K&R.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List