donn at drizzle.com
Tue Dec 28 05:07:19 CET 2004
Quoth "It's me" <itsme at yahoo.com>:
| A newbie question.
| How can I tell from within a function whether a particular argument is a
| sigular type, or a complex type?
| For instance, in:
| def abc(arg1)
| How do I know if arg1 is a single type (like a number), or a list?
| In C++, you would do it with function overloading. If arg1 is always simple
| type, I wouldn't care what it is. But what if I *do* need to know whether
| arg1 is a list or not?
| I hate to have to have 2 functions: 1 for simple types, and one for list
| types and then do something like:
| Any help would be greatly appreciated.
How about abc([1.0])? That's easy, and it's a lot cleaner than
mucking up your API with functions whose parameters have multiple
possible interpretations. C++ doesn't always point the way to
great programming models.
Donn Cave, donn at drizzle.com
More information about the Python-list