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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
On Thu, Jul 1, 2010 at 16:18, Steven D'Aprano wrote:
> On Fri, 2 Jul 2010 05:18:00 am Eike Welk wrote:
>
>> As you are using long integers (and you were previously writing about
>> prime numbers) the precision of floating point numbers might not be
>> enough for your purposes.
>
> It certainly won
On Fri, 2 Jul 2010 05:18:00 am Eike Welk wrote:
> As you are using long integers (and you were previously writing about
> prime numbers) the precision of floating point numbers might not be
> enough for your purposes.
It certainly won't be once you get to large enough primes!
> Therefore you sho
On Thu, Jul 1, 2010 at 12:18, Eike Welk wrote:
> Therefore you should probably use the integer division operator: "//"
>>> x = 200033
>>> x//2
100016
I can live with THAT error!
Thanks, Eike!
But I will press on with Mark
On 01/07/2010 20:18, Eike Welk wrote:
Hello Richard!
On Thursday July 1 2010 15:11:21 Richard D. Moores wrote:
Thanks to yours and others responses, I've learned some things I
didn't know, but remember, I'm starting with long ints such as
Also note that in Python 3 the "/" (division) operator
Hello Richard!
On Thursday July 1 2010 15:11:21 Richard D. Moores wrote:
> Thanks to yours and others responses, I've learned some things I
> didn't know, but remember, I'm starting with long ints such as
Also note that in Python 3 the "/" (division) operator returns a floating
point number when
On Thu, Jul 1, 2010 at 09:25, Mark Lawrence wrote:
> Take a look at section 7.1.3 here.
>
> http://docs.python.org/py3k/library/string.html#string-formatting
>
> This is the recommended way to format strings in Python 3.
Thanks, Mark. Looks good, if cryptic. I don't have time to dig into it
now
On 01/07/2010 14:11, Richard D. Moores wrote:
On Thu, Jul 1, 2010 at 04:57, Steven D'Aprano wrote:
On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote:
x = 2034
x/2
1017.0
print(x/2)
1e+15
I was expecting, in fact needing, 117 or
1000
On Thu, Jul 1, 2010 at 04:57, Steven D'Aprano wrote:
> On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote:
>> >>> x = 2034
>> >>> x/2
>> 1017.0
>>
>> >>> print(x/2)
>> 1e+15
>>
>> I was expecting, in fact needing, 117 or
>> 117.0
>>
>> 1e
On Thu, 1 Jul 2010 06:26:21 pm Richard D. Moores wrote:
> >>> x = 2034
> >>> x/2
> 1017.0
>
> >>> print(x/2)
> 1e+15
>
> I was expecting, in fact needing, 117 or
> 117.0
>
> 1e+15 is unsatisfactory. Am I forced to use the decimal module?
This
x = 2034
x/2
> 1017.0
print(x/2)
> 1e+15
>
> I was expecting, in fact needing, 117 or 117.0
>
> 1e+15 is unsatisfactory. Am I forced to use the decimal module?
Can't you use string formatting? Eg:
>>> print("{0:15.0f}".format
without using decimal module:
>>> x = 2034
>>> print('%d'%(x/2))
1017
On Thu, Jul 1, 2010 at 13:56, Richard D. Moores wrote:
x = 2034
x/2
> 1017.0
print(x/2)
> 1e+15
>
> I was expecting, in fact needing, 117 or 1
On Fri, Aug 29, 2008 at 6:15 PM, ammar azif <[EMAIL PROTECTED]> wrote:
> Thanks for the explanation. Btw, How can I get the size of python primitive
> data types in bytes? Is it defined somewhere in a file that I can look at?
Not really. sys.maxint gives the largest int, from which you can infer t
Thanks for the explanation. Btw, How can I get the size of python primitive
data types in bytes? Is it defined somewhere in a file that I can look at?
--- On Fri, 8/29/08, Kent Johnson <[EMAIL PROTECTED]> wrote:
From: Kent Johnson <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Puzzle
On Fri, Aug 29, 2008 at 5:13 PM, ammar azif <[EMAIL PROTECTED]> wrote:
> I wrote a python program that used time() function from the time module to
> retrieve time in seconds since Epoch. After the value was retrieved which I
> checked is a float by using type(), the value was then written into a
Dick Moores wrote:
> At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>
>> Maybe following is helpful:
>>
>>
> a=[3,2,1]
> b=a[:]
> b.sort()
> c=sorted(a)
> print a,b,c
> [3, 2, 1] [1, 2, 3] [1, 2, 3]
>
>
>> Shantanoo
>>
>
> Sorry to be dense,
At 01:37 PM 9/30/2006, Shantanoo Mahajan wrote:
>Maybe following is helpful:
>
> >>> a=[3,2,1]
> >>> b=a[:]
> >>> b.sort()
> >>> c=sorted(a)
> >>> print a,b,c
> >>> [3, 2, 1] [1, 2, 3] [1, 2, 3]
> >>>
>
>Shantanoo
Sorry to be dense, but I don't see what showing what happens to a
copy of list a ad
+++ Dick Moores [30-09-06 10:47 -0700]:
| At 05:07 AM 9/30/2006, Liam Clarke wrote:
| >Dick Moores wrote:
| > > At 03:22 AM 9/30/2006, Liam Clarke wrote:
| > >> Dick Moores wrote:
|
| > >> A Python list sort is destructive, as you can see - it has modified
| > >> lst. So, to emphasise that it is d
At 05:07 AM 9/30/2006, Liam Clarke wrote:
>Dick Moores wrote:
> > At 03:22 AM 9/30/2006, Liam Clarke wrote:
> >> Dick Moores wrote:
> >> A Python list sort is destructive, as you can see - it has modified
> >> lst. So, to emphasise that it is destructive, it returns None. You'll
> >> find this in
Dick Moores wrote:
> At 03:22 AM 9/30/2006, Liam Clarke wrote:
>> Dick Moores wrote:
>>>
>>> >>> lst = [5,3,7,6,2]
>>> >>> lst.sort()
>>> >>> lst
>>> [2, 3, 5, 6, 7]
>>> >>> lst = [5,3,7,6,2]
>>> >>> print lst.sort()
>>> None
>>> >>> lst
>>> [2, 3, 5, 6, 7]
>>>
>>> I'm wondering why "print ls
Dick Moores wrote:
> At 03:22 AM 9/30/2006, Liam Clarke wrote:
>> Dick Moores wrote:
>>>
>>> >>> lst = [5,3,7,6,2]
>>> >>> lst.sort()
>>> >>> lst
>>> [2, 3, 5, 6, 7]
>>> >>> lst = [5,3,7,6,2]
>>> >>> print lst.sort()
>>> None
>>> >>> lst
>>> [2, 3, 5, 6, 7]
>>>
>>> I'm wondering why "print ls
At 03:22 AM 9/30/2006, Liam Clarke wrote:
Dick Moores wrote:
>>> lst = [5,3,7,6,2]
>>> lst.sort()
>>> lst
[2, 3, 5, 6, 7]
>>> lst = [5,3,7,6,2]
>>> print lst.sort()
None
>>> lst
[2, 3, 5, 6, 7]
I'm wondering why "print lst.sort()" doesn't print the newly
sorted
list, but instead prints
Dick Moores wrote:
>>> lst = [5,3,7,6,2]
>>> lst.sort()
>>> lst
[2, 3, 5, 6, 7]
>>> lst = [5,3,7,6,2]
>>> print lst.sort()
None
>>> lst
[2, 3, 5, 6, 7]
I'm wondering why "print lst.sort()" doesn't print the newly sorted
list, but instead prints "None". In fact, the sorting has taken
[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,
>>
[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
[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
Tim Peters wrote:
> [Dick Moores, computes 100 factorial as
>
> 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864
>
> but worries about all the trailing zeros]
>
>> Yes, I'm sure you a
[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
At 04:50 PM 8/18/2006, Christian Tschabuschnig wrote:
> >>
> 9332621544394415268169923885626670049071596826438162146859296389521753229915608941463976156518286253697920827223758251185210916864
> >>> Still not exactly correct! I'm bewildered.
> >>>
> >> The results look t
>> 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
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
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
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
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
49 matches
Mail list logo