Re: derived / base class name conflicts

2005-11-16 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > so the following would not result in any conflicts > > class A: >def __init__(self): > self.__i= 0 > > class B(A): >def __init__(self): > A.__init__(self) > self.__i= 1 > Be careful here. The above won't result in any conflicts, but related

Re: derived / base class name conflicts

2005-11-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Your suggestion ('_name' -> implementation, 'name' -> API) This is not "my" convention, it's *the* (mostly agreed upon) Python convention. Like 'self', or CONSTANT, or a whole lot of things in Python. > makes sense > as a convention between programmers that know a

Re: derived / base class name conflicts

2005-11-11 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > I don't think it is reasonable in general to only subclass from base > classes you have studied the full API of, however. The double I think you underestimate the level of coupling that inevitably occurs between base and derived classes. In general, such coupl

Re: derived / base class name conflicts

2005-11-11 Thread christopherlmarshall
Your suggestion ('_name' -> implementation, 'name' -> API) makes sense as a convention between programmers that know a fair amount about each other's classes before using them. I don't think it is reasonable in general to only subclass from base classes you have studied the full API of, however.

Re: derived / base class name conflicts

2005-11-11 Thread christopherlmarshall
I see what you mean now. It would indeed be enlightening if I wanted to study the internals of Tkinter, and perhaps one day I will. -- http://mail.python.org/mailman/listinfo/python-list

Re: derived / base class name conflicts

2005-11-11 Thread bruno at modulix
[EMAIL PROTECTED] wrote: (snip) > So putting two underscores in front of an instance variable (or any > identifier used inside the scope of a class statement) invokes a name > mangling mechanism (snip) > Is it commonplace to use underscores I assume you mean double underscore... > when definin

Re: derived / base class name conflicts

2005-11-10 Thread Ben Finney
[EMAIL PROTECTED] wrote: > Suppose you want to write a subclass of some existing class you are > importing from a module you didn't write and that you don't want to > study the internals of No need to study its internals. Fire up a Python interpreter and inspect its outside: >>> import foomod

Re: derived / base class name conflicts

2005-11-10 Thread christopherlmarshall
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Now, 'i' might have already been defined by A or by the call to > > A.__init__() so if you define it without knowing that, you could be > > changing the behavior of A's methods in unknown ways, which is > > obviously a bad thing. > > http://doc

Re: derived / base class name conflicts

2005-11-10 Thread christopherlmarshall
Steve Juranich wrote: > This should prove most enlightening: > > import Tkinter > dir(Tkinter.Canvas) > > Huh? Chris Marshall -- http://mail.python.org/mailman/listinfo/python-list

Re: derived / base class name conflicts

2005-11-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Now, 'i' might have already been defined by A or by the call to > A.__init__() so if you define it without knowing that, you could be > changing the behavior of A's methods in unknown ways, which is > obviously a bad thing. http://docs.python.org/tut/node11.html#SECTION

Re: derived / base class name conflicts

2005-11-10 Thread Steve Juranich
This should prove most enlightening: import Tkinter dir(Tkinter.Canvas) On 10 Nov 2005 14:53:04 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Suppose you want to write a subclass of some existing class you are > importing from a module you didn't write and that you don't want to > study