Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104388
| From | "Veek. M" <vek.m1234@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: exec "x = 3; print x" in a - How does it work? |
| Date | 2016-03-09 11:51 +0530 |
| Organization | Home |
| Message-ID | <nbof84$6mo$1@dont-email.me> (permalink) |
| References | <nboc29$up4$1@dont-email.me> <mailman.68.1457502660.15725.python-list@python.org> |
Ben Finney wrote: > "Veek. M" <vek.m1234@gmail.com> writes: > >> What is the return value of `exec`? > > You can refer to the documentation for questions like that. > <URL:https://docs.python.org/3/library/functions.html#exec> > >> Would that object be then used to iterate the sequence in 'a'? > > The ‘for’ or ‘while’ statements are correct for iteration. > >> I'm reading this: >> https://www.python.org/download/releases/2.2.3/descrintro/ > > Why? > Well, i had a question on MRO and asked on freenode #python and they suggested i read that. My question was: class A(x, y, z): pass class x(q,w,r) pass I wanted to know how the __mro__ would be generated (c3 linearization) I had assumed when using super() it would do: x, q, w, r, y, z, object basically hit a base class and finish with all it's parents before stepping to the next sibling But then i read somewhere else that it's like this: x, y, z, q, w, r, object and of course if q has base-classes then: x, y, z, q, w, r, e, f, g which is utterly confusing because you can't tell by looking where e, f, g are coming from (q) in this case.. This doc: https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ I was getting all cross-eyed reading this: 'The ancestor tree for our new class is: LoggingOD, LoggingDict, OrderedDict, dict, object. For our purposes, the important result is that OrderedDict was inserted after LoggingDict and before dict! This means that the super() call in LoggingDict.__setitem__ now dispatches the key/value update to OrderedDict instead of dict.' I was wondering why they had chosen this notation over the other. And if you're wondering why that paper - because i was reading Beazley super() pg 120 and the whole hard-coding avoided using super() bit.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
exec "x = 3; print x" in a - How does it work? "Veek. M" <vek.m1234@gmail.com> - 2016-03-09 10:57 +0530
Re: exec "x = 3; print x" in a - How does it work? Ben Finney <ben+python@benfinney.id.au> - 2016-03-09 16:50 +1100
Re: exec "x = 3; print x" in a - How does it work? "Veek. M" <vek.m1234@gmail.com> - 2016-03-09 11:51 +0530
Re: exec "x = 3; print x" in a - How does it work? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-03-09 16:54 +1100
Re: exec "x = 3; print x" in a - How does it work? "Veek. M" <vek.m1234@gmail.com> - 2016-03-09 11:55 +0530
Re: exec "x = 3; print x" in a - How does it work? Chris Angelico <rosuav@gmail.com> - 2016-03-09 17:34 +1100
csiph-web