Re: Overloaded Functions

2008-07-29 Thread Daniel da Silva
With a little hacking, you might be able to do something like this: @overload("f", (int, int, str)) def f1(x, y, z): pass @overload("f", (str, str)) def f2(x, y): pass The way I would typically do method overloading would be as follows (this has been tested): class Person: def __in

Re: Overloaded Functions

2008-07-29 Thread Tim Henderson
Yes i am aware of that but I want the code to be self documenting, so the intent is clear. I actually have an implementation using that style which you suggest. I would like cleaner style, like the one i suggested in my first post. Cheers Tim Henderson -- http://mail.python.org/mailman/listinfo/py

Re: Overloaded Functions

2008-07-29 Thread Gary Herron
Tim Henderson wrote: Hi, So this may have been asked before but i haven't found the answer by googling so far. My situation is this: I want this structure for my code: @overloaded def sign_auth(secret, salt, auth_normalized): return __sign_auth(saltedhash_bin(secret, salt), auth_normalized

Overloaded Functions

2008-07-29 Thread Tim Henderson
Hi, So this may have been asked before but i haven't found the answer by googling so far. My situation is this: I want this structure for my code: @overloaded def sign_auth(secret, salt, auth_normalized): return __sign_auth(saltedhash_bin(secret, salt), auth_normalized) @sign_auth.register(

Re: Replacing overloaded functions with closures.

2007-07-31 Thread king kikapu
Ok, i see... Thank you all :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Terry Reedy
"king kikapu" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | > def func(obj): | > if isinstance(obj, bool): | > return not obj | > elif isinstance(obj, int): | > return obj * 2 | > elif isinstance(obj, basestring): | > return obj + obj | > else: | > raise No

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Bruno Desthuilliers
king kikapu a écrit : > Hi, > > i am trying, to no avail yet, to take a C#'s overloaded functions > skeleton and rewrite it in Python by using closures. > I read somewhere on the net (http://dirtsimple.org/2004/12/python-is- > not-java.html) that in Python we can redu

Re: Replacing overloaded functions with closures.

2007-07-30 Thread king kikapu
> The closures discussed in the article are not a solution for > function overloading. They are a solution for function > composition. Hmmm > > Python generally has no need for function name overloading--if > you really want it you must do it manually using runtime type > checking. > > def fu

Re: Replacing overloaded functions with closures.

2007-07-30 Thread Neil Cerutti
On 2007-07-30, king kikapu <[EMAIL PROTECTED]> wrote: > i am trying, to no avail yet, to take a C#'s overloaded > functions skeleton and rewrite it in Python by using closures. > I read somewhere on the net > (http://dirtsimple.org/2004/12/python-is- not-java.html) that &g

Replacing overloaded functions with closures.

2007-07-30 Thread king kikapu
Hi, i am trying, to no avail yet, to take a C#'s overloaded functions skeleton and rewrite it in Python by using closures. I read somewhere on the net (http://dirtsimple.org/2004/12/python-is- not-java.html) that in Python we can reduce code duplication for overloaded functions by using clo