Phil <phil_...@bigpond.com> writes:

> 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?

In other words, why is the data such that you *need* to know whether it
is a set versus a string, before using it? Can the data be handled
differently such that the condition you describe isn't a prerequisite?

> For example, if c is a character and s is a set with only one member.

Note that “a character” and “an empty string” and “three characters” are
all values that have the exact same type: the ‘str’ type.

Similarly, “a set with only one member” and “a set with two dozen
members” and “an empty set” are all values that are of the same type:
the ‘set’ type.

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.

-- 
 \         “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\        Brain, but this time *you* put the trousers on the chimp.” |
_o__)                                           —_Pinky and The Brain_ |
Ben Finney

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to