Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

__str__ method python

class Person:
    def __init__(self, first_name, last_name, age):
        self.first_name = first_name
        self.last_name = last_name
        self.age = age

    def __str__(self):
        return f'Person({self.first_name},{self.last_name},{self.age})'
Code language: Python (python)
Comment

__str__

def __str__(self):
        return self.name
Comment

__str__python

The __str__ method in Python represents the class objects as a string – it can be used for classes. 
This method is called when print() or str() function is invoked on an object. This method must return the String object.
Comment

PREVIOUS NEXT
Code Example
Python :: odoo scaffold 
Python :: sha512 python 
Python :: pandas select 2nd row 
Python :: check for missing values in pandas 
Python :: delete nans in df python 
Python :: only get top 10 python dataframe 
Python :: calculate days between two dates python 
Python :: python repeting timer 
Python :: display values on top of seaborn bar plot 
Python :: splitting a number into digits python 
Python :: how to download instagram profile picture with the help of python 
Python :: convert list to generator python 
Python :: render template in django 
Python :: replace string if it contains a substring pandas 
Python :: np.random 
Python :: add system path python jupytre 
Python :: Add Border to input Pysimplegui 
Python :: django models integer field default value 
Python :: form errors in django 
Python :: csv writer python 
Python :: hex python add 0 
Python :: python bitwise operators 
Python :: how to get bot voice channel discord.py 
Python :: batchnorm1d pytorch 
Python :: Python all versions lookup 
Python :: python list prime numbers 
Python :: lower upper in pytho 
Python :: 2d dictionary in python 
Python :: python return min length of list 
Python :: create square matrix python 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =