ANN: wxPython 2.7.2.0

2006-11-08 Thread Robin Dunn
Announcing
--

The 2.7.2.0 release of wxPython is now available for download at
http://wxpython.org/download.php.  This is expected to be the last
stepping stone in the path to the next stable release series,
2.8.x. We're pushing full speed ahead in order to get 2.8.0 included
with OSX 10.5, and so far we are very close to being on schedule. This
release has some house-keeping style changes, as well as some
user-contributed patches and also the usual crop of bug fixes.  Source
and binaries are available for both Python 2.4 and 2.5 for Windows and
Mac, as well some pacakges for varous Linux distributions.  A summary
of changes is listed below and also at
http://wxpython.org/recentchanges.php.


What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most
cases the native widgets are used on each platform.


Changes in 2.7.2.0
--

Patch [ 1583183 ] Fixes printing/print preview inconsistencies

Add events API to wxHtmlWindow (patch #1504493 by Francesco Montorsi)

Added wxTB_RIGHT style for right-aligned toolbars (Igor Korot)

Added New Zealand NZST and NZDT timezone support to wx.DateTime.

wx.Window.GetAdjustedBestSize is deprecated.  In every conceivable
scenario GetEffectiveMinSize is probably what you want to use instead.

wx.Image: Gained support for TGA image file format.

wx.aui: The classes in the wx.aui module have been renamed to be more
consistent with each other, and make it easier to recognize in the
docs and etc. that they belong together.

 FrameManager -->   AuiManager
 FrameManagerEvent -->  AuiManagerEvent
 PaneInfo -->   AuiPaneInfo
 FloatingPane -->   AuiFloatingPane
 DockArt -->AuiDockArt
 TabArt --> AuiTabArt
 AuiMultiNotebook -->   AuiNotebook
 AuiNotebookEvent -->   AuiNotebookEvent

wx.lib.customtreectrl: A patch from Frame Niessink which adds an
additional style (TR_AUTO_CHECK_PARENT) that (un)checks a parent when
all children are (un)checked.

wx.animate.AnimationCtrl fixed to display inactive bitmap at start
(patch 1590192)

Patch from Dj Gilcrease adding the FNB_HIDE_ON_SINGLE_TAB style flag
for wx.lib.flatnotebook.

wx.Window.GetBestFittingSize has been renamed to GetEffectiveMinSize.
SetBestFittingSize has been renamed to SetInitialSize, since it is
most often used only to set the initial (and minimal) size of a
widget.

The QuickTime backend for wx.media.MediaCtrl on MS Windows works
again.  Just pass szBackend=wx.media.MEDIABACKEND_QUICKTIME to the
constructor to use it instead of the default ActiveMovie backend,
(assuming the quicktime DLLs are available on the system.)

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

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


Re: assigning a sequence to an array

2006-11-08 Thread Robert Kern
[EMAIL PROTECTED] wrote:
> Hi,
> I am using  "A[a,:]=row" in python, where A is a matrix and row is a
> sequence. But it gives following error:
>  error--
> A[a,:]=row
> ValueError: setting an array element with a sequence.
> 
> Is there a way to change type of sequence to array so that this
> situation could be handled

You don't say what array package you are using. I presume numpy. In any case,
the place to ask those questions (even for the older numarray and Numeric
packages) is the numpy list.

  http://www.scipy.org/Mailing_Lists

We will need some more information from you when you come to the numpy list.
Please reduce your problematic code to the smallest, self-contained script that
demonstrates the problem, and post it and the exact output that you get.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: ANN: wxPython 2.7.2.0

2006-11-08 Thread Jia Lu

Robin Dunn wrote:
> Announcing
> --

Thanx.

But I found wxPy's release speed is too fast that we nearly cannot
catch up with it :)

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


Re: unpickling Set as set

2006-11-08 Thread George Sakkis
Nick Vatamaniuc wrote:
> The two are not of the same type:
>
> -
> In : import sets
> In : s1=sets.Set([1,2,3])
>
> In : s2=set([1,2,3])
>
> In: type(s1)
> Out: 
>
> In : type(s2)
> Out: 
>
> In : s1==s2
> Out: False   # oops!
>
> In: s2==set(s1)
> Out: True   # aha!
> --
>
> You'll have to just cast:
>  unpickled_set=set(unpickled_set)
>
> -Nick V.


Or you may have this done automatically by hacking the Set class:

from sets import Set
import cPickle as pickle

Set.__reduce__ = lambda self: (set, (self._data,))

s = Set([1,2,3])
x = pickle.dumps(s)
print pickle.loads(x)


This doesn't work though if you have already pickled the Set before
replacing its __reduce__, so it may not necessarily be what you want.
If there is a way around it, I'd like to know it.

George

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


E-Commerce Partner Program

2006-11-08 Thread jlicht
Just thought that I'd let you know that PricePlay.com has launched an
awesome Partner Program for all the E-Commerce developers.  All you
have to do is sign someone up and get paid.

http://www.priceplay.com/corporate/partners/incentive/signup.cfm

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


Cactching Stdout

2006-11-08 Thread Massi
Hi everyone! I'm writing a python script which uses a C-written dll. I
call the functions in the dll using ctypes, but I don't know how to
catch the output of the "printf" which the C functions use. In fact I
don't even know if it is possible! I've heard something about PIPE and
popen...is this what I need? How can I use them? It is very important
for me that I could take the output in real-time.
Thanks for the help!
Massi

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


Searching for a module to generate GUI events

2006-11-08 Thread Stephan Kuhagen
Hello

I'm searching for a Python Module which is able to generate GUI events on
different platforms (at least X11 and Windows, MacOSX would be nice), but
without being a GUI toolkit itself. So PyTk is not a choice, because I need
to use it, to control GUIs of other Programs. I want to generate Mouse
events (move, click etc.) and keyboard events and inject them directly into
the event-queue of the underlying window system. 

Does somebody know such a module or do I have to utilize platform specific
tools from within Python?

Regards and Thanks
Stephan

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


Re: E-Commerce Partner Program

2006-11-08 Thread [EMAIL PROTECTED]
I am willing to barter for the space.  I need csoundgrid2.py to be
callable from inside a program just like it is from the command line.
This has been driving me nuts for a couple of weeks.  The program is
part of csoundroutines beta 8.  and the program is called dex tracker
although knowing how to do it is what Im after a simple test program
will work.

https://sourceforge.net/project/showfiles.php?group_id=156455
http://www.dexrow.com


[EMAIL PROTECTED] wrote:
> Just thought that I'd let you know that PricePlay.com has launched an
> awesome Partner Program for all the E-Commerce developers.  All you
> have to do is sign someone up and get paid.
> 
> http://www.priceplay.com/corporate/partners/incentive/signup.cfm

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


Re: E-Commerce Partner Program

2006-11-08 Thread [EMAIL PROTECTED]

[EMAIL PROTECTED] wrote:
> Just thought that I'd let you know that PricePlay.com has launched an
> awesome Partner Program for all the E-Commerce developers.  All you
> have to do is sign someone up and get paid.
>
> http://www.priceplay.com/corporate/partners/incentive/signup.cfm

To extend and revise my notes that I need it to be callible from inside
a program with two arguments in exchange for addspace or links or
whatever that isn't actual cash.  Offer good to anyone who isn't
running obsene adds.

http://www.dexrow.com

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


please help with optimisation of this code - update of given table according to another table

2006-11-08 Thread Farraige
Hi I need your help...
I am implementing the method that updates given table (table is
represented as list of lists of strings) according to other table (some
kind of merging)...

This method takes following arguments:
t1   - table we would like to update
t2   - table we would like to take data
from
keyColumns- list of key indexes e.g. [0,1]
columnsToBeUpdated -  list of column indexes we would like to update in
our table T1 e.g [2,4]

Let's say we have a table T1:

A B C D E
---
1 4  5  7 7
3 4  0  0 0

and we call a method mergeTable(T1, T2, [0,1], [2,4])

It means that we would like to update columns C and E of table T1 with
data from table T2 but only in case the key columns A and B are equal
in both tables I grant that the given key is unique in both tables
so if I find a row with the same key in table T2 I do merging, stop and
go to next row in table T1...

Let's say T2 looks following:

A B C D E
---
2 2  8 8 8
1 4  9 9 9

So after execution of our   mergeTable method, the table T1 should look
like :

A B C D E
1 4  9  7 9
3 4  0 0  0

The 2nd row ['3', '4',  '0' ,'0',  '0'] didn't change because there was
no row in table T2 with key = 3 ,4

The main part of my algorithm now looks something like ...

merge(t1, t2, keyColumns, columnsToBeUpdated)

...

for row_t1 in t1:
for  row_t2 in t2:
if [row_t1[i] for i in keyColumns] == [row_t2[j] for j
in keyColumns]:
# the keys are the same
for colName in columnsToBeUpdated:
row_t1[colName] = row_t2[colName]

# go outside the inner loop - we found a row with
# the same key in the table
break

In my algorithm I have 2 for loops and I have no idea how to optimise
it (maybe with map? )
I call this method for very large data and the performance is a
critical issue for me :(

I will be grateful for any ideas
Thanks in advance!

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


MODULE mx.DateTime

2006-11-08 Thread Antonios Katsikadamos
Hi all. I am using python2.4 on suse linux 10.1 and i want to import the mx.DateTime module. does anyone know where i can find this module and how i can install it on linux?I would appreciate any help.thnx a lot kind regards,Antonios 


Access over 1 million songs - Yahoo! Music Unlimited.-- 
http://mail.python.org/mailman/listinfo/python-list

Python deployment options.

2006-11-08 Thread king kikapu

Hi to all folks here,

i just bought a book and started reading about this language.
I want to ask what options do we have to deploy a python program to
users that do not have the labguage installed ??

I mean, can i make an executable file, or something that contains the
runtime and the modules that the program only use or am i forced to
download the language to the user machine so the .py  files can be run
??

Thanks in advance,

king kikapu

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


Re: Python deployment options.

2006-11-08 Thread dimitri pater
Hi,try:http://www.py2exe.org/regards,DimitriOn 8 Nov 2006 02:37:42 -0800, king kikapu <
[EMAIL PROTECTED]> wrote:Hi to all folks here,i just bought a book and started reading about this language.
I want to ask what options do we have to deploy a python program tousers that do not have the labguage installed ??I mean, can i make an executable file, or something that contains theruntime and the modules that the program only use or am i forced to
download the language to the user machine so the .py  files can be run??Thanks in advance,king kikapu--http://mail.python.org/mailman/listinfo/python-list
-- ---You can't have everything. Where would you put it? -- Steven Wright---please visit www.serpia.org
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: object data member dumper?

2006-11-08 Thread Bruno Desthuilliers
tom arnall wrote:
> Bruno Desthuilliers wrote:
> 
>> tom arnall a écrit :
>>> does anyone know of a utility to do a recursive dump of object data
>>> members?
>>>
>> What are "object data members" ? (hint: in Python, everything is an
>> object - even functions and methods).
>>
>> What is your real use case ?
> 
> something like:
> 
>class A:

Make it :
 class A(object):

>   def __init__(self, p1):
>  self.p1 = p1
> 
>class B: 
>   def __init__(self,p1, p2):
>  self.a = A(p1)
>  self.p2 = p2
>  self.v1 = '3'
> 
>class C:
>   def __init__(self):
>  self.b = B(3,4)
>  self.p3 = 5
> 
>class D:
>   def __init__(self):
>  self.v2=2
>  self.o1 = C()
>  self.o2 = B(11,12)
> 
> 
>d = D()
>objectDataDumper(d)
> 
> 
> would produce something like:
> 
>object of class D with:
>o1(C)->b(B)->a(A)->p1=3
>o1(C)->b(B)->p2=4
>o1(C)->b(B)->v1=3
>o1(C)->p3=5
>o2(B)->a(A)->p1=11
>o2(B)->p2=12
>o2(B)->v1=3
>v2=2

Ok, so this is for debugging purpose ?

A small question : how should this behave for:
- _implementation attributes
- __magic__ attributes
- class attributes
- callable attributes
- properties and other descriptors  ?

In fact, the problem is that in Python, everything's an object, and an
object is mostly a composed namespace (ie a set of name-object mappings)
subject to some lookup rules. FWIW, the class of an object is an
attribute (__class__) referencing the class objet; superclasses are
class objects referenced by the __bases__ and __mro__ attributes of the
class object; method objects are usually attributes of the class object,
but it's possible to add/replace methods on a per-instance basis;
properties are class attributes that most of the time works on some
instance attribute. etc, etc, etc... Even the code of a function is an
attribute of the function object. And as an icing on top of the cake,
there's the __getattr__ magic method...

With all this in mind, writing a generic python object inspector is not
that trivial : either you'll end up with way too much informations or
you'll arbitrary skip informations that would be useful in a given
context or you'll need to pass so much args to the inspector that it'll
become too heavy for a quick, intuitive use... Well, that's at least my
own experience.

OTOH, "live" inspection of an object (either in the Python shell or in a
pdb session) works fine. The pprint and inspect modules may help too.

My 2 cents...
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python deployment options.

2006-11-08 Thread Chris_147
king kikapu wrote:
> Hi to all folks here,
>
> i just bought a book and started reading about this language.
> I want to ask what options do we have to deploy a python program to
> users that do not have the labguage installed ??
>
> I mean, can i make an executable file, or something that contains the
> runtime and the modules that the program only use or am i forced to
> download the language to the user machine so the .py  files can be run
> ??
>
> Thanks in advance,
>
> king kikapu

Well, on Windows you have to look for the Py2Exe package
(www.py2exe.org)
On Mac OS X you can use Py2App
(http://undefined.org/python/py2app.html)

Mind you, on Windows there is one big potentional problem: Python is
compiled with Visual Studio 2003 and needs msvcr71.dll.  So Py2Exe
wants to distribute that dll also, but if you don't have a valid Visual
Studio license, you are not allowed to.
It is explained further in this thread:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/bccb45b7dae7ddd5/dacec12e300a74d4#dacec12e300a74d4

I doubt Microsoft will unleash their lawyers on you, but it is a
problem.

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


Re: Python deployment options.

2006-11-08 Thread king kikapu

I see...So, if these are the only options, the only "safe" bet is to
install the language on the machine (beeing Win, Linux or Mac)
and execute the .py files, right ??


On Nov 8, 1:24 pm, "Chris_147" <[EMAIL PROTECTED]> wrote:
> king kikapu wrote:
> > Hi to all folks here,
>
> > i just bought a book and started reading about this language.
> > I want to ask what options do we have to deploy a python program to
> > users that do not have the labguage installed ??
>
> > I mean, can i make an executable file, or something that contains the
> > runtime and the modules that the program only use or am i forced to
> > download the language to the user machine so the .py  files can be run
> > ??
>
> > Thanks in advance,
>
> > king kikapuWell, on Windows you have to look for the Py2Exe package
> (www.py2exe.org)
> On Mac OS X you can use Py2App
> (http://undefined.org/python/py2app.html)
>
> Mind you, on Windows there is one big potentional problem: Python is
> compiled with Visual Studio 2003 and needs msvcr71.dll.  So Py2Exe
> wants to distribute that dll also, but if you don't have a valid Visual
> Studio license, you are not allowed to.
> It is explained further in this 
> thread:http://groups.google.com/group/comp.lang.python/browse_frm/thread/bcc...
>
> I doubt Microsoft will unleash their lawyers on you, but it is a
> problem.

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


Re: struggling with memory release using ctypes wrapper

2006-11-08 Thread geskerrett
Oops, found the problem in my code.
Sorry for wasting peoples time if you're viewing.

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


for x in... x remains global

2006-11-08 Thread Antoine De Groote
for x in range(3): pass

After this statement is executed x is global variable. This seems very 
unnatural to me and caused me 3 three days of debugging because I was 
unintentionally using x further down in my program (typo). I would have 
thought that variables like this are local to the for block.

Is there a reason this is not the case? Maybe there are PEPs or 
something else about the matter that you can point me to?

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


Need help

2006-11-08 Thread Srinivasa
Hai friends,
I wrote a programme to display a window (ui) using Python. I renamed it
as .pyw to avoid popping-up the dos window while running it. It worked
fine. But when i converted  it to executable file using py2exe; the dos
window appears. Can anybody tell me what the solution is.

Thanks and Regards
- Srinivasa Raju Datla

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


Re: for x in... x remains global

2006-11-08 Thread Diez B. Roggisch
Antoine De Groote wrote:

> for x in range(3): pass
> 
> After this statement is executed x is global variable. This seems very
> unnatural to me and caused me 3 three days of debugging because I was
> unintentionally using x further down in my program (typo). I would have
> thought that variables like this are local to the for block.
> 
> Is there a reason this is not the case? Maybe there are PEPs or
> something else about the matter that you can point me to?

It's an somewhat unfortunate fact that loop variables leak to the outer
scope.  List-comps as well, btw.

In 

http://www.python.org/dev/peps/pep-0289/

it says that this will be remedied in Py3K 

"""
List comprehensions also "leak" their loop variable into the surrounding
scope. This will also change in Python 3.0, so that the semantic definition
of a list comprehension in Python 3.0 will be equivalent to list(). Python 2.4 and beyond should issue a deprecation warning if a
list comprehension's loop variable has the same name as a variable used in
the immediately surrounding scope.
"""

And while I can't make an authorative statement about this, I can imagine
that it won't be fixed anywhere in python2.X, as code like this is
certainly to be found:

for x in some_xes:
if condition(x):
break

print x


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


Problem exiting application in Windows Console.

2006-11-08 Thread Ant
Hi all,

I'm putting together a simple help module for my applications, using
html files stored in the application directory somewhere. Basically it
sets up a basic web server, and then uses the webbrowser module to
display it in the users browser. I have it set up to call sys.exit(0)
if the url quit.html is called, but for some reason (on Windows XP via
the cmd.exe shell) python won't let me have the console back. I get the
System Exit stack trace OK:

Exiting...

Exception happened during processing of request from ('127.0.0.1',
3615)
Traceback (most recent call last):
...
  File "C:\Documents and Settings\aroy\My Do...
sys.exit(0)
SystemExit: 0



However, at this point instead of getting back to a command prompt, I
get an unresponsive console. Hitting CTRL-Break gets me the command
prompt back, but I would have expected to get back the command prompt
as soon as the sys.exit(0) had completed.

Here's the code:

import webbrowser, os, sys
from threading import Thread
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

class HelpHTTPRequestHandler(SimpleHTTPRequestHandler):
def do_GET(self):
print "PATH: ", self.path
if self.path.endswith("quit.html"):
print "Exiting..."
sys.exit(0)
else:
return SimpleHTTPRequestHandler.do_GET(self)

def help(base_dir, server_class=HTTPServer,
handler_class=HelpHTTPRequestHandler):
os.chdir(base_dir)
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
server_thread = Thread(target=httpd.serve_forever)
server_thread.start()

webbrowser.open("http://localhost:8000/index.html";)

print "Hit CTRL-Break or CTRL-C to exit server"

def main():
current_dir = os.path.split(sys.argv[0])[0]
help(current_dir)

if __name__ == "__main__":
main()

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


Python/Django Lead Developer Needed in NYC

2006-11-08 Thread [EMAIL PROTECTED]
I hope job ads are ok in this group. It looks like my efforts to
make python our base service oriented architecture technology and
Django as the core web framework is coming through. I now need to hire
a New York based developer to be the tech lead for much of this effort.
I can't reveal the company name yet but you've heard of us and this is
a high profile effort.

   If you'd like to apply for the spot, you need to be able to
demonstrate strong python skills and actual usage of Django to build
real systems. This is core infrastructure work so awareness of role
based capabilty authorizations, talking to disparate
services/applications on various platforms (windows & linux), and
general management of complex interconnected systems is going to be
key. Nothing we do will be stand alone.

   We're definitely an Agile shop and are trying to move even further
in that regard. Experience here is a plus as well. You'll need to be
able to work within and extend our new architecture and be able to
clearly specify requirements to other developers. Your team will exist
in New York as well as Bangkok (yes there will be some opportunity to
travel to BKK later) so co-ordinating across time zones means you have
to know what you're talking about and be able to make yourself
understood. Its an issue of delegation and coaching as much as pure
technical ability.

   Please send me your resume, cv, and salary requirements. I will make
sure that all qualified candidates get a response. Thanx for your
consideration,

   -- Ben

PS: I also have python/django positions in Bangkok but you must be a
Thai national and we pay competitive Thai salaries here.

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


Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?

2006-11-08 Thread dananrg
Thanks Roger, I'll give it a shot.

Is os.walk the best way (using standard library modules) to traverse
directory trees in Python 2.4 and beyond?

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


Web Browser Pythonlet

2006-11-08 Thread Bugra Cakir
Hi,I'm wondering if there is an environment for any web browser that executes python codeand running a gui inside the web browser like applet, flash or like those ?Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: for x in... x remains global

2006-11-08 Thread Ben Finney
Antoine De Groote <[EMAIL PROTECTED]> writes:

> for x in range(3): pass
>
> After this statement is executed x is global variable.

Not exactly. The name 'x' is bound at the scope of the 'for'
statement, and remains bound after the 'for' statement stops, just as
it would be if it was bound in any other statement.

> This seems very unnatural to me and caused me 3 three days of
> debugging because I was unintentionally using x further down in my
> program (typo).

This is, when used intentionally, one of the main useful features of
this behaviour: to determine where an iteration stopped by using the
value bound to the name ('x' in this case) after the iteration
statement.

> I would have thought that variables like this are local to the for
> block.

They're bound at the scope of the 'for' statement. They're available
inside the suite of that statement.

> Is there a reason this is not the case? Maybe there are PEPs or
> something else about the matter that you can point me to?

This message addresses it:

http://mail.python.org/pipermail/python-dev/2006-April/064624.html>

A search for the separate terms "python iteration variable scope" will
turn up more.

-- 
 \  "The best way to get information on Usenet is not to ask a |
  `\question, but to post the wrong information."  -- Aahz |
_o__)  |
Ben Finney

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


Re: for x in... x remains global

2006-11-08 Thread Duncan Booth
Antoine De Groote <[EMAIL PROTECTED]> wrote:

> for x in range(3): pass
> 
> After this statement is executed x is global variable. This seems very 
> unnatural to me and caused me 3 three days of debugging because I was 
> unintentionally using x further down in my program (typo). I would have 
> thought that variables like this are local to the for block.

Blocks in Python never create new scopes. You have global variables for 
each module and one set of local variables for each function. There is a 
minor exception in that the control variables in generator expressions are 
in a separate scope, but variables are never local to a block.

> Is there a reason this is not the case? Maybe there are PEPs or 
> something else about the matter that you can point me to?

One good reason is that sometimes you want to use the loop variable after 
the end of the loop:

for x in somesequence:
   if somecondition(x):
   break
else:
   raise NotFoundError
print "found", x

Try to write lots of small functions and then you can keep the scope of 
variables suitably small.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?

2006-11-08 Thread dananrg
Could you give an example for listing security descriptors using the
win32security module? I looked at the documentation but found it
confusing. Thanks.

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


Re: assigning a sequence to an array

2006-11-08 Thread [EMAIL PROTECTED]
actually what i want to do is this:
i have a file with following format:
1 2
3 9
2 3
4 4

I want to read it and then store the values into two matrices, s.t.
A=[1 2;3 9]
B=[2 3;4 4]

any easier way of doing this?
thanks
Amit

Robert Kern wrote:
> [EMAIL PROTECTED] wrote:
> > Hi,
> > I am using  "A[a,:]=row" in python, where A is a matrix and row is a
> > sequence. But it gives following error:
> >  error--
> > A[a,:]=row
> > ValueError: setting an array element with a sequence.
> >
> > Is there a way to change type of sequence to array so that this
> > situation could be handled
>
> You don't say what array package you are using. I presume numpy. In any case,
> the place to ask those questions (even for the older numarray and Numeric
> packages) is the numpy list.
>
>   http://www.scipy.org/Mailing_Lists
>
> We will need some more information from you when you come to the numpy list.
> Please reduce your problematic code to the smallest, self-contained script 
> that
> demonstrates the problem, and post it and the exact output that you get.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco

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


Re: Need help

2006-11-08 Thread Ant

Srinivasa wrote:
> Hai friends,
> I wrote a programme to display a window (ui) using Python. I renamed it
> as .pyw to avoid popping-up the dos window while running it. It worked
> fine. But when i converted  it to executable file using py2exe; the dos
> window appears. Can anybody tell me what the solution is.

Would be easier to give you a proper example if you posted some code,
esp the setup.py script. I'm guessing though that you are using  the
'console' option to the setup function in your script rather than the
'windows' option.

See help(py2exe) in the python console for more information.

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


Re: Searching for a module to generate GUI events

2006-11-08 Thread utabintarbo

Stephan Kuhagen wrote:
> Hello
>
> I'm searching for a Python Module which is able to generate GUI events on
> different platforms (at least X11 and Windows, MacOSX would be nice), but
> without being a GUI toolkit itself. So PyTk is not a choice, because I need
> to use it, to control GUIs of other Programs. I want to generate Mouse
> events (move, click etc.) and keyboard events and inject them directly into
> the event-queue of the underlying window system.
>
> Does somebody know such a module or do I have to utilize platform specific
> tools from within Python?
>
> Regards and Thanks
> Stephan

http://pywinauto.pbwiki.com/ for Win32

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


Re: Python deployment options.

2006-11-08 Thread Richard Charts

king kikapu wrote:
> I see...So, if these are the only options, the only "safe" bet is to
> install the language on the machine (beeing Win, Linux or Mac)
> and execute the .py files, right ??
>
>

Well on a Win machine, probably.
Almost every Linux machine you come across will have (most likely a
fairly recent build of) python.  For Macs, I'm not so sure but it's
probably closer to Linux than Win.

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


Re: psycopg2 faster way to retrieve last x records

2006-11-08 Thread Luis P. Mendes
Em Tue, 07 Nov 2006 17:03:17 -0800, Stuart Bishop escreveu:

> 
> The following SQL statement will return the last 200 rows in reverse order:
> 
> SELECT * FROM seconds ORDER BY tempounix DESC LIMIT 200
> 
> This will only send 200 rows from the server to the client (your existing
> approach will send all of the rows). Also, if you have an index on tempounix
> it will be really fast.
> 
> 
> If you really need the results in tempounix order, then:
> 
> SELECT * FROM (
> SELECT * FROM seconds ORDER BY tempounix DESC LIMIT 200
> ) AS whatever
> ORDER BY tempounix;

Thank you Stuart, I'll try it.

Luis P. Mendes
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: please help with optimisation of this code - update of given table according to another table

2006-11-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Farraige wrote:

> Let's say we have a table T1:
> 
> A B C D E
> ---
> 1 4  5  7 7
> 3 4  0  0 0
> 
> and we call a method mergeTable(T1, T2, [0,1], [2,4])
> 
> It means that we would like to update columns C and E of table T1 with
> data from table T2 but only in case the key columns A and B are equal
> in both tables I grant that the given key is unique in both tables
> so if I find a row with the same key in table T2 I do merging, stop and
> go to next row in table T1...
> 
> Let's say T2 looks following:
> 
> A B C D E
> ---
> 2 2  8 8 8
> 1 4  9 9 9
> 
> So after execution of our   mergeTable method, the table T1 should look
> like :
> 
> A B C D E
> 1 4  9  7 9
> 3 4  0 0  0
> 
> The 2nd row ['3', '4',  '0' ,'0',  '0'] didn't change because there was
> no row in table T2 with key = 3 ,4
> 
> The main part of my algorithm now looks something like ...
> 
> merge(t1, t2, keyColumns, columnsToBeUpdated)
> 
> ...
> 
> for row_t1 in t1:
> for  row_t2 in t2:
> if [row_t1[i] for i in keyColumns] == [row_t2[j] for j
> in keyColumns]:
> # the keys are the same
> for colName in columnsToBeUpdated:
> row_t1[colName] = row_t2[colName]
> 
> # go outside the inner loop - we found a row with
> # the same key in the table
> break
> 
> In my algorithm I have 2 for loops and I have no idea how to optimise
> it (maybe with map? )
> I call this method for very large data and the performance is a
> critical issue for me :(

Just go through the first table once and build a mapping key->row and then
go through the second table once and look for each row if the key is in
the mapping.  If yes: update columns.  This runs in O(2*rows) instead if
O(rows**2).

def update_table(table_a, table_b, key_columns, columns_to_be_updated):
def get_key(row):
return tuple(row[x] for x in key_columns)

key2row = dict((get_key(row), row) for row in table_a)
for row in table_b:
row_to_be_updated = key2row.get(get_key(row))
if row_to_be_updated is not None:
for column in columns_to_be_updated:
row_to_be_updated[column] = row[column]


def main():
table_a = [[1, 4, 5, 7, 7],
   [3, 4, 0, 0, 0]]
table_b = [[2, 2, 8, 8, 8],
   [1, 4, 9, 9, 9]]
update_table(table_a, table_b, (0, 1), (2, 4))
for row in table_a:
print row

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MODULE mx.DateTime

2006-11-08 Thread Steve Holden
Antonios Katsikadamos wrote:
> Hi all. I am using python2.4 on suse linux 10.1 and i want to import the 
> mx.DateTime module. does anyone know where i can find this module and 
> how i can install it on linux?
> 
> I would appreciate any help.
> 
Look on www.egenix.com

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread Ross Ridge
Ross Ridge schrieb:
> So give an example where reference counting is unsafe.

Martin v. Löwis wrote:
> Nobody claimed that, in that thread. Instead, the claim was
> "Atomic increment and decrement instructions are not by themselves
> sufficient to make reference counting safe."

So give an example of where atomic increment and decrement instructions
are not by themselves sufficent to make reference counting safe.

> I did give an example, in <[EMAIL PROTECTED]>.
> Even though f_name is reference-counted, it might happen that you get a
> dangling pointer.

Your example is of how access to the "f_name" member is unsafe, not of
how reference counting being unsafe.  The same sort of race condition
can without reference counting being involved at all.  Consider the
"f_fp" member: if one thread tries to use "printf()" on it while
another thread calls "fclose()", then you can have same problem.  The
race condition here doesn't happen because reference counting hasn't
been made safe, nor does it happen because stdio isn't thread-safe.  It
happens because accessing "f_fp" (without the GIL) is unsafe.

The problem your describing isn't that reference counting hasn't been
made safe.  What you and Joe seem to be trying to say is that atomic
increment and decrement instructions alone don't make accessing shared
structure members safe.
   Ross Ridge

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

Python cgi Apache os.system()

2006-11-08 Thread naima . mans
Hello :)

I have installed Apache on windows...
The server work well, and my python script also

but when I want in my python script to run a System command like
os.system(my_command) the script doesn't do anything!

here the error.log

[Wed Nov 08 14:19:30 2006] [error] [client 127.0.0.1] The system cannot
find the drive specified.\r, referer:
http://127.0.0.1/cgi-bin/extract_source.py

When i run the python script manually it works!

i think it's a user access probleme but i don't know how to resolve it
!

please help  
thanks

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


Python Jogos

2006-11-08 Thread [EMAIL PROTECTED]
Jogo da velha
Jogo do galo
Codigos em python kem me arranja

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


Re: please help with optimisation of this code - update of given table according to another table

2006-11-08 Thread Antoon Pardon
On 2006-11-08, Farraige <[EMAIL PROTECTED]> wrote:
>
> ...
>
> The main part of my algorithm now looks something like ...
>
> merge(t1, t2, keyColumns, columnsToBeUpdated)
>
> ...
>
> for row_t1 in t1:
> for  row_t2 in t2:
> if [row_t1[i] for i in keyColumns] == [row_t2[j] for j
> in keyColumns]:
> # the keys are the same
> for colName in columnsToBeUpdated:
> row_t1[colName] = row_t2[colName]
>
> # go outside the inner loop - we found a row with
> # the same key in the table
> break
>
> In my algorithm I have 2 for loops and I have no idea how to optimise
> it (maybe with map? )
> I call this method for very large data and the performance is a
> critical issue for me :(
>
> I will be grateful for any ideas

One idea would be to precompute the list comprehensions in the if test.

p2 = [[row_t2[i] for i in keyColums] for row_t2 in t2]
for row_t1 in t1:
proj1 = [row_t1[i] for i in keyColumns]
for row_t1, proj2 in izip(t2, p2):
if proj1 == proj2:
   ...


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


Help solving Python 2.5 crash: The instruction "0x7c168f1d" referenced memory at "0x00000001c" ...

2006-11-08 Thread Pedro Rodrigues
Hi everyone,
 
recently, I have installed Python 2.5 in a Windows XP (SP2) system, along with the numarray, PIL, and PyWin packages. Since then, I've been getting the following error message whenever I run one of my simulations within PyWin: 

 
The instruction "0x7c168f1d" referenced memory at "0x0001c". The memory could not be "read". 
 
 
If I run the same simulation from the python interactive shell, it still crashes but with a different error message:
 
This application has requested runtime to terminate it in an unusual way. Please contact the application's support team for more information.
 
 
The simulation demands a lot of memory but this shouldn't be the problem as it run in Windows XP before I switched to version 2.5. I've already tried to remove version 2.5 and install version 2.4.3 (the one I had before), but the I get the same problem :( 

 
Has anyone every experienced such a thing? Suggestions on how to solve this?
 
 
greetings,
pedro rodrigues
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?

2006-11-08 Thread Roger Upole

[EMAIL PROTECTED] wrote:
> Could you give an example for listing security descriptors using the
> win32security module? I looked at the documentation but found it
> confusing. Thanks.

There are some examples of using the security descriptor objects in
\Lib\site-packages\win32\Demos\security.
Also, searching the Python-win32 mailing list should turn up some
more code.

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


Delivering data to python from a c-thread

2006-11-08 Thread Svein Seldal
Hi,

I have a C-application that calls a Python function main(). This 
function will loop forever and not return until the entire application 
is about to terminate.

In a parallel C-thread, some data must be regularly delivered to the 
running python application. My initial plan was to call a py function 
deliver() from this thread, however I constantly run into troubles. I 
keep getting a "Fatal Python error: ceval: tstate mix-up" error from 
python, even when I handle the GIL with PyGILState_Ensure().

I fail to use PyEval_AcquireLock() prior to python call either, as the 
main app would then constantly keep this lock when its running 
permanently in python.

Basically I would the thread to stop the execution of the main py app, 
call the message function deliver(). When the function returns from 
python, resume the execution of the main pyapp.


Regards,
Svein Seldal



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


Re: Python deployment options.

2006-11-08 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Richard Charts <[EMAIL PROTECTED]> wrote:
.
.
.
>Well on a Win machine, probably.
>Almost every Linux machine you come across will have (most likely a
>fairly recent build of) python.  For Macs, I'm not so sure but it's
>probably closer to Linux than Win.
>

Recent releases of Mac OS build in Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python deployment options.

2006-11-08 Thread Fuzzyman

Chris_147 wrote:
> king kikapu wrote:
> > Hi to all folks here,
> >
> > i just bought a book and started reading about this language.
> > I want to ask what options do we have to deploy a python program to
> > users that do not have the labguage installed ??
> >
> > I mean, can i make an executable file, or something that contains the
> > runtime and the modules that the program only use or am i forced to
> > download the language to the user machine so the .py  files can be run
> > ??
> >
> > Thanks in advance,
> >
> > king kikapu
>
> Well, on Windows you have to look for the Py2Exe package
> (www.py2exe.org)
> On Mac OS X you can use Py2App
> (http://undefined.org/python/py2app.html)
>
> Mind you, on Windows there is one big potentional problem: Python is
> compiled with Visual Studio 2003 and needs msvcr71.dll.  So Py2Exe
> wants to distribute that dll also, but if you don't have a valid Visual
> Studio license, you are not allowed to.
> It is explained further in this thread:
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/bccb45b7dae7ddd5/dacec12e300a74d4#dacec12e300a74d4
>

I think that is an incorrect reading of the thread.

The *Python* developers need a valid Visual Studio license to
redistribute msvcr71.dll.

When you build an app with py2exe you are just bundling Python with
your application and so don't need the license.

Fuzzyman
http://www.voidspace.org.uk/index2.shtml

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


Re: for x in... x remains global

2006-11-08 Thread skip

Diez> It's an somewhat unfortunate fact that loop variables leak to the
Diez> outer scope.  List-comps as well, btw.

It's unfortunate that loop variables leak from list comprehensions (they
don't leak in genexps).  It's by design in for loops though.  Consider:

for i in range(10):
if i*i == 9:
break
print i

In this silly example, the loop index is the useful value of the
computation.  You could assign to a different variable, though that would be
slightly ugly:

for i in range(10:
j = i
if j*j == 9:
break
print j

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


python Error: IndentationError: expected an indented block

2006-11-08 Thread Antonios Katsikadamos
hi all. I am using python 2.4. I have to run an older python code and when i run it i get the following messageIndentationError: expected an indented block.1)what does this mean?2)how can i overcome this problemThanks for any advice.kind regards,Antonios 


Sponsored Link
Free Uniden 5.8GHz Phone System with Packet8 Internet Phone Service-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Character encoding

2006-11-08 Thread [EMAIL PROTECTED]

Dennis Lee Bieber wrote:
> On 7 Nov 2006 11:34:32 -0800, "mp" <[EMAIL PROTECTED]> declaimed the
> following in comp.lang.python:
>
> > I have html document titles with characters like >,  , and
> > ‡. How do I sddecode a string with these values in Python?
> >
>
>   Wouldn't HTMLParser be suited for such activity?
> --
>   WulfraedDennis Lee Bieber   KD6MOG
>   [EMAIL PROTECTED]   [EMAIL PROTECTED]
>   HTTP://wlfraed.home.netcom.com/
>   (Bestiaria Support Staff:   [EMAIL PROTECTED])
>   HTTP://www.bestiaria.com/

Use htmlentitydefs and SGMLParser to re-generate it .

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread Joe Seigh
Ross Ridge wrote:
> Ross Ridge schrieb:
> 
>>So give an example where reference counting is unsafe.
> 
> 
> Martin v. Löwis wrote:
> 
>>Nobody claimed that, in that thread. Instead, the claim was
>>"Atomic increment and decrement instructions are not by themselves
>>sufficient to make reference counting safe."
> 
> 
[...]
> 
> The problem your describing isn't that reference counting hasn't been
> made safe.  What you and Joe seem to be trying to say is that atomic
> increment and decrement instructions alone don't make accessing shared
> structure members safe.

How you increment and decrement a reference count is an implementation
issue and whether it's correct or not depends on the semantics of the
refcount based pointer.  I.e. what kind of thread safety guarantees
are we ascribing to pointer operations?  Java reference (pointer)
guarantees are not the same as C++ Boost shared_ptr guarantees.  In
Java simple pointer assignment, "a = b;" is always safe no matter what
any other thread may be doing to a and/or b.   With shared_ptr you have
to have a priori knowlege that the refcount for b will never go to
zero during the copy operation.  Usually that implies ownership of b.

To get a better feeling for the latter semantics you should take a look
at C++ String implementations.  A C++ String COW (copy on write) implementation
using atomic inc/dec is as thread-safe as a non-COW String implementation
because in both cases you have to own the strings you access.

About the term "thread-safe".  In Posix it's taken as meaning an operation
on non-shared data isn't affected by other threads.  So non-COW strings
are thread-safe, and COW strings are thread-safe if their internal
refcounting is synchronized properly.   But note that in both cases,
the implemention is transparent to the user.

So as you say, a lot depends on how you access or want to access shared
structure members, e.g. with or without locking. 


-- 
Joe Seigh

When you get lemons, you make lemonade.
When you get hardware, you make software. 
-- 
http://mail.python.org/mailman/listinfo/python-list


profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Beliavsky

Cliff Wells wrote:
> On Mon, 2006-11-06 at 18:20 -0800, Beliavsky wrote:
> > Carl J. Van Arsdall wrote:
> >
> > 
> >
> > > Pyro is fucking amazing and has been a great help to a couple of our 
> > > projects.
> >
> > You should watch your language in a forum with thousands of readers.
>
> The LA Times had a story that claimed that 64% of U.S. citizens use the
> word "fuck" and that 74% of us have heard it in public (I'll assume the
> remainder are your fellow AOL users).  I expect extrapolating these
> results worldwide wouldn't be far off the mark (the Brits were quite
> successful at spreading this versatile word).

If this is supposed to justify using bad language in a public forum, it
is poorly reasoned. Having heard "f***" does not mean they were not
annoyed. 100% of people have seen trash on the street, but that does
not justify littering. If a group of people don't mind profanity, there
is no harm in their swearing to each other. But Usenet is read by a
wide range of people, and needlessly offending some of them is wrong.
The OP used "f**" just for emphasis. English is a rich language,
and there are better ways of doing that.

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


Re: Help solving Python 2.5 crash: The instruction "0x7c168f1d" referenced memory at "0x00000001c

2006-11-08 Thread Bugra Cakir
Hi,I have came across this like problem in my simulations also. But the case is not for the program structure orpython version, the case is hardware :) . If you have time to try it on some other machine than the current and
if the problem arises then there is something different!
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python Error: IndentationError: expected an indented block

2006-11-08 Thread Vyacheslav Sotnikov


Antonios Katsikadamos пишет:
> hi all. I am using python 2.4. I have to run an older python code and when i 
> run it i get the following message
> 
> IndentationError: expected an indented block.
> 
> 1)what does this mean?

http://www.python.org/doc/2.4.3/ref/indentation.html

> 2)how can i overcome this problem

By syntax fixing

> 
> 
> Thanks for any advice.
> 
> kind regards,
> 
> Antonios
>  
> -
> Sponsored Link
> 
> Free Uniden 5.8GHz Phone System with Packet8 Internet Phone Service
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Summer of PyPy Call for Proposals

2006-11-08 Thread Carl Friedrich Bolz
Last chance to join the Summer of PyPy!
===

Hopefully by now you have heard of the "Summer of PyPy", our program for
funding the expenses of attending a sprint for students.  If not, you've
just read the essence of the idea :-)

However, the PyPy EU funding period is drawing to an end and there is
now only one sprint left where we can sponsor the travel costs of
interested students within our program. This sprint will probably take
place in Leysin, Switzerland from 8th-14th of January 2007.

So, as explained in more detail at:

http://codespeak.net/pypy/dist/pypy/doc/summer-of-pypy.html

we would encourage any interested students to submit a proposal in the
next month or so.  If you're stuck for ideas, you can find some at

http://codespeak.net/pypy/dist/pypy/doc/project-ideas.html

but please do not feel limited in any way by this list!

Cheers,

Carl Friedrich Bolz and the PyPy team

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


Re: ANN: wxPython 2.7.2.0

2006-11-08 Thread Kenneth Long
Is there a new version of Demo Docs released also?

I get this error from Sourceforge after clicking on
the  link at wxPython page.

Could not read file.

Go back.
/home/ftp/pub/sourceforge//w/wx/wxpython/wxPython2.7-win32-docs-demos-2.7.2.0.exe
Nov 08, 2006 07:10


--- Robin Dunn <[EMAIL PROTECTED]> wrote:

> Announcing
> --
> 
> The 2.7.2.0 release of wxPython is now available for
> download at
> http://wxpython.org/download.php.  This is expected
> to be the last
> stepping stone in the path to the next stable
> release series,
> 2.8.x. We're pushing full speed ahead in order to
> get 2.8.0 included
> with OSX 10.5, and so far we are very close to being
> on schedule. This
> release has some house-keeping style changes, as
> well as some
> user-contributed patches and also the usual crop of
> bug fixes.  Source
> and binaries are available for both Python 2.4 and
> 2.5 for Windows and
> Mac, as well some pacakges for varous Linux
> distributions.  A summary
> of changes is listed below and also at
> http://wxpython.org/recentchanges.php.
> 
> 
> What is wxPython?
> -
> 
> wxPython is a GUI toolkit for the Python programming
> language. It
> allows Python programmers to create programs with a
> robust, highly
> functional graphical user interface, simply and
> easily. It is
> implemented as a Python extension module that wraps
> the GUI components
> of the popular wxWidgets cross platform library,
> which is written in
> C++.
> 
> wxPython is a cross-platform toolkit. This means
> that the same program
> will usually run on multiple platforms without
> modifications.
> Currently supported platforms are 32-bit Microsoft
> Windows, most Linux
> or other Unix-like systems using GTK2, and Mac OS X
> 10.3+, in most
> cases the native widgets are used on each platform.
> 
> 
> Changes in 2.7.2.0
> --
> 
> Patch [ 1583183 ] Fixes printing/print preview
> inconsistencies
> 
> Add events API to wxHtmlWindow (patch #1504493 by
> Francesco Montorsi)
> 
> Added wxTB_RIGHT style for right-aligned toolbars
> (Igor Korot)
> 
> Added New Zealand NZST and NZDT timezone support to
> wx.DateTime.
> 
> wx.Window.GetAdjustedBestSize is deprecated.  In
> every conceivable
> scenario GetEffectiveMinSize is probably what you
> want to use instead.
> 
> wx.Image: Gained support for TGA image file format.
> 
> wx.aui: The classes in the wx.aui module have been
> renamed to be more
> consistent with each other, and make it easier to
> recognize in the
> docs and etc. that they belong together.
> 
>  FrameManager -->   AuiManager
>  FrameManagerEvent -->  AuiManagerEvent
>  PaneInfo -->   AuiPaneInfo
>  FloatingPane -->   AuiFloatingPane
>  DockArt -->AuiDockArt
>  TabArt --> AuiTabArt
>  AuiMultiNotebook -->   AuiNotebook
>  AuiNotebookEvent -->   AuiNotebookEvent
> 
> wx.lib.customtreectrl: A patch from Frame Niessink
> which adds an
> additional style (TR_AUTO_CHECK_PARENT) that
> (un)checks a parent when
> all children are (un)checked.
> 
> wx.animate.AnimationCtrl fixed to display inactive
> bitmap at start
> (patch 1590192)
> 
> Patch from Dj Gilcrease adding the
> FNB_HIDE_ON_SINGLE_TAB style flag
> for wx.lib.flatnotebook.
> 
> wx.Window.GetBestFittingSize has been renamed to
> GetEffectiveMinSize.
> SetBestFittingSize has been renamed to
> SetInitialSize, since it is
> most often used only to set the initial (and
> minimal) size of a
> widget.
> 
> The QuickTime backend for wx.media.MediaCtrl on MS
> Windows works
> again.  Just pass
> szBackend=wx.media.MEDIABACKEND_QUICKTIME to the
> constructor to use it instead of the default
> ActiveMovie backend,
> (assuming the quicktime DLLs are available on the
> system.)
> 
> -- 
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax
> with wxPython!
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


hello



 

Sponsored Link

Degrees online in as fast as 1 Yr - MBA, Bachelor's, Master's, Associate
Click now to apply http://yahoo.degrees.info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help with installing soappy module on Python 2.4.3 (windows machine)

2006-11-08 Thread Chris Lambacher
On Tue, Nov 07, 2006 at 07:30:49AM -0800, [EMAIL PROTECTED] wrote:
> Hi Folks,
> 
> 
> I want to install the SOAPpy module on my windows box. I have python
> 2.4.3
> 
> Can you help me with the steps and the URL from where can I get the
> download..??

http://pywebsvcs.sourceforge.net/

> 
> TIA.
> 
> Regards,
> Asrarahmed
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Character encoding

2006-11-08 Thread Frederic Rentsch
mp wrote:
> I have html document titles with characters like >,  , and
> ‡. How do I decode a string with these values in Python?
>
> Thanks
>
>   
This is definitely the most FAQ. It comes up about once a week.

The stream-editing way is like this:

 >>> import SE
 >>> HTM_Decoder = SE.SE ('htm2iso.se') # Include path

>>> test_string = '''I have html document titles with characters like >, 
>>>  , and
‡. How do I decode a string with these values in Python?'''
>>> print HTM_Decoder (test_string)
I have html document titles with characters like >,  , and
‡. How do I decode a string with these values in Python?

An SE object does files too.

>>> HTM_Decoder ('with_codes.txt', 'translated_codes.txt')  # Include path

You could download SE from -> http://cheeseshop.python.org/pypi/SE/2.3. The 
translation definitions file "htm2iso.se" is included. If you open it in your 
editor, you can see how to write your own definition files for other 
translation tasks you may have some other time.

Regards

Frederic



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


Re: Help solving Python 2.5 crash: The instruction "0x7c168f1d" referenced memory at "0x00000001c

2006-11-08 Thread Pedro Rodrigues
Hi Bugra,
 
thanks for your reply. I did try the same code on a Windows 2000 system where I also installed and later removed Python 2.5. There, I obtained the same problem :( That's why I think it has to do with software. I've also searched on the internet and this problem seems to come up also with other sorts of applications. This lead me to think that there might be some inconsistency in the Registry of Windows or some files that have been left behind after uninstall. I've tried to address these two possibilities but so far I did not succeed :(

 
pedro 
On 11/8/06, Bugra Cakir <[EMAIL PROTECTED]> wrote:
Hi,I have came across this like problem in my simulations also. But the case is not for the program structure or
python version, the case is hardware :) . If you have time to try it on some other machine than the current and if the problem arises then there is something different!--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pyro stability

2006-11-08 Thread BartlebyScrivener
"Some guy hit my fender, and I said to him, 'Be fruitful and multiply,'
but not in those words." --Woody Allen

"Language is a virus from outer space." --William Burroughs

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


Python Error:IndentationError: expected an indented block

2006-11-08 Thread Antonios Katsikadamos
hi all. I try to run an old python code and i get the following message  File "/home/antonis/db/access.py", line 119     def DoCsubnet1 (action, subject, target, args): # DoC servers net   ^ IndentationError: expected an indented block  1) and I don't know what causes it. I would be grate full if you could give me a tip.  2) how can i overcome it? Can i use the keyword pass?and if how ccan i use it   Kind regards,  Antonios  


Sponsored Link
For just $24.99/mo., Vonage offers unlimited local and long- distance calling. Sign up now.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: ANN: wxPython 2.7.2.0

2006-11-08 Thread Robin Dunn
Kenneth Long wrote:
> Is there a new version of Demo Docs released also?
> 
> I get this error from Sourceforge after clicking on
> the  link at wxPython page.
> 
> Could not read file.
> 
> Go back.
> /home/ftp/pub/sourceforge//w/wx/wxpython/wxPython2.7-win32-docs-demos-2.7.2.0.exe

Looks like there was an error when building that installer file.  I'll 
get it fixed and upload it again soon.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

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


Change directory permission under windows

2006-11-08 Thread __schronos__
Hi.

  I would like to add people with full control access to a directory. I
can do it to a file in the following way:

info=win32security.DACL_SECURITY_INFORMATION
sd=win32security.GetFileSecurity(DIR, info)
acl=sd.GetSecurityDescriptorDacl()
sidUser=win32security.LookupAccountName(None,USER)[0]
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
sd.SetSecurityDescriptorDacl(1, acl, 0)
win32security.SetFileSecurity(dir, info, sd)

and it work correctly, but if I try to do the same to a directory only
the "special permission" checkbox is checked and this is not useful to
me because I need a "full control" so that files under the directory
can inheritage the directory rigths.

Can anybody help me

Thank's

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


Change directory permission under windows

2006-11-08 Thread __schronos__
Hi.

  I would like to add users with full control access to a directory. I
can do it to a file in the following way:

info=win32security.DACL_SECURITY_INFORMATION
sd=win32security.GetFileSecurity(DIR, info)
acl=sd.GetSecurityDescriptorDacl()
sidUser=win32security.LookupAccountName(None,USER)[0]
acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser)
sd.SetSecurityDescriptorDacl(1, acl, 0)
win32security.SetFileSecurity(dir, info, sd)

and it work correctly, but if I try to do the same to a directory only
the "special permission" checkbox is checked and this is not useful to
me because I need a "full control" so that files under the directory
can inheritage the directory rigths.

Can anybody help me

Thank's

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


Re: sqlite query not working

2006-11-08 Thread John Salerno
BartlebyScrivener wrote:
> John Salerno wrote:
> 
>>> Ah well, I'm sure there was *something* different
> 
> Are you sure that it's not you were doing SELECT before, as opposed to
> INSERT?

Perhaps. It might have been that I used the INSERT statement on the 
sqlite command line, then used SELECT in Python, and got it all mixed up 
in my head. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite query not working

2006-11-08 Thread John Salerno
Dennis Lee Bieber wrote:

>   The other thing to consider is that, if you were testing using a
> single cursor, and single session, the database would have shown you
> uncommitted changes. It wouldn't have been until you closed the
> cursor/connection without a commit that the DBMS would have tossed them
> -- a select would still retrieve your uncommited changes during that
> transaction.

Good point, and I wouldn't be surprised if I had done that too! Working 
with databases in Python (as opposed to direct command line queries) is 
fairly new to me, so who knows what crazy things I tried to do. :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Exception Handling in TCPServer (was; Problem exiting application in Windows Console.)

2006-11-08 Thread Ant

Ant wrote:
...
> However, at this point instead of getting back to a command prompt, I
> get an unresponsive console. Hitting CTRL-Break gets me the command
> prompt back, but I would have expected to get back the command prompt
> as soon as the sys.exit(0) had completed.
...
> class HelpHTTPRequestHandler(SimpleHTTPRequestHandler):
> def do_GET(self):
> print "PATH: ", self.path
> if self.path.endswith("quit.html"):
> print "Exiting..."
> sys.exit(0)
> else:
> return SimpleHTTPRequestHandler.do_GET(self)
>
> def help(base_dir, server_class=HTTPServer,
> handler_class=HelpHTTPRequestHandler):
...

OK, I've narrowed the problem back to the way HTTPServer (actually its
TCPServer parent) handles exceptions thrown by the process_request
method by catching them all, and then calling a handle_error method.
There doesn't seem to be a way of getting at the exception thrown
however - does anyone know how I can get this information?

The default handle_error method in the TCPServer uses the traceback
module to print the stacktrace, but I can't find anything in that
module to get the actual exception object (or string) - is there an
alternative trick?

Incidentally, this seems to me to be a pretty drastic try: except:
block, catching *everything* and then (essentially) discarding the
exception. Wouldn't it be better to either catch only the exceptions
that are expected (presumably IO errors, Socket exceptions, HTTP error
code exceptions etc), and let others pass through, or alternatively
pass the exception through to the handle_error() method since this is
where it should be dealt with?

Thanks.

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


Re: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 7)

2006-11-08 Thread John Salerno
Chris Lambacher wrote:
> On Tue, Nov 07, 2006 at 04:15:39PM -0500, John Salerno wrote:
>> Cameron Laird wrote:
>>
>>> Fredrik Lundh collects pyidioms:
>>> http://effbot.org/zone/python-lists.htm
>> Not working?
> perhaps http://effbot.org/zone/python-list.htm ?
> 

Thanks guys!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: assigning values in __init__

2006-11-08 Thread John Salerno
Ben Finney wrote:
> John Salerno <[EMAIL PROTECTED]> writes:
> 
>> But I do like Steve's suggestion that it's better to be explicit
>> about each attribute, instead of just accepting a list of numbers
>> (but I can't help but feel that for some reason this is better,
>> because it's more general).
> 
> If you pass a *mapping* of the "I-might-want-to-add-more-in-the-future"
> values, then you get both explicit *and* expandable, without an
> arbitrary unneeded sequence.
> 

Do you mean by using the **kwargs parameter? If I do this, doesn't it 
mean that *anything* could be added though? Misspelled words and 
completely unrelated attributes as well?

Or does this matter as long as you are handling the processing yourself 
internally and not allowing users access to the Character class?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread robert
Ross Ridge wrote:
> Ross Ridge schrieb:
>> So give an example where reference counting is unsafe.
> 
> Martin v. Löwis wrote:
>> Nobody claimed that, in that thread. Instead, the claim was
>> "Atomic increment and decrement instructions are not by themselves
>> sufficient to make reference counting safe."
> 
> So give an example of where atomic increment and decrement instructions
> are not by themselves sufficent to make reference counting safe.
> 
>> I did give an example, in <[EMAIL PROTECTED]>.
>> Even though f_name is reference-counted, it might happen that you get a
>> dangling pointer.
> 
> Your example is of how access to the "f_name" member is unsafe, not of
> how reference counting being unsafe.  The same sort of race condition
> can without reference counting being involved at all.  Consider the
> "f_fp" member: if one thread tries to use "printf()" on it while
> another thread calls "fclose()", then you can have same problem.  The
> race condition here doesn't happen because reference counting hasn't
> been made safe, nor does it happen because stdio isn't thread-safe.  It
> happens because accessing "f_fp" (without the GIL) is unsafe.
> 
> The problem your describing isn't that reference counting hasn't been
> made safe.  What you and Joe seem to be trying to say is that atomic
> increment and decrement instructions alone don't make accessing shared
> structure members safe.

Yes.

To recall the motivation and have a real world example: 
The idea to share/handover objects between 2 (N) well separated Python 
interpreter instances (free-threading) with 2 different GILs.
There is of course the usage condition: * Only one interpreter may access (read 
& write) the hot (tunneled) object tree at a time *
 (e.g. application: a numeric calc and when finished (flag) the other 
interpreter walks again the objects directly (without MPI/pickling))

But a key problem was, that the other thread can have old pointer objects 
(containers) pointing into the hot object tree - an there is shared use of 
(immutable) singleton objects (None,1,2...): The old pointer objects in other 
interpreter may disapear at any time or the pointers maybe be doubled.
Thus the refcount of hot object will count down/up out of the interpreter which 
has not possession of the hot object tree -   even if the pointers are not used 
for write/read access.

Only and truly if you have atomic Py_INCREF/Py_DECREF this is no problem. 

Before all interpreters have lost the object there will be no accidental 
disapearance of the object as Ross Ridge already pointed out. 
In addition concurrent read access to _constant_ objects/sub-trees would be 
possible, and also concurrent read&write access by using an explicit locking! 
Thus the original OP requirements would be fulfilled.

See so far only 5 main additional requirements to offer the possibility of 
separated GILs/free-threading interpreters:

* pointer to current GIL in threadstate and dynamic PyThreadState_GET() / 
currentthreadstate in TLS

* locks for global objects (file etc) of course, if they should be supported 
therefore. (I'd use the free-threading only for mere computations)

* enable the already existing obmalloc.c/LOCK&UNLOCK by something fast like:
_retry:
  __asm   LOCK INC malloc_lock
  if (malloc_lock!=1) { LOCK DEC malloc_lock; /*yield();*/ goto _retry; } 

* a special (LOCK INC) locking dict type for the global dict of extension 
modules
  (created clearly by Py_InitModule(name, methods) - thus that would also 
preserve backwards compatibility for extension C-code)

* nice tunnel functions to create extra interpreters and for actually tunneling 
the objects and maybe offering the fast locking-dict type to enable a fast 
sharing of the hot tunneled object tree.

Speed costs? Probably not much as far as the discussion in this thread sounds...

Of course this option of 2 interpreters - though easy to use - would still be 
for power use cases only: A Python programming bug doing accidential unlocked 
concurrent access into a hot tunneled tree can cause a C-level crash.  (This 
cannot happen so far with simple Python threading - you'd only get inconsistent 
data or a Python exception. But of course you can crash already now at C-level 
by using the Python standard library  :-) ). 
That danger would be ok for me so far. Conceptually its not more complicated 
that using locks right in normal Python thread programming - only the effect of 
bugs will more critical ...

If one thinks about overcoming the GIL at all - we are probably not far away. 
Mainly:

* make the locking dict type (and locking list type) the common case - the 
non-locking obsolete or for optimization only

* lock some other non-constant types which are not already mainly dicts/lists. 
most objects which' access-functions only change INTEGERS etc and call 
threadsafe C-lib functions etc don't require extra locking

Maybe the separated-GIL/interpreter-method can be a bridge to that. 
Refcounting probably doen'

Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread robert
robert wrote:
> Martin v. Löwis wrote:
[..]
> 
> Thanks for that info. That is interesting.
> Thus even on x86 currently this LOCK is not used  (just
> (op)->ob_refcnt++) )
> 
> Reading this I got pinched: In win32ui there are infact Py_INC/DECREF's 
> outside of the GIL !
> And I have a severe crash problem with threaded apps - the problem is 
> only only on dual cores !
> That pointer probably will end a long search...

In fact that it was in win32ui. Months I've search the bug strainedly, and this 
fancy discussion revealed it :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread skip

Beliavsky> English is a rich language, and there are better ways of
Beliavsky> doing that.

aahz> Oh, gimme a fucking break.

I'm with Beliavsky on this one.  I can't see any particular reason to curse
in a forum such as c.l.py.  It just coarsens the discussion with no obvious
positive benefit as far as I can see.

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread robert
Sandra-24 wrote:
> On Nov 2, 1:32 pm, robert <[EMAIL PROTECTED]> wrote:
>> I'd like to use multiple CPU cores for selected time consuming Python 
>> computations (incl. numpy/scipy) in a frictionless manner.
>>
>> Interprocess communication is tedious and out of question, so I thought 
>> about simply using a more Python interpreter instances (Py_NewInterpreter) 
>> with extra GIL in the same process.
> 
> Why not use IronPython? It's up to date (unlike Jython), has no GIL,
> and is cross-platform wherever you can get .NET or Mono (UNIX, macs,
> windows) and you can use most any scientific libraries written for the
> .NET/Mono platform (there's a lot) Take a look anyway.
> 
> -Sandra

what about speed. Is it true that IronPython is almost as fast as C-Python 
meanwhile?

When this all is really true, its probably a proof that putting out 
LOCK-INC-lock's (on dicts, lists, mutables ...) in CPython to remove the GIL in 
future should not be really so expensive as it was teached in the past :-) 

Still to adopt to .NET libraries will be a big step. Is there really a thing 
out there as usable as numpy/scipy. And GUI programming in IronPython ...


( The FAQ's on codeplex.com and many docs are not readable currently due to 
site errors. What about overall stability and # of users of Iron as of today? )


-robert

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


Re: Delivering data to python from a c-thread

2006-11-08 Thread Steve Holden
Svein Seldal wrote:
> Hi,
> 
> I have a C-application that calls a Python function main(). This 
> function will loop forever and not return until the entire application 
> is about to terminate.
> 
> In a parallel C-thread, some data must be regularly delivered to the 
> running python application. My initial plan was to call a py function 
> deliver() from this thread, however I constantly run into troubles. I 
> keep getting a "Fatal Python error: ceval: tstate mix-up" error from 
> python, even when I handle the GIL with PyGILState_Ensure().
> 
> I fail to use PyEval_AcquireLock() prior to python call either, as the 
> main app would then constantly keep this lock when its running 
> permanently in python.
> 
> Basically I would the thread to stop the execution of the main py app, 
> call the message function deliver(). When the function returns from 
> python, resume the execution of the main pyapp.
> 

Could you have the Python code create a second Python thread and have it 
call back into the C code to collect any waiting data?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Python Error:IndentationError: expected an indented block

2006-11-08 Thread Steve Holden
Antonios Katsikadamos wrote:
> hi all. I try to run an old python code and i get the following message
> 
> File "/home/antonis/db/access.py", line 119
> def DoCsubnet1 (action, subject, target, args): # DoC 
> servers net
>   ^
> IndentationError: expected an indented block
> 
> 1) and I don't know what causes it. I would be grate full if you could 
> give me a tip.
> 
Typically you have a line ending in a colon (like an "if" or "for" 
statement) where the next line isn't at a higher indented level.

This is an indication that the code NEVER worked.

> 2) how can i overcome it? Can i use the keyword pass?and if how ccan i 
> use it
> 
You could just blindly add an indented pass statement, but there is of 
course no guarantee this will be what you require.

How long is the code? Would it be practical to publish it here? (If it's 
more than 200 lines assume the answer to that last question is "no").

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


PIL - Pixel Level Image Manipulation?

2006-11-08 Thread Gregory Piñero
I want to be able to randomly change pixels in an image and view the
results.  I can use whatever format of image makes this easiest, e.g.,
gray scale, bit tonal, etc.

Ideally I'd like to keep the pixels in an intermediate format like a
list of (integers?) or an array and convert that to an image as
needed.

I'm hoping someone has some experience on this and could offer some
advice or code.  I thought it would be easy in PIL  but I'm not sure.

Much Appreciated,

-- 
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Error:IndentationError: expected an indented block

2006-11-08 Thread jim-on-linux

try this

  def DoCsubnet1 (action, subject, target,
args): 
   pass



jim-on-linux
http://www.inqvista.com




On Wednesday 08 November 2006 10:47, Antonios 
Katsikadamos wrote:
> hi all. I try to run an old python code and i
> get the following message
>
>  File "/home/antonis/db/access.py", line 119
>  def DoCsubnet1 (action, subject, target,
> args): # DoC servers net ^
>  IndentationError: expected an indented block
>
>  1) and I don't know what causes it. I would be
> grate full if you could give me a tip.
>
>  2) how can i overcome it? Can i use the
> keyword pass?and if how ccan i use it
>
>
>  Kind regards,
>
>  Antonios
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread robert
Shane Hathaway wrote:
> of multiple cores.  I think Python only needs a nice way to share a
> relatively small set of objects using shared memory.  POSH goes in that
> direction, but I don't think it's simple enough yet.
> 
> http://poshmodule.sourceforge.net/

interesting, a solution possibly a little faster than pickling - but maybe only 
in selected situations. Made already experiments with pickling through shared 
memory.

With "x = posh.share(x)" an object tree will be (deep-)copied to shared mem ( 
as far as objects fullfil some conditions 
http://poshmodule.sourceforge.net/posh/html/node6.html: is this true for numpy 
arrays?)
Every object to be inserted in the hot tunnel object tree has to be copied that 
same style. Thus ~pickling, but somewhat easier to use.

And compiling it for Windows will be quite difficult ...

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Cliff Wells
On Wed, 2006-11-08 at 06:49 -0800, Beliavsky wrote:
> Cliff Wells wrote:

> > The LA Times had a story that claimed that 64% of U.S. citizens use the
> > word "fuck" and that 74% of us have heard it in public (I'll assume the
> > remainder are your fellow AOL users).  I expect extrapolating these
> > results worldwide wouldn't be far off the mark (the Brits were quite
> > successful at spreading this versatile word).
> 
> If this is supposed to justify using bad language in a public forum, it
> is poorly reasoned. Having heard "f***" does not mean they were not
> annoyed. 
> 100% of people have seen trash on the street, but that does
> not justify littering. 

Poorly reasoned or not, it was clearly poorly read, since the article I
mentioned also claimed that the majority of people also used the word.
Odd, I'd think with your selective reading skills you'd simply be able
to ignore words you don't like.

Regardless, I think the idea that certain words are profanity is fairly
silly.  They are words.  It's the meaning and intent behind them that
can be offensive.  If someone says "fuck off" then I'd expect you to be
offended *since that was the intent of the message* (of course if you
manage to not be offended then that makes you the better man, but
apparently that's rarely strived for).  On the other hand if someone
says "that's fucking great" in a positive way and you are offended by
it, well I'd say that's *your* problem and your best bet is to turn off
your TV, your PC, your radio, stop reading and try to limit interactions
with other people lest you be overwhelmed by how they really speak and
act.

> If a group of people don't mind profanity, there
> is no harm in their swearing to each other. But Usenet is read by a
> wide range of people, and needlessly offending some of them is wrong.

I halfway agree with you.  I tend to limit my profanity in public forums
and when speaking to strangers, etc.  On the other hand, when in public
I also expect to hear that language from others and am not offended by
it.  

And expecting anyone to escape without offense on Usenet is pretty
unrealistic.

> The OP used "f**" just for emphasis. English is a rich language,
> and there are better ways of doing that.

Hm, lots of people disagree with you.  In fact, simply because that word
*does* happen to be less widely used in this group it gave it extra
emphasis and was probably the most effective word he could have used in
this particular instance.  I don't think anyone here will have forgotten
his endorsement anytime soon.

Incidentally, using  to disguise "profanity" when the intended word
is perfectly understood is pretty silly too.  I strongly suspect you'd
be just as offended if I said "f*** off" as if I'd typed it out.  Once
again, intent and meaning are what matter rather than a particular
sequence of characters.

Regards,
Cliff

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread BartlebyScrivener

[EMAIL PROTECTED] wrote:

> I'm with Beliavsky on this one.  I can't see any particular reason to curse
> in a forum such as c.l.py.  It just coarsens the discussion with no obvious
> positive benefit as far as I can see.

All true. But it's like picking your nose. Yes, it's bad manners in
public, but if somebody does it, why jump on it and call attention to
it? It just makes the thread three times longer. It's easier and more
efficient to just ignore it.

I say this after posting three messages on the topic :)

rd

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


Re: Exception Handling in TCPServer (was; Problem exiting application in Windows Console.)

2006-11-08 Thread Ant

Ant wrote:
...
> OK, I've narrowed the problem back to the way HTTPServer (actually its
> TCPServer parent) handles exceptions thrown by the process_request
> method by catching them all, and then calling a handle_error method.
> There doesn't seem to be a way of getting at the exception thrown
> however - does anyone know how I can get this information?

Hmm. Lonely topic ;-)

I've found a way to solve the problem, by creating a subclass of
HTTPServer which overrides the handle_error method:

class HelpServer(HTTPServer):
def handle_error(self, request, client_address):
exception_line = inspect.trace()[-1][-2][0]
if "sys.exit" in exception_line:
print "Trying to exit again!"
sys.exit(0)
else:
HTTPServer.handle_error(self, request, client_address)

This seems a really nasty hack though - any ideas for a cleaner way to
do it?

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread sturlamolden
robert wrote:

> I'd like to use multiple CPU cores for selected time consuming Python 
> computations (incl. numpy/scipy) in a frictionless manner.

Threading is not the best way to exploit multiprocessors in this
context. Threads are not the preferred way of exploiting multiple
processors in scientific computing.

here are a few thoughts on the matter:

1. SciPy uses ATLAS/BLAS and LAPACK. You can compile these libraries
for SMPs. The same goes for FFTW, vendor optimized math kernels, etc.
If most of the CPU time is spent inside these numeric libraries, using
multi-processor versions of these libraries are a much better strategy.

2. The number of CPUs are not the only speed limiting factor on an SMP.
Use of cache and prefetching are just as important. That can make
multi-processor aware numeric libraries a lot more efficient than
manual multi-threading.

3. One often uses cluster architectures (e.g. Beowulf) instead of SMPs
for scientific computing. MPI works on SMP and clusters. Threads only
work on SMPs.

4. Fortran compilers can recognize parallel array statements in
Fortran90/95 and exploit multiple processors on an SMP automatically.
NumPy should be able to to the same when it matures. E.g. if you make a
statement like "arr[1,::] = arr[2,::] * arr[3,::]", then this statement
could be evaluated in parallel on multiple CPUs, without any
multi-threading on your part. Since the order in which the
multiplications are performed are of no significance, the work can just
as well be spread out to multiple processors in an SMP or a cluster.
NumPy is still immature, but Fortran compilers have done this at least
two decades.

5. Streaming SIMD extensions (SSE) and similar opcodes: Are you aware
that Pentium III (and newer) processors are pipe-lined to do four
floating-point operations in parallel? You could theoretically
quadruple your flops using the SSE registers, using no threading at
all. (The actual improvement is slightly less, due to some extra
book-keeping required to get the data in and out of the SSE registers.)
Again this requires modifications inside NumPy, not multi-threading.

> If not, would it be an idea to create such thing in the Python std libs to 
> make Python multi-processor-ready. I guess Python will always have a GIL - 
> otherwise it would loose lots of comfort in threaded programming

I would say that the GIL actually has very little effect of Python's
potential in high-performance numeric and scientific computing. It all
depends on the libraries, not on Python per se. Threading is for making
certain tasks more comfortable to write, not so much for computational
speed.

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


Re: Delivering data to python from a c-thread

2006-11-08 Thread Svein Seldal
Steve Holden wrote:

> Could you have the Python code create a second Python thread and have it 
> call back into the C code to collect any waiting data?

Well yeah, in principle. However one would need some synchronization 
mechanisms anyway. The C data source is generating asynch. messages to 
deliver to python and thus the py thread must be ready to wait for it. 
It will add another thread in the total application (cuz' I cant remove 
the extra C thread since it has other important tasks), but I'll give it 
a shot at least!

Regards
Svein Seldal
-- 
http://mail.python.org/mailman/listinfo/python-list


Strange re problem on OSX but Not Linux

2006-11-08 Thread Brian
I have a very small script:

import re

text = open('eq.txt','r').read()
regex = '[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]'
pattern = re.compile(regex)
match = pattern.findall(text)

print ''.join(match)

However, when I try to run it, I get this error:

Traceback (most recent call last):
  File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/bin/pydbgp", line
66, in 
import dbgp.client
  File
"/Applications/Komodo.app/Contents/SharedSupport/dbgp/pythonlib/dbgp/client.py",
line 44, in 
import traceback, re
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in 
#
AttributeError: 'module' object has no attribute 'compile'

---
Here is the error outside of Komodo:

Traceback (most recent call last):
  File "reg1.py", line 1, in 
import re
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 5, in 
#
AttributeError: 'module' object has no attribute 'compile'
--

This is running 2.5 on my OSX box.  If I run it (again with 2.5) on my
SUSE machine, I get no errors.

I am sure that I have overlooked something trivial here - so please be
gentle if it is on the stupid side of things.

Thanks,
Brian

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread Paul Rubin
robert <[EMAIL PROTECTED]> writes:
> what about speed. Is it true that IronPython is almost as fast as C-Python 
> meanwhile?
> 
> When this all is really true, its probably a proof that putting out
> LOCK-INC-lock's (on dicts, lists, mutables ...) in CPython to remove
> the GIL in future should not be really so expensive as it was teached
> in the past :-)

I don't think IronPython uses locks that way.  AFAIK it doesn't use
reference counts, and relies on user-supplied synchronization to keep
stuff like dictionaries safe.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Carl J. Van Arsdall
BartlebyScrivener wrote:
> Chaz Ginger wrote:
>
>   
>>> it is supposed to be about PYTHON. Get it?
>>>   
>
> I agree. And Python is an extremely serious matter calling for decorum
> and propriety.
>   
Lol, is it really now?  And I suppose its your definition of decorum and 
not mine right?  Things like that are always relative.  I think decorum 
would state that you should be an adult and not make a big deal out of 
nothing.  But that's just me, and as I said, its all relative.

(and honestly, if you thought the word fuck was bad, you should really 
be offended by my profanity-free statement above).

-c


-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Cliff Wells
On Wed, 2006-11-08 at 10:12 -0800, Carl J. Van Arsdall wrote:
> BartlebyScrivener wrote:

> > I agree. And Python is an extremely serious matter calling for decorum
> > and propriety.
> >   
> Lol, is it really now?  And I suppose its your definition of decorum and 
> not mine right?  Things like that are always relative.  I think decorum 
> would state that you should be an adult and not make a big deal out of 
> nothing.  But that's just me, and as I said, its all relative.

I think you missed the irony in his statement (or perhaps confused
BartlebyScrivener with Beliavsky, who was the original plaintiff).

Regards,
Cliff

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


is this the right way to do subclasses?

2006-11-08 Thread John Salerno
Ok, back to my so-called "game." I'm just curious if I've implemented 
the subclasses properly, because it seems like an awful lot of 
repetition with the parameters. And again, if I want to add a new 
attribute later, I'd have to change a lot of things. I can't help but 
get the feeling that I'm doing something very inefficiently.

Thanks!



class Character(object):

 def __init__(self, name, strength, dexterity, intelligence):
 self.name = name
 self.health = 10
 self.strength = strength
 self.dexterity = dexterity
 self.intelligence = intelligence


class Fighter(Character):

 def __init__(self, name, strength, dexterity, intelligence):
 Character.__init__(self, name, strength, dexterity, intelligence)
 self.health += 2
 self.strength += 1


class Thief(Character):

 def __init__(self, name, strength, dexterity, intelligence):
 Character.__init__(self, name, strength, dexterity, intelligence)
 self.health += 1
 self.dexterity += 1


class Mage(Character):

 def __init__(self, name, strength, dexterity, intelligence):
 Character.__init__(self, name, strength, dexterity, intelligence)
 self.intelligence += 1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread olsongt

BartlebyScrivener wrote:
> Chaz Ginger wrote:
>
> >> it is supposed to be about PYTHON. Get it?
>
> I agree. And Python is an extremely serious matter calling for decorum
> and propriety.
>
> Don't say fuck, ni, peng, or ni-wom.
>
> http://en.wikipedia.org/wiki/Knights_who_say_Ni
>
> rd

Does using foobar in examples count as profanity?

http://en.wikipedia.org/wiki/Foobar

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


Re: unpickling Set as set

2006-11-08 Thread Gabriel G

At Wednesday 8/11/2006 05:26, George Sakkis wrote:


Or you may have this done automatically by hacking the Set class:

from sets import Set
import cPickle as pickle

Set.__reduce__ = lambda self: (set, (self._data,))

s = Set([1,2,3])
x = pickle.dumps(s)
print pickle.loads(x)


This doesn't work though if you have already pickled the Set before
replacing its __reduce__, so it may not necessarily be what you want.
If there is a way around it, I'd like to know it.


Perhaps registering a suitable reduce function in the copy_reg module.
If the sets were pickled alone, and it's not too much trouble, using: 
a_set = set(a_set) just after unpickling may be enough.
And if they were instance attributes, __setstate__ on the class can 
do the conversion.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PIL - Pixel Level Image Manipulation?

2006-11-08 Thread Michael L Torrie
On Wed, 2006-11-08 at 11:53 -0500, Gregory Piñero wrote:
> I want to be able to randomly change pixels in an image and view the
> results.  I can use whatever format of image makes this easiest, e.g.,
> gray scale, bit tonal, etc.
> 
> Ideally I'd like to keep the pixels in an intermediate format like a
> list of (integers?) or an array and convert that to an image as
> needed.
> 
> I'm hoping someone has some experience on this and could offer some
> advice or code.  I thought it would be easy in PIL  but I'm not sure.

What OS are you using and what GUI library?  These things are specific
to the GUI library you wish to use to display images, and not python
itself (which doesn't care).

> 
> Much Appreciated,
> 
> -- 
> Gregory Piñero
> Chief Innovation Officer
> Blended Technologies
> (www.blendedtechnologies.com)

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Carl J. Van Arsdall
Cliff Wells wrote:
> On Wed, 2006-11-08 at 10:12 -0800, Carl J. Van Arsdall wrote:
>   
>> BartlebyScrivener wrote:
>> 
>
>   
>>> I agree. And Python is an extremely serious matter calling for decorum
>>> and propriety.
>>>   
>>>   
>> Lol, is it really now?  And I suppose its your definition of decorum and 
>> not mine right?  Things like that are always relative.  I think decorum 
>> would state that you should be an adult and not make a big deal out of 
>> nothing.  But that's just me, and as I said, its all relative.
>> 
>
> I think you missed the irony in his statement (or perhaps confused
> BartlebyScrivener with Beliavsky, who was the original plaintiff).
>
>   

Ah, yea, you are right.  My apologies.

-c


-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


How to choose the right GUI toolkit ?

2006-11-08 Thread Dan Lenski
Hi all,
I'm a recent, belated convert from Perl.  I work in a physics lab and
have been using Python to automate a lot of measurement equipment
lately.  It works fabulously for this purpose.  Recently I've wanted to
start writing GUIs for some of my programs, for data visualization and
to make the programs easier to use for some of my co-workers.

So far I've experimented with two Python GUI toolkits: Tkinter and
PyGTK.  I've had some issues with each:

* PyGTK - not very "pythonic", in my opinion.  Have to use get_ and
set_ methods rather than properties.  Have to write ugly things like
textview.insert(textview.get_end_iter(), ...) to append text to a text
buffer.  No useful doc strings, which makes experimenting with new
widgets in IPython a huge pain.  The toolkit feels very "heavyweight".
I don't want to write an XML file and an "action group" just to make a
piddly little menubar with 10 items.

I'm an avid Gnome fan, and love the professionalness and completeness
of GTK, but PyGTK seems frustratingly C-like compared to the
wonderfully designed high-level abstractions I've come to love in
Python!

* TkInter - Seems easy to learn, and better for quick "lightweight"
GUIs.  I wrote a complete working instrument GUI in less than a day of
figuring things out.  Not very Pythonic in terms of creating and
modifying widgets.  No factory functions to quickly create menu items.
My biggest problem with Tkinter is that it is very unreliable under
Cygwin: programs freeze and slow intermittently and the tkMessageDialog
stock dialog boxes show no visible text.

So, is there another toolkit I should be looking at?  Having something
that can run easily on Cygwin and native Windows is a priority so that
I can quickly move programs to new measurement computers.  I like GTK a
lot and Tk is growing on me too.. are there any higher-level "wrapper"
toolkits for GTK and Tk?

Thanks for any advice!

Dan Lenski
University of Maryland

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Paddy

Aahz wrote:
> In article <[EMAIL PROTECTED]>,
> Beliavsky <[EMAIL PROTECTED]> wrote:
> >
> >If this is supposed to justify using bad language in a public forum,
> >it is poorly reasoned. Having heard "f***" does not mean they were not
> >annoyed. 100% of people have seen trash on the street, but that does
> >not justify littering. If a group of people don't mind profanity, there
> >is no harm in their swearing to each other. But Usenet is read by a
> >wide range of people, and needlessly offending some of them is wrong.
> >The OP used "f**" just for emphasis. English is a rich language,
> >and there are better ways of doing that.
>
> Oh, gimme a f** break.  Do a simple Gooja search to find out how
> often people already use "f***" around here.  I think you're the one who
> needs to justify your position.
> --
> Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/
>
I too know your wrong Aahz. The written word is not the same as that
spoken. People should make an effort to put across their meaning in a
clear manner. If I were going to an interview I would be very careful
about swearing and most likely not do it. People complain about the
friendliness and tone of groups, and mention it when talking about
programming languages.

Not everyone swears like Eddy Murphy in Beverley Hills Cop, and a lot
of those that do, would not do so when they want to impress, or
communicate with a stranger.

The tone of comp.lang.python *is* an asset, I think, to Python that
swearing will diminish.

- Paddy.

P.S. I did a google search and found 540,000 hits for python in c.l.p.
and only 121 for f***. thats less than one in a thousand. Lets keep it
that way please.

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


Re: How to choose the right GUI toolkit ?

2006-11-08 Thread John Salerno
Dan Lenski wrote:

> So, is there another toolkit I should be looking at?

I highly recommend wxPython. It's very mature, full-featured, and 
portable, and fairly easy to learn as well. I can't really compare it to 
other toolkits (not having used any of them, except Tkinter), but it's 
definitely one of the most popular and well-supported ones out there.

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


Dispatcher experiment

2006-11-08 Thread egbert
As an exercise in the use of dispatcher 
I concocted a Zoo with some Animals, see below.
It works, but I think it is convoluted, obfuscated.

The idea is that in the Zoo each animal needs its own type of food,
and the Zoo should acknowledge a wish for that food,
as soon as the animal says it wants food.
The number and kind of animals (and their food) may vary.

The general problem is that you may have an unspecified number
of instances of some type, and that each instance must be recognized
and handled by the specific signal it sends into the world.

I would appeciate any comments or improvements on my design.
In a python shell you may test it with:
import dip
zoo = dip.Zoo()
zoo.animals["fish"].send_food_wish()

egbert

#!/usr/bin/env python
# dip.py := experiment with Patrick O'Brien's dispatcher 

import wx.py.dispatcher as disp

class Animal(object):
def __init__(self, animal_food):
self.animal_food = animal_food

def send_food_wish(self):
# started by some event outside this class.
disp.send(signal=self.animal_food, sender=self)

class Zoo(object):
def __init__(self):
# dummies for some gui that accepts names of animals and their food:
animal_list  = ["bird",  "lion", "fish"]
food_list= ["bread", "meat", "plankton"]

# zoo administration: register animals and their food;
self.animals = {}
for animal,food in zip(animal_list, food_list):
animal_food_signal = (animal, food)
self.animals[animal] = Animal(animal_food_signal)
disp.connect(self.listen_to_food_wish, signal=animal_food_signal)

def listen_to_food_wish(self, signal, sender=disp.Any):
print "sender %s is %s and wishes to eat %s now" % \
  (sender, signal[0], signal[1])

if __name__ == '__main__':
zoo = Zoo()
for animal in zoo.animals.values():
animal.send_food_wish()
-- 
Egbert Bouwman - Keizersgracht 197 II - 1016 DS  Amsterdam - 020 6257991

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


Re: Delivering data to python from a c-thread

2006-11-08 Thread Steve Holden
Svein Seldal wrote:
> Steve Holden wrote:
> 
>> Could you have the Python code create a second Python thread and have it 
>> call back into the C code to collect any waiting data?
> 
> Well yeah, in principle. However one would need some synchronization 
> mechanisms anyway. The C data source is generating asynch. messages to 
> deliver to python and thus the py thread must be ready to wait for it. 
> It will add another thread in the total application (cuz' I cant remove 
> the extra C thread since it has other important tasks), but I'll give it 
> a shot at least!
> 
OK. I was just thinking that, with Python threads, communication using 
Queue.Queue is thread-safe and will handle the GIL, so that way you only 
have the problem of how to synchronize your C code when it receives the 
callback from the Python thread.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread sturlamolden

sturlamolden wrote:

> 3. One often uses cluster architectures (e.g. Beowulf) instead of SMPs
> for scientific computing. MPI works on SMP and clusters. Threads only
> work on SMPs.

Following up on my previous post, there is a simple Python MPI wrapper
that can be used to exploit multiple processors for scientific
computing. It only works for Numeric, but an adaptaion to NumPy should
be easy (there is only one small C file in the source):

http://datamining.anu.edu.au/~ole/pypar/

If you are using Windows, you can get a free implementation of MPI
here:

http://www-unix.mcs.anl.gov/mpi/mpich1/mpich-nt/

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


Re: Exception Handling in TCPServer (was; Problem exiting application in Windows Console.)

2006-11-08 Thread Steve Holden
Ant wrote:
> Ant wrote:
> 
>> OK, I've narrowed the problem back to the way HTTPServer (actually its
>> TCPServer parent) handles exceptions thrown by the process_request
>> method by catching them all, and then calling a handle_error method.
>> There doesn't seem to be a way of getting at the exception thrown
>> however - does anyone know how I can get this information?
> 
> Hmm. Lonely topic ;-)
> 
> I've found a way to solve the problem, by creating a subclass of
> HTTPServer which overrides the handle_error method:
> 
> class HelpServer(HTTPServer):
> def handle_error(self, request, client_address):
> exception_line = inspect.trace()[-1][-2][0]
> if "sys.exit" in exception_line:
> print "Trying to exit again!"
> sys.exit(0)
> else:
> HTTPServer.handle_error(self, request, client_address)
> 
> This seems a really nasty hack though - any ideas for a cleaner way to
> do it?
> 
First of all, five hour response time is a high expectation, you must be 
a Platinum customer :-)

Secondly, while a try/except catching all exceptions *is* unusual it's 
justifiable in a server context (though some logging and/or analysis 
certainly wouldn't go amiss).

Thirdly your "ugly hack" *could* be replaced by something cleaner with 
more analysis of the trace structure, but given how infrequently this 
code is going to run and the low probability that anything else will 
trigger the hook I'd be happy with it as it is. But that's just me ...

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Problem getting a file pathname with tkFileDialog

2006-11-08 Thread cdroulers
Hello,
I am working on a school project that requires me to get the path of a
filename for future treatment.
I've tried getting a file with tkFileDialog.askopenfile.



import tkFileDialog
file = tkFileDialog.askopenfile()
print file



It prints the opened files stuff, but I just can not find how to get
that path as a string. I've searched around google and the present
group, and found no documentation on the file class used with
tkFileDialog. Does someone have a solution for that?

Thank you

Christian

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


Re: is this the right way to do subclasses?

2006-11-08 Thread Farshid Lashkari
John Salerno wrote:
> Ok, back to my so-called "game." I'm just curious if I've implemented 
> the subclasses properly, because it seems like an awful lot of 
> repetition with the parameters. And again, if I want to add a new 
> attribute later, I'd have to change a lot of things. I can't help but 
> get the feeling that I'm doing something very inefficiently.

Just accept variable arguments in the constructor of the sub-classes and 
forward them to the base class.

class Fighter(Character):

 def __init__(self, *args, **kw):
 Character.__init__(self, *args, **kw)
 self.health += 2
 self.strength += 1

This way, if you add a new parameter to the base class, you won't need 
to update all the derived classes.

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


Re: Exploiting Dual Core's with Py_NewInterpreter's separated GIL ?

2006-11-08 Thread sturlamolden

sturlamolden wrote:

> http://www-unix.mcs.anl.gov/mpi/mpich1/mpich-nt/

One should probably use this instead:

http://www-unix.mcs.anl.gov/mpi/mpich2/index.htm

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


Re: profanity on comp.lang.python (was Re: Pyro stability)

2006-11-08 Thread Carl J. Van Arsdall
Paddy wrote:
> Aahz wrote:
>   
>> In article <[EMAIL PROTECTED]>,
>> Beliavsky <[EMAIL PROTECTED]> wrote:
>> 
>>> If this is supposed to justify using bad language in a public forum,
>>> it is poorly reasoned. Having heard "f***" does not mean they were not
>>> annoyed. 100% of people have seen trash on the street, but that does
>>> not justify littering. If a group of people don't mind profanity, there
>>> is no harm in their swearing to each other. But Usenet is read by a
>>> wide range of people, and needlessly offending some of them is wrong.
>>> The OP used "f**" just for emphasis. English is a rich language,
>>> and there are better ways of doing that.
>>>   
>> Oh, gimme a f** break.  Do a simple Gooja search to find out how
>> often people already use "f***" around here.  I think you're the one who
>> needs to justify your position.
>> --
>> Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/
>>
>> 
> I too know your wrong Aahz. The written word is not the same as that
> spoken. People should make an effort to put across their meaning in a
> clear manner. If I were going to an interview I would be very careful
> about swearing and most likely not do it. People complain about the
> friendliness and tone of groups, and mention it when talking about
> programming languages.
>
> Not everyone swears like Eddy Murphy in Beverley Hills Cop, and a lot
> of those that do, would not do so when they want to impress, or
> communicate with a stranger.
>
> The tone of comp.lang.python *is* an asset, I think, to Python that
> swearing will diminish.
>   
You are comparing interviews to usenet.  I somehow see a disconnect.  I 
don't think many people are going to go to a potential employer and say 
"hey fuck face, how the fuck are ya?"  Yea, its not likely to happen, in 
most cases people might even dress up to an interview and use all of 
their professionalisms as to not appear as they would at home.  However 
communicating with people (cause that's what this is, its just people 
talking to one another about Python and the health of this forum) should 
be done as people see fit.  Although you mentioned impressing people 
etc,  is it really important to impress people here by watching your P's 
and Q's?  What impresses me here is someone's command of the language, I 
could really give a rats ass how they choose to disseminate their 
expertise. 

As its been mentioned before, its one thing for me or anyone else to get 
in someone's face and be like "listen you little fuck, use a while 
loop."  But that was clearly not the context.  Using an expletive as an 
adjective does not diminish the "friendless" of the group unless you are 
complete prude.  Granted, there are tons of them, I think that the real 
issue is that people need to learn to ignore things they don't like and 
not be so *damn* sensitive.  Meaning is clearly conveyed, people's 
sensitivity is their own issue and I think too many people have gotten 
way to used to the political correctness shoved down our throats by 
society.  Again, that's just my take on it, but those of you who would 
be offended by my statements and use of colorful language to describe my 
love of technology should probably just adjust your spam filters to scan 
for my name or emails that use words you can't handle.  Its kind of like 
not watching tv shows that bother as opposed to raising a stink and 
having them taken off the air. 

Hopefully now the count is more like 124.

/rant

-- 

Carl J. Van Arsdall
[EMAIL PROTECTED]
Build and Release
MontaVista Software

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


Re: Cactching Stdout

2006-11-08 Thread Gabriel Genellina

At Wednesday 8/11/2006 06:09, Massi wrote:


Hi everyone! I'm writing a python script which uses a C-written dll. I
call the functions in the dll using ctypes, but I don't know how to
catch the output of the "printf" which the C functions use. In fact I
don't even know if it is possible! I've heard something about PIPE and
popen...is this what I need? How can I use them? It is very important
for me that I could take the output in real-time.


Since you are calling a function the same process, popen&co won't help.
This is just an idea; printf is writting to STDOUT; you could replace 
STDOUT with the write end of a pipe, and read from the other end.



--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

  1   2   3   >