Re: requests.Session() how do you set 'replace' on the encoding?

2015-07-02 Thread dieter
Veek M writes: > I'm getting a Unicode error: > > Traceback (most recent call last): > File "fooxxx.py", line 56, in > parent = anchor.getparent() > UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in position > 8: illegal multibyte sequence You give us very little context.

Re: Bug in floating point multiplication

2015-07-02 Thread Ned Deily
In article <559579bb$0$2921$e4fe5...@news.xs4all.nl>, Irmen de Jong wrote: > Tested on Mac OSX 10.10.4, with a 64-bit core2duo processor. Below are all > 64-bit python > implementations: > 2.6.9 (apple supplied), 2.7.6 (apple supplied), 3.4.3 (homebrew), and > pypy-2.6.0 > (homebrew). I don't h

Creating JSON from iostat lines ; Adding timezone information to naive datetimes?

2015-07-02 Thread Victor Hooi
I just want to run some things past you guys, to make sure I'm doing it right. I'm using Python to parse disk metrics out of iostat output. The device lines look like this: Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sda

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread Ben Elam
On Thursday, July 2, 2015 at 5:34:19 PM UTC-5, Ben Elam wrote: > I've stripped things down to the least amount of code necessary to reproduce > the error. I can make tk.Button handle event '<3>' but not event '<1>'. That > is, the function the event is passed to receives the event and can even pr

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread Ben Elam
On Thursday, July 2, 2015 at 6:42:22 PM UTC-5, MRAB wrote: > On 2015-07-02 23:33, Ben Elam wrote: > > I've stripped things down to the least amount of code necessary to > > reproduce the error. I can make tk.Button handle event '<3>' but not event > > '<1>'. That is, the function the event is pas

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread Ben Elam
On Thursday, July 2, 2015 at 5:54:50 PM UTC-5, Terry Reedy wrote: > On 7/2/2015 6:33 PM, Ben Elam wrote: > > I've stripped things down to the least amount of code necessary to > > reproduce the error. I can make tk.Button handle event '<3>' but not > > event '<1>'. That is, the function the event i

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread MRAB
On 2015-07-02 23:33, Ben Elam wrote: I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event o

Re: Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread Terry Reedy
On 7/2/2015 6:33 PM, Ben Elam wrote: I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event obj

Mysterious tkinter bug: tk.Button doesn't think it passed event <1>

2015-07-02 Thread Ben Elam
I've stripped things down to the least amount of code necessary to reproduce the error. I can make tk.Button handle event '<3>' but not event '<1>'. That is, the function the event is passed to receives the event and can even print the address of the event object, but a callback later produces a

Re: Python 3 resuma a file download

2015-07-02 Thread MRAB
On 2015-07-02 21:27, zljubi...@gmail.com wrote: This is my final version which doesn't work. :( Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. I really don't know what to do? Regards. import os import urllib.request def Down

Re: Python 3 resuma a file download

2015-07-02 Thread Irmen de Jong
On 2-7-2015 22:27, zljubi...@gmail.com wrote: > This is my final version which doesn't work. :( > Actually, it works with another file on another server, but doesn't work with > mp4 files on this particular server. > > I really don't know what to do? Do you really need to download these files us

Re: Bug in floating point multiplication

2015-07-02 Thread Laurent Pointal
Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version > of Python and your operating system. Printing sys.version will probably > do. On Kubuntu 15.04,

Re: Python 3 resuma a file download

2015-07-02 Thread zljubisic
This is my final version which doesn't work. :( Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. I really don't know what to do? Regards. import os import urllib.request def Download(rfile, lfile): retval = False if os

Re: Bug in floating point multiplication

2015-07-02 Thread Irmen de Jong
On 2-7-2015 16:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > >

Re: Bug in floating point multiplication

2015-07-02 Thread Jason Swails
On Thu, Jul 2, 2015 at 10:52 AM, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version > of > Python and your operating system. Printing sys.version will

Re: Bug in floating point multiplication

2015-07-02 Thread Tim Chase
On 2015-07-03 00:52, Steven D'Aprano wrote: > x = 1 - 1/2**53 > assert x == 0. > for i in range(1, 100): > if int(i*x) == i: > print(i); break tkc@debian:~$ python Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Type "help", "copyright", "credit

Re: "normalizing" a value

2015-07-02 Thread bvdp
On Wednesday, July 1, 2015 at 8:37:18 PM UTC-7, Dennis Lee Bieber wrote: > On Wed, 1 Jul 2015 18:49:34 -0700 (PDT), bvdp declaimed > the following: > > > > >Thanks guys. Yes, that is exactly what I want. I have a number of places > >where a MIDI note value is being generated. MIDI should be 0..1

Re: Pylint bug in python35 b2

2015-07-02 Thread Mark Lawrence
On 02/07/2015 15:07, Peter Otten wrote: Florent Quesselaire wrote: i installed python35 b2 and tested to pip install / easy install pylint plgin but i got an : AttributeError : 'Call' object has no attribute "starargs". i feel this error more python side than pylint side because it is the sam

requests.Session() how do you set 'replace' on the encoding?

2015-07-02 Thread Veek M
I'm getting a Unicode error: Traceback (most recent call last): File "fooxxx.py", line 56, in parent = anchor.getparent() UnicodeEncodeError: 'gbk' codec can't encode character u'\xa0' in position 8: illegal multibyte sequence I'm doing: s = requests.Session() to suck data in, so.. how do

Re: Bug in floating point multiplication

2015-07-02 Thread MRAB
On 2015-07-02 15:52, Steven D'Aprano wrote: Despite the title, this is not one of the usual "Why can't Python do maths?" "bug" reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1 -

Re: Bug in floating point multiplication

2015-07-02 Thread duncan smith
On 02/07/15 15:52, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > >

Re: Bug in floating point multiplication

2015-07-02 Thread Todd
On Thu, Jul 2, 2015 at 5:29 PM, Robin Becker wrote: > > > $ uname -a > Linux everest 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:40:31 CEST 2015 > i686 GNU/Linux > I am wondering if this is a 32bit vs. 64bit thing. Has anyone gotten this problem to work on a 64bit python? -- https://mail.python

Re: Bug in floating point multiplication

2015-07-02 Thread Steven D'Aprano
On Fri, 3 Jul 2015 12:52 am, Steven D'Aprano wrote: > x = 1 - 1/2**53 Ooops, sorry I forgot that I had already run "from __future__ import division". Otherwise that line needs to be: x = 1 - 1.0/2**53 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Bug in floating point multiplication

2015-07-02 Thread Steven D'Aprano
On Fri, 3 Jul 2015 01:34 am, Chris Angelico wrote: > From previous discussions I happen to know that Steven normally runs > everything with "from __future__ import division" active (and possibly > others? not sure), so just assume he means to work with floats here. > Steven, I think this is one of

Re: Bug in floating point multiplication

2015-07-02 Thread Ian Kelly
On Thu, Jul 2, 2015 at 9:26 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> x = 1 - 1/2**53 >> assert x == 0. > > In Python 2.x I don't see how that assert can possibly succeed, since > x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 > and it threw an asser

Re: Bug in floating point multiplication

2015-07-02 Thread Chris Angelico
On Fri, Jul 3, 2015 at 1:26 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> x = 1 - 1/2**53 >> assert x == 0. > > In Python 2.x I don't see how that assert can possibly succeed, since > x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 > and it threw an asser

Re: Bug in floating point multiplication

2015-07-02 Thread Ian Kelly
On Thu, Jul 2, 2015 at 9:28 AM, Ian Kelly wrote: > On my Chromebook, using Python 2.7.6 from the Ubuntu Trusty > distribution, I get AssertionError, and x == 1. > > In Python 3.4.0 on the same system, the code runs to completion. Both > Pythons appear to be 64-bit builds. > > On my Mint 17.1 deskt

Re: Bug in floating point multiplication

2015-07-02 Thread Paul Rubin
Steven D'Aprano writes: > x = 1 - 1/2**53 > assert x == 0. In Python 2.x I don't see how that assert can possibly succeed, since x is the integer 1. But I tested it anyway on 2.7.5 under Fedora 19 and it threw an assertion error. I changed it to say 1 - 1/2.0**53 and then the lo

Re: Bug in floating point multiplication

2015-07-02 Thread Robin Becker
$ uname -a Linux everest 4.0.6-1-ARCH #1 SMP PREEMPT Tue Jun 23 14:40:31 CEST 2015 i686 GNU/Linux robin@everest:~ $ python2 Python 2.7.10 (default, May 26 2015, 04:28:58) [GCC 5.1.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = 1.0 - 1.0/2**53 >>> as

Re: Bug in floating point multiplication

2015-07-02 Thread Ian Kelly
On my Chromebook, using Python 2.7.6 from the Ubuntu Trusty distribution, I get AssertionError, and x == 1. In Python 3.4.0 on the same system, the code runs to completion. Both Pythons appear to be 64-bit builds. On my Mint 17.1 desktop (which should be using the same packages), I get the same r

Re: Bug in floating point multiplication

2015-07-02 Thread Vincent Vande Vyvre
Le 02/07/2015 16:52, Steven D'Aprano a écrit : Despite the title, this is not one of the usual "Why can't Python do maths?" "bug" reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1

Re: Bug in floating point multiplication

2015-07-02 Thread Robin Becker
On 02/07/2015 15:52, Steven D'Aprano wrote: Despite the title, this is not one of the usual "Why can't Python do maths?" "bug" reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1 -

Re: Bug in floating point multiplication

2015-07-02 Thread Chris Angelico
On Fri, Jul 3, 2015 at 12:52 AM, Steven D'Aprano wrote: > Can anyone reproduce this behaviour? If so, please reply with the version of > Python and your operating system. Printing sys.version will probably do. > > > x = 1 - 1/2**53 > assert x == 0. > for i in range(1, 100): >

Re: Bug in floating point multiplication

2015-07-02 Thread Michael Poeltl
hi Steven, I'm running python-3.4.2 on a linuxmint16 box and CANNOT reproduce it is just that int(i*x) == i is never True! hope that helps regards Michael * Steven D'Aprano [2015-07-02 16:56]: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > C

Re: Bug in floating point multiplication

2015-07-02 Thread Todd
The loop runs to completion for me on openSUSE Tumbleweed and both Python 2.7 64bits and Python 3.4 64bits. On Thu, Jul 2, 2015 at 4:52 PM, Steven D'Aprano wrote: > Despite the title, this is not one of the usual "Why can't Python do > maths?" "bug" reports. > > Can anyone reproduce this behavio

Re: "normalizing" a value

2015-07-02 Thread Skip Montanaro
This looks like a straightforward linear transformation issue to me (like Fahrenheit to Celsius). Add 50 to all input values, giving you values in the range 0 to 100. Then scale them into your 0 to 12 range by multiplying them by 12/100: >>> for n in range(-50, 50, 3): ... print n, n + 50, (n +

Bug in floating point multiplication

2015-07-02 Thread Steven D'Aprano
Despite the title, this is not one of the usual "Why can't Python do maths?" "bug" reports. Can anyone reproduce this behaviour? If so, please reply with the version of Python and your operating system. Printing sys.version will probably do. x = 1 - 1/2**53 assert x == 0. for i i

Re: Pylint bug in python35 b2

2015-07-02 Thread Peter Otten
Florent Quesselaire wrote: > i installed python35 b2 > and tested to pip install / easy install pylint plgin > but i got an : > > AttributeError : 'Call' object has no attribute "starargs". > > i feel this error more python side than pylint side because it is the same > version who works fine in

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Saran Ahluwalia
So what did you do to resolve this? Please provide your fix. This is an excellent case study for others. Sent from my iPhone > On Jul 2, 2015, at 5:34 AM, Veek M wrote: > > never mind fixed.. > > it's returning a list so whatever[0].text and relative-path for the xpath > > > > > -- > htt

Pylint bug in python35 b2

2015-07-02 Thread Florent Quesselaire
i installed python35 b2 and tested to pip install / easy install pylint plgin but i got an : AttributeError : 'Call' object has no attribute "starargs". i feel this error more python side than pylint side because it is the same version who works fine in 3.4.3 The exe installer is amazing. thank

Re: lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Veek M
never mind fixed.. it's returning a list so whatever[0].text and relative-path for the xpath -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'OldSample' object has no attribute '__getitem__'

2015-07-02 Thread Peter Otten
Hina Imran wrote: > The data set looks something like this, The data is from openstack > ceilometer python API > > [ > { > counter_name': cpu_util', > user_id': 7b', > resource_id': ef', > timestamp': 2015-07-02T08:13:55', >

lxml.xpath 'for/xpath' to get to a node and then xpath again within the loop?

2015-07-02 Thread Veek M
I travel to 'item-name', how do i quickly travel to c-price and then print both values of text. I tried: for anchor in element.xpath('//a[@class="item-name"]'): #Travel to item-name but when i getparent and then call xpath I get a whole bunch of span elements as a list - why? Shouldn't xpath sta

TypeError: 'OldSample' object has no attribute '__getitem__'

2015-07-02 Thread Hina Imran
The data set looks something like this, The data is from openstack ceilometer python API [ http://b8dc', image.links': [ {

Re: how to fix TypeError: format requires a mapping

2015-07-02 Thread Hina Imran
you are right the data is a list of dictionaries. When I try your solution I get an error Traceback (most recent call last): File "data.py", line 45, in col['x'] = row['timestamp'] TypeError: 'OldSample' object has no attribute '__getitem__' On Wednesday, July 1, 2015 at 11:57:39 PM

Re: error with pillow: decoder not avaliable

2015-07-02 Thread Mark Lawrence
On 02/07/2015 08:29, telmo bacile wrote: Hi list, im new in this list. Im trying to run a python code that was made originally with pil using pillow, The problem is that i get this error: IOError: decoder jpeg not available Any idea why this code is not working with pillow? import math from

error with pillow: decoder not avaliable

2015-07-02 Thread telmo bacile
Hi list, im new in this list. Im trying to run a python code that was made originally with pil using pillow, The problem is that i get this error: IOError: decoder jpeg not available Any idea why this code is not working with pillow? import math from PIL import Image imageFile = 'test.jpg