Re: os.environ.get('SSH_ORIGINAL_COMMAND') returns None

2008-12-15 Thread Tim Roberts
Tzury Bar Yochay wrote: > >added to ~/.ssh/authorized_keys the command="my_parder" parameter >which point to a python script file named 'my_parser' and located in / >usr/local/bin (file was chmoded as 777) > >in that script file '/usr/local/bin/my_parser' I got the following >lines: > >#!/usr/bin

Re: How can I return a non-zero status result from a python script?

2008-12-15 Thread Taskinoor Hasan
sys.exit() raise SystemExit() exception which could be caught and if not caught, terminate only the current thread. If your program is multi-threaded and you want to terminate the process, i.e all threads, immediately then use os._exit(1) On Tue, Dec 16, 2008 at 7:52 AM, Miki wrote: > Hello, > >

Re: Thread Locking issue - Can't allocate lock (sem_init fail)

2008-12-15 Thread Bryan Olson
jams...@googlemail.com wrote: [...] > The program is multithreaded to speed up the processing...there are > input and output Queues. It's not the major point here, but are you aware of Python's GIL? > Now, each domain entry is an class object containing various bits of > info. Each domain class

tutorial on parser

2008-12-15 Thread John Fabiani
Hi, I'm attempting to learn how to convert MsSQl Transact-SQL to postgres pgsql. So far my readings have led me to finding a parser. I'm looking for a tutorial on how to get it done. I did find a commercial product but they want over $10,000 us. This way beyond my means. Therefore, I need to ge

Re: socket and subprocess problem

2008-12-15 Thread Bryan Olson
goat...@gmail.com wrote: Guys thanks to point it out. Yes, it's a race problem. I tried sleep long enough, then I can connect to the socket. I should add code to try to connect to the socket for a given time out. As Roy noted, that's "the cheesy way". Are the kind of programmers who accept che

Re: ethical questions about global variables

2008-12-15 Thread Michele Simionato
On Dec 16, 3:45 am, "Giampaolo Rodola'" wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "ethical" doub

Re: ethical questions about global variables

2008-12-15 Thread rurpy
On Dec 15, 11:00 pm, ru...@yahoo.com wrote: > #my_module > class Config: pass > config = Config() > > def func1(state): > config.A = 1 > def func2(state) > config.A = 2 > def func3(state) > print config.A That of course should have been: def func1(config): config.A = 1 def func2(c

Re: parse C expression?

2008-12-15 Thread eliben
On Dec 16, 1:48 am, Torsten Mohr wrote: > Hi, > > i found some examples when googling for the subject but nothing really > matched. > > Is there a standard module available that lets me parse a syntax like "C" > with numbers, operators, braces, variables and function calls? > > I'd like to use thi

Re: ethical questions about global variables

2008-12-15 Thread rurpy
On Dec 15, 7:45 pm, "Giampaolo Rodola'" wrote: > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "ethical" doubts I'm

Re: socket and subprocess problem

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 3:30 PM, wrote: > Guys thanks to point it out. > Yes, it's a race problem. I tried sleep long enough, then I can > connect to the socket. I should add code to try to connect to the > socket for a given time out. This is where event-driven approaches become really useful :

Re: socket and subprocess problem

2008-12-15 Thread goatold
Guys thanks to point it out. Yes, it's a race problem. I tried sleep long enough, then I can connect to the socket. I should add code to try to connect to the socket for a given time out. Roy Smith wrote: > In article > <6d3291c3-4e12-4bdd-884a-21f15f38d...@a12g2000pro.googlegroups.com>, > goat..

Re: tricky nested list unpacking problem

2008-12-15 Thread Reckoner
On Dec 15, 1:28 pm, Arnaud Delobelle wrote: > Reckoner writes: > > Hi, > > > I have lists of the following type: > > > [1,2,3,[5,6]] > > > and I want to produce the following strings from this as > > > '0-1-2-3-5' > > '0-1-2-3-6' > > > That was easy enough. The problem is that these can be nested.

Re: socket and subprocess problem

2008-12-15 Thread Roy Smith
In article <6d3291c3-4e12-4bdd-884a-21f15f38d...@a12g2000pro.googlegroups.com>, goat...@gmail.com wrote: > In my python code I use subprocess.Popen to run and external program > who will listen to a TCP port. And I also create a socket to connect > to the TCP port that the external program is li

Re: Python is slow

2008-12-15 Thread Tomasz Rola
On Fri, 12 Dec 2008, bearophileh...@lycos.com wrote: > In the next years people that use low-level languages like C may need > to invent a new language fitter for multi-core CPUs, able to be used > on GPUs too (see the OpenCL), less error-prone than C, able to use the > CPU vector instructions eff

Re: socket and subprocess problem

2008-12-15 Thread Bryan Olson
goat...@gmail.com wrote: In my python code I use subprocess.Popen to run and external program who will listen to a TCP port. And I also create a socket to connect to the TCP port that the external program is listening. I will get 'Connection refused, errno=111' when I try to socket.connect ().

Re: Copying files in directory

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 12:49 PM, wrote: > I'm writing a project management system, and I need the ability to > accept a directory name and move its contents to another directory. > Can someone give me a code sample that will handle this? I can't find > any "copying" functions in os or os.path.

Re: ethical questions about global variables

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 12:45 PM, Giampaolo Rodola' wrote: > Hi, > in a module of mine (ftpserver.py) I'd want to add a (boolean) global > variable named "use_gmt_times" to decide whether the server has to > return times in GMT or localtime but I'm not sure if it is a good idea > because of the "e

Copying files in directory

2008-12-15 Thread pacsciadmin
I'm writing a project management system, and I need the ability to accept a directory name and move its contents to another directory. Can someone give me a code sample that will handle this? I can't find any "copying" functions in os or os.path. Regards, LeafStorm -- http://mail.python.org/mailma

socket and subprocess problem

2008-12-15 Thread goatold
Hi all, Here is my problem, see if any one else met this before In my python code I use subprocess.Popen to run and external program who will listen to a TCP port. And I also create a socket to connect to the TCP port that the external program is listening. I will get 'Connection refused, errno=11

ethical questions about global variables

2008-12-15 Thread Giampaolo Rodola'
Hi, in a module of mine (ftpserver.py) I'd want to add a (boolean) global variable named "use_gmt_times" to decide whether the server has to return times in GMT or localtime but I'm not sure if it is a good idea because of the "ethical" doubts I'm gonna write below. In first place I've never liked

Re: How can I return a non-zero status result from a python script?

2008-12-15 Thread Miki
Hello, > How can I return a non-zero status result from the script? Just do a > return 1? at the end? raise SystemExit(1) HTH, -- Miki http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

Re: parse C expression?

2008-12-15 Thread Miki
> Is there a standard module available that lets me parse a syntax like "C" > with numbers, operators, braces, variables and function calls? There is a C compiler implemented with PLY somewhere. > I'd like to use this to parse an own kind of configuration language > and preferred would be just sta

Re: parse C expression?

2008-12-15 Thread Chris Rebert
On Mon, Dec 15, 2008 at 3:48 PM, Torsten Mohr wrote: > Hi, > > i found some examples when googling for the subject but nothing really > matched. > > Is there a standard module available that lets me parse a syntax like "C" > with numbers, operators, braces, variables and function calls? > > I'd li

Re: tricky nested list unpacking problem

2008-12-15 Thread Chris Rebert
On Mon, Dec 15, 2008 at 12:24 PM, Kirk Strauser wrote: > At 2008-12-15T20:03:14Z, "Chris Rebert" writes: > >> You just need a recursive list-flattening function. There are many >> recipes for these. Here's mine: > > flattened = flatten([1,2,3,[5,6,[10, 11]],7,[9,[1, 2, 3, 4, 5 ]]]) > flat

Re: Removing None objects from a sequence

2008-12-15 Thread bearophileHUGS
Scott David Daniels: > If you want to keep the original's method, but do it in a more Pythonic > way, I would suggest: > >      def deNone4(alist): >          j = 0 >          for val in alist: >              if val is not None: >                  alist[j] = val >                  j += 1 >        

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread Дамјан Георгиевски
> In most languages, I'll do something like this > > xmlWriter.BeginElement("parent"); > xmlWriter.BeginElement("child"); > --xml.Writer.Characters("subtext"); > xmlWriter.EndElement(); > xmlWriter.EndElement(); > > Where the dashes are indentation (since some newsgroup handlers d

Re: Insatlling python on compute-node-linux (Cray).

2008-12-15 Thread skip
Rahul> Has anyone tried installing Python on Compute Node Linux (on a Rahul> cray)? I was having trouble getting it running. I see that CNL Rahul> does not support dynamic libraries but I am not sure what the Rahul> best way then is to get Python running. In the Modules directory

Re: Need help improving number guessing game

2008-12-15 Thread feba
> .strip() returns a copy of the string without leading and ending whitespaces (inlcuding newlines, tabs etc). Ahh. I had removed it because it didn't seem to do anything, but I've readded it. And I understand your dictionary stuff correctly now, I think, and I worked it in. Currently, I have:

Re: OpenOpt 0.21 (free optimization framework)

2008-12-15 Thread Neal Becker
Is it easy_install able? I got: sudo easy_install -U openopt Searching for openopt Reading http://pypi.python.org/simple/openopt/ Couldn't find index page for 'openopt' (maybe misspelled?) Scanning index of all packages (this may take a while) Reading http://pypi.python.org/simple/ Reading http:/

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Martin v. Löwis
> I noted, also, than, in some cases, Python26.dll is not copied in > %WINDIR%\system32 > After that, external softs don't find the DLL. Right. Only in "for all users" installations, python26.dll is put into system32. In a "just for me" installation, the user is not expected to have permissions to

Re: Bidrectional Subprocess Communication

2008-12-15 Thread Gabriel Genellina
En Sun, 14 Dec 2008 06:03:26 -0200, greg escribió: Gabriel Genellina wrote: (Pipes don't work the same as sockets, although unix-like systems try hard to hide the differences...) BSD-based unixes implement pipes using socketpair(), so pipes actually *are* sockets (or at least they used to

Re: parse C expression?

2008-12-15 Thread James Mills
On Tue, Dec 16, 2008 at 9:48 AM, Torsten Mohr wrote: > Hi, > > i found some examples when googling for the subject but nothing really > matched. > > Is there a standard module available that lets me parse a syntax like "C" > with numbers, operators, braces, variables and function calls? Try pypar

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Michel Claveau - NoSpam SVP ; merci
Hi! I noted, also, than, in some cases, Python26.dll is not copied in %WINDIR%\system32 After that, external softs don't find the DLL. But it's a detail, because it's easy to copy the DLL with install scripts. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/pytho

parse C expression?

2008-12-15 Thread Torsten Mohr
Hi, i found some examples when googling for the subject but nothing really matched. Is there a standard module available that lets me parse a syntax like "C" with numbers, operators, braces, variables and function calls? I'd like to use this to parse an own kind of configuration language and pre

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Michel Claveau - NoSpam SVP ; merci
Hi! Thank you very much for your answer. I appreciate many to receive an answer of somebody as you. But I, always, install Python 2.6.1 "for all users" (and, on Vista, UAC is always deactivated). After some tests, the problem seems a bit more complex: call the Python-COM-servers run OK, fr

Re: tricky nested list unpacking problem

2008-12-15 Thread bearophileHUGS
Arnaud Delobelle: > Here is a not thought out solution: >... I was waiting to answer because so far I have found a bad-looking solution only. Seeing there's only your solution, I show mine too. It seems similar to your one. def xflatten(seq): if isinstance(seq, list): stack = [iter(se

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Martin v. Löwis
>> Try installing Python 2.6.1 "for all users". > > Could you clarify why that's needed? I didn't say it's needed. I said that he should try that, perhaps it helps. > One thing we noticed (I'm not sure has this been yet submitted to > bugs.python.org yet) was that installing packages created wit

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Pekka Klärck
2008/12/15 "Martin v. Löwis" : >> I am very disappointed. Help me, please. > > Try installing Python 2.6.1 "for all users". Could you clarify why that's needed? Link to a relevant bug report or something similar is enough. We've got some weird problems installing Python packages (win32.exe) on Wi

Re: Need help improving number guessing game

2008-12-15 Thread Bruno Desthuilliers
feba a écrit : Alright! This is feeling more like it. #!/usr/bin/python #Py3k, UTF-8 import random (snip) def youwin(game): if game['pnum'] == 1: print("CONGRATULATIONS! IT TOOK YOU %s GUESSES" % game ['gcount']) else: if game['player'] == game['player1']:

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Lie Ryan
On Mon, 15 Dec 2008 11:53:40 -0800, Carl Banks wrote: > > (...For that matter, if the rule had been, "Never augment your words > spelling with an apostrophe", it would have really simplified > things) Th next dae, wee aul wil bee speling liek this -- http://mail.python.org/mailman/listinfo/

Re: Need help improving number guessing game

2008-12-15 Thread feba
Spent a bit more time looking over suggestions and working out some annoyances. import random def customrange(game, lowunsafe=True): game['defrang'] = False #Keeps setup from changing range to defaults while lowunsafe: #makes sure that the low number is positive picklow = int(inp

OpenOpt 0.21 (free optimization framework)

2008-12-15 Thread dmitrey
Hi all, OpenOpt 0.21, free optimization framework (license: BSD) with some own solvers and connections to tens of 3rd party ones, has been released. All details here: http://openopt.blogspot.com/2008/12/openopt-release-021.html Regards, OpenOpt developers. -- http://mail.python.org/mailman/listi

Re: tricky nested list unpacking problem

2008-12-15 Thread Scott David Daniels
Kirk Strauser wrote: At 2008-12-15T19:06:16Z, Reckoner writes: The problem is that I don't know ahead of time how many lists there are or how deep they go. In other words, you could have: Recursion is your friend. Write a function to unpack one "sublist" and call itself again with the new l

Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Bruno Desthuilliers
Joe Strout a écrit : On Dec 15, 2008, at 6:46 AM, Krishnakant wrote: in this case, I get a problem when there is ' in any of the values during insert or update. That's because ' is the SQL string literal delimiter. But any SQL-compliant database allows you to "escape" an apostrophe within a

Re: weird dict problem, how can this even happen?

2008-12-15 Thread Duncan Booth
Joel Hedlund wrote: > I would very much like an explanation to this that does not involve > threads, because I haven't made any that I'm aware of. I can't even > understand how this could happen. How do I even debug this? > It could happen quite easily if the hash value of the object has chang

Re: Removing None objects from a sequence

2008-12-15 Thread J. Cliff Dyer
On Mon, 2008-12-15 at 02:11 +, Lie Ryan wrote: > On Fri, 12 Dec 2008 22:55:20 +, Steven D'Aprano wrote: > > > On Fri, 12 Dec 2008 21:18:36 +, Lie Ryan wrote: > >> Personally, I'd prefer VB's version: > >> foo IsNot bar > >> > >> or in pseudo-python > >> foo isnot bar > >> > >> since

Insatlling python on compute-node-linux (Cray).

2008-12-15 Thread Rahul
Has anyone tried installing Python on Compute Node Linux (on a cray)? I was having trouble getting it running. I see that CNL does not support dynamic libraries but I am not sure what the best way then is to get Python running. Any tips? -- Rahul -- http://mail.python.org/mailman/listinfo/pyt

weird dict problem, how can this even happen?

2008-12-15 Thread Joel Hedlund
I'm having a very hard time explaining why this snippet *sometimes* raises KeyError: snippet: print type(self.pool) for frag in self.pool.keys(): if frag is fragment_info: print "the fragment_info *is* in the pool", hash(frag), hash(fragment_info), hash(frag) == hash(fragment_info)

Re: Limit traceback from most recent call

2008-12-15 Thread Brian Allen Vanderburg II
yinon...@gmail.com wrote: On Dec 14, 8:07 pm, Brian Allen Vanderburg II wrote: Hi, The interface of extract_tb is: traceback.extract_tb(tb, limit=None) try to play with the 'limit' argument Good luck, Yinon -- http://mail.python.org/mailman/listinfo/python-list I have, but the limit

Re: Problem Python 2.6.1 vs 2.6 & pyWin32

2008-12-15 Thread Martin v. Löwis
> I am very disappointed. Help me, please. Try installing Python 2.6.1 "for all users". Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread Marc 'BlackJack' Rintsch
On Mon, 15 Dec 2008 12:27:12 -0800, cmdrrickhun...@yaho.com wrote: > On Dec 15, 11:10 am, Terry Reedy wrote: >> > In general, I'm using indentation to show logical flow through code. >> >> That, of course, is what Python does. >> > Python does NOT use indentation to show logical flow. It uses it

Re: How can I return a non-zero status result from a python script?

2008-12-15 Thread Rob Williscroft
silverburgh.me...@gmail.com wrote in news:74b53da4-bf07-431b-898b- 49977f7a6...@r36g2000prf.googlegroups.com in comp.lang.python: > Hi > > How can I return a non-zero status result from the script? Just do a > return 1? at the end? > >>> import sys >>> help( sys.exit ) Help on built-in function

Re: How can I return a non-zero status result from a python script?

2008-12-15 Thread Marc 'BlackJack' Rintsch
On Mon, 15 Dec 2008 13:12:08 -0800, silverburgh.me...@gmail.com wrote: > How can I return a non-zero status result from the script? Just do a > return 1? at the end? ``sys.exit(42)`` Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem accessing a web page

2008-12-15 Thread Antoni Mont
Tim Chase wrote: > When you get the second page, are you getting the same content > back that you get if you do a search in your favorite browser? > > Using just > >content = urllib.urlopen(url2).read() >'Error' in content # True >'Friedrich' in content # False > > However, when you

Re: tricky nested list unpacking problem

2008-12-15 Thread Arnaud Delobelle
Reckoner writes: > Hi, > > I have lists of the following type: > > [1,2,3,[5,6]] > > and I want to produce the following strings from this as > > '0-1-2-3-5' > '0-1-2-3-6' > > That was easy enough. The problem is that these can be nested. For > example: > > [1,2,3,[5,6],[7,8,9]] > > which should

Re: Need help improving number guessing game

2008-12-15 Thread feba
I added the ability to select your own range. It takes two new modules: def customrange(game, lowunsafe=True): game['defrang'] = False #Keeps setup from changing range to defaults while lowunsafe: #makes sure that the low number is positive picklow = int(input("PLEASE PICK THE LOW

How can I return a non-zero status result from a python script?

2008-12-15 Thread silverburgh.me...@gmail.com
Hi How can I return a non-zero status result from the script? Just do a return 1? at the end? -- http://mail.python.org/mailman/listinfo/python-list

Re: stable algorithm with complexity O(n)

2008-12-15 Thread cmdrrickhun...@yaho.com
Just because its such an interesting problem, I'll take a stab at it. It can be proven that you cannot sort an arbitrarily large set of numbers, given no extra information, faster than O(n log n). It is provable using information theory. However, if your teacher is giving you evil problems, ther

Re: Problem accessing a web page

2008-12-15 Thread Tim Chase
I'm able to grab the problem webpage via Python just fine, albeit with a bit of a delay. So, don't know what your exact problem is, maybe your connection? When you get the second page, are you getting the same content back that you get if you do a search in your favorite browser? Using just

Re: Managing timing in Python calls

2008-12-15 Thread cmdrrickhun...@yaho.com
I believe WxTimerEvent is handled using the event queue, which isn't going to do what you want. An event which goes through the queue does not get processed until you return to the queue. What you want to do is actually a rather difficult task to do generically. Should the task be interrupted im

Re: tricky nested list unpacking problem

2008-12-15 Thread Kirk Strauser
At 2008-12-15T20:03:14Z, "Chris Rebert" writes: > You just need a recursive list-flattening function. There are many > recipes for these. Here's mine: flattened = flatten([1,2,3,[5,6,[10, 11]],7,[9,[1, 2, 3, 4, 5 ]]]) flattened > [1, 2, 3, 5, 6, 10, 11, 7, 9, 1, 2, 3, 4, 5] '-'.jo

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread cmdrrickhun...@yaho.com
On Dec 15, 11:10 am, Terry Reedy wrote: > > In general, I'm using indentation to show logical flow through code. > > That, of course, is what Python does. > Python does NOT use indentation to show logical flow. It uses it to show syntactical flow. The XML writer is the perfect example of a case

Python plugin for Netbeans

2008-12-15 Thread a
Netbeans added a python plugin to its plugin repository. Do you tried it? What do you think about this plugin? -- http://mail.python.org/mailman/listinfo/python-list

Re: tricky nested list unpacking problem

2008-12-15 Thread Kirk Strauser
At 2008-12-15T19:06:16Z, Reckoner writes: > The problem is that I don't know ahead of time how many lists there are or > how deep they go. In other words, you could have: Recursion is your friend. Write a function to unpack one "sublist" and call itself again with the new list. For instance, s

Re: Problem accessing a web page

2008-12-15 Thread Chris Rebert
On Mon, Dec 15, 2008 at 11:55 AM, Antoni Mont wrote: > Hi all, > > My apologises if this is not the appropriate group. > > I'd like to access a web site from a python script. That page, in fact, > is a form of main page. With a browser (Firefox, for instance) I can do > it without problem: I open

Simple multithreaded profiler using decorators fails on some built-in methods

2008-12-15 Thread k3xji
Hi all, I have written a simple multithreaded profiler using decorators. Below is how it works: 1) Iterate all modules in sys.modules and iterate each function/ class methods inside them, means all of them including built-in methods. 2) Decorate the methods and functions to a global function. 3)

Re: tricky nested list unpacking problem

2008-12-15 Thread Chris Rebert
On Mon, Dec 15, 2008 at 11:06 AM, Reckoner wrote: > Hi, > > I have lists of the following type: > > [1,2,3,[5,6]] > > and I want to produce the following strings from this as > > '0-1-2-3-5' > '0-1-2-3-6' > > That was easy enough. The problem is that these can be nested. For > example: > > [1,2,3,

Problem accessing a web page

2008-12-15 Thread Antoni Mont
Hi all, My apologises if this is not the appropriate group. I'd like to access a web site from a python script. That page, in fact, is a form of main page. With a browser (Firefox, for instance) I can do it without problem: I open the main web whose url is: 'http://www.mcu.es/webISBN/tituloSimpl

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Carl Banks
On Dec 15, 1:55 am, Ben Finney wrote: > James Stroud writes: > > Ben Finney wrote: > > > James Stroud writes: > > > >> Yes. I think it was the British who decided that the apostrophe > > >> rule for "it" would be reversed from normal usage relative to > > >> just about every other noun. > > It a

Re: Removing None objects from a sequence

2008-12-15 Thread Scott David Daniels
Steven D'Aprano wrote: On Fri, 12 Dec 2008 19:02:24 -0500, Terry Reedy wrote: ... Tim Chase wrote: If you want to literally remove None objects from a list(or mutable sequence) def deNone(alist): n=len(alist) i=j=0 while i < n: if alist[i] is not None: alist[j] = alist

Re: Rename of .mdb file -- lock

2008-12-15 Thread MRAB
Scott David Daniels wrote: noydb wrote: I have the code below, which unzips a zipfile containing only one file. Once it is unzipped, I want to rename the file based on a user provided name. But I get this (WindowsError: [Error 32] The process cannot access the file because it is being used by

tricky nested list unpacking problem

2008-12-15 Thread Reckoner
Hi, I have lists of the following type: [1,2,3,[5,6]] and I want to produce the following strings from this as '0-1-2-3-5' '0-1-2-3-6' That was easy enough. The problem is that these can be nested. For example: [1,2,3,[5,6],[7,8,9]] which should produce '0-1-2-3-5-7' '0-1-2-3-5-8' '0-1-2-3-

Re: Rename of .mdb file -- lock

2008-12-15 Thread Scott David Daniels
noydb wrote: I have the code below, which unzips a zipfile containing only one file. Once it is unzipped, I want to rename the file based on a user provided name. But I get this (WindowsError: [Error 32] The process cannot access the file because it is being used by another process) error, whic

os.environ.get('SSH_ORIGINAL_COMMAND') returns None

2008-12-15 Thread Tzury Bar Yochay
Trying to follow a technique found at bzr I did the following added to ~/.ssh/authorized_keys the command="my_parder" parameter which point to a python script file named 'my_parser' and located in / usr/local/bin (file was chmoded as 777) in that script file '/usr/local/bin/my_parser' I got the

Re: stable algorithm with complexity O(n)

2008-12-15 Thread Terry Reedy
Dan Upton wrote: And if n is small and sparse (ie, k > n) , O(k*n) for radix sort could be worse than O(n^2). You could also ask why people make such a big deal about quicksort over mergesort, since mergesort has a guaranteed O(n log n) time whereas quicksort can be O(n^2) on pathological cases

Re: Need help improving number guessing game

2008-12-15 Thread feba
Alright! This is feeling more like it. #!/usr/bin/python #Py3k, UTF-8 import random def setup(game, minr=1, maxr=99): #minr, maxr make minimum and maximum. Can be adjusted. game['minr'], game['maxr'] = minr, maxr game['gcount'] = 0 #Reset guess count game['target'] = random.randin

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread Terry Reedy
cmdrrickhun...@yaho.com wrote: I've been trying to search through the years of Python talk to find an answer to this, but my Googlefu is weak. In most languages, I'll do something like this xmlWriter.BeginElement("parent"); xmlWriter.BeginElement("child"); --xml.Writer.Characters("s

pexpect and inconsistent exit values

2008-12-15 Thread Heikki Toivonen
I don't seem to be able to figure out how to get the exit values of commands executed with pexpect reliably. Here's first with regular shell: hei...@ubuntu:~$ true; echo $? 0 Let's try with pexpect. Below is the program: ---CLIP--- import sys, pexpect cmd = "true" print 'cmd=', cmd child = pe

Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Krishnakant
Hi steve. you are right. Thanks for all you who helped to understand how to and *not* to pass queries through psycopg2 which is a module based on python dbapi. the following query worked. cursor.execute("insert into vendors values(%s,%s)", lstParams) lstParams contained all the values and yes one h

Wing IDE 3.1.6 released

2008-12-15 Thread Wingware
Hi, Wingware has released version 3.1.6 of Wing IDE, a bugfix release for all three product levels of Wing IDE. *Release Highlights* This release includes the following: * Added previously missing support for x64 Python on Windows * Avoid auto-starting batch searches when a project is opened *

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread Marek_SP
On 15 Gru, 18:14, MRAB wrote: > cmdrrickhun...@yaho.com wrote: > > I've been trying to search through the years of Python talk to find an > > answer to this, but my Googlefu is weak. > > > In most languages, I'll do something like this > > > xmlWriter.BeginElement("parent"); > > xmlWriter.Begi

Re: %s place holder does not let me insert ' in an sql query with python.

2008-12-15 Thread Steve Holden
Lamonte Harris wrote: > I had this problem too. If you've upgraded to python 2.6 you need to > use the new sytnax "format > > queryString = "insert into venders > values('{0}','{1}','{2}'".format(field1,field2,field3) > Will all readers of this thread kindly regard this as an example of how *not

Re: regex problem ..

2008-12-15 Thread Steve Holden
Analog Kid wrote: > Hi All: > I am new to regular expressions in general, and not just re in python. > So, apologies if you find my question stupid :) I need some help with > forming a regex. Here is my scenario ... > I have strings coming in from a list, each of which I want to check > against a r

Re: Structure using whitespace vs logical whitespace

2008-12-15 Thread MRAB
cmdrrickhun...@yaho.com wrote: I've been trying to search through the years of Python talk to find an answer to this, but my Googlefu is weak. In most languages, I'll do something like this xmlWriter.BeginElement("parent"); xmlWriter.BeginElement("child"); --xml.Writer.Characters("s

Re: Getting in to metaprogramming

2008-12-15 Thread eric_dex...@msn.com
On Nov 27, 9:56 pm, "Hendrik van Rooyen" wrote: >  "Steven D'Aprano" > > >GUI designer. You write a program to let the user create code by clicking > >buttons, dragging objects, drawing lines, etc. The GUI designer may use > >classes, but the purpose of those classes is to generate source code. >

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Steve Holden
Tim Chase wrote: > Steve Holden wrote: >> This led to a schism between the British and the >> newly-independent Americans, who responded by taking the "u" >> out of colour, valour, and aluminium. > > Darn Americans and their alminim ;-) > > Next thing you know, they'll be putting an I in TEAM

Re: XMPP xmpppy - User Authorization

2008-12-15 Thread Henson
On Dec 14, 4:23 am, "James Mills" wrote: > On Sun, Dec 14, 2008 at 3:47 PM, Henson wrote: > > In my own bot, using the latestxmpppy, I've been printing everything > > going to the message handler to the screen.  I've yet to see a > > 'subscribe' string.  Has this changed? > > No this hasn't chang

Re: Limit traceback from most recent call

2008-12-15 Thread Ethan Furman
Brian Allen Vanderburg II wrote: I've looked at traceback module but I can't find how to limit traceback from the most recent call if it is possible. I see that extract_tb has a limit parameter, but it limits from the start and not the end. Currently I've made my own traceback code to do this

pylab.ylabel: put label on the other side

2008-12-15 Thread Antoine De Groote
Hey everybody, I'm plotting graphs with 2 y-axes, which I created using ax_left = pylab.subplot(111) ax_right = pylab.twinx() Then I switch the sides of the ticks: ax_left.yaxis.tick_right() ax_right.yaxis.tick_left() This works, the ticks are on the opposite sides (left axis ticks are on the

Re: Managing timing in Python calls

2008-12-15 Thread Ross
bieff...@gmail.com wrote: Python has in its standard library a timer class which actually is implemented as a thread (I think) ... however, when using a GUI package, I think it is better to use gui- specific functions for event-driven programming, to make sure that your code do not mess with GUI

Structure using whitespace vs logical whitespace

2008-12-15 Thread cmdrrickhun...@yaho.com
I've been trying to search through the years of Python talk to find an answer to this, but my Googlefu is weak. In most languages, I'll do something like this xmlWriter.BeginElement("parent"); xmlWriter.BeginElement("child"); --xml.Writer.Characters("subtext"); xmlWriter.EndElemen

Re: stable algorithm with complexity O(n)

2008-12-15 Thread Dan Upton
On Mon, Dec 15, 2008 at 11:05 AM, wrote: >> Non-comparison sorts are a useful technique, but it's changing the >> problem, and they are only useful in very limited circumstances. There's >> a good reason that most sort routines are based on O(n*log n) comparison >> sorts instead of O(n) bucket so

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread MRAB
Tim Chase wrote: Steve Holden wrote: This led to a schism between the British and the newly-independent Americans, who responded by taking the "u" out of colour, valour, and aluminium. Darn Americans and their alminim ;-) Next thing you know, they'll be putting an I in TEAM.[1] -tkc

Re: Managing timing in Python calls

2008-12-15 Thread bieffe62
On 15 Dic, 16:21, Ross wrote: > I'm porting some ugly javascript managed stuff to have an equivalent > behaviour in a standalone app. It uses events that arrive from a server, > and various small images.  In this standalone version, the data is local > in a file and the images in a local directory

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread MRAB
Steve Holden wrote: Ben Finney wrote: James Stroud writes: Ben Finney wrote: James Stroud writes: Yes. I think it was the British who decided that the apostrophe rule for "it" would be reversed from normal usage relative to just about every other noun. It also seems an indefensible claim

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Tim Chase
Steve Holden wrote: This led to a schism between the British and the newly-independent Americans, who responded by taking the "u" out of colour, valour, and aluminium. Darn Americans and their alminim ;-) Next thing you know, they'll be putting an I in TEAM.[1] -tkc [1] http://www.quo

Re: stable algorithm with complexity O(n)

2008-12-15 Thread pruebauno
On Dec 15, 11:05 am, prueba...@latinmail.com wrote: > > Non-comparison sorts are a useful technique, but it's changing the > > problem, and they are only useful in very limited circumstances. There's > > a good reason that most sort routines are based on O(n*log n) comparison > > sorts instead of O

Re: 1 or 1/0 doesn't raise an exception

2008-12-15 Thread Grant Edwards
On 2008-12-14, Peter Otten <__pete...@web.de> wrote: > Grant Edwards wrote: > >> Short circuit evaluation of booleans is very common (and has >> been for decades), so I don't know why people would expect >> something else. > > Visual Basic ;) I should have known... -- Grant Edwards

Re: stable algorithm with complexity O(n)

2008-12-15 Thread pruebauno
> Non-comparison sorts are a useful technique, but it's changing the > problem, and they are only useful in very limited circumstances. There's > a good reason that most sort routines are based on O(n*log n) comparison > sorts instead of O(n) bucket sorts or radix sorts. > This is an assumption tha

Re: Having Issues with CMD and the 'python' command

2008-12-15 Thread Benjamin Kaplan
On Mon, Dec 15, 2008 at 8:13 AM, wrote: > On Mon, 15 Dec 2008 at 23:01, James Mills wrote: > >> On Mon, Dec 15, 2008 at 10:51 PM, Lamonte Harris >> wrote: >> >>> Every time I start cmd on windows it requires me to "set >>> path=%path%;C:\python26" why? I'm getting annoyed... >>> >> >> "cmd" has

  1   2   >