Issue 1 of PET: English Translation a Python magazine is out!

2010-09-10 Thread Roberto Alsina
This magazine is a community effort. It's done by Python guys in Argentina.
We are quite proud of it, and we hope you like it too. 

You can read Issue 1 in our webpage: http://revista.python.org.ar/1/html-en/

It's available in several different formats, including PDF, ePub, Mobipocket, 
HTML and FB2, and is released under a CC-by-nc-sa license.

It has been translated to english by us, and we are not native speakers.
Hopefully Shakespeare will not raise from his grave to slap us for grievous 
offense against his language! But, to save us from the Wrath of Wil, feel free 
to point out any mistakes and unhappy turns of phrase in the comments.

Now that we have the english version out, we have *much bigger* plans for our 
second issue. We'll keep you posted.

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

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


cx_OracleTools 8.0

2010-09-10 Thread Anthony Tuininga
What is cx_OracleTools?

cx_OracleTools is a set of Python scripts that handle Oracle database
development tasks in a cross platform manner and improve (in my
opinion) on the tools that are available by default in an Oracle
client installation. Those who use cx_Oracle may also be interested in
this project, if only as sample code. Binaries for Windows and Linux
are provided for those who do not have a Python installation.


Where do I get it?

http://cx-oracletools.sourceforge.net


What's new?

1) In DescribeObject, added option --show-synonyms which enables
display of synonyms that reference the object. The default value for
this option is false.

2) In DescribeObject, DescribeSchema, ExportObjects and RebuildTable,
added support for Oracle context objects.

3) In DescribeSchema, ExportObjects and RecompileSource, added option
--name-file which acts in the same fashion as the --name option except
that the value of the option refers to a file containing a list of
names, one name per line.

4) In DescribeObject, DescribeSchema and ExportObjects, added option
--include-view-columns which enables specification of the column names
when creating a view.

5) In DescribeObject and DescribeSchema added support for eliminating
the quotas on tablespaces when generating create user statements.

6) In DescribeObject, DescribeSchema and ExportObjects, added options
--as-of-timestamp and --as-of-scn which enable flashback queries when
performing describes. This can be very useful for recovering those
accidentally issued DDL commands!

7) In DumpCSV, make use of the builtin module csv and the standard
option --schema; in addition, allow the file name to be specified as
- or not at all in which case the output goes to stdout.

8) In DumpData, added support for dumping CLOB, BLOB and binary data
values correctly. A commit statement is also appended to the output
now as a convenience.

9) In ExportXML, added option --sort-by which allows the result set to
be sorted before exporting. In addition, the source can be a query
instead of simply a table name.

10) In GeneratePatch, switch to the new more intelligent parser.

11) In ImportXML, now use cElementTree rather than home-grown XML
processing library.

12) In RebuildTable, removed SQL*Plus specific statements since by
default connect statements are issued which only works properly with
PatchDB.

13) In RecompileSource, added option --connect-as-owner and removed
option --password. The new option specifies that when invalid objects
are recompiled that a connection to the owner of the invalid object is
established using the password of the current connection. The default
value is false since this is an uncommon situation and is retained at
all for support of product development at Computronix.

14) Replaced CompileSource with PatchDB which uses a much more
advanced parser and is setup to handle additional commands besides
executing SQL scripts.

15) Added setup.py for building with cx_Freeze which means that MSI
packages for Windows and RPM packages for Linux are now available.

16) Other changes required to keep up with changes in Python,
dependent libraries and Oracle (including up to Oracle 11.2)

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

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


Re: How Python works: What do you know about support for negativeindices?

2010-09-10 Thread Neil Hodgson
Mark Tolonen:

 It came across fine for me (on much maligned Outlook Express, no less).

   Yes, looks fine to me both in Thunderbird (news, not mailing list)
and at Google Groups. There is a single text part with all lines except
an URL easily within 80 columns. Perhaps there is a problem in Ben's
reader or in the mailing list gateway.

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


Re: 32 bit bdist_wininst vs x64 platform

2010-09-10 Thread Mark Hammond

Hi Robin,

On 9/09/2010 9:28 PM, Robin Becker wrote:

A reportlab user is using 32 bit python on x64 win 2003. he has a
problem installing our bdist_wininst exe because the installer cannot
find python.


That should work fine - lots of pywin32 users do exactly that.


Apparently the installer is looking at HKLM\Software to locate python,
but on x64 32 bit program requests get redirected to
HKLM\Software\Wow6432Node (Extended explanation in KB article 896459).

Is this fixable by me making a local patch to my distutils to check for
the real platform and modifying the RegOpenKeyEx call? Or is there some
distutils magic that I'm missing?


As you mention, 32bit apps querying the registry get redirected in some 
cases - but so long as the 32bit bdist_wininst stub is used, that too 
will get redirected, so it should all work out fine.  Is it possible 
they are attempting to install an x64 version of reportlab on a 32bit 
python?


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


Re: Printing the name of a variable

2010-09-10 Thread Paul Rudin
Stephen Boulet stephen.bou...@gmail.com writes:

 Does an arbitrary variable carry an attribute describing the text in
 its name? I'm looking for something along the lines of:

 x = 10
 print x.name
 'x'

 Perhaps the x.__getattribute__ method? Thanks.

The first thing is... what is your use case for this? I'd guess that you
probably don't want to do this even if you think you do :)

The thing referred to by x is the number 10. When you write x.name (or
property) then you're dealing with the number 10, not with some
representation of the variable x. There may be many variables (or none)
that refer to that number at any given time during the execution of your
code... and the object itself knows nothing about any of these.

A good way to think about variable lookup is as a dictionary . It's
something like variables['x'].name. Once the varables['x'] bit has
been evaluated the link with 'x' is gone... we just have the result of
the lookup.

If you want to know how it actually works, then read up on python
namespaces and scopes, e.g. here:
http://www.network-theory.co.uk/docs/pytut/PythonScopesandNameSpaces.html.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Ulrich Eckhardt
Raymond Hettinger wrote:
 collections.deque('abcde').__getitem__[-2]  # extension class, magic
 method

Small nit: You don't mean [square] brackets here, right?

Otherwise, good posting, thank you!

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


inspect the call stack

2010-09-10 Thread bussiere bussiere
i v'e got this :
i've got toto.py :

import titi
def niwhom():
pass

and titi.py :

def nipang():
 pass

how can i know in titi.py that's it's toto.py that is calling titi.py
and the path of toto ?

how can i inspect the call stack or an other way ?

Regards
Bussiere
Google Fan boy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 32 bit bdist_wininst vs x64 platform

2010-09-10 Thread Robin Becker

..


As you mention, 32bit apps querying the registry get redirected in some cases -
but so long as the 32bit bdist_wininst stub is used, that too will get
redirected, so it should all work out fine. Is it possible they are attempting
to install an x64 version of reportlab on a 32bit python?

..

I'm a bit puzzled about this as well, they mentioned something about the python 
being embedded so perhaps that's the problem. I am trying to ascertain the exact 
context.



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


Re: SendKeys and Python 2.7

2010-09-10 Thread Lawrence D'Oliveiro
In message mailman.600.1284026879.29448.python-l...@python.org, Jakson A. 
Aquino wrote:

 I would like to send code from Vim [1] to R [2] on Microsoft Windows.

Why such a roundabout way? Why not just run R in a subprocess and feed it a 
script to run?

 [1] http://www.vim.org/
 [2] http://www.r-project.org/

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


Re: [Tutor] Arguments from the command line

2010-09-10 Thread Lawrence D'Oliveiro
In message 8662yfklzu@aiuole.stru.polimi.it, Giacomo Boffi wrote:

 Dennis Lee Bieber wlfr...@ix.netcom.com writes:
 
 FORTRAN just differentiates by having the main file start with
 PROGRAM random_name
 whereas subfiles are all either (or both)
 SUBROUTINE another_name(args)
 FUNCTION that_other_name(args)
 
 no BLOCKDATA?

I think you mean COMMON.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Arguments from the command line

2010-09-10 Thread Lawrence D'Oliveiro
In message i6aqk5$ro...@speranza.aioe.org, Mel wrote:

 But historical COBOL didn't pass parameters anyway.  You read
 your optional arguments from a file, or accepted a few from an input
 device.

I think it could also read from switches. As in front-panel on/off switches.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Giacomo Boffi
Ben Finney ben+pyt...@benfinney.id.au writes:

 Raymond Hettinger pyt...@rcn.com writes:

 It doesn't seem to be common knowledge when and how a[x] gets
 translated to a[x+len(x)].  So, here's a short info post on how Python
 supports negative indices for sequences.

 Thanks for this. Could you post your messages using a channel that
 doesn't arbitrarily split your paragraphs into long-short-long-short
 lines?

hi Ben, i see that you uses gnus... well, it's gnus that does the
unwanted formatting

try C-u g, as dettailed below, ciao

g runs `gnus-summary-show-article'

`gnus-summary-show-article' is an interactive compiled Lisp function
  -- loaded from gnus-sum
(gnus-summary-show-article optional ARG)

Documentation:
Force redisplaying of the current article.
If ARG (the prefix) is a number, show the article with the charset
defined in `gnus-summary-show-article-charset-alist', or the charset
input.
If ARG (the prefix) is non-nil and not a number, show the raw article
without any article massaging functions being run.  Normally, the key
strokes are `C-u g'.
-- 
la lenza penzola
   -- PMF, in IHC
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing the name of a variable

2010-09-10 Thread Jonathan Hartley
On Sep 9, 9:11 pm, Albert Hopkins mar...@letterboxes.org wrote:
 On Thu, 2010-09-09 at 12:43 -0700, Stephen Boulet wrote:
  Does an arbitrary variable carry an attribute describing the text in
  its name? I'm looking for something along the lines of:

  x = 10
  print x.name
   'x'

  Perhaps the x.__getattribute__ method? Thanks.

 Variables are not objects and so they have no attributes.

 You can't really de-reference the object being referenced as it can
 potentially contain multiple references, but an innacurate way of doing
 this would be, e.g.

  x = [1, 2, 3]
  y = x
  g = globals()
  varnames = [i for i in g if g[i] is x]

 ['x', 'y']

 But this cries the question: why do you want to do this?  And usually
 that question is asked when someone thinks that a: you shouldn't need to
 do this and b: whatever the desired effect there is probably a better
 way of accomplishing it.

I have in the past wondered about creating a kind of graphical
debugger, that rendered representations of all the objects in globals
and/or locals, to give you a visual representation of your variables
and their states. Would this be a valid use case to try and look up
the variable names which reference various in-memory objects?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Steven D'Aprano
On Thu, 09 Sep 2010 18:37:49 -0700, Raymond Hettinger wrote:

 Hello Folks.
 
 It doesn't seem to be common knowledge when and how a[x] gets translated
 to a[x+len(x)].  So, here's a short info post on how Python supports
 negative indices for sequences.
[...]
 Hope you all found this to be informative,


Thanks Raymond!


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


Re: Printing the name of a variable

2010-09-10 Thread Simon Brunning
On 9 September 2010 20:43, Stephen Boulet stephen.bou...@gmail.com wrote:
 Does an arbitrary variable carry an attribute describing the text in
 its name? I'm looking for something along the lines of:

 x = 10
 print x.name
 'x'

http://effbot.org/pyfaq/how-can-my-code-discover-the-name-of-an-object.htm

-- 
Cheers,
Simon B.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Arguments from the command line

2010-09-10 Thread Giacomo Boffi
Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:

 In message 8662yfklzu@aiuole.stru.polimi.it, Giacomo Boffi wrote:

 Dennis Lee Bieber wlfr...@ix.netcom.com writes:
 
 FORTRAN just differentiates by having the main file start with
 PROGRAM random_name
 whereas subfiles are all either (or both)
 SUBROUTINE another_name(args)
 FUNCTION that_other_name(args)
 
 no BLOCKDATA?

 I think you mean COMMON.

i meant BLOCKDATA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Daniel Fetchinson
 Raymond Hettinger pyt...@rcn.com writes:

 It doesn't seem to be common knowledge when and how a[x] gets
 translated to a[x+len(x)].  So, here's a short info post on how Python
 supports negative indices for sequences.

 Thanks for this. Could you post your messages using a channel that
 doesn't arbitrarily split your paragraphs into long-short-long-short
 lines?

It came across fine for me as well (gmail with basic html interface).

 It makes paragraphs burdensome to read, and I skipped most of the
 message because of that.

You might want to switch to a client where you do not have this problem.

 I encourage anyone whose messages are munged like that to seek
 correction from their mail service provider, and switch to a different
 one until it's fixed.

I encourage anyone who has problems with reading various emails,
newsgroup postings, forums and what not, to start using modern tools
that work with the vast majority of other tools.

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 32 bit bdist_wininst vs x64 platform

2010-09-10 Thread Robin Becker

On 10/09/2010 09:52, Robin Becker wrote:

..


As you mention, 32bit apps querying the registry get redirected in some cases -
but so long as the 32bit bdist_wininst stub is used, that too will get
redirected, so it should all work out fine. Is it possible they are attempting
to install an x64 version of reportlab on a 32bit python?

..

I'm a bit puzzled about this as well, they mentioned something about the python
being embedded so perhaps that's the problem. I am trying to ascertain the exact
context.


I found out that although the end users had installed the amd64 python they were 
using reportlab-2.4.win32-py2.6.exe which is 32 bit. That complained until they 
fixed everything up by brute force registry copying. Fortunately, I don't think 
the pyds are importable and reportlab is robust enough to fall back to a working 
state even without those.

--
Robin Becker

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


Re: include a file in a python program

2010-09-10 Thread Bruno Desthuilliers

Steven D'Aprano a écrit :

On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote:


i've got a python.txt that contain python and it must stay as it
(python.txt)


Why? Is it against the law to change it? *wink*
 

how can i include it in my program ?
import python.txt doesn't work



You could write a custom importer to handle it, but I can't help you with 
that. Try Google.



is there a way :
a) to make an include(python.txt)
b) tell him to treat .txt as .py file that i can make an import python ?


fp = open(python.txt)
text = fp.read()
fp.close()
exec(text)


or just:

execfile(python.txt)


But keep in mind that the contents of python.txt will be executed as if 
you had typed it yourself. If you don't trust the source with your life 
(or at least with the contents of your computer), don't execute it.


+10

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


Re: inspect the call stack

2010-09-10 Thread Bruno Desthuilliers

bussiere bussiere a écrit :

i v'e got this :
i've got toto.py :

import titi
def niwhom():
pass

and titi.py :

def nipang():
 pass

how can i know in titi.py that's it's toto.py that is calling titi.py
and the path of toto ?

how can i inspect the call stack or an other way ?


http://www.google.fr/search?q=python+inspect+the+call+stack

First answer should point you to the relevant part of the FineManual(tm):
http://docs.python.org/library/inspect.html

ot
And while we're at it, what about not opening a new thread for a 
question already partially answered ?

/ot

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


Trap Authentication Errors in HTTP Request

2010-09-10 Thread naugiedoggie
Hello,

I have a script that authenticates to a web service provider to
retrieve data.  This script provides an authentication header built in
a very basic way like this:

code
# Creates an authentication object with the credentials for a given
URL
def createPasswordManager(headers) :
passwordManager = urllib2.HTTPPasswordMgrWithDefaultRealm()
 
passwordManager.add_password(None,overview_url,headers[0],headers[1])
return passwordManager

# Creates an authentication handler for the authentication object
created above
def createAuthenticationHandler(passwordManager) :
authenticationHandler =
urllib2.HTTPBasicAuthHandler(passwordManager)
return authenticationHandler

# Creates an opener that sets the credentials in the Request
def createOpener(authHandler) :
return urllib2.build_opener(authHandler)
/code

This script makes multiple calls for data.  I would like to trap an
exception for authentication failure so that it doesn't go through its
entire list of calls when there's a problem with the login.  The
assumption is that if there is a login failure, the script is using
incorrect authentication information.

I have the call for data retrieval wrapped in try/except, to catch
HTTPError, but apparently no '401' is explicitly thrown when
authentication fails.  And I don't see an explicit Exception that is
thrown in urllib2 for handling these failures.

How can I achieve my goal of trapping these exceptions and exiting
cleanly?

Thanks.

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


How to Convert IO Stream to XML Document

2010-09-10 Thread jakecjacobson
I am trying to build a Python script that reads a Sitemap file and
push the URLs to a Google Search Appliance.  I am able to fetch the
XML document and parse it with regular expressions but I want to move
to using native XML tools to do this.  The problem I am getting is if
I use urllib.urlopen(url) I can convert the IO Stream to a XML
document but if I use urllib2.urlopen and then read the response, I
get the content but when I use minidom.parse() I get a IOError:
[Errno 2] No such file or directory: error

THIS WORKS but will have issues if the IO Stream is a compressed file
def GetPageGuts(net, url):
pageguts = urllib.urlopen(url)
xmldoc = minidom.parse(pageguts)
return xmldoc

# THIS DOESN'T WORK, but I don't understand why
def GetPageGuts(net, url):
request=getRequest_obj(net, url)
response = urllib2.urlopen(request)
response.headers.items()
pageguts = response.read()
# Test to see if the response is a gzip/compressed data stream
if isCompressedFile(response, url):
compressedstream = StringIO.StringIO(pageguts)
gzipper = gzip.GzipFile(fileobj = compressedstream)
pageguts = gzipper.read()
xmldoc = minidom.parse(pageguts)
response.close()
return xmldoc

# I am getting the following error
Starting SiteMap Manager ...
Traceback (most recent call last):
  File ./tester.py, line 267, in ?
main()
  File ./tester.py, line 49, in main
fetchSiteMap(ResourceDict, line)
  File ./tester.py, line 65, in fetchSiteMap
pageguts = GetPageGuts(ResourceDict['NET'], url)
  File ./tester.py, line 89, in GetPageGuts
xmldoc = minidom.parse(pageguts)
  File /usr/lib/python2.4/xml/dom/minidom.py, line 1915, in parse
return expatbuilder.parse(file)
  File /usr/lib/python2.4/xml/dom/expatbuilder.py, line 922, in
parse
fp = open(file, 'rb')
IOError: [Errno 2] No such file or directory: '?xml version=1.0
encoding=UTF-8?\nsitemapindex xmlns=http://www.sitemaps.org/
schemas/sitemap/0.9\nsitemap\nlochttp://www.myorg.org/janes/
sitemaps/binder_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/
sitemap\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
dir_sitemap.xml/loc\nlastmod2010-05-05/lastmod\n/sitemap
\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
mags_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
news_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
sent_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
srep_sitemap.xml/loc\nlastmod2001-05-04/lastmod\n/sitemap
\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/yb_sitemap.xml/
loc\nlastmod2010-09-09/lastmod\n/sitemap\n/sitemapindex\n'

# A couple of supporting things
def getRequest_obj(net, url):
request = urllib2.Request(url)
request.add_header('User-Agent', 'ICES Sitemap Bot dni-ices-
searchad...@ugov.gov')
request.add_header('Accept-encoding', 'gzip')
return request

def isCompressedFile(r, u):
answer=False
if r.headers.has_key('Content-encoding'):
answer=True
else:
# Check to see if the URL ends in .gz
if u.endswith(.gz):
answer=True
return answer

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


Re: How to Convert IO Stream to XML Document

2010-09-10 Thread Nitin Pawar
try using parse from string ... and try
 minidom.parse(StringIO.StingIO(string)).documentElement

On Fri, Sep 10, 2010 at 9:50 PM, jakecjacobson jakecjacob...@gmail.comwrote:

 I am trying to build a Python script that reads a Sitemap file and
 push the URLs to a Google Search Appliance.  I am able to fetch the
 XML document and parse it with regular expressions but I want to move
 to using native XML tools to do this.  The problem I am getting is if
 I use urllib.urlopen(url) I can convert the IO Stream to a XML
 document but if I use urllib2.urlopen and then read the response, I
 get the content but when I use minidom.parse() I get a IOError:
 [Errno 2] No such file or directory: error

 THIS WORKS but will have issues if the IO Stream is a compressed file
 def GetPageGuts(net, url):
pageguts = urllib.urlopen(url)
xmldoc = minidom.parse(pageguts)
return xmldoc

 # THIS DOESN'T WORK, but I don't understand why
 def GetPageGuts(net, url):
request=getRequest_obj(net, url)
response = urllib2.urlopen(request)
response.headers.items()
pageguts = response.read()
# Test to see if the response is a gzip/compressed data stream
if isCompressedFile(response, url):
compressedstream = StringIO.StringIO(pageguts)
gzipper = gzip.GzipFile(fileobj = compressedstream)
pageguts = gzipper.read()
xmldoc = minidom.parse(pageguts)
response.close()
return xmldoc

 # I am getting the following error
 Starting SiteMap Manager ...
 Traceback (most recent call last):
  File ./tester.py, line 267, in ?
main()
  File ./tester.py, line 49, in main
fetchSiteMap(ResourceDict, line)
  File ./tester.py, line 65, in fetchSiteMap
pageguts = GetPageGuts(ResourceDict['NET'], url)
  File ./tester.py, line 89, in GetPageGuts
xmldoc = minidom.parse(pageguts)
  File /usr/lib/python2.4/xml/dom/minidom.py, line 1915, in parse
return expatbuilder.parse(file)
  File /usr/lib/python2.4/xml/dom/expatbuilder.py, line 922, in
 parse
fp = open(file, 'rb')
 IOError: [Errno 2] No such file or directory: '?xml version=1.0
 encoding=UTF-8?\nsitemapindex xmlns=http://www.sitemaps.org/
 schemas/sitemap/0.9\nsitemap\nlochttp://www.myorg.org/janes/
 sitemaps/binder_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/
 sitemap\nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
 dir_sitemap.xml/loc\nlastmod2010-05-05/lastmod\n/sitemap
 \nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
 mags_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
 \nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
 news_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
 \nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
 sent_sitemap.xml/loc\nlastmod2010-09-09/lastmod\n/sitemap
 \nsitemap\nlochttp://www.myorg.org/janes/sitemaps/
 srep_sitemap.xml/loc\nlastmod2001-05-04/lastmod\n/sitemap
 \nsitemap\nlochttp://www.myorg.org/janes/sitemaps/yb_sitemap.xml/
 loc\nlastmod2010-09-09/lastmod\n/sitemap\n/sitemapindex\n'

 # A couple of supporting things
 def getRequest_obj(net, url):
request = urllib2.Request(url)
request.add_header('User-Agent', 'ICES Sitemap Bot dni-ices-
 searchad...@ugov.gov')
request.add_header('Accept-encoding', 'gzip')
return request

 def isCompressedFile(r, u):
answer=False
if r.headers.has_key('Content-encoding'):
answer=True
else:
# Check to see if the URL ends in .gz
if u.endswith(.gz):
answer=True
return answer

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




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


Ugh! Python 3.1.x and MySQL

2010-09-10 Thread fuglyducky
Most of the python books coming out now are Py3K. I just started
programming and have a need to access a MySQL database. I would like
to use Python to do this. Unfortunately, I cannot find anyone that has
created anything that allows my to do this.

I've tried installing an ODBC driver and using sqlalchemy, oursql, and
a few other things with no luck.

So...just wondering if anyone is aware of any libraries/modules that I
can use to connect to a MySQL DB using Python 3.1.x?

Ideally, I'd like to be able to this from both x86 and x64 systems (if
that makes any difference).

Thanks for any input you may have!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SendKeys and Python 2.7

2010-09-10 Thread Jakson A. Aquino
On Fri, Sep 10, 2010 at 6:26 AM, Lawrence D'Oliveiro
l...@geek-central.gen.new_zealand wrote:
 In message mailman.600.1284026879.29448.python-l...@python.org, Jakson A.
 Aquino wrote:

 I would like to send code from Vim [1] to R [2] on Microsoft Windows.

 Why such a roundabout way? Why not just run R in a subprocess and feed it a
 script to run?

Emacs with ESS runs R in a subprocess (at least I think it does). Vim
can't do that.

The plugin doesn't simply send code to R. It has many other features
that make it easier to edit R scripts.

Best,

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


Re: [Python-ideas] Why not f(*my_list, *my_other_list) ?

2010-09-10 Thread MRAB

On 10/09/2010 17:37, cool-RR wrote:

I noticed that it's impossible to call a Python function with two
starred argument lists, like this: `f(*my_list, *my_other_list)`. I
mean, if someone wants to feed two lists of arguments into a function,
why not?

I understand why you can't have two stars in a function definition; But
why can't you have two (or more) stars in a function call?


Would there be any advantage over `f(*(my_list + my_other_list))`?
--
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Why not f(*my_list, *my_other_list) ?

2010-09-10 Thread Ian Kelly
On Fri, Sep 10, 2010 at 10:52 AM, MRAB pyt...@mrabarnett.plus.com wrote:
 On 10/09/2010 17:37, cool-RR wrote:

 I noticed that it's impossible to call a Python function with two
 starred argument lists, like this: `f(*my_list, *my_other_list)`. I
 mean, if someone wants to feed two lists of arguments into a function,
 why not?

 I understand why you can't have two stars in a function definition; But
 why can't you have two (or more) stars in a function call?

 Would there be any advantage over `f(*(my_list + my_other_list))`?

That fails if my_list and my_other_list are different types, whereas
the *args syntax happily accepts any iterable object.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] Why not f(*my_list, *my_other_list) ?

2010-09-10 Thread Stefan Behnel

Ian Kelly, 10.09.2010 19:03:

On Fri, Sep 10, 2010 at 10:52 AM, MRABpyt...@mrabarnett.plus.com  wrote:

On 10/09/2010 17:37, cool-RR wrote:


I noticed that it's impossible to call a Python function with two
starred argument lists, like this: `f(*my_list, *my_other_list)`. I
mean, if someone wants to feed two lists of arguments into a function,
why not?

I understand why you can't have two stars in a function definition; But
why can't you have two (or more) stars in a function call?


Would there be any advantage over `f(*(my_list + my_other_list))`?


That fails if my_list and my_other_list are different types, whereas
the *args syntax happily accepts any iterable object.


But I think it's still a rare enough use case to require

f(*(tuple(my_list) + tuple(my_other_list)))

when you need it, although the concatenation would likely get split up and 
moved into an explicit variable anyway.


Stefan

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


Re: Function Point Analysis (FPA) - Equivalent lines of code of Python

2010-09-10 Thread John Roth
On Sep 9, 2:30 am, Nicholas yue.nicho...@gmail.com wrote:
 Hi,

   In FPA, there are tables which shows equivalent lines of code for
 each Function Point (FP) for a number of programming languages.

   e.g.http://www.qsm.com/?q=resources/function-point-languages-table/index

   However, I have yet to find the figures for Python.

   Is someone able to advise the closest language equivalent.

 Regards

Function points do not translate to lines of code except when they're
standardized across a specific organization's portfolio of software. I
agree with Paul, any global table trying to do that is going to be
pretty bogus.

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


Re: [Python-ideas] Why not f(*my_list, *my_other_list) ?

2010-09-10 Thread Paul Rubin
Ian Kelly ian.g.ke...@gmail.com writes:
 Would there be any advantage over `f(*(my_list + my_other_list))`?

 That fails if my_list and my_other_list are different types, whereas
 the *args syntax happily accepts any iterable object.

f(*itertools.chain(my_list, my_other_list))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to kill a subprocess

2010-09-10 Thread cerr
On Sep 9, 4:18 pm, MRAB pyt...@mrabarnett.plus.com wrote:
 On 09/09/2010 23:52, cerr wrote:



  On Sep 9, 3:29 pm, Alain Ketterlinal...@dpt-info.u-strasbg.fr
  wrote:
  cerrron.egg...@gmail.com  writes:
  I'm calling a python script from a php script which again calls a perl
  script with subprocess.popen().
  This seems to work fine so far only that once the python script
  completed it is becoming a zombie because the perl script in the
  background is still running... so before i exit the python script, i
  would need to kill my perl subprocess.
  How can i do so?

  x.terminate() (and then x.wait()) where x is the value returned by
  subprocess.Popen().
  Well, this is what I have:

     writelog(starting GPS simulator)
     commandlist=[GPSsim,proto,GPSfile]
     writelog(commandlist[0]+ +commandlist[1]+ +commandlist[2])
     process=subprocess.Popen(commandlist)
     writelog(GPS simulator started)
     ...
     ...
     os.kill(process.pid,9)
     os.wait()

  but this is not working for me... :( any clues?

  P/S: I'm not sure why the python process survives, and I think your use
  of zombie is not correct (afaik a zombie is an exited process whose
  parent hasn't called wait() yet)

  This is what I have:

  localhost cgi-bin # ps ax | grep py
  11853 ?        Z      0:00 [python2.6]defunct
  12029 pts/1    S+     0:00 grep --colour=auto py

  The 'Z' you see there stands for Zombie

 How about:

      process.kill() # New in Python 2.6

 or:

      os.kill(process.pid, 9)

 then:

      process.wait()

 or:

      os.waitpid(process.pid, 0)

HI MRAB,

Thanks for your suggestion, changed my code now to:

  process=subprocess.Popen(commandlist)
  ...
  ...
  process.kill()
  os.waitpid(process.pid, 0)
but it's not killing the process running. it still runs in the
background and i don't see any errors, we're running python 2.6.4
any more clues?

Thanks,
Ron
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ugh! Python 3.1.x and MySQL

2010-09-10 Thread Rami Chowdhury
On Fri, Sep 10, 2010 at 22:27, fuglyducky fuglydu...@gmail.com wrote:

 Most of the python books coming out now are Py3K. I just started
 programming and have a need to access a MySQL database. I would like
 to use Python to do this. Unfortunately, I cannot find anyone that has
 created anything that allows my to do this.

 I've tried installing an ODBC driver and using sqlalchemy, oursql, and
 a few other things with no luck.

 So...just wondering if anyone is aware of any libraries/modules that I
 can use to connect to a MySQL DB using Python 3.1.x?


Have you tried OurSQL (http://packages.python.org/oursql/)?



 Ideally, I'd like to be able to this from both x86 and x64 systems (if
 that makes any difference).

 Thanks for any input you may have!!!
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Rami Chowdhury
Never assume malice when stupidity will suffice. -- Hanlon's Razor
408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
-- 
http://mail.python.org/mailman/listinfo/python-list


bool constructor is inconsistent?

2010-09-10 Thread Neal Becker
IN [3]: bool('False')
Out[3]: True

In [4]: int('32')
Out[4]: 32

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


Re: bool constructor is inconsistent?

2010-09-10 Thread Stefan Behnel

Neal Becker, 10.09.2010 20:23:

IN [3]: bool('False')
Out[3]: True


Not inconsistent at all:

   bool('false')
  True
   bool('true')
  True
   bool('')
  False
   bool(32)
  True
   bool(0)
  False

It simply follows Python's boolean coercion rules.

If you consider it inconsisten w.r.t. int('32'), then what about

list('[]')
   ['[', ']']

Stefan

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


Re: bool constructor is inconsistent?

2010-09-10 Thread Emile van Sebille

On 9/10/2010 11:23 AM Neal Becker said...

IN [3]: bool('False')
Out[3]: True

In [4]: int('32')
Out[4]: 32





 eval('False')
False
 eval('32')
32



Otherwise, 'False' is just a string?

Emile

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


Re: bool constructor is inconsistent?

2010-09-10 Thread Stefan Schwarzer
Hi Neal,

On 2010-09-10 20:23, Neal Becker wrote:
 IN [3]: bool('False')
 Out[3]: True

If you consider strings, only an empty string has a false
value. So the string 'False' which is non-empty, results in
a true boolean value.

For example, you can use

if my_string:
...

to execute some code if the string is not empty.

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


Re: how to kill a subprocess

2010-09-10 Thread Christian Heimes
Am 10.09.2010 19:51, schrieb cerr:
 Thanks for your suggestion, changed my code now to:
 
   process=subprocess.Popen(commandlist)
   ...
   ...
   process.kill()
   os.waitpid(process.pid, 0)
 but it's not killing the process running. it still runs in the
 background and i don't see any errors, we're running python 2.6.4
 any more clues?

It's not an issue with your Python process but with its parent process.
The parent process has to call the OS's waitpid() function with the PID
of the Python process in order to reap it. Please show us how you are
starting and controlling the Python process in your PHP code.

Christian

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


Re: how to kill a subprocess

2010-09-10 Thread cerr
On Sep 10, 11:45 am, Christian Heimes li...@cheimes.de wrote:
 Am 10.09.2010 19:51, schrieb cerr:

  Thanks for your suggestion, changed my code now to:

    process=subprocess.Popen(commandlist)
    ...
    ...
    process.kill()
    os.waitpid(process.pid, 0)
  but it's not killing the process running. it still runs in the
  background and i don't see any errors, we're running python 2.6.4
  any more clues?

 It's not an issue with your Python process but with its parent process.
 The parent process has to call the OS's waitpid() function with the PID
 of the Python process in order to reap it. Please show us how you are
 starting and controlling the Python process in your PHP code.

But I wanna kill the child process I start from my python code.
It's like
PHP - Python - Perl

and when the connection PHP - Python seems to work well!


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


3D cube navigation

2010-09-10 Thread sahilsk
hi, i need to make a 3d cube as a navigation menu.. each face having
separate  button .. or effect.
any idea,  how can i make one such 3D figures with functionality of
mouse events?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to kill a subprocess

2010-09-10 Thread Christian Heimes
Am 10.09.2010 20:56, schrieb cerr:
 But I wanna kill the child process I start from my python code.
 It's like
 PHP - Python - Perl
 
 and when the connection PHP - Python seems to work well!

You have said that the Python process becomes a zombie process. This
clearly tells me that the issue is in your PHP script. See
http://en.wikipedia.org/wiki/Fork-exec

Christian

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


Re: bool constructor is inconsistent?

2010-09-10 Thread David Robinow
On Fri, Sep 10, 2010 at 2:35 PM, Stefan Schwarzer
sschwar...@sschwarzer.net wrote:
 Hi Neal,

 On 2010-09-10 20:23, Neal Becker wrote:
 IN [3]: bool('False')
 Out[3]: True

 If you consider strings, only an empty string has a false
 value. So the string 'False' which is non-empty, results in
 a true boolean value.
 ...
 I've always felt that if a humorous post needs a smiley, that it's not funny.
However, there is the risk of being misunderstood.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ugh! Python 3.1.x and MySQL

2010-09-10 Thread nn
On Sep 10, 12:27 pm, fuglyducky fuglydu...@gmail.com wrote:
 Most of the python books coming out now are Py3K. I just started
 programming and have a need to access a MySQL database. I would like
 to use Python to do this. Unfortunately, I cannot find anyone that has
 created anything that allows my to do this.

 I've tried installing an ODBC driver and using sqlalchemy, oursql, and
 a few other things with no luck.

 So...just wondering if anyone is aware of any libraries/modules that I
 can use to connect to a MySQL DB using Python 3.1.x?

 Ideally, I'd like to be able to this from both x86 and x64 systems (if
 that makes any difference).

 Thanks for any input you may have!!!

Google found this:

http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/3831691
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to kill a subprocess

2010-09-10 Thread cerr
On Sep 10, 12:18 pm, Christian Heimes li...@cheimes.de wrote:
 Am 10.09.2010 20:56, schrieb cerr:

  But I wanna kill the child process I start from my python code.
  It's like
  PHP - Python - Perl

  and when the connection PHP - Python seems to work well!

 You have said that the Python process becomes a zombie process. This
 clearly tells me that the issue is in your PHP script. 
 Seehttp://en.wikipedia.org/wiki/Fork-exec

No, the Perl becomes the zombie.

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


Re: how to kill a subprocess

2010-09-10 Thread Christian Heimes
Am 10.09.2010 22:14, schrieb cerr:
 No, the Perl becomes the zombie.

How are you killing the Python process? Are you sending SIGINT, SIGTERM
or SIGKILL? SIGKILL can prevent Python from running its cleanup code.

Christian


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


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Terry Reedy

On 9/9/2010 9:37 PM, Raymond Hettinger wrote:


The docs guarantee that Python's builtin sequences implement support
for negative indices (


http://docs.python.org/dev/reference/expressions.html#subscriptions

The relevant paragraphs are

For built-in objects, there are two types of objects that support 
subscription:


If the primary is a mapping, the expression list must evaluate to an 
object whose value is one of the keys of the mapping, and the 
subscription selects the value in the mapping that corresponds to that 
key. (The expression list is a tuple except if it has exactly one item.)


If the primary is a sequence, the expression (list) must evaluate to an 
integer. If this value is negative, the length of the sequence is added 
to it (so that, e.g., x[-1] selects the last item of x.) The resulting 
value must be a nonnegative integer less than the number of items in the 
sequence, and the subscription selects the item whose index is that 
value (counting from zero).



Reading the third paragraph out of context, one can miss the restriction 
to built-in objects. I had assumed that the conversion using len(), when 
available, happened prior to the __getitem__ call. I believe I need to 
add the restriction in my discussion of negative indexing in my book. I 
would like the above rewritten something like the following:


Two types of built-in objects support subscription as primaries: 
mappings and sequences.


For built-in mappings, the

For built-in sequences, the ...


The second paragraph was written before defaultdict and does not apply 
to them. I presume that it is an extension rather than built-in class 
for the purpose of the Reference.



Hope you all found this to be informative,


Definitely. I save a copy for future reference.

--
Terry Jan Reedy

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


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Aahz
In article mailman.634.1284115580.29448.python-l...@python.org,
Daniel Fetchinson  fetchin...@googlemail.com wrote:
Attribution missing:

 I encourage anyone whose messages are munged like that to seek
 correction from their mail service provider, and switch to a different
 one until it's fixed.

I encourage anyone who has problems with reading various emails,
newsgroup postings, forums and what not, to start using modern tools
that work with the vast majority of other tools.

Why?  Raymond's post worked fine for me with trn3.6
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

[on old computer technologies and programmers]  Fancy tail fins on a
brand new '59 Cadillac didn't mean throwing out a whole generation of
mechanics who started with model As.  --Andrew Dalke
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Samurai Principle

2010-09-10 Thread Lawrence D'Oliveiro
In message mailman.567.1283927599.29448.python-l...@python.org, Ian Kelly 
wrote:

 And returning None on failure is dangerous, because if the programmer
 does not take care to handle that case, the program may attempt to
 regard it as actual data.

But None *is* actual data.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Tutor] Arguments from the command line

2010-09-10 Thread Lawrence D'Oliveiro
In message 86wrqtsxo2@aiuole.stru.polimi.it, Giacomo Boffi wrote:

 Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes:
 
 In message 8662yfklzu@aiuole.stru.polimi.it, Giacomo Boffi wrote:

 no BLOCKDATA?

 I think you mean COMMON.
 
 i meant BLOCKDATA

BLOCKDATA is an initializer. The actual storage is allocated by COMMON.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SendKeys and Python 2.7

2010-09-10 Thread Lawrence D'Oliveiro
In message mailman.638.1284137343.29448.python-l...@python.org, Jakson A. 
Aquino wrote:

 On Fri, Sep 10, 2010 at 6:26 AM, Lawrence D'Oliveiro
 l...@geek-central.gen.new_zealand wrote:

 In message mailman.600.1284026879.29448.python-l...@python.org, Jakson
 A. Aquino wrote:

 I would like to send code from Vim [1] to R [2] on Microsoft Windows.

 Why such a roundabout way? Why not just run R in a subprocess and feed it
 a script to run?
 
 Emacs with ESS runs R in a subprocess (at least I think it does). Vim
 can't do that.

Why not?

 The plugin doesn't simply send code to R. It has many other features
 that make it easier to edit R scripts.

But those are editing functions, nothing to do with R.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] with statement syntax forces ugly line breaks?

2010-09-10 Thread Lawrence D'Oliveiro
In message mailman.580.1283974241.29448.python-l...@python.org, MRAB 
wrote:

 On 08/09/2010 19:07, Georg Brandl wrote:

 Thus spake the Lord: Thou shalt indent with four spaces. No more, no
 less. Four shall be the number of spaces thou shalt indent, and the
 number of thy indenting shall be four. Eight shalt thou not indent,
 nor either indent thou two, excepting that thou then proceed to four.
 Tabs are right out.

 FYI, that should be thine indenting.
 
 My/thy before a consonant, mine/thine before a vowel. Compare with
 a/an, which we still do.

The funny thing is, that’s technically “Modern English”...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SendKeys and Python 2.7

2010-09-10 Thread Jakson A. Aquino
On Fri, Sep 10, 2010 at 7:19 PM, Lawrence D'Oliveiro
l...@geek-central.gen.new_zealand wrote:
 In message mailman.638.1284137343.29448.python-l...@python.org, Jakson A.
 Aquino wrote:
 On Fri, Sep 10, 2010 at 6:26 AM, Lawrence D'Oliveiro
 l...@geek-central.gen.new_zealand wrote:
 In message mailman.600.1284026879.29448.python-l...@python.org, Jakson
 A. Aquino wrote:
 I would like to send code from Vim [1] to R [2] on Microsoft Windows.

 Why such a roundabout way? Why not just run R in a subprocess and feed it
 a script to run?

 Emacs with ESS runs R in a subprocess (at least I think it does). Vim
 can't do that.

 Why not?

I don't know how to embed R into Vim, but I would be grateful if you
could explain how to do it since this could be an opportunity to
improve my plugin.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Q] Function Point Analysis (FPA) - Equivalent lines of code of Python

2010-09-10 Thread Lawrence D'Oliveiro
In message 7x4odz5mr3@ruckus.brouhaha.com, Paul Rubin wrote:

 Nicholas yue.nicho...@gmail.com writes:

   http://www.qsm.com/?q=resources/function-point-languages-
table/index.html
 
 That table looks pretty bogus ...

Dead giveaways are the disparity between the Ada, C++ and PL/I figures, and 
the fact that FORTRAN scores lower than C. Plus the inclusion of HTML and 
Dotnet on a par with the others. And what are “Web Scripts, if not 
JavaScript?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Samurai Principle

2010-09-10 Thread Robert Kern

On 9/10/10 5:17 PM, Lawrence D'Oliveiro wrote:

In messagemailman.567.1283927599.29448.python-l...@python.org, Ian Kelly
wrote:


And returning None on failure is dangerous, because if the programmer
does not take care to handle that case, the program may attempt to
regard it as actual data.


But None *is* actual data.


And that is exactly the reason why the Samurai Principle says to not return None 
when the function fails to do what it intended to do.


--
Robert Kern

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

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


Re: 3D cube navigation

2010-09-10 Thread Krister Svanlund
On Fri, Sep 10, 2010 at 9:10 PM, sahilsk sonukr...@gmail.com wrote:
 hi, i need to make a 3d cube as a navigation menu.. each face having
 separate  button .. or effect.
 any idea,  how can i make one such 3D figures with functionality of
 mouse events?

In what environment, what toolkit, for what purpose?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ugh! Python 3.1.x and MySQL

2010-09-10 Thread John Nagle

On 9/10/2010 12:57 PM, nn wrote:

On Sep 10, 12:27 pm, fuglyduckyfuglydu...@gmail.com  wrote:

Most of the python books coming out now are Py3K. I just started
programming and have a need to access a MySQL database. I would like
to use Python to do this. Unfortunately, I cannot find anyone that has
created anything that allows my to do this.

I've tried installing an ODBC driver and using sqlalchemy, oursql, and
a few other things with no luck.

So...just wondering if anyone is aware of any libraries/modules that I
can use to connect to a MySQL DB using Python 3.1.x?

Ideally, I'd like to be able to this from both x86 and x64 systems (if
that makes any difference).

Thanks for any input you may have!!!


Google found this:

http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/3831691


  That's progress, but it's a fork of MySQLdb.

  Can it be checked into the MySQLdb project on SourceForge?

John Nagle

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


Re: 3D cube navigation

2010-09-10 Thread Phlip
On Sep 10, 12:10 pm, sahilsk sonukr...@gmail.com wrote:
 hi, i need to make a 3d cube as a navigation menu.. each face having
 separate  button .. or effect.
 any idea,  how can i make one such 3D figures with functionality of
 mouse events?

omg

If you have to ask, you probably are not ready for the answer!

Is this a personal project, or are you satisfying a customer?

If the latter, is it a desktop project, or a web project?

If a web project, can you use a PNG of a rendered cube? Render it with
PovRay (which is honestly a ton of fun to author in), then use map
tags to define clicks on various faces.

From here, the question arises WHY your client wants this. Must the
cube rotate? Is it designed to be user hostile? Must the user rotate
the cube to find the correct menu item?

If you want to spend a couple weeks coding a nice learning project,
you could do a rotating cube in HTML5 using the canvas control.
Someone probably has an example out there, but efficient trigonometric
matrix transformations in JavaScript are not for the faint of heart.

If this is for the desktop, get a Python library that wraps something
that wraps OpenGL or DirectX. Or just google for python 3d cube.

Have fun!

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


Re: Ugh! Python 3.1.x and MySQL

2010-09-10 Thread Martin Gregorie
On Fri, 10 Sep 2010 09:27:28 -0700, fuglyducky wrote:

 Most of the python books coming out now are Py3K. I just started
 programming and have a need to access a MySQL database. I would like to
 use Python to do this. Unfortunately, I cannot find anyone that has
 created anything that allows my to do this.
 
 I've tried installing an ODBC driver and using sqlalchemy, oursql, and a
 few other things with no luck.
 
 So...just wondering if anyone is aware of any libraries/modules that I
 can use to connect to a MySQL DB using Python 3.1.x?
 
 Ideally, I'd like to be able to this from both x86 and x64 systems (if
 that makes any difference).

You don't say what OS you're using, but if you're on a *NIX, take a look 
at pyodbc: http://code.google.com/p/pyodbc/

This Python module is a wrapper for unixODBC and consequently works with 
standard MySQL ODBC drivers.
 
iODBC: http://www.iodbc.org/ is similar

If you want something that's Windows compatible I can't help: I don't use 
either Windows or MySQL.


-- 
martin@   | Martin Gregorie
gregorie. | Essex, UK
org   |
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Samurai Principle

2010-09-10 Thread Steven D'Aprano
On Sat, 11 Sep 2010 10:17:21 +1200, Lawrence D'Oliveiro wrote:

 In message mailman.567.1283927599.29448.python-l...@python.org, Ian
 Kelly wrote:
 
 And returning None on failure is dangerous, because if the programmer
 does not take care to handle that case, the program may attempt to
 regard it as actual data.
 
 But None *is* actual data.

Of course it is. Which makes it hard to distinguish None used as data 
from None used as a signal for an exceptional case.

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


Re: 3D cube navigation

2010-09-10 Thread Steven D'Aprano
On Sat, 11 Sep 2010 01:09:00 +0200, Krister Svanlund wrote:

 On Fri, Sep 10, 2010 at 9:10 PM, sahilsk sonukr...@gmail.com wrote:
 hi, i need to make a 3d cube as a navigation menu.. each face having
 separate  button .. or effect.
 any idea,  how can i make one such 3D figures with functionality of
 mouse events?
 
 In what environment, what toolkit, for what purpose?

What do you mean, what environment? Surely there's only one? The 
Original Poster obviously wants a 3D navigation cube for ksh under 
FreeBSD.

*wink*


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


Re: bool constructor is inconsistent?

2010-09-10 Thread Steven D'Aprano
On Fri, 10 Sep 2010 14:23:34 -0400, Neal Becker wrote:

 IN [3]: bool('False')
 Out[3]: True
 
 In [4]: int('32')
 Out[4]: 32

Where is the inconsistency? bool('False') returns the same result as for 
any other non-empty string:

 bool(not true)
True
 bool(no)
True
 bool(incorrect)
True
 bool(wrong)
True
 bool(Faux)
True
 bool(Falsch)
True
 bool(Falso)
True
 bool(偽)
True
 bool(Ложно)
True



Treating the string False as identical to the named global False would 
be inconsistent. 


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


Re: SendKeys and Python 2.7

2010-09-10 Thread Jakson A. Aquino
On Thu, Sep 9, 2010 at 8:24 PM, Jakson A. Aquino jaksonaqu...@gmail.com wrote:
 On Thu, Sep 9, 2010 at 5:40 PM, Michel Claveau - MVP
 enleverlesx_xx...@xmclavxeaux.com.invalid wrote:
 Hi!

 Example for send ^V  (with PyWin32):

  import time,win32api,win32con
  win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
  win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0)
  time.sleep(0.05)
  win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 
 win32con.KEYEVENTF_KEYUP, 0)
  win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0)

 Thank you very much! Your code solved my problem. I added some lines
 to set the focus into R before the ^V and then back to Vim:

Unfortunately, I was wrong. Your code do send the ^v as expected, but
I have problem with the selection of the Windows which will receive
the ^v. The code above was OK in a Windows XP running inside
VirtualBox, but when tested in a real machine, it proved to be highly
inconsistent. Sometimes the ^v gets pasted into R, but more frequently
it is pasted into Vim itself or nowhere. Below is the complete code
that I'm using. It's a vim script. The python code is delimited by
python  EOL and EOL:

function! SendToRPy(aString)
python  EOL
import time
import win32api
import win32con
import win32com.client
import win32clipboard
import vim

aString = vim.eval(a:aString)
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(aString)
win32clipboard.CloseClipboard()
shell = win32com.client.Dispatch(WScript.Shell)
ok = shell.AppActivate(R Console)
if ok:
win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0)
time.sleep(0.05)
win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY |
win32con.KEYEVENTF_KEYUP, 0)
win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0)
shell.AppActivate(Vim)
else:
vim.command(call RWarningMsg('Is R running?'))
time.sleep(1)
EOL
endfunction

When R isn't running, the script correctly shows the warning message
Is R running?. Does anyone know what should I do to correctly use
the AppActivate function or is there a better approach to this
problem?

Thanks!

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


Re: 3D cube navigation

2010-09-10 Thread Tim Chase

On 09/10/10 19:20, Steven D'Aprano wrote:

On Sat, 11 Sep 2010 01:09:00 +0200, Krister Svanlund wrote:

On Fri, Sep 10, 2010 at 9:10 PM, sahilsksonukr...@gmail.com  wrote:

hi, i need to make a 3d cube as a navigation menu.. each face having
separate  button .. or effect.


In what environment, what toolkit, for what purpose?


What do you mean, what environment? Surely there's only one? The
Original Poster obviously wants a 3D navigation cube for ksh under
FreeBSD.


Drat...all my work on a 3d navigation-cube working under ProDos 
on the Apple ][e for naught...what am I gonna do with all these 
360k 5.25 floppies now?!


-tkc



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


Re: How Python works: What do you know about support for negative indices?

2010-09-10 Thread Ben Finney
Ben Finney ben+pyt...@benfinney.id.au writes:

 Raymond Hettinger pyt...@rcn.com writes:

  It doesn't seem to be common knowledge when and how a[x] gets
  translated to a[x+len(x)]. So, here's a short info post on how
  Python supports negative indices for sequences.

 Thanks for this. Could you post your messages using a channel that
 doesn't arbitrarily split your paragraphs into long-short-long-short
 lines? It makes paragraphs burdensome to read, and I skipped most of
 the message because of that.

For those who think the problem may be with the recipient's software, I
see the same annoying line-wrapping problems in the archived message
URL:http://mail.python.org/pipermail/python-list/2010-September/1255167.html.

There's been enough sidetracking of Raymond's thread, though, so that
factual contribution will hopefully be my last in this thread on this
issue.

-- 
 \“Choose mnemonic identifiers. If you can't remember what |
  `\mnemonic means, you've got a problem.” —Larry Wall |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SendKeys and Python 2.7

2010-09-10 Thread MRAB

On 11/09/2010 01:45, Jakson A. Aquino wrote:

On Thu, Sep 9, 2010 at 8:24 PM, Jakson A. Aquinojaksonaqu...@gmail.com  wrote:

On Thu, Sep 9, 2010 at 5:40 PM, Michel Claveau - MVP
enleverlesx_xx...@xmclavxeaux.com.invalid  wrote:

Hi!

Example for send ^V  (with PyWin32):

  import time,win32api,win32con
  win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
  win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0)
  time.sleep(0.05)
  win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 
win32con.KEYEVENTF_KEYUP, 0)
  win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0)


Thank you very much! Your code solved my problem. I added some lines
to set the focus into R before the ^V and then back to Vim:


Unfortunately, I was wrong. Your code do send the ^v as expected, but
I have problem with the selection of the Windows which will receive
the ^v. The code above was OK in a Windows XP running inside
VirtualBox, but when tested in a real machine, it proved to be highly
inconsistent. Sometimes the ^v gets pasted into R, but more frequently
it is pasted into Vim itself or nowhere. Below is the complete code
that I'm using. It's a vim script. The python code is delimited by
python  EOL and EOL:

function! SendToRPy(aString)
python  EOL
import time
import win32api
import win32con
import win32com.client
import win32clipboard
import vim

aString = vim.eval(a:aString)
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(aString)
win32clipboard.CloseClipboard()
shell = win32com.client.Dispatch(WScript.Shell)
ok = shell.AppActivate(R Console)
if ok:
 win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
 win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY | 0, 0)
 time.sleep(0.05)
 win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_EXTENDEDKEY |
win32con.KEYEVENTF_KEYUP, 0)
 win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0)
 shell.AppActivate(Vim)
else:
 vim.command(call RWarningMsg('Is R running?'))
 time.sleep(1)
EOL
endfunction

When R isn't running, the script correctly shows the warning message
Is R running?. Does anyone know what should I do to correctly use
the AppActivate function or is there a better approach to this
problem?


I'd add some more small sleeps to give Windows/R time to act, IYSWIM. I
learned that from experience. :-)
--
http://mail.python.org/mailman/listinfo/python-list


Refactoring similar subclasses

2010-09-10 Thread Steven D'Aprano
I have some code that currently takes four different classes, A, B, C and 
D, and subclasses each of them in the same way:

class MyA(A):
def method(self, x):
result = super(MyA, self).method(x)
if result == spam:
return spam spam spam
return result
# many more methods overloaded


class MyB(B):
def method(self, x):
result = super(MyB, self).method(x)
if result == spam:
return spam spam spam
return result
# many more methods overloaded


and so on, for MyC and MyD. There's a lot of duplicated code in there. 
What techniques do you suggest for reducing the code duplication? I 
thought about some variation of:

names = MyA MyB MyC MyD.split()
bases = [A, B, C, D]
d = dict-of-overloaded-methods
for name, base in zip(names, bases):
globals()[name] = type(name, [base], d)


but I'm not sure that this is a good approach, or how to inject the right 
arguments to super in the dict.

Any suggestions or guidelines?


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


Hide DOS console for .pyc file

2010-09-10 Thread Muddy Coder
Hi Folks,

For a quick testing purpose, I deliver .pyc files to my customer. I
don't want the black DOS console appearing behind my GUI, but I have
no idea how to do it. Somebody can help? Thanks!


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


default value for __init__ doesn't work

2010-09-10 Thread 人言落日是天涯,望极天涯不见家
Please look at below code snippet:
class test():
def __init__(self, a, dic={}):
self.a = a
self.dic = dic
print('__init__ params:',a, dic)

def get(self):
self.dic[1] = 2
self.dic[4] = 5

def foo():
print('in foo function')
bar = test(1)
bar.get()

if __name__ == '__main__':
foo()
foo()
---
Result:
in foo function
__init__ params: 1 {}
in foo function
__init__ params: 1 {1: 2, 4: 5}

But my expect result is :
in foo function
__init__ params: 1 {}
in foo function
__init__ params: 1 {}

it seems that the default value for dic doesn't work on the second
call for the class test.
It's wired. Who can give a explaination for this scenario?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Convert IO Stream to XML Document

2010-09-10 Thread Stefan Behnel

jakecjacobson, 10.09.2010 18:20:

response = urllib2.urlopen(request)
pageguts = response.read()
xmldoc = minidom.parse(pageguts)


Check the minidom docs, there's a parseString() function that does what it 
says.


Also, don't forget to take a look at xml.etree.ElementTree. Depending on 
what you want to do with the XML result, it'll likely be easier to use and 
faster than minidom. The function there is called fromstring(), just in case ;)


Stefan

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


Re: default value for __init__ doesn't work

2010-09-10 Thread Benjamin Kaplan
On Sat, Sep 11, 2010 at 12:38 AM, 人言落日是天涯,望极天涯不见家 kelvin@gmail.com wrote:
 Please look at below code snippet:
 class test():
    def __init__(self, a, dic={}):
        self.a = a
        self.dic = dic
        print('__init__ params:',a, dic)



This is a pretty popular mistake to make. Default arguments aren't
evaluated when you call the method. They're created when the method is
created (meaning when you first run the file and the class itself is
defined), and that's it. Because you do self.dic = dic, this means
that every instance of the object will receive the same dict object.
Change it for one object, and the change will show up in all of them.
The solution to this is to use a sentinel value, like None

def __init__(self, a, dic=None) :
if dic is None :
self.dic = {}
else :
self.dic = dic

If None is a valid value for the parameter, make a sentinel object and use that

sentinel = object()
def __init__(self, a, dic=sentinel) :
if dic is sentinel : #you want to use is here, not ==
  ...
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue9503] print statement hangs Windows service

2010-09-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Closing as a duplicate of issue706263.

Instead of changing all print statements, you could set sys.stdout to another 
file, for example:
sys.stdout=StringIO()
or another object that simply discards written data.

--
nosy: +amaury.forgeotdarc
resolution:  - duplicate
status: open - closed
superseder:  - print raises exception when no console available

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9503
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9318] Py3k compilation on old MSVC

2010-09-10 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

Patch for import.c was checked in (#9752), so last piece is just patch
for Include/pythread.h. I'll commit this near future. I believe this is
not problematic.

--
assignee:  - ocean-city

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9318
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9815] test_tarfile sometimes ends with error Cannot remoe dir

2010-09-10 Thread Hirokazu Yamamoto

New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:

I noticed regrtest claimed it cannot delete folder after test_tarfile
ran. It was like this.

Traceback (most recent call last):
  File e:\python-dev\py3k\lib\runpy.py, line 160, in _run_module_as_main
__main__, fname, loader, pkg_name)
  File e:\python-dev\py3k\lib\runpy.py, line 73, in _run_code
exec(code, run_globals)
  File e:\python-dev\py3k\lib\test\test_tarfile.py, line 1566, in module
test_main()
  File e:\python-dev\py3k\lib\test\test_tarfile.py, line 1563, in test_main
shutil.rmtree(TEMPDIR)
  File e:\python-dev\py3k\lib\shutil.py, line 283, in rmtree
onerror(os.remove, fullname, sys.exc_info())
  File e:\python-dev\py3k\lib\shutil.py, line 281, in rmtree
os.remove(fullname)
WindowsError: [Error 32] プロセスはファイルにアクセスできません。別のプロセスが
使用中です。: 'E:\\python~1\\py3...@test_5276_tmp\\tmp.tar'

# It says Process cannot access the file. Another process is using it.

I tried to reproduce this by running test_tarfile alone, but failed.
But I succeeded to do it with following command.
  py3k -m test.regrtest test_capi test_tarfile

(Probably there is timing problem like GC... The reason why I think
so is below)

I think _Stream object left opened after exception occured in (even
after returned from function Tarfile#open) because it lives in stack
frame. Because t._extfileobj is True by default, TarFile object won't close it 
explicitly.

--
components: Extension Modules
files: py3k_fix_tarfile.patch
keywords: patch
messages: 115984
nosy: ocean-city
priority: normal
severity: normal
status: open
title: test_tarfile sometimes ends with error Cannot remoe dir
versions: Python 3.1, Python 3.2
Added file: http://bugs.python.org/file18815/py3k_fix_tarfile.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9815] test_tarfile sometimes ends with error Cannot remoe dir

2010-09-10 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


--
stage:  - commit review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9816] random.jumpahead and PRNG sequence independence

2010-09-10 Thread Joseph Schaeffer

New submission from Joseph Schaeffer thir...@gmail.com:

Reading the Python 2.6 docs, it appeared that using random.jumpahead would 
allow the initialization of several generators with the same seed but having 
much different internal states. While the resulting PRNG appear to have 
different internal states, the produced random numbers [via .random()] are 
exactly the same after a small initial segment.

Attached is some example code which shows the first point at which they all 
agree - in my testing (Mac OS X, Python versions 2.5, 2.6, 2.7) the generated 
numbers all agreed on the 12th number generated. For smaller differences in 
jumpahead it was noticeable a lot earlier - n=1,2 differ only in the first 
sample from each.

The internal state of the PRNGs is indeed different even after the successive 
sampling, so it may be that this is intended - however if so the docs may cause 
confusion: my particular case was where I need random numbers for a stochastic 
markov process and in addition needed many such generators [one for each 
trajectory] and was hoping to use random.jumpahead to have indepedent PRNG's 
without having to generate [and prove] my own independent set of seeds. Thus 
having a long sequence of non-independent random numbers near the initial start 
condition causes random.jumpahead to be unusable for my situation.

It appears that Python 3.1 removed random.jumpahead - if so, it may be useful 
to note in the 2.6 docs why this was / the issues with random.jumpahead: 
reading how it changed after 2.3 made it sound like it was exactly what I 
wanted. 

Possible cause: I suspect the issue may be related to how a Mersenne Twister 
algorithm can take a while to recover from poor seeding (excessive 0's), but do 
not know enough to explore that idea.

--
components: Library (Lib)
files: random_test.py
messages: 115985
nosy: Joseph.Schaeffer
priority: normal
severity: normal
status: open
title: random.jumpahead and PRNG sequence independence
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7
Added file: http://bugs.python.org/file18816/random_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9808] Implement os.getlogin on Windows

2010-09-10 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9808
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9816] random.jumpahead and PRNG sequence independence

2010-09-10 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +rhettinger
versions:  -Python 2.5, Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9816] random.jumpahead and PRNG sequence independence

2010-09-10 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
assignee:  - rhettinger
priority: normal - low

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9817] expat copyright/license file is missing

2010-09-10 Thread Matthias Klose

New submission from Matthias Klose d...@debian.org:

files in Modules/expat reference a file COPYING for the copyright/license, but 
this is file is not included in the Python sources.

Proposing to add the attached file, taken from the expat sources.

--
assignee: doko
components: None
files: COPYING
messages: 115986
nosy: doko
priority: normal
severity: normal
status: open
title: expat copyright/license file is missing
versions: Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file18817/COPYING

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9817
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue941346] AIX shared library fix

2010-09-10 Thread Sébastien Sablé

Sébastien Sablé sa...@users.sourceforge.net added the comment:

Antoine, I tested this patch on py3k with both gcc and xlc in static and shared 
mode and I did not notice any issue.

I attach the build and test logs.

I think you can safely commit it.

--
Added file: 
http://bugs.python.org/file18818/py3k_aix61_static_xlc_nopatch.txt.gz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue941346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue941346] AIX shared library fix

2010-09-10 Thread Sébastien Sablé

Changes by Sébastien Sablé sa...@users.sourceforge.net:


Added file: 
http://bugs.python.org/file18819/py3k_aix61_static_xlc_patchshared.txt.gz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue941346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue941346] AIX shared library fix

2010-09-10 Thread Sébastien Sablé

Changes by Sébastien Sablé sa...@users.sourceforge.net:


Added file: 
http://bugs.python.org/file18820/py3k_aix61_shared_xlc_pathshared.txt.gz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue941346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue941346] AIX shared library fix

2010-09-10 Thread Sébastien Sablé

Changes by Sébastien Sablé sa...@users.sourceforge.net:


Added file: 
http://bugs.python.org/file18821/py3k_aix61_static_gcc_patchshared.txt.gz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue941346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue941346] AIX shared library fix

2010-09-10 Thread Sébastien Sablé

Changes by Sébastien Sablé sa...@users.sourceforge.net:


Added file: 
http://bugs.python.org/file18822/py3k_aix61_shared_gcc_patchshared.txt.gz

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue941346
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9818] build files to build Lib/distutils/command/wininst-9.0* are missing

2010-09-10 Thread Matthias Klose

New submission from Matthias Klose d...@debian.org:

PC/V[CS]* contain the information to build the wininst-[678]* files, but I 
don't see any information how to build wininst-9.0*.

--
components: Build
messages: 115988
nosy: doko
priority: normal
severity: normal
status: open
title: build files to build Lib/distutils/command/wininst-9.0* are missing
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9818
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9706] ssl errors checking

2010-09-10 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9706
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread Hirokazu Yamamoto

New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:

Hello. I noticed test suite reports WARNING every time.

///

E:\python-devpy3k -m test.regrtest test_os
WARNING: The filename '@test_464_tmp-共有される' CAN be encoded by the filesyste
m encoding (mbcs). Unicode filename tests may not be effective
(snip)

///

This happens because TESTFN_UNICODE_UNDECODABLE in Lib/test/support.py
*is* decodable on Japanese environment (cp932).

It is easy to make this really undecodable in Japanese.
Using the characters like \u2661 or \u2668 (Former is heart mark,
latter is Onsen - Hot spring mark) I could remove the warning by this.
TESTFN_UNENCODABLE = TESTFN + -\u5171\u6709\u3055\u308c\u308b\u2661\u2668

///

And another issue. This happens only on test_unicode_file,

///

E:\python-devpy3k -m test.test_unicode_file
Traceback (most recent call last):
  File e:\python-dev\py3k\lib\test\test_unicode_file.py, line 12, in module
TESTFN_UNICODE.encode(TESTFN_ENCODING)
UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: inval
id character

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File e:\python-dev\py3k\lib\runpy.py, line 160, in _run_module_as_main
__main__, fname, loader, pkg_name)
  File e:\python-dev\py3k\lib\runpy.py, line 73, in _run_code
exec(code, run_globals)
  File e:\python-dev\py3k\lib\test\test_unicode_file.py, line 16, in module
raise unittest.SkipTest(No Unicode filesystem semantics on this platform.)

unittest.case.SkipTest: No Unicode filesystem semantics on this platform.

///

This happens because TESTFN_UNICODE cannot be encoded in Japanese.

E:\python-devpy3k
Python 3.2a2+ (py3k:84663M, Sep 10 2010, 13:24:41) [MSC v.1400 32 bit (Intel)] o
n win32
Type help, copyright, credits or license for more information.
 print(-\xe0\xf2)
Traceback (most recent call last):
  File stdin, line 1, in module
UnicodeEncodeError: 'cp932' codec can't encode character '\xe0' in position 1: i
llegal multibyte sequence

But interesting, this bytes sequence \xe0\xf2 can be read as
cp932 multibyte characters.

E:\python-devpython
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on
win32
Type help, copyright, credits or license for more information.
 print \xe0\xf2
瑣
 \xe0\xf2.decode(cp932)
u'\u7463'

E:\python-devpy3k
Python 3.2a2+ (py3k:84663M, Sep 10 2010, 13:24:41) [MSC v.1400 32 bit (Intel)] o
n win32
Type help, copyright, credits or license for more information.
 print('\u7463')
瑣

I believe this value \xe0\xf2 came from python2.x, maybe \u7463
should be used here? I'm not sure it can be decoded everywhere using
other encodings, though.

--
components: Tests, Unicode
messages: 115989
nosy: ocean-city
priority: normal
severity: normal
status: open
title: TESTFN_UNICODE and TESTFN_UNDECODABLE
versions: Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9816] random.jumpahead and PRNG sequence independence

2010-09-10 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Thanks for the report.  Something does appear to be broken.  When the states 
are different, the random numbers should be different.  Am looking in to it.

In the mean time, I recommend against using jumpahead() with MT.  It is better 
to separately seed three different generators and rely on the huge period of MT 
to keep the sequences from overlapping.

If you do use jumpahead(), it is intended to be supplied with large values of n 
(not 1, 11, or 21).

The function/method was removed in 3.x because it was an API defect.  The 
jumpahead concept as originally intended (move ahead n-steps) was something 
that could really only work with a generator like Wichmann-Hill.  Newer and 
more advanced generators aren't usually amenable to direct computation of a 
state that is n-steps forward.

--
priority: low - high

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

And one little thing. I noticed variable name varies in
python2.x and python3.x.
TESTFN_UNICODE_UNDECODEABLE (2.x)
TESTFN_UNICODE_UNDECODABLE  (3.x)

I think 2.x should be unified into 3.x name. Thanks.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc amaur...@gmail.com:


--
assignee:  - haypo
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9806] no need to try loading posix extensions without SOABI

2010-09-10 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

I'm not in favor of this change.  PEP 3179 was accepted because it presented an 
optional additional feature that doesn't break compatibility.

For example, build tools of third-party external modules that do not use 
distutils would break.

--
nosy: +benjamin.peterson, georg.brandl, loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9806
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9806] no need to try loading posix extensions without SOABI

2010-09-10 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Martin might be able to provide some insight from when (IIRC) Windows dynamic 
DLLs were restricted to .pyd extension only.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9806
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 WARNING: The filename '@test_464_tmp-共有される' CAN be encoded 
 by (...) cp932

We should find character not encodable in any Windows code page, but accepted 
as filenames.

 characters like \u2661 or \u2668 (...)

mbcs uses ANSI code pages: cp1250..cp1258 and cp874 (and maybe others because 
you wrote that your setup uses cp932):
http://en.wikipedia.org/wiki/Code_page#Windows_.28ANSI.29_code_pages

I wrote a short script to find a unencodable filename (attached to this issue). 
Output:

u'\u0301' is encodable to cp1258
u'\u0363' is not encodable to any code page
u'\u2661' is encodable to cp949
u'\u5171' is encodable to cp932, cp936, cp949, cp950

(CODE_PAGES constant of the script might be incomplete)

u'\u2661' is not a good candidate. u'\u0363' looks better. Be we can mix 
different characters to limit the probability that the whole string is 
encodable. Example:

u'\u2661\u5171' is encodable to cp949
u'\u0301\u0363\u2661\u5171' is not encodable to any code page

 TESTFN_UNICODE_UNDECODEABLE (2.x)

This is a typo fixed by r83987 in py3k.

--
Added file: http://bugs.python.org/file18823/find_unencode_filename.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

In Python 3.2, mbcs encoding (default filesystem encoding on Windows) is now 
strict: raise an error on unencodable/undecodable characters/bytes. But 
os.listdir(b'.') encodes unencodable bytes as b'?'.

Example:

 os.mkdir('listdir')
 open('listdir\\xxx-\u0363', 'w').close()
 filename = os.listdir(b'listdir')[0]
 filename
b'xxx-?'
 open(filename, 'r').close()
IOError: [Errno 22] Invalid argument: 'xxx-?'

os.listdir(b'listdir') should raise an error (and not ignore the filename or 
replaces unencodable characters by b'?').

I think that we should list the directory using the wide character API 
(FindFirstFileW) but encode the filename using PyUnicode_EncodeFSDefault() if 
the directory name type is bytes, instead of using the ANSI API 
(FindFirstFileA).

--
components: Library (Lib), Unicode, Windows
messages: 115995
nosy: haypo, loewis
priority: normal
severity: normal
status: open
title: Windows : os.listdir(b'.') doesn't raise an error for unencodable 
filenames
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

I found this bug while trying to find an unencodable filename for #9819 
(TESTFN_UNDECODABLE).

Anyway, the bytes API should be avoided on Windows since Windows native 
filename type is unicode.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

See also #9820.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9816] random.jumpahead and PRNG sequence independence

2010-09-10 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

I see the problem now.  Random.jumpahead(n) does a very poor job of shuffling 
MT's state when n is small.  The first few numbers of the state are different 
but some of the later ones are not.  When random() crawls across parts of the 
state that are identical, it produces identical output.  Later when has wrapped 
around, the random() calls diverge again.

Fixed by salting the jumpahead value.  See r84665.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

Thank you for a reply.

 u'\u2661' is encodable to cp949
Doh!

I can imagine it's difficult to find out such character. ;-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9819] TESTFN_UNICODE and TESTFN_UNDECODABLE

2010-09-10 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

I also confirmed '\u0363' can be used as filename.
dir command cannot print filename correctly, though.

 E:\python-dev\foo のディレクトリ

2010/09/10  19:44   DIR  .
2010/09/10  19:44   DIR  ..
2010/09/10  19:443 ͣ
   1 個のファイル   3 バイト
   2 個のディレクトリ   2,788,741,120 バイトの空き領域

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9819
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9821] Support PEP 383 on Windows: mbcs support of surrogateescape error handler

2010-09-10 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

It would be nice to support PEP 383 (surrogateescape) on Windows, but the mbcs 
codec doesn't support it for performance reason. The Windows functions to 
encode/decode MBCS don't give the index of the unencodable/undecodable 
character/byte. For encoding, we can try to encode character by character (but 
be careful of surrogate pairs) and check that the character is a Python lone 
surrogate character or not (character in range U+DC80..U+DCFF). For decoding, 
it is more complex because MBCS can be a multibyte encoding, eg. cp65001 
(Microsoft variant of utf-8, see #6058). So it's not possible to encode byte 
per byte and we should write an heuristic to guess the right number of bytes 
for each call to the decode function.

--

A completly different solution is to get the MBCS code page and use the Python 
code page codec (eg. cp1252) instead of mbcs encoding, because Python 
cp codecs support all Python error handlers. Example (with Python 2.6):

 print(uabcŁdef.encode(cp1252, replace))
abc?def
 print(uabcŁdef.encode(cp1252, ignore))
abcdef
 print(uabcŁdef.encode(cp1252, backslashreplace))
abc\u0141def

See also #8611 for the problem if the Python path cannot be encoded to mbcs 
(work in progress, see #9425).

--
components: Interpreter Core, Library (Lib), Unicode, Windows
messages: 116001
nosy: haypo, loewis
priority: normal
severity: normal
status: open
title: Support PEP 383 on Windows: mbcs support of surrogateescape error handler
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9821
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9820] Windows : os.listdir(b'.') doesn't raise an error for unencodable filenames

2010-09-10 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 os.listdir(b'listdir') should raise an error (and not ignore 
 the filename or replaces unencodable characters by b'?').

To avoid the error, a solution is to support the PEP 383 on Windows (for the 
mbcs encoding). I opened a separated issue for that: #9821.

But support PEP 383 will not fix this issue because the current implementation 
of listdir(b'.') doesn't use the Python codec, but use raw bytes filenames (use 
the ANSI API).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >