Re: collections.Counter surprisingly slow

2013-07-29 Thread Stefan Behnel
Stefan Behnel, 30.07.2013 08:39: > Serhiy Storchaka, 29.07.2013 21:37: >> 29.07.13 20:19, Ian Kelly написав(ла): >>> On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote: Also, couldn't Counter just extend from defaultdict? >>> >>> It could, but I expect the C helper function in 3.4 will be fa

Re: collections.Counter surprisingly slow

2013-07-29 Thread Stefan Behnel
Serhiy Storchaka, 29.07.2013 21:37: > 29.07.13 20:19, Ian Kelly написав(ла): >> On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote: >>> Also, couldn't Counter just extend from defaultdict? >> >> It could, but I expect the C helper function in 3.4 will be faster >> since it doesn't even need to ca

Re: Bitwise Operations

2013-07-29 Thread Terry Reedy
On 7/29/2013 7:44 PM, Chris Angelico wrote: But there's an easier way: x = 0b101 & 0b010 x 0 I think that might do what you want. Also check out the bin() function, which will turn an integer into a string of digits. >>> bin(0b101 | 0b010) '0b111' Now you are set to go. Have fun. -- Terry

Re: Bitwise Operations

2013-07-29 Thread Peter Otten
Devyn Collier Johnson wrote: > On Python3, how can I perform bitwise operations? For instance, I want > something that will 'and', 'or', and 'xor' a binary integer. >>> 0b1010 | 0b1100 14 >>> bin(_) '0b1110' >>> 0b1010 & 0b1100 8 >>> bin(_) '0b1000' >>> 0b1010 ^ 0b1100 6 >>> bin(_) '0b110' --

Re: must be dicts in tuple

2013-07-29 Thread Tim Roberts
Tanaya D wrote: > >I am using Python with Bots(EDI translator) > >But i am getting the following error: >MappingFormatError: must be dicts in tuple: get((({'BOTSID': 'HEADER'},),)) > >Can anyone pls help me with it. Possible hint: the error says you're supposed to have dicts in a tuple. What you

Re: [python] email 8bit encoding

2013-07-29 Thread rurpy
On 07/29/2013 12:16 AM, W. Trevor King wrote: > On Sun, Jul 28, 2013 at 04:41:27PM -0700, ru...@yahoo.com wrote: >> How, using Python-3.3's email module, do I "flatten" (I think >> that's the right term) a Message object to get utf-8 encoded >> body with the headers: >> Content-Type: text/plain; c

Re: PyQt5 and virtualenv problem

2013-07-29 Thread D. Xenakis
Could you help me install PyQt5 properly in my Virtualenv folder and not only globally? I tried installing PyQt5 and sip with the use of pip but i was getting errors all the time (Why is that? Are there any known pip issues along with PyQt5 and sip?), so in the end i had to install it with the

Re: SQLite logic error or missing database

2013-07-29 Thread Chris Angelico
On Tue, Jul 30, 2013 at 3:02 AM, CM wrote: > If I try additional commits in that same instance of my app being open, > it gives me the same error every time. If I close the app and re-open > it, it does not give me this error, with the same or very similar data > being written in the same routine

Re: PEP8 79 char max

2013-07-29 Thread Joshua Landau
On 30 July 2013 01:41, Rhodri James wrote: > On Tue, 30 Jul 2013 01:11:18 +0100, Joshua Landau > wrote: > > On 30 July 2013 00:08, Rhodri James wrote: >> >>> I'm working on some shonky C code at the moment that inconsistent >>> indentation and very long lines. It is extremely annoying not to

SQLite logic error or missing database

2013-07-29 Thread CM
(Posted to SQLite users list first; 3 views so far, and no answers, so trying here, thinking that perhaps a Python user would have some clues; I hope that is OK) I am using SQLite through either Python 2.5 or 2.7, which is the sqlite3 module. In a desktop application, every now and then, and in

Re: Bitwise Operations

2013-07-29 Thread MRAB
On 30/07/2013 00:34, Devyn Collier Johnson wrote: On 07/29/2013 05:53 PM, Grant Edwards wrote: On 2013-07-29, Devyn Collier Johnson wrote: On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or', and 'xor' a binary integer. http://www.google.co

Re: Pyglet on Python3.x, problems

2013-07-29 Thread Chris Angelico
On Tue, Jul 30, 2013 at 1:47 AM, John Ladasky wrote: > I'm getting one problem. After a few tests run, I can't close a window. I > am normally closing each interactive test with the ESC key. But when that > fails I try clicking with the mouse. This also fails. This broken behavior > appear

Re: Pyglet on Python3.x, problems

2013-07-29 Thread John Ladasky
G. Ian, thank you, you gave me a clue. I thought I was being careful about avoiding local imports. I just removed the tests directory from inside the pyglet-1.2alpha1 directory and tried running it from its new location. That got rid of the error message which was displaying uncorrected

Re: PEP8 79 char max

2013-07-29 Thread Rhodri James
On Tue, 30 Jul 2013 01:11:18 +0100, Joshua Landau wrote: On 30 July 2013 00:08, Rhodri James wrote: I'm working on some shonky C code at the moment that inconsistent indentation and very long lines. It is extremely annoying not to be able to put the original code, my "translation" and sund

Re: Pyglet on Python3.x, problems

2013-07-29 Thread John Ladasky
Thanks for your reply, Joshua. >From the interpreter, I too can import pyglet, instantiate a >pyglet.window.Window, and have it pop up (although, following your directions, >now I can't CLOSE it because you didn't assign a name to it! :^]). I can get >all the help information as well. It look

Re: virtualenv problem

2013-07-29 Thread alex23
On 26/07/2013 10:25 PM, D. Xenakis wrote: Apparently my problem was that i did not have correctly setup the new path.. But hey - learning is a good thing +1! Also, good job on posting the solution you found as well, that's always helpful if anyone else hits the same problem. Personally, I t

Re: PEP8 79 char max

2013-07-29 Thread Joshua Landau
On 30 July 2013 00:08, Rhodri James wrote: > On Mon, 29 Jul 2013 22:09:10 +0100, Steven D'Aprano < > steve+comp.lang.python@**pearwood.info> > wrote: > > On Mon, 29 Jul 2013 15:43:49 -0400, Devyn Collier Johnson wrote: >> >> In Python programming, the PEP8 recommends limiting lines to a maximum

Re: Bitwise Operations

2013-07-29 Thread Chris Angelico
On Tue, Jul 30, 2013 at 12:48 AM, Devyn Collier Johnson wrote: > Now here is something that confuses me, the binary numbers are numbers not > strings, so why are they put in quotes as if they are strings? They aren't numbers at that point, they're strings of digits. A number is represented in var

Re: Bitwise Operations

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 07:41 PM, Ethan Furman wrote: On 07/29/2013 04:34 PM, Devyn Collier Johnson wrote: On 07/29/2013 05:53 PM, Grant Edwards wrote: On 2013-07-29, Devyn Collier Johnson wrote: On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or',

Re: timing issue: shutil.rmtree and os.makedirs

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 8:16 PM, Tim wrote: > My intent is to pass it a directory name or path and if it exists, use > shutil.rmtree to remove whatever is there (if it isn't a directory, try to > unlink it); then use os.makedirs to create a new directory or path: > > def make_clean_dir(directory

Re: Pyglet on Python3.x, problems

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 4:04 PM, John Ladasky wrote: > pyglet-1.2alpha1/examples/programming_guide/hello_world.py runs fine. > > pyglet-1.2alpha1/examples/programming_guide/image_viewer.py also runs fine. > > pyglet-1.2alpha1/examples/programming_guide/animation.py produces an error. > Here's th

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Devyn Collier Johnson
Thanks everyone for your help. I installed AVbin v10. I no longer get Python errors, but no sound is produced. This is now an AVbin problem that I must figure out. At least I am done with the Python issues. For those of you that need AVbin: http://avbin.github.io/AVbin/Home/Home.html Mahal

Re: Bitwise Operations

2013-07-29 Thread Chris Angelico
On Tue, Jul 30, 2013 at 12:34 AM, Devyn Collier Johnson wrote: > > I understand the symbols. I want to know how to perform the task in a script > or terminal. I have searched Google, but I never saw a command. Typing "101 > & 010" or "x = (int(101, 2) & int(010, 2))" only gives errors. Your probl

Re: Bitwise Operations

2013-07-29 Thread Ethan Furman
On 07/29/2013 04:34 PM, Devyn Collier Johnson wrote: On 07/29/2013 05:53 PM, Grant Edwards wrote: On 2013-07-29, Devyn Collier Johnson wrote: On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or', and 'xor' a binary integer. http://www.google

Re: Bitwise Operations

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 05:53 PM, Grant Edwards wrote: On 2013-07-29, Devyn Collier Johnson wrote: On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or', and 'xor' a binary integer. http://www.google.com/search?q=python+bitwise+operations I understand

Re: import syntax

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 06:37 PM, Joshua Landau wrote: On 29 July 2013 21:23, Devyn Collier Johnson > wrote: On 07/29/2013 04:20 PM, Tim Chase wrote: On 2013-07-29 16:09, Dave Angel wrote: On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote:

Re: Pyglet on Python3.x, problems

2013-07-29 Thread Joshua Landau
On 29 July 2013 23:04, John Ladasky wrote: > For whatever reason, the pyglet package is getting a lot of attention on > c.l.python these past few days. I am guilty of generating some of that > potentially off-topic conversation myself. At the end of my last thread, I > reported that I had found

Re: PEP8 79 char max

2013-07-29 Thread Rhodri James
On Mon, 29 Jul 2013 22:09:10 +0100, Steven D'Aprano wrote: On Mon, 29 Jul 2013 15:43:49 -0400, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character l

Re: PEP8 79 char max

2013-07-29 Thread Ed Leafe
On Jul 29, 2013, at 5:30 PM, Devyn Collier Johnson wrote: > Evidently, it is personal preference. I prefer to read computer code like a > book (yes, I am a weirdo (^u^)). The only time I exced 79 characters is when > I write a set of commands that perform similar tasks. I do not make too many

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Joshua Landau
On 29 July 2013 23:22, Devyn Collier Johnson wrote: > Duh, thanks for the tip (^u^), but I still get an error (different error). > NOTE: this is all python2.7 code because Pyglet supposedly has issues with > Python3. > > collier@Nacho-Laptop:~$ pip install pyglet > Downloading/unpacking pyglet >

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 18:22:02 -0400, Devyn Collier Johnson wrote: > Duh, thanks for the tip (^u^), but I still get an error (different > error). NOTE: this is all python2.7 code because Pyglet supposedly has > issues with Python3. [...] > Traceback (most recent call last): >File "./pymedia.py",

Re: import syntax

2013-07-29 Thread Joshua Landau
On 29 July 2013 21:23, Devyn Collier Johnson wrote: > > On 07/29/2013 04:20 PM, Tim Chase wrote: > >> On 2013-07-29 16:09, Dave Angel wrote: >> >>> On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote: >>> The PEP8 recommends importing like this: import os import re no

Re: PEP8 79 char max

2013-07-29 Thread Joshua Landau
On 29 July 2013 22:34, Steven D'Aprano wrote: > On Mon, 29 Jul 2013 15:18:59 -0500, Ed Leafe wrote: > > > On Jul 29, 2013, at 3:08 PM, Joel Goldstick > > wrote: > >> Not performance, but human readability > > > > IMO, this isn't always the case. There are many lines of code > that are > >

Re: PEP8 79 char max

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 05:42 PM, Steven D'Aprano wrote: On Mon, 29 Jul 2013 16:24:51 -0400, Devyn Collier Johnson wrote: So, I can have a script with large lines and not negatively influence performance on systems that do not use punch cards? You'll negatively influence anyone who has to read, or edit

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 05:08 PM, Gary Herron wrote: On 07/29/2013 01:56 PM, Devyn Collier Johnson wrote: I tried Pyglet in a Python3 and a Python2 script, but both fail. The error code is below and the script is attached. The 'boot.ogg' file is Ubuntu's default bootup sound. I got my code from this lin

Re: PEP8 79 char max

2013-07-29 Thread Joshua Landau
On 29 July 2013 22:18, Skip Montanaro wrote: > For the purposes of limiting the length you need to scan between first > and last column, I would recommend leaving the recommended line length > to ~ 80 columns. > > Just for grins, I grabbed a non-computer book, Atul Gawande's > "Checklist Manifest

Pyglet on Python3.x, problems

2013-07-29 Thread John Ladasky
Hi folks, For whatever reason, the pyglet package is getting a lot of attention on c.l.python these past few days. I am guilty of generating some of that potentially off-topic conversation myself. At the end of my last thread, I reported that I had found the pyglet-users newsgroup, and would

Re: PEP8 79 char max

2013-07-29 Thread Terry Reedy
On 7/29/2013 5:01 PM, Terry Reedy wrote: On 7/29/2013 3:43 PM, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" "plus, limiting windows to 80

Bitwise Operations

2013-07-29 Thread Devyn Collier Johnson
On Python3, how can I perform bitwise operations? For instance, I want something that will 'and', 'or', and 'xor' a binary integer. Mahalo, devyncjohn...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Bitwise Operations

2013-07-29 Thread Grant Edwards
On 2013-07-29, Devyn Collier Johnson wrote: > On Python3, how can I perform bitwise operations? For instance, I want > something that will 'and', 'or', and 'xor' a binary integer. http://www.google.com/search?q=python+bitwise+operations -- Grant Edwards grant.b.edwardsYo

Re: PEP8 79 char max

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 16:24:51 -0400, Devyn Collier Johnson wrote: > So, I can have a script with large lines and not negatively influence > performance on systems that do not use punch cards? You'll negatively influence anyone who has to read, or edit, your code. Very likely including you. But n

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 16:56:06 -0400, Devyn Collier Johnson wrote: > collier@Nacho-Laptop:~$ ./pyglet.py Here you are running a module called pyglet, which I assume you wrote. > Traceback (most recent call last): >File "./pyglet.py", line 2, in > import pyglet And here you try to impor

Re: how to package embedded python?

2013-07-29 Thread Kevin Walzer
On 7/25/13 5:05 PM, David M. Cotter wrote: what must i include in my app package if i'm embedding python? i tried including *everything* in the "DLLs" directory, but my app still crashes as soon as i attempt to initialize python. this is on a system that does not have python installed, as most

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Lee Harr
> $ ./pyglet.py > Traceback (most recent call last): >    File "./pyglet.py", line 2, in >      import pyglet >    File "/home/collier/pyglet.py", line 3, in >      song = pyglet.media.load('./boot.ogg') > AttributeError: 'module' object has no attribute 'media' Name your program something othe

Re: PEP8 79 char max

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 15:18:59 -0500, Ed Leafe wrote: > On Jul 29, 2013, at 3:08 PM, Joel Goldstick > wrote: >> Not performance, but human readability > > IMO, this isn't always the case. There are many lines of code that are > broken up to meet the 79 character limit, and as a result

Re: PEP8 79 char max

2013-07-29 Thread Skip Montanaro
For the purposes of limiting the length you need to scan between first and last column, I would recommend leaving the recommended line length to ~ 80 columns. Just for grins, I grabbed a non-computer book, Atul Gawande's "Checklist Manifesto," from the pile on my desk and counted the number of cha

Re: Has anyone gotten Pyglet to work

2013-07-29 Thread Gary Herron
On 07/29/2013 01:56 PM, Devyn Collier Johnson wrote: I tried Pyglet in a Python3 and a Python2 script, but both fail. The error code is below and the script is attached. The 'boot.ogg' file is Ubuntu's default bootup sound. I got my code from this link (http://guzalexander.com/2012/08/17/playin

Re: Critic my module

2013-07-29 Thread Joshua Landau
On 29 July 2013 19:36, Lele Gaifax wrote: > This thread did not mention alternative and existing modules with > (almost) the same goal, two come to mind: > > * https://pypi.python.org/pypi/sh > * https://pypi.python.org/pypi/sarge Actually, I noted both those and plumbum. -- http://mail.python

Re: PEP8 79 char max

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 15:43:49 -0400, Devyn Collier Johnson wrote: > In Python programming, the PEP8 recommends limiting lines to a maximum > of 79 characters because "There are still many devices around that are > limited to 80 character lines" > (http://www.python.org/dev/peps/pep-0008/#code-lay-o

Re: PEP8 79 char max

2013-07-29 Thread Terry Reedy
On 7/29/2013 3:43 PM, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" "plus, limiting windows to 80 characters makes it possible to have sev

Has anyone gotten Pyglet to work

2013-07-29 Thread Devyn Collier Johnson
I tried Pyglet in a Python3 and a Python2 script, but both fail. The error code is below and the script is attached. The 'boot.ogg' file is Ubuntu's default bootup sound. I got my code from this link (http://guzalexander.com/2012/08/17/playing-a-sound-with-python.html). collier@Nacho-Laptop:~$

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Terry Reedy
On 7/29/2013 1:29 PM, Steven D'Aprano wrote: On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote: In other words, there can be multiple unequal Franctions that have the same float value: for instance, Fraction(1,3) and Fraction(6004799503160661, 18014398509481984) > So from that standpoint

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Jul 29, 2013 1:37 PM, "Serhiy Storchaka" wrote: > > 29.07.13 19:09, MRAB написав(ла): > >> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >> are approximate anyway, and the float value 1/3 is more likely to be >> Fraction(1, 3) than Fraction(6004799503160661, 180143985094

Re: PEP8 79 char max

2013-07-29 Thread John Gordon
In Devyn Collier Johnson writes: > (http://www.python.org/dev/peps/pep-0008/#code-lay-out). What devices > cannot handle 80 or more characters on a line? For a start, older fixed-width dumb terminals and printers. And even some very new devices (tablet, smartphone) might have limited screen

Re: PEP8 79 char max

2013-07-29 Thread Ed Leafe
On Jul 29, 2013, at 3:08 PM, Joel Goldstick wrote: >> Would following >> this recommendation improve script performance? > > Not performance, but human readability IMO, this isn't always the case. There are many lines of code that are broken up to meet the 79 character limit, and as a

Re: PEP8 79 char max

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 04:08 PM, Joel Goldstick wrote: On Mon, Jul 29, 2013 at 3:43 PM, Devyn Collier Johnson wrote: In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" (http://www.p

Re: import syntax

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 04:20 PM, Tim Chase wrote: On 2013-07-29 16:09, Dave Angel wrote: On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote: The PEP8 recommends importing like this: import os import re not like this: import os, re I got a bit further, and if I'm only using a couple of functions fr

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 18:04:19 +0100, MRAB wrote: > I thought that you're not meant to check for equality when using floats. Heavens no. You're only meant to *mostly* not check for equality using floats. As Miracle Max might say: "It just so happens that floats are only MOSTLY inexact. There's a

Re: import syntax

2013-07-29 Thread Tim Chase
On 2013-07-29 16:09, Dave Angel wrote: > On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote: > > The PEP8 recommends importing like this: > > > > import os > > import re > > > > not like this: > > > > import os, re > > I got a bit further, and if I'm only using a couple of functions > from the imp

Re: import syntax

2013-07-29 Thread Tim Chase
On 2013-07-29 15:48, Devyn Collier Johnson wrote: > The PEP8 recommends importing like this: > > import os > import re > > not like this: > > import os, re > > Why is that? Is there a performance advantage to one of the styles? While I don't believe there's much of a performance difference (if

Re: import syntax

2013-07-29 Thread Dave Angel
On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote: The PEP8 recommends importing like this: import os import re not like this: import os, re Why is that? Is there a performance advantage to one of the styles? Pep 8 is not about performance, it's about readability. And unless the two l

Re: PEP8 79 char max

2013-07-29 Thread Joel Goldstick
On Mon, Jul 29, 2013 at 3:43 PM, Devyn Collier Johnson wrote: > In Python programming, the PEP8 recommends limiting lines to a maximum of 79 > characters because "There are still many devices around that are limited to > 80 character lines" (http://www.python.org/dev/peps/pep-0008/#code-lay-out).

Re: import syntax

2013-07-29 Thread Joel Goldstick
On Mon, Jul 29, 2013 at 3:48 PM, Devyn Collier Johnson wrote: > The PEP8 recommends importing like this: > > import os > import re > > not like this: > > import os, re > > Why is that? Is there a performance advantage to one of the styles? > > > Mahalo, > > Devyn Collier Johnson > devyncjohn...@gm

import syntax

2013-07-29 Thread Devyn Collier Johnson
The PEP8 recommends importing like this: import os import re not like this: import os, re Why is that? Is there a performance advantage to one of the styles? Mahalo, Devyn Collier Johnson devyncjohn...@gmail.com -- http://mail.python.org/mailman/listinfo/python-list

PEP8 79 char max

2013-07-29 Thread Devyn Collier Johnson
In Python programming, the PEP8 recommends limiting lines to a maximum of 79 characters because "There are still many devices around that are limited to 80 character lines" (http://www.python.org/dev/peps/pep-0008/#code-lay-out). What devices cannot handle 80 or more characters on a line? Would

Re: collections.Counter surprisingly slow

2013-07-29 Thread Serhiy Storchaka
29.07.13 20:19, Ian Kelly написав(ла): On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote: Also, couldn't Counter just extend from defaultdict? It could, but I expect the C helper function in 3.4 will be faster since it doesn't even need to call __missing__ in the first place. I'm surpris

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 12:16 PM, Rotwang wrote: > On 29/07/2013 17:40, Ian Kelly wrote: >> At the point where the float is exactly equal to the value you get >> from the floating-point division 1/3. > > > But the interpreter has no way of knowing that the value 1/3 that's been > passed to the Fra

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 17:20:27 +0100, Chris Angelico wrote: Fraction(0.3) > Fraction(5404319552844595, 18014398509481984) Fraction(0.33) > Fraction(5944751508129055, 18014398509481984) [...] Fraction(0.3) > Fraction(6004799503160661, 18014398509481984) > > Rounding of

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Serhiy Storchaka
29.07.13 19:09, MRAB написав(ла): I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984). >>> def approximate_fraction(f): prev_numer, numer

timing issue: shutil.rmtree and os.makedirs

2013-07-29 Thread Tim
I have the following function (Python2.7 on FreeBSD) that results in an OSError. My intent is to pass it a directory name or path and if it exists, use shutil.rmtree to remove whatever is there (if it isn't a directory, try to unlink it); then use os.makedirs to create a new directory or path:

Re: Critic my module

2013-07-29 Thread Devyn Collier Johnson
On 07/29/2013 02:36 PM, Lele Gaifax wrote: This thread did not mention alternative and existing modules with (almost) the same goal, two come to mind: * https://pypi.python.org/pypi/sh * https://pypi.python.org/pypi/sarge bye, lele. Thanks everyone for the feedback. Clearly, I should stop my p

Re: [python] email 8bit encoding

2013-07-29 Thread W. Trevor King
On Sun, Jul 28, 2013 at 04:41:27PM -0700, ru...@yahoo.com wrote: > How, using Python-3.3's email module, do I "flatten" (I think > that's the right term) a Message object to get utf-8 encoded > body with the headers: > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > wh

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Grant Edwards
On 2013-07-29, MRAB wrote: > On 29/07/2013 17:40, Ian Kelly wrote: >> On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: >>> On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float val

Re: Critic my module

2013-07-29 Thread Lele Gaifax
This thread did not mention alternative and existing modules with (almost) the same goal, two come to mind: * https://pypi.python.org/pypi/sh * https://pypi.python.org/pypi/sarge bye, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Rotwang
On 29/07/2013 17:20, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984).

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Rotwang
On 29/07/2013 17:40, Ian Kelly wrote: On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3)

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 11:04 AM, MRAB wrote: > On 29/07/2013 17:40, Ian Kelly wrote: >> At the point where the float is exactly equal to the value you get >> from the floating-point division 1/3. If it's some other float then >> the user didn't get there by entering 1/3, so it's not worth trying

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 13:08:20 -0400, Terry Reedy wrote: > In other words, there can be multiple unequal Franctions that have the > same float value: for instance, Fraction(1,3) and > Fraction(6004799503160661, 18014398509481984) > > > So from that standpoint it makes sense to me to cast to Fracti

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Steven D'Aprano
On Mon, 29 Jul 2013 17:48:21 +0100, MRAB wrote: > On 29/07/2013 17:20, Chris Angelico wrote: >> On Mon, Jul 29, 2013 at 5:09 PM, MRAB >> wrote: >>> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >>> are approximate anyway, and the float value 1/3 is more likely to be >>> Fr

Re: collections.Counter surprisingly slow

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 5:49 AM, Joshua Landau wrote: > Also, couldn't Counter just extend from defaultdict? It could, but I expect the C helper function in 3.4 will be faster since it doesn't even need to call __missing__ in the first place. And the cost (both in terms of maintenance and run-tim

Re: What do you do when a library is outdated?

2013-07-29 Thread Terry Reedy
On 7/29/2013 12:14 PM, Matt wrote: I'm fairly new to python but have experience in other languages. What do you generally do when a library is outdated? I asked a question on a few forums and everyone has been pointing me to Mechanize, but it will not work with 3.3 What do you do? Update it yo

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 5:40 PM, Ian Kelly wrote: > On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: >> On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: >>> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >>> are approximate anyway, and the float value 1/3 is more likely

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Terry Reedy
On 7/29/2013 11:50 AM, Ian Kelly wrote: On Mon, Jul 29, 2013 at 9:43 AM, Steven D'Aprano wrote: Comparing floats to Fractions gives unexpected results: # Python 3.3 py> from fractions import Fraction py> 1/3 == Fraction(1, 3) False but: py> 1/3 == float(Fraction(1, 3)) True I expected that

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 17:40, Ian Kelly wrote: On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3)

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 10:20 AM, Chris Angelico wrote: > On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: >> I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats >> are approximate anyway, and the float value 1/3 is more likely to be >> Fraction(1, 3) than Fraction(6004799503160661,

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 17:20, Chris Angelico wrote: On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats are approximate anyway, and the float value 1/3 is more likely to be Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984).

Re: What do you do when a library is outdated?

2013-07-29 Thread Matt
On Monday, July 29, 2013 12:34:08 PM UTC-4, Chris Angelico wrote: > On Mon, Jul 29, 2013 at 5:14 PM, Matt wrote: > > > I'm fairly new to python but have experience in other languages. What do > > you generally do when a library is outdated? I asked a question on a few > > forums and everyone ha

Re: AssertionError: Headers already set! Status: 500 Internal Server Error Content-Type: text/plain Content-Length: 59

2013-07-29 Thread Terry Reedy
On 7/29/2013 8:55 AM, Jaiky wrote: learning web concpt in python wrote code in /usr/lib/cgi-bin/hello_world.py ### #!/usr/bin/env python import webapp2 This is an external package. form =""" http://www/google.com/

Re: FSR and unicode compliance - was Re: RE Module Performance

2013-07-29 Thread wxjmfauth
Le lundi 29 juillet 2013 16:49:34 UTC+2, Chris Angelico a écrit : > On Mon, Jul 29, 2013 at 3:20 PM, wrote: > > >>c:\python32\pythonw -u "timitmod.py" > > > 15.258061416225663 > > >>Exit code: 0 > > >>c:\Python33\pythonw -u "timitmod.py" > > > 17.052203122286194 > > >>Exit code: 0 > > >

Re: What do you do when a library is outdated?

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 5:14 PM, Matt wrote: > I'm fairly new to python but have experience in other languages. What do you > generally do when a library is outdated? I asked a question on a few forums > and everyone has been pointing me to Mechanize, but it will not work with 3.3 > > What do yo

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 5:09 PM, MRAB wrote: > I'm surprised that Fraction(1/3) != Fraction(1, 3); after all, floats > are approximate anyway, and the float value 1/3 is more likely to be > Fraction(1, 3) than Fraction(6004799503160661, 18014398509481984). At what point should it become Fraction(

Re: how to package embedded python?

2013-07-29 Thread David M. Cotter
nooobody knw the trouble a s... -- http://mail.python.org/mailman/listinfo/python-list

What do you do when a library is outdated?

2013-07-29 Thread Matt
I'm fairly new to python but have experience in other languages. What do you generally do when a library is outdated? I asked a question on a few forums and everyone has been pointing me to Mechanize, but it will not work with 3.3 What do you do? -- http://mail.python.org/mailman/listinfo/pyt

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread MRAB
On 29/07/2013 16:43, Steven D'Aprano wrote: Comparing floats to Fractions gives unexpected results: # Python 3.3 py> from fractions import Fraction py> 1/3 == Fraction(1, 3) False but: py> 1/3 == float(Fraction(1, 3)) True I expected that float-to-Fraction comparisons would convert the Fract

Re: MyOpenID.com no longer supported

2013-07-29 Thread Ethan Furman
On 07/29/2013 02:11 AM, Antoine Pitrou wrote: Le Mon, 29 Jul 2013 00:55:53 -0700, Ethan Furman a écrit : Excerpt from http://meta.stackoverflow.com/q/190442/176681: Janrain no longer actively supports MyOpenID, and announced on Twitter that their users should proceed with caution. This decisi

Re: Unexpected results comparing float to Fraction

2013-07-29 Thread Ian Kelly
On Mon, Jul 29, 2013 at 9:43 AM, Steven D'Aprano wrote: > Comparing floats to Fractions gives unexpected results: > > # Python 3.3 > py> from fractions import Fraction > py> 1/3 == Fraction(1, 3) > False > > but: > > py> 1/3 == float(Fraction(1, 3)) > True > > > I expected that float-to-Fraction c

Unexpected results comparing float to Fraction

2013-07-29 Thread Steven D'Aprano
Comparing floats to Fractions gives unexpected results: # Python 3.3 py> from fractions import Fraction py> 1/3 == Fraction(1, 3) False but: py> 1/3 == float(Fraction(1, 3)) True I expected that float-to-Fraction comparisons would convert the Fraction to a float, but apparently they do the op

Re: FSR and unicode compliance - was Re: RE Module Performance

2013-07-29 Thread Chris Angelico
On Mon, Jul 29, 2013 at 3:20 PM, wrote: >>c:\python32\pythonw -u "timitmod.py" > 15.258061416225663 >>Exit code: 0 >>c:\Python33\pythonw -u "timitmod.py" > 17.052203122286194 >>Exit code: 0 >>> len(dir(C)) Did you even think to check that before you posted timings? ChrisA -- http://mail.pytho

Re: dynamic type returning NameError:

2013-07-29 Thread Tim O'Callaghan
On Monday, July 29, 2013 1:43:39 AM UTC-4, Steven D'Aprano wrote: > On Sun, 28 Jul 2013 18:38:10 -0700, Tim O'Callaghan wrote: > > > > > Hi, > > > > > > I hope that this hasn't been asked for the millionth time, so my > > > apologies if it has. > > [...] > > > I hope that this was clear en

Re: FSR and unicode compliance - was Re: RE Module Performance

2013-07-29 Thread wxjmfauth
Le lundi 29 juillet 2013 13:57:47 UTC+2, Chris Angelico a écrit : > On Mon, Jul 29, 2013 at 12:43 PM, wrote: > > > Le dimanche 28 juillet 2013 22:52:16 UTC+2, Steven D'Aprano a écrit : > > > 3.2 > > timeit.timeit("r = dir(list)") > > > 22.300465007102908 > > > > > > 3.3 > > timei

  1   2   >