Passing by reference

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Dec 22 17:08:42 EST 2007


MartinRinehart at gmail.com a écrit :
> 
> Bruno Desthuilliers wrote:
> 
>>...  that's definitively not
>>something I'd store in global.
> 
> 
> So where would you put it?

You don't have to "put" functions arguments anywhere - they're already 
local vars.

def tokenize(text):
   do some work
   returns or (yields) a list of tokens or whatever

If you want the tokenizer module to work as a self-contained appliction 
*too*, then :

if __name__ == '__main__':
   text = reads the text from a file or stdin
   for token in tokenize(text):
     do something with token


HTH



More information about the Python-list mailing list