copy a file

2009-07-13 Thread amrita
Dear all, Can anyone tell me that suppose i want to copy few lines from one text file to another then how can i do that.Looking forward for soon reply. Amrita Kumari Research Fellow IISER Mohali Chandigarh INDIA -- http://mail.python.org/mailman/listinfo/python-list

Re: python _binary_ code

2009-07-13 Thread Christian Heimes
sanju ps schrieb: > Hi > > Can anyone give me solution to create a python binary file (bytecode) other > than pyc file .So my source code be secure.. I am working on ubuntu 9.04 > with python2.6.. I It's impossible to secure your code if it runs on an untrusted computer. This is true for all pro

Re: python _binary_ code

2009-07-13 Thread Chris Rebert
On Mon, Jul 13, 2009 at 10:41 PM, sanju ps wrote: > Hi > >  Can anyone give me solution to create a python binary file (bytecode) other > than pyc file .So my source code be secure.. I am working on ubuntu 9.04 > with python2.6.. I PyInstaller (http://www.pyinstaller.org/) will generate a self-con

Re: explode()

2009-07-13 Thread Tim Harig
On 2009-07-14, Fred Atkinson wrote: > The one thing I really dislike about Python over PHP is that > Python can usually only appear in the cgi directory (unless other > arragements are made with your hosting provider or if you reconfigure > Apache on your own server if you have your own). W

python _binary_ code

2009-07-13 Thread sanju ps
Hi Can anyone give me solution to create a python binary file (bytecode) other than pyc file .So my source code be secure.. I am working on ubuntu 9.04 with python2.6.. I Regards Sanju -- http://mail.python.org/mailman/listinfo/python-list

Re: explode()

2009-07-13 Thread Fred Atkinson
On Mon, 13 Jul 2009 22:32:55 -0700, Chris Rebert wrote: >On Mon, Jul 13, 2009 at 11:28 PM, Fred Atkinson wrote: >> On Sat, 11 Jul 2009 18:50:28 -0700, Chris Rebert >> wrote: >> >>>On Sat, Jul 11, 2009 at 7:41 PM, Fred Atkinson wrote:        What is the Python equivalent of the PHP explode()

Re: explode()

2009-07-13 Thread Chris Rebert
On Mon, Jul 13, 2009 at 11:28 PM, Fred Atkinson wrote: > On Sat, 11 Jul 2009 18:50:28 -0700, Chris Rebert > wrote: > >>On Sat, Jul 11, 2009 at 7:41 PM, Fred Atkinson wrote: >>>        What is the Python equivalent of the PHP explode() function? >> >>some_string.split("separator") >> >>Cheers, >>Ch

Re: explode()

2009-07-13 Thread Fred Atkinson
On Sat, 11 Jul 2009 18:50:28 -0700, Chris Rebert wrote: >On Sat, Jul 11, 2009 at 7:41 PM, Fred Atkinson wrote: >>        What is the Python equivalent of the PHP explode() function? > >some_string.split("separator") > >Cheers, >Chris What would the equivalent of the PHP function implode be?

Re: How to check if any item from a list of strings is in a big string?

2009-07-13 Thread Gabriel Genellina
En Mon, 13 Jul 2009 10:11:09 -0300, denis escribió: Matt, how many words are you looking for, in how long a string ? Were you able to time any( substr in long_string ) against re.compile ( "|".join( list_items )) ? There is a known algorithm to solve specifically this problem (Aho-Corasic

Re: Memory error due to big input file

2009-07-13 Thread Steven D'Aprano
On Mon, 13 Jul 2009 14:20:13 -0700, Aaron Scott wrote: >> BTW, you should derive all your classes from something.  If nothing >> else, use object. >>   class textfile(object): > > Just out of curiousity... why is that? I've been coding in Python for a > long time, and I never derive my base class

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-13 Thread Steven D'Aprano
On Mon, 13 Jul 2009 23:22:36 +1200, Lawrence D'Oliveiro wrote: [stupidity omitted] > Nope, still doesn't work... Are we supposed to interpret that post as Dumb Insolence or just Dumb? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Steven D'Aprano
On Tue, 14 Jul 2009 10:09:06 +1000, Ben Finney wrote: > Instead of catching *all* exceptions at a specific point in your code, > and then having nothing to do but end the program (possibly after some > pre-exit action like logging), I think you would be better served by > installing a custom top-l

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Steven D'Aprano
On Mon, 13 Jul 2009 17:49:23 -0700, Carl Banks wrote: > On Jul 13, 12:31 pm, Piet van Oostrum wrote: >> > seldan24 (s) wrote: >> >s> Hello, >> >s> I'm fairly new at Python so hopefully this question won't be too s> >> >awful.  I am writing some code that will FTP to a host, and want to s> >>

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Carl Banks
On Jul 13, 12:31 pm, Piet van Oostrum wrote: > > seldan24 (s) wrote: > >s> Hello, > >s> I'm fairly new at Python so hopefully this question won't be too > >s> awful.  I am writing some code that will FTP to a host, and want to > >s> catch any exception that may occur, take that and print it o

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Ben Finney
seldan24 writes: > I'm fairly new at Python so hopefully this question won't be too > awful. I am writing some code that will FTP to a host, and want to > catch any exception that may occur, take that and print it out > (eventually put it into a log file and perform some alerting action). You h

Re: multiprocessing and dictionaries

2009-07-13 Thread Bjorn Meyer
On Monday 13 July 2009 13:12:18 Piet van Oostrum wrote: > > Bjorn Meyer (BM) wrote: > > > >BM> Here is what I have been using as a test. > >BM> This pretty much mimics what I am trying to do. > >BM> I put both threading and multiprocessing in the example which shows > >BM> the output that I

Re: PDF: finding a blank image

2009-07-13 Thread Brian
Perhaps your blank pages have a characteristic size. Or perhaps if you trim them with `convert' (ImageMagick) there is nothing left. On Mon, Jul 13, 2009 at 3:44 PM, DrLeif wrote: > I have about 6000 PDF files which have been produced using a scanner > with more being produced each day. The PDF

Re: PDF: finding a blank image

2009-07-13 Thread Scott David Daniels
DrLeif wrote: I have about 6000 PDF files which have been produced using a scanner with more being produced each day. The PDF files contain old paper records which have been taking up space. The scanner is set to detect when there is information on the backside of the page (duplex scan). The

Re: PDF: finding a blank image

2009-07-13 Thread David Bolen
DrLeif writes: > What I would like to do is have python detect a "blank" pages in a PDF > file and remove it. Any suggestions? The odds are good that even a blank page is being "rendered" within the PDF as having some small bits of data due to scanner resolution, imperfections on the page, etc.

Re: Pickling classes -- disappearing lists?

2009-07-13 Thread Aaron Scott
> Your class definition isn't right. It makes 'value' and 'journal' > class variables (Java lingo: "static variables") as opposed to the > instance variables they should be. Here's a corrected version: > Woah, thanks. I can't believe I made such a stupid mistake. It's not like I'm a newcomer to Py

Re: Memory error due to big input file

2009-07-13 Thread Chris Rebert
On Mon, Jul 13, 2009 at 2:51 PM, Vilya Harvey wrote: > 2009/7/13 Aaron Scott : >>> BTW, you should derive all your classes from something.  If nothing >>> else, use object. >>>   class textfile(object): >> >> Just out of curiousity... why is that? I've been coding in Python for >> a long time, and

Re: Memory error due to big input file

2009-07-13 Thread Vilya Harvey
2009/7/13 Aaron Scott : >> BTW, you should derive all your classes from something.  If nothing >> else, use object. >>   class textfile(object): > > Just out of curiousity... why is that? I've been coding in Python for > a long time, and I never derive my base classes. What's the advantage > to der

Re: Pickling classes -- disappearing lists?

2009-07-13 Thread Chris Rebert
On Mon, Jul 13, 2009 at 2:14 PM, Aaron Scott wrote: > I'm trying to pickle an instance of a class. It mostly works just fine > -- I can save the pickle to a file, restore it from that file, and > it's mostly okay. The problem is, some lists seem to disappear. For > example (snipped and crunched fro

PDF: finding a blank image

2009-07-13 Thread DrLeif
I have about 6000 PDF files which have been produced using a scanner with more being produced each day. The PDF files contain old paper records which have been taking up space. The scanner is set to detect when there is information on the backside of the page (duplex scan). The problem of cours

Re: Memory error due to big input file

2009-07-13 Thread Aaron Scott
> BTW, you should derive all your classes from something.  If nothing > else, use object. >   class textfile(object): Just out of curiousity... why is that? I've been coding in Python for a long time, and I never derive my base classes. What's the advantage to deriving them? -- http://mail.python

Pickling classes -- disappearing lists?

2009-07-13 Thread Aaron Scott
I'm trying to pickle an instance of a class. It mostly works just fine -- I can save the pickle to a file, restore it from that file, and it's mostly okay. The problem is, some lists seem to disappear. For example (snipped and crunched from the code giving me trouble): --- class InitGame:

Re: Memory error due to big input file

2009-07-13 Thread Dave Angel
sityee kong wrote: Hi All, I have a similar problem that many new python users might encounter. I would really appreciate if you could help me fix the error. I have a big text file with size more than 2GB. It turned out memory error when reading in this file. Here is my python script, the error

Re: Efficient binary search tree stored in a flat array?

2009-07-13 Thread Douglas Alan
On Jul 13, 3:57 pm, a...@pythoncraft.com (Aahz) wrote: > Still, unless your list is large (more than thousands of elements), > that's the way you should go.  See the bisect module.  Thing is, the > speed difference between C and Python means the constant for insertion > and deletion is very very s

Tkinter / Entry widget problem

2009-07-13 Thread Andras Szabo
Hello. I searched the archives but couldn't find a solution to a problem related to the Entry widget in Tkinter. When creating a pop-up window in an app, which contains an Entry widget, I want this widget to contain some default string, to have all this default string selected (as if the us

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Terry Reedy
Diez B. Roggisch wrote: The latter is - unfortunately - the better. This comes from python allowing all kinds of objects being thrown as exceptions, not only those extending from a common ancestor like Exception. Fixed in Python 3. exceptions, without exceptions, are instances of BaseExceptio

Re: Efficient binary search tree stored in a flat array?

2009-07-13 Thread Aahz
In article , Douglas Alan wrote: > >I couldn't find a good algorithms forum on the Internet, so I guess >I'll ask this question here instead: Is it possible to efficiently >maintain a binary search tree in a flat array (i.e., without using >pointers), as is typically done for a binary heap? > >It

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Piet van Oostrum
> seldan24 (s) wrote: >s> Hello, >s> I'm fairly new at Python so hopefully this question won't be too >s> awful. I am writing some code that will FTP to a host, and want to >s> catch any exception that may occur, take that and print it out >s> (eventually put it into a log file and perform s

Re: multiprocessing and dictionaries

2009-07-13 Thread Piet van Oostrum
> Bjorn Meyer (BM) wrote: >BM> Here is what I have been using as a test. >BM> This pretty much mimics what I am trying to do. >BM> I put both threading and multiprocessing in the example which shows >BM> the output that I am looking for. >BM> #!/usr/bin/env python >BM> import threading >BM>

Re: Efficient binary search tree stored in a flat array?

2009-07-13 Thread Paul Rubin
Douglas Alan writes: > It would also clearly be > possible to store a balanced binary tree in a flat array, storing the > children of the node at index i at indices 2*i and 2*i + 1, just as > one does for a binary heap. But if you do that, I don't know if you > could then do insertions and deletio

Re: Threading.Condition problem

2009-07-13 Thread Piet van Oostrum
> Gabriel Rossetti (GR) wrote: >GR> Piet van Oostrum wrote: ... >GR> I wrote a small example that listens for xmpp msgs in a thread. The main >GR> program calls a function that blocks (using Condition.wait) until a msg >GR> has been received and then returns the msg. When a msg arrives, it is

Re: Automate rsync w/ authentication

2009-07-13 Thread Piet van Oostrum
> Bryan (B) wrote: >B> On Jul 10, 12:03 pm, mgi...@motorola.com (Gary Duzan) wrote: >>> In article >>> <3af970b1-b454-4d56-a33f-889ecfaca...@l28g2000vba.googlegroups.com>, >>> >>> Bryan   wrote: >>> >>> >rsyncExec = '/usr/bin/ssh' >>> >source = 'r...@10.0.45.67:/home/bry/jquery.lookup' >>>

Efficient binary search tree stored in a flat array?

2009-07-13 Thread Douglas Alan
I couldn't find a good algorithms forum on the Internet, so I guess I'll ask this question here instead: Is it possible to efficiently maintain a binary search tree in a flat array (i.e., without using pointers), as is typically done for a binary heap? It *is* possible, of course, to keep an order

Re: list of all possible values

2009-07-13 Thread David Gibb
> Or on systems with list comps try: > V='abc' ['%s%s'%(ii,jj) for ii in V for jj in V] > ['aa', 'ab', 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc'] Yeah, except that the length here is hard-coded. There's no way (as far as I can tell, at least), to make this generic with respect to lis

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Vilya Harvey
2009/7/13 seldan24 : > Thank you both for your input.  I want to make sure I get started on > the right track.  For this particular script, I should have included > that I would take the exception contents, and pass those to the > logging module.  For this particular script, all exceptions are fata

How to override Marshaller/Unmarshaller in xmlrpc?

2009-07-13 Thread Bogdan Opanchuk
Is there a way to override marshaller in xmlrpc.client properly? For example, I want to hide bytes -> Binary transformation inside marshaller (i.e., just let user pass a bytes value to function and marshaller dumps it in base64 autmatically). Unfortunately, I cannot just make a derived class with n

Re: list of all possible values

2009-07-13 Thread Emile van Sebille
On 7/13/2009 9:33 AM Tim Chase said... For example: if my values are ['a', 'b', 'c'], then all possible lists of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc. I created a recursive program to do it, but I was wondering if there was a better way of doing it (possibly with list comprehens

Re: Threading.Condition problem

2009-07-13 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti (GR) wrote: GR> Sorry if this appears twice, I sent it once with an attachment and it never GR> arrived so maybe the attachment is posing problems. I inlined the code this GR> time (at the bottom), thank you, GR> Gabriel

Re: Memory error due to big input file

2009-07-13 Thread skip
phoebe> I have a big text file with size more than 2GB. It turned out phoebe> memory error when reading in this file. Here is my python phoebe> script, the error occurred at line -- self.fh.readlines(). phoebe> import math phoebe> import time phoebe> class textfile: p

Re: Memory error due to big input file

2009-07-13 Thread MRAB
sityee kong wrote: Hi All, I have a similar problem that many new python users might encounter. I would really appreciate if you could help me fix the error. I have a big text file with size more than 2GB. It turned out memory error when reading in this file. Here is my python script, the erro

Memory error due to big input file

2009-07-13 Thread sityee kong
Hi All, I have a similar problem that many new python users might encounter. I would really appreciate if you could help me fix the error. I have a big text file with size more than 2GB. It turned out memory error when reading in this file. Here is my python script, the error occurred at line -- s

Re: Blocking XMPP API?

2009-07-13 Thread Gabriel Rossetti
Lawrence D'Oliveiro wrote: In message , Gabriel Rossetti wrote: I am looking for blocking XMPP API. I'm wanting to make a webservice that uses XMPP, but all the XMPP libs I find are non-blocking (i.e. w/ callbacks). So why not have the caller sleep or something until the callback is

Germany Ups Terrorism Alert Before Election

2009-07-13 Thread whatn...@gmail.com
With Germany going to the polls in a general election in three months, authorities are on high alert after detecting an increase in online warnings of terrorist attacks targeting the country. The German government held high-level talks with top security and intelligence chiefs in Berlin on Thursday

Re: multiprocessing and dictionaries

2009-07-13 Thread Bjorn Meyer
On Monday 13 July 2009 01:56:08 Piet van Oostrum wrote: > > Bjorn Meyer (BM) wrote: > > > >BM> I am trying to convert a piece of code that I am using the thread > > module with BM> to the multiprocessing module. > > > >BM> The way that I have it set up is a chunk of code reads a text file an

Re: list of all possible values

2009-07-13 Thread Bearophile
David Gibb: > For example: if my values are ['a', 'b', 'c'], then all possible lists > of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc. >>> from itertools import product >>> list(product("abc", repeat=2)) [('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'b'), ('b', 'c'), ('c', 'a'),

Re: Passing python list from C to python

2009-07-13 Thread John Machin
On Jul 14, 1:47 am, hartley wrote: > I'm very new at wrapping Python/C, and I have run into some problems. > > I have one python module that provides me with a list (provideBuffer > in provideBuff.py): > >  Py_Initialize(); >         pName = PyString_FromString("provideBuff"); >         pModule =

Re: list of all possible values

2009-07-13 Thread Tim Chase
For example: if my values are ['a', 'b', 'c'], then all possible lists of length 2 would be: aa, ab, ac, ba, bb, bc, ca, cb, cc. I created a recursive program to do it, but I was wondering if there was a better way of doing it (possibly with list comprehensions). Here's my recursive version: va

list of all possible values

2009-07-13 Thread David Gibb
Hi guys. I was thinking about a problem I had: suppose I have a list of possible values. I want to to have a list of all possible lists of length n whose values are in that original list. For example: if my values are ['a', 'b', 'c'], then all possible lists of length 2 would be: aa, ab, ac, ba,

Passing python list from C to python

2009-07-13 Thread hartley
I'm very new at wrapping Python/C, and I have run into some problems. I have one python module that provides me with a list (provideBuffer in provideBuff.py): Py_Initialize(); pName = PyString_FromString("provideBuff"); pModule = PyImport_Import(pName); pFunc = PyObject_

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Floris Bruynooghe
On Jul 13, 2:26 pm, seldan24 wrote: > The first example: > > from ftplib import FTP > try: >     ftp = FTP(ftp_host) >     ftp.login(ftp_user, ftp_pass) > except Exception, err: >     print err *If* you really do want to catch *all* exceptions (as mentioned already it is usually better to catch s

Re: Best Way to Handle All Exceptions

2009-07-13 Thread seldan24
On Jul 13, 10:33 am, MRAB wrote: > seldan24 wrote: > > Hello, > > > I'm fairly new at Python so hopefully this question won't be too > > awful.  I am writing some code that will FTP to a host, and want to > > catch any exception that may occur, take that and print it out > > (eventually put it int

Re: Automate rsync w/ authentication

2009-07-13 Thread Bryan
On Jul 10, 12:03 pm, mgi...@motorola.com (Gary Duzan) wrote: > In article > <3af970b1-b454-4d56-a33f-889ecfaca...@l28g2000vba.googlegroups.com>, > > Bryan   wrote: > > >rsyncExec = '/usr/bin/ssh' > >source = 'r...@10.0.45.67:/home/bry/jquery.lookup' > >dest = '/home/bry/tmp' > >rshArg = '-e "/usr/

Re: Best Way to Handle All Exceptions

2009-07-13 Thread MRAB
seldan24 wrote: Hello, I'm fairly new at Python so hopefully this question won't be too awful. I am writing some code that will FTP to a host, and want to catch any exception that may occur, take that and print it out (eventually put it into a log file and perform some alerting action). I've fi

Re: python make dies :libtk8.5.so: cannot open shared object file: No such file or directory

2009-07-13 Thread Tony Lay
On Jul 13, 10:09 am, Christian Heimes wrote: > Tony Lay wrote: > > # cd /usr/local/lib > > > # ls -la | grep libtk8.5.so > > > -r-xr-xr-x   1 root root  1112606 Jul 10 13:28 libtk8.5.so > > > Am I missing something, it’s there? > > Is /usr/local/lib in your library search path? It looks like it is

Re: need to write a assembly progrm

2009-07-13 Thread Grant Edwards
On 2009-07-12, Rhodri James wrote: >> The poorly punctuated paragraph sounds, to me, as if they mean >> they want (Windows assumed) EXE files that can be dropped onto >> remote/laptop machines without performing a full installation >> of Python... >> >> But yes... "assembly programs" does, to me,

Re: Problem with two instances of PySerial

2009-07-13 Thread Grant Edwards
> On Thu, 9 Jul 2009 08:40:18 -0500, Shine Jose wrote: > I achieve this by creating a separate worker thread to poll > the serial port for arrival of data and then updating the > required widget in main thread of program. For polling the > serial port, I create a separate instance of pySerial ob

Re: Best Way to Handle All Exceptions

2009-07-13 Thread Diez B. Roggisch
seldan24 wrote: > Hello, > > I'm fairly new at Python so hopefully this question won't be too > awful. I am writing some code that will FTP to a host, and want to > catch any exception that may occur, take that and print it out > (eventually put it into a log file and perform some alerting actio

Re: python make dies :libtk8.5.so: cannot open shared object file: No such file or directory

2009-07-13 Thread Christian Heimes
Tony Lay wrote: > # cd /usr/local/lib > > # ls -la | grep libtk8.5.so > > -r-xr-xr-x 1 root root 1112606 Jul 10 13:28 libtk8.5.so > > Am I missing something, it’s there? Is /usr/local/lib in your library search path? It looks like it isn't. Check /etc/ld.so.conf and /etc/ld.so.conf.d/. Chri

python make dies :libtk8.5.so: cannot open shared object file: No such file or directory

2009-07-13 Thread Tony Lay
Trying to build python-2.6.2 ./configure --prefix=/usr/local --exec-prefix=/usr/local LDFLAGS="-L/ usr/local" (runs through happily, had to make some libs local) make runs most of the way until… building '_tkinter' extension gcc -pthread -fPIC -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3

Re: Is it possible to use keyword arguments from C?

2009-07-13 Thread Darren Dale
On Jul 13, 9:38 am, Darren Dale wrote: > I am learning about the python C-api in order to contribute a feature > to numpy. I see a discussion (http://docs.python.org/extending/ > extending.html#keyword-parameters-for-extension-functions) on how to > create a function or method  in C that accepts k

Is it possible to use keyword arguments from C?

2009-07-13 Thread Darren Dale
I am learning about the python C-api in order to contribute a feature to numpy. I see a discussion (http://docs.python.org/extending/ extending.html#keyword-parameters-for-extension-functions) on how to create a function or method in C that accepts kwargs, but is it possible to call such a method

Best Way to Handle All Exceptions

2009-07-13 Thread seldan24
Hello, I'm fairly new at Python so hopefully this question won't be too awful. I am writing some code that will FTP to a host, and want to catch any exception that may occur, take that and print it out (eventually put it into a log file and perform some alerting action). I've figured out two diff

Re: How to check if any item from a list of strings is in a big string?

2009-07-13 Thread denis
Matt, how many words are you looking for, in how long a string ? Were you able to time any( substr in long_string ) against re.compile ( "|".join( list_items )) ? (REs are my method of choice, but different inputs of course give different times -- see google regex speed site:groups.google.com / sit

how to set timeout while colling a soap method?

2009-07-13 Thread dzizes
Hello! I wrote some some python code for executing a soap method: import SOAPpy from SOAPpy import WSDL _server = WSDL.Proxy(some wsdl) r=_server.generuj(some parameters...) print r.encode('cp1250') It works fine. However, the execution time of this soap method might be long. Therefore, I woul

Re: The meaning of "="

2009-07-13 Thread Piet van Oostrum
> Lawrence D'Oliveiro (LD) wrote: >LD> In message , Aahz wrote: >Aahz> class AttrDict: >Aahz> def __getitem__(self, key): >Aahz> return getattr(self, key) >LD> OK, let's try it: >LD> >>> c = {} >LD> >>> c["x"] = 3 >LD> >>> c.x = 4 >LD> Traceback (most recent call last): >LD> F

Re: Blocking XMPP API?

2009-07-13 Thread Lawrence D'Oliveiro
In message , Gabriel Rossetti wrote: > I am looking for blocking XMPP API. I'm wanting to make a webservice > that uses XMPP, but all the XMPP libs I find are non-blocking (i.e. w/ > callbacks). So why not have the caller sleep or something until the callback is invoked? It's easier to turn an

Re: A Bug By Any Other Name ...

2009-07-13 Thread Lawrence D'Oliveiro
In message , MRAB wrote: > I wonder whether the problem with assignment in conditionals in C is due > to the assignment operator being "=". If it was ":=", would the error > still occur? One of the original C designers, Kernighan or Ritchie, admitted that he made the assignment operator "=" ins

Re: A Bug By Any Other Name ...

2009-07-13 Thread Lawrence D'Oliveiro
In message <4a538a71$0$30236$9b4e6...@newsspool1.arcor-online.net>, Stefan Behnel wrote: > Lawrence D'Oliveiro wrote: >> >> I wonder how many people have been tripped up by the fact that >> >> ++n >> >> and >> >> --n >> >> fail silently for numeric-valued n. > > I doubt that there ar

Re: Check file is locked?

2009-07-13 Thread Lawrence D'Oliveiro
In message <652cca82-44a3-473f-b640- c2336a9cf...@v15g2000prn.googlegroups.com>, Rajat wrote: > ... my whole idea is to close the wordpad / notepad application so that I > can delete the file and the directory where this file resides. Don't you think the user might have that application open for

Re: send keys to focused window

2009-07-13 Thread Lawrence D'Oliveiro
In message , Broken wrote: > I am new to Python, and I'm miserably failing to send specific keys to > (say) notepad. I don't understand why you need to automate a GUI front-end, meant for human use, to a function that can be directly performed without that front-end anyway. -- http://mail.pytho

Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Ulrich Eckhardt
gganesh wrote: > I have a dict object like > emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com', > 'z...@gmail.com'], 'myname':['gganesh']} > I need to get the lenght of the list mycontacts ,like > mycontacts_numbers=3 mycontacts = emails['mycontacts'] mycontacts_number = len(mycontacts) A

Re: Looking for a tool to checkfor python script backward compatibility

2009-07-13 Thread Lawrence D'Oliveiro
In message <4a59951a$0$10853$426a7...@news.free.fr>, Baptiste Lepilleur wrote: > I'm looking for a tool that could be used in a pre-commit step to check > that only features available in a "old" python version are used, say > python 2.3 for example. The only sure way would be to run the script u

Re: MySQLdb + SSH Tunnel

2009-07-13 Thread Lawrence D'Oliveiro
In message , Emile van Sebille wrote: > ssh with something like... > > ssh -lroot -L3306:C:3306 B > > Watch out for other instances of mysql on A or B... You can use a non-default local port and specify that in your local connection parameters. Similarly you can tell the remote server to use

Re: Infinite loops and synchronization

2009-07-13 Thread Lawrence D'Oliveiro
In message , Vincent Gulinao wrote: > Q1: is this a common OK practice? I'm worried infinite loops hogs memory. The problem is not that the loop is infinite, but that it busy-waits, hogging CPU. -- http://mail.python.org/mailman/listinfo/python-list

Re: The meaning of "=" (Was: tough-to-explain Python)

2009-07-13 Thread Lawrence D'Oliveiro
In message , Aahz wrote: > In article , > Lawrence D'Oliveiro wrote: >>In message , Aahz wrote: >>> >>> It helps to remember that names and namespaces are in many >>> ways syntactic sugar for dicts or lists. >> >>Interesting, though, that Python insists on maintaining a distinction >>between c["

Re: simple question about Dictionary type containing List objects

2009-07-13 Thread Xavier Ho
On Mon, Jul 13, 2009 at 6:34 PM, gganesh wrote: > Hi group, > I have a dict object like > emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com', > 'z...@gmail.com'], 'myname':['gganesh']} > I need to get the lenght of the list mycontacts ,like > mycontacts_numbers=3

simple question about Dictionary type containing List objects

2009-07-13 Thread gganesh
Hi group, I have a dict object like emails={'mycontacts': [ 'x...@gmail.com, 'y...@gmail.com', 'z...@gmail.com'], 'myname':['gganesh']} I need to get the lenght of the list mycontacts ,like mycontacts_numbers=3 help me to solve Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Infinite loops and synchronization

2009-07-13 Thread pdpi
On Jul 13, 6:06 am, Vincent Gulinao wrote: > lst = list() > > (lst populated by async twisted deferred callbacks) > > while True: >         if len(lst) == SOME_NUMBER: >                 return lst > > Q1: is this a common OK practice? I'm worried infinite loops hogs memory. > Q2: operating on list

Re: the ultimate logging facility for debugging code

2009-07-13 Thread Vinay Sajip
On Jul 10, 10:39 am, Jean-Michel Pichavant wrote: > Greetings, > > Sorry for the dubious title :o). I was wandering if there is a standard > (or reliable) python module that implements the following feature: > > http://code.activestate.com/recipes/198078/ >  >>>Recipe 198078: Wrapping method calls

Re: Infinite loops and synchronization

2009-07-13 Thread Piet van Oostrum
> Vincent Gulinao (VG) wrote: >VG> lst = list() >VG> (lst populated by async twisted deferred callbacks) >VG> while True: >VG>if len(lst) == SOME_NUMBER: >VG>return lst >VG> Q1: is this a common OK practice? I'm worried infinite loops hogs memory. >VG> Q2: operating on list

Re: Addind imports to a class namespace

2009-07-13 Thread Ryan K
Thank you for your replies. I have factored out the dependency and everything is solved. Cheers, Ryan -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about generators

2009-07-13 Thread Piet van Oostrum
> Cameron Pulsford (CP) wrote: >CP> I read it on the haskell site in their sieves/prime wheel section, >CP> I guess I misunderstood something. (east to do over there...) I did >CP> verify it against established list of primes and other generators >CP> I've written that use more normal methods

Re: multiprocessing and dictionaries

2009-07-13 Thread Piet van Oostrum
> Bjorn Meyer (BM) wrote: >BM> I am trying to convert a piece of code that I am using the thread module >with >BM> to the multiprocessing module. >BM> The way that I have it set up is a chunk of code reads a text file and >assigns >BM> a dictionary key multiple values from the text file.