Re: call by reference howto????

2008-02-27 Thread castironpi
On Feb 27, 10:38 pm, Dan Bishop <[EMAIL PROTECTED]> wrote: > What exactly are you wanting to do? I'm having a hard time considering your question in the general case. I'm thinking of too many cases, the details of which are relevant to the answer, to even subdivide them. My specialty is specific

Re: How about adding rational fraction to Python?

2008-02-27 Thread Marc 'BlackJack' Rintsch
On Wed, 27 Feb 2008 19:00:19 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> Okay, that's just insane, making distinctions between literals and >> variables like that. >> >> 1 + 1.0 # okay > > => Yes > >> x = 1 >> x + 1.0 # is this okay or not? who knows? > > => Ye

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 10:46 pm, [EMAIL PROTECTED] wrote: > On Feb 27, 10:41 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > > On Feb 27, 11:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > > >             yield map(len, (''.join(s)).split('|')) > > > That line should have been just: > > >             yi

Re: XML expat error

2008-02-27 Thread Marc 'BlackJack' Rintsch
On Wed, 27 Feb 2008 14:02:25 -0800, dirkheld wrote: > Something strange here. The xml file causing the problem has only 361 > lines. Isn't there a way to catch this error, ignore it and continu > with the rest of the other files? Yes of course: handle the exception instead of letting it propagate

Re: Pythons & Ladders

2008-02-27 Thread Marc 'BlackJack' Rintsch
On Wed, 27 Feb 2008 19:18:27 -0800, Jeff Schwab wrote: > Benoit wrote: >> I've been teaching myself the python language over the past few months >> using Mark Lutz' Learning Python, 3ed. Python is also the first >> programming language I've ever taken up. I find the language easy to >> learn and

Re: How about adding rational fraction to Python?

2008-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2008 18:43:24 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> def pmean(data): # Paul Rubin's mean >> """Returns the arithmetic mean of data, unless data is all ints, in >> which case returns the mean rounded to the nearest integer less >> than

Re: Indentation and optional delimiters

2008-02-27 Thread Steven D'Aprano
By the way bearophile... the readability of your posts will increase a LOT if you break it up into paragraphs, rather than use one or two giant run-on paragraphs. My comments follow. On Tue, 26 Feb 2008 15:22:16 -0800, bearophileHUGS wrote: > Steven D'Aprano: >> Usability for beginners is a

download ebooks,softwares,students tutorials here for free!!

2008-02-27 Thread priya4u
download ebooks,softwares,students tutorials here for free!! Download Latest Softwares Ebooks Students tutorials Games Ring tones Wallpapers and Lots of fun everything for FREE only at www.studentshangout.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 10:49 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote the following on 02/27/2008 08:46 PM: > > > Just sort the list in text-ascending order, and it's pretty clear. > > Indeed.  After trying Mark's solution, I saw that it sorted in a very > nice manner. You co

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
[EMAIL PROTECTED] wrote the following on 02/27/2008 08:46 PM: > Just sort the list in text-ascending order, and it's pretty clear. Indeed. After trying Mark's solution, I saw that it sorted in a very nice manner. -- http://mail.python.org/mailman/listinfo/python-list

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 10:41 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Feb 27, 11:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > >             yield map(len, (''.join(s)).split('|')) > > That line should have been just: > >             yield map(len, s.split('|')) > > of course. > > Mark It's e

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Mark Dickinson
On Feb 27, 11:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: >             yield map(len, (''.join(s)).split('|')) That line should have been just: yield map(len, s.split('|')) of course. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Mark Dickinson
Here's a possible solution. I'm sure others will comment on how to fix up its inefficiencies (like the potentially slow string concatenations...). def comb(n, k): if n == k == 0: yield '' else: if n > 0: for x in comb(n-1, k): yield ' ' + x

Re: call by reference howto????

2008-02-27 Thread Dan Bishop
On Feb 27, 6:02 pm, Tamer Higazi <[EMAIL PROTECTED]> wrote: > Hi! > Can somebody of you make me a sample how to define a function based on > "call by reference" ??? > > I am a python newbie and I am not getting smart how to define functions, > that should modify the variable I passed by reference.

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
[EMAIL PROTECTED] wrote the following on 02/27/2008 08:14 PM: > On Feb 27, 10:12 pm, [EMAIL PROTECTED] wrote: >>> For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways. >>> (0,0,4) >>> (0,4,0) >>> (4,0,0) >>> (0,2,2) >>> (2,0,2) >>> (2,2,0) >>> (0,1,3) >>> (0,3,1) >>> (3,0,1) >>> (3,1,0) >>> (1,1,2

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 10:12 pm, [EMAIL PROTECTED] wrote: > On Feb 27, 8:40 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > > > > > > > Hi, > > > I need a generator which produces all ways to place n indistinguishable > > items into k distinguishable boxes. > > > For n=4, k=3, there are (4+3-1)!/(3-1)!/4! =

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 8:40 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > Hi, > > I need a generator which produces all ways to place n indistinguishable > items into k distinguishable boxes. > > For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways. > > (0,0,4) > (0,4,0) > (4,0,0) > > (0,2,2) > (2,0,2) >

Re: call by reference howto????

2008-02-27 Thread 7stud
On Feb 27, 5:02 pm, Tamer Higazi <[EMAIL PROTECTED]> wrote: > Hi! > Can somebody of you make me a sample how to define a function based on > "call by reference" ??? > > I am a python newbie and I am not getting smart how to define functions, > that should modify the variable I passed by reference.

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 9:31 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > Michael Robertson wrote the following on 02/27/2008 06:40 PM: > > > I need a generator which produces all ways to place n indistinguishable > > items into k distinguishable boxes. > > I found: > > http://portal.acm.org/citation.cfm?

Re: Python IRC Zork

2008-02-27 Thread Kris Davidson
I should have said, I'm guessing subprocess is the way to go but I'm probably wrong. On 28/02/2008, Kris Davidson <[EMAIL PROTECTED]> wrote: > Hi, > > If this has been done before in another language could someone please > tell me, if not I was wondering is its possible and what the easier > wa

Python IRC Zork

2008-02-27 Thread Kris Davidson
Hi, If this has been done before in another language could someone please tell me, if not I was wondering is its possible and what the easier way is to create an IRC bot that allows you to play Zork: I was thinking of just creating a simple Python IRC bot or finding an existing one then have it r

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread castironpi
On Feb 27, 9:03 pm, Michael Robertson <[EMAIL PROTECTED]> wrote: > Roy Smith wrote the following on 02/27/2008 06:56 PM: > > > What course is this homework problem for? > > None.  I assume you have an answer to this *trivial* problem... > > It's actually a very general question relating to a very s

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
Michael Robertson wrote the following on 02/27/2008 06:40 PM: > I need a generator which produces all ways to place n indistinguishable > items into k distinguishable boxes. I found: http://portal.acm.org/citation.cfm?doid=363347.363390 Do anyone know if there are better algorithms than this? -

Re: Pythons & Ladders

2008-02-27 Thread Jeff Schwab
Benoit wrote: > I've been teaching myself the python language over the past few months > using Mark Lutz' Learning Python, 3ed. Python is also the first > programming language I've ever taken up. I find the language easy to > learn and rather productive in relation to the introductory course on C

Re: Article of interest: Python pros/cons for the enterprise

2008-02-27 Thread Jeff Schwab
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Carl Banks <[EMAIL PROTECTED]> wrote: >> On Feb 24, 7:03 pm, [EMAIL PROTECTED] (Aahz) wrote: >>> In article <[EMAIL PROTECTED]>, >>> Jeff Schwab <[EMAIL PROTECTED]> wrote: (3) Garbage collection is at least as desirable a language feature as >>

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
Roy Smith wrote the following on 02/27/2008 06:56 PM: > What course is this homework problem for? None. I assume you have an answer to this *trivial* problem... It's actually a very general question relating to a very specific problem I am working on. Normally, I do not reply to such snide re

Re: How about adding rational fraction to Python?

2008-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Okay, that's just insane, making distinctions between literals and > variables like that. > > 1 + 1.0 # okay => Yes > x = 1 > x + 1.0 # is this okay or not? who knows? => Yes, ok > len('s') + 1.0 # forbidden Yes, forbidden. More examples:

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Michael Robertson <[EMAIL PROTECTED]> wrote: > Hi, > > I need a generator which produces all ways to place n indistinguishable > items into k distinguishable boxes. > > For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways. > > (0,0,4) > (0,4,0) > (4,0,0) > > (

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
Michael Robertson wrote the following on 02/27/2008 06:40 PM: > Hi, > > I need a generator which produces all ways to place n indistinguishable > items into k distinguishable boxes. > My first thought was to generate all integer partitions of n, and then generate all permutations on k elements

Re: How about adding rational fraction to Python?

2008-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2008 18:08:29 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> When it comes to mixed arithmetic, it's just too darn inconvenient to >> forbid automatic conversions. Otherwise you end up either forbidding >> things like 1 + 1.0 on the basis that it isn't cle

Re: How about adding rational fraction to Python?

2008-02-27 Thread Dan Bishop
On Feb 26, 11:21 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Feb 26, 11:55 pm, Paul Rubin wrote: > > > So use: return sum(number_list) / float(len(number_list)) > > That makes it somewhat more explicit what you want. Otherwise > > But that fails for a list of Dec

Re: How about adding rational fraction to Python?

2008-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > def pmean(data): # Paul Rubin's mean > """Returns the arithmetic mean of data, unless data is all > ints, in which case returns the mean rounded to the nearest > integer less than the arithmetic mean.""" > s = sum(data) > if isins

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Steven D'Aprano
On Thu, 28 Feb 2008 00:03:02 -0200, Gabriel Genellina wrote: > En Wed, 27 Feb 2008 23:18:14 -0200, Steven D'Aprano > <[EMAIL PROTECTED]> escribió: > >> I think there is a good case for % taking an iterator. Here's an >> artificial example: >> >> def spam(): >> while True: yield "spam" >> >> s

Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Michael Robertson
Hi, I need a generator which produces all ways to place n indistinguishable items into k distinguishable boxes. For n=4, k=3, there are (4+3-1)!/(3-1)!/4! = 15 ways. (0,0,4) (0,4,0) (4,0,0) (0,2,2) (2,0,2) (2,2,0) (0,1,3) (0,3,1) (3,0,1) (3,1,0) (1,1,2) (1,2,1) (2,1,1) The generator needs t

Re: How about adding rational fraction to Python?

2008-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2008 17:07:37 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> Oh come on. With a function named "mean" that calculates the sum of a >> list of numbers and then divides by the number of items, what else >> could it be? > > You have a bunch of marbles you wa

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 20:40:04 -0200, Tim Chase <[EMAIL PROTECTED]> escribió: >>> Note that your problem has nothing to do with map itself. >>> String interpolation using % requires either many individual >>> arguments, or a single *tuple* argument. A list is printed >>> as itself. > > Just as an

Re: How about adding rational fraction to Python?

2008-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > When it comes to mixed arithmetic, it's just too darn inconvenient to > forbid automatic conversions. Otherwise you end up either forbidding > things like 1 + 1.0 on the basis that it isn't clear whether the > programmer wants an int result or a floa

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 23:18:14 -0200, Steven D'Aprano <[EMAIL PROTECTED]> escribió: > I think there is a good case for % taking an iterator. Here's an > artificial example: > > def spam(): > while True: yield "spam" > > spam = spam() > > "%s eggs tomato and %s" % spam > "%s %s bacon tomato %s

Re: How about adding rational fraction to Python?

2008-02-27 Thread Steven D'Aprano
On Tue, 26 Feb 2008 21:41:16 -0800, Paul Rubin wrote: > Mark Dickinson <[EMAIL PROTECTED]> writes: >> > So use:  return sum(number_list) / float(len(number_list)) That makes >> > it somewhat more explicit what you want.  Otherwise >> >> But that fails for a list of Decimals... > > Again, that de

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > map() isn't deprecated, not even for Python 3 where it remains a built- > in. However it will return an iterator instead of a list, making it > (presumably) a more convenient way to spell itertools.imap(). That's the first I heard of that change. I g

Re: call by reference howto????

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 22:02:19 -0200, Tamer Higazi <[EMAIL PROTECTED]> escribió: > Can somebody of you make me a sample how to define a function based on > "call by reference" ??? > > I am a python newbie and I am not getting smart how to define functions, > that should modify the variable I passed

Re: call by reference howto????

2008-02-27 Thread Steven D'Aprano
On Thu, 28 Feb 2008 02:02:19 +0200, Tamer Higazi wrote: > Hi! > Can somebody of you make me a sample how to define a function based on > "call by reference" ??? Python doesn't do call by reference. Nor does it do call by value. Please pay no attention to anyone who says it does. Instead, read t

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Steven D'Aprano
On Wed, 27 Feb 2008 14:41:32 -0600, Tim Chase wrote: >>> Is there an easy way to make string-formatting smart enough to >>> gracefully handle iterators/generators? E.g. >>> >>>transform = lambda s: s.upper() >>>pair = ('hello', 'world') >>>print "%s, %s" % pair # works >>>print "%

Re: __getattribute__ meta class?

2008-02-27 Thread bambam
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Feb 27, 12:44 am, "bambam" <[EMAIL PROTECTED]> wrote: >> In retrospect, the project has three parts: remove >> side effects, push side effects to a common location, modify code so that >> changes only affect areas that

Re: How about adding rational fraction to Python?

2008-02-27 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Oh come on. With a function named "mean" that calculates the sum of a > list of numbers and then divides by the number of items, what else could > it be? You have a bunch of marbles you want to put into bins. The division tells you how many marbles

Re: Any experience with Python on a PDA ?

2008-02-27 Thread Heikki Toivonen
Martin Blume wrote: > - Mio A701 > (Windows Mobile) > > Experience is very good (with the exception of Tkinter > not running on the Zaurus), scripts can be moved to and > from PC and PDA and run unchanged (except for speed and > screen size issues). Hmm, my experience running Python 2.5 on Ci

Re: How about adding rational fraction to Python?

2008-02-27 Thread Steven D'Aprano
On Tue, 26 Feb 2008 20:55:14 -0800, Paul Rubin wrote: > Mark Dickinson <[EMAIL PROTECTED]> writes: >> def mean(number_list): >> return sum(number_list)/len(number_list) >> >> If you pass a list of floats, complex numbers, Fractions, or Decimal >> instances to mean() then it'll work just fine.

Re: Print to end of line in a terminal

2008-02-27 Thread John J. Lee
ndlarsen <[EMAIL PROTECTED]> writes: > Hey. > > This might seem as a arbitrary question to some. Anyway, I'm wondering > how I go about printing text to the end of a line in a > terminal/console. I've been googling it for a few days without any > success. Any suggestions will be greatly appreciate

call by reference howto????

2008-02-27 Thread Tamer Higazi
Hi! Can somebody of you make me a sample how to define a function based on "call by reference" ??? I am a python newbie and I am not getting smart how to define functions, that should modify the variable I passed by reference. thanks in advance Tamer -- http://mail.python.org/mailman/listinfo

Re: along the lines, hash and obj. id.

2008-02-27 Thread castironpi
On Feb 27, 4:16 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 26 Feb 2008 05:58:52 -0200, <[EMAIL PROTECTED]> escribió: > > > It works to keep a reference to the object, then access the member > > again. If your only reference to the object is the member itself, > > obj.a= {} breaks

Re: Pythons & Ladders

2008-02-27 Thread Benoit
On Feb 27, 5:24 pm, Benoit <[EMAIL PROTECTED]> wrote: > I've been teaching myself the python language over the past few months > using Mark Lutz' Learning Python, 3ed. Python is also the first > programming language I've ever taken up. I find the language easy to > learn and rather productive in

Pythons & Ladders

2008-02-27 Thread Benoit
I've been teaching myself the python language over the past few months using Mark Lutz' Learning Python, 3ed. Python is also the first programming language I've ever taken up. I find the language easy to learn and rather productive in relation to the introductory course on C ++ I'd begun in Janua

Snackages [Re: is there enough information?]

2008-02-27 Thread Micah Cowan
Gabriel Genellina wrote: >> Speak not of Wendy's -- they moved into town in my college days... >> The "hot and juicy" was commonly taken to mean: patty dipped in pan >> drippings, then nuked in microwave... And any CompSci person could >> figure out that the "256 different ways" meant one had a

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread D'Arcy J.M. Cain
On Wed, 27 Feb 2008 13:06:27 -0800 (PST) Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Feb 27, 5:25 pm, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > > Isn't map() deprecated?  The above can be done with; > I don't think that map() is deprecated. In python 3.0 it is still > present, only it

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Tim Chase
>> Note that your problem has nothing to do with map itself. >> String interpolation using % requires either many individual >> arguments, or a single *tuple* argument. A list is printed >> as itself. Just as an exercise to understand this better, I've been trying to figure out what allows for th

Re: Print to end of line in a terminal

2008-02-27 Thread Bjoern Schliessmann
ndlarsen wrote: > This might seem as a arbitrary question to some. Anyway, I'm > wondering how I go about printing text to the end of a line in a > terminal/console. I've been googling it for a few days without any > success. Any suggestions will be greatly appreciated. Well, just print ${COLUMNS

Re: along the lines, hash and obj. id.

2008-02-27 Thread Gabriel Genellina
En Tue, 26 Feb 2008 05:58:52 -0200, <[EMAIL PROTECTED]> escribió: > It works to keep a reference to the object, then access the member > again. If your only reference to the object is the member itself, > obj.a= {} breaks d, but obj.a.clear() keeps it alive. > > In the case of immutables, there i

Re: Instance of inherited nested class in outer class not allowed?

2008-02-27 Thread Diez B. Roggisch
mrstephengross schrieb: >> class Foo: >> foo = Foo() >> >> You have to live with that. Just do >> Outer.foo = Outer.Parent() >> after your class-statement to achieve the same result. > > Hmmm. Well, I see why that works. It's too bad, though. If I want to > keep all executed code safely with

Re: Raising exception on STDIN read

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 18:59:59 -0200, Michael Goerz <[EMAIL PROTECTED]> escribi�: >> Try with stdin=open("/dev/full") or stdin=open("/dev/null") > using /dev/null works in my specific case (in my posted minimal example > I still have to press Enter, but in the real program it causes pdflatex > to

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Grant Edwards wrote, on 02/27/2008 04:34 PM: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> >> latexprocess = subprocess.Popen( \ >> 'pdflatex' + " " \ >> + 'test' +

Re: Python's BNF

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 15:23:01 -0200, <[EMAIL PROTECTED]> escribi�: > I spent too long Googling for Python's BNF. Eventually found it at > Python.org, but only by accident. > > There's a link to the program, top-right of page. If anyone wants to > look at this no-longer-quite-newbie's code and give

Re: XML expat error

2008-02-27 Thread dirkheld
On 27 feb, 17:18, "Richard Brodie" <[EMAIL PROTECTED]> wrote: > "dirkheld" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > xml.parsers.expat.ExpatError: not well-formed (invalid token): line > > 554, column 20 > > > I guess that the element I try to read or the XML(which would

Re: Python's BNF

2008-02-27 Thread Ben Finney
[EMAIL PROTECTED] writes: > No, Google, I didn't want the Botswana daily news with its article > on the Botswana National Front and another on a fellow arrested for > having contraband python skins. +1 QOTW -- \ “I thought ’'d begin by reading a poem by Shakespeare, but then | `\

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Ben Finney
"D'Arcy J.M. Cain" <[EMAIL PROTECTED]> writes: > The above can be done with; > > "%s=%s&%s=%s" % tuple([urllib.quote(x) for x in params]) Or, better:: "%s=%s&%s=%s" % tuple(urllib.quote(x) for x in params) passing a generator, instead of a list created from a generator, to the tuple co

Re: Raising exception on STDIN read

2008-02-27 Thread Grant Edwards
On 2008-02-27, Grant Edwards <[EMAIL PROTECTED]> wrote: > ret1 = os.system('latex batchmodeinput %s' % 'label1.tex') At least for tetex under Linux, there's also a command line option to put TeX into batch mode: latex -interaction=batchmode file.tex I don't know if TeX on other platform

Re: Raising exception on STDIN read

2008-02-27 Thread Grant Edwards
On 2008-02-27, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> >> latexprocess = subprocess.Popen( \ >> 'pdflatex' + " " \ >>

Re: Raising exception on STDIN read

2008-02-27 Thread Grant Edwards
On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to raise an exception any time a subprocess tries to read > from STDIN: > > latexprocess = subprocess.Popen( \ > 'pdflatex' + " " \ > + 'test' + " 2>&1", \ > shell=True, \ > cwd=os.g

anydbm safe for simultaneous writes?

2008-02-27 Thread chris
I need simple data persistence for a cgi application that will be used potentially by multiple clients simultaneously. So I need something that can handle locking among writes. Sqlite probably does this, but I am using Python 2.4.4, which does not include sqlite. The dbm-style modules would prob

Re: threading/Queue: join() and task_done() not working? (deadlock)

2008-02-27 Thread 7stud
Gal Aviel wrote: > Hello All, > > I'm seeing strange behavior where one thread waits on a queue using join() and > the later (or so I think, according to order of the printing in STDOUT) > another > thread calls task_done() on the very same queue, What is task_done()? The python docs don't list

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Arnaud Delobelle
On Feb 27, 5:25 pm, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > On Wed, 27 Feb 2008 10:23:49 -0600 > > Tim Chase <[EMAIL PROTECTED]> wrote: > > >    "%s=%s&%s=%s" % map(urllib.quote, params) > > Isn't map() deprecated?  The above can be done with; > >     "%s=%s&%s=%s" % tuple([urllib.quote(x)

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Gabriel Genellina wrote, on 02/27/2008 03:26 PM: > En Wed, 27 Feb 2008 15:06:36 -0200, Ian Clark <[EMAIL PROTECTED]> > escribi�: > >> On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >>> Hi, >>> >>> I would like to raise an exception any time a subprocess tries to read >>> from STDIN: >>>

Re: macro in python

2008-02-27 Thread Terry Reedy
"Guilherme Polo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | 2008/2/27, bharath venkatesh <[EMAIL PROTECTED]>: | > how to create macro in python for set of instruction that is done | > frequently but too less in number to ignore the overhead of function call You can't in

Re: Tkinter: Missing the last piece of the puzzle

2008-02-27 Thread Russell E. Owen
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > Simon Forman wrote: > > yes! check out > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/464635 > > > > HTH, > > ~Simon > > Thanks, Simon. Looks like that will do it. > > Actually, it looks like that will overdo it. I'll be

Re: Article of interest: Python pros/cons for the enterprise

2008-02-27 Thread Aahz
In article <[EMAIL PROTECTED]>, Carl Banks <[EMAIL PROTECTED]> wrote: >On Feb 24, 7:03 pm, [EMAIL PROTECTED] (Aahz) wrote: >> In article <[EMAIL PROTECTED]>, >> Jeff Schwab <[EMAIL PROTECTED]> wrote: >>> >>>(3) Garbage collection is at least as desirable a language feature as >>>deterministic des

RE: first time use of swig, python and c++ .. it's a mess ... please advice

2008-02-27 Thread Bronner, Gregory
The operator= stuff is usually innocuous. The compiler died because it couldn't find 'vector', which is reasonable, since it thought it was compiling a C file. Probably because you swigged the file without the magic "-c++" option -- I'm not sure how distutils passes arguments to swig, but if you

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Tim Chase
>> Is there an easy way to make string-formatting smart enough to >> gracefully handle iterators/generators? E.g. >> >>transform = lambda s: s.upper() >>pair = ('hello', 'world') >>print "%s, %s" % pair # works >>print "%s, %s" % map(transform, pair) # fails >> >> with a """ >> Typ

Re: Backup Script over ssh

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 13:32:07 -0200, Christian Kortenhorst <[EMAIL PROTECTED]> escribi�: > But there is no rsync for windows without using cygwin That's no big deal; rsync doesn't require tons of libraries, just cygpopt-0.dll and cygwin1.dll. See this page: http://www.brentnorris.net/rsyncnt

Re: Raising exception on STDIN read

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 15:06:36 -0200, Ian Clark <[EMAIL PROTECTED]> escribi�: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> >> latexprocess = subprocess.Popen( \ >> 'pdflatex'

Re: Official IRC channel for Python?

2008-02-27 Thread Guilherme Polo
27 Feb 2008 11:34:54 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid>: > "Guilherme Polo" <[EMAIL PROTECTED]> writes: > > > I can join #perl, #php, #ruby, #mysql, #postgres without registration. > > > What advantage does it have? and the advantage really worth? > > > > > The direct benefit i

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 14:23:49 -0200, Tim Chase <[EMAIL PROTECTED]> escribi�: > Is there an easy way to make string-formatting smart enough to > gracefully handle iterators/generators? E.g. > >transform = lambda s: s.upper() >pair = ('hello', 'world') >print "%s, %s" % pair # works >

Re: Raising exception on STDIN read

2008-02-27 Thread Michael Goerz
Ian Clark wrote, on 02/27/2008 12:06 PM: > On 2008-02-27, Michael Goerz <[EMAIL PROTECTED]> wrote: >> I would like to raise an exception any time a subprocess tries to read >> from STDIN: >> latexprocess = subprocess.Popen( \ >> 'pdflatex' + " " \ >> + 'test' + " 2>&1", \ >>

Re: refreshing the cache time of a key

2008-02-27 Thread Sean Chittenden
>is it possible to refresh the cache time of a key with out having > to retrieving the cached data and storing it back in memcache .. for > example if a data is cached for > 1 hour and at the 50th minute from the time this data has been > cached i want to store it in the cache for 1

Re: Fwd: Problem with threads in python????????

2008-02-27 Thread James Matthews
Yes On Wed, Feb 27, 2008 at 3:56 AM, <[EMAIL PROTECTED]> wrote: > On Feb 26, 7:56 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: > > En Tue, 26 Feb 2008 01:46:48 -0200, Manikandan R <[EMAIL PROTECTED]> > > > escribió: > > > > > Hai, > > > > > Is it possible to share a single varia

Re: Instance of inherited nested class in outer class not allowed?

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 16:52:57 -0200, mrstephengross <[EMAIL PROTECTED]> escribi�: >> class Foo: >> foo = Foo() >> >> You have to live with that. Just do >> Outer.foo = Outer.Parent() >> after your class-statement to achieve the same result. > > Hmmm. Well, I see why that works. It's too bad

Re: threading/Queue: join() and task_done() not working? (deadlock)

2008-02-27 Thread Raymond Hettinger
On Feb 27, 11:06 am, Gal Aviel <[EMAIL PROTECTED]> wrote: > Hello All, > > I'm seeing strange behavior where one thread waits on a queue using join() and > the later (or so I think, according to order of the printing in STDOUT) > another > thread calls task_done() on the very same queue, however t

Re: Official IRC channel for Python?

2008-02-27 Thread Paul Rubin
"Guilherme Polo" <[EMAIL PROTECTED]> writes: > > I can join #perl, #php, #ruby, #mysql, #postgres without registration. > > What advantage does it have? and the advantage really worth? > > The direct benefit is a probability of having less spam, and things > like that. I don't remember ever see

Re: Making string-formatting smarter by handling generators?

2008-02-27 Thread Boris Borcic
D'Arcy J.M. Cain wrote: >> I find I hit it mostly with calls to map() where I want to apply >> some transform (as above) to all the items in a list of >> parameters such as >> >>"%s=%s&%s=%s" % map(urllib.quote, params) > > Isn't map() deprecated? The above can be done with; > > "%s=%s

Re: BaseHTTPServer and do_POST method

2008-02-27 Thread Gabriel Genellina
En Wed, 27 Feb 2008 10:33:35 -0200, rocksportrocker <[EMAIL PROTECTED]> escribi�: > Hi, > > I am trying to implement a local server for storing and retrieving > numerical data. > So I use BaseHTTPServer as follows: > > - > from BaseHTTP

threading/Queue: join() and task_done() not working? (deadlock)

2008-02-27 Thread Gal Aviel
Hello All, I'm seeing strange behavior where one thread waits on a queue using join() and the later (or so I think, according to order of the printing in STDOUT) another thread calls task_done() on the very same queue, however the first thread does not wake up, it keeps blocking forever. I'm usin

X Windows Problems in 2.5.2

2008-02-27 Thread SwimmingApe
Hi there, first off I'm running MAC OS X 10.4.11 on a Intel MacBook Pro using Apples X11. For a project I am working on I have to start a separate gui (in this case based on the Fox toolkit) as a thread in python. So I have a swig wrapper around some C++ code which starts the thread, creates the w

Re: Instance of inherited nested class in outer class not allowed?

2008-02-27 Thread mrstephengross
> class Foo: > foo = Foo() > > You have to live with that. Just do > Outer.foo = Outer.Parent() > after your class-statement to achieve the same result. Hmmm. Well, I see why that works. It's too bad, though. If I want to keep all executed code safely within a "if __name__ == '__main__'" blo

Print to end of line in a terminal

2008-02-27 Thread ndlarsen
Hey. This might seem as a arbitrary question to some. Anyway, I'm wondering how I go about printing text to the end of a line in a terminal/console. I've been googling it for a few days without any success. Any suggestions will be greatly appreciated. Regards ndlarsen -- http://mail.python.or

Re: How about adding rational fraction to Python?

2008-02-27 Thread Ross Ridge
Mark Dickinson <[EMAIL PROTECTED]> wrote: >True division and floor division are different operations. It doesn't >seem ridiculous to use different operators for them. I don't have a problem with there being different operators for integer and floating-point division. I have a problem with the b

Re: Instance of inherited nested class in outer class not allowed?

2008-02-27 Thread Diez B. Roggisch
mrstephengross schrieb: > I've got an interesting problem with my class hierarchy. I have an > outer class, in which two nested classes are defined: > > class Outer: > class Parent: > def __init__ (self): > print "parent!" > class Child(Parent): > def __init__ (self): > Out

Re: European python developers

2008-02-27 Thread Martin P. Hellwig
[EMAIL PROTECTED] wrote: > Hi Python Enthusiasts, > > I am hoping one or two members of this list might help me locate in Europe > to begin a small team of developers with a focus on python for the central > part of the server development. > > My personal first choice is Spain only because I lik

Re: time.time() strangeness

2008-02-27 Thread Ross Ridge
Nitro <[EMAIL PROTECTED]> wrote: >They should really make the fpu preserve flag the default. It just causes >very sneaky bugs. They did in Direct3D 10, which doesn't change the flags. It's too late to change the behaviour Direct3D 9 which was created a time where changing FPU precision could h

how to create eigenface image

2008-02-27 Thread harryos
hi all I am new to python and learning PCA method by reading up Turk&Petland papers etc while trying out PCA on a set of greyscale images using python, and numpy I tried to create eigenvectors and facespace. i have facesarray--- an NXP numpy.ndarray that contains data of images N=numof ima

Re: refreshing the cache time of a key

2008-02-27 Thread Dustin Sallings
On Feb 27, 2008, at 4:17, bharath venkatesh wrote: >is it possible to refresh the cache time of a key with out having > to retrieving the cached data and storing it back in memcache .. for > example if a data is cached for > 1 hour and at the 50th minute from the time this data has been

Re: refreshing the cache time of a key

2008-02-27 Thread Sean Chittenden
>is it possible to refresh the cache time of a key with out having > to retrieving the cached data and storing it back in memcache .. for > example if a data is cached for > 1 hour and at the 50th minute from the time this data has been > cached i want to store it in the cache for 1

Re: Python's BNF

2008-02-27 Thread Arnaud Delobelle
On Feb 27, 5:23 pm, [EMAIL PROTECTED] wrote: > I spent too long Googling for Python's BNF. Eventually found it at > Python.org, but only by accident. http://www.google.com/search?q=python+grammar -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >