Is there any reason to introduce this intermediate variable (sz)?

John Gordon gordon at panix.com
Tue Nov 17 17:20:39 EST 2015


In <c9b5f60f-b1ec-4857-bb02-2748a28b5460 at googlegroups.com> fl <rxjwg98 at gmail.com> writes:

> I still don't see the necessity of 'sz'. Thanks,

sz isn't required.  You can use (n_iter,) in place of sz.

However, as I posted earlier, sz is shorter so it might make your code
easier to read.

Using sz can also lead to easier code maintenance.  If the contents of
the tuple were ever to change, it would be much easier to simply change
it in once place (the definition of sz), rather than having to edit
several different occurrences of (n_iter,) in your code.


-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon at panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"




More information about the Python-list mailing list