[Tutor] Misc question about scoping
spir
denis.spir at gmail.com
Thu Jun 3 21:21:06 CEST 2010
On Thu, 3 Jun 2010 11:50:42 -0400
Tino Dai <oberoc at gmail.com> wrote:
> Hi All,
>
> Is there a way to express this:
> isThumbnail = False
> if size == "thumbnail":
> isThumbnail = True
>
> like this:
> [ isThumbnail = True if size == "thumbnail" isThumbnail = False ]
> and the scoping extending to one level above without resorting to the
> global keyword?
If you are not in a function, then your question does not make sense for python. If you are in a function, then isThumbnail must have been defined before and you must use global, yes.
Thus, maybe no need for complicated expression:
isThumbnail = False;
def f(size):
global isThumbnail
if size == "thumbnail":
isThumbnail = True
> Thanks,
> Tino
--
________________________________
vit esse estrany ☣
spir.wikidot.com
More information about the Tutor
mailing list