How to compare two methods?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, python
- Ambito
- compilers
Direzione di ricerca
No source file or test is named. Start by reproducing the provided ClassA callback-comparison example and inspect the generated JavaScript shown in the issue. Done means determining whether the differing method identity is expected or a compiler bug, then establishing a concrete workaround or regression coverage.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi.
I want to check whether a given callback is a specific method in a class. I found that comparing two methods failed. Following is the test code:
class ClassA:
def proc(self, callback=None):
if callback==self.method1:
print('callback==self.method1, callback=', callback)
else:
print('callback!=self.method1')
print('callback.name=', callback.name)
print('callback.__name__=', callback.__name__)
print('callback.__qualname__=', callback.__qualname__)
print('callback=', callback)
print('self.method1=', self.method1)
if self.method1==self.method1:
print('self.method1==self.method1')
else: print('self.method1!=self.method1')
def method1(self):
pass
def main():
a1= ClassA()
a1.proc(a1.method1)
if __name__ == '__main__':
main()
output:
callback!=self.method1
callback.name= None
callback.__name__= None
callback.__qualname__= None
callback= function () {
var args = [] .slice.apply (arguments);
return func.apply (null, [self] .concat (args));
}
self.method1= function () {
var args = [] .slice.apply (arguments);
return func.apply (null, [self] .concat (args));
}
self.method1!=self.method1
What I was surprised was the last line in the output, self.method1!=self.method1, which was a self comparison, but failed. (Is it a bug?)
How can I know a given callback is equal to a specific method? I tried to find a workaround. But as the output above, information about the method (name, _ _ name _ _, and _ _ qualname _ _) is not available. Any idea or workaround is welcome if you have any.
Thanks.
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 218
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TranscryptOrg/Transcrypt
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TranscryptOrg/Transcrypt#913 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
TranscryptOrg/Transcrypt#911 · 2 commenti ·
-
IS: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
TranscryptOrg/Transcrypt#656 · 7 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
TranscryptOrg/Transcrypt#914 ·
Tutte le issue di TranscryptOrg/Transcrypt
Issue simili
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100