Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Inheritance error in python 2.3.4???

Thread Tools

Re: Inheritance error in python 2.3.4???

Jack Diederich
Posts: n/a
On Tue, Feb 15, 2005 at 10:56:23AM +1100, Delaney, Timothy C (Timothy) wrote:
> Removed) wrote:
> > I guess I could just use one underscore.... but that means it is
> > easier for other people to get at my implementation details (which,
> > coming from a C++ background really bothers me).

> This is the correct solution, and getting over being bothered about it
> is the correct thing to do.
> Getting at private members is simple in C++ too if anyone wants to do
> that.

As a long time C++ guy that switched over to python (via a perl detour) my
advice is to do things the python way even if they feel strange at first.
In this case forget about "private" and "protected." If it helps you can
consider them conventions that have some compiler support. The 20th
commandment of python is "we're all adults here." To see the first 19, type
"import this" at the python prompt.

I also discovered - to my shock and horror - that many of the GoF's "Design
Patterns" were actually C++ centric and not universals. The sting of seeing
canon reduced to a HOWTO fades quickly, just jump in with both feet.

Reply With Quote
Posts: n/a
Thanks guys for all your input! I really appreciate the prompt

As you can tell I'm having a bit of trouble throwing out old habits...
I'm not new to loosely typed languages (I'm a big PHP fan) but learning
a new object model has been a little tough... I'm trying to make my old
ideas fit a new language (which is a bad idea in general).

So thanks for setting me straight. I hadn't yet heard of "properties"
it looks like it does what I want... so I will check them out further.
But if they don't do what I want I will probably just use a single
underscore and ummmm trust my users (In general, C++ people
aren't a trusting bunch.... Auto Garbage collection!!?!???!

Thanks again for the replies,

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Struct inheritance against class inheritance johnsonlau C++ 1 07-21-2008 04:58 PM
Interface inheritance vs Implementation inheritance. Daniel Pitts Java 27 02-27-2008 01:37 AM
Private Inheritance and Publice Inheritance karthikbalaguru C++ 9 09-10-2007 01:05 PM
mul. inheritance & overloading operator new/delete solved by virtual base inheritance? cppsks C++ 0 10-27-2004 07:49 PM
Private access modifier and Inheritance (Inheritance implementation in Java) maxw_cc Java 1 12-21-2003 11:38 AM