Simple Class Question - need clarity please

Shalabh Chaturvedi shalabh at cafepy.com
Fri Apr 9 19:58:44 EDT 2004


Stevie_mac wrote:

> OK, 1st off, I'm brand new to python so all help is appreciated. Right...
> 
> Lets say I want a class called Window.  It will have some functions namely
> DoModal() Now this class is inherited in MyClass
> What is wrong with this?...

<examples of working and non working code snipped>

> 
> . . . I get
> NameError: global name 'MakeDlgTemplate' is not defined  ???

On which line in your example do you get this error (from the traceback)?

> 
> another 1 I managed to clear up was . . .
> TypeError: Show() takes no arguments (1 given)
> . . . until I added 'self' to the Show function  ???

Going through the Python tutorial should clear this up and other confusions
as well. To quote "the method function is declared with an explicit first
argument representing the object, which is provided implicitly by the
call". I urge you read the entire section on classes [1].
 
> 
> I really am struggling with this - some real clarity is needed - can
> anyone explain the rules (I've read stuff &
> dissected samples, but I still struggle when it comes to this.  If someone
> can clear this up for me, I should be flying as I am familiar with the
> concepts of OOP)
> 
> I'm also struggling with other things like...
> Where do I save .py files?
> Will 'import' find my files where ever they are? (obviously not but...)

Look for PYTHONPATH and sys.path in the documentation. Hmm, now I urge you
to go through the entire tutorial - it doesn't take long!

> What basic should be considerations when deriving classes?
> 
> any help will be greatly appreciated - Ta Stevie_Mac
> 
> 

HTH,
Shalabh

[1] http://python.org/doc/2.3.3/tut/node11.html






More information about the Python-list mailing list