On 2016-08-27, Random832 wrote:
> On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote:
>> Becuase the parser thinks you've entered a floating point number with
>> a fractional part of "bit_length".
>
> 123.+456 doesn't think that the fractional part is "+456".
That's because the parser (or more t
On Sat, Aug 27, 2016, at 13:24, Grant Edwards wrote:
> Becuase the parser thinks you've entered a floating point number with
> a fractional part of "bit_length".
123.+456 doesn't think that the fractional part is "+456".
(Of course, the real reason is "because it would be even more annoying
to ge
On 2016-08-18, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
>
123.bit_length()
> SyntaxError: invalid syntax
Becuase the parser thinks you've entered a floating point number with
a fractional part of "bit_length".
You need to enter the integer such tha
On Thu, 18 Aug 2016 10:58 pm, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
>
123.bit_length()
> SyntaxError: invalid syntax
Because Python thinks you are writing a float, and "b" is not a valid digit.
Try:
(123).bit_length()
123 .bit_length()
i
On Friday, August 19, 2016 at 12:59:09 AM UTC+12, ast wrote:
> I wonder why calling a method on an integer
> doesn't work ?
Sure it does.
>>> 2 + 5
7
>>> (2).__add__(5)
7
--
https://mail.python.org/mailman/listinfo/python-list
On 18/08/2016 14:01, Marko Rauhamaa wrote:
"ast" :
123.bit_length()
SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Or use (123).bit_length() which looks slig
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Ok, this works:
>>> 123 .bit_length()
7
But it looks really strange. Let's use a variable instead of an integer
literal.
Lutz
--
https://mail.python.org/mailman/listinfo/
"Marko Rauhamaa" a écrit dans le message de
news:87k2fefcyu@elektro.pacujo.net...
"ast" :
123.bit_length()
SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and "."
Am 08/18/2016 um 02:58 PM schrieb ast:
123.bit_length()
SyntaxError: invalid syntax
You are not calling a method here because the parser is not finished.
The parser thinks you want to write a float with the value 1.bit_length
which is not valid Python syntax.
Lutz
--
https://mail.python.or
Hi,
On Thu, Aug 18, 2016 at 8:58 AM, ast wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?
123 is not an integer. Its an integer constant. ;-)
Thank you.
>
123.bit_length()
>
> SyntaxError: invalid syntax
>
123.to_bytes(3, 'big')
>
> SyntaxError: invalid
"ast" :
123.bit_length()
> SyntaxError: invalid syntax
I fell into that trap myself.
CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".
Marko
--
https://mail.python.org/mailman/listinfo/python-list
Hello
I wonder why calling a method on an integer
doesn't work ?
123.bit_length()
SyntaxError: invalid syntax
123.to_bytes(3, 'big')
SyntaxError: invalid syntax
but it works with a variable
i = 123
i.bit_length()
7
i=123
i.to_bytes(3, 'big')
b'\x00\x00{'
I am working with pyhton 3.5
12 matches
Mail list logo