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

John Fouhy john at fouhy.net
Tue Jul 1 00:14:44 CEST 2008

On 01/07/2008, Tony Cappellini <cappy2112 at gmail.com> wrote:
> In VB6 ( I have not worked with VB.NET), objects are set to Nothing when
> they go out of scope, yet there is a fair amount lot of code out there where
> objects are explicitly set to Nothing. This is a pretty common practice in
> VB land.
> >>but in Python these statements are unnecessary.
> What happened to "Explicit is better than implicit"?

If a name goes out of scope in python, you can't get at it anyway.  I
guess if you're worried about it, you could do 'del [var]' every time
you finish using a local variable -- but the only point of this would
be as a way of telling the programmer: "I have finished with this
variable."  If your functions are small enough to fit on a page, the
programmer should be able to see that anyway.

Sure, explicit is better than implicit, but worrying about what
happens to local variables when they go out of scope is a bridge too
far for most people.

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


More information about the Tutor mailing list