http://brain.fuw.edu.pl/edu/index.php?title=TI/Skrypty_z_zaj%C4%99%C4%87/k5&feed=atom&action=history
TI/Skrypty z zajęć/k5 - Historia wersji
2024-03-28T16:12:46Z
Historia wersji tej strony wiki
MediaWiki 1.34.1
http://brain.fuw.edu.pl/edu/index.php?title=TI/Skrypty_z_zaj%C4%99%C4%87/k5&diff=8352&oldid=prev
Tgub: Utworzono nową stronę "<source lang="python"> # -*- coding: utf-8 -*- """ Created on Wed May 20 11:17:56 2020 @author: Tomek """ class A(): def __str__(self): return 'Jestem obie..."
2020-05-20T22:18:40Z
<p>Utworzono nową stronę "<source lang="python"> # -*- coding: utf-8 -*- """ Created on Wed May 20 11:17:56 2020 @author: Tomek """ class A(): def __str__(self): return 'Jestem obie..."</p>
<p><b>Nowa strona</b></p><div><source lang="python"><br />
# -*- coding: utf-8 -*-<br />
"""<br />
Created on Wed May 20 11:17:56 2020<br />
<br />
@author: Tomek<br />
"""<br />
<br />
class A():<br />
def __str__(self):<br />
return 'Jestem obiektem klasy A'<br />
<br />
def __call__(self, *args):<br />
return 'Jestem metoda call wywolana z argumentami '+str(args)<br />
<br />
def __getitem__(self,index):<br />
return str(index)<br />
<br />
def __setitem__(self,ind,val):<br />
print('index =', ind, 'value =', val)<br />
<br />
a = A()<br />
<br />
#a+b = a.__add__(b)<br />
#a(x) = a.__call__(x)<br />
#a[n] = a.__getitem__(x)<br />
<br />
class naszSlownik():<br />
def __init__(self,dic={}):<br />
self.__sl = dic.copy()<br />
<br />
def __str__(self):<br />
return 'Nasz Slownik ' + str(self.__sl)<br />
<br />
def __getitem__(self,index):<br />
return self.__sl[index]<br />
<br />
def __setitem__(self,ind,val):<br />
if ind == 1:<br />
print('nie wolno Ci!!!')<br />
return None<br />
self.__sl[ind] = val<br />
<br />
<br />
a = {1:2,2:3,3:4}<br />
b = naszSlownik(a)<br />
a[1] = 100<br />
print(b)<br />
<br />
<br />
<br />
<br />
<br />
<br />
</source></div>
Tgub