Exemple #1
0
# from module3 import foo
# foo()

import module3 as m

m.foo()
Exemple #2
0
from module3 import foo, loo

foo()
loo()
import module3
module3.foo()
module3.bar()
Exemple #4
0
import module1 as m1
import module2 as m2
import module3 as m3

m1.foo()
m2.foo()
m3.foo()
Exemple #5
0
def test_foo():
    assert mod3.foo() is None
Exemple #6
0
'''
@Date: 2020-02-29 11:01:07
@LastEditors: gxm
@LastEditTime: 2020-02-29 11:12:32
@FilePath: \Python workplace\code\day05\module\test.py
'''
'''
def foo():
  print('hello,python')

def foo():
  print('hello,world') # 后面的函数会覆盖之前的同名函数

foo() # hello,world
'''

import module1

module1.foo()

import module2
module2.foo()

import module3
# 导入module3时,不会执行模块中if条件成立时的代码 因为模块的名字是module3 不是 __main__

print(module3.foo())
Exemple #7
0
    :type: str
    :rtype: str
    """
    if len(s) > 0:
        return s[1:]
    # if s == "hi":
    #     return "hello"
    else:
        return ""


if __name__ == "__main__":
    x, y = 1.0, 2.0
    print(mod1.add(x, y))

    mod3.foo()
    mod4.func1()

    print(math.sqrt(1.0))

    # we can directly access the logger defined in module1 and e.g. set the
    # logging level by reading command line input:
    if len(sys.argv) > 1:
        if sys.argv[1] in ["debug", "info", "warning", "error", "critical"]:
            mod1.logger.setLevel(
                getattr(logging, sys.argv[1].upper())
            )

    emp1 = mod1.Employee(1234, "John", "Smith")