Base class and Derived class question

2012-11-06 Thread cyberirakli
Hey guys, I'm trying to understand how is working base class and derived class. So, I have to files baseClass.py and derivedClass.py. baseClass.py : [CODE]class baseClass(): def bFunction(self): print We are in a base class[/CODE] derivedClass.py: [CODE]import baseClass as

Base class and Derived class question

2012-11-06 Thread cyberirakli
Hey guys, I'm trying to understand how is working base class and derived class. So, I have to files baseClass.py and derivedClass.py. baseClass.py : class baseClass(): def bFunction(self): print We are in a base class derivedClass.py: import baseClass as baseClassMod

Re: Base class and Derived class question

2012-11-06 Thread Dave Angel
On 11/06/2012 08:50 AM, cyberira...@gmail.com wrote: Hey guys, I'm trying to understand how is working base class and derived class. in what Python version ? So, I have to files baseClass.py and derivedClass.py. baseClass.py : class baseClass(): How did all those angle brackets get into

Re: Base class and Derived class question

2012-11-06 Thread cyberirakli
in what Python version ? Python 2.7.3 How did all those angle brackets get into the file? Are you confusing an interactive interpreter session with running source files? I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code] I have a file

Re: Base class and Derived class question

2012-11-06 Thread cyberirakli
Just got answer, I didn't call a class it's self. Correct code is: class derivedClass(baseClassMod.baseClass): def .. -- http://mail.python.org/mailman/listinfo/python-list

Re: Base class and Derived class question

2012-11-06 Thread Ian Kelly
On Tue, Nov 6, 2012 at 8:03 AM, cyberira...@gmail.com wrote: I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code] This is a Usenet group, not a web forum. Just got answer, I didn't call a class it's self. Correct code is: class

Re: Base class and Derived class question

2012-11-06 Thread cyberirakli
On Tuesday, November 6, 2012 4:35:47 PM UTC+1, Ian wrote: On Tue, Nov 6, 2012 at 8:03 AM, I've used angle brackets just for posting here,becauze this forum doesn't support [code][/code] This is a Usenet group, not a web forum. Just got answer, I didn't call a class it's

Re: Base class and Derived class question

2012-11-06 Thread Hans Mulder
On 6/11/12 14:47:03, cyberira...@gmail.com wrote: Hey guys, I'm trying to understand how is working base class and derived class. So, I have to files baseClass.py and derivedClass.py. baseClass.py : [CODE]class baseClass(): def bFunction(self): print We are in a base

Re: Base class and Derived class question

2012-11-06 Thread alex23
On Nov 7, 1:08 am, cyberira...@gmail.com wrote: Just got answer, I didn't call a class it's self.  Correct code is: class derivedClass(baseClassMod.baseClass):     def .. Incidentally, this is why it's recommended to give modules lowercase names - baseclass - and classes camelcased ones -

Decorated class question

2012-01-16 Thread deathweaselx86
Pardon me if this is a silly question. If I decorate a class, then subclass it, does my subclass feature whatever the decorator did to my superclass? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorated class question

2012-01-16 Thread Devin Jeanpierre
On Mon, Jan 16, 2012 at 10:10 AM, deathweaselx86 deathwea...@gmail.com wrote: If I decorate a class, then subclass it, does my subclass feature whatever the decorator did to my superclass? Yes. The following two things are completely equivalent: @foo class Bar(...): ... # and class

Re: Decorated class question

2012-01-16 Thread Ian Kelly
On Mon, Jan 16, 2012 at 8:10 AM, deathweaselx86 deathwea...@gmail.com wrote: Pardon me if this is a silly question. If I decorate a class, then subclass it, does my subclass feature whatever the decorator did to my superclass? That depends on what the decorator did. Changes made directly to

Re: embarrassing class question

2010-10-30 Thread Gregory Ewing
Paul Rudin wrote: Gregory Ewing greg.ew...@canterbury.ac.nz writes: You can clean up dir() by defining __all__ as a list of names that you want to officially export. I'm not sure that's necessarily a good idea... when you're trying to figure out why something behaves in a certain way you

Re: embarrassing class question

2010-10-30 Thread Steven D'Aprano
On Sat, 30 Oct 2010 19:30:21 +1300, Gregory Ewing wrote: (BTW, there are no function names that have a special meaning in a module dict -- a module is not like a class.) Pity... it would be nice to have a __main__() function, or perhaps main(), that was automatically called when you call the

Re: embarrassing class question

2010-10-29 Thread Gregory Ewing
Brendan wrote: I use Python sporadically, and frequently use the dir command to learn or remind myself of class methods. You can clean up dir() by defining __all__ as a list of names that you want to officially export. Other names will still be there, but they won't show up in the dir()

Re: embarrassing class question

2010-10-29 Thread Paul Rudin
Gregory Ewing greg.ew...@canterbury.ac.nz writes: Brendan wrote: I use Python sporadically, and frequently use the dir command to learn or remind myself of class methods. You can clean up dir() by defining __all__ as a list of names that you want to officially export. Other names will

Re: embarrassing class question

2010-10-29 Thread Lawrence D'Oliveiro
In message 8idvgaf21...@mid.individual.net, Peter Pearson wrote: Yes, module w imports x, and therefore w.x exists. Is that bad? No-one seems to have come out and said this yet (unless it was in one of those messages that no longer seem to be accessible on my ISP’s news server): Python has

Re: embarrassing class question

2010-10-25 Thread Brendan
On Oct 22, 2:21 pm, Peter Pearson ppear...@nowhere.invalid wrote: On Fri, 22 Oct 2010 07:49:39 -0700 (PDT), Brendan wrote: [snip] x.py class X(object):     pass y.py import x class Y(x.X):     pass z.py import x import y class ZX(x.X):     pass class ZY(y.Y):  

Re: embarrassing class question

2010-10-22 Thread Steven D'Aprano
On Thu, 21 Oct 2010 12:12:34 -0700, Brendan wrote: Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is usually done to prevent this? (In my case not wanting class x added to the y.py

Re: embarrassing class question

2010-10-22 Thread Brendan
On Oct 22, 5:02 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Thu, 21 Oct 2010 12:12:34 -0700, Brendan wrote: Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is

Re: Re: embarrassing class question

2010-10-22 Thread Dave Angel
On 2:59 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us wrote: snip Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted text - So what is usually done to prevent this? (In my case not

Re: embarrassing class question

2010-10-22 Thread Brendan
On Oct 22, 9:16 am, Dave Angel da...@dejaviewphoto.com wrote: On 2:59 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us  wrote: snip Because y.py has from x import x the x class from x.py is added to the y.py namespace. ~Ethan~- Hide quoted text - - Show quoted

Re: embarrassing class question

2010-10-22 Thread Peter Pearson
On Fri, 22 Oct 2010 07:49:39 -0700 (PDT), Brendan wrote: [snip] x.py class X(object): pass y.py import x class Y(x.X): pass z.py import x import y class ZX(x.X): pass class ZY(y.Y): pass w.py import x import y import z class WX(x.X): pass class WY(y.Y):

embarrassing class question

2010-10-21 Thread Brendan
Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not understand why class 'x' shows up here. --

Re: embarrassing class question

2010-10-21 Thread Jonas H.
On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not understand why class 'x'

Re: embarrassing class question

2010-10-21 Thread Carl Banks
On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):     pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I

Re: embarrassing class question

2010-10-21 Thread Brendan
On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):     pass Now from the python command line: import y dir(y)

Re: embarrassing class question

2010-10-21 Thread Ethan Furman
Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not

Re: embarrassing class question

2010-10-21 Thread Chris Rebert
On Thu, Oct 21, 2010 at 11:53 AM, Brendan brendandetra...@yahoo.com wrote: On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):  

Re: embarrassing class question

2010-10-21 Thread Robert Kern
On 10/21/10 1:53 PM, Brendan wrote: On Oct 21, 3:47 pm, Carl Bankspavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendanbrendandetra...@yahoo.com wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command

Re: embarrassing class question

2010-10-21 Thread Ian
On Oct 21, 12:53 pm, Brendan brendandetra...@yahoo.com wrote: So it must never make sense to put subclasses in separate modules? It doesn't matter to Python whether the subclass is in the same module or imported. Do it whichever way makes the most sense to you from a code organization

Re: embarrassing class question

2010-10-21 Thread Brendan
On Oct 21, 3:56 pm, Ethan Furman et...@stoneleaf.us wrote: Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object):      pass y.py: from x import x class y(x):      pass Now from the python command line: import y dir(y)

Re: embarrassing class question

2010-10-21 Thread Carl Banks
On Oct 21, 11:53 am, Brendan brendandetra...@yahoo.com wrote: On Oct 21, 3:47 pm, Carl Banks pavlovevide...@gmail.com wrote: On Oct 21, 11:09 am, Brendan brendandetra...@yahoo.com wrote: Two modules: x.py: class x(object):     pass y.py: from x import x class y(x):    

Re: embarrassing class question

2010-10-21 Thread Robert Kern
On 10/21/10 2:12 PM, Brendan wrote: On Oct 21, 3:56 pm, Ethan Furmanet...@stoneleaf.us wrote: Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y

Re: basic class question..

2009-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2009 16:26:59 -0800, Pyrot wrote: On 11월15일, 오후9시52분, Diez B. Roggisch de...@nospam.web.de wrote: Pyrot schrieb: class rawDNA:    import string [...] (Tthe core reason that I'm bothering with this at all is because I heard imports are costly(in time, space, processing

basic class question..

2009-11-15 Thread Pyrot
class rawDNA: import string trans = string.maketrans(GATC,CTAG) def __init__(self, template = GATTACA): self.template = template //shouldn't this make template accessible within the scope of rawDNA?? def noncoding(self): print

Re: basic class question..

2009-11-15 Thread Diez B. Roggisch
Pyrot schrieb: class rawDNA: import string Importing here is unusual. Unless you have good reasons to do so, I suggest you put the imports on top of the file. trans = string.maketrans(GATC,CTAG) def __init__(self, template = GATTACA): self.template

Re: basic class question..

2009-11-15 Thread Tim Chase
Pyrot wrote: class rawDNA: import string trans = string.maketrans(GATC,CTAG) def __init__(self, template = GATTACA): self.template = template //shouldn't this make template accessible within the scope of rawDNA?? No. Python's scope resolution

Re: basic class question..

2009-11-15 Thread Diez B. Roggisch
Diez B. Roggisch schrieb: Pyrot schrieb: class rawDNA: import string Importing here is unusual. Unless you have good reasons to do so, I suggest you put the imports on top of the file. trans = string.maketrans(GATC,CTAG) def __init__(self, template = GATTACA):

Re: basic class question..

2009-11-15 Thread Pyrot
On 11월15일, 오후10시15분, Tim Chase python.l...@tim.thechases.com wrote: Pyrot wrote: class rawDNA: import string trans = string.maketrans(GATC,CTAG) def __init__(self, template = GATTACA): self.template = template //shouldn't this make template accessible within the

Re: basic class question..

2009-11-15 Thread Pyrot
On 11월15일, 오후9시52분, Diez B. Roggisch de...@nospam.web.de wrote: Pyrot schrieb: class rawDNA:    import string Importing here is unusual. Unless you have good reasons to do so, I suggest you put the imports on top of the file.    trans = string.maketrans(GATC,CTAG)    def

Re: basic class question..

2009-11-15 Thread r
On Nov 15, 6:26 pm, Pyrot sungs...@gmail.com wrote: what happens when I use the import statement within a class/function declaration? I'm thinking either 1) It imports during the class/function declaration 2) It imports the first time a class/function call(x = rawDNA() ) occurs But if

psyco class question

2008-03-16 Thread Magdoll
I can't find a psyco mailing list that I can directly ask to (so point me to it if there is one), so I'm posting it here. I know very little about how types and classes work in python and this is probably why I'm having trouble. I wrote a class inheriting pysco.classes, and the class structure is

Re: A class question

2007-10-30 Thread Gabriel Genellina
En Tue, 30 Oct 2007 02:51:39 -0300, Donn Ingle [EMAIL PROTECTED] escribió: While Java's variable declarations bear a superficial (syntactical) similarity to C, their semantics is in fact equivalent to the object-reference semantics we know in Python. I come from Z80A/GWBASIC/VB and a

Re: A class question

2007-10-30 Thread Hrvoje Niksic
Bruno Desthuilliers [EMAIL PROTECTED] writes: While Java's variable declarations bear a superficial (syntactical) similarity to C, their semantics is in fact equivalent to the object-reference semantics we know in Python. They implicitly refer to objects allocated on the heap and, just like

Re: A class question

2007-10-30 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : Bruno Desthuilliers [EMAIL PROTECTED] writes: It seems to me that in recent times more Python beginners come from a Java background than from a C one. Java does have container variables for primitive types, and even for references, Java's variables are more than

Re: A class question

2007-10-30 Thread Bruno Desthuilliers
Donn Ingle a écrit : vzcbeg vafcrpg qrs _svaq(senzr, bow): sbe anzr, inyhr va senzr.s_ybpnyf.vgrevgrzf(): vs inyhr vf bow: erghea anzr sbe anzr, inyhr va senzr.s_tybonyf.vgrevgrzf(): vs inyhr vf bow: erghea anzr envfr XrlReebe(Bowrpg abg sbhaq

Re: A class question

2007-10-30 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : Bruno Desthuilliers [EMAIL PROTECTED] writes: While Java's variable declarations bear a superficial (syntactical) similarity to C, their semantics is in fact equivalent to the object-reference semantics we know in Python. They implicitly refer to objects allocated

Re: A class question

2007-10-30 Thread George Sakkis
On Oct 28, 6:01 am, Donn Ingle [EMAIL PROTECTED] wrote: Is there a way I can, for debugging, access the instance variable name from within a class? Shouldn't this be in a FAQ somewhere? It's the second time (at least!) it comes up this week. George --

A class question

2007-10-29 Thread Donn Ingle
Hello, Is there a way I can, for debugging, access the instance variable name from within a class? E.g: Class X: def debug(self): print My instance var is %s % (some magic Python stuff) So that: x = X() x.debug() My Instance var is x ( Without passing the name in like: x=X(name=x) ) Thx.

Re: A class question

2007-10-29 Thread Bruno Desthuilliers
Donn Ingle a écrit : Hello, Is there a way I can, for debugging, access the instance variable name from within a class? E.g: Class X: def debug(self): print My instance var is %s % (some magic Python stuff) So that: x = X() x.debug() My Instance var is x ( Without passing the

Re: A class question

2007-10-29 Thread Carl Banks
On Oct 28, 6:01 am, Donn Ingle [EMAIL PROTECTED] wrote: Hello, Is there a way I can, for debugging, access the instance variable name from within a class? E.g: Class X: def debug(self): print My instance var is %s % (some magic Python stuff) So that: x = X() x.debug() My Instance

Re: A class question

2007-10-29 Thread Hrvoje Niksic
Donn Ingle [EMAIL PROTECTED] writes: Is there a way I can, for debugging, access the instance variable name from within a class? E.g: Class X: def debug(self): print My instance var is %s % (some magic Python stuff) As others have answered, an instance can live in many variables, so

Re: A class question

2007-10-29 Thread Martin Marcher
2007/10/29, Hrvoje Niksic [EMAIL PROTECTED]: Sbe unpx inyhr, urer vf n cbffvoyr vzcyrzragngvba: ... was that on purpose? martin -- http://noneisyours.marcher.name http://feeds.feedburner.com/NoneIsYours -- http://mail.python.org/mailman/listinfo/python-list

Re: A class question

2007-10-29 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : Donn Ingle [EMAIL PROTECTED] writes: Is there a way I can, for debugging, access the instance variable name from within a class? E.g: Class X: def debug(self): print My instance var is %s % (some magic Python stuff) As others have answered, an instance can

Re: A class question

2007-10-29 Thread Hrvoje Niksic
Bruno Desthuilliers [EMAIL PROTECTED] writes: As others have answered, an instance can live in many variables, be bound to many names would be more accurate IMHO. Technically more accurate maybe (but see below), but I was responding to a beginner's post, so I was striving for ease of

Re: A class question

2007-10-29 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : Bruno Desthuilliers [EMAIL PROTECTED] writes: As others have answered, an instance can live in many variables, be bound to many names would be more accurate IMHO. Technically more accurate maybe (but see below), but I was responding to a beginner's post, so I was

Re: A class question

2007-10-29 Thread emorfo
On Oct 29, 12:46 pm, Martin Marcher [EMAIL PROTECTED] wrote: 2007/10/29, Hrvoje Niksic [EMAIL PROTECTED]: Sbe unpx inyhr, urer vf n cbffvoyr vzcyrzragngvba: ... was that on purpose? martin --http://noneisyours.marcher.namehttp://feeds.feedburner.com/NoneIsYours for humans: For hack

Re: A class question

2007-10-29 Thread Hrvoje Niksic
Bruno Desthuilliers [EMAIL PROTECTED] writes: The problem is that your formulation implies (to me at least) that the variable is actually a kind of container for the object. I really didn't expect it to be read that way, especially since the sentence claims that the same instance can reside in

Re: A class question

2007-10-29 Thread Bruno Desthuilliers
Hrvoje Niksic a écrit : Bruno Desthuilliers [EMAIL PROTECTED] writes: The problem is that your formulation implies (to me at least) that the variable is actually a kind of container for the object. I really didn't expect it to be read that way, especially since the sentence claims that

Re: A class question

2007-10-29 Thread Donn Ingle
bump :) -- http://mail.python.org/mailman/listinfo/python-list

Re: A class question

2007-10-29 Thread Donn Ingle
vzcbeg vafcrpg qrs _svaq(senzr, bow): sbe anzr, inyhr va senzr.s_ybpnyf.vgrevgrzf(): vs inyhr vf bow: erghea anzr sbe anzr, inyhr va senzr.s_tybonyf.vgrevgrzf(): vs inyhr vf bow: erghea anzr envfr XrlReebe(Bowrpg abg sbhaq va senzr

Re: A class question

2007-10-29 Thread Donn Ingle
for humans: Sweet. Thanks, I'll give it a go. It's only for debugging and will make life easier. \d -- http://mail.python.org/mailman/listinfo/python-list

Re: A class question

2007-10-29 Thread Hrvoje Niksic
Bruno Desthuilliers [EMAIL PROTECTED] writes: It seems to me that in recent times more Python beginners come from a Java background than from a C one. Java does have container variables for primitive types, and even for references, Java's variables are more than names - they do hold type

Re: A class question

2007-10-29 Thread Donn Ingle
While Java's variable declarations bear a superficial (syntactical) similarity to C, their semantics is in fact equivalent to the object-reference semantics we know in Python. I come from Z80A/GWBASIC/VB and a little C, I would describe a Python variable as a pointer - in that it contains the

class question

2007-03-17 Thread sittner
Hello there, i am pretty new to object-oriented programming and i have a question: let's say i have a simple class such as: class father: age=... name= def abcd. class son(father): age= name= def efgh: or any other heirarchic

Re: class question

2007-03-17 Thread Scott David Daniels
[EMAIL PROTECTED] wrote: Hello there, i am pretty new to object-oriented programming and i have a question: let's say i have a simple class such as: class father: age=... name= def abcd. class son(father): age= name=

newbie class question

2005-11-23 Thread vida00
Hi, I scouted the ng for someone w/ a similar problem and couldn't find one, so I might be thinking about this probable non-issue in a wrong way. What I am trying to accomplish should be pretty self explanatory when looking at the following: class heh(object): ... def __init__(self): ...

Re: newbie class question

2005-11-23 Thread vida00
[EMAIL PROTECTED] wrote: Hi, I scouted the ng for someone w/ a similar problem and couldn't find one, so I might be thinking about this probable non-issue in a wrong way. What I am trying to accomplish should be pretty self explanatory when looking at the following: class heh(object):

Re: newbie class question

2005-11-23 Thread Diez B. Roggisch
What I am trying to accomplish should be pretty self explanatory when looking at the following: It seems to me that what you are after is a nested or inner class like in JAVA. You can't do that in the same way as in JAVA, as nested classes in python don't know about their surrounding

Re: newbie class question

2005-11-23 Thread Mike Meyer
[EMAIL PROTECTED] writes: Sorry folks, this is what I meant: class heh(object): ... def __init__(self): ... self.foo='hello' ... def change(self): ... self.foo+=' world' ... def show(self): ... return self.foo ... ... class hih(object): ...

Python COM Class Question

2005-03-09 Thread pemo
I'm trying to use difflib.py from a COM aware language - and, for ease of use, I'm initially trying to get this going from VB6. I've wrappered difflib.py correctly I think, and I can now call into it and call a global method (called 'test' of course). Here's the consuming code: Dim

Re: Python COM Class Question

2005-03-09 Thread Steve Holden
pemo wrote: I'm trying to use difflib.py from a COM aware language - and, for ease of use, I'm initially trying to get this going from VB6. I've wrappered difflib.py correctly I think, and I can now call into it and call a global method (called 'test' of course). Here's the consuming code: