Re: Classes and Functions - General Questions

2006-10-19 Thread Sybren Stuvel
Setash enlightened us with: >> class1.py: >> >> class Class1(object): >> pass >> >> class2.py: >> import class1 This line imports class1.py and places its contents under the name "class1". > classes.py: > > class Class1 > pass > > class Class2(Class1) > pass That's co

Re: Classes and Functions - General Questions

2006-10-19 Thread John Salerno
John Salerno wrote: > Setash wrote: > >> And have class2 inherit class1 without any import statements, or need >> it be imported first? >> Or need class1 and class2 be both declared in the same .py file if >> there is inheritance? > > If the classes are in the same module, you don't need to do an

Re: Classes and Functions - General Questions

2006-10-18 Thread Setash
Andreas, and everyone else - thank you! I do appreciate the information and the quick responses, this single post with <10 replies has significantly helped my understanding level. Thanks again! -- http://mail.python.org/mailman/listinfo/python-list

Re: Classes and Functions - General Questions

2006-10-18 Thread Andreas Hartl
Setash schrieb: > 2) Function overloading - is it possible? > > Can I have the following code, or something which acts the same in > python?: > > > def function(a, b) >do things > > def function(a, b, c) >do things only if I get a third argument Several ways. The simplest and often mo

Re: Classes and Functions - General Questions

2006-10-18 Thread John Salerno
Setash wrote: > Also, I have seen the following syntax used once before, and havent > found any documentation on it, any comments as to use, where to find > docs, etc?: > > from module import x as name > name.function() All that does is give you a method for renaming a particularly unrul

Re: Classes and Functions - General Questions

2006-10-18 Thread Bruno Desthuilliers
Setash a écrit : > I've got a tiny bit of coding background, but its not the most > extensive. > > That said, I'm trying to wrap my head around python and have a couple > questions with classes and functions. > > Two notable questions: > > 1) Classes. How do you extend classes? > > I know its a

Re: Classes and Functions - General Questions

2006-10-18 Thread John Salerno
Setash wrote: > And have class2 inherit class1 without any import statements, or need > it be imported first? > Or need class1 and class2 be both declared in the same .py file if > there is inheritance? If the classes are in the same module, you don't need to do any importing or qualification. I

Re: Classes and Functions - General Questions

2006-10-18 Thread Setash
> > > > And have class2 inherit class1 without any import statements, or need > > it be imported first? > > It needs to be imported first: > > class1.py: > > class Class1(object): > pass > > class2.py: > import class1 > > class Class2(class1.Class1): > pass > In respo

Re: Classes and Functions - General Questions

2006-10-18 Thread Sybren Stuvel
Setash enlightened us with: > 1) Classes. How do you extend classes? > > I know its as easy as: > > class classname(a) >do stuff > > > But where does the parent class need to lie? In the same file? Can > it lie in another .py file in the root directory? It doesn't matter at all, as long as 'a'

Classes and Functions - General Questions

2006-10-18 Thread Setash
I've got a tiny bit of coding background, but its not the most extensive. That said, I'm trying to wrap my head around python and have a couple questions with classes and functions. Two notable questions: 1) Classes. How do you extend classes? I know its as easy as: class classname(a) do st