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 
 this, is that there can be any number of other tags in between. [...]
 
 Sounds like this would be easier to implement using Python's SAX API.
 
 Here's a short example that does something similar to what you want to 
 achieve:
 
 [...]
 

I so far forgot to say a thank you for the suggestion :-)

The sample code as you sent it doesn't do what I need to do, but I did look
at it for creating SAX handler code that does what I want.

It took me a while to implement, as it didn't fit in the parser-engine I had
and I was close to making a release.

But still: thanks!

--Tim

-- 
View this message in context: 
http://www.nabble.com/Python-regex-question-tp17773487p18997385.html
Sent from the Python - python-list mailing list archive at Nabble.com.

--
http://mail.python.org/mailman/listinfo/python-list

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 JYthon.

 Can you please help me in porting Tkinter application to Jython? Also kindly 
 let me know how to do the same.


 Thanks  Regards,
 Sandip Desale


In response to my previous post I got an e-mail suggesting to look at
JPype; however that message wasn't posted to the list, despite a CC: to
[EMAIL PROTECTED] And it seems that you haven't received the
message either.

Anyways, here's the URL for the JPype project which allows the use of
Java libraries from Python:

http://jpype.sourceforge.net/

I downloaded it for windows and it seems to work quite OK, although I
only did some toy-testing (opening a Swing filechooser window from
within PythonWin, for instance).

The purpose of the project is calling Java code from Python, and it has
some limited facilities to allow callbacks from Java to Python. I think
therefore that it fits very well what you and I would need: integration
of Java libraries into Python projects.

It does not, however, allow subclassing of Java classes in Python or
the other way round, and it does not allow calling of arbitrary Python
code from the JVM.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 fanatically installs mod_speling every time he/she installs
Apache httpd anywhere

 - Hendrik

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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))
  'reversed object at 0xb7edca4c'
  repr(reversed(some string))
  'reversed object at 0xb7edca4c'

 This doesn't seem particularly pure to me, either. I would
 have thought str(some_iter) should build a string out of the iterator, as
 list(some_iter) or dict(some_iter) do. I guess this might have to wait for
 Python 3, but str ought to be a proper string constructor, not a produce
 a printable representation of function, particularly when we have repr to
 do the latter.

The failing of str(reversed('the string')) caught me off-guard too. I
think you're quite right that it would be good if str() becomes a
proper constructor.

In practice, the short-term fix would be to add a __str__ method to the
'reversed' object, and perhaps to all iterators too (so that trying to
build a string from an iterator would do the obvious thing).

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.__str__() would do something like the
equivalent of ''.join(reversed(...))

Playing in the interactive shell with that idea I quickly realized that
this would of course consume the iterator as a side-effect... Which is
most likely to be undesirable.

(It works well if you just write it as in the examples above, where the
'reversed' object is temporary and instantly thrown away. But if you
assign the iterator object, in this case 'reversed', to an instance
variable then it should be immediately obvious that having the iterator
consumed as side-effect of calling it's __str__ method is very, very
wrong...)


  and perhaps to all iterators too (so that trying to build a string from an
  iterator would do the obvious thing).

 all iterators?  who's going to do that?


It's not as easy as I expected. But if we could come up with a
reasonable way to create a __str__ method for iterators, well who knows
I might give it a go. (It would be my first C code in many years
though)


 /F

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 I was thinking that
 Py2Exe would help on that.

 The support tools I write are mostly command line driven (no GUI), but
 in the future, I would like to write some expert applications that will
 contain GUI. I was thinking on using wxPython for the GUI, so I was
 wondering how well behaves Py2Exe with the wxPython module.


My experiences with Py2Exe and wxPython are very good. In fact, the
samples included with Py2Exe include some wxPython samples.

It's also possible to get PyGTK working with Py2exe, but it's a bit
more convoluted. However, the examples on the PyGTK and esp. Py2exe
websites should get you there.

What was more difficult was Amara, but with some tweaking even that
eventually worked.

I have no experience with CTypes, so I can only assume that it will
work... p4.py might be more reason to worry but you'd have to ask
around or try.

PythonWin was painless, no issues at all getting pythonwin/com etc.
stuff to work.

 Other modules I use besides the standard modules are CTypes and the
 Perforce python module p4.py. I try not to use any of the win32 stuff,
 but I can see how I will have to for some utilitites, so if anyone has
 experience with the win32 modules and Py2Exe, any feedback will be
 highly appreciated.
 
 Thanks,
 
 Isaac.

-- 
http://mail.python.org/mailman/listinfo/python-list


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.

 Anyone figured this out?


Hi,

It's of course strictly a PostgreSQL question, but have you tried

select lastval();

?

According to my reading of the postgress manuals, that should do the
trick.

Cheers,

--Tim


 Thanks.
 -- 
 Dale Strickland-Clark
 Riverhall Systems - www.riverhall.co.uk

-- 
http://mail.python.org/mailman/listinfo/python-list


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 since I  have to deal with
 potentially MBs of data.

 Thanks.

Another option is Amara; also quite high-level and also allows for
incremental parsing. I would say Amara is somewhat higher level than
ElementTree since it allows you to access your XML nodes as Python
objects (with some extra attributes and some minor warts), as well as
giving you XPath expressions on the object tree.

URL:

http://uche.ogbuji.net/tech/4suite/amara/

Best version currently available is version 1.1.7

It does work together with py2exe on windows if the need ever arises
for you but you have to fiddle a bit with it (ask for details on this
list if you ever need to do that)

 Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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).
 
  so i am curious. so long as i drop all reference to the passphrase
  string(s), eventually it gets garbage collected and the memory recycled.
  so before long the phrase is gone from memory.

 Since Python uses reference counting, if you drop all references, the
 object is garbaged collected immediately, and the associated memory is
 freed.  However, freeing memory doesn't mean that the memory is cleared,
 so the passphrase will still be visible in memory, until some other part
 of your program allocates the same memory area and overwrites it.

 you could obscure things a bit by storing the passphrase as a list of
 characters, or a list of integers, and write it to gpg one character at
 a time (if that's possible; if not, you may need to write a custom
 extension that builds a command string in a C-level buffer, runs the
 command, and then overwrites the buffer before returning).

Storing the passphrase as a list of something has the advantage that
you could set all list-entries to zero, None or random values before
the list goes out of scope. The individual characters from the
passphrase can of course still be snooped from memory, somehow, in
theory -- but without any coherence. (At most the coherence of the
order of allocation).

However, such obfuscation does not make any real sense unless the
passphrase is always stored in a list and in a list only; if it enters
your program in the form of a string somehow then basically such
obfuscations seem very meaningless to me.


Perhaps the Python interpreter should be extended with a new C Type,
'secure_string', which clears all it's bytes before being freed. (Just
phantasizing out loud here, not being in any way serious!)

 
 /F


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 new dictionary (and that dictionary is the standard
built-in type of dictionary, not your own fake-dictionary).

Just did some tests, redefining the dict-type:

 native_dict = dict
 type({}) == native_dict
True
 class my_dict(native_dict):
... pass
...
 dict = my_dict
 type({}) == native_dict
True
 type(dict()) == native_dict
False
 def foo(**kwargs):
... print type(kwargs) == native_dict
...
 foo(x=1)
True
 foo(**dict())
True


(NB: I also tried changing __builtins__.dict, no effect)

As the OP said, when passing keyword-arguments, a new instance of a
built-in dict is always generated and not the dict type bound to the
dict-constructor.

I do actually think that it would be useful in many circumstances to be
able to replace the default-constructor of a particular so that custom
objects are created for that type.

OTOH, there are probably many more cases where doing so would be a very
bad idea, not a good idea, and we would begin seeing an overwhelming
number of cases of mis-use of such feature.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.
 
  Shouldn't SOAPpy be able to get this information out of the WSDL?

 Yes, SOAPpy could extract this from the WSDL specs.
 SOAPpy could also find another way to pass call parameters, but I kinda
 like
 the named parameters (seems really Python-like). Microsoft could also
 build SOAP services that parse XML without making ordering mandatory
 where
 nobody said it was.

Are you sure that the order is not defined in the WSDL still? I don't
know WSDL, but in XML Schema for instance, order is defined when using
'xsd:sequence' yet many parsers don't care for receiving elements in a
different order from what's defined in the XSD which they're supposed
to validate against (working perhaps with the axiom 'be liberal in what
yo except, but strict in what you send'). Many people don't actually
realize that 'xsd:sequence' dictates the order of elements and use it
just for 'any order is good enough'.

Might be a similar case with the WSDL: Order is defined, but due to
mis-interpretation of the spec it's not realized / enforced by all /
some of the components.
Anyways, modifiying SOAPpy might not be a bad idea: submit your changes
to the project, and you can write on your CV that you have contributed
to open-source projects! ;-)

I do hope for you that you will find something better to do than
pushing template-instances down a socket-hole.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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-generated GUI.

Another thing you could do is to keep the original console program code
intact, and to make the GUI program create an instance of your original
console program, and call it.

You can modify to some extent the code generated by wxGlade, or you can
subclass it (which is what I do, following advice found on this list).

Good luck,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 should not get *that* slow.
 IronPython on Tim's machine is still faster than C++ (even though not as
 fast as CPython).

 --
 blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
 site:  http://www.akropolix.net/rik0/  | tenetevi riso e
 forum: http://www.akropolix.net/forum/ | bacchette per voi.

I have to admit to a stupid mistake, for which I feel quite ashamed - I
got the loop-size wrong in the Python code. So all Python results
posted by me were off by a factor of 10 :-(
I feel quite bad about that!

With the nr of loops corrected, Python on my laptop performs worse than
C++ under all circumstances, by a factor of about 2:

 Python 2.4 =
[EMAIL PROTECTED] ~/My Documents/Python
$ /cygdrive/c/Python24/python.exe SpeedTest.py
Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 400
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 4.239721 seconds
Slow - Elapsed: 11.883234 seconds

 Python 2.5 =
[EMAIL PROTECTED] ~/My Documents/Python
$ /cygdrive/c/Python25/python.exe SpeedTest.py
Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 400
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 4.031873 seconds
Slow - Elapsed: 11.314742 seconds


 GCC 3.4.5, MinGW, -O6 =
[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 2.088 seconds
Slow - Elapsed: 7.033 seconds

 VC++ 6, 'release' build =
[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest_VC.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 4.585 seconds
Slow - Elapsed: 5.024 seconds

== GCC 3.4.5, MinGW, -O6, with most optimized C++ code
==
[EMAIL PROTECTED] ~/My Documents/Python
$ ./testcpp.exe
print_occurence_of_strings
What do you know?
chicken crosses road
fool
so long...
print_occurence_of_unique_strings
What do you know?
chicken crosses road
fool
so long...
print_occurence_of_unique_strings_compared_by_address
What do you know?
chicken crosses road
fool
so long...
strings : 2.338
unique strings : 1.109
compared by address : 0.23

[EMAIL PROTECTED] ~/My Documents/Python

 IronPython 1.0rc2 =

IronPython had a hard time coping with it; creating 4 million string
objects is a bit too much and the CLR was eating nearly a gigabyte of
memory near the end.
Here are the numbers:

IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
 import sys
 sys.path.append('C:/Documents and Settings/LeeuwT/My Documents/Python')
 import SpeedTest
 SpeedTest.run_test()
Begin Test
Number of unique string objects: 4
What do you know
so long...
chicken crosses road
fool
Number of unique string objects: 400
What do you know
so long...
chicken crosses road
fool
Fast - Elapsed: 10.501273 seconds
Slow - Elapsed: 371.047343 seconds


 Java 1.6.0 b2 =
Set size: 4
chicken crosses road
What do you know
fool
so long...
Set size: 4
chicken crosses road
What do you know
fool
so long...
Fast - Elapsed 1.003 seconds
Slow - Elapsed 3.96 seconds

 Java 1.5.0  =
Set size: 4
fool
What do you know
so long...
chicken crosses road
Set size: 4
fool
What do you know
so long...
chicken crosses road
Fast - Elapsed 1.754 seconds
Slow - Elapsed 5.044 seconds
=

Note that the Python code creates a set of all unique id's of all
objects in list a, and prints the length of this set, to verify that
all strings are really unique instances or duplicate instances. The C++
versions don't do that (at least not for 4 million strings); so Python
is at a slight disadvantage here. Printing the number of strings still
didn't help me catch the off-by-ten errors though.

I included a Java version of the program, and it looks like it performs
quite well compared to C++ both with jdk1.5 and jdk1.6.


I humbly apologize for my misinformation yesterday.

Regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 still creates a new string - instance each time it tries to
  append a const char* to the vectorstring ...

 Yeah, you're right... I've been programming Java too long :)


Took me a while to see that too! Have been programming too much Java /
Python as well. Anyways, when changing the Python version so that it
adds 40.000 unique strings to the list (and proving that there are
indeed 40.000 unique ids in the list, by making a set of all id()s in
the list and taking the len() of that set), it still takes at most a
second. I cannot test the speed of the c++ version on my computer, so
nothing scientific here.

I'm curious though, if on the OP's machine the slowed-down Python
version is still faster than the C++ version.


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 times in seconds, right? So all
compilations except for the first two give results in less than a
second, right? (meaning the optimizations of your standard-compilation
give worst results than -O3?)

BTW, I don't quite understand your gcc optimizations for the first 2
compiles anyways: two -O options with different values. Doesn't that
mean the 2nd -O takes preference, and the compilation is at -O2 instead
of -O3?

Why both -O3 and -O2 at the command-line?

Cheers,

--Tim


 --
 blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
 site:  http://www.akropolix.net/rik0/  | tenetevi riso e
 forum: http://www.akropolix.net/forum/ | bacchette per voi.

-- 
http://mail.python.org/mailman/listinfo/python-list


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.akropolix.net/rik0/blogs | Uccidete i filosofi,
 site:  http://www.akropolix.net/rik0/  | tenetevi riso e
 forum: http://www.akropolix.net/forum/ | bacchette per voi.

Well, I guess I'm getting really obsessed with this. But anyways. I
installed MinGW on my Windows-XP (sp2) laptop. It is g++ version 3.4.5
-- ancient, yes, but on windows it's the latest available.

I compiled Mc Osten's C++ program (tweaked the output a little) and ran
it; ran his version of the python code too.
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!

Here's the output from my console:

[EMAIL PROTECTED] ~/My Documents/Python
$ g++ -O3 -march=pentium-m -o SpeedTest SpeedTest.cpp

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest.py
Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 0.037574 seconds
Slow - Elapsed: 0.081520 seconds

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 2.089 seconds
Slow - Elapsed: 6.303 seconds

[EMAIL PROTECTED] ~/My Documents/Python


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 the Python version does the very same number of iterations than the
 C++ one? I suppose they are looping on arrays of different sizes, just
 like my first version.


Hmmm.. You're quite right. The C++ version had an array size 100.000
(your version), the Python version still had an array size 10.000 (as
in my modified copy of the original version).

When fixing the Python version to have 100.000 items, like the C++
version, the Python timings are:

Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 40
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 0.512088 seconds
Slow - Elapsed: 1.139370 seconds

Still twice as fast as the fastest GCC 3.4.5 compiled version!

Incidentally, I also have a version compiled with VC++ 6 now... (not
yet w/VC++ 7) .. Compiled with release-flags and maximum optimization
for speed, here's the result of VC++ 6:

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest_VC.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 4.481 seconds
Slow - Elapsed: 4.842 seconds

So you can see that it's 'slow' version of the code is faster than the
'slow' version compiled with GCC, but the 'fast' code is barely faster
than the 'slow' code! And the 'fast' version compiled with GCC is much
faster than the 'fast' version compiled with VC++ 6!

My conclusion from that is, that the vector or set implementations
of GCC are far superior to those of VC++ 6, but that memory allocation
for GCC 3.4.5 (MinGW version) is far worse than that of MSCRT / VC++ 6.
(And Python still smokes them both).

Cheers,

--Tim



 --
 blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
 site:  http://www.akropolix.net/rik0/  | tenetevi riso e
 forum: http://www.akropolix.net/forum/ | bacchette per voi.

-- 
http://mail.python.org/mailman/listinfo/python-list


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
   implementation that comes with GCC 3.4!
 
  And the Python version does the very same number of iterations than the
  C++ one? I suppose they are looping on arrays of different sizes, just
  like my first version.
 

 Hmmm.. You're quite right. The C++ version had an array size 100.000
 (your version), the Python version still had an array size 10.000 (as
 in my modified copy of the original version).

 When fixing the Python version to have 100.000 items, like the C++
 version, the Python timings are:

[...]
 Fast - Elapsed: 0.512088 seconds
 Slow - Elapsed: 1.139370 seconds

 Still twice as fast as the fastest GCC 3.4.5 compiled version!

 Incidentally, I also have a version compiled with VC++ 6 now... (not
 yet w/VC++ 7) .. Compiled with release-flags and maximum optimization
 for speed, here's the result of VC++ 6:

 [EMAIL PROTECTED] ~/My Documents/Python
 $ ./SpeedTest_VC.exe
[...]
 Fast - Elapsed: 4.481 seconds
 Slow - Elapsed: 4.842 seconds

[...]

And the results of IronPython (1.0rc2) are just in as well:

IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.

 import sys
 sys.path.append('c:/documents and settings/leeuwt/my documents/python')
 import SpeedTest
 SpeedTest.run_test()
Begin Test
Number of unique string objects: 4
What do you know
so long...
chicken crosses road
fool
Number of unique string objects: 40
What do you know
so long...
chicken crosses road
fool
Fast - Elapsed: 1.287923 seconds
Slow - Elapsed: 4.516272 seconds



And for Python 2.5:
[EMAIL PROTECTED] ~/My Documents/Python
$ /cygdrive/c/Python25/python.exe SpeedTest.py
Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 40
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 0.440619 seconds
Slow - Elapsed: 1.095341 seconds

[EMAIL PROTECTED] ~/My Documents/Python

But beware! For Python2.5 I had to change the code slightly, because it
already realized that the expression

'%s' % 'something'

will be a constant expression, and evaluates it once only... so I had
to replace '%s' with a variable, and I got the timings above which show
Python2.5 to be slightly faster than Python2.4.

(Next step would be to create a VB version and a Java version of the
same program, oh and perhaps to try a version that would work with
Jython... perhaps somehow w/o the 'set')

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 a variable, and I got the timings above
 Tim which show Python2.5 to be slightly faster than Python2.4.

 Shouldn't you then get rid of any compiler optimizations your C++ compiler
 does?  Why penalize 2.5 because it recognizes a useful optimization?

The point is that I was trying to create 400.000 string instances. The
extra optimization in 2.5 required an extra trick for that.
The idea is to compare a C++ version which creates 400.000 string
instances, with a Python version which creates 400.000 string
instances; then reduce those 400.000 instances to a set of only 4
unique strings.
(So I cannot just create a list with strings generated from numbers 1 -
400.000, and I didn't want to change the original code too much, so I
just added a trick to make Python allocate a new string each time
round.)

I agree that Python2.5 recognized a useful optimization, and didn't
wish to penalize it for that, however the optimalization was defeating
the purpose of my code in the first place!

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 tried to get the
 equivalent in c++ of :


Your C++ version got me the following timings (using gcc 3.4.5 as the
compiler, MinGW version, with -O6):

[EMAIL PROTECTED] ~/My Documents/Python
$ ./testcpp.exe
print_occurence_of_strings
What do you know?
chicken crosses road
fool
so long...
print_occurence_of_unique_strings
What do you know?
chicken crosses road
fool
so long...
print_occurence_of_unique_strings_compared_by_address
What do you know?
chicken crosses road
fool
so long...
strings : 2.135
unique strings : 1.103
compared by address : 0.21


For reference, Python's best time was 0.39 seconds on the same computer
(in the 'fast' version, using only 4 unique string instances).

Hmmm... Can we conclude now that carefully crafted C++ code is about
twice as fast as casually and intuitively written Python code? ;) (Just
kidding here of course)

NB: Your code now tests for address-equality. Does it also still test
for string-equality? It looks to me that it does, but it's not quite
clear to me.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 several seconds to run! Can somebody
 explain this to me? Or is there something wrong with my code?

Hi,

I'm no C++ guru so cannot comment on the C++ code itself, however I do
wonder if you tested your C++ code with other STL implementation such
as gcc (gcc is available on windows as well, in various versions).

What could be is that expanding the list in C++ is done in very small
increments, leading to many re-allocations. Is it possible to
pre-allocate the vector with sufficient entries?


Also, your Python code as quoted, doesn't actually call your function
f(). If you say that you get results instantly, I assume that you mean
all 4 strings are actually printed to console?

(I'm surprised that the console prints things that fast).

btw, using range() in Python isn't very efficient, I think... Better to
use xrange().


Asked a C++ collegue of mine to comment, and he strongly suspects that
you're actually running it in the .Net runtime (your C++ code contains
some C#-isms, such as omitting the '.h' in the include  statements).

Luck,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 hash algorithm, so the equivalent STL type would be
 `hash_set`.  `set` in Python does not store its contents sorted.


The set should be only 4 items in size, according to my reading of the
code, so set implementation differences shouldn't lead to drastic
performance differences.


 Ciao,
   Marc 'BlackJack' Rintsch

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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++.  The standard C++ header names don't have a
 trailing '.h'.  ``gcc`` prints deprecation warnings if you write the
 names with '.h'.
 
 Ciao,
   Marc 'BlackJack' Rintsch

We stand corrected.

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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), and let the
 caller call that as usual (see Terry's last example).

 (hint: x.foo() can be written f=getattr(x,foo); f())


 /F

I can tell you from my experience that this works; I've used this
before to make something very much like this proxy-class:

class RequestCalculations(object):
def __init__(self, request):
self.serviceType, self.facade =
makeMessageFacadeInstance(request)
return

def __getattr__(self, name):
return getattr(self.facade, name)

(rest of the code omitted)

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.
 
  /F

 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 still creates a new string - instance each time it tries to
append a const char* to the vectorstring ...

You should instead create the string-objects ahead of time, outside of
the loop.

Regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 creating 4 string objects.
  
   /F
 
  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 still creates a new string - instance each time it tries to
 append a const char* to the vectorstring ...

 You should instead create the string-objects ahead of time, outside of
 the loop.

 Regards,

 --Tim

Alternatively, slow down the Python implementation by making Python
allocate new strings each time round:

a.append('%s' % 'What do you know')


... for each of your string-appends. But even then, the python-code is
still near-instant.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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

 - there's no way to build a single EXE, to make deployment easier (if
 multiple files, I need to build an installer with eg. NSIS or
 InnoSetup)?

 Thank you.

Hi,

I have a wxPython app, which I compile into one EXE file. Then there's
just 1 support file needed: a MS DLL (which, once distributed, you will
not need to update).
Oh, and for w9x support there's an extra file, popenw9x.exe (or
something like that) which you can probably forget about if you don't
wish to support that.

Well, OK, that makes 3 files... Icons for windows are extra too, and
any other setup/ini/datafiles you wish to add and that are opened as
'normal' files too.

So what I do then is bundle it up as an self-extracting-archives, using
7-zip, which by default extracts into a sub-directory of the directory
where you copy the SEA-exe.

Voila, simple and easy, no installer required.

Works for me; dunno if it's good enough for your needs as well. (Oh,
and creating the SEA-exe you can probably automate if from the setup.py
but I haven't bothered yet)

Cheers and good luck,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 example Python and Leo, python-based application)
 together? Does the installers have to be python-based to be able to use
 Py2exe? Are there any other alternatives?

 Many thanks in advance for your advice

 regards
 Casey Wong

Hi Casey Wong,

If you download py2exe, you'll find a number of examples of how to use
py2exe to create installers using InnoSetup.
On the wiki, you'll also find examples of how to do this -- even with
pygtk applications.

However, it's not platform independant -- it'll be for windows only.

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.python.org/mailman/listinfo/python-list


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 fixed again...

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 that exist? (Something which, in case of iterable,
  doesn't consume the first element of the iterable)

 isiterable = lambda obj: isinstance(obj, basestring) \
   or getattr(obj, '__iter__', False)


 Should cover most cases.

Yes, that seems to cover all cases I can think of, indeed. Funny
though, that string objects do not have an '__iter__' method, but are
still iterable... But it will make most of my use-cases easier: Often I
want to iterate over something, if it's an iterable, except when it's a
string.


Thanks,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond ([EMAIL PROTECTED]) -
see 'Help/About PythonWin' for further copyright information.
 def foo():
... def nestedfunc(bar):
... print bar, ';', localvar
... localvar += 1
... localvar=0
... nestedfunc('bar')
...
 foo()
bar =Traceback (most recent call last):
  File interactive input, line 1, in ?
  File interactive input, line 6, in foo
  File interactive input, line 3, in nestedfunc
UnboundLocalError: local variable 'localvar' referenced before
assignment


This is entirely counter-intuitive to me, and searching the manual for
nested scoping rules and for augmented assignment rules, I still feel
that I couldn't have predicted this from the docs.

Is this an implementation artifact, bug, or should it really just
follow logically from the language definition?

Regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 part even
 if there is an error in the previous statements? Or have I understood
 something wrong?

try ... finally already exists in current python; what's new is that it
can be combined in 1 statement with try ... except ... finally.

No, this is not defeating a compilers job. It's very useful.

It defines an amount of cleanup that needs to happen no matter what,
exception or no exception. Example: closing an open file. You'll want
to close the file, whether after you done the job you intended to do,
or after an exception occurred while doing something.

So you put 'f.close()' in your finally - suite.

Another example of a useful 'finally' is logging function-exit -- not
the actual 'return' statement, but just a log-statement recording
function-exit.

(Putting a 'return' statement in a 'finally' suite is totally defeating
the point of exceptions that you want thrown to the caller, yes. So
don't put your 'return' statement there.)

Clearer?

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 Wiki
site:
http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK

I followed those instructions to convert my setup.py file; everything
still worked the same as before.

Then I copied GTK's 'etc', 'share' and 'lib' directories into the
directory of my executable, as per instructions.

That's when it all went wrong...

(See errors below)

Apart from the errors below, there were also multiple windows
error-reporting popup boxes telling me that the program crashed; do I
want to send info to Microsoft.

If anyone can help me getting a PyGTK GUI running as standalone
executable, that would be very much appreciated!

I know it's possible, BitTorrent had a PyGTK GUI on windows.

(I'm not that attached to PyGTK as such, but I'm somewhat familiar with
it and it has a good multi-column TreeView widget with inline editing.
That's what I need for my program, and wxPython didn't seem to have a
very workable solution for multicolumn treeviews...)


$ ./CBGui.exe

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2255:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2255:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:1320): Gdk-CRITICAL **: gdk_window_new_internal: assertion
`GDK_IS_WINDOW (parent)' failed

(CBGui.exe:1320): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

(CBGui.exe:1320): Gdk-CRITICAL **: _gdk_window_destroy_hierarchy:
assertion `window != NULL' failed

(CBGui.exe:1320): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2215: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2255: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2215: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2255: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2215: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): GLib-GObject-CRITICAL **: gtype.c:2215: initialization
assertion failed, use g_type_init() prior to this function

(CBGui.exe:916): Gdk-CRITICAL **: gdk_window_new_internal: assertion
`GDK_IS_WINDOW (parent)' failed

(CBGui.exe:916): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

(CBGui.exe:916): Gdk-CRITICAL **: _gdk_window_destroy_hierarchy:
assertion `window != NULL' failed

(CBGui.exe:916): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2255:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2255:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use g_type_init() prior to this
function

(CBGui.exe:5020): Gdk-CRITICAL **: gdk_window_new_internal: assertion
`GDK_IS_WINDOW (parent)' failed

(CBGui.exe:5020): GLib-GObject-CRITICAL **: g_object_new: assertion
`G_TYPE_IS_OBJECT (object_type)' failed

(CBGui.exe:5020): Gdk-CRITICAL **: _gdk_window_destroy_hierarchy:
assertion `window != NULL' failed

(CBGui.exe:5020): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed

(CBGui.exe:5936): GLib-GObject-CRITICAL **: gtype.c:2215:
initialization assertion failed, use 

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 empty
  squares. But the program worked.
 
  I looked up some docs, found the following recipe on the PyGTK Wiki
  site:
  http://starship.python.net/crew/theller/moin.cgi/Py2exeAndPyGTK
 
  I followed those instructions to convert my setup.py file; everything
  still worked the same as before.

 versions of python,gtk,pygtk? wich windows?
 wich installer of gtk have you used?
 did you install pycairo too?

 try again with these one, if different from yours
 gtk - http://gladewin32.sourceforge.net
 pygtk/pycairo  - http://www.mapr.ucl.ac.be/~gustin/win32_ports/

 bye,
 Riccardo

Riccardo,

Thanks for your reply; sorry for omitting all the relevant details!

Python: 2.4.3 from python.org
Windows XP SP2
GTK 2.8.18 from gladewin32
pygtk  pycairo from Gustin's ports.
py2exe: 0.6.5

The program works when run under the interpreter; but crashes when
using py2exe and all shared files mentioned, are copied to the same dir
as the exe. (When I don't copy all those files, pango complains about
missing fonts and shows only empty squares for all leters. but the
program doesn't crash. It only crashes when GTK's shared files are with
the program)

Thanks,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 commercial project, but the current BitTorrent beta's
(versions 4.9.x) are written with wx ...

To me, the appearant lack of a good and easy-to-use multi-column tree
widget was a showstopper to diving deeper into wxPython, though. I
decided to use PyGTK for now, which I'm a bit more familiar already and
which I know has a multi-column tree good enough for me (and I found it
easy to add inline-editing too).

I don't know how good PyQT is on windows; other than that, in my
opinion PyGTK gives the best / most complete GUI for Python with
reasonable ease-of-programming.


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 miniprogram) but I actually need to display
2 columns -- perhaps more.

I figured out that I can specify the number of columns and the headers
of the columns, but I haven't yet figured out how to set the values of
the columns independantly.

I tried using a tuple for the value of 'text' attribute, but that
doesn't really seem to work. My second column never seems to be filled
- all text goes into the first column.
Also, the header for the second column never shows.

I must be overlooking something rather basic in the manuals but for the
moment I'm stumped.

I'm also trying to figure out how to create a Tix 'Tree' widget instead
of a HList, and make it do the same, but I don't know how to pass it
the option for 2 columns: the 'Tree' widget refuses the option
'columns'. The samples in the Tix manual are for Tcl. I don't know how
to translate their samples into Python/TkInter. How should I tell the
Tix 'Tree' mega-widget that I need to pass an option to it's
sub-widget? (At creation-time of that sub-widget, because that's the
only time you can set the nr. of columns)

Any clues? Anyone who can help? Are there any samples -- there's
supposed to be a 'Demo' directory but I can't find it in my (windows)
Python installation.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 length of 3? :-)
 
 --
 Greg

Against all zero of them... ;-)

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 in the discussions
linked from these pages:

http://en.wikipedia.org/wiki/Ilias_Lazaridis
http://www.encyclopediadramatica.com/index.php/Ilias
http://groups.google.com/group/comp.lang.java.softwaretools/tree/browse_frm/thread/f07832cf6d0094f0/ae6315fda51d50a1?rnum=1hl=en_done=%2Fgroup%2Fcomp.lang.java.softwaretools%2Fbrowse_frm%2Fthread%2Ff07832cf6d0094f0%2Fae6315fda51d50a1%3Ftvc%3D1%26q%3Dilias+EVALUATION%26#doc_ae6315fda51d50a1

EOT?

-- 
http://mail.python.org/mailman/listinfo/python-list


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 definately no rules in Python that allow you to 'abbreviate'
variable names.

Cheers,

--Tim

mateus wrote:
 print hello world

 I have a nested loop where the outer loop iterates over key value pairs
 of a dictionary and the inner loop iterates over a list each list of
 which is a mapped value from the dictionary

 def showReport(self):
 for dev, sessions in self.logger.items():
 for tree in session:
 self.addTestItem(self, tree)

 What I don't understand is why this executes w/o any problems when
 sessions was spelled as plural (sessionS) while later being spelled
 in the singular (session).

 Is there some type of name resolution of local variables where Python
 makes assumptions?

-- 
http://mail.python.org/mailman/listinfo/python-list


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 Excel object model.


You should definately run makepy, it will be a great help, but there
are objects for which you can still not get any 'help' from your IDE's
autocompletion...
In those cases you'll just have to wing it, and indeed refer to the
Excel helpfiles for VBA methods/objects/etc.

Look at some samples on the web, and experiment a lot (using the
PythonWin IDE seems to work quite well for this kind of experimenting,
perhaps IDLE would also do it quite well. Due to the dynamic nature of
this kind of explorations, the pydev Eclipse plugin doesn't work well
for it).


 Also, searching this group and the pywin32 mailing list
 for excel.application turns up a bunch of sample code.
 
 hth
Roger
 
 

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 free speech, but he's
repeatedly crossing boundaries on usenet nettiquette, even though
repeatedly he's being asked not to do so. (Extensive crossposting to
various usenetgroups / mailing lists, for instance).

If he would just post his stuff on a blog and find a why to get people
to visit hist blog, without crossposting to 10 usenest groups for each
post he makes to his blog, then nobody would mind him expressing his
opinions, and those interested could discuss them wildly on the blog.

But I've repeatedly seen people telling him not to crosspost his essays
to so many newsgroups, yet he continues doing it.
If that's enough to quit his subscription with his ISP I don't know,
but since I've stopped following threads originated by him I don't know
what other grounds there would be.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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

2006-05-22 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.



Hi Andrew,

I played around a bit more, not happy that the read_file method which I
discovered earlier on the Values - object takes a property-file like
input and doesn't call any callbacks (for instance).

So I wrote a little module to provide an option-parser callback for
reading arguments from file...

Since it seems that Google Groups doesn't allow me to attach the file,
I'll paste it into here, hoping that nobody objects very strongly:

===
Callback for optparse.OptionParser that interprets a command-line
argument as filename, reads the file, and adds the contents of the file
to the options to be parsed by the OptionParser.

Usage:

 from args_from_file import add_argsfile_option
 from optparse import OptionValueError
 import sys
 op = OptionParser()
 add_argsfile_option(op, '-f', '--file')
 op.parse_args(sys.argv)

(This sample assumes that on the command-line, there 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 optparse import OptionValueError

#SPLIT_ARGS = r'([^]*|\'[^\']*\'|[^\s]+)'
SPLIT_ARGS = r'((?:)([^]*)(?:)|(?:\')([^\']*)(?:\')|[^\s]+)'
g_split_args_re = None

def extract_args_from_string(arg_str, append_to=None):
global g_split_args_re
if not g_split_args_re:
g_split_args_re = re.compile(SPLIT_ARGS)
argv = g_split_args_re.findall(arg_str)
argv = ([v for v in x if v  ''][-1] for x in argv)
if not append_to is None:
return append_to.extend(argv)
else:
return list(argv)

def load_file(filename, skip_comments=True):
f = None
try:
f = open(filename, 'rb', 16384)
if skip_comments:
lines = .join((line for line in f if line.strip()[0] 
'#'))
else:
lines = .join(f)
return lines
finally:
if f  None:
f.close()

def optparse_cb_load_args_from_file(option, opt, value, parser):
try:
args = load_file(value)
extract_args_from_string(args, parser.rargs)
except Exception, e:
raise OptionValueError(
'Error parsing argument %s, with reading options from
option-file %s. Originating error: %s' %
(opt, value, e))
return

def add_argsfile_option(parser, *option_names):
return parser.add_option(*option_names,
  **{'type':'string',
 'action':'callback',
 'callback':optparse_cb_load_args_from_file})
===

Feel free to use as you like. Might make a nice addition to the
standard action types of optparse in the standard library? If there's
interest in that, I might try to write a patch for optparse.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Process forking on Windows

2006-05-18 Thread Tim N. van der Leeuw

Andrew Robert wrote:
 bruno at modulix wrote:
[...]
 
  just-asking
  Is this really the solution ?
  /just-asking
 
[...]


 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 get around this would be to fork off and terminate the parent.

 Unfortunately, Windows appears to be somewhat stubborn about it.

 Creating a subprocess does not alleviate the need to get the originating
 process out of the trigger monitor.

I have my doubts that this will solve the problem.

You have a process that communicates with another, single-threaded,
piece of software. If you fork of a sub-process, then you have another
process communicating (and hogging up) this single-threaded piece of
software.

Well, if your original program is long-running, your sub-process is
short-running, and you cannot 'disconnect' from the MQ Monitor other
than by terminating a process, yes then I can see how using a
subprocess could solve your problem... But I don't know why the
SubProcess module doesn't do what you want.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 your post I decided to play around with optparse a bit,
to get acquainted with it.

Experimenting with IDLE I found that the Values object returned by
parse_args has a method 'readfile', and this 'readfile' method allows
you to add options to the Values object.

The syntax should be in the form:

option=value

option should not include the hyphens -- if your option is added as
'-x', then you should write:

x=3

not:

-x=3

If you have options with both long names and short names, then you
should use the long name -- if your option is added as '-f', '--file',
then you should write:

file=foo.txt

not:

f=foo.txt


Also, you need the assignment-operator in your file.

I didn't find any documentation on this, and I didn't try this with any
actions; only with options added to the parser like
op.add_option('-x', dest='x')

Using this 2-step approach allows you to use optparse itself to get to
the command-line option with your command-line settings...


Out of pure personal interest, what queuing-system are you writing to
from Python? What libraries do you have for that? And is it commercial
software, or freely downloadable?
(I'd love to be able to write messages to IBM MQ Series from Python)

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 links instead of the 'reply' link beneath the
message.

On-Topic: I'd welcome PythonWin added to the Python Windows MSI
installer too, for purposes similar to the O-Ps.
Do not possess the necessary skill to write patches, but still voting
in favor.

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.net/pymqidoc.html .

 I have a few python examples on my web site located at
 http://home.townisp.com/~arobert/

 There are also a lot of good examples at
 http://www.koders.com/info.aspx?c=ProjectInfopid=TVM5FGBZMY4E5ZH7GC9AX54PAC
 .

 If you come up with anything, I would be glad to see what you have.



Thanks a lot for these examples! I have some Java tools that send MQ
messages (reading, in fact, a ton of command-line arguments from a
file) and I need better tools. If I could use some Python for rewriting
this, it might speed me up a lot.


 Back to the original issue:

 I'm not sure exactly what you mean about the readfile option and format.

 Could you send me a code snippet so I can get a better feel for it?


 Thanks,
 Andy

Here's the file I used:

===cut here===
x=4
w=6
what=7
zoo=9
===cut here===

Here's some snippets of code:

 from optparse import OptionParser
 op = OptionParser()
 op.add_option('-x', dest='x')
 op.add_option('--what', '-w', dest='what')
 v=op.parse_args()[0]
 v.read_file('options-test.txt')
 v
Values at 0x12a9c88: {'x': 4, 'what': 7}

As you can see, I'm parsing an empty command-line but I could parse a
full command-line as well before loading options from file.
After parsing the command-line, I get an instance of a 'Values' object,
and on this object I call a method 'read_file' with a filename. (I
could also call 'read_module', and it will add the __doc__ string).

I didn't test what happens with a more advanced useage of OptionParser
options.


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.

Sorry, but that's best I can offer!

-- 
http://mail.python.org/mailman/listinfo/python-list


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):
 calculate a factorial
 if n == 0:
return acc
 res = factorial(n-1, n*acc)
 return res

 but a more common way to write the function would be:

 @tail_recursion
 def factorial(n):
 calculate a factorial
 if n == 0:
return 1
 return n * factorial(n-1)

 which won't work because it isn't actually tail recursion, but it looks
 sufficiently close to tail recursion that it would probably mislead a lot
 of people into expecting it will work. If you are going to have to rewrite
 functions in a stilted manner, and they use simple tail recursion, then why
 not just factor out the tail recursion in the first place.

[...]

Hi Duncan,

I don't know why it wouldn't work this way, or why it isn't
tail-recursion?

I tried the tail_recursion decorator from the cookbook-recipe with both
definitions of factorial, and I tried both definitions of the factorial
function with and without tail_recursion decorator.

In all four cases I get the same results, so it does work with both
definitions of factorial(), even if (according to you) the second
definition is not proper tail-recursion.

Using the tail-recursion decorator (the version that does not inspect
the stackframes) I get a small performance-increase over using the
factorial-function undecorated.
However, calculating factorial(1000) with the factorial-function as
defined in the cookbook-recipe is much much faster than calculating the
same factorial(1000) with the factorial-function you gave!
I cannot yet explain why the first function has so much better
performance than the second function  - about a factor 10 difference,
in both python2.4.3 and python 2.5a2


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 defined in my test-file:

@tail_recursion
def factorial(n, acc=1):
# do the stuff
pass

def factorial_r(n, acc=1):
# do the stuff
pass

@tail_recursion
def factorial2(n):
# do the stuff
pass

def factorial2_r(n):
# do the stuff
pass

All four functions give the same output for the tests I did (n=120, and
n=1000).
Using timeit, both factorial(1000) and factorial2(1000) are somewhat
faster than factorial_r(1000) respectively factorial2_r(1000).
However, factorial(1000) and factorial_r(1000) are both 10x faster than
factorial2(1000) and factorial2_r(1000).

It's the latter performance difference which I do not understand.

The other thing I do not understand, due to my limited understanding of
what is tail-recursion: factorial2 (Duncan's definition) is not proper
tail-recursion. Why not? How does it differ from 'real' tail recursion?
And if it's not proper tail-recursion and therefore should not work,
then how comes that the tests I do show it to work? And I seemed to
consistently get a slightly better performance from factorial2(1000)
than from factorial2_r(1000).


NB: Regarding the recursion limits, I don't know what would be the
stacklimit on my system (Python 2.4.3 on WinXP SP2). I already
calculated the factorial of 50 using the recursive (non-decorated)
function...


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 have to rename the recursive calls as
 well. (At least, that's what I forgot to do when I first tried it and
 couldn't understand why it gave me an answer instead of crashing.)
[...]

Duncan,

You're totally right. Somehow, I had managed to completely overlook
this. Oops!
My apologies! :)

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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's
better to use 'xrange' instead of 'range': 'xrange' will not create the
whole list of numbers in advance, but will create an iterator,
producing the desired numbers one by one. With such large ranges, this
will reduce memory consumption significantly.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 import izip
 dict(izip(alist[::2], alist[1::2]))
{'QWER': 'askfhs', 'FGDG': 'sdfsdgffdgfdg', 'REWR': 'sfsdf'}

And perhaps using islice from iterools might improve efficiency even
more:

 from itertools import islice, izip
 dict(izip(islice(alist, 0, None, 2), islice(alist, 1, None, 2)))
{'QWER': 'askfhs', 'FGDG': 'sdfsdgffdgfdg', 'REWR': 'sfsdf'}


(I didn't try to time any of these solutions so I have no real idea
which is more efficient, but using iterators from the itertools-module
should in theory mean you create less temporary objects; especially
with large lists this can be a win)

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 sorting for anything iterable...

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 list elements position 0 up to (excluding) 5; in
other words: the first 5 elements.
A shortcut for this is: alist[:5] -- omitting an index position means a
default of 'start' resp. 'end'.
So to take all elements from the 5th to the end of list, you write:
alist[4:] (remember that indexing starts at position 0, so 0 is your
first element, 4 is your 5th).

To take a slice that is the whole list, write: alist[:]

Slices discussed so far take all elements in the indicated range,
however you can specify a 'step' with your slices. Default step is 1,
but to skip every other element you write:
alist[::2]
Which takes all elements of your list, starting at position 0, adding 2
to the index each step, so next is item 2, then 4, etc, until end of
list.
Now we have all the 'even-numbered' elements in the list, to get the
'odd-numbered elements' write:
alist[1::2]

I hope this helps.


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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?

Please specify!

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pre-PEP: The create statement

2006-04-06 Thread Tim N. van der Leeuw
From what I read here it would make a huge useability improvement for
properties, and for that alone I would vote this a +1 if I were given
the right to vote.

Could this still make it in Python 2.5 even? If it's pushed hard
enough? I don't know if this has been discussed on the python-dev
mailing lists and what the reactions of python-devs and GvR was?

regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitwise OR?

2006-03-24 Thread Tim N. van der Leeuw

xkenneth wrote:
 Why is 3500 | -67 equal to 3500 instead of -3567?

Well that's funny... On my computer, python says it's -67. Java also
says it's -67.

Haven't yet looked at the actual bits of both values.
What Python implementation and what machine do you have?

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitwise OR?

2006-03-24 Thread Tim N. van der Leeuw
Actually, following up to my own reply:

3500 | 67 = 3567. So perhaps that sets your expectations for 3500 |
-67.

But try

 -3500 | -67

for fun: it is -3

Bitwise or is no arithmetic and if you want to predict something about
the resulting integers, you should know something about how they are
stored.

Negative integers are stored in 2-complement format: minus 1 is all
bits set to 1. Turning bits off makes it a more negative number (as
long as you don't touch the sign-bit) and turning more bits on makes it
a smaller negative number.

Doing bitwise-OR for the positive numbers 3500 and 67 results in 3567:
proof that they don't have any overlapping bits.
Know it turns out that 3500 and -67 have only overlapping bits:
therefore the result is -67. (adding the bits from 3500 to the bits of
-67 doesn't turn on any extra bits).

Use bit operators to manipulate bits, and think of the operands as sets
of bits. Bitwise OR is the union of 2 sets of bits.
Don't think of the operands to bit operators as numbers, and don't try
to do your sums using bitwise or!

:-)

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bitwise OR?

2006-03-24 Thread Tim N. van der Leeuw
I wonder what causes one version to be faster for positive, and the
other faster for negative numbers? I can see that the pos-version
doesn't make as many iterations as the neg version, but it doesn't pad
the length of the result to the requested number of digits and
potentially produces more digits.

I also wonder if it wouldn't be faster to put the numbers into a list
and join the list into a string -- did you test with that?

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 declarations on
the web.

Your gAllSupported can be a set(); you can then create the intersection
between gAllSupported and the function-names found by your regex.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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' and
the iterable of all matches...

Your sample code would then look like this:

 import re
 r = re.compile(r\w+)
 file_content = foo bar-baz ignored foo()
 wanted = set([foo, bar, baz])
 found = wanted.intersection(name for name in r.findall(file_content))
 print found
set(['baz', 'foo', 'bar'])


Anyone who has an idea what is faster? (This dataset is so limited that
it doesn't make sense to do any performance-tests with it)

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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.python.org/mailman/listinfo/python-list


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,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 OO practice in
many places: The Image.open() method acts as a factory-function for
creating Image objects.
You don't know, until you inspect the return value, if the created
object is actually an instance of class Image or something which just
happens to behave like one...
It could for instance be a sub-class of Image, JpegImage, if that
better suits the class library designers.
In general, factory-functions allow greater uncoupling between
interface and implementation.

Regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 Cyrillic
characters and my program blew up.

So now what I need to know is, how do I find out in what encoding a
particular filename is? Is there a portable way for doing this? And if
not, then what is the non-portable way for doing this on Windows?
(WinXP)
(If there's only a non-portable way then I'll worry about porting it
later, if and when this program will ever have a need to run on a
Unix-like environment)


Many thanks in advance,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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-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 sleek pictures there if they weren't desperatly
trying to advertise success-stories but instead would link to real
content!)

I do like to overall look-and-feel of the beta site but I hope the bad
bits get fixed before launch!

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 could be there instead of those
3 pictures. But I'd like there to be some actual real Python content,
or links to events from the Python Events Calender; or perhaps links to
large python projects like Zope -- something that links to the major
parts of Python. Perhaps 1 picture that links to Python Web Development
including things like Zope, Django, etc; another picture that links to
a page giving overview of major IDEs for Python; and 3d picture that
links to page with Python Event calender... Something along those
lines. But I don't have any graphics for you.)

regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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


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 Word? Or is
it OK if it's an external application (with or without GUI) which does
manipulations with MS Word documents using COM objects?

(I frequently do the latter, but don't know about doing the former)

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 at the command prompt,
although not everything is very obvious (in part due to the way the
word object model is structured).

BTW, if you are new to Python, why not use VBA for the program?

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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: 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 already
exists).
This is clear, and easy to achieve with a simple wrapper or subclass.

But should the dict also be flagged as 'modified' when I append an item
to one of the lists that is in the dict?
 l = d['a']
 l.append('1')
Does that code mean that the dict should be flagged as 'modified' in
your use-case? or not?

If yes, then the only feasible way might be to pickle the dict. And if
repeated pickling of the same dict is not guaranteed to give the same
results, then perhaps pickling d.getitems() would give the right
results since, AFAIK, dict.getitems() is at least guaranteed to
maintain the same order given that A) The dict is not changed and B)
You're using the same Python version.

Right?

-- 
http://mail.python.org/mailman/listinfo/python-list


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: Python for the JVM. Because AFAIK, there are no
interfaces for Python to the likes of IBM's MQSeries or for any
distributed transaction managers.

- Is your application purely a web-based application? Or is there a
large amount of application logic which is not tied to the web in any
way?

- Python has a number of frameworks for developing server applications,
like Twisted, Zope and Django.
I don't know Twisted; I know a little bit about Zope. Zope has several
enterprise-level features and provides scalability/clustering.
However, I've found the learning-curve for Zope to be a bit steep so
far; too steep to master it in what little bits of spare time I have.
(If I would have more time I'd be able to get the hang of it but I
don't have enough time)

I've started to toy a bit with Django and it seems to get rather easy
to get started with developing a Web application using Django; however
I also get the feeling that installation is a bit more involved than
with Zope and that it will be not as easy to package up an application
and transport it to another machine, as it is with Zope.


So for development of Web-applications, I would certainly consider
either Zope or Django.
Both offer ways to store your data in a transactional database; Django
has some object-relation mapper tools but I'm not sure how exactly Zope
stores data in a SQL database (it comes with it's own powerful
object-database, the ZODB but I don't know if OR mapping tools exist
for Zope).


However you mentioned 'development in J2EE' and J2EE applications are
by no means restricted to Web interfaces. J2EE applications can have
rich GUI clients, or can be without any UI at all and exist just as
message-driven beans triggered by messages coming in via JMS
interfaces.
I wouldn't know what Python frameworks exist that would combine
web-based applications with tradional GUI client/server applications
and I have no idea how to listen to a queue using Python...


So what are your requirements for 'J2EE' applications? And which Python
framework would best fit the bill?


cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 like '20' etc. are hexadecimal values, meaning integers
with base 16.
  Get the actual int-value like this:
  code_int = int(code_str, 16)
- Convert to character as: code_chr = chr(code_int)
- Write this character to the output cStringIO buffer
- When the whole URL is done, do getvalue() to get the string of the
new URL and close the cStringIO buffer.

Is that sufficiently comprehensible? Or still too convoluted for you?

(PS: I researched doing it the manual way, 'the hard way'. However,
there are plenty of libraries in Python for all sorts of internet
stuff. Perhaps urllib or urllib2 already has the functionality that you
need -- didn't look it up)

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 f in riles:
fullname = os.join(root, f)
zf.write(fullname)
zf.close()


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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-compatible archive that puts all files directly into 1
compressed archive.

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 this using os.command(zip_command). It works fine...
 
  But when I run this script in Windows XP, I get an error while
  executing the above zip command. What command is there to zip files in
  Windows? Or is there any other problem ?

 zip is not a built-in command for windows.
 You might use winzip or something else, there is
 a bunch of different compression tools available.

 ciao - chris


Something else to watch for -- Spaces in filenames. Uncommon on
unix/linux, but very common on windows. Put some double-quotes around
the filenames in your zip_command:

zip_command = 'zip -qr %s %s' % (target, ' '.join(source))


AFAIK there are built-in zip modules available in Python? They might be
a better alternative to calling an external zip command?

(Winzip btw, has a seperate download for a command-line capable version
of the compressor)

cheers,

--Tim


 --
 Christian Tismer :^)   mailto:[EMAIL PROTECTED]
 tismerysoft GmbH : Have a break! Take a ride on Python's
 Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
 14109 Berlin : PGP key - http://wwwkeys.pgp.net/
 work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
 PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
   whom do you want to sponsor today?   http://www.stackless.com/

-- 
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-list


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 aside, the dates are all in english while my PC might have a
dutch locale -- not even sure about what Python would consider the
current locale.
So that's an extra obstacle to parsing these dates.

The datetime module doesn't seem to provide a better solution either.

What I want to get is some sort of sortable date; either as a number or
(if nothing else) as a string in ISO8601 format.
(But I want to avoid doing too many string manipulations on my input
dates; and changing the dateformat of the input-source will be hard if
at all justifiable.)


Any help is appreciated.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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: 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 this is more efficient than the other
method; try it on big lists if you want to know. (But I like the idea
that I'm not looking up indexes in the old list all the time, which
just feels slow to me)

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 LiteStep.

Don't have a working URL at hand so try googling for it...

But a direct solution for your problem, no I don't have that.

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 called only when the attribute cannot be looked up via
normal means)

If you are seeing recursive calls to __getattr__, perhaps you can
highlight the problem with some sample-code?

regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 more.

I also have some tool that generates basic XSD files from sample input
xmls, and a tool that generates sample xml files from an XSD.

I'm not aware of any Python XSD tooling but did you search google on
it?

How much of XSD do you need to be supported? And what do you need to do
with it?

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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, some option, that perhaps changes the way that Python
recognizes globals?

If you declare another global variable, then try to use it in your
function, then what's the result?

What Python version do you use?

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 too big.

I don't know if perhaps other string-matching techniques can be used
btw; you don't need the full power of regexes I guess to match DNA
string patterns.
Perhaps you should investigate that a bit, and do some performance
tests?

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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


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 statements that I'm not aware of.

So are there smarter ways to get the intersection of dictionary and set
into a dictionary than the following pseudo-code:

# Variation 1
d2 = {}
for key in s: d2[key] = d1[key]

# Variation 2
for key in d.iterkeys(): if key not in s: del d[key]


And if there's no smarter way, then which of these two options would
give best performance?

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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 intersection method.

(I'm using Python 2.4.1 so I do have convenient builtin set operations
available)

In my taste, using generator expressions with conditions actually
doesn't look very readable; it hides the set-membership test under the
syntactic clutter.
(I don't mind generator expressions in principle, but I do feel that
here they clutter up the intent of the code)

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 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('') to return  ['m', 'y', 's', 't', 'r', 'i', 'n',
 'g']. But I guess it's in line with There should be one-- and
 preferably only one --obvious way to do it. that it's not so.

Fortunately, this is easy to write as: list(mystring).
Actually for me it's not so counter-intuitive that mystring.split('')
doesn't work; what are you trying to split on?

Anyways, I usually need to split on something more complicated so I
split with regexes, usually.

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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-page.

Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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


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 soon.

thanks,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


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,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >