Creating Python class wrapper for a command line tool

Peter Otten __peter__ at web.de
Wed May 26 15:44:22 EDT 2004


Edvard Majakari wrote:

> Rico Huijbers <E.A.M.Huijbers at REMOVEstudent.tue.nl> writes:
> 
>> I am by no means a professional Pythonist... but it doesn't seem too bad
>> to me to check for each kwarg whether it's type is boolean and if so,
>> just add it to the command line as a flag instead of as a value
>> parameter. And data arguments can be passed in the *args tuple.
> 
> Wow - I had to test it and didn't work. Then I remembered it would
> probably work with Python2.3, and it did. But the thingamajick must work
> with Python2.2.
 
You could test object identity instead.

>>> def isbool(b):
...     return b is True or b is False
...
>>> isbool(1), isbool(True)
(0, 1)
>>> isbool(0), isbool(False)
(0, 1)

Peter




More information about the Python-list mailing list