Re: Impossible to change methods with special names of instances of new-style classes?

2008-07-10 Thread Steven D'Aprano
On Tue, 08 Jul 2008 17:56:45 -0400, Joseph Barillari wrote: > Hi python-list, > > I've just started using new-style classes and am a bit confused as to > why I can't seem to alter methods with special names (__call__, etc.) of > new-style class instances. [deploy weapon of mass snippage] Here i

ANN: Mac OS X versions of Rabbyt 0.81 - A fast 2D sprite engine using OpenGL

2008-07-10 Thread Python Nutter
Just a quick announcement, I have supplied PPC and Intel compiled eggs for the Rabbyt libary on Pypi http://pypi.python.org/pypi/Rabbyt/ Rabbyt-0.8.1-py2.5-macosx-10.3-ppc.egg (md5) Built on OS X 10.5.4 for PowerPC equipped Macs Rabbyt-0.8.1-py2.5-macosx-10.3-i386.egg (md5) Built on OS X 10.5.4

Re: a simple 'for' question

2008-07-10 Thread Tim Roberts
Ethan Furman <[EMAIL PROTECTED]> wrote: >Ben Keshet wrote: >> it didn't help. it reads the pathway "as is" (see errors for both >> tries). It looks like it had the write pathway the first time, but >> could not find it because it searched in the path/way instead of in the >> path\way. thanks

Re: start reading from certain line

2008-07-10 Thread Steven D'Aprano
On Wed, 09 Jul 2008 09:59:32 -0700, norseman wrote: > I would use: > > readthem= 0 > file=open(filename,'r') > while readthem == 0: >line=file.readline() >if not line: > break >if 'Item 1' in line: > readthem= 1 > # print line # uncomment if 'Item 1' is to

Re: Impossible to change methods with special names of instances of new-style classes?

2008-07-10 Thread Bruno Desthuilliers
samwyse a écrit : On Jul 8, 4:56 pm, Joseph Barillari <[EMAIL PROTECTED]> wrote: My question is: did something about the way the special method names are implemented change for new-style classes? Just off the top of my head, I'd guess that it's due to classes already having a default __call__

Fwd: [ANN] Genshi 0.5.1 released

2008-07-10 Thread Jeroen Ruigrok van der Werven
We have put up eggs for various operating systems as well. - Forwarded message from Christopher Lenz <[EMAIL PROTECTED]> - From: Christopher Lenz <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: [ANN] Genshi 0.5.1 released Date: Wed, 9 Jul 2008 21:44:11 +0200 X-Mailer: Apple Mail (2.926

Re: Allow tab completion when inputing filepath?

2008-07-10 Thread Tim Golden
Keith Hughitt wrote: On Jul 9, 10:18 am, Tim Golden <[EMAIL PROTECTED]> wrote: Keith Hughitt wrote: I've been looking around on the web for a way to do this, but so far have not come across anything for this particular application. I have found some ways to enable tab completion for program-rel

Re: Terminate a python script from linux shell / bash script

2008-07-10 Thread Piet van Oostrum
> Gros Bedo <[EMAIL PROTECTED]> (GB) wrote: >GB> I have a question about Python and Linux shell. I have a python >GB> program which is permanently resident in the end-user system. I'm >GB> currently producing a RPM package, and it works nicely. The problem is >GB> that when I uninstall it, my

Re: error when porting C code to Python (bitwise manipulation)

2008-07-10 Thread Jordan
Well, I have figured out something that works: def findit(u): u += 0xe91aaa35 u1 = ~(0x - u) ^ u >> 16 u1 += ((u1 << 8) & 0x) u1 ^= (u1 & 0x) >> 4 b = (u1 >> 8) & 0x1ff a = (u1 + (u1 << 2) & 0x) >> 19 r = int(a) ^ hash_adjust[int(b)]

Re: Freesoftware for auto/intelligent code completing in Python

2008-07-10 Thread Ali Servet Dönmez
On Jul 10, 1:07 am, Gros Bedo <[EMAIL PROTECTED]> wrote: > Hello, > Ali I totally support you, neither I couldn't find any really working code > completion for python in a free software, and it's really a mess, at least on > Linux. > > On Windows, there is PyScripter (http://pyscripter.googlepage

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Phillip B Oldham
On Jul 9, 9:26 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > This is somewhat subjective... Some would say that Python's object > model is fundamentally broken and crappy (not MHO, needless to say) > that Python + "solid OO principles" is antinomic !-) Really? Would you happen to be able t

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Phillip B Oldham
Thanks all - lots to go through there! :D I'd heard previously that Trac was a nice example, or rather its core was, but I'd also heard that there were lots of problems with it and that they were redeveloping it from scratch? -- http://mail.python.org/mailman/listinfo/python-list

Re: python scalability

2008-07-10 Thread Mike Hansen
> I have looked at the python > success stories page and haven't come up with anyone quite like us. > One of my project managers questions is: "Are we the only company in the > world with this kind and size of project?" > I want to say no, but am having trouble convincing myself, let alone him. > >

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread Kris Kennaway
John Machin wrote: Uh-huh ... try this, then: http://hkn.eecs.berkeley.edu/~dyoo/python/ahocorasick/ You could use this to find the "Str" cases and the prefixes of the "re" cases (which seem to be no more complicated than 'foo.*bar.*zot') and use something slower like Python's re to search the

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : Thanks all - lots to go through there! :D I'd heard previously that Trac was a nice example, or rather its core was, but I'd also heard that there were lots of problems with it and that they were redeveloping it from scratch? Trac's plugin system is interesting, yes,

Re: Retrieving BSTR * from a DLL

2008-07-10 Thread Andrew MacIntyre
mzdude wrote: I need to interface with a windows DLL that has the following signature extern "C" void Foo( BSTR in, BSTR *out ) Code so far from ctypes import * import comtypes LPBSTR = POINTER(comtypes.BSTR) hdl = windll.MyDll.Foo hdl.rettype = None hdl.argtypes = [comtypes.BSTR, LPBSTR] i

Re: TypeError, I know why but not how!?

2008-07-10 Thread ssecorp
ty I came to the same conckusion in bed :) now it works. however since there are 400 students and some are incompatible I shouldnt be able to generate a 200room list right? but it works sometimes the other times i get an error. might be because of recursion depth i never let the error finish.

Re: TypeError, I know why but not how!?

2008-07-10 Thread John Machin
On Jul 10, 12:07 pm, ssecorp <[EMAIL PROTECTED]> wrote: > pair1 = (student1,student2) > pair2 = (student2,student1) > if (pair1 or pair2) in incompatibles: Apart from the problems that others have mentioned, the above statement is NOT doing what you think it is. (pair1 or pair2) will

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Bruno Desthuilliers
Phillip B Oldham a écrit : On Jul 9, 9:26 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: This is somewhat subjective... Some would say that Python's object model is fundamentally broken and crappy (not MHO, needless to say) that Python + "solid OO principles" is antinomic !-) Really? Woul

Re: FOSS projects exhibiting clean/good OOP?

2008-07-10 Thread Michele Simionato
On Jul 9, 4:38 pm, Phillip B Oldham <[EMAIL PROTECTED]> wrote: > I'm wondering whether anyone can offer suggestions on FOSS projects/ > apps which exhibit solid OO principles, clean code, good inline > documentation, and sound design principles? > > I'm devoting some time to reviewing other people'

Graphics

2008-07-10 Thread vanam
hi all i am new to python programming a beginner. I Came to know from the groups that "How to think like a computer scientist" is preferable for begineers. i just looking through that i came to one section where a sample program for generation of graphics is present.i tried to copy the same script

B-Soup: broken iterator, tag a keyword?

2008-07-10 Thread Brendan
Hi there, I have the following using Beautiful Soup: soup = BeautifulSoup(data) tags = soup.findAll(href=re.compile("/MER_FRS_L2_Canada/MER_FRS_\S +gz")) for tag in tags: print tag['href'] print tag.parent.nextSibling.string print tag.parent.nextSibling.nextSibling.string print tag

Re: Relative Package Import

2008-07-10 Thread Thomas
Peter Otten wrote: Thomas wrote: Robert Hancock wrote: mypackage/ __init__.py push/ __init__.py dest.py feed/ __init__py subject.py In subject.py I have from ..push import dest T

Automatic keyword argument source change?

2008-07-10 Thread jorjun
Anyone know of a Python source code utility PSU, to automatically add keyword arguments to method calls that don't have them? : BEFORE def get_total(books, binders, hinges): return (binders.total + hinges.total - books.cost) def print_total(): print get_total(novels, covers, brackets) A

Re: Allow tab completion when inputing filepath?

2008-07-10 Thread Sion Arrowsmith
Keith Hughitt <[EMAIL PROTECTED]> wrote: >> Keith Hughitt wrote: >> > [ ... ] I have >> > found some ways to enable tab completion for program-related commands, >> > but not for system filepaths. >Currently Unix/Console. What's wrong with the readline module? http://docs.python.org/lib/module-re

Re: Graphics

2008-07-10 Thread Michiel Overtoom
Vanam wrote... > I want to know whether is there anything that has > to be installed in addition to python 2.5 > > from gasp import * You have to install the 'gasp' package too. https://launchpad.net/gasp-code/stable-0.1.x/0.1.1 -- "The ability of the OSS process to collect and harness the

Re: Retrieving BSTR * from a DLL

2008-07-10 Thread mzdude
On Jul 10, 6:15 am, Andrew MacIntyre <[EMAIL PROTECTED]> wrote: > This likely indicates that the DLL is using the C calling convention > and not the stdcall calling convention.  Use CDLL rather than WinDLL > to load the DLL. using cdll got me over the calling hurdle. However, I'm not seeing the r

Re: python scalability

2008-07-10 Thread Bruno Desthuilliers
Tim Mitchell a écrit : Hi All, I work on a desktop application that has been developed using python and GTK (see www.leapfrog3d.com). We have around 150k lines of python code (and 200k+ lines of C). We also have a new project manager with a C# background who has deep concerns about the scal

Re: User-defined exception: "global name 'TestRunError' is not defined"

2008-07-10 Thread Sion Arrowsmith
In article <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote: >I'm using some legacy code that has a user-defined exception in it. > >The top level program includes this line > >from TestRunError import * > >It also imports several other modules. These other modules do not >explicitly import TestRun

Symposium "Image Processing and Data Visualization" within the SEECCM 2009, Greece - Announce & Call for Papers

2008-07-10 Thread [EMAIL PROTECTED]
(Our apologies for cross-posting. We appreciate if you kindly distribute this information by your co- workers and colleagues.) *** Symposium “Image Processing and Data Visualization” 2nd South-East European Conference on Comp

Re: python scalability

2008-07-10 Thread Michele Simionato
On Jul 10, 6:32 am, Tim Mitchell <[EMAIL PROTECTED]> wrote: > Hi All, > > I work on a desktop application that has been developed using python and > GTK (seewww.leapfrog3d.com).  We have around 150k lines of python code > (and 200k+ lines of C). We have bigger numbers than yours here (although not

Re: TypeError, I know why but not how!?

2008-07-10 Thread ssecorp
I don't fully understand why I have to do this. On Jul 10, 4:17 am, Robert Kern <[EMAIL PROTECTED]> wrote: > ssecorp wrote: > > Im looking into PvsNP: > >http://www.claymath.org/millennium/P_vs_NP/ > > so I thought I'd write the program just to get a feel for it. > > > But I run into a problem. W

Weird lambda rebinding/reassignment without me doing it

2008-07-10 Thread ssecorp
I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that somehow means that the modified list is part of the environment and not the old one. i thought what happend inside a function stays inside a function meaning what comes out is in

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-10 Thread Bill Davy
"Tim Roberts" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Bill Davy" <[EMAIL PROTECTED]> wrote: >> >>I am trying to edit Contacts in Outlook. This is so I can transfer >>numbers >>from my address book which is an Excel spreadsheet to my mobile phone. > > Are you actually runni

Re: start reading from certain line

2008-07-10 Thread jstrick
Here's a simple way to do it with a minimum amount of loopiness (don't forget to use 'try-except' or 'with' in real life): f = open("item1.txt") for preline in f: if "Item 1" in preline: print preline, for goodline in f: # could put an end condition with a 'break'

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-10 Thread Tim Golden
Bill Davy wrote: I'm not sure OL2003 can read news. I think perhaps some later OL can (added tot he View menu, perhaps?). So I use OL Express to read news. The OL with which I wish to communicate is: Application name Outlook Version 11.0 Build 8217 Product ID 70141-700-0350904-56905 Languag

Re: socket-module: different behaviour on windows / unix when a timeout is set

2008-07-10 Thread Grant Edwards
On 2008-07-10, A.T.Hofkamp <[EMAIL PROTECTED]> wrote: > On 2008-07-09, Mirko Vogt <[EMAIL PROTECTED]> wrote: >> Is that behaviour common or even documented? Found nothing. > Second sentence in the socket module documentation: > > Note: Some behavior may be platform dependent, since calls are > made

Changing self: if self is a tree how to set to a different self

2008-07-10 Thread Bart Kastermans
I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS does not work; I have to write self.val = SS.val and the same for the other members (as shown below).

Re: Weird lambda rebinding/reassignment without me doing it

2008-07-10 Thread A.T.Hofkamp
Python doesn't use value semantics for variables but reference semantics: a = [1] b = a In many languages, you'd now have 2 lists. In Python you still have one list, and both a and b refer to it. Now if you modify the data (the list), both variables will change a.append(2) # in-place modificat

handling unexpected exceptions in pdb

2008-07-10 Thread Simon Bierbaum
Hi all, I'm in an interactive session in pdb, debugging my code using pdb.runcall. Somewhere, an exception is raised and lands uncaught on stdout. Is there any way of picking up this exception and at least read the full message, or even accessing its stack trace to determine where exactly

Re: python scalability

2008-07-10 Thread Jeffrey Froman
Tim Mitchell wrote: > One of my project managers questions is: "Are we the only company in the > world with this kind and size of project?" I can't provide a bigger success story personally (my largest project is currently about 15k lines of code, eminently manageable by one person.) But Google c

Re: Does omniORBpy 3.2 supports DII?

2008-07-10 Thread Wolfgang Keller
> My apologies if this is not the correct forum for thses quiestions, It's not the wrong place to ask, but you're more likely to get answers from the omniORB mailing lists: http://www.omniorb-support.com/mailman/listinfo Sincerely, Wolfgang -- http://mail.python.org/mailman/listinfo/python-lis

Loading just in time

2008-07-10 Thread D'Arcy J.M. Cain
I am trying to create a utility module that only loads functions when they are first called rather than loading everything. I have a bunch of files in my utility directory with individual methods and for each I have lines like this in __init__.py: def calc_tax(*arg, **name): from calc_tax imp

Smal question

2008-07-10 Thread Hans Müller
Hello group, I have some scripts sharing some common functions. So what I'd like to have is a modern include. Of course python does not have (with good reasons) no include statement. But I'm too lazy to create a module which has to be installed into the interpreter for some functions I need to s

Re: Smal question

2008-07-10 Thread Nick Dumas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 This is easy. Simply create a .py file containing all the methods you want to share. Put this file in the same directory as the rest of your project files. In each of your project files that requires one of the methods, simply "import ". Python support

RE: Terminate a python script from linux shell / bash script

2008-07-10 Thread Gros Bedo
>>That's not how it works. If you kill one running python script it will not >>effect other python scripts. Each script has its own interpreter process >>running. >GB> So, is there a way from the Linux shell or a bash script to terminate >GB> just one specific Python script ? >>So just kill it

profiling question

2008-07-10 Thread Neal Becker
Just to confirm, the profiling numbers (from cProfile) do include time spent inside my own C functions that I import as modules? -- http://mail.python.org/mailman/listinfo/python-list

Re: Smal question

2008-07-10 Thread Hans Müller
Thanks a lot, you made my day. As often in python, it's really simple and useful ! Greetings Hans -- http://mail.python.org/mailman/listinfo/python-list

Re: Python / Windows process control

2008-07-10 Thread Tim Golden
Salim Fadhley wrote: Does anybody know of a python module which can do process management on Windows? The sort of thing that we might usually do with taskmgr.exe or process explorer? For example: * Kill a process by ID * Find out which process ID is locking an object in the filesystem * Find ou

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread J. Cliff Dyer
On Wed, 2008-07-09 at 12:29 -0700, samwyse wrote: > On Jul 8, 11:01 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: > > samwyse wrote: > > > > You might want to look at Plex. > > >http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ > > > > > "Another advantage of Plex is that it compiles all of

Re: python scalability

2008-07-10 Thread Larry Bates
Tim Mitchell wrote: Hi All, I work on a desktop application that has been developed using python and GTK (see www.leapfrog3d.com). We have around 150k lines of python code (and 200k+ lines of C). We also have a new project manager with a C# background who has deep concerns about the scalabi

Local User Control

2008-07-10 Thread Sparky
I don't know how feasible this is, but is it possible to have users log in to access a local database file in such a way that allows the program to know what user name and password they logged in with? This would involve separate user names and passwords for each user. Thanks for your time and hel

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 2:45 pm, jstrick <[EMAIL PROTECTED]> wrote: > Here's a simple way to do it with a minimum amount of loopiness (don't > forget to use 'try-except' or 'with' in real life): > > f = open("item1.txt") > > for preline in f: >     if "Item 1" in preline: >         print preline, >         for

Re: Local User Control

2008-07-10 Thread Tim Golden
Sparky wrote: I don't know how feasible this is, but is it possible to have users log in to access a local database file in such a way that allows the program to know what user name and password they logged in with? This would involve separate user names and passwords for each user. Well, this

Re: start reading from certain line

2008-07-10 Thread Iain King
On Jul 10, 4:54 pm, Iain King <[EMAIL PROTECTED]> wrote: > On Jul 10, 2:45 pm, jstrick <[EMAIL PROTECTED]> wrote: > > > Here's a simple way to do it with a minimum amount of loopiness (don't > > forget to use 'try-except' or 'with' in real life): > > > f = open("item1.txt") > > > for preline in f:

Re: Loading just in time

2008-07-10 Thread Larry Bates
D'Arcy J.M. Cain wrote: I am trying to create a utility module that only loads functions when they are first called rather than loading everything. I have a bunch of files in my utility directory with individual methods and for each I have lines like this in __init__.py: def calc_tax(*arg, **na

Re: Local User Control

2008-07-10 Thread Sparky
On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Sparky wrote: > > I don't know how feasible this is, but is it possible to have users > > log in to access a local database file in such a way that allows the > > program to know what user name and password they logged in with? This > > wo

Re: Loading just in time

2008-07-10 Thread D'Arcy J.M. Cain
On Thu, 10 Jul 2008 11:03:10 -0500 Larry Bates <[EMAIL PROTECTED]> wrote: > D'Arcy J.M. Cain wrote: > > def calc_tax(*arg, **name): > > from calc_tax import calc_tax as _func_ > > calc_tax = _func_ > > return _func_(*arg, **name) > You are stuck in a futile battle called "premature opt

Re: Local User Control

2008-07-10 Thread Tim Golden
Sparky wrote: On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote: Sparky wrote: I don't know how feasible this is, but is it possible to have users log in to access a local database file in such a way that allows the program to know what user name and password they logged in with? This wo

Re: Weird lambda rebinding/reassignment without me doing it

2008-07-10 Thread David C. Ullrich
In article <[EMAIL PROTECTED]>, ssecorp <[EMAIL PROTECTED]> wrote: > I am never redefining the or reassigning the list when using validate > but since it spits the modified list back out that somehow means that > the modified list is part of the environment and not the old one. > i thought what

Re: a simple 'for' question

2008-07-10 Thread Ethan Furman
Tim Roberts wrote: Ethan Furman <[EMAIL PROTECTED]> wrote: Ben Keshet wrote: it didn't help. it reads the pathway "as is" (see errors for both tries). It looks like it had the write pathway the first time, but could not find it because it searched in the path/way instead of in the path\w

Re: Local User Control

2008-07-10 Thread Sparky
On Jul 10, 10:13 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Sparky wrote: > > On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote: > >> Sparky wrote: > >>> I don't know how feasible this is, but is it possible to have users > >>> log in to access a local database file in such a way that allow

Re: formatting list -> comma separated

2008-07-10 Thread norseman
Robert wrote: given d: d = ["soep", "reeds", "ook"] I want it to print like soep, reeds, ook I've come up with : print ("%s"+", %s"*(len(d)-1)) % tuple(d) but this fails for d = [] any (pythonic) options for this? Robert -- http://mail.python.org/mailman/listinfo/python-list ===

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread Sebastian "lunar" Wiesner
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]>: > On Mon, 07 Jul 2008 16:44:22 +0200, Sebastian \"lunar\" Wiesner wrote: > >> Mark Wooding <[EMAIL PROTECTED]>: >> >>> Sebastian "lunar" Wiesner <[EMAIL PROTECTED]> wrote: >>> # perl -e '("a" x 10) =~ /^(ab?)*$/;' zsh: segmentation fau

Re: Smal question

2008-07-10 Thread Bruno Desthuilliers
Hans Müller a écrit : Hello group, I have some scripts sharing some common functions. So what I'd like to have is a modern include. Of course python does not have (with good reasons) no include statement. But I'm too lazy to create a module which has to be installed into the interpreter for som

Re: ActiveState Code: the new Python Cookbook site

2008-07-10 Thread Trent Mick
Stef Mientki wrote: one small remark, If I want to browse 200 recipes, at 10 per page ... please make something like 100 available per page, are internet is fast enough nowadays. Touche. Done: http://code.activestate.com/recipes/?paginate_by=100 Cheers, Trent -- Trent Mick trentm at

Re: Emacs/Python Essentials?

2008-07-10 Thread Sebastian "lunar" Wiesner
xkenneth <[EMAIL PROTECTED]>: > What does everyone consider essential for emacs python dev? yasnippet is worth being looked at -- Freedom is always the freedom of dissenters. (Rosa Luxemburg) -- http://mail.python.org/mailman/listinfo/python-list

installing any python module

2008-07-10 Thread Bhagwat Kolde
Hi all, What is the correct process of installing any external python module? Once we downloaded any python module, Q1) Where this module should be placed in python installation file structure? Q2) How to execute setup.py file? Thanks, Bhagwat -- http://mail.python.org/mailman/listinfo/python-

Re: variable question

2008-07-10 Thread norseman
Support Desk wrote: I am trying to assign a variable using an if / else statement like so: If condition1: Variable = something If condition2: Variable = something else Do stuff with variable. But the variable assignment doesn't survive outside the if stateme

Re: plugins using cvs/distutils?

2008-07-10 Thread Sebastian "lunar" Wiesner
Deacon <[EMAIL PROTECTED]>: > Hi. I have an open-source application development environment that I > would like to enable an automated package download system for (like > downloadable plugins), using sourceforge as its repository. My > software will have a menu-based popup window, that will list t

Idiomatic Python to convert list to dict

2008-07-10 Thread James Fassett
Hi all, Simple question really on a best practice. I want to avoid adding duplicates to a list. my_list = ['a', 'b', 'c', 'd', 'e'] dup_map = {} for item in my_list: dup_map[item] = True # ... sometime later for complex_dict in large_list: if complex_dict["char"] not in dup_map:

Re: Idiomatic Python to convert list to dict

2008-07-10 Thread Diez B. Roggisch
James Fassett schrieb: Hi all, Simple question really on a best practice. I want to avoid adding duplicates to a list. my_list = ['a', 'b', 'c', 'd', 'e'] dup_map = {} for item in my_list: dup_map[item] = True # ... sometime later for complex_dict in large_list: if complex_dict["char"

Re: re.search much slower then grep on some regular expressions

2008-07-10 Thread Kris Kennaway
J. Cliff Dyer wrote: On Wed, 2008-07-09 at 12:29 -0700, samwyse wrote: On Jul 8, 11:01 am, Kris Kennaway <[EMAIL PROTECTED]> wrote: samwyse wrote: You might want to look at Plex. http://www.cosc.canterbury.ac.nz/greg.ewing/python/Plex/ "Another advantage of Plex is that it compiles all of the

Re: Determining when a file has finished copying

2008-07-10 Thread Manuel Vazquez Acosta
Cameron Simpson wrote: > On 09Jul2008 15:54, Ethan Furman <[EMAIL PROTECTED]> wrote: >> The solution my team has used is to monitor the file size. If the file >> has stopped growing for x amount of time (we use 45 seconds) the file is >> done copying. Not elegant, but it works. > > If you kn

Re: Idiomatic Python to convert list to dict

2008-07-10 Thread craig75
On Jul 10, 10:06 am, James Fassett <[EMAIL PROTECTED]> wrote: > Hi all, > > Simple question really on a best practice. I want to avoid adding > duplicates to a list. > > my_list = ['a', 'b', 'c', 'd', 'e'] > dup_map = {} > for item in my_list: >     dup_map[item] = True > > # ... sometime later > >

Re: Idiomatic Python to convert list to dict

2008-07-10 Thread James Fassett
On Jul 10, 6:13 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > > my_list = ['a', 'b', 'c', 'd', 'e'] > > dup_map = {} > > for item in my_list: > >     dup_map[item] = True > > > # ... sometime later > > > for complex_dict in large_list: > >     if complex_dict["char"] not in dup_map: > >      

Re: error when porting C code to Python (bitwise manipulation)

2008-07-10 Thread MRAB
On Jul 10, 4:56 am, Jordan <[EMAIL PROTECTED]> wrote: > I am trying to rewrite some C source code for a poker hand evaluator > in Python.  Putting aside all of the comments such as just using the C > code, or using SWIG, etc.  I have been having problems with my Python > code not responding the sam

using Python's AST generator for other languages

2008-07-10 Thread eliben
Hello, I'm building a parser in Python, and while pondering on the design of my ASTs had the idea to see what Python uses. I quickly got to the compiler.ast module, and understood it's automatically generated. So I went to the source, ast.txt and tools/compiler/astgen.py, where I was this unexpect

Fwd: [ANN] Babel 0.9.3 released

2008-07-10 Thread Jeroen Ruigrok van der Werven
- Forwarded message from Christopher Lenz <[EMAIL PROTECTED]> - From: Christopher Lenz <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: [ANN] Babel 0.9.3 released Date: Thu, 10 Jul 2008 11:26:23 +0200 X-Mailer: Apple Mail (2.926) Babel 0.9.3 - Jul 9, 2007 =

Re: Python and decimal character entities over 128.

2008-07-10 Thread Manuel Vazquez Acosta
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 [EMAIL PROTECTED] wrote: > Some web feeds use decimal character entities that seem to confuse > Python (or me). For example, the string "doesn't" may be coded as > "doesn’t" which should produce a right leaning apostrophe. > Python hates decimal entiti

Re: error when porting C code to Python (bitwise manipulation)

2008-07-10 Thread Jordan
On Jul 10, 1:35 pm, MRAB <[EMAIL PROTECTED]> wrote: > On Jul 10, 4:56 am, Jordan <[EMAIL PROTECTED]> wrote: > > > > > I am trying to rewrite some C source code for a poker hand evaluator > > in Python.  Putting aside all of the comments such as just using the C > > code, or using SWIG, etc.  I have

Re: Weird lambda rebinding/reassignment without me doing it

2008-07-10 Thread Terry Reedy
David C. Ullrich wrote: In article <[EMAIL PROTECTED]>, ssecorp <[EMAIL PROTECTED]> wrote: I am never redefining the or reassigning the list when using validate but since it spits the modified list back out that somehow means that the modified list is part of the environment and not the old

Re: Changing self: if self is a tree how to set to a different self

2008-07-10 Thread Terry Reedy
Bart Kastermans wrote: I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS does not work; I have to write self.val = SS.val and the same for the othe

Re: sort(cmp=func)

2008-07-10 Thread norseman
Tobiah wrote: I have a list of objects that generate code. Some of them depend on others being listed first, to satisfy dependencies of others. I wrote a cmp function something like this: def dep_cmp(ob1, ob2): if ob1.name in ob2.deps: return -1 else

Re: Smal question

2008-07-10 Thread Terry Reedy
Bruno Desthuilliers wrote: Hans Müller a écrit : Hello group, I have some scripts sharing some common functions. So what I'd like to have is a modern include. Of course python does not have (with good reasons) no include statement. But I'm too lazy to create a module which has to be installed

Re: Doubts about how implementing asynchronous timeouts through a heap

2008-07-10 Thread Josiah Carlson
On Jul 9, 4:13 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > Hi, > I'm trying to implement an asynchronous scheduler for asyncore to call > functions at a later time without blocking the main loop. > The logic behind it consists in: > > - adding the scheduled functions into a heapified list

Re: Elisp Lesson on file processing (make downloadable copy of a website)

2008-07-10 Thread Sashi
On Jul 6, 4:05 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > In this week i wrote a emacs program and tutorial that does archiving > a website for offline reading. > (Seehttp://xahlee.org/emacs/make_download_copy.html) Why not use wget or curl? -- http://mail.python.org/mailman/listinfo/pyt

Re: Loading just in time

2008-07-10 Thread samwyse
On Jul 10, 9:45 am, "D'Arcy J.M. Cain" <[EMAIL PROTECTED]> wrote: > I am trying to create a utility module that only loads functions when > they are first called rather than loading everything.  I have a bunch > of files in my utility directory with individual methods and for each I > have lines li

Problems Returning an HTTP 200 Ok Message

2008-07-10 Thread Guy Davidson
Hi Folks, I'm having some issues with an small socket based server I'm writing, and I was hoping I could get some help. My code (attached below) us supposed to read an HTTP Post message coming from a power meter, parse it, and return a proper HTTP 200 Ok message. The problem is that the socket fa

Re: handling unexpected exceptions in pdb

2008-07-10 Thread R. Bernstein
Simon Bierbaum <[EMAIL PROTECTED]> writes: > Hi all, > > I'm in an interactive session in pdb, debugging my code using > pdb.runcall. Somewhere, an exception is raised and lands uncaught on > stdout. Is there any way of picking up this exception and at least > read the full message, or even access

Re: sort(cmp=func)

2008-07-10 Thread Tobiah
On Wed, 09 Jul 2008 20:58:32 -0700, Daniel Fetchinson wrote: >> I have a list of objects that generate code. Some >> of them depend on others being listed first, to >> satisfy dependencies of others. >> >> I wrote a cmp function something like this: >> >> def dep_cmp(ob1, ob2): >> >> i

Re: Problems Returning an HTTP 200 Ok Message

2008-07-10 Thread Joshua Kugler
Guy Davidson wrote: > Hi Folks, > > I'm having some issues with an small socket based server I'm writing, > and I was hoping I could get some help. > > My code (attached below) us supposed to read an HTTP Post message > coming from a power meter, parse it, and return a proper HTTP 200 Ok > messa

Re: Python with Ecmascript

2008-07-10 Thread Alan Isaac
Daniel Fetchinson wrote: Is there a way to do similar things on linux? NJSModule? http://en.wikipedia.org/wiki/NJS Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

parsing incoming emails

2008-07-10 Thread Ahmed, Shakir
HI, I am working on a project where I need to parse incoming emails (Microsoft outlook) with a specific subject into an excel file or a Microsoft access table. I am using python for my GIS works but not sure how I can use python script here to work with Microsoft outlook email. Any h

Re: Problems Returning an HTTP 200 Ok Message

2008-07-10 Thread samwyse
On Jul 10, 1:50 pm, Guy Davidson <[EMAIL PROTECTED]> wrote: > Hi Folks, > > I'm having some issues with an small socket based server I'm writing, > and I was hoping I could get some help. > > My code (attached below) us supposed to read an HTTP Post message > coming from a power meter, parse it, an

Re: parsing incoming emails

2008-07-10 Thread Terry Reedy
I am working on a project where I need to parse incoming emails (Microsoft outlook) with a specific subject into an excel file or a Microsoft access table. You should be able to give Outlook a rule to call a program (your Python one) when the subject matches whatever. From Python, use the

Can this program be shortened? Measuring program-length?

2008-07-10 Thread r.e.s.
Can the following program be shortened? ... def h(n,m): E=n, while (E!=())*m>0:n=h(n+1,m-1);E=E[:-1]+(E[-1]>0)*(E[-1]-1,)*n return n h(9,9) Note: Although it halts eventually in principle, this program can't be expected to terminate on any machine in the universe, as it computes a number lar

Re: error when porting C code to Python (bitwise manipulation)

2008-07-10 Thread Harald Luessen
On Thu, 10 Jul 2008 Jordan wrote: >On Jul 10, 1:35 pm, MRAB <[EMAIL PROTECTED]> wrote: >> On Jul 10, 4:56 am, Jordan <[EMAIL PROTECTED]> wrote: >> >> >> >> > I am trying to rewrite some C source code for a poker hand evaluator >> > in Python.  Putting aside all of the comments such as just using t

Re: You, spare time and SyntaxError

2008-07-10 Thread [EMAIL PROTECTED]
On 10 juil, 08:53, [EMAIL PROTECTED] wrote: > > just... great !-) > > Thanks :) Nope, really, I mean it. To me, there's a clear relation between code, mathematics and poetry. I've been wanting to write some "code poems" for a long time now but never managed to get enough time and inspiration. Whil

Re: parsing incoming emails

2008-07-10 Thread Michiel Overtoom
Ahmed wrote... > I am working on a project where I need to parse incoming emails > (Microsoft outlook) I'm not sure if you are able to bypass Outlook (and have Python fetch the mail itself using poplib), but if you are, the following code might be useful. I use this to pry apart emails which mig

  1   2   >