Re: [Pyobjc-dev] Calling methods on nil
Brought to you by:
ronaldoussoren
From: Just v. R. <ju...@le...> - 2003-05-06 14:18:43
|
Dinu Gherman wrote: > 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! ;-) -1. It may be the ObjC way, but it's not the Python way. Remember we're using Python to use Cocoa and not to write ObjC with a nicer syntax... Just |