Re: Some thougts on cartesian products

2006-01-23 Thread Bryan Olson
Christoph Zwerschke wrote: > Bryan Olson schrieb: > >>> Still think there is no such thing? >> >> >> Uh, yes. >> >>The Cartesian product of two sets A and B (also called the >>product set, set direct product, or cross product) is defined to >>be the set of [...] >> >> All sets, no stri

Re: Some thougts on cartesian products

2006-01-23 Thread Kay Schluehr
Christoph Zwerschke wrote: > Now as I'm thinking about it, wouldn't it be nice to have the cartesian > products on Python sets? Maybe also a method that returns the power set > of a set (the set of all subsets), or the set of all subsets with a > given length. For defining powersets it might suf

[ANN] IPython 0.7.1 is out.

2006-01-23 Thread Fernando Perez
Hi all, I have released IPython 0.7.1, which is mainly a bugfix release over 0.7.0. As expected in that release, given the large changes made, some problems inevitably appeared. I believe all regressions and known bugs have been fixed, along with some useful new features. This release marks the

Re: os.unlink() AND win32api.DeleteFile()

2006-01-23 Thread Martin v. Löwis
rbt wrote: > Can someone detail the differences between these two? On Windows which > is preferred? They do the same thing: unlink calls DeleteFile. The only difference is how errors are reported. For portability, os.unlink is preferred. Regards, Martin -- http://mail.python.org/mailman/listinf

Re: Real-world use cases for map's None fill-in feature?

2006-01-23 Thread rurpy
Andrae Muys wrote: > [EMAIL PROTECTED] wrote: > > Thank you for the posting Andrae, it has increased my > > knowledge. > No problem, happy to help. > > But my original point was there are cases (often involving > > file iterators) where the problem's complexity seems to be > > on the same order as

Re: Arithmetic sequences in Python

2006-01-23 Thread Bengt Richter
On Mon, 23 Jan 2006 21:43:16 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Sun, 22 Jan 2006 16:40:48 -0800, Paul Rubin wrote: > >> Steve Holden <[EMAIL PROTECTED]> writes: >>> > The current list function is supposed to be something like a >>> > typecast: >>> > >>> list() isn't a function,

Re: Real-world use cases for map's None fill-in feature?

2006-01-23 Thread Andrae Muys
[EMAIL PROTECTED] wrote: > Thank you for the posting Andrae, it has increased my > knowledge. No problem, happy to help. > But my original point was there are cases (often involving > file iterators) where the problem's complexity seems to be > on the same order as problems involving iterate-to-sh

Re: Some thoughts on garbage collection

2006-01-23 Thread Frank Millman
Martin v. Löwis wrote: > Frank Millman wrote: > > In principle I agree. My concern was that I might have inadvertently > > done something wrong (e.g. left a reference dangling) which would > > prevent gc from removing all objects which I wanted to be removed. > > Depends on what it really is that

Re: Some thougts on cartesian products

2006-01-23 Thread val bykoski
Christoph Zwerschke wrote: > Bryan Olson schrieb: > >>> Still think there is no such thing? >> >> >> Uh, yes. >> >>The Cartesian product of two sets A and B (also called the >>product set, set direct product, or cross product) is defined to >>be the set of [...] >> >> All sets, no stri

Re: list comprehention

2006-01-23 Thread Bryan Olson
Bryan Olson wrote: > Duncan Booth wrote: > >> Here's the way I would do it: >> > def occurrences(it): >> >> >> res = {} >> for item in it: >> if item in res: >> res[item] += 1 >> else: >> res[item] = 1 >> return res > > > I slightly prefer:

Re: Using non-ascii symbols

2006-01-23 Thread Robert Kern
James Stroud wrote: > I can't find "≤, ≥, or ≠" on my keyboard. Get a better keyboard? or OS? On OS X, ≤ is Alt-, ≥ is Alt-. ≠ is Alt-= Fewer keystrokes than <= or >= or !=. -- Robert Kern [EMAIL PROTECTED] "In the fields of hell where the grass grows high Are the graves of dreams allowed

Re: Some thougts on cartesian products

2006-01-23 Thread Bryan Olson
Kay Schluehr wrote: > Bryan Olson wrote: > > >>There's no such thing; you'd have to define it first. Are duplicates >>significant? Order? > > > That's all trivial isn't it? A string is a set of pairs (i,c) where i > is an integer number, the index, with 0<=i (i,c), (j,d) in string and c is a ch

Re: Some thougts on cartesian products

2006-01-23 Thread Bryan Olson
Steven D'Aprano wrote: > On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote: > > >>Steven D'Aprano wrote: >> >>>Bryan Olson wrote: >>> >>[Christoph Zwerschke had written:] >> >What I expect as the result is the "cartesian product" of the strings. There's no such thing; you'd have

Re: Using non-ascii symbols

2006-01-23 Thread James Stroud
Christoph Zwerschke wrote: > On the page http://wiki.python.org/moin/Python3%2e0Suggestions > I noticed an interesting suggestion: > > "These operators ≤ ≥ ≠ should be added to the language having the > following meaning: > > <= >= != > > this should improve readibility (and make language

Using non-ascii symbols

2006-01-23 Thread Christoph Zwerschke
On the page http://wiki.python.org/moin/Python3%2e0Suggestions I noticed an interesting suggestion: "These operators ≤ ≥ ≠ should be added to the language having the following meaning: <= >= != this should improve readibility (and make language more accessible to beginners). This shoul

os.unlink() AND win32api.DeleteFile()

2006-01-23 Thread rbt
Can someone detail the differences between these two? On Windows which is preferred? Also, is it true that win32api.DeleteFile() can remove the 'special' files located in the 'special' folders only accessible by the shell object such as Temporary Internet Files, etc. Thanks! -- http://mail.py

Re: Loop exception catching

2006-01-23 Thread Aldo Cortesi
Thus spake Ivan Shevanski ([EMAIL PROTECTED]): > Alright this is kind of a continuation of a past conversation. . .But not > really. Anyway, heres the problem. Say I had this: > > try: > x = input("> ") > except SyntaxError: >print "explain the problem he

Weekly Python Patch/Bug Summary (Revised)

2006-01-23 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 391 open ( +7) / 3028 closed (+12) / 3419 total (+19) Bugs: 906 open ( -3) / 5519 closed (+19) / 6425 total (+16) RFE : 207 open ( -1) / 197 closed ( +1) / 404 total ( +0) New / Reopened Patches __ Patch for

Re: Some thougts on cartesian products

2006-01-23 Thread Christoph Zwerschke
Bryan Olson schrieb: >> Still think there is no such thing? > > Uh, yes. > >The Cartesian product of two sets A and B (also called the >product set, set direct product, or cross product) is defined to >be the set of [...] > > All sets, no strings. What were you looking at? Not only

Re: Loop exception catching

2006-01-23 Thread stv
I'm just learning Python myself, but I just saw an example of something similar. Not sure if this is what you're looking for, but while 1: try: x=input('>') except Exception, e: print 'Problems: ', e else: break The else clause is executed UNLESS something is c

Weekly Python Patch/Bug Summary

2006-01-23 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 391 open ( +7) / 3028 closed (+12) / 3419 total (+19) Bugs: 905 open ( -4) / 5519 closed (+19) / 6424 total (+15) RFE : 207 open ( -1) / 197 closed ( +1) / 404 total ( +0) New / Reopened Patches __ Patch for

Re: Problem with running external process

2006-01-23 Thread Dan Sommers
On 23 Jan 2006 10:03:28 -0800, "ToMasz" <[EMAIL PROTECTED]> wrote: > Yes, each time the process is created, it remains. os.waitpid(-1, > os.WNOHANG) doesn't work before starting the process for the first > time. Argh. That's what I get for looking at my example too quickly. ;-) Of course: th

file_name_fixer.py

2006-01-23 Thread ewaguespack
i put this together to fix a bunch of files with wierd names, please gimme feedback, i am a newbie #!/usr/bin/env python import os import sys import string import platform dir = sys.argv[1] noworky = sys.argv[2] if platform.system() == 'Linux': uglychars = ''.join( set(string.punctuation+' ')

Re: Redirecting stdin/stdout to self

2006-01-23 Thread Dan M
>>> And if I'm reading it correctly, the Perl >>> script's process starts tcpdump, but redirects its output to its own >>> input, and reads it line by line. And to clarify, what the Perl script is doing is redirecting the standard error to standard out. STDIN is file handle 0, STDOUT is file handl

Re: list comprehention

2006-01-23 Thread Patrick Maupin
Duncan Booth showed how to solve a problem posed by Mathijs. This is very similar to Duncan's solution, except I (ab)use setdefault on a regular basis... >>> def occurrences(t): ... res = {} ... for item in t: ... res.setdefault(item,[0])[0] += 1 ... return res ... >>> ref = [

Re: Real-world use cases for map's None fill-in feature?

2006-01-23 Thread rurpy
"Andrae Muys" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I am still left with a difficult to express feeling of > > dissatifaction at this process. > > > > Plese try to see it from the point of view of > > someone who it not a expert at Python: > > > > Here is izip(). > > My concepti

Suggestions for workaround in CSV bug

2006-01-23 Thread Simmons, Stephen
Hi, I've come across a bug in CSV where the csv.reader() raises an exception if the input line contains '\r'. Example code and output below shows a test case where csv.reader() cannot read an array written by csv.writer(). I believe this is a known bug and may have been fixed for Python 2.5. Ho

obtain client ip address from SimpleXMLRPCServer ?

2006-01-23 Thread stuff
Is it possible to obtain the client's ip address from a SimpleXMLRPCServer instance or subclass instance? When running SimpleXMLRPCServer with logRequests = 1, the xmlrpc server prints out the fqdn on the console, however, I'm not sure if this information (either fqdn or ip address) is available t

Re: OpenGL

2006-01-23 Thread Fernando Perez
Mike C. Fletcher wrote: > OpenGL-ctypes is designed with a fairly well abstracted array-handling > API. Basically any array type can be registered with handlers that let > you tell the system how to do basic operations; get an array's size, > shape, data-type, convert to a given data-format, bui

Re: logging module question

2006-01-23 Thread chuck
Ok, so I've figured this out (see below), mail = logging.handlers.SMTPHandler('mail.vw.com', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', 'Data Processing Error at location: %s' %

Re: Some thougts on cartesian products

2006-01-23 Thread [EMAIL PROTECTED]
Steven D'Aprano wrote: > On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote: > > > Steven D'Aprano wrote: > >> Bryan Olson wrote: > >> > >> > > [Christoph Zwerschke had written:] > What I expect as the result is the "cartesian product" of the strings. > >>> > >>>There's no such thing; you'd

Re: Oddities of Tkinter

2006-01-23 Thread James Stroud
Tuvas wrote: > Only 1 process initiated Tkinter.Tk. I guess this'll just be a tough > bug hunt... It drives me nuts that it should work, it just doesn't for > some reason... I guess I can try various things to make it work, but, > well, I would rather that it just works to start out with... > If

problem getting started with pyDB2

2006-01-23 Thread jimburton
Hi, I'm using python 2.4, DB2 8.1 (with development libraries) on ubuntu linux 5.10. I installed PyDB2 1.1 but when I try to connect to any database I've got this: >>> import DB2 >>> conn = DB2.connect(dsn='sample', uid='db2inst1', pwd='secret') Traceback (most recent call last): File "", line 1

Re: converting wiki markup to html (or xml)

2006-01-23 Thread Tim Parkin
Jarek Zgoda wrote: > Tim Parkin napisa�(a): > > >>I'm trying to convert fragments of wiki markup into fragments of html >>(specifically using moinmoin markup). I've managed to do this with >>MoinMoin but I've had to create a data directory, config file and >>underlay. Does anybody know if there a

Loop exception catching

2006-01-23 Thread Ivan Shevanski
Alright this is kind of a continuation of a past conversation. . .But not really.  Anyway, heres the problem.  Say I had this:     try:    x = input("> ")    except SyntaxError:   print "explain the problem here"   x = input("> ")That's to catch when people just pres

Re: trying to get hash from os.urandom

2006-01-23 Thread Robert Kern
Paul Rubin wrote: > IMO it's better to use words than strings of letters. Try something > like (untested): > >import binascii,os >short_words = [w.strip() for w in file('/usr/dict/words') if len(w) < 8] >assert len(short_words) > 5000 >passphrase = [] > >for i in range(2):

How to build Boost.Python

2006-01-23 Thread Andrew Ayre
Hi, I can't seem to get the library built, and any help is greatly appreciated. Here is the info: Windows XP Borland C++ Builder 5 Latest Boost source code (downloaded at the weekend) Windows binary bjam 3.1.11 Command line: bjam "-sTOOLS=borland" "--with-python-root=C:\Python" "--with-python" i

Re: trying to get hash from os.urandom

2006-01-23 Thread Paul Rubin
Grzegorz Smith <[EMAIL PROTECTED]> writes: > '\xec2a\xe2\xe2\xeb_\n',"\x9f\\]'\xad|\xe6\xeb",'\xb0\xf8\xd3\xa0>01\xaf'. > How can I convert this to hash? i change python defaultencoding from ascii > to utf-8 and try convert this to unicode object but I only get: Don't use totally arbitrary 8-bit

Re: list comprehention

2006-01-23 Thread Steven D'Aprano
On Mon, 23 Jan 2006 17:41:55 +, Mathijs wrote: > Op 19 jan 2006 vond "[EMAIL PROTECTED]" : > >> another approach: >> >> ref = [2,2,4,1,1] >> lis = [2,2,5,2,4] >> >> len([ref.pop(ref.index(x)) for x in lis if x in ref]) >> > > This is the type of solution I was hoping to see: one-liners, w

Re: Some thougts on cartesian products

2006-01-23 Thread Steven D'Aprano
On Mon, 23 Jan 2006 18:17:08 +, Bryan Olson wrote: > Steven D'Aprano wrote: >> Bryan Olson wrote: >> >> > [Christoph Zwerschke had written:] What I expect as the result is the "cartesian product" of the strings. >>> >>>There's no such thing; you'd have to define it first. Are duplicates

Re: Oddities of Tkinter

2006-01-23 Thread Tuvas
Only 1 process initiated Tkinter.Tk. I guess this'll just be a tough bug hunt... It drives me nuts that it should work, it just doesn't for some reason... I guess I can try various things to make it work, but, well, I would rather that it just works to start out with... -- http://mail.python.org/

Re: Some thoughts on garbage collection

2006-01-23 Thread Martin v. Löwis
Frank Millman wrote: > In principle I agree. My concern was that I might have inadvertently > done something wrong (e.g. left a reference dangling) which would > prevent gc from removing all objects which I wanted to be removed. Depends on what it really is that you want to know. If you want to kn

Re: C Extended module init/cleanup

2006-01-23 Thread Farshid Lashkari
> Can C extended python modules provide any kind module destructor, so > that whenever the module is unloaded some cleanup is run? I've needed the same thing before but couldn't find it. AFAIK, the best you can do is register an exit function that will be called when python exits. Here is a sa

logging module question

2006-01-23 Thread chuck
I want to create two different loggers so that users see one output (e.g. no exception/stack traces) and others (e.g support staff) that does see stack traces via email. The code below is close but I still get console output on the email logger from the "root" logger. How do I get rid of it? im

Re: Testing for the presence of input from stdin.

2006-01-23 Thread Peter Gsellmann
Will McDonald wrote: > On 23/01/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >> > I can get the script to behave as expected when content's piped to it >> > using sys.stdin but I'd like to know that there's data coming from >> > stdin or fail and print the useage again. Is there a simple way to

trying to get hash from os.urandom

2006-01-23 Thread Grzegorz Smith
Hi all I'm writing small python module which will be a password generator. I read that python can use system random generator on machine whit *nix os. So i start using os.urandom and when i generate random string i get something like this: urandom(8) -> '\xec2a\xe2\xe2\xeb_\n',"\x9f\\]'\xad|\xe6\x

Re: Concurrency, I guess

2006-01-23 Thread Grant Edwards
On 2006-01-23, Stormcoder <[EMAIL PROTECTED]> wrote: > Using candygram you can send the sync thread a message telling it to > reread the config file or you could send a message that changes the > setting directly. Candygram is much better than the standard threading > module which is designed afte

Re: Concurrency, I guess

2006-01-23 Thread Grant Edwards
On 2006-01-20, David S <[EMAIL PROTECTED]> wrote: > Anyway, I have tried messing around with the threading module > and referenced some examples I have come across, but to no > avail. Fundamentally I expected that when I change a global > variable in 1 thread, the new value would be picked up in

C Extended module init/cleanup

2006-01-23 Thread Carl J. Van Arsdall
I'm extending Python with C, it seems as though initialization is easy enough with an init() function that all C extended python modules must provide that can serve as a sort of "module constructor". Can C extended python modules provide any kind module destructor, so that whenever the module i

Re: Concurrency, I guess

2006-01-23 Thread Stormcoder
Using candygram you can send the sync thread a message telling it to reread the config file or you could send a message that changes the setting directly. Candygram is much better than the standard threading module which is designed after the Java threading library. Java recently added another thre

Re: Loading a Python collection from an text-file

2006-01-23 Thread Ken Starks
Ilias Lazaridis wrote: > within a python script, I like to create a collection which I fill with > values from an external text-file (user editable). > > How is this accomplished the easiest way (if possible without the need > of libraries which are not part of the standard distribution)? > > so

Re: Some thougts on cartesian products

2006-01-23 Thread Kay Schluehr
Bryan Olson wrote: > There's no such thing; you'd have to define it first. Are duplicates > significant? Order? That's all trivial isn't it? A string is a set of pairs (i,c) where i is an integer number, the index, with 0<=ihttp://mail.python.org/mailman/listinfo/python-list

Re: Numarray, numeric, NumPy, scpy_core ??!!

2006-01-23 Thread Sébastien Boisgérault
Robert Kern wrote: > Sébastien Boisgérault wrote: > > Robert Kern wrote: > > > >>Sébastien Boisgérault wrote: > >> > >>>By the way, I tried numpy 0.9.4 10 minutes ago and guess > >>>what ? 'eigenvalue' is broken too ... (hangs forever) > >> > >>On what platform? > > > > Linux, Mandriva 2006 (gcc 4

Re: Numarray, numeric, NumPy, scpy_core ??!!

2006-01-23 Thread Sébastien Boisgérault
[EMAIL PROTECTED] wrote: > Robert Kern wrote: > > Sébastien Boisgérault wrote: > > > > > By the way, I tried numpy 0.9.4 10 minutes ago and guess > > > what ? 'eigenvalue' is broken too ... (hangs forever) > > > > On what platform? Are you linking against an optimized BLAS? We can't fix > > anythi

Re: ANN: Introduction to Event-Driven Programming

2006-01-23 Thread Carl Cerecke
Randall Parker wrote: > Steve, > > This is an aside: I'd love to see someone implement in Python a > framework similar to the Quantum Leaps Quantum Framework for > event-driven programming. I think Python has some features that lend > themselves to a neater implementation than what can be done in

Re: Backreferences in python ?

2006-01-23 Thread Giovanni Bajo
Pankaj wrote: Perl ::: > *** > while( ) > { > > line = $_; > > pattern = "printf\( \"$lineNo \" \),"; > > line =~ s/"for(.*)\((*.)\;(.*)/for$1\($pattern$2\;$3/g; > } > > This is used to > > search for :for ( i = 0; i < 10; i++) > Replace with: for( printf( "10" ),

trying to use swig for the first time

2006-01-23 Thread Gary Wilson Jr
...I have some C code (foo.c and foo.h) that I would like to be able to access using python. I've written my interface file (foo.i) like so: %module foo %{ #include "foo.h" %} %include "foo.h" I then do the following on the command line: $ swig -python foo.i $ gcc -c foo.c foo_wrap.c -I /usr/inc

Re: Oddities of Tkinter

2006-01-23 Thread James Stroud
Tuvas wrote: > Nope, that's the oddest thing about it all... Perhaps the statement is > called twice or something along those lines, but there again, I can't > see how it would be... > Very strange behavior can occur if the same python process instantiates Tkinter.Tk more than once (either con

Re: Oddities of Tkinter

2006-01-23 Thread Tuvas
Nope, that's the oddest thing about it all... Perhaps the statement is called twice or something along those lines, but there again, I can't see how it would be... -- http://mail.python.org/mailman/listinfo/python-list

Re: Oddities of Tkinter

2006-01-23 Thread James Stroud
Tuvas wrote: > I am building a tkinter program. A part of this program is to read data > from an incoming interface, and depending on the data, will display a > bit of text on the tk dialog, it decodes this data, so to speak. If one > command is sent, everything's just fine. When multiple are sent,

Re: Loading a Python collection from an text-file

2006-01-23 Thread James Stroud
Ilias Lazaridis wrote: > within a python script, I like to create a collection which I fill with > values from an external text-file (user editable). > > How is this accomplished the easiest way (if possible without the need > of libraries which are not part of the standard distribution)? > > s

XML + Elementree + (ZODB or Durus) experiments?

2006-01-23 Thread News Reader
A year or so ago, there was a posting - I believe on someone's blog - which told of a unique experiment. The experimenter tried loading and searching a large XML document based on three strategies: 1. (I think) elementree directly 2. Store entire XML document in ZODB (or Durus, can't remember)

Re: Redirecting stdin/stdout to self

2006-01-23 Thread Grant Edwards
On 2006-01-23, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2006-01-23, Jan Danielsson <[EMAIL PROTECTED]> wrote: > >> And if I'm reading it correctly, the Perl >> script's process starts tcpdump, but redirects its output to its own >> input, and reads it line by line. > [...] >>...however, th

Re: Problems with import of modules

2006-01-23 Thread Carl J. Van Arsdall
Ilias Lazaridis wrote: > I am within a directory > > \doc\template\ > > I launch script.py > > within this script.py, I like to import a module from the doc directory. > > this here does not work: > > form ..\..\module_name import this_one > Well, if you are in linux you can do this easily by ch

Re: Redirecting stdin/stdout to self

2006-01-23 Thread Grant Edwards
On 2006-01-23, Jan Danielsson <[EMAIL PROTECTED]> wrote: > And if I'm reading it correctly, the Perl > script's process starts tcpdump, but redirects its output to its own > input, and reads it line by line. [...] >...however, the Perl script solution looks interresting.. Is it > possible to d

Oddities of Tkinter

2006-01-23 Thread Tuvas
I am building a tkinter program. A part of this program is to read data from an incoming interface, and depending on the data, will display a bit of text on the tk dialog, it decodes this data, so to speak. If one command is sent, everything's just fine. When multiple are sent, the program will sto

Re: converting wiki markup to html (or xml)

2006-01-23 Thread Jarek Zgoda
Tim Parkin napisał(a): > I'm trying to convert fragments of wiki markup into fragments of html > (specifically using moinmoin markup). I've managed to do this with > MoinMoin but I've had to create a data directory, config file and > underlay. Does anybody know if there a sane way of doing this wi

Re: Backreferences in python ?

2006-01-23 Thread Paul McGuire
"Pankaj" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > I have something like below in perl and i am searching for equivalent > in python: > > ::: Perl ::: > *** > while( ) > { > > line = $_; > > pattern = "printf\( \"$lineNo \" \),"; > > line =~ s/"for(.*)

Re: Numarray, numeric, NumPy, scpy_core ??!!

2006-01-23 Thread Robert Kern
Sébastien Boisgérault wrote: > Robert Kern wrote: > >>Sébastien Boisgérault wrote: >> >>>By the way, I tried numpy 0.9.4 10 minutes ago and guess >>>what ? 'eigenvalue' is broken too ... (hangs forever) >> >>On what platform? > > Linux, Mandriva 2006 (gcc 4.0.1, etc.) Okay, my answer then is, "D

Re: how to find not the next sibling but the 2nd sibling orfindsibling "a" OR sinbling "b"

2006-01-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > well actually all i want it to do is find the first thing that shows up > whether its class:food or class: drink so that works for me. what makes you think that looking "food" only will find either "food" or "drink" ? -- http://mail.python.org/mailman/listinfo/pyt

Re: Problems with import of modules

2006-01-23 Thread Farshid Lashkari
> How can I modify the python search-path from within the script, thus it > contains the doc directory? Hi, The sys.path variable is a list of strings that contains the current module search path. You can add your own path to this list: import sys sys.path.append('../') -Farshid -- http://ma

Loading a Python collection from an text-file

2006-01-23 Thread Ilias Lazaridis
within a python script, I like to create a collection which I fill with values from an external text-file (user editable). How is this accomplished the easiest way (if possible without the need of libraries which are not part of the standard distribution)? something like: text-file: {peter, 16

wxPython layout problem

2006-01-23 Thread py
I have the following code: [code] class MainFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, wx.ID_ANY, title, style=wx.DEFAULT_FRAME_STYLE |wx.NO_FULL_REPAINT_ON_RESIZE) # build top area topSizer = self.buildTopPanel() # bu

Redirecting stdin/stdout to self

2006-01-23 Thread Jan Danielsson
Hello, I thought I'd write a program to collect information from pf (packet filter) and insert it into a postgresql database for review on a web page. First I checked if this has been done already, and found that it has.. Using Perl and SQLite in a program called "hatchet". Well, I want to do i

Problems with import of modules

2006-01-23 Thread Ilias Lazaridis
I am within a directory \doc\template\ I launch script.py within this script.py, I like to import a module from the doc directory. this here does not work: form ..\..\module_name import this_one how do I go back in the directory hierarchy to import something? If this is not possible: How ca

Re: Numarray, numeric, NumPy, scpy_core ??!!

2006-01-23 Thread Sébastien Boisgérault
Robert Kern wrote: > Sébastien Boisgérault wrote: > > > By the way, I tried numpy 0.9.4 10 minutes ago and guess > > what ? 'eigenvalue' is broken too ... (hangs forever) > > On what platform? Linux, Mandriva 2006 (gcc 4.0.1, etc.) > Are you linking against an optimized BLAS? Nope -- I tried the ba

Re: Numarray, numeric, NumPy, scpy_core ??!!

2006-01-23 Thread greg . landrum
Robert Kern wrote: > Sébastien Boisgérault wrote: > > > By the way, I tried numpy 0.9.4 10 minutes ago and guess > > what ? 'eigenvalue' is broken too ... (hangs forever) > > On what platform? Are you linking against an optimized BLAS? We can't fix > anything without details. I'll be happy to work

Re: list comprehention

2006-01-23 Thread Peter Otten
Mathijs wrote: > Op 20 jan 2006 vond Duncan Booth <[EMAIL PROTECTED]>: >> Or in other words, define a function to return a dictionary containing >> a count of the number of occurrences of each element in the list (this >> assumes that the list elements are hashable). Then you just add up the >> va

Re: how to find not the next sibling but the 2nd sibling or findsibling "a" OR sinbling "b"

2006-01-23 Thread localpricemaps
well actually all i want it to do is find the first thing that shows up whether its class:food or class: drink so that works for me. only thing is that after it finds class:food i think it runs through the html again and finds the following class:drink and being that there is not class tag after t

Re: Dominant color & PIL

2006-01-23 Thread Sebastjan Trepca
Hehe, interesting. I'll try it out.Thanks, SebastjanOn 1/23/06, Terry Hancock <[EMAIL PROTECTED] > wrote:On 23 Jan 2006 05:47:58 -0800"Rinzwind" < [EMAIL PROTECTED]> wrote:> For example:>> getdata>> im.getdata() => sequence>> Returns the contents of an image as a sequence object> containing pixel v

Re: Launch file based on association

2006-01-23 Thread Chris Cioffi
On 23/01/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Chris Cioffi wrote:> Q:  If I have a file called "spreadsheet.xls" how can I launch it in what> ever program it is associated with?  I don't care if that program is Excel> or OpenOffice Calc.  I just want to launch the file. >>> import os>>> hel

Re: list comprehention

2006-01-23 Thread Duncan Booth
Mathijs wrote: > Op 20 jan 2006 vond Duncan Booth <[EMAIL PROTECTED]>: >> Or in other words, define a function to return a dictionary >> containing a count of the number of occurrences of each element in >> the list (this assumes that the list elements are hashable). Then you >> just add up the v

Re: Problem with running external process

2006-01-23 Thread ToMasz
Yes, each time the process is created, it remains. os.waitpid(-1, os.WNOHANG) doesn't work before starting the process for the first time. I tried this: pid = os.fork() if pid == 0: os.execl('ext_script.py','ext_script.py') else: (pid,status) = os.waitpid(pid, 0) It seems to work w

Re: Some thougts on cartesian products

2006-01-23 Thread Bryan Olson
Steven D'Aprano wrote: > Bryan Olson wrote: > > [Christoph Zwerschke had written:] >>>What I expect as the result is the "cartesian product" of the strings. >> >>There's no such thing; you'd have to define it first. Are duplicates >>significant? Order? > > > Google "cartesian product" and hit "

Re: list comprehention

2006-01-23 Thread Mathijs
Op 20 jan 2006 vond Duncan Booth <[EMAIL PROTECTED]>: > Or in other words, define a function to return a dictionary containing > a count of the number of occurrences of each element in the list (this > assumes that the list elements are hashable). Then you just add up the > values in the test list

Re: list comprehention

2006-01-23 Thread Mathijs
Op 19 jan 2006 vond "Paddy" <[EMAIL PROTECTED]>: answer = [ val for val in set(ref) for x in range(min(lst.count(val), ref.count(val)))] answer > [2, 2, 4] I don't think it's correct. Your algoritm with the ref and lst below gives 3 as answer. The answer should have been 2 (1,3). ref=

Re: Backreferences in python ?

2006-01-23 Thread Duncan Booth
Pankaj wrote: > Here problem is , i am not getting backreferences using \1 and \2 > You wrote: > subStrPattern1_hasInitialization = "\1" "\1" is the way to create a string containing a control-A character. What you actually wanted was a string containing a backslash and a "1", so you need e

Re: list comprehention

2006-01-23 Thread Mathijs
Op 19 jan 2006 vond Peter Otten <[EMAIL PROTECTED]> : > sum(min(list.count(n), ref.count(n)) for n in set(ref)) > > Is that it? Seems like this is it! Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Backreferences in python ?

2006-01-23 Thread Pankaj
I got my answer if ( m != None ) : subStrPattern1_hasInitialization = m.group(1) subStrPattern2_hasRestTillEnd = m.group(2) str = subStrPattern1_hasInitialization + subStrPattern2_hasRestTillEnd strToReplace = "for(" + pattern + str This gave me my soluti

Re: list comprehention

2006-01-23 Thread Mathijs
Op 19 jan 2006 vond "[EMAIL PROTECTED]" : > another approach: > > ref = [2,2,4,1,1] > lis = [2,2,5,2,4] > > len([ref.pop(ref.index(x)) for x in lis if x in ref]) > This is the type of solution I was hoping to see: one-liners, with no use of local variables. As Tim Chase already wrote, it has

Re: Some thougts on cartesian products

2006-01-23 Thread Bryan Olson
Steven D'Aprano wrote: > Bryan Olson wrote: >>Christoph Zwerschke wrote: >>[...] >> >>>That may be the main problem to decide whether the cartesian product >>>should return a generator or a list. >> >>The Cartesion product is a set. > > And the generalization of mathematical sets in Python can be

Re: wxPython or wxWidgets

2006-01-23 Thread Grant Edwards
On 2006-01-23, Matthias Kaeppler <[EMAIL PROTECTED]> wrote: >> wxPython are the Python bindings to wxWidgets which is a C++ library. > > Don't want to hijack the thread, but since it's answered already: > Has wxWidgets finally arrived at migrating to GTK2? Yes. -- Grant Edwards

Re: Backreferences in python ?

2006-01-23 Thread Pankaj
My tries have with re have not yielded results:: { strToFind = 'for*;*' ## Converting int to string, i.e. line no. to string lineNoClone = lineno pattern = "printf(\"" + str( lineNoClone) + "\")," regObj = re.compile( strToFind) m = regObj.searc

Re: wxPython or wxWidgets

2006-01-23 Thread Matthias Kaeppler
Marc 'BlackJack' Rintsch wrote: > wxPython are the Python bindings to wxWidgets which is a C++ library. Don't want to hijack the thread, but since it's answered already: Has wxWidgets finally arrived at migrating to GTK2? ^^ If so, I might consider using wxPython instead of pygtk for that small a

Re: Launch file based on association

2006-01-23 Thread Paul Boddie
Fredrik Lundh wrote: > Chris Cioffi wrote: > > > Q: If I have a file called "spreadsheet.xls" how can I launch it in what > > ever program it is associated with? I don't care if that program is Excel > > or OpenOffice Calc. I just want to launch the file. > > >>> import os > >>> help(os.startfil

Re: Cross-module imports?

2006-01-23 Thread Matthias Kaeppler
Ant wrote: > If you have to trick the compiler like this though, I'd take a good > look at *why* you want to couple the modules so tightly in the first > place! Yeah, you're right. I think loosening up the coupling by introducing a module which holds common shared data is probably a good idea any

Re: Some thougts on cartesian products

2006-01-23 Thread Christoph Zwerschke
Bryan Olson schrieb: > Christoph Zwerschke wrote: > [...] >> That may be the main problem to decide whether the cartesian product >> should return a generator or a list. > > The Cartesion product is a set. Of course it is a set. But if the factors of the product have a total order (as in the ca

Re: Xah's Edu Corner: IT Industry Predicament

2006-01-23 Thread sszmidt
On Friday 20 January 2006 15:42, Keith Thompson wrote: > "Xah Lee" <[EMAIL PROTECTED]> writes: > [the usual] > > ___ > /| /| | | > > ||__|| | Please do | > >

RE: Strange python behavior with modules on an emt64 box

2006-01-23 Thread Joshua Luben
To clarify this issue, I checked, DCOracle is compile such that sizeof(int) = 4, sizeof(long) = 8. I guess this is closer to what you are expecting. If a 'Python' int is a C long, then why is it passing in a 4 byte size? Digging deaper, I've found that this size is not passed in by Python, but

Re: Launch file based on association

2006-01-23 Thread Fredrik Lundh
Chris Cioffi wrote: > Q: If I have a file called "spreadsheet.xls" how can I launch it in what > ever program it is associated with? I don't care if that program is Excel > or OpenOffice Calc. I just want to launch the file. >>> import os >>> help(os.startfile) Help on built-in function startf

  1   2   >