ExcelMailer 0.2

2007-12-23 Thread mario ruggier
It is a pleasure to announce this first public release of ExcelMailer.

ExcelMailer is a small os-independent command line business tool for 
emailing personalized messages with attachments. Data and options are 
specified via an Excel file and the message content via plain text or 
HTML file templates. For each data row in the Excel file ExcelMailer 
prepares and sends, when explicitly requested, a personalized MIME 
email message and its attachments if any.

Highlights:

- The text message may be in plain text or in HTML or in both i.e. in 
HTML with an alternative plain text version.
- May define any number of data columns (only to is required) that are 
then all accessible in the message templates with ${ column heading }.
- Rich and flexible set of options, that may be conveniently saved in 
the Excel file itself as well as be explicitly overridden on the 
command line.
- Automatic recognition of input text encodings. Output text is always 
encoded in UTF-8.
- Extensive data validation before sending any messages. No emails are 
sent unless explicitly requested and all data checks pass. No error 
goes silent.
- Data rows can be tagged, for test runs or selective re-runs.
- All actions, such as sending of an email, are logged to a file named 
${ excel file }.log, placed alongside the Excel file.

Special thanks to John Machin, for the xlrd package, to Bryan 
Niederberger, for his recipe making using xlrd even easier, and to Skip 
Montanaro, for some sample code to facilitate handling of input 
encodings.

ExcelMailer is GPL3-licensed, and is available from:

 http://gizmojo.org/software/excelmailer/

Any and all comments, problem reports, suggestions welcome!

Thanks and all the best,

mario

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

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


Re: Modify arguments between __new__ and __init__

2007-12-23 Thread Arnaud Delobelle
On Dec 23, 5:03 am, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
 When you call a new-style class, the __new__ method is called with the
 user-supplied arguments, followed by the __init__ method with the same
 arguments.

 I would like to modify the arguments after the __new__ method is called
 but before the __init__ method, somewhat like this:

  class Spam(object):

 ...     def __new__(cls, *args):
 ...             print __new__, args
 ...             x = object.__new__(cls)
 ...             args = ['spam spam spam']
 ...             return x
 ...     def __init__(self, *args):
 ...             print __init__, args  # hope to get 'spam spam spam'
 ...             return None

 but naturally it doesn't work:

  s = Spam('spam and eggs', 'tomato', 'beans are off')

 __new__ ('spam and eggs', 'tomato', 'beans are off')
 __init__ ('spam and eggs', 'tomato', 'beans are off')

 Is there any way to do this, or am I all outta luck?

 --
 Steven

The ususal way is to override the __call__ method of the metaclass.

HTH

--
Arnaud

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


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Akihiro KAYAMA

Thanks for your replies.

In article [EMAIL PROTECTED],
Arnaud Delobelle [EMAIL PROTECTED] writes:

arnodel def f1():
arnodel print f1 start
arnodel yield f2,
arnodel print f1 foo
arnodel v = yield f2,
arnodel print f1 v=%s world % v
arnodel yield f2, OK
arnodel print f1 end
arnodel 
arnodel def f2():
arnodel print f2 start
arnodel yield f1,
arnodel print f2 bar
arnodel result = yield f1, Hello, 
arnodel print f2 result=%s % result
arnodel print f2 end
arnodel yield f1,

This is the most simple example. In real programming, things are more
complicate so I will want to refactor it like below:

def foo(fiber, s, arg=None)
print s
return yield fiber, arg

def f1():
foo(f2, start)# XXX returns generator object
v = foo(f2, foo)
foo(f2, v=%s world % v, OK)

But current Python generator specification requires me:

def f1():
for x in foo(f2, foo): yield x
for x in foo(f2, foo): yield x
# XXX v = ... (I don't know how to do this)
for x in foo(f2, v=%s world % v, OK): yield x

I think it is not straitforward. Single level function which generator
impose is impractical for real use.

In article [EMAIL PROTECTED],
Duncan Booth [EMAIL PROTECTED] writes:

duncan.booth Unfortunately generators only save a single level of stack-frame, 
so they 
duncan.booth are not really a replacement for fibers/coroutines. The OP should 
perhaps 
duncan.booth look at Stackless Python or Greenlets. See 
duncan.booth http://codespeak.net/py/dist/greenlet.html

I am happy if I could use convenient coroutine features via standard
or simple extension library.  py.magic.greenlet may be what I'm
looking for, but I wonder why this is named magic :-)

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


Re: Detecting memory leaks on apache, mod_python

2007-12-23 Thread Ilias Lazaridis
On Dec 23, 2:47 am, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
 On Sat, 22 Dec 2007 13:05:23 -0800, Dennis Lee Bieber wrote:
  I've never encountered such items
  supported by the language.

 OS specific extensions MIGHT supply it...

 Picky picky... but of course you are right. When I said that programming
 languages I have used before had facilities to measure memory usage, I
 meant that the *implementation* had those facilities rather than the
 language itself.


yes, that's what this thread is about.


I'm really just looking for a low-level python (memory) profiling
tool, and thus i'm asking in c.l.p. for experiences, mainly in context
of an apache mod_python environment.


But seeing the responses within this thread, it looks like there's no
such tool available.

.

http://case.lazaridis.com/wiki/PythonAudit
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inter-process communication, how? Part 2

2007-12-23 Thread Guilherme Polo
2007/12/22, [EMAIL PROTECTED] [EMAIL PROTECTED]:
 Hello,

 just to recap: last time I asked how to do an interprocess
 communitation, between one Manager process (graphical beckend) and
 some Worker processes.

 I decided to go with sockets, thanks for replies, once more.

 However, I would like to ask another thing: I would like to collect
 everyting what the Workers print and display in Manager. Or, redirect
 all Workers' stdout to stdio of Manager. If there was only one Worker
 I could use a pipe, right? But if there are more than one Worker, what
 to do? I found something called named pipe which seems rather
 complicated.

Named pipe is called FIFO, but they are not that complicated.

 Then I thought I could somehow (how?) create a fake
 (virtual) file object,

That is why it is called named pipe, because you will be using a
(especial) file in your filesystem to use as a pipe.

 redirect stdout of a Worket into it and from
 there send the data to Manager via sockets. Please, what do you think?

 Preferably, it should look like this:

 --- Worker 1 ---
 ...some code...
 print '123'

 --- Manager ---
 Worker 1: 123

 --- Worker 2 ---
 ...some code...
 print '456'

 --- Manager ---
 Worker 1: 123
 Worker 2: 456

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


Manager would create and open the FIFO, Workers would open this same
FIFO. So workers write to FIFO and the manager reads from FIFO.

-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Element bug?(ElementTree)

2007-12-23 Thread Fredrik Lundh
limodou wrote:

 I don't know if it's a bug? Try below code:
 
   from elementtree.ElementTree import Element
   a = Element('a')
   if a:
  ... print ''
  ...
   a.__len__()
  0
 
 You can see if I test a, the result will be False. I don't know if
 it's an expected result, but this thing has beaten me some times.

http://effbot.org/zone/element.htm#truth-testing

/F

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


Re: 5 queens

2007-12-23 Thread cf29
To make it simple and not have to deal with the 8 queens problem that
is different with the 5 queens one, I'll ask in a different way.

I am not familiar with implementing in Python such terms as standard
depth-first search of the solution space, permutation, recursion,
'canonical' form, ... I couldn't find the Wolffram site's Dudeney
reference.

How would you write a function that will populate a list with a list
of numbers with all the possibilities? For example a list of 3 numbers
taken among 4 [0,1,2,3] without duplicates. The result should be:
[0,1,2]
[0,1,3]
[0,2,3]
[1,2,3]

I would apply this to my problem by adding conditions.
Thanks again for your help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Local variables in classes and class instantiation

2007-12-23 Thread A.J. Bonnema
Hi all,

I just started using Python. I used to do some Java programming, so I am 
not completely blank.

I have a small question about how classes get instantiated within other 
classes. I have added the source of a test program to the bottom of this 
mail, that contains 3 methods within a testclass that each instantiate 
the same class and bind it to a local variable. My understanding was, 
that the local variable gets garbage collected as soon as the method 
goes out of scope. Thus I would expect the local variable 'cpu' in these 
methods to be independant and create different instances of the class CPU.

Still, when I execute all three methods, I get two instances that are 
equal and the third is different.
Is there some circomstance that makes two object creations result in the 
same object?

= output
Output from the (test)program is:
cpu class = cpu.CPU instance at 0x8244eec
.cpu class = cpu.CPU instance at 0x8244eec
.cpu class = cpu.CPU instance at 0x8244f0c
.
--
Ran 3 tests in 0.001s

OK
=== source
The source of the test program is:

import sys
import unittest
from cpu import CPU

class cpuAddEntries(unittest.TestCase):
 def testEmptyCPU(self):
 Test empty CPU.
 expected={}
 cpu = CPU(cpu01)
 print cpu class = +repr(cpu)
 result = cpu.showTimes()
 self.assertEquals(expected,result)
 def testOneEntry(self):
 Test one entry into CPU
 time = 
 expected={'%s': ('user', 'system')} % time
 cpu = CPU(cpu02)
 print cpu class = +repr(cpu)
 cpu.addMetric (time, user, system)
 result = cpu.showTimes()
 self.assertEquals(expected,result)
 def testDuplicate(self):
 Test inserting a duplicate entry.
 global exceptions
 time = 
 expected={'%s': ('user', 'system')} % time
 cpu = CPU(cpu03)
 print cpu class = +repr(cpu)
 cpu.addMetric (time, user, system)
 self.assertRaises(Exception, cpu.addMetric, time, user1, 
system1)

if __name__ == __main__:
 unittest.main()

-- 
A.J. Bonnema, Leiden The Netherlands,
user #328198 (Linux Counter http://counter.li.org)

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


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Duncan Booth
Akihiro KAYAMA [EMAIL PROTECTED] wrote:

 Thanks for your replies.
 
 But current Python generator specification requires me:
 
 def f1():
 for x in foo(f2, foo): yield x
 for x in foo(f2, foo): yield x
 # XXX v = ... (I don't know how to do this)
 for x in foo(f2, v=%s world % v, OK): yield x
 
 I think it is not straitforward. Single level function which generator
 impose is impractical for real use.

Not just impractical, there are plenty of situations where you simply
cannot do that at all. 

Here's a greenlet example (from
http://socal-piggies.org/presentations/grig/2005_07_21/): 

from py.magic import greenlet
import xml.parsers.expat

def send(arg):
greenlet.getcurrent().parent.switch(arg)

def start_element(name, attrs):
send(('START', name, attrs))
def end_element(name):
send(('END', name))
def char_data(data):
data = data.strip()
if data: send(('DATA', data))

def greenparse(xmldata):
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = char_data
p.Parse(xmldata, 1)

def iterxml(xmldata):
g = greenlet(greenparse)
data = g.switch(xmldata)
while data is not None:
yield data
data = g.switch()

if __name__ == __main__:
for data in iterxml(somexmldata):
# do something with data


The greenlet here calls expat, but the 'yield' happens inside an expat
callback. To get this to work you would need to rewrite expat to use its
callback as a generator. Expat is coded in C, so you also need to find
some way to get it to save the state of the C functions when it has
yielded. 

I think this example should answer Arnaud's question (In fact it is not
clear to me at the moment what can be done (sensibly :) with the OP's
Fiber class that cannot be achieved with the run() function I
suggested.) Arnaud's run function cannot be used by anything which needs 
to save C stack state.

 I am happy if I could use convenient coroutine features via standard
 or simple extension library.  py.magic.greenlet may be what I'm
 looking for, but I wonder why this is named magic :-)

I think it is called magic because it does something which is at first 
glance impossible: saving the C stack state as well as the Python stack. 
Possibly it does something underhand to achieve an impressive effect.
I haven't looked at the implementation to see how it does it: creating 
threads and then scheduling them cooperatively would be one way but I 
expect it just switches the C stack around between different areas of 
memory.

A long time ago I ported the BCPL coroutine library and there is one 
function in the middle (the one which does the stack switch) that 
definitely felt like magic.

One interesting question raised by all this is whether those of us using 
Windows can usefully call Microsoft's Fiber functions through ctypes and 
get the benefit of coroutines without having to load any additional C 
extensions at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Local variables in classes and class instantiation

2007-12-23 Thread Matt Nordhoff
A.J. Bonnema wrote:
 Hi all,
 
 I just started using Python. I used to do some Java programming, so I am 
 not completely blank.
 
 I have a small question about how classes get instantiated within other 
 classes. I have added the source of a test program to the bottom of this 
 mail, that contains 3 methods within a testclass that each instantiate 
 the same class and bind it to a local variable. My understanding was, 
 that the local variable gets garbage collected as soon as the method 
 goes out of scope. Thus I would expect the local variable 'cpu' in these 
 methods to be independant and create different instances of the class CPU.
 
 Still, when I execute all three methods, I get two instances that are 
 equal and the third is different.
 Is there some circomstance that makes two object creations result in the 
 same object?
 
 = output
 Output from the (test)program is:
 cpu class = cpu.CPU instance at 0x8244eec
 .cpu class = cpu.CPU instance at 0x8244eec
 .cpu class = cpu.CPU instance at 0x8244f0c
 .
 --
 Ran 3 tests in 0.001s
 
 OK
 === source
 The source of the test program is:
 
 snip

What if the second object is separate, but just gets allocated at the
same location as the first one?

Try printing some unique attribute of each object, like the one that
stores the cpuXX argument that gets passed in.
-- 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing by reference

2007-12-23 Thread MartinRinehart


Dennis Lee Bieber wrote:
 Great if one is using a teletype as editor

The original Dartmouth computer room was a basement that featured 8
teletypes.

The original BASIC, Dennis, was implemented on a time-shared
mainframe with a gigantic 8k words (20-bit words, if I remember) of
core memory.  Designing a language for such a machine, I'd bet you,
too, would choose single-letter names. ('A' was a numeric. 'A$' a
string.)

If you compare the teletype to a tube it was lame. But that's not the
right comparison. The Fortran technology was cards, punched on a card
punch, carried to the operator. Wait your turn (hours more commonly
than minutes). Get a report off the line printer. Repunch the
offending cards.

Indeed, the teletype with line numbers was a giant step forward. No
operator. No waiting. Compiler complains. Retype the offending line. A
miracle in its day. You didn't even have to start your statements in
column 7!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Local variables in classes and class instantiation

2007-12-23 Thread Peter Otten
A.J. Bonnema wrote:

 I have a small question about how classes get instantiated within other 
 classes. I have added the source of a test program to the bottom of this 
 mail, that contains 3 methods within a testclass that each instantiate 
 the same class and bind it to a local variable. My understanding was, 
 that the local variable gets garbage collected as soon as the method 
 goes out of scope. Thus I would expect the local variable 'cpu' in these 
 methods to be independant and create different instances of the class CPU.
 
 Still, when I execute all three methods, I get two instances that are 
 equal and the third is different.
 Is there some circomstance that makes two object creations result in the 
 same object?
 
 = output
 Output from the (test)program is:
 cpu class = cpu.CPU instance at 0x8244eec
 .cpu class = cpu.CPU instance at 0x8244eec
 .cpu class = cpu.CPU instance at 0x8244f0c
 .

That two instances of CPU print the same at 0x... representation doesn't
mean they are the same object, they may just be located at the same
location in memory. For that to happen it is neccessary (but not
sufficient) for the first instance to be garbage-collected.

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


Re: Passing by reference

2007-12-23 Thread MartinRinehart


Bruno Desthuilliers wrote:
 [EMAIL PROTECTED] a �crit :
 
  Bruno Desthuilliers wrote:
 
 ...  that's definitively not
 something I'd store in global.
 
 
  So where would you put it?

 You don't have to put functions arguments anywhere - they're already
 local vars.

Bruno, right now I've got this:

def __init__ ( self, t ):
 Constructor, called with array of strings. 

self.text = t
...

Some other program will say:
tok = Toker( text_array )
tokens = tok.tokenize()

So how does the constructor make the array of strings available to the
tokenize() method?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Inter-process communication, how? Part 2

2007-12-23 Thread ecir . hana
On Dec 23, 4:54 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Sat, 22 Dec 2007 17:56:05 -0800 (PST), [EMAIL PROTECTED] declaimed
 the following in comp.lang.python:

  just to recap: last time I asked how to do an interprocess
  communitation, between one Manager process (graphical beckend) and
  some Worker processes.

 Never considered a graphical control process as a backend
 before... Backend processing, to me, implies some sort of server without
 a user interface.

  However, I would like to ask another thing: I would like to collect
  everyting what the Workers print and display in Manager. Or, redirect
  all Workers' stdout to stdio of Manager. If there was only one Worker
  I could use a pipe, right? But if there are more than one Worker, what
  to do? I found something called named pipe which seems rather
  complicated. Then I thought I could somehow (how?) create a fake
  (virtual) file object, redirect stdout of a Worket into it and from
  there send the data to Manager via sockets. Please, what do you think?

 I'd forget about stdout as a data communication means... The parent
 should probably set up a socket that accepts messages from any worker...
 or create a reply socket for each worker, and pass the worker the port
 on which the master expects to retrieve its output.

Ok, but how to redirect print statement into a socket?


 Named pipes are, I think, a M$ Windows creation (though I think
 the Amiga supported disjoint pipes by using run program pipe:name and
 program pipe:name instead of program | 
 programhttp://stason.org/TULARC/pc/amiga/faq/2-5-1-Using-PIPE-in-a-standard-...
 -- run program being ~ program  in most UNIX-based shells)
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

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


Re: Inter-process communication, how? Part 2

2007-12-23 Thread ecir . hana
On Dec 23, 10:30 am, Guilherme Polo [EMAIL PROTECTED] wrote:
 2007/12/22, [EMAIL PROTECTED] [EMAIL PROTECTED]:

  Hello,

  just to recap: last time I asked how to do an interprocess
  communitation, between one Manager process (graphical beckend) and
  some Worker processes.

  I decided to go with sockets, thanks for replies, once more.

  However, I would like to ask another thing: I would like to collect
  everyting what the Workers print and display in Manager. Or, redirect
  all Workers' stdout to stdio of Manager. If there was only one Worker
  I could use a pipe, right? But if there are more than one Worker, what
  to do? I found something called named pipe which seems rather
  complicated.

 Named pipe is called FIFO, but they are not that complicated.

  Then I thought I could somehow (how?) create a fake
  (virtual) file object,

 That is why it is called named pipe, because you will be using a
 (especial) file in your filesystem to use as a pipe.



  redirect stdout of a Worket into it and from
  there send the data to Manager via sockets. Please, what do you think?

  Preferably, it should look like this:

  --- Worker 1 ---
  ...some code...
  print '123'

  --- Manager ---
  Worker 1: 123

  --- Worker 2 ---
  ...some code...
  print '456'

  --- Manager ---
  Worker 1: 123
  Worker 2: 456

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

 Manager would create and open the FIFO, Workers would open this same
 FIFO. So workers write to FIFO and the manager reads from FIFO.

 --
 -- Guilherme H. Polo Goncalves

What I don't like about FIFO, is that on Unix they are persistent
files. So whatever happens to Manager they would stay there...
I was just wondering if there's another way of doing the above and if
not, I would probably go with FIFO. Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modify arguments between __new__ and __init__

2007-12-23 Thread Steven D'Aprano
On Sat, 22 Dec 2007 23:01:50 -0700, Steven Bethard wrote:

 Steven D'Aprano wrote:
 When you call a new-style class, the __new__ method is called with the
 user-supplied arguments, followed by the __init__ method with the same
 arguments.
 
 I would like to modify the arguments after the __new__ method is called
 but before the __init__ method, somewhat like this:

[snip]

 You can really only achieve this by writing a metaclass.  When a new
 object is created, what's first called is the __call__ method of the
 type object.  This basically looks like::

[snip]


That's an excellent explanation of how to use metaclasses!

Thanks Steve, and everyone else who answered. I'm not yet sure if that's 
the approach I'm going to use (I may end up moving all the instance code 
into __new__, or __init__, rather than splitting it) but that's an 
interesting option for me to explore.


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


Re: 5 queens

2007-12-23 Thread Steven D'Aprano
On Sun, 23 Dec 2007 02:22:38 -0800, cf29 wrote:

 How would you write a function that will populate a list with a list of
 numbers with all the possibilities? For example a list of 3 numbers
 taken among 4 [0,1,2,3] without duplicates. The result should be:
 [0,1,2]
 [0,1,3]
 [0,2,3]
 [1,2,3]

What you are asking for is the combinations of the list, taking 3 
elements at a time. Try using this generator:

def combinations(seq, n):
if n == 0:
yield []
else:
for i in xrange(len(seq)):
for cc in combinations(seq[i+1:], n-1):
yield [seq[i]]+cc


 for c in combinations(range(4), 3):
... print c
...
[0, 1, 2]
[0, 1, 3]
[0, 2, 3]
[1, 2, 3]


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


Re: Element bug?(ElementTree)

2007-12-23 Thread limodou
On Dec 23, 2007 5:30 PM, Fredrik Lundh [EMAIL PROTECTED] wrote:
 limodou wrote:

  I don't know if it's a bug? Try below code:
 
from elementtree.ElementTree import Element
a = Element('a')
if a:
   ... print ''
   ...
a.__len__()
   0
 
  You can see if I test a, the result will be False. I don't know if
  it's an expected result, but this thing has beaten me some times.

 http://effbot.org/zone/element.htm#truth-testing

 /F

Thanks. What I done just as that.

-- 
I like python!
UliPad The Python Editor: http://code.google.com/p/ulipad/
meide wxPython UI module: http://code.google.com/p/meide/
My Blog: http://www.donews.net/limodou
-- 
http://mail.python.org/mailman/listinfo/python-list


Python DLL in Windows Folder

2007-12-23 Thread Markus Gritsch
Hi,

why does the Python installer on Windows put the Python DLL into the
Windows system32 folder?  Wouldn't it be more clean to place it into
the Python installation folder beside the python.exe file?

Kind regards,
Markus
-- 
http://mail.python.org/mailman/listinfo/python-list


Unicode Regular Expressions

2007-12-23 Thread bryan rasmussen
Hi,

I'm writing a program that requires specifically Unicode regular
expressions http://unicode.org/reports/tr18/ to be loaded in from an
external file and then interpreted against the data.  if I use Python
Regular expressions is there a flag I can set to specify that the
regular expressions that are loaded from the file conform to Unicode
regular expressions. What problems can be expected using Unicode Regex
with Python, is there a library I should be using?

Cheers,
Bryan Rasmussen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Michael Sparks
Duncan Booth wrote:

 Unfortunately generators only save a single level of stack-frame, so they
 are not really a replacement for fibers/coroutines. The OP should perhaps
 look at Stackless Python or Greenlets. See

On the surface of things, the single level aspect *LOOKS* like a problem,
but in fact is actually really useful. The reason is because it encourages
a generator to be relatively simple and focused encouraging reuse.

cf the components listed here:
   * http://kamaelia.sourceforge.net/Components

Also, because they're simple, you can link every component in that list
either directly with all the others or via a trivial filtering component.

Also the fact that you have to build your own scheduler means you can do the
equivalent of saying to the scheduler Don't run me next, run this next.
This gives you pretty much the full power of co-routines but allows for
very heavy reusability and independence of testing. 

An example application that makes moderate use of this bounce back
coroutines is a greylisting server you can find here:
   * http://kamaelia.sourceforge.net/KamaeliaGrey

I'd (almost) argue that the single level aspect of generators is perhaps
their best feature.


Michael.
--
http://yeoldeclue.com/blog
http://kamaelia.sourceforge.net/Developers/


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


Re: Inter-process communication, how? Part 2

2007-12-23 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:
 What I don't like about FIFO, is that on Unix they are persistent
 files. So whatever happens to Manager they would stay there...

Nope. /tmp exists. Many distributions delete /tmp contents on
reboot.

 I was just wondering if there's another way of doing the above and
 if not, I would probably go with FIFO. Thanks!

Didn't you write you went with sockets?

Regards,


Björn

-- 
BOFH excuse #354:

Chewing gum on /dev/sd3c

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


Re: Inter-process communication, how? Part 2

2007-12-23 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:
 Ok, but how to redirect print statement into a socket?

Create an object that has the socket's send-or-what-it's-called
method as a member called write and bind this object to
sys.stdout. Alternatively, you can use the print text  object
syntax (see language reference).

Regards,


Björn

-- 
BOFH excuse #116:

the real ttys became pseudo ttys and vice-versa.

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


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Michael Sparks
Hi,


 It just works, but using native Python threads for non-preemptive
 threading is not cost-effective. Python has generator instead but it
 seemed to be very restricted for general scripting. I wish I could
 write nested (generator) functions easily at least.
 
 Is there any plan of implementing real (lightweight) fiber in Python?

Please take a look at Kamaelia. Generators work extremely well, and are
extremely useful to work with:

   * http://kamaelia.sourceforge.net/Home

(I need to update/improve the website...)

If you *must* have nested generators (it's rarely useful) you can do that,
but just need to have your thing running the generators understand
a don't run me next, run this next message. Our message is called
WaitComplete, and you can see it used here (in a non-trivial useful
system):

https://kamaelia.svn.sourceforge.net/svnroot/kamaelia/branches/private_MPS_Scratch/Apps/Kamaelia-Grey/App/greylisting.py

(I could point at trivial examples, but prefer something real)

The shortest overall description is here:
   * http://kamaelia.sourceforge.net/t/TN-LightTechnicalIntroToKamaelia.pdf

Cookbook examples:
   * http://kamaelia.sourceforge.net/Cookbook

List of dozens of reusable (all with each other) components:
   * http://kamaelia.sourceforge.net/Components

How to build your own (non-optimised) core:
   * http://kamaelia.sourceforge.net/MiniAxon/

Ruby (mini) version:  (for comparison :-)
https://kamaelia.svn.sourceforge.net/svnroot/kamaelia/trunk/Code/Ruby/miniaxon.rb

Experimental process based (as well as thread  generator based) version:

http://yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=viewpostnodeid=1196129474

(Going to move to process based components for static segmentation of an
application across process boundaries to give explicit multicore support.
May move to automatic distribution at some point, but static is an easy win
as the above example shows :-)

It's not as lightweight as stackless python's microthreads, but it's pretty
close. The scaling style is pretty similar as well - cf:

http://www.rhonabwy.com/wp/2007/11/13/generator-based-concurrent-programming-in-python/
I also blogged about that here:
http://yeoldeclue.com/cgi-bin/blog/blog.cgi?rm=viewpostnodeid=1195688924

(Someone curious about comparing Kamaelia to stackless. Interesting to see
the same scaling curve, but unsurprisingly stackless wins :-) Kamaelia
however works with standard python from version 2.2.late onwards :-) )

Interestingly recently discovered that Kamaelia's been slowly reinventing a
system the UK's MOD have been using for around 30 years to make concurrent
systems easier to build (mascot) :-)

Merry Christmas :-)


Michael
--
http://yeoldeclue.com/blog
http://kamaelia.sourceforge.net/Developers/

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


Re: Passing by reference

2007-12-23 Thread Marc 'BlackJack' Rintsch
On Sun, 23 Dec 2007 03:10:48 -0800, MartinRinehart wrote:

 Bruno, right now I've got this:
 
 def __init__ ( self, t ):
  Constructor, called with array of strings. 
 
 self.text = t
 ...
 
 Some other program will say:
 tok = Toker( text_array )
 tokens = tok.tokenize()
 
 So how does the constructor make the array of strings available to the
 tokenize() method?

Assuming the `__init__()` above belongs to the `Toker` class then the
`tokenize()` method can access it via `self.text` of course.

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


Re: Inter-process communication, how? Part 2

2007-12-23 Thread John Nagle
[EMAIL PROTECTED] wrote:
 Hello,
 
 just to recap: last time I asked how to do an interprocess
 communitation, between one Manager process (graphical beckend) and
 some Worker processes.
 
 I decided to go with sockets, thanks for replies, once more.
 
 However, I would like to ask another thing: I would like to collect
 everyting what the Workers print and display in Manager. Or, redirect
 all Workers' stdout to stdio of Manager. If there was only one Worker
 I could use a pipe, right? But if there are more than one Worker, what
 to do? I found something called named pipe which seems rather
 complicated. Then I thought I could somehow (how?) create a fake
 (virtual) file object, redirect stdout of a Worket into it and from
 there send the data to Manager via sockets. Please, what do you think?

  Take a look at

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296

which does this.  I wouldn'd do it quite that way; read the notes
on the article for some criticism.  But it's an approach that works.

  One can get fancier.  I wrote a system under QNX where each
real time process had its text output labeled, timestamped, and transmitted
using QNX interprocess communication to a lower priority logging process
on a different machine.  Text output never blocked; if a queue
filled, ... appeared in the log file.  That's a special real-time situation.

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


Re: Python DLL in Windows Folder

2007-12-23 Thread Thorsten Kampe
* Markus Gritsch (Sun, 23 Dec 2007 15:52:50 +0100)
 why does the Python installer on Windows put the Python DLL into the
 Windows system32 folder?

Are you sure it does?!

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


Re: Unicode Regular Expressions

2007-12-23 Thread Jim
Have you googled?

http://www.google.com/search?hl=enq=python+regular+expression+unicodebtnG=Google+Search
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python DLL in Windows Folder

2007-12-23 Thread Markus Gritsch
On 23/12/2007, Thorsten Kampe [EMAIL PROTECTED] wrote:
 * Markus Gritsch (Sun, 23 Dec 2007 15:52:50 +0100)
  why does the Python installer on Windows put the Python DLL into the
  Windows system32 folder?

 Are you sure it does?!

Yes.

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


why does a disabled button respond to clicks

2007-12-23 Thread damonjulian
hi ,i created 3 buttons such that if button1 is clicked it will
disable button2 ,and clicking button3 will restore state of button2 to
normal,

to my dismay i find that button2 still responds to clicks even if it
is greyed out

here is the code..am i doing something wrong? is there a way to truly
disable the button?



class MyApp:
def __init__(self,parent):
self.mainframe=Frame(parent)
self.mainframe.pack()

#self.canvorig=Canvas(self.mainframe,width=100,height=200)
#self.canvorig.pack()
self.button1=Button(self.mainframe,bg=green)
self.button1.configure(text=1)
self.button1.pack(side=LEFT)
self.button1.bind(Button-1,self.buttonClick1)
self.button2=Button(self.mainframe,bg=yellow)
self.button2.configure(text=2)
self.button2.pack(side=LEFT)
self.button2.bind(Button-1,self.buttonClick2)
self.button3=Button(self.mainframe,bg=red)
self.button3.configure(text=3)
self.button3.pack(side=RIGHT)
self.button3.bind(Button-1,self.buttonClick3)

def buttonClick1(self,event):
print ok clicked
self.button2.configure(state=disabled)
self.button2.update_idletasks()

def buttonClick2(self,event):
print 2 clicked

def buttonClick3(self,event):
print 3 clicked
self.button2.configure(state=normal)
self.button2.update_idletasks()

root = Tk()
myapp = MyApp(root)
root.mainloop()

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


Re: Python DLL in Windows Folder

2007-12-23 Thread Christian Heimes
Markus Gritsch wrote:
 why does the Python installer on Windows put the Python DLL into the
 Windows system32 folder?  Wouldn't it be more clean to place it into
 the Python installation folder beside the python.exe file?

It's the easiest and best way to expose Python for 3rd party
applications and COM. The DLL is removed by the Windows Installer when
its usage counter drops to 0. There is no need to worry ;)

Christian

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


Re:Re: Output buffer

2007-12-23 Thread Cesar D. Rodas
On 22/12/2007, Fredrik Lundh [EMAIL PROTECTED] wrote:

 Cesar D. Rodas wrote:

  I am newbie in Python, but I like it very much.
 
  Right now I am having a problem, I am working with mod_python in apache.
  What I needing is a stdout buffering, that means that everything that I
  send to stdout keep it in a variable, then flush it and clear.

 plug in a StringIO instance on sys.stdout, or use (or adapt) a library
 designed for this purpose:

  http://www.mnot.net/cgi_buffer/


hum, seems working right if I'll code  but what about if I want to print the
content of the function help() (which print and return nothing) into a
website?

Can I inherit the class system and override the output?

/F

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




-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python DLL in Windows Folder

2007-12-23 Thread Markus Gritsch
On 23/12/2007, Christian Heimes [EMAIL PROTECTED] wrote:
 Markus Gritsch wrote:
  why does the Python installer on Windows put the Python DLL into the
  Windows system32 folder?  Wouldn't it be more clean to place it into
  the Python installation folder beside the python.exe file?

 It's the easiest and best way to expose Python for 3rd party
 applications and COM. The DLL is removed by the Windows Installer when
 its usage counter drops to 0. There is no need to worry ;)

I am not worrying about an orphaned DLL.  The Problem is that this way
the Python DLL is being made available for 3rd party applications,
which possibly need a version of Python which is compiled using
another compiler.  We are embedding Python into our application which
gets compiled using MSVC 8.0.  We like to link dynamically, so the
Python interpreter is not statically linked into the program.  The
Python DLL from the Python installer in the Windows system32 folder is
compiled using MSVC 7.1.

Our current solution to the problem is modifying the Python build
process to produce our Python DLL with a filename containing also the
patchlevel of the version number i.e. python251.dll instead of
python25.dll.  This way we can be sure that *our* Python DLL gets
loaded.  This works fine.

I was just curious, if there is a special reason for placing the
Python DLL into the system32 folder.  So COM seems to be the answer.

Thank you,
Markus
-- 
http://mail.python.org/mailman/listinfo/python-list


Releasing malloc'd memory using ctypes?

2007-12-23 Thread skip
I am starting to experiment with ctypes.  I have a function which returns a
pointer to a struct allocated in heap memory.  There is a corresponding free
function for that sort of struct, e.g.:

from ctypes import *

cdll.LoadLibrary(libthing.so)
c_thing = CDLL(libthing.so)

class THING(Structure):
_fields_ = [(name, c_char_p),
(value, c_int)]

get_thing = c_thing.get_thing
get_thing.restype = POINTER(THING)
free_thing = c_thing.free_thing

So I call get_thing() and get back this ctypes wrapper for a pointer to a
thing.  I can extract the name and value elements from the thing instance
just fine:

thing_p = get_thing()
thing = thing_p.contents
print thing.name, =, thing.value

Now I need to call free_thing.  What do I pass it?  thing_p?  Some attribute
of thing_p?  Something else altogether?  The ctypes module docs seem to be
strangely silent on the question of freeing heap memory which you've
received from the underlying library's functions.

Thanks,

Skip

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


=?UTF-8?Q?=E2=96=BA=E2=96=BA=E2=96=BA_Earn_MILLIONS_online, _working_One_Hour_a_D?= AY ◄◄◄

2007-12-23 Thread sandy
Would you like a side-income of 1000's of Dollars a month?

YES, This is possible if you have the skills to trade Forex.

AND you can do all this without monitoring the market constantly.

The Website listed below is tailored to both the new as well as the
intermediate trader.

In it, you will learn

:: How the Forex market works,
:: How to Profit from it, with as little as an hour a day of work.

And Above ALL you get $50 bonus to TRADE FOREX ONLINE.

For Further Details: http://forexzing.gigacities.net
-- 
http://mail.python.org/mailman/listinfo/python-list


clearing selection in Tix.FileSelectBox

2007-12-23 Thread [EMAIL PROTECTED]
hello
i am creating a Tix.FileSelectBox to select some jpeg files
on clicking an OK button i wish to get the selected imagename as
string ,so i code like below


class TixGUI:
def __init__(self, parent):

self.imgsel=FileSelectBox(self.bgframe)
self.imgsel.configure(pattern=*.jp*)
self.imgsel.pack(side=LEFT)

self.okButton = Button(self.bgframe,text=OK)
self.okButton.bind(Button-1,self.okbuttonClick)
self.okButton.pack(side=LEFT )

def  okbuttonClick(self,event):
 self.cursel=self.imgsel.selection.cget(value)
  print selected image::,self.cursel

here if i select an imagefile say sh1.jpg and click ok..it will print
the imagefilename..BUT if i just select a folder next and don't choose
any imagefile ,it will still print the previous value of sh1.jpg..

i managed to set the selection to  by adding a
self.imgsel.selection.__setitem__(value,)
 to the end of  okbuttonClick(self,event).. but i want to know if this
is the correct way .or is there another way to clear the selection?

thanx in adv
dn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: exception message output problem

2007-12-23 Thread Florian Diesch
Lie [EMAIL PROTECTED] wrote:


 # Python have an odd (read: broken) singleton implementation
 # single member tuple must have a comma behind it

Otherwise (1+2)+(3+4) would evaluate to (3, 7) instead of 10.

   Florian
-- 
http://www.florian-diesch.de/
---
**  Hi! I'm a signature virus! Copy me into your signature, please!  **
---
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Duncan Booth
Michael Sparks [EMAIL PROTECTED] wrote:

 Duncan Booth wrote:
 
 Unfortunately generators only save a single level of stack-frame, so
 they are not really a replacement for fibers/coroutines. The OP
 should perhaps look at Stackless Python or Greenlets. See
 
 On the surface of things, the single level aspect *LOOKS* like a
 problem, but in fact is actually really useful. The reason is because
 it encourages a generator to be relatively simple and focused
 encouraging reuse. 
 

Ah, perhaps Python should similarly limit function call nesting to one 
level so as to keep things simple and encourage reuse.
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQL-python Error

2007-12-23 Thread Steve Ametjan
I've been trying to get MySQL-python to install on Leopard for the  
past couple of days, and I keep running into relatively the same  
error. I'm hoping that someone on this list will be able to help me  
out in solving the issue. I'd like to get this solved so I can  
continue developing with Django using MySQL since that's what my web  
server uses as well. I'd hate to have to develop using a different  
database engine on my local machine.

Here's what happens when I try to do an easy_install:

W8743145X91:~ stevea$ sudo easy_install MySQL-python
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python
Reading http://sourceforge.net/projects/mysql-python/
Best match: MySQL-python 1.2.2
Downloading 
http://osdn.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
Processing MySQL-python-1.2.2.tar.gz
Running MySQL-python-1.2.2/setup.py -q bdist_egg --dist-dir /tmp/ 
easy_install-DYH0yq/MySQL-python-1.2.2/egg-dist-tmp-zpJkox
In file included from _mysql.c:35:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining  
SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining  
SIZEOF_LONG = 4
/usr/include/mysql/my_config.h:1151:1: warning: WORDS_BIGENDIAN  
redefined
In file included from /System/Library/Frameworks/Python.framework/ 
Versions/2.5/include/python2.5/Python.h:8,
  from pymemcompat.h:10,
  from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.5/include/ 
python2.5/pyconfig.h:928:1: warning: this is the location of the  
previous definition
In file included from /usr/include/mysql/mysql.h:43,
  from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in  
declaration specifiers
In file included from _mysql.c:35:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining  
SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining  
SIZEOF_LONG = 4
In file included from /usr/include/mysql/mysql.h:43,
  from _mysql.c:40:
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’
/usr/include/sys/types.h:92: error: two or more data types in  
declaration specifiers
lipo: can't open input file: /var/tmp//ccg4YkGM.out (No such file or  
directory)
error: Setup script exited with error: command 'gcc' failed with exit  
status 1

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


Re: How to get Python to default to UTF8

2007-12-23 Thread Martin v. Löwis
 However, the situation is still unacceptable to me because I often make 
 mistakes and it is easy for me to miss places where encoding is necessary. I 
 rely on testing to find my faults. On my development environment, I get no 
 error message and it seems that everything works perfectly. However, once 
 ported to the server, I see a crash. But this is too late a stage to catch 
 the error since the app is already live.

If you want to check whether there is indeed no place where you forgot
to properly .encode, you can set the default encoding on your
development machine to undefined (see site.py). This will give you an
exception whenever the default encoding is invoked, even if the encoding
would have succeeded under the default default encoding (ie. ascii)

Such a setting should not be applied a production environment.

 Can you elaborate on where to look to see what stdin/stdout encodings are 
 set to?

Just print out sys.stdin.encoding and sys.stdout.encoding. Or were you
asking for the precise source in the interpreter that sets them?

 All inputs are coming at my app either via html forms or input 
 files. All output goes either to the browser via html or to an output file.

Then sys.stdout.encoding will not be set to anything.

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


Re: Unicode Regular Expressions

2007-12-23 Thread Martin v. Löwis
 I'm writing a program that requires specifically Unicode regular
 expressions http://unicode.org/reports/tr18/ to be loaded in from an
 external file and then interpreted against the data.  if I use Python
 Regular expressions is there a flag I can set to specify that the
 regular expressions that are loaded from the file conform to Unicode
 regular expressions. 

It's not supported in the standard re module. Contributions are welcome.

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


Re: Python DLL in Windows Folder

2007-12-23 Thread Ross Ridge
Markus Gritsch [EMAIL PROTECTED] wrote:
... We are embedding Python into our application which
gets compiled using MSVC 8.0.  We like to link dynamically, so the
Python interpreter is not statically linked into the program.  The
Python DLL from the Python installer in the Windows system32 folder is
compiled using MSVC 7.1.

If you're targetting Windows XP or newer you can use manifests to force
Windows to link your application with a particular version of the DLL.
On Windows 98SE or newer you can use .local files to force Windows to
link with whatever DLLs are in the same directory as your executable.

Our current solution to the problem is modifying the Python build
process to produce our Python DLL with a filename containing also the
patchlevel of the version number i.e. python251.dll instead of
python25.dll.  This way we can be sure that *our* Python DLL gets
loaded.  This works fine.

I'd give it a more unique name, like companyname_python25_1_msvc80.dll.
That gives you more certainty that it is actually your DLL.  You also
won't have to worry if your users copied python251.dll to the system
directory when you upgrade to Visual Studio 2008.

Ross Ridge

-- 
 l/  //   Ross Ridge -- The Great HTMU
[oo][oo]  [EMAIL PROTECTED]
-()-/()/  http://www.csclub.uwaterloo.ca/~rridge/ 
 db  //   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Michael Sparks
Duncan Booth wrote:

 Michael Sparks [EMAIL PROTECTED] wrote:
 
 Duncan Booth wrote:
 
 Unfortunately generators only save a single level of stack-frame, so
 they are not really a replacement for fibers/coroutines. The OP
 should perhaps look at Stackless Python or Greenlets. See
 
 On the surface of things, the single level aspect LOOKS like a
 problem, but in fact is actually really useful. The reason is because
 it encourages a generator to be relatively simple and focused
 encouraging reuse.
 
 
 Ah, perhaps Python should similarly limit function call nesting to one
 level so as to keep things simple and encourage reuse.

Bit of a grumpy response?  ... and a straw man argument ? Generators can be
used to build co-operative multitasking (eg WSGI is implicitly co-op
multitasking), whereas function calls are used to build sequential code. I
agree for sequential code generators being single level can be rather
limiting. However, the thread is about co-operative multitasking. 

Decades of experience has shown that the best way to build concurrent
systems (MASCOT[1], Unix, MPI, Occam, Erlang, even VHDL  some mashups)
is to have small things loosely connected. Generators encourage making
little things which then encourages connecting them together. It seems,
to me, to help. (Which is all I said really)

[1] Only recently heard about MASCOT - best reference is here:
http://async.org.uk/Hugo.Simpson/
(MASCOT is over 30 years old... (fun thing of the week that I've been
 pointed at for me :-) )

It's the same basic ethos that makes Unix pipelines useful, and is why
WSGI is useful. Simple transformational things which work best when they're
pipelined together. The fact that you can't trivially nest generators in a
way that feels nice[2] IMO naturally encourages making small things, which
end up being reusable. 

   [2] I don't personally feel for i in X(): yield i is particularly nice.

To be clear - I REALLY didn't like the fact that generators were single
layer when I first saw them - it seemed a huge limitation. (Indeed as huge
a limitation as only having single level function calls, or only single
layer of nesting for namespaces, etc)... I even asked a question [3] on
that point before choosing python to write Kamaelia in... The fact that
it's been a benefit rather than a problem rather surprised me.

[3]
http://groups.google.com/group/comp.lang.python/tree/browse_frm/thread/fcd2709952d23e34/8a0b9ba0e3beb108

That's rather different from the recursion limit (which is a limit on
function call depth) that really *has* been a pain at times. (Something
which tail recursion would really help with)

Incidentally, you may note that you helped me back then (which I'm thankful
for :-), so you can kinda view this as me reporting back actually, it's
turned out to be helpful rather than a pain :-) Took a while to figure
that out though ;)

Your mileage may vary :)

Incidentally, it was probably your response (message 7) in that thread
that was responsible for me deciding to see where things could go by
trying python :-)

Merry Christmas,


Michael. (hoping that's a suitably positive response :-)
--
http://yeoldeclue.com/blog
http://kamaelia.sourceforge.net/Developers/

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


Re: fiber(cooperative multi-threading)

2007-12-23 Thread Martin v. Löwis
 Is there any plan of implementing real (lightweight) fiber in Python?

I have no such plan, and I don't know of anybody else's plan, either.

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


Re: How to get Python to default to UTF8

2007-12-23 Thread John Nagle
weheh wrote:
 Hi Fredrik,
 
 Thanks again for your feedback. I am much obliged.
 

Bear in mind that in Python, ASCII currently means ASCII, values
0..127.  Type str will accept values  127.  However, the default
conversion from str to unicode requires true ASCII values, in
0..127.  So if you take in data from some source which might have
a byte value  127, the default conversion to Unicode won't work.

There are conversion functions for specifying the meaning of
values 128..255, (the input might be latin1 encoding, for
example), or ignoring unexpected characters, or converting them
to ?.

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


convert pdf to png

2007-12-23 Thread Carl K
I need to take the take the pdf output from reportlab and create a preview 
image 
for a web page.  so png or something.  I am sure ghostscript will be involved. 
I am guessing PIL or ImageMagic ?

all sugestions welcome.

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


Happy Christmas Pythoneers

2007-12-23 Thread Paddy
After quite enjoying participating in the group in 2007, I'd like to
wish you all a Merry Xmas.

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


Re: Happy Christmas Pythoneers

2007-12-23 Thread rishi pathak
Is santa clause subscribed to the list .
I want a gift:)

On 12/24/07, Paddy [EMAIL PROTECTED] wrote:

 After quite enjoying participating in the group in 2007, I'd like to
 wish you all a Merry Xmas.

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




-- 
Regards--
Rishi Pathak
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Happy Christmas Pythoneers

2007-12-23 Thread Cesar D. Rodas
On 24/12/2007, rishi pathak [EMAIL PROTECTED] wrote:

 Is santa clause subscribed to the list .
 I want a gift:)


Me too!, :-)

On 12/24/07, Paddy [EMAIL PROTECTED] wrote:
 
  After quite enjoying participating in the group in 2007, I'd like to
  wish you all a Merry Xmas.
 
  - Paddy.
  --
  http://mail.python.org/mailman/listinfo/python-list
 



 --
 Regards--
 Rishi Pathak


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




-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165
-- 
http://mail.python.org/mailman/listinfo/python-list

[issue1690] Crash on cancellation of windows install

2007-12-23 Thread mtvernon

New submission from mtvernon:

Steps to reproduce the bug:

1)  Download the Python 2.5.1 Windows installer (Windows binary -- 
does not include source).
2)  Select Install for all users and click Next.
3)  Click Next.
4)  Click Advanced.
5)  Click Cancel.
6)  Click Yes.

--
components: Installation
messages: 58968
nosy: mtvernon
severity: normal
status: open
title: Crash on cancellation of windows install
type: crash
versions: Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1690
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1688] Incorrectly displayed non ascii characters in prompt using input() - Python 3.0a2

2007-12-23 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Would you like to work on a patch?

--
nosy: +loewis

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1688
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1690] Crash on cancellation of windows install

2007-12-23 Thread Martin v. Löwis

Martin v. Löwis added the comment:

What do you mean by Crash?

--
nosy: +loewis

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1690
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

2007-12-23 Thread Christian Heimes

Christian Heimes added the comment:

A small note from me:

Your proposed patch is no good and is going to lead to strange, hard to
debug bugs in your app. os.chdir() isn't safe in a threaded environment.
You must protect the entire section with a global lock.

--
nosy: +tiran

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1684
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

2007-12-23 Thread Fazal Majid

Fazal Majid added the comment:

MT-safety has nothing to do with this. The os.chdir() is invoked from
the new child process that is forked just prior to calling execve() to
run the CGI script, after which it exits. The parent CGIHTTPServer may
be multithreaded, but invoking the CGI script is not a concurrent affair.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1684
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1676] Fork/exec issues with Tk 8.5/Python 2.5.1 on OS X

2007-12-23 Thread Adam Olsen

Changes by Adam Olsen:


--
nosy: +rhamphoryncus

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1676
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1691] feature request: methods that modify instances should return instance

2007-12-23 Thread Peter Farson

New submission from Peter Farson:

Here's an example:
I'd like to be able to reverse a list for iterating...
for i in range(10).reverse()

This could work if reverse method returned self, but currently it
doesn't return anything.  I think the overhead is slight and worth it.

--
components: None
messages: 58973
nosy: eukaryot
severity: normal
status: open
title: feature request: methods that modify instances should return instance
type: behavior
versions: Python 2.5

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1691
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1691] feature request: methods that modify instances should return instance

2007-12-23 Thread Christian Heimes

Christian Heimes added the comment:

No, it's too confusing for users and it might hide bugs. The core types
either change an object in place and return None *OR* the method returns
a  modified object. It's a design decision we won't change.

In your case you can use the reversed(range(10)) wrapper. Python has
several wrappers like reversed() and sorted().

--
nosy: +tiran
resolution:  - wont fix
status: open - closed

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1691
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1677] Ctrl-C will exit out of Python interpreter in Windows

2007-12-23 Thread Isaul Vargas

Isaul Vargas added the comment:

I wanted to add that this issue also affects python 2.5.1 on the Mac.
Sometimes I may be writing something in the interpreter and I decide to 
invalidate my input by pressing Ctrl-C. This will exit the interpreter 
occasionally. I think it would be a good idea to see if there's a way 
to make the interpreter bullet proof from Ctrl-C, or at least good 
enough so that a single Ctrl-c won't cause the interpreter to exit.

--
versions: +Python 2.4, Python 2.5, Python 2.6

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1677
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1692] Syntax Error exception dosen't print string; not informative

2007-12-23 Thread Isaul Vargas

New submission from Isaul Vargas:

Python 3.0 doesn't print the string with the carat underneath when 
there is a syntax error.

 if x
SyntaxError: invalid syntax (stdin, line1)
 if (x=5):
SyntaxError: invalid syntax (stdin, line 1)

Python 2.x behavior:

 if (x=5): pass
  File stdin, line 1
if (x=5): pass

 if x
  File stdin, line 1
if x

--
messages: 58977
nosy: Dude-X
severity: normal
status: open
title: Syntax Error exception dosen't print string; not informative
type: behavior
versions: Python 3.0

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1692
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1760357] ZipFile.write fails with bad modification time

2007-12-23 Thread Alan McIntyre

Alan McIntyre added the comment:

At the moment I don't have a Windows machine available, but on my Mac,
time.localtime doesn't seem to mind interpreting negative input values.
 So I doubt that forcing timestamps to be non-negative is the way to fix
this. 

I poked around a bit in the current 2.6 source, and it seems to me that
in this case the Windows XP localtime function doesn't like a timestamp
value that was generated by the same platform's stat function.  It seems
like raising a ValueError is the correct thing for the time module to
do, since it relies on the platform to do the conversions; what should
zipfile.writestr do?  I don't like the idea of silently using some dummy
timestamp if the conversion of os.stat results fails, and I can't think
of an alternative at the moment.

--
nosy: +alanmcintyre

_
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1760357
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1650] IDLE: help() displays output on the wrong shell

2007-12-23 Thread Kurt B. Kaiser

Kurt B. Kaiser added the comment:

Yes, and it does on linux, also.  Someone changed the way help() 
works.  Since the help listing is often extensive and clutters up the 
shell, I'm thinking that the best solution would be to pop up a new 
window.  I haven't got around to addressing either the bug or a new 
design.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1650
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1647] IDLE messes around with sys.exitfunc

2007-12-23 Thread Kurt B. Kaiser

Kurt B. Kaiser added the comment:

It was done for VPython support, as described in the docstring in 
run.py:exit().  What are you doing, removing sys.exitfunc from 
2.6? 

The 3.0 run.py code was changed to use atexit._clear().

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1647
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1658] RuntimeError: dictionary changed size during iteration in Tkinter

2007-12-23 Thread Kurt B. Kaiser

Changes by Kurt B. Kaiser:


--
nosy: +kbk

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1658
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com