On 09/19/10 17:31, Seebs wrote: > Basically, think of what happens as I read each symbol: > > x = x + 1 if condition else x - 1 > > Up through the '1', I have a perfectly ordinary assignment of a value. > The, suddenly, it retroactively turns out that I have misunderstood > everything I've been reading. I am actually reading a conditional, and > the things I've been seeing which looked like they were definitely > part of the flow of evaluation may in fact be completely skipped.
Seems like you've got a much more complicated parser than I do. You can read code from top-down, bottom-left; doing that would require keeping a mental stack of the contexts of code all the time; that's something I can't do. What I normally do when reading code is to first scan the overall structure first, then zoom in to the interesting parts until I get to an atomic structure (something I can understand in a quick glance). I'd then agglutinate some of the atoms into bigger chunks that I don't read in detail anymore. Reading code left-right is too difficult for me since then, you'd have to keep a stack that tracks how many logical parentheses (i.e. how deep in the code structure) you've seen and their types. -- http://mail.python.org/mailman/listinfo/python-list