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:
- Creating multiple python dictionaries from a file
- Invalid Syntax and I don't know why
- Immutable vs Mutable types
- Binning a column with Python Pandas
- multiple prints on the same line in Python
- How to plot and annotate a grouped bar chart
- Why do I get a “referenced before assignment” error when assigning to a global variable in a function?
- Getting the docstring from a function
- negative zero in python
- How to make scipy.interpolate give an extrapolated result beyond the input range?
- Django multi tenancy
- Can you list the keyword arguments a function receives?
- Django – How to make a variable available to all templates?
- Get number of items from list (or other iterable) with certain condition
- Passing a matplotlib figure to HTML (flask)
- ValueError: malformed string when using ast.literal_eval
- Pythonic way of detecting outliers in one dimensional observation data
- How to remove square brackets from list in Python? [duplicate]
- Pytorch – RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed
- How to stop Python closing immediately when executed in Microsoft Windows
- Running sum in pandas (without loop)
- Recursive directory download with Paramiko?
- How do I read text from the Windows clipboard in Python?
- Sorting list according to corresponding values from a parallel list [duplicate]
- Python version
- How to run a python script from IDLE interactive shell?
- Converting xml to dictionary using ElementTree
- Detecting thresholds in HSV color space (from RGB) using Python / PIL
- Counting depth or the deepest level a nested list goes to
- What is the difference between super() with arguments and without arguments?