[Tutor] Is "var = None" in Python equivalent to "Set var =Nothing"in VB?

Alan Gauld alan.gauld at btinternet.com
Sun Jun 29 15:41:08 CEST 2008


"wesley chun" <wescpy at gmail.com> wrote

> one question i'd like to ask is, in what context is such a line part
> of your code? altho alan is correct in that syntactically, they're
> very similar, i'm wondering what you're using it for.

That's a very good point.

The normal way to delete a reference to an object in Python
would be to use del(objVar). Assigning to None tends only to
be needed is if you are reusing the same variable to point to
multiple (or optional)  objects and don't want to recreate the
variable each time. That is, as Wesley says, rather uncommon.

The other use for v=None is in default parameter definitions,
but in that case its usually quite different to the VB example!

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list