Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Veek. M" Newsgroups: comp.lang.python Subject: Re: exec "x = 3; print x" in a - How does it work? Date: Wed, 09 Mar 2016 11:51:50 +0530 Organization: Home Lines: 54 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Date: Wed, 9 Mar 2016 06:18:44 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d79aca86af8f98f0a505cf6aa929e91b"; logging-data="6872"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18WVJCDDtuN0bprWmlGRkB6" User-Agent: KNode/4.14.1 Cancel-Lock: sha1:sj2KpyyfDq8X7lXtJXQZxj7pXRg= Xref: csiph.com comp.lang.python:104388 Ben Finney wrote: > "Veek. M" writes: > >> What is the return value of `exec`? > > You can refer to the documentation for questions like that. > > >> 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.