0
안녕하세요, 파이썬에서 다른 파일에서 클래스를 가져오고 싶습니다. 그러나 가져 오려는 클래스는 명령 행 인수를받습니다. 가져온 후 (성공적 임) 클래스에서 명령 줄 인수를 어떻게 제공합니까? (측면 : 노트는 슈퍼 클래스 또는 어떤이는 그게 무슨 뜻인지 나도 몰라?)다른 파이썬 파일 문제에서 클래스 가져 오기
#class I'm importing
class trend:
def __init__(self):
self.user_name = sys.argv[1] #receives commandline argument
_______________________________________________________________
#class I want to use it in
class game:
def __init__(self):
self.twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
def do_something(self):
import filenameforthetrendclass as TC
game = TC.trend() #how do I bring in the commandline argument in here?
인스턴스 속성을 설정하는 것은 매우 나쁜 방법이므로 클래스를 다시 작성해야합니다. – roippi
@roippi 네, 그건 내 계획 B, 좋은 디자인 패턴을 배우려고 메신저. – user3255763