Re: Signature-based Function Overloading in Python

2010-02-27 Thread alex23
Michael Rudolf spamfres...@ch3ka.de wrote: In Java, Method Overloading is my best friend Guido wrote a nice article[1] on multimethods using decorators, which Ian Bicking followed up on[2] with a non-global approach. 1: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 2:

Re: Signature-based Function Overloading in Python

2010-02-27 Thread Michael Rudolf
Am 27.02.2010 10:00, schrieb alex23: Michael Rudolfspamfres...@ch3ka.de wrote: In Java, Method Overloading is my best friend Guido wrote a nice article[1] on multimethods using decorators, which Ian Bicking followed up on[2] with a non-global approach. 1:

Re: Signature-based Function Overloading in Python

2010-02-25 Thread Jean-Michel Pichavant
Michael Rudolf wrote: First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its advantages: 1 docstring, 1 way do

Re: Signature-based Function Overloading in Python

2010-02-25 Thread Jean-Michel Pichavant
Jean-Michel Pichavant wrote: Michael Rudolf wrote: First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its

Re: Signature-based Function Overloading in Python

2010-02-25 Thread Michael Rudolf
Am 25.02.2010 11:58, schrieb Jean-Michel Pichavant: You said it yourself: simply make two or three functions and name them appropiately :-) When 2 methods of a class were to have the same name for doing completely different things like you said, there's a design flaw to my opinion. JM I

Re: Signature-based Function Overloading in Python

2010-02-25 Thread Bruno Desthuilliers
Michael Rudolf a écrit : (snip) (pseudocode - this is *not* python ;) class Machines (Object): @classmethod def shutdown(cls, Machine, emergency=False): try: if Machine is instanceof(Fileservers): if not emergency:

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Jean-Michel Pichavant
Michael Rudolf wrote: Just a quick question about what would be the most pythonic approach in this. In Java, Method Overloading is my best friend, but this won't work in Python: def a(): pass def a(x): pass a() Traceback (most recent call last): File pyshell#12, line 1, in

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Michael Rudolf
First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its advantages: 1 docstring, 1 way do do it, 1 interface.

Re: Signature-based Function Overloading in Python

2010-02-24 Thread Diez B. Roggisch
Am 24.02.10 12:42, schrieb Michael Rudolf: First: Thanks for all the replies so far, they really helped me. Am 24.02.2010 11:28, schrieb Jean-Michel Pichavant: def a(x=None): if x is None: pass else: pass This is the way to do it python, and it has its advantages: 1 docstring, 1 way do do

Signature-based Function Overloading in Python

2010-02-23 Thread Michael Rudolf
Just a quick question about what would be the most pythonic approach in this. In Java, Method Overloading is my best friend, but this won't work in Python: def a(): pass def a(x): pass a() Traceback (most recent call last): File pyshell#12, line 1, in module a()

Re: Signature-based Function Overloading in Python

2010-02-23 Thread Daniel Fetchinson
In Java, Method Overloading is my best friend, but this won't work in Python: def a(): pass def a(x): pass a() Traceback (most recent call last): File pyshell#12, line 1, in module a() TypeError: a() takes exactly 1 argument (0 given) So - What would be the

Re: Signature-based Function Overloading in Python

2010-02-23 Thread John Posner
On 2/23/2010 1:25 PM, Michael Rudolf wrote: Just a quick question about what would be the most pythonic approach in this. In Java, Method Overloading is my best friend, but this won't work in Python: def a(): pass def a(x): pass a() Traceback (most recent call last): File pyshell#12,

Re: Signature-based Function Overloading in Python

2010-02-23 Thread Arnaud Delobelle
Michael Rudolf spamfres...@ch3ka.de writes: Just a quick question about what would be the most pythonic approach in this. In Java, Method Overloading is my best friend, but this won't work in Python: def a(): pass def a(x): pass a() Traceback (most recent call last):

Re: Signature-based Function Overloading in Python

2010-02-23 Thread Lie Ryan
On 02/24/10 05:25, Michael Rudolf wrote: Just a quick question about what would be the most pythonic approach in this. In Java, Method Overloading is my best friend, but this won't work in Python: snip So - What would be the most pythonic way to emulate this? Is there any better Idom than: