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
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&
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
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
> 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
>
> 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
> 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
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