|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Nov 2009
Messaggi: 50
|
cosa è il monkey patching?
ho fatto qualche ricerca ma non l'ho capito. se potessi vedere un pò di codice python ad esempio e capire cosa è sarebbe una cosa ottima
|
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Jan 2002
Città: Germania
Messaggi: 26110
|
Codice:
>>> class c:
... def f(self): print 'f!'
>>> a = c()
>>> a.f()
f!
>>> def g(self):
... print 'g!'
>>> c.g = g
>>> a.g()
g!
>>> def h(x):
... print 'x:', x
>>> a.h = h
>>> a.h(1)
x: 1
>>> b = c()
>>> b.h(1)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
b.h(1)
AttributeError: c instance has no attribute 'h'
>>> del c.f
>>> a.f()
Traceback (most recent call last):
File "<pyshell#17>", line 1, in <module>
a.f()
AttributeError: c instance has no attribute 'f'
__________________
Per iniziare a programmare c'è solo Python con questo o quest'altro (più avanzato) libro @LinkedIn Non parlo in alcun modo a nome dell'azienda per la quale lavoro Ho poco tempo per frequentare il forum; eventualmente, contattatemi in PVT o nel mio sito. Fanboys |
|
|
|
|
|
#3 | |
|
Senior Member
Iscritto dal: Jun 2002
Città: Dublin
Messaggi: 5989
|
Quote:
__________________
C'ho certi cazzi Mafa' che manco tu che sei pratica li hai visti mai! |
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 21:04.




















