Re: No method overloading

2008-08-24 Thread alex23
On Aug 24, 6:15 pm, Hussein B <[EMAIL PROTECTED]> wrote: > Please correct me if I'm wrong but Python doesn't support method > overload, right? Guido once wrote an article on rolling your own: http://www.artima.com/weblogs/viewpost.jsp?thread=101605 -- http://mail.python.org/mailman/listinfo/pyth

Re: No method overloading

2008-08-24 Thread Fredrik Lundh
Hussein B wrote: Please correct me if I'm wrong but Python doesn't support method overload, right? -- def method(self): #code def method(self, data): #code -- The last declaration of method() erase the previous one (like JavaScript). in Python, methods are callable attributes, and an attribu

Re: No method overloading

2008-08-24 Thread MeTheGameMakingGuy
On Aug 24, 6:15 pm, Hussein B <[EMAIL PROTECTED]> wrote: > Hey, > Please correct me if I'm wrong but Python doesn't support method > overload, right? > -- > def method(self): >  #code > def method(self, data): >  #code > -- > The last declaration of method() erase the previous one (like > JavaScrip

No method overloading

2008-08-24 Thread Hussein B
Hey, Please correct me if I'm wrong but Python doesn't support method overload, right? -- def method(self): #code def method(self, data): #code -- The last declaration of method() erase the previous one (like JavaScript). Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Method overloading?

2007-02-15 Thread placid
On Feb 16, 3:37 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-02-15, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > >> def multiAccept( argOfVariousTypes ): > >> if isinstance(argOfVariousTypes,int): > >> # treat like an int > >> elif isinstance(argOfVariousTypes,float): > >

RE: Method overloading?

2007-02-15 Thread Delaney, Timothy (Tim)
Steven D'Aprano wrote: > This is an example of overloading: > > class Cheese(object): > def flavour(self): > return "tasty and scrumptious" > def colour(self): > return "yellow" > > Now we define a sub-class which overloads some methods: > > class BlueVein(Cheese): >

Re: Method overloading?

2007-02-15 Thread Neil Cerutti
On 2007-02-15, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> def multiAccept( argOfVariousTypes ): >> if isinstance(argOfVariousTypes,int): >> # treat like an int >> elif isinstance(argOfVariousTypes,float): >> # treat like a float >> elif isinstance(argOfVariousTypes,(l

Re: Method overloading?

2007-02-15 Thread Grant Edwards
On 2007-02-15, placid <[EMAIL PROTECTED]> wrote: >> > Is it possible to be able to do the following in Python? >> >> > class Test: >> > def __init__(self): >> > pass >> >> > def puts(self, str): >> > print str >> >> > def puts(self, str,str2): >> > print str,str

Re: Method overloading?

2007-02-15 Thread [EMAIL PROTECTED]
On 15 fév, 09:32, "Troy Melhase" <[EMAIL PROTECTED]> wrote: > On 14 Feb 2007 20:54:31 -0800, placid <[EMAIL PROTECTED]> wrote: > > > class Test: > > def __init__(self): > > pass > > > def puts(self, str): > > print str > > > def puts(self, str,str2): > > print st

Re: Method overloading?

2007-02-15 Thread Troy Melhase
On 14 Feb 2007 20:54:31 -0800, placid <[EMAIL PROTECTED]> wrote: > class Test: > def __init__(self): > pass > > def puts(self, str): > print str > > def puts(self, str,str2): > print str,str2 you might look into the overloading module and its decorator. source

Re: Method overloading?

2007-02-14 Thread Paul McGuire
"Overloading" is used in C++, Java and C# to describe a single method name with multiple signatures. It is not really possible to implement such a thing in Python, which just binds methods to names, and duplicate definitions of methodX just replace the former with the latter. But fro

Re: Method overloading?

2007-02-14 Thread Steven D'Aprano
On Wed, 14 Feb 2007 21:58:35 -0800, Paul McGuire wrote: > No, Python does not do overloading as part of the language, you have > to do the variable argument interpretation for yourself. > > For instance, if you want a method to accept a single argument of > various types, it would look something

Re: Method overloading?

2007-02-14 Thread Steven D'Aprano
On Wed, 14 Feb 2007 21:12:39 -0800, placid wrote: > On Feb 15, 4:04 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: >> On 2007-02-15, placid <[EMAIL PROTECTED]> wrote: >> >> >> >> > Is it possible to be able to do the following in Python? >> >> > class Test: >> > def __init__(self): >> >

Re: Method overloading?

2007-02-14 Thread Paul McGuire
On Feb 14, 10:54 pm, "placid" <[EMAIL PROTECTED]> wrote: > Hi all, > > Is it possible to be able to do the following in Python? > > class Test: > def __init__(self): > pass > > def puts(self, str): > print str > > def puts(self, str,str2): > print str,str2 > > if

Re: Method overloading?

2007-02-14 Thread placid
On Feb 15, 4:04 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2007-02-15, placid <[EMAIL PROTECTED]> wrote: > > > > > Is it possible to be able to do the following in Python? > > > class Test: > > def __init__(self): > > pass > > > def puts(self, str): > > print str > >

Re: Method overloading?

2007-02-14 Thread Grant Edwards
On 2007-02-15, placid <[EMAIL PROTECTED]> wrote: > Is it possible to be able to do the following in Python? > > class Test: > def __init__(self): > pass > > def puts(self, str): > print str > > def puts(self, str,str2): > print str,str2 > > if __name__ == "__mai

Method overloading?

2007-02-14 Thread placid
Hi all, Is it possible to be able to do the following in Python? class Test: def __init__(self): pass def puts(self, str): print str def puts(self, str,str2): print str,str2 if __name__ == "__main__": t = Test() t.puts("hi") t.puts("hi","hello")

Re: Multiple hierarchie and method overloading

2006-04-25 Thread Philippe Martin
Thanks, I'll try that. Philippe Ben Cartwright wrote: > Philippe Martin wrote: >> I have something like this: >> >> Class A: >> def A_Func(self, p_param): >> . >> Class B: >> def A_Func(self): >> . >> >> Class C (A,B): >> A.__init__(self) >>

Re: Multiple hierarchies and method overloading

2006-04-25 Thread Philippe Martin
Well, the whole point was to clean up my code: Actually this is what I have: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) Class D (A,B): A.__init__(self)

Re: Multiple hierarchies and method overloading

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > "Ben Cartwright" <[EMAIL PROTECTED]> wrote: > > >>Philippe Martin wrote: >> >> >>>I renamed A_Func(self) to fix that ... but is there a cleaner way around ? >> >>When using multiple inheritence, the order of the base classes matters!

Re: Multiple hierarchie and method overloading

2006-04-25 Thread bruno at modulix
Philippe Martin wrote: > Hi, > > I have something like this: > > Class A: > def A_Func(self, p_param): > . > Class B: > def A_Func(self): > . > > Class C (A,B): > A.__init__(self) > B.__init__(self) > > . > > self.A_Func() #

Re: Multiple hierarchie and method overloading

2006-04-25 Thread bruno at modulix
Philippe Martin wrote: > Hi, > > > > > I have something like this: > > Class A: > def A_Func(self, p_param): > . > Class B: > def A_Func(self): > . > > Class C (A,B): > A.__init__(self) If that's really your code, you should have an exception

Re: Multiple hierarchies and method overloading

2006-04-25 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Ben Cartwright" <[EMAIL PROTECTED]> wrote: >Philippe Martin wrote: > >> I renamed A_Func(self) to fix that ... but is there a cleaner way around ? > >When using multiple inheritence, the order of the base classes matters! When you have to start worrying about com

Re: Multiple hierarchie and method overloading

2006-04-24 Thread Ben Cartwright
Philippe Martin wrote: > I have something like this: > > Class A: > def A_Func(self, p_param): > . > Class B: > def A_Func(self): > . > > Class C (A,B): > A.__init__(self) > B.__init__(self) > > . > > self.A_Func() #HERE I GET AN

Multiple hierarchie and method overloading

2006-04-24 Thread Philippe Martin
Hi, I have something like this: Class A: def A_Func(self, p_param): . Class B: def A_Func(self): . Class C (A,B): A.__init__(self) B.__init__(self) . self.A_Func() #HERE I GET AN EXCEPTION "... takes at least 2 arguments