Re: [Tutor] intefaces in python

2009-06-30 Thread Jan Ulrich Hasecke
Am 28.06.2009 um 17:00 schrieb Amit Sethi: Hi , I don't suppose python has a concept of interfaces. But can somebody tell me if their is a way i can implement something like a java interface in python. The Web Framework Zope has a notion of interfaces. http://pypi.python.org/pypi/zope.int

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
"Amit Sethi" wrote I think ideally i want a compile Error just like java .. I think you are trying to make Python act like Java which is always a really bad mistake when using a programming language. As Bjarne Stroustrup used to say (repeatedly) "C++ is not Smalltalk". And Python is not

Re: [Tutor] intefaces in python

2009-06-29 Thread Amit Sethi
well dir(object) , how would that help . All the functions in base class would automatically be inherited by the objects of plug-in class ... so they would come in the list even if it was not implemented... On Mon, Jun 29, 2009 at 5:58 PM, Luke Paireepinart wrote: > Amit Sethi wrote: >> >> I think

Re: [Tutor] intefaces in python

2009-06-29 Thread Luke Paireepinart
Amit Sethi wrote: I think ideally i want a compile Error just like java .. Why? For developers, so they'll know if their plugin meets the interface requirements? Have you considered just making a unit test that will call all interface functions with appropriate parameters? Then they can just

Re: [Tutor] intefaces in python

2009-06-29 Thread Amit Sethi
wait even in the above example i would have to run all the functions in __init__ that is plain stupid ... i was just brain storming On Mon, Jun 29, 2009 at 5:34 PM, Amit Sethi wrote: > I think ideally i want a compile Error just like java .. but from the > discussion here ... i wrote this litt

Re: [Tutor] intefaces in python

2009-06-29 Thread Amit Sethi
I think ideally i want a compile Error just like java .. but from the discussion here ... i wrote this little example: class a(object):     def __init__(self):         self.query()         try:             if self.query_not_implemented==True:                 raise NotImplementedError         excep

Re: [Tutor] intefaces in python

2009-06-29 Thread Dave Angel
Amit Sethi wrote: Well I want to implement plug-in like mechanism for an application . I want to define some minimum functions that any body writing a plugin has to implement. For that i thought an interface would be best because in a scenario where the function is not implemented some kind of

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
"Amit Sethi" wrote Well I want to implement plug-in like mechanism for an application . I want to define some minimum functions that any body writing a plugin has to implement. For that i thought an interface would be best because in a scenario where the function is not implemented some kind

Re: [Tutor] intefaces in python

2009-06-29 Thread Amit Sethi
Well I want to implement plug-in like mechanism for an application . I want to define some minimum functions that any body writing a plugin has to implement. For that i thought an interface would be best because in a scenario where the function is not implemented some kind of error would occur. I w

Re: [Tutor] intefaces in python

2009-06-29 Thread Alan Gauld
"Amit Sethi" wrote class MyInterface(object): doSomething(line): raise NotImplementedError doSomethingElse(line): raise NotImplementedError I think that is exactly the kind of structure i was looking for ... As a matter of interest, why? What do you anticipate using this fo

Re: [Tutor] intefaces in python

2009-06-29 Thread Amit Sethi
class MyInterface(object): doSomething(line): raise NotImplementedError doSomethingElse(line): raise NotImplementedError I think that is exactly the kind of structure i was looking for ... On Mon, Jun 29, 2009 at 12:58 PM, Andre Engels wrote: > On Sun, Jun 28, 2009 at 5:00 P

Re: [Tutor] intefaces in python

2009-06-29 Thread Andre Engels
On Sun, Jun 28, 2009 at 5:00 PM, Amit Sethi wrote: > Hi , I don't suppose python has a concept of interfaces. But can somebody > tell me if their is a way i can  implement something like a java interface > in python. Sure. Interfaces are just Java's compensation for not having multiple inheritance

Re: [Tutor] intefaces in python

2009-06-28 Thread Lie Ryan
Bob Rea wrote: > On Sun June 28 2009 1:48 pm, Alan Gauld wrote: >> advantages to them over defining, say, a mixin > > Noob, here, wanted to know what a mixin is > eh, just getting back into learning python > googled it, still not sure what it is, but > wikipedia says the name come from ice cream m

Re: [Tutor] intefaces in python

2009-06-28 Thread Bob Rea
On Sun June 28 2009 1:48 pm, Alan Gauld wrote: > advantages to them over defining, say, a mixin Noob, here, wanted to know what a mixin is eh, just getting back into learning python googled it, still not sure what it is, but wikipedia says the name come from ice cream mixins at Steve's Ice Cream

Re: [Tutor] intefaces in python

2009-06-28 Thread Alan Gauld
"Amit Sethi" wrote Hi , I don't suppose python has a concept of interfaces. Yes and No, I'll come back to that... But can somebody tell me if their is a way i can implement something like a java interface in python. First, can you tell me why you would want to? Java style interfaces tend

[Tutor] intefaces in python

2009-06-28 Thread Amit Sethi
Hi , I don't suppose python has a concept of interfaces. But can somebody tell me if their is a way i can implement something like a java interface in python. -- A-M-I-T S|S ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo