Re: Ideas for a module to process command line arguments

2011-01-13 Thread Michele Simionato
On Jan 12, 6:09 pm, Alice Bevan–McGregor wrote: > entirely sure what you mean by 'smart' options.  If your'e referring to > using a single hyphen and a list of characters to represent a long > option (which, to the rest of the world, use two leading hyphens) then > that's pretty weird.  ;) > > One

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread DevPlayer
lst = [1, 2, 3, 4, 5] def maketup(lst): cur_item = lst[-1] lst = lst[:-1] if len(lst): return maketup(lst), cur_item else: return cur_item print maketup(lst) 1, 2), 3), 4), 5) But I'm confused as to what you mean by : > Among them, I want to pair up terminals

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread DevPlayer
def maketup(lst): if len(lst) == 1: return lst[0] elif len(lst) == 2: return (lst[0],lst[1]) elif len(lst) > 2: return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) maketup(lst) 1, 2), 3), 4), 5) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
justin writes: > Suppose I have [1,2,3,4,5], then there are many ways of making > clustering. > Among them, I want to pair up terminals until there is only one left > at the end. Are you trying "ascending hierarchical clustering" by any chance? In that case you're supposed to use some kind of di

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
DevPlayer writes: > def maketup(lst): > > if len(lst) == 1: > return lst[0] > > elif len(lst) == 2: > return (lst[0],lst[1]) > > elif len(lst) > 2: > return ( (maketup(lst[:-2]), lst[-2]), lst[-1]) The OP wants all binary trees over the elements, not just one.

File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs

2011-01-13 Thread dzizes451
Hello! I wrote a python (2.6) deamon running on linux. Program (deamon, manager) collects lets say work-orders from db and creates sub- processes for each one. Sub-processes do their job with out problems, errors, exceptions. However, sometimes deamon throws: Traceback (most recent call last):

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread DevPlayer
tuple([ (tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]]) ((1, 2), (3, 4), 5) # or x = ((tuple(lst[x-1:x+1]) if len(tuple(lst[x-1:x+1]))==2 else lst[x-1]) for x in lst[::2]) x.next() (1, 2) x.next() (3, 4) x.next() 5 -- http://mail.python.org/mailman/listinf

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread DevPlayer
Ah. out of my depth. -- http://mail.python.org/mailman/listinfo/python-list

Re: cipher encoding

2011-01-13 Thread Krzysztof Bieniasz
> Dear all, > > I hope someone out there can help me. > > The output string of my code is close to what i need, but i need it > 1)printed on one line and > 2) reversed > > #mycode: > s= input("Enter message: ") > key=1 > for letter in s: > num=(chr(ord(letter)+1)) > print(num) > #or

Re: Nested structures question

2011-01-13 Thread Jean-Michel Pichavant
Physics Python wrote: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number betw

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Richard Thomas
On Jan 13, 10:02 am, Alain Ketterlin wrote: > justin writes: > > Suppose I have [1,2,3,4,5], then there are many ways of making > > clustering. > > Among them, I want to pair up terminals until there is only one left > > at the end. > > Are you trying "ascending hierarchical clustering" by any ch

Re: Career path - where next?

2011-01-13 Thread Hank Fay
I would second the recommendation for Django: on LinkedIn, the python jobs postings (there is a Python group there) most often mention Django. I also would second the recommendation to participate in open source projects. I met a couple of days ago with a college sophomore who is a core contrib

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Alain Ketterlin
Richard Thomas writes: > On Jan 13, 10:02 am, Alain Ketterlin >> def clusterings(l): >>     if len(l) == 1: >>         print repr(l) >>     else: >>         n = len(l) >>         for i in xrange(n): >>             for j in xrange(i+1,n): >>                 clusterings(l[:i]+l[i+1:j]+l[j+1:]+[[l

Re: File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs

2011-01-13 Thread Terry Reedy
On 1/13/2011 5:28 AM, dzizes451 wrote: Hello! I wrote a python (2.6) deamon running on linux. Program (deamon, manager) collects lets say work-orders from db and creates sub- processes for each one. Sub-processes do their job with out problems, errors, exceptions. However, sometimes deamon throw

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Richard Thomas
On Jan 13, 3:59 pm, Alain Ketterlin wrote: > Richard Thomas writes: > > On Jan 13, 10:02 am, Alain Ketterlin > >> def clusterings(l): > >>     if len(l) == 1: > >>         print repr(l) > >>     else: > >>         n = len(l) > >>         for i in xrange(n): > >>             for j in xrange(i+1,n

Re: Career path - where next?

2011-01-13 Thread Ethan Furman
Hank Fay wrote: > ... From a selfish (to you and to me ) perspective, may I suggest > the pyjamas (pyjs.org) project and accompanying visual designer > (http://pyjsglade.sourceforge.net), which brings the GWT widgets > to Python, for desktop and web apps. Selfish to me because I'm > porting o

troubles compiling pythonwebkit

2011-01-13 Thread Dave
Hello Python enthusiasts, I'm trying to install the "Python Webkit DOM Bindings" (http://www.gnu.org/software/pythonwebkit/) but am not successful. The trouble starts when trying to 'make' pywebkitgtk. I've tried the prepatched version and downloading and patching myself. In both case the 'm

how to use priority queue with multiprocessing

2011-01-13 Thread Marco Hornung
Hey, -- question -- How can I use a priority queue to schedule jobs within the "multiprocessing pool" module? -

Re: apscheduler error

2011-01-13 Thread Hesham
In cases like that instead of sleep() can use pause(). E.g., from apscheduler.scheduler import Scheduler import signal sched = Scheduler() sched.start() def some_job(): print "Decorated job" sched.add_interval_job(some_job,minutes=1) signal.pause() Mosalam -- http://mail.python.org/mailman/

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Arnaud Delobelle
Peter Otten <__pete...@web.de> writes: > justin wrote: > >> The title sounds too complex, but my question is actually simple. >> >> Suppose I have [1,2,3,4,5], then there are many ways of making >> clustering. >> Among them, I want to pair up terminals until there is only one left >> at the end.

python 3 and Unicode line breaking

2011-01-13 Thread leoboiko
Hi, Is there an equivalent to the textwrap module that knows about the Unicode line breaking algorithm (UAX #14, http://unicode.org/reports/tr14/ )? -- http://mail.python.org/mailman/listinfo/python-list

GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread bolega
Basically, I have spent a few hours experimenting and searching on the comp.unix.shell how to break a command with several switches into more than one line AND to be able to put some comment on each line. #!/bin/bash -xv command \ # comment1 -sw1 \ # comment2 -sw2 \ # com

Re: GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread Chris Rebert
On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command    

Re: GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread Berthold Höllmann
bolega writes: > Basically, I have spent a few hours experimenting and searching on the > comp.unix.shell > > how to break a command with several switches into more than one line > AND to be able to put some comment on each line. > > #!/bin/bash -xv > > command \ # comment1 > -sw1

Re: GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread David W. Hodgins
On Thu, 13 Jan 2011 16:18:31 -0500, bolega wrote: how to break a command with several switches into more than one line AND to be able to put some comment on each line. command \ # comment1 -sw1 \ # comment2 Not what you want to hear, but that will not work. With the above, the

Re: python 3 and Unicode line breaking

2011-01-13 Thread Steven D'Aprano
On Thu, 13 Jan 2011 12:45:31 -0800, leoboiko wrote: > Hi, > > Is there an equivalent to the textwrap module that knows about the > Unicode line breaking algorithm (UAX #14, > http://unicode.org/reports/tr14/ )? Is access to Google blocked where you are, or would you just like us to do your sea

Multiple independently started python processes and sharing of a module

2011-01-13 Thread Martin P. Hellwig
Hi all, I have the following problem (which I already have a hacked around solution that works but I'd would like some more input on it): I have a situation where multiple python processes are started independently from each other but by the same user with the same environment (as happens wi

Re: GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread Steven D'Aprano
On Thu, 13 Jan 2011 13:49:06 -0800, Chris Rebert wrote: > On Thu, Jan 13, 2011 at 1:18 PM, bolega wrote: >> Basically, I have spent a few hours experimenting and searching on the >> comp.unix.shell [...] > This doesn't seem to have anything whatsoever to do with Python... Well, I launch Python s

Re: Trying to parse a HUGE(1gb) xml file

2011-01-13 Thread Aahz
In article , Stefan Behnel wrote: > >Try > > import xml.etree.cElementTree as etree > >instead. Note the leading "c", which hints at the C implementations of >ElementTree. It's much faster and much more memory friendly than the Python >implementation. Thanks! I updated our codebase this a

Re: Resolve circular reference

2011-01-13 Thread Magnus Lyckå
On 2011-01-07 03:24, moerchendiser2k3 wrote: Everything works fine, the problem starts when I start to make a circular reference in Python. I didn't quite grok your example, but concerning CPython GC & circular references... >>> import gc >>> class X: ... def __del__(self): ...

Re: How to read ansic file into a pre-defined class?

2011-01-13 Thread Magnus Lyckå
On 2011-01-08 04:24, Ying Zu wrote: How to read ansic file into a pre-defined class? I have a series of files written in the following format, ... You might like to take a look at the json module if you aren't locked to the exact format you suggested. http://json.org/ http://docs.python.org

Re: Multiple independently started python processes and sharing of a module

2011-01-13 Thread Kushal Kumaran
- Original message - > Hi all, > > I have the following problem (which I already have a hacked around > solution that works but I'd would like some more input on it): > > I have a situation where multiple python processes are started > independently from each other but by the same user

Re: GURU NEEDED : break a command into several lines and comment each line

2011-01-13 Thread Stefan Monnier
> #!/bin/bash -xv > command \ # comment1 > -sw1 \ # comment2 > -sw2 \ # comment3 > arguments > One ought to be able to comment every single switch if desired for > whatever reason. Thanks for the riddle. Here's a solution: command$(: # comment1 )

overplot while keeping the axes fixed

2011-01-13 Thread ZuYing
Hi folks, I was trying to split the frame into 2 panels using "subplot", fig = matplotlib.pyplot.figure() plt1 = fig.add_subplot(2,1,1 ) plt2 = fig.add_subplot(2,1,2 ) plt1.plot(x1, y1, 'g-') plt2.plot(x2, y2, 'g-') then I need to overplot other curves on each subplot panel using the same axes

Re: How to populate all possible hierarchical clusterings from a set of elements?

2011-01-13 Thread Peter Otten
Arnaud Delobelle wrote: > more simply: > > def clusters(l): > if len(l) == 1: > yield l[0] > return > for i in range(1, len(l)): > for left in clusters(l[:i]): > for right in clusters(l[i:]): > yield (left, right) > > That would give al