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

2008-11-13 Thread Slaunger
On 13 Nov., 22:48, Robert Kern <[EMAIL PROTECTED]> wrote: > 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

Re: Python IF THEN chain equivalence

2008-11-13 Thread Ethan Furman
Grant Edwards wrote: On 2008-11-14, Ethan Furman <[EMAIL PROTECTED]> wrote: jzakiya 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: duck-type-checking?

2008-11-13 Thread George Sakkis
On Nov 13, 10:55 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Take this example: > > def foo(alist): >     alist.sort() >     alist.append(5) > > The argument can be any object with sort and append methods (assumed to > act in place). But what happens if you pass it an objec

Re: email notifier question ??

2008-11-13 Thread Benjamin Kaplan
On Thu, Nov 13, 2008 at 11:23 PM, yoma <[EMAIL PROTECTED]> wrote: > Is it really impossible to get the message receipt ?? > i hope more people to help me! > -- > When you send the email, there isn't even any way to ensure that it got through, let alone that the recipient read it. When you send

Re: email notifier question ??

2008-11-13 Thread Steve Holden
yoma wrote: >Is it really impossible to get the message receipt ?? > i hope more people to help me! Even though it is possible to 'Request a return receipt" there is no guarantee that the recipient will agree to send one. If the recipient *does* allow a return receipt to be sent you will have

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 18:57:37 -0800, alex23 wrote: > On Nov 14, 12:16 pm, Joe Strout <[EMAIL PROTECTED]> wrote: >> Argh.  I've been back in the Python community for about a month, and >> I've been continually amazed at how every single "how do I do X" or >> "what do you think of this method of doin

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 19:52:13 -0700, Joe Strout wrote: > Pity there isn't a way for a function to get a reference to itself > except by name. Still, when you rename a method, you're going to have > to update all the callers anyway -- updating a couple of extra > references within the method is not

Win98, Python 2.5 and plotmatlib

2008-11-13 Thread W. eWatson
Has anyone gotten the combination of items in the Subject to work together? The pylab line here fails: from Tkinter import * from numpy import * import Image import ImageChops import ImageTk import time import binascii import tkMessageBox import tkSimpleDialog from pylab import plot, xlabel, yla

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Fri, 14 Nov 2008 13:35:02 +1100, Ben Finney wrote: > Instead, it looks like you're falling foul of one of the classic > mistakes in the “How to ask questions the smart way” document: you've > got a goal, but you're assuming that you need to use a specific tool to > get there. Instead, you're be

Re: email notifier question ??

2008-11-13 Thread yoma
Is it really impossible to get the message receipt ?? i hope more people to help me! -- http://mail.python.org/mailman/listinfo/python-list

Re: To throw or to throw not?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 17:11:26 -0800, Emanuele D'Arrigo wrote: > I'm pondering on what is a bit of a philosophical dilemma. When should I > throw an exception and when should I not? > > Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 > (). > Suppose myFunc3() has detected a p

Re: duck-type-checking?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 14:28:49 +0100, paul wrote: > 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

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 14:25:08 -0800, Paul Boddie wrote: > 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 outs

Re: email notifier question ??

2008-11-13 Thread Grant Edwards
On 2008-11-14, yoma <[EMAIL PROTECTED]> wrote: > I want to use python send an email to acceptor. That's easy. > $B!!(BAnd i hope to receive the message that the acceptor > has read my email. That's not generally possible. > So how to realize that get the message? In the message you send, as

Re: Python IF THEN chain equivalence

2008-11-13 Thread Grant Edwards
On 2008-11-14, Ethan Furman <[EMAIL PROTECTED]> wrote: > jzakiya 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: duck-type-checking?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 13:11:12 -0800, George Sakkis wrote: > 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 functi

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
Hi Luis, A lot of languages have ditched the "concept" of a static variable on a method (how do you parse that sentence, btw?) in favour of using encapsulation. A static variable IS encapsulation. Encapsulation happens at many levels: module, class, instance, and (in languages that suppor

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 13:35:21 -0500, 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 >>

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 14:05:17 -0500, Jean-Paul Calderone 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 what class

Re: using "private" parameters as static storage?

2008-11-13 Thread Steven D'Aprano
On Thu, 13 Nov 2008 10:16:59 -0700, 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 ca

Re: using "private" parameters as static storage?

2008-11-13 Thread Arnaud Delobelle
Aaron Brady <[EMAIL PROTECTED]> writes: > One way around it, which I like the idea of but I'll be honest, I've > never used, is getting a function a 'self' parameter. You could make > it a dictionary or a blank container object, or just the function > itself. > > @self_param > def spam( self ): >

Re: Avoiding local variable declarations?

2008-11-13 Thread Arnaud Delobelle
dpapathanasiou <[EMAIL PROTECTED]> writes: >> but what's wrong with you original code? > > I come from a functional programming school of thought, where you > avoid local variable declarations if at all possible. Holding on to this principle won't help you write nice Python code :) Although you

Re: using "private" parameters as static storage?

2008-11-13 Thread George Sakkis
On Nov 13, 9:22 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > Steve wrote: > > This is a pretty bizarre requirement, IMHO. The normal place to keep > > such information is either class variables or instance variables. > > Holy cow, I thought it was just Chris, but there were half a dozen   > similar

Re: using "private" parameters as static storage?

2008-11-13 Thread Luis Zarrabeitia
Quoting Joe Strout <[EMAIL PROTECTED]>: > On Nov 13, 2008, at 10:19 AM, Chris Mellon wrote: > > > Static storage is a way of preserving state. Objects are a way of > > encapsulating state and behavior. Use an object. > > Argh. I've been back in the Python community for about a month, and >

Re: using "private" parameters as static storage?

2008-11-13 Thread alex23
On Nov 14, 12:16 pm, Joe Strout <[EMAIL PROTECTED]> wrote: > Argh.  I've been back in the Python community for about a month, and   > I've been continually amazed at how every single "how do I do X" or   > "what do you think of this method of doing X" question is answered by   > people on high hors

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
On Nov 13, 2008, at 11:15 AM, J. Cliff Dyer wrote: Here are a few essays into the matter def foo(): ... foo._count += 1 ... return ("spam " * foo.count).rstrip() Simple and straightforward, and _count is still encapsulated in the function, but it's kind of ugly, because when the func

Re: email notifier question ??

2008-11-13 Thread Chris Rebert
2008/11/13 yoma <[EMAIL PROTECTED]>: > hi guys! >I want to use python send an email to acceptor. And i hope to > receive the message that the acceptor has read my email. > > So how to realize that get the message? To send an email using Python, you'll need to use the `smtplib` module: http:/

Re: using "private" parameters as static storage?

2008-11-13 Thread Ben Finney
Joe Strout <[EMAIL PROTECTED]> writes: > On Nov 13, 2008, at 10:19 AM, Chris Mellon wrote: > > > Static storage is a way of preserving state. Objects are a way of > > encapsulating state and behavior. Use an object. > > Argh. I've been back in the Python community for about a month, and > I've b

email notifier question ??

2008-11-13 Thread yoma
hi guys! I want to use python send an email to acceptor.  And i hope to receive the message that the acceptor has read my email. So how to realize that get the message? -- http://mail.python.org/mailman/listinfo/python-list

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
Steve wrote: This is a pretty bizarre requirement, IMHO. The normal place to keep such information is either class variables or instance variables. Holy cow, I thought it was just Chris, but there were half a dozen similar responses after that. I'm starting to see a pattern here... any tim

Re: using "private" parameters as static storage?

2008-11-13 Thread Joe Strout
On Nov 13, 2008, at 10:19 AM, Chris Mellon wrote: Static storage is a way of preserving state. Objects are a way of encapsulating state and behavior. Use an object. Argh. I've been back in the Python community for about a month, and I've been continually amazed at how every single "how do I

Re: Avoiding local variable declarations?

2008-11-13 Thread Paul McGuire
On Nov 13, 6:47 pm, [EMAIL PROTECTED] wrote: > Paul McGuire: > > > coinflip = lambda : int(random.random()*2) > > I warmly suggest you to use this instead: > randrange(2) > > Bye, > bearophile Really? Looking at randrange, it sure seems to do a lot of work in pursuit of handling all possible case

Re: To throw or to throw not?

2008-11-13 Thread Steve Holden
Emanuele D'Arrigo wrote: > I'm pondering on what is a bit of a philosophical dilemma. > When should I throw an exception and when should I not? > > Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 > (). > Suppose myFunc3() has detected a problem. What should it do? > > Throw

Re: To throw or to throw not?

2008-11-13 Thread Mensanator
On Nov 13, 7:11 pm, "Emanuele D'Arrigo" <[EMAIL PROTECTED]> wrote: > I'm pondering on what is a bit of a philosophical dilemma. > When should I throw an exception and when should I not? > > Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 > (). > Suppose myFunc3() has detected

Re: Little direction please Python MySQL

2008-11-13 Thread Ethan Furman
len wrote: Hi all; [snip] Here is my problem. I need to start doing this in the really world at my company converting some older cobol system and data to python programs and MySQL. I have gotten past packed decimal fields and various other little tidbits. My problem is the data files aren'

Re: To throw or to throw not?

2008-11-13 Thread Chris Rebert
On Thu, Nov 13, 2008 at 5:11 PM, Emanuele D'Arrigo <[EMAIL PROTECTED]> wrote: > I'm pondering on what is a bit of a philosophical dilemma. > When should I throw an exception and when should I not? > > Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 > (). > Suppose myFunc3() h

Re: Python IF THEN chain equivalence

2008-11-13 Thread Ethan Furman
jzakiya 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 --- .- -- IF x10 < limt: --- do j ---

Re: What is the best Python GUI API?

2008-11-13 Thread Alex_Gaynor
On Nov 13, 7:08 pm, Stef Mientki <[EMAIL PROTECTED]> wrote: > rm 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 m

Re: Python IF THEN chain equivalence

2008-11-13 Thread Mensanator
On Nov 13, 4:39 pm, 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 ---

Code generation architecture question

2008-11-13 Thread Alex_Gaynor
I'm trying to figure out what the best architecture for doing code generation would be. I have a set of ASTs that define a program, so what should I do to for code generation. As I see it the 2 choices are to have the ASTs have a generate code method that returns the correct code for themselves,

To throw or to throw not?

2008-11-13 Thread Emanuele D'Arrigo
I'm pondering on what is a bit of a philosophical dilemma. When should I throw an exception and when should I not? Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 (). Suppose myFunc3() has detected a problem. What should it do? Throw an exception, forcing myFunc2() to handl

Re: Avoiding local variable declarations?

2008-11-13 Thread bearophileHUGS
Paul McGuire: > coinflip = lambda : int(random.random()*2) I warmly suggest you to use this instead: randrange(2) Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use a contiguous memory location of n bytes in python

2008-11-13 Thread bearophileHUGS
chachi: > I want to know how to instantiate a data structure which has n bytes > (given by me) and is internally stored in a contiguous fashion. array.array("B", ...) may be fit for you. You can also use a numpy array of bytes. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-lis

Re: Python IF THEN chain equivalence

2008-11-13 Thread bearophileHUGS
jzakiya: > I asked a very narrow question about a very specific language > mechanism, and I know exactly what and why I'm doing what I'm doing. You are of course free to use Python as you want. And probably some of the answers weren't fully polite. But it's interesting to see why they have given s

Re: Avoiding local variable declarations?

2008-11-13 Thread Paul McGuire
On Nov 13, 2:32 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: > 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 > > dec

How to use a contiguous memory location of n bytes in python

2008-11-13 Thread chachi
Hi, I want to know how to instantiate a data structure which has n bytes (given by me) and is internally stored in a contiguous fashion. I know list is not implemented like this, so I am in a fix. There seems to be a buffer object available, but haven't seen it being used anywhere. Does anyone kno

Re: Python IF THEN chain equivalence

2008-11-13 Thread M.-A. Lemburg
On 2008-11-14 00:19, jzakiya wrote: > On Nov 13, 5:48 pm, "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: From: jzakiya <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Sent: Thursday, November 13, 2008 5:06:53 PM Subject: Python IF THEN chain equivalence I'm translating a program in P

Re: using "private" parameters as static storage?

2008-11-13 Thread Steve Holden
Ben Finney wrote: > Joe Strout <[EMAIL PROTECTED]> writes: > >> 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 > > This is precisely what classes are for: allowing functionality and >

Re: unittest exits

2008-11-13 Thread Ben Finney
Alan Baljeu <[EMAIL PROTECTED]> writes: > When I call unittest.main(), it invokes sys.exit(). I would like to > run tests without exiting. How can I? Use a ‘TestRunner’ instance, instead of ‘main()’. -- \ “If you go flying back through time and you see somebody else | `\ flying forwa

Re: using "private" parameters as static storage?

2008-11-13 Thread Ben Finney
Joe Strout <[EMAIL PROTECTED]> writes: > 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 This is precisely what classes are for: allowing functionality and state to exist in a single obj

Re: What is the best Python GUI API?

2008-11-13 Thread Stef Mientki
rm 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 application and I need something easy and cross platform. Qt

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

2008-11-13 Thread Terry Reedy
[EMAIL PROTECTED] wrote: I have yet to see any reasonable definition of a Python value in the Python docs or elsewhere, despite the fact that a value is one of the three defining characteristics of an object, a central concept in Python. I noticed too. My try: The value of an object is the i

Re: Avoiding local variable declarations?

2008-11-13 Thread Aahz
In article <[EMAIL PROTECTED]>, dpapathanasiou <[EMAIL PROTECTED]> wrote: > >I come from a functional programming school of thought, where you >avoid local variable declarations if at all possible. Python is *so* not a functional programming language. There are a number of functional programming

Re: Python IF THEN chain equivalence

2008-11-13 Thread jzakiya
On Nov 13, 5:48 pm, "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: > 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

Re: duck-type-checking?

2008-11-13 Thread Steve Holden
Craig Allen wrote: >> 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,

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

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: 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: 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: 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 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 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: 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 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 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 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: 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.

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: 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

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: 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

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: 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

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 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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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

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.

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

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

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: 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: 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: 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: 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: 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: 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:

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: 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

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: 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: 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

  1   2   >