Re: Signature-based Function Overloading in Python

2010-02-27 Thread Michael Rudolf
Am 27.02.2010 10:00, schrieb alex23: Michael Rudolf 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=1016

Re: Signature-based Function Overloading in Python

2010-02-27 Thread alex23
Michael Rudolf 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: http://blog.ianbicking.org/more-o

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: Machine.unmount_raid_first

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 wond

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 adva

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-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

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 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 "", line 1, in

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: > So - What would be the most pythonic way to emulate this? > Is there any better Idom tha

Re: Signature-based Function Overloading in Python

2010-02-23 Thread Arnaud Delobelle
Michael Rudolf 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): > F

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 "", lin

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 "", line 1, in > a() > TypeError: a() takes exactly 1 argument (0 given) > > So - What would

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 "", line 1, in a() TypeError: