Contact: aviboots(AT)netvision.net.il
39,066 questions
50,783 answers
573 users
from collections import namedtuple Point = namedtuple("Point", "x y") p = Point(x=9.23, y=7.18) print(p[0], p[1]) print(p.x, p.y) ''' run: 9.23 7.18 9.23 7.18 '''
class Point: def __init__(self, _x, _y): self.x= _x self.y = _y def PrintPoint(self): print(self.x, self.y) p = Point(5.63, 7.42) p.PrintPoint() ''' run: 5.63 7.42 '''
from dataclasses import dataclass @dataclass class Point: # Constructor x: float y: float p = Point(x=3.42, y=4.91) print(p.x, p.y) ''' run: 3.42 4.91 '''