Using Python to Comprehend Lists.

Tired of writing complex and lengthy filters just to prepare some data? Try out one of these for size.

# get a bunch of info about some object
e = dir(e)
# now just show me the public attrs
[x for x in dir(e) if not x.startswith('__')]

List comprehensions. They rule.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>