On Fri, 28 Apr 2017 19:42:36 -0700
"Martin A. Brown" <[email protected]> wrote:
>
> Hello and greetings Phil,
>
> >> I'm trying to implement a conditional branch based on a variable
> >> type.
> >
> >This is often (not always) a mistake, in Python. So the question
> >needs to be asked: What makes you think that condition is a
> >requirement?
> >
> >So, I suspect you will need to explain better what larger problem you
> >are trying to solve, and re-consider whether the condition you're
> >trying to test is actually going to help that purpose.
Thank you Ben and Martin for your detailed replies. I was debating whether or
not to post my question at all because it looked vague, even to me.
This a simplified version of what I had in mind:
alist = [1,2,9,6]
alist[2] = set({4})
for i in range(4):
if i is a set:
do this
1, 2 and 6 are given numbers and the set containing 4 is what I want to operate
on.
My alternative method that I mentioned in my previous question compares each
alist[i] number to another list of given numbers. If alist[i] does not appear
in the given number list then it must be a set. At this point of the program
I'm only interested in sets that have only have one member. Sets with more than
one member are dealt with later.
I'm nearly certain that this is the method that I should continue to pursue,
unless someone can offer a cleverer solution.
--
Regards,
Phil
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor