Re: performance of tight loop

2010-12-14 Thread Ulrich Eckhardt
Thank you for the explanation, Ryan! Uli -- Domino Laser GmbH Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932 -- http://mail.python.org/mailman/listinfo/python-list

Fail import with SWIG generated imp.load_module ?

2010-12-14 Thread Hvidberg, Martin
I'm trying to load a module GDAL into a Python script. The loader/binder that is then called, seems to be generated by SWIG, a project with which I'm unfortunately not familiar. The part of the SWIG generated code that fails on me is as follow: -- start code snip 1 - # This file

Re: performance of tight loop

2010-12-14 Thread Paul Rubin
gry writes: ... > rest = ['%d' % randint(1, mx) for i in range(wd - 1)] > for i in range(i,i+rows): ... One thing that immediately comes to mind is use xrange instead of range. Also, instead of first = ['%d' % i] rest = ['%d' % randint(1, mx) for i in range(wd - 1)] re

Re: while True or while 1

2010-12-14 Thread Gregory Ewing
Steven D'Aprano wrote: while True: ... print "Looping" ... True = 0 Just remember that if you use that inside a function, you'll have to initialise True to True before... er, wait a moment, that won't work... ah, I know: def f(true = True): True = true while True: ..

Re: while True or while 1

2010-12-14 Thread Hans-Peter Jansen
On Tuesday 14 December 2010, 10:19:04 Gregory Ewing wrote: > Steven D'Aprano wrote: > while True: > > > > ... print "Looping" > > ... True = 0 > > Just remember that if you use that inside a function, you'll > have to initialise True to True before... er, wait a moment, > that won't wor

Re: optparse/argparse for cgi/wsgi?

2010-12-14 Thread Joost Molenaar
Many people have. :-) In the context of WSGI you're basically talking about routing middleware, which solves the problem: "given a request, which application should be called to construct a response?" In my case, it turned out as simple as a list of (regex, resource) tuples, where regex is a regu

Re: optparse/argparse for cgi/wsgi?

2010-12-14 Thread Joost Molenaar
To aid your googling, the problem is also commonly called 'Dispatching' instead of 'Routing'. Joost On 14 December 2010 12:19, Joost Molenaar wrote: > Many people have. :-) > > In the context of WSGI you're basically talking about routing > middleware, which solves the problem: "given a request

International Workshop: DATICS-ISPA'11 (EI Indexed)

2010-12-14 Thread SS DATICS
Dear authors, = International Workshop: DATICS-ISPA'11 CALL FOR PAPERS http://datics.nesea-conference.org/datics-ispa2011 Busan, Korea, 26-28 May, 2011. = Aims

Re: while True or while 1

2010-12-14 Thread Kurt Mueller
Am 14.12.2010 11:33, schrieb Hans-Peter Jansen: > On Tuesday 14 December 2010, 10:19:04 Gregory Ewing wrote: >> Steven D'Aprano wrote: >> while True: >>> >>> ... print "Looping" >>> ... True = 0 >> >> Just remember that if you use that inside a function, you'll >> have to initialise True to Tru

Re: performance of tight loop

2010-12-14 Thread Peter Otten
gry wrote: > [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] > I have a little data generator that I'd like to go faster... any > suggestions? > maxint is usually 9223372036854775808(max 64bit int), but could > occasionally be 99. > width is usually 500 or 1600, rows ~ 5000. >

Re: performance of tight loop

2010-12-14 Thread Peter Otten
Peter Otten wrote: > gry wrote: > >> [python-2.4.3, rh CentOS release 5.5 linux, 24 xeon cpu's, 24GB ram] >> I have a little data generator that I'd like to go faster... any >> suggestions? >> maxint is usually 9223372036854775808(max 64bit int), but could >> occasionally be 99. >> width is usual

Re: packaging and installing

2010-12-14 Thread Brian Blais
On Dec 13, 2010, at 12:30 PM, Godson Gera wrote: > > > On Mon, Dec 13, 2010 at 10:46 PM, Brian Blais wrote: >> Hello, >> >> I was wondering if there is any standard or suggested way of installing >> packages *without* going to the commandline. I often have students who, >> from there experi

Re: packaging and installing

2010-12-14 Thread Godson Gera
On Tue, Dec 14, 2010 at 6:59 PM, Brian Blais wrote: > On Dec 13, 2010, at 12:30 PM, Godson Gera wrote: > > > > > > > On Mon, Dec 13, 2010 at 10:46 PM, Brian Blais wrote: > >> Hello, > >> > >> I was wondering if there is any standard or suggested way of installing > packages *without* going to t

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread baloan
Unfortunately you use command('cp...') to copy the file instead of Pythons portable library methods. This choice effectively makes your program work on Unix only (not Windows). See http://modcopy.sourceforge.net for a more portable version. Regards, bal...@gmail.com -- http://mail.python.org/mai

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread D'Arcy J.M. Cain
On Tue, 14 Dec 2010 07:35:45 -0800 (PST) baloan wrote: > Unfortunately you use command('cp...') to copy the file instead of > Pythons portable library methods. This choice > effectively makes your program work on Unix only (not Windows). > > See http://modcopy.sourceforge.net for a more portable

Sybase module 0.40pre1 released

2010-12-14 Thread Robert Boehne
WHAT IS IT: The Sybase module provides a Python interface to the Sybase relational database system. It supports all of the Python Database API, version 2.0 with extensions. ** This version is a pre-release not intended for production use ** The module is available here: http://downloads.sourcef

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread Harishankar
On Tue, 14 Dec 2010 10:57:40 -0500, D'Arcy J.M. Cain wrote: > I guess I missed the beginning of this thread but can someone tell me > why one needs to download a whole other program in order to do this? > > open(out_fn, 'w').write(open(in_fn).read()) Or what about shutil? Isn't that the higher

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread D'Arcy J.M. Cain
On Tue, 14 Dec 2010 16:25:54 + (UTC) Harishankar wrote: > On Tue, 14 Dec 2010 10:57:40 -0500, D'Arcy J.M. Cain wrote: > > open(out_fn, 'w').write(open(in_fn).read()) > Or what about shutil? Isn't that the higher level file operation module? At least that's in the standard library but even t

Re: while True or while 1

2010-12-14 Thread Arnaud Delobelle
Gregory Ewing writes: > Steven D'Aprano wrote: > >while True: >> >> ... print "Looping" >> ... True = 0 > > Just remember that if you use that inside a function, you'll > have to initialise True to True before... er, wait a moment, > that won't work... ah, I know: > > def f(true = T

Re: Fail import with SWIG generated imp.load_module ?

2010-12-14 Thread MRAB
On 14/12/2010 08:43, Hvidberg, Martin wrote: I'm trying to load a module GDAL into a Python script. The loader/binderthat is then called, seems to be generated by SWIG, a project with which I'm unfortunately not familiar. The part of the SWIG generated code that fails on me is as follow: [sni

Re: Sage's Python

2010-12-14 Thread Akand Islam
On Dec 13, 4:33 pm, "Rhodri James" wrote: > On Fri, 10 Dec 2010 17:11:55 -, Akand Islam wrote: > > In my system (Ubuntu 10.04) there are sage-4.6, python 2.6.5, tk8.5- > > dev installed. When I give command from terminal "sage -f > > python-2.6.5.p8" to get sage's python it shows following me

Re: while True or while 1

2010-12-14 Thread Christian Heimes
Am 14.12.2010 17:52, schrieb Arnaud Delobelle: > You also need to initialise False to False for it to be really > robust. So something like this will do. > > True = not 0 > False = not True > while True: > ... > True = False Tres Seavers once told me a joke like this:

Re: ctypes question

2010-12-14 Thread News Wombat
On Dec 11, 12:59 pm, MrJean1 wrote: > In general, for shared libraries, you need to define those first as > prototype using ctypes.CFUNCTYPE() and then instantiate each prototype > once supplying the necessary parameter flags using > prototype(func_spec, tuple_of_param_flags).  See sections 15.16

Map Linux locale codes to Windows locale codes?

2010-12-14 Thread python
Is there a way to map Linux locale codes to Windows locale codes? Windows has locale codes like 'Spanish_Mexico'. We would like to use the more ISO compliant 'es_MX' locale format under Windows. Is there a resource or API that might help us with this mapping? Babel is not an option for us since

Concatenate a string as binary bytes

2010-12-14 Thread Jaime Fernández
Hi To build a binary packet (for SMPP protocol), we have to concatenate different types of data: integers, floats, strings. We are using struct.pack to generate the binary representation of each integer and float of the packet, and then they are concatenated with the + operand. However, for strin

Re: Sage's Python

2010-12-14 Thread Emile van Sebille
On 12/14/2010 10:27 AM Akand Islam said... On Dec 13, 4:33 pm, "Rhodri James" wrote: On Fri, 10 Dec 2010 17:11:55 -, Akand Islam wrote: In my system (Ubuntu 10.04) there are sage-4.6, python 2.6.5, tk8.5- dev installed. When I give command from terminal "sage -f python-2.6.5.p8" to get sag

Re: Concatenate a string as binary bytes

2010-12-14 Thread MRAB
On 14/12/2010 19:50, Jaime Fernández wrote: Hi To build a binary packet (for SMPP protocol), we have to concatenate different types of data: integers, floats, strings. We are using struct.pack to generate the binary representation of each integer and float of the packet, and then they are conca

Re: Concatenate a string as binary bytes

2010-12-14 Thread Benjamin Kaplan
2010/12/14 Jaime Fernández : > Hi > To build a binary packet (for SMPP protocol), we have to concatenate > different types of data: integers, floats, strings. > We are using struct.pack to generate the binary representation of each > integer and float of the packet, and then they are concatenated w

Re: while True or while 1

2010-12-14 Thread Arnaud Delobelle
Christian Heimes writes: [...] > Tres Seavers once told me a joke like this: > >True = not not "Who's at the door?" # say it out loud! > > This was back in the old days of Zope 2.5 and Python 2.1, which didn't > have True and False. I almost used: True = "to be" or not "to be" # that is

Re: PyArg_ParseTuple question

2010-12-14 Thread Mark Wooding
Mark Crispin writes: > In a C module, I want to pick up the arguments for a Python call like: > module.call("string1",["string2a", "string2b", "string2c"], "string3") > and stash these into: > char *arg1; > char *arg2[]; > char *arg3; > All arguments are required, and we can

Re: Map Linux locale codes to Windows locale codes?

2010-12-14 Thread Flávio Lisbôa
You could look into the windows registry, the key "HKLM\SYSTEM\CurrentControlSet\Control\Nls" has all the supported LCID's listed. If not, you could simply get the codepage provided by locale.setlocale(), e.g.: import locale print(locale.setlocale(locale.LC_ALL, "")) prints "Portuguese_Brazil.125

How to pop the interpreter's stack?

2010-12-14 Thread kj
Consider this code: def spam(*args, **kwargs): args, kwargs = __pre_spam(*args, **kwargs) # args & kwargs are OK: proceed # ... def __pre_spam(*args, **kwargs): # validate args & kwargs; # return canonicalized versions of args & kwargs; # on failure, raise some *info

Alternative to PIL in Python 3.1

2010-12-14 Thread craf
Hi. I wonder if anyone knows any alternative to PIL library, as this does not work with Python 3.1. Thanks in advance Regards. Cristian -- http://mail.python.org/mailman/listinfo/python-list

How to experience python on a handheld, tablet, etc on linux?

2010-12-14 Thread stateslave
Without buying first? I'd like to run the front end of all these new devices, on my PC and program in python, to assess which is the best on for me. pre-test python scripts before cross loading onto the device I finally buy. Is that possible? It would also be nice to have some of the look and f

Combing Medusa's Hair... (Design Pattern)

2010-12-14 Thread kirby.ur...@gmail.com
This is an idea I got thinking about COM objects, and getting some support from Mark Hammond, Python's Win32 wizard. The goal is to have a host language (not Python) instantiate an object that runs against the Python interpreter, which lives as its own process. The VMs have various ways of imple

Re: Alternative to PIL in Python 3.1

2010-12-14 Thread Emile van Sebille
On 12/14/2010 3:17 PM craf said... Hi. I wonder if anyone knows any alternative to PIL library, as this does not work with Python 3.1. Thanks in advance Regards. Cristian You might try the 1.1.6 port referenced here: http://www.mail-archive.com/image-sig@python.org/msg02404.html Emile

Re: ctypes question

2010-12-14 Thread MrJean1
Try again after changing line 16 to sn = SmiGetNode(None, "1.3.6.1.2.1.2.2") Because, SmiGetNode is a Python function which accepts Python objects as arguments. Passing is a ctypes object oid is incorrect. /Jean On Dec 14, 10:36 am, News Wombat wrote: > On Dec 11, 12:59 pm, MrJean1 wrote:

[Fwd: Re: Alternative to PIL in Python 3.1]

2010-12-14 Thread craf
- Mensaje reenviado > De: Emile van Sebille > Para: python-list@python.org > Asunto: Re: Alternative to PIL in Python 3.1 > Fecha: Tue, 14 Dec 2010 16:39:19 -0800 > > On 12/14/2010 3:17 PM craf said... > > Hi. > > > > I wonder if anyone knows any alternative to PIL library, as th

Re: How to experience python on a handheld, tablet, etc on linux?

2010-12-14 Thread Benjamin Kaplan
On Tue, Dec 14, 2010 at 6:30 PM, stateslave wrote: > > Without buying first? > > I'd like to run the front end of all these new devices, > on my PC and program in python, to assess which is the > best on for me. pre-test python scripts before cross > loading onto the device I finally buy. > > Is t

Re: How to pop the interpreter's stack?

2010-12-14 Thread Ethan Furman
kj wrote: The one thing I don't like about this strategy is that the tracebacks of exceptions raised during the execution of __pre_spam include one unwanted stack level (namely, the one corresponding to __pre_spam itself). __pre_spam should be completely invisible and unobtrusive I am unaware

Re: Proposed changes to logging defaults

2010-12-14 Thread samwyse
On Dec 9, 6:12 pm, Vinay Sajip wrote: > Some changes are being proposed to how logging works in default > configurations. > > Briefly - when a logging event occurs which needs to be output to some > log, the behaviour of the logging package when no explicit logging > configuration is provided will

Re: Combing Medusa's Hair... (Design Pattern)

2010-12-14 Thread Kushal Kumaran
On Wed, Dec 15, 2010 at 5:04 AM, kirby.ur...@gmail.com wrote: > > This is an idea I got thinking about COM objects, and getting > some support from Mark Hammond, Python's Win32 wizard. > > The goal is to have a host language (not Python) instantiate > an object that runs against the Python interpr

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread JohnWShipman
On Dec 14, 8:57 am, "D'Arcy J.M. Cain" wrote: > On Tue, 14 Dec 2010 07:35:45 -0800 (PST) > > baloan wrote: > > Unfortunately you use command('cp...') to copy the file instead of > > Pythons portable library methods. This choice > > effectively makes your program work on Unix only (not Windows). >

Re: Tkinter polling example: file copy with progress bar

2010-12-14 Thread JohnWShipman
On Dec 14, 8:57 am, "D'Arcy J.M. Cain" wrote: > On Tue, 14 Dec 2010 07:35:45 -0800 (PST) > > baloan wrote: > > Unfortunately you use command('cp...') to copy the file instead of > > Pythons portable library methods. This choice > > effectively makes your program work on Unix only (not Windows). >

Re: Combing Medusa's Hair... (Design Pattern)

2010-12-14 Thread kirby urner
On Tue, Dec 14, 2010 at 8:10 PM, Kushal Kumaran wrote: << snip >> >> >> In this design pattern, you have something like a dry cleaner's, >> where people submit jobs at the counter, and go away right >> away with a ticket (Python returns -- but keeps running).  When >> they come back is more up t

Re: ctypes question

2010-12-14 Thread Mark Tolonen
"News Wombat" wrote in message news:413f5a8f-69a0-4351-acc2-18d7edda8...@j3g2000vbp.googlegroups.com... On Dec 11, 12:59 pm, MrJean1 wrote: > In general, for shared libraries, you need to define those first as > prototype using ctypes.CFUNCTYPE() and then instantiate each prototype > once supp

how tohandling output generated after execution of command/script on host unix machine?

2010-12-14 Thread Darshak Bavishi
Hi Experts, I am still struggling with handling output generated after execution of command/script on host unix machine using windows client machine ssh code : import sys import datetime import time # setup logging paramiko.util.log_to_file('darshak_simple.log') ssh=paramiko.SSHClient() ssh.set