Re: Generate a sequence of random numbers that sum up to 1?

2006-04-22 Thread Gerard Flanagan
Gerard Flanagan wrote: > Gerard Flanagan wrote: > > Anthony Liu wrote: > > > I am at my wit's end. > > > > > > I want to generate a certain number of random numbers. > > > This is easy, I can repeatedly do uniform(0, 1) for > > > example

Re: problems when unpacking tuple ...

2006-04-22 Thread Gerard Flanagan
harold wrote: > Dear all, > > Maybe I stared on the monitor for too long, because I cannot find the > bug ... > My script "transition_filter.py" starts with the following lines: > > import sys > > for line in sys.stdin : > try : > for a,b,c,d in line.split() : > pass > >

Re: problems when unpacking tuple ...

2006-04-22 Thread Gerard Flanagan
harold wrote: > Thank you Gerard. > This must be the problem. Now I can get it working. Good! I got confused thinking about it too, but I think you just had one loop too many. for line in sys.stdin : try : a,b,c,d = line.split() not: for line in sys.stdin : try : for a

Re: Generate a sequence of random numbers that sum up to 1?

2006-04-23 Thread Gerard Flanagan
Nick Craig-Wood wrote: > Gerard Flanagan <[EMAIL PROTECTED]> wrote: > > def distribution(N=2): > > p = [0] + sorted( random.random() for _ in range(N-1) ) + [1] > > for j in range(N): > > yield p[j+1] - p[j] > > > > spread =

Re: bug in modulus?

2006-04-24 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > But maybe I'm reading it wrong. In any case what I wanted was simply a > way to extract the angle from a complex number where the angle is > between 0 and 2*pi. I think I'll just take the modulus twice. > > def angle(complex): > """Returns angle where 2*pi > angle >

Re: can anyone advise me

2006-04-27 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > why the output of this code : > x = 0 > while x < 10: > z = 0 > print x > x = x + 1 > while z < x: > print z, > z = z + 1 > > is > > 0 > 0 1 > 0 1 2 > 0 1 2 3 > 0 1 2 3 4 > 0 1 2 3 4 5 > 0 1 2 3 4 5 6 > 0 1

searching for an article on name-binding

2006-04-27 Thread Gerard Flanagan
Hello I'm trying to find a webpage I remember reading which contained a layman's description of how Python binds names to objects. It used some ASCII-art illustrations where an arrow represented a 'binding'. Anyone got a link for that? (Google's not my friend!) Thanks Gerard -- http://mail.pyt

Re: searching for an article on name-binding

2006-04-27 Thread Gerard Flanagan
Fredrik Lundh wrote: > Gerard Flanagan wrote: > > > I'm trying to find a webpage I remember reading which contained a > > layman's description of how Python binds names to objects. It used some > > ASCII-art illustrations where an arrow represented a 'b

Re: an error in commented code?

2006-04-28 Thread Gerard Flanagan
John Salerno wrote: > Here's my code, with the error following it: > > props = ['A', 'B', 'C', 'D'] > group1 = ['C', 'A', 'D', 'B', 17] > group2 = ['A', 'B', 'D', 'C', 32] > group3 = ['D', 'B', 'C', 'A', 34] > group4 = ['B', 'A', 'C', 'D', 17] > > # Submitter: Michael Davies > def all_perms(str):

From the Tutorial Wiki: suggested restructure

2006-04-30 Thread Gerard Flanagan
For anyone interested, here's a blog entry I've added over at the Tutorial Wiki: As mentioned by effbot in the previous post I've put together a suggested alternative factoring of the Tutorial here(http://pytut.infogami.com/gerard_refactor). At the minute i

Re: Dictionaries -- ahh the fun.. (newbie help)

2006-05-10 Thread Gerard Flanagan
rh0dium wrote: > Hi all, > > Can someone help me out. I am trying to determing for each run whether > or not the test should pass or fail but I can't seem to access the > results .. > > Alternatively can someone suggest a better structure ( and a lesson as > to the reasoning ) that would be great

Re: where do you run database scripts/where are DBs 'located'?

2006-05-12 Thread Gerard Flanagan
John Salerno wrote: > Ok, I've been browsing through the MySQLdb docs, and I *think* I know > the kind of code I need to write (connect, cursor, manipulate data, > commmit, etc. -- although I probably need to get more familiar with > actual SQL commands too), but here's my problem: I don't know whe

Re: comparing values in two sets

2006-05-15 Thread Gerard Flanagan
John Salerno wrote: > I'd like to compare the values in two different sets to test if any of > the positions in either set share the same value (e.g., if the third > element of each set is an 'a', then the test fails). > > I have this: > > def test_sets(original_set, trans_letters): > for pair

Re: comparing values in two sets

2006-05-15 Thread Gerard Flanagan
Gerard Flanagan wrote: > John Salerno wrote: > > I'd like to compare the values in two different sets to test if any of > > the positions in either set share the same value (e.g., if the third > > element of each set is an 'a', then the test fails). > &

Re: Python and Combinatorics

2006-05-16 Thread Gerard Flanagan
Nic wrote: > Hello, > I've a problem in defining a good Python code useful to articulate the > following algorithm. > Can you help me please? > Thanks a bunch, > Nic > > 1. Insert a number "n". > Example: 3 > > 2. List all the numbers < or = to n. > Example: 1,2,3. > > 3. Combine the listed number

Re: Proposal for new operators to python that add syntactic sugar for hierarcical data.

2006-05-18 Thread Gerard Flanagan
glomde wrote: > i I would like to extend python so that you could create hiercical [...] > # build a tree structure > root = ET.Element("html") > *!*root: > *!*head("head"): > *!*title("title): > *=*text = "Page Title" > *!*body("body"): > *=*b

Re: Newbie append() question

2006-05-18 Thread Gerard Flanagan
Brian Blazer wrote: > I promise that this is not homework. I am trying to self teach here > and have run into an interesting problem. I have created a method > that asks for a class name and then is supposed to add it to classes > []. Here is a snippet: > > def getCurrentClasses(): > cl

Generating Cutter numbers

2006-05-20 Thread Gerard Flanagan
All would anyone happen to have code to generate Cutter Numbers: eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm or is anyone looking for something to do?-) (I'm under pressure!) def cutter(lname, fname, book_title): (maybe more to it than that). cheers Gerard -- http:/

Re: combining a C# GUI with Python code?

2006-05-20 Thread Gerard Flanagan
John Salerno wrote: > Is it possible to construct a C# form (using Visual Studio) but write > only Python code for the events? Is there some way to tell your program > to run Python whenever code is run, since it will be all Python code > (e.g. for button presses, etc.)? > > I know it's sort of si

Re: Generating Cutter numbers

2006-05-20 Thread Gerard Flanagan
[EMAIL PROTECTED] wrote: > Gerard Flanagan wrote: > > All > > > > would anyone happen to have code to generate Cutter Numbers: > > > > eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm > > > > or is anyone looking for something to do

Re: Generating Cutter numbers

2006-05-22 Thread Gerard Flanagan
Terry Reedy wrote: > "Gerard Flanagan" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I'm cataloging a small library and want to generate a unique id (called > > a 'call number') for each book. This id is composed of: >

UPDATE: Generating Cutter numbers

2006-05-23 Thread Gerard Flanagan
Gerard Flanagan wrote: > All > > would anyone happen to have code to generate Cutter Numbers: > > eg. http://www1.kfupm.edu.sa/library/cod-web/Cutter-numbers.htm > > or is anyone looking for something to do?-) (I'm under pressure!) > > def cutter(lname, fname, bo

Re: starting some Python script from C#

2006-05-27 Thread Gerard Flanagan
tatamata wrote: > Hello. > > How can I run some Python script within C# program? > - ProcessStartInfo startInfo; Process process; string directory; string pyArgs;

Re: starting some Python script from C#

2006-05-28 Thread Gerard Flanagan
> "Gerard Flanagan" <[EMAIL PROTECTED]> je napisao u poruci interesnoj > grupi:[EMAIL PROTECTED] > > tatamata wrote: > >> Hello. > >> > >

Re: is there enough information?

2008-02-29 Thread Gerard Flanagan
On Feb 29, 7:55 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 28 Feb 2008 00:54:44 -0800 (PST), [EMAIL PROTECTED] declaimed > the following in comp.lang.python: > > > On Feb 28, 2:30 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > ### I smell Java burning... +1 QOTW "Mistah Kur

Re: joining strings question

2008-02-29 Thread Gerard Flanagan
On Feb 29, 7:56 pm, I V <[EMAIL PROTECTED]> wrote: > On Fri, 29 Feb 2008 08:18:54 -0800, baku wrote: > > return s == s.upper() > > A couple of people in this thread have used this to test for an upper > case string. Is there a reason to prefer it to s.isupper() ? Premature decreptiude, officer

Re: metaclasses

2008-03-03 Thread Gerard Flanagan
On Mar 4, 6:31 am, [EMAIL PROTECTED] wrote: > On Mar 3, 10:01 pm, Benjamin <[EMAIL PROTECTED]> wrote: > > > > > On Mar 3, 7:12 pm, [EMAIL PROTECTED] wrote: > > > > What are metaclasses? > > > Depends on whether you want to be confused or not. If you do, look at > > this old but still head bursting

Re: Removing default logging handler (causes duplicate logging)

2008-03-04 Thread Gerard Flanagan
On Mar 4, 1:29 pm, Gal Aviel <[EMAIL PROTECTED]> wrote: > Hello All, > > I want to add a logger to my application, then addHandler to it to log to a > special destination. > > Unfortunately when I use logging.getLogger("my_logger") to create the new > logger, it apparently comes with a default hand

Re: defining a method that could be used as instance or static method

2008-03-10 Thread Gerard Flanagan
On Mar 10, 4:39 pm, Sam <[EMAIL PROTECTED]> wrote: > Hello > > I would like to implement some kind of comparator, that could be > called as instance method, or static method. Here is a trivial pseudo > code of what I would like to execute > > >> class MyClass: > > ...def __init__(self, value):

Re: parsing directory for certain filetypes

2008-03-11 Thread Gerard Flanagan
On Mar 11, 6:21 am, royG <[EMAIL PROTECTED]> wrote: > On Mar 10, 8:03 pm, Tim Chase wrote: > > > In Python2.5 (or 2.4 if you implement the any() function, ripped > > from the docs[1]), this could be rewritten to be a little more > > flexible...something like this (untested): > > that was quite a g

Re: Script Request...

2008-03-20 Thread Gerard Flanagan
On Mar 19, 10:29 pm, some one <[EMAIL PROTECTED]> wrote: > Thanks Diez, I found some docs and examples on urllib2. Now how do i > search the string I get from urllib2, lets say I put it in "myURL", How > do I search for only Numbers and ".'s" in the "#.#.#.#" pattern. That > is all I am intereste

Re: Inheritance question

2008-03-25 Thread Gerard Flanagan
On Mar 25, 1:34 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > Rather than use Foo.bar(), use this syntax to call methods of the > > super class: > > > super(ParentClass, self).method() > > Hi Jeff, > here is the nw version which cause an error > > class Foo(object): > def __init__(self):

Re: Inheritance question

2008-03-25 Thread Gerard Flanagan
On Mar 25, 4:37 pm, Brian Lane <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Gerard Flanagan wrote: > > Use the child class when calling super: > > > -- > > class Foo(object): &g

Re: writing pickle function

2009-01-23 Thread Gerard Flanagan
On Jan 23, 2:48 pm, perfr...@gmail.com wrote: > hello, > > i am using nested defaultdict from collections and i would like to > write it as a pickle object to a file. when i try: > > from collections import defaultdict > x = defaultdict(lambda: defaultdict(list)) > > and then try to write to a pick

Re: ElementTree and clone element toot

2009-02-02 Thread Gerard Flanagan
Gabriel Genellina wrote: En Mon, 02 Feb 2009 12:37:36 -0200, Gerard Flanagan escribió: e = ET.fromstring(s) def clone(elem): ret = elem.makeelement(elem.tag, elem.attrib) ret.text = elem.text for child in elem: ret.append(clone(child)) return ret f = clone(e

Re: ElementTree and clone element toot

2009-02-02 Thread Gerard Flanagan
m.banaouas wrote: Hi all, Working with the ElementTree module, I looked for clone element function but not found such tool: def CloneElment(fromElem, destRoot = None) fromElem is the element to clone destRoot is the parent element of the new element ; if None so the new element will be child of

Re: Breaking Python list into set-length list of lists

2009-02-11 Thread Gerard Flanagan
Jason wrote: Hey everyone-- I'm pretty new to Python, & I need to do something that's incredibly simple, but combing my Python Cookbook & googling hasn't helped me out too much yet, and my brain is very, very tired & flaccid @ the moment I have a list of objects, simply called "list". I ne

Re: flexible find and replace ?

2009-02-17 Thread Gerard Flanagan
OdarR wrote: Hi guys, how would you do a clever find and replace, where the value replacing the tag is changing on each occurence ? "...TAGTAGTAG..TAG." is replaced by this : "...REPL01REPL02REPL03..REPL04..."

Re: flexible find and replace ?

2009-02-17 Thread Gerard Flanagan
Gerard Flanagan wrote: def replace(s, patt, repls): def onmatch(m): onmatch.idx += 1 return repls[onmatch.idx] onmatch.idx = -1 return patt.sub(onmatch, s) test = """ abcTAG TAG asdTAGxyz """ REPLS = [ 'REPL1', &#

Re: get most common number in a list with tolerance

2009-02-20 Thread Gerard Flanagan
Astan Chee wrote: Hi, I have a list that has a bunch of numbers in it and I want to get the most common number that appears in the list. This is trivial because i can do a max on each unique number. What I want to do is to have a tolerance to say that each number is not quite unique and if the

Re: Enumerating k-segmentations of a sequence

2008-11-25 Thread Gerard flanagan
bullockbefriending bard wrote: I'm not sure if my terminology is precise enough, but what I want to do is: Given an ordered sequence of n items, enumerate all its possible k- segmentations. This is *not* the same as enumerating the k set partitions of the n items because I am only interested in

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread Gerard flanagan
r wrote: To think...that I would preach freedom to the slaves and be lynched for it...IS MADNESS! Not one vote for Python, not a care. I think everyone here should look deep within their self and realize the damage that has been done today! I hope Guido's eyes never see this thread, for he may l

Re: HELP!...Google SketchUp needs a Python API

2008-11-27 Thread Gerard flanagan
alex23 wrote: On Nov 28, 4:32 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: http://en.wikipedia.org/wiki/Zero-sum#Complexity You're a far more generous soul than I am, I would've been more inclined to link to the following: http://en.wikipedia.org/wiki/Persecution_complex

Re: A more pythonic way of writting

2008-12-05 Thread Gerard flanagan
eric wrote: Hi, I've got this two pieces of code that works together, and fine def testit(): for vals in [[i&mask==mask for mask in [1<', flag(*vals) def flag(IGNORECASE=False, LOCALE=False, MULTILINE=False, DOTALL=False, UNICODE=False, VERBOSE=False): vals = [IGNORECASE, LOCALE, MULT

Re: Mathematica 7 compares to other languages

2008-12-11 Thread Gerard flanagan
Xah Lee wrote: On Dec 10, 2:47 pm, John W Kennedy <[EMAIL PROTECTED]> wrote: Xah Lee wrote: In lisp, python, perl, etc, you'll have 10 or so lines. In C or Java, you'll have 50 or hundreds lines. [...] Thanks to various replies. I've now gather code solutions in ruby, python, C, Java, here:

Re: "return" in def

2008-12-28 Thread Gerard Flanagan
On Dec 28, 5:19 pm, Roger wrote: > Hi Everyone, [...] > When I define a method I always include a return statement out of > habit even if I don't return anything explicitly: > > def something(): >         # do something >         return > > Is this pythonic or excessive?  Is this an unnecessary af

Re: Generator metadata/attributes

2009-01-08 Thread Gerard Flanagan
On Thu, 08 Jan 2009 08:42:55 -0600, Rob Williscroft wrote: > > def mydecorator( f ): > def decorated(self, *args): > logging.debug( "Created %s", self.__class__.__name__ ) > for i in f(self, *args): > yield i > return decorated > can optionally be written as: def mydecorator

Re: algorizm to merge nodes

2008-10-17 Thread Gerard flanagan
JD wrote: Hi, I need help for a task looks very simple: I got a python list like: [['a', 'b'], ['c', 'd'], ['e', 'f'], ['a', 'g'], ['e', 'k'], ['c', 'u'], ['b', 'p']] Each item in the list need to be merged. For example, 'a', 'b' will be merged, 'c', 'd' will be merged. Also if the node in

Re: Unyeilding a permutation generator

2008-11-04 Thread Gerard Flanagan
On Nov 3, 11:45 pm, [EMAIL PROTECTED] wrote: > > Thats interesting code but seems to give a different output, > suggesting thet the underlying algorithm is different. > Ignoring linebreaks and case, the original code gives: > abcd bacd bcad bcda acbd cabd cbad cbda acdb cadb cdab cdba abdc badc > b

Re: Clustering the keys of a dict according to its values

2008-11-16 Thread Gerard flanagan
Florian Brucker wrote: Florian Brucker wrote: Hi everybody! Given a dictionary, I want to create a clustered version of it, collecting keys that have the same value: >>> d = {'a':1, 'b':2, 'c':1, 'd':1, 'e':2, 'f':3} >>> cluster(d) {1:['a', 'c', 'd'], 2:['b', 'e'], 3:['f']} That is, gene

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Slaunger wrote: Hi all, I am a Python novice, and I have run into a problem in a project I am working on, which boils down to identifying the patterns in a sequence of integers, for example 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Anton Vredegoor wrote: On Fri, 21 Nov 2008 18:10:02 +0100 Gerard flanagan <[EMAIL PROTECTED]> wrote: data = ''' 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 6 6 1 9 3 3 0 3 3 0 3 3 0 3 3 0 10 6 6 1 6 6 1 6 6 1 6 6 1 6 6

Re: Best strategy for finding a pattern in a sequence of integers

2008-11-21 Thread Gerard flanagan
Slaunger wrote: Hi Gerard, This definitely looks like a path to walk along, and I think your code does the trick, although I have to play a little around with the groupby method, of which I had no prior knowledge. I think I will write some unit test cases to stress test you concept (on Monday, wh

Re: looking for template package

2009-03-04 Thread Gerard Flanagan
Neal Becker wrote: I'm looking for something to do template processing. That is, transform text making various substitutions. I'd like to be able to do substitutions that include python expressions, to do arithmetic computations within substitutions. I know there are lots of template packag

Re: Number of Packages in the "cheeseshop"

2009-03-05 Thread Gerard Flanagan
Michael Rudolf wrote: > Hi, I just wondered how many Packages are in the Python Package Index. fwiw http://bitbucket.org/djerdo/musette/src/tip/tools/download-pypi.py regards G. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help cleaning up some code

2009-03-07 Thread Gerard Flanagan
odeits wrote: I am looking to clean up this code... any help is much appreciated. Note: It works just fine, I just think it could be done cleaner. The result is a stack of dictionaries. the query returns up to STACK_SIZE ads for a user. The check which i think is very ugly is putting another con

Re: objectoriented -?- functional

2009-03-18 Thread Gerard Flanagan
Walther Neuper wrote: >>> def reverse_(list): ... """list.reverse() returns None; reverse_ returns the reversed list""" ... list.reverse() ... return list ... >>> ll = [[11, 'a'], [33, 'b']] >>> l = ll[:] # make a copy ! >>> l = map(reverse_, l[:]) # make a copy ? >>> ll.exte

Re: Automatically generating arithmetic operations for a subclass

2009-04-14 Thread Gerard Flanagan
Steven D'Aprano wrote: I have a subclass of int where I want all the standard arithmetic operators to return my subclass, but with no other differences: class MyInt(int): def __add__(self, other): return self.__class__(super(MyInt, self).__add__(other)) # and so on for __mul__,

Re: find sublist inside list

2009-05-05 Thread Gerard Flanagan
Matthias Gallé wrote: Hi. My problem is to replace all occurrences of a sublist with a new element. Example: Given ['a','c','a','c','c','g','a','c'] I want to replace all occurrences of ['a','c'] by 6 (result [6,6,'c','g',6]). For novelty value: from itertools import izip def replace2(da

Re: Producing multiple items in a list comprehension

2008-05-22 Thread Gerard flanagan
Joel Koltner wrote: Is there an easy way to get a list comprehension to produce a flat list of, say, [x,2*x] for each input argument? E.g., I'd like to do something like: [ [x,2*x] for x in range(4) ] ...and receive [ 0,0,1,2,2,4,3,6] ...but of course you really get a list of lists: [[0, 0

Re: Simple Doc Test failing without any reason [Help Needed]

2008-05-28 Thread Gerard Flanagan
On May 28, 1:48 pm, afrobeard <[EMAIL PROTECTED]> wrote: > The following following code fails with the failiure:- > > File "test.py", line 27, in __main__.sanitize_number > Failed example: > sanitize_number('0321-4683113') > Expected: > '03214683113' > Got: > '03214683113' > > Expected

Re: Removing inheritance (decorator pattern ?)

2008-06-16 Thread Gerard flanagan
George Sakkis wrote: I have a situation where one class can be customized with several orthogonal options. Currently this is implemented with (multiple) inheritance but this leads to combinatorial explosion of subclasses as more orthogonal features are added. Naturally, the decorator pattern [1]

Re: Removing inheritance (decorator pattern ?)

2008-06-17 Thread Gerard flanagan
Maric Michaud wrote: Le Monday 16 June 2008 20:35:22 George Sakkis, vous avez écrit : On Jun 16, 1:49 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: [...] variation of your toy code. I was thinking the Strategy pattern, different classes have different initialisation strategies? But th

Re: Docutils rst2html.py gives Unknown Directive type "toctree"

2008-06-29 Thread Gerard Flanagan
On Jun 19, 11:19 pm, "Calvin Cheng" <[EMAIL PROTECTED]> wrote: > Hi, > > I am attempting to convert a bunch of .txt files into html using the > docutils package. > > It works for most of the txt files except for the index.txt file which > gives 2 errors: > (1) Unknown Directive type "toctree" > (2

Re: ANN: XML builder for Python

2008-07-03 Thread Gerard flanagan
Jonas Galvez wrote: Not sure if it's been done before, but still... from __future__ import with_statement from xmlbuilder import builder, element xml = builder(version="1.0", encoding="utf-8") with xml.feed(xmlns='http://www.w3.org/2005/Atom'): xml.title('Example Feed') xml.link

Re: read file into list of lists

2008-07-11 Thread Gerard flanagan
antar2 wrote: Hello, I can not find out how to read a file into a list of lists. I know how to split a text into a list sentences = line.split(\n) following text for example should be considered as a list of lists (3 columns and 3 rows), so that when I make the print statement list[0] [0], tha

Re: Regular expression help

2008-07-18 Thread Gerard flanagan
[EMAIL PROTECTED] wrote: Hello, I am new to Python, with a background in scientific computing. I'm trying to write a script that will take a file with lines like c afrac=.7 mmom=0 sev=-9.56646 erep=0 etot=-11.020107 emad=-3.597647 3pv=0 extract the values of afrac and etot and plot them. I'm r

ANN: Google custom search engine for Python

2008-07-30 Thread Gerard flanagan
What is it? --- A Google custom search engine which targets only the following sites: + `The Hazel Tree `__ + `The Python standard library docs `__ + `The Python wiki `__ + `Python Package Index

Re: ANN: Google custom search engine for Python

2008-07-31 Thread Gerard flanagan
Gerard flanagan wrote: What is it? --- A Google custom search engine which targets only the following sites: + `The Hazel Tree <http://thehazeltree.org>`__ + `The Python standard library docs <http://docs.python.org/lib>`__ + `The Python wiki <http://wiki.python.or

Re: finding euclidean distance,better code?

2008-03-29 Thread Gerard Flanagan
On Mar 29, 11:01 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 29 Mar 2008 10:11:28 +0100, Roel Schroeven wrote: > > Steven D'Aprano schreef: > >> On Fri, 28 Mar 2008 16:59:59 +0100, Robert Bossy wrote: > > >>> Gabriel Genellina wrote: > That's what I said in anot

Re: Copy Stdout to string

2008-04-01 Thread Gerard Flanagan
On Apr 1, 4:03 pm, sophie_newbie <[EMAIL PROTECTED]> wrote: > Hi, I'm wondering if its possible to copy all of stdout's output to a > string, while still being able to print on screen. I know you can > capture stdout, but I still need the output to appear on the screen > also... > > Thanks! I don'

Re: Python-by-example - new online guide to Python Standard Library

2008-04-07 Thread Gerard Flanagan
On Apr 3, 8:33 pm, AK <[EMAIL PROTECTED]> wrote: > AK wrote: > > Hello, > > > I find that I learn easier when I go from specific examples to a more > > general explanation of function's utility and I made a reference guide > > that will eventually document all functions, classes and methods in > >

Re: subprocess.Popen() output to logging.StreamHandler()

2008-04-10 Thread Gerard Flanagan
On Apr 10, 2:11 pm, "sven _" <[EMAIL PROTECTED]> wrote: > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > My goal is to have stdout and stderr written to a logging handler. > This code does not work: > > # START > import logging, subprocess > ch = logging.StreamHandler() > ch.setLevel

Re: subprocess.Popen() output to logging.StreamHandler()

2008-04-10 Thread Gerard Flanagan
On Apr 10, 5:34 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > On Apr 10, 2:11 pm, "sven _" <[EMAIL PROTECTED]> wrote: > > > > > Version: Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12) > > > My goal is to have stdout and stderr written

Re: Rounding a number to nearest even

2008-04-11 Thread Gerard Flanagan
On Apr 11, 12:14 pm, bdsatish <[EMAIL PROTECTED]> wrote: > The built-in function round( ) will always "round up", that is 1.5 is > rounded to 2.0 and 2.5 is rounded to 3.0. > > If I want to round to the nearest even, that is > > my_round(1.5) = 2# As expected > my_round(2.5) = 2# No

Re: Rounding a number to nearest even

2008-04-11 Thread Gerard Flanagan
On Apr 11, 2:05 pm, Gerard Flanagan <[EMAIL PROTECTED]> wrote: > On Apr 11, 12:14 pm, bdsatish <[EMAIL PROTECTED]> wrote: > > > The built-in function round( ) will always "round up", that is 1.5 is > > rounded to 2.0 and 2.5 is rounded to 3.0. > > >

Re: manipulating class attributes from a decorator while the class is being defined

2008-04-21 Thread Gerard Flanagan
On Apr 19, 11:19 pm, Wilbert Berendsen <[EMAIL PROTECTED]> wrote: > Hi, is it possible to manipulate class attributes from within a decorator > while the class is being defined? > > I want to register methods with some additional values in a class attribute. > But I can't get a decorator to change

Re: Script to convert Tcl scripts to Python?

2008-04-23 Thread Gerard Flanagan
On Apr 23, 9:17 am, "Achillez" <[EMAIL PROTECTED]> wrote: > Hi, > > I have a 10k+ line Tcl program that I would like to auto convert over to > Python. Do any scripts exist that can convert ~90% of the standard Tcl > syntax over to Python? I know Python doesn't handle strings, but just for > general

Re: Ideas for parsing this text?

2008-04-24 Thread Gerard Flanagan
On Apr 24, 4:05 am, Paul McGuire <[EMAIL PROTECTED]> wrote: > On Apr 23, 8:00 pm, "Eric Wertman" <[EMAIL PROTECTED]> wrote: > > > I have a set of files with this kind of content (it's dumped from > > WebSphere): > > > [propertySet "[[resourceProperties "[[[description "This is a required > > prope

Re: Issue with regular expressions

2008-04-30 Thread Gerard Flanagan
On Apr 29, 3:46 pm, Julien <[EMAIL PROTECTED]> wrote: > Hi, > > I'm fairly new in Python and I haven't used the regular expressions > enough to be able to achieve what I want. > I'd like to select terms in a string, so I can then do a search in my > database. > > query = ' " some words" with an

Re: Formatting input text file

2008-08-14 Thread Gerard flanagan
[EMAIL PROTECTED] wrote: Hi, it's me again with tons of questions. I hava an input file structured like this: X XYData-1 1. 3.08333 2. 9.05526 3. 3.13581

Re: online tutorials?

2008-08-18 Thread Gerard Flanagan
On Aug 18, 12:53 am, Gits <[EMAIL PROTECTED]> wrote: > I want to learn how to program in python and would like to know if you > guys know of any free online tutorials.  Or is it too complicated to > learn from a site or books? Some texts and examples here: http://thehazeltree.org/ hth G. -- htt

Re: Filling in Degrees in a Circle (Astronomy)

2008-08-25 Thread Gerard flanagan
W. eWatson wrote: The other night I surveyed a site for astronomical use by measuring the altitude (0-90 degrees above the horizon) and az (azimuth, 0 degrees north clockwise around the site to 360 degrees, almost north again) of obstacles, trees. My purpose was to feed this profile of obstacle

Re: Identifying the start of good data in a list

2008-08-27 Thread Gerard flanagan
[EMAIL PROTECTED] wrote: I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry that is followed by at least 4 consecutive non-zero data items (i.e. a week's worth of non-zero da

Re: Identifying the start of good data in a list

2008-08-28 Thread Gerard flanagan
George Sakkis wrote: On Aug 27, 3:00 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: I have a list that starts with zeros, has sporadic data, and then has good data. I define the point at which the data turns good to be the first index with a non-zero entry t

Re: Counting Elements in an xml file

2008-08-31 Thread Gerard flanagan
Ouray Viney wrote: Hi All: I am looking at writing a python script that will let me parse a TestSuite xml file that contains n number of TestCases. My goal is to be able to count the elements base on a key value pair in the xml node. Example I would like to be able to count the number of T

Re: decorator and API

2008-09-18 Thread Gerard flanagan
Lee Harr wrote: I have a class with certain methods from which I want to select one at random, with weighting. The way I have done it is this import random def weight(value): def set_weight(method): method.weight = value return method return set_weight class A(o

Re: dict generator question

2008-09-18 Thread Gerard flanagan
Simon Mullis wrote: Hi, Let's say I have an arbitrary list of minor software versions of an imaginary software product: l = [ "1.1.1.1", "1.2.2.2", "1.2.2.3", "1.3.1.2", "1.3.4.5"] I'd like to create a dict with major_version : count. (So, in this case: dict_of_counts = { "1.1" : "1",

Re: dict generator question

2008-09-18 Thread Gerard flanagan
George Sakkis wrote: On Sep 18, 11:43 am, Gerard flanagan <[EMAIL PROTECTED]> wrote: Simon Mullis wrote: Hi, Let's say I have an arbitrary list of minor software versions of an imaginary software product: l = [ "1.1.1.1", "1.2.2.2", "1.2.2.3", "

Re: dict generator question

2008-09-19 Thread Gerard flanagan
Boris Borcic wrote: Gerard flanagan wrote: George Sakkis wrote: .. Note that this works correctly only if the versions are already sorted by major version. Yes, I should have mentioned it. Here's a fuller example below. There's maybe better ways of sorting version numbers, b

Re: Docstrings for class attributes

2008-09-23 Thread Gerard flanagan
George Sakkis wrote: On Sep 23, 1:23 am, "Tom Harris" <[EMAIL PROTECTED]> wrote: Greetings, I want to have a class as a container for a bunch of symbolic names for integers, eg: class Constants: FOO = 1 BAR = 2 Except that I would like to attach a docstring text to the constants, so

Re: Finding subsets for a robust regression

2008-09-29 Thread Gerard flanagan
[EMAIL PROTECTED] wrote: x1 = [] #unique instances of x and y y1 = [] #median(y) for each unique value of x for xx,yy in d.iteritems(): x1.append(xx) l = len(yy) if l == 1: y1.append(yy[0]) else:

Re: Finding subsets for a robust regression

2008-09-29 Thread Gerard flanagan
Gerard flanagan wrote: [EMAIL PROTECTED] wrote: x1 = [] #unique instances of x and y y1 = [] #median(y) for each unique value of x for xx,yy in d.iteritems(): x1.append(xx) l = len(yy) if l == 1: y1.append(yy[0

Re: Python Evangelism

2006-03-09 Thread Gerard Flanagan
Steve Holden wrote: > I've been thinking (and blogging) about python evangelism since PyCon, > as a result of which I created a squidoo lens: > >http://www.squidoo.com/pythonlogy > > Imagine my surprise at discovering that this has gone up in rank (by > number of views) from # 442,000 or so to

Re: Any python HTML generator libs?

2006-03-09 Thread Gerard Flanagan
Sullivan WxPyQtKinter wrote: > Hi, everyone. Simply put, what I need most now is a python lib to > generate simple HTML. > > I am now using XML to store my lab report records. I found python > really convinient to manipulate XML, so I want to make a small on-line > CGI program to help my colleag

OT: Sixteen Thousand Oranges

2006-03-11 Thread Gerard Flanagan
Dennis Lee Bieber wrote: > On Sat, 11 Mar 2006 13:30:43 +1100, Tim Churches > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > Would it be possible to rename "Cheese Shop" as "Bright Side of Life"? > > > I think I'd prefer "The Larch"... > > Or just "SPAM" ( Python

Re: markup.py - HTML/XML generator

2006-03-20 Thread Gerard Flanagan
Daniel Nogradi wrote: > Just in case the thought of not having a millionth implementation of a > HTML/XML generator for Python makes the world as we know it a > miserable place, well then your suffering might be over soon since > exactly the one millionth implementation is out. You can download >

Re: NOT Python: Taxonomy list reference

2006-03-21 Thread Gerard Flanagan
ej wrote: > I hope you will forgive this being a bit off subject, but this is about > the smartest list of people I know. I came across a list in the past while > studying OO methdology stuff. The list was trying to make the point of the > problem classification systems often run into (i.e., ofte

Re: markup.py - HTML/XML generator

2006-03-22 Thread Gerard Flanagan
Fredrik Lundh wrote: > Gerard Flanagan wrote: > > > Now I can do this: > > > > page = HtmlPage('Test Page') > > navbar = page.div(id='left').ul(css='navbar') > > for href,link in {'/home':'Home', &

Re: import random module

2006-03-22 Thread Gerard Flanagan
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: > >>> import random > >>> x = random.randint(1,55) > >>> print x > 14 > >>> > > BUT, when I put the same code in a python script: > * random.py: > > import random > > x = random.randint(1,55) > pr

<    1   2   3   4   >