C-log

Welcome to Python : 패키지 본문

📘Python

Welcome to Python : 패키지

4:Bee 2023. 7. 24. 22:44
728x90

Title Code Console
패키지 만들기

def
echo_test():
    print("echo")
 

import
game.sound.echo
game.sound.echo.echo_test()
echo
패키지 변수 및 함수 정의

# game/__init__.py
from .grahpic.render import render_test
VERSION = 3.5


def print_version_info():
    print(f"The version of this game is {VERSION}.")


print("Initializing game...")
 

import
game
print(game.VERSION)

game.print_version_info()
3.5
The version of this game is 3.5.
__all__

#game/sound/__init__.py
__all__ = ['echo']
*다시 확인 필요

from
game.sound import *
echo.echo_test()
 
Initializing game...
echo
relative 패키지

# game/grahpic/render.py
from ..sound.echo import echo_test


def render_test():
    print("render")
    echo_test()
 

from
game.grahpic.render import render_test
render_test()
Initializing game...
render
echo
728x90

'📘Python' 카테고리의 다른 글

Welcome to Python : 내장 함수  (0) 2023.07.25
Welcome to Python : 예외처리  (0) 2023.07.25
Welcome to Python : 모듈  (0) 2023.07.24
Welcome to Python : 클래스  (0) 2023.07.21
Welcome to Python : 프로그램의 입출력  (0) 2023.07.13
Comments