[Tutor] all right students, what do we learn
crk at godblessthe.us
Sun Nov 2 06:43:43 CET 2014
To prove that a little knowledge is a little stupid or something to that
# for key in key_list:
# if key not in key_list0:
# print("Error:", key, "not available, start again")
# get_new_list = True
# else: get_new_list = False
Assume key_list0 = [('a', 'Ask'), ('y', 'Dividend Yield')]
The above worked when key_list was 'a y' or 'hhh'
Well, if a little cool was good why not use all of my new found knowledge of
So I head down the path of all sorts of variations of the following. And I
mean all sorts. Instead of [reenter, key_columns] I used a single list.
Instead of the exec('reenter = True') I used a simple reenter=True (and an
eval and compile which I don't totally understand yet). Turns out that
python doesn't seem to like an assignment in the overall if clause - error.
Weird thing, entering a y would make the final print spit out (False,
'a') (False, 'o') but the entry of hhh caused the final print to spit out
 (in the best of the various experiments. Which I don't quite understand.
The reason is because I set up the if statement to be True either way. With
an a it would go thru and create the proper output. But with hhh the
print prints out the Error:.., and I was hoping the assignment of True to
reenter would create a True which would make it out to the while. But it
won't. I think I have to just stay with the more verbose as above. Besides
after trying so many variations the comprehension was getting rather
But really grok comprehension a lot better.
key_list = input('Please enter space separated keys in the order you
[reenter, key_columns ]=[(reenter, key) for key in key_list if ((key in
key_list0)) or (print("Error:", key, "not available, start again") and
exec('reenter = True', ))]
You can tell the caliber of a man by his gun--c. kirkwood
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor