[Pythonmac-SIG] objc methods to pythonese
Ronald Oussoren
ronaldoussoren at mac.com
Thu Mar 23 22:33:07 CET 2006
On 23-mrt-2006, at 20:53, Scott Frankel wrote:
>
> Apologies in advance for this tangential question.
>
> I'm trying to wrap my head around how Objective-C methods are
> constructed -- and more importantly, how they're converted to Python
> methods. Doco I've found uses as an example a method with white
> space between the parts of the method name. Working with Python has
> made me gun shy with respect to white space ;)
>
> Is the white space syntactically significant? i.e.:
>
> [rectangle setWidth:width height:height];
> ^
>
> If I understand correctly, this would translate in Python to:
>
> rectangle = setWidthheight_(width, height)
>
> Correct that the 'h' in the "height" part of the method name is not
> capitalized?
I have no idea what gave you that impression. The pyobjc documentation
clearly states that to translate a method name from Objective-C to
python you take the canonical ObjC name (all parts including colons
appended and without whitepace), e.g. setWidth:height:, and then
replace colons by underscores: setWidth_height_
>
>
>
> How about the following?
>
> - (id)tableView:(NSTableView *)tableView
> objectValueForTableColumn(NSTableColumn *)tableColumn
> row:(int)row
>
> Would this translate like so?
>
> def tableViewobjectValueForTableColumnrow_(tableView,
> tableColumn, row):
tableView_objectValueForTableColumn_row_
Ronald
>
>
>
>
> Thanks in advance! Reminds me of a friend's reverse polish notation
> calculator ...
> Scott
>
>
>
>
>
>
>
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
More information about the Pythonmac-SIG
mailing list