[ANN] Leipzig Python User Group - Meeting, July 10, 2007, 08:00pm

2007-07-05 Thread Mike Müller
=== Leipzig Python User Group ===

We will meet on Tuesday, July 10 at 08:00pm at the training
center of Python Academy in Leipzig, Germany
( http://www.python-academy.com/center/find.html ).

Mike Müller will give his talk Parallel Computing in Python with
Pyro (PYRO) again. This is a wish of some group members.

Food and soft drinks are provided. Please send a short
confirmation mail to [EMAIL PROTECTED], so we can prepare
appropriately.

Everybody who uses Python, plans to do so or is interested in
learning more about the language is encouraged to participate.

While the meeting language will be mainly German, we will provide
English translation if needed.

Current information about the meetings are at
http://www.python-academy.com/user-group .

Mike



=== Leipzig Python User Group ===

Wir treffen uns am Dienstag, 10.07.2007 um 20:00 Uhr
im Schulungszentrum der Python Academy in Leipzig
( http://www.python-academy.de/Schulungszentrum/anfahrt.html ).

Mike Müller wird seinen Vortrag Parallelisierung von
Pythonanwendungen mit Python Remote Objects (PYRO) auf
Wunsch einiger Gruppenmitglieder nochmals halten.

Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter
[EMAIL PROTECTED] wäre nett, damit wir genug Essen
besorgen können.

Willkommen ist jeder, der Interesse an Python hat, die Sprache
bereits nutzt oder nutzen möchte.

Aktuelle Informationen zu den Treffen sind unter
http://www.python-academy.de/User-Group zu finden.

Viele Grüße
Mike

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANN: A STOMP messaging broker in pure Python (GPLv3)

2007-07-05 Thread tundish
This is the first announcement of a release of Sprinkle, a messaging
broker written in Python.

http://www.thuswise.org/sprinkle/index.html

Sprinkle implements the STOMP protocol

   http://stomp.codehaus.org/

Sprinkle is very simple and lightweight. I believe it is fully
functional, but I need help testing it so I can make it suitable for
an enterprise environment. In this early phase, you can get Sprinkle
as a development snapshot: sprinkle-2007-07-01.

Asynchronous messaging is receiving renewed interest from developers.
Let's give Python a simple, effective, and trusted messaging solution.

The code is distributed under version 3 of the GPL, and runs on Unix-
like platforms. Python 2.3.4 or later is required.

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


ANNOUNCE: PyGTK 2.10.5

2007-07-05 Thread Johan Dahlin
I am pleased to announce the stable version 2.10.5 of the Python bindings
for GTK+.

The new release is available from ftp.gnome.org and its mirrors
as soon as its synced correctly:

 http://ftp.gnome.org/pub/GNOME/sources/pygtk/2.10/

Blurb:

GTK+ is a toolkit for developing graphical applications that run on
systems such as Linux, Windows and MacOS X. It provides a comprehensive set
of GUI widgets, can display Unicode bidi text.  It links into the Gnome
Accessibility Framework through the ATK library.

PyGTK provides a convenient wrapper for the GTK+ library for use in
Python programs, and takes care of many of the boring details such as
managing memory and type casting.  When combined with PyORBit and
gnome-python, it can be used to write full featured Gnome applications.

Like the GTK+ library itself PyGTK is licensed under the GNU LGPL, so is
suitable for use in both free software and proprietary applications.  It
is already in use in many applications ranging from small single purpose
scripts up to large full features applications.

What's new since 2.10.4 ?
  - Do access private GtkTooltip member tips_data_list, fixes build
against Gtk+ 2.11.x (Johan)
  - Allow None to gtk_rc_get_style_by_paths (Mariano Suarez-Alvarez)
  - Fix defs file inconsistencies (Andrew Cowie)
  - Documentation build fixes (Richard Hult)
  - Code generator improvements (Tim Evans, Gustavo)
  - Include atk-types.defs when building using distutils, so gtk.Accessible
is available on win32

PyGTK requires GTK+ = 2.8.0 and Python = 2.3.5 to build.

Bug reports, as always, should go to Bugzilla; check out
http://pygtk.org/developer.html and http://pygtk.org/feedback.html for
links to posting and querying bug reports for PyGTK.

--
Johan Dahlin
[EMAIL PROTECTED]

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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


itools 0.16.1 released

2007-07-05 Thread J. David Ibáñez
itools is a Python library, it groups a number of packages into a single
meta-package for easier development and deployment:

   itools.catalogitools.i18n itools.tmx
   itools.cmsitools.ical itools.uri
   itools.csvitools.odf  itools.vfs
   itools.datatypes  itools.pdf  itools.web
   itools.gettextitools.rest itools.workflow
   itools.handlers   itools.rss  itools.xhtml
   itools.html   itools.schemas  itools.xliff
   itools.http   itools.stl  itools.xml

This is (mostly) a bug fix release:

  - The command line tool rsync is not required anymore.

  - Indexing of XML documents (like web pages) works again.

  - Now itools.web supports X_FORWARDED_PROTO, what makes possible to
deploy web applications behind Apache (or another web server) using
the HTTPS protocol.

  - Now itools.xml is able to serialize documents with CDATA sections.

  - In itools.stl the repeat variables repeat/x/index, repeat/x/start
and repeat/x/end work again.

  - The method set_handler works now when the container is a virtual
handler.

But most changes are in the itools.cms package:

  - The Quick Start is updated now, the icms-make-package -t quickstart
command works again.

  - The new method get_object has been added to the itools.cms API.

  - An important bug has been fixed in the itools.cms database, where
the incorrect usage of mkstemp made sometimes a transaction to
fail because all files descriptors were used.

  - Now we correctly unindex the content of a folder when it is removed.

  - There are various fixes and improvements to the Calendar and Wiki
objects.

  - The script icms-update has been improved in different ways.  Most
important, now it is possible to upgrade an itools.cms instance
directly from 0.14 to 0.16 (no need to go through 0.15).


Credits:

  - Hervé Cauwelier updated the Quick Start and fixed bugs;
  - Nicolas Deram worked on the Calendar object;
  - J. David Ibáñez fixed bugs;
  - Henry Obein fixed bugs;
  - Sylvain Taverne fixed bugs;


Resources
-

Download
http://download.ikaaro.org/itools/itools-0.16.1.tar.gz

Home
http://www.ikaaro.org/itools

Mailing list
http://mail.ikaaro.org/mailman/listinfo/itools

Bug Tracker
http://bugs.ikaaro.org/




-- 
J. David Ibáñez
Itaapy http://www.itaapy.com Tel +33 (0)1 42 23 67 45
9 rue Darwin, 75018 Paris  Fax +33 (0)1 53 28 27 88
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: login http://cheeseshop.python.org/pypi broken ?

2007-07-05 Thread Martin v. Löwis
gert schrieb:
 tried reseting password but i can not login anymore to upload my new
 source code ?

Please try again. It was a misconfiguration which should be fixed now.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: connecting to serial port + python

2007-07-05 Thread Gabriel Genellina
En Tue, 03 Jul 2007 10:01:51 -0300, Japan Shah [EMAIL PROTECTED]  
escribió:

 I am trying to connect my Nokia 6610 using usb cable,
 I have installed usb-serial driver of it.
 I hv tested it with Hyperterminal and it works fine.
 but when I wrote a python script I am not able to receive the responce
 from the device.


lines = self.sock.read(100)
If the response contains less than 100 bytes, the above line will block.

 command = ['AT','ATI','ATl1','AT+GMMM']

 for cmd in command:
conn1.write(str(cmd))

Don't you have to send ENTER after each command? \n

th = connect_serial(conn1)
list1.append(th)
th.start()

You can't have four threads all reading the same serial port. The device  
sends its responses sequentially anyway.

-- 
Gabriel Genellina

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


Re: windows cetificates

2007-07-05 Thread m.banaouas
thank you
I will take a look on capicom ...

Roger Upole a écrit :
 m.banaouas wrote:
 hi,

 is there any way to decrypt an email (already read with poplib, so available 
 on client side) with python using a window 
 certificate (those we can see on ie/internet options/content/certificates) ?

 the purpose is to decrypt an email sent and crypted by the sender with both 
 his own certificate and the recipient one.

 thanks for any help.
 
 If the messages use standard encoding, you should be able to use CAPICOM.
 The interfaces are fairly simple to use through win32com.client.
 The 'capicom.envelopeddata' object encrypts and decrypts using certificate 
 keys.
 
  Roger
 
 
 
 
 == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
 News==
 http://www.newsfeeds.com The #1 Newsgroup Service in the World! 100,000 
 Newsgroups
 ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-05 Thread Diez B. Roggisch
Siegfried Heintze schrieb:
 I love the typing assist I get when using C# in VS2005 to write COM clients.
 
 I need to write a program to automate some tasks in outlook. Givin that the 
 typing assist feature is very important to me, what would be the best 
 combination of IDE and language for COM scripting?
 
 I was experimenting with Groovy and Eclipse and was extremely pleased to 
 discover that I get the typing assist with that combination. However, I'm 
 getting an accvio with a minimal outlook COM client. I hear great things 
 about Iron Python: is there a good IDE for it that has a typing assist?

You won't get it in python. Python has no type declarations, thus the 
IDE has no idea what type a name points to. This is true for IronPython 
as well.

There are some other aids - for example eric (a python editor written in 
python, using Qt) will have API-files generated that at least let you 
choose the name of a method/property after you typed the first character.


But you should still try and see how productive one is in python. I'm 
working in a Java shop, with eclipse - one of the most intimate 
IDE-language-relationships imaginable. I get all the auto-completion, 
refactoring and whatnot-support.

And I'd swap it for python + emacs every minute.

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


['a', 'b'][True] results 'b' But how?

2007-07-05 Thread kath
Hi,

Can any one please tell me how is the following code is working?
['a','b'] is a list of string, and [True] is list of boolean value.
How is it making effect?
code Python24

 ['a','b] [True]
'b'
 ['a','b'] [False]
'a'
 ['a','b']['some_string' == r'some_string']
'b'
 ['a','b']['some_string' == r'somestring']
'a'

code


Thanks in advance,
regards,
kath.

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


Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-05 Thread Diez B. Roggisch
M�� schrieb:
 Hi!
 
 I love the typing assist I get when using C# in VS2005 to write COM 
 clients.
 
 But this run only for static-COM-servers. Dynamic-COM-servers are not 
 supported by these assists.

No. The IDIspatch-interface explicitely lists what methods with what 
arguments it has. So code completion is possible there as well.

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

Re: ['a', 'b'][True] results 'b' But how?

2007-07-05 Thread Kelvie Wong
In this case, [True] and [False] are not lists, rather you're
accessing the items of the list with the index True or False, as per
the following example:

 a_list = ['a', 'b']
 a_list[True]
'b'
 a_list[False]
'a'

This happens because the __getitem__ method takes its argument (which
in this case is True or False) and casts it into an integer:

 int(True)
1
 int(False)
0

So thus it follows logically that since:
 a_list[1]
'b'
 a_list[0]
'a'

a_list[True] and a_list[False] must be its first and zeroth  indexed
members, respectively.


On 7/4/07, kath [EMAIL PROTECTED] wrote:
 Hi,

 Can any one please tell me how is the following code is working?
 ['a','b'] is a list of string, and [True] is list of boolean value.
 How is it making effect?
 code Python24

  ['a','b] [True]
 'b'
  ['a','b'] [False]
 'a'
  ['a','b']['some_string' == r'some_string']
 'b'
  ['a','b']['some_string' == r'somestring']
 'a'

 code


 Thanks in advance,
 regards,
 kath.

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



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


Re: ['a', 'b'][True] results 'b' But how?

2007-07-05 Thread Robert Bauck Hamar
kath wrote:

 Hi,
 
 Can any one please tell me how is the following code is working?
 ['a','b'] is a list of string

Yes.

 and [True] is list of boolean value. 

No. It's the subscription operator applied to the list of strings.
a = ['a', 'b']
a[True]
may be clearer.

 How is it making effect?

 int(True)
1
 int(False)
0
 isinstance(True, int)
True
 bool.__bases__
(type 'int',)

 code Python24
 
 ['a','b] [True]
 'b'
 ['a','b'] [False]
 'a'
 ['a','b']['some_string' == r'some_string']
 'b'
 ['a','b']['some_string' == r'somestring']
 'a'
 
 code

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


Re: ['a', 'b'][True] results 'b' But how?

2007-07-05 Thread rishi pathak

True stands for 1 and False stands for 0
so list[True] is equivalent to list[1]
and list[False] is equivalent to list[0]

On 7/5/07, kath [EMAIL PROTECTED] wrote:


Hi,

Can any one please tell me how is the following code is working?
['a','b'] is a list of string, and [True] is list of boolean value.
How is it making effect?
code Python24

 ['a','b] [True]
'b'
 ['a','b'] [False]
'a'
 ['a','b']['some_string' == r'some_string']
'b'
 ['a','b']['some_string' == r'somestring']
'a'

code


Thanks in advance,
regards,
kath.

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [True] results 'b' But how?

2007-07-05 Thread kath
Hi Kelvie and RBH,

Thanks for your quick reply. That was very much helpful indeed.

regards,
kath.


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


Re: PyRun_String using my module in a def

2007-07-05 Thread Gabriel Genellina
En Thu, 05 Jul 2007 01:19:32 -0300, Stuart [EMAIL PROTECTED]  
escribió:

 What command do you mean when you say update main_dict with
 dlfl_dict?

I think Alex Martelly was refering to use main_dict.update(dlfl_dict)  
(Python code) or PyDict_Update(main_dict, dlfl_dict) (in C code).

 I tried PyObject *rstring = PyRun_String( cmd, Py_file_input,
 dlfl_dict, dlfl_dict );
 This worked, but has the side effect of not allowing other commands
 like execfile

The idea is to copy all items from dlfl_dict into main_dict, and use  
main_dict for both globals and locals.

-- 
Gabriel Genellina

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


Problem with building extension in Python

2007-07-05 Thread vedrandekovic
Hi,

I have already install Microsoft visual studio .NET 2003 and MinGw,
when I try to build a extension:

python my_extension_setup.py build ( or install ) , I get an error:

LINK : fatal error LNK1141: failure during build of exports file
error: command 'C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\link.exe' failed with exit status 1141.What shoud I
do???

If you now anything useful,
please contact me!!





 
Thanks!!

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


Re: Memory leak issue with complex data structure

2007-07-05 Thread Hrvoje Niksic
Alan Franzoni [EMAIL PROTECTED] writes:

 I have a serious leak issue; even though I clear all those sets
 and I delete all the references I can have to the current namespace,
 memory is not freed.

Maybe the memory is freed (marked as available for further use by
Python), just not released to the operating system.[1]  To test against
that, try to allocate more Python structures and see if they reuse the
freed memory or if they allocate even more memory.  Even better, run
code like this:

while 1:
  ... populate your data structures ...
  clear()

If this causes Python to allocate more and more memory, it means you
have a real leak.  If not, it means that the GC is working fine, but
it's not possible to release the memory to the OS.


[1]
Not giving freed memory back to the system is not (necessarily) a
Python bug; the same thing happens in C and is a consequence of
managed memory being assigned to the process as a contiguous block.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: import mysteries

2007-07-05 Thread Peter Otten
David Abrahams wrote:

 
 on Wed Jul 04 2007, Peter Otten __peter__-AT-web.de wrote:
 
 Explicitly passed, see



http://genshi.edgewall.org/browser/trunk/genshi/filters/tests/transform.py
 
 IIRC I ran doctest on the file I cited, not the one you're pointing
 at.  Is there some new magic doctest feature I should know about?

 Had you looked at it
 
 Gimme a little credit, please!  Of course I looked at it.

Sorry.
 
 you'd seen that the file I pointed to is the driver
 script for running the doctests in the file you pointed to
 
 Yes, I saw that, but I don't know of any magic feature that causes the
 driver script to get loaded when I invoke doctest directly on the file
 I pointed to.

Nor do I.

 -- unfortunately they have the same name. [...]/tests/transform.py
 does indeed inject a HTML object into the globals of
 [...]/filters/transform.py before it runs the tests.
 
 Yes, I saw that, but as I said...
 
 Anyway, maybe I just got confused and doctest-ed the driver script.
 That certainly would explain everything.

Compelling assumption because it does away with the mystery...

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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Michele Simionato
On Jul 5, 3:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
 snip

Alex already explained everything beautifully. I will just add a link
to
the definite guide to descriptors: 
http://users.rcn.com/python/download/Descriptor.htm

 Michele Simionato

(who spent lot of brain cycles studying descriptors *before* that
guide was written :-()

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


Re: Problem with building extension in Python

2007-07-05 Thread Gabriel Genellina
En Thu, 05 Jul 2007 05:08:58 -0300, [EMAIL PROTECTED]  
escribió:

 I have already install Microsoft visual studio .NET 2003 and MinGw,
 when I try to build a extension:

Is this for Python 2.4? I think you can't compile Python 2.5 with VS2003.

 python my_extension_setup.py build ( or install ) , I get an error:

 LINK : fatal error LNK1141: failure during build of exports file
 error: command 'C:\Program Files\Microsoft Visual Studio .NET
 2003\Vc7\bin\link.exe' failed with exit status 1141.What shoud I
 do???

Almost surely you got a previous error, making link to fail. Try to  
correct *that* error.

-- 
Gabriel Genellina

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


Re: Tkinter toggle a Label Widget based on checkbutton value

2007-07-05 Thread Eric Brunel
On Wed, 04 Jul 2007 21:51:34 +0200, O.R.Senthil Kumaran  
[EMAIL PROTECTED] wrote:
 Following is a tk code, which will display a checkbutton, and when  
 checkbox is
 enabled, it will show the below present Label.

 What I was trying is, when checkbox is enabled the Label should be shown  
 and
 when checkbox is disabled, the window should look like before.

 But, I am finding that once enabled (shown), its not  
 very-straightforward to
 hide it from the window.

 Any suggestions on  how can i make this checkbutton effect.
 1) Press Enable IP, the Label IP should be shown.
 2) Toggle Enable IP (So that its unset). the Label IP should not be  
 shown.

 #!/usr/bin/python
 from Tkinter import *
 root = Tk()
 root.title('something')
 x = StringVar()
 def display():
 if x.get():
 ip = Label(root,text=IP:)
 ip.grid(row=3,column=0)

 proxy = Checkbutton(root, text=Enable IP:, variable =  
 x,onvalue=proxy,
 offvalue=,command=display)
 proxy.grid(row=2,column=0)
 root.mainloop()

Wojciech gave a perfectly valid answer that'll work in all cases.

Here is another one, that you may or may not be able to use, which  
consists in using the same Tkinter variable for your check-button's value  
and your label's text:
--
 from Tkinter import *

root = Tk()

labelString = StringVar()

b = Checkbutton(root, text=Enable IP:, variable=labelString,
   onvalue='IP:', offvalue='')
b.grid(row=2, column=0)

Label(root, textvariable=labelString).grid(row=3, column=0)

root.mainloop()
--

This doesn't really make the label disappear when the check-button is  
off, but simply sets its text to the empty string.

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-05 Thread Nis Jørgensen
Bruno Desthuilliers skrev:
 Paul Rubin a écrit :
 Bruno Desthuilliers [EMAIL PROTECTED] writes:

 Haskell - as other languages using type-inference like OCaml - are in
 a different category. Yes, I know, don't say it, they are statically
 typed - but it's mostly structural typing, not declarative
 typing. Which makes them much more usable IMHO. 


 Some users in fact recommend writing an explicit type signature for
 every Haskell function, which functions sort of like a unit test.
 
 Stop here. explicit type signature == declarative static typing != unit
 test.

Well, it quacks like a duck ...

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


Re: Find This Module

2007-07-05 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 I'm looking at the source for the module sre_compile.py and it does
 this import:
 
 import _sre
 
 But I can't find a file related to _sre anywhere.  Where is it?  

If you want the source code, have a look at

http://svn.python.org/view/python/trunk/Modules/_sre.c?rev=52147view=markup

 And more generally, how does one find the location of a built in module?

For the source of modules written in C, built in or not, you have to look in
the source distribution. 

Peter


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


Re: what is wrong with that r\

2007-07-05 Thread Nick Craig-Wood
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
  On Wed, 04 Jul 2007 11:21:14 +, Neil Cerutti wrote:
 
  If the escaped quotes didn't function in raw strings, I'd be
  unable to construct (with a single notation) a regex that
  included both kinds of quotes at once.
  
re.compile(r'\)
 
  Where's the problem!? ::
 
re.compile(r''')
 
  Ah, I see -- readability is the problem.  :-)

Actually the problem is that those backslashes don't actually
disappear thus producing non-intuititive behaviour.  The example you
provided produces a different result to Neil's result.

   r'\
  '\'\\'
   r'''
  '\''
   

Neil is correct in saying that his example works for regexp matching
though, as the regexp matcher understands \ as being the same as .

So r strings work well as Regexp-strings but not so well as
Raw-strings IMHO.

-- 
Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with building extension in Python

2007-07-05 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
 I have already install Microsoft visual studio .NET 2003 and MinGw,
 when I try to build a extension:
 
 python my_extension_setup.py build ( or install ) , I get an error:
 
 LINK : fatal error LNK1141: failure during build of exports file
 error: command 'C:\Program Files\Microsoft Visual Studio .NET
 2003\Vc7\bin\link.exe' failed with exit status 1141.

 What shoud I do???

Tell us what the actual error message is? What you provide here is only the
last line, the real error is most likely before that. Please provide a bit
more of the output, anything that might be helpful to understand the problem.

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


Re: Proposal: s1.intersects(s2)

2007-07-05 Thread Nis Jørgensen
Steven D'Aprano skrev:
 On Wed, 04 Jul 2007 23:53:15 -0400, David Abrahams wrote:
 
 on Wed Jul 04 2007, Steven D'Aprano 
 steve-AT-REMOVE.THIS.cybersource.com.au wrote:

 On Wed, 04 Jul 2007 14:37:34 +, Marc 'BlackJack' Rintsch wrote:

 On Wed, 04 Jul 2007 09:59:24 -0400, David Abrahams wrote:

 Here's an implementation of the functionality I propose, as a
 free-standing function:

 def intersects(s1,s2):
 if len(s1)  len(s2):
 for x in s1:
 if x in s2: return True
 else:
 for x in s2:
 if x in s1 return True
 return False
 In Python 2.5 this can be written a bit more concise:

 def intersects(set_a, set_b):
 if len(set_a)  len(set_b):
 set_a, set_b = set_b, set_a
 return any(item in set_a for item in set_b)

 I'd rather see sets gain an method isintersect() 
 And why is that a good name?  It's not even grammatical.
 
 Neither is It's not even grammatical, but all but purists use it
 regardless.
 
 A common Python convention is to have test functions named something
 like isfoo, e.g. str.isdigit(), isspace(), islower() etc. They're not
 exactly grammatical either, e.g. isdigit() should actually be contains
 one or more digits, and nothing but digits. (Presumably the pedantically
 correct name was rejected as being too long.) I was just following that
 convention.

The problem is, these functions can be read as X is [consisting only
of] digit[s], X is lower [case] etc, where the bits in brackets have
been removed for brewity. In the case of s1 is intersect s2 there is
no way I can see of adding words to get a correct sentence. The
obvious naming is s1.intersects(s2) which reads as s1 intersects
s2, a perfectly cromulent sentence.

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


Python daemon in Linux

2007-07-05 Thread [EMAIL PROTECTED]
i made MyThread(Thread)

when isDaemon() == 0:
  everything works

when isDaemon() == 1:
  nothing works

 why???

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


WXPYTHON push button call a frame

2007-07-05 Thread Marcpp
Hi I need to call a widget from a button in WXPYTHON. I've tried to
this from a function like this, but when push the button, the program
opens a window and do error.
Any idea?

.
def DialogRRHH(self,event):
prog = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
DialogRRHH = MTRRHH(None, -1, )
prog.SetTopWindow(DialogRRHH)
DialogRRHH.Show()
prog.MainLoop()

class MTRRHH(wx.Frame):
...
if __name__ == __main__:
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
tasques = tasques(None, -1, )
app.SetTopWindow(tasques)
tasques.Show()
app.MainLoop()

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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Alex Popescu
On Jul 5, 11:17 am, Michele Simionato [EMAIL PROTECTED]
wrote:
 On Jul 5, 3:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote:

  snip

 Alex already explained everything beautifully. I will just add a link
 to
 the definite guide to 
 descriptors:http://users.rcn.com/python/download/Descriptor.htm

  Michele Simionato

 (who spent lot of brain cycles studying descriptors *before* that
 guide was written :-()

Guys, I appreciate a lot your help and explanations. It looks like I
have to read/play a bit more as some of the terms/ideas are pretty new
to me (coming to Python with a 10 years Java bag, and only with a
small dynlang bag - Ruby, Perl).

Once again thanks,

./alex
--
.w( the_mindstorm )p.


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


Re: The best platform and editor for Python

2007-07-05 Thread kimiraikkonen
Thanks for the links and replies, taking care.

My another aim is: Can i develop graphical applications (like in
Windows) which contain menus, interactive dialog boxes etc. using
Ptyhon?

I got it quite but not sure. I don't know Ptyhon's capability skills
for creating interactive softwares like in Windows's created by C++ or
Delphi.

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


Re: Building a Python app with Mozilla

2007-07-05 Thread Stefan Sonnenberg-Carstens
On Do, 5.07.2007, 03:45, greg wrote:
 [EMAIL PROTECTED] wrote:

 wxWidgets will give you native looking apps on both Linux and Windows

 Well, maybe. There's more to getting a native feel than
 just using the right widgets. I once saw a Qt-based app on
 MacOSX that had tiny little buttons that were too small
 for the text they contained -- Aqua buttons just don't
 scale down like that. :-(

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


Qt based buttons don't either.
If some fool uses absolute positioning and sizing,
then it is not the toolkit to blame.
I'm using wxPython for instance and use the sizers and placeholders
there, so this is possible with Qt also.
So, perhaps (which I don't know) Aqua buttons simply don't permit
absolute stuff ?
Or the Aqua programmers read the user interface guidelines carefully ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best platform and editor for Python

2007-07-05 Thread Kay Schluehr
On Jul 3, 8:12 pm, [EMAIL PROTECTED] (Cameron Laird) wrote:

 Python is simply easier than C++; you might
 well find that a debugger, for example, doesn't feel as essential
 as it is for you with C++.

That's what I love most about the Python community. Whenever there is
just a non-standard, platform-dependent or crappy implementation of a
feature you get told that you don't need it. When printf was good for
little David print is good enough for me.

Among the first things I examine about an IDE ( for Python ) is the
integration of a good REPL and how well recursive functions can be
debugged ( yes, I know, Pythonistas can't recurse and so it is not
recommended as well but sometimes ... )

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


Re: Python daemon in Linux

2007-07-05 Thread [EMAIL PROTECTED]
As far as I understand the issue, any Python process has a sort of
main thread. When the main thread exits, the Python process will
exit
if there are only daemon threads around. If there are any non-daemon
threads, the Python process will only exit after those threads are
finished.
Or, as the documentation says: The entire Python program exits when
no
active non-daemon threads are left.

Kind regards,
Benjamin

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


Re: Python daemon in Linux

2007-07-05 Thread [EMAIL PROTECTED]
thanx benjamin )
no more questions

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


Re: The best platform and editor for Python

2007-07-05 Thread Gregor Horvath
kimiraikkonen schrieb:

 My another aim is: Can i develop graphical applications (like in
 Windows) which contain menus, interactive dialog boxes etc. using
 Ptyhon?
 
 I got it quite but not sure. I don't know Ptyhon's capability skills
 for creating interactive softwares like in Windows's created by C++ or
 Delphi.
 

have a look at Dabo

http://www.dabodev.com/

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


Re: The best platform and editor for Python

2007-07-05 Thread Gregor Horvath
Kay Schluehr schrieb:

 That's what I love most about the Python community. Whenever there is
 just a non-standard, platform-dependent or crappy implementation of a
 feature you get told that you don't need it. When printf was good for
 little David print is good enough for me.
 

That's a property of open source projects.
Features nobody really needs are not implemented.

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


(EMBEDDING) Can't get python error message

2007-07-05 Thread anonymisiert85
I run this string to produce a error x+1

PyRun_SimpleStringFlags() return -1, so that i know this is a script
with error inside...

but now - how can i get error message?

i tested some py-functions - but this functions do not work... i
called this functions direct after PyRun_SimpleStringFlags

PyErr_Occurred() return always 0
PyErr_Fetch() with 3 pointers... all values are always Null
PyErr_Print() do nothing

strange...

but after my programm end... here comes a error message (from StdErr i
think)

Traceback (most recent call last):
  File string, line 1, in module
NameError: name 'x' is not defined

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


Re: Reversing a string

2007-07-05 Thread Sion Arrowsmith
Jan Vorwerk  [EMAIL PROTECTED] wrote:
 [ lots of sensible stuff to discover reversed ]
  print reversed.__doc__

See also:
 help(reversed)

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   Frankly I have no feelings towards penguins one way or the other
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Chat programs

2007-07-05 Thread HangZhou Monty Boy
I'd like to think of building a chat program, could you advise me if
python is good enough for people to get all of my source code ?

Thanks

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


Re: The best platform and editor for Python

2007-07-05 Thread Thomas Heller
QOTW?

Gregor Horvath schrieb:

 That's a property of open source projects.
 Features nobody really needs are not implemented.
 
 Gregor

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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Steve Holden
Alex Popescu wrote:
 On Jul 5, 11:17 am, Michele Simionato [EMAIL PROTECTED]
 wrote:
 On Jul 5, 3:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote:

 snip
 Alex already explained everything beautifully. I will just add a link
 to
 the definite guide to 
 descriptors:http://users.rcn.com/python/download/Descriptor.htm

  Michele Simionato

 (who spent lot of brain cycles studying descriptors *before* that
 guide was written :-()
 
 Guys, I appreciate a lot your help and explanations. It looks like I
 have to read/play a bit more as some of the terms/ideas are pretty new
 to me (coming to Python with a 10 years Java bag, and only with a
 small dynlang bag - Ruby, Perl).
 
 Once again thanks,
 
Please also realise that for someone new to the language you have dived 
right into the nitty gritty. This isn't necessarily a bad way to learn, 
but it does mean that there's a lot of background to assimilate as you 
go along.

Good luck with your studies.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: WXPYTHON push button call a frame

2007-07-05 Thread Steve Holden
Marcpp wrote:
 Hi I need to call a widget from a button in WXPYTHON. I've tried to
 this from a function like this, but when push the button, the program
 opens a window and do error.
 Any idea?
 
Well, one *really* good idea would be to copy the error message and 
paste it into your message. The readers of this list have amazing 
psychic powers, but you can always help improve the answer quality by 
providing relevant information.

 .
 def DialogRRHH(self,event):
 prog = wx.PySimpleApp(0)
 wx.InitAllImageHandlers()
 DialogRRHH = MTRRHH(None, -1, )
 prog.SetTopWindow(DialogRRHH)
 DialogRRHH.Show()
 prog.MainLoop()
 
 class MTRRHH(wx.Frame):
 ...
 if __name__ == __main__:
 app = wx.PySimpleApp(0)
 wx.InitAllImageHandlers()
 tasques = tasques(None, -1, )
 app.SetTopWindow(tasques)
 tasques.Show()
 app.MainLoop()
 
Unfortunately your code extracts don't tell us what's going wrong, only 
how the program is constructed. While that *is* useful information, by 
itself it only paints half the picture.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Alex Popescu
On Jul 5, 3:32 pm, Steve Holden [EMAIL PROTECTED] wrote:
 Alex Popescu wrote:
  On Jul 5, 11:17 am, Michele Simionato [EMAIL PROTECTED]
  wrote:
  On Jul 5, 3:41 am, [EMAIL PROTECTED] (Alex Martelli) wrote:

  snip
  Alex already explained everything beautifully. I will just add a link
  to
  the definite guide to 
  descriptors:http://users.rcn.com/python/download/Descriptor.htm

   Michele Simionato

  (who spent lot of brain cycles studying descriptors *before* that
  guide was written :-()

  Guys, I appreciate a lot your help and explanations. It looks like I
  have to read/play a bit more as some of the terms/ideas are pretty new
  to me (coming to Python with a 10 years Java bag, and only with a
  small dynlang bag - Ruby, Perl).

  Once again thanks,

 Please also realise that for someone new to the language you have dived
 right into the nitty gritty. This isn't necessarily a bad way to learn,
 but it does mean that there's a lot of background to assimilate as you
 go along.

 Good luck with your studies.


I am starting to realize this on my own :-). The true story is that
while working on Groovy (I am a committer on this dynlang meant to run
on the Java VM: http://groovy.codehaus.org) and reading some Python
materials, my interest grew exponentially. And now I have decided to
see how other succesfull java project I have co-created (TestNG:
http://testng.org) would look like in Python (this giving me the
opportunity to explore Python in more depth).

Thanks for the encouragement.

./alex
--
.w( the_mindstorm )p.

 regards
   Steve
 --
 Steve Holden+1 571 484 6266   +1 800 494 3119
 Holden Web LLC/Ltd  http://www.holdenweb.com
 Skype: holdenweb  http://del.icio.us/steve.holden
 --- Asciimercial --
 Get on the web: Blog, lens and tag the Internet
 Many services currently offer free registration
 --- Thank You for Reading -


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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Michele Simionato
On Jul 5, 11:16 am, Alex Popescu [EMAIL PROTECTED]
wrote:
 Guys, I appreciate a lot your help and explanations. It looks like I
 have to read/play a bit more as some of the terms/ideas are pretty new
 to me (coming to Python with a 10 years Java bag, and only with a
 small dynlang bag - Ruby, Perl).

 Once again thanks,

 ./alex
 --
 .w( the_mindstorm )p.

BTW, if you are interested in decorators I should mention my own
module, which I
upgraded just yesterday to version 2.1:
http://www.phyast.pitt.edu/~micheles/python/documentation.html

HTH,

M.S.

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-05 Thread Steve Holden
Paul Rubin wrote:
 John Nagle [EMAIL PROTECTED] writes:
  This has been tried.  Original KR C had non-enforced static typing.
 All struct pointers were equivalent.  It wasn't pretty.

  It takes strict programmer discipline to make non-enforced static
 typing work.  I've seen it work in an aerospace company, but the Python
 crowd probably doesn't want that level of engineering discipline.
 
 I think even enforced static types wouldn't cure what I see as the
 looseness in Python.  There is not enough composability of small
 snippets of code.  For example, the for statement clobbers its index
 variable and then leaks it to the outside of the loop.  That may be
 more of a culprit than dynamic types.  Perl and C++ both fix this with
 syntax like
 
 for (my $i in ...) ...   (perl)  or
 for (int i = 0; i  n; i++) ...  (C++, Java)
 
 making a temporary scope for the index variable.  Python even leaks
 the index variable of list comprehensions (I've mostly stopped using
 them because of this), though that's a recognized wart and is due to
 be fixed.
 
Wow, you really take non-pollution of the namespace seriously. I agree 
it's a wart, but it's one I have happily worked around since day one.

 Python would be helped a lot by some way to introduce temporary
 scopes.  We had some discussion of this recently, concluding that
 there should be a compiler warning message if a variable in a
 temporary scope shadows one from a surrounding scope.

Yeah, well the approach to scoping could really be improved, but if you 
keep your namespaces small it's not difficult to keep things straight. I 
have always been rather guarded in my approach to accessing non-local 
scopes because the coupling is rather less than obvious, and is subject 
to variation due to non-local changes.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd   http://www.holdenweb.com
Skype: holdenweb  http://del.icio.us/steve.holden
--- Asciimercial --
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
--- Thank You for Reading -

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


RE: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-05 Thread Hamilton, William
 From: Paul Rubin
 
 greg [EMAIL PROTECTED] writes:
   E.g. your program might pass its test and run properly for years
   before some weird piece of input data causes some regexp to not
quite
   work.
 
  Then you get a bug report, you fix it, and you add a test
  for it so that particular bug can't happen again.
 
 Why on earth would anyone prefer taking a failure in the field over
 having a static type check make that particular failure impossible?
 

Because static typechecking won't make that particular failure
impossible,  but instead just change it from a type error into a data
error that may or may not be harder to identify.  If your program gets a
piece of data that breaks it, you'll get a failure in the field.  Static
typechecking won't prevent that.  


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


Re: Building a Python app with Mozilla

2007-07-05 Thread Shane Geiger
Brett Cannon was doing some work with the Firefox security model to
allow Python coding from within Firefox.  He may have stopped doing the
work because it would not lead to a PhD.  I am really looking forward to
seeing someone making this a possibility.



Stefan Sonnenberg-Carstens wrote:
 On Do, 5.07.2007, 03:45, greg wrote:
   
 [EMAIL PROTECTED] wrote:

 
 wxWidgets will give you native looking apps on both Linux and Windows
   
 Well, maybe. There's more to getting a native feel than
 just using the right widgets. I once saw a Qt-based app on
 MacOSX that had tiny little buttons that were too small
 for the text they contained -- Aqua buttons just don't
 scale down like that. :-(

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


 
 Qt based buttons don't either.
 If some fool uses absolute positioning and sizing,
 then it is not the toolkit to blame.
 I'm using wxPython for instance and use the sizers and placeholders
 there, so this is possible with Qt also.
 So, perhaps (which I don't know) Aqua buttons simply don't permit
 absolute stuff ?
 Or the Aqua programmers read the user interface guidelines carefully ?
   

-- 
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED]  |  402-438-8958  |  http://www.ncee.net

Leading the Campaign for Economic and Financial Literacy

begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard

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

Re-raising exceptions with modified message

2007-07-05 Thread Christoph Zwerschke
What is the best way to re-raise any exception with a message 
supplemented with additional information (e.g. line number in a 
template)? Let's say for simplicity I just want to add sorry to every 
exception message. My naive solution was this:

try:
 ...
except Exception, e:
 raise e.__class__, str(e) + , sorry!

This works pretty well for most exceptions, e.g.

  try:
... 1/0
... except Exception, e:
... raise e.__class__, str(e) + , sorry!
...
Traceback (most recent call last):
   File stdin, line 4, in module
ZeroDivisionError: integer division or modulo by zero, sorry!

But it fails for some exceptions that cannot be instantiated with a 
single string argument, like UnicodeDecodeError which gets converted 
to a TypeError:

  try:
... unicode('\xe4')
... except Exception, e:
... raise e.__class__, str(e) + , sorry!
...
Traceback (most recent call last):
   File stdin, line 4, in module
TypeError: function takes exactly 5 arguments (1 given)

Another approach is using a wrapper Extension class:

class SorryEx(Exception):
 def __init__(self, e):
 self._e = e
 def __getattr__(self, name):
 return getattr(self._e, name)
 def __str__(self):
 return str(self._e) + , sorry!

try:
 unicode('\xe4')
except Exception, e:
 raise SorryEx(e)

But then I get the name of the wrapper class in the message:

__main__.SorryEx: 'ascii' codec can't decode byte 0xe4 in position 0: 
ordinal not in range(128), sorry!

Yet another approach would be to replace the __str__ method of e, but 
this does not work for new style Exceptions (Python 2.5).

Any suggestions?

-- Chris


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


Re: The best platform and editor for Python

2007-07-05 Thread Roy Smith
In article [EMAIL PROTECTED],
 Nicola Musatti [EMAIL PROTECTED] wrote:

 On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
 [...]
  That's a property of open source projects.
  Features nobody really needs are not implemented.
 
 No, no, you got it all wrong. It's in *commercial* projects that
 features nobody really needs are not implemented.

No, no, squared.  In a commercial project, the only features that get 
implemented are the ones somebody is willing to pay for.  Whether there is 
any correlation between need and willingness to pay is an open question.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best platform and editor for Python

2007-07-05 Thread Nicola Musatti
On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
[...]
 That's a property of open source projects.
 Features nobody really needs are not implemented.

No, no, you got it all wrong. It's in *commercial* projects that
features nobody really needs are not implemented. Profit is
fundamental in convincing you that you really need the features.

On the other hand open source projects tend to lack features nobody
enjoys implementing.

Cheers,
Nicola Musatti

P.S. Maybe I should add a ;-)

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


Re: IDEs for COM scripting: C# v. Python v. Iron Python v. JPython

2007-07-05 Thread Siegfried Heintze
Can someone suggest some criterion for selecting Python, JPython or Iron 
Python for COM Scripting?

I have not looked: I assume there are multiple eclipse plugins for 
Python/JPython/Iron Python. Could someone recommend one? I'll also try out 
eric that was mentioned previously.

I figured out my problem with Groovy/COM/Eclipse scripting: I had outlook 
running in another remote desktop session and discovered that if I run my 
script in the same session as I am running outlook in, it works. I assume 
the situation would be the same with Python.

Since Groovy/COM/Eclipse works for this purpose, I assume JPython with 
JaWin/Jacob would work too.

Thanks,
Siegfried 


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


Re: MethodType/FunctionType and decorators

2007-07-05 Thread Michele Simionato
On Jul 5, 3:17 pm, Alex Popescu [EMAIL PROTECTED]
wrote:
 The true story is that
 while working on Groovy (I am a committer on this dynlang meant to run
 on the Java VM:http://groovy.codehaus.org) and reading some Python
 materials, my interest grew exponentially. And now I have decided to
 see how other succesfull java project I have co-created 
 (TestNG:http://testng.org) would look like in Python (this giving me the
 opportunity to explore Python in more depth).


If you are interested in testing, you should give a look at 1)
doctest; 2) py.test
(Python unittest framework should be old hat to you and not worth
looking at).

 Michele Simionato

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


Re: WXPYTHON push button call a frame

2007-07-05 Thread Marcpp
On 5 jul, 14:51, Steve Holden [EMAIL PROTECTED] wrote:
 Marcpp wrote:
  Hi I need to call a widget from a button in WXPYTHON. I've tried to
  this from a function like this, but when push the button, the program
  opens a window and do error.
  Any idea?

 Well, one *really* good idea would be to copy the error message and
 paste it into your message. The readers of this list have amazing
 psychic powers, but you can always help improve the answer quality by
 providing relevant information.



  .
  def DialogRRHH(self,event):
  prog = wx.PySimpleApp(0)
  wx.InitAllImageHandlers()
  DialogRRHH = MTRRHH(None, -1, )
  prog.SetTopWindow(DialogRRHH)
  DialogRRHH.Show()
  prog.MainLoop()

  class MTRRHH(wx.Frame):
  ...
  if __name__ == __main__:
  app = wx.PySimpleApp(0)
  wx.InitAllImageHandlers()
  tasques = tasques(None, -1, )
  app.SetTopWindow(tasques)
  tasques.Show()
  app.MainLoop()

 Unfortunately your code extracts don't tell us what's going wrong, only
 how the program is constructed. While that *is* useful information, by
 itself it only paints half the picture.

 regards
   Steve
 --
 Steve Holden+1 571 484 6266   +1 800 494 3119
 Holden Web LLC/Ltd  http://www.holdenweb.com
 Skype: holdenweb  http://del.icio.us/steve.holden
 --- Asciimercial --
 Get on the web: Blog, lens and tag the Internet
 Many services currently offer free registration
 --- Thank You for Reading -

Hi, the problem is No Error message, but the program continues running
after I closed it (by the X).

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


Re: Re-raising exceptions with modified message

2007-07-05 Thread Thomas Heller
Christoph Zwerschke schrieb:
 What is the best way to re-raise any exception with a message 
 supplemented with additional information (e.g. line number in a 
 template)?

I have the impression that you do NOT want to change the exceptions,
instead you want to print the traceback in a customized way.  But I may be 
wrong...

Thomas

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


Re: The best platform and editor for Python

2007-07-05 Thread [EMAIL PROTECTED]
Kay Schluehr wrote:
 On Jul 3, 8:12 pm, [EMAIL PROTECTED] (Cameron Laird) wrote:

  Python is simply easier than C++; you might
  well find that a debugger, for example, doesn't feel as essential
  as it is for you with C++.

 That's what I love most about the Python community. Whenever there is
 just a non-standard, platform-dependent or crappy implementation of a
 feature you get told that you don't need it.

A fairly nice debugger is standard and built-in to the regular Python
distribution on all platforms.

But 95% of what a debugger is used for IME is getting a stack trace--
in Python (or Java or Ruby or most modern languages) you get that
automatically, and the debugger is nowhere near as useful as it is in
C or C++.

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


Re: Re-raising exceptions with modified message

2007-07-05 Thread Christoph Zwerschke
Thomas Heller wrote:
 I have the impression that you do NOT want to change the exceptions,
 instead you want to print the traceback in a customized way.  But I may be 
 wrong...

No, I really want to modify the exception, supplementing its message 
with additional information about the state of the program.

The use case are compiled Kid templates (http://kid-templating.org). If 
an error occurs, I want to add the corresponding line number of the XML 
file as information for the template developer. Since the final error 
handling may happen somewhere else (e.g. by TurboGears importing a Kid 
template), I do not want to modify trackeback handling or something.

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


Re: Proposal: s1.intersects(s2)

2007-07-05 Thread Aahz
In article [EMAIL PROTECTED],
Steven D'Aprano  [EMAIL PROTECTED] wrote:

My main feeling is that any such function should be a set method rather
than a built-in function like len(). The name change was comparatively
unimportant.

Look up at the Subject: line.  There never was any suggestion that
intersects() be anything other than a set method.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

I support the RKAB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best platform and editor for Python

2007-07-05 Thread Paul McGuire
On Jul 5, 9:21 am, Roy Smith [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
  Nicola Musatti [EMAIL PROTECTED] wrote:

  On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
  [...]
   That's a property of open source projects.
   Features nobody really needs are not implemented.

  No, no, you got it all wrong. It's in *commercial* projects that
  features nobody really needs are not implemented.

 No, no, squared.  In a commercial project, the only features that get
 implemented are the ones somebody is willing to pay for.  Whether there is
 any correlation between need and willingness to pay is an open question.

Then tell us, pray, who was willing to pay for the epitome of useless
features in MS Word, that Useless Features' Useless Feature, the
ability to format text with the animated effect Marching Red Ants?
I'm sure I paid for it, but it wasn't willingly...

-- Paul

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


Re: Re-raising exceptions with modified message

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Christoph Zwerschke [EMAIL PROTECTED] wrote:
 Thomas Heller wrote:
 I have the impression that you do NOT want to change the
 exceptions, instead you want to print the traceback in a
 customized way.  But I may be wrong...

 No, I really want to modify the exception, supplementing its
 message with additional information about the state of the
 program.

 The use case are compiled Kid templates
 (http://kid-templating.org). If an error occurs, I want to add
 the corresponding line number of the XML file as information
 for the template developer. Since the final error handling may
 happen somewhere else (e.g. by TurboGears importing a Kid
 template), I do not want to modify trackeback handling or
 something.

The documentation for BaseException contains something that might
be relevant:

   [...] If more data needs to be attached to the exception,
   attach it through arbitrary attributes on the instance. All
   arguments are also stored in args as a tuple, but it will
   eventually be deprecated and thus its use is discouraged. New
   in version 2.5. [...]

I don't know if something like the following would help:

 def foo():
...   try:
... 12/0
...   except ZeroDivisionError, e:
... e.my_info = Oops!
... raise
...
 try:
...   foo()
... except ZeroDivisionError, e:
...   print e.my_info
...
Oops!

Users could get at the extra info you attached, but it wouldn't
be automatically displayed by the interpreter.

-- 
Neil Cerutti
Symphonies of the Romantic era were a lot longer in length. --Music Lit Essay
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best platform and editor for Python

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Paul McGuire [EMAIL PROTECTED] wrote:
 On Jul 5, 9:21 am, Roy Smith [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
  Nicola Musatti [EMAIL PROTECTED] wrote:

  On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
  [...]
   That's a property of open source projects.
   Features nobody really needs are not implemented.

  No, no, you got it all wrong. It's in *commercial* projects that
  features nobody really needs are not implemented.

 No, no, squared.  In a commercial project, the only features that get
 implemented are the ones somebody is willing to pay for.  Whether there is
 any correlation between need and willingness to pay is an open question.

 Then tell us, pray, who was willing to pay for the epitome of useless
 features in MS Word, that Useless Features' Useless Feature, the
 ability to format text with the animated effect Marching Red Ants?
 I'm sure I paid for it, but it wasn't willingly...

You should count your blessings. At least it doesn't play
pinball any more. At least, I hope not.

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


Re: The best platform and editor for Python

2007-07-05 Thread Cameron Laird
In article [EMAIL PROTECTED],
Kay Schluehr  [EMAIL PROTECTED] wrote:
On Jul 3, 8:12 pm, [EMAIL PROTECTED] (Cameron Laird) wrote:

 Python is simply easier than C++; you might
 well find that a debugger, for example, doesn't feel as essential
 as it is for you with C++.

That's what I love most about the Python community. Whenever there is
just a non-standard, platform-dependent or crappy implementation of a
feature you get told that you don't need it. When printf was good for
little David print is good enough for me.

Among the first things I examine about an IDE ( for Python ) is the
integration of a good REPL and how well recursive functions can be
debugged ( yes, I know, Pythonistas can't recurse and so it is not
recommended as well but sometimes ... )


You've made factual claims with which I can't agree.

If I understand you correctly, Pythoneers (to the exclusion of other
software workers?) are prone to misrepresent lacunae as irrelevant.
Perhaps I've done so in this case; perhaps I characteristically do
so myself, and need to examine my own judgment more closely.  It
simply is not true, though, and even slanderous, to leave the
impression that the community as a whole wallows fat and dumb in
its rut of missing features.  Py2exe, pyexpect, pylint, ElementTree,
and many, many other Python facilities we now take for granted didn't
exist at one time, and were recognized as important lacks.  Old
comp.lang.python threads make this clear.

In writing this, I don't mean to minimize at all the merit of the
specific individuals who authored ElementTree, pylint, and so on.

You seem also to be saying that all Python debuggers are non-standard,
platform-dependent or crappy.  Is that truly your assessment of pdb
URL: http://docs.python.org/lib/module-pdb.html ?  Or are you focused
on the IDEs URL:
http://wiki.python.org/moin/IntegratedDevelopmentEnvironments , and
really see them all that way?

Anyway, I repeat my claim:  I recommend to the original poster that he
consider learning Python in a style that's qualitatively different--
lighter--than his experience with C++.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Building a Python app with Mozilla

2007-07-05 Thread [EMAIL PROTECTED]
greg wrote:
 [EMAIL PROTECTED] wrote:

  wxWidgets will give you native looking apps on both Linux and Windows

 Well, maybe. There's more to getting a native feel than
 just using the right widgets. I once saw a Qt-based app on
 MacOSX that had tiny little buttons that were too small
 for the text they contained -- Aqua buttons just don't
 scale down like that. :-(

wxWidgets isn't Qt-related.  wx wraps the Aqua widgets on MacOS, the
gtk widgets on Linux, and the Windows widgets on Windows.  So you're
actually using the real platform-specific widgets, and if you follow
the style guidelines you'll get pretty native-looking apps (including
things like the menubar showing up in the app on Linux/Windows but
using the main menubar on Mac).

Last I looked (3.1-ish), Qt didn't use the Aqua widgets but rather
tried to write their own widgets that looked (kinda) like the MacOS
widgets.  I hear that may have changed in more recent versions, but I
no longer have a Mac.  They did do the menubar correctly even at that
time, though.

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


Re: The best platform and editor for Python

2007-07-05 Thread Kay Schluehr
On Jul 5, 4:08 pm, Nicola Musatti [EMAIL PROTECTED] wrote:
 On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
 [...]

  That's a property of open source projects.
  Features nobody really needs are not implemented.

 No, no, you got it all wrong. It's in *commercial* projects that
 features nobody really needs are not implemented. Profit is
 fundamental in convincing you that you really need the features.

 On the other hand open source projects tend to lack features nobody
 enjoys implementing.

OSS projects have the healthy tendency to die silently. No one has yet
counted all the corpses.

Someone has mentioned Eclipse before and it somehow indicates that the
strongest distinction between an OSS project and a commercial one is
the property of being OSS.

Kay

 Cheers,
 Nicola Musatti

 P.S. Maybe I should add a ;-)

This is a full ;-) thread. So it would be a bit redundant to mention
it - just like this meta-comment.

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


Re: WXPYTHON push button call a frame

2007-07-05 Thread kyosohma
On Jul 5, 9:04 am, Marcpp [EMAIL PROTECTED] wrote:
 On 5 jul, 14:51, Steve Holden [EMAIL PROTECTED] wrote:



  Marcpp wrote:
   Hi I need to call a widget from a button in WXPYTHON. I've tried to
   this from a function like this, but when push the button, the program
   opens a window and do error.
   Any idea?

  Well, one *really* good idea would be to copy the error message and
  paste it into your message. The readers of this list have amazing
  psychic powers, but you can always help improve the answer quality by
  providing relevant information.

   .
   def DialogRRHH(self,event):
   prog = wx.PySimpleApp(0)
   wx.InitAllImageHandlers()
   DialogRRHH = MTRRHH(None, -1, )
   prog.SetTopWindow(DialogRRHH)
   DialogRRHH.Show()
   prog.MainLoop()

   class MTRRHH(wx.Frame):
   ...
   if __name__ == __main__:
   app = wx.PySimpleApp(0)
   wx.InitAllImageHandlers()
   tasques = tasques(None, -1, )
   app.SetTopWindow(tasques)
   tasques.Show()
   app.MainLoop()

  Unfortunately your code extracts don't tell us what's going wrong, only
  how the program is constructed. While that *is* useful information, by
  itself it only paints half the picture.

  regards
Steve
  --
  Steve Holden+1 571 484 6266   +1 800 494 3119
  Holden Web LLC/Ltd  http://www.holdenweb.com
  Skype: holdenweb  http://del.icio.us/steve.holden
  --- Asciimercial --
  Get on the web: Blog, lens and tag the Internet
  Many services currently offer free registration
  --- Thank You for Reading -

 Hi, the problem is No Error message, but the program continues running
 after I closed it (by the X).

When I open a custom frame from one of my applications, I do something
like this:


main app code

def BtnEventHandler(self, event):
frame = myFrame()
frame.Show()

/main app code


myframe code

class myFrame(wx.Frame):
def __init__(self, filename=None):
wx.Frame.__init__(self, None, -1, 'Whatever', size=(570,295))
# you can set the OnTop style here
# lots of other code...

def OnClose(self, event):
# Close the frame
self.Close()

/myframe code

If you have additional problems, try mailing the wxPython group, which
you can find here: www.wxpython.org

Mike



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


Re: PyRun_String using my module in a def

2007-07-05 Thread Alex Martelli
Gabriel Genellina [EMAIL PROTECTED] wrote:

 En Thu, 05 Jul 2007 01:19:32 -0300, Stuart [EMAIL PROTECTED]  
 escribió:
 
  What command do you mean when you say update main_dict with
  dlfl_dict?
 
 I think Alex Martelly was refering to use main_dict.update(dlfl_dict)
 (Python code) or PyDict_Update(main_dict, dlfl_dict) (in C code).

Yep.


  I tried PyObject *rstring = PyRun_String( cmd, Py_file_input,
  dlfl_dict, dlfl_dict );
  This worked, but has the side effect of not allowing other commands
  like execfile
 
 The idea is to copy all items from dlfl_dict into main_dict, and use
 main_dict for both globals and locals.

Exactly.


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


Re: The best platform and editor for Python

2007-07-05 Thread Nicola Musatti
On Jul 5, 4:21 pm, Roy Smith [EMAIL PROTECTED] wrote:
 In article [EMAIL PROTECTED],
  Nicola Musatti [EMAIL PROTECTED] wrote:

  On Jul 5, 1:23 pm, Gregor Horvath [EMAIL PROTECTED] wrote:
  [...]
   That's a property of open source projects.
   Features nobody really needs are not implemented.

  No, no, you got it all wrong. It's in *commercial* projects that
  features nobody really needs are not implemented.

 No, no, squared.  In a commercial project, the only features that get
 implemented are the ones somebody is willing to pay for.  Whether there is
 any correlation between need and willingness to pay is an open question.

Ah, but you snipped the most important part of my post:
 Profit is fundamental in convincing you that you really
 need the features.

I mean, marketing is all about creating the willingness by stimulating
the perception of the need.

Cheers,
Nicola Musatti

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


Re: list.append not working?

2007-07-05 Thread Hardy
On 5 Jul., 18:07, infidel [EMAIL PROTECTED] wrote:
 On Jul 5, 8:58 am, Hardy [EMAIL PROTECTED] wrote:



  I experience a problem with append(). This is a part of my code:

  for entity in temp:
  md['module']= entity.addr.get('module')
  md['id']=entity.addr.get('id')
  md['type']=entity.addr.get('type')
  #print md
  mbusentities.append(md)
  #print mbusentities

  I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
  {'module': 'work', 'id': 456, 'type': 'core'}]
  md is always correct, BUT:mbusentities is wrong. Length of
  mbusentities is same of temp, so it appended everything. BUT:
  mbusentities only shows the values of the last append: [{'module':
  'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
  'type': 'core'}]

  What's wrong?

 You're reusing the same md dictionary over and over, appending the
 same object to the list each time.  So what you have is a list of
 references to the same dictionary.  You need to set md = {} first
 thing each iteration.

Thanks, that was my mistake, should take a break, getting code-blind :D

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


Re: list.append not working?

2007-07-05 Thread infidel
On Jul 5, 8:58 am, Hardy [EMAIL PROTECTED] wrote:
 I experience a problem with append(). This is a part of my code:

 for entity in temp:
 md['module']= entity.addr.get('module')
 md['id']=entity.addr.get('id')
 md['type']=entity.addr.get('type')
 #print md
 mbusentities.append(md)
 #print mbusentities

 I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
 {'module': 'work', 'id': 456, 'type': 'core'}]
 md is always correct, BUT:mbusentities is wrong. Length of
 mbusentities is same of temp, so it appended everything. BUT:
 mbusentities only shows the values of the last append: [{'module':
 'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
 'type': 'core'}]

 What's wrong?

You're reusing the same md dictionary over and over, appending the
same object to the list each time.  So what you have is a list of
references to the same dictionary.  You need to set md = {} first
thing each iteration.

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


Re: How can i change an Object type ?

2007-07-05 Thread KuhlmannSascha
On Jul 4, 12:14 pm, [EMAIL PROTECTED] wrote:
 On Jul 4, 12:40 am, Tim Roberts [EMAIL PROTECTED] wrote:



  KuhlmannSascha [EMAIL PROTECTED] wrote:

  i tried now for several hours to read through a win32com API to access
  Itunes and read out myplaylists.

  First of all the Code:
  ...
  The current Logic is to access first Itunes and then a Playlist
  Collection.
  This Playlist collection returns different kind of objects for
  Playlists.
  I am focussing on the Playlists of the object UserPlaylist.
  (CodeLine:   if curPlaylist.Kind == 2:)
  After that i should be sure to have a UserPlaylist, but Python stops
  with an exception that the requested Attribute Smart  is not
  available
  Error MEssage:
  AttributeError: 'win32com.gen_py.iTunes 1.9 Type Library.IITPlaylist
  instance at 0x30216960' object has no attribute 'Smart'

  Smart is part of IITUserPlaylist, not IITPlaylist.  You need to call
  curPlaylist.QueryInterface to get the IITUserPlaylist, but that means
  you'll need to know the GUID for IITUserPlaylist.  Perhaps Google will
  help.
  --
  Tim Roberts, [EMAIL PROTECTED]
  Providenza  Boekelheide, Inc.

 These look like they could give you some pointers too:

 http://www.brunningonline.net/simon/blog/archives/001627.htmlhttp://lazycat.org/backburner.htmlhttp://mail.python.org/pipermail/python-win32/2007-February/005506.html

 Mike

Thanks all of you !
The Casting was the issue !!!
Regards
Sascha

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


list.append not working?

2007-07-05 Thread Hardy
I experience a problem with append(). This is a part of my code:

for entity in temp:
md['module']= entity.addr.get('module')
md['id']=entity.addr.get('id')
md['type']=entity.addr.get('type')
#print md
mbusentities.append(md)
#print mbusentities

I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
{'module': 'work', 'id': 456, 'type': 'core'}]
md is always correct, BUT:mbusentities is wrong. Length of
mbusentities is same of temp, so it appended everything. BUT:
mbusentities only shows the values of the last append: [{'module':
'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
'type': 'core'}]

What's wrong?

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


Re: list.append not working?

2007-07-05 Thread 7stud

Hardy wrote:
 I experience a problem with append(). This is a part of my code:

 for entity in temp:
 md['module']= entity.addr.get('module')
 md['id']=entity.addr.get('id')
 md['type']=entity.addr.get('type')
 #print md
 mbusentities.append(md)
 #print mbusentities

 I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
 {'module': 'work', 'id': 456, 'type': 'core'}]
 md is always correct, BUT:mbusentities is wrong. Length of
 mbusentities is same of temp, so it appended everything. BUT:
 mbusentities only shows the values of the last append: [{'module':
 'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
 'type': 'core'}]

 What's wrong?

Inside your loop, you assign md[module], md[id], and md[type]
the same values over and over again.

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


Re: Chat programs

2007-07-05 Thread Thomas Jollans
On Thursday 05 July 2007, HangZhou Monty Boy wrote:
 I'd like to think of building a chat program, could you advise me if
 python is good enough for people to get all of my source code ?

I'm not sure what the language you use has to do with how people acquire your 
source code, but (remember: this is a python list) I think python is a 
brilliant language for many things, including building chat programs [1] ;-)

[1]: http://zombiehq.xyzplanet.net/zhq/projects/chat
  this really needs an update... like automatic client discovery etc...

-- 
  Regards,   Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key http://hackerkey.com/:
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Proposal: s1.intersects(s2)

2007-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2007 07:34:28 -0700, Aahz wrote:

 In article [EMAIL PROTECTED],
 Steven D'Aprano  [EMAIL PROTECTED] wrote:

My main feeling is that any such function should be a set method rather
than a built-in function like len(). The name change was comparatively
unimportant.
 
 Look up at the Subject: line.  

Subject line? What's that?

*chagrined wink*

 There never was any suggestion that
 intersects() be anything other than a set method.

My fault for replying to a reply instead of the original post.


-- 
Steven.

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Chris Mellon
On 7/5/07, Captain Poutine [EMAIL PROTECTED] wrote:
 I'm simply trying to read a CSV into a dictionary.

 (if it matters, it's ZIP codes and time zones, i.e.,
 35983,CT
 39161,CT
 47240,EST



 Apparently the way to do this is:

 import csv

 dictZipZones = {}

 reader = csv.reader(open(some.csv, rb))
 for row in reader:
  # Add the row to the dictionary


 But how to do this?

 Apparently there is no dict.append() nor dict.add()

 But what is there?  I see vague references to the dict() constructor
 and some examples, and news that it has been recently improved.  But
 where is the full, current documentation for the dict() constructor?


There's no dict.append or dict.add because a dict doesn't require
them. You insert keys via the normal indexing interface:

somedict[somekey] = somevalue.

Depending on which direction your mapping is, you may be interested in
the setdefault method.

The dict constructor is described in section 2.1, built in functions
(even though it's not a function anymore).

The other dict methods are described in section 3.8, mapping types.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's only one way to do it philosophy isn't good?

2007-07-05 Thread Chris Mellon
On 7/2/07, Douglas Alan [EMAIL PROTECTED] wrote:
 Lenard Lindstrom [EMAIL PROTECTED] writes:
  If they are simply a performance tweak then it's not an issue *. I
  was just concerned that the calls were necessary to keep resources
  from being exhausted.

 Well, if you catch an exception and don't return quickly, you have to
 consider not only the possibility that there could be some open files
 left in the traceback, but also that there could be a large and now
 useless data structures stored in the traceback.

 Some people here have been arguing that all code should use with to
 ensure that the files are closed.  But this still wouldn't solve the
 problem of the large data structures being left around for an
 arbitrary amount of time.


I don't think anyone has suggested that. Let me be clear about *my*
position: When you need to ensure that a file has been closed by a
certain time, you need to be explicit about it. When you don't care,
just that it will be closed soonish then relying on normal object
lifetime calls is sufficient. This is true regardless of whether
object lifetimes are handled via refcount or via true garbage
collection. Relying on the specific semantics of refcounting to give
certain lifetimes is a logic error.

For example:

f = some_file() #maybe it's the file store for a database implementation
f.write('a bunch of stuff')
del f
#insert code that assumes f is closed.

This is the sort of code that I warn against writing.

f = some_file()
with f:
  f.write(a bunch of stuff)
#insert code that assumes f is closed, but correctly this time

is better.

On the other hand,
f = some_file()
f.write(a bunch of stuff)
#insert code that doesn't care about the state of f

is also fine. It *remains* fine no matter what kind of object lifetime
policy we have. The very worst case is that the file will never be
closed. However, this is exactly the sort of guarantee that GC can't
make, just as it can't ensure that you won't run out of memory. That's
a general case argument about refcounting semantics vs GC semantics,
and there are benefits and disadvantages to both sides.

What I am arguing against are explicit assumptions based on implicit
behaviors. Those are always fragile, and doubly so when the implicit
behavior isn't guaranteed (and, in fact, is explicitly *not*
guaranteed, as with refcounting semantics).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list.append not working?

2007-07-05 Thread Abhishek Jain

with every iteration your previous values are overwritten ('md' is a
dictionary) so thats why your are observing this ouput..

check  if the following patch solves your problem

for entity in temp:
   md['module']= entity.addr.get('module')
   md['id']=entity.addr.get('id')
   md['type']=entity.addr.get('type')
   #print md
   mbusentities.append(md)
   md = {}
   #print mbusentities


Regards
Abhi




On 7/5/07, Hardy [EMAIL PROTECTED] wrote:


I experience a problem with append(). This is a part of my code:

for entity in temp:
md['module']= entity.addr.get('module')
md['id']=entity.addr.get('id')
md['type']=entity.addr.get('type')
#print md
mbusentities.append(md)
#print mbusentities

I want something like: [{'module': 'home', 'id': 123, 'type': 'core'},
{'module': 'work', 'id': 456, 'type': 'core'}]
md is always correct, BUT:mbusentities is wrong. Length of
mbusentities is same of temp, so it appended everything. BUT:
mbusentities only shows the values of the last append: [{'module':
'work', 'id': 456, 'type': 'core'}, {'module': 'work', 'id': 456,
'type': 'core'}]

What's wrong?

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

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

Re: The best platform and editor for Python

2007-07-05 Thread Cameron Laird
In article [EMAIL PROTECTED],
Gregor Horvath  [EMAIL PROTECTED] wrote:
kimiraikkonen schrieb:

 My another aim is: Can i develop graphical applications (like in
 Windows) which contain menus, interactive dialog boxes etc. using
 Ptyhon?
 
 I got it quite but not sure. I don't know Ptyhon's capability skills
 for creating interactive softwares like in Windows's created by C++ or
 Delphi.
 

have a look at Dabo

http://www.dabodev.com/
.
.
.
I want to make this explicit for the benefit of the original questioner:
A.  Dabo's great stuff; but
B.  there are, at the same time, quite a few
other frameworks for GUI programming with
Python URL: http://wiki.python.org/moin/GuiProgramming .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: disappearing documentation of `coerce`

2007-07-05 Thread Alan Isaac
 On 2007-07-05, Alan Isaac [EMAIL PROTECTED] wrote:
Once upon a time, `coerce` was documented
with the other built-ins.


Neil Cerutti wrote:
 It's now documented in Library Reference 2.2 Non-essential
 Built-in Functions.
 Apparently it is no longer needed or useful, but only kept for
 backward compatibility.


Thanks.
I now see that it is going away:
http://www.python.org/dev/peps/pep-3100/

Cheers,
Alan Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Proposal: s1.intersects(s2)

2007-07-05 Thread Steven D'Aprano
On Thu, 05 Jul 2007 01:48:58 +, richyjsm wrote:

 On Jul 4, 8:14 pm, Steven D'Aprano
 [EMAIL PROTECTED] wrote:
 However, there's a very subtle flaw in the idea. While the intersection
 of two sets is well-defined, these two sets intersect is (surprisingly!)
 _not_ well-defined.
 
 Poppycock!  It's perfectly well defined:  two sets intersect if and
 only if their intersection is nonempty.

That's certainly _a_ definition.

I'm not a professional set theorist, but in 15-odd years of studying and
teaching maths I've never come across mathematicians using intersect as a
verb except as informal short-hand. I often say North Street and South
Street don't intersect, but the intersection of sets A and B is empty.

Just because I've never come across it doesn't mean it exists, so I'd be
grateful for any reference to a technical definition, or even references
to any mathematician using intersect as a verb in a vigorous,
non-hand-waving way. Here's a link to get you started:

http://www.google.com.au/search?q=define%3Aintersect


 There's absolutely no reason
 to single out the empty set for special treatment in this definition.

But you can't avoid treating the empty set as special, because it _is_
special. You can only choose where to do so. For instance, do sets
intersect with themselves?

By my rule, every set intersects with itself, no exceptions.

By your rule, every set intersects with itself, except for the empty set.



 The problem comes if we (perhaps naively) try to say that if a set A is a
 subset of set B, set A must intersect with B.
 
 Well of course false statements are going to cause problems.

My statement is only false if we treat the empty set as special, which
you've said we shouldn't do.

By my rule: if A = B, then A and B intersect, no exceptions.

By your rule: if A = B and A is not the empty set, then A and B intersect.



 (Not all intersecting sets are subsets, but all subsets are
 intersecting sets.)
 
 Not true.

Can you give a counter-example, without treating the empty set as special?

Of course if you exclude the empty set by definition, my statement is no
longer true -- but that's begging the question of whether we should
exclude the empty set or not.


 As a result, any proposed function or method that returns a True/False
 value for whether set A intersects with set B needs to define (and
 justify) what it means to say that two sets intersect when one or both
 are the empty set.
 
 Nope.  There's one, obvious, correct definition, as given above.  No
 need to mention the empty set at all.

It is obvious, but whether it is correct or not depends on how you decide
whether two things intersect or not.


-- 
Steven.

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


Re: login http://cheeseshop.python.org/pypi broken ?

2007-07-05 Thread gert
On Jul 5, 8:30 am, Martin v. Löwis [EMAIL PROTECTED] wrote:
 gert schrieb:

  tried reseting password but i can not login anymore to upload my new
  source code ?

 Please try again. It was a misconfiguration which should be fixed now.

 Regards,
 Martin

thank you, it works.

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

Re: The best platform and editor for Python

2007-07-05 Thread kimiraikkonen
I just wanted a simple answer to my simple question, however topic has
messed up. Think questioner as a beginner and use more understandable
terms to help :)

Thanks.

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


Re: Proposal: s1.intersects(s2)

2007-07-05 Thread OKB (not okblacke)
Steven D'Aprano wrote:

 Just because I've never come across it doesn't mean it exists, so
 I'd be grateful for any reference to a technical definition, or
 even references to any mathematician using intersect as a verb in a
 vigorous, non-hand-waving way. Here's a link to get you started:

Here ( http://arxiv.org/PS_cache/math/pdf/0702/0702029v1.pdf )is a 
Russian math text (in English) which says:

If A \cap B 6 = \emptyset, then we say that the sets A and B do 
intersect. Otherwise, if A \cap B = \emptyset, then we say that these 
sets do not intersect.

Here ( 
http://www.tcs.ifi.lmu.de/~fischerf/publications/bfh_tark07.pdf ) is a 
math paper which says:

Sets that are disjoint in the diagram may have an empty 
intersection, i.e., there exist instances where these sets do not 
intersect.

A simple Google search will also turn up numerous uses of the 
phrase non-intersecting sets, which would seem to be parallel (i.e., 
people are not bending over backwards to say disjoint sets or sets 
with empty intersection).

-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The best platform and editor for Python

2007-07-05 Thread Mark Morss
On Jul 1, 3:30 pm, Sönmez Kartal [EMAIL PROTECTED] wrote:
Emacs is the best for anything for me.

Me too.

Also, as pointed out by some others, a debugger is not really all that
necessary for an interpreted language like Python.

  Hi,
  For experienced with Pyhton users, which developing software and
  enviroment would you suggest for Pyhton programming? Compiler+Editor
  +Debugger.

  Also what are your suggestions for beginners of Pyhton programming?

  Thank you.

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


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

deliberate versus os socket timeout

2007-07-05 Thread Robin Becker
While messing about with some deliberate socket timeout code I got an 
unexpected 
timeout after 20 seconds when my code was doing socket.setdefaulttimeout(120).

Closer inspection revealed that this error in fact seemed to come from the os 
(in this case windows xp).

By inspection of test cases the error.reason from the deliberate socket timeout 
looks like
 'timed out'
whereas the windows caused timeout error.reason looks like
 '(10060 operation timed out)'

it would be nice to know if that is in fact true and whether there is any way 
to 
do the attribution of errors more sensibly.

Both of these seem to cause urllib2.URLError and presumably appear somewhere in 
the socket code.

It might be nice if the deliberate timeout could be something like 'timed out 
deliberately after xxx seconds'.

More importantly is there anything I can do to avoid these wrong os inspired 
timeouts? I'm just using urllib2 to read from a remote site inside of a cgi 
script. I'm not sure it's a big problem, but I have no idea what could cause it.

The code I'm using is based on one of jjlee's recipes

def httpGet(self):
 import urllib2, socket
 from xml.sax.saxutils import escape
 oto = socket.getdefaulttimeout()
 try:
 socket.setdefaulttimeout(self.timeout)
 self.url = url = self.makeUrl(self.params)
 try:
 self.response = r = urllib2.urlopen(url)
 except urllib2.URLError, e:
 if hasattr(e, 'reason'):
 msg = 'HTTP error '+str(e.reason)
 if 'time' in msg:
 msg += '(our timeout=%s)' % socket.getdefaulttimeout()
 return 1,escape(msg)
 elif hasattr(e, 'code'):
 return 1, escape('The server couldn\'t fulfill the 
request.\nError code: '+str(e.code))
 else:
 # everything is fine
 h = self.headers = {}
 
 return 0,..
 finally:
 socket.setdefaulttimeout(oto)

-- 
Robin Becker

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Captain Poutine [EMAIL PROTECTED] wrote:
 I'm simply trying to read a CSV into a dictionary.

 (if it matters, it's ZIP codes and time zones, i.e.,
 35983,CT
 39161,CT
 47240,EST



 Apparently the way to do this is:

 import csv

 dictZipZones = {}

 reader = csv.reader(open(some.csv, rb))
 for row in reader:
  # Add the row to the dictionary

In addition to Chris's answer, the csv module can read and write
dictionaries directly. Look up csv.DictReader and csv.DictWriter.

-- 
Neil Cerutti
In my prime I could have handled Michael Jordan.  Of course, he would be only
12 years old. --Jerry Sloan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WXPYTHON push button call a frame

2007-07-05 Thread Roel Schroeven
Marcpp schreef:
 Hi I need to call a widget from a button in WXPYTHON. I've tried to
 this from a function like this, but when push the button, the program
 opens a window and do error.
 Any idea?
 
 .
 def DialogRRHH(self,event):
 prog = wx.PySimpleApp(0)
 wx.InitAllImageHandlers()
 DialogRRHH = MTRRHH(None, -1, )
 prog.SetTopWindow(DialogRRHH)
 DialogRRHH.Show()
 prog.MainLoop()
 
 class MTRRHH(wx.Frame):
 ...
 if __name__ == __main__:
 app = wx.PySimpleApp(0)
 wx.InitAllImageHandlers()
 tasques = tasques(None, -1, )
 app.SetTopWindow(tasques)
 tasques.Show()
 app.MainLoop()

In DialogRRHH() you create a new application object with a new event 
loop, while you already have one running. wxPython should have only one 
application object though; otherwise there conflicts between the 
different event loops. Also you don't need to call 
wx.InitAllImageHandlers() again.

It seems to me that in DialogRRHH() you want to create a dialog and wait 
until the user closes it. In that case, it should look more or less like 
this (beware, I'm not a wxPython expert myself):

 def DialogRRHH(self, event):
 DialogRRHH = MTRRHH(None, -1, )
 DialogRRHH.ShowModal()

Also, in that case MTRRHH should be a wxDialog, not a wxFrame.

In case you want to show MTRRHH without waiting for the user to close 
it, use DialogRRHH.Show() instead of .ShowModal(). I think MTRRHH can be 
either a wxDialog or a wxForm in that case.



-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Peter Otten
Neil Cerutti wrote:

 On 2007-07-05, Captain Poutine [EMAIL PROTECTED] wrote:
 I'm simply trying to read a CSV into a dictionary.

 (if it matters, it's ZIP codes and time zones, i.e.,
 35983,CT
 39161,CT
 47240,EST



 Apparently the way to do this is:

 import csv

 dictZipZones = {}

 reader = csv.reader(open(some.csv, rb))
 for row in reader:
  # Add the row to the dictionary
 
 In addition to Chris's answer, the csv module can read and write
 dictionaries directly. Look up csv.DictReader and csv.DictWriter.

DictReader gives one dict per row, with field names as keys. The OP is more
likely to want

dict(csv.reader(open(some.csv, rb)))

which produces a dict that maps ZIP codes to time zones.

Peter

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Captain Poutine
Neil Cerutti wrote:
 On 2007-07-05, Captain Poutine [EMAIL PROTECTED] wrote:
 I'm simply trying to read a CSV into a dictionary.

 (if it matters, it's ZIP codes and time zones, i.e.,
 35983,CT
 39161,CT
 47240,EST



 Apparently the way to do this is:

 import csv

 dictZipZones = {}

 reader = csv.reader(open(some.csv, rb))
 for row in reader:
  # Add the row to the dictionary
 
 In addition to Chris's answer, the csv module can read and write
 dictionaries directly. Look up csv.DictReader and csv.DictWriter.
 

Yes, thanks.  I was happy when I saw it at 
http://www.python.org/doc/2.4/lib/node615.html


Reader objects (DictReader instances and objects returned by the 
reader() function) have the following public methods:

next(   )
 Return the next row of the reader's iterable object as a list, 
parsed according to the current dialect.

But that's not enough information for me to use.  Also, the doc says 
basically csv has dialects, but doesn't even enumerate them.  Where is 
the real documentation?


Also, when I do a print of row, it comes out as:
['12345', 'ET']

But there are no quotes around the number in the file.  Why is Python 
making it a string?

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


Re: Re-raising exceptions with modified message

2007-07-05 Thread Christoph Zwerschke
Neil Cerutti wrote:
 The documentation for BaseException contains something that might
 be relevant:
 
[...] If more data needs to be attached to the exception,
attach it through arbitrary attributes on the instance. All

 Users could get at the extra info you attached, but it wouldn't
 be automatically displayed by the interpreter.

Yes, that's the problem here. It wouldn't be displayed automatically and 
the users must be aware of this attribute. I'd like to have a more 
transparent solution.

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


Re: Python's only one way to do it philosophy isn't good?

2007-07-05 Thread Falcolas
On Jul 5, 10:30 am, Chris Mellon [EMAIL PROTECTED] wrote:

 I don't think anyone has suggested that. Let me be clear about *my*
 position: When you need to ensure that a file has been closed by a
 certain time, you need to be explicit about it. When you don't care,
 just that it will be closed soonish then relying on normal object
 lifetime calls is sufficient. This is true regardless of whether
 object lifetimes are handled via refcount or via true garbage
 collection. Relying on the specific semantics of refcounting to give
 certain lifetimes is a logic error.

 For example:

 f = some_file() #maybe it's the file store for a database implementation
 f.write('a bunch of stuff')
 del f
 #insert code that assumes f is closed.

 This is the sort of code that I warn against writing.

 f = some_file()
 with f:
   f.write(a bunch of stuff)
 #insert code that assumes f is closed, but correctly this time

 is better.

This has raised a few questions in my mind. So, here's my newbie
question based off this.

Is this:

f = open(xyz)
f.write(wheee)
f.close()
# Assume file is closed properly.

as safe as your code:

f = some_file()
with f:
  f.write(a bunch of stuff)
#insert code that assumes f is closed, but correctly this time

Thanks!

G

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Captain Poutine
Peter Otten wrote:
 Neil Cerutti wrote:
 
 On 2007-07-05, Captain Poutine [EMAIL PROTECTED] wrote:
 I'm simply trying to read a CSV into a dictionary.

 (if it matters, it's ZIP codes and time zones, i.e.,
 35983,CT
 39161,CT
 47240,EST



 Apparently the way to do this is:

 import csv

 dictZipZones = {}

 reader = csv.reader(open(some.csv, rb))
 for row in reader:
  # Add the row to the dictionary
 In addition to Chris's answer, the csv module can read and write
 dictionaries directly. Look up csv.DictReader and csv.DictWriter.
 
 DictReader gives one dict per row, with field names as keys. The OP is more
 likely to want
 
 dict(csv.reader(open(some.csv, rb)))
 
 which produces a dict that maps ZIP codes to time zones.
 
 Peter
 

Thanks Peter, that basically works, even if I don't understand it.

What does rb mean? (read binary?)
Why are the keys turned into strings (they are not quoted in the .csv file)?

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


SMTP server w/o using Twisted framework

2007-07-05 Thread _spitFIRE
Is it possible to run a SMTP server that sends mail to recipients
using standard libraries, without using twisted framework, and also
without using any relay server?

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


Re: Where is the syntax for the dict() constructor ?!

2007-07-05 Thread Thomas Jollans
On Thursday 05 July 2007, Captain Poutine wrote:
 Peter Otten wrote:
  Neil Cerutti wrote:
  On 2007-07-05, Captain Poutine [EMAIL PROTECTED] wrote:
  I'm simply trying to read a CSV into a dictionary.
 
  (if it matters, it's ZIP codes and time zones, i.e.,
  35983,CT
  39161,CT
  47240,EST
 
 
 
  Apparently the way to do this is:
 
  import csv
 
  dictZipZones = {}
 
  reader = csv.reader(open(some.csv, rb))
  for row in reader:
   # Add the row to the dictionary
 
  In addition to Chris's answer, the csv module can read and write
  dictionaries directly. Look up csv.DictReader and csv.DictWriter.
 
  DictReader gives one dict per row, with field names as keys. The OP is
  more likely to want
 
  dict(csv.reader(open(some.csv, rb)))
 
  which produces a dict that maps ZIP codes to time zones.
 
  Peter

 Thanks Peter, that basically works, even if I don't understand it.

 What does rb mean? (read binary?)
 Why are the keys turned into strings (they are not quoted in the .csv
 file)?

rb is read, in binary mode. On DOS and derivatives this prevents intentional 
file corruption when reading. (for ASCII files, omitting the b might be 
desirable...)

Think of csv.reader as a fancy variant of the following: (fancy in that it 
supports things like non-comma separators and comma escaping)

def CSVReader(file):
  for line in file:
yield line.split(',')

-- 
  Regards,   Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key http://hackerkey.com/:
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: SMTP server w/o using Twisted framework

2007-07-05 Thread Jeff McNeil
If you just want to send mail, you should be able to use the standard
smtplib module (http://docs.python.org/lib/module-smtplib.html). If
your recipients are on the Internet, you would need to handle MX
resolution yourself.

I know you said you want to avoid a relay server, but it's probably
the best bet unless you control the SMTP infrastructure or are simply
sending messages locally. Otherwise, you'll probably need to also
implement queuing and retry logic (depending on your requirements).
There are also some warning lights that may go off and flag your mail
as spam if you're using a method like that...

-Jeff

On 7/5/07, _spitFIRE [EMAIL PROTECTED] wrote:
 Is it possible to run a SMTP server that sends mail to recipients
 using standard libraries, without using twisted framework, and also
 without using any relay server?

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

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


Re: SMTP server w/o using Twisted framework

2007-07-05 Thread _spitFIRE
On Jul 5, 1:34 pm, Jeff McNeil [EMAIL PROTECTED] wrote:
 If you just want to send mail, you should be able to use the standard
 smtplib module (http://docs.python.org/lib/module-smtplib.html). If
 your recipients are on the Internet, you would need to handle MX
 resolution yourself.


How complicated is to handle the MX resolution by myself? I'm sorry
that I don't have a clue regarding that. Any pointers would be greatly
appreciated.

 I know you said you want to avoid a relay server, but it's probably
 the best bet unless you control the SMTP infrastructure or are simply
 sending messages locally.

The problem is that with the scenario I'm faced with, I don't have any
reliable SMTP server that I can use. Hence, I though I will spawn my
own light-weight SMTP server that can send mails to the people I want,
on the Internet. But, from what you are saying it seems, it might not
be that light weight after all!

 Otherwise, you'll probably need to also
 implement queuing and retry logic (depending on your requirements).

Isn't there a library module that can help me implement all this?

 There are also some warning lights that may go off and flag your mail
 as spam if you're using a method like that...

 -Jeff

Would you please fill me in with some pointers as to why my mail might
get flagged as spam? Would it be considered spam even if I've a valid
from address, and a proper message/subject? Does the spam filter also
rely on the sending server's DNS etc because of which you say it might
get flagged as spam?

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


Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-07-05 Thread Klaas
On Jun 29, 3:48 am, Mark Dufour [EMAIL PROTECTED] wrote:

 I have just released version 0.0.22 of Shed Skin, an experimental
 Python-to-C++ compiler. Among other things, it has the exciting new
 feature of being able to generate (simple, for now) extension modules,
 so it's much easier to compile parts of a program and use them (by
 just importing them). Here's the complete changelog:

 -support for generating simple extension modules (linux/windows; see README)

Great work.  You might want to advertise this on the main site
(currently it states that this is impossible).

You've said somewhere that you didn't/don't plan on working on this
aspect, but it is surely the killer feature of shed skin needed to
for it to be able to be used as pyrex is currently (optimizing bits of
larger projects).

Of course, the perfect synthesis would be to combine the two projects
into something that applied type inferencing with a fallback to python
vm when necessary g.  But there is such a large gap betwixt the
twain that such dreaming is but an excercise in fantasy (there's
always pypy).

I wish I had time to help,
-Mike

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


Re: Re-raising exceptions with modified message

2007-07-05 Thread Neil Cerutti
On 2007-07-05, Christoph Zwerschke [EMAIL PROTECTED] wrote:
 Neil Cerutti wrote:
 The documentation for BaseException contains something that might
 be relevant:
 
[...] If more data needs to be attached to the exception,
attach it through arbitrary attributes on the instance. All

 Users could get at the extra info you attached, but it wouldn't
 be automatically displayed by the interpreter.

 Yes, that's the problem here. It wouldn't be displayed
 automatically and the users must be aware of this attribute.
 I'd like to have a more transparent solution.

You ought to be able to use the third arg of raise to raise a new
exception as if it were from the previous location, but now with
a new message.

You may need the traceback module to get at the error message, if
trying to read e.message can fail.

Something like this mess here: ;)

   ...
   except Exception, e:
 etype, evalue, etb = sys.exc_info()
 ex = traceback.format_exception_only(etype, evalue)
 message = ex[0].partition(':')[2].strip()
 raise etype, message+. Sorry!, etb

Note that the above will break for SyntaxError (who's message
contains more than one line) and any kind of exception that
doesn't inherit from Exception.

You might need some crufty try, finally to avoid having a
circular reference hang around, according to the docs for
sys.exc_info.

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


Callback scoping

2007-07-05 Thread Dan
So, I think I understand what python's scoping is doing in the
following situation:
 x = [ lambda: ind for ind in range(10) ]
 x
[function lambda at 0x00BEC070, function lambda at 0x00BEC7F0,
function lambda at 0x00BECA70, function lambda at 0x00C1EBF0,
function lambda at 0x00C1EE30, function lambda at 0x00C228F0,
function lambda at 0x00C228B0, function lambda at 0x00C28730,
function lambda at 0x00C286F0, function lambda at 0x00C287F0]
 x[0]()
9
 x[5]()
9
 x[9]()
9
 ind
9
 ind = 2
 x[0]()
2


But, I'm wondering what is the easiest (and/or most pythonic) way to
get the behavior I want? (If you haven't guessed, I want a list of (no
parameter) functions, each of which returns its index in the list.)

-Dan

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


Re: Proposal: s1.intersects(s2)

2007-07-05 Thread Christoph Zwerschke
Nis Jørgensen wrote:
 The problem is, these functions can be read as X is [consisting only
 of] digit[s], X is lower [case] etc, where the bits in brackets have
 been removed for brewity. In the case of s1 is intersect s2 there is
 no way I can see of adding words to get a correct sentence. The
 obvious naming is s1.intersects(s2) which reads as s1 intersects
 s2, a perfectly cromulent sentence.

Agree. A possible alternative would be s1.hasintersection(s2), but 
s1.intersects(s2) is ok as well.

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


Re: SMTP server w/o using Twisted framework

2007-07-05 Thread Jean-Paul Calderone
On Thu, 05 Jul 2007 18:56:49 -, _spitFIRE [EMAIL PROTECTED] wrote:
On Jul 5, 1:34 pm, Jeff McNeil [EMAIL PROTECTED] wrote:
 If you just want to send mail, you should be able to use the standard
 smtplib module (http://docs.python.org/lib/module-smtplib.html). If
 your recipients are on the Internet, you would need to handle MX
 resolution yourself.


How complicated is to handle the MX resolution by myself? I'm sorry
that I don't have a clue regarding that. Any pointers would be greatly
appreciated.

You need to do a DNS MX lookup.  There's nothing in the Python stdlib
which provides this functionality.  There are several libraries available
which do this, though (Twisted among them ;).  You can probably find them
with a little googling.  Beyond that, the rules for processing MX records
are simple and it's not much work to pick the right host once you can do
the MX lookups.

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


  1   2   >