Hello,
I am just starting learning Python and I am having some trouble properly importing a function from a module.
I wrote the short script:
def print_twice(param):
print(param, param)
When I try to import the function print_twice, the shell tells me it cannot import the name print_twice.
When I choose "run module" from the "window" menu, it works fine.
Why is it telling me it cannot import the name print_twice?
This is copied and pasted from the shell (first I try to import, then I "restart" and run the module):
Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import os
>>> os.chdir('/Users/3FLryan/Documents/Programming/Python/HTLCS')
>>> from test import print_twice
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from test import print_twice
ImportError: cannot import name print_twice
>>> ================================ RESTART ================================
>>>
>>> print_twice('spam')
spam spam
The current directory is correct.
Thanks!