Simple question

2014-04-15 Thread Phil Dobbin
Hi, all.

I've just started to learn Python (I'm reading Mark Lutz's 'Learning
Python' from O'Reilly)  I'm confused as to this part:

' 0.1 + 0.1 + 0.1 - 0.3
5.55111.'

Using 'import Decimal' you can get a much closer result i.e.
'Decimal('0.0')'

What I'm wondering is why the first calculation that arrives at
'5.55111...' is so far out?

Many thanks,

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:25, Zachary Ware wrote:

 On Tue, Apr 15, 2014 at 1:18 PM, Phil Dobbin phildob...@gmail.com wrote:
 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?
 
 First, note that the ... part of 5.55111... is very important
 here, it's actually 5.55111...e-17 which means it's really
 approximately 0.55111, which is really very close to
 the answer you'd expect from a human.  To learn more about why Python
 doesn't give 0.0, read this:
 https://docs.python.org/3/tutorial/floatingpoint.html
 
 Hope this helps,
 

Hi, Zach.

I saw the 'e-17' appended to the end but was unsure of its meaning (
quite a number of things are introduced in the book with clarification
of their meaning not forthcoming 'til later on).

Thank you for the link. It'll be very helpful.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:30, Robert Kern wrote:

 On 2014-04-15 19:18, Phil Dobbin wrote:
 Hi, all.

 I've just started to learn Python (I'm reading Mark Lutz's 'Learning
 Python' from O'Reilly)  I'm confused as to this part:

 ' 0.1 + 0.1 + 0.1 - 0.3
 5.55111.'

 Using 'import Decimal' you can get a much closer result i.e.
 'Decimal('0.0')'

 What I'm wondering is why the first calculation that arrives at
 '5.55111...' is so far out?
 
 The `...` elides the exponent:
 
0.1 + 0.1 + 0.1 - 0.3
   5.551115123125783e-17
 
 If you copied that verbatim directly out of a book, that's just sloppy
 editing.
 

No, the ellipses are sloppy editing on my part done purely for brevity.
Unfortunately they elided the relevant part, the meaning of which was,
prior to these conversations, lost on me.

Thanks to all who replied.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 19:41, Chris Angelico wrote:

 On Wed, Apr 16, 2014 at 4:31 AM, Phil Dobbin phildob...@gmail.com wrote:
 I saw the 'e-17' appended to the end but was unsure of its meaning (
 quite a number of things are introduced in the book with clarification
 of their meaning not forthcoming 'til later on).
 
 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.
 
 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

Good advice.

Truth is I'm writing emails on my laptop  attempting Python on a
Desktop machine so I lazily copied by eye. My mistake.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question

2014-04-15 Thread Phil Dobbin
On 15/04/2014 20:07, Chris Angelico wrote:

 On Wed, Apr 16, 2014 at 5:02 AM, Phil Dobbin phildob...@gmail.com wrote:
 On 15/04/2014 19:41, Chris Angelico wrote:

 Recommendation: If you don't understand something, keep it there :)
 You can just copy and paste from the Python interactive interpreter
 (command line or IDLE) straight into the email; it'll be easier to
 explain, that way.

 This is *especially* true of tracebacks. You might not see the
 difference, but to us, it's often hugely helpful to see the entire
 exception report.

 Good advice.

 Truth is I'm writing emails on my laptop  attempting Python on a
 Desktop machine so I lazily copied by eye. My mistake.
 
 Understandable. I currently am using two consoles (laptop at my right
 hand, desktop in front of me), and every now and then I want to copy
 and paste across them :) I mean, shared clipboard works just fine
 across all my VM guests (and as I type that, Disney's cast is singing
 Be our guest in my background music), it even works across remote
 desktop, but for some reason, swinging my hands 90 degrees doesn't
 transfer the clipboard. This strikes me as a major flaw in human
 beings.

:-)

Couldn't agree more. Not enough thought put into that one whoever did it :-)

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Martijn Faassen: The Call of Python 2.8

2014-04-14 Thread Phil Dobbin
On 14/04/2014 13:56, Mark Lawrence wrote:

 http://blog.startifact.com/posts/the-call-of-python-28.html so in
 response to the last line, who *IS* going to do all of the required work?
 

On a related note, Guido announced today that there will be no 2.8 
that the eol for 2.7 will be 2020.

Cheers,

  Phil...

-- 
currently (ab)using
CentOS 6.5, Debian Squeeze  Wheezy, Fedora 19  20, OS X Snow Leopard,
RHEL 7, Ubuntu Precise  Saucy
GnuGPG Key : http://phildobbin.org/publickey.asc
Based in London, UK


-- 
https://mail.python.org/mailman/listinfo/python-list