My first Python program

Seebs usenet-nospam at seebs.net
Wed Oct 13 12:59:27 EDT 2010


On 2010-10-12, Hallvard B Furuseth <h.b.furuseth at usit.uio.no> wrote:
>> list = map(lambda x: x.call(), self.args)
>> return ', '.join(list)
>
>   return ', '.join([x.call() for x in self.args])

I think I wrote that before I found out about list comprehensions.  How
new are list comprehensions?

I do like that, it's clearer.

>> self.type, self.name = None, None

> Actually you can write self.type = self.name = None,
> though assignment statements are more limited than in C.
> (And I think they're assigned left-to-right.)

Okay.

>>  match = re.match('(.*)\(\*([a-zA-Z0-9_]*)\)\((.*)\)', text)

> Make a habit of using r'' for strings with lots of backslashes,
> like regexps.

Hmm.  There's an interesting question -- does this work as-is?  I'm
assuming it must or it would have blown up on me pretty badly, so
presumably those backslashes are getting passed through untouched
already.  But if that's just coincidence (they happen not to be valid
\-sequences), I should definitely fix that.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam at seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.



More information about the Python-list mailing list