Python function with **kwargs Question

2006-01-05 Thread Khoa Nguyen
I would like to pass some keyword with special character to a foo(**kwargs) function, but it doesn't workdef foo(**kwargs):  print kwargsThis doesn't work:foo(a-special-keyword=5)How do I tell Python to treat '-' as a normal character but not part of an _expression_? Thanks,Khoa -- http://mail.py

Re: Python function with **kwargs Question

2006-01-05 Thread Khoa Nguyen
Thanks for your responses. I guess the foo(**{'x-y':3}) is ugly but will do the trick Cheers,Khoa On 1/5/06, Mike C. Fletcher < [EMAIL PROTECTED]> wrote:Christian Tismer wrote:>Khoa Nguyen wrote: >>>>I would like to pass some keyword with special character to a&

Process files in order

2006-07-27 Thread Khoa Nguyen
Hi, I have a requirement to process all files in a directory in chronological order. The os.listdir() function, however, lists the files in random order. Is there a similar function in Python that allows me to specify the listing order (like ls -t for example)? Thanks, Khoa -- http://mail.python

Pyparsing: Grammar Suggestion

2006-05-17 Thread Khoa Nguyen
I am trying to come up with a grammar that describes the following: record = f1,f2,...,fn END_RECORD All the f(i) has to be in that order. Any f(i) can be absent (e.g. f1,,f3,f4,,f6 END_RECORD) Number of f(i)'s can vary. For example, the followings are allowed: f1,f2 END_RECORD f1,f2,,f4,,f6 END_R

Re: Pyparsing: Grammar Suggestion

2006-05-17 Thread Khoa Nguyen
> record = f1,f2,...,fn END_RECORD > All the f(i) has to be in that order. > Any f(i) can be absent (e.g. f1,,f3,f4,,f6 END_RECORD) > Number of f(i)'s can vary. For example, the followings are allowed: > f1,f2 END_RECORD > f1,f2,,f4,,f6 END_RECORD > > Any suggestions? > > > > pyparsing in

Re: Pyparsing: Grammar Suggestion. 2nd thought

2006-05-17 Thread Khoa Nguyen
> > for tokens,start,end in commaSeparatedList.scanString(data): > print tokens > > > This returns: > > ['f1', 'f2', 'f3', 'f4', 'f5', 'f6'] > ['f1', 'f2'] > ['f1', 'f2', '', 'f4', '', 'f6'] > Thanks for your reply. This looks promising, but I have a few more questions: 1. If f(i) is non-termi

Re: Python-list Digest, Vol 32, Issue 300

2006-05-17 Thread Khoa Nguyen
> Optional(f1SpecificFormat) + "," + Optional(f2SpecificFormat) + "," + ... > and so on. Thanks for your input again. This is exactly what I am trying. The only thing is it can get ugly if the number of fields are many -- I have about 61 fields right now. Just wondering if there is a "cleaner" a

Pyparsing: Specify grammar at run time

2006-05-17 Thread Khoa Nguyen
I run into another issue with my grammar: My input record contains a common part and an extended part. Based on the value of the common part, the extended part will be different. So, I am thinking of parsing the common part first and check the common's value and then parse again for the rest of th