forked from bantosik/python_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_features.py
More file actions
33 lines (27 loc) · 761 Bytes
/
python_features.py
File metadata and controls
33 lines (27 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import collections
Point = collections.namedtuple('Point', ['x', 'y'])
class Student(object):
def __init__(self, imie, nazwisko, ident):
self.imie = imie
self.nazwisko = nazwisko
self.ident = ident
def __str__(self):
return "Imie %s, Nazwisko %s" % (self.imie, self.nazwisko)
def swap_names(self):
self.imie, self.nazwisko = self.nazwisko, self.imie
if __name__ == "__main__":
d = {}
d['imie'] = 'Jeff'
d['nazwisko'] = 'Bridges'
d['ident'] = 0
s = Student('Bartek', 'Antosik', 152814)
dude = Student(**d)
print s, dude
s.swap_names()
p = Point(4,5)
t = (6, 4)
o = Point(*t)
print p
if p.x < p.y:
print "Druga wspolrzedna wieksza"
print s