Python crashed when importing SOAPpy, printing out 'usage:copy source destination'

Fredrik Lundh fredrik at pythonware.com
Sat Oct 28 11:19:02 CEST 2006


jiang.haiyun at gmail.com wrote:

> when i import SOAPpy, the python crashed and print out 'usage:copy
> source destination'.
> As follows:
> ############################
> haiyun# python
> Python 2.4.1 (#2, Mar 28 2006, 21:00:14)
> [GCC 3.4.2 [FreeBSD] 20040728] on freebsd5
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import SOAPpy
> usage:copy source destination
> #############################
> Then i checked and found that in my pwd there is a .py file,
> i guess it is this file caused the problem.
> the file content is as follows:
> ############################
> haiyun# cat a.py
> #!env python
> usage="usage:copy source destination\n"
> import sys
> len=len(sys.argv)
> if len!=3 :
>         print usage
>         sys.exit()
> ################end#########
> 
> So the python will crash when i import SOAPpy if working in a dir
> containing this .py file,
> and if rename the .py file to another type , say .txt, the problem
> dispeared.
> 
> Who can tell me what's the problem.

this is how things work: Python doesn't distinguish between script
files and module files; a module is simply a script that defines a
bunch of things.

if you want to create something that can work both as a script and a 
module, see:

    http://effbot.org/pyfaq/tutor-what-is-if-name-main-for.htm

</F>




More information about the Python-list mailing list