Simple questions on use of objects (probably faq)
Matt Hammond
matt.hammond at rd.bbc.co.uk
Wed Mar 8 06:00:09 EST 2006
Hi,
> 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:
http://docs.python.org/tut/node7.html#SECTION007140000000000000000
> 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]
yz.reverse()
--
| Matt Hammond
| R&D Engineer, BBC Research & Development, Tadworth, Surrey, UK.
| http://kamaelia.sf.net/
| http://www.bbc.co.uk/rd/
More information about the Python-list
mailing list