Python version 2.6.6

I wrote this in Idle and ran it in Idle and it worked fine.

class ExClass:
    eyes = "brown"
    age = 99
    height = '5\'11'
    def thisMethod(self):
        return 'This method works.'

This is me running it in Idle.

>>> ExClass
*<class __main__.ExClass at 0xb5aec2fc>*
>>> x = ExClass()
>>> x.eyes
*'brown'*
>>> x.age
*99*
>>> x.height
*"5'11"*
>>> x.thisMethod()
*'This method works.'*

Then I try to run it from a script in Gnome-terminal and it does not run. I do not get output. I have to add print. to get any output like this:

#!/usr/bin/python

class ExClass:
    eyes = "brown"
    age = 99
    height = '5\'11'
    def thisMethod(self):
        return 'This method works.'

x = ExClass()
x.eyes
x.age
x.height
x.thisMethod()
*print* x.thisMethod()

What is the difference? This is what was confusing me before.

Brandon


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to