newbie: why it does not work: command=sys.exit?

Kirk Strauser kirk at strauser.com
Sun May 23 19:40:08 EDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 2004-05-23T22:54:53Z, "Paul van Dam" <paul.van.dam at planet.nl> writes:
> import sys
> widget = Button(None, text='Hello widget world', command = sys.exit)


> Traceback (most recent call last):
>   File "I:\Python\Projecten\#Prog_in_Python\Hfst06\gui02.py", line 5,
> in -toplevel-
>     widget.mainloop()
>   File "D:\Python23\lib\lib-tk\Tkinter.py", line 965, in mainloop
>     self.tk.mainloop(n)
>   File "D:\Python23\lib\lib-tk\Tkinter.py", line 1347, in __call__
>     raise SystemExit, msg
> SystemExit

- From "pydoc sys.exit"

    Help on built-in function exit in sys:

    sys.exit = exit(...)
        exit([status])

        Exit the interpreter by raising SystemExit(status).  If the status
        is omitted or None, it defaults to zero (i.e., success).  If the
        status is numeric, it will be used as the system exit status.  If it
        is another kind of object, it will be printed and the system exit
        status will be one (i.e., failure).

The documentation says that calling sys.exit raises a SystemExit exception.
Your program calls sys.exit and gets a SystemExit exception.  It seems to be
working as expected and documented, unless I'm missing something.
- -- 
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAsTXZ5sRg+Y0CpvERAthNAKCSCOtUsv/6eX4TU+ka0c93tOISrQCfRbRz
XvgGK2Kzu137pw4bNlWk7/k=
=mWAd
-----END PGP SIGNATURE-----



More information about the Python-list mailing list