Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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)
Source by www.pythontutorial.net #
 
PREVIOUS NEXT
Tagged: #method #python
ADD COMMENT
Topic
Name
2+5 =