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

Alan Gauld alan.gauld at btinternet.com
Tue Jul 1 01:20:32 CEST 2008

"John Fouhy" <john at fouhy.net> wrote 

> (I don't want to criticise VB programmers because I am not one.
> "Follow the local conventions" is generally always a good rule of
> programming)

I think this is a key point. I'm no VB expert but I do have
to read it from time to time.

VB programmers tend to set to null more often than Python 
programmers because their variables are not typeless.
In VB Set is explicitly used for setting variables to object 
references (as opposed to Let which is (optionally) used 
to set variables to non-object values(int, string etc). 

Set myvar = New MyObject

is like Python doing

myvar = MyObject()

and is different to 

Let X = myvalue

which in turn is usually written more simply as

X = myvalue

In Python we do not distinguish. Because of the specific 
nature of Set it seems to me that VB programmers treat 
explicitly freeing object references rather like we would 
treat closure of files. Most of the time you can get away 
with not doing it but its safer if you do. So while you do see

Set myobj = Nothing

You almost never see

Let X = Nothing

In fact it's possibly not even valid syntax!

Alan G.

More information about the Tutor mailing list