Esempio n. 1
0
class TestForFromClassImportItsSundryAttributes:
    ClassAttribute = lambda: tprint("class attribute")
    def ordinaryMethod(self):
        tprint("ordinary method")
    @staticmethod
    def staticMethod():
        tprint("static method")
    @classmethod
    def classMethod(that):
        tprint("class method")
    def __repr__(self):
        tprint("magic method")
        return "test for from class import its sundry attributes"
Esempio n. 2
0
File: d.py Progetto: nagexiucai/pmdd
def __init__(this, *args, **kwargs):
    tprint("top __init__ function within a script is", type(__init__), "in",
           __file__, this, args, kwargs)
Esempio n. 3
0
File: d.py Progetto: nagexiucai/pmdd
from cfg import tprint

tprint("file is", __file__)
tprint("package is", __package__)

# TODO: 在脚本顶层定义以下魔法属性是然并卵的事情
# __new__
# __init__
# __call__
# __add__
# __del__
# __eq__
# __metaclass__
# __slot__

# TODO: 为何可以给模块对象动态添加却用不到下列方法
# def __getattr__(this, name):
#     tprint("get a none-existent attribute", name, "in", __file__)
# def __setattr__(this, name, entity):
#     tprint("set attribute", this, name, entity, "in", __file__)
# def __getattribute__(this, name):
#     tprint("get a defined attribute", name, "in", __file__)

__dict__ = {"name": "bob", "sex": "secret"}


def __init__(this, *args, **kwargs):
    tprint("top __init__ function within a script is", type(__init__), "in",
           __file__, this, args, kwargs)

Esempio n. 4
0
def me():
    tprint("this is", me.__name__, "in", __file__)
Esempio n. 5
0
from cfg import tprint


tprint("file is", __file__)
tprint("package is", __package__)


from operator import getitem
from collections import Counter


def me():
    tprint("this is", me.__name__, "in", __file__)


from explicit.intricacy import *


# 测试相对引入
# from ..implicit import libi  # attempted relative import beyond top-level package
from .intricacy import *
Esempio n. 6
0
def c():
    tprint("this is", c.__name__, "in", __file__)
Esempio n. 7
0
 def __repr__(self):
     tprint("magic method")
     return "test for from class import its sundry attributes"
Esempio n. 8
0
def __init__(this, *args, **kwargs):
    tprint("top __init__ function within folder module's __init__.py", this,
           args, kwargs, "in", __file__)
Esempio n. 9
0
 def staticMethod():
     tprint("static method")
Esempio n. 10
0
 def ordinaryMethod(self):
     tprint("ordinary method")
Esempio n. 11
0
File: b.py Progetto: nagexiucai/pmdd
def b():
    tprint("this is", b.__name__, "in", __file__)
Esempio n. 12
0
def init():
    tprint("this is", __file__, init.__name__, "in", __file__)
Esempio n. 13
0
 def __init__(self):
     tprint("i am", self.__class__.__name__, "in", __file__)
Esempio n. 14
0
from cfg import tprint, tpprint

tprint("file is", __file__)
tprint("package is", __package__)


def init():
    tprint("this is", __file__, init.__name__, "in", __file__)


class Init(object):
    def __init__(self):
        tprint("i am", self.__class__.__name__, "in", __file__)


def me():
    tprint("this is", me.__name__, "in", __file__)


from momus import c

c.c()
c.cc()

import momus
tprint("folder without __init__.py is", type(momus), "in", __file__,
       dir(momus))
tprint("script under folder without __init__ attribute is", type(c), "in",
       __file__, dir(c))

from momus import d
Esempio n. 15
0
File: d.py Progetto: nagexiucai/pmdd
def dd():
    tprint("this is", dd.__name__, "in", __file__)
Esempio n. 16
0
 def classMethod(that):
     tprint("class method")
Esempio n. 17
0
File: d.py Progetto: nagexiucai/pmdd
 def __init__(self):
     tprint("classic class in newer python is normal class automatically")
Esempio n. 18
0
File: a.py Progetto: nagexiucai/pmdd
def a():
    tprint("this is", a.__name__, "in", __file__)