Re: Easy caching

2008-11-13 Thread Peter Otten
jalanb3 wrote: > Evening all, > > And thank you for your valuable reading skills. > > The following pattern turned up in coding tonight. > It works, but I'm suspicious, it just seems too easy. > > So any comments or constructive criticisms welcome ? > > *** Start doctest format *** > > >>> cl

Re: duck-type-checking?

2008-11-13 Thread Ben Finney
Joe Strout <[EMAIL PROTECTED]> writes: > Because if I write a method with the intention of treating the > arguments like strings in various ways (slicing, combining with > other strings, printing to stdout or writing to a file, etc. etc.), > and some idiot (i.e. me six weeks later or long after I

Re: Python Wrapper Tools; a Performance Study

2008-11-13 Thread Peter Otten
Srijit Kumar Bhadra wrote: > I am looking for the file Python Wrapper Tools; a Performance Study > (http://people.web.psi.ch/geus/talks/europython2004_geus.pdf). The > link seems to be no longer valid. > > If someone has a local copy, I request him/her to share it. The wayback machine has a copy

Re: Single-instance daemons

2008-11-13 Thread Cameron Simpson
On 12Nov2008 22:30, Jeffrey Barish <[EMAIL PROTECTED]> wrote: | Cameron Simpson wrote: | > Or, more simply, get root to make an empty pid file once and chown it to | > the daemon user. Then the daemon can rewrite the file as needed. You need | > to move to truncating the file instead of removing it

Re: Python 2.5 and sqlite

2008-11-13 Thread Thorsten Kampe
* (Wed, 12 Nov 2008 17:52:55 -0500) > Quoting Thorsten Kampe <[EMAIL PROTECTED]>: > > * (Tue, 11 Nov 2008 17:58:15 -0500) > > It checks whether it can find the SQLite header files. So the SQLite > > source (or the binary) is only needed for compiling Python. If you > > build SQLite support as a s

Re: need to suspend/resume a child thread

2008-11-13 Thread M.-A. Lemburg
On 2008-11-13 02:57, scsoce wrote: > A child thread has a long-time executions, how to suspend it and resume > back the orignial place ? I know it' nature to use singal, but child > thread cannot get signal as Python Manual say. And i dnt like to check > status variable as the long-time executi

Re: Easy caching

2008-11-13 Thread M.-A. Lemburg
On 2008-11-13 09:03, Peter Otten wrote: > jalanb3 wrote: > >> Evening all, >> >> And thank you for your valuable reading skills. >> >> The following pattern turned up in coding tonight. >> It works, but I'm suspicious, it just seems too easy. >> >> So any comments or constructive criticisms welcom

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread greg
Steve Holden wrote: greg wrote: Do you agree that it makes sense to talk about assigning that value to something? No. Why do you think that we are (mostly) careful to talk about binding names and values instead? That's an odd position to take, considering that the Python docs use the word "

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread greg
Grant Edwards wrote: I stopped paying much attention to this thread a while ago, but you've got to admire the persistence of somebody who soldiers on even though Aahz, Fredrik Lund, and Steve Holden are all on the other side of the argument... Those people clearly know a great deal about Pytho

[Regex] Search and replace?

2008-11-13 Thread Gilles Ganault
Hello I need to iterate through a variable, and for each pattern that matches, replace this with something else. I read the chapter in www.amk.ca/python/howto/regex/, but the output is wrong: === #Extract two bits, and rewrite the HTML person = re.compile('.+?)>.+?', input) === Does som

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Aaron Brady
On Nov 13, 3:44 am, greg <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > > I stopped paying much attention to this thread a while ago, but > > you've got to admire the persistence of somebody who soldiers > > on even though Aahz, Fredrik Lund, and Steve Holden are all on > > the other side of t

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread greg
Fredrik Lundh wrote: Python's definition of the word "value" can be found in the language reference: http://docs.python.org/reference/datamodel.html#objects-values-and-types That whole passage is talking almost exclusively about the value of an *object*: Every object has an identity, a ty

Re: [Regex] Search and replace?

2008-11-13 Thread Sion Arrowsmith
Gilles Ganault <[EMAIL PROTECTED]> wrote: >#Extract two bits, and rewrite the HTML >person = re.compile('.+?)>.+?onmouseover="Tip(?P.+?) ') > >output = person.sub('' (note the backslash escaping). Oh, and don't use "input" as a name -- you're shadowing the builtin input function. -- \S -- [EMA

Re: multiple breaks

2008-11-13 Thread Marc 'BlackJack' Rintsch
On Thu, 13 Nov 2008 11:07:25 +0100, TP wrote: > According to this page, the best way is to modify the loop by affecting > the variables that are tested in the loops. Otherwise, use exception: > > "If, for some reason, the terminating conditions can't be worked out, > exceptions are a fall-back pl

Re: multiple breaks

2008-11-13 Thread Peter Otten
TP wrote: > Hi everybody, > > Several means to escape a nested loop are given here: > > http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python > > According to this page, the best way is to modify the loop by affecting > the variables that are tested in the loops

How to "reduce" a numpy array using a costum binary function

2008-11-13 Thread Slaunger
I know there must be a simple method to do this. I have implemented this function for calculating a checksum based on a ones complement addition: def complement_ones_checksum(ints): """ Returns a complements one checksum based on a specified numpy.array of dtype=uint16 """ res

The return code

2008-11-13 Thread devi thapa
Hi, I am running one service in the python script eg like "service httpd status". If I execute this command in normal shell kernel, the return code is 3. But in the python script its return code is different, ie not 3, I mean to say that return codes are differing. But I want the return

Re: multiple breaks

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 2:07 AM, TP <[EMAIL PROTECTED]> wrote: > Hi everybody, > > Several means to escape a nested loop are given here: > > http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python > > According to this page, the best way is to modify the loop by affec

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Fredrik Lundh
greg wrote: If you're going to indulge in argument by authority, you need to pick authorities that can be considered, er, authoritative in the field concerned... Like Barbara Liskov, who's won tons of awards for her work on computer science and programming languages, and who was among the fir

Re: duck-type-checking?

2008-11-13 Thread paul
Ben Finney schrieb: Joe Strout <[EMAIL PROTECTED]> writes: "x quacks like a basestring if it implements all the public methods of basestring, and can be used in pretty much any context that a basestring can." That is not duck typing. Rather than checking what foo does in response to prodding t

Re: duck-type-checking?

2008-11-13 Thread Tim Rowe
2008/11/13 Ben Finney <[EMAIL PROTECTED]>: > That is not duck typing. Oh, I'm pretty sure it is. It just isn't /using/ the duck typing in the way you'd like. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: How to "reduce" a numpy array using a costum binary function

2008-11-13 Thread Slaunger
It is always good to ask yourself a question. I had forgooten about the reduce function I guess this implementation from numpy import * def compl_add_uint16(a, b): c = a + b c += c >> 16 return c & 0x def compl_one_checksum(uint16s): return reduce(compl_add_uint16, uint16s,

Re: best python unit testing framwork

2008-11-13 Thread James Harris
On 11 Nov, 22:59, Brendan Miller <[EMAIL PROTECTED]> wrote: > What would heavy python unit testers say is the best framework? > > I've seen a few mentions that maybe the built in unittest framework > isn't that great. I've heard a couple of good things about py.test and > nose. Are there other opti

multiple breaks

2008-11-13 Thread TP
Hi everybody, Several means to escape a nested loop are given here: http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python According to this page, the best way is to modify the loop by affecting the variables that are tested in the loops. Otherwise, use exception:

setuptools for 2.6 and windows?

2008-11-13 Thread Werner F. Bruhin
I would like to start looking into Python 2.6 and do some testing. First hurdle I run into is that I can not find a 2.6 installer for Windows for setuptools-0.6.9c, only Py2.4 and Py2.5 seem to be available on pypi. Is there such a thing yet? If yes can someone provide me a link to it. Than

Re: Python 2.5 and sqlite

2008-11-13 Thread david . lyon
Quoting Thorsten Kampe <[EMAIL PROTECTED]>: And even if you want to compile Python yourself, SQLite doesn't have to be _installed_. You simply can dump the files wherever you like and point Python to it. This is often necessary on a machine where you cannot install anything to the default locati

ChicagoLug Code review

2008-11-13 Thread Adam Jenkins
We would like to announce that this Saturday November 15th from 3 to 6pm is the Chicago Lug code review meeting. If you're stuck on a piece of code, looking to learn a few tricks, or just wanna hang out with some nerds, then come by. We will have people with knowledge in C, Python, Django, Ruby,

Re: The return code

2008-11-13 Thread Jeremiah Dodds
On Thu, Nov 13, 2008 at 7:15 AM, devi thapa <[EMAIL PROTECTED]> wrote: > Hi, > > I am running one service in the python script eg like > "service httpd status". > If I execute this command in normal shell kernel, the return code is > 3. But in the python script its return code is differen

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread rurpy
On Nov 12, 2:05 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Python's definition of the word "value" can be found in the language > reference: > > http://docs.python.org/reference/datamodel.html#objects-values-and-types > > Using that definition, a Python expression yields an object, not an > obj

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-13 Thread Steve Holden
Gerhard Häring wrote: > Steve Holden wrote: [...] >>> >> It's also why SQLite's not a real RDBMS. Fortunately this doesn't stop >> it being very useful. > > What does pysqlite extending the DB-API have to do with *SQLite* not > being a "real" RDBMS? > Nothing at all. I was just being pissy. Sorry

Re: what should we use instead of the 'new' module?

2008-11-13 Thread John Roth
On Nov 12, 8:32 pm, Flavio <[EMAIL PROTECTED]> wrote: > How is this code going to look like in Python 3.0? (it's deprecated > according tohttp://docs.python.org/library/new.html#module-new, but > it does not tell what to use instead) > >  method = new.instancemethod(raw_func, None, cls) >  setattr(

Re: email questions

2008-11-13 Thread Steve Holden
ted & irma slage wrote: > I tried to get a message to the below email address and this information > was sent back to me. Can you help me find out why it would not go > through, or send it to the place that may help me? > Thank you, > Irma Slage > [EMAIL PROTECTED] > >

Re: duck-type-checking?

2008-11-13 Thread Joe Strout
On Nov 12, 2008, at 7:32 PM, Steven D'Aprano wrote: I'm surprised nobody has pointed you at Alex Martelli's recipe here: http://code.activestate.com/recipes/52291/ Thanks for that -- it's clever how he combines binding the methods he'll use with doing the checking. While the recipe is gr

Re: potential bug in UnixMailbox method of Python

2008-11-13 Thread Steve Holden
Sirshendu Rakshit wrote: > Hi, > > I am using UnixMailbox to parse an mbox file. This mbox file starts with > the following lines. > > From [EMAIL PROTECTED] Tue May 18 01:43:12 2004 >>From [EMAIL PROTECTED] Tue May 18 01:43:12 2004 > Return-Path: <[EMAIL PROTECTED]> > X-Original-To: [EMAIL PRO

Re: multiple breaks

2008-11-13 Thread Steve Holden
Chris Rebert wrote: > On Thu, Nov 13, 2008 at 2:07 AM, TP <[EMAIL PROTECTED]> wrote: >> Hi everybody, >> >> Several means to escape a nested loop are given here: >> >> http://stackoverflow.com/questions/189645/how-to-break-out-of-multiple-loops-in-python >> >> According to this page, the best way i

Re: Parsing: request for pointers

2008-11-13 Thread Paul McGuire
On Nov 11, 1:59 pm, André <[EMAIL PROTECTED]> wrote: > Hi everyone, > > I would like to implement a parser for a mini-language > and would appreciate some pointers.  The type of > text I would like to parse is an extension of: > > http://www.websequencediagrams.com/examples.html > > For those that

Re: duck-type-checking?

2008-11-13 Thread Steve Holden
greg wrote: > Joe Strout wrote: >> This is not hypothetical -- just last week I had a hard-to-track-down >> abend that ultimately turned out to be an NLTK.Tree object stored >> someplace that I expected to only contain strings. I found it by >> littering my code with assertions of the form >>

win32com and DispatchWithEvents

2008-11-13 Thread RyanN
Greetings, I'm trying to get DispatchWithEvents() to work with HyperAccess (terminal program) without much success. I've done a bunch of searching and found some examples using IE: This works but doesn't handle the "Event Driven Functions": haObj = win32com.client.Dispatch(r"HAWin32") And so doe

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Grant Edwards
On 2008-11-13, greg <[EMAIL PROTECTED]> wrote: > Grant Edwards wrote: > >> I stopped paying much attention to this thread a while ago, but >> you've got to admire the persistence of somebody who soldiers >> on even though Aahz, Fredrik Lund, and Steve Holden are all on >> the other side of the argu

Text based screens without ncurses

2008-11-13 Thread Mirat Can Bayrak
Hi, i'll try to write a editor in python, i want it run under terminal (no qt or gtk) but i dont want to use urwid or curses modules. Can i write my curses like module in python? i googled to find metods that curses uses to write characters,colors etc. on screen but it did not make sense to me.

Re: Text based screens without ncurses

2008-11-13 Thread Jean-Paul Calderone
On Thu, 13 Nov 2008 20:11:30 +0200, Mirat Can Bayrak <[EMAIL PROTECTED]> wrote: Hi, i'll try to write a editor in python, i want it run under terminal (no qt or gtk) but i dont want to use urwid or curses modules. Why don't you want to use one of these libraries for doing the thing that you wa

using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
One thing I miss as I move from REALbasic to Python is the ability to have static storage within a method -- i.e. storage that is persistent between calls, but not visible outside the method. I frequently use this for such things as caching, or for keeping track of how many objects a facto

Re: Text based screens without ncurses

2008-11-13 Thread Mirat Can Bayrak
On Thu, 13 Nov 2008 12:14:10 -0500 Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > Why don't you want to use one of these libraries for doing the thing that > you want to do? mmm lets say i want to improve myself with building a curses like module. :) -- Mirat Can Bayrak <[EMAIL PROTECTED]> --

Re: using "private" parameters as static storage?

2008-11-13 Thread Chris Mellon
On Thu, Nov 13, 2008 at 11:16 AM, Joe Strout <[EMAIL PROTECTED]> wrote: > One thing I miss as I move from REALbasic to Python is the ability to have > static storage within a method -- i.e. storage that is persistent between > calls, but not visible outside the method. I frequently use this for su

Re: Text based screens without ncurses

2008-11-13 Thread Jean-Paul Calderone
On Thu, 13 Nov 2008 20:16:58 +0200, Mirat Can Bayrak <[EMAIL PROTECTED]> wrote: On Thu, 13 Nov 2008 12:14:10 -0500 Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: Why don't you want to use one of these libraries for doing the thing that you want to do? mmm lets say i want to improve myself wit

Re: using "private" parameters as static storage?

2008-11-13 Thread Matimus
On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > One thing I miss as I move from REALbasic to Python is the ability to   > have static storage within a method -- i.e. storage that is persistent   > between calls, but not visible outside the method.  I frequently use   > this for such thi

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Terry Reedy
Fredrik Lundh wrote: greg wrote: If you're going to indulge in argument by authority, you need to pick authorities that can be considered, er, authoritative in the field concerned... Like Barbara Liskov, who's won tons of awards for her work on computer science and programming languages, and

Re: using "private" parameters as static storage?

2008-11-13 Thread J. Cliff Dyer
On Thu, 2008-11-13 at 09:38 -0800, Matimus wrote: > On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > > One thing I miss as I move from REALbasic to Python is the ability to > > have static storage within a method -- i.e. storage that is persistent > > between calls, but not visible o

Re: using "private" parameters as static storage?

2008-11-13 Thread Steve Holden
Joe Strout wrote: > One thing I miss as I move from REALbasic to Python is the ability to > have static storage within a method -- i.e. storage that is persistent > between calls, but not visible outside the method. I frequently use > this for such things as caching, or for keeping track of how ma

Re: using "private" parameters as static storage?

2008-11-13 Thread J. Cliff Dyer
On Thu, 2008-11-13 at 11:19 -0600, Chris Mellon wrote: > On Thu, Nov 13, 2008 at 11:16 AM, Joe Strout <[EMAIL PROTECTED]> wrote: > > One thing I miss as I move from REALbasic to Python is the ability to have > > static storage within a method -- i.e. storage that is persistent between > > calls, b

What is the best Python GUI API?

2008-11-13 Thread Abah Joseph
What is the best Python GUI API? I am planning to start my first GUI application and I need something easy and cross platform. Qt applications look beautiful but I hate the license. What do you advice? -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the best Python GUI API?

2008-11-13 Thread Stef Mientki
Abah Joseph wrote: What is the best Python GUI API? I am planning to start my first GUI application and I need something easy and cross platform. Qt applications look beautiful but I hate the license. What do you advice? I agree about the Qt-license, and I'm now a happy wxPython user. cheers,

Re: using "private" parameters as static storage?

2008-11-13 Thread rurpy
On Nov 13, 11:32 am, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > On Thu, 2008-11-13 at 09:38 -0800, Matimus wrote: > > On Nov 13, 9:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > > > One thing I miss as I move from REALbasic to Python is the ability to > > > have static storage within a method --

Re: using "private" parameters as static storage?

2008-11-13 Thread Jean-Paul Calderone
On Thu, 13 Nov 2008 10:58:49 -0800 (PST), [EMAIL PROTECTED] wrote: On Nov 13, 11:32 am, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: On Thu, 2008-11-13 at 09:38 -0800, Matimus wrote: [snip] > Preserving state is what classes are for. Preserving state is what *objects* are for. Not exclusively

unittest exits

2008-11-13 Thread Alan Baljeu
When I call unittest.main(), it invokes sys.exit(). I would like to run tests without exiting. How can I? Alan Baljeu __ Instant Messaging, free SMS, sharing photos and more... Try the new Yahoo! Canada Messenger at http

Re: Text based screens without ncurses

2008-11-13 Thread Grant Edwards
On 2008-11-13, Mirat Can Bayrak <[EMAIL PROTECTED]> wrote: > Hi, i'll try to write a editor in python, i want it run under > terminal (no qt or gtk) but i dont want to use urwid or curses > modules. > > Can i write my curses like module in python? Sure. If you don't want to use the ncurses libra

Re: win32com and DispatchWithEvents

2008-11-13 Thread Mike Driscoll
On Nov 13, 10:27 am, RyanN <[EMAIL PROTECTED]> wrote: > Greetings, > > I'm trying to get DispatchWithEvents() to work with HyperAccess > (terminal program) without much success. I've done a bunch of > searching and found some examples using IE: > > This works but doesn't handle the "Event Driven Fu

Re: using "private" parameters as static storage?

2008-11-13 Thread rurpy
On Nov 13, 12:05 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Thu, 13 Nov 2008 10:58:49 -0800 (PST), [EMAIL PROTECTED] wrote: > >On Nov 13, 11:32 am, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote: > >> On Thu, 2008-11-13 at 09:38 -0800, Matimus wrote: > > [snip] > >> > Preserving state is wh

Re: What is the best Python GUI API?

2008-11-13 Thread James Harris
On 13 Nov, 18:59, Stef Mientki <[EMAIL PROTECTED]> wrote: > Abah Joseph wrote: > > What is the best Python GUI API? I am planning to start my first GUI > > application and I need something easy and cross platform. Qt > > applications look beautiful but I hate the license. What do you advice? > > I

Installing packages

2008-11-13 Thread Alan Baljeu
I'm new to Python, and just downloaded Py2.6. I also want to use Nose. So I downloaded the latest sources, but it's not at all clear what's the best way to put this stuff into the Python package system. Nose supports easy_install, easy_install doesn't have an installer for Windows and Py2.6,

Re: unittest exits

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 11:01 AM, Alan Baljeu <[EMAIL PROTECTED]> wrote: > When I call unittest.main(), it invokes sys.exit(). I would like to run > tests without exiting. How can I? There's probably a better way that stops it from trying to exit in the first place, but here's a quick kludge:

Re: Installing packages

2008-11-13 Thread Diez B. Roggisch
Alan Baljeu schrieb: I'm new to Python, and just downloaded Py2.6. I also want to use Nose. So I downloaded the latest sources, but it's not at all clear what's the best way to put this stuff into the Python package system. Nose supports easy_install, easy_install doesn't have an installer for

Re: using "private" parameters as static storage?

2008-11-13 Thread Steve Holden
Steve Holden wrote: > Joe Strout wrote: >> One thing I miss as I move from REALbasic to Python is the ability to >> have static storage within a method -- i.e. storage that is persistent >> between calls, but not visible outside the method. I frequently use >> this for such things as caching, or f

Re: What is the best Python GUI API?

2008-11-13 Thread Dotan Cohen
2008/11/13 Abah Joseph <[EMAIL PROTECTED]>: > What is the best Python GUI API? I am planning to start my first GUI > application and I need something easy and cross platform. Qt applications > look beautiful but I hate the license. What do you advice? Without dragging us into a flame war, could y

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread rurpy
On Nov 12, 7:09 pm, George Sakkis <[EMAIL PROTECTED]> wrote: > On Nov 12, 4:05 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >> greg wrote: >> >> It's not only misleading, it's also a seriously flawed reading of the >> >> original text - the Algol 60 report explicitly talks about assignment >> >>

Re: Python 2.5 and sqlite

2008-11-13 Thread Martin v. Löwis
> If you think making a distinction between the SQLite package and the > libsqlite package is pedantic - I don't have a problem with that. I think that is not only pedantic - it is also inaccurate. There is no SQLite package, nor is there a libsqlite package, in the bigger+ world. From http://

Re: duck-type-checking?

2008-11-13 Thread Craig Allen
> This is better achived, not by littering the functional code unit with > numerous assertions that obscure the normal function of the code, but > rather by employing comprehensive unit tests *separate from* the code > unit. that doesn't seem to work too well when shipping a library for someone el

Re: duck-type-checking?

2008-11-13 Thread Craig Allen
> since both are equally informative when it comes to tracing the faulty > assignment. > steve, they are not equally informative, the assertion is designed to fire earlier in the process, and therefore before much mischief and corruption can be done compared to later, when you happen to hit the m

Avoiding local variable declarations?

2008-11-13 Thread dpapathanasiou
I have some old Common Lisp functions I'd like to rewrite in Python (I'm still new to Python), and one thing I miss is not having to declare local variables. For example, I have this Lisp function: (defun random-char () "Generate a random char from one of [0-9][a-z][A-Z]" (if (< 50 (random 10

Little direction please Python MySQL

2008-11-13 Thread len
Hi all; I am looking for a little direction in moving from novice python MySQL to real world processing. I can connect to MySQL databases and have performed most of the various select, create, update, insert, etc given the examples in the various books and internet tutorials not to many problems.

Re: Avoiding local variable declarations?

2008-11-13 Thread Chris Mellon
On Thu, Nov 13, 2008 at 2:22 PM, dpapathanasiou <[EMAIL PROTECTED]> wrote: > I have some old Common Lisp functions I'd like to rewrite in Python > (I'm still new to Python), and one thing I miss is not having to > declare local variables. > > For example, I have this Lisp function: > > (defun rando

Re: Python 2.5 and sqlite

2008-11-13 Thread Thorsten Kampe
* "Martin v. Löwis" (Thu, 13 Nov 2008 20:58:35 +0100) > > If you think making a distinction between the SQLite package and the > > libsqlite package is pedantic - I don't have a problem with that. > > I think that is not only pedantic - it is also inaccurate. There is > no SQLite package, nor is

Re: What is the best Python GUI API?

2008-11-13 Thread rm
On Nov 13, 2:23 pm, James Harris <[EMAIL PROTECTED]> wrote: > On 13 Nov, 18:59, Stef Mientki <[EMAIL PROTECTED]> wrote: > > > Abah Joseph wrote: > > >  What is the best Python GUI API? I am planning to start my first GUI > > > application and I need something easy and cross platform. Qt > > > appli

Re: Avoiding local variable declarations?

2008-11-13 Thread Gary Herron
dpapathanasiou wrote: > I have some old Common Lisp functions I'd like to rewrite in Python > (I'm still new to Python), and one thing I miss is not having to > declare local variables. > > For example, I have this Lisp function: > > (defun random-char () > "Generate a random char from one of [0-

Re: Avoiding local variable declarations?

2008-11-13 Thread dpapathanasiou
> return chr( random.randrange(0, 26) + (97 if random.randrange(0, > 100) > 50 else 65) > or > > return chr( random.randrange(0, 26) + [26,97][random.randrange(0, > 100) > 50] Ah, thanks, these are the syntax examples I was looking for. > but what's wrong with you original code? I come

Re: Avoiding local variable declarations?

2008-11-13 Thread dpapathanasiou
> Any time you port between languages, it's rarely a good idea to just > convert code verbatim. For example: > > import random, string > def random_char(): > return random.choice(string.ascii_letters + string.digits) Good point, and thanks for the idiomatic Python example (I like the concisen

Re: Where can I get Lucid Toolkit?

2008-11-13 Thread member thudfoo
On 11/11/08, est <[EMAIL PROTECTED]> wrote: > Hi guys, > > I tried to grab source code for Lucid Toolkit > http://www.clarographics.org/svn_details > which was mentioned http://wiki.python.org/moin/GuiProgramming > > So is this project abandoned? Is there any backup that I can get the > code?

Re: What is the best Python GUI API?

2008-11-13 Thread Benjamin Kaplan
On Thu, Nov 13, 2008 at 3:36 PM, rm <[EMAIL PROTECTED]> wrote: > On Nov 13, 2:23 pm, James Harris <[EMAIL PROTECTED]> > wrote: > > On 13 Nov, 18:59, Stef Mientki <[EMAIL PROTECTED]> wrote: > > > > > Abah Joseph wrote: > > > > What is the best Python GUI API? I am planning to start my first GUI >

Re: using "private" parameters as static storage?

2008-11-13 Thread Aaron Brady
On Nov 13, 11:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > One thing I miss as I move from REALbasic to Python is the ability to   > have static storage within a method -- i.e. storage that is persistent   > between calls, but not visible outside the method.  I frequently use   > this for such th

Re: duck-type-checking?

2008-11-13 Thread George Sakkis
On Nov 13, 10:15 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Nov 12, 2008, at 7:32 PM, Steven D'Aprano wrote: > > > While the recipe is great, it can be tiresome to apply all the time. I > > would factor out the checks into a function, something like this: > > > def isstringlike(obj, methods=Non

Re: The return code

2008-11-13 Thread Aaron Brady
On Nov 13, 6:15 am, "devi thapa" <[EMAIL PROTECTED]> wrote: > Hi, > >           I am running one service in the python script eg like > "service httpd status". > If I execute this command in normal shell kernel, the return code is > 3. But in the python script its return code is different, ie not 3

Re: Avoiding local variable declarations?

2008-11-13 Thread Andrew Koenig
"Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >return chr( random.randrange(0, 26) + [26,97][random.randrange(0, > 100) > 50] return chr(random.randrange(0, 26) + (97 if random.randrange(0,100) > 50 else 26)) -- http://mail.python.org/mailman/listinfo/python-li

Re: The return code

2008-11-13 Thread Jeff McNeil
On Nov 13, 4:12 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > On Nov 13, 6:15 am, "devi thapa" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am running one service in the python script eg like > > "service httpd status". > > If I execute this command in normal shell kernel, the return code

embedding python

2008-11-13 Thread Alan Baljeu
Thanks, I have 2.5 now and it works great with Nose. Now for my next project, I want to embed Python and Nose in a C++ program. I know this means using the python25.dll, and I know how to setup the calls. I think though I will not be installing Python on target systems, so I don't want to re

Re: How to "reduce" a numpy array using a costum binary function

2008-11-13 Thread Robert Kern
Slaunger wrote: It is always good to ask yourself a question. I had forgooten about the reduce function I guess this implementation from numpy import * def compl_add_uint16(a, b): c = a + b c += c >> 16 return c & 0x def compl_one_checksum(uint16s): return reduce(compl_add

Documenation for yum and rpmUtils modules

2008-11-13 Thread Peter Wang
Hi All, I'm new to Python. I troubleshoot a yum install error. so i'm studying yum and rmpUtils module and try to understand how yum works. Do you know where can I find the documenation for yum and rpmUtils module? Thanks, Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: Little direction please Python MySQL

2008-11-13 Thread Steve Holden
len wrote: > Hi all; > > I am looking for a little direction in moving from novice python MySQL > to real world processing. > > I can connect to MySQL databases and have performed most of the > various select, create, update, insert, etc given the examples in the > various books and internet tuto

Python IF THEN chain equivalence

2008-11-13 Thread jzakiya
I'm translating a program in Python that has this IF Then chain IF x1 < limit: --- do a --- IF x2 < limit: --- do b --- IF x3 < limit: --- do c --- .- -- IF x10 < limt: --- do j --- T

Re: PIL's ImageFile Parser and PNG's

2008-11-13 Thread Silfheed
On Nov 12, 6:04 pm, Silfheed <[EMAIL PROTECTED]> wrote: > On Nov 12, 5:28 pm,Silfheed<[EMAIL PROTECTED]> wrote: > > > > > Heyas > > > So I've been messing around with the PIL and PNG's and came across a > > little problem with PNG's. > > > So just to clarify, I'm running with the standard ubuntu 8.

Re: Python IF THEN chain equivalence

2008-11-13 Thread Diez B. Roggisch
jzakiya schrieb: I'm translating a program in Python that has this IF Then chain IF x1 < limit: --- do a --- IF x2 < limit: --- do b --- IF x3 < limit: --- do c --- .- -- IF x10 < limt: --- do j ---

Re: using "private" parameters as static storage?

2008-11-13 Thread Paul McGuire
On Nov 13, 3:08 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > On Nov 13, 11:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > > > > > > > One thing I miss as I move from REALbasic to Python is the ability to   > > have static storage within a method -- i.e. storage that is persistent   > > between call

Re: Python IF THEN chain equivalence

2008-11-13 Thread Alan Baljeu
I think you should rethink your post. The first case you posted makes no sense in any language I know. Also, a whole lot of nested IF's is a bad idea in any language. In Python, you will end up with code indented 40+ characters if you keep going. - Original Message From: jzakiya <[

Re: using "private" parameters as static storage?

2008-11-13 Thread Paul Boddie
On 13 Nov, 18:16, Joe Strout <[EMAIL PROTECTED]> wrote: > One thing I miss as I move from REALbasic to Python is the ability to > have static storage within a method -- i.e. storage that is persistent > between calls, but not visible outside the method. I frequently use > this for such things as c

Re: Python IF THEN chain equivalence

2008-11-13 Thread jzakiya
On Nov 13, 5:21 pm, Alan Baljeu <[EMAIL PROTECTED]> wrote: > I think you should rethink your post. The first case you posted makes no > sense in any language I know.  Also, a whole lot of nested IF's is a bad idea > in any language.  In Python, you will end up with code indented 40+ > characters

Re: Python IF THEN chain equivalence

2008-11-13 Thread Grant Edwards
On 2008-11-13, jzakiya <[EMAIL PROTECTED]> wrote: > I'm translating a program in Python that has this IF Then chain > > > IF x1 < limit: --- do a --- > IF x2 < limit: --- do b --- > IF x3 < limit: --- do c --- >.- > -- >

Re: Python IF THEN chain equivalence

2008-11-13 Thread Grant Edwards
On 2008-11-13, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-11-13, jzakiya <[EMAIL PROTECTED]> wrote: >> I'm translating a program in Python that has this IF Then chain >> >> >> IF x1 < limit: --- do a --- >> IF x2 < limit: --- do b --- >> IF x3 < limit: --- do c --- >>

Re: Python IF THEN chain equivalence

2008-11-13 Thread M.-A. Lemburg
On 2008-11-13 23:31, jzakiya wrote: > On Nov 13, 5:21 pm, Alan Baljeu <[EMAIL PROTECTED]> wrote: >> I think you should rethink your post. The first case you posted makes no >> sense in any language I know. Also, a whole lot of nested IF's is a bad >> idea in any language. In Python, you will en

Re: Installing packages

2008-11-13 Thread [EMAIL PROTECTED]
On Nov 13, 2:25 pm, Alan Baljeu <[EMAIL PROTECTED]> wrote: > I'm new to Python, and just downloaded Py2.6.  I also want to use Nose.  So I > downloaded the latest sources, but it's not at all clear what's the best way > to put this stuff into the Python package system.  Nose supports > easy_inst

Re: ctypes shared object FILE*

2008-11-13 Thread member thudfoo
On 11/8/08, Dog Walker <[EMAIL PROTECTED]> wrote: > I need to call a function in a shared object with this signature: > init_dialog(FILE *input, FILE *output) > The FILE*'s are to stdin and stdout. > > The call from python is libdialog.init_dialog( x, y) > I need to define x and y so that they

Re: using "private" parameters as static storage?

2008-11-13 Thread Aaron Brady
On Nov 13, 4:13 pm, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Nov 13, 3:08 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > > > > > On Nov 13, 11:16 am, Joe Strout <[EMAIL PROTECTED]> wrote: > > > > One thing I miss as I move from REALbasic to Python is the ability to   > > > have static storage wit

  1   2   >