Calling string on a python list calls the __repr__
method on each element inside. For some items, __str__
and __repr__
are the same. If you want that behavior, do:
def __str__(self):
...
def __repr__(self):
return self.__str__()
More Related Contents:
- How do I put a variable’s value inside a string?
- Configure Flask dev server to be visible across the network
- Install a Python package into a different directory using pip?
- Remove duplicate dict in list in Python
- How to scp in Python?
- Printing all instances of a class
- Passing functions with arguments to another function in Python?
- In Python, how can you load YAML mappings as OrderedDicts?
- Hashing a dictionary?
- Right way to reverse a pandas DataFrame?
- What’s the best practice using a settings file in Python? [closed]
- pip is not able to install packages correctly: Permission denied error [duplicate]
- Why use sys.path.append(path) instead of sys.path.insert(1, path)?
- Vectorized look-up of values in Pandas dataframe
- Removing the timestamp from a datetime in pandas dataframe
- Send http request through specific network interface
- parsing XML file gets UnicodeEncodeError (ElementTree) / ValueError (lxml)
- Union find implementation using Python
- Script to change ip address on windows
- OSError geos_c could not be found when Installing Shapely [duplicate]
- How Can I Update a Qml Object’s Property from my Python file?
- Creating a custom categorized corpus in NLTK and Python
- Difference between dir(…) and vars(…).keys() in Python?
- Python: Using xpath locally / on a specific element
- How to declare a static attribute in Python?
- How to install python3.7 and create a virtualenv with pip on Ubuntu 18.04?
- ImportError: DLL load failed when importing Numpy installed in conda virtual environment
- Django 1.9 ImportError for import_module
- countplot() with frequencies
- Changing position of vertical (z) axis of 3D plot