ANN Queues: Distributed, Fault-Tolerant Message Processing by PiCloud

2013-05-07 Thread John Riley
PiCloud's (http://www.picloud.com) latest feature gives Python users a
distributed, fault-tolerant message queue with a scalable message
processing system. We ensure that you never lose any messages, and that
they're processed at the speed you need--even thousands of messages per
second.

More information:
Blog Post:
http://blog.picloud.com/2013/04/03/introducing-queues-creating-a-pipeline-in-the-cloud/
Documentation: http://docs.picloud.com/queue.html

What's it for?
Queues let you decouple discrete components of your application, and
simplify communication between them as the pushing and popping of messages.
Queues are perfect for integrating PiCloud into a web application backend,
or any realtime, high-throughput system. If your workloads have been too
short ( 1s) to use our job system effectively, or you've found difficulty
creating a multi-stage pipeline with jobs, then you'll want to give queues
a try!

You'll need the latest cloud library v2.7.7 to use the feature.

Best Regards,
John
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: eGenix mxODBC Zope/Plone Database Adapter 2.1.2

2013-05-07 Thread eGenix Team: M.-A. Lemburg


ANNOUNCEMENT

  mxODBC Zope/Plone Database Adapter

Version 2.1.2

 for Zope and the Plone CMS

Available for Plone 4.0, 4.1 and 4.2,
Zope 2.12 and 2.13, on
Windows, Linux, Mac OS X, FreeBSD and other platforms

This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.2-GA.html



INTRODUCTION

The eGenix mxODBC Zope DA allows you to easily connect your Zope or
Plone CMS installation to just about any database backend on the
market today, giving you the reliability of the commercially supported
eGenix product mxODBC and the flexibility of the ODBC standard as
middle-tier architecture.

The mxODBC Zope Database Adapter is highly portable, just like Zope
itself and provides a high performance interface to all your ODBC data
sources, using a single well-supported interface on Windows, Linux,
Mac OS X, FreeBSD and other platforms.

This makes it ideal for deployment in ZEO Clusters and Zope hosting
environments where stability and high performance are a top priority,
establishing an excellent basis and scalable solution for your Plone
CMS.

Product page:

http://www.egenix.com/products/zope/mxODBCZopeDA/



NEWS

We are pleased to announce the new version 2.1.2 of our mxODBC
Zope/Plone Database Adapter product.

Compatibility Enhancements
--

 * Added a work-around for a regression in Python 2.7.4 that results
   in a segfault when exiting Zope/Plone after loading the mxODBC Zope
   DA.

   The regression will be fixed in Python 2.7.5, but we don't want to
   expose our users to segfaults, so added a work-around.

   See http://bugs.python.org/issue17703 for the bug ticket.

 * Upgraded the underlying mxODBC library to version 3.2.3. Please see
   the mxODBC 3.2.3 release announcement for additional details:

   http://www.egenix.com/company/news/eGenix-mxODBC-3.2.3-GA.html


Driver Compatibility


 * Please also see the mxODBC Zope DA 2.1.1 announcement for an
   important new feature which allows to dramatically increase the
   fetch performance when working with MS SQL Server and IBM DB2
   databases.

   http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.1-GA.html


For the full set of changes please check the change log:

http://www.egenix.com/products/zope/mxODBCZopeDA/changelog.html



FEATURES

Version 2.1.0 of our mxODBC Zope/Plone Database Adapter product was
released on 2012-09-18. Please see the announcement for highlights of
the 2.1 release:

http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.0-GA.html

For the full set of features mxODBC Zope DA has to offer, please see:

http://www.egenix.com/products/zope/mxODBCZopeDA/#Features



UPGRADING

Users are encouraged to upgrade to this latest mxODBC Zope/Plone DA
release to benefit from the new features and updated ODBC driver
support.

We have taken special care not to introduce backwards incompatible
changes, making the upgrade experience as smooth as possible.

As always, patch level upgrades (e.g. from 2.1.0 to 2.1.2) are free of
charge. The licenses you have purchased for 2.1 will continue to work
with this new release.

For major and minor upgrade purchases, we will give out 20% discount
coupons going from mxODBC Zope DA 1.x to 2.1 and 50% coupons for
upgrades from mxODBC 2.x to 2.1. After upgrade, use of the original
license from which you upgraded is no longer permitted.

Please contact the eGenix.com Sales Team with your existing license
serials for details for an upgrade discount coupon.

If you want to try the new release before purchase, you can request
30-day evaluation licenses by visiting our web-site or writing to
sa...@egenix.com, stating your name (or the name of the company) and
the number of evaluation licenses that you need.

___

SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.



MORE INFORMATION

For more information on the mxODBC Zope Database Adapter, licensing
and download instructions, please visit our web-site:

http://www.egenix.com/products/zope/mxODBCZopeDA/

You can buy mxODBC Zope DA licenses online from the eGenix.com shop at:

http://shop.egenix.com/

About Python (http://www.python.org/):

Python is an object-oriented Open 

devpi-server-0.8.4: using pip's link parser now

2013-05-07 Thread holger krekel
hi all,

devpi-server, the self-updatding pypi.python.org caching proxy,
just saw a new 0.8.4 release.  Instead of BeautifulSoup it now
uses pip's link parsing.  This should serve as a shortcut to avoid
real life crawling issues.  IOW, whatever pip can install, should
also be installable through the devpi-server cache.

More info, getting started, deployment info  on devpi-server:

http://pypi.python.org/pypi/devpi-server

thanks to Markus Zapke-Gruendemann for cleaning up some internals.

cheers,
holger

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

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


PyPy 2.0 alpha for ARM

2013-05-07 Thread Maciej Fijalkowski
Hello.

We're pleased to announce an alpha release of PyPy 2.0 for ARM. This is mostly
a technology preview, as we know the JIT is not yet stable enough for the
full release. However please try your stuff on ARM and report back.

This is the first release that supports a range of ARM devices - anything with
ARMv6 (like the Raspberry Pi) or ARMv7 (like Beagleboard, Chromebook,
Cubieboard, etc.) that supports VFPv3 should work. We provide builds with
support for both ARM EABI variants: hard-float and some older operating
systems soft-float.

This release comes with a list of limitations, consider it alpha quality,
not suitable for production:

* stackless support is missing.

* assembler produced is not always correct, but we successfully managed to
  run large parts of our extensive benchmark suite, so most stuff should work.

You can download the PyPy 2.0 alpha ARM release here:

http://pypy.org/download.html

Part of the work was sponsored by the `Raspberry Pi foundation`_.

.. _`Raspberry Pi foundation`: http://www.raspberrypi.org/

What is PyPy?
=

PyPy is a very compliant Python interpreter, almost a drop-in replacement for
CPython 2.7.3. It's fast due to its integrated tracing JIT compiler.

This release supports ARM machines running Linux 32bit. Both hard-float
``armhf`` and soft-float ``armel`` builds are provided.  ``armhf`` builds are
created using the Raspberry Pi custom `cross-compilation toolchain`_ based on
gcc-arm-linux-gnueabihf and should work on ARMv6 and ARMv7 devices running at
least debian or ubuntu. ``armel`` builds are built using gcc-arm-linux-gnuebi
toolchain provided by ubuntu and currently target ARMv7.  If there is interest
in other builds, such as gnueabi for ARMv6 or without requiring a VFP let us
know in the comments or in IRC.

.. _`cross-compilation toolchain`: https://github.com/raspberrypi

Benchmarks
==

Everybody loves benchmarks. Here is a table of our benchmark suite
(for ARM we don't provide it yet on http://speed.pypy.org,
unfortunately).

This is a comparison of Cortex A9 processor with 4M cache and Xeon W3580 with
8M of L3 cache. The set of benchmarks is a subset of what we run for
http://speed.pypy.org that finishes in reasonable time. The ARM machine
was provided by Calxeda.
Columns are respectively:

* benchmark name

* PyPy speedup over CPython on ARM (Cortex A9)

* PyPy speedup over CPython on x86 (Xeon)

* speedup on Xeon vs Cortex A9, as measured on CPython

* speedup on Xeon vs Cortex A9, as measured on PyPy

* relative speedup (how much bigger the x86 speedup is over ARM speedup)

(in case this table is not readable, please visit
http://morepypy.blogspot.com/2013/05/pypy-20-alpha-for-arm.html)

| Benchmark  | PyPy vs CPython (arm) | PyPy vs CPython (x86) |
x86 vs arm (pypy) | x86 vs arm (cpython) | relative speedup |
| ai | 3.61  | 3.16  |
7.70  | 8.82 | 0.87 |
| bm_mako| 3.41  | 2.11  |
8.56  | 13.82| 0.62 |
| chaos  | 21.82 | 17.80 |
6.93  | 8.50 | 0.82 |
| crypto_pyaes   | 22.53 | 19.48 |
6.53  | 7.56 | 0.86 |
| django | 13.43 | 11.16 |
7.90  | 9.51 | 0.83 |
| eparse | 1.43  | 1.17  |
6.61  | 8.12 | 0.81 |
| fannkuch   | 6.22  | 5.36  |
6.18  | 7.16 | 0.86 |
| float  | 5.22  | 6.00  |
9.68  | 8.43 | 1.15 |
| go | 4.72  | 3.34  |
5.91  | 8.37 | 0.71 |
| hexiom2| 8.70  | 7.00  |
7.69  | 9.56 | 0.80 |
| html5lib   | 2.35  | 2.13  |
6.59  | 7.26 | 0.91 |
| json_bench | 1.12  | 0.93  |
7.19  | 8.68 | 0.83 |
| meteor-contest | 2.13  | 1.68  |
5.95  | 7.54 | 0.79 |
| nbody_modified | 8.19  | 7.78  |
6.08  | 6.40 | 0.95 |
| pidigits   | 1.27  | 0.95  |
14.67 | 19.66| 0.75 |
| pyflate-fast   | 3.30  | 3.57  |
10.64 | 9.84 | 1.08 |
| raytrace-simple

ANN: pyroute2 (python netlink library) initial public release

2013-05-07 Thread Peter V. Saveliev


General description
===

Started as python NETLINK_ROUTE library, pyroute2 provides simple 
netlink encoder/decoder. Families and messages supported by now:


* rtnetlink: addresses, links, neighbors, routes
* taskstats

More netlink families to support are planned.

Features


* pure-python, w/o any additional *.so or ctypes
* transactional database for rtnetlink family
  * interfaces as context managers
  * transaction review() / rollback() / commit()
  * automatic transaction rollback() on commit() exception
  * monitors IP stack for changes
* for old-school guys: old-style API ip.link('set', dev, param=…)
* netlink-over-SOCK_STREAM — with TLS/SSL client/server auth

IP stack monitoring allows not to fetch data from the system upon user's 
request, but keep it in sync all the time in the database, and on huge 
arrays of VLANs or VPN nics response even faster than C with ioctl() 
does — and still provide more info, 'cause through ioctl() not any data 
is available.


Goals
=

The main goal is to provide simple (maybe even simplest) API for netlink 
usage. In the todo list are (beside of support for different netlink 
families) also userspace-to-userspace netlink transport, more auth 
mechanisms, e.g. SASL (in addition to TLS/SSL).


Links
=

home: https://github.com/svinota/pyroute2
bugs: https://github.com/svinota/pyroute2/issues
pypi: https://pypi.python.org/pypi/pyroute2
docs: http://peet.spb.ru/pyroute2/

Some easy code samples: http://peet.spb.ru/pyroute2/modules.html

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

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


Re: First python program, syntax error in while loop

2013-05-07 Thread Mark Lawrence

On 07/05/2013 01:17, alex23 wrote:

On May 6, 10:37 pm, Mark Lawrence breamore...@yahoo.co.uk wrote:

One of these days I'll work out why some people insist on using
superfluous parentheses in Python code.  Could it be that they enjoy
exercising their fingers by reaching for the shift key in conjunction
with the 9 or 0 key?


One of these days I'll work out why some programmers consider typing
to be effort.



I think it's very important to consider this aspect.  E.g. any one using 
dynamically typed languages has to put in more effort as they should be 
typing up their test code, whereas people using statically typed 
languages can simply head down to the pub once their code has compiled.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: python backup script

2013-05-07 Thread Peter Otten
Chris Angelico wrote:

 It's also worth noting that the ~/ notation is a shell feature. You
 may or may not be able to use it in config.read().

The latter. Combined with


read(self, filenames) method of ConfigParser.ConfigParser instance
Read and parse a filename or a list of filenames.

Files that cannot be opened are silently ignored; this is
...


you'll get no configuration at all. You have to apply

os.path.expanduser()

to get a valid path.

$ cd
$ touch tmp.config
$ cd /
$ python
Python 2.7.2+ (default, Jul 20 2012, 22:15:08) 
[GCC 4.6.1] on linux2
Type help, copyright, credits or license for more information.
 from ConfigParser import ConfigParser
 p = ConfigParser()
 p.read(~/tmp.config)
[]
 import os
 p.read(os.path.expanduser(~/tmp.config))
['/home/peter/tmp.config']


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


ANN: eGenix mxODBC Zope/Plone Database Adapter 2.1.2

2013-05-07 Thread eGenix Team: M.-A. Lemburg


ANNOUNCEMENT

  mxODBC Zope/Plone Database Adapter

Version 2.1.2

 for Zope and the Plone CMS

Available for Plone 4.0, 4.1 and 4.2,
Zope 2.12 and 2.13, on
Windows, Linux, Mac OS X, FreeBSD and other platforms

This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.2-GA.html



INTRODUCTION

The eGenix mxODBC Zope DA allows you to easily connect your Zope or
Plone CMS installation to just about any database backend on the
market today, giving you the reliability of the commercially supported
eGenix product mxODBC and the flexibility of the ODBC standard as
middle-tier architecture.

The mxODBC Zope Database Adapter is highly portable, just like Zope
itself and provides a high performance interface to all your ODBC data
sources, using a single well-supported interface on Windows, Linux,
Mac OS X, FreeBSD and other platforms.

This makes it ideal for deployment in ZEO Clusters and Zope hosting
environments where stability and high performance are a top priority,
establishing an excellent basis and scalable solution for your Plone
CMS.

Product page:

http://www.egenix.com/products/zope/mxODBCZopeDA/



NEWS

We are pleased to announce the new version 2.1.2 of our mxODBC
Zope/Plone Database Adapter product.

Compatibility Enhancements
--

 * Added a work-around for a regression in Python 2.7.4 that results
   in a segfault when exiting Zope/Plone after loading the mxODBC Zope
   DA.

   The regression will be fixed in Python 2.7.5, but we don't want to
   expose our users to segfaults, so added a work-around.

   See http://bugs.python.org/issue17703 for the bug ticket.

 * Upgraded the underlying mxODBC library to version 3.2.3. Please see
   the mxODBC 3.2.3 release announcement for additional details:

   http://www.egenix.com/company/news/eGenix-mxODBC-3.2.3-GA.html


Driver Compatibility


 * Please also see the mxODBC Zope DA 2.1.1 announcement for an
   important new feature which allows to dramatically increase the
   fetch performance when working with MS SQL Server and IBM DB2
   databases.

   http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.1-GA.html


For the full set of changes please check the change log:

http://www.egenix.com/products/zope/mxODBCZopeDA/changelog.html



FEATURES

Version 2.1.0 of our mxODBC Zope/Plone Database Adapter product was
released on 2012-09-18. Please see the announcement for highlights of
the 2.1 release:

http://www.egenix.com/company/news/eGenix-mxODBC-Zope-DA-2.1.0-GA.html

For the full set of features mxODBC Zope DA has to offer, please see:

http://www.egenix.com/products/zope/mxODBCZopeDA/#Features



UPGRADING

Users are encouraged to upgrade to this latest mxODBC Zope/Plone DA
release to benefit from the new features and updated ODBC driver
support.

We have taken special care not to introduce backwards incompatible
changes, making the upgrade experience as smooth as possible.

As always, patch level upgrades (e.g. from 2.1.0 to 2.1.2) are free of
charge. The licenses you have purchased for 2.1 will continue to work
with this new release.

For major and minor upgrade purchases, we will give out 20% discount
coupons going from mxODBC Zope DA 1.x to 2.1 and 50% coupons for
upgrades from mxODBC 2.x to 2.1. After upgrade, use of the original
license from which you upgraded is no longer permitted.

Please contact the eGenix.com Sales Team with your existing license
serials for details for an upgrade discount coupon.

If you want to try the new release before purchase, you can request
30-day evaluation licenses by visiting our web-site or writing to
sa...@egenix.com, stating your name (or the name of the company) and
the number of evaluation licenses that you need.

___

SUPPORT

Commercial support for this product is available from eGenix.com.
Please see

http://www.egenix.com/services/support/

for details about our support offerings.



MORE INFORMATION

For more information on the mxODBC Zope Database Adapter, licensing
and download instructions, please visit our web-site:

http://www.egenix.com/products/zope/mxODBCZopeDA/

You can buy mxODBC Zope DA licenses online from the eGenix.com shop at:

http://shop.egenix.com/

About Python (http://www.python.org/):

Python is an object-oriented Open 

Re: First python program, syntax error in while loop

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 4:10 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 On 07/05/2013 01:17, alex23 wrote:

 On May 6, 10:37 pm, Mark Lawrence breamore...@yahoo.co.uk wrote:

 One of these days I'll work out why some people insist on using
 superfluous parentheses in Python code.  Could it be that they enjoy
 exercising their fingers by reaching for the shift key in conjunction
 with the 9 or 0 key?


 One of these days I'll work out why some programmers consider typing
 to be effort.


 I think it's very important to consider this aspect.  E.g. any one using
 dynamically typed languages has to put in more effort as they should be
 typing up their test code, whereas people using statically typed languages
 can simply head down to the pub once their code has compiled.

And those who are porting other people's code to a new platform have
weeks of work just to get ./configure to run, but after that it's
smooth...

Everything is variable.

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


Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread cheirasacan
from tkinter import *
import sfml


window = Tk()
window.minsize( 640, 480 )


def sonido():
file = sfml.Music.from_file('poco.ogg')
file.play()


test = Button ( window, text = 'Sound test', command=sonido )
test.place ( x = 10, y = 60)

window.mainloop()




Using Windows 7, Python 3.3, sfml 1.3.0 library, the file it is played if i put 
it out of the function. ¿ what am i doing wrong ? Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread MRAB

On 07/05/2013 10:27, cheirasa...@gmail.com wrote:

from tkinter import *
import sfml


window = Tk()
window.minsize( 640, 480 )


def sonido():
 file = sfml.Music.from_file('poco.ogg')
 file.play()


test = Button ( window, text = 'Sound test', command=sonido )
test.place ( x = 10, y = 60)

window.mainloop()




Using Windows 7, Python 3.3, sfml 1.3.0 library, the file it is played if i put 
it out of the function. ¿ what am i doing wrong ? Thanks.


Perhaps what's happening is that sonido starts playing it and then
returns, meaning that there's no longer a reference to it ('file' is
local to the function), so it's collected by the garbage collector.

If that's the case, try keeping a reference to it, perhaps by making
'file' global (in a simple program like this one, using global should
be OK).

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


unexpected syntax errors

2013-05-07 Thread Robin Becker

A user is getting this error



New issue 8: bad raise syntax
https://bitbucket.org/rptlab/reportlab/issue/8/bad-raise-syntax



  File /usr/lib/python2.7/site-packages/svg2rlg.py, line 16, in module
from reportlab.graphics import renderPDF
  File /usr/lib64/python2.7/site-packages/reportlab/graphics/renderPDF.py, 
line 168
raise ValueError, 'bad value for textAnchor '+str(text_anchor)
^
SyntaxError: invalid syntax




however, I believe that this older syntax is allowed in python 2.7. We've had 
other issues like this raised from various distros which are apparently making 
changes to 2.7 which change the external behaviour eg spelling corrections to 
attribute names. Could this be one of those?

--
Robin Becker

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


use python to split a video file into a set of parts

2013-05-07 Thread iMath
I use the following python code to split a FLV video file into a set of parts 
,when finished ,only the first part video can be played ,the other parts are 
corrupted.I wonder why and Is there some correct ways to split video files

import sys, os
kilobytes = 1024
megabytes = kilobytes * 1000
chunksize = int(1.4 * megabytes)   # default: roughly a floppy

print(chunksize , type(chunksize ))

def split(fromfile, todir, chunksize=chunksize):
if not os.path.exists(todir):  # caller handles errors
os.mkdir(todir)# make dir, read/write parts
else:
for fname in os.listdir(todir):# delete any existing files
os.remove(os.path.join(todir, fname))
partnum = 0
input = open(fromfile, 'rb')   # use binary mode on Windows
while True:# eof=empty string from read
chunk = input.read(chunksize)  # get next part = chunksize
if not chunk: break
partnum += 1
filename = os.path.join(todir, ('part{}.flv'.format(partnum)))
fileobj  = open(filename, 'wb')
fileobj.write(chunk)
fileobj.close()# or simply open().write()
input.close()
assert partnum =  # join sort fails if 5 digits
return partnum

if __name__ == '__main__':

fromfile = input('File to be split: ')   # input if clicked
todir= input('Directory to store part files:')
print('Splitting', fromfile, 'to', todir, 'by', chunksize)
parts = split(fromfile, todir, chunksize)
print('Split finished:', parts, 'parts are in', todir)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: use python to split a video file into a set of parts

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 9:15 PM, iMath redstone-c...@163.com wrote:
 I use the following python code to split a FLV video file into a set of parts 
 ,when finished ,only the first part video can be played ,the other parts are 
 corrupted.I wonder why and Is there some correct ways to split video files

Most complex files of this nature have headers. You're chunking it in
pure bytes, so chances are you're disrupting that. The only thing you
can reliably do with your chunks is recombine them into the original
file.

 import sys, os
 kilobytes = 1024
 megabytes = kilobytes * 1000
 chunksize = int(1.4 * megabytes)   # default: roughly a floppy

Hrm. Firstly, this is a very small chunksize for today's files. You
hard-fail any file more than about 13GB, and for anything over a gig,
you're looking at a thousand files or more. Secondly, why are you
working with 1024 at the first level and 1000 at the second? You're
still a smidge short of the 1440KB that was described as 1.44MB, and
you have the same error of unit. Stick to binary kay OR decimal kay,
don't mix and match!

 print(chunksize , type(chunksize ))

Since you passed chunksize through the int() constructor, you can be
fairly confident it'll be an int :)

 def split(fromfile, todir, chunksize=chunksize):
 if not os.path.exists(todir):  # caller handles errors
 os.mkdir(todir)# make dir, read/write 
 parts
 else:
 for fname in os.listdir(todir):# delete any existing files
 os.remove(os.path.join(todir, fname))

Tip: Use os.mkdirs() in case some of its parents need to be made. And
if you wrap it in try/catch rather than probing first, you eliminate a
race condition. (By the way, it's pretty dangerous to just delete
files from someone else's directory. I would recommend aborting with
an error if you absolutely must work with an empty directory.)

 input = open(fromfile, 'rb')   # use binary mode on 
 Windows

As a general rule I prefer to avoid shadowing builtins, but it's not
strictly a problem.

 filename = os.path.join(todir, ('part{}.flv'.format(partnum)))
 assert partnum =  # join sort fails if 5 
 digits
 return partnum

Why the assertion? Since this is all you do with the partnum, why does
it matter how long the number is? Without seeing the join sort I can't
know why that would fail; but there must surely be a solution to this.

 fromfile = input('File to be split: ')   # input if clicked

clicked? I'm guessing this is a translation problem, but I've no
idea what you mean by it.

What you have seems to be a reasonably viable (not that I tested it or
anything) file-level split. You should be able to re-join the parts
quite easily. But the subsequent parts are highly unlikely to play.
Even if you were working in a format that had no headers and could
resynchronize, chances are a 1.4MB file won't have enough to play
anything. Consider: A 1280x720 image contains 921,600 pixels;
uncompressed, this would take 2-4 bytes per pixel, depending on color
depth. To get a single playable frame, you would need an i-frame (ie
not a difference frame) to start and end within a single 1.4MB unit;
it would need to compress 50-75% just to fit, and that's assuming
optimal placement. With random placement, you would need to be getting
87% compression on your index frames, and then you'd still get just
one frame inside your chunk. That's not likely to be very playable.

But hey. You can stitch 'em back together again :)

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


formatted output

2013-05-07 Thread Sudheer Joseph
Dear members,
I need to print few arrays in a tabular form for example below 
array IL has 25 elements, is there an easy way to print this as 5x5 comma 
separated table? in python

IL=[]
for i in np.arange(1,bno+1):
   IL.append(i)
print(IL)
%
in fortran I could do it as below
%
integer matrix(5,5)
   in=0
  do, k=1,5
  do, l=1,5
   in=in+1
  matrix(k,l)=in
  enddo
  enddo
  m=5
  n=5
  do, i=1,m
  write(*,(5i5)) ( matrix(i,j), j=1,n )
  enddo
  end
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: use python to split a video file into a set of parts

2013-05-07 Thread Dave Angel

On 05/07/2013 07:15 AM, iMath wrote:

I use the following python code to split a FLV video file into a set of parts 
,when finished ,only the first part video can be played ,the other parts are 
corrupted.I wonder why and Is there some correct ways to split video files



There are two parts to answering the question.  First, did it accurately 
chunk the file into separate pieces.  That should be trivial to test -- 
simply concatenate them back together (eg. using copy /b) and make sure 
you get exactly the original.  (using md5sum, for example) I think you will.


And second, why the arbitrary pieces don't play in some unspecified 
video player.  That one's more interesting, but hasn't anything to do 
with Python.  I'm curious why you would expect that it would play.  It 
won't have any of the header information, and the compressed data will 
be missing its context information.  To split apart a binary file into 
useful pieces requires a lot of knowledge about the file format.




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


Re: formatted output

2013-05-07 Thread Roy Smith
In article add22437-64a4-4dfb-b6d9-28832e769...@googlegroups.com,
 Sudheer Joseph sjo.in...@gmail.com wrote:

 Dear members,
 I need to print few arrays in a tabular form for example below 
 array IL has 25 elements, is there an easy way to print this as 
 5x5 comma separated table? in python
 
 IL=[]
 for i in np.arange(1,bno+1):
IL.append(i)
 print(IL)
 %
 in fortran I could do it as below
 %
 integer matrix(5,5)
in=0
   do, k=1,5
   do, l=1,5
in=in+1
   matrix(k,l)=in
   enddo
   enddo
   m=5
   n=5
   do, i=1,m
   write(*,(5i5)) ( matrix(i,j), j=1,n )
   enddo
   end
  

Excellent.  My kind of programming language!  See 
http://www.python.org/doc/humor/#bad-habits.

Anyway, that translates, more or less, as follows.

Note that I'm modeling the Fortran 2-dimensional array as a dictionary 
keyed by (k, l) tuples.  That's easy an convenient, but conceptually a 
poor fit and not terribly efficient.  If efficiency is an issue (i.e. 
much larger values of (k, l), you probably want to be looking at numpy.

Also, in is a keyword in python, so I changed that to value.  
There's probably cleaner ways to do this. I did a pretty literal 
transliteration.


matrix = {}
value = 0
for k in range(1, 6):
   for l in range(1, 6):
  value += 1
  matrix[(k, l)] = value

for i in range(1, 6):
   print ,.join(%5d % matrix[(i, j)] for j in range(1, 6))

This prints:

1,2,3,4,5
6,7,8,9,   10
   11,   12,   13,   14,   15
   16,   17,   18,   19,   20
   21,   22,   23,   24,   25
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread jmfauth
On 6 mai, 09:49, Fábio Santos fabiosantos...@gmail.com wrote:
 On 6 May 2013 08:34, Chris Angelico ros...@gmail.com wrote:

  Well you see, it was 70 bytes back in the Python 2 days (I'll defer to
  Steven for data points earlier than that), but with Python 3, there
  were two versions: one was 140 bytes representing 70 characters, the
  other 280 bytes representing 70 characters. In Python 3.3, they were
  merged, and a trivial amount of overhead added, so now it's 80 bytes
  representing 70 characters. But you have an absolute guarantee that
  it's correct now.

  Of course, the entire code can be represented as a single int now. You
  used to have to use a long.

  ChrisA
  --

 Thanks. You have made my day.

 I may rise the average pay of a Python programmer in Portugal. I have asked
 for a raise back in December, and was told that it wouldn't happen before
 this year. I have done well. I think I deserve better pay than a
 supermarket employee now. I am sure that my efforts were appreciated and I
 will be rewarded. I am being sarcastic.

 The above paragraph wouldn't be true if I programmed in perl, c++ or lisp.


-


1) The memory gain for many of us (usually non ascii users)
just become irrelevant.

 sys.getsizeof('maçã')
41
 sys.getsizeof('abcd')
29

2) More critical, Py 3.3, just becomes non unicode compliant,
(eg European languages or ascii typographers !)

 import timeit
 timeit.timeit('abcd'*1000 + 'a')
2.186670111428325
 timeit.timeit('abcd'*1000 + '€')
2.9951699820528432
 timeit.timeit('abcd'*1000 + 'œ')
3.0036780444886233
 timeit.timeit('abcd'*1000 + 'ẞ')
3.004992278824048
 timeit.timeit('maçã'*1000 + 'œ')
3.231025618708202
 timeit.timeit('maçã'*1000 + '€')
3.215894398100758
 timeit.timeit('maçã'*1000 + 'œ')
3.224407974255655
 timeit.timeit('maçã'*1000 + '’')
3.2206342273566406
 timeit.timeit('abcd'*1000 + '’')
2.991440344906

3) Python is pround to cover the whole unicode range,
unfortunately it breaks the BMP range.
Small GvR exemple (ascii) from the the bug list,
but with non ascii characters.

# Py 3.2, all chars

 timeit.repeat(a = 'hundred'; 'x' in a)
[0.09087790617297742, 0.07456871885972305, 0.07449940353376405]
 timeit.repeat(a = 'maçãé€ẞ'; 'x' in a)
[0.10088136800095526, 0.07488497003487282, 0.07497594640028638]


# Py 3.3 ascii and non ascii chars
 timeit.repeat(a = 'hundred'; 'x' in a)
[0.11426985953005442, 0.10040049292649655, 0.09920834808588097]
 timeit.repeat(a = 'maçãé€ẞ'; 'é' in a)
[0.2345595188256766, 0.21637172864154763, 0.2179096624382737]


There are plenty of good reasons to use Python. There are
also plenty of good reasons to not use (or now to drop)
Python and to realize that if you wish to process text
seriously, you are better served by using corporate
products or tools using Unicode properly.

jmf


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


Re: formatted output

2013-05-07 Thread Peter Otten
Roy Smith wrote:

 In article add22437-64a4-4dfb-b6d9-28832e769...@googlegroups.com,
  Sudheer Joseph sjo.in...@gmail.com wrote:
 
 Dear members,
 I need to print few arrays in a tabular form for example
 below array IL has 25 elements, is there an easy way to print
 this as 5x5 comma separated table? in python
 
 IL=[]
 for i in np.arange(1,bno+1):
IL.append(i)
 print(IL)
 %
 in fortran I could do it as below
 %
 integer matrix(5,5)
in=0
   do, k=1,5
   do, l=1,5
in=in+1
   matrix(k,l)=in
   enddo
   enddo
   m=5
   n=5
   do, i=1,m
   write(*,(5i5)) ( matrix(i,j), j=1,n )
   enddo
   end
  
 
 Excellent.  My kind of programming language!  See
 http://www.python.org/doc/humor/#bad-habits.
 
 Anyway, that translates, more or less, as follows.
 
 Note that I'm modeling the Fortran 2-dimensional array as a dictionary
 keyed by (k, l) tuples.  That's easy an convenient, but conceptually a
 poor fit and not terribly efficient.  If efficiency is an issue (i.e.
 much larger values of (k, l), you probably want to be looking at numpy.
 
 Also, in is a keyword in python, so I changed that to value.
 There's probably cleaner ways to do this. I did a pretty literal
 transliteration.
 
 
 matrix = {}
 value = 0
 for k in range(1, 6):
for l in range(1, 6):
   value += 1
   matrix[(k, l)] = value
 
 for i in range(1, 6):
print ,.join(%5d % matrix[(i, j)] for j in range(1, 6))
 
 This prints:
 
 1,2,3,4,5
 6,7,8,9,   10
11,   12,   13,   14,   15
16,   17,   18,   19,   20
21,   22,   23,   24,   25

Or, as the OP may be on the road to numpy anyway:

 import numpy
 a = numpy.arange(1, 26).reshape(5, 5)
 a
array([[ 1,  2,  3,  4,  5],
   [ 6,  7,  8,  9, 10],
   [11, 12, 13, 14, 15],
   [16, 17, 18, 19, 20],
   [21, 22, 23, 24, 25]])
 import sys
 numpy.savetxt(sys.stdout, a, delimiter=, , fmt=%5d)
1, 2, 3, 4, 5
6, 7, 8, 9,10
   11,12,13,14,15
   16,17,18,19,20
   21,22,23,24,25


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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 11:22 PM, jmfauth wxjmfa...@gmail.com wrote:
 There are plenty of good reasons to use Python. There are
 also plenty of good reasons to not use (or now to drop)
 Python and to realize that if you wish to process text
 seriously, you are better served by using corporate
 products or tools using Unicode properly.

There are plenty of good reasons to use Python. One of them is the
laughs you can get any time jmf posts here. There are also plenty of
good reasons to drop Python. One of them is because corporate products
like Microsoft Visual Studio are inherently better specifically
because they cost you money, and there's no way that something you
paid nothing for can ever be as good as that. Plus, you get to write
code that works on only one platform, and that's really good. Finally,
moving off Python would mean you don't feel obliged to respond to jmf,
which will increase your productivity measurably.

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


Re: First python program, syntax error in while loop

2013-05-07 Thread Chris Angelico
On Tue, May 7, 2013 at 10:44 PM, Ombongi Moraa Fe
moraa.lovetak...@gmail.com wrote:
 My first language was Pascal. It was at a time in 2005 when computers were
 finally becoming popular in Africa and our year was the first time a girls
 school from our Province did a computer coursework for National Exams. (That
 was such an achievement *sigh*)

 The teacher said ... Good Programming Practice ... Use parentheses to
 format code.. or I will deduct a point from your work when I feel like it.

 Cant seem to let go of the behavior. I use parentheses in all languages.

Pretty much all such blanket advice is flawed. I cannot at present
think of any example of a Good Programming Practice suggestion that
doesn't have its exceptions and caveats. The only ones that don't are
the ones that get codified into language/syntax rules, and even there,
most of them have their detractors. Python's indentation rule is a
prime example; most people follow the advice to always indent blocks
of code, Python makes it mandatory, and some people hate Python for
it. (And yes, there have been times when I've deliberately misindented
a block of C code, because it made more logical sense that way. I can
quote examples if you like.)

The only principle that you should follow is: Think about what you're
doing. Everything else is an elaboration on that. [1]

ChrisA
[1] Matthew 22:37-40 :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Fábio Santos


 -


 1) The memory gain for many of us (usually non ascii users)
 just become irrelevant.

  sys.getsizeof('maçã')
 41
  sys.getsizeof('abcd')
 29

 2) More critical, Py 3.3, just becomes non unicode compliant,
 (eg European languages or ascii typographers !)

  import timeit
  timeit.timeit('abcd'*1000 + 'a')
 2.186670111428325
  timeit.timeit('abcd'*1000 + '€')
 2.9951699820528432
  timeit.timeit('abcd'*1000 + 'œ')
 3.0036780444886233
  timeit.timeit('abcd'*1000 + 'ẞ')
 3.004992278824048
  timeit.timeit('maçã'*1000 + 'œ')
 3.231025618708202
  timeit.timeit('maçã'*1000 + '€')
 3.215894398100758
  timeit.timeit('maçã'*1000 + 'œ')
 3.224407974255655
  timeit.timeit('maçã'*1000 + '’')
 3.2206342273566406
  timeit.timeit('abcd'*1000 + '’')
 2.991440344906

 3) Python is pround to cover the whole unicode range,
 unfortunately it breaks the BMP range.
 Small GvR exemple (ascii) from the the bug list,
 but with non ascii characters.

 # Py 3.2, all chars

  timeit.repeat(a = 'hundred'; 'x' in a)
 [0.09087790617297742, 0.07456871885972305, 0.07449940353376405]
  timeit.repeat(a = 'maçãé€ẞ'; 'x' in a)
 [0.10088136800095526, 0.07488497003487282, 0.07497594640028638]


 # Py 3.3 ascii and non ascii chars
  timeit.repeat(a = 'hundred'; 'x' in a)
 [0.11426985953005442, 0.10040049292649655, 0.09920834808588097]
  timeit.repeat(a = 'maçãé€ẞ'; 'é' in a)
 [0.2345595188256766, 0.21637172864154763, 0.2179096624382737]


 There are plenty of good reasons to use Python. There are
 also plenty of good reasons to not use (or now to drop)
 Python and to realize that if you wish to process text
 seriously, you are better served by using corporate
 products or tools using Unicode properly.

 jmf

This is so off-topic that, after reading this, I feel I have just returned
from the Moon.

OTOH, it would seem like you know the Portuguese word for apple, so I also
feel home.

I am so confused.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Red Black Tree implementation?

2013-05-07 Thread duncan smith

On 07/05/13 02:20, Dan Stromberg wrote:



[snip]


I'm starting to think Red Black Trees are pretty complex.




A while ago I looked at a few different types of self-balancing binary 
tree. Most look much easier to implement.


BTW, the licence might be MIT - I just copied it from someone else's code.

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


Re: distributing a binary package

2013-05-07 Thread Eric Frederich
I see where I can specify a module that distutils will try to compile.
I already have the .so files compiled.

I'm sure its simple, I just can't find it or don't know what to look for.

On Mon, May 6, 2013 at 9:13 PM, Miki Tebeka miki.teb...@gmail.com wrote:

 Basically, I'd like to know how to create a proper setup.py script
 http://docs.python.org/2/distutils/setupscript.html
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread cheirasacan
El martes, 7 de mayo de 2013 12:53:25 UTC+2, MRAB  escribió:
 On 07/05/2013 10:27, cheirasa...@gmail.com wrote:
 
  from tkinter import *
 
  import sfml
 
 
 
 
 
  window = Tk()
 
  window.minsize( 640, 480 )
 
 
 
 
 
  def sonido():
 
   file = sfml.Music.from_file('poco.ogg')
 
   file.play()
 
 
 
 
 
  test = Button ( window, text = 'Sound test', command=sonido )
 
  test.place ( x = 10, y = 60)
 
 
 
  window.mainloop()
 
 
 
 
 
 
 
 
 
  Using Windows 7, Python 3.3, sfml 1.3.0 library, the file it is played if i 
  put it out of the function. � what am i doing wrong ? Thanks.
 
 
 
 Perhaps what's happening is that sonido starts playing it and then
 
 returns, meaning that there's no longer a reference to it ('file' is
 
 local to the function), so it's collected by the garbage collector.
 
 
 
 If that's the case, try keeping a reference to it, perhaps by making
 
 'file' global (in a simple program like this one, using global should
 
 be OK).

Thanks. A global use of 'sonido' fix the problem. The garbage collector must be 
the point. But this code is part of a longer project. What can i do to fix it 
without the use of globals? I will use more functions like this, and i would 
like to keep learning python as well good programming methodology.
Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Steve Simmons
Fábio Santos fabiosantos...@gmail.com wrote:



 -


 1) The memory gain for many of us (usually non ascii users)
 just become irrelevant.

  sys.getsizeof('maçã')
 41
  sys.getsizeof('abcd')
 29

 2) More critical, Py 3.3, just becomes non unicode compliant,
 (eg European languages or ascii typographers !)

  import timeit
  timeit.timeit('abcd'*1000 + 'a')
 2.186670111428325
  timeit.timeit('abcd'*1000 + '€')
 2.9951699820528432
  timeit.timeit('abcd'*1000 + 'œ')
 3.0036780444886233
  timeit.timeit('abcd'*1000 + 'ẞ')
 3.004992278824048
  timeit.timeit('maçã'*1000 + 'œ')
 3.231025618708202
  timeit.timeit('maçã'*1000 + '€')
 3.215894398100758
  timeit.timeit('maçã'*1000 + 'œ')
 3.224407974255655
  timeit.timeit('maçã'*1000 + '’')
 3.2206342273566406
  timeit.timeit('abcd'*1000 + '’')
 2.991440344906

 3) Python is pround to cover the whole unicode range,
 unfortunately it breaks the BMP range.
 Small GvR exemple (ascii) from the the bug list,
 but with non ascii characters.

 # Py 3.2, all chars

  timeit.repeat(a = 'hundred'; 'x' in a)
 [0.09087790617297742, 0.07456871885972305, 0.07449940353376405]
  timeit.repeat(a = 'maçãé€ẞ'; 'x' in a)
 [0.10088136800095526, 0.07488497003487282, 0.07497594640028638]


 # Py 3.3 ascii and non ascii chars
  timeit.repeat(a = 'hundred'; 'x' in a)
 [0.11426985953005442, 0.10040049292649655, 0.09920834808588097]
  timeit.repeat(a = 'maçãé€ẞ'; 'é' in a)
 [0.2345595188256766, 0.21637172864154763, 0.2179096624382737]


 There are plenty of good reasons to use Python. There are
 also plenty of good reasons to not use (or now to drop)
 Python and to realize that if you wish to process text
 seriously, you are better served by using corporate
 products or tools using Unicode properly.

 jmf

This is so off-topic that, after reading this, I feel I have just
returned
from the Moon.

OTOH, it would seem like you know the Portuguese word for apple, so I
also
feel home.

I am so confused.




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

Good to see jmf finally comparing apples with apples :-) 

Sent from a Galaxy far far away-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread MRAB

On 07/05/2013 14:56, cheirasa...@gmail.com wrote:

El martes, 7 de mayo de 2013 12:53:25 UTC+2, MRAB  escribió:

On 07/05/2013 10:27, cheirasa...@gmail.com wrote:
 from tkinter import *
 import sfml

 window = Tk()
 window.minsize( 640, 480 )

 def sonido():
  file = sfml.Music.from_file('poco.ogg')
  file.play()

 test = Button ( window, text = 'Sound test', command=sonido )
 test.place ( x = 10, y = 60)

 window.mainloop()

 Using Windows 7, Python 3.3, sfml 1.3.0 library, the file it is played if i 
put it out of the function. � what am i doing wrong ? Thanks.


Perhaps what's happening is that sonido starts playing it and then
returns, meaning that there's no longer a reference to it ('file' is
local to the function), so it's collected by the garbage collector.

If that's the case, try keeping a reference to it, perhaps by making
'file' global (in a simple program like this one, using global should
be OK).


Thanks. A global use of 'sonido' fix the problem. The garbage collector must be 
the point. But this code is part of a longer project. What can i do to fix it 
without the use of globals? I will use more functions like this, and i would 
like to keep learning python as well good programming methodology.
Thanks.


Presumably the details of the window are (or will be) hidden away in a
class, so you could make 'file' an attribute of an instance.

Also, please read this:

http://wiki.python.org/moin/GoogleGroupsPython

because gmail insists on adding extra linebreaks, which can be somewhat
annoying.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread Chris Angelico
On Wed, May 8, 2013 at 12:57 AM, MRAB pyt...@mrabarnett.plus.com wrote:
 Also, please read this:

 http://wiki.python.org/moin/GoogleGroupsPython

 because gmail insists on adding extra linebreaks, which can be somewhat
 annoying.

Accuracy correction: It's nothing to do with gmail, which is what I
use (via python-list subscription). It's just Google Groups.

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


dist-packages or site-packages in Python 3.2 ?

2013-05-07 Thread Vincent Vande Vyvre

Hi,

I've one machine with python3.2 (on Ubuntu 12.04), in the folder 
/usr/lib/python3.2 it is a subfolder dist-packages, maybe created at the 
install or created when I've installed the binding pyexiv2, I don't know.


Now, I've installed a new machine, again with Ubuntu 12.04 and therefore 
python3.2.

This new install hasn't any *-packages subfolder in /usr/lib/python3.2

Today I install PyQt5, the make and make install are executed without 
error but when I try:


 from PyQt5 import QtGui
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named PyQt5

I go to check in /usr/lib/python3.2 and I see the install of PyQt5 has 
created a subfolder site-packages.
Is this naming dist-packages/site-packages critical for Python? (My 
intuition is yes!)


So, I've tried with:
 sys.path.append('/usr/lib/python3.2/site_packages')
and, also, created a file __init__.py in /site-packages but that's not 
solved the problem.


Thanks for your advices.
--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte 
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager

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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Terry Jan Reedy
On 5/7/2013 9:22 AM, jmfauth road forth on his dead hobbyhorse to hijack 
yet another thread:



# Py 3.3 ascii and non ascii chars

timeit.repeat(a = 'hundred'; 'x' in a)

[0.11426985953005442, 0.10040049292649655, 0.09920834808588097]

timeit.repeat(a = 'maçãé€ẞ'; 'é' in a)

[0.2345595188256766, 0.21637172864154763, 0.2179096624382737]


Python 3.3 is a language. Languages do not have timings.
CPython 3.3.0 is an implementation compiled and run under a particular 
OS and hardware. With respect to Unicode timings, especially for 
find/replace, it is obsolete. On my Win7 machine with fresh debug builds 
from the current repository, I see these times.


Python 3.3.1+ (default, May  7 2013, 14:03:12) [MSC v.1600 32 bit (Int
 from timeit import repeat
 repeat(a = 'hundred'; 'x' in a)
[0.19007337649622968, 0.190116721780754, 0.1900149679567562]
 repeat(a = 'maçaé??'; 'é' in a)
[0.20568874581187716, 0.20568782357178053, 0.20577051776710914]

Python 3.4.0a0 (default:32067784f198, May  7 2013, 13:59:10) [MSC v.1600
 from timeit import repeat
 repeat(a = 'hundred'; 'x' in a)
[0.1708080882915779, 0.17062978853956826, 0.1706740560642051]
 repeat(a = 'maçaé??'; 'é' in a)
[0.17612111348809734, 0.17562925210324565, 0.17549245315558437]

Note 1: debug builds are slower than install builds, especially for 
microbenchmarks with trivial statements. My installed 3.3.1 on a 
different machine has timings of about .1 for the ascii test. It is 
slower for the non-ascii test because the latest improvements were made 
after 3.3.1 was released.


Note 2: 3.4 has additional improvements that speed up everything, so 
that the 3.4 non-ascii time is faster that even the 3.3 ascii time.


Terry


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


Re: python backup script

2013-05-07 Thread Enrico 'Henryx' Bianchi
John Gordon wrote:


 Looks like you need a comma after 'stdout=filename'.

Sigh, yesterday was a terrible day (yes, it lacks a comma)...
Anyway, when it is possible, is recommended to use the drivers for 
communicate with databases, because subprocess (or os.*open*) is more 
expensive compared to (python needs to spawn an external process to execute 
the command)

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


Making safe file names

2013-05-07 Thread Andrew Berg
Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and 
have been naming the files using the artist name. However,
artist names can have characters that are not allowed in file names for most 
file systems (e.g., C/A/T has forward slashes). Are there any
recommended strategies for naming such files while avoiding conflicts (I 
wouldn't want to run into problems for an artist named C-A-T or
CAT, for example)? I'd like to make the files easily identifiable, and there 
really are no limits on what characters can be in an artist name.
-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why sfml does not play the file inside a function in this python code?

2013-05-07 Thread cheirasacan
El martes, 7 de mayo de 2013 16:57:59 UTC+2, MRAB  escribió:
 On 07/05/2013 14:56, cheirasa...@gmail.com wrote:
 
  El martes, 7 de mayo de 2013 12:53:25 UTC+2, MRAB  escribió:
 
  On 07/05/2013 10:27, cheirasa...@gmail.com wrote:
 
   from tkinter import *
 
   import sfml
 
  
 
   window = Tk()
 
   window.minsize( 640, 480 )
 
  
 
   def sonido():
 
file = sfml.Music.from_file('poco.ogg')
 
file.play()
 
  
 
   test = Button ( window, text = 'Sound test', command=sonido )
 
   test.place ( x = 10, y = 60)
 
  
 
   window.mainloop()
 
  
 
   Using Windows 7, Python 3.3, sfml 1.3.0 library, the file it is played 
   if i put it out of the function. � what am i doing wrong ? Thanks.
 
  
 
 
 
  Perhaps what's happening is that sonido starts playing it and then
 
  returns, meaning that there's no longer a reference to it ('file' is
 
  local to the function), so it's collected by the garbage collector.
 
 
 
  If that's the case, try keeping a reference to it, perhaps by making
 
  'file' global (in a simple program like this one, using global should
 
  be OK).
 
 
 
  Thanks. A global use of 'sonido' fix the problem. The garbage collector 
  must be the point. But this code is part of a longer project. What can i do 
  to fix it without the use of globals? I will use more functions like this, 
  and i would like to keep learning python as well good programming 
  methodology.
 
  Thanks.
 
 
 
 Presumably the details of the window are (or will be) hidden away in a
 
 class, so you could make 'file' an attribute of an instance.
 
 
 
 Also, please read this:
 
 
 
 http://wiki.python.org/moin/GoogleGroupsPython
 
 
 
 because gmail insists on adding extra linebreaks, which can be somewhat
 
 annoying.

 The reply is very useful. I will keep learning.
 Thanks for all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Get filename using filefialog.askfilename

2013-05-07 Thread cheirasacan
Well. It's driving me crazy. So simple

I use:

file = filedialog.askopenfile ( mode... )

to open a file with an open dialog box, OK. Made it.

How i get the name of the opened file?

i do :

print(file)

the output is: ..name=file.doc...mode=..encoding..  

How can i get the second member of 'file'?

I had prove with print(file[1]) and print(file(1)) but does not work.

And i am unable to find a detailed reference to this object in the i.net

http://fossies.org/dox/Python-3.3.1/filedialog_8py_source.html#l00393 is
where i could reach!



Thanks

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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Martijn Lievaart
On Sun, 05 May 2013 17:07:41 -0400, Roy Smith wrote:

 There *are* programming languages worse than PHP.  Have you ever tried
 britescript?

Have you tried MUMPS? :-)

M4


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


Re: Get filename using filefialog.askfilename

2013-05-07 Thread John Gordon
In ab1feb45-0397-4411-bab1-898c95f57...@googlegroups.com 
cheirasa...@gmail.com writes:

 print(file)

 the output is: ..name=file.doc...mode=..encoding..  

 How can i get the second member of 'file'?

If you're using the interpreter, you can type this command:

 help(file)

And it will display documentation for using objects of that type.
You can also use this command:

 dir(file)

And it will display all the members and methods that the object provides.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread 88888 Dihedral
Chris Angelico於 2013年5月7日星期二UTC+8下午9時32分55秒寫道:
 On Tue, May 7, 2013 at 11:22 PM, jmfauth wxjmfa...@gmail.com wrote:
 
  There are plenty of good reasons to use Python. There are
 
  also plenty of good reasons to not use (or now to drop)
 
  Python and to realize that if you wish to process text
 
  seriously, you are better served by using corporate
 
  products or tools using Unicode properly.
 
 
 
 There are plenty of good reasons to use Python. One of them is the
 
 laughs you can get any time jmf posts here. There are also plenty of
 
 good reasons to drop Python. One of them is because corporate products
 
 like Microsoft Visual Studio are inherently better specifically
 
 because they cost you money, and there's no way that something you
 
 paid nothing for can ever be as good as that. Plus, you get to write
 
People used MS products  because most bosses did not  want to pay 
the prices of work stations,  the minis, or the main-frames and 
the salaries of the system  administrators  in 199x. 


 code that works on only one platform, and that's really good. Finally,
 
 moving off Python would mean you don't feel obliged to respond to jmf,
 
 which will increase your productivity measurably.
 
 
 
 ChrisA

The price issue of a software  package or a platform is not 
the only  way to judge a programming language.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Walter Hurry
On Tue, 07 May 2013 23:32:55 +1000, Chris Angelico wrote:

 On Tue, May 7, 2013 at 11:22 PM, jmfauth wxjmfa...@gmail.com wrote:
 There are plenty of good reasons to use Python. There are also plenty
 of good reasons to not use (or now to drop) Python and to realize that
 if you wish to process text seriously, you are better served by using
 corporate products or tools using Unicode properly.
 
 There are plenty of good reasons to use Python. One of them is the
 laughs you can get any time jmf posts here. There are also plenty of
 good reasons to drop Python. One of them is because corporate products
 like Microsoft Visual Studio are inherently better specifically because
 they cost you money, and there's no way that something you paid nothing
 for can ever be as good as that. Plus, you get to write code that works
 on only one platform, and that's really good. Finally,
 moving off Python would mean you don't feel obliged to respond to jmf,
 which will increase your productivity measurably.

TMML. Thanks!

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


Re: Get filename using filefialog.askfilename

2013-05-07 Thread Terry Jan Reedy

On 5/7/2013 4:27 PM, cheirasa...@gmail.com wrote:


file = filedialog.askopenfile ( mode... )


askopenfile is a convenience function that creates an Open dialog 
object, shows it, gets the name returned by the dialog, opens the file 
with that name, and returns an appropriate normal file object



to open a file with an open dialog box, OK. Made it.

How i get the name of the opened file?


file.name, (at least in 3.3), which in your example below is file.doc


print(file)

the output is: ..name=file.doc...mode=..encoding..  


This is the standard string representation of a file object. It is 
created from the various attributes of the file instance, including 
file.name.



How can i get the second member of 'file'?


Strings do not have fields. The second 'member', would be the second 
character, file[1], which is not what you want.



And i am unable to find a detailed reference to this object in the i.net


Use the Fine Manual. The entry for builtin open() function, which you 
should read to understand the 'open' part of askopenfile, directs you to 
the Glossary entry 'file object' which says There are actually three 
categories of file objects: raw binary files, buffered binary files and 
text files. Their interfaces are defined in the io module. The canonical 
way to create a file object is by using the open() function. The kind 
of file object you get is determined by the mode ('b' present or not), 
buffer arg, and maybe something else. You can look in the io chapter or 
use dir() and help() as John G. suggested.


Python programmers should really learn to use dir(), help(), and the 
manuls, including the index and module index.


--
Terry Jan Reedy


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


Re: Making safe file names

2013-05-07 Thread Terry Jan Reedy

On 5/7/2013 3:58 PM, Andrew Berg wrote:

Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and 
have been naming the files using the artist name. However,
artist names can have characters that are not allowed in file names for most 
file systems (e.g., C/A/T has forward slashes). Are there any
recommended strategies for naming such files while avoiding conflicts (I 
wouldn't want to run into problems for an artist named C-A-T or
CAT, for example)? I'd like to make the files easily identifiable, and there 
really are no limits on what characters can be in an artist name.


Sounds like you want something like the html escape or urlencode 
functions, which serve the same purpose of encoding special chars. 
Rather than invent a new tranformation, you could use the same scheme 
used for html entities. (Sorry, I forget the details.) It is possible 
that one of the functions would work for you as is, or with little 
modification.


Terry



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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread William Ray Wing
On May 7, 2013, at 4:31 PM, Martijn Lievaart m...@rtij.nl.invlalid wrote:

 On Sun, 05 May 2013 17:07:41 -0400, Roy Smith wrote:
 
 There *are* programming languages worse than PHP.  Have you ever tried
 britescript?
 
 Have you tried MUMPS? :-)
 
 M4
 

Which one?  The original MUMPS (Massachusetts General Hospital Utility 
Multi-Programming System), or the one that came out of Europe in the '90s and 
stole the MUMPS name (MUltifrontal Massively Parallel sparse direct Solver)?

I used both the original and its baby brother FOCAL which, considering that 
they ran on DEC PDP-7 (MUMPS) and DEC PDP-8 (FOCAL) systems with as little as 
4k words of 18-bit memory on the PDP-7 and 8-bit memory on the PDP-8 is pretty 
spectacular.  They should be forgiven for a somewhat constrained list of key 
words and operations. 

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


Re: Making safe file names

2013-05-07 Thread Fábio Santos
I suggest Base64. b64encode
(http://docs.python.org/2/library/base64.html#base64.b64encode) and
b64decode take an argument which allows you to eliminate the pesky /
character. It's reversible and simple.

More suggestions: how about a hash? Or just use IDs from the database?

On Tue, May 7, 2013 at 8:58 PM, Andrew Berg bahamutzero8...@gmail.com wrote:
 Currently, I keep Last.fm artist data caches to avoid unnecessary API calls 
 and have been naming the files using the artist name. However,
 artist names can have characters that are not allowed in file names for most 
 file systems (e.g., C/A/T has forward slashes). Are there any
 recommended strategies for naming such files while avoiding conflicts (I 
 wouldn't want to run into problems for an artist named C-A-T or
 CAT, for example)? I'd like to make the files easily identifiable, and there 
 really are no limits on what characters can be in an artist name.
 --
 CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
 --
 http://mail.python.org/mailman/listinfo/python-list



--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread MRAB

On 07/05/2013 20:58, Andrew Berg wrote:

Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and 
have been naming the files using the artist name. However,
artist names can have characters that are not allowed in file names for most 
file systems (e.g., C/A/T has forward slashes). Are there any
recommended strategies for naming such files while avoiding conflicts (I 
wouldn't want to run into problems for an artist named C-A-T or
CAT, for example)? I'd like to make the files easily identifiable, and there 
really are no limits on what characters can be in an artist name.


Conflicts won't occur if:

1. All of the characters of the artist's name are mapped to an encoding.

2. Different characters map to different encodings.

3. No encoding is a prefix of another encoding.

In practice, you'll be mapping most characters to themselves.

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


Re: Making safe file names

2013-05-07 Thread Dan Stromberg
On 5/7/13, Andrew Berg bahamutzero8...@gmail.com wrote:
 Currently, I keep Last.fm artist data caches to avoid unnecessary API calls
 and have been naming the files using the artist name. However,
 artist names can have characters that are not allowed in file names for most
 file systems (e.g., C/A/T has forward slashes). Are there any
 recommended strategies for naming such files while avoiding conflicts (I
 wouldn't want to run into problems for an artist named C-A-T or
 CAT, for example)? I'd like to make the files easily identifiable, and there
 really are no limits on what characters can be in an artist name.

You might consider:
http://stromberg.dnsalias.org/svn/backshift/trunk/escape_mod.py
http://stromberg.dnsalias.org/svn/backshift/trunk/test-escape_mod

It doubles the length of the string, but it produces safe, easily
readable escaped strings - which tends to make debugging easier.

It requires a couple of other modules (easily obtained from the same
SVN repo) though.
-- 
http://mail.python.org/mailman/listinfo/python-list


multiple versions of python

2013-05-07 Thread sokovic . anamarija
Hi,

what is the generally recommended structure when we have into play this type of 
problem:
multiple versions of python (both in the sense of main versions and sub 
versions, e.g., 
2.7 :
   2.7.1
   2.7.3
3:
 3.3
   3.3.1
Different versions of gcc
different compilation strategies (-vanilla and non-vanilla)
different modules (numpy,scipy) together with the different versions of all the 
rest.

any help is appreciated

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


Re: Making safe file names

2013-05-07 Thread Jens Thoms Toerring
Andrew Berg bahamutzero8...@gmail.com wrote:
 Currently, I keep Last.fm artist data caches to avoid unnecessary API calls
 and have been naming the files using the artist name. However, artist names
 can have characters that are not allowed in file names for most file systems
 (e.g., C/A/T has forward slashes). Are there any recommended strategies for
 naming such files while avoiding conflicts (I wouldn't want to run into
 problems for an artist named C-A-T or CAT, for example)? I'd like to make
 the files easily identifiable, and there really are no limits on what
 characters can be in an artist name. --

It's not clear what the context that you need this for. You
could e.g. replace all characters not allowed by the file
system by their hexidecimal (ASCII) values, preceeded by a
'% (so '/' would be changed to '%2F', and also encode a '%'
itself in a name by '%25'). Then you have a well-defined
two-way mapping (isomorphic if I remember my math-lear-
nining days correctly) between the original name and the
way you store it. E.g.

  C/A/T  would become  C%2FA%2FT

and

  C%2FA/T  would become  C%252FA%2FT

You can translate back and forth between them with not too
much effort.

Of course, that assumes that '%' is a character allowed by
your file system - otherwise pick some other one, any one
will do in principle. It's a bit harder for a human to in-
terpret but rathe likely not that much of a problem. You
probably will have seen that kind of scheme used in URLs.
The concept is rather old and called 'escape character',
i.e. have one character that assumes some special meaning
and also escaped it.

If, on the hand, those names are never to be translated back
to the original name another strategy would be to use the SHA1
hash value of the artists name. Since clashes between SHA1 hash
values are rather hard to produce it's a rather safe method of
converting something (i.e. the artists name) to a number. The
drawback, of course, is that you can't translate back from the
hash value to the original name (if that would be simple the
whole thing wouldn't work;-)

   Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Chris Angelico
On Wed, May 8, 2013 at 8:18 AM, Fábio Santos fabiosantos...@gmail.com wrote:
 I suggest Base64. b64encode
 (http://docs.python.org/2/library/base64.html#base64.b64encode) and
 b64decode take an argument which allows you to eliminate the pesky /
 character. It's reversible and simple.

But it doesn't look anything like the original.

I'd be inclined to go for something like quoted-printable or
URL-encoding; special characters become much longer, but ordinary
characters (mostly) stay as themselves.

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


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 17:18, Fábio Santos wrote:
 I suggest Base64. b64encode
 (http://docs.python.org/2/library/base64.html#base64.b64encode) and
 b64decode take an argument which allows you to eliminate the pesky /
 character. It's reversible and simple.
 
 More suggestions: how about a hash? Or just use IDs from the database?
None of these would work because I would have no idea which file stores data 
for which artist without writing code to figure it out. If I
were to end up writing a bug that messed up a few of my cache files and noticed 
it with a specific artist (e.g., doing a now playing and
seeing the wrong tags), I would either have to manually match up the hash or 
base64 encoding in order to delete just that file so that it
gets regenerated or nuke and regenerate my entire cache.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 17:01, Terry Jan Reedy wrote:
 Sounds like you want something like the html escape or urlencode 
 functions, which serve the same purpose of encoding special chars. 
 Rather than invent a new tranformation, you could use the same scheme 
 used for html entities. (Sorry, I forget the details.) It is possible 
 that one of the functions would work for you as is, or with little 
 modification.
This has the problem of mangling non-ASCII characters (and artist names with 
non-ASCII characters are not rare). I most definitely want to
keep as many characters untouched as possible so that the files are easy to 
identify by looking at the file name. Ideally, only characters
that file systems don't like would be transformed.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple versions of python

2013-05-07 Thread Roy Smith
In article 72f93710-9812-441e-8d3d-f221d5698...@googlegroups.com,
 sokovic.anamar...@gmail.com wrote:

 Hi,
 
 what is the generally recommended structure when we have into play this type 
 of problem:
 multiple versions of python (both in the sense of main versions and sub 
 versions, e.g., 
 2.7 :
2.7.1
2.7.3
 3:
  3.3
3.3.1
 Different versions of gcc
 different compilation strategies (-vanilla and non-vanilla)
 different modules (numpy,scipy) together with the different versions of all 
 the rest.
 
 any help is appreciated
 
 Ana

Virtualenv is your friend.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Dave Angel

On 05/07/2013 03:58 PM, Andrew Berg wrote:

Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and 
have been naming the files using the artist name. However,
artist names can have characters that are not allowed in file names for most 
file systems (e.g., C/A/T has forward slashes). Are there any
recommended strategies for naming such files while avoiding conflicts (I 
wouldn't want to run into problems for an artist named C-A-T or
CAT, for example)? I'd like to make the files easily identifiable, and there 
really are no limits on what characters can be in an artist name.



So what you need first is a list of allowable characters for all your 
target OS versions.  And don't forget that the allowable characters may 
vary depending on the particular file system(s) mounted on a given OS.


You also need to decide how to handle Unicode characters, since they're 
different for different OS.  In Windows on NTFS, filenames are in 
Unicode, while on Unix, filenames are bytes.  So on one of those, you 
will be encoding/decoding if your code is to be mostly portable.


Don't forget that ls and rm may not use the same encoding you're using. 
 So you may not consider it adequate to make the names legal, but you 
may also want they easily typeable in the shell.


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


Re: Making safe file names

2013-05-07 Thread Roy Smith
In article mailman.1428.1367972114.3114.python-l...@python.org,
 Dave Angel da...@davea.name wrote:

 On 05/07/2013 03:58 PM, Andrew Berg wrote:
  Currently, I keep Last.fm artist data caches to avoid unnecessary API calls 
  and have been naming the files using the artist name. However,
  artist names can have characters that are not allowed in file names for 
  most file systems (e.g., C/A/T has forward slashes). Are there any
  recommended strategies for naming such files while avoiding conflicts (I 
  wouldn't want to run into problems for an artist named C-A-T or
  CAT, for example)? I'd like to make the files easily identifiable, and 
  there really are no limits on what characters can be in an artist name.
 
 
 So what you need first is a list of allowable characters for all your 
 target OS versions.  And don't forget that the allowable characters may 
 vary depending on the particular file system(s) mounted on a given OS.
 
 You also need to decide how to handle Unicode characters, since they're 
 different for different OS.  In Windows on NTFS, filenames are in 
 Unicode, while on Unix, filenames are bytes.  So on one of those, you 
 will be encoding/decoding if your code is to be mostly portable.
 
 Don't forget that ls and rm may not use the same encoding you're using. 
   So you may not consider it adequate to make the names legal, but you 
 may also want they easily typeable in the shell.

One possible tool that may help you here is unidecode 
(https://pypi.python.org/pypi/Unidecode).  It doesn't solve your whole 
problem, but it does help get unicode text into a form which is both 
7-bit clean and human readable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 17:37, Jens Thoms Toerring wrote:
 You
 could e.g. replace all characters not allowed by the file
 system by their hexidecimal (ASCII) values, preceeded by a
 '% (so '/' would be changed to '%2F', and also encode a '%'
 itself in a name by '%25'). Then you have a well-defined
 two-way mapping (isomorphic if I remember my math-lear-
 nining days correctly) between the original name and the
 way you store it. E.g.
 
   C/A/T  would become  C%2FA%2FT
 
 and
 
   C%2FA/T  would become  C%252FA%2FT
 
 You can translate back and forth between them with not too
 much effort.
 
 Of course, that assumes that '%' is a character allowed by
 your file system - otherwise pick some other one, any one
 will do in principle. It's a bit harder for a human to in-
 terpret but rathe likely not that much of a problem.
Yes, something like this is what I am trying to achieve. Judging by the 
responses I've gotten so far, I think I'll have to roll my own
transformation scheme since URL encoding and the like transform Unicode 
characters. I can memorize that 植松伸夫 is a Japanese composer who
is well-known for his works in the Final Fantasy series of video games. Trying 
to match up the URL-encoded version to an artist would be
almost impossible when I have several other artist names that have no ASCII 
characters.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Neil Hodgson

jmfauth:


2) More critical, Py 3.3, just becomes non unicode compliant,
(eg European languages or ascii typographers !)
...


   This is not demonstrating non-compliance. It is comparing 
performance, not compliance.


   Please show an example where Python 3.3 is not compliant with Unicode.

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


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 19:14, Dave Angel wrote:
 You also need to decide how to handle Unicode characters, since they're 
 different for different OS.  In Windows on NTFS, filenames are in 
 Unicode, while on Unix, filenames are bytes.  So on one of those, you 
 will be encoding/decoding if your code is to be mostly portable.
Characters outside whatever sys.getfilesystemencoding() returns won't be 
allowed. If the user's locale settings don't support Unicode, my
program will be far from the only one to have issues with it. Any problem 
reports that arise from a user moving between legacy encodings
will generally be ignored. I haven't yet decided how I will handle artist names 
with characters outside UTF-8, but inside UTF-16/32 (UTF-16
is just fine on Windows/NTFS, but on Unix(-ish) systems, many use UTF-8 in 
their locale settings).
 Don't forget that ls and rm may not use the same encoding you're using. 
 So you may not consider it adequate to make the names legal, but you 
 may also want they easily typeable in the shell.
I don't understand. I have no intention of changing Unicode characters.


This is not a Unicode issue since (modern) file systems will happily accept it. 
The issue is that certain characters (which are ASCII) are
not allowed on some file systems:
 \ / : * ?| @ and the NUL character
The first 9 are not allowed on NTFS, the @ is not allowed on ext3cow, and NUL 
and / are not allowed on pretty much any file system. Locale
settings and encodings aside, these 11 characters will need to be escaped.
-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distributing a binary package

2013-05-07 Thread Miki Tebeka
 I already have the .so files compiled.
http://docs.python.org/2/distutils/setupscript.html#installing-package-data ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Dave Angel

On 05/07/2013 08:51 PM, Andrew Berg wrote:

On 2013.05.07 19:14, Dave Angel wrote:

You also need to decide how to handle Unicode characters, since they're
different for different OS.  In Windows on NTFS, filenames are in
Unicode, while on Unix, filenames are bytes.  So on one of those, you
will be encoding/decoding if your code is to be mostly portable.

Characters outside whatever sys.getfilesystemencoding() returns won't be 
allowed. If the user's locale settings don't support Unicode, my
program will be far from the only one to have issues with it. Any problem 
reports that arise from a user moving between legacy encodings
will generally be ignored. I haven't yet decided how I will handle artist names 
with characters outside UTF-8,


There aren't any characters outside UTF-8.  But a character is not in 
utf-8, it can be encoded by utf-8.


 but inside UTF-16/32 (UTF-16

Nor outside UTF-16 or 32.


is just fine on Windows/NTFS, but on Unix(-ish) systems, many use UTF-8 in 
their locale settings).

Don't forget that ls and rm may not use the same encoding you're using.
So you may not consider it adequate to make the names legal, but you
may also want they easily typeable in the shell.

I don't understand. I have no intention of changing Unicode characters.


So you're comfortable typing arbitrary characters?  what about all the 
characters that have identical displays in your font? What about viewing 
0x07 in the terminal window?  Or 0x04?





This is not a Unicode issue since (modern) file systems will happily accept it. 
The issue is that certain characters (which are ASCII) are
not allowed on some file systems:
  \ / : * ?| @ and the NUL character
The first 9 are not allowed on NTFS, the @ is not allowed on ext3cow, and NUL 
and / are not allowed on pretty much any file system. Locale
settings and encodings aside, these 11 characters will need to be escaped.



As soon as you have a small, finite list of invalid characters, writing 
an escape system is pretty easy.



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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Benjamin Kaplan
On May 7, 2013 5:42 PM, Neil Hodgson nhodg...@iinet.net.au wrote:

 jmfauth:

 2) More critical, Py 3.3, just becomes non unicode compliant,
 (eg European languages or ascii typographers !)
 ...


This is not demonstrating non-compliance. It is comparing performance,
not compliance.

Please show an example where Python 3.3 is not compliant with Unicode.

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

It's violating page 1+1j of the Unicode spec, where it says precisely how
long each operation is allowed to take. Only wise people can see that page.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Dave Angel

On 05/07/2013 09:11 PM, Benjamin Kaplan wrote:

On May 7, 2013 5:42 PM, Neil Hodgson nhodg...@iinet.net.au wrote:


jmfauth:


2) More critical, Py 3.3, just becomes non unicode compliant,
(eg European languages or ascii typographers !)
...



This is not demonstrating non-compliance. It is comparing performance,

not compliance.


Please show an example where Python 3.3 is not compliant with Unicode.

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


It's violating page 1+1j of the Unicode spec, where it says precisely how
long each operation is allowed to take. Only wise people can see that page.




Of course!   It's a complex page.


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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Mark Lawrence

On 08/05/2013 01:34, Neil Hodgson wrote:

jmfauth:


2) More critical, Py 3.3, just becomes non unicode compliant,
(eg European languages or ascii typographers !)
...


This is not demonstrating non-compliance. It is comparing
performance, not compliance.

Please show an example where Python 3.3 is not compliant with Unicode.

Neil


Surely nobody expects an answer, although I suppose there is always a 
first time for everything.  Once again stealing from Tommy Docherty, 
jmfauth is to Python what King Herod was to baby sitting.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Making safe file names

2013-05-07 Thread Neil Hodgson

Andrew Berg:


This is not a Unicode issue since (modern) file systems will happily accept it. 
The issue is that certain characters (which are ASCII) are
not allowed on some file systems:
  \ / : * ? | @ and the NUL character
The first 9 are not allowed on NTFS, the @ is not allowed on ext3cow, and NUL 
and / are not allowed on pretty much any file system. Locale
settings and encodings aside, these 11 characters will need to be escaped.


   There's also the Windows device name hole. There may be trouble with 
artists named 'COM4', 'CLOCK$', 'Con', or similar.


http://support.microsoft.com/kb/74496
http://en.wikipedia.org/wiki/Nul_%28band%29

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


Re: multiple versions of python

2013-05-07 Thread Colin J. Williams

On 07/05/2013 6:26 PM, sokovic.anamar...@gmail.com wrote:

Hi,

what is the generally recommended structure when we have into play this type of 
problem:
multiple versions of python (both in the sense of main versions and sub 
versions, e.g.,
2.7 :
2.7.1
2.7.3
3:
  3.3
3.3.1
Different versions of gcc
different compilation strategies (-vanilla and non-vanilla)
different modules (numpy,scipy) together with the different versions of all the 
rest.

any help is appreciated

Ana


Do you really need more than 2.7.3  and 3.3.1.

Typically, these go to C:\Python27 and C:\Python33 with windows.

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


Re: multiple versions of python

2013-05-07 Thread Roy Smith
In article kmca64$pd3$1...@theodyn.ncf.ca,
 Colin J. Williams c...@ncf.ca wrote:

 Do you really need more than 2.7.3  and 3.3.1.

It's often useful to have older versions around, so you can test your 
code against them.  Lots of projects try to stay compatible with older 
releases.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Dave Angel

On 05/07/2013 09:28 PM, Neil Hodgson wrote:

Andrew Berg:


This is not a Unicode issue since (modern) file systems will happily
accept it. The issue is that certain characters (which are ASCII) are
not allowed on some file systems:
  \ / : * ? | @ and the NUL character
The first 9 are not allowed on NTFS, the @ is not allowed on ext3cow,
and NUL and / are not allowed on pretty much any file system. Locale
settings and encodings aside, these 11 characters will need to be
escaped.


There's also the Windows device name hole. There may be trouble with
artists named 'COM4', 'CLOCK$', 'Con', or similar.



In MSDOS 2, there was a switch that would tell the OS to ignore such 
names unless they were prefixed by \DEV.  But like the switchar switch, 
it was largely ignored by the ignorant, and probably doesn't exist in 
current versions of M$OS



http://support.microsoft.com/kb/74496
http://en.wikipedia.org/wiki/Nul_%28band%29

Neil


While we're looking for trouble, there's also case insensitivity. 
Unclear if the user cares, but tom and TOM are the same file in most 
configurations of NT.


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


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 20:28, Neil Hodgson wrote:
 http://support.microsoft.com/kb/74496
 http://en.wikipedia.org/wiki/Nul_%28band%29
I can indeed confirm that at least 'nul' cannot be used as a filename. However, 
I add an extension to the file names to identify them as caches.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 20:45, Dave Angel wrote:
 While we're looking for trouble, there's also case insensitivity. 
 Unclear if the user cares, but tom and TOM are the same file in most 
 configurations of NT.
Artist names on Last.fm cannot differ only in case. This does remind me to make 
sure to update the case of the artist name as necessary,
though. For example, if Sam becomes SAM again (I have seen Last.fm change the 
case for artist names), I need to make sure that I don't end
up with two file names differing only in case.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 20:13, Dave Angel wrote:
 So you're comfortable typing arbitrary characters?  what about all the 
 characters that have identical displays in your font?
Identification is more important than typing. I can copy and paste into a 
terminal if necessary. I don't foresee typing out one of the
filenames being anything more than a rare occurrence, but I will occasionally 
just read the list.
 What about viewing 
 0x07 in the terminal window?  Or 0x04?
I don't think Last.fm will even send those characters. In any case, control 
characters in artist names are rare enough that it's not worth
the trouble to write the code to avoid the problems associated with them.
 As soon as you have a small, finite list of invalid characters, writing 
 an escape system is pretty easy.
Probably. I was just hoping there was an existing system that would work, but 
as I said in a different reply, it would seem I need to roll
my own.

-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making safe file names

2013-05-07 Thread Roy Smith
In article mailman.1435.1367977523.3114.python-l...@python.org,
 Dave Angel da...@davea.name wrote:

 While we're looking for trouble, there's also case insensitivity. 
 Unclear if the user cares, but tom and TOM are the same file in most 
 configurations of NT.

OSX, too.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: multiple versions of python

2013-05-07 Thread Mark Lawrence

On 08/05/2013 02:35, Colin J. Williams wrote:

On 07/05/2013 6:26 PM, sokovic.anamar...@gmail.com wrote:

Hi,

what is the generally recommended structure when we have into play
this type of problem:
multiple versions of python (both in the sense of main versions and
sub versions, e.g.,
2.7 :
2.7.1
2.7.3
3:
  3.3
3.3.1
Different versions of gcc
different compilation strategies (-vanilla and non-vanilla)
different modules (numpy,scipy) together with the different versions
of all the rest.

any help is appreciated

Ana


Do you really need more than 2.7.3  and 3.3.1.

Typically, these go to C:\Python27 and C:\Python33 with windows.

Colin W.


In which case you'll normally be doing a binary installation.  If you're 
compiling it's more likely to be VC++ not gcc.


--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: Why do Perl programmers make more money than Python programmers

2013-05-07 Thread Steven D'Aprano
On Tue, 07 May 2013 15:17:52 +0100, Steve Simmons wrote:

 Good to see jmf finally comparing apples with apples :-)

*groans*

Truly the terrible pun that the terrible hijacking deserves.



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


Re: Making safe file names

2013-05-07 Thread Steven D'Aprano
On Tue, 07 May 2013 19:51:24 -0500, Andrew Berg wrote:

 On 2013.05.07 19:14, Dave Angel wrote:
 You also need to decide how to handle Unicode characters, since they're
 different for different OS.  In Windows on NTFS, filenames are in
 Unicode, while on Unix, filenames are bytes.  So on one of those, you
 will be encoding/decoding if your code is to be mostly portable.

 Characters outside whatever sys.getfilesystemencoding() returns won't be
 allowed. If the user's locale settings don't support Unicode, my program
 will be far from the only one to have issues with it. Any problem
 reports that arise from a user moving between legacy encodings will
 generally be ignored. I haven't yet decided how I will handle artist
 names with characters outside UTF-8, but inside UTF-16/32 (UTF-16 is
 just fine on Windows/NTFS, but on Unix(-ish) systems, many use UTF-8 in
 their locale settings).

There aren't any characters outside of UTF-8 :-) UTF-8 covers the entire 
Unicode range, unlike other encodings like Latin-1 or ASCII.

Well, that is to say, there may be characters that are not (yet) handled 
at all by Unicode, but there are no known legacy encodings that support 
such characters.

To a first approximation, Unicode covers the entire set of characters in 
human use, and for those which it does not, there is always the private 
use area. So for example, if you wish to record the Artist Formerly Known 
As The Artist Formerly Known As Prince as Love Symbol, you could pick 
an arbitrary private use code point, declare that for your application 
that code point means Love Symbol, and use that code point as the artist 
name. You could even come up with a custom font that includes a rendition 
of that character glyph.

However, there are byte combinations which are not valid UTF-8, which is 
a different story. If you're receiving bytes from (say) a file name, they 
may not necessarily make up a valid UTF-8 string. But this is not an 
issue if you are receiving data from something guaranteed to be valid 
UTF-8.


 Don't forget that ls and rm may not use the same encoding you're using.
 So you may not consider it adequate to make the names legal, but you
 may also want they easily typeable in the shell.

 I don't understand. I have no intention of changing Unicode characters.

Of course you do. You even talk below about Unicode characters like * 
and ? not being allowed on NTFS systems.

Perhaps you are thinking that there are a bunch of characters over here 
called plain text ASCII characters, and a *different* bunch of 
characters with funny accents and stuff called Unicode characters. If 
so, then you are labouring under a misapprehension, and you should start 
off by reading this:

http://www.joelonsoftware.com/articles/Unicode.html


then come back with any questions.


 This is not a Unicode issue since (modern) file systems will happily
 accept it. The issue is that certain characters (which are ASCII) are
 not allowed on some file systems:
  \ / : * ?| @ and the NUL character

These are all Unicode characters too. Unicode is a subset of ASCII, so 
anything which is ASCII is also Unicode.


 The first 9 are not allowed on NTFS, the @ is not allowed on ext3cow,
 and NUL and / are not allowed on pretty much any file system. Locale
 settings and encodings aside, these 11 characters will need to be
 escaped.

If you have an artist with control characters in their name, like newline 
or carriage return or NUL, I think it is fair to just drop the control 
characters and then give the artist a thorough thrashing with a halibut.

Does your mapping really need to be guaranteed reversible? If you have an 
artist called JoeBlow, and another artist called Joe\0Blow, and a 
third called Joe\nBlow, does it *really* matter if your application 
conflates them?


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


Re: Making safe file names

2013-05-07 Thread Dave Angel

On 05/07/2013 10:06 PM, Andrew Berg wrote:

On 2013.05.07 20:28, Neil Hodgson wrote:

http://support.microsoft.com/kb/74496
http://en.wikipedia.org/wiki/Nul_%28band%29

I can indeed confirm that at least 'nul' cannot be used as a filename. However, 
I add an extension to the file names to identify them as caches.



Won't help.  NUL.txt is just as reserved as NUL is.  Extensions are 
ignored in this particular piece of historical nonsense.



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


Re: Making safe file names

2013-05-07 Thread Dave Angel

On 05/07/2013 11:40 PM, Steven D'Aprano wrote:


   SNIP

These are all Unicode characters too. Unicode is a subset of ASCII, so
anything which is ASCII is also Unicode.




Typo.  You meant  Unicode is a superset of ASCII.


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


Re: Making safe file names

2013-05-07 Thread Steven D'Aprano
On Wed, 08 May 2013 00:13:20 -0400, Dave Angel wrote:

 On 05/07/2013 11:40 PM, Steven D'Aprano wrote:

SNIP

 These are all Unicode characters too. Unicode is a subset of ASCII, so
 anything which is ASCII is also Unicode.



 Typo.  You meant  Unicode is a superset of ASCII.

Damn. Yes, you're right. I was thinking superset, but my fingers typed 
subset.

Thanks for the correction.


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


Re: Making safe file names

2013-05-07 Thread Andrew Berg
On 2013.05.07 22:40, Steven D'Aprano wrote:
 There aren't any characters outside of UTF-8 :-) UTF-8 covers the entire 
 Unicode range, unlike other encodings like Latin-1 or ASCII.
You are correct. I'm not sure what I was thinking.

 I don't understand. I have no intention of changing Unicode characters.
 
 Of course you do. You even talk below about Unicode characters like * 
 and ? not being allowed on NTFS systems.
I worded that incorrectly. What I meant, of course, is that I intend to 
preserve as many characters as possible and have no need to stay
within ASCII.

 If you have an artist with control characters in their name, like newline 
 or carriage return or NUL, I think it is fair to just drop the control 
 characters and then give the artist a thorough thrashing with a halibut.
While the thrashing with a halibut may be warranted (though I personally would 
use a rubber chicken), conflicts are problematic.

 Does your mapping really need to be guaranteed reversible? If you have an 
 artist called JoeBlow, and another artist called Joe\0Blow, and a 
 third called Joe\nBlow, does it *really* matter if your application 
 conflates them?
Yes and yes. Some artists like to be real cute with their names and make witch 
house artist names look tame in comparison, and some may
choose to use names similar to some very popular artists. I've also seen people 
scrobble fake artists with names that look like real artist
names (using things like a non-breaking space instead of a regular space) with 
different artist pictures in order to confuse and troll
people. If I could remember the user profiles with this, I'd link them. Last.fm 
is a silly place.
As I said before though, I don't think control characters are even allowed in 
artist names (likely for technical reasons).
-- 
CPython 3.3.1 | Windows NT 6.2.9200 / FreeBSD 9.1
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17833] test_gdb broken PPC64 Linux

2013-05-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 63f2941477d3 by Ezio Melotti in branch '2.7':
#17833: add debug output to investigate buildbot failure.
http://hg.python.org/cpython/rev/63f2941477d3

--

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



[issue17833] test_gdb broken PPC64 Linux

2013-05-07 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
Removed message: http://bugs.python.org/msg188621

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



[issue17871] Wrong signature of TextTestRunner's init function

2013-05-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5dd076d441ec by Ezio Melotti in branch '3.3':
#17871: fix unittest.TextTestRunner signature in the docs.  Patch by Yogesh 
Chaudhari.
http://hg.python.org/cpython/rev/5dd076d441ec

New changeset 15ed67602ddf by Ezio Melotti in branch 'default':
#17871: merge with 3.3.
http://hg.python.org/cpython/rev/15ed67602ddf

--
nosy: +python-dev

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



[issue17871] Wrong signature of TextTestRunner's init function

2013-05-07 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!

--
assignee: docs@python - ezio.melotti
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed
versions: +Python 3.3

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



[issue17914] add os.cpu_count()

2013-05-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 I also vote +1 for returning None when the information is unknown.

I still don't like it.
If a function returns a number of CPU, it should either return an
integer = 1, or raise an exception.
None is *not* an integer.

And returning an exception is IMO useles, since the user can't do
anything with anyway, other than fallback to 1.

 Just write os.cpu_count() or 1 if you need 1 when the count is unknown ;-)

os.cpu_count() or 1 is an ugly idiom.

 See also #17444, Trent Nelson wrote an implementation of os.cpu_count().

I don't see exactly what this C implementation brings over the one in
multiprocessing (which is written in Python)?

--

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



[issue17917] use PyModule_AddIntMacro() instead of PyModule_AddIntConstant() when applicable

2013-05-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 PC/_msi.c: Oh, here you should remove cast to int. Example:

 PyModule_AddIntMacro(m, (int)MSIDBOPEN_CREATEDIRECT);

 I'm surprised that the does compile. You may have a 
 (int)MSIDBOPEN_CREATEDIRECT variable :-)

Probably, good catch ;-)
I'll fix that.

 Modules/fcntlmodule.c and Modules/posixmodule.c are using explicit cast to 
 long. I don't know if there is a good reason for such cast.

There's a prototype, so arguments are implicitly converted to long:

PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)

--

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



[issue17914] add os.cpu_count()

2013-05-07 Thread STINNER Victor

STINNER Victor added the comment:

 I don't see exactly what this C implementation brings over the one
 in multiprocessing (which is written in Python)?

multiprocessing.cpu_count() creates a subprocess on BSD and Darwin to get the 
number of CPU. Calling sysctl() or sysctlnametomib() should be faster and use 
less memory.

On Windows, GetSystemInfo() is called instead of reading an environment 
variable. I suppose that this function is more reliable.

Trent's os.cpu_count() returns -1 if the count cannot be read, 
multiprocessing.cpu_count() raises NotImplementedError.

--

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



[issue17914] add os.cpu_count()

2013-05-07 Thread Charles-François Natali

Charles-François Natali added the comment:

Fair enough, I guess we should use it then.

We just have to agree on the value to return when the number of CPUs
can't be determined ;-)

--

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



[issue17914] add os.cpu_count()

2013-05-07 Thread Ezio Melotti

Ezio Melotti added the comment:

Returning None sounds reasonable to me.
Raising an exception pretty much means that the function should always be 
called in a try/except (unless you are sure that the code is running on an OS 
that knows the number of CPUs).  Returning -1 is not very Pythonic, and between 
0 and None I prefer the latter, since it's IMHO a clearer indication that the 
value couldn't be determined.

--
nosy: +ezio.melotti

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Jan Safranek

New submission from Jan Safranek:

I have Python 2.7.4 running on Fedora Rawhide and I get segmentation fault with 
following backtrace:

#0  0x7f73f69ca5f1 in clear_weakref (self=0x7f73ff515c00) at 
Objects/weakrefobject.c:56
#1  weakref_dealloc (self=0x7f73ff515c00) at Objects/weakrefobject.c:106
#2  0x7f73f698ea27 in PyList_SetItem (op=optimized out, i=optimized 
out, newitem=optimized out) at Objects/listobject.c:218
#3  0x7f73f69ba9db in add_subclass (type=type@entry=0x7f73e00456b0, 
base=optimized out) at Objects/typeobject.c:4155
#4  0x7f73f69c440e in PyType_Ready (type=type@entry=0x7f73e00456b0) at 
Objects/typeobject.c:4120
#5  0x7f73f69c6d4b in type_new (metatype=optimized out, args=optimized 
out, kwds=optimized out) at Objects/typeobject.c:2467
#6  0x7f73f69be7d3 in type_call (type=0x7f73f6cdad00 PyType_Type, 
args=0x7f73f61e1550, kwds=0x0) at Objects/typeobject.c:725
#7  0x7f73f6954833 in PyObject_Call (func=func@entry=0x7f73f6cdad00 
PyType_Type, arg=arg@entry=0x7f73f61e1550, kw=kw@entry=0x0) at 
Objects/abstract.c:2529
#8  0x7f73f69553c9 in PyObject_CallFunctionObjArgs 
(callable=callable@entry=0x7f73f6cdad00 PyType_Type) at 
Objects/abstract.c:2760
#9  0x7f73f6a06bf3 in build_class (name=optimized out, 
bases=0x7f73f61e3910, methods=0x7f73e0045590) at Python/ceval.c:4632
#10 PyEval_EvalFrameEx (f=f@entry=0x7f73e0043a40, throwflag=throwflag@entry=0) 
at Python/ceval.c:1928
#11 0x7f73f6a0b46d in PyEval_EvalCodeEx (co=co@entry=0x7f73f61f50b0, 
globals=globals@entry=0x7f73e003bf00, locals=locals@entry=0x7f73e003bf00, 
args=args@entry=0x0, argcount=argcount@entry=0, 
kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0, 
defcount=defcount@entry=0, closure=closure@entry=0x0) at Python/ceval.c:3253
#12 0x7f73f6a0b5a2 in PyEval_EvalCode (co=co@entry=0x7f73f61f50b0, 
globals=globals@entry=0x7f73e003bf00, locals=locals@entry=0x7f73e003bf00) at 
Python/ceval.c:667
#13 0x7f73f6a22cfc in PyImport_ExecCodeModuleEx 
(name=name@entry=0x7f73e003d760 warnings, co=co@entry=0x7f73f61f50b0, 
pathname=pathname@entry=0x7f73e003ac90 
/usr/local/lib/python2.7/warnings.pyc) at Python/import.c:709
#14 0x7f73f6a2305e in load_source_module (name=0x7f73e003d760 warnings, 
pathname=0x7f73e003ac90 /usr/local/lib/python2.7/warnings.pyc, fp=optimized 
out) at Python/import.c:1099
#15 0x7f73f6a23f59 in import_submodule (mod=mod@entry=0x7f73f6cd2ec0 
_Py_NoneStruct, subname=subname@entry=0x7f73e003d760 warnings, 
fullname=fullname@entry=0x7f73e003d760 warnings)
at Python/import.c:2700
#16 0x7f73f6a24b93 in load_next (p_buflen=synthetic pointer, 
buf=0x7f73e003d760 warnings, p_name=synthetic pointer, 
altmod=0x7f73f6cd2ec0 _Py_NoneStruct, 
mod=0x7f73f6cd2ec0 _Py_NoneStruct) at Python/import.c:2515
#17 import_module_level (locals=optimized out, level=optimized out, 
fromlist=0x7f73f6cd2ec0 _Py_NoneStruct, globals=optimized out, name=0x0) at 
Python/import.c:2224
#18 PyImport_ImportModuleLevel (name=0x7f73ff54fbf4 warnings, 
globals=optimized out, locals=optimized out, fromlist=0x7f73f6cd2ec0 
_Py_NoneStruct, level=optimized out)
at Python/import.c:2288
#19 0x7f73f6a033af in builtin___import__ (self=optimized out, 
args=optimized out, kwds=optimized out) at Python/bltinmodule.c:49
...
#61 0x7f73f6a37dbc in initsite () at Python/pythonrun.c:721
#62 Py_InitializeEx (install_sigs=1) at Python/pythonrun.c:265

(full back trace is attached, it's quite long).

(gdb) py-bt
#10 Frame 0x7f4bf8043df0, for file /usr/lib64/python2.7/warnings.py, line 281, 
in module ()
class WarningMessage(object):
#23 Frame 0x7f4bf803d300, for file /usr/lib64/python2.7/posixpath.py, line 17, 
in module ()
import warnings
#36 Frame 0x7f4bf8024fc0, for file /usr/lib64/python2.7/os.py, line 49, in 
module ()
import posixpath as path
#49 Frame 0x7f4bf801c520, for file /usr/lib64/python2.7/site.py, line 62, in 
module ()
import os

I get the same crash with vanilla Python 2.7.4 without Fedora patches. Python 
2.7.3 works well and doesn't crash.

--
components: Interpreter Core
files: full-bt.txt
messages: 188629
nosy: jsafrane
priority: normal
severity: normal
status: open
title: Crash in clear_weakref
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file30161/full-bt.txt

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Jan Safranek

Jan Safranek added the comment:

I can reproduce the crash in very unusual setup:
1. OpenPegasus (http://www.openpegasus.org/), for this bug we may consider it 
just a network daemon, listening on TCP port. When a request comes, it is 
eventually processed by a provider (= something like plugin).
2. cmpi-bindings ([1], [2]), which allows to write these plugins in Python
+ some other python modules, but IMHO not relevant (e.g. pywbem [3])

1: https://github.com/kkaempf/cmpi-bindings
2: http://sourceforge.net/apps/mediawiki/pywbem/index.php?title=Provider_Home
3: http://sourceforge.net/apps/mediawiki/pywbem/index.php?title=Main_Page

Now, if the Pegasus daemon gets a request, it calls cmpi-bindings, which 
creates embedded Python [4], loads the python plugin, and processes the 
request. If the plugin is idle for 15 minutes, it is unloaded by Pegasus (= 
the embedded Python is destroyed). So far everything works like charm. But, 
when new request arrives *after* the unload, Pegaasus calls cmpi-bindings 
again, which tries to create the embedded Python for second time and here I get 
the crash.

[4]: python initialization/shutdown: 
https://github.com/kkaempf/cmpi-bindings/blob/master/src/target_python.c, 
TargetInitialize() and TargetCleanup(), some marcos are generated by swig from 
https://github.com/kkaempf/cmpi-bindings/blob/master/swig/cmpi.i

I haven't been able to reproduce the crash with simpler setup (and I have 
tried, believe me). It is also possible that the Python initialization/shutdown 
in cmpi-bindings is wrong, but I am not able to find any bug here.

--

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Jan Safranek

Jan Safranek added the comment:

Bisecting Python mercurial repository, I found the patch which causes the crash:

changeset:   80762:7e771f0363e2
branch:  2.7
parent:  80758:29627bd5b333
user:Antoine Pitrou solip...@pitrou.net
date:Sat Dec 08 21:15:26 2012 +0100
summary: Issue #16602: When a weakref's target was part of a long 
deallocation chain, the object could remain reachable through its weakref even 
though its refcount had dropped to zero.

If I revert the patch in Python 2.7.4, my setup works fine, without any crash.

--

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +benjamin.peterson, pitrou

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



[issue17714] str.encode('base64') add trailing new line character. It is not documented.

2013-05-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8b764c3521fa by Ezio Melotti in branch '2.7':
#17714: document that the base64 codec adds a trailing newline.
http://hg.python.org/cpython/rev/8b764c3521fa

--
nosy: +python-dev

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



[issue17714] str.encode('base64') add trailing new line character. It is not documented.

2013-05-07 Thread Ezio Melotti

Ezio Melotti added the comment:

The str.encode() doc is the wrong place where to document this, since the '\n' 
is added only for the base64 codec.  I added a note about this in the codecs 
docs[0].

[0]: http://docs.python.org/2/library/codecs.html#standard-encodings

--
assignee: docs@python - ezio.melotti
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue17714] str.encode('base64') add trailing new line character. It is not documented.

2013-05-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cbb23e40e0d7 by Ezio Melotti in branch '3.3':
#17714: document that the base64 codec adds a trailing newline.
http://hg.python.org/cpython/rev/cbb23e40e0d7

New changeset b3e1be1493a5 by Ezio Melotti in branch 'default':
#17714: merge with 3.3.
http://hg.python.org/cpython/rev/b3e1be1493a5

--

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



[issue13515] Consistent documentation practices for security concerns and considerations

2013-05-07 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage: patch review - commit review

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



[issue17923] test glob with trailing slash fail

2013-05-07 Thread Delhallt

New submission from Delhallt:

test_glob's trailing_slash tests fails on AIX 6.1/Python 2.7.4:

The code section for no_magic/slash case seems to be the issue.

Attached patch resolves issue.

FAIL: test_glob_directory_with_trailing_slash (test.test_glob.GlobTests)
--
Traceback (most recent call last):
  File /opt/freeware/lib/python2.7/test/test_glob.py, line 120, in 
test_glob_directory_with_trailing_slash
self.assertEqual(res, [])
AssertionError: Lists differ: ['@test_7602318_tmp_dir/ZZZ/'] != []

First list contains 1 additional elements.
First extra element 0:
@test_7602318_tmp_dir/ZZZ/

- ['@test_7602318_tmp_dir/ZZZ/']
+ []

==
FAIL: test_glob_unicode_directory_with_trailing_slash (test.test_glob.GlobTests)
--
Traceback (most recent call last):
  File /opt/freeware/lib/python2.7/test/test_glob.py, line 137, in 
test_glob_unicode_directory_with_trailing_slash
self.assertEqual(res, [])
AssertionError: Lists differ: [u'@test_7602318_tmp_dir/ZZZ/'... != []

First list contains 1 additional elements.
First extra element 0:
@test_7602318_tmp_dir/ZZZ/

- [u'@test_7602318_tmp_dir/ZZZ/']
+ []

--
components: Tests
files: Python-2.7.4-glob.patch
keywords: patch
messages: 188635
nosy: delhallt
priority: normal
severity: normal
status: open
title: test glob with trailing slash fail
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file30162/Python-2.7.4-glob.patch

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hi Jan,

First, have you seen the following message on that bug report:
http://bugs.python.org/issue16602#msg177180

Second, I would suggest you build a debug build of Python (./configure 
--with-pydebug), it should give you more information in the stack trace, and 
allow you to debug using gdb.

--

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



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2013-05-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I checked in the missing file after I woke up this morning. Maybe I'll learn to 
use hg import instead of patch some day...

Sorry for the noise.

--
status: open - closed

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



[issue17912] thread states should use a doubly-linked list

2013-05-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 There are a couple other places, IIRC. That said, I'm not sure what the
 point is, since a linked list is quite a simple structure anyway?

Well, it was just to avoid code duplication, and gain a nice iteration macro ;-)

Anyway, I'll submit a patch later today.

--

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



[issue17922] Crash in clear_weakref

2013-05-07 Thread Jan Safranek

Jan Safranek added the comment:

 First, have you seen the following message on that bug report:
 http://bugs.python.org/issue16602#msg177180

I'm reading it now... I searched for PyWeakref_GET_OBJECT in cmpi-bindings and 
both occurrences generated by SWIG and both look safe.
Is it hidden/wrapped by any other macro?

Sorry, I don't know much about python internals and extension development, I'm 
not author of cmpi-bindings.

And I'm attaching stack trace with --with-pydebug. Debugging with gdb is quite 
a problem, I have gdb linked with distribution Python 2.7.4 and it doesn't 
cooperate with my custom built python, which I have in LD_LIBRARY_PATH (so 
Pegasus gets the right one when loading providers).

--
Added file: http://bugs.python.org/file30163/full-bt.txt

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



[issue17915] Encoding error with sax and codecs

2013-05-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

It is not working fine on Python 3.3.0.

 with codecs.open('/tmp/test.txt', 'w', encoding='iso-8859-1') as f:
... xml = XMLGenerator(f, encoding='iso-8859-1')
... xml.startDocument()
... xml.startElement('root', {'attr': u'\u20ac'})
... xml.endElement('root')
... xml.endDocument()
... 
Traceback (most recent call last):
  File stdin, line 4, in module
  File /home/serhiy/py/cpython-3.3.0/Lib/xml/sax/saxutils.py, line 141, in 
startElement
self._write(' %s=%s' % (name, quoteattr(value)))
  File /home/serhiy/py/cpython-3.3.0/Lib/xml/sax/saxutils.py, line 96, in 
_write
self._out.write(text)
  File /home/serhiy/py/cpython-3.3.0/Lib/codecs.py, line 699, in write
return self.writer.write(data)
  File /home/serhiy/py/cpython-3.3.0/Lib/codecs.py, line 355, in write
data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'latin-1' codec can't encode character '\u20ac' in position 
7: ordinal not in range(256)

And shouldn't. On Python 2 XMLGenerator works only with binary files and 
works with text files only due implicit str-unicode converting. On Python 3 
working with binary files was broken. Issue1470548 restores working with binary 
file (for which only XMLGenerator can work correctly), but for backward 
compatibility accepting of text files was left. The problem is that there no 
trustworthy method to determine whenever a file-like object is binary or text.

Accepting of text streams in XMLGenerator should be deprecated in future 
versions.

--

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



[issue17924] Deprecate stat.S_IF* integer constants

2013-05-07 Thread Christian Heimes

New submission from Christian Heimes:

Related to #11016
I like to deprecate the S_IF* constants in favor of the S_IS*() functions.

rationals:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html

No new S_IFMT symbolic names for the file type values of mode_t will be defined 
by POSIX.1-2008; if new file types are required, they will only be testable 
through S_ISxx() or S_TYPEISxxx() macros instead.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 188641
nosy: christian.heimes, docs@python
priority: normal
severity: normal
status: open
title: Deprecate stat.S_IF* integer constants
type: behavior
versions: Python 3.4

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



[issue17915] Encoding error with sax and codecs

2013-05-07 Thread STINNER Victor

STINNER Victor added the comment:

 Accepting of text streams in XMLGenerator should be deprecated in future 
 versions.

I agree that the following pattern is strange:

with codecs.open('/tmp/test.txt', 'w', encoding='iso-8859-1') as f:
   xml = XMLGenerator(f, encoding='iso-8859-1')

Why would I specify a codec twice? What happens if I specify two
different codecs?

with codecs.open('/tmp/test.txt', 'w', encoding='utf-8') as f:
   xml = XMLGenerator(f, encoding='iso-8859-1')

It may be simpler (and safer?) to reject text files. If you cannot
detect that f is a text file, just make it explicit in the
documentation that f must be a binary file.

2013/5/7 Serhiy Storchaka rep...@bugs.python.org:

 Serhiy Storchaka added the comment:

 It is not working fine on Python 3.3.0.

 with codecs.open('/tmp/test.txt', 'w', encoding='iso-8859-1') as f:
 ... xml = XMLGenerator(f, encoding='iso-8859-1')
 ... xml.startDocument()
 ... xml.startElement('root', {'attr': u'\u20ac'})
 ... xml.endElement('root')
 ... xml.endDocument()
 ...
 Traceback (most recent call last):
   File stdin, line 4, in module
   File /home/serhiy/py/cpython-3.3.0/Lib/xml/sax/saxutils.py, line 141, in 
 startElement
 self._write(' %s=%s' % (name, quoteattr(value)))
   File /home/serhiy/py/cpython-3.3.0/Lib/xml/sax/saxutils.py, line 96, in 
 _write
 self._out.write(text)
   File /home/serhiy/py/cpython-3.3.0/Lib/codecs.py, line 699, in write
 return self.writer.write(data)
   File /home/serhiy/py/cpython-3.3.0/Lib/codecs.py, line 355, in write
 data, consumed = self.encode(object, self.errors)
 UnicodeEncodeError: 'latin-1' codec can't encode character '\u20ac' in 
 position 7: ordinal not in range(256)

 And shouldn't. On Python 2 XMLGenerator works only with binary files and 
 works with text files only due implicit str-unicode converting. On Python 
 3 working with binary files was broken. Issue1470548 restores working with 
 binary file (for which only XMLGenerator can work correctly), but for 
 backward compatibility accepting of text files was left. The problem is that 
 there no trustworthy method to determine whenever a file-like object is 
 binary or text.

 Accepting of text streams in XMLGenerator should be deprecated in future 
 versions.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue17915
 ___

--

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



  1   2   >