Re: True
On Sun, Oct 19, 2003 at 08:17:15AM -0700, David Eppstein wrote:[color=blue]
> In article <3f929cf0$1_1@t hemost.net>,
> "Paul Watson" <pwatson@redlin ec.com> wrote:
>[color=green]
> > Then, what is the best way to write boolean operations for Python 2.1 so
> > that it will be as 2.3+ ready as possible?[/color]
>
> I've been including the following at the start of some of my code:
>
> if 'True' not in globals():
> globals()['True'] = not None
> globals()['False'] = not True[/color]
Why not simply:
try:
True
except NameError:
True = (1 == 1) # or not None, if you prefer
False = not True
Or were you trying to change the __builtins__ by using globals()?
-Andrew.
On Sun, Oct 19, 2003 at 08:17:15AM -0700, David Eppstein wrote:[color=blue]
> In article <3f929cf0$1_1@t hemost.net>,
> "Paul Watson" <pwatson@redlin ec.com> wrote:
>[color=green]
> > Then, what is the best way to write boolean operations for Python 2.1 so
> > that it will be as 2.3+ ready as possible?[/color]
>
> I've been including the following at the start of some of my code:
>
> if 'True' not in globals():
> globals()['True'] = not None
> globals()['False'] = not True[/color]
Why not simply:
try:
True
except NameError:
True = (1 == 1) # or not None, if you prefer
False = not True
Or were you trying to change the __builtins__ by using globals()?
-Andrew.
Comment