weird problem with os.chmod

Mike Meyer mwm at mired.org
Fri Nov 11 20:41:26 EST 2005


James Colannino <james at colannino.org> writes:
> James Colannino wrote:
>
>> So then I entered the command print 0600, and saw that the actual
>> number being output was 384 (why would it output 384?!)
>>
>>
>
> Ok, so further research revealed that 0600 is actually the octal
> representation for 384 (which makes sense.)  So then, I guess my
> question would have to be, is there a way for me to make Python aware
> that the 0600 I'm passing to int() is octal and not decimal so that I
> will get 384 instead of 600?

Strange that int doesn't recognize the leading 0. But you can use the
second argument to int:

>>> int("0600", 16)
1536
>>> 

    <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list