Re: [Tutor] Reformatting phone number

2008-08-22 Thread Lie Ryan
> Message: 4 > Date: Thu, 21 Aug 2008 12:13:58 +0200 > From: "Dotan Cohen" <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Reformatting phone number > To: OmerT <[EMAIL PROTECTED]> > Cc: "python-tutor." > Message-ID: > <[EMAIL PROTEC

Re: [Tutor] Reformatting phone number

2008-08-21 Thread W W
On Thu, Aug 21, 2008 at 5:13 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > 2008/8/21 OmerT <[EMAIL PROTECTED] <[EMAIL PROTECTED]>>: > > mostly, I google "docs.python" and the term or class I'm looking for. > > Mind, this mainly works for modules or classes which came with the > interpreter. > > > >

Re: [Tutor] Reformatting phone number

2008-08-21 Thread Dotan Cohen
2008/8/21 OmerT <[EMAIL PROTECTED]>: > mostly, I google "docs.python" and the term or class I'm looking for. > Mind, this mainly works for modules or classes which came with the > interpreter. > Exactly- that only works for term, classes, and functions that you already know the name of. The php d

Re: [Tutor] Reformatting phone number

2008-08-21 Thread Kent Johnson
On Thu, Aug 21, 2008 at 2:08 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > Is there a list of functions, organized by categories, for Python? > Take for example these pages from te php documentation: > http://il.php.net/manual/en/book.strings.php > http://il.php.net/manual/en/book.array.php > http:

Re: [Tutor] Reformatting phone number

2008-08-21 Thread OmerT
mostly, I google "docs.python" and the term or class I'm looking for. Mind, this mainly works for modules or classes which came with the interpreter. G'luck. On Thu, Aug 21, 2008 at 9:08 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > 2008/8/21 Kent Johnson <[EMAIL PROTECTED]>: >> Another way to wri

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
2008/8/21 Robert Berman <[EMAIL PROTECTED]>: > One can 'quasi' compile Python code. Since you come from a C background and > I come from a C++ background, a Python compile isn't really compiling an > object module. I don't see an object file, I don't see an executable; > therefore, in my opinion, P

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
2008/8/21 Kent Johnson <[EMAIL PROTECTED]>: > Another way to write this is > if sys.argv[1].startswith('0'): Nice! I had looked for this type of function, but could not find it. Is there a list of functions, organized by categories, for Python? Take for example these pages from te php documentat

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Kent Johnson
On Wed, Aug 20, 2008 at 4:43 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > I have a small script (linux) that takes a phone number as an argument: > #!/usr/bin/env python > import sys > number = '+' + sys.argv[1] > > > However, if the first digit of the phone number is a 0 then I need to > repl

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
2008/8/21 Robert Berman <[EMAIL PROTECTED]>: > Not directly as in C, but, for example, if you have s='3' and you want s > used as an integer, you can say s=int(s) and it is an integer. Conversely, > if you have a question about the type, you could also say type(s) which, > depending, will return, '

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
2008/8/21 Alan Gauld <[EMAIL PROTECTED]>: > "Dotan Cohen" <[EMAIL PROTECTED]> wrote > >> know if this is the case. Can I declare a variable type in Python as >> in C? > > In Python values have types and variables are simply > names associated with values. > > Thus > > v = '123'# v 'is' a string

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Alan Gauld
"Dotan Cohen" <[EMAIL PROTECTED]> wrote know if this is the case. Can I declare a variable type in Python as in C? In Python values have types and variables are simply names associated with values. Thus v = '123'# v 'is' a string because '123' is a string v = 123 # now v 'is' an int

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Robert Berman
Not directly as in C, but, for example, if you have s='3' and you want s used as an integer, you can say s=int(s) and it is an integer. Conversely, if you have a question about the type, you could also say type(s) which, depending, will return, 'str','int', etc. Hope this helps a bit. Robert

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
2008/8/21 Robert Berman <[EMAIL PROTECTED]>: > Perhaps because preNumber is a character and not an integer? > Perhaps. In php the distinction was made by the fact that there were no non-numerical characters in a string. I don't know enough Python to know if this is the case. Can I declare a variab

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Robert Berman
Perhaps because preNumber is a character and not an integer? Robert Dotan Cohen wrote: I was missing the quotes in the if statement. Changing if preNumber[0] == 0: to if preNumber[0] == "0": fixed the problem. Why did I need those quotes? The 0 is numerical, so it should not need the quot

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
I was missing the quotes in the if statement. Changing if preNumber[0] == 0: to if preNumber[0] == "0": fixed the problem. Why did I need those quotes? The 0 is numerical, so it should not need the quotes, no? -- Dotan Cohen http://what-is-what.com http://gibberish.co.il א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ

Re: [Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
I have gotten a bit farther, but I cannot get this to work as described in the previous mail: #!/usr/bin/env python import sys preNumber = sys.argv[1] if preNumber[0] == 0: number = '+972' + preNumber[1:] else: number = '+' + preNumber Where is my flaw? -- Dotan Cohen http://what-is-w

[Tutor] Reformatting phone number

2008-08-20 Thread Dotan Cohen
I have a small script (linux) that takes a phone number as an argument: #!/usr/bin/env python import sys number = '+' + sys.argv[1] However, if the first digit of the phone number is a 0 then I need to replace that 0 with "972". I can add the "972", but how do I remove the leading "0"? For i