On Tue, 17 Mar 2009 22:41:26 -0700, John Machin wrote:
> On Mar 18, 4:19 pm, Matt Nordhoff wrote:
>> The implicit string concatenation is actually done by the compiler; it
>> isn't an operator at all. Look:
>>
>> >>> import dis
>> >>> def f():
>>
>> ... return "foo" "bar"
>> ...>>> dis.dis(f
On Mar 18, 4:19 pm, Matt Nordhoff wrote:
> bdb112 wrote:
> > Thanks for all the replies:
> > I think I see now - % is a binary operator whose precedence rules are
> > shared with the modulo operator regardless of the nature of its
> > arguments, for language consistency.
> > I understand the argum
bdb112 wrote:
> Thanks for all the replies:
> I think I see now - % is a binary operator whose precedence rules are
> shared with the modulo operator regardless of the nature of its
> arguments, for language consistency.
> I understand the arguments behind the format method, but hope that the
> sli
Thanks for all the replies:
I think I see now - % is a binary operator whose precedence rules are
shared with the modulo operator regardless of the nature of its
arguments, for language consistency.
I understand the arguments behind the format method, but hope that the
slightly idiosyncratic print(
bdb112 wrote:
... the difference between ...
print(" %d, %d, buckle my shoe" % (1,2))
... and ...
print(" %d, " + " %d, buckle my shoe" % (1,2))
# a bug or a feature?
A feature. a + b % c is a + (b % c)
But do note that string constant concatentation is higher priority
than the other ope
> On Mar 16, 5:00 pm, bdb112 wrote:
> > # is the difference between
> > print(" %d, %d, buckle my shoe" % (1,2))
> > # and
> > print(" %d, " + " %d, buckle my shoe" % (1,2))
> > # a bug or a feature?
It is correct behavior. On the other hand, it is one of the, well,
bugs, that is avoided by
>
> print(10 + 20 % 7)
> a bug or a feature?
It is a feature
print ((10+20) % 7)
-Alex Goretoy
http://www.goretoy.com
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 16, 7:00 pm, bdb112 wrote:
> # is the difference between
> print(" %d, %d, buckle my shoe" % (1,2))
> # and
> print(" %d, " + " %d, buckle my shoe" % (1,2))
> # a bug or a feature?
Here's a question for you:
Is the difference between
print(30 % 7)
and
print(10 + 20 % 7)
a bug or
#whoops, the first output is actually
1, 2, buckle my shoe
# in case it wasn't obvious
On Mar 16, 5:00 pm, bdb112 wrote:
> # is the difference between
> print(" %d, %d, buckle my shoe" % (1,2))
> # and
> print(" %d, " + " %d, buckle my shoe" % (1,2))
> # a bug or a feature?
>
> First ou
# is the difference between
print(" %d, %d, buckle my shoe" % (1,2))
# and
print(" %d, " + " %d, buckle my shoe" % (1,2))
# a bug or a feature?
First output
... print(" %d " + " %d, buckle my shoe" % (1,2))
Second output
TypeError: not all arguments converted during string formatting
Versio
10 matches
Mail list logo