New to python and I'm trying to save and import my first modules. When I go to import my first module which I've named convert.py I receive the following error:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import convert
File "C:\Python27\convert.py", line 1
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
^
SyntaxError: invalid syntax

I guess my question is am I saving it wrong? Importing wrong?

I'm using IDLE as a text editor and when I'm done typing the module I go to save as ---> and save as file name: convert.py save as type: Python and text files (*.py. *.pyw, *.txt). When importing I'm simply typing ---> import convert.

And what is contents of the line 1, the interpreter complains about.

You need to save your code file from the editor of IDLE not the dang Python shell! That Python shell is one of the worst traps for beginners.

Do us a favor and take a look at:
http://www.daniweb.com/forums/thread20774.html

Line 1 of your convert.py says 'on win32'?

I guess that's not valid python code, and thats why the import is failing.

Cheers and Happy coding

You need to save your code file from the editor of IDLE not the dang Python shell! That Python shell is one of the worst traps for beginners.

Do us a favor and take a look at:
http://www.daniweb.com/forums/thread20774.html

Thanks alot! That did it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.