Creating commands with Python

Christopher A. Craig ccraig at ccraig.org
Wed Apr 25 16:20:46 EDT 2001


costas at meezon.com writes:

> Is there a way in Python to define new keyworded commands. For example
> Python has the "import  from" command. 

No.

> If not, why does Python have this inconsitent keyword based command? 

It is consistent.  "del <object>"  is also keyword based.  In both of
these cases making the commands functions would be deceptive.

import(foo,bar)

would mean that "foo" and "bar" existed before the import function was
call and

del(foo)

means that a reference to "foo" must still exist after the del function
has returned (thus negating the purpose of the command).  There is no
legitimate way to do del with a function, and the only way I can see
to do import would be something similar to

bar = import("foo", "bar")

which is silly.

-- 
Christopher A. Craig <ccraig at ccraig.org>
"When all else fails, manipulate the data."



More information about the Python-list mailing list