Re: Estimating memory use?

2005-11-27 Thread Tim N. van der Leeuw
Hi, What is your 'static' data (database), and what is your input-data? Those 200.000 probes are your database? Perhaps they can be stored as pickled compiled regexes and thus be loaded in pickled form; then you don't need to keep them all in memory at once -- if you fear that memory usage will be

Re: Why I need to declare import as global in function

2005-11-28 Thread Tim N. van der Leeuw
Sounds like something, either in your program, in another lib you imported, or perhaps some extension you recently installed (and which automatically starts), overrides 'import' (replaces it with it's own version) -- and forgets to add the imported modules properly to the globlals? Or something, so

Re: XMLSchema Parsing

2005-11-29 Thread Tim N. van der Leeuw
Hi, Depends entirely on what you want. I've written some XSD tools in Python that do exactly what I want -- but don't offer support for any XSD features that I didn't happen to need. Module I wrote supports include/import and redefine; parses sequences, complexTypes and simpleTypes, but not much m

Re: variable hell

2005-08-30 Thread Tim N. van der Leeuw
What you could do is to create a class for this; fill it's __dict__ instance; and use custom getattr() / setattr() methods for accessing a0, a1, a2 etc. cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

win32com and Python2.4: Interpreter crashing!

2005-03-07 Thread Tim N. van der Leeuw
Hi, When trying to use win32com functionality with Python2.4, the interpreter often crashes! I don't know if it's a known problem already that will be fixed in an upcoming Python2.4.1 version. Basically, the problem is: makepy.py generates a (large, nearly 2mb) Python file for use with COM inter

Re: RELEASED Python 2.4.1, release candidate 1

2005-03-10 Thread Tim N. van der Leeuw
Hi, I have a problem with Python2.4 and win32com extensions, from Mark Hammond's win32all package... I posted a few days back about a crash when compiling files generated by win32com's 'makepy.py' utility. Now these generated files, which are fine in Python 2.3.5, give a syntax error on compile.

Re: RELEASED Python 2.4.1, release candidate 1

2005-03-11 Thread Tim N. van der Leeuw
Sorry, but I don't know what you mean with 'workaround for the crash'... The interpreter no longer crashes when trying to compile this file. In Python2.4.0 I never saw any syntax error, there was just crash. Now there is a syntax error, and I when I look at the code I don't spot it. regards, --Ti

Re: RELEASED Python 2.4.1, release candidate 1

2005-03-11 Thread Tim N. van der Leeuw
Hi, The new installer worked fine for me (WinXP1), but I wasn't sure if I could install over the old version and have it work properly / remove the old version from the 'Add / remove programs' list. It suggested a default location on the C: drive but the old version was installed on the D: drive

Re: RELEASED Python 2.4.1, release candidate 1

2005-03-12 Thread Tim N. van der Leeuw
Hi Roger, Thanks, I understand it now, I didn't yet receive in the mail any replies to my post on py-dev when I read your post here! That's why it didn't make any sense to me. I didn't yet have a chance to try the workaround given in the bug-report (remove MBCS encoding line). Hope to find time s

PyWin32 COM mailing list / web forum?

2005-04-11 Thread Tim N. van der Leeuw
Hi, I have some questions specifically about python win32com extensions, and I thought it might be more appropriate to ask them on a mailing list / newsgroup / webforum etc. dedicated to that. But is there such a thing anywhere? I couldn't find links to it from the pywin32 homepage or sourceforge-

Re: PyWin32 COM mailing list / web forum?

2005-04-11 Thread Tim N. van der Leeuw
Thanks for the answer... I subscribed, but meanwhile found the answer to my problem via the MS-Word documentation already. cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Removing dictionary-keys not in a set?

2005-04-18 Thread Tim N. van der Leeuw
Hi, I'd like to remove keys from a dictionary, which are not found in a specific set. So it's kind of an intersection-operation. I can create a new dictionary, or a loop over all keys and test them for set-membership, but I was wondering if there was a smart way to express this in 1 or 2 concise

Re: Can a function be called within a function ?

2005-04-18 Thread Tim N. van der Leeuw
Hiya, That's certainly possible, it's standard practice. (It might be cleaner to pass filenames using parameters though) cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing dictionary-keys not in a set?

2005-04-18 Thread Tim N. van der Leeuw
Hi Aahz, The problem with using the builtin set operations is, that the dictionary keys don't represent a set, so you can't directly create a new dictionary using set methods. So I'm looking for what's a concise way to update a dictionary, or create a new dictionary, using basically an intersecti

Re: Removing dictionary-keys not in a set?

2005-04-18 Thread Tim N. van der Leeuw
Hi Klaus, I think I like the looks of your version the best, so far. Readable and clear, to me. cheers and thanks, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Behaviour of str.split

2005-04-18 Thread Tim N. van der Leeuw
runes wrote: > The behaviour of "".split("*") is not that strange as the splitpoint > always disappear. The re.split() have a nice option to keep the > splitpoint which the str.split should have, I think. > > One expectation I keep fighting within myself is that I expect > > "mystring".split('') t

Re: Get rid of recursive call __getattr__

2005-12-14 Thread Tim N. van der Leeuw
Pelmen wrote: > How can I get rid of recursive call __getattr__ inside this method, if > i need to use method or property of the class? Hi Pelmen, Having read the docs included with my Python distribution on __getattr__, I don't see yet how you will get recursive calls to the method... (It's cal

Re: how to remove duplicated elements in a list?

2005-12-20 Thread Tim N. van der Leeuw
Another way to do this, that also maintains order, is: >>> l = [3, 1, 'a', '@', -4, 'z', 'r', 1, '@', -4] >>> s = set() >>> l2 = [] >>> for v in l: ... if not v in s: ... s.add(v) ... l2.append(v) ... >>> l2 [3, 1, 'a', '@', -4, 'z', 'r'] I have no idea whether or not

Re: Disable 'windows key'

2005-12-20 Thread Tim N. van der Leeuw
I found out that installing the LiteStep alternative for windows taskbar actually has the sideeffect of disabling the windows key... (But I don't know how inclined you are to tinker with your system to that degree. At least it offers a clean uninstall) winKey+e still works after installing LiteSte

Parsing a date-time string?

2005-12-21 Thread Tim N. van der Leeuw
Hi, I want to parse strings containing date-time, which look like the following: "Mon Dec 19 11:06:12:333 CET 2005" That's a problem for strptime it seems, b/c I cannot find any format-spec for the milliseconds-part in here. (I'm also not sure about the validity of the tz part, but ...) As an

Re: Newbie: adding string values to a list?

2005-12-21 Thread Tim N. van der Leeuw
You need to use result.append(...) instead of result.extend(...) (Been stumped with that myself too, several times, when I was still a newby... Except was using the operator '+=' I think) cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a date-time string?

2005-12-22 Thread Tim N. van der Leeuw
I downloaded the tar.bz2 file, extracted it, and had no problem building it and creating a windows installer using 'python ./setup.py bdist_wininst' This windows installer I then used to install it via the 'official windows' way :) luck, --Tim -- http://mail.python.org/mailman/listinfo/python-

Re: Compressing folders in Windows using Python.

2006-01-01 Thread Tim N. van der Leeuw
Christian Tismer wrote: > sri2097 wrote: > > Hi, > > I'm trying to zip a particular fiolder and place the zipped folder into > > a target folder using python. I have used the following command in > > 'ubuntu'. > > > > zip_command = 'zip -qr %s %s' % (target, ' '.join(source)) > > > > I execute

Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Tim N. van der Leeuw
Isn't it much easier to figure out how python built-in module 'zipfile' works? Pseudo-code would be something like: #UNTESTED import zipfile import os import os.path zf = zipfile.ZipFile('myzipfilename.zip', 'w', zipfile.ZIP_DEFLATED) for root, dirs, files in os.walk('compressthisdir'): for

Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Tim N. van der Leeuw
Using gzip means you can compress only 1 file per gzip; so you'll have to invent something like tar to put all your files in your directories together into 1 file and then apply gzip on that file to get it compressed... Using the zipfile module should allow you to create a standard winzip-compatib

Re: URL 'special character' replacements

2006-01-09 Thread Tim N. van der Leeuw
My outline for a solution would be: - Use StringIO or cStringIO for reading the original URLs character for character, and to build the result URLs character for character - When you read a '%' then read the next 2 character (should be digits!!!) and create a new string with them - The numbers li

Re: How can I create a dict that sets a flag if it's been modified

2006-01-12 Thread Tim N. van der Leeuw
Should the dict flag when the dict itself has been updated? Or also when any of the items in the dict has been updated? Say you have a dict consisting of lists... The dict should be flagged as modified when an item is added; or when an item is replaced (you call dict.__setitem__ with a key that a

Re: Help me in this please--is Python the answer?

2006-01-12 Thread Tim N. van der Leeuw
Hi Ray, I'm in a bit of the same boat as you only I don't get to choose my implementation language ;-) Some of the concerns should be: - Do you have to interface with things like messaging-systems (a la JMS specs), distributed transaction managers? If so, the only way to go Python is Jython: Pyth

Re: Python and Word

2006-01-16 Thread Tim N. van der Leeuw
rodmc wrote: > Is there a way to write Word plug-ins in Python? I am using Python > 2.3.5 and Word 2000, and need to be able to write a small network > application with a basic GUI which can run inside Word. > > cheers, > > rod Hi Rod, Does it really need to be an application which runs inside

Re: Python and Word

2006-01-16 Thread Tim N. van der Leeuw
Hi Rod, If you download and install the 'Python Win' extensions, which I think are linked from from the Python download page for windows, you have a set of COM classes for Python which allow you to do everything you can do in Word from a Python program. It allows a lot of interactive exploration

Re: recursively removing files and directories

2006-01-16 Thread Tim N. van der Leeuw
Wasn't this the example given in the Python manuals? Recursively deleting files and directories? cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
Shalabh, You've managed very well to express the same things I feel about the new Python website. What I especially dislike about the new website are the flashy pictures on the front-page with no content and no purpose -- purely boasting but nothing to back up your claims. (I wouldn't mind some

Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
> Checkins to subversion cause an automated update in the site content. Good :) What's the subversion URL where I can fetch the site? ;) regards, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
Steve, My apologies if this apppeared to be 'slagging'. I was trying to give some feedback but I do realize that I don't have anything better to offer yet to replace the pictures I dislike. Perhaps I should have withheld my criticisms until I could offer an alternative. (Still thinking about what

Re: New Python.org website ?

2006-01-18 Thread Tim N. van der Leeuw
I need to supply a username/password before I can look at the SVN repository in my webbrowser; I tried username/pwd 'anonymous' but that don't work. cheers, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Python website problem?

2006-07-22 Thread Tim N. van der Leeuw
Hi, Does the Python.org website have a problem? I only get a directory index, and clicking on any of the HTML files in there shows a page without any CSS makeup. Anyone noticed this too? --Tim -- http://mail.python.org/mailman/listinfo/python-list

How to test if object is sequence, or iterable?

2006-07-22 Thread Tim N. van der Leeuw
Hi, I'd like to know if there's a way to check if an object is a sequence, or an iterable. Something like issequence() or isiterable(). Does something like that exist? (Something which, in case of iterable, doesn't consume the first element of the iterable) Regards, --Tim -- http://mail.pytho

Re: Python website problem?

2006-07-22 Thread Tim N. van der Leeuw
Tim N. van der Leeuw wrote: > Hi, > > Does the Python.org website have a problem? I only get a directory > index, and clicking on any of the HTML files in there shows a page > without any CSS makeup. > > Anyone noticed this too? > > --Tim Well, it seems fixe

Re: How to test if object is sequence, or iterable?

2006-07-22 Thread Tim N. van der Leeuw
Bruno Desthuilliers wrote: > Tim N. van der Leeuw a écrit : > > Hi, > > > > I'd like to know if there's a way to check if an object is a sequence, > > or an iterable. Something like issequence() or isiterable(). > > > > Does something like

Re: Py2exe for packaging installers?

2006-07-28 Thread Tim N. van der Leeuw
K.S.Wong wrote: > Hi all, > > I am trying to find out what tools (platform-independent if possible) that I > can use to package a goup (few) of installers to become an exe application. > I have heard of Py2exe but have not use it before. Could it be used to wrap > different installers (for exampl

Re: Compiling wxPython app for Windows; Single EXE

2006-08-13 Thread Tim N. van der Leeuw
Vincent Delporte wrote: > Hi > > I browsed the archives, but since some messages date back a bit, I > wanted to make sure that > > - py2exe is still the best tool in town to compile Python scripts to > run on a Windows host that doesn't have Python installed, including > wxWidgets/wxPython > > - t

Re: Python and STL efficiency

2006-08-21 Thread Tim N. van der Leeuw
Licheng Fang wrote: > Hi, I'm learning STL and I wrote some simple code to compare the > efficiency of python and STL. > > > I was using VC++.net and IDLE, respectively. I had expected C++ to be > way faster. However, while the python code gave the result almost > instantly, the C++ code took seve

Re: Python and STL efficiency

2006-08-21 Thread Tim N. van der Leeuw
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Licheng Fang > wrote: > > > Hi, I'm learning STL and I wrote some simple code to compare the > > efficiency of python and STL. > > [...] > > There's a difference in data structures at least. The Python `set` type > is implemented with a ha

Re: Python and STL efficiency

2006-08-21 Thread Tim N. van der Leeuw
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Tim N. van der > Leeuw wrote: > > > (your C++ code contains some C#-isms, such as omitting the '.h' in the > > include <> statements). > > That's no C#-ism, that's C++

Re: Help in using introspection to simplify repetitive code

2006-08-21 Thread Tim N. van der Leeuw
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > And they do take arguments, and a variable number of them, so AFAIK > > hooking with __getattr__ or __getattribute__ will not work, as you can > > only get the method name with that. > > why not just return the bound method *object* (a callable

Re: Python and STL efficiency

2006-08-21 Thread Tim N. van der Leeuw
Ray wrote: > Fredrik Lundh wrote: > > in the Python example, the four strings in your example are shared, so > > you're basically copying 4 pointers to the list. > > > > in the C++ example, you're creating 4 string objects. > > > > > > In which case, Licheng, you should try using the /GF

Re: Python and STL efficiency

2006-08-21 Thread Tim N. van der Leeuw
Tim N. van der Leeuw wrote: > Ray wrote: > > Fredrik Lundh wrote: > > > in the Python example, the four strings in your example are shared, so > > > you're basically copying 4 pointers to the list. > > > > > > in the C++ example, you're

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Ray wrote: > Tim N. van der Leeuw wrote: > > > In which case, Licheng, you should try using the /GF switch. This will > > > tell Microsoft C++ compiler to pool identical string literals together. > > > > > > > > > :) > > > > The code

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Mc Osten wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > Python's memory allocator is also quite fast, compared to most generic > > allocators... > > In fact also in the two "slow" versions Python outperforms C++. > I didn't notice it in the first place. > But your C++ program outputs tim

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Mc Osten wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > Python's memory allocator is also quite fast, compared to most generic > > allocators... > > In fact also in the two "slow" versions Python outperforms C++. > I didn't notice it in the first place. > > -- > blog: http://www.akropoli

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Mc Osten wrote: > Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote: > > > Oh boy; yes indeed the slow python is faster than the fast C++ > > version... Must be something really awful happening in the STL > > implementation that comes with GCC 3.4! > > And t

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Tim N. van der Leeuw wrote: > Mc Osten wrote: > > Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote: > > > > > Oh boy; yes indeed the slow python is faster than the fast C++ > > > version... Must be something really awful happening in the STL > > > imp

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
[EMAIL PROTECTED] wrote: > Tim> But beware! For Python2.5 I had to change the code slightly, > Tim> because it already realized that the expression > > Tim> '%s' % 'something' > > Tim> will be a constant expression, and evaluates it once only... so I > Tim> had to replace '%s' with

Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw
Maric Michaud wrote: > Le mardi 22 août 2006 12:55, Mc Osten a écrit : > > In fact Python here is faster. Suppose it has a really optimized set > > class... > > Maybe I'm missing something but the posted c++codes are not equivalent IMO to > what python is doing. I discarded the "slow" version, and

Re: Python and STL efficiency

2006-08-23 Thread Tim N. van der Leeuw
Mc Osten wrote: > Ray <[EMAIL PROTECTED]> wrote: > > > Yeah, my guess would be either he used the Debug configuration or he > > actually created a Managed executable instead of a pure Win32 > > application. Sigh, now I can't wait to get home and try it out :) > > Can be. But I suppose a Managed sh

Re: Experiences with Py2Exe

2006-10-11 Thread Tim N. van der Leeuw
Hi Isaac, Isaac Rodriguez wrote: > Hi, > > I am looking for feedback from people that has used or still uses > Py2Exe. I love to program in python, and I would like to use it to > write support tools for our development team, but I cannot require > everyone to install python in their machines, so

Re: invert or reverse a string... warning this is a rant

2006-10-20 Thread Tim N. van der Leeuw
I V wrote: > On Fri, 20 Oct 2006 09:04:07 +1000, Steven D'Aprano wrote: > > I agree -- the reversed() function appears to be an obvious case of purity > > overriding practicality :( > > > str(reversed("some string")) > > '' > repr(reversed("some string")) > > '' > > This doesn't seem par

Re: invert or reverse a string... warning this is a rant

2006-10-20 Thread Tim N. van der Leeuw
Fredrik Lundh wrote: > Tim N. van der Leeuw wrote: > > > In practice, the short-term fix would be to add a __str__ method to the > > 'reversed' object > > so what should > > str(reversed(range(10))) > > do ? > My idea was that reversed.__

Re: ANN: wxPython 2.7.1.3

2006-10-28 Thread Tim N. van der Leeuw
Hendrik van Rooyen wrote: > "Johann C. Rocholl" <[EMAIL PROTECTED]>wrote: > > 8<-- > > > Oh, it's fun to be a speling fanatic! :-) > > > six munce ago I could not even spell 'fatanic' - and now I are one... > > I wander what a speling fanatic is? > Someone who

Re: Variable name has a typo, but code still works. Why?

2006-05-31 Thread Tim N. van der Leeuw
Hi Mateus, We'd need to see more code then just this snippet. It looks like the name 'session' is used elsewhere in the code, and is in scope for the showReport() method. But without seeing a bit more code of this class, and possibly global variables / code, it's not possible to say this. There's

Re: CONSTRUCT - Python's way of Ruby's "alias_method"

2006-06-08 Thread Tim N. van der Leeuw
Since your question is so much about Django, you might want to ask on Django groups. Oops, you're not welcome there anymore, almost forgot. But if merely reading the subject of a posting I already know who's the poster, it's perhaps a bad sign. Further readers of this thread might be interested

Re: Allowing zero-dimensional subscripts

2006-06-10 Thread Tim N. van der Leeuw
greg wrote: > Carl Banks wrote: > > > Think of it this way: an array with n-dimensions of length 3 would have > > 3**n total entries. How many entries would a 0-dimensional array have? > > 3**0 == 1. > > Er, hang on a minute. Along which dimension of this > 0-dimensional array does it have a len

Tix Tree / HList widget?

2006-06-19 Thread Tim N. van der Leeuw
Hi, I need to display some hierarchical data, and because I don't want to force users to install too many things beyond Python itself, I'm hoping to use Tix which is at least included with Python. I've managed to use the Tix HList widget to display a tree of items (at least in a proof-of-concept

Re: wxPython GUI designer

2006-06-22 Thread Tim N. van der Leeuw
[EMAIL PROTECTED] wrote: > Are there any good commercial project built with wx ? I am a newbie and > a have to write a small application in Python. I was wondering which > optin would be best for me in terms of least learning curve and getting > the final product ASAP. > > Thanks > It's not a com

PyGTK and Py2Exe troubles

2006-06-24 Thread Tim N. van der Leeuw
I tried to create a windows executable of a pygtk program. My first attempt worked, kinda, except that no themes were applied and no readable fonts were found by pango; so all letters where just empty squares. But the program worked. I looked up some docs, found the following recipe on the PyGTK W

Re: PyGTK and Py2Exe troubles

2006-06-24 Thread Tim N. van der Leeuw
[EMAIL PROTECTED] wrote: > Tim N. van der Leeuw ha scritto: > > > I tried to create a windows executable of a pygtk program. My first > > attempt worked, kinda, except that no themes were applied and no > > readable fonts were found by pango; so all letters where just em

Re: About python 2.5 and its try statement.

2006-06-26 Thread Tim N. van der Leeuw
Hi, defcon8 wrote: > I can't remember the proposal number, but many of you reading will have > probably read the features that will be added to python 2.5. The actual > part I wanted to talk about was the finally part of try. Isn't it > totally defeating a compiler's job by executing the finally

Nested scopes, and augmented assignment

2006-07-04 Thread Tim N. van der Leeuw
Hi, The following might be documented somewhere, but it hit me unexpectedly and I couldn't exactly find this in the manual either. Problem is, that I cannot use augmented assignment operators in a nested scope, on variables from the outer scope: PythonWin 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC

Re: wxGlade and __init__

2006-08-26 Thread Tim N. van der Leeuw
crystalattice wrote: > I'm making a GUI for a console-based program I just wrote. I figured > it would be mostly straight forward to convert it over in wxPython but > now I'm confused. > Hi Crystalattice, One thing you could do is make your original console-program a subclass of the wxGlade-gen

Re: Extending the dict class

2006-08-29 Thread Tim N. van der Leeuw
Fredrik Lundh wrote: > "chosechu" wrote: > > > Yes, if I could simply modify myfunc() I would have workarounds. > > This would mean me modifying SOAPpy and specializing it for > > my needs. > > maybe you could fake it: > No you cannot fake it, because the ** form of passing arguments constructs a

Re: Extending the dict class

2006-08-29 Thread Tim N. van der Leeuw
chosechu wrote: > Duncan Booth wrote: > > If the order of the argument names matters, then it seems to me that should > > be handled by the SOAP library, not pushed onto the end user whoch should > > just be calling the function with the named arguments in the most > > convenient order. > > > > Sh

Re: GC and security

2006-08-31 Thread Tim N. van der Leeuw
Fredrik Lundh wrote: > Les Schaffer wrote: > > > i am working on a python application that uses encryption as part of its > > security features. so then at some point someone has to enter a > > passphrase into the system and passed into a decryption functions (we > > are using gpg via subprocess).

Re: PostgreSQL, psycopg2 and OID-less tables

2006-09-15 Thread Tim N. van der Leeuw
Dale Strickland-Clark wrote: > Now that OIDs have been deprecated in PostgreSQL, how do you find the key of > a newly inserted record? > > I've tried three Python client libraries, including psycopg2, and where they > support cursor attribute 'lastrowid' (Python DB API 2.0), it is always > zero. >

Re: high level, fast XML package for Python?

2006-09-15 Thread Tim N. van der Leeuw
Hi Gleb, Gleb Rybkin wrote: > I searched online, but couldn't really find a standard package for > working with Python and XML -- everybody seems to suggest different > ones. > > Is there a standard xml package for Python? Preferably high-level, fast > and that can parse in-file, not in-memory sin

Re: Porting Tkinter application to JYthon

2006-11-23 Thread Tim N. van der Leeuw
Hi, sandip desale wrote: > Dear All, > > We have a Tcl/Tk application written using Python 2.2. Using this application > we want to call some customizable Java APIs. I tried porting Tcl/Tk > application to Jython but not able to do the same as TKinter library is not > available with JYthon. > >

Re: Porting Tkinter application to JYthon

2006-11-27 Thread Tim N. van der Leeuw
Hi Sandip, sandip desale wrote: > Dear All, > > We have a Tcl/Tk application written using Python 2.2. Using this application > we want to call some customizable Java APIs. I tried porting Tcl/Tk > application to Jython but not able to do the same as TKinter library is not > available with JYth

Re: OO conventions

2006-02-02 Thread Tim N. van der Leeuw
Daniel Nogradi wrote: > > > > In this case, Image seems to be a python module, with the open function > > defined, PIL's Image is not a class. > > > > Thanks for the enlightening remarks, especially this last one, indeed, > it's not a class. Actually, this way of creating a class instance is good

Detecting filename-encoding (on WinXP)?

2006-02-02 Thread Tim N. van der Leeuw
Hi, I have a need to store directory and filenames in a database. For the database I chose to use UTF-8 encoding; but the actual encoding used is probably immaterial: whichever coding I take, I'll run into this issue eventually. At first my code worked until I ran into a directory full of Cyrilli

Re: Detecting filename-encoding (on WinXP)?

2006-02-02 Thread Tim N. van der Leeuw
Hi Magnus, I get the filename from a URL, which probably is not in any kind of unicode-string but just a plain ASCII string. It should be possible to cast this to an ASCII string -- I'll try it right away to see if this works. Thanks! --Tim -- http://mail.python.org/mailman/listinfo/python-lis

Re: Detecting filename-encoding (on WinXP)?

2006-02-10 Thread Tim N. van der Leeuw
Actually, the directory-name comes in as a URL and as such I had no problems yet just creating a unicode-string from it which I can pass to os.walk(), and get proper unicode-filenames back from it. Then I can encode them into utf-8 and pass them to the database-layer and it all works. cheers, --T

Re: 88k regex = RuntimeError

2006-02-14 Thread Tim N. van der Leeuw
Why don't you create a regex that finds for you all C function declarations (and which returns you the function-names); apply re.findall() to all files with that regex; and then check those funtion-names against the set of allSupported? You might even be able to find a regex for C funtion declarat

Re: 88k regex = RuntimeError

2006-02-14 Thread Tim N. van der Leeuw
This is basically the same idea as what I tried to describe in my previous post but without any samples. I wonder if it's more efficient to create a new list using a list-comprehension, and checking each entry against the 'wanted' set, or to create a new set which is the intersection of set 'wanted

Re: Embedding an Application in a Web browser

2006-02-14 Thread Tim N. van der Leeuw
'A' Web Browser? Meaning: any random web-browser? Or specifically and *only* Internet Explorer? If you want it to work only and ever only in Internet Explorer, then you can create a Python ActiveX object and embed that in your page; using the pythonwin extensions. Cheers, --Tim -- http://mail.

Re: printing out elements in list

2006-05-08 Thread Tim N. van der Leeuw
Using slices and built-in zip: >>> alist = ['>QWER' , 'askfhs', '>REWR' ,'sfsdf' , '>FGDG', 'sdfsdgffdgfdg' ] >>> dict(zip(alist[::2], alist[1::2])) {'>QWER': 'askfhs', '>FGDG': 'sdfsdgffdgfdg', '>REWR': 'sfsdf'} Slightly more efficient might be to use izip from itertools: >>> from itertools imp

Re: Why list.sort() don't return the list reference instead of None?

2006-05-08 Thread Tim N. van der Leeuw
So you write: for key in sorted(dict.iterkeys()): ... do it ... dict.iterkeys() returns an iterable which doesn't even have a sort-method; and somehow I find it unnatural to apply a 'sort' method to an iterator whereas I find it perfectly natural to feed an iterator to a function that does sor

Re: printing out elements in list

2006-05-08 Thread Tim N. van der Leeuw
alist[::2] means taking a slice. You should look up slice-syntax in the tutorials and reference manual. in general, alist[1:5] means: take list elements position 1 up to (excluding) 5. (List indexing starts at position 0, so the first element in the list is not included!) alist[0:5] means: take l

Re: How can I do this with python ?

2006-05-08 Thread Tim N. van der Leeuw
Your question is insufficiently clear for me to answer. Do you want to know how to read from standard-input in a Python program? Do you want to know how to start an external program from Python, and then connect something to that programs standard input? Do you want to know something else? Plea

Re: Python memory deallocate

2006-05-11 Thread Tim N. van der Leeuw
Hi, 'del a' should remove 'a', as a reference to the tuple created by the 'range' function. If that is also the last reference, it can now be garbage-collected. Of course, the question is if you really need to allocate such a big amount of memory. If you just need to iterate over some numbers, it

Re: New tail recursion decorator

2006-05-12 Thread Tim N. van der Leeuw
[...] > > > I'm not convinced by this. You have to recognise that the function is using > tail recursion, and then you have to modify the code to know that it is > using tail recursion. This is not always trivial. For example, the given > example is: > > @tail_recursion > def factorial(n, acc=1): >

Re: New tail recursion decorator

2006-05-12 Thread Tim N. van der Leeuw
Hi Michele, I'm sorry, but you misunderstood me. There are two definitions of the factorial() function, one given by the OP and the other given by Duncan. I tested both factorial() definitions with, and without the tail_recursion decorator (the version of the OP). So I had 4 factorial-functions

Re: New tail recursion decorator

2006-05-12 Thread Tim N. van der Leeuw
Duncan Booth wrote: > Tim N. van der Leeuw wrote: > [...] > @tail_recursion > def factorial2(n): > # do the stuff > pass > > your 'do the stuff' actually had an erroneous call to 'factorial'. If you > are going to rename the function you ha

Re: Windows & Apache 1.3 & mod_python.dll

2006-05-16 Thread Tim N. van der Leeuw
Any particular reason for not using Apache 2, and mod_python 3.x? Anyways, looks to me like there's a problem with the path where the DLL is installed, vs. where it's search for by Apache? I had no particular problems installing Apache 2 and mod_python 3.x on WinXP, using the mod_python installer

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Tim N. van der Leeuw
Andrew Robert wrote: > Hi Everyone. > > > I tried the following to get input into optionparser from either a file > or command line. > > > The code below detects the passed file argument and prints the file > contents but the individual swithces do not get passed to option parser. > After reading

Re: Time to bundle PythonWin

2006-05-17 Thread Tim N. van der Leeuw
John Bokma wrote: > "Robert Hicks" <[EMAIL PROTECTED]> wrote: > > > No it isn't. > > Learn to quote when you use Google's Usenet garbage. > I don't know why you consider it 'garbage', using it myself for this 'contribution', but quoting isn't hard using google groups. Just clicking the right link

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Tim N. van der Leeuw
Andrew Robert wrote: > Tim N. van der Leeuw wrote: > > Andrew Robert wrote: [...] > Hi Tim, > > I am using the pymqi module which is freely available at > http://pymqi.sourceforge.net/ . > > Documentation on the module can be found at > http://pymqi.sourceforge.ne

Re: Process forking on Windows

2006-05-18 Thread Tim N. van der Leeuw
Andrew Robert wrote: > bruno at modulix wrote: [...] > > > > > > Is this really the solution ? > > > > [...] > > > Unfortunately there is a real need for this. > > The MQSeries trigger monitor is single threaded. > > Because of this, my program would absorb it until it completes. > > The way to

Re: Option parser question - reading options from file as well as command line

2006-05-22 Thread Tim N. van der Leeuw
is an option '-f' or '--file'followed by the filename with options you wish to add to the command-line). The implementation reads the entire contents of the file into memory. (c) Copyright 2006 Tim N. van der Leeuw ([EMAIL PROTECTED]) """ import re from optpa

Re: documentation for win32com?

2006-05-24 Thread Tim N. van der Leeuw
Roger Upole wrote: > The Excel docs are your best bet. The examples they give > are all MS-specific languages like VB, but most translate > fairly easily to Python. > > You can also run makepy on the Excel typelib, which will > generate a file with all the methods, events etc available > thru the

Re: John Bokma harassment

2006-05-24 Thread Tim N. van der Leeuw
[EMAIL PROTECTED] wrote: > I agree there are limits to you right to free speech, but I believe Xah > Lee is not crossing > any boundaries. If he starts taking over newspapers and TV stations be > sure to notify me, > I might revise my position. > Immanuel Perhaps he's not crossing boundaries of f

Re: Python regex question

2008-08-15 Thread Tim N. van der Leeuw
Hey Gerhard, Gerhard Häring wrote: > > Tim van der Leeuw wrote: >> Hi, >> >> I'm trying to create a regular expression for matching some particular >> XML strings. I want to extract the contents of a particular XML tag, >> only if it follows one tag, but not follows another tag. Complicating

  1   2   >