Re: weird problem with os.chmod

2005-11-12 Thread Fredrik Lundh
Bengt Richter wrote: > >*) unless you're living in sweden, in which case "08" is quite often used > >as an insult. > > I am always curious about languages, and considering my name, I think I'd > like to know this definition ;-) Is it telephone-exchange-related? it's the area code for Stockholm. I

Re: weird problem with os.chmod

2005-11-12 Thread Bengt Richter
On Sat, 12 Nov 2005 12:53:17 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: [...] >int is designed for humans, not C programmers. humans tend to view >e.g. "08" as a valid decimal number (*), not a ValueError. [...] > > >*) unless you're living in sweden, in which case "08" is quite often used

Re: weird problem with os.chmod

2005-11-12 Thread Mardy
On Fri, 11 Nov 2005 16:49:23 -0800, James Colannino wrote: > Ok, so now I have a very interesting problem, this time related to > os.chmod. I have the following in a text file: 0600. My script reads > that number as a string and converts it to an integer for use with > chmod. However, when I

Re: weird problem with os.chmod

2005-11-12 Thread Roel Schroeven
Gary Herron wrote: > James Colannino wrote: > >> 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 oc

Re: weird problem with os.chmod

2005-11-12 Thread Fredrik Lundh
Mike Meyer wrote: > Strange that int doesn't recognize the leading 0. But you can use the > second argument to int: > > >>> int("0600", 16) > 1536 > >>> int is designed for humans, not C programmers. humans tend to view e.g. "08" as a valid decimal number (*), not a ValueError. to get programme

Re: weird problem with os.chmod

2005-11-11 Thread Peter Hansen
Mike Meyer wrote: > Strange that int doesn't recognize the leading 0. But you can use the > second argument to int: > int("0600", 16) > > 1536 You can use it another way too: >>> int('0600', 0) 384 >>> int('0x180', 0) 384 >>> 0600 384 -Peter -- http://mail.python.org/mailman/listinfo/p

Re: weird problem with os.chmod

2005-11-11 Thread Mike Meyer
James Colannino <[EMAIL PROTECTED]> 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

Re: weird problem with os.chmod

2005-11-11 Thread Gary Herron
James Colannino wrote: >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

Re: weird problem with os.chmod

2005-11-11 Thread Martin v. Löwis
James Colannino wrote: > 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 th

Re: weird problem with os.chmod

2005-11-11 Thread Martin v. Löwis
James Colannino wrote: > I discovered the solution and thought I'd share it with everyone. I > discovered as I googled that Python used to have a function called > atoi() that took the parameter base=X. I decided to see if that worked > with the newer function int() and it did :) I recommend

Re: weird problem with os.chmod

2005-11-11 Thread James Colannino
James Colannino wrote: >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

Re: weird problem with os.chmod

2005-11-11 Thread James Colannino
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 wo