Re: What is the best way to upgrade python?

2007-03-08 Thread Sick Monkey

Have you tried to upgrade the current python RPM?

rpm -Uvh 

You can also build from source.  Once you get Python 2.4 up and running I am
pretty sure you can do a symbolic link on the python 2.3 application (either
in /usr/bin or /usr/sbin) and point it to the 2.4 python file.

On 8 Mar 2007 13:13:13 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Hi,

i am using red hat enterprise 4. It has python 2.3 installed. What is
the best way to upgrade to python 2.4?

I think one way is to compile python 2.4 from the source, but I can't
remove the old one since when i do 'rpm -e python', i get error like
'failed dependencies'.

Thank you for any idea.

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

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

Re: SQLAlchemy and Oracle Functions?

2007-03-08 Thread Giles Brown
On 8 Mar, 22:19, Greg Copeland [EMAIL PROTECTED] wrote:
 I'm using SQLAlchemy and have a need to call an Oracle function; which
 is not the same as a stored procedure.  Can this be done directory or
 indirectly with SQLAlchemy?  If so, can someone please provide an
 example?  If not, how do I obtain the raw cx_Oracle cursor so I can
 use callfunc directly on that?

 Thanks,

 Greg

http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_whereclause_functions
?

SQLAlchemy has its own google group

http://groups.google.co.uk/group/sqlalchemy

You could try asking there too.

Giles

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


convert time string in UTC to time in local time

2007-03-08 Thread davelist
I'm guessing there is an easy way to do this but I keep going around  
in circles in the documentation.

I have a time stamp that looks like this (corresponding to UTC time):

start_time = '2007-03-13T15:00:00Z'

I want to convert it to my local time.

start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M: 
00Z'))
start_time -= time.timezone

This was working fine now, but if I do it for a date next week (such  
as March 13th in the above example), it breaks because my local time  
moves to daylight savings time this weekend. So my time is now off by  
an hour. I'm guessing if I try this next week it will work okay  
because time.timezone will be give a different value next week - is  
that correct?

Is there a direct way to convert that timestamp in UTC to a local  
time stamp that will always work?

TIA,
Dave

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


Re: SQLAlchemy and Oracle Functions?

2007-03-08 Thread Greg Copeland
On Mar 8, 3:35 pm, Giles Brown [EMAIL PROTECTED] wrote:
http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_whereclause_fu...
 SQLAlchemy has its own google group

 http://groups.google.co.uk/group/sqlalchemy

 You could try asking there too.

 Giles

Very nice.  That exactly answered by question.  It works!  Also, I
didn't know about the sqlalchemy group so I appreciate the heads up.

Thanks,

Greg


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


Re: Configuration: Apache + mod_python

2007-03-08 Thread Graham . Dumpleton
On Mar 9, 12:02 am, Danilo [EMAIL PROTECTED] wrote:
 On 8 Mrz., 12:18, [EMAIL PROTECTED] wrote:



  On Mar 8, 9:50 pm, Danilo [EMAIL PROTECTED] wrote:

   Hi there,

   is it possible to create a rewrite rule to send every server-request
   to the directory /py? But only if the file does not exists on the
   server.

   This is my mod_python section of the apache config-file.

   Location /py
   SetHandler python-program
   PythonHandler django.core.handlers.modpython
   PythonPath ['/var/www/mydomain.com/htdocs/py'] + sys.path
   SetEnv DJANGO_SETTINGS_MODULE myapp.settings
   PythonDebug Off
   /Location

  For the more general case of where a HTTP 404 error would otherwise be
  returned, indicating that a resource could not be found, as opposed to
  an actual physical file, you can just use:

ErrorDocument 404 /py

  This would be simpler than using mod_rewrite. I can't remember though
  whether the handler when triggered in this case can change the
  response status to something other than 404.

  You could use mod_rewrite if you really must, but not sure how it
  would interact with virtual resources managed by some handler where no
  actual file exists. To be practical you would probably want to
  restrict the scope of mod_rewrite to specific contexts.

  Quoting an example from very good book The Definitive Guide to Apache
  mod_rewrite, you can do something similar to:

RewriteEngine On
# If its not here ...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Look here instead ...
RewriteRule ^/images/(.*) /pics/$1 [PT]

  In this case it is causing lookups for images to be made in two
  places, but your case wouldn't be much different.

  Graham

 The rewrite rule works, but now every request ist send to /py.
 This is my .conf:

 VirtualHost *
 DocumentRoot /var/www/mydomain.com/htdocs
 ServerName mydomain.com
 ServerAliaswww.mydomain.com

 Location /py
 SetHandler python-program
 PythonHandler django.core.handlers.modpython
 PythonPath ['/var/www/mydomain.com/htdocs/py'] + sys.path
 SetEnv DJANGO_SETTINGS_MODULE myapp.settings
 PythonDebug Off
 /Location

 RewriteEngine On
 # If its not here...
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # Look here instead...
 RewriteRule (.*) /py$1 [PT]

 ErrorLog /var/www/mydomain.com/logs/error.log
 CustomLog /var/www/mydomain.com/logs/access.log common
 /VirtualHost

 Any ideas what is wrong?

I did say you would probably need to restrict the scope of the
mod_rewrite rule to a specific context. In particular, put it inside
of a Directory directive corresponding to the file system directory
where your files live. Where you have it as the moment,
REQUEST_FILENAME probably will not resolve to anything as Apache
hasn't yet matched it to the filesystem. Thus:

  Directory /some/path/to/document/root

RewriteEngine On
# If its not here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Look here instead...
RewriteRule (.*) /py$1 [PT]


  /Directory

Graham

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


Re: What is the best way to upgrade python?

2007-03-08 Thread ying lcs
On 3/8/07, Sick Monkey [EMAIL PROTECTED] wrote:
 Have you tried to upgrade the current python RPM?

 rpm -Uvh 

 You can also build from source.  Once you get Python 2.4 up and running I am
 pretty sure you can do a symbolic link on the python 2.3 application (either
 in /usr/bin or /usr/sbin) and point it to the 2.4 python file.



I get '$rpm -Uvh python'
error: open of python failed: no such file or directory

but when I do '$rpm -q python ' , I get python -2.3.4-14.1



 On 8 Mar 2007 13:13:13 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED]  wrote:
  Hi,
 
  i am using red hat enterprise 4. It has python 2.3 installed. What is
  the best way to upgrade to python 2.4?
 
  I think one way is to compile python 2.4 from the source, but I can't
  remove the old one since when i do 'rpm -e python', i get error like
  'failed dependencies'.
 
  Thank you for any idea.
 
  --
  http://mail.python.org/mailman/listinfo/python-list
 


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


Re: What is the best way to upgrade python?

2007-03-08 Thread Sick Monkey

Yeah, sorry I should have added more data.
You will need to go to rhn.redhat.com and either download the RPM or get the
url.

So you would do:
(1) download the rpm to your home directory
rpm -Uvh nameOfRPM

or
(2) grab the url
rpm -Uvh http://urlOfRPM

either way should update your python.   Dont be distressed if you need to
update or install new RPMs.

On 3/8/07, ying lcs [EMAIL PROTECTED] wrote:


On 3/8/07, Sick Monkey [EMAIL PROTECTED] wrote:
 Have you tried to upgrade the current python RPM?

 rpm -Uvh 

 You can also build from source.  Once you get Python 2.4 up and running
I am
 pretty sure you can do a symbolic link on the python 2.3 application
(either
 in /usr/bin or /usr/sbin) and point it to the 2.4 python file.



I get '$rpm -Uvh python'
error: open of python failed: no such file or directory

but when I do '$rpm -q python ' , I get python -2.3.4-14.1



 On 8 Mar 2007 13:13:13 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] 
wrote:
  Hi,
 
  i am using red hat enterprise 4. It has python 2.3 installed. What is
  the best way to upgrade to python 2.4?
 
  I think one way is to compile python 2.4 from the source, but I can't
  remove the old one since when i do 'rpm -e python', i get error like
  'failed dependencies'.
 
  Thank you for any idea.
 
  --
  http://mail.python.org/mailman/listinfo/python-list
 



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

Re: Dyanmic import of a class

2007-03-08 Thread Arnaud Delobelle
On Mar 8, 9:09 pm, rh0dium [EMAIL PROTECTED] wrote:
[snip]
 for mod in listdir():
__import__(mod)
a=mod()
a.dosomething()  # This is a function which each class shares.

 Can anyone help?

You are not using __import__ correctly.  Perhaps reading the doc would
be a good start:
http://docs.python.org/lib/built-in-funcs.html

For example to import the module defined in 'foo.py' you would do
foo = __import__('foo')
Then your class foo would be accessible as foo.foo

HTH

--
Arnaud

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


Re: What is the best way to upgrade python?

2007-03-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 Hi,
 
 i am using red hat enterprise 4. It has python 2.3 installed. What is
 the best way to upgrade to python 2.4?
 
 I think one way is to compile python 2.4 from the source, but I can't
 remove the old one since when i do 'rpm -e python', i get error like
 'failed dependencies'.

Not really a python-related problem by itself, but anyway: you probably 
have other packages depending on this version of Python, so better to 
keep it. Now nothing prevents you from having multiple Python versions. 
Just build from sources (preferably giving /usr/local as prefix to 
./configure since it's not the 'system' version), and install in a 
different location (IIRC there's a make altinstall rule - anyway all 
this is documented in the source directory).

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


Re: pylint: don't warn about tabs

2007-03-08 Thread Bjoern Schliessmann
Ben Finney wrote:
 Bjoern Schliessmann [EMAIL PROTECTED]

 IIRC it's planned in future Python versions that TABs aren't
 supported for indentation.
 
 I've not seen such plans, can you support that?

No ... 8)
 
 If you're thinking of this post from Guido, please note the date
 it was made:

Not this one; I thought that if there was a warning added about tabs
as whitespace recently, tabs will become forbidden in the future. 

(That is not True, obviously ;) )

Anyway, thanks for correction.

Regards,


Björn

-- 
BOFH excuse #164:

root rot

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


Re: What is the best way to upgrade python?

2007-03-08 Thread ying lcs
On 3/8/07, Sick Monkey [EMAIL PROTECTED] wrote:
 Yeah, sorry I should have added more data.
 You will need to go to rhn.redhat.com and either download the RPM or get the
 url.

 So you would do:
 (1) download the rpm to your home directory
 rpm -Uvh nameOfRPM

 or
 (2) grab the url
 rpm -Uvh http://urlOfRPM

 either way should update your python.   Dont be distressed if you need to
 update or install new RPMs.


Thanks. I went to  rhn.redhat.com, but they only have python 2.3.4 for RHEL4.




 On 3/8/07, ying lcs [EMAIL PROTECTED] wrote:
  On 3/8/07, Sick Monkey [EMAIL PROTECTED] wrote:
   Have you tried to upgrade the current python RPM?
  
   rpm -Uvh 
  
   You can also build from source.  Once you get Python 2.4 up and running
 I am
   pretty sure you can do a symbolic link on the python 2.3 application
 (either
   in /usr/bin or /usr/sbin) and point it to the 2.4 python file.
  
 
 
  I get '$rpm -Uvh python'
  error: open of python failed: no such file or directory
 
  but when I do '$rpm -q python ' , I get python -2.3.4-14.1
 
 
 
   On 8 Mar 2007 13:13:13 -0800, [EMAIL PROTECTED] [EMAIL PROTECTED] 
 wrote:
Hi,
   
i am using red hat enterprise 4. It has python 2.3 installed. What is
the best way to upgrade to python 2.4?
   
I think one way is to compile python 2.4 from the source, but I can't
remove the old one since when i do 'rpm -e python', i get error like
'failed dependencies'.
   
Thank you for any idea.
   
--
http://mail.python.org/mailman/listinfo/python-list
   
  
  
 


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


Re: SQLAlchemy and Oracle Functions?

2007-03-08 Thread Greg Copeland
On 8 Mar, 15:35, Giles Brown [EMAIL PROTECTED] wrote:
 On 8 Mar, 22:19, Greg Copeland [EMAIL PROTECTED] wrote:

  I'm using SQLAlchemy and have a need to call an Oracle function; which
  is not the same as a stored procedure.  Can this be done directory or
  indirectly with SQLAlchemy?  If so, can someone please provide an
  example?  If not, how do I obtain the raw cx_Oracle cursor so I can
  use callfunc directly on that?

  Thanks,

  Greg

 http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_whereclause_fu...
 ?

 SQLAlchemy has its own google group

 http://groups.google.co.uk/group/sqlalchemy

 You could try asking there too.

 Giles


I think I spoke too soon!  Are SQL functions which have out arguments
not allowed?  I get:
sqlalchemy.exceptions.SQLError: (DatabaseError) ORA-06572: Function
blah has out arguments.

Seems google is having problems right now too.  I tried to join but it
just times out so I am currently unable to post to the sqlalchemy
google group.

Anthing special I need to do to call an Oracle function via the func
method, which also has output parameters?


Greg

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


Re: Where to import?

2007-03-08 Thread Paulo da Silva
Paulo da Silva escreveu:


This is to thank all the answers I got so far.
Now I understand perfectly how import works.

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


Re: Where to import?

2007-03-08 Thread Paulo da Silva
Paulo da Silva escreveu:


This is to thank all the answers I got so far.
Now I understand perfectly how import works.

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


Re: pylint: don't warn about tabs

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 14:33:38 -0300, Bjoern Schliessmann  
[EMAIL PROTECTED] escribió:

 Alan Isaac wrote:
 As a tab user, I want the tabs warning turned off.

 Advice: Don't. IIRC it's planned in future Python versions that TABs
 aren't supported for indentation.

AFAIK, using tabs xor spaces will be ok, but not MIXING them.

-- 
Gabriel Genellina

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


Re: Where to import?

2007-03-08 Thread Paulo da Silva
Bruno Desthuilliers escreveu:
 Paulo da Silva a écrit :
...


 c.py
 class c:
 class C(object):
 
 1/ better to stick to naming conventions (class names in CamelCase)
Ok. Thanks.
 2/ do yourself a favor: use new-style classes
I still have python 2.4.3 (The gentoo current version).
I didn't find this in my tutorial. Would you please enlight me
a bit about this (class C(object))? Or just point me out some doc
to read about.

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


Re: merits of Lisp vs Python

2007-03-08 Thread Aahz
In article [EMAIL PROTECTED],
Paul Rubin  http://[EMAIL PROTECTED] wrote:

Care to name a real hosting provider that cares whether Python works?

http://www.webfaction.com/
-- 
Aahz ([EMAIL PROTECTED])   * http://www.pythoncraft.com/

I disrespectfully agree.  --SJM
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where to import?

2007-03-08 Thread Bruno Desthuilliers
Paulo da Silva a écrit :
 Bruno Desthuilliers escreveu:
 
Paulo da Silva a écrit :
 
 ...
 
 
c.py
class c:

class C(object):

1/ better to stick to naming conventions (class names in CamelCase)
 
 Ok. Thanks.

FWIW:
http://www.python.org/dev/peps/pep-0008/

2/ do yourself a favor: use new-style classes
 
 I still have python 2.4.3 (The gentoo current version).

new-style classes came with Python 2.2.1 IIRC.

 I didn't find this in my tutorial. Would you please enlight me
 a bit about this (class C(object))? 

Inheriting from the builtin class 'object' (or from any other new-style 
class) makes your class a new-style class. new-style classes have much 
more features than old-style ones. Like support for properties (computed 
attributes). old-style classes are still here mainly for compatibility 
with old code. While there not yet officially deprecated, you can 
consider them as such.

 Or just point me out some doc
 to read about.

http://www.python.org/doc/newstyle/

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


Re: tkinter how to write

2007-03-08 Thread Gigs_
James Stroud wrote:
 Gigs_ wrote:
 as I write my first gui program (text editor) I wanna ask you guys how 
 to separate code in classes.?
 Should I put in one class my menu and in another class text and 
 scorllbars etc?

 or something else?


 thanks
 
 Check out Grayson: http://www.manning.com/grayson/
 
 Its $25 for the pdf and is worth about 20 or 30 times that in the effort 
 it will take you if you attempt to re-invent the wheel.
 
 For an example of a Tkinter code disaster from not having a good 
 reference, glimpse at the source of http://passerby.sf.net.
 
 How I wish I'd just read the damn book first!
 
 James
thx for both replies
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: merits of Lisp vs Python

2007-03-08 Thread Paul Rubin
[EMAIL PROTECTED] (Aahz) writes:
 Care to name a real hosting provider that cares whether Python works?
 http://www.webfaction.com/

Thanks!  This is good to know about.
-- 
http://mail.python.org/mailman/listinfo/python-list


Coding a scheduled journal application

2007-03-08 Thread [EMAIL PROTECTED]
I'm a python newbie and would like to develop a tiny application to
schedule a document to open in a text processor and ask a question.
I'd like to be able to give it multiple time:question pairs such as
(monday 1:00pm : Please enter your completed tasks for the morning?).
It could just open a dialog box with a big text entry area and the
question, then append a text file after a submit command. I guess the
question is how to get it to run in the background and pop-up at the
appropriate times?

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


Extend distutils bdist_rpm to support %config?

2007-03-08 Thread [EMAIL PROTECTED]
Is there any way to get the functionality of the %config RPM directive
using python distutils?

http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html

%config /etc/foonly

This will save the current file as fooonly.rpmsave if the file is
different from the one in the package, so users can prevent their
changes from being lost.

I looked at the distutils/command/bdist_rpm.py, it supports creation
of the %files keyword, but I did not see anything about %config,
presumably because distutils does not support that config file
install concept of RPM? Is there any other way to get this done using
distutils, for a setup.py that installs a python script (not a module)?

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


Re: catching exceptions from an except: block

2007-03-08 Thread Steven D'Aprano
On Thu, 08 Mar 2007 06:31:20 -0300, Gabriel Genellina wrote:

 En Thu, 08 Mar 2007 06:17:37 -0300, Gerard Flanagan  
 [EMAIL PROTECTED] escribió:
 
 @onfail(False)
 def a(x):
 if x == 1:
 return 'function a succeeded'
 else:
 raise
 
 I know it's irrelevant, as you use a bare except, but such raise looks a  
 bit ugly...


I thought raise on its own was supposed to re-raise the previous
exception, but I've just tried it in the interactive interpreter and it
doesn't work for me.

 raise ValueError # prime a previous exception
Traceback (most recent call last):
  File stdin, line 1, in ?
ValueError
 raise # re-raise the previous exception?
Traceback (most recent call last):
  File stdin, line 1, in ?
TypeError: exceptions must be classes, instances, or strings (deprecated), not 
NoneType


Have I misunderstood?



-- 
Steven D'Aprano 

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


Re: catching exceptions from an except: block

2007-03-08 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes:
 I thought raise on its own was supposed to re-raise the previous
 exception, but I've just tried it in the interactive interpreter and it
 doesn't work for me.

It means you can catch an exception, do stuff with it, and then pass
it upward to earlier callers:

def foo(n):
   try:
  bar(n)
   except (ValueError, TypeError):
  print invalid n:, n
  raise  # re-signal the same error to foo's caler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: {Possible_Spam} tkinter text editor

2007-03-08 Thread John McMonagle
Gigs_ wrote:
 I'm writing text editor.
 
 How to enable/disable (cut, copy etc.) when text is selected/not selected


Bind the Button1-ButtonRelease event to a function which checks the 
length of the SEL tag of the text widget.  If it is zero length, disable 
the appropriate menu entries, if it is non-zero, enable the appropriate 
menu entries.

Simple example:


from Tkinter import *
root = Tk()

textWidget = Text(root)
textWidget.pack()

def onButton1Release(event):
 if len(textWidget.tag_ranges(SEL)) == 0:
 print 'No text selected.  Disable appropriate menu entries'
 else:
 print 'Some text selected.  Enable appropriate menu entries'

textWidget.bind('Button1-ButtonRelease', onButton1Release)

root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing dictionary to file

2007-03-08 Thread jim-on-linux
On Thursday 08 March 2007 14:40, kavitha thankaian 
wrote:
 Hi Simon,

   iam till here:

   dorc=some['DorC']
   amount=some['amount']
   f=open(logfile.txt, w)
   if dorc =='C':
a = -(amount)
 if dorc == 'D':
b = amount
sum=a + b
if sum == 0:
f.writelines(name:)
f.writelines(%s %some['name'])
f.writelines(credit:)
f.writelines(%s % amount)

   but i see an empty file opened,,,

   kavitha

   Simon Brunning [EMAIL PROTECTED]
 wrote:

   On 3/8/07, kavitha thankaian wrote:
  can anyone help me???

 I'm sure we can. How far have you got so far?

try
 f=open(logfile.txt, w)
 f.write('name')
 f.write('\n')
 f.write(('credit(')
 f:close()

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

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


Re: property syntax

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 08:04:38 -0300, [EMAIL PROTECTED] escribió:

 Gabriel Genellina:
 You miss this common way, that does not depend on metaclasses,
 nor base classes, nor custom decorators...

 My purpose was to discuss a new syntax. The other stuff is mostly for
 reference, to show that lot of (some) people has tried to find
 alternative solutions to a problem they feel.

Nex syntax has many disadvantages, so you should come with a greater  
analysis of what would be the gain.
Maybe these comments are applicable here:  
http://mail.python.org/pipermail/python-dev/2007-February/071061.html and  
http://mail.python.org/pipermail/python-dev/2007-February/071123.html  
(sorry, a long thread, and two subject lines, that's why I had to post two  
references)
I think this thread belongs to python-ideas instead.

-- 
Gabriel Genellina

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


any better code to initalize a list of lists?

2007-03-08 Thread John
For my code of radix sort, I need to initialize 256 buckets. My code looks a 
little clumsy:

radix=[[]]
for i in range(255):
radix.append([])

any better code to initalize this list? 


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


Re: any better code to initalize a list of lists?

2007-03-08 Thread Paul Rubin
John [EMAIL PROTECTED] writes:
 For my code of radix sort, I need to initialize 256 buckets. My code looks a 
 little clumsy:
 
 radix=[[]]
 for i in range(255):
 radix.append([])
 
 any better code to initalize this list? 

Typically you'd say 
   radix = [[] for i in xrange(256)]

but what are you really doing?  This plan to implement radix sorting
sounds a little bit odd, unless it's just an exercise.

You could also consider using a dictionary instead of a list,
something like:

   radix = defaultdict(list)
-- 
http://mail.python.org/mailman/listinfo/python-list


list of dictionary in embedded Python

2007-03-08 Thread ZiZi Zhao
I tried to build a list of dictionaries using embedded Python2.5 
in the following way to append dictionaries to a list.

Py_Object *pList = PyList_New(0);

for (i=0; iMAXSIZE; i++) {
Py_Object *pDict = PyDict_New();
// 
// build this dictionary of keys  values
// 
if (pDict != NULL) {
if (PyList_Append(pList, pDict)  0) {
printf (Failed to append new dict to dict-list\n);
}
Py_DECREF(pDict);
}
}

In this way, I found the PyList_Append only appends the pointer 
of pDict to pList. 

After Py_DECREF(pDict) and going back to, 
Py_Object *pDict = PyDict_New();
for next run in loop, it gets the same pointer as last time, 
which finally makes all dictionaries in the list are the same 
as the last one. (BTW, in Python, the result is correct.)

What goes wrong? 

Now, I have to do no Py_DECREF(pDict) in the loop, but do once at 
the end, when the loop is finished, like 

Py_Object *pDict;
for (i=0; iMAXSIZE; i++) {
pDict = PyDict_New();
// 
// build this dictionary of keys  values
// 
if (pDict != NULL) {
if (PyList_Append(pList, pDict)  0) {
printf (Failed to append new dict to dict-list\n);
}
}
}
Py_DECREF(pDict);

In this way, would it cause memory leak?

Thanks in advance for help!



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

Re: merits of Lisp vs Python

2007-03-08 Thread John Nagle
Paul Rubin wrote:
 Chris Mellon [EMAIL PROTECTED] writes:
 
Any *real* hosting provider is going to support whatever
language and environment I tell them to, because I'm going to pay them
a lot of money for excellent support and if they give me any trouble I
will go with someone who provides what I want.

Who are you buying from?

 Hosting providers are generally not in the business of doing anything
 like that, except the low end ones that mostly support PHP.  
 
 
What was *meant* was low priced, zero maintenance, reasonably reliable
consumer level hosting. Thats a totally different market, it's not
industrial strength, and it doesn't merit the emphasis on *real*
provider. And it is true that in that realm Python is not well
represented.
 
 
 Python is not so well represented in industrial strength hosting
 either; that kind of hosting generally leaves language support up to
 the customer.

 The industry trend seems to be towards two dedicated server offerings.
One is dedicated hosting in a relatively controlled manner, with web based
server control and a somewhat locked down environment.  You get
root access, but if you mess with the controlled environment, it's
your problem if anything breaks.  The Plesk control panel is widely
used for this.

 The other offering is power, pipe, and ping - an empty machine in
a rack.  What you do with it is your problem.

 In neither case is the Python environment typically ready for serious use
out of the box.

 There's denial in the Python community that this is a problem, but it is.
The Ruby on Rails people get it; they work to provide a seamless experience
for web developers.  Which is why their market share is way up over two years
ago.

 Here's an overview of the dedicated server industry from the Gartner
Group:

http://www.savvis.net/NR/rdonlyres/E2C3E79F-8F8D-46D0-9718-E26C76805D0F/13782/SAVVISPositionedasLeaderinGartnerNAHostingMQGARTNE.pdf

 There's an emphasis on standardized offerings from the major players.
Customized environments are usually either user-managed or offered
as part of enterprise IT outsourcing.

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


Re: merits of Lisp vs Python

2007-03-08 Thread Paul Rubin
John Nagle [EMAIL PROTECTED] writes:
  There's denial in the Python community that this is a problem,
 but it is.  The Ruby on Rails people get it; they work to provide a
 seamless experience for web developers.  Which is why their market
 share is way up over two years ago.

I do know that a big Perl site that I hang out on (but am not involved
with the software for) decided to redo its software and had a big
discussion of what to use.  Python/Django was a serious contender but
in the end they chose Ruby on Rails.  I didn't pay too close attention
to the exact rationale but it was somewhat disappointing and yet
unsurprising.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: catching exceptions from an except: block

2007-03-08 Thread Steven D'Aprano
On Thu, 08 Mar 2007 16:19:27 -0800, Paul Rubin wrote:

 Steven D'Aprano [EMAIL PROTECTED] writes:
 I thought raise on its own was supposed to re-raise the previous
 exception, but I've just tried it in the interactive interpreter and it
 doesn't work for me.
 
 It means you can catch an exception, do stuff with it, and then pass
 it upward to earlier callers:

[snip code]

Are you saying it only works as advertised within the except clause of a
try...except block?



-- 
Steven D'Aprano 

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


Re: How to check whether file is open or not

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 11:10:42 -0300, Bart Ogryczak [EMAIL PROTECTED]  
escribió:

 On Mar 7, 6:28 am, Ros [EMAIL PROTECTED] wrote:
 There are 10 files in the folder. I wish to process all the files one
 by one. But if the files are open or some processing is going on them
 then I do not want to disturb that process. In that case I would
 ignore processing that particular file and move to next file.

 If you can os.open() with O_EXLOCK flag, it's not open by other
 process. Now that should work on Unix, Linux and MacOS X. All Windows
 proceeding form NT line, are supposed to be POSIX compatible, but
 somehow this flag is not available.

O_EXLOCK is not in POSIX.

-- 
Gabriel Genellina

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


Re: catching exceptions from an except: block

2007-03-08 Thread Paul Rubin
Steven D'Aprano [EMAIL PROTECTED] writes:
 Are you saying it only works as advertised within the except clause of a
 try...except block?

I think that's the idea.  It hadn't occurred to me that it could be
used any other way, but I don't have the docs in front of me right
now, so maybe I missed something.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Source Code Beautifier

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 13:13:23 -0300, Alan Franzoni  
[EMAIL PROTECTED] escribió:

 this
 container does create a copy of the object even employing incremental
 operators.

 Now, let's suppose I find that container type not useful for my purposes,
 *or* I have already written a different container type which mimicks a
 list's behaviour (adding some kind of functionality, of course).

If the library relies on that behavior, it should be documented as such.  
If you provide an alternative container that does not respect that  
interfase, it's your fault. It it was not documented, it's theirs.

 Now, let's suppose a certain function in that library should give a  
 certain
 result based on the contents of that container, but without modifying the
 original object, but it needs to modify it in order to do some  
 operations.

 if the function looks like this:

 def foo(container):
   container += [1, 2, 3]
   ...

 it might happen that the original object gets modified even when it
 shouldn't, depending on the actual object passed to the library.

And that would be bad coding style in the library. += is an augmented  
assignment, *can* be carried in place, or not. If they want a different  
value for the container, why not just write:

extended_container = container + [1,2,3]

You can't write bulletproof code, but some constructs are safer than  
others.

 What I just mean... I don't see calling extend() to be that painful in
 respect to += . If there were no other way to do it, I would agree it  
 would
 be useful. But if there're such methods, do we really need this syntactic
 sugar to introduce confusion?

Feel free to write a PEP suggesting removal of += and *= from lists.
http://www.python.org/dev/peps/

-- 
Gabriel Genellina

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


Re: any better code to initalize a list of lists?

2007-03-08 Thread John
I want to radix sort non-negative integers that can fit into 32-bits. That 
will take 4 passes, one for each byte. So, I will need 256 buckets
The list radix of 256 elements of list is good for this purpose.

Your code is much shorter, works and probably takes less time.

Thanks!

John


Paul Rubin http://[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 John [EMAIL PROTECTED] writes:
 For my code of radix sort, I need to initialize 256 buckets. My code 
 looks a
 little clumsy:

 radix=[[]]
 for i in range(255):
 radix.append([])

 any better code to initalize this list?

 Typically you'd say
   radix = [[] for i in xrange(256)]

 but what are you really doing?  This plan to implement radix sorting
 sounds a little bit odd, unless it's just an exercise.

 You could also consider using a dictionary instead of a list,
 something like:

   radix = defaultdict(list) 


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


Re: Python threading

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 14:25:02 -0300, [EMAIL PROTECTED] escribió:

 I am wondering what happens to a thread in python in relation to
 win32com extensions.

 If I create a new thread, that uses the Dispatch method from win32com,
 what happens to the memory allocated in that thread when the thread is
 done. Will the Dispatch release the memory it created, or will the
 memory remain?

 The problem rises from the fact that Dispatch does not seem to release
 memory correctly every time. If I include the commands in a thread by
 themselves, will the thread clean up ALL memory it used after it is
 done?

All threads share the same memory space, there is not a per-thread  
memory allocator, if that's what you are thinking.
Perhaps you hold a reference to some objects in the Thread object? Or you  
still keep the Thread object itself?

 I did try the pythoncom.CoUnitialize() to release memory, but it
 doesn't seem to work (it does work about 30-45 seconds after the
 command is run).

I don't understand what you say here.
What means it doesn't seem to work and it does work 30 seconds after?

 Any input is greatly appreciated (on the thread issue or how to use
 the pythoncom.CoUnitiliaze() to make it release memory right away).

What memory do you want to release right away?

-- 
Gabriel Genellina

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


Re: Coding a scheduled journal application

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 20:42:45 -0300, [EMAIL PROTECTED]  
[EMAIL PROTECTED] escribió:

 I guess the
 question is how to get it to run in the background and pop-up at the
 appropriate times?

Use cron on linux or the task scheduler on windows

-- 
Gabriel Genellina

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


Re: any better code to initalize a list of lists?

2007-03-08 Thread Paul Rubin
John [EMAIL PROTECTED] writes:
 I want to radix sort non-negative integers that can fit into 32-bits.

But why do you want to do that?  Why not just use Python's built-in
sorting operation?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: catching exceptions from an except: block

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 21:11:54 -0300, Steven D'Aprano  
[EMAIL PROTECTED] escribió:

 @onfail(False)
 def a(x):
 if x == 1:
 return 'function a succeeded'
 else:
 raise

 I thought raise on its own was supposed to re-raise the previous
 exception, but I've just tried it in the interactive interpreter and it
 doesn't work for me.

Not the *previous* exception, but the *current* one. You must be inside an  
except clause to use a bare raise.

-- 
Gabriel Genellina

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


Re: Reading a portion of a file

2007-03-08 Thread attn . steven . kuo
On Mar 8, 10:35 am, [EMAIL PROTECTED] wrote:

(snipped)



 Ok, regex was my first thought because I used to use grep with Perl
 and shell scripting to grab everything from one pattern to another
 pattern. The file is just an unformatted file. What is below is
 exactly what is in the file. There are no spaces between the beginning
 and ending tags and the content. Would you recommend using spaces
 there? And if so, why?

 A sample of the file:


You can use iterators:

import StringIO
import itertools

def group(line):
if line[-6:-1] == 'START':
group.current = group.current + 1
return group.current

group.current = 0

data = 
#VS:COMMAND:df:START
Filesystem   1K-blocks  Used Available Use% Mounted on
/dev/vzfs 20971520517652  20453868   3% /
tmpfs  201603244   2015988   1% /var/run
tmpfs  2016032 0   2016032   0% /var/lock
tmpfs  2016032 0   2016032   0% /dev/shm
tmpfs  201603244   2015988   1% /var/run
tmpfs  2016032 0   2016032   0% /var/lock
#VS:COMMAND:df:STOP

#VS:FILE:/proc/loadavg:START
0.00 0.00 0.00 1/32 14543
#VS:FILE:/proc/loadavg:STOP

#VS:FILE:/proc/meminfo:START
MemTotal:   524288 kB
MemFree:450448 kB
Buffers: 0 kB
Cached:  0 kB
SwapCached:  0 kB
Active:  0 kB
Inactive:0 kB
HighTotal:   0 kB
HighFree:0 kB
LowTotal:   524288 kB
LowFree:450448 kB
SwapTotal:   0 kB
SwapFree:0 kB
Dirty:   0 kB
Writeback:   0 kB
Mapped:  73840 kB
Slab:0 kB
CommitLimit: 0 kB
Committed_AS:   248704 kB
PageTables:  0 kB
VmallocTotal:0 kB
VmallocUsed: 0 kB
VmallocChunk:0 kB
#VS:FILE:/proc/meminfo:STOP

#VS:FILE:/proc/stat:START
cpu  67188 0 26366 391669264 656686 0 0
cpu0 24700 0 10830 195807826 373309 0 0
cpu1 42488 0 15536 195861438 283376 0 0
intr 0
swap 0 0
ctxt 18105366807
btime 1171391058
processes 26501285
procs_running 1
procs_blocked 0
#VS:FILE:/proc/stat:STOP

#VS:FILE:/proc/uptime:START
1962358.88 1577059.05
#VS:FILE:/proc/uptime:STOP
.lstrip(\n);

fh = StringIO.StringIO(data)

sections = itertools.groupby(itertools.ifilter(lambda line: len(line)
 1, fh),
lambda line: group(line))

for key, section in sections:
for line in section:
print key, line,


--
Hope this helps,
Steven

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


Re: list of dictionary in embedded Python

2007-03-08 Thread Gabriel Genellina
En Thu, 08 Mar 2007 22:26:59 -0300, ZiZi Zhao [EMAIL PROTECTED] escribió:

 I tried to build a list of dictionaries using embedded Python2.5
 in the following way to append dictionaries to a list.

 Py_Object *pList = PyList_New(0);

 for (i=0; iMAXSIZE; i++) {
 Py_Object *pDict = PyDict_New();
 //
 // build this dictionary of keys  values
 //
 if (pDict != NULL) {
 if (PyList_Append(pList, pDict)  0) {
 printf (Failed to append new dict to dict-list\n);
 }
 Py_DECREF(pDict);
 }
 }

 In this way, I found the PyList_Append only appends the pointer
 of pDict to pList.

All Python objects are seen as pointers on C code.

 After Py_DECREF(pDict) and going back to,
 Py_Object *pDict = PyDict_New();
 for next run in loop, it gets the same pointer as last time,

Perhaps (in the non-posted block) there is a Py_INCREF missing, and that  
last Py_DECREF destroys the object.
(You don't see the printf message, I presume)

 which finally makes all dictionaries in the list are the same
 as the last one. (BTW, in Python, the result is correct.)
 Now, I have to do no Py_DECREF(pDict) in the loop, but do once at
 the end, when the loop is finished, like

You could check using sys.getrefcount; if all of them say 2 (including the  
last dict) you know the list holds the only reference to them. (And all  
id() should be different, too).

Maybe this code is useful; builds a list of empty dictionaries. (Note that  
I *know* the list is empty and has the right size, so I can use  
PyList_SET_ITEM instead of the non-macro version PyList_SetItem or the  
insert/append variants).


/*
  flistdict - fast list of dictionaries
  flistdict(size) - [{},{},...] = [{} for _ in range(size)]
  Devuelve una lista de diccionarios vacíos (todos diferentes)
*/
static PyObject *
flistdict(PyObject *self, PyObject *args)
{
 int i, size;
 PyObject *result=NULL, *dict=NULL;

 if (!PyArg_ParseTuple(args, i, size))
 return NULL;
 result = PyList_New(size);
 if (result==NULL)
 goto error;
 for (i=0; isize; i++) {
 dict = PyDict_New();
 if (dict==NULL)
  goto error;
 PyList_SET_ITEM(result, i, dict);
 }
 goto normalexit;

error:
 Py_XDECREF(result);
 result = NULL;

normalexit:
 return result;
}

-- 
Gabriel Genellina

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


Python books?

2007-03-08 Thread Tommy Nordgren
Could some kind soul please recommend a few text books on Python 2.5
and it's class library?


Kine dies, Kinfolk dies, and thus at last yourself
This I know that never dies, how a dead mans deeds are deemed. --  
Elder edda
Tommy Nordgren
[EMAIL PROTECTED]



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


Re: Python threading

2007-03-08 Thread test . 07
On Mar 8, 6:15 pm, Gabriel Genellina [EMAIL PROTECTED] wrote:
 En Thu, 08 Mar 2007 14:25:02 -0300, [EMAIL PROTECTED] escribió:
 All threads share the same memory space, there is not a per-thread
 memory allocator, if that's what you are thinking.
 Perhaps you hold a reference to some objects in the Thread object? Or you
 still keep the Thread object itself?

That is what I was thinking. A per-thread memory allocator of some
sort. What I need is run a lot of commands from a COM object that can
be run independently. There commands leak memory, so when the command
finishes, the memory consumption jumps to 800MBs or so. Which begs the
question, if I initialize the COM object in a separate thread and run
the command, does finishing the thread clean up any and all memory the
thread used or not. The output of each thread would actually be a file
on disk, therefore there is no need to pass any data between the
threads and the main program.

  I did try the pythoncom.CoUnitialize() to release memory, but it
  doesn't seem to work (it does work about 30-45 seconds after the
  command is run).

 I don't understand what you say here.
 What means it doesn't seem to work and it does work 30 seconds after?

pythoncom.CoUninitialize(), if I am not mistaken, releases a COM
object (and therefore the memory it uses I assume). When the command
is run (in PythonWin for example), the memory is not released but
persists for quite a while. Using my watch and the Task Manager in
Windows I can see that the memory is released approximately 30 seconds
AFTER I run the pythoncom.CoUninitialize() command is run.

 What memory do you want to release right away?

The memory I want to release is the memory the COM object used (the
one initialized with the win32com Dispatch command). The right-away
is not much of an issue, but if I can release it before I run each
command from the COM object that leaks memory, it would be nice.
Running upwards to 800MBs of RAM for one 500 line python script seems
a little bit too much for me.

Thank you for your reply Gabriel. If you have any more input, I would
greatly appreciate it.


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

I am a new guy on python world

2007-03-08 Thread YySwing . 杨
I am study python today

print Python world,yang coming

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

Re: Where to import?

2007-03-08 Thread MonkeeSage
On Mar 8, 5:49 pm, Bruno Desthuilliers
[EMAIL PROTECTED]
 1/ better to stick to naming conventions (class names in CamelCase)

  Ok. Thanks.

 FWIW:http://www.python.org/dev/peps/pep-0008/

By my reading, PEP8 doesn't specify CamelCase as preferred over the
other styles it mentions. non_camel_case is also considered good
style, as I understand (and is used all over the standard library).

Regards,
Jordan

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


Re: Where to import?

2007-03-08 Thread MonkeeSage
Disregard my last message, I'm stupid. I totally missed that Bruno was
talking about classname. Bruno is exactly right.

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


Re: I am a new guy on python world

2007-03-08 Thread MonkeeSage
Welcome. :)

Regards,
Jordan

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


Re: Where to import?

2007-03-08 Thread Gabriel Genellina
En Fri, 09 Mar 2007 01:09:36 -0300, MonkeeSage [EMAIL PROTECTED]  
escribió:

 FWIW:http://www.python.org/dev/peps/pep-0008/

 By my reading, PEP8 doesn't specify CamelCase as preferred over the
 other styles it mentions. non_camel_case is also considered good
 style, as I understand (and is used all over the standard library).

Class names should be CamelCase. Read it again, and notice the difference  
between a Descriptive section and a Prescriptive one.

-- 
Gabriel Genellina

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


Re: Where to import?

2007-03-08 Thread MonkeeSage
On Mar 8, 10:27 pm, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 Class names should be CamelCase. Read it again, and notice the difference
 between a Descriptive section and a Prescriptive one.

Yes, I misread Bruno's comment (missed that he was speaking of class
names). Disregard my post.

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


TitleCase, camelCase, lowercase (was: Where to import?)

2007-03-08 Thread Ben Finney
Gabriel Genellina [EMAIL PROTECTED] writes:

 Class names should be CamelCase.

Note that the term camel case has ambiguous usage. Some use it to
refer to *both* of nameWithSeveralWords and NameWithSeveralWords.

I prefer to use the term title case to refer unambiguously to
NameWithSeveralWords, leaving the term camel case to describe the
case with the humps only in the middle :-)

PEP 8 recommends TitleCase for class names. The use of camelCase for
instances and method names seems to come from (at least) Java, but PEP
8 prefers lowercase_with_underscores.

-- 
 \ My theory of evolution is that Darwin was adopted.  -- Steven |
  `\Wright |
_o__)  |
Ben Finney

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


Re: heapq.heappush and pop to use key

2007-03-08 Thread [EMAIL PROTECTED]
On Mar 8, 9:02 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
 In [EMAIL PROTECTED],

 [EMAIL PROTECTED] wrote:
  I wanted to have a heap of custom objects, and in different heaps I
  wanted to have the weights for my elements differently. So, I modified
  the heapq module to accept key arguments also.

 I would have just used tuples of the form (weight, obj) with the original
 `heapq` module.

 Ciao,
 Marc 'BlackJack' Rintsch

Thanks. I will go with tuples itself.
-
Suresh

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


Re: VIM: Python type indented-block command equivalent to % for C?

2007-03-08 Thread Paddy3118
On Mar 8, 5:02 am, Paddy3118 [EMAIL PROTECTED] wrote:
   Not python:
 but python type
 indented text

 Notice the blank line above.
 It could have several
 spaces or tabs, and still
 be a part of the block
 beginning 'Not python:':
   The block ends at the
   first non-blank line
   with less indent.

 Assuming that only space characters are allowed
 for indenting, is their a way to yank a Python
 block like y% works for C , or a way to move to
 the end of a block defined by indentation?

 I have tried help indent but could not find
 anything.

 Thanks, Paddy.

I have installed the following plugins for my Python work:
taglist
  http://vim-taglist.sourceforge.net/images/taglist_python.gif
python.vim
  http://vim.sourceforge.net/scripts/script.php?script_id=30
and Bicycle Repair Man
   http://bicyclerepair.sourceforge.net/

- Paddy

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


Re: TitleCase, camelCase, lowercase

2007-03-08 Thread Scott David Daniels
Ben Finney wrote:
 I prefer to use the term title case to refer unambiguously to
 NameWithSeveralWords, leaving the term camel case to describe the
 case with the humps only in the middle :-)

The names TitleCase and camelCase might suffice here.

-- 
--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: any better code to initalize a list of lists?

2007-03-08 Thread Terry Reedy

Paul Rubin http://phr.cx@NOSPAM.invalid wrote in message 
news:[EMAIL PROTECTED]
| John [EMAIL PROTECTED] writes:
|  I want to radix sort non-negative integers that can fit into 32-bits.
|
| But why do you want to do that?  Why not just use Python's built-in
| sorting operation?

Perhaps to learn or teach about the algorithm.  Python is good for that. 



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


C++ and Python

2007-03-08 Thread [EMAIL PROTECTED]
Hi Everyone,

I'm considering about generating some Python Bindings for C++
libraries. What are considered the best tools for doing something like
this? I know that there are SWIG, SIP, Boost.Python, and GCC_XML.

Thanks!

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


Re: Dyanmic import of a class

2007-03-08 Thread Scott David Daniels
   Arnaud Delobelle wrote:
 On Mar 8, 9:09 pm, rh0dium [EMAIL PROTECTED] wrote:
 [snip]
 for mod in listdir():
__import__(mod)
a=mod()
a.dosomething()  # This is a function which each class shares.

 Can anyone help?
 
 You are not using __import__ correctly.  Perhaps reading the doc would
 be a good start:
 http://docs.python.org/lib/built-in-funcs.html
 
 For example to import the module defined in 'foo.py' you would do
 foo = __import__('foo')
 Then your class foo would be accessible as foo.foo

To get even more explicit:
 import glob, os.path
 for filename in glob.glob('*.py*'):
 modname, ext = os.path.splitext(filename)
 try:
 class_ = getattr(__import__(modname), modname)
 except (ImportError, AttributeError, SyntaxError), err:
print filename, modname, err
else:
 class_().dosomething()

-- 
--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python books?

2007-03-08 Thread Alex Martelli
Tommy Nordgren [EMAIL PROTECTED] wrote:

 Could some kind soul please recommend a few text books on Python 2.5
 and it's class library?

I believe recent books on Python (such as Python for Dummies and the
second edition of Core Python Programming) do cover 2.5; I do know
that the 2nd edition of Python in a Nutshell tries to do so, but falls
quite a bit short on a number of important new additions to the library
(I had to close the book a tad too early to really do them justice,
sigh).


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


Re: merits of Lisp vs Python

2007-03-08 Thread Alex Martelli
Paul Rubin http://[EMAIL PROTECTED] wrote:

 alex23 [EMAIL PROTECTED] writes:
   Hosting providers and distro
   makers aren't concerned over whether Python works.  They
   care if C, C++, Java, PHP, and Perl work, but not Python or LISP.
   Ask them.
  
  Do you have any real experience with recent linux distros? Or with any
  _real_ hosting providers?
 
 Care to name a real hosting provider that cares whether Python works?

The first name that comes to mind is xs4all, the major Dutch provider
(they've even got their own Wikipedia entry!-) -- they've long offered
outstanding sponsorship to the Python community, hosting lots of
services for us, btw.

But the OP's mention of distro ain't even funny -- ever since RedHat's
original implementation of RPM (in Python), ever more Linux distros are
positively _fanatical_ about Python.  Ubuntu, for example, has as its
BDFL Mark Shuttleworth, who (since, as he explains, he made his fortune
thanks to Python -- Python's what allowed him to build Thawte, which he
later sold for mucho dinero) is an unabashed fan of Python; the XO
(nee One Laptop Per Child, OLPC, and once known as the $100 laptop)
uses Python as its preferred (only?-) application language, and it's
slated to be the most widely distributed Python distro if it hits even
half of its ambitious target-numbers...


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


Re: Python threading

2007-03-08 Thread Gabriel Genellina
En Fri, 09 Mar 2007 00:38:55 -0300, [EMAIL PROTECTED] escribió:

 pythoncom.CoUninitialize(), if I am not mistaken, releases a COM
 object (and therefore the memory it uses I assume).

Not exactly. *You* must release the COM object (usually assigning None to  
all references to it). CoUninitialize releases all system resources held  
by the COM application, unloads DLLs, and so; it *may* release all COM  
objects but I'm not sure.

 When the command
 is run (in PythonWin for example), the memory is not released but
 persists for quite a while. Using my watch and the Task Manager in
 Windows I can see that the memory is released approximately 30 seconds
 AFTER I run the pythoncom.CoUninitialize() command is run.

If it is eventually released, you don't have a problem, right?
And, if it will be needed again after a while (when you run the next  
command), it looks better this way.
There are many layers on memory management: the OS manages 4K pages that  
are mapped on the process address space; the C runtime suballocates such  
pages as memory blocks; Python itself has two levels of memory allocation  
(and I don't know the details). It's not easy to know exactly how much  
memory is actually used; I think the Python runtime, once it allocates a  
memory block, never releases it to the OS (remaining as a free block,  
available for further usage).

And in general, DLLs are *not* unloaded as soon as its usage count goes to  
0; there is certain delay. (I don't remember, but I think there is a  
registry key called DLLUnloadTime or something). The idea is to avoid  
removing it from memory just to load it again a few moments later, so the  
unloading is delayed for a few seconds. You may be seeing this effect.

 What memory do you want to release right away?

 The memory I want to release is the memory the COM object used (the
 one initialized with the win32com Dispatch command). The right-away
 is not much of an issue, but if I can release it before I run each
 command from the COM object that leaks memory, it would be nice.
 Running upwards to 800MBs of RAM for one 500 line python script seems
 a little bit too much for me.

Let's see if I can understand the problem. You run multiple commands on a  
COM object, one after another. The COM object is buggy and leaks some  
memory. You run each command on a separate thread, with a CoInitialize(),  
waiting for completion, and a CoUninitialize() at the end. Memory usage  
grows to 800MB when you invoke each command, but if you wait enough time  
after the thread finalizes, memory usage goes down to normal. After that,  
you run the next command, and so on.
Or do you wait until the whole program finalizes, and 30 seconds after  
that, memory usage drops?

-- 
Gabriel Genellina

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


Re: Python books?

2007-03-08 Thread rishi pathak

I would suggest you the python docs available on python.org.They are the
best and latest

On 3/9/07, Tommy Nordgren [EMAIL PROTECTED] wrote:


Could some kind soul please recommend a few text books on Python 2.5
and it's class library?


Kine dies, Kinfolk dies, and thus at last yourself
This I know that never dies, how a dead mans deeds are deemed. --
Elder edda
Tommy Nordgren
[EMAIL PROTECTED]



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





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

Re: catching exceptions from an except: block

2007-03-08 Thread Gerard Flanagan
On Mar 8, 10:31 am, Gabriel Genellina [EMAIL PROTECTED]
wrote:
 En Thu, 08 Mar 2007 06:17:37 -0300, Gerard Flanagan
 [EMAIL PROTECTED] escribió:

  @onfail(False)
  def a(x):
  if x == 1:
  return 'function a succeeded'
  else:
  raise

 I know it's irrelevant, as you use a bare except, but such raise looks a
 bit ugly...

 --
 Gabriel Genellina

Agreed. I thought a 'gentle reader' could have filled in the blanks,
but I suppose I should have taken the time to put in a custom
exception.

Another version:

import exceptions

class ABCException(exceptions.Exception):
pass

class DoItException(exceptions.Exception):
pass

def onfailFalse(fn):
def inner(*args, **kwargs):
try:
return fn(*args, **kwargs)
except ABCException:
return False
return inner

@onfailFalse
def a(x):
if x == 1:
return 'function a succeeded'
else:
raise ABCException()

@onfailFalse
def b(x):
if x == 2:
return 'function b succeeded'
else:
raise ABCException()

@onfailFalse
def c(x):
if x == 3:
return 'function c succeeded'
else:
raise ABCException()

def doit(x):
for f in [a, b, c]:
result = f(x)
if result:
return result
raise DoItException()

print doit(1)
print doit(2)
print doit(3)
print doit(4)

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

[ python-Bugs-1676321 ] scheduler.empty() in module sched appears broken

2007-03-08 Thread SourceForge.net
Bugs item #1676321, was opened at 2007-03-08 00:50
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676321group_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: Mark (theshtat)
Assigned to: Nobody/Anonymous (nobody)
Summary: scheduler.empty() in module sched appears broken

Initial Comment:
In:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) 
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin

The sched.scheduler.empty() method appears to be broken.  Its implementation is:
  return not not self.queue
Which returns true when the event queue is *not* empty.
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22not+not%22+show:_EUH1sHctjI:SV8rbKB68UQ:wZlnTyplW4csa=Ncd=1ct=rccs_p=http://svn.python.org/snapshots/python25.tar.bz2cs_f=python/Lib/sched.py#a0

Other Python builds seem to have a correct implementation:
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22len(self.queue)%22+show:tKxWDv9S6Xg:d-f-3CzYpHc:iU9xQ6L5s1ssa=Ncd=1ct=rccs_p=http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2cs_f=Python-2.4.3/Lib/sched.py#a0

Thanks,
Mark
mayzenshtat at) gmail (dot com

--

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



[ python-Bugs-1671411 ] python code fails with MemoryError on HP-UX 11.11 PA_RISC

2007-03-08 Thread SourceForge.net
Bugs item #1671411, was opened at 2007-03-01 05:27
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1671411group_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: Performance
Group: None
Status: Closed
Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: shashi (shashikala)
Assigned to: Nobody/Anonymous (nobody)
Summary: python code fails with MemoryError on HP-UX 11.11 PA_RISC 

Initial Comment:

Hi,

 Python-2.5 code fails with MemoryError. This is happening only on one 
system, PA-RISC running HP-UX 11.11.Failing system has 12 GB of RAM installed, 
non-failing system has 8 GB.

1) spark 9GB phys mem(Python is working fine)
2) stalker 12GB phys mem (that has problem with python 2.5 )


please assist me in this.

Thanks in advance
Shashi



--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-08 10:19

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

If you think your problem is solved, then fine (you seem to have found a
work-around).

If Python raises a MemoryError, this is still a problem; it sholdn't
normally do that, and it should normally invoke garbage collection itself.
To analyse this further, we still would need a debug stack trace. However,
I'm closing this as won't fix now; if you ever feel like analysing it
further, and have data to help there, feel free to reopen the report.

--

Comment By: shashi (shashikala)
Date: 2007-03-08 04:57

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


 Hi ,

 I added import gc and gc.collect() , it worked out fine , I dint get
any further  MemoryError  is this the correct approach , please let me know
about the same. 

Thanks and Reagrds,
shashi

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-01 22:34

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

Can you also provide a gdb/dbx backtrace of where the problem occurred?

--

Comment By: shashi (shashikala)
Date: 2007-03-01 12:47

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

File Added: Pythonmemoryerror.txt

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-01 07:38

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

This tracker is not about assistance. If at all, we need you to assist
us.

Can you please report more details, like stack traces, causes of the
crash, patches? If not, I think there is little we can do about this report
(it crashes is pretty unspecific).

--

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



[ python-Bugs-1676656 ] Stdlib reference is in italics

2007-03-08 Thread SourceForge.net
Bugs item #1676656, was opened at 2007-03-08 16:34
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676656group_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: Fixed
Priority: 5
Private: No
Submitted By: Bj�rn Lindqvist (sonderblade)
Assigned to: Nobody/Anonymous (nobody)
Summary: Stdlib reference is in italics

Initial Comment:
The development version of the stdlib reference is messed up. All pages after 
this one http://docs.python.org/dev/lib/module-SocketServer.html has all the 
text in italics.

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-08 17:50

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

The problem was that \em sets italics for the whole LaTeX scope while
\emph does that only for the following argument.

Fixed in rev. 54220, 54221 (2.5)

--

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



[ python-Bugs-1676321 ] scheduler.empty() in module sched appears broken

2007-03-08 Thread SourceForge.net
Bugs item #1676321, was opened at 2007-03-08 08:50
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676321group_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: Mark (theshtat)
Assigned to: Raymond Hettinger (rhettinger)
Summary: scheduler.empty() in module sched appears broken

Initial Comment:
In:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) 
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin

The sched.scheduler.empty() method appears to be broken.  Its implementation is:
  return not not self.queue
Which returns true when the event queue is *not* empty.
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22not+not%22+show:_EUH1sHctjI:SV8rbKB68UQ:wZlnTyplW4csa=Ncd=1ct=rccs_p=http://svn.python.org/snapshots/python25.tar.bz2cs_f=python/Lib/sched.py#a0

Other Python builds seem to have a correct implementation:
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22len(self.queue)%22+show:tKxWDv9S6Xg:d-f-3CzYpHc:iU9xQ6L5s1ssa=Ncd=1ct=rccs_p=http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2cs_f=Python-2.4.3/Lib/sched.py#a0

Thanks,
Mark
mayzenshtat at) gmail (dot com

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-08 18:24

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

This was your change, Raymond.

--

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



[ python-Bugs-1676321 ] scheduler.empty() in module sched appears broken

2007-03-08 Thread SourceForge.net
Bugs item #1676321, was opened at 2007-03-08 03:50
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676321group_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: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: Mark (theshtat)
Assigned to: Raymond Hettinger (rhettinger)
Summary: scheduler.empty() in module sched appears broken

Initial Comment:
In:
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) 
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin

The sched.scheduler.empty() method appears to be broken.  Its implementation is:
  return not not self.queue
Which returns true when the event queue is *not* empty.
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22not+not%22+show:_EUH1sHctjI:SV8rbKB68UQ:wZlnTyplW4csa=Ncd=1ct=rccs_p=http://svn.python.org/snapshots/python25.tar.bz2cs_f=python/Lib/sched.py#a0

Other Python builds seem to have a correct implementation:
http://www.google.com/codesearch?hl=enq=+file:sched.py+%22len(self.queue)%22+show:tKxWDv9S6Xg:d-f-3CzYpHc:iU9xQ6L5s1ssa=Ncd=1ct=rccs_p=http://www.python.org/ftp/python/2.4.3/Python-2.4.3.tar.bz2cs_f=Python-2.4.3/Lib/sched.py#a0

Thanks,
Mark
mayzenshtat at) gmail (dot com

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-08 14:25

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

Fixed in revs 54224 and 54225.
Thanks for the bug report.

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-08 13:24

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

This was your change, Raymond.

--

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



[ python-Bugs-1673403 ] date-datetime comparison doesn't work

2007-03-08 Thread SourceForge.net
Bugs item #1673403, was opened at 2007-03-04 06:51
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1673403group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jon Ribbens (jribbens)
Assigned to: Tim Peters (tim_one)
Summary: date-datetime comparison doesn't work

Initial Comment:
Summary: bug #1028306 was not a bug, but the fix for it introduced one

Comparing a date to a datetime currently throws an exception. This makes no 
sense. In what way is:

  datetime(2006, 1, 1, 0, 0, 0)  date(2007, 1, 1)

not a perfectly reasonable and well-defined comparison? Throwing an exception 
here violates the Principle of Least Surprise to a considerable degree.

Obviously some slight ambiguity arises if the date and the datetime differ only 
in the time part. There are two sensible responses in this situation that I can 
see:

  Treat dates as if they have a time-part of midnight. This is my preferred 
solution, and it is already what the datetime module does, for example, when 
subtracting two dates.

  Treat dates as if they refer to the entire day, i.e. if the date and datetime 
differ only in the time part then they are equal. This is consistent but 
becomes confusing in other situations such as when subtracting dates.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-08 16:09

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

Tim, any thoughts?

--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-08 15:55

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

I think this warrants discussion on python-dev
(http://mail.python.org/mailman/listinfo/python-dev) as to which of the two
date interpretations to pick. Please post a description of the problem
there and ask for suggestions.

--

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



[ python-Bugs-1676656 ] Stdlib reference is in italics

2007-03-08 Thread SourceForge.net
Bugs item #1676656, was opened at 2007-03-08 17:34
Message generated for change (Comment added) made by sonderblade
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676656group_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: Fixed
Priority: 5
Private: No
Submitted By: Bj�rn Lindqvist (sonderblade)
Assigned to: Nobody/Anonymous (nobody)
Summary: Stdlib reference is in italics

Initial Comment:
The development version of the stdlib reference is messed up. All pages after 
this one http://docs.python.org/dev/lib/module-SocketServer.html has all the 
text in italics.

--

Comment By: Bj�rn Lindqvist (sonderblade)
Date: 2007-03-08 22:30

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

That was FAST. Thanks! 

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-08 18:50

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

The problem was that \em sets italics for the whole LaTeX scope while
\emph does that only for the following argument.

Fixed in rev. 54220, 54221 (2.5)

--

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



[ python-Bugs-1637850 ] make_table in difflib does not work with unicode

2007-03-08 Thread SourceForge.net
Bugs item #1637850, was opened at 2007-01-17 11:22
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1637850group_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: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: y-unno (y-unno)
Assigned to: Raymond Hettinger (rhettinger)
Summary: make_table in difflib does not work with unicode

Initial Comment:
make_table function in difflib.HtmlDiff does not work correctly when input 
strings are unicode.
This is because the library uses cStringIO.StringIO classes, and 
cStringIO.StringIO returns strings encoded by the default encoding.
When the default encoding is 'ascii', for example, this behaviour becomes a 
problem because some unicode characters cannot be encoded in 'ascii'.
 
So, please change cStringIO to StringIO in difflib.py.
When I use StringIO in difflib.py, this function returns unicode strings and no 
problems occured.
 
This problem occured in Python 2.5/2.4 on Windows XP.

--

Comment By: Raymond Hettinger (rhettinger)
Date: 2007-03-08 16:35

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

Fixed in revs 54229 and 54230.

It wasn't necessary to use StringIO at all.
A simple list of strings and join works fine
(and handles unicode transparently).

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-01-17 16:13

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

I don't know. Perhaps we should rather fix cStringIO to accept Unicode
strings.

--

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



[ python-Feature Requests-1624674 ] webbrowser.open_new() suggestion

2007-03-08 Thread SourceForge.net
Feature Requests item #1624674, was opened at 2006-12-29 19:03
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1624674group_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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Imre Péntek (imi1984)
Assigned to: Georg Brandl (gbrandl)
Summary: webbrowser.open_new() suggestion

Initial Comment:
Hello,

under Linux if I use
webbrowser.open_new('...') a konqueror gets invoked. At the time when invoking 
konqueror (maybe you probe first, but anyways) you assume that user has a 
properly installed kde. But if you assume the user has a properly installed KDE 
you have a better opportunity to open a webpage, even in the browser preferred 
by the user -- no matter really what it is. Try this one:
kfmclient exec http://sourceforge.net/
using this one the client associated with .html in kcontrol gets invoked.
I suppose that (becouse of the ability to customize the browser) this way would 
be better if available than guessing which browser would the user prefer.


--

Comment By: Mark Roberts (mark-roberts)
Date: 2007-01-14 18:08

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

A quick look at the code makes me think that it does try to run kfmclient
first.  Specifically, line 351 of webbrowser.py tries kfmclient, while like
line 363 of webbrowser.py opens konqueror.

I don't really run KDE, Gnome, or Windows, so I'm not a lot of help for
testing this for you.  I can, however, tell you that it does the right
thing for me, in that it opens Firefox.  When I did Python development on
Windows, it also did the right thing there.

--

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



[ python-Bugs-1628987 ] inspect trouble when source file changes

2007-03-08 Thread SourceForge.net
Bugs item #1628987, was opened at 2007-01-05 13:43
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1628987group_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: phil (philipdumont)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect trouble when source file changes

Initial Comment:
backtrace (relevant outer frames only):

  File /path/to/myfile, line 1198, in get_hook_name
for frame_record in inspect.stack():
  File /usr/mbench2.2/lib/python2.4/inspect.py, line 819, in stack
return getouterframes(sys._getframe(1), context)
  File /usr/mbench2.2/lib/python2.4/inspect.py, line 800, in getouterframes
framelist.append((frame,) + getframeinfo(frame, context))
  File /usr/mbench2.2/lib/python2.4/inspect.py, line 775, in getframeinfo
lines, lnum = findsource(frame)
  File /usr/mbench2.2/lib/python2.4/inspect.py, line 437, in findsource
if pat.match(lines[lnum]): break
IndexError: list index out of range

Based on a quick look at the inspect code, I think
this happens when you:

  - Start python and load a module
  - While it's running, edit the source file for the
module (before inspect tries to look into it).
  - Call a routine in the edited module that will
lead to a call to inspect.stack().

During an inspect.stack() call, inspect will open
source files to get the source code for the
routines on the stack.  If the source file that is
opened doesn't match the byte compiled code that's
being run, there are problems.  Inspect caches the
files it reads (using the linecache module), so if
the file gets cached before it is edited, nothing
should go wrong.  But if the source file is edited
after the module is loaded and before inspect has
a chance to cache the source, you're out of luck.

Of course, this shouldn't be a problem in production
code, but it has bit us more than once in a
development environment.

Seems like it would be easy to avoid by just comparing
the timestamps on the source/object files.  If the
source file is newer, just behave the same as if it
wasn't there.

Attached is a stupid little python script that
reproduces the problem.



--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-08 16:19

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

Could you possibly work up a patch demonstrating exactly what you're
proposing with the comparing the timestamps solution? That seems like a
lot of complication for such a rare issue, but I'd be interested in seeing
a patch all the same.

--

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



[ python-Bugs-1676121 ] Problem linking to readline lib on x86(64) Solaris

2007-03-08 Thread SourceForge.net
Bugs item #1676121, was opened at 2007-03-07 23:07
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676121group_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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alexander Belopolsky (belopolsky)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem linking to readline lib on x86(64) Solaris

Initial Comment:
Configuring with 

./configure --with-gcc=gcc -m64 -L/usr/sfw/lib/64 -R/usr/sfw/lib/64 

where 64bit libreadline is found in /usr/sfw/lib/64, configure script fails to 
realize that readline lib is present.

I was able to fix the problem by editing config script manually as follows:

$ diff configure~ configure
20744c20744
 if test $ac_cv_have_readline_readline = no
---
 if test $ac_cv_lib_readline_readline = no
20747c20747
 echo $as_me:$LINENO: checking for readline in -ltermcap 5
---
 echo $as_me:$LINENO: checking for readline in -lreadline -ltermcap 5
20753c20753
 LIBS=-ltermcap  $LIBS
---
 LIBS=-lreadline -ltermcap  $LIBS


A proper fix would be to change configure.in, but I don't know enough about 
autoconf to submit a proper patch.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-08 23:18

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

The right solution in this case is to edit Modules/Setup

--

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



[ python-Bugs-1676121 ] Problem linking to readline lib on x86(64) Solaris

2007-03-08 Thread SourceForge.net
Bugs item #1676121, was opened at 2007-03-07 17:07
Message generated for change (Comment added) made by belopolsky
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676121group_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: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alexander Belopolsky (belopolsky)
Assigned to: Nobody/Anonymous (nobody)
Summary: Problem linking to readline lib on x86(64) Solaris

Initial Comment:
Configuring with 

./configure --with-gcc=gcc -m64 -L/usr/sfw/lib/64 -R/usr/sfw/lib/64 

where 64bit libreadline is found in /usr/sfw/lib/64, configure script fails to 
realize that readline lib is present.

I was able to fix the problem by editing config script manually as follows:

$ diff configure~ configure
20744c20744
 if test $ac_cv_have_readline_readline = no
---
 if test $ac_cv_lib_readline_readline = no
20747c20747
 echo $as_me:$LINENO: checking for readline in -ltermcap 5
---
 echo $as_me:$LINENO: checking for readline in -lreadline -ltermcap 5
20753c20753
 LIBS=-ltermcap  $LIBS
---
 LIBS=-lreadline -ltermcap  $LIBS


A proper fix would be to change configure.in, but I don't know enough about 
autoconf to submit a proper patch.

--

Comment By: Alexander Belopolsky (belopolsky)
Date: 2007-03-08 17:25

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

Can you explain how to edit Module/Setup to solve this problem?

Note that the problem that I see comes before modules are built. In fact
it comes even before make.

In any case, I think the check for $ac_cv_have_readline_readline = no
instead of $ac_cv_lib_readline_readline = no looks like a typo in
configure.in.  And looking for readline in libtermcap does not look like
sound logic either.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-08 17:18

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

The right solution in this case is to edit Modules/Setup

--

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



[ python-Bugs-1625381 ] re module documentation on search/match is unclear

2007-03-08 Thread SourceForge.net
Bugs item #1625381, was opened at 2006-12-31 11:42
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1625381group_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: Richard Boulton (richardb)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: re module documentation on search/match is unclear

Initial Comment:
Section 4.2.2 (Matching vs Searching) of the Python Library Reference covers 
the match and search methods of regular expression objects.  However, it 
doesn't begin by describing the difference between these methods.  Each time I 
try to remember which way round match and search are, it takes several minutes 
of checking the documentation to work out which is which. I suggest that the 
first paragraph of the section is replaced with the following text (in two 
paragraphs), to make the distinction between the methods clearer:

Python offers two different primitive operations based on regular expressions: 
match and search.  match() checks for a match at the beginning of the search 
string, whereas search() checks for a match anywhere in the string.

If you want something equivalent to Perl's semantics, the search operation is 
what you're looking for. See the search() function and corresponding method of 
compiled regular expression objects.

--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-08 19:21

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

+1 on the general idea, though I'd change your match() checks for a match
at the beginning... to match() checks for a match starting at the
beginning I'd also like to drop the reference to Perl entirely; saying
that I should look to search() for Perl's semantics makes it sound like
match() doesn't support PCREs.

Fred, any thoughts?

--

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



[ python-Feature Requests-1625576 ] add ability to specify name to os.fdopen

2007-03-08 Thread SourceForge.net
Feature Requests item #1625576, was opened at 2007-01-01 02:19
Message generated for change (Comment added) made by collinwinter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1625576group_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: Mark Diekhans (diekhans)
Assigned to: Nobody/Anonymous (nobody)
Summary: add ability to specify name to os.fdopen

Initial Comment:
Please add an optional argument to os.fdopen() to specify the name field in
the resulting file object.  This would allow
for a more useful name than:
  open file 'fdopen'...

--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-08 20:02

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

Changing this to a feature request, since it's certainly not a bug.

I can see both sides of this; on the one hand, fdopen isn't the most
descriptive string and doesn't give you an idea where it came from; on the
other hand, you lose the distinction between files opened by filename and
those by file descriptor.

If the purpose is to distinguish between fdopen()'d files, what if
fdopen() was changed so that the filename matched fdopen \d+, where \d+
is the file descriptor passed to fdopen()?

--

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



[ python-Bugs-1666807 ] Incorrect file path reported by inspect.getabsfile()

2007-03-08 Thread SourceForge.net
Bugs item #1666807, was opened at 2007-02-23 07:08
Message generated for change (Comment added) made by fer_perez
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1666807group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Fernando P�rez (fer_perez)
Assigned to: Nobody/Anonymous (nobody)
Summary: Incorrect file path reported by inspect.getabsfile()

Initial Comment:
The following code demonstrates the problem succinctly:

###
import inspect,sys

print 'Version info:',sys.version_info
print

f1 = inspect.getabsfile(inspect)
f2 = inspect.getabsfile(inspect.iscode)
print 'File for `inspect`   :',f1
print 'File for `inspect.iscode`:',f2
print 'Do these match?',f1==f2
if f1==f2:
print 'OK'
else:
print 'BUG - this is a bug in this version of Python'

###  EOF

Running this on my system (Linux, Ubuntu Edgy) with 2.3, 2.4 and 2.5 produces:

tlon[bin] ./python2.3 ~/code/python/inspect_bug.py
Version info: (2, 3, 6, 'final', 0)

File for `inspect`   : /home/fperez/tmp/local/lib/python2.3/inspect.py
File for `inspect.iscode`: /home/fperez/tmp/local/lib/python2.3/inspect.py
Do these match? True
OK
tlon[bin] python2.4 ~/code/python/inspect_bug.py
Version info: (2, 4, 4, 'candidate', 1)

File for `inspect`   : /usr/lib/python2.4/inspect.py
File for `inspect.iscode`: /home/fperez/tmp/local/bin/inspect.py
Do these match? False
BUG - this is a bug in this version of Python
tlon[bin] python2.5 ~/code/python/inspect_bug.py
Version info: (2, 5, 0, 'final', 0)

File for `inspect`   : /usr/lib/python2.5/inspect.py
File for `inspect.iscode`: /home/fperez/tmp/local/bin/inspect.py
Do these match? False
BUG - this is a bug in this version of Python


###

The problem arises in the fact that inspect relies, for functions (at least), 
on the func_code.co_filename attribute to contain a complete path.  This 
changed between 2.3 and 2.4, but the inspect module was never updated.  This 
code:

###
import inspect,sys

print 'Python version info:',sys.version_info
print 'File info for `inspect.iscode function`:'
print ' ',inspect.iscode.func_code.co_filename
print
### EOF

shows the problem:

tlon[bin] ./python2.3 ~/code/python/inspect_bug_details.py
Python version info: (2, 3, 6, 'final', 0)
File info for `inspect.iscode function`:
  /home/fperez/tmp/local//lib/python2.3/inspect.py

tlon[bin] python2.5 ~/code/python/inspect_bug_details.py
Python version info: (2, 5, 0, 'final', 0)
File info for `inspect.iscode function`:
  inspect.py

###

(2.4 has the same issue).

Basically, if the func_code.co_filename attribute now stores only the final 
filename without the full path, then the logic in the inspect module needs to 
be changed to accomodate this so that correct paths are reported to the user 
like they were in the 2.3 days.

--

Comment By: Fernando P�rez (fer_perez)
Date: 2007-03-09 02:00

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

As I mentioned, on hand-built Pythons I don't get the bug at all.  So it
may be a problem with how Ubuntu builds its Python, since I can reproduce
the problem with both 2.4 and 2.5, but only with the default ones provided
by Ubuntu Edgy.  I don't know enough about their packaging system to know
how to retrieve build info.

There may be something odd in their build, but it would be nice if this
simply couldn't happen at all.  If anyone knows how to retrieve the
relevant info from an ubuntu build, I'll be happy to try and provide it.

--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-09 00:04

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

I haven't been able to reproduce this with Python 2.3.5, 2.4.4, 2.5.0 or
SVN HEAD (all hand-built on Slackware Linux).

What options are you providing to ./configure?

--

Comment By: Fernando P�rez (fer_perez)
Date: 2007-02-24 07:22

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

No, in my case the original tests with 2.4 and 2.5 were done with the
Ubuntu-provided (Edgy) versions, unmodified from their apt-get install
state.  But your comments are interesting.  I just rebuilt 2.5 by hand from
source on the same system, and this is what I get:

tlon[bin] ./python2.5 ~/code/python/inspect_bug.py
Version info: (2, 5, 0, 'final', 0)

File for `inspect`   :
/home/fperez/tmp/local/lib/python2.5/inspect.py
File for `inspect.iscode`:
/home/fperez/tmp/local/lib/python2.5/inspect.py
Do these match? True
OK


tlon[bin] ./python2.5 ~/code/python/inspect_bug_details.py
Python version info: (2, 5, 0, 'final', 0)
File info for `inspect.iscode 

[ python-Feature Requests-1625576 ] add ability to specify name to os.fdopen

2007-03-08 Thread SourceForge.net
Feature Requests item #1625576, was opened at 2007-01-01 07:19
Message generated for change (Comment added) made by diekhans
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1625576group_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: Mark Diekhans (diekhans)
Assigned to: Nobody/Anonymous (nobody)
Summary: add ability to specify name to os.fdopen

Initial Comment:
Please add an optional argument to os.fdopen() to specify the name field in
the resulting file object.  This would allow
for a more useful name than:
  open file 'fdopen'...

--

Comment By: Mark Diekhans (diekhans)
Date: 2007-03-09 04:58

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

thanks collin; that was suppose to be a feature request!

fdopen \d+ doesn't really help.  For end user message, a file name is
very use, the fact that it is opened by fdopen is not.  If one is debugging
a program and knows the file name, one can usually figure out where it is
opened, the file number, or for that matter that fdopen was used is less
useful.

The particular case that prompted this request was the need use os.open to
get non-blocking mode and then pass the result to fdopen.  However this now
loses the file name, replacing it with something not useful.

thanks.


--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-09 01:02

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

Changing this to a feature request, since it's certainly not a bug.

I can see both sides of this; on the one hand, fdopen isn't the most
descriptive string and doesn't give you an idea where it came from; on the
other hand, you lose the distinction between files opened by filename and
those by file descriptor.

If the purpose is to distinguish between fdopen()'d files, what if
fdopen() was changed so that the filename matched fdopen \d+, where \d+
is the file descriptor passed to fdopen()?

--

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



[ python-Feature Requests-1625576 ] add ability to specify name to os.fdopen

2007-03-08 Thread SourceForge.net
Feature Requests item #1625576, was opened at 2007-01-01 07:19
Message generated for change (Comment added) made by diekhans
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1625576group_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: Mark Diekhans (diekhans)
Assigned to: Nobody/Anonymous (nobody)
Summary: add ability to specify name to os.fdopen

Initial Comment:
Please add an optional argument to os.fdopen() to specify the name field in
the resulting file object.  This would allow
for a more useful name than:
  open file 'fdopen'...

--

Comment By: Mark Diekhans (diekhans)
Date: 2007-03-09 05:00

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

p.s.  I will happy implement the change.

--

Comment By: Mark Diekhans (diekhans)
Date: 2007-03-09 04:58

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

thanks collin; that was suppose to be a feature request!

fdopen \d+ doesn't really help.  For end user message, a file name is
very use, the fact that it is opened by fdopen is not.  If one is debugging
a program and knows the file name, one can usually figure out where it is
opened, the file number, or for that matter that fdopen was used is less
useful.

The particular case that prompted this request was the need use os.open to
get non-blocking mode and then pass the result to fdopen.  However this now
loses the file name, replacing it with something not useful.

thanks.


--

Comment By: Collin Winter (collinwinter)
Date: 2007-03-09 01:02

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

Changing this to a feature request, since it's certainly not a bug.

I can see both sides of this; on the one hand, fdopen isn't the most
descriptive string and doesn't give you an idea where it came from; on the
other hand, you lose the distinction between files opened by filename and
those by file descriptor.

If the purpose is to distinguish between fdopen()'d files, what if
fdopen() was changed so that the filename matched fdopen \d+, where \d+
is the file descriptor passed to fdopen()?

--

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



[ python-Bugs-1676971 ] Complex OverflowError has a typo

2007-03-08 Thread SourceForge.net
Bugs item #1676971, was opened at 2007-03-09 05:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676971group_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: John Dong (jdong2002)
Assigned to: Nobody/Anonymous (nobody)
Summary: Complex OverflowError has a typo

Initial Comment:
 (1-24j)**34324324
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: complex exponentiaion


Exponentiation is spelled incorrectly. This has been reproduced on Python 2.4 
and 2.5.

--

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



[ python-Bugs-1676971 ] Complex OverflowError has a typo

2007-03-08 Thread SourceForge.net
Bugs item #1676971, was opened at 2007-03-08 21:21
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1676971group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Private: No
Submitted By: John Dong (jdong2002)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Complex OverflowError has a typo

Initial Comment:
 (1-24j)**34324324
Traceback (most recent call last):
  File stdin, line 1, in module
OverflowError: complex exponentiaion


Exponentiation is spelled incorrectly. This has been reproduced on Python 2.4 
and 2.5.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-03-08 22:02

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

Thanks for the report!

Committed revision 54237.
Committed revision 54238. (2.5)


--

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



[ python-Bugs-1675511 ] Python still uses broken -xcode option on Solaris/x86

2007-03-08 Thread SourceForge.net
Bugs item #1675511, was opened at 2007-03-07 08:54
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1675511group_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: Carson Gaspar (cgaspar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Python still uses broken -xcode option on Solaris/x86

Initial Comment:
Bug 1561333 was submitted against Python 2.4 with no action, so I'm submitting 
a new bug against 2.5 in the hopes that someone will read it... text updated 
with minor corrections.

Python 2.5, Solaris x86 10 Update 3, Sun Studio 11

xcode=pic32 option is not supported on Solaris x86 Sun C  . Python's 
./configure script on Solaris systems sets the
compiler flag -xcode=pic32 when any compiler other than gcc is used. 
Unfortunately, the -xcode flag is only available in the sparc version of Sun C. 
The x86 version of Sun C does not support the -xcode option at all and 
generates an error that an illegal option was used. The portable flag supported 
on both platforms to use independent 32-bit addressing is -KPIC.

--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-09 08:08

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

One problem is that the proposed change is incorrect. According to the C
User's Guide of Sun Studio 11 (document 819-3688-10), -KPIC is an obsolete
option on SPARC, and should be replaced with -xcode=pic32 (section
A.1.15).

So I think a patch should be architecture-specific. Can somebody come up
with a patch that does that?



--

Comment By: James Lick (jlick)
Date: 2007-03-07 09:34

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

Perhaps I was unclear in bug #1561333 that this resulted in only a
warning.  Actually the build will fail because of the incorrect flag.

--

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



[ python-Bugs-1675026 ] Redirect cause invalid descriptor error

2007-03-08 Thread SourceForge.net
Bugs item #1675026, was opened at 2007-03-06 16:58
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1675026group_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: Windows
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jean-Marc Ranger (jmranger)
Assigned to: Nobody/Anonymous (nobody)
Summary: Redirect cause invalid descriptor error

Initial Comment:
Test setup:
- Windows 2000 (french)
- Python 2.5 (reproducible with 2.4.2 and 2.4.4)

One python source file, test.py:
---
  import os
  print os.system(echo test)
---

Console output:
---
C:\testtest.py
test
0

C:\testtest.py  test.log
Descripteur non valide

C:\testtype test.log
0

C:\testc:\python25\python test.py
test
0

C:\testc:\python25\python test.py  test.log

C:\testtype test.log
test
0

C:\test
---

The Descripteur non valide error would translate to invalid file descriptor.

I would expect the 2nd call to perform the same way the 4th does.


--

Comment By: Martin v. Löwis (loewis)
Date: 2007-03-09 08:10

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

Do you have an explanation for the cause of the problem?

--

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



<    1   2