better way to write this function

2007-11-25 Thread Kelie
Hello, This function does I what I want. But I'm wondering if there is an easier/better way. To be honest, I don't have a good understanding of what "pythonic" means yet. def divide_list(lst, n): """Divide a list into a number of lists, each with n items. Extra items are ignored, if an

Re: basic if stuff- testing ranges

2007-11-25 Thread Paddy
On Nov 25, 6:49 pm, Donn Ingle <[EMAIL PROTECTED]> wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > > So that x must be > 0 and < 20. > > I usually do: > if x > 0 and x < 20: print "within" > > What's the rule? Does it even exist? >

Re: Code Management

2007-11-25 Thread A.T.Hofkamp
On 2007-11-24, BlueBird <[EMAIL PROTECTED]> wrote: > On Nov 21, 7:05 am, "Sergio Correia" <[EMAIL PROTECTED]> wrote: > And then you do your development in python-dev. But how do you manage > multiple development branches of the same program ? If you are using SVN, you may want to check out 'combi

RE: Recursive loading trouble for immutables

2007-11-25 Thread rekkufa
Mel wrote: ... >Here's something that works, in the sense of creating a tuple >containing a self-reference. I don't know how dangerous it realliy is ... Thanks for the testing. Given the unknown dangers that might (or might not) lurk with these things, the fact that recursive tuples are never go

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread MonkeeSage
On Nov 25, 3:30 pm, Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > MonkeeSage <[EMAIL PROTECTED]> wrote: > > I use the following for a progam I wrote using sqlite, to ensure > > maximum compatibility (since the API is the same, importing them both > > as 'sqlite' should be fine): > > > try: > >

Very beautiful girls and complete stock information, please check it out

2007-11-25 Thread my glass
Very beautiful girls and complete stock information,please check it out http://groups.google.com/group/all-good-things/web/beautiful-girls-and-ladies -- http://mail.python.org/mailman/listinfo/python-list

i want to know what is the problem in this code

2007-11-25 Thread nani
i am getting the following error for below code Python 2.5.1: C:\Python25\python.exe Mon Nov 26 10:13:17 2007 A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. C:\Program Files\Apache Group\Apache2\cgi-bin\hello

Re: Compile Cheetah Template on Windows

2007-11-25 Thread Tim Roberts
brianrpsgt1 <[EMAIL PROTECTED]> wrote: > >I have been able to successful pull info from a MySQL DB, get the >results and output them in an HTML format using Cheetah to the screen >using IDLE. I am doing this on a Windows Laptop, running WinXP, >Python 2.5 and the latest version of Cheetah. > >I ha

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
>> if 0 > x < 20: print "within" > That means "if x LESS THAN 0 and x < 20". Oh, bugger. It's tricky. > So try > if 0 < x < 20: Thanks. I was flipping signs in my tests, but I guess I flipped both and got myself all confused. > Likely manuals: Tutorial & Reference > Tutorial: check contents,

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
> > if 0 > x: print "within" > Ah, I didn't know you could one could use the sarcasm.xml module and then use tags to influence Python commands. Most interesting... import sarcasm.xml I.fartIn( Your.Direction( general ) ) :D \d -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
Mel wrote: > if 0 < x < 20: > ? I take it I was tripping then. That's okay, it seemed a little too weird anyway :) \d -- http://mail.python.org/mailman/listinfo/python-list

Re: basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
> you mean : 0 < x < 20 ? Yes. I had gotten the impression that there was some Python form of: if NUMBER test VAR test NUMBER: Part of the question was to discover if I was smoking my socks :) > x in range(1,20) ? Sure, that's okay, but it has clarity issues, and is calling a func. >> but then a

Re: mod_python

2007-11-25 Thread [EMAIL PROTECTED]
On Nov 24, 1:19 am, Vernon Wenberg III <[EMAIL PROTECTED]> wrote: > Why do I receive a "File not found" error on a perfect good and simple > script but properly receive errors when I deliberately add errors in the > script? The file is there, it just doesn't do anything. > > Any help would be appre

multiple selection of cells

2007-11-25 Thread linda.s
Hi, I wonder how to hold the ctrl key and left button (button-1) to do multiple selection of the following items? Thanks, Linda import Tkinter s = Tkinter.Scrollbar() L = Tkinter.Listbox() s.pack(side=Tkinter.RIGHT, fill=Tkinter.Y) L.pack(side=Tkinter.LEFT, fill=Tkinter.Y) s.config(command=L.yv

Re: OPLC purchase period extended

2007-11-25 Thread Grant Edwards
On 2007-11-26, Damjan <[EMAIL PROTECTED]> wrote: >> It is fairly nice for that. It's especially cool that the screen >> works outdoors (reflective). I don't know why regular laptops don't >> do that any more. > > I think because they can't reproduce colors correctly with > reflective light. It'

Re: How to display unicode with the CGI module?

2007-11-25 Thread Jan Claeys
Op Sun, 25 Nov 2007 13:02:26 -0800, schreef coldpizza: > It is funny that encode() and decode() omit the name of the other > encoding (Unicode ucs2?), which makes it far less readable than a > s.recode('ucs2','utf8'). The internal encoding/representation of a "string" of Unicode characters is co

Re: Python web frameworks

2007-11-25 Thread Jan Claeys
Op Fri, 23 Nov 2007 09:29:38 -0800, schreef BartlebyScrivener: > I'm just learning Django and feeling my way through all of this server > terminology. Where does Django's memcached feature fit into all of this? > When you all speak of start up costs and memory intensive loading for > each requests

Re: OPLC purchase period extended

2007-11-25 Thread Damjan
> It is fairly nice for that. It's especially cool that the screen > works outdoors (reflective). I don't know why regular laptops don't > do that any more. I think because they can't reproduce colors correctly with reflective light. The OLPC is black&white (and grey) when in the reflective outd

image rendering in python

2007-11-25 Thread mobiledreamers
http://cdnll.i.imagechef.com/ic/templimg2/Shaved%20Head.jpg Do u know how to make such images using PIL or other tools in python thanks a lot for your kind help -- http://mail.python.org/mailman/listinfo/python-list

Re: How to Teach Python "Variables"

2007-11-25 Thread none
Ben Finney wrote: > none <""atavory\"@(none)"> writes: > >> IIRC, I once saw an explanation how Python doesn't have "variables" >> in the sense that, say, C does, and instead has bindings from names >> to objects. Does anyone have a link? > > In addition to the good answers you've had already, I

Re: win32serviceutil won't start

2007-11-25 Thread Nikola Skoric
Dana Sun, 25 Nov 2007 13:52:35 -0800 (PST), [EMAIL PROTECTED] <[EMAIL PROTECTED]> kaze: > Looks like Microsoft thinks you mis-spelled it. > > http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2000Msgs/3310.mspx?mfr=true > > I would check and see if that service is installed on y

Re: How to Teach Python "Variables"

2007-11-25 Thread Ben Finney
none <""atavory\"@(none)"> writes: > IIRC, I once saw an explanation how Python doesn't have "variables" > in the sense that, say, C does, and instead has bindings from names > to objects. Does anyone have a link? In addition to the good answers you've had already, I highly recommend David Goodge

Re: basic if stuff- testing ranges

2007-11-25 Thread J. Clifford Dyer
On Sun, 2007-11-25 at 20:49 +0200, Donn Ingle wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > if 0 > x: print "within" -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing modules via setuptools in a script

2007-11-25 Thread Ben Finney
Thorsten Kampe <[EMAIL PROTECTED]> writes: > * Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) > > Thorsten Kampe wrote: > > > can anyone give me a short code snippet how to install a missing > > > module via setuptools (assuming setuptools is already > > > installed)?! > > > > The recommended way

Re: win32serviceutil won't start

2007-11-25 Thread kyosohma
On Nov 25, 2:40 pm, Nikola Skoric <[EMAIL PROTECTED]> wrote: > I have a very simple win32serviceutil script: > import win32serviceutil, time > > win32serviceutil.StartService("burek", "localhost") > > time.sleep(10) > > exit() > > It successfuly imports win32serviceutil, and chokes on StartService:

Re: Subprocess and 16-bit FORTRAN

2007-11-25 Thread Nick Craig-Wood
Federico Ceccatto <[EMAIL PROTECTED]> wrote: > This is the kind of 'bugs' i've run into, perhaps someone could shed > some light onto them? > > - Sometimes execution of child process (in this case, NTVDM.exe and > its children) stops and the object is destroyed for no reason > whatsoever. Ver

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread Nick Craig-Wood
MonkeeSage <[EMAIL PROTECTED]> wrote: > I use the following for a progam I wrote using sqlite, to ensure > maximum compatibility (since the API is the same, importing them both > as 'sqlite' should be fine): > > try: >from sqlite3 import dbapi2 as sqlite # python 2.5 I've been using

Re: the annoying, verbose self

2007-11-25 Thread Arnaud Delobelle
On Nov 24, 10:55 am, jakub silar <[EMAIL PROTECTED]> wrote: > BJörn Lindqvist wrote: > > On Nov 22, 2007 2:08 PM, Colin J. Williams <[EMAIL PROTECTED]> wrote: > > >>[EMAIL PROTECTED] wrote: > > >>>Alexy: > > Sometimes I > avoid OO just not to deal with its verbosity. In fact, I try to use

Re: How to display unicode with the CGI module?

2007-11-25 Thread coldpizza
> Unicode != UTF-8. ... >`encode()` method is your friend. Thanks a lot for help! I am always confused as to which one to use: encode() or decode(); I have initially tried decode() and it did not work. It is funny that encode() and decode() omit the name of the other encoding (Unicode ucs2?), wh

Greylisting with Kamaelia (was Re: Python North-West meeting - 6 november 18.30)

2007-11-25 Thread Michael Sparks
Giacomo Lacava wrote: > New meeting of the Python North-West UK community! > > This month's talk is: > - Michael Sparks on "Greylisting with Kamaelia" - Just a small note that the slides from this are now up here: http://www.slideshare.net/kamaelian/kamaelia-grey With the main page on the Ka

Re: OPLC purchase period extended

2007-11-25 Thread Paul Rubin
Grant Edwards <[EMAIL PROTECTED]> writes: > It's not going to be a full-time computer. It's mostly going > to be something to play with -- though using it in tablet mode > as an e-book reader sounds like it might work. It is fairly nice for that. It's especially cool that the screen works outdoo

win32serviceutil won't start

2007-11-25 Thread Nikola Skoric
I have a very simple win32serviceutil script: import win32serviceutil, time win32serviceutil.StartService("burek", "localhost") time.sleep(10) exit() It successfuly imports win32serviceutil, and chokes on StartService: Traceback (most recent call last): File "foobar.py", line 3, in ? win3

Re: How to Teach Python "Variables"

2007-11-25 Thread Bjoern Schliessmann
Aurélien Campéas wrote: > I mean : aren't C variables also bindings from names to objects ? No, C variables are aliases for memory addresses. Regards, Björn -- BOFH excuse #390: Increased sunspot activity. -- http://mail.python.org/mailman/listinfo/python-list

Re: OPLC purchase period extended

2007-11-25 Thread Grant Edwards
On 2007-11-25, Paul Rubin wrote: > You've got to remember that the OLPC was made for little kids, > and as such, the keyboard is quite small. Also, because of > its expected physical environment, the keyboard is water > resistant (membrane cover). These two things make the OLPC > difficult enou

Re: How to Teach Python "Variables"

2007-11-25 Thread none
Aahz wrote: > In article <[EMAIL PROTECTED]>, none <""atavory\"@(none)"> wrote: >> IIRC, I once saw an explanation how Python doesn't have "variables" in >> the sense that, say, C does, and instead has bindings from names to >> objects. Does anyone have a link? > > http://starship.python.n

Re: OPLC purchase period extended

2007-11-25 Thread Paul Rubin
Grant Edwards <[EMAIL PROTECTED]> writes: > The most imporant thing is that the "control" key is to the > left of the "A" keay where god intened. Not too surprising > when you realized the design was headed by folks from the media > lab at MIT. MIT requires everybody to use Emacs, right? You've

Re: How to Teach Python "Variables"

2007-11-25 Thread Andrew Koenig
"Aurélien Campéas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I mean : aren't C variables also bindings from names to objects ? Or what > ? No, they're not. In C, when you execute x = y; you cause x to become a copy of y. In Python, when you execute x = y you ca

Re: basic if stuff- testing ranges

2007-11-25 Thread John Machin
On Nov 26, 5:49 am, Donn Ingle <[EMAIL PROTECTED]> wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" That means "if x LESS THAN 0 and x < 20". > > So that x must be > 0 and < 20. So try if 0 < x < 20: > > I usually do: > if x >

Re: How to Teach Python "Variables"

2007-11-25 Thread Aahz
In article <[EMAIL PROTECTED]>, none <""atavory\"@(none)"> wrote: > > IIRC, I once saw an explanation how Python doesn't have "variables" in >the sense that, say, C does, and instead has bindings from names to >objects. Does anyone have a link? http://starship.python.net/crew/mwh/hacks/ob

Re: How to Teach Python "Variables"

2007-11-25 Thread none
Aurélien Campéas wrote: > none a écrit : >> Hello, >> >> IIRC, I once saw an explanation how Python doesn't have >> "variables" in the sense that, say, C does, and instead has bindings >> from names to objects. Does anyone have a link? >> >> Thanks, >> >> Ami > > That's something

Re: How to Teach Python "Variables"

2007-11-25 Thread Diez B. Roggisch
Aurélien Campéas schrieb: > none a écrit : >> Hello, >> >> IIRC, I once saw an explanation how Python doesn't have >> "variables" in the sense that, say, C does, and instead has bindings >> from names to objects. Does anyone have a link? >> >> Thanks, >> >> Ami > > That's somethi

[ANN] pysqlite 2.4.0 released

2007-11-25 Thread Gerhard Häring
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 pysqlite 2.4.0 released === I'm pleased to announce the availability of pysqlite 2.4.0. This is a release with major new features. Go to http://pysqlite.org/ for downloads, online documentation and reporting bugs. What is pysqlit

Re: How to Teach Python "Variables"

2007-11-25 Thread Aurélien Campéas
none a écrit : > Hello, > > IIRC, I once saw an explanation how Python doesn't have "variables" > in the sense that, say, C does, and instead has bindings from names to > objects. Does anyone have a link? > > Thanks, > > Ami That's something I've often heard and I don't get it

Re: basic if stuff- testing ranges

2007-11-25 Thread Aurélien Campéas
Donn Ingle a écrit : > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" you mean : 0 < x < 20 ? or x in xrange(1,20) ? > > So that x must be > 0 and < 20. > > I usually do: > if x > 0 and x < 20: print "within" > > What's the rule? Does

Re: basic if stuff- testing ranges

2007-11-25 Thread Mel
Donn Ingle wrote: > Sheesh, I've been going spare trying to find how to do this short-hand: > if 0 > x < 20: print "within" > > So that x must be > 0 and < 20. > > I usually do: > if x > 0 and x < 20: print "within" > > What's the rule? Does it even exist? if 0 < x < 20: ? Mel. -

basic if stuff- testing ranges

2007-11-25 Thread Donn Ingle
Sheesh, I've been going spare trying to find how to do this short-hand: if 0 > x < 20: print "within" So that x must be > 0 and < 20. I usually do: if x > 0 and x < 20: print "within" What's the rule? Does it even exist? I read something like it recently on the list but can't find it, that's whe

Re: Trouble getting loop to break

2007-11-25 Thread Fredrik Johansson
On Nov 25, 2007 2:47 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Wow. your f() is ingenious, Frederik. Thanks very much. > > Any more tricks up your sleeve? You did say a post or so ago, > "Further improvements are possible." The next improvement would be to find a recurrence formula for the term

How to Teach Python "Variables"

2007-11-25 Thread none
Hello, IIRC, I once saw an explanation how Python doesn't have "variables" in the sense that, say, C does, and instead has bindings from names to objects. Does anyone have a link? Thanks, Ami -- http://mail.python.org/mailman/listinfo/python-list

Re: PyQt, Cannot send events to objects owned by a different thread?

2007-11-25 Thread Alexander Tuchacek
David Boddie wrote: > You can either construct some sort of event handling mechanism or use > signals and slots. Personally, I'd use signals and slots for this, if > possible. > > The idea would be to set up a connection between your callback code and > the status bar's showMessage() slot. Then y

Re: Recursive loading trouble for immutables

2007-11-25 Thread Mel
Mel wrote: > rekkufa wrote: [ ... ] >> How to load >> data that specifies immutables that recursively reference >> themselves. > I can imagine a C function that might do it. [ ... ] Here's something that works, in the sense of creating a tuple containing a self-reference. I don't know how danger

Re: PyQt, Cannot send events to objects owned by a different thread?

2007-11-25 Thread David Boddie
On Sun Nov 25 15:22:24 CET 2007, Alexander Tuchacek wrote: > i try to adress an qt object > > self.statusbar.showMessage("rtt %s" % (n.rtt)) > > in an callback function, comming from a shared lib importet by ctypes, on > osx this works wonderfull > > when i run the same code on linux (ubu

Re: OPLC purchase period extended

2007-11-25 Thread Grant Edwards
On 2007-11-25, Aahz <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Grant Edwards <[EMAIL PROTECTED]> wrote: >> >>The most imporant thing is that the "control" key is to the left of the >>"A" keay where god intened. Not too surprising when you realized the >>design was headed by fo

Re: the annoying, verbose self

2007-11-25 Thread Colin J. Williams
MonkeeSage wrote: > The issue of lexical scope still looms large on the horizon. How does > one distinguish between attributes (as scoped by the "with" clause), > local/global variables, and function/method calls? There doesn't seem > to be an easy way. You'd need multiple passes over the data to >

Re: the annoying, verbose self

2007-11-25 Thread Colin J. Williams
Andrew Koenig wrote: I am not advocating this, but this could be: def abs(self): with self: with math: return sqrt(x**2 + y**2 + z**2) The idea being that "with self" use creates a new namespace: newGlobal= oldGlobal + oldLoc

You have come? Definitely you have not gone

2007-11-25 Thread shoplifes
Dear Friends The Shoplifes.com belongs to Shoplife Limited Company who mainly sell personal stylish electronic consumable products such as Mobile phones, Laptops, Digital Cameras, Digital Videos,Mp3,Mp4 and bulk products such as LCD TV, Motorcycles and so on. The specific item please visit our c

Re: PyQt, Cannot send events to objects owned by a different thread?

2007-11-25 Thread Bjoern Schliessmann
Alexander Tuchacek wrote: > i try to adress an qt object > > self.statusbar.showMessage("rtt %s" % (n.rtt)) > > in an callback function, comming from a shared lib importet by > ctypes, on osx this works wonderfull > > when i run the same code on linux (ubuntu gutsy), i get this core > dump,

Re: the annoying, verbose self

2007-11-25 Thread MonkeeSage
The issue of lexical scope still looms large on the horizon. How does one distinguish between attributes (as scoped by the "with" clause), local/global variables, and function/method calls? There doesn't seem to be an easy way. You'd need multiple passes over the data to determine various scopes --

PyQt, Cannot send events to objects owned by a different thread?

2007-11-25 Thread Alexander Tuchacek
hallo, i try to adress an qt object self.statusbar.showMessage("rtt %s" % (n.rtt)) in an callback function, comming from a shared lib importet by ctypes, on osx this works wonderfull when i run the same code on linux (ubuntu gutsy), i get this core dump, ok, i understand that the problem

RE: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
> I am not advocating this, but this could be: > def abs(self): >with self: > with math: >return sqrt(x**2 + y**2 + z**2) > The idea being that "with self" use > creates a new namespace: >newGlobal= oldGlobal + oldLocal >newLocal= names from self You don't know what thos

Re: the annoying, verbose self

2007-11-25 Thread Colin J. Williams
Andrew Koenig wrote: > "Colin J. Williams" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> Alternatively, as someone else suggested, an analogue of the Pascal "with" >> could be used: >> >> def abs(self): >> with self: >> return math.sqrt(x**2 + y**2 + z**2) > > How does

Re: OPLC purchase period extended

2007-11-25 Thread GHUM
> > [http://laptopgiving.org/en/terms-and-conditions.php] > > I'm sure that some people would be willing to serve as middleware... So, which US-Pythoneer is willing to serve as middleware for my buying of the XO? Please contact me. Harald -- GHUM Harald Massa persuadere et programmare Harald A

Re: the annoying, verbose self

2007-11-25 Thread Andrew Koenig
"Colin J. Williams" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Alternatively, as someone else suggested, an analogue of the Pascal "with" > could be used: > > def abs(self): > with self: > return math.sqrt(x**2 + y**2 + z**2) How does your suggested "with" statement know

Re: Trouble getting loop to break

2007-11-25 Thread Dick Moores
At 03:26 AM 11/25/2007, Fredrik Johansson wrote: >On Nov 25, 2007 9:00 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > > Fredrik, > > > > I'm afraid I'm just too dumb to see how to use your first suggestion > > of cached_factorials. Where do I put it and def()? Could you show me, > > even on-line, wha

Re: Installing modules via setuptools in a script

2007-11-25 Thread Thorsten Kampe
* Robert Kern (Sat, 24 Nov 2007 16:33:37 -0600) > Thorsten Kampe wrote: > > can anyone give me a short code snippet how to install a missing > > module via setuptools (assuming setuptools is already installed)?! > > > > Something like this: > > > > try: > > import missing_module > > except i

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread Colin J. Williams
Steven D'Aprano wrote: > On Sun, 25 Nov 2007 01:38:51 +0100, Hrvoje Niksic wrote: > >> samwyse <[EMAIL PROTECTED]> writes: >> >>> create a hash that maps your keys to themselves, then use the values of >>> that hash as your keys. >> The "atom" function you describe already exists under the name "i

Re: the annoying, verbose self

2007-11-25 Thread samwyse
On Nov 24, 1:10 pm, "Patrick Mullen" <[EMAIL PROTECTED]> wrote: > If there were a "using" or if the with statement would handle > something like this, I wouldn't use it. "s." is only 2 characters. I > saw chained dots mentioned. Chained dots are 2 characters. Why are > we still discussing this?

Re: the annoying, verbose self

2007-11-25 Thread MonkeeSage
I like the explicit "self", personally. It helps distinguish class methods from functions. When I see a "self" I think "A-ha, a class method". Of course, I could tell that from just the indentation and following that back to the class declaration, but as a quick reference I find it helpful. Besides

Re: the annoying, verbose self

2007-11-25 Thread Colin J. Williams
Kay Schluehr wrote: > Colin J. Williams schrieb: >> Kay Schluehr wrote: >>> On Nov 22, 8:43 pm, Bruno Desthuilliers >>> <[EMAIL PROTECTED]> wrote: Colin J. Williams a écrit : > [EMAIL PROTECTED] wrote: >> Alexy: >>> Sometimes I >>> avoid OO just not to deal with

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread MonkeeSage
On Nov 24, 6:42 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > This has nothing, absolutely NOTHING, to do with memoization. Memoization > trades off memory for time, allowing slow functions to return results > faster at the cost of using more memory. The OP wants to save memo

Re: How to display unicode with the CGI module?

2007-11-25 Thread paul
Marc 'BlackJack' Rintsch schrieb: > On Sat, 24 Nov 2007 15:58:56 -0800, coldpizza wrote: > >> The problem I am having is that I get an error while trying to display >> Unicode UTF-8 characters via a Python CGI script. >> >> The error goes like this: "UnicodeEncodeError: 'ascii' codec can't >> enco

Re: the annoying, verbose self

2007-11-25 Thread Colin J. Williams
Steven D'Aprano wrote: > On Fri, 23 Nov 2007 23:38:24 +, BJörn Lindqvist > wrote: > >> I like that a lot. This saves 12 characters for the original example and >> removes the need to wrap it. >> >> 7return math.sqrt(.x * .x + .y * .y + .z * .z) >> >> +1 Readability counts, even on

Re: Recursive loading trouble for immutables

2007-11-25 Thread Mel
rekkufa wrote: > I am currently building a system for serializing python objects > to a readable file-format, as well as creating python objects by > parsing the same format. It is more or less complete except for > a single issue I just cannot figure out by myself: How to load > data that spec

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread MonkeeSage
I use the following for a progam I wrote using sqlite, to ensure maximum compatibility (since the API is the same, importing them both as 'sqlite' should be fine): try: from sqlite3 import dbapi2 as sqlite # python 2.5 except: try: from pysqlite2 import dbapi2 as sqlite except: print

Re: Trouble getting loop to break

2007-11-25 Thread Fredrik Johansson
On Nov 25, 2007 9:00 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > Fredrik, > > I'm afraid I'm just too dumb to see how to use your first suggestion > of cached_factorials. Where do I put it and def()? Could you show me, > even on-line, what to do? > You (

Re: Trouble getting loop to break

2007-11-25 Thread John Machin
On Nov 25, 7:00 pm, Dick Moores <[EMAIL PROTECTED]> wrote: > At 01:32 PM 11/20/2007, Fredrik Johansson wrote: > > > > > > > > >On Nov 20, 2007 10:00 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > > > And also with the amazing Chudnovsky algorithm for pi. See > > >

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread Steven D'Aprano
On Sun, 25 Nov 2007 10:39:38 +0100, Peter Otten wrote: > So if you are going to submit Sam's function make sure to bundle it with > this little demo... Well Peter, I was going to reply with a comment about not changing the problem domain (tuples of ints to trigrams from a text file for natural

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread Licheng Fang
On Nov 25, 5:59 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 24 Nov 2007 03:44:59 -0800, Licheng Fang wrote: > > On Nov 24, 7:05 pm, Bjoern Schliessmann > [EMAIL PROTECTED]> wrote: > >> Licheng Fang wrote: > >> > I find myself frequently in need of classes like this

Re: import pysqlite2 or import sqlite3?

2007-11-25 Thread Hertha Steck
Mike MacDonald wrote: > On Nov 21, 3:02 pm, Hertha Steck <[EMAIL PROTECTED]> wrote: >> Hello, >> >> I'm using Python 2.5.1, Pysqlite 2.3.5 and SQLite 3.4.1 on Gentoo Linux. >> I've always imported pysqlite using >> >> from pysqlite2 import dbapi2 >> >> and that works. If I try >> ... >> > Suppose

Re: How can I create customized classes that have similar properties as 'str'?

2007-11-25 Thread Peter Otten
Steven D'Aprano wrote: > store = {} > def atom(str): >> global store >> if str not in store: >> store[str] = str >> return store[str] > > Oh lordy, that's really made my day! That's the funniest piece of code > I've seen for a long time! Worthy of being submit

Re: Trouble getting loop to break

2007-11-25 Thread Dick Moores
At 01:32 PM 11/20/2007, Fredrik Johansson wrote: >On Nov 20, 2007 10:00 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > > And also with the amazing Chudnovsky algorithm for pi. See > > > >Nice! I'd like to suggest two improvements for speed. > >First, the Chudnov