[BangPypers] Python "Wat"s

Anand Chitipothu anandology at gmail.com
Tue Sep 10 07:09:32 CEST 2013


On Tue, Sep 10, 2013 at 10:37 AM, Ramchandra Apte <maniandram01 at gmail.com>wrote:

> On 10 September 2013 10:21, Anand Chitipothu <anandology at gmail.com> wrote:
>
> > On Tue, Sep 10, 2013 at 10:14 AM, Shabda Raaj <shabda at 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 at 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


More information about the BangPypers mailing list