Re: Game programming for kids: looking for open source 2D game development kit

2007-03-31 Thread Paul Rudin
John Salerno [EMAIL PROTECTED] writes:

 Laurent Pointal wrote:

 With Python:
 * pygame + build your drag'n drop features
 * if you like 3D, vpython.


 http://www.pygame.org/
 http://www.vpython.org/

 Wow, vpython looks pretty  need. I'm messing around with it right now
 and reading the docs. But I can't find something...do you know how to
 clear the contents of the current scene? I checked the attributes of
 the display, but there is nothing like empty that would do it.

for x in scene.objects: 
x.visible = 0

?

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


Re: Hpw make lists that are easy to sort.

2007-03-31 Thread Anton Vredegoor
Paul Rubin wrote:

 Oh, I see what you mean.  I don't see an obvious faster way to do it
 and I don't have the feeling that one necessarily exists.  As someone
 mentioned, you could do an n-way merge, which at least avoids using
 quadratic memory.  Here's a version using Frederik Lundh's trick of
 representing a lazy list as its head plus the generator for the tail:

That's a beautiful trick! I was just exploring some idea about 
traversing the matrix starting from the upper left and ending at the 
lower right by forming some kind of wave like front line. It's currently 
very slow but I hope it can be polished a bit.

Also I was trying to figure out if it could have any advantage over the 
straight row by row merge, but now that these lazy rows have appeared 
the field has changed a lot :-)

def typewriter(L,R):
 Z = [0] * len(R)
 M = [(L[0]+R[0],0)]
 while M:
 val,k = min(M)
 yield val
 Z[k] += 1
 M = []
 for k,x in enumerate(Z):
 if x  len(R):
 M.append((L[k]+R[x],k))
 if not x:
 break

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


wx textctrl font style

2007-03-31 Thread Pom
Hello

I have a tuple of strings which I must show in a textctrl, each item in 
the tuple representing one line of text.

The first three lines of text should each have another style (fontsize 
and color)

i'm using this code to achieve this:
   tmppos = self.txtInfo.GetInsertionPoint() # get the cursor pos
   self.txtInfo.write(str(csr[0])+'\n')
   tmppos2 = self.txtInfo.GetInsertionPoint() # get the new cursor pos
   self.txtInfo.SetStyle(tmppos, tmppos2, wx.TextAttr(BLUE, 
wx.NullColour, tmpnewfont))
   self.txtInfo.write(str(csr[1])+'\n')
   tmppos3 = self.txtInfo.GetInsertionPoint() # get the new cursor pos
   self.txtInfo.SetStyle(tmppos2, tmppos3, wx.TextAttr(BLUE, 
wx.NullColour, tmpnewfont2))
   self.txtInfo.write(str(csr[2])+'\n')
   tmppos4 = self.txtInfo.GetInsertionPoint() # get the new cursor pos
   self.txtInfo.SetStyle(tmppos3, tmppos4, wx.TextAttr(wx.Nullcolour, 
wx.NullColour, tmpnewfont3))


Now, I was wondering if this is the right way of doing this, because I 
have the feeling this code sucks.

Anybody has a better way of doing this?

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


Send Anti-Flickering off to logitech cam

2007-03-31 Thread eriq
Hi,

I am currently working with a Logitech Quickcam STX via USB. Using the
VideoCapture module to make pictures. Because the camera is outside I
will have to turn off a special Option on the camera called Anti-
Flickering. Is there anyway that I can send a hardware seq to the cam
to do this. Or manipulate the driver (Accessed via DirectX). Any
ideals what path I should follow to achieve this?

Thx

bytesman

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


Re: with timeout(...):

2007-03-31 Thread Nick Craig-Wood
Hendrik van Rooyen [EMAIL PROTECTED] wrote:
   Nick Craig-Wood [EMAIL PROTECTED] wrote:
 
  I'd like there to be something which works well enough for day to day
  use.  Ie doesn't ever wreck the internals of python.  It could have
  some caveats like may not timeout during C functions which haven't
  released the GIL and that would still make it very useable.
 
  I second this (or third or whatever if my post is slow).
  It is tremendously useful to start something and to be told it has timed
  out by a call, rather than to have to unblock the i/o yourself and
  to busy-loop to see if its successful.

Yes, exactly!

  And from what I can see the select functionality is not much
  different from busy looping...

Conceptually it is no different.  In practice your process goes to
sleep until the OS wakes it up again with more data so it is much more
CPU efficient (and possibly lower latency) than busy waiting.

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


Re: with timeout(...):

2007-03-31 Thread Nick Craig-Wood
John Nagle [EMAIL PROTECTED] wrote:
  Diez B. Roggisch wrote:
  Nick Craig-Wood wrote:
  
  
 Did anyone write a contextmanager implementing a timeout for
 python2.5?
 
 And have it work reliably and in a cross platform way!
  
  Cross platform isn't the issue here - reliability though is. To put it
  simple: can't be done that way. You could of course add a timer to the
  python bytecode core, that would jump back to a stored savepoint or
  something like that.
 
   Early versions of Scheme had a neat solution to this problem.
  You could run a function with a limited amount of fuel.  When the
  fuel ran out, the call returned with a closure.  You could
  run the closure again and pick up from where the function had been
  interrupted, or just discard the closure.

That sounds like a really nice concept.  That would enable you to make
long running stuff yield without threads too.

I wonder if it is possible in python...

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


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

2007-03-31 Thread Mark Dufour
Hi all,

I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an
optimizing Python-to-C++ compiler. Shed Skin allows for translation of
pure (unmodified), implicitly statically typed Python programs into
optimized C++, and hence, highly optimized machine language. Besides
many bug fixes and optimizations, these releases add the following
changes:

-support for 'bisect', 'collections.deque' and 'string.maketrans'
-improved 'copy' support
-support for 'try, else' construction
-improved error checking for dynamic types
-printing of floats is now much closer to CPython

For more details about Shed Skin and a collection of 27 programs, at a
total of about 7,000 lines, that it can compile (resulting in an
average speedup of about 39 times over CPython and 11 times over Psyco
on my computer), please visit the homepage at:

http://mark.dufour.googlepages.com

I could really use more help it pushing Shed Skin further. Simple ways
to help out, but that can save me lots of time, are to find smallish
code fragments that Shed Skin currently breaks on, and to help
improve/optimize the (C++) builtins and core libraries. I'm also
hoping someone else would like to deal with integration with CPython
(so Shed Skin can generate extension modules, and it becomes easier to
use 'arbitrary' external CPython modules such as 're' and 'pygame'.)
Finally, there may be some interesting Master's thesis subjects in
improving Shed Skin, such as transforming heap allocation into stack-
and static preallocation, where possible, to bring performance even
closer to manual C++. Please let me know if you are interested in
helping out, and/or join the Shed Skin mailing list.


Thanks!
Mark Dufour.
-- 
One of my most productive days was throwing away 1000 lines of code
- Ken Thompson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Long way around UnicodeDecodeError, or 'ascii' codec can't decode byte

2007-03-31 Thread Jarek Zgoda
Oleg Parashchenko napisał(a):

 I spent two hours fixing it, and I hope it's done. The solution is one
 of the ugliest hack I ever written, but it solves the pain. The full
 story and the code is in my blog:
 http://uucode.com/blog/2007/03/23/shut-up-you-dummy-7-bit-python/
 Calling sys.setdefaultencoding might not even help in this case, and
 the consensus is that it may be harmful to your code's portability
 [1].
 
 Yes, but I think UTF-8 is now everywhere.

No, it is not. Your own system is not ready for UTF-8, as you stated
somewhere in this blog entry. How can you expect everybody else's system
being utf-8, while you are not ready for transition?

It would be better if you write your programs in encoding-agnostic way,
using byte streams only for input and output (yes, printing a debug
statement on terminal *is* a kind of producing the output). An, oh, you
cann't encode/decode text not knowing the encoding...

-- 
Jarek Zgoda
http://jpa.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


os.system questions

2007-03-31 Thread Eric Price

Hi;
I have a couple bugs to work out in the below script; namely, I don't know 
how to capture the result of an os.system command, nor am I convinced that 
the call to os.system actually results in the execution of the command. Here 
is the script:


#!/usr/local/bin/python
import re, os

def freshReboot():
up = os.system(uptime)
if re.search('day|hour', up):
pass
else:
first = up
tup = re.split('min', up)
first = tup[0]
n = len(first)
char = first[n-3:n-2]
if re.match(' ', char):

os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)


Here are my problems:

up = os.system(uptime)
How do I assign the output of uptime to the variable up?

os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)
When I substitute a test variable for up, I don't get this script to 
actually run. Everything else is tested and works. Why won't this script 
run?


TIA,
Eric

_
It’s tax season, make sure to follow these few simple tips 
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=HMMartagline


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

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

2007-03-31 Thread Bjoern Schliessmann
Mark Dufour wrote:

 Shed Skin allows for translation of pure (unmodified), implicitly
 statically typed Python programs into optimized C++, and hence,
   ^
 highly optimized machine language. 
  

Wow, I bet all C++ compiler manufacturers would want you to work for
them.

Regards,


Björn

-- 
BOFH excuse #23:

improperly oriented keyboard

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


Re: What are OOP's Jargons and Complexities

2007-03-31 Thread Michele Dondi
On Fri, 30 Mar 2007 09:28:36 +0100, bugbear
[EMAIL PROTECTED] wrote:

Er. How about

public class test {
   public static void main(String[] args) {
 String a = a string;
 String b = another one;
 StringBuffer c = a + b;
 System.out.println(c);
 }
}

Even better: pick one entry of your choice from

http://images.google.com/images?q=%22don%27t+feed+the+troll%22


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}-(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^RY]*YB='
.'KYU;*EVH[.FHF2W+#\Z*5TI/ERZ`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:\r;print,redo}#JAPH,
-- 
http://mail.python.org/mailman/listinfo/python-list


Sorting a multidimensional array by multiple keys

2007-03-31 Thread Rehceb Rotkiv
Hello everyone,

can I sort a multidimensional array in Python by multiple sort keys? A 
litte code sample would be nice!

Thx,
Rehceb

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


Re: os.system questions

2007-03-31 Thread Thomas Krüger
Eric Price schrieb:
 up = os.system(uptime)
 How do I assign the output of uptime to the variable up?

|  print os.system.__doc__
| system(command) - exit_status
|
| Execute the command (a string) in a subshell.

os.system returns the exitcode of the given command. To get the output
try os.popen to os.popen4 or the commands lib.

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


Re: os.system questions

2007-03-31 Thread Amit Khemka
On 3/31/07, Eric Price [EMAIL PROTECTED] wrote:
 Hi;
 I have a couple bugs to work out in the below script; namely, I don't know
 how to capture the result of an os.system command, nor am I convinced that
 the call to os.system actually results in the execution of the command. Here
 is the script:

 #!/usr/local/bin/python
 import re, os

 def freshReboot():
 up = os.system(uptime)
 if re.search('day|hour', up):
 pass
 else:
 first = up
 tup = re.split('min', up)
 first = tup[0]
 n = len(first)
 char = first[n-3:n-2]
 if re.match(' ', char):
 
 os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)


 Here are my problems:

 up = os.system(uptime)
 How do I assign the output of uptime to the variable up?

 os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)
 When I substitute a test variable for up, I don't get this script to
 actually run. Everything else is tested and works. Why won't this script
 run?

os.system doesn't allow you to get the output of the program, use
os.popen instead.
example:
import os
up = os.popen('uptime').readlines()

Cheers,

-- 

Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Thomas Krüger
Rehceb Rotkiv schrieb:
 can I sort a multidimensional array in Python by multiple sort keys? A 
 litte code sample would be nice!

You can pass a function as argument to the sort method of a list.
The function should take two arguments and return -1, 0 or 1 as
comparison result. Just like the cmp function.

This will objects in list obj_lst by their id attributes:

def sorter(a, b):
return cmp(a.id, b.id)

obj_lst.sort(sorter)

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


Need help with python and pyxml on AIX

2007-03-31 Thread loial
I have been asked to install a python application on AIX 5.3 that runs
OK on Windows
I have installed Python 4.2.2 from python.org and pyXML form
sourceforge.

However when I run the application I get the following error :

class xml.sax._exceptions.SAXReaderNotAvailable

Do I need to set some Python environment variables?

Can I test the availibility of this from the python command line. e.g
import something?

I am new to Python

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread bearophileHUGS
Rehceb Rotkiv:
 can I sort a multidimensional array in Python by multiple sort keys? A
 litte code sample would be nice!

If you want a good answer you have to give me/us more details, and an
example too.

Bye,
bearophile

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


Re: os.system questions

2007-03-31 Thread Eric Price
Great! That seems to work fine:

#!/usr/local/bin/python
import re, os

def freshReboot():
up = os.popen('uptime').readlines()
up = up[0]
if re.search('day|hour', up):
pass
else:
tup = re.split('min', up)
first = tup[0]
n = len(first)
char = first[n-3:n-2]
if re.match(' ', char):

os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)

However, I don't see evidence that the os.system call at the end actually 
executes said script. The reason for this screwy script is because MySQL 
doesn't set the proper environment on boot and that screws up my Zope 
instances. So, I'll cron this script to run every 6 mins. If the server has 
been up less than 10 mins, this script will run. So, I rebooted the server 
and ran the script. But it didn't execute the os.system script at the end! 
If I run this from the python prompt instead:

import re, os

def a():
up = os.popen('uptime').readlines()
up = up[0]
up =  7:25AM  up 2 mins, 1 user, load averages: 2.42, 1.01, 0.41
if re.search('day|hour', up):
pass
else:
tup = re.split('min', up)
first = tup[0]
n = len(first)
char = first[n-3:n-2]
if re.match(' ', char):
print gotcha!

it prints gocha! Now, that substitution for the up var is what I got as 
output from the uptime command at the shell prompt. So, obviously, it 
should be running the script! What am I doing wrong?
TIA,
Eric

_
Watch free concerts with Pink, Rod Stewart, Oasis and more. Visit MSN 
Presents today. 
http://music.msn.com/presents?icid=ncmsnpresentstaglineocid=T002MSN03A07001

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


Re: os.system questions

2007-03-31 Thread Eric Price
Oops! The problem isn't in the os.system call. It's in the fact that I don't 
call the function. That is, I write a script called test.py with a 
function in it called freshReboot. Now, how do I call that function from 
test.py? That is, how do I write a cron event such that freshReboot 
actually gets called when I run test.py?
TIA,
Eric


From: Eric Price [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
CC: python-list@python.org
Subject: Re: os.system questions
Date: Sat, 31 Mar 2007 09:33:03 -0400

Great! That seems to work fine:

#!/usr/local/bin/python
import re, os

def freshReboot():
   up = os.popen('uptime').readlines()
   up = up[0]
   if re.search('day|hour', up):
   pass
   else:
   tup = re.split('min', up)
   first = tup[0]
   n = len(first)
   char = first[n-3:n-2]
   if re.match(' ', char):
   
 os.system(/usr/local/etc/rc.d/zz_mysql_starter_script.sh)

However, I don't see evidence that the os.system call at the end actually
executes said script. The reason for this screwy script is because MySQL
doesn't set the proper environment on boot and that screws up my Zope
instances. So, I'll cron this script to run every 6 mins. If the server has
been up less than 10 mins, this script will run. So, I rebooted the server
and ran the script. But it didn't execute the os.system script at the end!
If I run this from the python prompt instead:

import re, os

def a():
   up = os.popen('uptime').readlines()
   up = up[0]
   up =  7:25AM  up 2 mins, 1 user, load averages: 2.42, 1.01, 0.41
   if re.search('day|hour', up):
   pass
   else:
   tup = re.split('min', up)
   first = tup[0]
   n = len(first)
   char = first[n-3:n-2]
   if re.match(' ', char):
   print gotcha!

it prints gocha! Now, that substitution for the up var is what I got as
output from the uptime command at the shell prompt. So, obviously, it
should be running the script! What am I doing wrong?
TIA,
Eric

_
Watch free concerts with Pink, Rod Stewart, Oasis and more. Visit MSN
Presents today.
http://music.msn.com/presents?icid=ncmsnpresentstaglineocid=T002MSN03A07001

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

_
5.5%* 30 year fixed mortgage rate. Good credit refinance. Up to 5 free 
quotes - *Terms 
https://www2.nextag.com/goto.jsp?product=10035url=%2fst.jsptm=ysearch=mortgage_text_links_88_h2a5ds=4056p=5117disc=yvers=910

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Rehceb Rotkiv
 If you want a good answer you have to give me/us more details, and an
 example too.

OK, here is some example data:

reaction is BUT by the
sodium , BUT it is
sea , BUT it is
this manner BUT the dissolved
pattern , BUT it is
rapid , BUT it is

As each line consists of 5 words, I would break up the data into an array 
of five-field-arrays (Would you use lists or tuples or a combination in 
Python?). The word BUT would be in the middle, with two fields/words 
left and two fields/words right of it. I then want to sort this list by

- field 3
- field 4
- field 1
- field 0

in this hierarchy. This is the desired result:  

pattern , BUT it is
rapid , BUT it is
sea , BUT it is
sodium , BUT it is
reaction is BUT by the
this manner BUT the dissolved

The first 4 lines all could not be sorted by fields 3  4, as they are 
identical (it, is), so they have been sorted first by field 1 (which 
is also identical: ,) and then by field 0:

pattern
rapid
sea
sodium

I hope I have explained this in an understandable way. It would be cool 
if you could show me how this can be done in Python!

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Rehceb Rotkiv
Wait, I made a mistake. The correct result would be

reaction is BUT by the
pattern , BUT it is
rapid , BUT it is
sea , BUT it is
sodium , BUT it is
this manner BUT the dissolved

because by the comes before and the dissolved after it is. Sorry 
for the confusion.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Indentation for code readability

2007-03-31 Thread jkn
If I wanted to mark out stack depth stuff like this in python, I'd do
it
with some form of stylised comment, like this:

# LEVEL 0

pushMatrix():
# LEVEL 1

drawstuff()
pushMatrix()
# LEVEL 2

drawSomeOtherStuff()
popMatrix()
# LEVEL 1

popMatrix()
# LEVEL 0

(there's probably a better comment form for your specific
requirement).

Any decent modern editor should be capable of being set up to
highlight such lines in a colour/style of your choice, and you then
set your eyeball filter to look for those lines when you want to be
sure of where you are.

jon N

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


Opening Photoshop EPS with PIL?

2007-03-31 Thread [EMAIL PROTECTED]
Hey Everyone,

I am trying to get PIL to open some EPS files I have (Photoshop EPS,
whatever the difference is). I'm trying to use PIL to do this, but
when I run it, the following happens:

 from PIL import Image, ImageOps
 Image.open('/flora.eps')
Traceback (most recent call last):
  File console, line 1, in ?
  File /opt/local/lib/python2.4/site-packages/PIL/Image.py, line
1741, in open
return factory(fp, filename)
  File /opt/local/lib/python2.4/site-packages/PIL/ImageFile.py, line
82, in __init__
self._open()
  File /opt/local/lib/python2.4/site-packages/PIL/EpsImagePlugin.py,
line 206, in _open
raise IOError, bad EPS header

I've never had any real trouble with PIL before (never used it for EPS
though). Can anyone offer any advice on this one? I'd be most
grateful.

Many Thanks Everyone,
Oliver Beattie

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


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

2007-03-31 Thread skip

Björn Mark Dufour wrote:
 Shed Skin allows for translation of pure (unmodified), implicitly
 statically typed Python programs into optimized C++, and hence,
 highly optimized machine language.
Bjoern   

Bjoern Wow, I bet all C++ compiler manufacturers would want you to work
Bjoern for them.

Why are you taking potshots at Mark?  He's maybe onto something and he's
asking for help.  If he can generate efficient C++ code from implicitly
statically type Python it stands to reason that he can take advantage of the
compiler's optimization facilities.

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


Re: Newbie Question (real-time communication between apps: audio, 3d, PD, Blender)

2007-03-31 Thread Laurent Pointal
[EMAIL PROTECTED] wrote:

 Hi All,
 
 I'm just beginning my exploration of Python and I have a rather
 general question. If two particular programs have Python scripting
 capabilities, does that mean those two programs can communicate in
 real time through Python?
 
 I'm running some audio experiments (for artistic purposes) in the
 program Pure Data (PD). I would like to use data that I extract from
 audio files to affect 3-d game simulations in Blender.  I don't know
 specifically what it is I would be manipulating -- this is an artistic
 project, so intend to do a lot of experimenting to see what I come up
 with...
 
 My question(s): Is this possible, reasonable, plausible?

Plausible, with a recent PC.

I use some Java code + a research TTS engine (C) + Python code + Pure Data +
VirChor (3D renderer+interract, C++) in a TalkingHead project at LIMSI.
All these communicate via UDP, we just tries to keep amount of transmitted
data not too huge (ie. just transmit status, positions, commands...).
For the realtime side capacity, it depend on the process you need in
Python - if Python reveal to be too slow, you may write long computing code
into a separate C module or library (may see ctypes and pyrex). 
Another point, if you build Python multithreading code in same process, the
Global Lock may lead to unefficient use of your computing capacities.

Note. You may take a look at OSC (Open Sound Control), there is a module for
PD and one for Python.

A+

Laurent.

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


Re: Remote XML Parsing

2007-03-31 Thread Laurent Pointal
[EMAIL PROTECTED] wrote:

 On Mar 30, 5:56 pm, Laurent Pointal [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] a écrit :

  How can I parse a remote XML file with Python?
  And what will I be able to do with this XML file in Python?

  Sorry if this is a noob-ish question.

 You can process XML data with Python as long as you can get it - you
 will be able to do what you want with it.

 How do you access your remote file ?

 ...more details would be welcome...
 
 Well I'll be happy to access in the way your comfortable with.

Net protocols - urllib2 module
Local files (or network mounted files) - open function
Remote call - xmlrpc, omniORBpy, pyrpc...


Once you get the XML data... sax/dom/elementtree  Co (see Python docs, Dive
Into Python...).


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

saving Python process state for later debugging

2007-03-31 Thread yossi . kreinin
Hi!

Is there a way to save the state of a Python process for later
inspection with a debugger? One way to do this is to dump core, but is
the result usable for debugging with pdb (it can be debugged by gdb,
which can inspect PyObjects in a CPython core, for example, but it's
not much fun)?

If there is no way to do this today, are there essential difficulties
in implementing this on top of an OS support for raw core dumps?

TIA,
Yossi

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


wxPython help

2007-03-31 Thread [EMAIL PROTECTED]
i have installed wxpython v2.6 for python 2.4 
my python installation is at d:\python24

the statement import wx works perfectly
but when i use import images, it says that there is no module, but 
i know for a fact that there is.

can anyone help?


--
- --- -- -
Posted with NewsLeecher v3.8 Beta 8
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


Re: Mouse click in python

2007-03-31 Thread hlubenow
Synt4x wrote:

 I'm creating a webcam user interface (to control google earth through
 my webcam) and I still can't find a good example to how to control the
 mouse to click and drag (not just click and release).

Pygame:

http://www.pygame.org/
http://www.pygame.org/docs/ref/mouse.html

provides event-control including mouse-event-control.
Mainly it's intended for games, but it should work for other projects like
yours too. HTH

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


Re: os.system questions

2007-03-31 Thread Eric Price
Thank you :)
Eric


From: Parthan SR [EMAIL PROTECTED]
To: Eric Price [EMAIL PROTECTED]
Subject: Re: os.system questions
Date: Sat, 31 Mar 2007 19:52:01 +0530

On 3/31/07, Eric Price [EMAIL PROTECTED] wrote:

Oops! The problem isn't in the os.system call. It's in the fact that I
don't
call the function. That is, I write a script called test.py with a
function in it called freshReboot. Now, how do I call that function from
test.py? That is, how do I write a cron event such that freshReboot
actually gets called when I run test.py?


Just call the function name within the test.py itself

def freshReboot():
...
...
...
...

if __name__ == '__main__':
freshReboot()

(or)

freshReboot()

Now, run test.py. If you are printing anything or having a return value,
then it will be displayed in the terminal from where you call the program.
If you are executing it from another script, then the return value will be
returned where it is being called.
--
With Regards

---
Parthan.S.R.
Research Assistant
National Resource Center for Free/Open Source Software
Python Developer n00b

_
Interest Rates near 39yr lows! $430,000 Mortgage for $1,399/mo - Calculate 
new payment 
http://www.lowermybills.com/lre/index.jsp?sourceid=lmb-9632-18466moid=7581

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


Re: wxPython help

2007-03-31 Thread hg
Blh ([EMAIL PROTECTED]) wrote:

 i have installed wxpython v2.6 for python 2.4
 my python installation is at d:\python24
 
 the statement import wx works perfectly
 but when i use import images, it says that there is no module, but
 i know for a fact that there is.
 
 can anyone help?
 
 
 --
 - --- -- -
 Posted with NewsLeecher v3.8 Beta 8
 Web @ http://www.newsleecher.com/?usenet
 --- -  -- -

Maybe this:

http://mail.python.org/pipermail/python-list/2002-February/128104.html

hg

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


Re: os.system questions

2007-03-31 Thread David Brochu








From: Eric Price [EMAIL PROTECTED]
Date: March 31, 2007 9:38:53 AM EDT
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Cc: python-list@python.org
Subject: Re: os.system questions


Oops! The problem isn't in the os.system call. It's in the fact  
that I don't call the function. That is, I write a script called  
test.py with a function in it called freshReboot. Now, how do I  
call that function from test.py? That is, how do I write a cron  
event such that freshReboot actually gets called when I run test.py?

TIA,
Eric



 Eric - to call a function that is located inside another module  
you first need to import that module into the program you are running:



from test.py import * # this would import all functions from test.py
from test.py import freshReboot # this will import freshReboot from  
test.py



to call freshReboot in your program you would simply call it by it's  
name freshReboot


ex: x = freshReboot()-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Is any way to split zip archive to sections?

2007-03-31 Thread Tim Williams
On 30/03/07, Durumdara [EMAIL PROTECTED] wrote:
 Hi!

 I want to create some backup archives with python (I want to write a backup
 application in Python).
 Some package managers (7z, arj, winzip) can create splitted archives (1
 mega, 650, 700 mega, etc).

 Because I want to ftp these results to a ftp server, I want to split large
 volumes to 15 mb sections.

 Can I do it with any python wrapper automatically (like in Cobian), or I
 need to create the large volume, and next split it with another tool?

 Or anybody knows about a command line tool (like 7z, or arj) that can expand
 the splitted archive (and I can add files with them from Python one by one)?


If you are iterating through a list of files to be backed up, and
adding them to a ZIP one-by-one then you could use something like this
 which adds each file until the zip is over 15mb - then it closes the
ZIP and creates the next one.

Not tested or optimised :)
---
import zipfile

archive_num = 1
outfile = zipfile.ZipFile('/zips/archive%s.zip' % archive_num, w)
zsize = 0

for full_name in filelist:
full_name_path = os.path.join(full_name, full_path)

if zsize  15728640 : # 15mb
outfile.close()
archive_num += 1
outfile = zipfile.ZipFile('/zips/archive%s.zip' % archive_num, w)
zsize= 0

outfile.write( full_name_path , full_name_path ,
zipfile.ZIP_DEFLATED) # add the file
zsize += outfile.getinfo(full_name_path).compress_size #  get
compressed size of file

outfile.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Steven Bethard
Rehceb Rotkiv wrote:
 If you want a good answer you have to give me/us more details, and an
 example too.
 
 OK, here is some example data:
 
 reaction is BUT by the
 sodium , BUT it is
 sea , BUT it is
 this manner BUT the dissolved
 pattern , BUT it is
 rapid , BUT it is
 
 As each line consists of 5 words, I would break up the data into an array 
 of five-field-arrays (Would you use lists or tuples or a combination in 
 Python?). The word BUT would be in the middle, with two fields/words 
 left and two fields/words right of it. I then want to sort this list by
 
 - field 3
 - field 4
 - field 1
 - field 0

You're probably looking for the key= argument to list.sort().  If your 
function simply returns the fields in the order above, I believe you get 
the right thing::

  s = '''\
... reaction is BUT by the
... sodium , BUT it is
... sea , BUT it is
... this manner BUT the dissolved
... pattern , BUT it is
... rapid , BUT it is
... '''
  word_lists = [line.split() for line in s.splitlines()]
  def key(word_list):
... return word_list[3], word_list[4], word_list[1], word_list[0]
...
  word_lists.sort(key=key)
  word_lists
[['reaction', 'is', 'BUT', 'by', 'the'],
  ['pattern', ',', 'BUT', 'it', 'is'],
  ['rapid', ',', 'BUT', 'it', 'is'],
  ['sea', ',', 'BUT', 'it', 'is'],
  ['sodium', ',', 'BUT', 'it', 'is'],
  ['this', 'manner', 'BUT', 'the', 'dissolved']]

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Duncan Booth
Rehceb Rotkiv [EMAIL PROTECTED] wrote:

 Wait, I made a mistake. The correct result would be
 
 reaction is BUT by the
 pattern , BUT it is
 rapid , BUT it is
 sea , BUT it is
 sodium , BUT it is
 this manner BUT the dissolved
 
 because by the comes before and the dissolved after it is. Sorry 
 for the confusion.

 data = [
reaction is BUT by the,
sodium , BUT it is,
sea , BUT it is,
this manner BUT the dissolved,
pattern , BUT it is,
rapid , BUT it is,
]
 data = [ s.split() for s in data]
 from pprint import pprint
 pprint(data)
[['reaction', 'is', 'BUT', 'by', 'the'],
 ['sodium', ',', 'BUT', 'it', 'is'],
 ['sea', ',', 'BUT', 'it', 'is'],
 ['this', 'manner', 'BUT', 'the', 'dissolved'],
 ['pattern', ',', 'BUT', 'it', 'is'],
 ['rapid', ',', 'BUT', 'it', 'is']]
 from operator import itemgetter
 data.sort(key=itemgetter(0))
 data.sort(key=itemgetter(1))
 data.sort(key=itemgetter(4))
 data.sort(key=itemgetter(3))
 pprint(data)
[['reaction', 'is', 'BUT', 'by', 'the'],
 ['pattern', ',', 'BUT', 'it', 'is'],
 ['rapid', ',', 'BUT', 'it', 'is'],
 ['sea', ',', 'BUT', 'it', 'is'],
 ['sodium', ',', 'BUT', 'it', 'is'],
 ['this', 'manner', 'BUT', 'the', 'dissolved']]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What are OOP's Jargons and Complexities

2007-03-31 Thread Lew
Arved Sandstrom wrote:
 Timofei Shatrov [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 On Fri, 30 Mar 2007 06:48:05 GMT, Mike Schilling 
 [EMAIL PROTECTED]
 tried to confuse everyone with this message:

 Xah Lee wrote:

 So, a simple code like this in normal languages:
 becomes in Java:
 Only when written by someone almost entirely ignorant of Java.

 Which is the state most people want to be in...
 
 Which based on what I've seen, is the state that most Java programmers are 
 in. They'd have no idea why Mike said what he did.

what EVerrr!

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


Re: What are OOP's Jargons and Complexities

2007-03-31 Thread Lew
Michele Dondi wrote:
 Even better: pick one entry of your choice from
 
 http://images.google.com/images?q=%22don%27t+feed+the+troll%22

I pick http://img371.imageshack.us/img371/8263/noah7ok6rh.jpg/

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread attn . steven . kuo
On Mar 31, 6:42 am, Rehceb Rotkiv [EMAIL PROTECTED] wrote:

(snipped)

 As each line consists of 5 words, I would break up the data into an array
 of five-field-arrays (Would you use lists or tuples or a combination in
 Python?). The word BUT would be in the middle, with two fields/words
 left and two fields/words right of it. I then want to sort this list by

 - field 3
 - field 4
 - field 1
 - field 0



import StringIO

buf = 
reaction is BUT by the
sodium , BUT it is
sea , BUT it is
this manner BUT the dissolved
pattern , BUT it is
rapid , BUT it is
.lstrip()

mockfile = StringIO.StringIO(buf)

tokens = [ line.split() + [ line ] for line in mockfile ]
tokens.sort(key=lambda l: (l[3], l[4], l[1], l[0]))
for l in tokens:
print l[-1],


--
Hope this helps,
Steven

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


Re: os.system questions

2007-03-31 Thread Aahz
In article [EMAIL PROTECTED],
Eric Price [EMAIL PROTECTED] wrote:

I have a couple bugs to work out in the below script; namely, I don't
know how to capture the result of an os.system command, nor am I
convinced that the call to os.system actually results in the execution
of the command. Here is the script:

Although you've already figured out the problem, I'll just make the
standard recommendation for the subprocess module, assuming you have
Python 2.4 or later.
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

Need a book?  Use your library!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Peter Otten
Duncan Booth wrote:

 from operator import itemgetter
 data.sort(key=itemgetter(0))
 data.sort(key=itemgetter(1))
 data.sort(key=itemgetter(4))
 data.sort(key=itemgetter(3))

Or, in Python 2.5:

 data.sort(key=itemgetter(3, 4, 1, 0))

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


Re: Long way around UnicodeDecodeError, or 'ascii' codec can't decode byte

2007-03-31 Thread Paul Boddie
Oleg  Parashchenko wrote:
 On Mar 29, 4:53 pm, Paul Boddie [EMAIL PROTECTED] wrote:
  On 29 Mar, 06:26, Oleg  Parashchenko [EMAIL PROTECTED] wrote:
  
   I'm working on an unicode-aware application. I like to use print to
   debug programs, but in this case it was nightmare. The most popular
   result of print was:
  
   UnicodeDecodeError: 'ascii' codec can't decode byte 0xXX in position
   0: ordinal not in range(128)

I think I've found the actual source of this, and it isn't the print
statement. UnicodeDecodeError relates to the construction of Unicode
objects, not the encoding of such objects as byte strings. The
terminology is explained using this simple diagram (which hopefully
won't be ruined in transmission):

  byte string in XYZ encoding
  |
  (decode from XYZ) -- possible UnicodeDecodeError
  |
  V
  Unicode object
  |
  (encode to ABC) -- possible UnicodeEncodeError
  |
  V
  byte string in ABC encoding

  What does sys.stdout.encoding say?

 'KOI8-R'

[...]

  What do you get if you do this...?
 
  import locale
  locale.setlocale(locale.LC_ALL, )
  print locale.getlocale()

 ('ru_RU', 'koi8-r')

 
  What is your terminal encoding?

 koi8-r

Here's a transcript on my system answering the same questions:

  Python 2.4.1 (#2, Oct  4 2006, 16:53:35)
  [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2.1)] on linux2
  Type help, copyright, credits or license for more
information.
   import locale
   locale.getlocale()
  (None, None)
   locale.setlocale(locale.LC_ALL, )
  'en_US.ISO-8859-15'
   locale.getlocale()
  ('en_US', 'iso-8859-15')

So Python knows about the locale. Note that neither of us use UTF-8 as
a system encoding.

   import sys
   sys.stdout.encoding
  'ISO-8859-15'
   sys.stdin.encoding
  'ISO-8859-15'

This tells us that Python could know things about writing Unicode
objects out in the appropriate encoding. I wasn't sure whether Python
was so smart about this, so let's see what happens...

   print unicode(æøå)
  Traceback (most recent call last):
File stdin, line 1, in ?
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position
0: ordinal not in range(128)

Now this isn't anything to do with the print operation: what's
happening here is that I'm explicitly making a Unicode object but
haven't said what the encoding of my byte string is. The default
encoding is 'ascii' as stated in the error message. None of the
characters provided belong to the ASCII character set.

We can check this by not printing anything out:

   s = unicode(æøå)
  Traceback (most recent call last):
File stdin, line 1, in ?
  UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position
0: ordinal not in range(128)

So, let's try again and provide an encoding...

   print unicode(æøå, sys.stdin.encoding)
  æøå

Here, we've mentioned the encoding and even though the print statement
is acting on a Unicode object, it seems to be happy to work out the
resulting encoding.

   print uæøå
  æøå

Here, we've skipped the explicit Unicode object construction by using
a Unicode literal, which works in this simple case.

Of course, if your system encoding (along with the terminal) isn't
capable of displaying every Unicode character, you'll experience
problems doing the above. Frequently, it's interesting to encode
things as UTF-8 and look at them in applications that are capable of
displaying the text. Thus, you'd do something like this:

  import unicodedata

(This gets an interesting function to help us look up characters in
the Unicode database.)

  somefile = open(somefile.txt, wb)
  print somefile, unicodedata.lookup(MONGOLIAN VOWEL
SEPARATOR).encode(utf-8)

Or even this:

  import codecs
  somefile = codecs.open(somefile.txt, wb, encoding=utf-8)
  print somefile, unicodedata.lookup(MONGOLIAN VOWEL SEPARATOR)

Here, we only specified the encoding once when opening the file. The
file object accepts Unicode objects thereafter.

  Usually, if I'm wanting to print Unicode objects, I explicitly encode
  them into something I know the terminal will support. The codecs
  module can help with writing Unicode to streams in different
  encodings, too.

 As long as input/output is the only place for such need, it's ok to
 encode expliciyely. But I also had problems, for example, with md5
 module, and I don't know the whole list of potential problematic
 places. Therefore, I'd better go with my brutal utf8ization.

It's best to decode (ie. construct Unicode objects) upon receiving
data as input, and to encode (ie. convert Unicode objects to byte
strings) upon producing output. What may be the problem with the md5
module, and you'd have to post example code for us to help you out, is
that it assumes byte strings and doesn't work properly with Unicode
objects, but I can't say for sure because I'm usually presenting byte
strings to md5 module functions on the rare occasions I do anything
with them. Note that one would usually calculate MD5 checksums on raw
data, 

Re: When will 2.5.1 be released?

2007-03-31 Thread Martin v. Löwis
 And while we're waiting for 2.5.1, can somebody post a clear (as
 opposed to the one that comes with Tix ;)) explanation of how to
 manually install Tix into python 2.5?  It should be possible...
 
 LLoyd
 -Not possible - this is a known bug and won't be fixed until 2.5.1

This is not true. Copying the tix files into the Python installation
will work just fine.

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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Rehceb Rotkiv
Thank you all for your helpful solutions!

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


Re: Newbie Question (real-time communication between apps: audio, 3d, PD, Blender)

2007-03-31 Thread gregorywieber
Thank you, everyone!

On Mar 31, 6:43 am, Laurent Pointal [EMAIL PROTECTED]
wrote:
 [EMAIL PROTECTED] wrote:
  Hi All,

  I'm just beginning my exploration of Python and I have a rather
  general question. If two particular programs have Python scripting
  capabilities, does that mean those two programs can communicate in
  real time through Python?

  I'm running some audio experiments (for artistic purposes) in the
  program Pure Data (PD). I would like to use data that I extract from
  audio files to affect 3-d game simulations in Blender.  I don't know
  specifically what it is I would be manipulating -- this is an artistic
  project, so intend to do a lot of experimenting to see what I come up
  with...

  My question(s): Is this possible, reasonable, plausible?

 Plausible, with a recent PC.

 I use some Java code + a research TTS engine (C) + Python code + Pure Data +
 VirChor (3D renderer+interract, C++) in a TalkingHead project at LIMSI.
 All these communicate via UDP, we just tries to keep amount of transmitted
 data not too huge (ie. just transmit status, positions, commands...).
 For the realtime side capacity, it depend on the process you need in
 Python - if Python reveal to be too slow, you may write long computing code
 into a separate C module or library (may see ctypes and pyrex).
 Another point, if you build Python multithreading code in same process, the
 Global Lock may lead to unefficient use of your computing capacities.

 Note. You may take a look at OSC (Open Sound Control), there is a module for
 PD and one for Python.

 A+

 Laurent.


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


Re: What are OOP's Jargons and Complexities

2007-03-31 Thread Bart Willems
 
 Even better: pick one entry of your choice from
 
 http://images.google.com/images?q=%22don%27t+feed+the+troll%22
 
 
 Michele

OMG and here I am thinking that Ken Rockwell's site is full of crap. 
This one's worse... Does the guy have a job? Or a life?
-- 
http://mail.python.org/mailman/listinfo/python-list


Extending embedded python of multiple interpreters

2007-03-31 Thread vishnu
Hello All,

I have embedded python 2.5 in to my C application. As we need the
python scripts to run in multi threaded environment I have used
Py_NewInterpreter() and Py_EndInterpreter each time I execute a run
script function.
The code is as follows:
RunScript(char *pScriptName,char *pFuncName,...)
{
PyEval_AcquireLock()
threadState = Py_NewInterpreter();
PyThreadState_Swap(threadState);

/* Import the script module and run the fnc in that script module */
Pyobject *pModule = PyImport_Import(pScriptName);
PyObject *pFunc = PyObject_GetAttrString(pModule, pFuncName);

/* End running the script and calling the script fnc */
Py_EndInterpreter(threadState);
PyEval_ReleaseLock();
}.

And my python initialise looks as :
pythonInit() {
Py_initialise();
PyEval_initThreads();//which enables multi thread support
}

Now I am extending the embedded python to expose my application
library API's to python using SWIG. I written one extension module and
from python i am setting the C structure member values which i
wrapped. I execute this python code using call to RunScript (above
function), it works fine for the first time, but from second time
onwards I get an error - Type Error : in method
structurename_member_set.
Hence my question is the same python code worked for first call, but
from 2nd call it is not working. Could any body help me where I am
making mistake.

Is extension modules does not work properly with multiple
interpreters? Does any body had this behaviour when worked with
extension modules and multiple interpreters creation for each thread.

Thanks in Advance for the help.

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


Re: Game programming for kids: looking for open source 2D game development kit

2007-03-31 Thread pabloreda
I 'm doing the same

in forth...

www.reda4.org



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


Re: Sorting a multidimensional array by multiple keys

2007-03-31 Thread Duncan Booth
Peter Otten [EMAIL PROTECTED] wrote:

 Duncan Booth wrote:
 
 from operator import itemgetter
 data.sort(key=itemgetter(0))
 data.sort(key=itemgetter(1))
 data.sort(key=itemgetter(4))
 data.sort(key=itemgetter(3))
 
 Or, in Python 2.5:
 
 data.sort(key=itemgetter(3, 4, 1, 0))
 
Thanks, I'd forgotten itemgetter had that strangley assymmetric behaviour 
of returning either a single value or a tuple.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyPy for dummies

2007-03-31 Thread Georg Brandl
Cameron Laird schrieb:
 In article [EMAIL PROTECTED],
 Paddy [EMAIL PROTECTED] wrote:
   .
   .
   .
It is also European funding for an open source project with sprints.
I'm sure some eurocrat will be dissecting the project to see if it is
aa good way to fund technical projects.

- Paddy.

 
 PyPy-ers, what *are* the prospects in this direction?
 Are there write-ups planned that'll be of interest to
 computing people?

There is already a whole bunch of reports for the EU at

http://codespeak.net/pypy/extradoc/eu-report/

HTH,
Georg

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


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

2007-03-31 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:

 Why are you taking potshots at Mark? 

What suggests that I'm taking potshots at Mark?

 He's maybe onto something and he's asking for help.  If he can
 generate efficient C++ code from implicitly statically type Python
 it stands to reason that he can take advantage of the compiler's
 optimization facilities. 

Yes, compilers do output optimized machine code. But generally
calling that code highly optimized is, IMHO, exaggeration.

Regards,


Björn

-- 
BOFH excuse #426:

internet is needed to catch the etherbunny

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


help with dates

2007-03-31 Thread rustybear

I'm working on a website for some firefighters that want to be able to
sign-up for overtime and I need some help figuring out a date related
problem.

Here's the scenario:

Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.

I need to come up with a methodology for the following:

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


help with dates

2007-03-31 Thread rustybear
[sorry about the earlier post. accidently hit enter]

I'm working on a website for some firefighters that want to be able to
sign-up for overtime and I need some help figuring out a date related
problem.

Here's the scenario:

Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.

I need to come up with a methodology for the following:

If given a date, find out what group is working on that date.

Has anyone dealt with a problem like this before?  Obviously I'll need
to have a starting date where group1 is associated with a starting
date. Fortunately there are no surprises. Groups work in order
(1,2,3,4,1,2,3,4,1,2,...) and dates go in order and there are
absolutely no special exceptions for holidays and anything else.

Thanks in advance for any clues.

Kevin

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


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

2007-03-31 Thread Luis M. González
On Mar 31, 8:38 am, Bjoern Schliessmann usenet-
[EMAIL PROTECTED] wrote:
 Mark Dufour wrote:
  Shed Skin allows for translation of pure (unmodified), implicitly
  statically typed Python programs into optimized C++, and hence,

^ highly 
 optimized machine language.

   

 Wow, I bet all C++ compiler manufacturers would want you to work for
 them.

 Regards,

 Björn

 --
 BOFH excuse #23:

 improperly oriented keyboard


Mark has been doing an heroic job so far.
Shedskin is an impressive piece of software and, if pypy hadn't been
started some time ago, it should have gotten more attention from the
community.
I think he should be taken very seriously.

He is the first programmer I know who actually released working
code(and a lot of it) of a project that actually manages to speed up
python by a large margin, by means of advanced type inference
techniques.
Other people, in the past, have attended conferences and made
spectacular announcements of projects that could speed up python by
60x or more, but never ever released any code.

Mark has been working quietly for a long time, and his works deserves
a lot of credit (and hopefully, some help).




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


Re: help with dates

2007-03-31 Thread Pierre Quentel
 Four groups of firefighters (group1, group2, group3, group4). Each
 group works a 24 hr shift. So group1 works April 1, group2 works April
 2, group3 works April 3, group4 works April 4, group 1 works April 5,
 etc. It just keeps rolling like this forever into next year, etc.

 I need to come up with a methodology for the following:

 If given a date, find out what group is working on that date.

Hello,

You can use method datetime.date.toordinal() :

from datetime import date
start = date(2007,4,1) # Arpil 1, 2007

def group(_date):
return (date.toordinal(_date)-date.toordinal(start)) % 4

print group(date(2007,4,15))

Regards,
Pierre

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


I18n issue with optik

2007-03-31 Thread Thorsten Kampe
Hi,

I've written a script which uses Optik/Optparse to display the 
options (which works fine). The text for the help message is localised 
(with german umlauts) and when I execute the script with the localised 
environment variable set, I get this traceback[1]. The interesting 
thing is that the localised optparse messages from displays fine - 
it's only my localisation that errors.

From my understanding, my script doesn't put out anything, it's 
optik/optparse who does that. My po file is directly copied from the 
optik po file (who displays fine) and modified so the po file should 
be fine, too.

What can I do to troubleshoot whether the culprit is my script, optik 
or gettext?

Would it make sense to post the script and the mo or po files?


Thorsten

[1]
Traceback (most recent call last):
  File script.py, line 37, in module
options, args = cmdlineparser.parse_args()
  File /usr/lib/python2.5/optparse.py, line 1378, in parse_args
stop = self._process_args(largs, rargs, values)
  File /usr/lib/python2.5/optparse.py, line 1418, in _process_args
self._process_long_opt(rargs, values)
  File /usr/lib/python2.5/optparse.py, line 1493, in 
_process_long_opt
option.process(opt, value, values, self)
  File /usr/lib/python2.5/optparse.py, line 782, in process
self.action, self.dest, opt, value, values, parser)
  File /usr/lib/python2.5/optparse.py, line 804, in take_action
parser.print_help()
  File /usr/lib/python2.5/optparse.py, line 1648, in print_help
file.write(self.format_help().encode(encoding, replace))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 
264: ordinal not in range(128)
-- 
http://mail.python.org/mailman/listinfo/python-list


shelf membership

2007-03-31 Thread Aaron Brady
can you shelve objects with membership?

this gives you:

TypeError: object does not support item assignment
dict 0 True
Exception exceptions.TypeError: 'object does not support item assignment' 
in  ignored

 ignored is a bit mysterious.  tx in advance.

from shelve import *
class MyShelf(DbfilenameShelf):
def __init__(self, filename, flag='c', protocol=None, 
writeback=False, binary=None):
self.__dict__['ready']=False
DbfilenameShelf.__init__(self, filename, flag, protocol, 
writeback, binary)
self.ready=True
def __setattr__(self,name,value):
if not self.ready:
self.__dict__[name]=value
else:
print name, value, self.ready
self.__dict__[name]=value
DbfilenameShelf.__setitem__(self,name,value)

def open(filename, flag='c', protocol=None, writeback=False, binary=None):
  return MyShelf(filename, flag, protocol, writeback, binary)

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


Using Simple MAPI with MS Outlook 2007

2007-03-31 Thread tomer . ha
Hi there,

I'd like to send emails from a Python program using Simple MAPI. I've
tried this code: 
http://mail.python.org/pipermail/python-list/2004-December/298066.html
and it works well with Outlook Express 6 and Thunderbird 1.5, but it
doens't work at all with Microsoft Outlook 2007. I keep getting this
message: WindowsError: MAPI error 2.

I don't want to use Extended MAPI because it doesn't support
thunderbird not OE. Therefore, Simple MAPI is the only option for me.

So, what did I miss here?

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


Re: saving Python process state for later debugging

2007-03-31 Thread aspineux
On 31 mar, 16:48, [EMAIL PROTECTED] wrote:
 Hi!

 Is there a way to save the state of a Python process for later
 inspection with a debugger? One way to do this is to dump core, but is
 the result usable for debugging with pdb (it can be debugged by gdb,
 which can inspect PyObjects in a CPython core, for example, but it's
 not much fun)?

 If there is no way to do this today, are there essential difficulties
 in implementing this on top of an OS support for raw core dumps?

Pylon has something like that.
http://pylonshq.com/docs/0.9.4.1/interactive_debugger.html

Turbogears has the same with option tg.fancy_exception

You can navigate into the stack trace from the web interface :-)




 TIA,
 Yossi


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


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

2007-03-31 Thread Alexander Schmolck
Luis M. González [EMAIL PROTECTED] writes:

 On Mar 31, 8:38 am, Bjoern Schliessmann usenet-
 [EMAIL PROTECTED] wrote:
  Mark Dufour wrote:
   Shed Skin allows for translation of pure (unmodified), implicitly
   statically typed Python programs into optimized C++, and hence,
 
 ^ highly 
  optimized machine language.
 

 
  Wow, I bet all C++ compiler manufacturers would want you to work for
  them.
 
  Regards,
 
  Björn
 
  --
  BOFH excuse #23:
 
  improperly oriented keyboard
 
 
 Mark has been doing an heroic job so far.
 Shedskin is an impressive piece of software and, if pypy hadn't been
 started some time ago, it should have gotten more attention from the
 community.

Regardless of its merrits, it's GPL'ed which I assume is an immediate turn-off
for many in the community.

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


Re: help with dates

2007-03-31 Thread John Machin
On Apr 1, 7:51 am, Pierre Quentel [EMAIL PROTECTED] wrote:
  Four groups of firefighters (group1, group2, group3, group4). Each
  group works a 24 hr shift. So group1 works April 1, group2 works April
  2, group3 works April 3, group4 works April 4, group 1 works April 5,
  etc. It just keeps rolling like this forever into next year, etc.

  I need to come up with a methodology for the following:

  If given a date, find out what group is working on that date.

 Hello,

 You can use method datetime.date.toordinal() :

 from datetime import date
 start = date(2007,4,1) # Arpil 1, 2007

 def group(_date):
 return (date.toordinal(_date)-date.toordinal(start)) % 4

... whose possible outcomes are (0, 1, 2, 3) whereas the groups are
numbered 1 to 4. However I'm sure the OP can make the necessary
adjustment :-)


 print group(date(2007,4,15))

 Regards,
 Pierre


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


Re: shelf membership

2007-03-31 Thread John Machin
On Apr 1, 8:02 am, Aaron Brady [EMAIL PROTECTED] wrote:
 can you shelve objects with membership?

 this gives you:

 TypeError: object does not support item assignment
 dict 0 True
 Exception exceptions.TypeError: 'object does not support item assignment'
 in  ignored

  ignored is a bit mysterious.  tx in advance.

 from shelve import *
 class MyShelf(DbfilenameShelf):
 def __init__(self, filename, flag='c', protocol=None,
 writeback=False, binary=None):
 self.__dict__['ready']=False
 DbfilenameShelf.__init__(self, filename, flag, protocol,
 writeback, binary)
 self.ready=True
 def __setattr__(self,name,value):
 if not self.ready:
 self.__dict__[name]=value
 else:
 print name, value, self.ready
 self.__dict__[name]=value
 DbfilenameShelf.__setitem__(self,name,value)

 def open(filename, flag='c', protocol=None, writeback=False, binary=None):
   return MyShelf(filename, flag, protocol, writeback, binary)

Please supply the *full* traceback, using copy/paste.

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


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

2007-03-31 Thread Paul Boddie
Alexander Schmolck wrote:

 Regardless of its merrits, it's GPL'ed which I assume is an immediate turn-off
 for many in the community.

In the way that tools such as gcc are GPL-licensed, or do you have
something else in mind?

Paul

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


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

2007-03-31 Thread Paul McGuire
On Mar 31, 6:45 pm, Alexander Schmolck [EMAIL PROTECTED] wrote:
 Regardless of its merrits, it's GPL'ed which I assume is an immediate turn-off
 for many in the community.


Why would that be?  GPL'ed code libraries can be a turn-off for those
who want to release commercial products using them, but a GPL'ed
utility such as a compiler bears no relationship or encumbrance on the
compiled object code it generates.

-- Paul

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


Unicode list

2007-03-31 Thread Rehceb Rotkiv
Hello,

I have this little grep-like program:

++snip++
#!/usr/bin/python

import sys
import re

pattern = sys.argv[1]
inputfile = file(sys.argv[2], 'r')

for line in inputfile:
matches = re.findall(pattern, line)
if matches:
print matches
++snip++

Like this, the program prints some characters as strange escape 
sequences, which is due to the input file being encoded in utf-8: When I 
convert re.findall... to a string and wrap an unicode() around it, 
the matches get printed correctly. Is it possible to make matches 
unicode without saving it as a single string first? The function unicode
() seems only to work for strings. Or is there a general way of telling 
Python to abandon the ancient and evil land of iso-8859 for good and use 
utf-8 only?

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


Re: Unicode list

2007-03-31 Thread Paul Boddie
Rehceb Rotkiv wrote:
 Hello,

 I have this little grep-like program:

 ++snip++
 #!/usr/bin/python

 import sys
 import re

 pattern = sys.argv[1]
 inputfile = file(sys.argv[2], 'r')

 for line in inputfile:
 matches = re.findall(pattern, line)
 if matches:
 print matches
 ++snip++

 Like this, the program prints some characters as strange escape
 sequences, which is due to the input file being encoded in utf-8:

So the UTF-8 data gets printed to your terminal which isn't configured
for UTF-8, right?

 When I convert re.findall... to a string and wrap an unicode() around it,
 the matches get printed correctly.

How do you meaningfully convert it to a string? The matches variable
refers to a list, but you surely don't want to be dealing with the
list's string representation.

 Is it possible to make matches unicode without saving it as a single string 
 first?

Why not convert your input into Unicode and then, for the benefit of
certain kinds of character classes, use re.findall in Unicode mode (by
specifying re.U as a flag)? Then, each match will be produced as a
Unicode object.

 The function unicode() seems only to work for strings. Or is there a 
 general way of telling
 Python to abandon the ancient and evil land of iso-8859 for good and use 
 utf-8 only?

The only refuge from ancient and evil lands is found by climbing the
mountain of Unicode: convert from encoded text as soon as you can,
work only with Unicode objects, produce encoded text only when
necessary.

Paul

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


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

2007-03-31 Thread Paul Rubin
Paul McGuire [EMAIL PROTECTED] writes:
 Why would that be?  GPL'ed code libraries can be a turn-off for those
 who want to release commercial products using them, but a GPL'ed
 utility such as a compiler bears no relationship or encumbrance on the
 compiled object code it generates.

For some of us, doing volunteer work on non-GPL projects is a
turn-off.  I don't mind writing code that goes into proprietary
products, but I expect to get paid for it just like the vendors of the
products expect to get paid.  If I'm working for free I expect the
code to stay free.  This is why I don't contribute code to Python on
any scale.
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2007-03-31 Thread Bjoern Schliessmann
Luis M. González wrote:

 I think he should be taken very seriously.

Agreed.

Okay, it seems focusing a discussion on one single point is
difficult for many people. Next time I'll be mind-bogglingly clear
that even the last one understands after reading it one time ...
 
Regards,


Björn

Fup2 p

-- 
BOFH excuse #46:

waste water tank overflowed onto computer

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


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

2007-03-31 Thread Luis M. González
On Mar 31, 10:31 pm, Bjoern Schliessmann usenet-
[EMAIL PROTECTED] wrote:
 Luis M. González wrote:
  I think he should be taken very seriously.

 Agreed.

 Okay, it seems focusing a discussion on one single point is
 difficult for many people. Next time I'll be mind-bogglingly clear
 that even the last one understands after reading it one time ...

 Regards,

 Björn

 Fup2 p

 --
 BOFH excuse #46:

 waste water tank overflowed onto computer


Bjoern,

I understood what you said. It's just that it seemed that you were
mocking at the poster's message.
I apologize if that wasn't your intention.

Luis

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


Re: I18n issue with optik

2007-03-31 Thread Steven Bethard
Thorsten Kampe wrote:
 I've written a script which uses Optik/Optparse to display the 
 options (which works fine). The text for the help message is localised 
 (with german umlauts) and when I execute the script with the localised 
 environment variable set, I get this traceback[1]. The interesting 
 thing is that the localised optparse messages from displays fine - 
 it's only my localisation that errors.
 
 From my understanding, my script doesn't put out anything, it's 
 optik/optparse who does that. My po file is directly copied from the 
 optik po file (who displays fine) and modified so the po file should 
 be fine, too.
 
 What can I do to troubleshoot whether the culprit is my script, optik 
 or gettext?
 
 Would it make sense to post the script and the mo or po files?

Yes, probably.  Though if you can reduce it to the simplest test case 
that produces the error, it'll increase your chances of having someone 
look at it.

You could also try posting to the optik list:
 http://lists.sourceforge.net/lists/listinfo/optik-users

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


CRC CCITT UPDATE in Python

2007-03-31 Thread pythoneiro
Please,

  Please, is there here some good soul that understand this
functions hi8 and lo8 (from GCC AVR) and can help me to port it to
Python?

uint16_t
crc_ccitt_update (uint16_t crc, uint8_t data)
{
   data ˆ= lo8 (crc);
   data ˆ= data  4;
   return uint16_t)data  8) | hi8 (crc)) ˆ (uint8_t)(data  4)
ˆ ((uint16_t)data  3));
}

Source: 
http://tldp.tuxhilfe.de/linuxfocus/common/src2/article352/avr-libc-user-manual-1.0.4.pdf

 Reason, I would like to code in Python one simulator from one
code C++ AVR

Thanks.,

./Fã  -Py -Thorneiro

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

Pygame Q (linux) beginner

2007-03-31 Thread enquiring mind
Running 2.4.1 Python (learning)
Running SUSE Linux 10

Am learning from a new books that mostly deals with windows python and
Pygames called Game Programming by Randy Harris (2007)  His books
references Python 2.4.2 and Pygame 1.7.1 with these comments:  

If you are using a Linux machine, you probably won't have the simple
installer that came with the windows version.  Follow the instructions
at http://pygame.org/install.  You may have to run a couple of scripts
to make everything work, but just follow the directions and you will be
fine.  

Could anybody suggest or make a helpful comment in view of what
information I have supplied.  At Chapter 5 is where the Pygame module is
introduced so I have a little time before I have to figure out what I
have to download and install.  

Thanks very much in advance for any direction. 

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


re.findall() hangs in python

2007-03-31 Thread [EMAIL PROTECTED]
Hi,

I have the following regular expression.
It works when 'data' contains the pattern and I see 'match2' get print
out.
But when 'data' does not contain pattern, it just hangs at
're.findall'

pattern = re.compile((.*)img (.*?) src=\(.*?)img(.*?)\(.*?),
re.S)

print before find all

match = re.findall(pattern, data)

if (match):
   print match2



Can you please tell me why it that?

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


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

2007-03-31 Thread Michael Torrie
On Sun, 2007-04-01 at 02:49 +, Dennis Lee Bieber wrote:
   Take that up with ACT... GNAT 3.15p was explicitly unencumbered, but
 the current version of GNAT, in the GPL (no-service contract) form has
 gone the other direction, claiming that executables must be released
 GPL.

The no-service contract version of the GPL is not the same as the
standard GPLv2.  Ordinarily the GPLv2 does not apply to the output of
the program unless the license specifies that it does (a modification or
addendum).  Thus the output of a program is not part of the GPL usually,
unless specified  MySQL's take on the GPLv2 without an addendum is
mistaken, in my opinion.  However, copyright law probably still applies
to the programs output regardless of license, but in what way I don't
think the courts have ever specified, given that the output depends
largely on the input.  GCC, Bison, and Flex, all explicitly state that
the output of the program is not under any license, and is your own
property.  Perhaps the author of Shed Skin could make a note in the
license file to clarify the state of the output of his program.

There should be no problem with this Shed Skin program being under the
GPL and using it with python scripts that are not under the GPL.  But if
you have any concern with a copyright license at all, you should consult
your lawyer.  Too many companies see GPL'd programs as a free ride, not
willing to accept that they need a copyright license to use the code
just as they would with any code from any source.  It's sad to see
because free software gets an unfair bad rap because of the greed of
others.  On the other hand, others take an overly paranoid view of the
GPL and pretend it is viral and somehow magically infects your code with
the GPL license, which is false--if you use GPL'd code in your non GPL'd
application then you are in a copyright violation situation and your
only options are to either GPL your code or remove the offending GPL'd
source from your code and write your own dang code, thank you very much.



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


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

2007-03-31 Thread Paul Rubin
Michael Torrie [EMAIL PROTECTED] writes:
 The no-service contract version of the GPL is not the same as the
 standard GPLv2.

I don't see how that can be--we're talking about a GCC-based compiler,
right?
-- 
http://mail.python.org/mailman/listinfo/python-list


Generic logic/conditional class or library for classification of data

2007-03-31 Thread Basilisk96
This topic is difficult to describe in one subject sentence...

Has anyone come across the application of the simple statement if
(object1's attributes meet some conditions) then (set object2's
attributes to certain outcomes), where object1 and object2 are
generic objects, and the conditions and outcomes are dynamic run-
time inputs? Typically, logic code for any application out there is
hard-coded. I have been working with Python for a year, and its
flexibility is nothing short of amazing. Wouldn't it be possible to
have a class or library that can do this sort of dynamic logic?

The main application of such code would be for classification
algorithms which, based on the attributes of a given object, can
classify the object into a scheme. In general, conditions for
classification can be complex, sometimes involving a collection of
and, or, not clauses. The simplest outcome would involve simply
setting a few attributes of the output object to given values if the
input condition is met. So each such if-then clause can be viewed as
a rule that is custom-defined at runtime.

As a very basic example, consider a set of uncategorized objects that
have text descriptions associated with them. The objects are some type
of tangible product, e.g., books. So the input object has a
Description attribute, and the output object (a categorized book)
would have some attributes like Discipline, Target audience, etc.
Let's say that one such rule is if ( 'description' contains
'algebra') then ('discipline' = 'math', 'target' = 'student') . Keep
in mind that all these attribute names and their values are not known
at design time.

Is there one obvious way to do this in Python?
Perhaps this is more along the lines of data mining methods?
Is there a library with this sort of functionality out there already?

Any help will be appreciated.

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


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

2007-03-31 Thread Michael Torrie
On Sat, 2007-03-31 at 20:47 -0700, Paul Rubin wrote:
 Michael Torrie [EMAIL PROTECTED] writes:
  The no-service contract version of the GPL is not the same as the
  standard GPLv2.
 
 I don't see how that can be--we're talking about a GCC-based compiler,
 right?

Well, that's beside the point anyway.  The output of a program is beyond
the scope of the source code license for the program.  However the
default is for the output to be copyrighted the author.  Thus the author
of a program is free to say (give license, in other words) that the
output of a program can distributed.  The real point is the Shed Skin
author can both license the program under the GPLv2 and also say that
the output from his program is not bound by any license.  There's no
conflict unless the author of Shed Skin wants there to be.  Worst case,
if indeed the GPLv2 says it covers the output of the program (which I
don't believe it does), copyright law still trumps everything and the
author is free at add an exemption to the license if he chooses, which
is what I've seen done with Bison.  Bison is also a special case because
the output of bison contains code fragments that are part of the bison
source code itself, which is under the GPL.  Thus a special exception
had to be made in this case.  

Anyway, the only real point is that if there is a concern about the
copyright and licensing of the output of Shed Skin, then we merely need
to ask the author of it to clarify matters and move on with life.  With
the exception of GNAT, to date no GPL'd compiler has ever placed a GPL
restriction on its output.  Whether this is explicit or implicit doesn't
matter, so long as it's there.




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


Converting _node* to a Code object?

2007-03-31 Thread Brendon Costa
Hi All,

I have an application with an embedded python interpreter and i need to
get the embedded interpreter to import strangely named files as python
modules.

Anyhow the simple part of the question is:

How do i convert a _node* object returned from:
PyParser_SimpleParseStringFlagsFilename()

into a code object i can use as a module to import with:
PyImport_ExecCodeModule()


I cant seem to find any documentation about this. If you are wondering
why i want to do this, then you can read on and maybe there is a much
better way to achieve what i am after.



Thanks,
Brendon




- What i am trying to achieve -


Basically i want to import using the python C API a module from
various files which may have names that do not make valid python module
names.


In particular i have an embedded python interpreter that is used to
apply a number of operations on some data based on a user supplied
suppressions file (*.eds). This .eds file is just a python source file
designed only to be used from within this application.


Now the names of these suppression files usually matche that of a
library or application to which they will apply to. For example:

libstdc++.so.6.0.5 : has eds file: libstdc++.so.6.0.5.eds


Now i want to have my code import this eds file as a python module so
that i can then use it as any other standard python module. So i need to
separate the name of the module from the name of the file. I was
thinking for example for the above filename i would give it a module
name like:

libstdc___so_6_0_5

(The name is not important just that the above one is a valid module
name from what i understand and it is based on the original name)

So i have some random file:
/foo/bar/lib/libstdc++.so.6.0.5.eds

and i want to be able to import that as a module using the Python C API
so native python code can access the module like:

libstdc___so_6_0_5.PostCalculation()


If you have any better method of doing this, i would love to know what
it is.

Thanks in advance for any help,
Brendon.


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


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

2007-03-31 Thread Michael Torrie
On Sat, 2007-03-31 at 20:47 -0700, Paul Rubin wrote:
 Michael Torrie [EMAIL PROTECTED] writes:
  The no-service contract version of the GPL is not the same as the
  standard GPLv2.
 
 I don't see how that can be--we're talking about a GCC-based compiler,
 right?

I found the real reason why the GPL'd GNAT compiler's produced
executables are required to be GPL'd, and it has nothing to do with the
license of the compiler:

What is the license of the GNAT GPL Edition?
Everything (tools, runtime, libraries) in the GNAT GPL Edition is
licensed under the General Public License (GPL). This ensures that
executables generated by the GNAT GPL Edition are Free Software and that
source code is made available with the executables, giving the freedom
to recepients to run, study, modify, adapt, and redistribute sources and
execuatbles under the terms of the GPL.[1]

Note that it says the runtime *and* the libraries are GPL. Thus the
linking clause in the GPL requires that programs that link against them
(the executable in other words) must be GPL'd.  Note that GLibC, while
being GPL, has an exception clause in it, allowing linking to it by code
of any license.

Hence it's a red herring as far as the discussion and Shed Skin is
concerned, although the licensing of any Shed Skin runtime libraries
should be a concern to folks.

[1] https://libre.adacore.com/

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


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

2007-03-31 Thread John Nagle
Mark Dufour wrote:
 Hi all,
 
 I have recently released version 0.0.20 and 0.0.21 of Shed Skin, an
 optimizing Python-to-C++ compiler. Shed Skin allows for translation of
 pure (unmodified), implicitly statically typed Python programs into
 optimized C++, and hence, highly optimized machine language. Besides
 many bug fixes and optimizations, these releases add the following
 changes:
 
 I'm also
 hoping someone else would like to deal with integration with CPython
 (so Shed Skin can generate extension modules, and it becomes easier to
 use 'arbitrary' external CPython modules such as 're' and 'pygame'.)

Reusing precompiled external modules will be tough.  Even
CPython has trouble with that.  But that's just a conversion
problem.  Maybe SWIG (yuck, but it exists) could be persuaded
to cooperate.

For regular expressions, here's an implementation, in C++,
of Python-like regular expressions.

http://linuxgazette.net/issue27/mueller.html

That might be a way to get a regular expression capability into
Shed Skin quickly.

 Finally, there may be some interesting Master's thesis subjects in
 improving Shed Skin, such as transforming heap allocation into stack-
 and static preallocation, where possible, to bring performance even
 closer to manual C++. Please let me know if you are interested in
 helping out, and/or join the Shed Skin mailing list.

Find out where the time is going before spending it on that.

A good test: BeautifulSoup.  Many people use it for parsing
web pages, and it's seriously compute-bound.

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


Re: CRC CCITT UPDATE in Python

2007-03-31 Thread Martin v. Löwis

   Please, is there here some good soul that understand this
 functions hi8 and lo8 (from GCC AVR) and can help me to port it to
 Python?
 
 uint16_t
 crc_ccitt_update (uint16_t crc, uint8_t data)
 {
data ˆ= lo8 (crc);
data ˆ= data  4;
return uint16_t)data  8) | hi8 (crc)) ˆ (uint8_t)(data  4)
 ˆ ((uint16_t)data  3));
 }

Most likely, lo8(crc) == crc  0xFF, and hi8(crc) == (crc  8)  0xFF
(the last bit masking might be redundant, as crc should not occupy more
than 16 bits, anyway).

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

Re: Unicode list

2007-03-31 Thread Martin v. Löwis
 Like this, the program prints some characters as strange escape 
 sequences, which is due to the input file being encoded in utf-8: When I 
 convert re.findall... to a string and wrap an unicode() around it, 
 the matches get printed correctly. Is it possible to make matches 
 unicode without saving it as a single string first? The function unicode
 () seems only to work for strings. Or is there a general way of telling 
 Python to abandon the ancient and evil land of iso-8859 for good and use 
 utf-8 only?

Python does not live in the ancient and evi land of iso-8859; it lives
in the ancient and evil land of ASCII.

When printing a list, the individual elements are converted with repr(),
not with str(). For a string object, repr() adds escape codes for all
bytes that are not printable ASCII characters. To avoid this call to
repr, you need to iterate over the list yourself, and print it:

if matches:
for m in matches:
print m,
print

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


[ python-Bugs-1689458 ] pdb unable to jump to first statement

2007-03-31 Thread SourceForge.net
Bugs item #1689458, was opened at 2007-03-27 17:07
Message generated for change (Comment added) made by rockyb
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1689458group_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: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: gotgenes (gotgenes)
Assigned to: Nobody/Anonymous (nobody)
Summary: pdb unable to jump to first statement

Initial Comment:
The Python debugger is unable to jump back to the first executable statement 
in a frame once that statement has been executed. For example:

[EMAIL PROTECTED]:~/development/playground$ python -m pdb simple.py 
 /home/chris/development/playground/simple.py(3)?()
- a = 1
(Pdb) next
 /home/chris/development/playground/simple.py(4)?()
- b = 2
(Pdb) jump 3
 /home/chris/development/playground/simple.py(3)?()
- a = 1
(Pdb) list
  1 #!/usr/bin/env python
  2  
  3 a = 1
  4  - b = 2
  5  
  6 c = a + b
  7  
  8 print c
[EOF]
(Pdb) next
 /home/chris/development/playground/simple.py(6)?()
- c = a + b

One can see that after supposedly jumping to line 3 at the second command, 
when listing the line, the debugger is actually at line 4. The next command 
further demonstrates this since it re-executes line 4 and moves to line 6.

This issue was raised on comp.lang.python. (For example, see
http://groups.google.com/group/comp.lang.python/browse_thread/thread/7960201616873f41/e9623c08e3618051
or if that link is munged, refer to
http://tinyurl.com/324feu

Duncan Booth offers the following:
[quote]
I verified (with a print statement in pdb) that assigning to 
self.curframe.f_lineno sets self.curframe.f_lineno and sel.curframe.f_lasti 
incorrectly

...

The problem looks to be in frameobject.c:

addr = 0;
line = f-f_code-co_firstlineno;
new_lasti = -1;
for (offset = 0; offset  lnotab_len; offset += 2) {
addr += lnotab[offset];
line += lnotab[offset+1];
if (line = new_lineno) {
new_lasti = addr;
new_lineno = line;
break;
}
}

The first bytes in lnotab are the length and line increment for line 3 (i.e. 6, 
1). If line==f-f_code-co_firstlineno it should set new_lasti=0, 
new_lineno=line but the loop still executes once which increments new_lasti and 
new_lineno to the next line (6, 4).
[/quote]

And Rocky Bernstein offers the following:
[quote]
Best as I can tell, it looks like a bug in Python. pdb, pydb, rpdb2 all handle 
the jump command by changing the frame f_lineno value. When the corresponding 
code pointer has offset 0 (or equivalently and more simlply as you put it, is 
the first statement) this doesn't seem to work properly.
[/quote]

--

Comment By: Rocky Bernstein (rockyb)
Date: 2007-03-31 06:32

Message:
Logged In: YES 
user_id=158581
Originator: NO

Although a single file unit test would be nice, below is a short simple
program that I think clearly shows the bug. Alas, as a follow-up comment I
don't see a way to attach files so I have to paste it inline. However with
this example and the information from Duncan Booth, I think the problem and
how to fix it is pretty clear.

file: jumpbug.py

#!/usr/bin/env python
import inspect, linecache, sys
def tracer(frame, event, arg):
global z
(filename, line_no) = inspect.getframeinfo(frame)[0:2]
print Event %s at line %d: % (event, line_no)
print \t, linecache.getline(filename, line_no),
print --
try: 
if z == 0:
if line_no == 4:
print ***We jumped back to line 4 but should have gone to
2**
sys.exit(1)
frame.f_lineno = 2 # And 3 is broken too.
except NameError:
pass
return tracer # This helps emacs figure indentation out
sys.settrace(tracer)
execfile(jumpbug2.py)
#END first file

file jumpbug2.py:

#!/usr/bin/env python
x = 2  # This statement gets skipped the 2nd time around
q = 1  # This statement gets skipped too!
try:   # tracer() will exit here if z == 0 and line_no == 4
y = z   
except NameError:
z = 0
print When tracing via tracer(), f_lineno will be set to 2 here.
print You should never get here when tracing


file jumpbug2.py:

--

Comment By: gotgenes (gotgenes)
Date: 2007-03-28 21:24

Message:
Logged In: YES 
user_id=1180453
Originator: YES

Truthfully, I don't have enough know-how to write a full test case or a
patch. I have put forth a request on the comp.lang.python thread (link in
original report) for those that would to please do so.


[ python-Bugs-1622664 ] language reference index links are broken

2007-03-31 Thread SourceForge.net
Bugs item #1622664, was opened at 2006-12-26 22:15
Message generated for change (Comment added) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1622664group_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: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Drew Perttula (drewp)
Assigned to: Nobody/Anonymous (nobody)
Summary: language reference index links are broken

Initial Comment:
http://docs.python.org/ref/genindex.html

For example, this text globals() (built-in function) links to 
http://docs.python.org/ref/exec.html#l2h-571, which is completely wrong.

Some links are correct, but many others are broken.

The page footer says Release 2.5, documentation updated on 19th September, 
2006.


--

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-31 09:05

Message:
Logged In: YES 
user_id=752496
Originator: NO

Where do you think it should point to?

Take note that you're looking into the language reference, not the library
reference.

Regards,

--

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



[ python-Bugs-920573 ] http libraries throw errors internally

2007-03-31 Thread SourceForge.net
Bugs item #920573, was opened at 2004-03-21 15:16
Message generated for change (Comment added) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=920573group_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: None
Status: Open
Resolution: Rejected
Priority: 5
Private: No
Submitted By: Bram Cohen (bram_cohen)
Assigned to: Nobody/Anonymous (nobody)
Summary: http libraries throw errors internally

Initial Comment:
Here's an error which someone just got running BitTorrent -

Exception in thread Thread-2:
 Traceback (most recent call last):
   File /usr/lib/python2.3/threading.py, line 436, in
__bootstrap
 self.run()
   File /usr/lib/python2.3/threading.py, line 416, in run
 self.__target(*self.__args, **self.__kwargs)
   File
/usr/lib/python2.3/site-packages/BitTorrent/Rerequester.py,
line 72, in rerequest
 h = urlopen(url)
   File /usr/lib/python2.3/urllib2.py, line 129, in
urlopen
 return _opener.open(url, data)
   File /usr/lib/python2.3/urllib2.py, line 326, in open
 '_open', req)
   File /usr/lib/python2.3/urllib2.py, line 306, in
_call_chain
 result = func(*args)
   File /usr/lib/python2.3/urllib2.py, line 491, in
lambda
 lambda r, proxy=url, type=type,
meth=self.proxy_open: \
   File /usr/lib/python2.3/urllib2.py, line 498, in
proxy_open
 if '@' in host:
 TypeError: iterable argument required

And here's one which people have been getting
*forever*, without it ever having been fixed (I've been
simply catching and ignoring it) -

Exception in thread Thread-60:
Traceback (most recent call last):
  File /usr/lib/python2.2/threading.py, line 414, in
__bootstrap
self.run()
  File /usr/lib/python2.2/threading.py, line 402, in run
apply(self.__target, self.__args, self.__kwargs)
  File /home/zkessin/bin/BitTorrent/Rerequester.py,
line 85, in
rerequest
r = h.read()
  File /usr/lib/python2.2/httplib.py, line 1140, in read
assert not self._line_consumed and self._line_left
AssertionError

Both of the above were caused by very straightforward
calls to httplib. I'm fairly certain (especially with
the second one) that they're internal bugs.

I'd like to mention while I'm at it that I'm extremely
unhappy with httplib. It's buggy, blocking, and doesn't
even support timeouts. While it's good to have a
library which supports all the vagaries of http, it
would be far better for it to be a simple object which
you tell when data  was received and it tells you when
there's data to be sent out. That way it could
integrate easily into other applications's event loops.
The blocking and buggy nature of httplib has caused me
no end of headaches, and I think I'm not the only one.

--

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-31 09:09

Message:
Logged In: YES 
user_id=752496
Originator: NO

For any bug to be solved, we'd need a way to reproduce it.

Thes three points are very useful:

- What do you do
- What do you get
- What do you expect

this is an error from somebody running bittorrent is not specific enough
to us to be able to find the bug (if any).

Please, consider detail this a bit more.

Regards,

--

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



[ python-Bugs-1623153 ] preferred diff format should be mentioned as unified.

2007-03-31 Thread SourceForge.net
Bugs item #1623153, was opened at 2006-12-27 18:18
Message generated for change (Settings changed) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1623153group_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: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Raghuram Devarakonda (draghuram)
Assigned to: Facundo Batista (facundobatista)
Summary: preferred diff format should be mentioned as unified.

Initial Comment:

The page at http://www.python.org/dev/tools/ mentions that context diffs are 
preferred. However, the link at http://www.python.org/dev/patches/ mentions 
that We like unified diffs. We grudgingly accept contextual diffs.. So 
tools page should preferably mention unified diffs as well.

Thanks,
Raghu

--

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



[ python-Bugs-1430435 ] urllib2 has memory leaks

2007-03-31 Thread SourceForge.net
Bugs item #1430435, was opened at 2006-02-13 01:30
Message generated for change (Comment added) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1430435group_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.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: halfik (halfik)
Assigned to: Nobody/Anonymous (nobody)
Summary: urllib2 has memory leaks

Initial Comment:
reg = urllib2.Request(url, data, headers)
rl_handle = urllib2.urlopen(reg)

urllib2 has hot memory leaks.

gc: uncollectable _fileobject memory_adres
gc: uncollectable list memory adres


--

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-31 09:36

Message:
Logged In: YES 
user_id=752496
Originator: NO

How did you produce those results? (how can I reproduce them?)

In which Python version you did?

Regards,

--

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



[ python-Bugs-1379209 ] socket.recv(OOB) raises exception on closed socket

2007-03-31 Thread SourceForge.net
Bugs item #1379209, was opened at 2005-12-13 00:14
Message generated for change (Settings changed) made by facundobatista
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1379209group_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.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Roy Smith (roysmith)
Assigned to: Facundo Batista (facundobatista)
Summary: socket.recv(OOB) raises exception on closed socket

Initial Comment:
frame:pyClient$ python
Python 2.4.1 (#1, Aug 16 2005, 20:11:22) 
[GCC 3.4.3] on sunos5
Type help, copyright, credits or license for more information.
 ^D
frame:pyClient$ uname -a
SunOS frame 5.8 Generic_108528-27 sun4u sparc

If you try to read out-of-band data on a closed socket, the recv() call 
raises socket.error, signaling invalid argument.  This seems wrong.  
Doing a normal (in-band) recv() on a closed socket returns an empty 
string; trying to read OOB data should do the same thing.

At worst, it should raise a more specific error.  I'm guessing this 
exception is reflecting an errno of EBADF.  A more specific error would 
at least make it clear that it's the first argument to recv() which was 
bad, not the second.

frame:pyClient$ cat oob.py
#!/usr/bin/env python

import socket

s = socket.socket()
s.connect ((localhost, 13))  # 13 = daytime
print == , `s.recv(1024)`
print OOB: , `s.recv (1024, socket.MSG_OOB)`

frame:pyClient$ ./oob.py
==  'Mon Dec 12 22:00:29 2005\n\r'
OOB: 
Traceback (most recent call last):
  File ./oob.py, line 8, in ?
print OOB: , `s.recv (1024, socket.MSG_OOB)`
socket.error: (22, 'Invalid argument')
frame:pyClient$ 


--

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



[ python-Bugs-1671676 ] test_mailbox is hanging while doing gmake test on HP-UX v3

2007-03-31 Thread SourceForge.net
Bugs item #1671676, was opened at 2007-03-01 19:24
Message generated for change (Comment added) made by shashikala
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1671676group_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: Threads
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: shashi (shashikala)
Assigned to: Nobody/Anonymous (nobody)
Summary: test_mailbox is hanging while doing gmake test on HP-UX v3

Initial Comment:

 Hi ,

  I am testing Python 2.5 on HP-UX 11iv3 using gmake test , while testing the 
test  test_mailbox.py is hanging . 

  when tried to track the problem i came to know that
in the function 
  if pid == 0:
# In the child, lock the mailbox.
self._box.lock()
time.sleep(2)
self._box.unlock()
os._exit(0)

# In the parent, sleep a bit to give the child time to acquire
# the lock.
time.sleep(0.5)
try:
self.assertRaises(mailbox.ExternalClashError,
  self._box.lock)
finally:
# Wait for child to exit.  Locking should now succeed.
exited_pid, status = os.waitpid(pid, 0)

 after forking the child , child is not returning status to the parent while 
its waiting for the return status. 

  which part of the Python functionality is checked. 
 
   Please assist me to solve this.

Thanks in advance ,
shashi

 

--

Comment By: shashi (shashikala)
Date: 2007-03-31 20:27

Message:
Logged In: YES 
user_id=1506183
Originator: YES

please find attached log stacktrace of test_mailbox.py , assist me to
analyse the test hang.
File Added: python.txt

--

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



[ python-Bugs-1688393 ] sock.recvfrom(-24) crashes

2007-03-31 Thread SourceForge.net
Bugs item #1688393, was opened at 2007-03-26 07:13
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1688393group_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: Extension Modules
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Andrew Bennetts (spiv)
Assigned to: Facundo Batista (facundobatista)
Summary: sock.recvfrom(-24) crashes

Initial Comment:
Actually sock.recvfrom(x) crashes or causes memory corruption for all values in 
-sizeof(PyStringObject) = x  0, I think.

This script demonstrates the problem:

import socket, sys
s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s1.bind(('127.0.0.1', ))
s2 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s2.sendto('fdsjkldsfkj', ('127.0.0.1', ))
print s1.recvfrom(-24)

Try e.g. -1 instead of -24 as well.

I'm attaching a patch that fixes this bug, and adds a simple test for it too.

Other sock_recv* functions in socketmodule.c seem to already catch negative 
recvlen values and raise ValueError, but for some reason recvfrom missed out.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-03-31 11:57

Message:
Logged In: YES 
user_id=33168
Originator: NO

Committed revision 54635. (2.5)

2.6 fix was in 54594.

Also fixed some other copy and paste errors wrt method names when parsing
arguments.

--

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-27 20:46

Message:
Logged In: YES 
user_id=752496
Originator: NO

Applied this to the trunk, let's see if we should backport it to 2.5.x
before close this bug.

--

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



[ python-Bugs-1655392 ] thirdparty extensions, --enable-shared, static linking

2007-03-31 Thread SourceForge.net
Bugs item #1655392, was opened at 2007-02-08 17:16
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1655392group_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: Build
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Marien Zwart (marienz)
Assigned to: Georg Brandl (gbrandl)
Summary: thirdparty extensions, --enable-shared, static linking

Initial Comment:
(I'm filing this under the Build category which may not be entirely accurate, 
but couldn't find a closer match. Is there a description of what the categories 
mean somewhere?).

Python 2.5 built with --enable-shared on linux produces a shared 
libpython2.5.so in the normal libdir and only a static libpython2.5.a in 
/usr/lib/python2.5/config. Normally when you build extensions you want them to 
link to the dynamic one. However python-config --ldflags has 
-L/usr/lib/python2.5/config in its output, causing build processes using it to 
prefer the static library over the dynamic one.

This is somewhat similar to bug 1600860: distutils does the same thing when 
compiling extensions in an --enable-shared python 2.5.

I think either python-config should be modified to not mention that config 
dir on an --enable-shared build or the build process should be modified to put 
a .so file next to the .a file in that directory.


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-31 18:58

Message:
Logged In: YES 
user_id=849994
Originator: NO

Fixed in rev. 54634, 54636.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-02-09 12:46

Message:
Logged In: YES 
user_id=21627
Originator: NO

The categories aren't described anywhere.

python-config should describe the installed code; we shouldn't change what
gets installed how for 2.5.1.

Georg, with python-config being your code, can you take a look? If not,
please unassign (in which case I'd ask marienz whether he would like to
contribute a patch).

--

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



[ python-Bugs-920573 ] http libraries throw errors internally

2007-03-31 Thread SourceForge.net
Bugs item #920573, was opened at 2004-03-21 13:16
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=920573group_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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Bram Cohen (bram_cohen)
Assigned to: Nobody/Anonymous (nobody)
Summary: http libraries throw errors internally

Initial Comment:
Here's an error which someone just got running BitTorrent -

Exception in thread Thread-2:
 Traceback (most recent call last):
   File /usr/lib/python2.3/threading.py, line 436, in
__bootstrap
 self.run()
   File /usr/lib/python2.3/threading.py, line 416, in run
 self.__target(*self.__args, **self.__kwargs)
   File
/usr/lib/python2.3/site-packages/BitTorrent/Rerequester.py,
line 72, in rerequest
 h = urlopen(url)
   File /usr/lib/python2.3/urllib2.py, line 129, in
urlopen
 return _opener.open(url, data)
   File /usr/lib/python2.3/urllib2.py, line 326, in open
 '_open', req)
   File /usr/lib/python2.3/urllib2.py, line 306, in
_call_chain
 result = func(*args)
   File /usr/lib/python2.3/urllib2.py, line 491, in
lambda
 lambda r, proxy=url, type=type,
meth=self.proxy_open: \
   File /usr/lib/python2.3/urllib2.py, line 498, in
proxy_open
 if '@' in host:
 TypeError: iterable argument required

And here's one which people have been getting
*forever*, without it ever having been fixed (I've been
simply catching and ignoring it) -

Exception in thread Thread-60:
Traceback (most recent call last):
  File /usr/lib/python2.2/threading.py, line 414, in
__bootstrap
self.run()
  File /usr/lib/python2.2/threading.py, line 402, in run
apply(self.__target, self.__args, self.__kwargs)
  File /home/zkessin/bin/BitTorrent/Rerequester.py,
line 85, in
rerequest
r = h.read()
  File /usr/lib/python2.2/httplib.py, line 1140, in read
assert not self._line_consumed and self._line_left
AssertionError

Both of the above were caused by very straightforward
calls to httplib. I'm fairly certain (especially with
the second one) that they're internal bugs.

I'd like to mention while I'm at it that I'm extremely
unhappy with httplib. It's buggy, blocking, and doesn't
even support timeouts. While it's good to have a
library which supports all the vagaries of http, it
would be far better for it to be a simple object which
you tell when data  was received and it tells you when
there's data to be sent out. That way it could
integrate easily into other applications's event loops.
The blocking and buggy nature of httplib has caused me
no end of headaches, and I think I'm not the only one.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-31 14:29

Message:
Logged In: YES 
user_id=80475
Originator: NO

Both of these still need to be looked at (whether or not Bram supplies
more detail).

--

Comment By: Facundo Batista (facundobatista)
Date: 2007-03-31 07:09

Message:
Logged In: YES 
user_id=752496
Originator: NO

For any bug to be solved, we'd need a way to reproduce it.

Thes three points are very useful:

- What do you do
- What do you get
- What do you expect

this is an error from somebody running bittorrent is not specific enough
to us to be able to find the bug (if any).

Please, consider detail this a bit more.

Regards,

--

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



[ python-Bugs-1623153 ] preferred diff format should be mentioned as unified.

2007-03-31 Thread SourceForge.net
Bugs item #1623153, was opened at 2006-12-27 16:18
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1623153group_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: Documentation
Group: None
Status: Closed
Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: Raghuram Devarakonda (draghuram)
Assigned to: Facundo Batista (facundobatista)
Summary: preferred diff format should be mentioned as unified.

Initial Comment:

The page at http://www.python.org/dev/tools/ mentions that context diffs are 
preferred. However, the link at http://www.python.org/dev/patches/ mentions 
that We like unified diffs. We grudgingly accept contextual diffs.. So 
tools page should preferably mention unified diffs as well.

Thanks,
Raghu

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-31 14:38

Message:
Logged In: YES 
user_id=80475
Originator: NO

I don't think we really do care.  Sometimes context diffs are easier to
understand and sometimes unified diffs are the way to go depending on the
patch.  I say, let the world do what the world will do.  No unnecessary
rules.

--

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



[ python-Bugs-1689617 ] Intel icc build fails with optimizations -O2

2007-03-31 Thread SourceForge.net
Bugs item #1689617, was opened at 2007-03-27 21:26
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1689617group_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: Build
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Forbes (mforbes)
Assigned to: Nobody/Anonymous (nobody)
Summary: Intel icc build fails with optimizations -O2

Initial Comment:
When building python 2.5 with the free Intel compilers for non-commercial use 
(icc), the build works without optimizations, but fails when optimizations -O2 
and -O3 are used.

The compilation proceedes without errors (though there are lot's of warnings 
and remarks) and makes a python executable, but when the python setup starts, 
the intepreter cannot import certain packages and cannot add two strings.

case $MAKEFLAGS in \
*-s*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 
-Ob2 -w1' ./python -E ./setup.py -q build;; \
*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 -Ob2 
-w1' ./python -E ./setup.py build;; \
esac
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File ./setup.py, line 6, in module
import sys, os, imp, re, optparse
  File /int/apps/mmf/src/Python-2.5_intel/Lib/optparse.py, line 71, in 
module
import textwrap
  File /int/apps/mmf/src/Python-2.5_intel/Lib/textwrap.py, line 10, in 
module
import string, re
  File /int/apps/mmf/src/Python-2.5_intel/Lib/string.py, line 26, in module
letters = lowercase + uppercase
SystemError: error return without exception set
make: *** [sharedmods] Error 1

For example:
$ ./python
'import site' failed; use -v for traceback
Python 2.5 (r25:51908, Mar 27 2007, 20:10:22) 
[GCC Intel(R) C++ gcc 3.4 mode] on linux2
Type help, copyright, credits or license for more information.
 a = 123
 a + 12
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: error return without exception set
 

Note that both the import of the site file fails and the addition fails.

Python was configured with the following options:
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O2 -Ob2 -w1

When compiled with fewer optimiztions, everything seems to work.
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O1 -Ob2 -w1



--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-03-31 12:56

Message:
Logged In: YES 
user_id=33168
Originator: NO

My guess is that it relates to strict aliasing (which Python violates). 
Can you find the equivalent flag to gcc's -fno-strict-aliasing in icc?

--

Comment By: Michael Forbes (mforbes)
Date: 2007-03-29 15:06

Message:
Logged In: YES 
user_id=253921
Originator: YES

I have spoken with some people who have had similar issues with the intel
compilers in other applications, so it looks like it might be a compiler
bug.  I will look into this.

Can anyone confirm this behaviour? (I only have access to one linux box).

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-28 04:32

Message:
Logged In: YES 
user_id=21627
Originator: NO

Can you debug this further to determine a specific problem? It could be a
compiler bug also, for all I can tell.

--

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



[ python-Bugs-1689617 ] Intel icc build fails with optimizations -O2

2007-03-31 Thread SourceForge.net
Bugs item #1689617, was opened at 2007-03-28 04:26
Message generated for change (Comment added) made by mforbes
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1689617group_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: Build
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Forbes (mforbes)
Assigned to: Nobody/Anonymous (nobody)
Summary: Intel icc build fails with optimizations -O2

Initial Comment:
When building python 2.5 with the free Intel compilers for non-commercial use 
(icc), the build works without optimizations, but fails when optimizations -O2 
and -O3 are used.

The compilation proceedes without errors (though there are lot's of warnings 
and remarks) and makes a python executable, but when the python setup starts, 
the intepreter cannot import certain packages and cannot add two strings.

case $MAKEFLAGS in \
*-s*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 
-Ob2 -w1' ./python -E ./setup.py -q build;; \
*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 -Ob2 
-w1' ./python -E ./setup.py build;; \
esac
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File ./setup.py, line 6, in module
import sys, os, imp, re, optparse
  File /int/apps/mmf/src/Python-2.5_intel/Lib/optparse.py, line 71, in 
module
import textwrap
  File /int/apps/mmf/src/Python-2.5_intel/Lib/textwrap.py, line 10, in 
module
import string, re
  File /int/apps/mmf/src/Python-2.5_intel/Lib/string.py, line 26, in module
letters = lowercase + uppercase
SystemError: error return without exception set
make: *** [sharedmods] Error 1

For example:
$ ./python
'import site' failed; use -v for traceback
Python 2.5 (r25:51908, Mar 27 2007, 20:10:22) 
[GCC Intel(R) C++ gcc 3.4 mode] on linux2
Type help, copyright, credits or license for more information.
 a = 123
 a + 12
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: error return without exception set
 

Note that both the import of the site file fails and the addition fails.

Python was configured with the following options:
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O2 -Ob2 -w1

When compiled with fewer optimiztions, everything seems to work.
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O1 -Ob2 -w1



--

Comment By: Michael Forbes (mforbes)
Date: 2007-03-31 20:31

Message:
Logged In: YES 
user_id=253921
Originator: YES

It does not appear to be a problem with aliasing (icc accepts the
-fno-strict-aliasing flag and it is set by default using ./configure.  It
is another question of whether or not icc behaves this flag!).

This looks similar to a previous problem but I am not using any processor
specific optimizations:
http://mail.python.org/pipermail/python-list/2005-March/312145.html


--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-03-31 19:56

Message:
Logged In: YES 
user_id=33168
Originator: NO

My guess is that it relates to strict aliasing (which Python violates). 
Can you find the equivalent flag to gcc's -fno-strict-aliasing in icc?

--

Comment By: Michael Forbes (mforbes)
Date: 2007-03-29 22:06

Message:
Logged In: YES 
user_id=253921
Originator: YES

I have spoken with some people who have had similar issues with the intel
compilers in other applications, so it looks like it might be a compiler
bug.  I will look into this.

Can anyone confirm this behaviour? (I only have access to one linux box).

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-28 11:32

Message:
Logged In: YES 
user_id=21627
Originator: NO

Can you debug this further to determine a specific problem? It could be a
compiler bug also, for all I can tell.

--

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



[ python-Bugs-1689617 ] Intel icc build fails with optimizations -O2

2007-03-31 Thread SourceForge.net
Bugs item #1689617, was opened at 2007-03-28 04:26
Message generated for change (Comment added) made by mforbes
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1689617group_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: Build
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Michael Forbes (mforbes)
Assigned to: Nobody/Anonymous (nobody)
Summary: Intel icc build fails with optimizations -O2

Initial Comment:
When building python 2.5 with the free Intel compilers for non-commercial use 
(icc), the build works without optimizations, but fails when optimizations -O2 
and -O3 are used.

The compilation proceedes without errors (though there are lot's of warnings 
and remarks) and makes a python executable, but when the python setup starts, 
the intepreter cannot import certain packages and cannot add two strings.

case $MAKEFLAGS in \
*-s*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 
-Ob2 -w1' ./python -E ./setup.py -q build;; \
*)  CC='icc -pthread' LDSHARED='icc -pthread -shared' OPT='-DNDEBUG -g -O2 -Ob2 
-w1' ./python -E ./setup.py build;; \
esac
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File ./setup.py, line 6, in module
import sys, os, imp, re, optparse
  File /int/apps/mmf/src/Python-2.5_intel/Lib/optparse.py, line 71, in 
module
import textwrap
  File /int/apps/mmf/src/Python-2.5_intel/Lib/textwrap.py, line 10, in 
module
import string, re
  File /int/apps/mmf/src/Python-2.5_intel/Lib/string.py, line 26, in module
letters = lowercase + uppercase
SystemError: error return without exception set
make: *** [sharedmods] Error 1

For example:
$ ./python
'import site' failed; use -v for traceback
Python 2.5 (r25:51908, Mar 27 2007, 20:10:22) 
[GCC Intel(R) C++ gcc 3.4 mode] on linux2
Type help, copyright, credits or license for more information.
 a = 123
 a + 12
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: error return without exception set
 

Note that both the import of the site file fails and the addition fails.

Python was configured with the following options:
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O2 -Ob2 -w1

When compiled with fewer optimiztions, everything seems to work.
./configure --with-gcc=icc\
--with-cxx-main=icc\
--prefix=/int/apps/mmf/apps/Python-2.5_intel/\
OPT=-g -O1 -Ob2 -w1



--

Comment By: Michael Forbes (mforbes)
Date: 2007-04-01 00:53

Message:
Logged In: YES 
user_id=253921
Originator: YES

I have narrowed the problem a bit to the file Python/ceval.c.  If you
build this manually without optimizations, then everything works fine
(make test works).
icc -pthread -c -fno-strict-aliasing -DNDEBUG -g -w1 -O1 \
-I. -I./Include -DPy_BUILD_CORE -o Python/ceval.o Python/ceval.c

I have included the warnings the compiler spits out (but it spits out
similar warnings everywhere, so I doubt that these are the problem) and
attached the optimization report.  I tried turning off as much as
possible (inlining, loop unrolling etc.) but could still not get it to
work.  There are some threads about loop unrolling issues with icc, but
these were for -O3 optimizations:

http://softwarecommunity.intel.com/isn/community/en-us/forums/thread/321812.aspx

If I compile with -O1 and -Ob1 then it breaks and I get the optimization
report attached.  The wierd thing is that if I use -O1 and -finline, I get
an empty optimization report and it works.  TFM states that -finline [is
the] Same as -Ob1.  This at least is a compiler problem!  I suspect that
-Ob1 is doing more than just inlining (it looks that way from the report)
so I am not exactly sure where the problem is here yet.
 
icc -pthread -c -fno-strict-aliasing -DNDEBUG -g -Wall -O1\
 -Ob1 -opt-report -opt-report-level=max -opt-report-file=opt.rep.txt\
  -I. -I./Include   -DPy_BUILD_CORE -o Python/ceval.o Python/ceval.c

Python/ceval.c(198): remark #869: parameter self was never referenced
  PyEval_GetCallStats(PyObject *self)
^
Python/ceval.c(2710): remark #981: operands are evaluated in unspecified
order
PyString_AsString(keyword));
^
Python/ceval.c(2706): remark #981: operands are evaluated in unspecified
order
PyErr_Format(PyExc_TypeError,
^
Python/ceval.c(2722): remark #981: operands are evaluated in unspecified
order
 PyString_AsString(keyword));