i++ in Python?

Rob Hall blokeatiidotnet
Mon Jul 22 11:15:39 EDT 2002


"Alex Martelli" <aleax at aleax.it> wrote in message
news:doSZ8.84684$Jj7.2150581 at news1.tin.it...
> David Eppstein wrote:
>
> > In article <5606b639.0207181429.2c6d2569 at posting.google.com>,
> >  otis_usenet at yahoo.com (OtisUsenet) wrote:
> >
> >> Python newbie question.  How does one do something like this in
> >> Python:
> >>
> >>     # assign the value of j to i and then increment j by 1
> >>     i = j++
> >
> > Python is not designed for maximal terseness, nor for compatibility with
> > C, so you need two statements to do this (well, maybe there's a way to
> > do it in one, but the easiest-to-read and therefore best is with two):
> >
> >       i = j
> >       j += 1
>
> A particularly mysterious, unreadable and useless way to "do it in one":
>
> i = [ j for j in j, j+1 ][0]
>
> Generally, I find that abusing list comprehensions is the easiest way
> to produce obfuscated Python.  The specific "feature" of LCs that makes
> them so suitable for obfuscation is their ability to rebind variables
> in their for clauses.
>
>
> Alex
>

There always has to be some smart arse who can invent a complex way of doing
things!

(Just jealous 'cause I have a hard enough time reading it, lete alone coming
up with it)





More information about the Python-list mailing list