[Tutor] Running Python in script vs. Idle
brandon w
thisisonlyatest at gmx.com
Mon Jul 25 01:21:58 CEST 2011
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110724/91ae698b/attachment.html>
More information about the Tutor
mailing list