[Tutor] def problem
Gregor Lingl
glingl@aon.at
Mon, 11 Jun 2001 21:26:05 +0200
--------------8BBF5159477132DCF7019982
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Ron schrieb:
> I'm having problems with "def". Here's what I put in and save as
> "test122" def here():
> print "hello"
> print
> print "that was a space" This is what I get. >>> import test123
> >>> here()
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in ?
> here()
> NameError: name 'here' is not defined
> >>>
you have to call (qualified):
>>> test123.here()
hello
that was a space
>>>
or to import this way:
>>> from test123 import *
>>> here()
hello
that was a space
>>>
Gregor
--------------8BBF5159477132DCF7019982
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body bgcolor="#FFFFFF">
<p>Ron schrieb:
<blockquote TYPE=CITE><style></style>
<font face="Arial"><font size=-1>I'm
having problems with "def". Here's what I put in and save as "test122"</font></font> <font face="Arial"><font size=-1>def
here():</font></font>
<br><font face="Arial"><font size=-1> print "hello"</font></font>
<br><font face="Arial"><font size=-1> print</font></font>
<br><font face="Arial"><font size=-1> print "that was
a space"</font></font> <font face="Arial"><font size=-1>This is what
I get.</font></font> <font face="Arial"><font size=-1>>>> import test123</font></font>
<br><font face="Arial"><font size=-1>>>> here()</font></font>
<br><font face="Arial"><font size=-1>Traceback (most recent call last):</font></font>
<br><font face="Arial"><font size=-1> File "<pyshell#1>", line
1, in ?</font></font>
<br><font face="Arial"><font size=-1> here()</font></font>
<br><font face="Arial"><font size=-1>NameError: name 'here' is not defined</font></font>
<br><font face="Arial"><font size=-1>>>></font></font></blockquote>
<p><br><tt>you have to call (qualified):</tt><tt></tt>
<p><tt>>>> test123.here()</tt>
<br><tt>hello</tt><tt></tt>
<p><tt>that was a space</tt>
<br><tt>>>></tt><tt></tt>
<p><tt>or to import this way:</tt>
<br><tt>>>> from test123 import *</tt>
<br><tt>>>> here()</tt>
<br><tt>hello</tt><tt></tt>
<p><tt>that was a space</tt>
<br><tt>>>></tt><tt></tt>
<p><tt>Gregor</tt>
</body>
</html>
--------------8BBF5159477132DCF7019982--