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

Pages: 1-4041-

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-13 3:10

original content, believe it or not

Name: Anonymous 2009-12-13 3:25

>>1
8/10. Will rage again

Name: Anonymous 2009-12-13 3:34

I was thinking some similar things the other day, but alas, Python is still a rather useful language (not useful in the conventional sense, e.g. it's fast or serves a particular purpose, though).

What we need is all of our Anonymous EXPERT LANGUAGE DESIGNERS to come up with something better, and no, LISP doesn't count. LISP is great for circlejerking over academia and it's also very good in math-related fields; but it doesn't serve well for many problem domains.

Name: Anonymous 2009-12-13 3:35

still not sure whether I want to learn Python.  It seems really nice and then I read things like this.

Name: Anonymous 2009-12-13 3:35

still not sure whether I want to learn Python.  It seems really nice and then I read things like this.

Name: Anonymous 2009-12-13 3:41

>>4
dude lisp is okay, dont blame the language. the language is fine maybe there are just not enough libraries, i dont know i only programed in elisp but lisp is cool.

Name: Anonymous 2009-12-13 4:05

>>4
No, Lisp is quite good, as you can write your own DSL' for any problem domain, but some people choke on the fact that Lisp is not about syntax, it's about semantics, and if you start designing a language which tries to mimic Lisp's properties, you'll just end up with Lisp in the end (or maybe some XML-like abomination, if you choose a shitty syntax).

>>7
There's actually quite a lot of useful libraries these days. I have yet to find something for which I couldn't find a library for, and in those rare situation, the FFI and bindings generators are there for you.

However since >>4 doesn't like Lisp, probably because it doesn't have any shiny syntax like normal languages, the next best thing which has a syntax is Haskell, but not everyone is into staticaly typed purely functional languages, so that might not work well for everyone.

>>4
If after having studied and mastered a few good languages, you still can't find a general purpose language which works for you, maybe you should make one for yourself?

Name: Anonymous 2009-12-13 5:19

>>4
Actually, Lisp does count. You've just been fed some bizarre line about how Lisp is different. Any inadequacy Lisp has is unrelated to language design, and is all about the brand of scaremongering you are engaging in here.

Name: Anonymous 2009-12-13 5:31

functional programming is for teenage anti-conformists (read: frozenvoid).
no exceptions.

Name: Anonymous 2009-12-13 5:38

>>4
LISP is great for circlejerking over academia and it's also very good in math-related fields;
This is what EXPERT ENTERPRISE PROGRAMMERS.
but it doesn't serve well for many problem domains.
The only problem domain that LISP doesn't cope with is commercial backing because somehow it's "old". If Google hired someone to develop Closure tomorrow, LISP would be the next Best Thing Since Sliced BreadTM.

Name: Anonymous 2009-12-13 5:38

>>10
Confuses Lisp with functional programming. ... one of many supported programming paradigms
The reason most people use it is because it's the fastest/easiest way for them to get things done.

Name: Anonymous 2009-12-13 7:10

I actually like Lisp but, ITT we sound like Mat Dickie :O

More importantly, we are we still falling for the same troll? He is pretty obvious, since he always calls it LISP (which hasn't been the name for a good while) and not Lisp

If Google hired someone to develop Closure tomorrow, LISP would be the next Best Thing Since Sliced Bread™
Sad, but true. I'm not sure that this is a good thing, do we really want books like `Lisp in 24 Hours', 'Enterprise Lisp Patterns', 'How to integrate your existing infrastructure with best practice Lisp solutions'? Blog posts over how to write the simplest of macros? Another million rounds of 'How I understand continuations?'

Name: Anonymous 2009-12-13 7:24

>>14
I do because I am not an elitist faggot.

Name: Anonymous 2009-12-13 7:47

>>14
I can see why you think it's elitist, but I don't actually care. :P

Name: Anonymous 2009-12-13 7:50

>>15
>I can see why you think it's elitist, but I don't actually care. :P
>but I don't actually care. :P
This is why we can't have nice things.

Name: Anonymous 2009-12-13 7:54

>>14
improper tail call

Name: Anonymous 2009-12-13 8:32

>>16
Perhaps you would understand if I put it another way. I would rather than users of more "niche" languages didn't spend time courting "mainstream" programmers, since it inevitably leads to a large amount of complaining about why "language X isn't like Java/C#/VB" etc, instead of focussing on how it could make them better programmers. I would also prefer if we did genuinely interesting things, rather than appeasing them with dull and lifeless examples.

Name: Anonymous 2009-12-13 9:34

Ah. The circlejerk. I expected ye. I'm surprised nobody's said anything about tail-call optimization like usual.

Name: Anonymous 2009-12-13 14:46

>>5
OP here; this isn't a recommendation against using Python. Despite all of this, I still find it the best general-purpose language for non-performance-critical applications. It's easy to code, easy to maintain, and 'just fast enough'. I just felt like ranting about how their 'design principles' are actually bullshit.

>>8
if you start designing a language which tries to mimic Lisp's properties, you'll just end up with Lisp in the end
the next best thing which has a syntax is Haskell, but not everyone is into staticaly typed purely functional languages, so that might not work well for everyone.
Is there some reason we can't have a statically typed Lisp? Is there some reason we can't use type inference without making the language purely functional? Because my ideal language is something very much like ATS, and if it had syntax closer to Lisp and less like ancient Algol, that would be even better.

Name: Anonymous 2009-12-13 15:03

I don't understand why the OP spends so much time raging at python when he could just help improve PLT Scheme. Python is the reason why "scripting language" is a derisive term.

Name: Anonymous 2009-12-13 15:20

>>20
There is a statically typed Lisp, it's called Qi.
Is there some reason we can't use type inference without making the language purely functional?
There's some languages out there with type inference and which are not fully functional (such as O'Caml). And, some Lisp implementations have type inferrence, but it's usually hard to get much of it as Common Lisp and Scheme are designed to be dynamic languages. For full type inferrence to really work, you'd need to redesign the library and language for it.
My only regret for using a dynamic language is that they require some form of tag bits being used, which practically means fixnums(C-like integers) are not full 32 or 64 bit(whatever your CPU's integer is), but 29-30bit or 61-62bit, which means that you'll have to either accept slightly less efficient code if you want the full integer (bignum in worst case scenario), or have to coax the compiler to actually give you true full 32/64bit through some fancy implementation-specific declarations. I don't really miss full type inferrence myself when coding in Lisp: it's much less restrictive and offers a lot more freedom about how one can do things, and some good implementations (such as SBCL), already have some type inferrence support, which catch some errors: the others you'll have to handle using the debugger or condition system, which isn't nearly as hard as one might think. With proper testing and interactive development practices, most errors are easily weeded out.

Name: Anonymous 2009-12-13 15:37

>>20
Is there some reason we can't have a statically typed Lisp?
Do you mean, "Is there some reason no one has made the language I want?" Because there is no reason why you couldn't write a toy language yourself. I just wrote one this weekend, it "compiles" to an assembly manual written in latex but it essentially is a typed language (implemented as tagged data). If you want to get fancy, then you can "compile" it to C (plausible) or C++ (not likely to be an enjoyable project).

Of course, maybe you are just one of those people who know what's wrong with everything but never attempts to do anything about it because of "the system" or "fat cats" or "jew bankers" or whatever made-up conspiracy manages to keep you from realizing you should just commit suicide.

Name: Anonymous 2009-12-13 16:08

>>22
But 30 bits is more natural, more human. Base 10 FTW, goes up to a thousand millions!

Also, worry not because Guido will auto-promote overflows to bignums for you in his latest masterpiece called Python 3000!

(Oh, and seriously, modern fucking javascript engines with nanojit will work with machine integers using all the 32/64 bits with auto-promotion with a single machine instruction of penalty - what you mention is a implementation issue that hampers shitty interpreters)

Name: Anonymous 2009-12-13 16:20

>>24
The language I was talking about is actually one Common Lisp implementation, and like all CL implementations it automatically promotes fixnums to bignums if it is needed (and bignums to fixnums if the value is within range). My only concern about not having 32/64-bit integers was in the difficulty of writing fast crypto code portably. Unportably, you have use some declarations which would make it generate efficient code.

Name: Anonymous 2009-12-13 17:10

>>20
Is there some reason we can't have a statically typed Lisp?
Just basic good sense. Lisp isn't really about making things difficult to feed our micromanagement addiction.

Is there some reason we can't use type inference without making the language purely functional?
No, none. It's going into Sepplesox, isn't it?

Name: Anonymous 2009-12-13 20:37

>>23
it "compiles" to an assembly manual written in latex
Uh, what?  It compiles to a fucking manual?  Alright, so your programs can be translated into a little user-friendly guide to assembly language!  Written in LaTeX!

Name: Anonymous 2009-12-13 20:59

>>27
Nothing wrong with that. I was hatin' on him for taking that attitude until I got to the punchline. Then I did a 360 and saged away.

Name: Anonymous 2009-12-13 21:30

>>27
Maybe I am missing something obvious, but why would compiling to a manual be worth derision, but compiling to processor opcodes not? Is a literate programming tool not a valid program because it compiles files to latex documents? Also, I think he meant "manual to assemble something," not, "manual about assembly language."

Anyway, sage.

Name: Anonymous 2009-12-13 21:55

>>23
Of course, maybe you are just one of those people who know what's wrong with everything but never attempts to do anything about it because of "the system" or "fat cats" or "jew bankers" or whatever made-up conspiracy manages to keep you from realizing you should just commit suicide.
Interesting; your solution is to make your own toy language. That doesn't seem like a solution at all. I would think that participating in the design discussions of a popular language would do a lot more.

But it's true, there's no reason I can't make my own toy language. Maybe I'll start working on that.

>>26
No, none. It's going into Sepplesox, isn't it?
Sort of, not really. You can use the 'auto' keyword for variable declarations, and the compiler will try to figure it out, but it only works in an extremely limited set of cases. It's not for real type inference so much as to avoid writing huge template declarations.

Name: Anonymous 2009-12-13 22:03

>>30
That doesn't seem like a solution at all.
Maybe you would find out why your language doesn't exist?

Name: Anonymous 2009-12-14 2:09

>>31
Actually as I mentioned earlier, it *almost* does already, in ATS. That language looks pretty fucking sweet.

Name: Anonymous 2009-12-14 2:23

>>22
There is a statically typed Lisp, it's called Qi.
Lies. Qi is purely functional. The designer opines that one of Lisp's challenges that is damaging to its widespread use is "procedural contamination" (and yes, that's all I've learned from thirty seconds of googling and wikipedia.)

Name: Anonymous 2009-12-14 2:42

>>33
Being (optionally) statically typed is not directly related to how 'functional' the language is.

Name: Anonymous 2009-12-14 3:05

I find the idea of Zen of Python revolting.

Name: meh 2009-12-14 3:17

I have to program in php all day so quit your bitching!

Name: Anonymous 2009-12-14 3:30

I had to use some Python script written by someone else today:
- I run the script
- The script popped a dialog box to ask me for some input
- I enter the input correctly
- Script crashes with a division by zero.
- I examine the source code: division by zero was used to signal an error(poor man's exception handling? It executed 1/0 when something went wrong), further checking indicates that it relies on the user's cursor as a second source of input. If the cursor isn't pointing at the exact right spot (there is only one possible valid spot it can point, but it's not something which is supposed to be obvious, at least without reading the source code, and understanding what exactly it wants). If the cursor is pointing in the wrong place, it generates an error by executing 1/0.
- Luckily for me, the script did its job fine, and I was able to use its output which will be processed by a mixed Lisp/C toolset that I'm developing myself.

As someone who does not have much of a clue of Python, are such strange hacks idiomatic Python? Dividing by zero to cause an error? Adding 0.0 to an integer to cast it to a float? Seems awfully hacky to me.

Name: Anonymous 2009-12-14 3:34

>>37
ONLY ONE WAY TO DO IT.

Also, what's with the cursor deal? Programmer wanted to restrict access only to people who knew about the super secret/could read code?

Name: Anonymous 2009-12-14 3:40

>>38
The cursor pointed to where the script should start processing the input, however there's only one possible place where it should start processing (in this case, a fairly obvious place  in the middle of the file).

There was no official documentation, which means the source is the documentation.

Name: Anonymous 2009-12-14 4:25

>>37
In short, no, that's not idiomatic python. That would be throwing appropriate exceptions with an descriptive error message, and casting to floats by calling the float type like float(x).
The worst Python code I see 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.

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.

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