Question mark in variable and function names
m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Wed Oct 6 17:49:46 CEST 2004
Andr? N?ss wrote:
> One thing I liked about Lisp was the ability to use the question mark
> (and the exclamation mark) in function names. I found this
> particularily useful when checking boolean properties of a object like
> for example myObj.isContextSet. It just feels so much more natural to
> write myObj.contextSet?
> I also found it neat that destructive operations were clearly marked
> with !.
> Is there anything preventing this from being possible in Python?
The fact that Guido has different aesthetic preferences than you do? And
personally I would call it obj.is_context_set() so we have different
preferences too <wink>.
Actually, the "Pythonic" way of doing it might be to do a try/except
block that assumes it's a context set. Another alternative is to just
have an attribute called context_set, which could actually be a
descriptor that calls another function...
> One of the things I really love about Python is the way it feels when
> I type it. It just comes completely natural to write "for foo in bar"
> and then push the colon, all those curly braces on the other hand
> always feel awkward.
More information about the Python-list