Re: python to sharepoint ?

2006-11-05 Thread David
You might want to check out IronPython:

http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython

It's a port of the .NET FW for Python, which probably exposes the API
you'll need.

-David


curtin wrote:
 anyone have code that allows me to post files direct to sharepoint from
 python?
 
 any pointers, FAQ, etc,  appreciated!
 
 thanks,
 
 craig

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


Re: Programming Language that is Spreadsheet/Table Based

2006-11-05 Thread Hendrik van Rooyen
James Stroud [EMAIL PROTECTED] wrote:

 Gerard Flanagan wrote:

8--

 Thank you, this is very good stuff to think about.

 James

 I can't really add to the above train of thought...

And I don't know if this will help - but if you want to think, here is a skewed,
simple view:

If I were to try and do something like this, I would start by defining a spread
sheet like dict to keep everything in, using (column,row) tuples as keys, and
build on top of that.

This would give you the ability to keep *anything* in a cell, and the database
like structures you are thinking of would live on top of this underlying access
structure, with the (column,row) being a direct *pointer* to an element in one
fast step.

I would then also use other dicts to describe what is kept in the columns -
something simple like:

header_dict = {0:['name of person','Name','Enter your name'],1:['age of person
since birth','Age','Enter your birthday'], ... }

where the first item in the list is a help string, the second a column header
for printing, the third the string to use as prompt for a GUI, etc... - you
could even keep and enforce type if you wanted to - must be int, must be date,
column width for printing, validation data and rules, - whatever.

In a sense this is a sort of inverted way of looking at a file - instead of
having an underlying dict with (column, row) keys, you could alternatively have
loose column dicts only to keep the data in ( note that I have been writing
(column, row) consistently, instead of the more conventional (row,column).) -
this would make adding or deleting columns almost trivial.

You *could* also have references to Python functions or class methods living
alongside the data in the cells, and then things can get hairy - for an age
entry, for instance, the cell can look like:

Data[(column,row)] =   # (or Age[row] in the alternative
approach)

 [(1947,01,24),self.BirthdayChecker,self.PresentChooser,self.LetterWriter, ...]

where the first entry, the tuple,  represents the data (could have been a list
or dict, of course ) and the rest are methods or functions to use, in this
particular instance.   You could instead have these function references in the
age column's header dict entry, for those of them that have applicability across
all rows of the column, just like the idea of type enforcement or validation
above.

For a kind of row, or row type, you need then simply keep a list of column
numbers that are required for this record, with a different list defining a
different record type - Gold members need these column entries filled in, while
Silver members need only those... simple, but then you need a record type
column...

This sort of thing organises the stuff, but the code to use it becomes a bit
impenetrable, as you have to write a kind of crawling process to access the
structure to do what is required, but it is all table driven and can be very
flexible.  Its not a weekend project though, and when you are finished its a
kind of super relational database...

HTH

- Hendrik

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


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

2006-11-05 Thread Paul Rubin
Martin v. Löwis [EMAIL PROTECTED] writes:
  I think that has to be on a single processor, or at most a dual core
  processor with shared cache on die.  With multiple cpu chips I don't
  think can get the signals around that fast.
 
 Can you explain what you mean? The lock# signal takes *immediate*
 effect, within the CPU cycle in which it is asserted. There is no
 delay whatsoever (except for speed-of-light issues, of course).

I dunno about x86 hardware signals but these instructions do
read-modify-write operaitons.  That means there has to be enough
interlocking to prevent two cpu's from updating the same memory
location simultaneously, which means the CPU's have to communicate.
See http://en.wikipedia.org/wiki/MESI_protocol (I think this is
how the current x86's do it):

A cache that holds a line in the Modified state must snoop
(intercept) all attempted reads (from all of the other CPUs in the
system) of the corresponding main memory location and insert the
data that it holds. This is typically done by forcing the read to
back off (i.e. to abort the memory bus transaction), then writing
the data to main memory and changing the cache line to the Shared
state.

A cache that holds a line in the Shared state must also snoop all
invalidate broadcasts from other CPUs, and discard the line (by
moving it into Invalid state) on a match.

It is quite difficult to get signals off of a chip at GHz speeds, and
so this signalling is much slower than the CPU cycle.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: Script help needed

2006-11-05 Thread Nick Vatamaniuc
If the other commands work but 3) doesn't, it means there is something
different (wrong?) with the command.

So try running 3) ,  then one of the other ones and see the difference.


The getCommandOutput() , I suspect,  just waits for the data from the
actual command and the command is not returning anything. It could be
because it just takes way too long (I am not familiar with Gentoo, so
not sure if emerge world takes 1 second or 24 hours...) or perhaps the
emerge -uvp world stops at some point and is waiting for input (a
command prompt like are you sure you want to do this [Y/n]?

For more in depth on subprocesses in Python take a look at the
subprocess module:
http://docs.python.org/lib/module-subprocess.html

Hope this helps,
Nick V.



Lorenzo wrote:
 I have this script that I want to use weekly to send me email with
 information regarding disk space and available upgrades for my system.
 This script is actually a learning tool for me as I learn Python. The
 problem I've run into has me stumped and I need some help. What happens
 is when the script runs it does these things, parses the result and
 appends that to an html string:

 1) checks disk space by using df -t reiserfs
 2) runs time emerge --sync
 3) runs emerge -uvp world
 4) runs emerge -uv --fetchonly world

 The 'emerge' command is a Gentoo specific one. If I remove step 3),
 everything else runs just fine, the email is sent and I receive what I
 expect. But when step 3) is allowed to run, even if its the only command
 that runs, it hangs somewhere in the function getCommandOutput. If I try
 and debug the command, it appears to hang on this line:
 err = child.wait()

 I suspect a race condition, but I'm not sure how to proceed, can someone
 lend me a hand. Here is the script I wrote, I got the command
 getCommandOutput from this site:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296
 TIA

 [code]
 #!/usr/bin/python

 
 ### NEED TO RUN THIS AS ROOT ###
 ### EMERGE SYNC REQUIRES THIS ###
 
 import os, re, smtplib, MimeWriter, mimetools, cStringIO, popen2, fcntl,
 select, pdb

 cmd = 'df -t reiserfs'
 finalList = []
 theOutput = []

 text = This realy should be in HTML


 html = html\
 head\
 meta http-equiv=\Content-Type\ content=\text/html;
 charset=iso-8859-1\\
 /head\
 BODYBRfont color='green'emDisk Utilization on
 Hedley:/em/fontBR

 out = cStringIO.StringIO()
 writer = MimeWriter.MimeWriter(out)
 txtin = cStringIO.StringIO(text)


 def createhtmlmail (html, text, subject):
  Create a mime-message that will render HTML in popular
   MUAs, text in better ones
import MimeWriter
import mimetools
import cStringIO

out = cStringIO.StringIO() # output buffer for our message
htmlin = cStringIO.StringIO(html)
txtin = cStringIO.StringIO(text)

writer = MimeWriter.MimeWriter(out)
#
# set up some basic headers... we put subject here
# because smtplib.sendmail expects it to be in the
# message body
#
writer.addheader(Subject, subject)
writer.addheader(MIME-Version, 1.0)

writer.addheader(From, [EMAIL PROTECTED])
   writer.addheader(To, [EMAIL PROTECTED])
#
# start the multipart section of the message
# multipart/alternative seems to work better
# on some MUAs than multipart/mixed
#
writer.startmultipartbody(alternative)
writer.flushheaders()
#
# the plain text section
#
subpart = writer.nextpart()
subpart.addheader(Content-Transfer-Encoding, quoted-printable)
pout = subpart.startbody(text/plain, [(charset, 'us-ascii')])
mimetools.encode(txtin, pout, 'quoted-printable')
txtin.close()
#
# start the html subpart of the message
#
subpart = writer.nextpart()
subpart.addheader(Content-Transfer-Encoding, quoted-printable)
#
# returns us a file-ish object we can write to
#
pout = subpart.startbody(text/html, [(charset, 'us-ascii')])
mimetools.encode(htmlin, pout, 'quoted-printable')
htmlin.close()
#
# Now that we're done, close our writer and
# return the message body
#
writer.lastpart()
msg = out.getvalue()
out.close()
print msg
return msg

 def makeNonBlocking(fd):
 fl = fcntl.fcntl(fd, fcntl.F_GETFL)
 try:
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NDELAY)
 except AttributeError:
fcntl.fcntl(fd, fcntl.F_SETFL, fl | fcntl.FNDELAY)


 def getCommandOutput(command):
 theOutput = []
 child = popen2.Popen3(command, 1) # capture stdout and stderr from
 command
 child.tochild.close() # don't need to talk to child
 outfile = child.fromchild
 outfd = outfile.fileno()
 errfile = child.childerr
 errfd = errfile.fileno()
 makeNonBlocking(outfd)# don't deadlock!
 makeNonBlocking(errfd)
 outdata = errdata = ''
 outeof = erreof = 0
 while 1:
ready = select.select([outfd,errfd],[],[]) # 

Re: WSDL?

2006-11-05 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED],
[EMAIL PROTECTED] wrote:

 CORBA may work fine in an intranet environment, where you can control
 the server and the client, but it clearly failed to be a popular choice
 on the internet: have you seen any company offering webservices with a
 CORBA interface??

The OP wanted something for in-house communication between programs.  You
are right that CORBA is not a popular choice for offering webservices
for the masses but there used to be companies that offered CORBA
interfaces in the business to business arena when the word webservice
was yet to be invented.

A huge part of the SOAP popularity comes from marketing and shoving down
the buzzwords webservices and XML down everyone's throat and has
nothing to do with technical advantages or disadvantages.  Well, IMHO at
least.

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


tips requested for a log-processing script

2006-11-05 Thread Jaap
Python ers,
As a relatively new user of Python I would like to ask your advice on 
the following script I want to create.

I have a logfile which contains records. All records have the same 
layout, and are stored in a CSV-format. Each record is (non-uniquely) 
identified by a date and a itemID. Each itemID can occur 0 or more times 
per month. The item contains a figure/amount which I need to sum per 
month and per itemID. I have already managed to separate the individual 
parts of each logfile-record by using the csv-module from Python 2.5. 
very simple indeed.

Apart from this I have a configuration file, which contains the list of 
itemID's i need to focus on per month. Not all itemID's are relevant for 
each month, but for example only every second or third month. All 
records in the logfile with other itemID's can be ignored. I have yet to 
define the format of this configuration file, but am thinking about a 0 
or 1 for each month, and then the itemID, like:
1 0 0 1 0 0 1 0 0 1 0 0 123456 for a itemID 123456 which only needs 
consideration at first month of each quarter.

My question to this forum is: which data structure would you propose? 
The logfile is not very big (about 200k max, average 200k) so I assume I 
can store in internal memory/list?

How would you propose I tackle the filtering of relevant/non-relevant 
items from logfile? Would you propose I use a filter(func, list) for 
this task or is another thing better?

In the end I want to mail the outcome of my process, but this seems 
straitforward from the documentation I have found, although I must 
connect to an external SMTP-server.

Any tips, views, advice is highly appreciated!


Jaap

PS: when I load the logfile in a spreadsheet I can create a pivot table 
which does about the same ;-] but that is not what I want; the 
processing must be automated in the end with a periodic script which 
e-mails the summary of the keyfigure every month.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2006-11-05 Thread Ross Ridge
Paul Rubin wrote:
 I dunno about x86 hardware signals but these instructions do
 read-modify-write operaitons.  That means there has to be enough
 interlocking to prevent two cpu's from updating the same memory
 location simultaneously, which means the CPU's have to communicate.
 See http://en.wikipedia.org/wiki/MESI_protocol (I think this is
 how the current x86's do it):

The MESI protocol is used to ensure all read and write operations are
cache coherent, not just locked read-modify-write operations.  Whether
the LOCK prefix is used or not in an instruction normally isn't
externally visable.  From IA-32 Intel® Architecture Software
Developer's Manual Volume 3A: System Programming Guide, Part 1:

For the Pentium 4, Intel Xeon, and P6 family processors,
if the area of memory being locked during a LOCK operation
is cached in the processor that is performing the LOCK operation
as write-back memory and is completely contained in a cache line,
the processor may not assert the LOCK# signal on the bus. Instead,
it will modify the memory location internally and allow it's
cache coherency mechanism to insure that the operation is carried
out atomically. This operation is called cache locking.
The cache coherency mechanism automatically prevents two or
more processors that have cached the same area of memory from
simultaneously modifying data in that area.

The cost of mantaining cache coherency for a locked increment
instruction should be no different than that of an unlocked increment
instruction.

 Ross Ridge

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


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

2006-11-05 Thread Martin v. Löwis
Paul Rubin schrieb:
 I dunno about x86 hardware signals but these instructions do
 read-modify-write operaitons.  That means there has to be enough
 interlocking to prevent two cpu's from updating the same memory
 location simultaneously, which means the CPU's have to communicate.
 See http://en.wikipedia.org/wiki/MESI_protocol (I think this is
 how the current x86's do it):

Ah, but in the case where the lock# signal is used, it's known that
the data is not in the cache of the CPU performing the lock operation;
I believe it is also known that the data is not in the cache of any
other CPU. So the CPU performing the LOCK INC sequence just has
to perform two memory cycles. No cache coherency protocol runs
in that case.

But even when caching is involved, I don't see why there should be
more than three memory cycles. The MESI protocol really consists
only of two pins: HIT# and HITM#; the actual implementation is just
in keeping the state for each cache line, and in snooping. There
CPU's don't really communicate. Instead, if one processor tries
to fill a cache line, the others snoop the read, and assert either
HIT# (when they have not modified their cache lines) or HITM#
(when they do have modified their cache lines). Assertions of
these signals is also immediate.

The worst case would be that one processor performs a LOCK INC,
and another processor has the modified value in its cache line.
So it needs to first flush the cache line, before the other
processor can modify the memory. If the memory is not cached
yet in another processor, the MESI protocol does not involve
additional penalties.

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


Re: small python cgi webserver

2006-11-05 Thread Norbert Kaufmann
Fabian Braennstroem wrote:
[...]
In your response (cgi-script) you have to divide the header from the
content '\r\n\r\n'.
 
 
 I am not sure, what that means!?  ... but it works :-)
 

We are talking about HTTP, take a look at the HTTP response in version 1.1:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6

As you may see you separate the header of a response from the body by an
empty line, generated with CRLF.
Since one CRLF ends the line inside the header you need two of them.

Bye

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


Re: Pyro stability

2006-11-05 Thread Irmen de Jong
writeson wrote:
[some questions about Pyro]

I've replied to this on Pyro's mailing list.
-Irmen
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: SE 2.3. Available now

2006-11-05 Thread Tim Chase
 nah, if you've spent more than five minutes on c.l.python lately, you'd 
 noticed that it's the Solution to Everything (up there with pyparsing, I 
 think).

SE would be the Solution to Everything.

pyparsing Provides Your Perfect Alternative where Regexp Syntax 
Is No Good.

The re module is just Routinely Expected to solve all problems.

:)

-tkc



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


Re: python GUIs comparison (want)

2006-11-05 Thread timmy
Mudcat wrote:
 When you say far better widgets, do you mean that it has a greater
 number of widgets to choose from, or that the types of widgets are
 basically the same but have a greater amount of flexibility in them?


by better i mean more of them to choose from and the functionality they 
provide.


when i started working with wx i discovered widgets i hadn't even seen 
before. and if you can't find a widget to suit, it's easy to make one.
-- 
http://mail.python.org/mailman/listinfo/python-list


string to list of numbers conversion

2006-11-05 Thread [EMAIL PROTECTED]
Hi,
  I have a string '((1,2), (3,4))' and I want to convert this into a
python tuple of numbers. But I do not want to use eval() because I do
not want to execute any code in that string and limit it to list of
numbers.
  Is there any alternative way?

Thanks.
Suresh

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


Is there a commas-in-between idiom?

2006-11-05 Thread Ernesto García García
Hi experts,

it's very common that I have a list and I want to print it with commas 
in between. How do I do this in an easy manner, whithout having the 
annoying comma in the end?

code

list = [1,2,3,4,5,6]

# the easy way
for element in list:
   print element, ',',

print


# this is what I really want. is there some way better?
if (len(list)  0):
   print list[0],
   for element in list[1:]:
 print ',', element,

/code

Thx,
Ernesto
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: tips requested for a log-processing script

2006-11-05 Thread martdi
if you are running in windows you can use the win32com module to
automate the process of generating a pivot table in excel and then code
to send it via e-mail



Jaap wrote:
 Python ers,
 As a relatively new user of Python I would like to ask your advice on
 the following script I want to create.

 I have a logfile which contains records. All records have the same
 layout, and are stored in a CSV-format. Each record is (non-uniquely)
 identified by a date and a itemID. Each itemID can occur 0 or more times
 per month. The item contains a figure/amount which I need to sum per
 month and per itemID. I have already managed to separate the individual
 parts of each logfile-record by using the csv-module from Python 2.5.
 very simple indeed.

 Apart from this I have a configuration file, which contains the list of
 itemID's i need to focus on per month. Not all itemID's are relevant for
 each month, but for example only every second or third month. All
 records in the logfile with other itemID's can be ignored. I have yet to
 define the format of this configuration file, but am thinking about a 0
 or 1 for each month, and then the itemID, like:
 1 0 0 1 0 0 1 0 0 1 0 0 123456 for a itemID 123456 which only needs
 consideration at first month of each quarter.

 My question to this forum is: which data structure would you propose?
 The logfile is not very big (about 200k max, average 200k) so I assume I
 can store in internal memory/list?

 How would you propose I tackle the filtering of relevant/non-relevant
 items from logfile? Would you propose I use a filter(func, list) for
 this task or is another thing better?

 In the end I want to mail the outcome of my process, but this seems
 straitforward from the documentation I have found, although I must
 connect to an external SMTP-server.

 Any tips, views, advice is highly appreciated!


 Jaap

 PS: when I load the logfile in a spreadsheet I can create a pivot table
 which does about the same ;-] but that is not what I want; the
 processing must be automated in the end with a periodic script which
 e-mails the summary of the keyfigure every month.

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


finding the list of the matched strings

2006-11-05 Thread [EMAIL PROTECTED]
Hi, I have a list of strings. And I want to find the subset which
matches a particular regular expression.

import re
ll = ('a', 'b', 's1', 's2', '3s')
p = re.compile('^s.*')
newList = filter(lambda s: p.match(s), ll)

I suppose there should be simple function to do this in re module. Is
there any?

I searched google, but could not find one, may be for keywords were not
perfect.

Thanks.
Suresh

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


Re: string to list of numbers conversion

2006-11-05 Thread Gerard Flanagan

[EMAIL PROTECTED] wrote:
 Hi,
   I have a string '((1,2), (3,4))' and I want to convert this into a
 python tuple of numbers. But I do not want to use eval() because I do
 not want to execute any code in that string and limit it to list of
 numbers.
   Is there any alternative way?


Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type help, copyright, credits or license for more information.
 s = '((1,2), (3,4))'
 s = filter(lambda char: char not in ')(', s)
 s
'1,2, 3,4'
 s = s.split(',')
 s
['1', '2', ' 3', '4']
 s = map(float, s)
 s
[1.0, 2.0, 3.0, 4.0]
 t1 = s[::2]
 t1
[1.0, 3.0]
 t2 = s[1::2]
 t2
[2.0, 4.0]
 zip(t1, t2)
[(1.0, 2.0), (3.0, 4.0)]


Gerard

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


Re: string to list of numbers conversion

2006-11-05 Thread Peter Otten
[EMAIL PROTECTED] wrote:

   I have a string '((1,2), (3,4))' and I want to convert this into a
 python tuple of numbers. But I do not want to use eval() because I do
 not want to execute any code in that string and limit it to list of
 numbers.
   Is there any alternative way?

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

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


Re: Is there a commas-in-between idiom?

2006-11-05 Thread Christian Joergensen
Ernesto García García [EMAIL PROTECTED] writes:

 Hi experts,

 it's very common that I have a list and I want to print it with commas
 in between. How do I do this in an easy manner, whithout having the
 annoying comma in the end?

 list = [1,2,3,4,5,6]
 print ','.join(map(str, list))
1,2,3,4,5,6

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  | Visit us at: http://www.gmta.info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a commas-in-between idiom?

2006-11-05 Thread Peter Otten
Ernesto García García wrote:

 it's very common that I have a list and I want to print it with commas
 in between. How do I do this in an easy manner, whithout having the
 annoying comma in the end?

 items = [1, 2, 3, many]
 print , .join(str(item) for item in items)
1, 2, 3, many

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


Re: finding the list of the matched strings

2006-11-05 Thread Christian Joergensen
[EMAIL PROTECTED] [EMAIL PROTECTED] writes:

 Hi, I have a list of strings. And I want to find the subset which
 matches a particular regular expression.

 import re
 ll = ('a', 'b', 's1', 's2', '3s')
 p = re.compile('^s.*')
 newList = filter(lambda s: p.match(s), ll)

 I suppose there should be simple function to do this in re module. Is
 there any?

 I searched google, but could not find one, may be for keywords were not
 perfect.

I dont believe there exists such a function. I would have written
it using a list comprehension.

 import re
 ll = ('a', 'b', 's1', 's2', '3s')
 p = re.compile('^s.*')
 newList = [s for s in ll if p.match(s)]
 newList
['s1', 's2']

-- 
Christian Joergensen | Linux, programming or web consultancy
http://www.razor.dk  | Visit us at: http://www.gmta.info
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: finding the list of the matched strings

2006-11-05 Thread James Stroud
[EMAIL PROTECTED] wrote:
 Hi, I have a list of strings. And I want to find the subset which
 matches a particular regular expression.
 
 import re
 ll = ('a', 'b', 's1', 's2', '3s')
 p = re.compile('^s.*')
 newList = filter(lambda s: p.match(s), ll)
 
 I suppose there should be simple function to do this in re module. Is
 there any?
 
 I searched google, but could not find one, may be for keywords were not
 perfect.
 
 Thanks.
 Suresh
 

I think I'm having some network problems. I'll try again. Also the 
previous attempt had a typo (perhaps a freudian slip).

,.join(some_list).

By the way, don't name your own objects with the names of built-in 
types, such as list or str, etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a commas-in-between idiom?

2006-11-05 Thread James Stroud
Ernesto García García wrote:
 Hi experts,
 
 it's very common that I have a list and I want to print it with commas 
 in between. How do I do this in an easy manner, whithout having the 
 annoying comma in the end?
 
 code
 
 list = [1,2,3,4,5,6]
 
 # the easy way
 for element in list:
   print element, ',',
 
 print
 
 
 # this is what I really want. is there some way better?
 if (len(list)  0):
   print list[0],
   for element in list[1:]:
 print ',', element,
 
 /code
 
 Thx,
 Ernesto

print ,.joint(some_list)

Where what you have named list is now called some_list because it is 
terribly ill-advised to reassign the name of a built-in type.

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


Re: finding the list of the matched strings

2006-11-05 Thread Gerard Flanagan

[EMAIL PROTECTED] wrote:
 Hi, I have a list of strings. And I want to find the subset which
 matches a particular regular expression.

 import re
 ll = ('a', 'b', 's1', 's2', '3s')
 p = re.compile('^s.*')
 newList = filter(lambda s: p.match(s), ll)

 I suppose there should be simple function to do this in re module. Is
 there any?


# s = ('a', 'b', 's1', 's2', 'c')
# import re
# regexp = re.compile('^s.*')
# filter( regexp.match, s)
#('s1', 's2')
#

Gerard

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


Re: finding the list of the matched strings

2006-11-05 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 Hi, I have a list of strings. And I want to find the subset which
 matches a particular regular expression.
 
 import re
 ll = ('a', 'b', 's1', 's2', '3s')
 p = re.compile('^s.*')
 newList = filter(lambda s: p.match(s), ll)

or

newList = [s for s in ll if p.match(s)]

 I suppose there should be simple function to do this in re module. Is
 there any?

No.

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


Re: Is there a commas-in-between idiom?

2006-11-05 Thread Ernesto García García
Ernesto García García wrote:
 Hi experts,
 
 it's very common that I have a list and I want to print it with commas 
 in between. How do I do this in an easy manner, whithout having the 
 annoying comma in the end?
 
 code
 
 list = [1,2,3,4,5,6]
 
 # the easy way
 for element in list:
   print element, ',',
 
 print
 
 
 # this is what I really want. is there some way better?
 if (len(list)  0):
   print list[0],
   for element in list[1:]:
 print ',', element,
 
 /code
 
 Thx,
 Ernesto

mylist = [1,2,3,4,5,6]
print ','.join(map(str, mylist))

Great solution!

Thank all of you,
Ernesto
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a commas-in-between idiom?

2006-11-05 Thread Tim Peters
]Ernesto García García]
 it's very common that I have a list and I want to print it with commas
 in between. How do I do this in an easy manner, whithout having the
 annoying comma in the end?

 code

 list = [1,2,3,4,5,6]

 # the easy way
 for element in list:
print element, ',',

 print


 # this is what I really want. is there some way better?
 if (len(list)  0):

More idiomatic as

if len(list)  0:

and even more so as plain

if list:

print list[0],
for element in list[1:]:
  print ',', element,

Do you really want a space before and after each inter-element comma?

 /code

An often-overlooked alternative to playing with ,.join() is:

print str(list)[1:-1]

That is, ask Python to change the list into a big string, and just
strip the brackets off each end:

 alist = ['a, bc', 4, True]
 print str(alist)[1:-1]
'a, bc', 4, True

Note the quotes around the string element!  This differs from what
your code snippet above would produce (in addition to differing wrt
spaces around inter-element commas):

a, bc , 4 , True
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: SIP v4.5 Released

2006-11-05 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of SIP v4.5 available 
from http://www.riverbankcomputing.co.uk/sip/.

SIP is a tool for generating Python modules that wrap C or C++ libraries.  It 
is similar to SWIG.  It is used to generate PyQt and PyKDE.  Full 
documentation is available at 
http://www.riverbankcomputing.com/Docs/sip4/sipref.html.

SIP is licensed under the Python License and runs on Windows, UNIX, Linux and 
MacOS/X.  SIP requires Python v2.3 or later.

The main focus of this release is support for Python v2.5.

Other features of SIP include:

- extension modules are implemented as a single binary .pyd or .so file (no
  Python stubs)
- support for Python new-style classes
- generated modules are quick to import, even for large libraries
- support for Qt's signal/slot mechanism
- thread support
- the ability to re-implement C++ abstract and virtual methods in Python
- the ability to define Python classes that derive from abstract C++ classes
- the ability to spread a class hierarchy across multiple Python modules
- support for C++ namespaces
- support for C++ exceptions
- support for C++ operators
- an extensible build system written in Python that supports over 50
  platform/compiler combinations
- the generation of API files for IDEs that support autocompletion and call
  tips.

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


Re: string to list of numbers conversion

2006-11-05 Thread [EMAIL PROTECTED]
Peter, Thanks.

This recipe fails when negative numbers are used.

safe_eval('(12, -12)')
*** Unsafe_Source_Error: Line 1.  Unsupported source construct:
compiler.ast.UnarySub

But, I think it could  be easily fixed for somebody who understands the
script. Can somebody help.

Thanks.
Suresh
Peter Otten wrote:
 [EMAIL PROTECTED] wrote:

I have a string '((1,2), (3,4))' and I want to convert this into a
  python tuple of numbers. But I do not want to use eval() because I do
  not want to execute any code in that string and limit it to list of
  numbers.
Is there any alternative way?

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/364469
 
 Peter

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


ANN: PyQt v4.1 Released

2006-11-05 Thread Phil Thompson
Riverbank Computing is pleased to announce the release of PyQt v4.1
available from http://www.riverbankcomputing.co.uk/pyqt/.

The highlights of this release include:

- support for Qt v4.2 including QGraphicsView and related classes, the undo
  framework, widget stylesheets, and integration with GNOME (both visually and
  the event loop)
- the addition of the QtTest module for automated GUI testing
- the addition of the QAxContainer module for Windows for integrating ActiveX
  controls.

PyQt is a comprehensive set of Qt bindings for the Python programming language 
and supports the same platforms as Qt (Windows, Linux and MacOS/X).  Like Qt, 
PyQt is available under the GPL and a commercial license.

See http://www.riverbankcomputing.com/Docs/PyQt4/html/classes.html for the 
class documentation.

PyQt v4 supports Qt v4 (http://www.trolltech.com/products/qt/index.html).  
PyQt v3 is still available to support earlier versions of Qt.

PyQt v4 is implemented as a set of 10 extension modules containing 
approximately 400 classes and 6,000 functions and methods.

QtCore
The non-GUI infrastructure including event loops, threads, i18n, Unicode,
signals and slots, user and application settings.

QtGui
A rich collection of GUI widgets.

QtNetwork
A set of classes to support TCP and UDP socket programming and higher
level protocols (eg. HTTP).

QtOpenGL
A set of classes that allows PyOpenGL to render onto Qt widgets.

QtSql
A set of classes that implement SQL data models and interfaces to industry
standard databases.  Includes an implementation of SQLite.

QtSvg
A set of classes to render SVG files onto Qt widgets.

QtTest
A set of classes to automate unit testing of PyQt applications and GUIs.

QtXML
A set of classes that implement DOM and SAX parsers.

QtAssistant
A set of classes that enables the Qt Assistant online help browser to be
integrated with an application.

QAxContainer
A set of classes for Windows that allows the integration of ActiveX
controls and COM objects.

A Windows installer is provided for the GPL version of PyQt to be used with 
the GPL version of Qt v4 (http://www.trolltech.com/download/qt/windows.html). 
It enabes a complete PyQt environment to be installed on Windows without the 
need for a C++ compiler.

PyQt includes the pyuic utility which generates Python code to implement user 
interfaces created with Qt Designer in the same way that the uic utility 
generates C++ code.  It is also able to load Designer XML files dynamically.

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


Re: Event driven server that wastes CPU when threaded doesn't

2006-11-05 Thread Snor
 You got a lot of long-winded replies, but the short reply is that
 Twisted has packaged solutions for this. 
 Seehttp://twistedmatrix.com/projects/core/enterprise

   Twisted provides an interface to any Python DB-API 2.0 compliant
 database through an asynchronous interface which allows database
 connections to be used, and multiplexed by multiple threads, while still
 remaining thread-safe for use with Twisted's event-based main loop.
 Twisted Enterprise provides these services by leveraging Twisted
 Internet's utilities for managing thread pools and asynchronous
 programming.

Thanks for this - exactly what I needed. Thanks for the other replies
too even if they weren't so much help :)

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


Re: Trouble compiling win32all on Windows

2006-11-05 Thread robert
Ross Ridge wrote:
 robert wrote:
 I've trouble compiling win32all. VC98 and latest SDK installed
 (otherwise with original SDK it won't even compile).
 It tells that uuid.lib(cguid_i.obj) : fatal error LNK1103: debug info
 is destroyed.
 
 The library isn't compatable with the compiler you're using.  You'll
 need to use an older version of the Platform SDK that supports your
 compiler.

thanks. the last Windows SDK supporting VC6 (Py2.3) is February 2003 Edition. 

If someone seeks here:

MS' front pages tell you need to get it via CD. 
Yet this SDK exists (well hidden) on the net here:

http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.1.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.2.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.3.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.4.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.5.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.6.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.7.cab

wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.8.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.9.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.10.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.11.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.12.cab
wget 
http://download.microsoft.com/download/platformsdk/sdk/update/win98mexp/en-us/3790.0/FULL/PSDK-FULL.13.cab


one needs to set IE as default browser during installation. otherwise setup.exe 
will fail.

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


Re: string to list of numbers conversion

2006-11-05 Thread bearophileHUGS

[EMAIL PROTECTED] wrote:
 Hi,
   I have a string '((1,2), (3,4))' and I want to convert this into a
 python tuple of numbers. But I do not want to use eval() because I do
 not want to execute any code in that string and limit it to list of
 numbers.
   Is there any alternative way?

This is a possibile solution, no input errors are taken into account:

 s = '((1,2), (3,4), (-5,9.2))'
 from string import maketrans
 tab = maketrans((), ,  *4)
 s.translate(tab)
'  1 23 4-5 9.2  '
 l = s.translate(tab).split()
 l
['1', '2', '3', '4', '-5', '9.2']
 l2 = map(float, l)
 l2
[1.0, 2.0, 3.0, 4.0, -5.0, 9.1993]
 # This is partition(l2, 2)
 [l2[i:i+2] for i in xrange(0, len(l2), 2)]
[[1.0, 2.0], [3.0, 4.0], [-5.0, 9.1993]]

Bye,
bearophile

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


forwarding *arg parameter

2006-11-05 Thread Tuomas
  def g(*arg):
... return arg
...
  g('foo', 'bar')
('foo', 'bar')
  # seems reasonable
...
  g(g('foo', 'bar'))
(('foo', 'bar'),)
  # not so good, what g should return to get rid of the outer tuple

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


Re: forwarding *arg parameter

2006-11-05 Thread Diez B. Roggisch
Tuomas schrieb:
   def g(*arg):
 ... return arg
 ...
   g('foo', 'bar')
 ('foo', 'bar')
   # seems reasonable
 ...
   g(g('foo', 'bar'))
 (('foo', 'bar'),)
   # not so good, what g should return to get rid of the outer tuple

g(*g('foo', 'bar'))


* and **  are the symetric - they capture ellipsis arguments, and they 
make iterables/dicts passed as positional/named arguments.

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


Re: Is there a commas-in-between idiom?

2006-11-05 Thread Ernesto García García
Tim Peters wrote:

 More idiomatic as
 
if len(list)  0:
 
 and even more so as plain
 
if list:
 
print list[0],
for element in list[1:]:
  print ',', element,
 
 
 Do you really want a space before and after each inter-element comma?

No, but it was only an example. I usually go for string concatenation.

 An often-overlooked alternative to playing with ,.join() is:
 
print str(list)[1:-1]

That's funny! Not that I like it more that the join solution, but funny 
nevertheless.

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


Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Diez B. Roggisch wrote:
 Tuomas schrieb:
 
   def g(*arg):
 ... return arg
 ...
   g('foo', 'bar')
 ('foo', 'bar')
   # seems reasonable
 ...
   g(g('foo', 'bar'))
 (('foo', 'bar'),)
   # not so good, what g should return to get rid of the outer tuple
 
 
 g(*g('foo', 'bar'))
 
 
 * and **  are the symetric - they capture ellipsis arguments, and they 
 make iterables/dicts passed as positional/named arguments.
 
 Diez

Thanks Diez

And what about this case if I want the result ('foo', 'bar')

  def f(*arg):
... return g(arg)
...
  f('foo', 'bar')
(('foo', 'bar'),)

  def h(*arg):
... return arg[0]
...
  g=h
  f('foo', 'bar')
('foo', 'bar')

Where can g know it should use arg[0] when arg is forwarded?

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


Re: Really strange behavior

2006-11-05 Thread IloChab
Il Sun, 05 Nov 2006 04:19:36 +1100, Steven D'Aprano ha scritto:

 Why don't you add some temporary print statements into your code to try
 to narrow it down?
 
 
I did it and I followed the script with the dubugger and what I saw is
that it gets lost in the simulate method of QTReactor instead if executing
QTapplication.
So I thought about some wrong rebinding of 'app' in the multiple functions
call.
I was guessing about some python error that I could not see.

But the fact that neither you can't see anything wrong, let me guess about
some problem with the reactor.

Thank for your time.
Licia
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: forwarding *arg parameter

2006-11-05 Thread Stargaming
Tuomas schrieb:
   def g(*arg):
 ... return arg
 ...
   g('foo', 'bar')
 ('foo', 'bar')
   # seems reasonable
 ...
   g(g('foo', 'bar'))
 (('foo', 'bar'),)
   # not so good, what g should return to get rid of the outer tuple
 
 TV
Use the following then:
  g(*g('foo', 'bar'))
('foo', 'bar')

Otherwise, you would have to check if arg is a 1-tuple consisting of a 
tuple and strip it out then.

e.g.
  def g(*arg):
...  return arg[0] if isinstance(arg[0], tuple) else arg
...
  g('foo', 'bar')
('foo', 'bar')
  g(g('foo', 'bar'))
('foo', 'bar')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: disabledforeground or similar for Entry (in Tkinter)

2006-11-05 Thread jim-on-linux
Since others want to see more,


Try this, you can make the changes you want to the 
look of your final output with grid or 
pack_forget() . 

root = Tk()
class Ktest:
def __init__(self):
self.Ftest1()

def  Ftest1(self):
try:
self.test2.grid_forget()
except AttributeError :
pass
self.test1 = Button(root, text='Push #1
  button', bg = 'yellow',
  width = 25,
  command = self.Ftest2,
  height = 25)
self.test1.grid(row=0, column=0)


def Ftest2(self):
   self.test1.grid_forget()

   self.test2 = Button(root, text='Push #2
 button', bg = 'green',
 width = 25,
 command = self.Ftest1,
 height = 8)
   self.test2.grid(row=0, column=0)
if __name__==  '__main__' :
Ktest()
mainloop()


jim-on-linux

http://www.inqvista.com

 On Saturday 04 November 2006 11:03, Dustan 
wrote:
  Back in this post, I attempted to make a
  label look like a button:
  http://groups.google.com/group/comp.lang.pyth
 on
  /browse_thread/thread/a83195d3970a6851/2053cb
 aec
  1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAG
 UTt
  T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgP
 fcu
  OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2
 fuL
  m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21OD
 ZBh ouQ
 
  Alright, I've learned my lesson - don't use a
  new widget; modify the old one.
 
  Except the Entry widget doesn't have a
  disabledforeground option. Neither does the
  Text widget, but IDLE seems to accomplish
  making a disabled Text look the same as an
  enabled Text in the IDLE Help section.
 
  No, foreground (fg) and background (bg) don't
  make a difference; it still changes the color
  of the Entry widget upon disabling.
 
  There must be something I'm missing here...

 My previous post was hasty and we all know,
 Haste makes waste.

 Try this;

 If you use wiget-01.pack_forget() or
 wiget-01.grid_forget(),  you can now build
 wiget-02 using wiget-02.pack or grid() for the
 same location.

 You can reinstall uninstalled wigets by using
 pack() or grid() again for those hidden wigets.
 However only after uninstalling for the wigets
 in those locations.



 root = Tk()

 test1 = Button(root, text='Test No.1 button',
 bg = 'yellow', width = 15, height = 10)
 test1.grid(row=0, column=0)
 test1.grid_forget()


 test2 = Button(root, text='Test #2 button', bg
 = 'green', width = 15, height = 10)
 test2.grid(row=0, column=0)

 mainloop()


 jim-on-linux

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


Re: string to list of numbers conversion

2006-11-05 Thread Peter Otten
[EMAIL PROTECTED] wrote:

 This recipe fails when negative numbers are used.
 
 safe_eval('(12, -12)')
 *** Unsafe_Source_Error: Line 1.  Unsupported source construct:
 compiler.ast.UnarySub
 
 But, I think it could  be easily fixed for somebody who understands the
 script. 

I think that somebody could be you.

 Can somebody help. 

Start with

class SafeEval(object):
# ...
def visitUnarySub(self, node, **kw):
return -node.expr.value

and then add some error handling.

Peter

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


Re: forwarding *arg parameter

2006-11-05 Thread Steven D'Aprano
On Sun, 05 Nov 2006 15:26:58 +, Tuomas wrote:

   def g(*arg):
 ... return arg
 ...
   g('foo', 'bar')
 ('foo', 'bar')
   # seems reasonable

The function g:
- takes the arguments 'foo' and 'bar'
- collects them in a tuple named 'arg' = ('foo', 'bar')
- returns the tuple named arg


   g(g('foo', 'bar'))
 (('foo', 'bar'),)

The function g:
- takes the argument ('foo', 'bar')
- collects it in a tuple named 'arg' = (('foo', 'bar'),)
- returns the tuple named arg

The function is doing exactly the same as in the first case, except the
arguments are different.


   # not so good, what g should return to get rid of the outer tuple

Why do you want to? The way the function is now makes perfect sense. All
argument types are treated in exactly the same way:

g(string) = tuple containing string
g(float) = tuple containing float
g(int) = tuple containing int
g(list) = tuple containing list
g(instance) = tuple containing instance
g(tuple) = tuple containing tuple

You could write something like this:

def g(*arg):
# Detect the special case of a single tuple argument
if len(arg) == 1 and type(arg[0]) == tuple:
return arg[0]
else:
return arg

but now tuple arguments are treated differently to all other data. Why do
you think you need that?


-- 
Steven

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


Re: python GUIs comparison (want)

2006-11-05 Thread Mudcat

Paul Rubin wrote:


 No that would suck.  Best to try to stay as close as possible to the
 native widgets on whatever the underlying platform is.  If you want
 to depart from the native UI, then start from scratch and write a whole
 new window system with a complete app suite etc.

Ok. But other than thinking it would suck, you're basically repeating
my point about starting from scratch with a whole new suite of widgets.


I think there are situations where having an app that looks completely
different is a big bonus. Having developed apps for both engineers and
non-technical people alike, sometimes the non-techs are much more
impressed by the look/feel than what it actually does.

Sometimes you want a tool that blends in. Sometimes you want one that
stands out, especially when you're competing against other tools where
they all kind of look the same.

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


Wait for a system command executed in the background

2006-11-05 Thread Brice
Hello


I am new to python and I am really a bad programmer...

As a linux user, I use quodlibet for listening to music. Quodlibet
allows me to write plugins in python.

I am trying to write a plugins to burn a playlist by using cdrecord, and
this either in dao or tao mode.

The basic of this plugin is the following:

- make a temp directory
- convert the songs in my playlist into wave files in the temp directory
  using mplayer and renaming them with 3 digits number so that the order
of my playlist is conserved
- normalize the wave files
- burn the cd
- delete the temp directory.


At the time, I have a working solution (not fully developped by
myself...), but in this solution os.system is used to start the
different shell commands and the commands do not have a  at the end.
Therefore during the whole execution of the plugin, quodlibet is not
responsive.

What I would like to is program the whole such that I can use  at the
end of the shell commands and each command to be executed one after the
other! (I tried to put  simply at the end of each shell command with
the result that each where started at the same time)

Here is the plugin:

###


import os, string, re
import util
import sys
import shutil
from qltk import ErrorMessage
from shutil import copy
from plugins.songsmenu import SongsMenuPlugin

class _Base(SongsMenuPlugin):
 PLUGIN_ICON = 'gtk-cdrom'
 PLUGIN_VERSION = '0.1'

 # XXX : pb potentiel: si deux utilisateurs utilisent ce plugin
 # en meme temps, ils vont se marcher sur les pieds...
 destdir = /tmp/cd_QL

 convert_cmd = mplayer -ao pcm:file=%(dest)s %(source)s
 normalize_cmd = normalize -m %(path)s/*.wav
 burn_cmd = cdrecord -v -eject %(flags)s -pad -audio
%(path)s/*.wav
 burn_flags = ''

 def plugin_songs(self, songs):
 if not self.check_mplayer():
 return

 self.setup()
 try:
 try:
 for num, song in enumerate(songs):
 self.makewav(song, num)
 self.normalize()
 self.burn()
 except Exception, e:
 ErrorMessage(
 None,
 Unknown error,
 An error occured while processing files:\n%s. % e
 ).run()
 finally:
 self.teardown()

 def check_mplayer(self):
 if not util.iscommand(mplayer):
 ErrorMessage(
 None,
 Mplayer not found,
 Mplayer is used to convert files in wave files.
 ).run()
 return False
 return True

 def setup(self):
 os.mkdir(self.destdir)

 def makewav(self, song, num):
 source = song['~filename'].replace( , \
).replace(',\\')
 dest = os.path.join(self.destdir, %03d.wav % num)
 cmd = self.convert_cmd % dict(source=source, dest=dest)
 os.system(cmd)

 def normalize(self):
 os.system(self.normalize_cmd % dict(path=self.destdir))

 def burn(self):
 flags = self.burn_flags
 cmd = self.burn_cmd % dict(path=self.destdir, flags=flags)
 os.system(cmd)

 def teardown(self):
 shutil.rmtree(self.destdir)


class DAO(_Base):
 PLUGIN_ID = 'Burn CD w/o blanks'
 PLUGIN_NAME = _('Burn CD w/o blanks')
 PLUGIN_DESC = 'Burn CD w/o blanks.'
 burn_flags = '-dao'


class TAO(_Base):
 PLUGIN_ID = 'Burn CD with blanks'
 PLUGIN_NAME = _('Burn CD with blanks')
 PLUGIN_DESC = 'Burn CD with blanks.'

# on exporte seulement ces deux classes
__all__ = ['DAO', 'TAO']



#



and yeah, please consider that I am new to python and do understand
something to the thread!


Thanks in advance

-- 
Brice
Arch Linux (Linux user nb. 372699)
-
Unix IS user friendly, it is just selective about who his friends are
-- 
http://mail.python.org/mailman/listinfo/python-list


socket.error.__bases__ = (EnvironmentError,) ?

2006-11-05 Thread robert
I've often trouble catching IO errors in general. Now a frequent case 
everywhere in an app after I've added a defaultsockettimout.
Is this a legal/right practice to change the Exception tree like this:

socket.error.__bases__ = (EnvironmentError,)

And is there a chance that in future there is a common base exception class 
(EnvironmentError or an new super class) for these kind of exceptions (socket, 
httplib, ftplib, ...)


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


python bindings

2006-11-05 Thread Lane Brooks
I have a header file and archive file for a C-api that I would like to
interface via python.  I tried using SWIG, but I get the error message
to compile the object files with the -fPIC option.  Since I do not have
the source code, I cannot recompile.

Can anyone suggest a way to get this C-api into python?

Thanks,
Lane Brooks

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


Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Steven D'Aprano wrote:
snip
 You could write something like this:
 
 def g(*arg):
 # Detect the special case of a single tuple argument
 if len(arg) == 1 and type(arg[0]) == tuple:
 return arg[0]
 else:
 return arg
 
 but now tuple arguments are treated differently to all other data. Why do
 you think you need that?

I am looking a shorter way to do the above in the case:

def g(*arg):
 return arg

def f(*arg):
 return g(arg)

How can g know if it is called directly with (('foo', 'bar'),) or via f 
with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if I 
know the number of arguments, but what if I don't know that in design time?

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


Re: ANN: PyQt v4.1 Released

2006-11-05 Thread vj
 Riverbank Computing is pleased to announce the release of PyQt v4.1
 available from http://www.riverbankcomputing.co.uk/pyqt/.

What's the best way to learn pyqt. Do the examples from the book GUI
Programming with Python: QT Edition still work? Is the material from
the book mostly valid or have things changed quite a bit?

http://www.commandprompt.com/community/pyqt/

Vineet

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


Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Tuomas wrote:
 def g(*arg):
 return arg
 
 def f(*arg):
 return g(arg)
 
 How can g know if it is called directly with (('foo', 'bar'),) or via f 
 with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if I 
 know the number of arguments, but what if I don't know that in design time?

So it seems that I would like to have an unpack operator:

def f(*arg):
 return(!*arg)

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


maybe this is a print odds

2006-11-05 Thread pipehappy
I come this code:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
(Intel)] on win
32
Type help, copyright, credits or license for more information.
 class He(object):
... def __str__(self):
... return He
...
 hes = [He(),He(),He()]
 print hes
[__main__.He object at 0x00BE92D0, __main__.He object at
0x00BE9370, __main
__.He object at 0x00BE93B0]   # I expect output: [He,He,He]
 print hes[0]
He


Do anyone know trick to overcome this or python has some proposal to
extend print that can do iterately print? I just want to get the way of
print which I my guess. Thanks a lot!

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


Re: maybe this is a print odds

2006-11-05 Thread Peter Otten
pipehappy wrote:

 I come this code:
 
 Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
 (Intel)] on win
 32
 Type help, copyright, credits or license for more information.
 class He(object):
 ... def __str__(self):
 ... return He
 ...
 hes = [He(),He(),He()]
 print hes
 [__main__.He object at 0x00BE92D0, __main__.He object at
 0x00BE9370, __main
 __.He object at 0x00BE93B0]   # I expect output: [He,He,He]
 print hes[0]
 He

 
 Do anyone know trick to overcome this or python has some proposal to
 extend print that can do iterately print? I just want to get the way of
 print which I my guess. Thanks a lot!

Lists print their items via repr(), not str():

 class Ho(object):
... def __str__(self):
... return That's a bit early, don't you think?
... def __repr__(self):
... return Ho
...
 print [Ho()] * 3
[Ho, Ho, Ho]
 print Ho()
That's a bit early, don't you think?

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


Re: finding the list of the matched strings

2006-11-05 Thread John Machin

James Stroud wrote:
[snip]
 I think I'm having some network problems. I'll try again. Also the
 previous attempt had a typo (perhaps a freudian slip).

Also this time you replied to the wrong thread :-)


 ,.join(some_list).

 By the way, don't name your own objects with the names of built-in
 types, such as list or str, etc.

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


How to get/read Hard disk label / drive label

2006-11-05 Thread Praveen
I want to read individual disk label

for Hard disk (C: drive, D: drive disk label)
and
CD-ROM disk label

Please provide some pointer to the code or document.

Thanks in advance.

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


Re: forwarding *arg parameter

2006-11-05 Thread Stargaming
Tuomas schrieb:
 Tuomas wrote:
 
 def g(*arg):
 return arg

 def f(*arg):
 return g(arg)

 How can g know if it is called directly with (('foo', 'bar'),) or via 
 f with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if 
 I know the number of arguments, but what if I don't know that in 
 design time?
 
 
 So it seems that I would like to have an unpack operator:
 
 def f(*arg):
 return(!*arg)
 
 TV

Either you take one of the snippets here:
http://aspn.activestate.com/ASPN/search?query=flattensection=PYTHONCKBKtype=Subsection
or just use arg[0] clever (as mentioned a few times in this thread).
-- 
http://mail.python.org/mailman/listinfo/python-list


sneak peak: pythonic math in the silicon forest

2006-11-05 Thread [EMAIL PROTECTED]

Greetings Pythoneers:

Per usual, I've been walking this talk in Portland Open Source
Capital Oregon revolving around Python as a math learning language,
viewing math as an extensible type system (like Python) with such
well-known inhabitants as Vector, Polynomial, Polyhedron and so on.

Whereas I've been adjunct faculty by day, piggy backing on Portland
State's bookkeeping, our Saturday Academy is in the midst of
transitioning to an independent 501(c)(3), which will be better for
fundraising (donors will know exactly where their money is going).

Saturday Academy was established by Silicon Forest executives such as
myself, but 23 years ago (i.e. before my time -- I'm aged forty nine or
forty ten or like that), so I'm like this next-gen with a lot of new
ideas inherited from the open source movement (a big part of Portland's
economy these days).

My first gig with this Academy was West Precinct, Hillsboro, a police
station serving a large migrant population of Anglo, Euro and Latino
Americans.  That was a Linux heavy experience, thanks to my co-teacher
Jerritt Collord, then of linuxfund.org and since moved on I know not
where.

Anyway, if you're a CS prof looking for cues, tips and/or tricks, you
might be interested in my writeups, which occur in my blog and
scattered in the various Python in Education groups, most notably
edu-sig and edupython here on Google.

Here're some blog links to get ya started.  Feel free to send further
inquiries by email:

http://worldgame.blogspot.com/2006/11/more-pythonic-mathematics.html
http://mybizmo.blogspot.com/2006/10/whiteboard-doodles.html

(includes digicam shots of my whiteboard doodles).

Other background:  Kirby was Guido's side kick at this year's
Shuttleworth Summit in London, starring Alan Kay, Helen King, other
luminaries, aimed at kicking off Project Kusasa, a way of teaching
analytical engineering type skills through TuxLabs and so forth in the
Republic of South Africa.  Kirby was also a volunteer xBase programmer
for the Royal Kingdom of Bhutan, Office of the National Budget and
Royal Insurance Company of Bhutan (RICB).

Kirby Urner
Ministry of Education
Python Nation
[EMAIL PROTECTED]
[EMAIL PROTECTED]

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


Awesome Python Information

2006-11-05 Thread Brandon
Check out: www.ChezBrandon.com

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


Re: ANN: PyQt v4.1 Released

2006-11-05 Thread Tool69
Thanks Phil,
Can you put some hints about how to build QScintilla2 on Windows please
?

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


Re: Programming Language that is Spreadsheet/Table Based

2006-11-05 Thread dug

I think that Gnumeric lets you do some python stuff.

Douglas

Omar wrote:
 I'm looking for a programming language or module that sorta looks and
 feels like MS Excel (I love and think in tables), yet has the power and
 open-endedness of python or javascript.  I'm still pretty new to
 python.

 any ideas?  i've been having some fun with VBA in excel, but I want
 something I can save as en exe and call my own creation, y'know?

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


question about loading variables from a file...

2006-11-05 Thread avidfan
Can someone offer some advice as to how the best way to approach this
might be?

I am trying to write a generic python script to build out some
applications, so the python script will be generic enough to work for
all of them, but it needs to 'source' a file that contains app and
environment specific variables.

I have used WLST, which provides the loadProperties() method for
reading values for weblogic domains, but I'm trying to find the best
way to do the same sort of thing in python...

thanks for any advice.

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


Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Stargaming wrote:
 Either you take one of the snippets here:
 http://aspn.activestate.com/ASPN/search?query=flattensection=PYTHONCKBKtype=Subsection
  
 
 or just use arg[0] clever (as mentioned a few times in this thread).

Thanks. My solution became:

  def flattern(arg):
... result = []
... for item in arg:
... if isinstance(item, (list, tuple)):
... result.extend(flattern(item))
... else:
... result.append(item)
... return tuple(result)
...
  def g(*arg):
... arg = flattern(arg)
... return arg
...
  def f(*arg):
... return g(arg)
...
  f('foo', 'bar')
('foo', 'bar')

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


Re: How to get/read Hard disk label / drive label

2006-11-05 Thread Rob Williscroft
Praveen wrote in news:1162752076.121514.313750
@h48g2000cwc.googlegroups.com in comp.lang.python:

 I want to read individual disk label
 
 for Hard disk (C: drive, D: drive disk label)
 and
 CD-ROM disk label
 
 Please provide some pointer to the code or document.
 

You could use:

url: 
http://aspn.activestate.com/ASPN/docs/ActivePython/2.2/PyWin32/win32api__
GetVolumeInformation_meth.html

which will require:

http://sourceforge.net/projects/pywin32/

Or you can use this:

http://windowssdk.msdn.microsoft.com/en-us/library/ms685899.aspx

with this:

http://docs.python.org/dev/lib/module-ctypes.html

which is built in to python 2.5

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Awesome Python Information

2006-11-05 Thread Terry Reedy

Brandon [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Check out: www.ChezBrandon.com

for awesome megalomania having nothing to do with Python. 



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


RAW network programming under Windows

2006-11-05 Thread billie
RAW network programming under Windows it's not always possible because
of the security limitations that microsoft introduced in the latest
Windows versions and that affects WinSocket API.
On UNIX systems I'm able to freely send raw packets (for example I'm
able to compile IP packets with a src address defined by me) through
raw socket API, but if I do the same on a Windows system socket module
raises an error.

Now I'm searching for something different from raw socket api, an
extension module able to send arbitrary RAW packets through the
network.
I noticed that WinPcap (http://www.winpcap.org/) has a function to do
that (pcap_sendpacket()) so I started to search a Python wrapping for
WinPcap.
I found:
pcapy: http://oss.coresecurity.com/projects/pcapy.html
pypcap: http://www.monkey.org/~dugsong/pypcap/
...but none of them include a wrap for pcap_sendpacket() function.

Does someone know if exist a *complete* Python wrapping of WinPcap
library?

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


[newbie] conditional imports

2006-11-05 Thread John Remfry






--
No virus found in this outgoing message.
Checked by AVG Free Edition.

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

Re: NEWBIE: Script help needed

2006-11-05 Thread Lorenzo Thurman
Thanks for the reply, but I know there is something wrong with the 
command, I'm just not sure how to troubleshoot it. Anyway, I can execute 
all of the commands from the command line, but only 3 fails when run 
from within the script. I'll take a look at the link.


Nick Vatamaniuc wrote:
 If the other commands work but 3) doesn't, it means there is something
 different (wrong?) with the command.
 
 So try running 3) ,  then one of the other ones and see the difference.
 
 
 The getCommandOutput() , I suspect,  just waits for the data from the
 actual command and the command is not returning anything. It could be
 because it just takes way too long (I am not familiar with Gentoo, so
 not sure if emerge world takes 1 second or 24 hours...) or perhaps the
 emerge -uvp world stops at some point and is waiting for input (a
 command prompt like are you sure you want to do this [Y/n]?
 
 For more in depth on subprocesses in Python take a look at the
 subprocess module:
 http://docs.python.org/lib/module-subprocess.html
 
 Hope this helps,
 Nick V.
 
 
 
 Lorenzo wrote:
 I have this script that I want to use weekly to send me email with
 information regarding disk space and available upgrades for my system.
 This script is actually a learning tool for me as I learn Python. The
 problem I've run into has me stumped and I need some help. What happens
 is when the script runs it does these things, parses the result and
 appends that to an html string:

 1) checks disk space by using df -t reiserfs
 2) runs time emerge --sync
 3) runs emerge -uvp world
 4) runs emerge -uv --fetchonly world

 The 'emerge' command is a Gentoo specific one. If I remove step 3),
 everything else runs just fine, the email is sent and I receive what I
 expect. But when step 3) is allowed to run, even if its the only command
 that runs, it hangs somewhere in the function getCommandOutput. If I try
 and debug the command, it appears to hang on this line:
 err = child.wait()

 I suspect a race condition, but I'm not sure how to proceed, can someone
 lend me a hand. Here is the script I wrote, I got the command
 getCommandOutput from this site:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296
 TIA

 [code]
 #!/usr/bin/python

 
 ### NEED TO RUN THIS AS ROOT ###
 ### EMERGE SYNC REQUIRES THIS ###
 
 import os, re, smtplib, MimeWriter, mimetools, cStringIO, popen2, fcntl,
 select, pdb

 cmd = 'df -t reiserfs'
 finalList = []
 theOutput = []

 text = This realy should be in HTML


 html = html\
 head\
 meta http-equiv=\Content-Type\ content=\text/html;
 charset=iso-8859-1\\
 /head\
 BODYBRfont color='green'emDisk Utilization on
 Hedley:/em/fontBR

 out = cStringIO.StringIO()
 writer = MimeWriter.MimeWriter(out)
 txtin = cStringIO.StringIO(text)


 def createhtmlmail (html, text, subject):
  Create a mime-message that will render HTML in popular
   MUAs, text in better ones
import MimeWriter
import mimetools
import cStringIO

out = cStringIO.StringIO() # output buffer for our message
htmlin = cStringIO.StringIO(html)
txtin = cStringIO.StringIO(text)

writer = MimeWriter.MimeWriter(out)
#
# set up some basic headers... we put subject here
# because smtplib.sendmail expects it to be in the
# message body
#
writer.addheader(Subject, subject)
writer.addheader(MIME-Version, 1.0)

writer.addheader(From, [EMAIL PROTECTED])
   writer.addheader(To, [EMAIL PROTECTED])
#
# start the multipart section of the message
# multipart/alternative seems to work better
# on some MUAs than multipart/mixed
#
writer.startmultipartbody(alternative)
writer.flushheaders()
#
# the plain text section
#
subpart = writer.nextpart()
subpart.addheader(Content-Transfer-Encoding, quoted-printable)
pout = subpart.startbody(text/plain, [(charset, 'us-ascii')])
mimetools.encode(txtin, pout, 'quoted-printable')
txtin.close()
#
# start the html subpart of the message
#
subpart = writer.nextpart()
subpart.addheader(Content-Transfer-Encoding, quoted-printable)
#
# returns us a file-ish object we can write to
#
pout = subpart.startbody(text/html, [(charset, 'us-ascii')])
mimetools.encode(htmlin, pout, 'quoted-printable')
htmlin.close()
#
# Now that we're done, close our writer and
# return the message body
#
writer.lastpart()
msg = out.getvalue()
out.close()
print msg
return msg

 def makeNonBlocking(fd):
 fl = fcntl.fcntl(fd, fcntl.F_GETFL)
 try:
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NDELAY)
 except AttributeError:
fcntl.fcntl(fd, fcntl.F_SETFL, fl | fcntl.FNDELAY)


 def getCommandOutput(command):
 theOutput = []
 child = popen2.Popen3(command, 1) # capture stdout and stderr from
 command
 child.tochild.close() # don't need to talk to child
 

Re: python GUIs comparison (want)

2006-11-05 Thread Paul Rubin
Mudcat [EMAIL PROTECTED] writes:
  No that would suck.  Best to try to stay as close as possible to the
  native widgets on whatever the underlying platform is.  If you want
  to depart from the native UI, then start from scratch and write a whole
  new window system with a complete app suite etc.
 
 Ok. But other than thinking it would suck, you're basically repeating
 my point about starting from scratch with a whole new suite of widgets.

No.  In both cases I'm saying stick with a consistent set of widgets
and visual look across all applications.  Either use your OS's
existing widget set and make your apps look like the existing apps for
that OS, or else throw out all those apps and write a whole new set
whose look is new, but is consistent across all of them.  

 Sometimes you want a tool that blends in. Sometimes you want one that
 stands out, especially when you're competing against other tools where
 they all kind of look the same.

This is what I'm saying would suck.  Maybe the standing-out would get
more attention but it's a nuisance for users.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python GUIs comparison (want)

2006-11-05 Thread Mudcat

Dennis Lee Bieber wrote:

   IOWs, eyecandy with no functionality... Sounds like the same mindset
 that creates entire web sites using Flash animations such that one /can
 not/ access them using a simple fast-loading text modes.


Not exactly. Look...when you're using freeware to compete with OTS
applications then you have to keep up with appearances. One of the apps
I wrote was used by our Sales team to show to customers. These same
customers are used to seeing flashy apps being shown to them all the
time, and we are basically competing against other companies using
these programs.

Anyone who has written apps like this understand what a difference that
first appearances make. You can take the exact same program, give it a
flashier wrapper, and customers will automatically think it offers that
much more. Customers usually only test drive these things long enough
to get a feel for it, not long enough to understand what all it will
do.

Therefore you can get a competitive edge using something that sets it
apart appearance-wise. It has nothing to do with being hollow inside.

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


Re: Awesome Python Information

2006-11-05 Thread Paul McGuire
Brandon [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Check out: www.ChezBrandon.com

By which he means, do NOT waste your time checking out this ridiculous 
website with absolutely no Python whatever anywhere.
(This is the idiot who claims he saved the Congress from some Mossad poison 
gas attack, or whatever.)

-- Paul


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


simple way to un-nest (flatten?) list

2006-11-05 Thread djc
There is I am sure an easy way to do this, but I seem to be brain dead 
tonight. So:

I have a table such that I can do

  [line for line  in table if line[7]=='JDOC']
and
  [line for line  in table if line[7]=='Aslib']
and
  [line for line  in table if line[7]=='ASLIB']
etc

I also have a dictionary
  r=  {'a':('ASLIB','Aslib'),'j':('JDOC', 'jdoc')}
so I can extract values
r.values()
[('ASLIB', 'Aslib'), ('JDOC', 'jdoc')]

I would like to do

[line for line  in table if line[7] in ('JDOC','jdoc','Aslib','ASLIB')]

so how should I get from
{'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
to
('Aslib','ASLIB','JDOC','jdoc')



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


Re: Awesome Python Information

2006-11-05 Thread jim-on-linux

Thanks for the heads up. I spend enough time with 
the  email without having to chase gosts.

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






On Sunday 05 November 2006 16:39, Paul McGuire 
wrote:
 Brandon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
groups.com...

  Check out: www.ChezBrandon.com

 By which he means, do NOT waste your time
 checking out this ridiculous website with
 absolutely no Python whatever anywhere. (This
 is the idiot who claims he saved the Congress
 from some Mossad poison gas attack, or
 whatever.)

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


Re: ANN: PyQt v4.1 Released

2006-11-05 Thread Phil Thompson
On Sunday 05 November 2006 7:19 pm, Tool69 wrote:
 Thanks Phil,
 Can you put some hints about how to build QScintilla2 on Windows please
 ?

You mean something other than the installation instructions?

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


Re: tips requested for a log-processing script

2006-11-05 Thread George Sakkis
Jaap wrote:

 Apart from this I have a configuration file, which contains the list of
 itemID's i need to focus on per month. Not all itemID's are relevant for
 each month, but for example only every second or third month. All
 records in the logfile with other itemID's can be ignored. I have yet to
 define the format of this configuration file, but am thinking about a 0
 or 1 for each month, and then the itemID, like:
 1 0 0 1 0 0 1 0 0 1 0 0 123456 for a itemID 123456 which only needs
 consideration at first month of each quarter.

It's probably not necessary if your records are in the order of 100K,
but if you're dealing with millions and above, you can write your
config file in binary using the struct module and condense it down to 6
bytes per record (32 bits for the ID and 12 bits for the months
occurences). Filtering will also be faster, as for each record you just
have to do a bitwise AND with the 0..010...0 mask corresponding to a
given month.

George

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


Re: ANN: PyQt v4.1 Released

2006-11-05 Thread Phil Thompson
On Sunday 05 November 2006 6:00 pm, vj wrote:
  Riverbank Computing is pleased to announce the release of PyQt v4.1
  available from http://www.riverbankcomputing.co.uk/pyqt/.

 What's the best way to learn pyqt. Do the examples from the book GUI
 Programming with Python: QT Edition still work? Is the material from
 the book mostly valid or have things changed quite a bit?

 http://www.commandprompt.com/community/pyqt/

The basics haven't changed, but Qt v4 covers many more things than Qt v2. I 
think it's still perfectly valid for the basics - but API differences 
probably mean the examples need some changes.

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


Re: Wait for a system command executed in the background

2006-11-05 Thread Brice
On 2006-11-05, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Sun, 5 Nov 2006 18:32:39 +0100, Brice
[EMAIL PROTECTED] declaimed the following in
 comp.lang.python:


 
 At the time, I have a working solution (not fully developped by
 myself...), but in this solution os.system is used to start the
 different shell commands and the commands do not have a  at the end.
 Therefore during the whole execution of the plugin, quodlibet is not
 responsive.

   Might it not be easier to just write each of those commands to a
 temporary file, then at the end submit that file as a shell script that
 runs in the background? {Maybe the last command should be one the
 deletes the file itself?}
  

At the time being I don't see other possible solution. Let's see if
someone else's got an idea.

Thx

-- 
Brice
Arch Linux (Linux user nb. 372699)
-
Unix IS user friendly, it is just selective about who his friends are
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple way to un-nest (flatten?) list

2006-11-05 Thread George Sakkis
djc wrote:

 There is I am sure an easy way to do this, but I seem to be brain dead
 tonight. So:

 I have a table such that I can do

   [line for line  in table if line[7]=='JDOC']
 and
   [line for line  in table if line[7]=='Aslib']
 and
   [line for line  in table if line[7]=='ASLIB']
 etc

 I also have a dictionary
   r=  {'a':('ASLIB','Aslib'),'j':('JDOC', 'jdoc')}
 so I can extract values
 r.values()
 [('ASLIB', 'Aslib'), ('JDOC', 'jdoc')]

 I would like to do

 [line for line  in table if line[7] in ('JDOC','jdoc','Aslib','ASLIB')]

 so how should I get from
 {'a':('ASLIB','Aslib'),'j':('JDOC','jdoc')}
 to
 ('Aslib','ASLIB','JDOC','jdoc')

Meet itertools:

from itertools import chain
names = set(chain(*r.itervalues()))
print [line for line in table if line[7] in names]


George

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


Projecting MUD maps

2006-11-05 Thread BJörn Lindqvist
Hello, I'm looking for an algorithm to project MUD maps such as the
following map: http://www.aww-mud.org/maps/MUD_Maps/Caerin-colour.jpg

MUD:s consists of rooms, each rooms has up to four orthogonal edges
(north, east, west and south) that connects it to another room. So it
is very easy to model a MUD as a directed graph. But projecting the
graph on a surface is very complicated. For example, Room A:s North
edge may connect it to Room B. But Room B:s South edge may connect it
to Room C. Or another tricky example: Room A:s East edge connects it
to Room B, whose East edge connect it to Room C, whose North edge
connects it to Room D, whose West edge connects it to Room E, whose
South edge connects it to Room A. In that example, there would be a
hole between Room D and E.

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Awesome Python Information

2006-11-05 Thread John Machin

Paul McGuire wrote:
 Brandon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Check out: www.ChezBrandon.com
 
 By which he means, do NOT waste your time checking out this ridiculous
 website with absolutely no Python whatever anywhere.
 (This is the idiot who claims he saved the Congress from some Mossad poison
 gas attack, or whatever.)

 -- Paul

Nothing to do with Python?

1. Mossad is an agency of the state of Israel.
2. Some Israelis have long curly hair and wear big black hats.
3. Guy Fawkes and his co-conspirators in the alleged attempt to blow up
the House of Lords in 1606 had long curly hair and wore big black hats.
4. Fawkes signed his name 'Guido.

Q.E.D.

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


Re: Programming Language that is Spreadsheet/Table Based

2006-11-05 Thread Ravi Teja
Omar wrote:
 I'm looking for a programming language or module that sorta looks and
 feels like MS Excel (I love and think in tables), yet has the power and
 open-endedness of python or javascript.  I'm still pretty new to
 python.

PyCells
http://pycells.pdxcb.net/
http://pycells.pdxcb.net/wiki/index.php?title=Basic_Tutorial

 any ideas?  i've been having some fun with VBA in excel
 but I want something I can save as en exe and call my own creation, y'know?

You can also do Excel automation using Python.
http://www.markcarter.me.uk/computing/python/excel.html

There are many packaging tools for Python. Py2exe is the most popular.
Although in Excel's case, it would be difficult to make stand alone.

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


Re: forwarding *arg parameter

2006-11-05 Thread Tuomas
Dennis Lee Bieber wrote:
 On Sun, 05 Nov 2006 17:42:30 GMT, Tuomas [EMAIL PROTECTED]
 declaimed the following in comp.lang.python:
 
 
 
I am looking a shorter way to do the above in the case:

def g(*arg):
 return arg

def f(*arg):
 return g(arg)

How can g know if it is called directly with (('foo', 'bar'),) or via f 
 
 
   Typically, the responsibility should be on the CALLER, not the
 CALLED..
 
 
def g(*arg):
 
 ...   return arg
 ... 
 
def f(*arg):
 
 ...   return g(*arg)  # unpack tuple on call
 ... 
 
f(a, 1, 2)
 
 ('a', 1, 2)
 
 
   Note how f() is calling g() using an * -- Since f() knows that its
 arguments were packed it calls g() with an unpack marker. Then g()
 gets the arguments via whatever scheme it was coded to use.
 
 
def f(*arg):
 
 ...   return g(arg)   # no tuple unpack
 ... 
 
f(a, 1, 2)
 
 (('a', 1, 2),)
 
  
I fylly agree with tis: Typically, the responsibility should be on the 
CALLER, not the CALLED... I just don't know how to unpack *arg for 
calling g. I can get the len(arg), but how to formulate an unpacked call 
g(arg[0], arg[1], ..). Building a string for eval(g(arg[0], arg[1], 
..)) seems glumsy to me.

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


SPE editor slow?

2006-11-05 Thread timmy
hello i've been using the SPE editor on a moderately large project and 
it's constantly pausing during editing, like it's attempting to check 
something as i edit.
as you can imagine a 4 second pause every few characters is EXTREMELY 
annoying when you just want to get some work done. i really like SPE's 
layout and features but if it's going to be dogshit slow all the time 
i'll have to change. please help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Projecting MUD maps

2006-11-05 Thread Diez B. Roggisch
BJörn Lindqvist schrieb:
 Hello, I'm looking for an algorithm to project MUD maps such as the
 following map: http://www.aww-mud.org/maps/MUD_Maps/Caerin-colour.jpg
 
 MUD:s consists of rooms, each rooms has up to four orthogonal edges
 (north, east, west and south) that connects it to another room. So it
 is very easy to model a MUD as a directed graph. But projecting the
 graph on a surface is very complicated. For example, Room A:s North
 edge may connect it to Room B. But Room B:s South edge may connect it
 to Room C. Or another tricky example: Room A:s East edge connects it
 to Room B, whose East edge connect it to Room C, whose North edge
 connects it to Room D, whose West edge connects it to Room E, whose
 South edge connects it to Room A. In that example, there would be a
 hole between Room D and E.


try graphviz. You can also annotate some compass information ther, I 
guess it should make for a better placement.

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


Re: RAW network programming under Windows

2006-11-05 Thread sturlamolden

billie wrote:

 RAW network programming under Windows it's not always possible because
 of the security limitations that microsoft introduced in the latest
 Windows versions and that affects WinSocket API.
 On UNIX systems I'm able to freely send raw packets (for example I'm
 able to compile IP packets with a src address defined by me) through
 raw socket API, but if I do the same on a Windows system socket module
 raises an error.

You can try to install Windows Services for Unix 3.5 (aka SFU 3.5).
It transforms your Windows into a certified UNIX (not just a Unix
clone). SFU 3.5 has a full BSD socket API (derived from OpenBSD), not
just Winsock. As the POSIX subsystem in SFU 3.5 is not layered on top
of the Win32 subsystem, but talks directly to the NT kernel,
restrictions in Winsock should not affect the BSD sockets in SFU 3.5.
This behaviour is different from e.g. Cygwin, where the Unix APIs are
layered on top of the Win32 subsystem.

In any case, I hope you are aware that spoofing IP packets gives you
bad karma.

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


Re: Projecting MUD maps

2006-11-05 Thread [EMAIL PROTECTED]

BJörn Lindqvist wrote:
 Hello, I'm looking for an algorithm to project MUD maps such as the
 following map: http://www.aww-mud.org/maps/MUD_Maps/Caerin-colour.jpg

 MUD:s consists of rooms, each rooms has up to four orthogonal edges
 (north, east, west and south) that connects it to another room. So it
 is very easy to model a MUD as a directed graph. But projecting the
 graph on a surface is very complicated. For example, Room A:s North
 edge may connect it to Room B. But Room B:s South edge may connect it
 to Room C. Or another tricky example: Room A:s East edge connects it
 to Room B, whose East edge connect it to Room C, whose North edge
 connects it to Room D, whose West edge connects it to Room E, whose
 South edge connects it to Room A. In that example, there would be a
 hole between Room D and E.

 --
 mvh Björn

I'm working on a text adventure where if the player types in n, w, e or
s he/she gets something back like You go north, then turn around, then
look left, right . . . finally you realize that you have no idea in
which direction North is. It makes mapping more tedious, but also
simplifies it and gives you more freedom.

Or you could do something like this.

 rooms = [class instance, class instance, 0 (because there's no room here),
. . . . . . . . . . .0,  , class instance]

But that would still only get you the mapping and not the
implimentation, and it's untested by me because I chose not to do it.

And for my closing remark:
You know the game Zork? The people who made that game never made a grid
or anything. I'd bet that in the class, they had a variable for NW, N,
NE, E, SE, S, SW and W, and they probably even had a U and D for
defining what rooms would be in those directions..

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


Re: wing ide vs. komodo?

2006-11-05 Thread Karlo Lozovina
vj [EMAIL PROTECTED] wrote in news:1162708898.962171.161120
@e3g2000cwe.googlegroups.com:

 The embedded python shell is also a useful feature.

Yes, but Debug Probe and Stack Data absolutely rock! Can't live without 
them anymore. Just set a breakpoint, run your code end then you can 
inspect all of the structures via Stack Data, and you can play with those 
structures using Debug Probe. Huge productivity boost...

-- 
 ___Karlo Lozovina - Mosor
|   |   |.-.-. web: http://www.mosor.net || ICQ#: 10667163
|   ||  _  |  _  | Parce mihi domine quia Dalmata sum.
|__|_|__||_|_|
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to define a true global across modules?

2006-11-05 Thread alex23
Hendrik van Rooyen wrote:
 robert [EMAIL PROTECTED] wrote:
  Fredrik Lundh wrote:
   http://www.effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm

  Or worse style - if you are too lazy to create a extra global variables 
  module
  (ab)use the __main__ module als global:
  import __main__
  __main__.mysemphore += 1

 Thanks - how could you possibly have guessed that I am lazy - does it show 
 that
 much?  *WEG*

You could merge the two approaches and bind a more explicit name to
__main__:

import __main__ as config

config.mysemaphore = 0

It's a little clearer what you're subverting __main__ for here :)

- alex23

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


Re: Pyro stability

2006-11-05 Thread writeson
Irmen,

Thanks, you're very good about answering Pyro related questions!

Thanks again. I posted a more detailed question to the mailing list
describing as best I could how I want to use Pyro and the questions I
have in regards to the system described.

Doug

Irmen de Jong wrote:
 writeson wrote:
 [some questions about Pyro]
 
 I've replied to this on Pyro's mailing list.
 -Irmen

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


Re: Awesome Python Information

2006-11-05 Thread Dave Setchell
On Sun, 05 Nov 2006 17:05:10 -0500, jim-on-linux wrote:

 Thanks for the heads up. I spend enough time with 
 the  email without having to chase gosts.
 
 jim-on-linux
 http://www.inqvista.com 
 
 
 
 
 
 
 On Sunday 05 November 2006 16:39, Paul McGuire 
 wrote:
 Brandon [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
groups.com...

  Check out: www.ChezBrandon.com

 By which he means, do NOT waste your time
 checking out this ridiculous website with
 absolutely no Python whatever anywhere. (This
 is the idiot who claims he saved the Congress
 from some Mossad poison gas attack, or
 whatever.)

 -- Paul

So I'm using a new fangled newsreader...[pan] and thought i'd test it's
posting and headers on this silly thread...sorry if I wasted anyones time!.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Distilled

2006-11-05 Thread Simon Wittber
I want to build a Python2.5 interpreter for an embedded system. I only
have 4MB of RAM to play with, so I want to really minimise the python
binary.

Things I can think of removing safely are:
 - Unicode
 - Long numbers
 - Complex number
 - Compiler / Parser
 - Thread support
 - OS specific stuff

I'd also like to remove any deprecated or stuff which is left in for
backwards functionality (eg Classic classes).

Google tells me that people have done this before, back in Python1.5.2
days. Has anyone tried to do this recently with a more modern Python?

-Sw.

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


Re: how to write code into a blog post?

2006-11-05 Thread Jorge Vargas
On 4 Nov 2006 14:40:19 -0800, thebjorn
[EMAIL PROTECTED] wrote:
 Jorge Vargas wrote:
  Hi I know many people here blog so sorry for the OT.
 
  Currently I have a wordpress install and went I wanted to post some
  code I notice how painfull it is.

 Indeed :-)  I'm using the iG:Syntax Hiliter over on
 http://blog.tkbe.org after I got some comments about the lack of
 readability of my code samples ;-)  It can be even more colorful than
 I've set it up, but it handles a considerable number of languages and
 is pretty simple to both use and manage. You can get it at:
 http://blog.igeek.info/wp-plugins/igsyntax-hiliter/  I added the
 following to the end of the stylesheet to make the code frame bigger
 and dynamic:

 div.igBar { width: 95%; }
 div.syntax_hilite { width:95%; }

thanks I'll take a look at it

 hth,
 -- bjorn

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

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


Re: tips requested for a log-processing script

2006-11-05 Thread Hendrik van Rooyen
Jaap [EMAIL PROTECTED] wrote:


 Python ers,
 As a relatively new user of Python I would like to ask your advice on
 the following script I want to create.

 I have a logfile which contains records. All records have the same
 layout, and are stored in a CSV-format. Each record is (non-uniquely)
 identified by a date and a itemID. Each itemID can occur 0 or more times
 per month. The item contains a figure/amount which I need to sum per
 month and per itemID. I have already managed to separate the individual
 parts of each logfile-record by using the csv-module from Python 2.5.
 very simple indeed.

 Apart from this I have a configuration file, which contains the list of
 itemID's i need to focus on per month. Not all itemID's are relevant for
 each month, but for example only every second or third month. All
 records in the logfile with other itemID's can be ignored. I have yet to
 define the format of this configuration file, but am thinking about a 0
 or 1 for each month, and then the itemID, like:
 1 0 0 1 0 0 1 0 0 1 0 0 123456 for a itemID 123456 which only needs
 consideration at first month of each quarter.

 My question to this forum is: which data structure would you propose?
 The logfile is not very big (about 200k max, average 200k) so I assume I
 can store in internal memory/list?

 How would you propose I tackle the filtering of relevant/non-relevant
 items from logfile? Would you propose I use a filter(func, list) for
 this task or is another thing better?

 In the end I want to mail the outcome of my process, but this seems
 straitforward from the documentation I have found, although I must
 connect to an external SMTP-server.

 Any tips, views, advice is highly appreciated!


 Jaap

 PS: when I load the logfile in a spreadsheet I can create a pivot table
 which does about the same ;-] but that is not what I want; the
 processing must be automated in the end with a periodic script which
 e-mails the summary of the keyfigure every month.


I would do something like this: (obviously untested)

for line in readlines(open(logfile,r,1)):
(code to get hold of item, date, amount)
if item not in item_dict:
item_dict[item] = [(date,amount)]
else:
item_dict[item].append(date,amount)

this will give you, for each unique item, a direct ref to wherever its been
used.

I would then work through the config file, and extract the items of interest for
the run date...

HTH - Hendrik



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


adding python scripting to my application

2006-11-05 Thread Julian
Hi, first of all, I have to say I am new to Python. I have been working
with a finite element analysis program written in c++. now, I am trying
to 'rebuild' this code (possibly a full re-write) with scripting
capability. I did some reading on the web, and found that there are two
ways to do this : extending and embedding. and I still haven't figured
out what I should be using. I guess the first thing is to figure out
what I am to do with the scripting capability - at the very least, I
would like to run parametric analyses - run multiple analysis models by
changing certain parameters using for loops.
i found that the commercial fea package - abaqus uses python as well -
I don't know whether they embedded or extended ? is there any way to
find out?
another fea application called OOF2
(http://www.ctcms.nist.gov/oof/oof2/#features) says OOF2 is completely
scriptable in Python. and I don't really understand what that means...
maybe I haven't grasped the full potential of what python scripting
could do for an fea program.

can you tell me how to decide what path I should take - embed or extend
? or maybe some one could point me to some document/webpage that talks
about this.

thanks a lot,
Julian.

PS, my fea program uses its own script to read the analysis model
information using the c++ iostream and our own parsing functions - but
I don't have to stick to those function when I am writing the new code.

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


Re: wing ide vs. komodo?

2006-11-05 Thread [EMAIL PROTECTED]
Karlo Lozovina wrote:
 vj [EMAIL PROTECTED] wrote in news:1162708898.962171.161120
 @e3g2000cwe.googlegroups.com:

  The embedded python shell is also a useful feature.

 Yes, but Debug Probe and Stack Data absolutely rock! Can't live without
 them anymore. Just set a breakpoint, run your code end then you can
 inspect all of the structures via Stack Data, and you can play with those
 structures using Debug Probe. Huge productivity boost...

Those are pretty basic features that any environment supporting a
symbolic python debugger should have, they're not a distinguishing
feature for one particular IDE--I wouldn't expect any environment that
didn't allow that to even be in the discussion.

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


Timer Usage

2006-11-05 Thread chewjeremy
I'm planning to do C++ development together with Python on Linux. I
understand that Linux allows only one timer per process. Does Python
use the Linux timer? If so, how do I use the timer without interfering
with Python?

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


how can I send several command by useing pexpect ssh

2006-11-05 Thread haishan chang
I have studied pexpect example sshls.py and ssh_session.py, trying to carry several linux command by ssh. for example.
1. ssh connect one remotehost,
2. cd /tmp directory
3. mkdir myname
4. touch output.log

But I found these examplesonly can carry one command.who knows how to carry sereval linux command continuely.
Background: I have hundreds computers, and try to control all computers at one time.
thank you very much.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: how do I pass values between classes?

2006-11-05 Thread kath
hi, Larry Bates  thanks for the reply...

 You might consider doing it the same way wx passes things around.
 When you instantiate the subclass pass the parent class' instance
 as first argument to __init__ method.

Yes thats absolutely right..

 That way the subclass can
 easily pass values back to the parent by using that pointer.

Could you please explain me this.. more clearly. I think it is much
close to the solution.


Thank you.
regards, sudhir

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


Re: Is there a way to define a true global across modules?

2006-11-05 Thread Hendrik van Rooyen
 alex23 [EMAIL PROTECTED] wrote:

 Hendrik van Rooyen wrote:
  robert [EMAIL PROTECTED] wrote:
   Fredrik Lundh wrote:
   
http://www.effbot.org/pyfaq/how-do-i-share-global-variables-across-modules.htm

   Or worse style - if you are too lazy to create a extra global variables
module
   (ab)use the __main__ module als global:
   import __main__
   __main__.mysemphore += 1

  Thanks - how could you possibly have guessed that I am lazy - does it show
that
  much?  *WEG*

 You could merge the two approaches and bind a more explicit name to
 __main__:

 import __main__ as config

 config.mysemaphore = 0

 It's a little clearer what you're subverting __main__ for here :)

 - alex23

Thanks - clever and clear!

- Hendrik

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


Re: question about loading variables from a file...

2006-11-05 Thread georgeryoung
On Nov 5, 2:26 pm, avidfan [EMAIL PROTECTED] wrote:
 Can someone offer some advice as to how the best way to approach this
 might be?

 I am trying to write a generic python script to build out some
 applications, so the python script will be generic enough to work for
 all of them, but it needs to 'source' a file that contains app and
 environment specific variables.

 I have used WLST, which provides the loadProperties() method for
 reading values for weblogic domains, but I'm trying to find the best
 way to do the same sort of thing in python...

Try configparser:
 http://docs.python.org/lib/module-ConfigParser.html

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


[ python-Bugs-1590036 ] __getattr__ = getattr crash

2006-11-05 Thread SourceForge.net
Bugs item #1590036, was opened at 2006-11-03 16:44
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590036group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Closed
Resolution: Duplicate
Priority: 6
Private: No
Submitted By: Brian Harring (ferringb)
Assigned to: Armin Rigo (arigo)
Summary: __getattr__ = getattr crash

Initial Comment:
class c(object):__getattr__ = getattr
c().spam

segfault from overflowing the c stack

Now granted... it's retarded to attempt this.  But out
of curiousity, I decided to be the retard, and noticed
the interpreter crashes instead of triggering a
RuntimeError for recursion.

As far as I know, getattr is instrumented with
Py_EnterRecursiveCall and Py_LEaveRecursiveCall... so a
bit curious as to how it's occuring.

--

Comment By: Armin Rigo (arigo)
Date: 2006-11-05 09:30

Message:
Logged In: YES 
user_id=4771

This is a particular case of bug #1202533.

With Brett we arrived at a patch in #1202533 which
should solve a family of similar problems.  Can you
check that it also solves the __getattr__=getattr
attack?  If so, we should check in Brett's patch.

--

Comment By: Brian Harring (ferringb)
Date: 2006-11-05 03:57

Message:
Logged In: YES 
user_id=874085

can do the same trick with hasattr also (same type of fix)...

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-11-04 19:40

Message:
Logged In: YES 
user_id=33168

The attached patch fixes this problem.  However, I'm
concerned there are more places like this.  I hope Armin has
some ideas if more things are needed to fix this problem.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590036group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1590804 ] python: Python/ast.c:541: seq_for_testlist: Assertion

2006-11-05 Thread SourceForge.net
Bugs item #1590804, was opened at 2006-11-05 08:13
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590804group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: AST
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jay T Miller (jaytmiller)
Assigned to: Nobody/Anonymous (nobody)
Summary: python: Python/ast.c:541: seq_for_testlist: Assertion

Initial Comment:
When I build Python for debug using --with-pydebug on
linux platforms (RHEL3 or FC6) I get the following
assertion error when I try to install numpy-1.0:

[EMAIL PROTECTED] numpy-1.0]$ python setup.py install
Running from numpy source directory.
python: Python/ast.c:541: seq_for_testlist: Assertion
`((n)-n_type) == 326 || ((n)-n_type) == 318 ||
((n)-n_type) == 319 || ((n)-n_type) == 300' failed.
Abort



--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590804group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1590864 ] subprocess deadlock

2006-11-05 Thread SourceForge.net
Bugs item #1590864, was opened at 2006-11-05 11:06
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590864group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Tsai (michaeltsai)
Assigned to: Nobody/Anonymous (nobody)
Summary: subprocess deadlock

Initial Comment:
When I use subprocess.py from a child thread, sometimes it deadlocks. I 
determined that the new process is blocked during an import:

#0  0x90024427 in semaphore_wait_signal_trap ()
#1  0x90028414 in pthread_cond_wait ()
#2  0x004c77bf in PyThread_acquire_lock (lock=0x3189a0, waitflag=1)  
at Python/thread_pthread.h:452
#3  0x004ae2a6 in lock_import () at Python/import.c:266
#4  0x004b24be in PyImport_ImportModuleLevel (name=0xaad74 errno,  
globals=0xbaed0, locals=0x502aa0, fromlist=0xc1378, level=-1) at  
Python/import.c:2054
#5  0x0048d2e2 in builtin___import__ (self=0x0, args=0x53724c90,  
kwds=0x0) at Python/bltinmodule.c:47
#6  0x0040decb in PyObject_Call (func=0xa94b8, arg=0x53724c90,  
kw=0x0) at Objects/abstract.c:1860

and that the code in question is in os.py:

def _execvpe(file, args, env=None):
 from errno import ENOENT, ENOTDIR

I think the problem is that since exec (the C function) hasn't yet been 
called in the new process, it's inherited from the fork a lock that's already 
held. The main process will eventually release its copy of the lock, but this 
will not unlock it in the new process, so it deadlocks.

If I change os.py so that it imports the constants outside of  
_execvpe, the new process no longer blocks in this way.

This is on Mac OS X 10.4.8.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1590864group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >