Am I missing something with Python not having interfaces?

hdante hdante at gmail.com
Tue May 6 13:43:22 EDT 2008


On May 6, 12:09 pm, jmDesktop <needin4mat... at gmail.com> wrote:
> On May 6, 10:26 am, "A.T.Hofkamp" <h... at se-162.se.wtb.tue.nl> wrote:
>
>
>
> > On 2008-05-06, jmDesktop <needin4mat... at gmail.com> wrote:
>
> > > Studying OOP and noticed that Python does not have Interfaces.  Is
> > > that correct?  Is my schooling for nought on these OOP concepts if I
>
> > Depends on your definition of 'Python does not have Interfaces'. They are not
> > in the official language, but they do exist. look into zope.interfaces, athttp://www.zope.org/Products/ZopeInterface.
>
> > > use Python.  Am I losing something if I don't use the "typical" oop
> > > constructs found in other languages (Java, C# come to mind.)  I'm
>
> > I think you are still thinking with a Java mind-set (no idea about C#, never
> > programmed with it).
>
> > Interfaces mainly exist to formalize TO A COMPILER that an object will provide
> > certain stuff. In this way, the compiler can catch such errors at compile time.
>
> > Python on the other hand does very little at compile time (other than parse
> > errors). Instead, at run-time it performs the checks that something you want to
> > use is actually there.
> > (in the same way that you don't declare variables a priori. You simply use them
> > and Python creates them for you when needed).
>
> > As a result, you get much more light-weight, more dynamic, code, which supports
> > the RAD nature of Python what makes it so much more productive.
>
> > (after a few years Python, you may find the Java way of doing things clunky).
>
> > > afraid that if I never use them I'll lose them and when I need them
> > > for something beside Python, I'll be lost.  Thank you.
>
> > You can continue doing everything exactly in the way you do now. Effectively
> > you would then be programming Java/C# in Python syntax. I believe you would
> > gain very little by that move.
>
> > If you dare let go of your old habits, and embrace the mindset of a new
> > language, you can learn a lot more, namely that programming can be done in many
> > different ways (even if all those ways are called OOP).
> > If you only have a hammer, the whole world looks like a nail. If you have a
> > whole toolbox, problems become much more diverse (subtle). You learn to use
> > the right tools for the right problem, and maybe you find new (better) ways of
> > approaching old problems.
>
> > In the process, you may lose details of how something was done in language X,
> > but that's why they have invented books.
>
> > Sincerely,
> > Albert
>
> I would imagine this is why I haven't found any schools teaching
> Python in their basic programming classes too.  On the dynamic typing,

 No. When teaching problem solving in the basic programming courses,
the language is irrelevant. You don't even need a computer for that.

> isn't that the same sort of thing that lots of scripting languages
> do?  VBScript doesn't require you to define your variables, but I
> don't really want to use it for anything (used to use it a lot in
> Classic ASP.)  I believe everyone that Python is great, but some of it
> doesn't make sense to me as to why.  Thanks.

 If you want to understand the design decisions behind python, read
its history:
 http://www.artima.com/intv/python.html

 Also, do you have an example of some problem that requires an
interface that you would like to know how it's done in python (or
maybe an explanation of why it's not possible) ?



More information about the Python-list mailing list