I get UnboundLocalError: local variable 'x' referenced before assignment. That's strange, I'd expect the first print statement to print 10, not generate an exception.
On 10 September 2013 10:39, Anand Chitipothu <anandol...@gmail.com> wrote: > On Tue, Sep 10, 2013 at 10:37 AM, Ramchandra Apte <maniandra...@gmail.com > >wrote: > > > On 10 September 2013 10:21, Anand Chitipothu <anandol...@gmail.com> > wrote: > > > > > On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj <sha...@agiliq.com> > wrote: > > > > > > > This is a popular talk on quircks of ruby/js > > > > > > > > https://www.destroyallsoftware.com/talks/wat > > > > > > > > What are the quircks/unexpected behavior you find in Python? (Aka > > Python > > > > "wats"). > > > > > > > > > > x = 10 > > > > > > class Foo: > > > print x > > > x = 0 > > > print x > > > del x > > > print x > > > > > > # wat? > > > _______________________________________________ > > > BangPypers mailing list > > > BangPypers@python.org > > > https://mail.python.org/mailman/listinfo/bangpypers > > > > > > > I fail to see how that is a "wat", it worked as I expected. (x is defined > > in the the scope of Foo, then deleted, so then the last print x will > > display 10) > > > > Try replacing class Foo: with def foo(): and see what happens. > > Anand > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > https://mail.python.org/mailman/listinfo/bangpypers > _______________________________________________ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers