kevin parks wrote:
This discussion is making my brain melt.
It is also showing how clever Bob was to do it the way he did... I found
a solution that i think works, and think has not yet been suggested. I
quarantined Bob's code into a black box ... and then cast the output as
a plain old fashioned python built in dictionary on output. So now
instead of printing the code Bob gave the collection is returned by the
func.
Then i can cast it as a dict and pick over that dictionary as i wish.
Here (as a bonus) I can transverse a range of keys that is inclusive of
all my keys and also use python's get() dict method to also indicate
index points (keys) that are empty.. which by default returns 'None',
which is also useful in this case to show me what is missing. But I also
have to do some type testing tomfoolery since missing keys return None,
which is a special type (and not a list like the others)... I wanted the
value list sorted so... i did if type(item) == type(foo): .... not sure
if there is a betterererer way.
You can use:
alist = [1, 2, 3]
if isinstance(alist, list):
...
or alternatively check for the None case:
if alist is not None:
...
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor