Tuco Benedicto Pacífico Juan María Ramírez (en_ki) wrote,
Tuco Benedicto Pacífico Juan María Ramírez
en_ki

Why Python Is A Bad Language And People Who Use It Are Bad People

I had read about generators but not used them. I did some reading up after the user group on Wednesday night and figured out how they work, and:

If you write a function that happens to have a "yield" statement in it, the function becomes a generator, which behaves in a completely different way from a normal function.

(I don't have a problem with generators. Ruby's Enumerable, Scheme streams, all good. The problem is that you have a function that, without any change in how it's declared, changes from a function-you-call-and-get-something-back to a function-you-call-to-get-an-object-that-you-call-a-method-on-to-execute-the-function-you-wrote because somewhere in its code is a magic statement that changes its nature.)

When you write a language feature like that, you're saying you don't give a damn about readability. For a language that sells itself on readability, that's FAIL FAIL FAIL SUPER FAIL. Go home, blog about what you did, and study Cobol for a year as penance.
$ python
Python 2.5.1 (r251:54863, Jul 23 2008, 11:00:16) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def function():
...     print "hello"
... 
>>> def generator():
...     print "hello"
...     yield "goodbye"
... 
>>> function()
hello
>>> generator()
<generator object="object" at="at" 0x6bbc0="0x6bbc0">
>>> generator().next()
hello
'goodbye'
>>> 
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 12 comments