Re: number generator

2007-03-10 Thread Raymond Hettinger
On Mar 9, 7:32 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, cesco wrote: > > Given two positive integers, N and M with N < M, I have to generate N > > positive integers such that sum(N)=M. No more constraints. > > Break it into subproblems. Generate a random nu

Re: Hamburg Pythoneers Monthly Meeting: Wed, Apr 11

2007-03-10 Thread Daniel Miller
Hello Helge, Which "AOPython" module will be covered during the meeting? Is it this one: http://www.openpolitics.com/pieces/archives/001710.html If that's not the one then you can stop reading now :)... But if that's the one you'll be highlighting then I'd be interested to hear what people thi

Re: Need help with a string plz! (newbie)

2007-03-10 Thread Hendrik van Rooyen
<[EMAIL PROTECTED]> wrote: > Oh, thanks for the advice then. And as for Grant..look forward to > seeing more of your posts. YOW! - some recognition at last! - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: UTF-8 output problems

2007-03-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Michael B. Trausch wrote: > However, when I attempt to redirect the output to a file: > > [EMAIL PROTECTED]:~/tmp$ python test.py >f > Traceback (most recent call last): > File "test.py", line 6, in > print u"This is Unicode code point %d (0x%x): %s" % (x, x, > unic

Re: number generator

2007-03-10 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Raymond Hettinger wrote: > On Mar 9, 7:32 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, cesco wrote: >> > Given two positive integers, N and M with N < M, I have to generate N >> > positive integers such that sum(N)=M. No more constraint

Re: number generator

2007-03-10 Thread greg
Steven D'Aprano wrote: > Last but not least, another possible algorithm is to start with a list of > N numbers, regardless of whether or not they add to M, and then adjust > each one up or down by some amount until they sum to the correct value. Another possibility is to generate a list of N non-

Re: floating point rounding

2007-03-10 Thread greg
John Henry wrote: > Or more precisely: > > round(0.014999,2) No, that *won't* solve the problem. Using a slightly different example, >>> x = 1.5 * 0.1 >>> x 0.15002 >>> round(x, 2) 0.14999 The problem is that floats are stored internally in binary, not de

Re: number generator

2007-03-10 Thread Klaus Alexander Seistrup
Raymond Hettinger wrote: > To make the solutions equi-probable, a simple approach is to > recursively enumerate all possibilities and then choose one > of them with random.choice(). Or create a list using the biased method, then use .shuffle() to return another permutation. Cheers, -- Klaus

Re: number generator

2007-03-10 Thread Dick Moores
At 07:17 AM 3/9/2007, cesco wrote: >On Mar 9, 3:51 pm, Paul Rubin wrote: > > "cesco" <[EMAIL PROTECTED]> writes: > > > I have to generate a list of N random numbers (integer) whose sum is > > > equal to M. If, for example, I have to generate 5 random numbers whose > > > s

Re: SQLite3 trapping OperationalError

2007-03-10 Thread paul
jim-on-linux schrieb: > pyhelp, > > I set up a table in SQLite3. > > While running other modules I want to know if a > table exists. > > SQL has a command "List Tables" but I don't think > SQLlite3 has this command. I think "list tables" is a mysqlism > > I've tried >cursor.execute("se

Re: number generator

2007-03-10 Thread Steven D'Aprano
On Sat, 10 Mar 2007 02:32:21 -0800, Dick Moores wrote: > So why not just repeatedly call a function to generate lists of > length N of random integers within the appropriate range (the closed > interval [1,M-N-1]), and return the first list the sum of which is M? > I don't understand what all t

Re: number generator

2007-03-10 Thread Steven D'Aprano
On Fri, 09 Mar 2007 18:41:39 +, Dennis Lee Bieber wrote: > On 9 Mar 2007 06:44:01 -0800, "cesco" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > >> I have to generate a list of N random numbers (integer) whose sum is >> equal to M. If, for example, I have to generate 5 ra

UTF-8

2007-03-10 Thread Olivier Verdier
First off: i thoroughly enjoy python. I use it for scientific computing with scipy, numpy and matplotlib and it's an amazingly efficient and elegant language. About this mailing list: it is very hard to search. I can't find any search field on the page: http://mail.python.org/mailman/listinf

Re: pylint: don't warn about tabs

2007-03-10 Thread Bjoern Schliessmann
Alan Isaac wrote: > What ambiguity? > Tabs are *less* ambiguous. > One tab character is one level of indentation. > > I have never seen this violated. Not quite a proof ... > Users of spaces cannot even count > on shared code being 4 rather than 8 spaces. You also can't count on proper TAB cod

Database module & multithreading

2007-03-10 Thread jupiter
Hi guys!!! Just one quick question... Which database module should I use when I want to use multi threading as my application requires lots of data from internet I also want this database module to be fast, simple n efficient, in any case multi threading capabilities are # 1 requirement. T

Re: UTF-8

2007-03-10 Thread Laurent Pointal
Olivier Verdier wrote: > My question is the following: how to set a default encoding in > python? I read an old thread about that and it didn't seem possible > by then. You *can* put a sys.setdefaultencoding("utf-8") in your sitecustomize.py (see Python libs/site-packages/). Note that this functi

Re: Database module & multithreading

2007-03-10 Thread Laurent Pointal
jupiter wrote: > Hi guys!!! > > > Just one quick question... Which database module should I use when I > want to use multi threading as my application requires lots of data > from internet I also want this database module to be fast, simple > n efficient, in any case multi threading capabil

Re: UTF-8 output problems

2007-03-10 Thread Laurent Pointal
Michael B. Trausch wrote: > I am having a slight problem with UTF-8 output with Python. I have the > following program: > > x = 0 > > while x < 0x4000: > print u"This is Unicode code point %d (0x%x): %s" % (x, x, > unichr(x)) > x += 1 > > This program works perfectly when run directly:

Re: UTF-8

2007-03-10 Thread Leif K-Brooks
Laurent Pointal wrote: > You should prefer to put > # -*- coding: utf-8 -*- > at the begining of your sources files. With that you are ok with all Python > installations, whatever be the defautl encoding. > Hope this will become mandatory in a future Python version. The default encoding

Re: Database module & multithreading

2007-03-10 Thread jupiter
On Mar 10, 7:29 pm, Laurent Pointal <[EMAIL PROTECTED]> wrote: > jupiter wrote: > > Hi guys!!! > > > Just one quick question... Which database module should I use when I > > want to use multi threading as my application requires lots of data > > from internet I also want this database module t

Re: Database module & multithreading

2007-03-10 Thread Jorge Godoy
"jupiter" <[EMAIL PROTECTED]> writes: > Hi guys!!! > > > Just one quick question... Which database module should I use when I > want to use multi threading as my application requires lots of data > from internet I also want this database module to be fast, simple > n efficient, in any case mu

Searching comp.lang.python/python-list@python.org (was: UTF-8)

2007-03-10 Thread skip
Olivier> About this mailing list: it is very hard to search. I can't Olivier> find any search field on the page: Olivier> http://mail.python.org/mailman/listinfo/ python-list. I would Olivier> greatly appreciate if you moved that list over to google, for Olivier> instance, so t

Re: pylint: don't warn about tabs

2007-03-10 Thread skip
>> Finally, note this from PEP 666: Alan> I really think you should reread the PEP, which is making Alan> the opposite of your point. Quite the opposite, in fact. Laura Creighton wrote that PEP precisely with the expectation (and hope) that Guido would reject it, which he did: P

Help controlling CDROM from python

2007-03-10 Thread Ognjen Bezanov
Hello, I am trying to control a CD-ROM drive using python. The code I use is shown below. > import CDROM > from fcntl import ioctl > import os > > > class Device: > > CDdevice="" > CDfd = None > > def __init__(self,name): > self.CDdevice = name#we get

making an "executable" for a python code (newbie)

2007-03-10 Thread Pradnyesh Sawant
hello, i have some python scripts (especially, PyQt4 scripts) that i want to deploy on both linux and windows m/c's. different packaging tools that i checked (cx_freeze, distutils, pyinstaller) allow me to create "installers". however, i'm interested in creating "executables" that allow the code to

Re: Database module & multithreading

2007-03-10 Thread Michael Bentley
> > Thanx for this pointer buddy! I have done my homework. Some Database > modules are not actively maintained some modules does not work with > Python 2.5. At this moment I am using Sqlite3 which is pretty fast but > it dosent allow me to use multi threading so which database module is > better i

minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread Brian Blais
Hello, I was wondering what the approximate minimum age to learn python is. Has anyone had experience teaching middle school students, or elementary school students Python? What brought this up for me is thinking about starting a Lego robots group in a local middle school. I only teach col

Re: Database module & multithreading

2007-03-10 Thread jupiter
On Mar 10, 8:16 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > > Thanx for this pointer buddy! I have done my homework. Some Database > > modules are not actively maintained some modules does not work with > > Python 2.5. At this moment I am using Sqlite3 which is pretty fast but > > it dosent a

Re: Database module & multithreading

2007-03-10 Thread jupiter
On Mar 10, 8:16 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > > Thanx for this pointer buddy! I have done my homework. Some Database > > modules are not actively maintained some modules does not work with > > Python 2.5. At this moment I am using Sqlite3 which is pretty fast but > > it dosent a

Re: Database module & multithreading

2007-03-10 Thread Alex Martelli
jupiter <[EMAIL PROTECTED]> wrote: ... > Python 2.5. At this moment I am using Sqlite3 which is pretty fast but > it dosent allow me to use multi threading so which database module is > better in terms of multithreading Perhaps psycopg2 (with PostgreSQL as the engine), according to

Re: UTF-8

2007-03-10 Thread John Machin
On Mar 11, 1:00 am, Olivier Verdier <[EMAIL PROTECTED]> wrote: > First off: i thoroughly enjoy python. I use it for scientific > computing with scipy, numpy and matplotlib and it's an amazingly > efficient and elegant language. > > About this mailing list: it is very hard to search. I can't find an

Re: C++ and Python

2007-03-10 Thread Alex Martelli
hg <[EMAIL PROTECTED]> wrote: ... > target but rather C: I need to integrate a printer driver and and would > like if possible to avoid all of the .h stuff involved with SWIG (I am not > being sarcastic): if I can setup my prototypes directly in python, why go > through an extra layer ? > > Are

Re: Database module & multithreading

2007-03-10 Thread jupiter
On Mar 10, 8:42 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > jupiter <[EMAIL PROTECTED]> wrote: > >... > > > Python 2.5. At this moment I am using Sqlite3 which is pretty fast but > > it dosent allow me to use multi threading so which database module is > > better in terms of multithreading >

Re: Database module & multithreading

2007-03-10 Thread Jean-Paul Calderone
On 10 Mar 2007 07:40:23 -0800, jupiter <[EMAIL PROTECTED]> wrote: >On Mar 10, 8:16 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: >> > Thanx for this pointer buddy! I have done my homework. Some Database >> > modules are not actively maintained some modules does not work with >> > Python 2.5. At t

Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread Brad Allen
At 6:05 AM -0600 3/9/07, Jeff Rush wrote: >Prior to PyCon I'd been thinking about some kind of campaign, service or >documents, that I call "So you think you know Python...". My initial idea was >for use by Python programmers, who are honest with themselves, to have a way >to measure their knowled

Re: number generator

2007-03-10 Thread Anton Vredegoor
Raymond Hettinger wrote: > To make the solutions equi-probable, a simple approach is to > recursively enumerate all possibilities and then choose one of them > with random.choice(). Maybe it is possible to generate the possibilities by an indexing function and then use randint to pick one of the

Announcing BBCode parsing module

2007-03-10 Thread Will McGugan
Hi, I have written a BBCode parsing module that may be of use to some people. It turns BBCode in to XHTML snippets. See the following page if you are interested... http://www.willmcgugan.com/2007/03/10/bbcode-python-module/ Will McGugan -- blog: http://www.willmcgugan.com -- http://mail.pyt

Re: number generator

2007-03-10 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > Doesn't mean that it isn't random. After all, the first four numbers are > random, therefore their sum is random. 50 - (something random) is also > random. What does it mean for the first 4 numbers to be random? For example, is 27 random? By your met

Re: Database module & multithreading

2007-03-10 Thread Jorge Godoy
"jupiter" <[EMAIL PROTECTED]> writes: > conn = psycopg2.connect("dbname=test user=test") > > Traceback (most recent call last): > File "", line 1, in > conn = psycopg2.connect("dbname=test user=test") > OperationalError: could not connect to server: Connection refused > (0x274D/10061) >

Re: [Edu-sig] minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread kirby urner
<< questions about others' experience >> > Is it no big deal either way? > > >thanks, > >Brian Blais Hi Brian -- Lego Mindstorms is popular in my neck of the woods (Silicon Forest -- Oregon), starting in middle school. I helped coach a team a few years ago

Re: C++ and Python

2007-03-10 Thread Thomas Heller
Alex Martelli schrieb: > hg <[EMAIL PROTECTED]> wrote: >... >> target but rather C: I need to integrate a printer driver and and would >> like if possible to avoid all of the .h stuff involved with SWIG (I am not >> being sarcastic): if I can setup my prototypes directly in python, why go >> th

Re: number generator

2007-03-10 Thread Mel Wilson
Gerard Flanagan wrote: > On Mar 9, 4:17 pm, "cesco" <[EMAIL PROTECTED]> wrote: >> On Mar 9, 3:51 pm, Paul Rubin wrote: >> >>> "cesco" <[EMAIL PROTECTED]> writes: I have to generate a list of N random numbers (integer) whose sum is equal to M. If, for example, I

Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread Michael Bernstein
On Sat, 2007-03-10 at 10:01 -0600, Brad Allen wrote: > When I discussed this problem with Michael Bernstein at PyCon he suggested > the idea of creating a "chroot jail" for each web session which could run > the Python interpreter in a secure sandbox. That might be easier than giving > each sessio

Re: making an "executable" for a python code (newbie)

2007-03-10 Thread John Machin
On Mar 11, 1:54 am, "Pradnyesh Sawant" <[EMAIL PROTECTED]> wrote: > hello, > i have some python scripts (especially, PyQt4 scripts) that i want to > deploy on both linux and windows m/c's. different packaging tools that > i checked (cx_freeze, distutils, pyinstaller) allow me to create > "installer

Logfile for my App not "rewriting"

2007-03-10 Thread Adam
Hello, I have a small app I am creating to crawl a directory and check that if it is moved to another a location it's path will not break a character limit. Usually the Windows path limit. Now the script is working but every time I want to scan again I have to restart for the log files to be writ

Re: Is this right? Multiple imports of same module.

2007-03-10 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > Expected behavior if you 1) understand how Python variable binding > works, and 2) that "from <> import *" is equivalent to > > import <> > name1 = <>.name1 > name2 = <>.name2 > > IOWs, one is creating

Re: Is this right? Multiple imports of same module.

2007-03-10 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > On 3/9/07, Lou Pecora <[EMAIL PROTECTED]> wrote: > > I have noticed that using from xxx import * can lead to problems when > > trying to access variables in the xxx module. > > Don't do it, then. ;-) I don't anymore.

Re: Is this right? Multiple imports of same module.

2007-03-10 Thread Lou Pecora
In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote: > Lou Pecora <[EMAIL PROTECTED]> writes: > > > ['import mymodule' in three separate modules] > > > > Then mymodule is imported only once, but each module has access to > > it through the module name (mod1 and mod2) and the ali

Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread John Nagle
Michael Bernstein wrote: > On Sat, 2007-03-10 at 10:01 -0600, Brad Allen wrote: > > >>When I discussed this problem with Michael Bernstein at PyCon he suggested >>the idea of creating a "chroot jail" for each web session which could run >>the Python interpreter in a secure sandbox. That might be

unsigned integer?

2007-03-10 Thread Jack
This is a naive question: "%u" % -3 I expect it to print 3. But it still print -3. Also, if I have an int, I can convert it to unsigned int in C: int i = -3; int ui = (unsigned int)i; Is there a way to do this in Python? -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-10 Thread Paulo da Silva
cesco escreveu: > I have to generate a list of N random numbers (integer) whose sum is > equal to M. If, for example, I have to generate 5 random numbers whose > sum is 50 a possible solution could be [3, 11, 7, 22, 7]. Is there a > simple pattern or function in Python to accomplish that? > > Than

Re: Database module & multithreading

2007-03-10 Thread John Nagle
Michael Bentley wrote: >> >> Thanx for this pointer buddy! I have done my homework. Some Database >> modules are not actively maintained some modules does not work with >> Python 2.5. At this moment I am using Sqlite3 which is pretty fast but >> it dosent allow me to use multi threading so which d

Re: unsigned integer?

2007-03-10 Thread Dan Bishop
On Mar 10, 11:32 am, "Jack" <[EMAIL PROTECTED]> wrote: > This is a naive question: > > "%u" % -3 > > I expect it to print 3. But it still print -3. > > Also, if I have an int, I can convert it to unsigned int in C: >int i = -3; >int ui = (unsigned int)i; > > Is there a way to do this in Pyt

Re: pylint: don't warn about tabs

2007-03-10 Thread John Nagle
Gabriel Genellina wrote: > En Thu, 08 Mar 2007 14:33:38 -0300, Bjoern Schliessmann > <[EMAIL PROTECTED]> escribió: > >> Alan Isaac wrote: >> >>> As a tab user, I want the tabs warning turned off. >> >> >> Advice: Don't. IIRC it's planned in future Python versions that TABs >> aren't supported fo

Re: [python-advocacy] A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread Brad Allen
At 9:10 AM -0800 3/10/07, Michael Bernstein wrote: >On Sat, 2007-03-10 at 10:01 -0600, Brad Allen wrote: > >> When I discussed this problem with Michael Bernstein at PyCon he suggested >> the idea of creating a "chroot jail" for each web session which could run >> the Python interpreter in a sec

Re: unsigned integer?

2007-03-10 Thread Duncan Booth
"Jack" <[EMAIL PROTECTED]> wrote: > This is a naive question: > > "%u" % -3 > > I expect it to print 3. But it still print -3. Internally it uses the C runtime to format the number, but if the number you ask it to print unsigned is negative it uses %d instead of %u. I have no idea if it is ac

Re: Database module & multithreading

2007-03-10 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, John Nagle wrote: > As for "some modules not being maintained", it really is sad > that MySQLdb is kind of behind. If you're running Windows and need > MySQL, you're either stuck with Python 2.4 Looks like that's changed: http://sourceforge.net/project/showfi

Re: unsigned integer?

2007-03-10 Thread hg
Dan Bishop wrote: > On Mar 10, 11:32 am, "Jack" <[EMAIL PROTECTED]> wrote: >> This is a naive question: >> >> "%u" % -3 >> >> I expect it to print 3. But it still print -3. >> >> Also, if I have an int, I can convert it to unsigned int in C: >>int i = -3; >>int ui = (unsigned int)i; >> >>

Re: pylint: don't warn about tabs

2007-03-10 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > http://www.python.org/dev/peps/pep-0666/ In pep-0666, Laura Creighton wrote: >People who mix tabs and spaces, naturally, will find that their >programs do not run. Alas, we haven't found a way to give them an >electric shock as from a cattle prod remote

OLPC vs. mobile phones (was Re: merits of Lisp vs Python)

2007-03-10 Thread Paul Boddie
Gabriel Genellina wrote: > En Fri, 09 Mar 2007 16:10:51 -0300, Tim Bradshaw <[EMAIL PROTECTED]> escribió: > > > The electronic gadget people need in the developing world is a mobile phone > > not a > > computer. > > What for? > That requires a phone company, installed antennas everywhere, and > av

Re: unsigned integer?

2007-03-10 Thread Dan Bishop
On Mar 10, 11:50 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > "Jack" <[EMAIL PROTECTED]> wrote: > > This is a naive question: > > > "%u" % -3 > > > I expect it to print 3. But it still print -3. > > Internally it uses the C runtime to format the number, but if the number > you ask it to print unsi

Re: A Pythonic Way to Measure and Improve Your Programming Skills?

2007-03-10 Thread André
On Mar 10, 1:54 pm, Brad Allen <[EMAIL PROTECTED]> wrote: > At 9:10 AM -0800 3/10/07, Michael Bernstein wrote: > > >On Sat, 2007-03-10 at 10:01 -0600, Brad Allen wrote: > > >> When I discussed this problem with Michael Bernstein at PyCon he suggested > >> the idea of creating a "chroot jail" for

Re: unsigned integer?

2007-03-10 Thread Duncan Booth
"Dan Bishop" <[EMAIL PROTECTED]> wrote: > On Mar 10, 11:50 am, Duncan Booth <[EMAIL PROTECTED]> > wrote: >> "Jack" <[EMAIL PROTECTED]> wrote: >> > This is a naive question: >> >> > "%u" % -3 >> >> > I expect it to print 3. But it still print -3. >> >> Internally it uses the C runtime to format the

CGI handler: Retrieving POST and GET at the same time

2007-03-10 Thread Samuel
Hi, I have the following form: and would like to retrieve both fields, "one" and "two". However, the following does not work: form_data = cgi.FieldStorage() for key in form_data: print key + ":", form_data[key].value It prints out: two: 2 How can I retrieve the GET variables in that co

Re: minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread [EMAIL PROTECTED]
Brian Blais wrote: > Hello, > > I was wondering what the approximate minimum age to learn python is. Has > anyone had > experience teaching middle school students, or elementary school students > Python? > What brought this up for me is thinking about starting a Lego robots group in > a local >

Re: unsigned integer?

2007-03-10 Thread Jack
Thanks for all the replies. Because I want to convert an int, Dan's function actually does it well. "Jack" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This is a naive question: > > "%u" % -3 > > I expect it to print 3. But it still print -3. > > Also, if I have an int, I can con

Re: Phase change material ...

2007-03-10 Thread thermate
On Mar 8, 5:57 pm, "martinl" <[EMAIL PROTECTED]> wrote: > Hi All, > I'm looking for a substance that does a phase change at between 60 and > 100 C. > > I need something with a high heat capacity so that when it cools > through the phase change, it stays at the freezing temperature for as > long as

Re: unsigned integer?

2007-03-10 Thread Paul Rubin
"Jack" <[EMAIL PROTECTED]> writes: > Also, if I have an int, I can convert it to unsigned int in C: >int i = -3; >int ui = (unsigned int)i; I just tried it: main() { int i = -3; unsigned int ui = i; printf("%d\n", ui); } prints -3. What do you want the conversi

Re: minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread Michel Claveau
Hi! Personally, I was yet in the belly of my mom, whom I already thought in Python… -- @-salutations Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Formatted Input

2007-03-10 Thread Deep
Hi all, I am a newbie to python I have an input of form space ie. 4 3 how can i assign this to my variables?? -- http://mail.python.org/mailman/listinfo/python-list

Formatted Input

2007-03-10 Thread Deep
Hi all, I am a newbie to python I have an input of form space ie. 4 3 how can i assign these numbers to my variables?? -- http://mail.python.org/mailman/listinfo/python-list

Re: Formatted Input

2007-03-10 Thread Dan Bishop
On Mar 10, 1:29 pm, "Deep" <[EMAIL PROTECTED]> wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign these numbers to my variables?? n1, n2 = map(int, raw_input().split()) -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-10 Thread Paul Rubin
Paulo da Silva <[EMAIL PROTECTED]> writes: > May be this is what you want ... > I didn't test it enough ... but seems fine. That's way too complicated. Think about Gerald Flanagan's description of the telegraph poles, and how to implement simply. It is a two liner. -- http://mail.python.org/mai

Re: CGI handler: Retrieving POST and GET at the same time

2007-03-10 Thread Pierre Quentel
On 10 mar, 19:52, "Samuel" <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following form: > > > > > > and would like to retrieve both fields, "one" and "two". However, the > following does not work: > > form_data = cgi.FieldStorage() > for key in form_data: > print key + ":", form_data[key]

Re: Help on Dict

2007-03-10 Thread Clement
On Feb 26, 11:58 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 26 Feb 2007 07:15:43 +0200, Hendrik van Rooyen wrote: > > "James Stroud" <[EMAIL PROTECTED]> wrote: > > >> Clement wrote: > >> > Can any body tell how Dict is implemented in python... plz tell what > >> > datastructure that

Re: Phase change material ...

2007-03-10 Thread Dan Bloomquist
[EMAIL PROTECTED] wrote: > On Mar 8, 5:57 pm, "martinl" <[EMAIL PROTECTED]> wrote: > >>Hi All, >>I'm looking for a substance that does a phase change at between 60 and >>100 C. >> >>I need something with a high heat capacity so that when it cools >>through the phase change, it stays at the freezi

Re: Database module & multithreading

2007-03-10 Thread John Nagle
Jon Ribbens wrote: > In article <[EMAIL PROTECTED]>, John Nagle wrote: > >> As for "some modules not being maintained", it really is sad >>that MySQLdb is kind of behind. If you're running Windows and need >>MySQL, you're either stuck with Python 2.4 > > > Looks like that's changed: > > ht

Re: CGI handler: Retrieving POST and GET at the same time

2007-03-10 Thread Samuel
On Mar 10, 8:45 pm, "Pierre Quentel" <[EMAIL PROTECTED]> wrote: > To get the key-value dictionary : > > cgi.parse_qs(os.environ["QUERY_STRING"]) Thanks a lot, it works! -Samuel -- http://mail.python.org/mailman/listinfo/python-list

Re: making an "executable" for a python code (newbie)

2007-03-10 Thread Sick Monkey
You will probably want to read this documentation: http://pyinstaller.hpcf.upr.edu/docs/Manual_v1.1.html Look carefully at the following sections on the documentation: "Building the runtime environment" and "Spec File" and "Spec File -> EXE"

Re: Database module & multithreading

2007-03-10 Thread fumanchu
On Mar 10, 6:14 am, "jupiter" <[EMAIL PROTECTED]> wrote: > Just one quick question... Which database module > should I use when I want to use multi threading > as my application requires lots of data from > internet I also want this database module > to be fast, simple n efficient, in any case

Re: number generator

2007-03-10 Thread Terry Reedy
"Anton Vredegoor" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Raymond Hettinger wrote: | | > To make the solutions equi-probable, a simple approach is to | > recursively enumerate all possibilities and then choose one of them | > with random.choice(). | | Maybe it is possible to

Re: pylint: don't warn about tabs

2007-03-10 Thread Alan Isaac
> Alan: >> I really think you should reread the PEP, which is making >> the opposite of your point. Skip: > Quite the opposite, in fact. Laura Creighton wrote that > PEP precisely with the expectation (and hope) that Guido > would reject it, which he did: Note the title and status. Sorry Skip,

Need help in using mod_python

2007-03-10 Thread [EMAIL PROTECTED]
Hi, I am trying to setup Apache with Trac which uses mod_python. I get the following error: assert have_pysqlite > 0 And I have verify this via command line as well, that seem no problem. # python Python 2.3.4 (#1, Feb 2 2005, 11:44:49) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2 T

How to test if a key in a dictionary exists?

2007-03-10 Thread Frank
Hi, does anyone know how one can test if, e.g., a dictionary 'name' has a key called 'name_key'? This would be possible: keys_of_names = names.keys() L = len(keys_of_names) for i in range(L): if keys_of_names[i] == name_key: print 'found' But certainly not efficient. I would expect there is s

Re: IronPython with Apache

2007-03-10 Thread John J. Lee
"edfialk" <[EMAIL PROTECTED]> writes: [...] > So, I'm told I need IronPython, which I get, and I replace the #!c: > \Python25\python.exe with the IronPython executable (#!c: > \IronPython-1.0.1\ipy.exe), but I get a 500 Internal Server error and: > > "[Wed Mar 07 17:02:21 2007] [error] [client 127

Re: Formatted Input

2007-03-10 Thread Frank
On Mar 10, 11:28 am, "Deep" <[EMAIL PROTECTED]> wrote: > Hi all, > I am a newbie to python > I have an input of form > space > ie. > 4 3 > how can i assign this to my variables?? Hi, you could use: aux = f.readline() # read a line from your input file new_aux = string.split(aux, ' ') # you ca

Re: How to test if a key in a dictionary exists?

2007-03-10 Thread Irmen de Jong
Frank wrote: > Hi, > > does anyone know how one can test if, e.g., a dictionary 'name' has a > key called 'name_key'? name_key in name e.g. >>> name={"john": 42} >>> "john" in name True >>> "julie" in name False --Irmen -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if a key in a dictionary exists?

2007-03-10 Thread Rune Strand
Yes, you have name.has_key(name_key) and perhaps better, the in operator: if name_key in name: do something -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if a key in a dictionary exists?

2007-03-10 Thread Jeff McNeil
Sure, you can use "if key in dict" to test for membership: Python 2.3.5 (#1, Jan 13 2006, 20:13:11) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> exampledict = {"a" : 1, "b" : 2} >>> "a" in exampledict True >>> "

Curious behaviour of Tkinter object

2007-03-10 Thread zefciu
I am writing a program with python and Tkinter. I have encountered a mysterious problem with the whole application hanging itself (cannot be stopped with ctrl-c, must be killed from another console). I have done several tests with interactive mode, and here what I noticed: - the problem is with a

Re: pylint: don't warn about tabs

2007-03-10 Thread Alan Isaac
> Alan: >> my actual question remains unanswered... Bjoern: > --indent-string or changing a config file doesn't work for you? Works great. (I read Robert's message subsequent to that complaint.) And pylint is wonderful. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__ in subclass of tuple

2007-03-10 Thread Alan Isaac
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > The signature is like you said, but it's not a tuple method, it's an > object method instead: > py> tuple.__init__ > > The only important thing is that it says: of 'object' objects, not: of > 'tuple' objects. Compare with: > py> tuple.__len__ >

Re: Help controlling CDROM from python

2007-03-10 Thread MonkeeSage
On Mar 10, 8:27 am, Ognjen Bezanov <[EMAIL PROTECTED]> wrote: > My issue is that I need to be able to eject the CDROM tray even if there > is no disk inside. Here's a Q&D version (haven't tested the windows part, it's from an old mailing list post, but it looks correct): import os, sys if 'win'

Re: [Edu-sig] minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread Andreas Raab
kirby urner wrote: > I just talked to the computer teacher yesterday and he > was reporting some rumor that future versions of Alice will > center around the same Sims as in Sims, which my daughter > plays with *a lot* (we also bought Civ City Rome yesterday, > coincidentally, and she built Rome in

Re: [Edu-sig] minimum age to learn python (a.k.a graphical vs text languages)

2007-03-10 Thread kirby urner
On 3/10/07, Andreas Raab <[EMAIL PROTECTED]> wrote: > kirby urner wrote: > > I just talked to the computer teacher yesterday and he > > was reporting some rumor that future versions of Alice will > > center around the same Sims as in Sims, which my daughter > > plays with *a lot* (we also bought Ci

distributed queue?

2007-03-10 Thread Paul Rubin
Does anyone have an implementation of a distributed queue? I.e. I have a long running computation f(x) and I'd like to be able to evaluate it (for different values of x) on a bunch of different computers simultaneously, the usual "worker thread" pattern except distributed across a network. I gues

Re: distributed queue?

2007-03-10 Thread Robert Kern
Paul Rubin wrote: > Does anyone have an implementation of a distributed queue? I.e. I > have a long running computation f(x) and I'd like to be able to > evaluate it (for different values of x) on a bunch of different > computers simultaneously, the usual "worker thread" pattern except > distribut

Re: unsigned integer?

2007-03-10 Thread Gabriel Genellina
En Sat, 10 Mar 2007 16:26:08 -0300, Paul Rubin <"http://phr.cx"@NOSPAM.invalid> escribió: > "Jack" <[EMAIL PROTECTED]> writes: >> Also, if I have an int, I can convert it to unsigned int in C: >>int i = -3; >>int ui = (unsigned int)i; > > I just tried it: > > main() { > int i =

Re: merits of Lisp vs Python

2007-03-10 Thread John J. Lee
"Gabriel Genellina" <[EMAIL PROTECTED]> writes: > En Fri, 09 Mar 2007 16:10:51 -0300, Tim Bradshaw <[EMAIL PROTECTED]> > escribi�: [...] > > ill-conceived idea (not because of Python, note!). The electronic > > gadget people need in the developing world is a mobile phone not a > > computer. >

Re: merits of Lisp vs Python

2007-03-10 Thread John J. Lee
John Nagle <[EMAIL PROTECTED]> writes: [...] > Python, on the other hand, is uphill all the way. Constant trouble > with version issues, especially with C components called from Python. > MySQLdb, M2Crypto, SSL - they all have platform/version > incompatibility problems. I just spent three da

  1   2   >