이유를 알 수없는 코드 조각이 작동합니다. 그것은 내 이해에서 작동해서는 안됩니다. 문제는 쉽게 아래에 설명되어파이썬 가져 오기 문은 언제 필요합니까?
"Main.py"
from x import * #class x is defined
from y import * #class y is defined
xTypeObj = x()
yTypeObj = y()
yTypeObj.func(xTypeObj)
"x.py"
class x(object):
def __init__...
...
def functionThatReturnsAString(self):
return "blah"
"y.py을"
이#NO IMPORT STATEMENT NEEDED?? WHY
class y(object):
def __init__...
...
def func(self, objOfTypeX):
print(objOfTypeX.functionThatReturnsAString())
내 질문입니다 왜 "y.py"에
유형의 import 문이 필요하지 않습니까?from x import functionThatReturnAString()
이 메소드를 호출하는 방법은 무엇입니까?
클래스에 대해 이야기하고 몇 가지 메소드를 호출하지만 모듈은 클래스 및 메소드가 아닌 함수 만 정의합니다. #confusion – heltonbiker
[파이썬 튜토리얼] (http : //docs.python. org/2/tutorial /), 특히 [클래스에 대한 섹션] (http://docs.python.org/2/tutorial/classes.html)을 참조하십시오. –
매개 변수로 전달했습니다. – Keith