Esempio n. 1
0
michael.program("업그레이드된 매직미러 앱")

print(
    "-------------------------------------------------------------------------"
)
# 모듈 OR 패키지 사용법
# animal package
# dog, cat modules
# dog, cat modules can say "hi"

print("모듈 OR 패키지 사용법")

from animal import dog  # animal 패키지에서 dog라는 모듈을 갖고와줘
from animal import cat  # animal 패키지에서 cat라는 모듈을 갖고와줘

d = dog.Dog()  # instance
d.hi()

c = cat.Cat()  # instance
c.hi()

from animal import *  # animal 패키지가 갖고 있는 모듈을 다 불러와!
d = Dog()
c = Cat()

d.hi()
c.hi()

print(
    "-------------------------------------------------------------------------"
)
Esempio n. 2
0
from animal import dog #animal패키지에서 dog이라는 모듈을 가져온다
from animal import cat

#form animal import * #animal 패키지에서 모든 모듈을 불러온다


d=dog.Dog()#dog모듈에서 Dog클래스를 instance로 만든다
d.hi()

c=cat.Cat()
c.hi()  
Esempio n. 3
0
# animal package
# dog, cat modules
# dog, cat modules can say "hi"

from animal import dog # animal 패키지에서 dog 라는 모듈을 갖고와줘
from animal import cat

from animal import *

d = dog.Dog()
d.hi()

c = cat.Cat()
c.hi()

d = Dog()
c = Cat()

d.hi()
c.hi()
Esempio n. 4
0
# animal package
# dog, cat modules; can say "hi"
print("tmp_01")

from animal import dog  # get dog module from animal package
from animal import cat  # get cat module from animal package

d = dog.Dog()  # instance from "Dog" class in "dog" module
d.hi()

c = cat.Cat()
c.hi()

# another way to get package
print("\ntmp_02")

from animal import *  # get all modules from animal package

d = Dog()
c = Cat()

d.hi()
c.hi()
Esempio n. 5
0
### Package (library) : Module의 합 ;ex.날씨 정보를 알아보는 패키지
### 내가 만든 package를 공유 <-> 반대로 남이 만든 걸 갖다 쓸 수 있음
### Module: 코드가 들어있는 파일. 이 코드가 모여서 한 기능을 구현함

# animal package
# dog, cat modules
# dog, cat modules can say "hi"

#패키지를 만들려면 폴더가 필요

from animal import dog    # animal 패키지에서 dog 모듈을 갖고와
from animal import cat   

#i
d = dog.Dog()       # instnace
d.hi()

c = cat.Cat()
c.hi()

#ii (좀 더 간단히 하고싶다면?)
from animal import *     # animal 패키지가 갖고 있는 모듈을 다 불러와

d = Dog()
c = Cat()

d.hi()
c.hi()