On 11/23/06, Tony Lownds <[EMAIL PROTECTED]> wrote: > I have a working optional argument syntax implementation, I'm hoping > to get some direction on > the implementation decisions so far.... please see below.
Wow! > Python 3.0x (p3yk:52824M, Nov 23 2006, 09:22:23) > [GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> def f()-> 1: pass > ... > >>> f.func_returns > 1 > >>> def f(): pass > ... > >>> f.func_annotations It would be ok if this returned {} too. (But None is fine too I think.) > >>> f.func_returns > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'function' object has no attribute 'func_returns' I would prefer this to be None. Attributes that don't always exist are a pain to use. > >>> def f(x:1): pass > ... > >>> f.func_annotations > {'x': 1} Very cool! I agree that Phillip's idea for simplification is worth a try. We're generally not too concerned over the cost of function declarations since they typically execute only once per program. As long as it's really cheap when no annotations are present (which would suggest that func_annotations should be None in that case since an empty dict is kind of expensive, at least in memory). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com