Wish there was an error message
Thomas Wouters
thomas at xs4all.net
Sat Feb 3 21:05:04 EST 2001
More information about the Python-list mailing list
Sat Feb 3 21:05:04 EST 2001
- Previous message (by thread): Wish there was an error message
- Next message (by thread): Wish there was an error message
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Feb 03, 2001 at 12:39:57AM -0000, kwasi007uk at yahoo.co.uk wrote: > But M.quit does not exist. So it should give me an error message? Why > doesn't it? Can I turn it on somehow? M.quit does exist. It's a function or method object. M.quit is simply an attribute access, which yields the object that is 'stored' in the 'quit' attribute of 'M'. If you then 'call' that object, using ()'s, you execute the code. This would do exactly the same: q = M.quit q() As would getattr(M, "quit")() There is nothing special about functions or methods, they are just objects like everything else. In fact, you can create your own class that behaves just like a function, by supplying a __call__ method. -- Thomas Wouters <thomas at xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
- Previous message (by thread): Wish there was an error message
- Next message (by thread): Wish there was an error message
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list