[Pyobjc-dev] Calling methods on nil
Brought to you by:
ronaldoussoren
From: Dinu G. <gh...@da...> - 2003-05-06 14:11:07
|
Ok, I'm looking deeper into the documentation.... so here we go! Item 2 in pyobjc/Doc/warts.html currently says: In objective-C it is valid to call methods on nil, these calls will be ignored. The nil 'object' is mapped to None and None will not ignore method calls, but will most likely raise an AttributeError. You'll have to remember this when translating from Objective-C to python. This might lead to people who are trying to convert Cocoa code to Python to change the application logic. I remember I wrote a Null class that would behave as much as a "black whole" as possible. It's in the O'Reilly Python Cookbook and available online here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68205 This might benefit from some more detailed inspection using ver- sion 2.3 of Python, which I haven't done, yet. I might be possible to replace the current None (as currently con- verted from nil) with a singleton Null instance, possibly as an option only, if the code rewriting ever becomes more of a real issue... I know that it can be very convenient in some cases if "nothing" happens in a well-defined way! ;-) Regards, Dinu -- Dinu C. Gherman ...................................................................... "Les gens se divisent en deux cat=E9gories=A0: les uns cherchent et ne trouvent pas, les autres trouvent et ne sont pas contents." (Mihail Eminescu)= |