나는 몇 가지 클래스가 :파이썬은
class RSA:
CONST_MOD=2
def __init__(self):
print "created"
def fast_powering(self,number,power,mod):
print "powering"
내가 및 호출 방법 fast_powering 인스턴스화 할 :
def main():
obj=RSA() # here instant of class is created
val=obj.fast_powering(10,2,obj.CONST_MOD) # and we call method of object
print val
을 그리고 그것은 잘 작동!
하지만 내가 좋아하는, 너무 그것을 조금 다른 방식으로 할 수 있다는 것을 발견 :
def main():
obj=RSA #do we create a link to the class without creating of object , or what?
val=obj().fast_powering(10,2,obj().CONST_MOD) # and here we do something like
# calling of static method of class in C++ without class instantiation,
# or ?
print val
죄송합니다, 나는 조금 C++에서 방법을 생각하지만, 어쨌든 내 큰 놀라움에 너무 작품!
여기 실제로 무슨 일이 일어나고 있습니까? 어느 쪽이 더 좋을까요? 나에게 약간의 신비가있다.
미리 답변 해 주셔서 감사합니다. obj = RSA
후
+1 줄임표 (...)에 오른쪽 그림 문자를 사용합니다. 농담하는 것만으로도 그 해답을 얻으실 수 있습니다. – delnan