Re: number generator

2007-03-14 Thread Hendrik van Rooyen
"Duncan Smith" <[EMAIL PROTECTED]> wrote: > Yes, if the generating processes yield numbers from different > probability mass functions. You could simply look at the likelihood > ratio. Otherwise, the likelihood ratio will be 1. > I was thinking about the same random number generator being use

Re: number generator

2007-03-14 Thread Hendrik van Rooyen
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > Easy-peasey. Just collate the individual numbers from the lists, and graph > their frequencies. You will get quite different distributions. Both are > "random", but in different ways. > 8< code - Thanks - I think too com

Re: number generator

2007-03-14 Thread Hendrik van Rooyen
"Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >You can't have two different sets with four equal numbers - it's not a >very difficult thing, it's impossible to distinguish because they're >identical! >Given 4 numbers in the set, the 5th is uniquely determined. By example: >12, 3, 10, 18 *must* e

Re: number generator

2007-03-14 Thread Steven D'Aprano
On Tue, 13 Mar 2007 23:08:38 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> > It should be possible to enumerate all sets of five numbers which sum >> > to 50 and randomly select one of them. >> >> Of course it's possible. It's also a very inefficient way of doing so. F

Re: number generator

2007-03-14 Thread Steven D'Aprano
On Wed, 14 Mar 2007 19:25:46 +1100, Steven D'Aprano wrote: > Now that I've seen your _partition() function, I'm quite impressed. It is > still brute-force, but it avoids generating all 50**5 non-unique lists. By > my count, it only has to throw away 11,294 lists to generate the 2611 > unique lists

Mocking OpenOffice in python?

2007-03-14 Thread PaoloB
Hi everyone, during our development, we need to write some unit tests that interact with OpenOffice through pyUno. Is there anyone who has got any experience on it? As OpenOffice is quite a large beast, and interaction is rather complex, I would like to know if there is someone who is willing to

Re: number generator

2007-03-14 Thread Raymond Hettinger
> To make the solutions equi-probable, a simple approach is to > recursively enumerate all possibilities and then choose one of them > with random.choice(). Since people are posting their solutions now (originally only hints were provided for the homework problem), here's mine: def genpool(n, m):

Re: How to capture environment state after running a shell script.

2007-03-14 Thread Gerard Flanagan
On Mar 13, 7:54 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 5:57 am, "Gerard Flanagan" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I have a third party shell script which updates multiple environment > > values, and I want to investigate (and ultimately capture to python) > > the environment state

Re: using python to visit web sites and print the web sites image to files

2007-03-14 Thread imx
On 3月14日, 上午5时44分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > The reason I want to do simulation but not just crawling is : we have > > to check many web pages' front page to see whether it conform to our > > visual standard, e.g, it should put a search box on the top part of > > the page.

Re: how to detect change of list of instances

2007-03-14 Thread Bruno Desthuilliers
manstey a écrit : > Thanks. > > All I want to know is whether the newlist, as a list of instances, is > modified. I thought equality was the way to go, but is there a simpler > way? How can I monitor the state of newlist and set a flag if it is > changed in anyway? Override the mutators - or jus

Re: Setting Up SOAPpy for Python v2.5 on Windows?

2007-03-14 Thread Simon Brunning
On 13 Mar 2007 11:53:24 -0700, Steve <[EMAIL PROTECTED]> wrote: > What are the required version of the SOAPpy, PyXML, fpconst that are > needed to run under the Python 2.5 environment on Windows? SOAPpy doesn't install under Python 2.5 as-is. You'll need to add source code encodings on all the sou

how to catch system errors in python

2007-03-14 Thread Manpreet Singh Khurana
Hi, I am using paramiko 1.5.3 with python 2.4 and pycrypto 1.9 I need to know if it is possible to catch sysytem level error, like "disk space full" or "cpu usage indication" etc. Any help would be appriciated. Regards, MSK -- http://mail.python.org/mailman/listinfo/python-list

Re: help developing an editor to view openoffice files.

2007-03-14 Thread krishnakant Mane
On 14/03/07, Paul Hummer <[EMAIL PROTECTED]> wrote: > I actually just read this in the O'Reilly book "Python Cookbook," so I > know this answer off the top of my head. OpenOffice files are merely > zip files with well documented XML inside. Use the builtin zip module > to open them, and then it'

python-list@python.org

2007-03-14 Thread Amitabh Saikia
Hi I have created a simple function called 'addTheString(string& str, string appstr)' and the intension is to append the 'appstr' to 'str' and use 'str'. I tried swigging this method. My swigtest.i file is okay as I think I have added both - stl.i at top - std_string.i Howeve

Re: number generator

2007-03-14 Thread Hendrik van Rooyen
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > > Consider the distance between each paid of consecutive poles. The sum of > the distances must add up to the distance from the first to the last, and > if there are two fixed poles plus five in between, there are five > distances. No there are six

Re: Mocking OpenOffice in python?

2007-03-14 Thread M�ta-MCI
Hi! Under windows, I drive OOo, from Python, via COM/OLE-automation. It's run OK, but some bugs, in the OOo-COM-Python, had stop my devloppements... However, this way is usable (only on Win, ok?) @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterating across a filtered list

2007-03-14 Thread Bruno Desthuilliers
Paul Rubin a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> writes: (snip) >> Python has had functions as first class objects and >> (quite-limited-but) anonymous functions, map(), filter() and reduce() >> as builtin funcs at least since 1.5.2 (quite some years ago). > > True, though no iterato

Re: Iterating across a filtered list

2007-03-14 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : > On Mar 13, 8:53 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Paul Rubin a écrit : > > [snip] > >>> Iterators like that are a new Python feature >> List comps are not that new (2.0 or 2.1 ?): >> print "\n".join([contact for name, contact in contacts.items()

Re: python/C++ wrapper

2007-03-14 Thread Szabolcs Nagy
> - A c++ program receives a 2D-matrix from python as input and gives a > 2D-matrix as output back to python. pyogre uses swig ogre is a 3d realtime rendering engine written in c++ so there are many matrix manipulation there and also pyogre does not modify the original code cgkit is a computer g

Re: number generator

2007-03-14 Thread Raymond Hettinger
[Alex Martelli] > map([random.randrange(5) for i in xrange(45)].count, xrange(5)) > > i.e., this gives 5 integers (each between 0 and 45 included) summing to > 45 -- add 1 to each of them to get the desired result. This is a really nice approach. Besides being fast, it is not too hard to see th

Re: python/C++ wrapper

2007-03-14 Thread Roman Yakovenko
On 14 Mar 2007 02:38:32 -0700, Szabolcs Nagy <[EMAIL PROTECTED]> wrote: > > - A c++ program receives a 2D-matrix from python as input and gives a > > 2D-matrix as output back to python. > > pyogre uses swig Well, pyogre has few problems with maintenance, and new bindings to Ogre engine was created

Re: number generator

2007-03-14 Thread Anton Vredegoor
Raymond Hettinger wrote: > Since people are posting their solutions now (originally only hints > were provided for the homework problem), here's mine: Homework problem? Do you have some information from the OP that I can't find in this thread? Anyway, I consider the 'homework' idea and the asso

Attribute monitoring in a class

2007-03-14 Thread Joel Andres Granados
Hi list: I have googled quite a bit on this matter and I can't seem to find what I need (I think Im just looking where I'm not suppose to :). I'm working with code that is not of my authorship and there is a class attribute that is changes by directly referencing it (object.attr = value) inst

Re: python/C++ wrapper

2007-03-14 Thread Szabolcs Nagy
> Well, pyogre has few problems with maintenance, and new bindings to > Ogre engine was > created using Boost.Python( http://www.ogre3d.org/wiki/index.php/PyOgre ) oh last time i played with pyogre they made a transition from boost to swig :) so they are back again at boost (the problem with boos

Re: Attribute monitoring in a class

2007-03-14 Thread Simon Brunning
On 3/14/07, Joel Andres Granados <[EMAIL PROTECTED]> wrote: > I have googled quite a bit on this matter and I can't seem to find what > I need (I think Im just looking where I'm not suppose to :). I'm > working with code that is not of my authorship and there is a class > attribute that is changes

Passing a FILE* from Python into a MinGW/SWIG module

2007-03-14 Thread John Pye
Hi all I understand that I can't hope to pass a FILE* from the Windows version of Python into a SWIG module that I've built using MinGW gcc/g+ +, because apparently the FILE* structure are different and incompatible. Is there an official workaround for this? Presumably I need to implement a mingw

Re: python/C++ wrapper

2007-03-14 Thread John Pye
Check out this example from NumPy. This would be the way sanctioned by the scipy community, as you benefit from a large library of matrix routines that you can use to prepare/postprocess the data. http://www.scipy.org/Cookbook/SWIG_and_NumPy -- http://mail.python.org/mailman/listinfo/python-lis

Re: Attribute monitoring in a class

2007-03-14 Thread Bruno Desthuilliers
Joel Andres Granados a écrit : > Hi list: > > I have googled quite a bit on this matter and I can't seem to find what > I need (I think Im just looking where I'm not suppose to :). I'm > working with code that is not of my authorship and there is a class > attribute that is changes by directly

Re: Attribute monitoring in a class

2007-03-14 Thread Laurent Pointal
Joel Andres Granados a écrit : > Hi list: > > I have googled quite a bit on this matter and I can't seem to find what > I need (I think Im just looking where I'm not suppose to :). I'm > working with code that is not of my authorship and there is a class > attribute that is changes by directly re

Quick Filter Dictionary

2007-03-14 Thread abcd
Hi, I have a dictionary which may contain various keys/values, however, it will always contain 'name' and 'age' keys. This dictionary is kept inside a class, such as class Person: def __init__(self, name, age): self.data = {'name' : name, 'age' : age} de

Re: Quick Filter Dictionary

2007-03-14 Thread abcd
On Mar 14, 7:29 am, "abcd" <[EMAIL PROTECTED]> wrote: > Hi, >I have a dictionary which may contain various keys/values, however, > it will always contain 'name' and 'age' keys. > >This dictionary is kept inside a class, such as > > class Person: > def __init__(self, name, ag

Re: number generator

2007-03-14 Thread cesco
> Since people are posting their solutions now (originally only hints > were provided for the homework problem), here's mine: Well, I never really said it was a homework problem. Sure there are more implications to my question that I had first imagined and I'm really happy I could get so many insi

mod_python demo

2007-03-14 Thread Jan Danielsson
Hello all, I have written a web-based voting system (add question, add possible answers to that question, and let users vote) in python. It uses: - mod_python - postgreql (through psycopg2) It includes basic session and user management. It's a very simple system, and the session/

Re: Problem I have with a while loop/boolean/or

2007-03-14 Thread Steve Holden
Scott David Daniels wrote: > Bart Willems wrote: >> ... >> I always try to stay away from 'negative' operators if possible, to >> improve readability: >> >> while True: >>hint = raw_input('\nAre you stuck? y/n: ').lower() >>if hint = 'y' or hint = 'n': >> break >>else: >> p

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

2007-03-14 Thread Slawomir Nowaczyk
Hello, When I execfile a file which contains a syntax error, the file becomes locked and stays this way all the way until I exit the interpreter (I am unable to delete it, for example). I have tried but failed to find any way to unlock the file... Is this a bug in Python? Is there *any* way to un

Re: Quick Filter Dictionary

2007-03-14 Thread Bruno Desthuilliers
abcd a écrit : > On Mar 14, 7:29 am, "abcd" <[EMAIL PROTECTED]> wrote: >> Hi, >>I have a dictionary which may contain various keys/values, however, >> it will always contain 'name' and 'age' keys. >> >>This dictionary is kept inside a class, such as >> >> class Person: Do yourself

Grep Equivalent for Python

2007-03-14 Thread tereglow
Hello all, I come from a shell/perl background and have just to learn python. To start with, I'm trying to obtain system information from a Linux server using the /proc FS. For example, in order to obtain the amount of physical memory on the server, I would do the following in shell: grep ^MemT

Re: Quick Filter Dictionary

2007-03-14 Thread Steve Holden
abcd wrote: > On Mar 14, 7:29 am, "abcd" <[EMAIL PROTECTED]> wrote: >> Hi, >>I have a dictionary which may contain various keys/values, however, >> it will always contain 'name' and 'age' keys. >> >>This dictionary is kept inside a class, such as >> >> class Person: >> def _

IronPython and COM Interface

2007-03-14 Thread Divya
Hello, I'm new to IronPython and COM so please bear with me. I have a COM interface provided to me. I need to implement this interface and pass it to a method as a way of implementing 'callbacks'. However it appears that the methods of my interface object are never called. As a alternative, I i

Re: Grep Equivalent for Python

2007-03-14 Thread Steve Holden
tereglow wrote: > Hello all, > > I come from a shell/perl background and have just to learn python. To > start with, I'm trying to obtain system information from a Linux > server using the /proc FS. For example, in order to obtain the amount > of physical memory on the server, I would do the fol

Re: i can`t get python working on the command line (linux)

2007-03-14 Thread Facundo Batista
Mark wrote: > and i`ve put it in tel.py (just the same as in the sample) than chmod > it to 777 (just to make sure it isn`t a permission issue) and than i > run it with: ./tel.py > now this is the error that i get: > > Traceback (most recent call last): > File "./tel.py", line 12, in > for

logging and wx.Timer

2007-03-14 Thread hg
Hi, I read that logging was thread safe ... but can I use it under a GUI timer ? Thanks, hg -- http://mail.python.org/mailman/listinfo/python-list

Re: Attribute monitoring in a class

2007-03-14 Thread Joel Andres Granados
Bruno Desthuilliers wrote: > Joel Andres Granados a écrit : > >> Hi list: >> >> I have googled quite a bit on this matter and I can't seem to find what >> I need (I think Im just looking where I'm not suppose to :). I'm >> working with code that is not of my authorship and there is a class >

Re: Grep Equivalent for Python

2007-03-14 Thread Paul Boddie
On 14 Mar, 13:37, "tereglow" <[EMAIL PROTECTED]> wrote: > Hello all, > > I come from a shell/perl background and have just to learn python. Welcome aboard! > To start with, I'm trying to obtain system information from a Linux > server using the /proc FS. For example, in order to obtain the amou

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

2007-03-14 Thread skip
Slawomir> When I execfile a file which contains a syntax error, the file Slawomir> becomes locked and stays this way all the way until I exit the Slawomir> interpreter (I am unable to delete it, for example). I have Slawomir> tried but failed to find any way to unlock the file... I

Re: Grep Equivalent for Python

2007-03-14 Thread Laurent Pointal
Steve Holden a écrit : > Regular expressions aren't really needed here. Untested code follows: > > for line in open('/proc/meminfo').readlines: for line in open('/proc/meminfo').readlines(): > if line.startswith("Memtotal:"): > name, amt, unit = line.split() > print name, amt,

Re: Mocking OpenOffice in python?

2007-03-14 Thread Carsten Haese
On Wed, 2007-03-14 at 01:39 -0700, PaoloB wrote: > Hi everyone, > > during our development, we need to write some unit tests that interact > with OpenOffice through pyUno. > > Is there anyone who has got any experience on it? As OpenOffice is > quite a large beast, and interaction is rather compl

Re: IronPython and COM Interface

2007-03-14 Thread Larry Bates
Divya wrote: > Hello, > > I'm new to IronPython and COM so please bear with me. > > I have a COM interface provided to me. I need to implement this > interface and pass it to a method as a way of implementing > 'callbacks'. > > However it appears that the methods of my interface object are never

Re: Grep Equivalent for Python

2007-03-14 Thread BJörn Lindqvist
> I come from a shell/perl background and have just to learn python. To > start with, I'm trying to obtain system information from a Linux > server using the /proc FS. For example, in order to obtain the amount > of physical memory on the server, I would do the following in shell: > > grep ^MemTo

Re: Mocking OpenOffice in python?

2007-03-14 Thread Shane Geiger
My take was that this is an effort to manipulate these files without the need for Open Office, so I replied as follows: Open Office files (.ods and perhaps .odt) are just zipped or gzipped. Unpack that and then you are dealing with manipulating regular text files--probably HTML.

Re: number generator

2007-03-14 Thread Duncan Smith
Duncan Smith wrote: > greg wrote: > >>Gabriel Genellina wrote: >> >> >>>The 5th number is not "random". >> >> >>More precisely, the fifth number is not *independent* >>of the others. You can't have five independent random >>numbers that sum to 50; only four independent numbers >>plus a dependent o

Re: Mocking OpenOffice in python?

2007-03-14 Thread PaoloB
On 14 Mar, 14:48, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2007-03-14 at 01:39 -0700, PaoloB wrote: > > Hi everyone, > > > during our development, we need to write some unit tests that interact > > with OpenOffice through pyUno. > > > Is there anyone who has got any experience on it? As O

Re: number generator

2007-03-14 Thread Alex Martelli
Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Alex Martelli] > > map([random.randrange(5) for i in xrange(45)].count, xrange(5)) > > > > i.e., this gives 5 integers (each between 0 and 45 included) summing to > > 45 -- add 1 to each of them to get the desired result. > > This is a really nice

Re: Mocking OpenOffice in python?

2007-03-14 Thread PaoloB
On 14 Mar, 14:52, Shane Geiger <[EMAIL PROTECTED]> wrote: > My take was that this is an effort to manipulate these files without the > need for Open Office, so I replied as follows: > > Open Office files (.ods and perhaps .odt) are just zipped or gzipped. > Unpack that and then you are dealing with

Re: using python to visit web sites and print the web sites image to files

2007-03-14 Thread [EMAIL PROTECTED]
On Mar 14, 9:02 am, "imx" <[EMAIL PROTECTED]> wrote: > Cool, but does it mean that I will need .net to run the code? Yep - runtime is free though as is IronPython. For my program the license is BSD. Cheers, Davy -- http://mail.python.org/mailman/listinfo/python-list

Re: number generator

2007-03-14 Thread Duncan Smith
Hendrik van Rooyen wrote: > "Duncan Smith" <[EMAIL PROTECTED]> wrote: > > > >>Yes, if the generating processes yield numbers from different >>probability mass functions. You could simply look at the likelihood >>ratio. Otherwise, the likelihood ratio will be 1. >> > > I was thinking about th

RE: Mocking OpenOffice in python?

2007-03-14 Thread Sells, Fred
I currently use Java to generate a 150 page PDF from about 50 .odt files, including replacing occurrances of about 10 "place-holder" phrases from data in our system. I do not use the OOo database/mailmerge features, just UNO. This process takes about 20 seconds on my 2 year old XP laptop and about

Re: Questions on migrating from Numeric/Scipy to Numpy

2007-03-14 Thread vj
What should I be using to replace Numeric/arrayobject.h: numpy/arrayobject.h or numpy/oldnumeric.h Thanks, VJ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem I have with a while loop/boolean/or

2007-03-14 Thread [EMAIL PROTECTED]
On Mar 13, 5:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi all. > > I have a problem with some code :( > > --- > > hint = raw_input("\nAre you stuck? y/n: ") > hint = hint.lower() > > while (hint != 'n') or (hint != 'y'): > hint = raw_input("Please specify a valid choice: "

Re: most complete xml package for Python?

2007-03-14 Thread Stefan Behnel
metaperl wrote: > Without even checking them all out, I'm thinking the Amara XML Toolkit > must be the most feature-packed. Please check out lxml before you post FUD like this. http://codespeak.net/lxml/ Regards, Stefan -- http://mail.python.org/mailman/listinfo/python-list

dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Drew
When is it appropriate to use dict.items() vs dict.iteritems. Both seem to work for something like: for key,val in mydict.items(): print key,val for key,val in mydict.iteritems(): print key,val Also, when is it appropriate to use range() vs xrange(). From my understanding, xrange() essential

Re: number generator

2007-03-14 Thread Shane Geiger
Raymond: It looks to me as if you are trying to turn a generator into a list in the final line. That doesn't work. Raymond Hettinger wrote: To make the solutions equi-probable, a simple approach is to recursively enumerate all possibilities and then choose one of them with random.choice().

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Laurent Pointal
Drew a écrit : > When is it appropriate to use dict.items() vs dict.iteritems. Both > seem to work for something like: > > for key,val in mydict.items(): > print key,val > > for key,val in mydict.iteritems(): > print key,val > > Also, when is it appropriate to use range() vs xrange(). From m

getting user id (from an arbitrary sys user)

2007-03-14 Thread Gerardo Herzig
hi all. What i need to know is if there is some function like os.getuid(), but taking an argument (the username, off course), so i can do getuid('myuser') Thanks you dudes! Gerardo -- http://mail.python.org/mailman/listinfo/python-list

Re: httplib/socket problems reading 404 Not Found response

2007-03-14 Thread Patrick Altman
On Mar 13, 3:16 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 13 Mar 2007 10:38:24 -0300, Patrick Altman <[EMAIL PROTECTED]> > escribió: > > >> Yes, it's a known problem. See this message with a > >> self-response:http://mail.python.org/pipermail/python-list/2006-March/375087.html >

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Drew
On Mar 14, 11:44 am, Laurent Pointal <[EMAIL PROTECTED]> wrote: > Both work, you may prefer xrange/iteritems for iteration on large > collections, you may prefer range/items when processing of the result > value explicitly need a list (ex. calculate its length) or when you are > going to manipulate

Re: number generator

2007-03-14 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > If you generate all the possible sets of five numbers between 1 and 50, > there are 50**5 of them, not 2611. Yes, the idea is generate only the sets that add up to 50. > unique_partitions(60, 6) takes 0.8 seconds; unique_partitions(80, 8) > takes abou

Re: number generator

2007-03-14 Thread Paul Rubin
"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > Since people are posting their solutions now (originally only hints > were provided for the homework problem), here's mine: > > def genpool(n, m): > if n == 1: > yield [m] > else: > for i in xrange(1, m): > for r

Re: Communicating with a DLL under Linux

2007-03-14 Thread Mikael Olofsson
Thanks for all the responces, both on and off list. So, I should forget about the DLL, and if I intend to connect the thing to a Linux computer, I'll have to develop the code myself for communicating with it over USB. Fair enough. I might even try that. I've done some surfing since yesterday. W

Q: Cteni unicode retezcu ze souboru UTF-8 s BOM?

2007-03-14 Thread Petr Prikryl
Ahoj všeci, Tak nějak prakticky poprvé se dostávám k tomu, jak přečíst unicode řetězce ze souboru, který je uložen ve formátu UTF-8 se signaturou na začátku (BOM). Nějak se mi nedaří. Mám takovýto soubor.txt v UTF-8 s BOM = První řádek. Druhý řádek. Třetí řáde

Re: Grep Equivalent for Python

2007-03-14 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Laurent Pointal wrote: > Steve Holden a écrit : >> Regular expressions aren't really needed here. Untested code follows: >> >> for line in open('/proc/meminfo').readlines: > for line in open('/proc/meminfo').readlines(): for line in open('/proc/meminfo'): >> if line.s

Re: most complete xml package for Python?

2007-03-14 Thread Paul Boddie
On 14 Mar, 16:15, Stefan Behnel <[EMAIL PROTECTED]> wrote: > metaperl wrote: > > Without even checking them all out, I'm thinking the Amara XML Toolkit > > must be the most feature-packed. > > Please check out lxml before you post FUD like this. > > http://codespeak.net/lxml/ Calm down, Stefan! Th

print and softspace in python

2007-03-14 Thread Phoe6
print and softspace in python In python, whenever you use >>>print statement it will append a newline by default. If you don't want newline to be appended, you got use a comma at the end (>>>print 10,) When, you have a list of characters and want them to be printed together a string using a for loo

Re: Setting Up SOAPpy for Python v2.5 on Windows?

2007-03-14 Thread Steve
All, Thanks for the suggestions! I think that I will move forward with elementsoap instead of soappy... Steve On Mar 13, 11:53 am, "Steve" <[EMAIL PROTECTED]> wrote: > Hi All, > > What are the required version of the SOAPpy, PyXML, fpconst that are > needed to run under the Python 2.5 environme

Re: number generator

2007-03-14 Thread Anton Vredegoor
Paul Rubin wrote: >> def genpool(n, m): >> if n == 1: >> yield [m] >> else: >> for i in xrange(1, m): >> for rest in genpool(n-1, m-i): >> yield rest + [i] >> >> import random >> print random.choice(list(genpool(n=4, m=20))) > > This generates a

Re: number generator

2007-03-14 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > >>> list(_partitions(25, 24)) > [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2)] > >>> list(_partitions(25, 25)) > [] Hmm. I'll look into this later if I get a chance. Thanks. -- http://mail.python.org/mailman/listinfo/pyth

(beginners) howto ascribe _all_ fields of parent class to child class?

2007-03-14 Thread dmitrey
Hi all, I'm rewriting some code from other language to Python; can anyone explain me which way is the simpliest: I have class C1(): def __init__(self): self.a = 5 class C2(C1): def __init__(self): self.b = 8 c = C2() print c.b#prints 8 print c.a#prints error, because fi

Re: Grep Equivalent for Python

2007-03-14 Thread tereglow
On Mar 14, 11:57 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Laurent Pointal wrote: > > > Steve Holden a écrit : > >> Regular expressions aren't really needed here. Untested code follows: > > >> for line in open('/proc/meminfo').readlines: > > for line in open(

Re: logging and wx.Timer

2007-03-14 Thread Jordan
On Mar 14, 1:52 am, hg <[EMAIL PROTECTED]> wrote: > Hi, > > I read that logging was thread safe ... but can I use it under a GUI timer ? > > Thanks, > > hg That was barely enough information to be worthy of a reply. Need more than that. What do you mean under a gui timer? What gui? What type of

Re: most complete xml package for Python?

2007-03-14 Thread Steve Holden
Paul Boddie wrote: > On 14 Mar, 16:15, Stefan Behnel <[EMAIL PROTECTED]> wrote: >> metaperl wrote: >>> Without even checking them all out, I'm thinking the Amara XML Toolkit >>> must be the most feature-packed. >> Please check out lxml before you post FUD like this. >> >> http://codespeak.net/lxml/

Re: (beginners) howto ascribe _all_ fields of parent class to child class?

2007-03-14 Thread Diez B. Roggisch
dmitrey schrieb: > Hi all, > I'm rewriting some code from other language to Python; can anyone > explain me which way is the simpliest: > I have > class C1(): > def __init__(self): > self.a = 5 > > class C2(C1): > def __init__(self): > self.b = 8 > > c = C2() > print c.

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Shane Geiger
# Just by looking at the output, it seems pretty obvious that xrange would be more memory effcient for large ranges: print "With range():",range(100,200) print print "With xrange():",xrange(100,200) d = {1:2,2:3,3:4} d.items() d.iteritems() # I have been curious to use Pysizer (which requires

Re: (beginners) howto ascribe _all_ fields of parent class to child class?

2007-03-14 Thread Steve Holden
dmitrey wrote: > Hi all, > I'm rewriting some code from other language to Python; can anyone > explain me which way is the simpliest: > I have > class C1(): > def __init__(self): > self.a = 5 > > class C2(C1): > def __init__(self): > self.b = 8 > > c = C2() > print c.b#

Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread dmitrey
I can't find these via web serch thank you in advance, Dmitrey -- http://mail.python.org/mailman/listinfo/python-list

Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread Alexander Schmolck
"dmitrey" <[EMAIL PROTECTED]> writes: > I can't find these via web serch > > thank you in advance, > Dmitrey str2func: getattr(some_module, 'f') func2str: f.__name__ ischar: isinstance(x, basestring) and len(x) == 1 isfunc: callable(x) # is most likely to be what you want 'as -- http://mail.p

Re: dict.items() vs dict.iteritems and similar questions

2007-03-14 Thread Leif K-Brooks
Laurent Pointal wrote: > Both work, you may prefer xrange/iteritems for iteration on large > collections, you may prefer range/items when processing of the result > value explicitly need a list (ex. calculate its length) or when you are > going to manipulate the original container in the loop. xra

Re: number generator

2007-03-14 Thread Anton Vredegoor
Anton Vredegoor wrote: > def memoize(fn): > cache = {} > def proxy(*args): > try: return cache[args] > except KeyError: return cache.setdefault(args, fn(*args)) > return proxy Sorry this doesn't work in this case. This works: def memoize(fn): cache = {

Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread Travis Oliphant
dmitrey wrote: > I can't find these via web serch > You won't find exact equivalents. But, the same functionality is available. Perhaps you would like to show us what you are trying to do in Python. Python's eval has some similarity with str2func Python's repr() or str() has some similarity

Re: Python equivalents to MATLAB str2func, func2str, ischar, isfunc?

2007-03-14 Thread dmitrey
Thank you (however in MATLAB ischar is the same as isstr) but what if I don't know the name of module? I.e. I have def myfunc(param): ... #where param can be both funcName or a function, and I want to obtain both name and func, something like if isinstance(param, basestring): func, funcName = ,

Fwd: Server-side script takes way too long to launch

2007-03-14 Thread Teresa Hardy
Thanks Jeff for all the great advice on where to look next, including help with mailman. (I fell off the list and am using this reply to figure out why!) Just switched to gmail and still learning it too. And thanks for being so kind in the code review. Fundamentally, I had too many imported modul

Re: print and softspace in python

2007-03-14 Thread Stargaming
Phoe6 schrieb: > print and softspace in python > In python, whenever you use >>>print statement it will append a > newline by default. If you don't want newline to be appended, you got > use a comma at the end (>>>print 10,) > When, you have a list of characters and want them to be printed > togeth

Constructor of object

2007-03-14 Thread inline
Hello! I want to assign self to object of parent class in constructor, like def my_func(): ... return ParentClass() class MyClass (ParentClass): def __init__(self): self = my_func() but it not work, because "object not initialized". What i can do? -- http://mail.python.org/

Re: Grep Equivalent for Python

2007-03-14 Thread tereglow
Okay, It is now working as follows: memFile = open('/proc/meminfo') for line in memFile.readlines(): if line.startswith("MemTotal"): memStr = line.split() memTotal = memStr[1] memFile.close() print "Memory: " + memTotal + "kB" I'm learning the whole try, f

Re: Constructor of object

2007-03-14 Thread Sylvain Defresne
inline wrote: > Hello! > I want to assign self to object of parent class in constructor, like > > def my_func(): > ... > return ParentClass() > > class MyClass (ParentClass): > def __init__(self): > self = my_func() > > but it not work, because "object not initialized". What

Re: getting user id (from an arbitrary sys user)

2007-03-14 Thread Thinker
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gerardo Herzig wrote: > hi all. What i need to know is if there is some function like > os.getuid(), but taking an argument (the username, off course), so i can > do getuid('myuser') > > Thanks you dudes! > > Gerardo Please refer http://docs.python.org

Python & Oracle

2007-03-14 Thread Facundo Batista
Hi! I need to connect to Oracle. I found this binding, http://www.zope.org/Members/matt/dco2 that is the recommended in the Python page. But that page seems a bit confuse to me. In the upper right corner says that the last release is PreRelease 1, from 2001-11-15. At the bottom, however, it

Re: Python & Oracle

2007-03-14 Thread Josh Bloom
I would suggest using cx_Oracle as I have had good experience with it. http://www.cxtools.net/default.aspx?nav=cxorlb -Josh On 3/14/07, Facundo Batista <[EMAIL PROTECTED]> wrote: Hi! I need to connect to Oracle. I found this binding, http://www.zope.org/Members/matt/dco2 that is the recom

Re: Constructor of object

2007-03-14 Thread Thinker
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 inline wrote: > Hello! I want to assign self to object of parent class in > constructor, like > > def my_func(): ... return ParentClass() > > class MyClass (ParentClass): def __init__(self): self = my_func() > > but it not work, because "object not ini

Re: logging and wx.Timer

2007-03-14 Thread hg
Jordan wrote: > On Mar 14, 1:52 am, hg <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I read that logging was thread safe ... but can I use it under a GUI >> timer ? >> >> Thanks, >> >> hg > > That was barely enough information to be worthy of a reply. Need more > than that. What do you mean under a g

Re: Python & Oracle

2007-03-14 Thread Jean-Philippe Durand
So do I ! 2007/3/14, Josh Bloom <[EMAIL PROTECTED]>: > I would suggest using cx_Oracle as I have had good experience with it. > http://www.cxtools.net/default.aspx?nav=cxorlb > > -Josh > > > On 3/14/07, Facundo Batista <[EMAIL PROTECTED]> wrote: > > Hi! I need to connect to Oracle. > > > > I found

  1   2   3   >