Simple questions on use of objects (probably faq)

Matt Hammond matt.hammond at
Wed Mar 8 06:00:09 EST 2006


> 3: Why canøt I say and get the maximum of instance attributes and a
> list of them?
> y_max=max(y[].x) and
> ys=[y[].x]

y_max = max([e.x for e in y])

See "List comprehensions" in python docs:

> 4: Can I avoid the dummy counter i in the for loop and do something
> like:
> yz=[y[:-1].x-y[1:].x]

yz = [e.x for e in y]


| Matt Hammond
| R&D Engineer, BBC Research & Development, Tadworth, Surrey, UK.

More information about the Python-list mailing list