PEP0238 lament

Roy Smith roy at panix.com
Tue Jul 24 07:41:14 EDT 2001


Duncan Grisby <dgrisby at uk.research.att.com> wrote:

> So what can I do?  I can't even do something ugly like
> 
>   if sys.hexversion > 0x2000200:
>       c = a // b
>   else:
>       c = a / b
> 
> since the a // b gives a syntax error.

I'm almost embarassed to suggest this, but what about:

   if sys.hexversion > 0x2000200:
       c = eval ("a // b")
   else:
       c = a / b

It makes me barf to even suggest it, but it does solve the immediate 
problem.

PS -- please don't infer from this posting that I'm in support of the PEP; 
I'm just addressing this specific issue.  The fundamental problem here is 
that the PEP breaks existing code, which if it's not a cardinal sin, should 
be.



More information about the Python-list mailing list