"Sullivan WxPyQtKinter" wrote:

> In IDLE, this py file work all right. But if I launch python
> interpretor in the command shell like this:
>
>
> C:\Documents and Settings\Xiaozhong Zheng>python "C:\Documents and
> Settings\Xiaozhong Zheng\Desktop\t.py"
>
> The interpretor would not find the file.

open("ticket.txt") means "look for ticket.txt in the current directory",
not in the directory where the PY file lives.  if you change to the Desk-
top directory before you run the Python interpreter, your script should
work as expected.

to fix this, you can

- use a full path

or

- use os.path.basedir(__file__) to get the directory where the module
  lives, and do something like

        root = os.path.basedir(__file__)
        ticketfile = os.path.join(root, "ticket.txt")
        f = open(ticketfile)

</F>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to