ACCEPTED: PEP 285

Neal Norwitz neal at metaslash.com
Thu Apr 4 21:00:18 EST 2002


Paul Rubin wrote:
> 
> James Logajan <JamesL at Lugoj.com> writes:
> > x = ["is", "are"]
> > y = {0: "", 1:"s"}
> >
> > for n in range(3):
> >    print "There %s %d item%s." % (x[n <> 1], n, y[n <> 1])
> >
> > Will the behavior be backword compatible and equivalent or not? Simple
> > question I assume; waiting for an answer.
> 
> Yes, if I understand the PEP, that should still work.
> 
> This, however, won't work compatibly:
> 
>    print "Calm down, it's only %s's and %s's." % (1==1, 1==0)

Correct, 2.1:
	>>> print "Calm down, it's only %s's and %s's." % (1==1, 1==0)
	Calm down, it's only 1's and 0's.

2.3:
	>>> print "Calm down, it's only %s's and %s's." % (1==1, 1==0)
	Calm down, it's only True's and False's.

However, if you really want integers, then ask for them:

2.1:
	>>> print "Calm down, it's only %d's and %d's." % (1==1, 1==0)
	Calm down, it's only 1's and 0's.

2.3:
	>>> print "Calm down, it's only %d's and %d's." % (1==1, 1==0)
	Calm down, it's only 1's and 0's.

That is backwards compatible.  And explicit.



More information about the Python-list mailing list