[Baypiggies] A beginner's question on python class
Glen Jarvis
glen at glenjarvis.com
Mon Feb 20 05:45:48 CET 2012
>
> On Sun, Feb 19, 2012 at 6:57 PM, Yiou Li <liyiou at gmail.com> wrote:
>
>> Hi All,
>>
>> I created a python class by inherating from and existing class:
>>
>> myPythonScript.py
>>
>> from standardClass import ClassX
>>
>> Class myClass(ClassX)
>> myVariable
>>
>
> What's your question? By the way, class should be lower case, and you're
> forgetting a semicolon.
>
Let me also add:
I think JJ means that you forgot to put the colon (not semicolon) at the
end of your class definition syntax.
Here is a sample of code that demonstrates. Try this:
class ClassX(object):
pass
class MyClass(ClassX):
my_variable = "Some Content"
my_class = MyClass()
print my_class.my_variable
There are some great books and tutorials that help teach you to use
Python...
G
--
Things which matter most must never be at the mercy of things which matter
least.
-- Goethe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20120219/b5708506/attachment.html>
More information about the Baypiggies
mailing list