Favorite non-python language trick?
kosh at aesaeion.com
Sat Jun 25 09:00:50 CEST 2005
On Friday 24 June 2005 02:53 pm, D H wrote:
> Again, you are splitting hairs. His point still stands that it is not
> possible to do method overloading in python (unless you use decorator
> hacks). It may be possible to add this feature when type declarations
> and type checking are added to a future version of python.
Decorators are actually a syntax hack remember. Everything you can do in a
decorator you could do with python before since they work via nested scopes.
It is easy to write wrapper methods and I use them for many purposes but not
for type checking.
Wrapper methods are very useful to take out common checking code. The checking
of conditions does not really belong in the caller (the caller could forget),
it does not really belong in the called function since that is not that
functions purpose but putting it in a wrapper and having it wrap the called
function sure gives a nice seperation and makes life simpler.
More information about the Python-list