Create an instance of some class
436831
public function build($name, $arg1 = null, $arg2 = null, $arg3 = null, $arg4 = null)
    {
        $class = $this->getClass($name);

        if ($class) {
            return new $class($arg1, $arg2, $arg3, $arg4);
        }

        return null;
    }
1316967
def new(self, name, *args, **kwargs):
        '''
        '''
        if name in self._instance_map:
            raise ValueError('Instance {0} is already initialized'
                             .format(name))

        instance = self._class_map[name](*args, **kwargs)
        self._instance_map[name] = instance
        return instance
1227257
function createInstance() {
    var instance = { publish: publish, subscribe: subscribe, close: close };
    instance.__defineGetter__("value", function () { return shared; });
    return instance;
  }
329558
def singleton(cls):
    
    INSTANCES = {}

    def _singleton(*args, **kwargs):
        if cls not in INSTANCES:
            INSTANCES[cls] = cls(*args, **kwargs)
        return INSTANCES[cls]

    return _singleton
136205
def singleton(*args, **kwargs):
    '''
    
    '''

    def decorator(cls: type) -> Callable[[], object]:
        if issubclass(type(cls), _SingletonMetaClassBase):
            raise TypeError('cannot inherit from another singleton class.')

        box = _Box()
        factory = None
        lock = Lock()

        def metaclass_call(_):
            if box.value is None:
                with lock:
                    if box.value is None:
                        instance = cls(*args, **kwargs)
                        instance.__class__ = factory
                        box.value = (instance, ) # use tuple to handle `cls()` return `None`
            return box.value[0]

        def _is_init(*_):
            return box.value is not None

        SingletonMetaClass = type('SingletonMetaClass', (type(cls), _SingletonMetaClassBase), {
            '__slots__': (),
            '__call__': metaclass_call
        })

        factory = SingletonMetaClass(cls.__name__, (cls, ), {
            '__slots__': (),
            '_is_init': _is_init
        })
        return update_wrapper(factory, cls, updated=())

    return decorator
346472
def instance(self_or_cls,**params):
        

        if isinstance (self_or_cls,ParameterizedMetaclass):
            cls = self_or_cls
        else:
            p = params
            params = dict(self_or_cls.get_param_values())
            params.update(p)
            params.pop('name')
            cls = self_or_cls.__class__

        inst=Parameterized.__new__(cls)
        Parameterized.__init__(inst,**params)
        if 'name' in params:  inst.__name__ = params['name']
        else:                 inst.__name__ = self_or_cls.name
        return inst
55029
static <T> T newInstance(Class<T> cls) {
        try {
            return cls.newInstance();
        } catch (Exception e) {
            throw wrap(e);
        }
    }
161316
def singleton(cls):
    '''
    
    '''

    cls.__new_original__ = cls.__new__

    @wraps(cls.__new__)
    def singleton_new(cls, *args, **kw):
        it = cls.__dict__.get('__it__')
        if it is not None:
            return it

        cls.__it__ = it = cls.__new_original__(cls, *args, **kw)
        it.__init_original__(*args, **kw)
        return it

    cls.__new__ = singleton_new
    cls.__init_original__ = cls.__init__
    cls.__init__ = object.__init__

    return cls
708805
public static Object newInstance(Class target, Class type, Object arg) throws InstantiationException,
                                                                                  IllegalAccessException,
                                                                                  IllegalArgumentException,
                                                                                  InvocationTargetException,
                                                                                  NoSuchMethodException,
                                                                                  SecurityException
    {
        return newInstance(target, new Class[]{ type }, new Object[]{ arg });
    }
604665
public <T> T createInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new IllegalArgumentException("Cannot create instance of class " + type.getName(), e);
        }
    }
1002356
def _create(cls, model_class, *args, **kwargs):
        """"""
        session = cls._meta.sqlalchemy_session
        session_persistence = cls._meta.sqlalchemy_session_persistence
        if cls._meta.force_flush:
            session_persistence = SESSION_PERSISTENCE_FLUSH

        obj = model_class(*args, **kwargs)
        if session is None:
            raise RuntimeError("No session provided.")
        session.add(obj)
        if session_persistence == SESSION_PERSISTENCE_FLUSH:
            session.flush()
        elif session_persistence == SESSION_PERSISTENCE_COMMIT:
            session.commit()
        return obj
817146
public static <T> T newInstance(Class<T> aClass)
    {
        try
        {
            return aClass.getConstructor().newInstance();
        }
        catch (InstantiationException e)
        {
            throw new RuntimeException(e);
        }
        catch (IllegalAccessException e)
        {
            throw new RuntimeException(e);
        }
        catch (NoSuchMethodException e)
        {
            throw new RuntimeException(e);
        }
        catch (InvocationTargetException e)
        {
            throw new RuntimeException(e);
        }
    }
886623
private static Object newInstance(String className,
                                      ClassLoader classLoader)
        throws SOAPException
    {
        try {
            Class spiClass;
            if (classLoader == null) {
                spiClass = Class.forName(className);
            } else {
                spiClass = classLoader.loadClass(className);
            }
            return spiClass.newInstance();
        } catch (ClassNotFoundException x) {
            throw new SOAPException(
                "Provider " + className + " not found", x);
        } catch (Exception x) {
            throw new SOAPException(
                "Provider " + className + " could not be instantiated: " + x,
                x);
        }
    }
536925
def make_instance(self, data):
        """"""
        if not self.opts.model:
            return data

        if self.instance is not None:
            for key, value in data.items():
                setattr(self.instance, key, value)
            return self.instance

        return self.opts.model(**data)
1221319
def instance(cls):
        

        if not hasattr(cls, "_instance") or cls._instance is None:
            cls._instance = cls()
        return cls._instance
324534
protected T createInstance() {
		try {
			return targetClass.newInstance();
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
1052661
def CreateInstance(self, *args, **kwargs):
        

        inst = args[0] if args else kwargs['NewInstance']
        try:
            self.instances[self.default_namespace].append(inst)
        except KeyError:
            self.instances[self.default_namespace] = [inst]
        return inst.path