About 50 results
Open links in new tab
  1. python - How to check if type of a variable is string? - Stack Overflow

    Jan 30, 2011 · Is there a way to check if the type of a variable in python is a string, like: isinstance(x,int); for integer values?

  2. python - Convert a str to path type? - Stack Overflow

    Jul 22, 2021 · What is path.path? Sounds like a class that is defined by the code you are using; it's not a standard type or class. Prior to Python 3.4, there was no standard for paths; functions operating on …

  3. Convert a python 'type' object to a string - Stack Overflow

    Jul 3, 2022 · I'm wondering how to convert a python 'type' object into a string using python's reflective capabilities. For example, I'd like to print the type of an object print ("My type is " + type (

  4. How to find out if a Python object is a string? - Stack Overflow

    Aug 20, 2009 · Python 2 To check if an object o is a string type of a subclass of a string type: isinstance(o, basestring) because both str and unicode are subclasses of basestring. To check if the …

  5. python - Lexical cast from string to type - Stack Overflow

    Apr 23, 2015 · Recently, I was trying to store and read information from files in Python, and came across a slight problem: I wanted to read type information from text files. Type casting from string to int or to...

  6. String-based enum in Python - Stack Overflow

    Oct 29, 2019 · Formatted string literals, str.format (), and format () will use the mixed-in type’s format () unless str () or format () is overridden in the subclass, in which case the overridden methods or …

  7. python - What is the difference between <class 'str'> and <type 'str ...

    Feb 5, 2017 · Python changed the text representation of type objects between python 2 (Types are written like this: <type 'int'>.) and python 3 (Types are written like this: <class 'int'>.).

  8. Python 3 string to hex - Stack Overflow

    In Python 3, all strings are unicode. Usually, if you encode an unicode object to a string, you use .encode('TEXT_ENCODING'), since hex is not a text encoding, you should use codecs.encode() to …

  9. string - Typecasting in Python - Stack Overflow

    Dec 22, 2008 · I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings. How can I do this?

  10. python - What exactly do "u" and "r" string prefixes do, and what are ...

    There are two types of string in Python 2: the traditional str type and the newer unicode type. If you type a string literal without the u in front you get the old str type which stores 8-bit characters, and with the …