python - how to tell a variable is iterable but not a string -


I have a function that takes an argument that can be either an item or a double item:

  DEF iterative (RGR) if #arg is a walkable: print "yes" and: print "no"  

is such that:

Yes >>> Iterated (["F", "F"]) Yes >>> Not repeat ("FF")

The problem is that the string is technically permeable, so when I'm trying to arg [1] Not just ValueError could not hold I do not want to use isinstance (), because it has told me is not good practice (either).

Use utility (I do not think why it is bad behavior)

  is not an import type if it is not (arg, types.StringTypes):  

Note that the use of string type ensures that we have some ambiguous type of string Do not forget about

On the top, this derived string also works for sections.

Pre-< MyString (str): Passed Evernance (Mysterrine (""), Type. String Type) # True

In addition, Want to keep an eye on

Cheers.

NB: Behavior has not been changed to string type and basestring in Python 3. According to your requirements, you can convert them to isinstance in a subset of str , or (str, bytes, unicode) in the example , e.g. . As mentioned for Cython users, you can also use six .


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -