¡@

Home 

python Programming Glossary: basestring

Can anyone help condense this Python code?

http://stackoverflow.com/questions/11921320/can-anyone-help-condense-this-python-code

prop return property_ if isinstance properties basestring properties properties.split for prop in properties setattr klass..

Fastest way to convert a dict's keys & values from `unicode` to `str`?

http://stackoverflow.com/questions/1254454/fastest-way-to-convert-a-dicts-keys-values-from-unicode-to-str

u'and' u'a' u'set' 1 def convert data if isinstance data basestring return str data elif isinstance data collections.Mapping return..

overloading __init__ in python

http://stackoverflow.com/questions/141545/overloading-init-in-python

the datatype it gave you. The problem with isinstance x basestring is that there is no way for the caller to tell you for instance.. tell you for instance that even though the type is not a basestring you should treat it as a string and not another sequence. And..

What's the canonical way to check for type in python?

http://stackoverflow.com/questions/152580/whats-the-canonical-way-to-check-for-type-in-python

in this case you may actually want to use isinstance o basestring because this will also catch Unicode strings unicode is not.. a subclass of str both str and unicode are subclasses of basestring . Alternatively isinstance accepts a tuple of classes. This..

JSON serialization of Google App Engine models

http://stackoverflow.com/questions/1531501/json-serialization-of-google-app-engine-models

datetime import time SIMPLE_TYPES int long float bool dict basestring list def to_dict model output for key prop in model.properties..

Differences between isinstance() and type() in python

http://stackoverflow.com/questions/1549801/differences-between-isinstance-and-type-in-python

else using the argument as if it was of some other type . basestring is however quite a special case a builtin type that exists only.. to let you use isinstance both str and Unicode subclass basestring . Strings are sequences you could loop over them index them.. way all containers lists sets dicts ... in another way and basestring plus isinstance helps you do that the overall structure of this..

Python: check if an object is a list or tuple (but not string)

http://stackoverflow.com/questions/1835018/python-check-if-an-object-is-a-list-or-tuple-but-not-string

improve this question I think assert not isinstance lst basestring Is actually what you want otherwise you'll miss out on a lot..

Flatten (an irregular) list of lists in Python

http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python

for el in x if hasattr el __iter__ and not isinstance el basestring result.extend flatten el else result.append el return result.. isinstance el collections.Iterable and not isinstance el basestring for sub in flatten el yield sub else yield el I used the Iterable..

What is the best (idiomatic) way to check the type of a Python variable? [duplicate]

http://stackoverflow.com/questions/378927/what-is-the-best-idiomatic-way-to-check-the-type-of-a-python-variable

Python - can I detect unicode string language code?

http://stackoverflow.com/questions/4545977/python-can-i-detect-unicode-string-language-code

list of corresponding language codes if isinstance chunks basestring chunks chunks url 'https www.googleapis.com language translate.. list of corresponding language codes if isinstance chunks basestring chunks chunks url 'https www.googleapis.com language translate..

Type of compiled regex object in python

http://stackoverflow.com/questions/6102019/type-of-compiled-regex-object-in-python

up with was for allowed in alloweds if isinstance allowed basestring and allowed input ignored False break elif isinstance allowed..

Suppressing treatment of string as iterable

http://stackoverflow.com/questions/9168904/suppressing-treatment-of-string-as-iterable

item if issubclass item str # issubclass item basestring for Py 2.x return iter item else return iter item for thing..