RE: Accelerating For Loop

2011-02-22 Thread Şansal Birbaş
Nothing changed, Mr. Chris -Original Message- From: ch...@rebertia.com [mailto:ch...@rebertia.com] On Behalf Of Chris Rebert Sent: Wednesday, February 23, 2011 9:37 AM To: Şansal Birbaş Cc: python-list@python.org Subject: Re: Accelerating For Loop 2011/2/22 Şansal Birbaş : > Hi All, > > I

Re: Accelerating For Loop

2011-02-22 Thread Chris Rebert
2011/2/22 Şansal Birbaş : > Hi All, > > I needed to find the cheapest combination among given data and I developed > an algorithm for this task. It works correctly. But it takes much time > (nearly 2 minutes) for second function to find the result while it is just > one second for the first functio

Another lxml.objectify question

2011-02-22 Thread Johann Spies
Stefan has helped me in the past to make some progress on using lxml.objectify. I am trying to parse xml to create sql-compatible data. My problem is that the xml records are not consistant: some might have tags that does not appear in others. That makes it very difficult for me to setup an ex

Re: Looking for some PyPI query help

2011-02-22 Thread Martin v. Loewis
Am 23.02.2011 07:53, schrieb Travis Griggs: > Howdy Python brethren. I'm a Smalltalker, doing a bit of research on > packaging ecospaces, in other languages and environments (I just > finished examining Debian for example). I found what seems to be the > big repository at PyPI. Correct. There is a

Looking for some PyPI query help

2011-02-22 Thread Travis Griggs
Howdy Python brethren. I'm a Smalltalker, doing a bit of research on packaging ecospaces, in other languages and environments (I just finished examining Debian for example). I found what seems to be the big repository at PyPI. What would be enough for me, is to enumerate all of the packages ther

Re: python and parsing an xml file

2011-02-22 Thread Stefan Behnel
John Nagle, 22.02.2011 23:56: On 2/21/2011 2:08 PM, Matt Funk wrote: On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not su

Re: ctypes inheritance issue

2011-02-22 Thread Carl Banks
Steve wrote: > I've filed a bug in python but I wanted to see if other ctypes users/ > experts viewed this issue as a bug. > Consider the following: > python code: > import ctypes > class my_array( ctypes.Array ): > _type_= ctypes.c_uint8 > _length_ = 256 > > class my_array2( my_array

Accelerating For Loop

2011-02-22 Thread Şansal Birbaş
Hi All, I needed to find the cheapest combination among given data and I developed an algorithm for this task. It works correctly. But it takes much time (nearly 2 minutes) for second function to find the result while it is just one second for the first function. How can I improve the calculatio

Re: Python programming books

2011-02-22 Thread John Bokma
David Keeler writes: > I am relatively new to python. I've been reading online docs and > tutorials for 4-5 weeks now, but I like actual books. I am not new to > programming and I have worked with quite a few languages. I'd like a > good reference with basic stuff including classes and maybe some

Re: Is setdefaultencoding bad?

2011-02-22 Thread Nobody
On Tue, 22 Feb 2011 19:34:21 -0800, moerchendiser2k3 wrote: > Hi, I embedded Py2.6.1 in my app and I use UTF-8 encoded strings > everywhere in the interface, so the interface between my app and > Python is UTF-8 so I can simply write: > > print u"\uC042" > print u"\uC042".encode("utf_8") > > and

Is setdefaultencoding bad?

2011-02-22 Thread moerchendiser2k3
Hi, I embedded Py2.6.1 in my app and I use UTF-8 encoded strings everywhere in the interface, so the interface between my app and Python is UTF-8 so I can simply write: print u"\uC042" print u"\uC042".encode("utf_8") and get the corresponding chinese char in the console. But currently sys.default

Re: subprocess pipe question

2011-02-22 Thread Rita
Thanks everyone for your replies. Chris, Unfortunately, I can't redirect the output to a file because there are other processes which use this processes output as stdin. Rob, I will give this a try. On Tue, Feb 22, 2011 at 7:48 PM, Chris Kaynor wrote: > > On Tue, Feb 22, 2011 at 3:44 PM, Rita

Re: Dictionary with additional attributes

2011-02-22 Thread goodman
On Feb 22, 1:32 pm, Robert Kern wrote: > On 2/22/11 1:49 PM, goodman wrote: > > > Hi, my question is this: Is it a bad idea to create a wrapper class > > for a dictionary so I can add attributes? > > Nope. I do recommend adding a custom __repr__(), though. > Good point. Thanks -- http://mail.pyt

Re: Python programming books

2011-02-22 Thread Terry Reedy
On 2/22/2011 7:54 PM, David Keeler wrote: I am relatively new to python. I've been reading online docs and tutorials for 4-5 weeks now, but I like actual books. I am not new to programming and I have worked with quite a few languages. I'd like a good reference with basic stuff including classes a

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Ned Deily
In article <4d640175$0$81482$e4fe5...@news.xs4all.nl>, Irmen de Jong wrote: > However, I'm having trouble compiling a framework build from source on > Mac OS 10.5.8 on PowerPC. No matter what I try (gcc 4.0, gcc 4.2, > different compiler options), the compilation aborts with the following > e

C12

2011-02-22 Thread Verde Denim
Anyone on the list have decent knowledge of C12 ? Please send me an email if you've got knowledge in this area. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python fails on math

2011-02-22 Thread Terry Reedy
On 2/22/2011 2:42 PM, Grant Edwards wrote: Except that Python (and computer languages in general) don't deal with real numbers. They deal with floating point numbers, which aren't the same thing. [In case anybody is still fuzzy about that.] In particular, floats are a fixed finite set of rat

Re: subprocess pipe question

2011-02-22 Thread Rob Williscroft
Rita wrote in news:AANLkTi=w95gxosc1tkt2bntgjqys1cbmdnojhokq4...@mail.gmail.com in gmane.comp.python.general: > > When using wait() it works a bit better but not consistent > def run(cmd): > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > rc=p.wait() > print rc > return p.stdout > > W

Python programming books

2011-02-22 Thread David Keeler
I am relatively new to python. I've been reading online docs and tutorials for 4-5 weeks now, but I like actual books. I am not new to programming and I have worked with quite a few languages. I'd like a good reference with basic stuff including classes and maybe some web programming, sockets, tkin

Re: subprocess pipe question

2011-02-22 Thread Chris Kaynor
On Tue, Feb 22, 2011 at 3:44 PM, Rita wrote: > I have a process like this, > > def run(cmd): > #cmd=a process which writes a lot of data. Binary/ASCII data > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > > I would like to get cmd's return code so I am doing this, > > def run(cmd): > p=su

Re: subprocess pipe question

2011-02-22 Thread GMail Felipe
On 22/02/2011, at 20:44, Rita wrote: > I have a process like this, > > def run(cmd): > #cmd=a process which writes a lot of data. Binary/ASCII data > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > > I would like to get cmd's return code so I am doing this, > > def run(cmd): > p=subpro

ANN: ActivePython 3.2.0.0 is now available

2011-02-22 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 3.2.0.0, a complete, ready-to-install binary distribution of Python 3.2. http://www.activestate.com/activepython/downloads What's New in ActivePython-3.2.0.0 == New Features & Upgrades --- -

subprocess pipe question

2011-02-22 Thread Rita
I have a process like this, def run(cmd): #cmd=a process which writes a lot of data. Binary/ASCII data p=subprocess.Popen(cmd,stdout=subprocess.PIPE) I would like to get cmd's return code so I am doing this, def run(cmd): p=subprocess.Popen(cmd,stdout=subprocess.PIPE) rc=p.poll() print

ctypes inheritance issue

2011-02-22 Thread Steve
I've filed a bug in python but I wanted to see if other ctypes users/ experts viewed this issue as a bug. Consider the following: python code: import ctypes class my_array( ctypes.Array ): _type_= ctypes.c_uint8 _length_ = 256 class my_array2( my_array ): pass Output: class my_ar

Re: python and parsing an xml file

2011-02-22 Thread John Nagle
On 2/21/2011 2:08 PM, Matt Funk wrote: Hi Terry, On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not sure how to answer thi

python cgi webpage won't redirect before background children processes finish

2011-02-22 Thread Yingjie Lin
Hi all, I have a python cgi script which looks like this: [CODE STARTING HERE] open('x') print 'Content-Type: text/html\n\n' .. print '' % myURL .. ### after printing the webpage os.system('python myfile.py') logfile.write('END OF SCRIPT') logfile.close() [CODE ENDING] Question:

Re: Pickle compatibility between Python 2.7 and python 3.2

2011-02-22 Thread Michel Claveau - MVP
Hi! I am, also, very interested in the answers. Thank you for asking this question. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Python fails on math

2011-02-22 Thread christian schulze
On 22 Feb., 21:18, Stephen Hansen wrote: > On 2/22/11 5:20 AM, christian schulze wrote: > > > I just found out, how much Python fails on simple math. > 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > > Everyone else has answered very well, so I won't comment on the actual > question at hand-- it see

Re: Dictionary with additional attributes

2011-02-22 Thread Santoso Wijaya
Instead of inheriting a dict, why not composing a dict into your "model" class, like: class Model(object): def __init__(self, *args, **kwargs): self._probabilities = defaultdict(lambda: defaultdict(float)) @property def features(self): # insert

Re: Dictionary with additional attributes

2011-02-22 Thread Robert Kern
On 2/22/11 1:49 PM, goodman wrote: Hi, my question is this: Is it a bad idea to create a wrapper class for a dictionary so I can add attributes? Nope. I do recommend adding a custom __repr__(), though. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Irmen de Jong
On 22-02-11 21:27, Benjamin Kaplan wrote: There really isn't a "Macports build". Macports just downloads the source tarball and compiles it locally. It's only doing three things compared to compiling it yourself: update checking, dependency tracking, and applying some patches for problems that h

Re: Python fails on math

2011-02-22 Thread sturlamolden
On 22 Feb, 14:20, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. Python does not fail. Floating point arithmetics and numerical approximations will do this. If you need symbolic maths, consider using the

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 2:54 PM, Irmen de Jong wrote: > On 22-02-11 19:57, Benjamin Kaplan wrote: > >> Have you tried compiling it with Macports? The port file is too much >> of a mess for me to figure out exactly what is getting called in what >> circumstances, but whatever they're doing probably

Dictionary with additional attributes

2011-02-22 Thread goodman
Hi, my question is this: Is it a bad idea to create a wrapper class for a dictionary so I can add attributes? E.g.: class DictWithAttrs(dict): pass More information: I'm using a nested defaultdict to store a machine-learning model, where the first key is a class, the second key is a feature,

Re: Python fails on math

2011-02-22 Thread Stephen Hansen
On 2/22/11 5:20 AM, christian schulze wrote: > I just found out, how much Python fails on simple math. 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) Everyone else has answered very well, so I won't comment on the actual question at hand-- it seems to have been answered completely. But! I shall go

Re: Whats new in Python 3: concurrent-futures example error?

2011-02-22 Thread Paddy
My thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing dependencies in Windows

2011-02-22 Thread John Gordon
In RVince writes: > Im installing to a Win7 machine, duplicating a CentOS setup. The > dependences in CentOs for a particular project are: > _ldap.so > dsml.py > easy-install.pth > ldap > ldapurl.py > ldapurl.pyc > ldapurl.pyo > ldif.py > libxml2.py > libxml2.pyc > libxml2mod.a > libxml2mod.la

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Irmen de Jong
On 22-02-11 19:57, Benjamin Kaplan wrote: Have you tried compiling it with Macports? The port file is too much of a mess for me to figure out exactly what is getting called in what circumstances, but whatever they're doing probably works. I have not, and I don't intend to. I figure Python.org'

Re: Python fails on math

2011-02-22 Thread Grant Edwards
On 2011-02-22, Ian Kelly wrote: > On Tue, Feb 22, 2011 at 9:54 AM, David C. Ullrich > wrote: >> Anyway, I don't know why you're jumping to the conclusion that it's >> Python that's wrong here. Could be the math you learned in school >> is wrong. I mean you're assuming that >> >> (*) ? ? ? a(b+c)

Re: Python fails on math

2011-02-22 Thread Grant Edwards
On 2011-02-22, Roy Smith wrote: > In article , > Grant Edwards wrote: > >> Python doesn't do equations. Python does floating point operations. > > More generally, all general-purpose programming languages have the same > problem. You'll see the same issues in Fortran, C, Java, Ruby, Pascal,

Re: python and parsing an xml file

2011-02-22 Thread Matt Funk
One thing i forgot, in case anyone is at this point: the reason i chose ConfigObj over ConfigParser is that it allows subsections. matt On 2/22/2011 4:01 AM, Ian wrote: > On 21/02/2011 22:08, Matt Funk wrote: >>> Why? >> mmmh. not sure how to answer this question exactly. I guess it's a >> design

Re: python and parsing an xml file

2011-02-22 Thread Matt Funk
Hi, first of all thanks everyone for the (at least to me) valuable discussion about xml and its usage domain. Also thanks for all the hints and suggestions. In terms of my problems, from what i can tell right now the ConfigObj4 (see: http://www.voidspace.org.uk/python/configobj.html#reading-a-confi

Re: How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 1:33 PM, Irmen de Jong wrote: > On 20-02-11 23:22, Georg Brandl wrote: >> >> On behalf of the Python development team, I'm delighted to announce >> Python 3.2 final release. > > Thanks to all the people who worked on this. > > However, I'm having trouble compiling a framewo

How to compile on OS X PPC? was: Re: [RELEASED] Python 3.2

2011-02-22 Thread Irmen de Jong
On 20-02-11 23:22, Georg Brandl wrote: On behalf of the Python development team, I'm delighted to announce Python 3.2 final release. Thanks to all the people who worked on this. However, I'm having trouble compiling a framework build from source on Mac OS 10.5.8 on PowerPC. No matter what I

Re: Python fails on math

2011-02-22 Thread Ian Kelly
On Tue, Feb 22, 2011 at 9:54 AM, David C. Ullrich wrote: > Anyway, I don't know why you're jumping to the conclusion that it's > Python that's wrong here. Could be the math you learned in school > is wrong. I mean you're assuming that > > (*)       a(b+c) = ab + ac > > but what makes you so certai

Re: Python fails on math

2011-02-22 Thread Roy Smith
In article , Grant Edwards wrote: > Python doesn't do equations. Python does floating point operations. More generally, all general-purpose programming languages have the same problem. You'll see the same issues in Fortran, C, Java, Ruby, Pascal, etc, etc. You'll see the same problem if yo

Re: running Python code from external application

2011-02-22 Thread Santoso Wijaya
Sounds like an embedding job. Have you taken a look at this documentation ? ~/santa On Tue, Feb 22, 2011 at 4:30 AM, Nadav Chernin wrote: > Hello, > > I need to run Python code from external application. In this external > application i have 2 options to run:

Re: Python fails on math

2011-02-22 Thread Grant Edwards
On 2011-02-22, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. Python doesn't do math. It does floating point operations. They're different. Seriously. On all of the platforms I know of, it's IEEE 754 (base-2) floating point. > I checked a sim

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Sathish S
Oops, i got the wrong person. Thanks Peter. I was able to achieve the blinking functionality. Thanks, Sathish On Tue, Feb 22, 2011 at 10:44 PM, Peter Otten <__pete...@web.de> wrote: > Terry Reedy wrote: > > > On 2/22/2011 6:50 AM, Peter Otten wrote: > >> import Tkinter as tk > >> from itertool

Dynamic imports + relative imports in Python 3

2011-02-22 Thread zildjohn01
This is a copy-paste of a StackOverflow question. Nobody answered there, but I figured I might have better luck here. I have a Python 3 project where I'm dynamically importing modules from disk, using `imp.load_module`. But, I've run into an problem where relative imports fail, when the relative i

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Sathish S
Jeff, Thanks a lot. It worked great for me as well. Thanks, Sathish On Tue, Feb 22, 2011 at 10:28 PM, Jeff Hobbs wrote: > On Feb 22, 8:48 am, Terry Reedy wrote: > > On 2/22/2011 6:50 AM, Peter Otten wrote: > > > > > import Tkinter as tk > > > from itertools import cycle > > > > > root = tk.T

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Peter Otten
Terry Reedy wrote: > On 2/22/2011 6:50 AM, Peter Otten wrote: >> import Tkinter as tk >> from itertools import cycle >> >> root = tk.Tk() >> text = tk.Text(root, font=("Helvetica", 70)) >> text.pack() >> >> text.insert(tk.END, "Hello, geocities") >> text.tag_add("initial", "1.0", "1.1") >> text.ta

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Jeff Hobbs
On Feb 22, 8:48 am, Terry Reedy wrote: > On 2/22/2011 6:50 AM, Peter Otten wrote: > > > import Tkinter as tk > > from itertools import cycle > > > root = tk.Tk() > > text = tk.Text(root, font=("Helvetica", 70)) > > text.pack() > > > text.insert(tk.END, "Hello, geocities") > > text.tag_add("initial

Installing dependencies in Windows

2011-02-22 Thread RVince
Im installing to a Win7 machine, duplicating a CentOS setup. The dependences in CentOs for a particular project are: _ldap.so dsml.py easy-install.pth ldap ldapurl.py ldapurl.pyc ldapurl.pyo ldif.py libxml2.py libxml2.pyc libxml2mod.a libxml2mod.la libxml2mod.so libxslt.py libxslt.pyc libxsltmod.a

Re: Python fails on math

2011-02-22 Thread David C. Ullrich
In article <127fc97e-c210-4df1-952c-f6383d44b...@o8g2000vbq.googlegroups.com>, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. > > [code] > >>> from math import e as e > >>> from math import sqrt as s

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Terry Reedy
On 2/22/2011 6:50 AM, Peter Otten wrote: import Tkinter as tk from itertools import cycle root = tk.Tk() text = tk.Text(root, font=("Helvetica", 70)) text.pack() text.insert(tk.END, "Hello, geocities") text.tag_add("initial", "1.0", "1.1") text.tag_add("initial", "1.7", "1.8") colors = cycle("

Re: Creating Long Lists

2011-02-22 Thread Terry Reedy
On 2/22/2011 4:40 AM, Kelson Zawack wrote: The answer it turns out is the garbage collector. When I disable the garbage collector before the loop that loads the data into the list and then enable it after the loop the program runs without issue. This raises a question though, can the logic of th

Re: Whats new in Python 3: concurrent-futures example error?

2011-02-22 Thread Terry Reedy
On 2/22/2011 4:45 AM, Paddy wrote: I just noted the example here: http://docs.python.org/dev/whatsnew/3.2.html#pep-3148-the-concurrent-futures-module import concurrent.futures, shutil with concurrent.futures.ThreadPoolExecutor(max_workers=4) as e: e.submit(shutil.copy, 'src1.txt', 'dest1.tx

Re: Making Line Graphs

2011-02-22 Thread Andrea Crotti
On Feb 22, 4:28 pm, Paul Anton Letnes wrote: > +1, I like matplotlib a lot. Consider python(x,y) as an easy install > path. It both shows plots interactively and let you save to file. I even > use it for publications. > > Paul. +1 for matplotlib, incredibly powerful and (if you know a bit about

reading lines from non-terminating subprocess; threading, gtk

2011-02-22 Thread jfcg
Greetings, I am using Python 2.6 on Ubuntu. I have a problem with simultaneously reading lines from stdout of a subprocess. listargs.c: #include #include int main (int argc, char ** argv) { int i; // while (1) for (i=0; i1: print 'O', l, #

Re: Making Line Graphs

2011-02-22 Thread Paul Anton Letnes
Den 21.02.11 10.34, skrev Jean-Michel Pichavant: spam head wrote: I'm looking for an easy way to display simple line graphs generated by a python program in Windows. It could be done from within the program, or I could write the information out to a file and call an external program. Either is f

Re: PY-Tkinter Title Bar Icon

2011-02-22 Thread Terry Reedy
On 2/21/2011 7:06 AM, Ganesh Kumar wrote: Hai.. I am new to python Tkinter..I want Title Bar Icon.. plz..Guide me to set up icon in Title Bar. Search the tkinter doc for 'icon'. Then look at one of the references for details. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/p

Re: How to use Python well?

2011-02-22 Thread Grant Edwards
On 2011-02-20, Chris Jones wrote: > On Sat, Feb 19, 2011 at 05:27:24PM EST, Cameron Simpson wrote: > > [..] > >> Any yet I (and others, based on stuff I've seen) find info to be a >> disaster. Why? >> >> - it forces the reader to use a non-standard pager to look >>at info, typically the utte

Re: ANN: pyTenjin 1.0.0 - a high-speed and full-featured template engine

2011-02-22 Thread Dhaivat Pandya
On Feb 21, 8:15 pm, Makoto Kuwata wrote: > Hi all, > > I released pyTenjin > 1.0.0.http://pypi.python.org/pypi/Tenjin/http://www.kuwata-lab.com/tenjin/ > > This release contains a lot of enhancements and changes. > > Overview > > > * Very fast: about 10 times faster than Django template

Re: "ImportError: No module named gobject"

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 9:20 AM, J. Gerlach wrote: > Am 21.02.2011 16:04, schrieb Luther: >> I've tried installing pygtk, pygobject, and gobject-introspection from >> source, but none of them will compile, and nothing I install through >> synaptic has any effect. >> >> I've tried too many things t

PY-Tkinter Title Bar Icon

2011-02-22 Thread Ganesh Kumar
Hai.. I am new to python Tkinter..I want Title Bar Icon.. plz..Guide me to set up icon in Title Bar. Advance Thanks Thanks -Ganesh. -- Did I learn something today? If not, I wasted it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2 or 3 ? with Django , My SQL and YUI

2011-02-22 Thread Dhaivat Pandya
On Feb 21, 11:01 pm, Sumit wrote: > Python 2 or 3 ? with Django , My SQL and YUI > > For a web project We have decided to work on Python 2 or 3 ? with > Django , My SQL and YUI, and this would be the first time to work with > Python, just now I explored a little and found Python -2 vs 3 Stuff , >

Re: Python fails on math

2011-02-22 Thread Duncan Booth
christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. > > [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > False > [/code] > Try the same i

Re: "ImportError: No module named gobject"

2011-02-22 Thread J. Gerlach
Am 21.02.2011 16:04, schrieb Luther: > I've tried installing pygtk, pygobject, and gobject-introspection from > source, but none of them will compile, and nothing I install through > synaptic has any effect. > > I've tried too many things to post all the details here, but I'll post > any details o

Re: Python fails on math

2011-02-22 Thread Jean-Michel Pichavant
christian schulze wrote: Hey guys, I just found out, how much Python fails on simple math. I checked a simple equation for a friend. [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) e has no accurate representation in computer science. Nei

Re: Python fails on math

2011-02-22 Thread Ian
On 22/02/2011 13:20, christian schulze wrote: Hey guys, I just found out, how much Python fails on simple math. I checked a simple equation for a friend. [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) False [/code] So WTF? The equation is

Re: Python fails on math

2011-02-22 Thread Benjamin Kaplan
On Tue, Feb 22, 2011 at 8:20 AM, christian schulze wrote: > Hey guys, > > I just found out, how much Python fails on simple math. I checked a > simple equation for a friend. > > [code] from math import e as e from math import sqrt as sqrt 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > Fal

Re: Python fails on math

2011-02-22 Thread Tim Wintle
On Tue, 2011-02-22 at 05:20 -0800, christian schulze wrote: > [code] > >>> from math import e as e > >>> from math import sqrt as sqrt > >>> 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) > False > [/code] > I was wondering what exactly is failing here. The math module? Python, > or the IEEE specification

Re: Python fails on math

2011-02-22 Thread Mel
christian schulze wrote: > #1: 2.0 * e * sqrt(3.0) - 2.0 * e > 3.9798408154464964 > > #2: 2.0 * e * (sqrt(3.0) -1.0) > 3.979840815446496 > > I was wondering what exactly is failing here. The math module? Python, > or the IEEE specifications? Limited-precision calculation, computer flo

Re: Python fails on math

2011-02-22 Thread Grigory Javadyan
-- Forwarded message -- From: Grigory Javadyan Date: Tue, Feb 22, 2011 at 5:32 PM Subject: Re: Python fails on math To: christian schulze Everybody knows you can't just compare floating point values for equality with a simple ==. Instead, check that the difference between them i

Re: Python fails on math

2011-02-22 Thread Nitin Pawar
You may want to restrict the result to certain limit in the floating numbers each system has its own levels of floating numbers and even a small difference is a difference to return FALSE On Tue, Feb 22, 2011 at 6:50 PM, christian schulze wrote: > Hey guys, > > I just found out, how much Python

Python fails on math

2011-02-22 Thread christian schulze
Hey guys, I just found out, how much Python fails on simple math. I checked a simple equation for a friend. [code] >>> from math import e as e >>> from math import sqrt as sqrt >>> 2*e*sqrt(3) - 2*e == 2*e*(sqrt(3) - 1) False [/code] So WTF? The equation is definitive equivalent. (See http://mat

Re: return an object of a different class

2011-02-22 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 21 Feb 2011 14:23:10 +0100, Jean-Michel Pichavant wrote: What is not legit, is to return different objects for which the caller has to test the type to know what attributes he can use. Well, I don't know... I'm of two minds. On the one hand, I find it *

Re: python and parsing an xml file

2011-02-22 Thread Paul Anton Letnes
Den 22.02.11 13.29, skrev pyt...@bdurham.com: Paul, How about skipping the whole xml thing? You can dynamically import any python module, even if it does not have a python filename. Great example! Can you do the same with a cStringIO based file that exists in memory vs. on disk? Your exampl

Execute bit in .tar.gz file produced by distutils

2011-02-22 Thread Dan Goodman
Hi all, I have a problem with using distutils and was hoping someone might be able to help. The .exe and .zip files work fine - and easy_install uses the .zip file by default it seems - but in the .tar.gz file the execute bit is not set for any directories meaning a user on linux has to go th

running Python code from external application

2011-02-22 Thread Nadav Chernin
Hello, I need to run Python code from external application. In this external application i have 2 options to run: DLL or COM. Can i create dll or com from the Python code? Or how can i use Python27.dll to call the script and get returned values? Thanks -- http://mail.python.org/mailman/listin

Re: python and parsing an xml file

2011-02-22 Thread python
Paul, > How about skipping the whole xml thing? You can dynamically import any python > module, even if it does not have a python filename. Great example! Can you do the same with a cStringIO based file that exists in memory vs. on disk? Your example requires a physical file on disk. Is it poss

Re: Tkinter Text Widget Background Color

2011-02-22 Thread Peter Otten
Sathish S wrote: > Hi Ppl, > > I'm using the Tkinter Text Widget in my user interface. I'm trying to > create a blinking effect for this Text Widget. I saw from the > documentation I can set the color if the widget when I create it. > > x=Text(root,bg='#CFF') > > However, I couldn't find any pr

Re: python and parsing an xml file

2011-02-22 Thread Ian
On 21/02/2011 22:08, Matt Funk wrote: Why? mmmh. not sure how to answer this question exactly. I guess it's a design decision. I am not saying that it is best one, but it seemed suitable to me. I am certainly open to suggestions. But here are some requirements: 1) My boss needs to be able to rea

Re: Creating Long Lists

2011-02-22 Thread Kelson Zawack
I am using python 2.6.2, so it may no longer be a problem. I am open to using another data type, but the way I read the documentation array.array only supports numeric types, not arbitrary objects. I also tried playing around with numpy arrays, albeit for only a short time, and it seems that alth

Re: LDFLAGS problem

2011-02-22 Thread Robin Becker
On 21/02/2011 22:46, Stefan Krah wrote: error: command 'gcc' failed with exit status 1 where should I be looking to fix this problem? Try the patch from http://bugs.python.org/issue10547 or use an svn checkout. The patch didn't make it into 2.7.1. Stefan Krah well that fixes thin

Tkinter Text Widget Background Color

2011-02-22 Thread Sathish S
Hi Ppl, I'm using the Tkinter Text Widget in my user interface. I'm trying to create a blinking effect for this Text Widget. I saw from the documentation I can set the color if the widget when I create it. x=Text(root,bg='#CFF') However, I couldn't find any property or function that set's the ba

Re: Creating Long Lists

2011-02-22 Thread Peter Otten
Kelson Zawack wrote: > The answer it turns out is the garbage collector. When I disable the > garbage collector before the loop that loads the data into the list > and then enable it after the loop the program runs without issue. > This raises a question though, can the logic of the garbage colle

Re: Creating Long Lists

2011-02-22 Thread Ben Finney
Kelson Zawack writes: > This raises a question though, can the logic of the garbage collector > be changed so that it is not triggered in instances like this were you > really do want to put lots and lots of stuff in memory. Have you considered using a more specialised data type for such large d

Whats new in Python 3: concurrent-futures example error?

2011-02-22 Thread Paddy
I just noted the example here: http://docs.python.org/dev/whatsnew/3.2.html#pep-3148-the-concurrent-futures-module import concurrent.futures, shutil with concurrent.futures.ThreadPoolExecutor(max_workers=4) as e: e.submit(shutil.copy, 'src1.txt', 'dest1.txt') e.submit(shutil.copy, 'src2.tx

Re: Creating Long Lists

2011-02-22 Thread Kelson Zawack
The answer it turns out is the garbage collector. When I disable the garbage collector before the loop that loads the data into the list and then enable it after the loop the program runs without issue. This raises a question though, can the logic of the garbage collector be changed so that it is

Re: LDFLAGS problem

2011-02-22 Thread Robin Becker
On 21/02/2011 22:36, Philip Semanchuk wrote: .. running build_ext building '_mysql' extension creating build/temp.freebsd-7.0-RELEASE-i386-2.7 gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,2,'final',0) -D__version_

Re: python and parsing an xml file

2011-02-22 Thread Stefan Behnel
Matt Funk, 21.02.2011 23:08: On 2/21/2011 11:22 AM, Terry Reedy wrote: On 2/21/2011 12:30 PM, Matt Funk wrote: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Why? mmmh. not sure how to answer this question exactly.

Re: python and parsing an xml file

2011-02-22 Thread Paul Anton Letnes
Den 21.02.11 18.30, skrev Matt Funk: Hi, I was wondering if someone had some advice: I want to create a set of xml input files to my code that look as follows: Alg1 ./Alg1.in c:\tmp 1 So there are co

Fwd: Python 2 or 3 ? with Django , My SQL and YUI

2011-02-22 Thread Grigory Javadyan
-- Forwarded message -- From: Grigory Javadyan Date: Tue, Feb 22, 2011 at 12:01 PM Subject: Re: Python 2 or 3 ? with Django , My SQL and YUI To: Sumit Python 2 only. See http://docs.djangoproject.com/en/dev/faq/install/#can-i-use-django-with-python-3 On Tue, Feb 22, 2011 at 9:0