Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

override python print for class

>>> class Test:
...     def __repr__(self):
...         return "Test()"
...     def __str__(self):
...         return "member of Test"
... 
>>> t = Test()
>>> t
Test()
>>> print(t)
member of Test
Comment

PREVIOUS NEXT
Code Example
Python :: post to instagram from pc python 
Python :: robust scaler 
Python :: tkinter prevent window resize 
Python :: conda python update 
Python :: exit in python 
Python :: python checking if something is equal to NaN 
Python :: python __init_subclass__ 
Python :: RuntimeError: Broken toolchain: cannot link a simple C program 
Python :: find duplicates in python list 
Python :: live plot loss 
Python :: pymongo [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate 
Python :: python range in reverse order 
Python :: make pickle file python 
Python :: django.db.utils.ProgrammingError: relation "users" does not exist in django 3.0 
Python :: import math sqrt python 
Python :: custom signal godot 
Python :: python basic flask app 
Python :: create limit using matplotlib 
Python :: python to excel 
Python :: how to reverse a list in python without using inbuilt function 
Python :: python get file name without dir 
Python :: convert datetime to date python 
Python :: python multiline string 
Python :: batchnormalization keras 
Python :: how to rotate screen with python 
Python :: get absolute url django 
Python :: number of unique pairs in columns pandas 
Python :: pip install python-telegram-bot 
Python :: django set random password 
Python :: get name of variable python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =