Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:10, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >>> Richard D. Moores wrote: >>> I wrote before that I had pasted the function (convertPath()) from my initial post into

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:16, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that there was no problem importing it from mycalc

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into). Ther

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >> Richard D. Moores wrote: >> >>> I wrote before that I had pasted the function (convertPath()) from my >>> initial post into mycalc.py because I had accidentally deleted it from >>> mycalc.py. And that

Re: [Tutor] Puzzled again

2011-08-03 Thread Dave Angel
On 08/03/2011 01:48 PM, Richard D. Moores wrote: On Wed, Aug 3, 2011 at 10:11, Peter Otten<__pete...@web.de> wrote: Dave was close, but Steven hit the nail: the string r"C:\Users\Dick\..." is fine, but when you put it into the docstring it is not a raw string within another string, it becomes

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that there was no problem importing i

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > I wrote before that I had pasted the function (convertPath()) from my > initial post into mycalc.py because I had accidentally deleted it from > mycalc.py. And that there was no problem importing it from mycalc. > Well, I was mistaken (for a reason too tedious to go into

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into). There WAS a problem, the same o

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: But here's a try using the regular command line: C:\Windows\System32>python Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. from mycalc import convertPath Traceba

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
Ops! I accidentally erased convertPath() from mycalc.py while trying out various things. It was my only copy of convertPath that had the docstring as posted, so I went to my initial post and copy-and-pasted it into mycalc.py. Now no problem: from Wing's shell: Python 3.2.1 (default, Jul 10 2

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Steven D'Aprano wrote: Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that pat

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that path with forward slashes.

Re: [Tutor] Puzzled again

2011-08-03 Thread Dave Angel
On 08/03/2011 02:07 AM, Richard D. Moores wrote: On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: When I paste that from your email into a file and run Python 2.7 on it, it behaves fine with no errors. That's in Linux. I should have said that I'm using Wing IDE Professional 4.0.3-1 (rev 2472

Re: [Tutor] Puzzled again

2011-08-02 Thread Andre Engels
On Wed, Aug 3, 2011 at 8:07 AM, Richard D. Moores wrote: > On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: > > > When I paste that from your email into a file and run Python 2.7 on it, > it > > behaves fine with no errors. That's in Linux. > > I should have said that I'm using Wing IDE Professio

Re: [Tutor] Puzzled again

2011-08-02 Thread Richard D. Moores
On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: > When I paste that from your email into a file and run Python 2.7 on it, it > behaves fine with no errors.  That's in Linux. I should have said that I'm using Wing IDE Professional 4.0.3-1 (rev 24721), Windows Vista, and Python 3.2.1. > But the e

Re: [Tutor] Puzzled again

2011-08-02 Thread Dave Angel
On 08/02/2011 10:36 PM, Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that p

[Tutor] Puzzled again

2011-08-02 Thread Richard D. Moores
Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path):     """     Given a path with backslashes, return that path with forward slashes.     By Steven D'Aprano  07

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Tim Peters] >> You would in this case, and that would be wrong. In fp you'd get an >> approximation to the exact n * (1./5 + 1./5**2 + ...) == n/4. (use >> the rule for the sum of an infinite geometric series). For example, >> that way you'd compute that 4! == 24 has 4/4 == 1 trailing zero, >>

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
[Tim Peters] > You would in this case, and that would be wrong. In fp you'd get an > approximation to the exact n * (1./5 + 1./5**2 + ...) == n/4. (use > the rule for the sum of an infinite geometric series). For example, > that way you'd compute that 4! == 24 has 4/4 == 1 trailing zero, > inste

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Tim Peters] >> For a fun :-) exercise, prove that the number of trailing zeroes in n! >> is the sum, from i = 1 to infinity, of n // 5**i (of course as soon as >> you reach a value of i such that n < 5**i, the quotient is 0 at that i >> and forever after). >> >> In this case, >> >> 100 // 5 + 100

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
Tim Peters wrote: > [Dick Moores, computes 100 factorial as > > 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 > > but worries about all the trailing zeros] > >> Yes, I'm sure you a

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Tim Peters
[Dick Moores, computes 100 factorial as 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 but worries about all the trailing zeros] > Yes, I'm sure you are. I'd forgotten about all tho

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 04:50 PM 8/18/2006, Christian Tschabuschnig wrote: > >> > 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 > >>> Still not exactly correct! I'm bewildered. > >>> > >> The results look t

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Christian Tschabuschnig
>> 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864 >>> Still not exactly correct! I'm bewildered. >>> >> The results look the same to me >> why do you think they're not correct? >> what is

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 04:24 PM 8/18/2006, Luke Paireepinart wrote: >Dick Moores wrote: > > But here's the revised precisionFactorial.py: > > > > > > # 1precisionFactorial.py > > > > import decimal > > > > def d(x): > > return decimal.Decimal(str(x)) > > > > def fact(n): > > product

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Luke Paireepinart
Dick Moores wrote: > At 02:41 PM 8/18/2006, Bob Gailer wrote: > >> Dick Moores wrote: >> >>> As an exercise that I thought would help me understand the decimal >>> module, I've been trying write a script (precisionFactorial.py) >>> that uses a modified fact(n) to compute precise factorial

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
At 02:41 PM 8/18/2006, Bob Gailer wrote: >Dick Moores wrote: >>As an exercise that I thought would help me understand the decimal >>module, I've been trying write a script (precisionFactorial.py) >>that uses a modified fact(n) to compute precise factorials >What do you mean by "precise factorials

Re: [Tutor] puzzled again by decimal module

2006-08-18 Thread Bob Gailer
Dick Moores wrote: > As an exercise that I thought would help me understand the decimal > module, I've been trying write a script (precisionFactorial.py) that > uses a modified fact(n) to compute precise factorials What do you mean by "precise factorials"? Python's long integer should handle th

[Tutor] puzzled again by decimal module

2006-08-18 Thread Dick Moores
As an exercise that I thought would help me understand the decimal module, I've been trying write a script (precisionFactorial.py) that uses a modified fact(n) to compute precise factorials using the decimal module. I''m getting nowhere fast, and don't understand why. Here's what I have so far: