New Python language abuse: ++x with bytecodehacks
Christian Tismer
tismer at appliedbiometrics.com
Thu Jul 8 11:35:05 EDT 1999
Jeff Epler wrote:
>
> I know just everyone has always neede to write
> def f(y):
> x=0
> while ++x < y:
> print x,
> print
>
> in Python. Well, you always could write it, but it printed the rather
> boring
> 0 0 0 0 0 0 0 ...........................
> which is probably not what you wanted. Well, presenting some code using
> Michael Hudson's bytecodehacks. You can still write the above code, but
> now it will print
> 1 2 3 4 5 6 7 8 9
> instead.
Thanks for the big laugh!
This should go into Python's humor pages. :)
but-not-into-prodction-code-please - chris
p.s.: I wondered why Guido didn't optimize a double
unary positive. But he can't, since he has no idea what
this operator does.
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net
10553 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list