[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Making A Module
RR4CLB schrieb:
> How do you make a module so you can place all your functions into it? I want to be able to load the functions in without having a long list.
---- 8< ----
# mymodule.py
__all__ = [
'func1',
'func2',
'func3',
'funcn',
]
def func1():
print "Function 1"
def func1():
print "Function 2"
def funcn():
print "Function 3"
def funcn():
print "Function n"
---- >8 ----
# python
>>> from mymodule import *
>>> func1()
Function 1
>>> func2()
Function 2
>>> func3()
Function 3
>>> funcn()
Function n
See also:
http://www.python.org/doc/current/tut/node8.html#SECTION008410000000000000000
HTH, Chris