Re: lock problem

2007-03-16 Thread Ritesh Raj Sarraf
Gabriel Genellina wrote: > En Thu, 15 Mar 2007 18:31:29 -0300, Ritesh Raj Sarraf <[EMAIL PROTECTED]> > escribió: > >> I'm not sure if there's something wrong in the code mentioned above or >> is it >> really a lock problem. > > Try to break the code into smaller pieces to see what is wrong. It's

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Paul McGuire
On Mar 16, 12:49 am, "n00m" <[EMAIL PROTECTED]> wrote: > for o in range(int(f.readline())): > row = map(int, f.readline().split()) > q.append(row[0]) > w.append(row[1]) > e.append(row[2]) > r.append(row[3]) Does this help at all in reading in your data? numlines = f.readline() rows = [

Re: lock problem

2007-03-16 Thread Ritesh Raj Sarraf
Leo Kislov wrote: > You're changing environmental variable __kabc_ldap that is shared > between your threads. Environment is not designed for that kind of > usage, it was designed for settings. Either use an option to set > output file or just redirect stdout. If the interface of ldapsearch is > s

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Paul Rubin wrote: > "n00m" <[EMAIL PROTECTED]> writes: >> h = collections.defaultdict(itertools.repeat(0).next) > > Something wrong with >h = collections.defaultdict(int) > ? According to a post by Raymond Hettinger it's faster to use that iterator instead of `in

Re: lock problem

2007-03-16 Thread Leo Kislov
On Mar 16, 12:40 am, Ritesh Raj Sarraf <[EMAIL PROTECTED]> wrote: > Leo Kislov wrote: > > You're changing environmental variable __kabc_ldap that is shared > > between your threads. Environment is not designed for that kind of > > usage, it was designed for settings. Either use an option to set > >

Re: Python shell on mac os x

2007-03-16 Thread martin . laloux
or go to http://pythonmac.org/packages/ and you have python 2.5 or python 2.4.4 with readline support -- http://mail.python.org/mailman/listinfo/python-list

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > Hi there, > > I'm very new to python, the problem I need to solve is whats the "best/ > simplest/cleanest" way to read in multiple files (ascii), do stuff to > them, and write them out(ascii). > > -- > import os > > filePath = ('O:/spam/eggs/')

Re: python noob, multiple file i/o

2007-03-16 Thread Jon Clements
On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: > On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: > > > > > > > Hi there, > > > I'm very new to python, the problem I need to solve is whats the "best/ > > simplest/cleanest" way to read in multiple files (ascii), do stuff to > > them,

Re: distributing python software in jar like fashion

2007-03-16 Thread Gary Duzan
In article <[EMAIL PROTECTED]>, alf <[EMAIL PROTECTED]> wrote: >Hi, > >I have a small app which consist of a few .py files. Is there any way to >distribute it in jar like fashion as a single file I can just run python >on. I obviously look for platform independent solution. > >Thx in advance, A.

Re: execfile locks file forever if there are any syntax errors - is it python bug?

2007-03-16 Thread Slawomir Nowaczyk
On Wed, 14 Mar 2007 07:59:57 -0500 [EMAIL PROTECTED] wrote: #> #> Slawomir> When I execfile a file which contains a syntax error, the file #> Slawomir> becomes locked and stays this way all the way until I exit the #> Slawomir> interpreter (I am unable to delete it, for example). I ha

RE: Readline()

2007-03-16 Thread Taylor, Stuart
for anyone who gets this same problem i managed to resolve the issue using two threads. The main program spawned a subprocess and used readlines to read the output. The process spawned was a script which executes a command using a thread. The thread reads the output from this command using readline

CSV module and "fileobj"

2007-03-16 Thread Jon Clements
Hi Group, If I have a CSV reader that's passed to a function, is it possible for that function to retrieve a reference to the "fileobj" like object that was passed to the reader's __init__? For instance, if it's using an actual file object, then depending on the current row, I'd like to open the f

Writing python module in C: wchar_t or Py_UNICODE?

2007-03-16 Thread Yury
I am new to python and programming generally, but someday it is time to start :) I am writing a python module in C and have a question about multibyte character strings in python<=>C. I want a C function which takes a string as argument from python script: static PyObject * connect_to_server(PyObj

Sharing Objects in Python

2007-03-16 Thread Clement
Can a object sharable by two different python programs... If so can you please explain... because my project needs two programs to access nearly 45GB file Symentaniously... By Clement Jeba kumar, Tenkasi. - It's here! Your new message! Get new email alerts

Mastering Python

2007-03-16 Thread Gerald
Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my curriculum did not include Python programming yet I see many vacancies for Python developers.I studied programming Pascal,C++ and Delphi.So I need to catch up quickly and master Python programming.How do you suggest that I achieve this g

Re: Using wildcards with Popen in the Subprocess module

2007-03-16 Thread Sion Arrowsmith
William Hudspeth <[EMAIL PROTECTED]> wrote: > [ ... ] I need to pass multiple filenames to an >executable. The filenames are similar to one another, but differ only >slightly, hence the use of the wildcard. The executable works well from >the command line if I pass in a wildcard filename, but Pope

Re: problem with str()

2007-03-16 Thread Steve Holden
Alex Martelli wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: >... Get yourself a stuffed bear, and next time you have this kind of problem spend a few minutes explaining to the bear exactly how your program can't possibly be wrong. Works like a charm. >>> A rubber ducky works m

Re: Registration Open for South Florida Software Symposium 2007

2007-03-16 Thread K
It is just a good news. -- http://mail.python.org/mailman/listinfo/python-list

Re: python noob, multiple file i/o

2007-03-16 Thread Laurent Rahuel
Maybe the walk method in os module is what you need http://docs.python.org/lib/os-file-dir.html Regards Jon Clements wrote: > On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: >> On 16 Mar, 03:56, "hiro" <[EMAIL PROTECTED]> wrote: >> >> >> >> >> >> > Hi there, >> >> > I'm very new to p

getopt or optparse options/arguments wrapping?

2007-03-16 Thread Rocky Zhou
I wonder is there any way to make the wrapper program can wrap options && arguments for the the subprocess/command the wrapper will execute? by getopt or optparse module? This is something like the shell script like this: optwrap="" while [ $# -gt 0 ]; do case $1 in -a) do-something; s

Re: Python Eggs on Cygwin

2007-03-16 Thread Jason Tishler
Kazu, On Thu, Mar 15, 2007 at 05:33:29PM -0700, Kazu Nisimura wrote: > >>> import MySQLdb > Traceback (most recent call last): > File "", line 1, in ? > File "build/bdist.cygwin-1.5.22-i686/egg/MySQLdb/__init__.py", line > 19, in ? > File "build/bdist.cygwin-1.5.22-i686/egg/_mysql.py", line

Re: python noob, multiple file i/o

2007-03-16 Thread Jordan
On Mar 16, 7:09 am, Laurent Rahuel <[EMAIL PROTECTED]> wrote: > Maybe the walk method in os module is what you > needhttp://docs.python.org/lib/os-file-dir.html > > Regards > > Jon Clements wrote: > > On 16 Mar, 09:02, "Jon Clements" <[EMAIL PROTECTED]> wrote: > >> On 16 Mar, 03:56, "hiro" <[EMAIL

Re: CSV module and "fileobj"

2007-03-16 Thread skip
Jon> If I have a CSV reader that's passed to a function, is it possible Jon> for that function to retrieve a reference to the "fileobj" like Jon> object that was passed to the reader's __init__? Nope, that isn't exposed from the C type. Skip -- http://mail.python.org/mailman/listin

String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach >>> f = 21.1 >>> s = "%.03f" % f >>> s '21.100' But there are mis

String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Hello alltogether, is it possible to format stings with fixed width of let's say 7 character. T need a floating point with 3 chars before dot, padded with ' ' and 3 chars after dot, padded with '0'. Followingh is my approach >>> f = 21.1 >>> s = "%.03f" % f >>> s '21.100' But there are mis

Re: Mastering Python

2007-03-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gerald wrote: > Can you recommend websites that feature a gentle introduction to Python? If you already know programming in general, `Dive Into Python`_ might be a good starting point. And of course the tutorial in the Python documentation. _Dive Into Python: http://www.

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Anton Vredegoor
n00m wrote: > 62.5030784639 Maybe this one could save a few seconds, it works best when there are multiple occurrences of the same value. A. from time import time def freq(L): D = {} for x in L: D[x] = D.get(x,0)+1 return D def test(): t = time() f = fil

Re: Mastering Python

2007-03-16 Thread Bruno Desthuilliers
Gerald a écrit : > Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my > curriculum did not include Python programming yet I see many vacancies > for Python developers.I studied programming Pascal,C++ and Delphi.So I > need to catch up quickly and master Python programming.How do you > su

Re: String formatting with fixed width

2007-03-16 Thread Steve Holden
Alexander Eisenhuth wrote: > Hello alltogether, > > is it possible to format stings with fixed width of let's say 7 character. T > need a floating point with 3 chars before dot, padded with ' ' and 3 chars > after > dot, padded with '0'. > > Followingh is my approach > >>> f = 21.1 > >>> s =

Importing

2007-03-16 Thread HMS Surprise
Greetings, First I will admit I am new to Python but have experience with C++ and some Tcl/Tk. I am starting to use a tool called MaxQ that uses jython. I have been studying Rossum's tutorial but still am unclear on importing, the use of self, and calling functions with their own name in quotes.

Re: String formatting with fixed width

2007-03-16 Thread Jon Clements
On 16 Mar, 13:20, Alexander Eisenhuth <[EMAIL PROTECTED]> wrote: > Hello alltogether, > > is it possible to format stings with fixed width of let's say 7 character. T > need a floating point with 3 chars before dot, padded with ' ' and 3 chars > after > dot, padded with '0'. > > Followingh is my a

Re: CSV module and "fileobj"

2007-03-16 Thread Bruno Desthuilliers
Jon Clements a écrit : > Hi Group, > > If I have a CSV reader that's passed to a function, is it possible for > that function to retrieve a reference to the "fileobj" like object > that was passed to the reader's __init__? For instance, if it's using > an actual file object, then depending on the

Re: Mastering Python

2007-03-16 Thread Paul McGuire
On Mar 16, 6:41 am, "Gerald" <[EMAIL PROTECTED]> wrote: > Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my > curriculum did not include Python programming yet I see many vacancies > for Python developers.I studied programming Pascal,C++ and Delphi.So I > need to catch up quickly and ma

Re: Mastering Python

2007-03-16 Thread Paul McGuire
On Mar 16, 6:41 am, "Gerald" <[EMAIL PROTECTED]> wrote: > Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my > curriculum did not include Python programming yet I see many vacancies > for Python developers.I studied programming Pascal,C++ and Delphi.So I > need to catch up quickly and ma

Re: Eureka moments in Python

2007-03-16 Thread Paul McGuire
On Mar 13, 2:16 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > I'd be interested in hearing people's stories of Eureka moments in Python, > moments where you suddenly realise that some task which seemed like it > would be hard work was easy with Python. > The day I wrote a CORBA method intercept

Re: String formatting with fixed width

2007-03-16 Thread Steve Holden
Steve Holden wrote: > Alexander Eisenhuth wrote: >> Hello alltogether, >> >> is it possible to format stings with fixed width of let's say 7 character. T >> need a floating point with 3 chars before dot, padded with ' ' and 3 chars >> after >> dot, padded with '0'. >> >> Followingh is my approac

Re: Writing python module in C: wchar_t or Py_UNICODE?

2007-03-16 Thread Carsten Haese
On Fri, 2007-03-16 at 04:04 -0700, Yury wrote: > I am new to python and programming generally, but someday it is time > to start :) > I am writing a python module in C and have a question about multibyte > character strings in python<=>C. > I want a C function which takes a string as argument from

Re: String formatting with fixed width

2007-03-16 Thread Alexander Eisenhuth
Thanks for your fast reply. I'm fine with your "%7.03f" solution. (negatives are not significant) Alexander Eisenhuth schrieb: > Hello alltogether, > > is it possible to format stings with fixed width of let's say 7 > character. T need a floating point with 3 chars before dot, padded with >

Re: Mastering Python

2007-03-16 Thread Dave Hansen
On Mar 16, 8:39 am, "Paul McGuire" <[EMAIL PROTECTED]> wrote: [...] > Stop thinking about *how* to start and *just start*. Python is pretty Indeed. Of all the fortune cookies I've eaten over the years, I've saved (and taped to my monitor) only one fortune. It reads: Begin...the rest is easy.

Re: Mastering Python

2007-03-16 Thread BartlebyScrivener
On Mar 16, 8:39 am, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > > Wow, are you still reading? Quit wasting time and go download a > Python dist and get started already! > I think you should extract that and spend twenty minutes tidying it up and then publish it to the Python for Programmers page

Re: Importing

2007-03-16 Thread Bruno Desthuilliers
HMS Surprise a écrit : > Greetings, > > First I will admit I am new to Python but have experience with C++ and > some Tcl/Tk. I am starting to use a tool called MaxQ that uses > jython. I have been studying Rossum's tutorial but still am unclear on > importing, What's your problem here ? > the

Re: Mastering Python

2007-03-16 Thread paul
Paul McGuire schrieb: > What does Python have that C++ doesn't? > - The biggie: dynamic typing (sometimes called "duck typing"). > Dynamic typing is a huge simplifier for development: > . no variable declarations > . no method type signatures > . no interface definitions needed > . no templ

Re: Python COM called from VB/Delphi

2007-03-16 Thread Jorge Mazzonelli
Larry, It's been a while since I coded something in VB or Delphi because I'm mostly turn on Python ;) so please excuse me any mistakes I can make 8I don't have neither VB or Delphi installed on this computer) For Delphi to use an OLE/COM Object it requires a TypeLibrary that explains how to acc

RE: Need help with apack compression code

2007-03-16 Thread Sells, Fred
try google: "python apack" found several in general, always google first; python has so many devotees that someone has generally solved most problems already. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of priya kale Sent: Thursday, March 15, 2007 11:33 PM

Re: Mastering Python

2007-03-16 Thread Jan Danielsson
Gerald wrote: > Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my > curriculum did not include Python programming yet I see many vacancies > for Python developers.I studied programming Pascal,C++ and Delphi.So I > need to catch up quickly and master Python programming.How do you > sugge

Re: war with china? a different approach?

2007-03-16 Thread Graeme Glass
Whats this got to do with python? On Jan 19, 9:34 pm, [EMAIL PROTECTED] wrote: > Coz we have fools in the govt, the downfall of the US has only been > accelerated !! > The are morons who staged 9/11 controlled demolition to kill americans > to start their idiotic war. > > Date: Sat, 21 Oct 2006 1

Re: Eureka moments in Python

2007-03-16 Thread Jarek Zgoda
Ben Finney napisał(a): >> I'd be interested in hearing people's stories of Eureka moments in >> Python, moments where you suddenly realise that some task which >> seemed like it would be hard work was easy with Python. > > I don't recall the exact context, but Python was the language that > intro

Re: Python shell on mac os x

2007-03-16 Thread Bert Heymans
On Mar 16, 4:08 am, [EMAIL PROTECTED] (Alex Martelli) wrote: > Bert Heymans <[EMAIL PROTECTED]> wrote: > > Hi! > > > I'm using iTerm on the mac the keymapping isn't right. On Linux and > > Windows it's really nice to be able to hit up to get the previous > > command. Does anyone know a way to get t

UpNp messages

2007-03-16 Thread ozan SARI
I want to sendmessages to a upnp device ,and listen to it's notify messages. Can I do that with Python. Can you help me and send an example? Thanks Ozan -- http://mail.python.org/mailman/listinfo/python-list

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Steven Bethard
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Paul Rubin wrote: > >> "n00m" <[EMAIL PROTECTED]> writes: >>> h = collections.defaultdict(itertools.repeat(0).next) >> Something wrong with >>h = collections.defaultdict(int) >> ? > > According to a post by Raymond Hettinger it's

Re: python noob, multiple file i/o

2007-03-16 Thread 7stud
The general idiom for altering lines in a file is to open the original file and write the alterations to a temp file. After you are done writing to the temp file, delete the original file, and change the temp file name to the original file name. If instead you were to read the whole file into a va

mySQLdb versus platform problem

2007-03-16 Thread Robin Becker
I am seeing different outcomes from simple requests against a common database when run from a freebsd machine and a win32 box. The test script is ### import MySQLdb, sys print sys.version print MySQLdb.__version__ db=MySQLdb.connect(host='appx',db='sc_0',user='user',passwd='s

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread Paul Rubin
Steven Bethard <[EMAIL PROTECTED]> writes: > > According to a post by Raymond Hettinger it's faster to use that > > iterator instead of `int`. > Yep. It's because the .next() method takes no arguments, while int() > takes varargs because you can do:: ... Heh, good point. Might be worth putting a

Re: distributing python software in jar like fashion

2007-03-16 Thread John Nagle
Were Python "eggs" a flop, or what? We need to have one packager that everyone agrees on. Otherwise, installs become a mess, and then you have to have installers that handle multiple packagers. John Nagle Gary Duzan wrote: > In article <[EMAIL PR

Re: python noob, multiple file i/o

2007-03-16 Thread 7stud
On Mar 16, 9:38 am, "7stud" <[EMAIL PROTECTED]> wrote: > - > import os > > filepath = "./change_files" > > li = os.listdir(filepath) > for name in li: > fullpath = filepath + "/" + name > if os.path.isfile(fullpath): > infile = open(fullpath, 'r') > >

Re: looking for a simple crypto library

2007-03-16 Thread Pınar Yanardağ
yep, thanx a lot ;) 2007/3/15, hg <[EMAIL PROTECTED]>: Paul Rubin wrote: > tlslite cool ! -- http://mail.python.org/mailman/listinfo/python-list -- Pınar "pinguar" Yanardağ http://pinguar.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing

2007-03-16 Thread HMS Surprise
Thanks for posting. I continued to read and realized the instantiation was not a function call soon after I posted. Oh well... Still unsure about the best way to break up the large #start - #end section. I appreciate your answers and try to digest them more fully. Then maybe I will have a better i

Re: Mastering Python

2007-03-16 Thread Diez B. Roggisch
Dennis Lee Bieber wrote: > On 16 Mar 2007 04:41:38 -0700, "Gerald" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > >> Hi ,Im a BSc4 Maths/Computer Science student.Unfortunately my >> curriculum did not include Python programming yet I see many vacancies >> for Python develope

Re: Eureka moments in Python

2007-03-16 Thread Sion Arrowsmith
Paul McGuire <[EMAIL PROTECTED]> wrote: >On Mar 13, 2:16 am, Steven D'Aprano <[EMAIL PROTECTED]> >wrote: >> I'd be interested in hearing people's stories of Eureka moments in Python, >> moments where you suddenly realise that some task which seemed like it >> would be hard work was easy with Python

Re: getopt or optparse options/arguments wrapping?

2007-03-16 Thread Steven Bethard
Rocky Zhou wrote: > I wonder is there any way to make the wrapper program can wrap options > && arguments for the the subprocess/command the wrapper will > execute? by getopt or optparse module? [snip] > I need this because I now have finished a fs_backup script written in > python, it will execu

Python training in Barcelona, Spain?

2007-03-16 Thread xavim
Hi! I work for a company located in Barcelona, Spain, and we are looking for an on-site introductory Python training. The audience would consist of about 10 developers with Java background. The training should be taught in Spanish. Does anyone knows of a company or individual that could deliver

TypeError: 'module' object is not callable

2007-03-16 Thread randomtalk
Hello everyone! i have the following test code: class temp: def __init__(self): self.hello = "hello world!" def printworld(self): print(self.hello) t = temp() and i tried to call profile('t.printworld()') but i received the following error: Traceback (most recent call last

Finding the insertion point in a list

2007-03-16 Thread tkpmep
I have an ordered list e.g. x = [0, 100, 200, 1000], and given any positive integer y, I want to determine its appropriate position in the list (i.e the point at which I would have to insert it in order to keep the list sorted. I can clearly do this with a series of if statements: if yx[i] for i i

Re: Finding the insertion point in a list

2007-03-16 Thread Matimus
You might look at the bisect module (part of the standard distribution). -- http://mail.python.org/mailman/listinfo/python-list

Re: distributing python software in jar like fashion

2007-03-16 Thread Robert Kern
John Nagle wrote: > Were Python "eggs" a flop, or what? No. > We need to have one packager that everyone agrees on. > Otherwise, installs become a mess, and then you have to have > installers that handle multiple packagers. Eggs and Squisher are complementary tools. Squisher is good fo

Re: distributing python software in jar like fashion

2007-03-16 Thread Chris Cioffi
Hi John, I don't think eggs are a flop, however the pain they are trying to solve is generally pretty minor in the Python world vs what we often see with other languages. We're starting to see some push to move more 3rd party libraries and frameworks to eggs (ie: Turbogears) and as the developer

Re: Finding the insertion point in a list

2007-03-16 Thread kyosohma
On Mar 16, 12:59 pm, [EMAIL PROTECTED] wrote: > I have an ordered list e.g. x = [0, 100, 200, 1000], and given any > positive integer y, I want to determine its appropriate position in > the list (i.e the point at which I would have to insert it in order to > keep the list sorted. I can clearly do

Re: TypeError: 'module' object is not callable

2007-03-16 Thread kyosohma
On Mar 16, 12:42 pm, [EMAIL PROTECTED] wrote: > Hello everyone! > i have the following test code: > class temp: > def __init__(self): > self.hello = "hello world!" > def printworld(self): > print(self.hello) > t = temp() > > and i tried to call profile('t.printworld()') > >

Determining cause of termination

2007-03-16 Thread Yang
Hi all, my Python (2.4) program crashed after a couple days of running (this'll be a pain to debug, I know). I think it just...stopped running. My log files didn't show any (unusual) exceptions (I use the logging module to files and stdout/stderr piped to files). I have a feeling that the python in

Displaying EPS in a GUI

2007-03-16 Thread virtk0s
Does anybody know of a good way to display Encapsulated Postscript images in a GUI? I'm currently using wx, but would be perfectly willing to switch to another binding to keep the program from becoming hackish. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError: 'module' object is not callable

2007-03-16 Thread 7stud
Hi, I can't find any documentation on the profile() function. But it might take a function reference as an argument and not the string you are feeding it. For instance: profile(t.printworld) Note the difference between: t.printworld t.printworld() The latter executes the function and then re

MySQLdb collectable memory leak

2007-03-16 Thread John Nagle
It's not big, but it's there. Just attaching to a MySQL database with MySQLdb, then closing the connection without doing anything results in some collectable garbage: gc: collectable gc: collectable gc: collectable gc: collectable gc: collectable (Python 2.4, MySQL 5, Windows 2000) (For te

Re: Finding the insertion point in a list

2007-03-16 Thread Paul McGuire
On Mar 16, 12:59 pm, [EMAIL PROTECTED] wrote: > I have an ordered list e.g. x = [0, 100, 200, 1000], and given any > positive integer y, I want to determine its appropriate position in > the list (i.e the point at which I would have to insert it in order to > keep the list sorted. I can clearly do

Re: mySQLdb versus platform problem

2007-03-16 Thread John Nagle
Try: db=MySQLdb.connect(host='appx',db='sc_0',user='user',passwd='secret', use_unicode=True, charset = "utf8") The distinction is that "use_unicode" tells Python to convert to Unicode, but Python doesn't know the MySQL table type. 'charset="utf8"' tells MySQL to do the conversion to

Re: python noob, multiple file i/o

2007-03-16 Thread hiro
Thanks a lot for the help guys, I'm at work right now and I will go over your suggestions one by one this weekend. Being more alert now, taking a look at the examples you posted, I now see how to approach this problem. The thing with python that I'm starting to realize is that there are a million

Re: python noob, multiple file i/o

2007-03-16 Thread hiro
Thanks a lot for the help guys, I'm at work right now and I will go over your suggestions one by one this weekend. Being more alert now, taking a look at the examples you posted, I now see how to approach this problem. The thing with python that I'm starting to realize is that there are a million

Re: Finding the insertion point in a list

2007-03-16 Thread kyosohma
On Mar 16, 2:32 pm, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > On Mar 16, 12:59 pm, [EMAIL PROTECTED] wrote: > > > > > I have an ordered list e.g. x = [0, 100, 200, 1000], and given any > > positive integer y, I want to determine its appropriate position in > > the list (i.e the point at which I w

socket.error: (9, 'Bad file descriptor') Python 2.5

2007-03-16 Thread Brian G. Merrell
I'm getting the following trace in python 2.5: Traceback (most recent call last): File "./template_unittest.py", line 36, in zencc.start_browser(machines.zones[0].devices.get_primary_servers()[0]) File "/home/bean/code/automation/nrm-qa/trunk/brimstone/lib/zcc.py", line 221, in start_browse

Re: To count number of quadruplets with sum = 0

2007-03-16 Thread marek . rocki
My attempt uses a different approach: create two sorted arrays, n^2 elements each; and then iterate over them looking for matching elements (only one pass is required). I managed to get 58,2250612857 s on my 1,7 MHz machine. It requires numpy for decent performance, though. import numpy import tim

python global variable error

2007-03-16 Thread ANIL KARADAĞ
hi, i made a program in python but received global name error. the program code; serverhost = '127.0.0.1' serverport = 2000 BUFSIZ = 1024 addr = (serverhost,serverport) if str(sys.argv).find("-s") == -1: cs = socket(AF_INET, SOCK_STREAM,0) # create a TCP socket cs.c

Re: Finding the insertion point in a list

2007-03-16 Thread 7stud
How about: --- x = [0, 100, 200, 1000] y = -1 inserted = False for i in range(len(x)): if(y <= x[i]): x.insert(i, y) inserted = True break if(not inserted): x.append(y) print x -- http://mail.python.org/mailman/listin

Re: Returning other instance from __init__

2007-03-16 Thread Paulo da Silva
Paulo da Silva escreveu: > Alex Martelli escreveu: >> Paulo da Silva <[EMAIL PROTECTED]> wrote: > > >> E.g.: >> >> class C1(object): >> def __new__(cls, xxx): >> if xxx: return type.__new__(cls, xxx) >> else: return C1.load(xxx) >> @staticmethod >> def load(xxx):

Re: Finding the insertion point in a list

2007-03-16 Thread Matimus
On Mar 16, 11:20 am, "Matimus" <[EMAIL PROTECTED]> wrote: > You might look at the bisect module (part of the standard > distribution). Here is an example: >>> from bisect import insort >>> x = [0,100,200,1000] >>> insort(x,10) >>> x [0, 10, 100, 200, 1000] -- http://mail.python.org/mailman/list

How to get the previous line in a file?

2007-03-16 Thread Qilong Ren
Hi,all I am new to this list. And I am glade I am here. I have a question. I need to do some text processing. I need to read from a file line by line. If some line is met with some condition, the previous line needs some modification. How to get the info of the previous line? Thanks! Qilong

Re: Sharing Objects in Python

2007-03-16 Thread Christoph Haas
On Friday 16 March 2007 12:41, Clement wrote: > Can a object sharable by two different python programs... If so can you > please explain... because my project needs two programs to access nearly > 45GB file Symentaniously... What kind of information is that? Can you put it into a database? Chris

Re: Finding the insertion point in a list

2007-03-16 Thread tobiaskk
Or like this: x = [0, 100, 200, 1000] y = 435 for n, i in enumerate(x): if y < i: n = n - 1 break x.insert(n + 1, y) If you decide to stick with n = sum ( y>x[i] for i in range(len(x)) ) - 1 Replace it with:

Re: How to get the previous line in a file?

2007-03-16 Thread Shane Geiger
lines = open('/tmp/foo.py', "r").read().splitlines() previous_line = ''

Re: How to get the previous line in a file?

2007-03-16 Thread Qilong Ren
Hi, Shane, Thanks for fast reply. What I used is : for line in open(FILE): I don't want to store all lines in a list because sometimes the file is very large. We need to store the value of the previous line in a variable. Is that right? Thanks,Qilong - Original Message

Re: How to get the previous line in a file?

2007-03-16 Thread kyosohma
On Mar 16, 3:51 pm, Shane Geiger <[EMAIL PROTECTED]> wrote: > lines = open('/tmp/foo.py', > "r").read().splitlines() > > previous_line = > '' > > for line in > lines: > > if "foo" in > line: > > print "found foo in the current line. The previous line is: " > + > previous_line > >

Re: How to get the previous line in a file?

2007-03-16 Thread Paul McGuire
On Mar 16, 3:51 pm, Shane Geiger <[EMAIL PROTECTED]> wrote: > lines = open('/tmp/foo.py', > "r").read().splitlines() > > > previous_line = > ''

Re: How to get the previous line in a file?

2007-03-16 Thread Jerry Hill
On 3/16/07, Qilong Ren <[EMAIL PROTECTED]> wrote: > I have a question. I need to do some text processing. I need to read from a > file line by line. If some line is met with some condition, the previous > line needs some modification. How to get the info of the previous line? I would do something

Executing a list of functions

2007-03-16 Thread HMS Surprise
Seems to me that one should be able to put the names of several functions in a list and then have the list executed. But it seems the output of the functions is hidden, only their return value is visible. Is this because the list execution is another scope? Thanx, jh ~~~

SQLite3, data not found

2007-03-16 Thread jim-on-linux
Python help, I just started working with SQLite3 and ran into this problem. Below, the first select produces results but, after closing then re-opening the database the select produces an empty list. Anyone know the reason ?? The table seems to be empty. import sqlite3 con = sqlite3.c

Re: Executing a list of functions

2007-03-16 Thread 7stud
lst = [a, b] The () symbol causes the named function to execute, and a function call in the code is always replaced by the function's return value. -- http://mail.python.org/mailman/listinfo/python-list

Re: mySQLdb versus platform problem

2007-03-16 Thread Robin Becker
John Nagle wrote: > Try: > > db=MySQLdb.connect(host='appx',db='sc_0',user='user',passwd='secret', > use_unicode=True, charset = "utf8") > > The distinction is that "use_unicode" tells Python to convert to Unicode, > but Python doesn't know the MySQL table type. 'charset="utf8"' tells >

Re: Executing a list of functions

2007-03-16 Thread 7stud
On Mar 16, 3:59 pm, "7stud" <[EMAIL PROTECTED]> wrote: > lst = [a, b] > > The () symbol causes the named function to execute, and a function > call in the code is always replaced by the function's return value. Try this: -- def a(): print "this is a" def b(): print "this is b

Re: How to get the previous line in a file?

2007-03-16 Thread dhn
On Mar 16, 5:10 pm, [EMAIL PROTECTED] wrote: > On Mar 16, 3:51 pm, Shane Geiger <[EMAIL PROTECTED]> wrote: > > > > > lines = open('/tmp/foo.py', > > "r").read().splitlines() > > > previous_line = > > '' > > > for line in > > lines: > > > if "foo" in > > line: > > > print "found foo in t

Re: SQLite3, data not found

2007-03-16 Thread jim-on-linux
from John Clark use con.commit() Thanks John, this works jim-on-linux On Friday 16 March 2007 17:55, jim-on-linux wrote: > Python help, > > I just started working with SQLite3 and ran > into this problem. > > Below, the first select produces results but, > after closing then re-opening the

Re: python global variable error

2007-03-16 Thread Sönmez Kartal
Then after defining clientsock, write a print statement as "print clientsock", see what it will print, None or a object? Sönmez ANIL KARADAĞ wrote: > ok , arranged block.but program give error global name 'clientsock' is not > defined " ,.. > > 2007/3/17, Sönmez Kartal <[EMAIL PROTECTED]>: >> >

Re: SQLite3, data not found

2007-03-16 Thread Jerry Hill
On 3/16/07, jim-on-linux <[EMAIL PROTECTED]> wrote: > Below, the first select produces results but, > after closing then re-opening the database the > select produces an empty list. Anyone know the > reason ?? When you first open a connection, you implicitly begin a transaction. You need to call

  1   2   >