Example #1
0
 def _dir(self, obj=None):
     if obj is None:
         obj = self
     results = [(i, getattr(obj, i)) for i in builtins.dir(obj)
                if i[0] != "_"]
     print("[" + "{}, ".format(color()).join(
         _dir_color(i[1]) + i[0] for i in results) + color() + "]")
Example #2
0
    def todict(cls):
        """
        Returns a list of all of class cls' private members and caches them in a dict.

        :type cls: Class
        :rtype: dict
        """
        try:
            return cls._cached_member_dict
        except AttributeError:
            cls._cached_member_dict = {name: getattr(cls, name)
                                       for name in dir(cls)
                                       if not name.startswith('_')}
            return cls._cached_member_dict
Example #3
0
def type_of_name(type_name=''):
    """
    Returns the type of name
        if found in the builtins, reserved ,
            returns builtin or reserved, respectively
        else
            returns pgm/module indicating is a name defined in the program
               or an imported module
    :param type_name: string
    :return: string
    """
    if type_name in builtins.dir():
        to_return = 'builtin'
    elif type_name in keyword.kwlist:
        to_return = 'reserved'
    else:
        to_return = 'pgm/module'
    return to_return
Example #4
0
 def commands(self, *ignored):
     return [
         command.rsplit("_").pop() for command in dir(self)
         if command.startswith("command_")
     ]
def dir(obj):  # @ReservedAssignment
    """
    Super useful for debugging...
    """
    return str(builtins.dir(obj))
Example #6
0
complex._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.complex)(*args, **kwargs),
    builtins.complex)
delattr = functools.update_wrapper(
    lambda *args, **kwargs: builtins.delattr(*args, **kwargs),
    builtins.delattr)
delattr._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.delattr)(*args, **kwargs),
    builtins.delattr)
dict = functools.update_wrapper(
    lambda *args, **kwargs: builtins.dict(*args, **kwargs), builtins.dict)
dict._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.dict)(*args, **kwargs),
    builtins.dict)
dir = functools.update_wrapper(
    lambda *args, **kwargs: builtins.dir(*args, **kwargs), builtins.dir)
dir._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.dir)(*args, **kwargs), builtins.dir)
divmod = functools.update_wrapper(
    lambda *args, **kwargs: builtins.divmod(*args, **kwargs), builtins.divmod)
divmod._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.divmod)(*args, **kwargs),
    builtins.divmod)
enumerate = functools.update_wrapper(
    lambda *args, **kwargs: builtins.enumerate(*args, **kwargs),
    builtins.enumerate)
enumerate._ = functools.update_wrapper(
    lambda *args, **kwargs: wrap(builtins.enumerate)(*args, **kwargs),
    builtins.enumerate)
eval = functools.update_wrapper(
    lambda *args, **kwargs: builtins.eval(*args, **kwargs), builtins.eval)
Example #7
0
 def test_builtins(self):
     if 'builtins' in sys.modules.keys():
         del sys.modules['builtins']
     import builtins
     self.assertEqual(builtins.dir(), "patched dir")
Example #8
0
# 1、标准包、模块
import os
import builtins
import wheel
print(os.path)
#
#
# 2、三方包、模块
#
#
#
# 3、自定义包、模块

print(dir(os))
print(builtins.dir(builtins))