LINUX.ORG.RU

История изменений

Исправление val-amart, (текущая версия) :

упростил:

import abc

class metaCommand (abc.ABCMeta):
    def __repr__ (self):
        return self._str

def commandFactory (name):
    class cls (baseCommand):
        _str = name
    return cls

class baseCommand (object):
    __metaclass__ = metaCommand

scp = commandFactory ('scp')

print (scp)

Исходная версия val-amart, :

упростил:

[code=python]
import abc

class metaCommand (abc.ABCMeta):
def __repr__ (self):
return self._str

def commandFactory (name):
class cls (baseCommand):
_str = name
return cls

class baseCommand (object):
__metaclass__ = metaCommand

scp = commandFactory ('scp')

print (scp)
[/code]