Some basic questions

Alex Martelli aleax at aleax.it
Wed Mar 26 18:36:32 EST 2003


Brian Christopher Robinson wrote:

> Irmen de Jong <irmen at -NOSPAM-REMOVE-THIS-xs4all.nl> wrote in
> news:3e82156d$0$49105$e4fe514c at news.xs4all.nl:
> 
>> Brian Christopher Robinson wrote:
>> (Note that recompiling the regex on each function invocation isn't
>> very efficient, but that's another story).
> 
> Right now I'm not doing a class, just free standing functions.  Is there
> anything akin to C's static keyword for Python functions that will
> initialize a variable once and keep it that way for the rest of the
> execution of the program?

The "default-argument" mechanism works like that:

def isalpha(c, letters=re.compile('[a-zA-Z]')):
    return letters.match(c) is not None


Alex





More information about the Python-list mailing list