Question: I want to change guest VM's(Windows) IP address on ESXi. One way I have known is using RDP to connect to the guest OS and modifying the network configuration.

However, I wish to make the process automated. Hence, does vCenter or ESXi contain similar functions or tools to perform this demand? (I have tried ovftool and vCLI but not work)

Thanks for ur reply.

Rocas

Answer: 
Other answers describe how to use `__new__` to implement a singleton, but that's not how None is actually implemented (in cPython at least, I haven't looked into other implementations).

Trying to create an instance of None through `type(None)()` is special cased, and ends up calling the [following C function](http://hg.python.org/cpython/file/8b4d36d0c090/Objects/object.c#l1409):

```
static PyObject *
none_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
    if (PyTuple_GET_SIZE(args) || (kwargs && PyDict_Size(kwargs))) {
        PyErr_SetString(PyExc_TypeError, "NoneType takes no arguments");
        return NULL;
    }
    Py_RETURN_NONE;
}

```

And `Py_RETURN_NONE` is [defined here](http://hg.python.org/cpython/file/8b4d36d0c090/Include/object.h#l837):

```
/*
_Py_NoneStruct is an object of undefined type which can be used in contexts
where NULL (nil) is not suitable (since NULL often means 'error').

Don't forget to apply Py_INCREF() when returning this value!!!
*/
PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
#define Py_None (&_Py_NoneStruct)

/* Macro for returning Py_None from a function */
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None

```

Contrast this with the [function that creates a normal python object](http://hg.python.org/cpython/file/8b4d36d0c090/Objects/object.c#l237):

```
PyObject *
_PyObject_New(PyTypeObject *tp)
{
    PyObject *op;
    op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
    if (op == NULL)
        return PyErr_NoMemory();
    return PyObject_INIT(op, tp);
}

```

When you create a normal object, memory for the object is allocated and initialized. When you try to create a new instance of `None`, all you get is a reference to the already existing `_Py_NoneStruct`. That's why, no matter what you do, every reference to `None` will be the exact same object.
> 
> Why is n the exact same Object as None? 
> 
> 
> 

Many immutable objects in Python are [interned](http://en.wikipedia.org/wiki/String_interning) including `None`, smaller ints, and many strings.

Demo:

```
>>> s1='abc'
>>> s2='def'
>>> s3='abc'
>>> id(s1)
4540177408
>>> id(s3)
4540177408    # Note: same as s1
>>> x=1
>>> y=2
>>> z=1
>>> id(x)
4538711696
>>> id(z)
4538711696    # Note: same as x

```

> 
> Why was the language designed
>  such that n is the exact same Object as None? 
> 
> 
> 

See above -- speed, efficiency, lack of ambiguity and memory usage among other reasons to intern immutable objects.

> 
> How would one even
>  implement this behavior in python?
> 
> 
> 

Among other ways, you can override `__new__` to return the same object:

```
class Singleton(object):
    _instance = None
    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(Singleton, cls).__new__(
                                cls, *args, **kwargs)
        return cls._instance

```

For strings, you can call [intern](http://docs.python.org/2/library/functions.html#intern) on Python 2 or [sys.intern](http://docs.python.org/3.3/library/sys.html#sys.intern) on Python 3