makes sense that the RHS of the equality (deafult value) should be evaluated before the LHS (arg name + type) but if you hadn't pointed out that something was not as you expected, i would not have paid attention and anticipated as you did. Then again RHS vs LHS might have nothing to do with the reason that the interpreter evaluates in this order :)
On Fri, 19 May 2017 at 21:59 Chris Angelico <ros...@gmail.com> wrote: > On Sat, May 20, 2017 at 11:42 AM, Gregory Ewing > <greg.ew...@canterbury.ac.nz> wrote: > > Steve D'Aprano wrote: > >> > >> On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote: > >> > >>> I *thought* python 3.0 to 3.4 would *ignore* annotations, but it > >>> doesn't... > >> > >> > >> Why would you think that? > > > > > > Ever since Guido retconned the purpose of annotations to be > > for static type hinting *only*, it would make more sense for > > the interpreter to ignore them, or at least not evaluate them > > immediately at run time (since it would avoid all the problems > > of forward references, etc). > > > > So I can see how someone relying on the principle of least > > surprise might assume that. > > They're function metadata. What would the principle of least surprise > say about this? > > print("Spam") > def func(arg: print("Foo") = print("Quux")): > print("Blargh") > print("Fred") > func() > print("Eggs") > > What should be printed, and in what order? > > Actually, Python does violate least-surprise in one area here. There's > one message that gets printed "out of order" compared to my > expectation. I wonder if it's the same one that other people will be > surprised at. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > -- Oliver My StackOverflow contributions My CodeProject articles My Github projects My SourceForget.net projects -- https://mail.python.org/mailman/listinfo/python-list