About 51 results
Open links in new tab
  1. What is the purpose of using str [i]-'0' where str is a string?

    The part str[i] - '0' takes the ASCII character of the corresponding digit which are sequentially "0123456789" and subtracts the code for '0' from the current character. This leaves a number in the …

  2. c - What does str [i - 1] == ' ' mean? - Stack Overflow

    Jun 12, 2020 · 1 " What does str[i - 1] == ' ' mean? " ' ' is a character constant for the white space character (ASCII value 32). str is a pointer to char in the caller. (Practically thinking, it should point to …

  3. python - Meaning of a function "-> str" - Stack Overflow

    In your example, you function is expecting ham of type str, and eggs of type str (defaulting to eggs). The final -> str implies that this function, should have a return type of str as well.

  4. How to define a __str__ method for a class? - Stack Overflow

    In Python, the object class serves as the root superclass for all the (new-style) classes. By default at least, applying str and repr to the "class instance" of any subclass of object produces the...

  5. python - AttributeError: 'str' object has no attribute 'str' - Stack ...

    Jan 15, 2019 · AttributeError: 'str' object has no attribute 'str' Asked 7 years ago Modified 7 years ago Viewed 80k times

  6. Metodo __str__ en una clase en Python, para que sirve?

    Apr 27, 2022 · mi duda es para que sirve el metodo str agregado en la clase de Persona? actua como un metodo que solo muestra todos los atributos o metodos de la clase Padre o tiene otra …

  7. What is the purpose of __str__ and __repr__? - Stack Overflow

    Called by the str() built-in function and by the print statement to compute the "informal" string representation of an object. Use __str__ if you have a class, and you'll want an informative/informal …

  8. 'str' object does not support item assignment - Stack Overflow

    I would like to read some characters from a string s1 and put it into another string s2. However, assigning to s2[j] gives an error: s2[j] = s1[i] # TypeError: 'str' object does not support item

  9. Relationship between string module and str - Stack Overflow

    Jan 8, 2010 · There is some overlap between the string module and the str type, mainly for historical reasons. In early versions of Python str objects did not have methods, so all string manipulation was …

  10. How to use __str__ function to return a string representation of a class

    May 23, 2022 · I have been tasked with creating an inventory manager in python, and one of the required is to define the following function within the class: __str__ - This function returns a string …