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
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
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
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(
Ok, i see...
Thank you all :)
--
http://mail.python.org/mailman/listinfo/python-list
"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
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
> 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
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
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
10 matches
Mail list logo