tim at johnsons-web.com
Tue Apr 4 03:10:05 CEST 2006
* Alan Gauld <ukc802591034 at btconnect.com> [060403 09:10]:
> > I can't find the defined() function in python, so I used
> >'variable name' in dir()
> > Is it really missing, or I am just so simple ?
> It is really missing, just as it is for most programming languages.
> Which language(s) do you know that has such a feature?
> And why do you consider it so useful that you expect to find
> it in Python?
In rebol, there is a predicate called
Sample console session below:
>> test: [a 1 b 2 c 3]
== [one 1 two 2 three 3]
>> value? test/1
>> value? test/2
== [a 1 b 2 c 3]
Don't as much about lisp as I do rebol and python, but lisp has symbols,
which don't necessarily have values.
> The main place where I could see such a thing being useful
> would be in dynamically loaded code but then the usual
> approach is to load a dictionary and an 'in' check suffices.
Rebol doesn't have dictionaries (it should IMHO), you could also
use value? after importing a module to check if some word existed
in the module namespace.
Kind of like hasattr()
> I'm interested in what use you would make of such a thing?
My business partner is a perl programmer. He uses defined() a lot, I
think, I've seen it in his code....
I use value? a lot in rebol.
I like python's in operator. Very handy
Tim Johnson <tim at johnsons-web.com>
More information about the Tutor