[Python-ideas] Simple class initialization

Bruce Leban bruce at leapyear.org
Sun Apr 17 02:46:42 CEST 2011


For:

def __init__(self, pid:pid, ppid:ppid, cmd:cmd, _fd:fd, reachable:reachable,
user:user)


This either conflicts with parameter annotations or you've got the
annotation on the wrong side (and annotations are expressions so this won't
work). I had a similar idea to what Chris Rebert suggested:

from somewhere import auto_init
@auto_init
def __init__(self, pid, ppid, cmd, fd:[auto_init.private], reachable:[
auto_init.skip], user:[auto_init.name('user_name')])
   blah


The annotation auto_init.private is equivalent to auto_init.name('_'+*
parameter_name*).

Note that I wrote fd:[auto_init.private] instead of auto_init.private. One
of the strange aspects (to me) of parameter annotations is that they have no
semantics which opens them up to multiple conflicting uses. If we
standardize on a convention that the annotation is a list (or tuple)
of annotations, then this leads us to usage like

foo:[auto_init.name('bar'),constraint.non_negative,etc].


--- Bruce
*New! *Puzzazz newsletter: http://j.mp/puzzazz-news-2011-04 including April
Fools!
*New!** *Blog post: http://www.vroospeak.com Ironically, a glaring Google
grammatical error
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110416/a18d9b29/attachment.html>


More information about the Python-ideas mailing list