ANN: GMPY2 or How I learned to love "nan"

2011-06-08 Thread casevh
Everyone, I'm pleased to announce a new alpha release of GMPY2. GMPY2 is a wrapper for GMP and MPFR multiple-precision arithmetic libraries. GMPY2 alpha2 introduces context manager support for MPFR arithmetic. It's now possible to trigger an exception when comparing against "nan" (and other for o

Re: how to inherit docstrings?

2011-06-08 Thread Ben Finney
Eric Snow writes: > p.s. Am I missing something or can you really not change the docstring > of a class? I was thinking about the idea of inheriting class > docstrings too. The docstring of an object (whether function or class or module) is the object's ‘__doc__’ attribute. Access that attribute

how to inherit docstrings?

2011-06-08 Thread Eric Snow
Sometimes when using class inheritance, I want the overriding methods of the subclass to get the docstring of the matching method in the base class. You can do this with decorators (after the class definition), with class decorators, and with metaclasses [1]. However, I was hoping for a way to do

test_popen

2011-06-08 Thread harrismh777
Looks like my 2.7 test_popen failure is an open issue7671... since Jan 2010. Looks like it really does function ok. At any rate, I was able to test Popen myself today, and it ran fine. I needed to write a script that will disable the touch pad on this HP g series, because there is no way to do

Re: The pythonic way equal to "whoami"

2011-06-08 Thread Cameron Simpson
On 07Jun2011 20:22, Nitin Pawar wrote: | import getpass | user = getpass.getuser() | | On Tue, Jun 7, 2011 at 7:54 PM, TheSaint wrote: | > I was trying to find out whose the program launcher, but os.environ['USER'] | > returns the user whom owns the desktop environment, regardless the program |

Re: the stupid encoding problem to stdout

2011-06-08 Thread Benjamin Kaplan
2011/6/8 Sérgio Monteiro Basto : > hi, > cat test.py > #!/usr/bin/env python > #-*- coding: utf-8 -*- > u = u'moçambique' > print u.encode("utf-8") > print u > > chmod +x test.py > ./test.py > moçambique > moçambique > > ./test.py > output.txt > Traceback (most recent call last): >  File "./test.py

Re: the stupid encoding problem to stdout

2011-06-08 Thread Ben Finney
Sérgio Monteiro Basto writes: > ./test.py > moçambique > moçambique In this case your terminal is reporting its encoding to Python, and it's capable of taking the UTF-8 data that you send to it in both cases. > ./test.py > output.txt > Traceback (most recent call last): > File "./test.py", li

Re: The pythonic way equal to "whoami"

2011-06-08 Thread Nobody
On Wed, 08 Jun 2011 21:58:17 +0800, TheSaint wrote: >> os.geteuid > This return 0 for *root* . I don't know if it's a standard for all distro. UID 0 is the "superuser". The name "root" is conventional, but it's the EUID (effective UID) which is used in permission checks; the kernel doesn't care a

Re: how to avoid leading white spaces

2011-06-08 Thread Chris Torek
>On 03/06/2011 03:58, Chris Torek wrote: >>> - >> This is a bit surprising, since both "s1 in s2" and re.search() >> could use a Boyer-Moore-based algorithm for a sufficiently-long >> fixed string, and the time required should be proportional to that

the stupid encoding problem to stdout

2011-06-08 Thread Sérgio Monteiro Basto
hi, cat test.py #!/usr/bin/env python #-*- coding: utf-8 -*- u = u'moçambique' print u.encode("utf-8") print u chmod +x test.py ./test.py moçambique moçambique ./test.py > output.txt Traceback (most recent call last): File "./test.py", line 5, in print u UnicodeEncodeError: 'ascii' codec

Re: pthreads in C++ with embedded Python

2011-06-08 Thread Jason Tackaberry
On 11-06-08 06:28 PM, Tom Brown wrote: I found that PyEval_ReleaseLock() was necessary to keep the program from hanging. The lock() and unlock() methods were used in a previous attempt to lock/unlock the GIL. I just tried your example code and indeed it segfaults as is, but works fine for me

Re: Problems Compiling Python 2.6.7 for Win7

2011-06-08 Thread Gabriel Genellina
En Wed, 08 Jun 2011 12:28:56 -0300, Jay Osako escribió: I have been trying to get PyODBC to work with Python 2.6 (the latest version it is known to be compatible with) and Django, but have run into a problem which, according to the information I've got elsewhere, probably stems from a DLL inc

Re: pthreads in C++ with embedded Python

2011-06-08 Thread Tom Brown
On Wed, Jun 8, 2011 at 2:11 PM, Jason Tackaberry wrote: > On 11-06-07 07:29 PM, Tom Brown wrote: > >> Any suggestions will be appreciated. >> > > Why are you calling PyEval_ReleaseLock() in the CmdThread constructor? > This looks suspicious. > > Also, I don't see where CmdThread::lock() and CmdT

Calling a matlab gui from python using pymatlab without allowing python to close it

2011-06-08 Thread Ven
Before proceeding further, my system configuration is as follows: Mac OS X 10.6.6 MATLAB 2010b ActiveState Python 2.7 I have a gui built using matlab. I wrote the following python script to open that matlab gui using pymatlab python module: from pymatlab.matlab import MatlabSession session = M

Re: pthreads in C++ with embedded Python

2011-06-08 Thread Jason Tackaberry
On 11-06-07 07:29 PM, Tom Brown wrote: Any suggestions will be appreciated. Why are you calling PyEval_ReleaseLock() in the CmdThread constructor? This looks suspicious. Also, I don't see where CmdThread::lock() and CmdThread::unlock() are being invoked in your example. Relics from your e

Re: Bloom Filter in 22 lines of Python (updated)

2011-06-08 Thread geremy condra
On Wed, Jun 8, 2011 at 1:05 PM, Raymond Hettinger wrote: > On Jun 6, 10:47 am, geremy condra wrote: >> On Fri, Jun 3, 2011 at 1:17 PM, Raymond Hettinger wrote: >> > Thanks for all the feedback on the earlier post. >> >> > I've updated the recipe to use a cleaner API, simpler code, >> > more easi

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread John Gordon
In Cathy James writes: > b) I would like to append to my list, but my line dogs.dogAppend() is > giving a TypeError: > for i in enumerate (self.dogAppend()): > TypeError: 'list' object is not callable > def dogAppend(self): > self.dogAppend = [] You have a method and a list that

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread Benjamin Kaplan
On Wed, Jun 8, 2011 at 1:09 PM, Cathy James wrote: > I am almost there, but I need a little help: > > I would like to > > a) print my dogs in the format  index. name: breed as follows: > > 0. Mimi:Poodle > 1.Sunny: Beagle > 2. Bunny: German Shepard > I am getting > > (0, ('Mimi', 'Poodle')) . Mimi

Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread Ethan Furman
Cathy James wrote: I am almost there, but I need a little help: I would like to a) print my dogs in the format index. name: breed as follows: 0. Mimi:Poodle 1.Sunny: Beagle 2. Bunny: German Shepard I am getting (0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong? b) I wou

Re: In Python 2.x, is it possible to make unicode as default like in Python 3.x?

2011-06-08 Thread Benjamin Kaplan
On Wed, Jun 8, 2011 at 11:22 AM, G00gle and Python Lover wrote: > Hello. > I almost like everything in Python. Code shrinking, logic of processes, > libraries, code design etc. > But, we... - everybody knows that Python 2.x has lack of unicode support. > In Python 3.x, this has been fixed :) And I

smtp - python

2011-06-08 Thread Josias L.G
Hi for all, I'm very newbie in python and is very good language. I'm trying to adopt a example: import smtpd import asyncore server = smtpd.PureProxy(('127.0.0.1', 1025), ('mail', 25)) asyncore.loop() I'm trying to copy the email that is send to another email in maildir format. Here, i'm read

Re: The pythonic way equal to "whoami"

2011-06-08 Thread Christopher Head
On Wed, 08 Jun 2011 21:58:17 +0800 TheSaint wrote: > Kushal Kumaran wrote: > > > os.geteuid > This return 0 for *root* . I don't know if it's a standard for all > distro. Mine is Archlinux. > I'd just like to avoid error caused by wrong access by user > It is. Until Linux capabilities, EUID==0

Re: Bloom Filter in 22 lines of Python (updated)

2011-06-08 Thread Raymond Hettinger
On Jun 6, 10:47 am, geremy condra wrote: > On Fri, Jun 3, 2011 at 1:17 PM, Raymond Hettinger wrote: > > Thanks for all the feedback on the earlier post. > > > I've updated the recipe to use a cleaner API, simpler code, > > more easily subclassable, and with optional optimizations > > for better c

Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-08 Thread Cathy James
I am almost there, but I need a little help: I would like to a) print my dogs in the format index. name: breed as follows: 0. Mimi:Poodle 1.Sunny: Beagle 2. Bunny: German Shepard I am getting (0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong? b) I would like to append to

Re: How to run C++ binaries with python in parallel?

2011-06-08 Thread Chris Rebert
On Wed, Jun 8, 2011 at 12:06 PM, Pony wrote: > Hi all, > > I'm a newbie with python, and I have a question about running parallel > C++ binaries with python. > > Suppose I have a C++ binary named "test" and it takes two inputs, if I > want to run below three commands in bash: > test a b > test c d

How to run C++ binaries with python in parallel?

2011-06-08 Thread Pony
Hi all, I'm a newbie with python, and I have a question about running parallel C++ binaries with python. Suppose I have a C++ binary named "test" and it takes two inputs, if I want to run below three commands in bash: test a b test c d test e f What's the best way to run it parallel with python?

In Python 2.x, is it possible to make unicode as default like in Python 3.x?

2011-06-08 Thread G00gle and Python Lover
Hello. I almost like everything in Python. Code shrinking, logic of processes, libraries, code design etc. But, we... - everybody knows that Python 2.x has lack of unicode support. In Python 3.x, this has been fixed :) And I like 3.x more than 2.x But, still major applications haven't been ported t

Re: simple web/html testing

2011-06-08 Thread Tim
On Jun 8, 9:57 am, Santi wrote: > For static html testing, I'd avoid using Selenium. Even though Selenium is > *the* tool for RIA and javascript intensive environments, feels like bringing > up a browser with all the coordination and resources that it takes just to > crawl the website and find

Import error while running python application on Mac OS

2011-06-08 Thread hisan
HI All, I have created an application for Mac OS using py2app module, in my python script i have external modules such as MySQLdb and other , while trying to run on Mac OS i get an error saying unable to import the module MySQLdb. On Windows i convert python script to an exe using py2exe module an

Re: Question about pyjamas inner workings (pyjd's version of imputil.py)

2011-06-08 Thread Luke Kenneth Casson Leighton
[i'm bcc'ing this to python-list because it's something that is generic to python, not pyjamas] On Tue, Jun 7, 2011 at 4:38 PM, Alexander Tsepkov wrote: > I'm working on a python-based side project where I want to be able to > generate multiple variations of the program and I really like the way

Re: how to avoid leading white spaces

2011-06-08 Thread rusi
On Jun 8, 7:38 pm, "ru...@yahoo.com" wrote: > On 06/07/2011 06:30 PM, Roy Smith wrote: > > > > > On 06/06/2011 08:33 AM, rusi wrote: > >>> Evidently for syntactic, implementation and cultural reasons, Perl > >>> programmers are likely to get (and then overuse) regexes faster than > >>> python prog

test_popen

2011-06-08 Thread harrismh777
hi folks, I've installed 3.2 and 2.7.1 on a second development notebook from sources. 3.2 was smooth, and 2.7.1 make test failed test_popen. All other tests either passed or were skipped for valid reasons. I do not remember 3.2 failing popen... so I'm wondering about 2.7? I'm assuming (witho

Eigensolver for Large Sparse Matrices in Python

2011-06-08 Thread Andrew MacLean
Hi, I need to solve symmetric generalized eigenvalue problems with large, sparse stiffness and mass matrices, say 'A' and 'B'. The problem is of the form Av = lambdaBV. I have been using lobpcg (scipy.sparse.linalg.lobpcg), in Scipy 0.7.2, although this has been giving me incorrect values that are

We wholesale Amazon Kindle/ Monster Beats / Ipods / Apple products of all types

2011-06-08 Thread sdgsad
hi We wholesale Amazon Kindle/ Monster Beats / Ipods / Apple products of all types Apple iPad 2 16GB WiFi 450$ Apple iPad 2 32GB WiFi580$ Apple iPad 2 64GB WiFi 620$ iPad 2 16GB Wi-Fi+3G Verizon/AT&T 550$ iPad 2 32GB Wi-Fi+3G Verizon/AT&T 650$ iPad 2 64GB Wi-Fi+3G Verizon/AT&T 750

Problems Compiling Python 2.6.7 for Win7

2011-06-08 Thread Jay Osako
I have been trying to get PyODBC to work with Python 2.6 (the latest version it is known to be compatible with) and Django, but have run into a problem which, according to the information I've got elsewhere, probably stems from a DLL incompatibility - apparently, the standard CPython distribution f

[ANN] RuPy 11 Conference : Call for Proposals

2011-06-08 Thread J. P. Nowak
:: Call for Proposals 2011 RuPy 11 :: Strongly Dynamic Conference http://rupy.eu/ Poznan, Poland October 14th-16th, 2011 RuPy is a conference about dynamically typed programming languages. Held for the first time in April 2007 it gathered enthusiasts from Poland and other countries. The idea

Re: how to avoid leading white spaces

2011-06-08 Thread ru...@yahoo.com
On 06/07/2011 06:30 PM, Roy Smith wrote: > On 06/06/2011 08:33 AM, rusi wrote: >>> Evidently for syntactic, implementation and cultural reasons, Perl >>> programmers are likely to get (and then overuse) regexes faster than >>> python programmers. > > "ru...@yahoo.com" wrote: >> I don't see how the

Re: how to avoid leading white spaces

2011-06-08 Thread ru...@yahoo.com
On 06/08/2011 03:01 AM, Duncan Booth wrote: > "ru...@yahoo.com" wrote: >> On 06/06/2011 09:29 AM, Steven D'Aprano wrote: >>> Yes, but you have to pay the cost of loading the re engine, even if >>> it is a one off cost, it's still a cost, [...] > At least part of the reason that there's no differen

Re: Function declarations ?

2011-06-08 Thread D'Arcy J.M. Cain
On Wed, 8 Jun 2011 13:58:18 + (UTC) Andre Majorel wrote: > Is there a way to keep the definitions of the high-level > functions at the top of the source ? I don't see a way to > declare a function in Python. You don't declare functions in Python. You simply define them. You could define all

Re: Web Applications - Separating DB Connections

2011-06-08 Thread Burhan
On Jun 8, 1:22 pm, Stuart MacKay wrote: > A simple way to do this is use fabric for deployment. It allows you to > upload a file as if it was a template and replaces any placeholder > strings with values supplied when you upload. The values can be supplied > either in a config file or interactivel

Re: Function declarations ?

2011-06-08 Thread Calvin Spealman
Just write the function, at the top of the source. Easy peasy. On Wed, Jun 8, 2011 at 9:58 AM, Andre Majorel wrote: > Is there a way to keep the definitions of the high-level > functions at the top of the source ? I don't see a way to > declare a function in Python. > > Thanks in advance. > > --

Re: The pythonic way equal to "whoami"

2011-06-08 Thread TheSaint
Kushal Kumaran wrote: > os.geteuid This return 0 for *root* . I don't know if it's a standard for all distro. Mine is Archlinux. I'd just like to avoid error caused by wrong access by user -- goto /dev/null -- http://mail.python.org/mailman/listinfo/python-list

Function declarations ?

2011-06-08 Thread Andre Majorel
Is there a way to keep the definitions of the high-level functions at the top of the source ? I don't see a way to declare a function in Python. Thanks in advance. -- André Majorel http://www.teaser.fr/~amajorel/ J'ai des droits. Les autres ont des devoirs. -- http://mail.python.org/mailman/lis

Re: simple web/html testing

2011-06-08 Thread Santi
For static html testing, I'd avoid using Selenium. Even though Selenium is *the* tool for RIA and javascript intensive environments, feels like bringing up a browser with all the coordination and resources that it takes just to crawl the website and find 404s is an overkill. What we implemented

Re: Tix Combobox

2011-06-08 Thread Kevin Walzer
On 6/8/11 8:00 AM, peter wrote: I'm writing some fairly simple code using a Tkinter GUI, and found I wanted a Combo box. As Tkinter does not provide one, I turned to Tix, and struggled. Extensive googling failed to turn up any python specific documentation, and there was no obvious way to tran

Tix Combobox

2011-06-08 Thread peter
I'm writing some fairly simple code using a Tkinter GUI, and found I wanted a Combo box. As Tkinter does not provide one, I turned to Tix, and struggled. Extensive googling failed to turn up any python specific documentation, and there was no obvious way to translate the Tcl documentation. Noth

Re: Web Applications - Separating DB Connections

2011-06-08 Thread Stuart MacKay
A simple way to do this is use fabric for deployment. It allows you to upload a file as if it was a template and replaces any placeholder strings with values supplied when you upload. The values can be supplied either in a config file or interactively when the deployment takes place. For my dj

Re: How good is security via hashing

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 11:13 schrieb Robin Becker: we have been using base62 ie 0-9A-Za-z just to reduce the name length. Ugly concerning calculation. Then maybe better use radix32 - 0..9a..v, case-insensitive. Thomas -- http://mail.python.org/mailman/listinfo/python-list

best book about Webdesign with Django

2011-06-08 Thread News123
Hi, Do you have any recommendations for a good book about Web design with Django? Thanks for suggestions. -- http://mail.python.org/mailman/listinfo/python-list

Re: How good is security via hashing

2011-06-08 Thread Robin Becker
On 07/06/2011 21:42, Paul Rubin wrote: geremy condra writes: # adds random junk to the filename- should make it hard to guess rrr = os.urandom(16) fname += base64.b64encode(rrr) Don't use b64 output in a filename -- it can have slashes in it! :-( Simplest is to use old fashioned hexadeimal

Re: how to avoid leading white spaces

2011-06-08 Thread Duncan Booth
"ru...@yahoo.com" wrote: > On 06/06/2011 09:29 AM, Steven D'Aprano wrote: >> Yes, but you have to pay the cost of loading the re engine, even if >> it is a one off cost, it's still a cost, > > ~$ time python -c 'pass' > real 0m0.015s > user 0m0.011s > sys 0m0.003s > > ~$ time python

Re: how to avoid leading white spaces

2011-06-08 Thread rusi
On Jun 7, 11:37 pm, "ru...@yahoo.com" wrote: > On 06/06/2011 08:33 AM, rusi wrote: > > > For any significant language feature (take recursion for example) > > there are these issues: > > > 1. Ease of reading/skimming (other's) code > > 2. Ease of writing/designing one's own > > 3. Learning curve >

Re: simple web/html testing

2011-06-08 Thread Burhan
On Jun 7, 10:42 pm, Tim wrote: > On Jun 7, 2:05 pm, Miki Tebeka wrote: > > >http://pypi.python.org/pypi/selenium? > > I looked at Selenium and it may be what I need, but when I searched > for selenium and "broken link" (one of the things I need to test for), > I found only an unanswered > questi

Web Applications - Separating DB Connections

2011-06-08 Thread Burhan
Hello Everyone: I am trying to find a way to extract and remove database connection information (username, password, schema name) from the application source. I need to do this because in my organization - for security reasons - access to databases is controlled by a separate department; and as

Re: How good is security via hashing

2011-06-08 Thread Paul Rubin
Nobody writes: >>> If you're going to read from /dev/urandom, limit it to a few bytes per >>> minute, not per request. >> That's really not going to help you. > In what way? > If I need security, I'll use /dev/random or /dev/urandom. If I don't, I'll > save the real entropy for something which nee

Re: Call python function from Matlab

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 09:19 schrieb Adam Przybyla: nazmul.is...@gmail.com wrote: I need to call a python function from a Matlab environment. Is it possible? Let's assume, I have the following python code: def squared(x): y = x * x return y I want to call squared(3) from Matlab workspace/code

Re: Call python function from Matlab

2011-06-08 Thread Thomas Rachel
Am 08.06.2011 07:12 schrieb nazmul.is...@gmail.com: I need to call a python function from a Matlab environment. Is it possible? Let's assume, I have the following python code: def squared(x): y = x * x return y I want to call squared(3) from Matlab workspace/code and get 9. Thanks f

Re: Call python function from Matlab

2011-06-08 Thread Adam Przybyla
nazmul.is...@gmail.com wrote: > I need to call a python function from a Matlab environment. Is it > possible? > > Let's assume, I have the following python code: > > def squared(x): >y = x * x >return y > > I want to call squared(3) from Matlab workspace/code and get 9. > > Thanks for

Re: How good is security via hashing

2011-06-08 Thread Nobody
On Tue, 07 Jun 2011 19:38:29 -0700, Paul Rubin wrote: >> Personally, I'd take whatever "cheap" entropy I can get and hash it. >> If you're going to read from /dev/urandom, limit it to a few bytes per >> minute, not per request. > > That's really not going to help you. In what way? If I need sec

Re: Dynamic Zero Padding.

2011-06-08 Thread Friedrich Clausen
On Wed, Jun 8, 2011 at 4:56 AM, Terry Reedy wrote: > On 6/7/2011 7:05 PM, John Posner wrote: > >> You might want to try "new style" string formatting [1], which I think >> is better than the "old style" in this particular case: >> >>     >>> "Testing {0:0{1}d}".format(42, 4) >>    'Testing 0042' >