Yes. This is all part of the Python language. There's nothing SymPy
specific going on here.

It looks like int() works with leading 0's because the second
argument, which specifies the base, defaults to 2, so the input will
always be interpreted as base 2. To make int act like eval(), you need
to pass 0 as the second argument, like int("025", 0).

Aaron Meurer

On Tue, Oct 29, 2013 at 11:25 PM, gsagrawal <[email protected]> wrote:
> Is this expected behavior ??
> As quick fix for this was adding repr on the number in tokenizer of
> str_parser (as we are already doing int() in the number init ).
>
> but i am not sure why  If i do int("025") it will return 25 and eval("025")
> returns 21  ?
>
>
> On Wed, Oct 30, 2013 at 2:21 AM, Aaron Meurer <[email protected]> wrote:
>>
>> And note that in Python 3 both would raise an exception.
>>
>> Aaron Meurer
>>
>> On Tue, Oct 29, 2013 at 7:05 AM, Julien Rioux <[email protected]>
>> wrote:
>> > On Tuesday, 29 October 2013 08:40:39 UTC-4, gsagrawal wrote:
>> >>
>> >> try  sympify("026") -> 22
>> >> sympify("028") ->exception ???
>> >>
>> >> what is happening ??
>> >>
>> >
>> > In python, numbers with a leading zero are octal numbers; such numbers
>> > may
>> > only contain the digits 0 through 7.
>> >
>> > Cheers,
>> > Julien
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sympy" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > To post to this group, send email to [email protected].
>> > Visit this group at http://groups.google.com/group/sympy.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to