[RELEASE] six 1.7.0

2014-06-11 Thread Benjamin Peterson
I'm pleased to announce the immediate availability of six 1.7.0. six is
a small Python 2/3 compatibility library. The most interesting change in
this release is yet another implementation by Anselm Kruis of six.moves
using a sys.meta_path hook. Hopefully, this will cause less issues with
the various tools that iterate blindly over sys.modules.

Downloads are on PyPI:
https://pypi.python.org/pypi/six

Documentation is available on Read the Docs:
http://six.readthedocs.org/

Here is the changelog for 1.7.0:
- Pull request #30: Implement six.moves with a PEP 302 meta path hook.

- Pull request #32: Add six.wraps, which is like functools.wraps but
always sets
  the __wrapped__ attribute.

- Pull request #35: Improve add_metaclass, so that it doesn't end up
inserting
  another class into the hierarchy.

- Pull request #34: Add import mappings for dummy_thread.

- Pull request #33: Add import mappings for UserDict and UserList.

- Pull request #31: Select the implementations of dictionary iterator
routines
  at import time for a 20% speed boost.
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Fwd: ANN: Intro+Intermediate Python, San Francisco, Jul 30-31, Aug 1

2014-06-11 Thread wesley chun
Greetings!

I'll be offering another hardcore Python course this summer near the
San Francisco airport. If you're somewhat new to or have some Python
experience under your belt already but want to fill-in the holes,
this course is for you. Why take a real course when you can learn
Python online or by reading books?

Well, my goal isn't to teach Python syntax, which you can from any
teacher, live or online, or from giant books. My job is to create
great Python developers and removing the roadblocks that impede
your path to getting there. This intensive course is based on my
 Core Python (http://corepython.com) books and is made up of 3
full days complete with lectures and several hands-on coding labs
per day. t's also a great excuse to coming to beautiful Northern
California for a summer vacation!

Groups and development teams are welcome as well as individuals. I do
more private gigs and fewer of these public courses lately, so please
come join if you can... my next public intro/intermediate course may
not be for awhile, so I'm hoping to meet some of you this time around!

Sign up soon... there's a special earlybird rate for the rest of this
month before going up to the regular rate after that. More details and
registration at http://cyberwebconsulting.com as well as in the ad:
http://goo.gl/pyJseQ

I'm no fan of spam, so I'll only send out one last reminder as the
date gets closer... say around the end of June.

Cheers,
-- Wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
A computer never does what you want... only what you tell it.
+wesley chun http://google.com/+WesleyChun : wescpy at gmail :
@wescpyhttp://twitter.com/wescpy
Python training  consulting : http://CyberwebConsulting.com
Core Python books : http://CorePython.com
Python blog: http://wescpy.blogspot.com
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Course: HPC with Python, Leipzig, Germany, June 16 - 20, 2014

2014-06-11 Thread Mike Müller
High-Performance Computing with Python
==

Date: June 16 - 20, 2014
Location: Leipzig, Germany
Language: English
Link: http://www.python-academy.com/courses/python_hpc.html
Instructor: Dr. Mike Müller and Dr. Stefan Behnel

Python programs can be fast, if done right. This five day-course
provides a good opportunity to dive into the world of high-performance
computing with Python. You will get an overview what techniques and
tools are useful for writing fast Python programs and learn how to use
them.

The first three days are taught by Mike Müller. He has ten years
of Python training experience and has introduced thousands of
programmers, scientists and engineers to the world of Python.

The following two days are dedicated to Cython and are taught by
Stefan Behnel. He is a Cython core developer and can provide deep
insight how to use Cython to achieve C speed in Python.

The course is hands-on with lots of exercises and covers
these topics:


Day 1: Profiling, Algorithms and Parallel Computation
*

* Profiling
* Algorithms
* Multiprocessing
* Pyro4

Day 2: Beyond Pure Python
*

* Numba
* PyPy
* f2py

Day 3 NumPy for Fast Computations
*

* Introduction to NumPy
* Advanced NumPy
* NumPy and C
* Numexpr
* Algorithms and SciPy

Day 4: Cython for Speed
***

* My first Cython extension
* Speeding up Python code with Cython
* Interfacing with external C code

Day 5 Cython and NumPy
**

* Use of Python's buffer interface from Cython code
* Implementing fast Cython loops over NumPy arrays
*Use of parallel loops to make use of multiple processing cores



---
Our next courses:

09.06.-11.06.2014 (Krakow) Advanced Python (Polish)
13.06.2014(Leipzig) SQLAlchemy Course (English)
16.06.-20.06.2014 (Leipzig) High-Performance Computing with Python (English)
23.06.-25.06.2014 (Krakow) Advanced Python (Polish)
23.06.-25.06.2014 (Krakow) Introduction to Django (Polish)
29.06.-02.07.2014 (Leipzig) Python für Nichtprogrammierer (German)
30.06.-02.07.2014 (Leipzig) Python für Programmierer (German)
30.06.-02.07.2014 (Krakow) Advanced Django (Polish)
03.07.-05.07.2014 (Leipzig) Python für Wissenschaftler und Ingenieure (German)
07.07.-09.07.2014 (Krakow) Introduction to Django (Polish)
14.07.-16.07.2014 (Warsaw) Advanced Python (Polish)
21.07.-24.07.2014 (Krakow) Python for Non-Programmers (Polish)
28.07.-30.07.2014 (Berlin) Advanced Python (English)
18.08.-20.08.2014 (Krakow) Python for Programmers (Polish)
25.08.-27.08.2014 (Warsaw) Advanced Python (Polish)
15.09.-17.09.2014 (Warsaw) Advanced Django (Polish)
16.09.-17.09.2014 (Warsaw) Introduction to Django (Polish)
19.09.2014(Herentals) SQLAlchemy Course (English)
20.09.2014(Herentals) Camelot Course (English)
21.09.-24.09.2014 (Leipzig) Python for Non-Programmers (English)
22.09.-24.09.2014 (Leipzig) Python for Programmers (English)
25.09.-27.09.2014 (Leipzig) Python for Scientists and Engineers (English)
29.09.2014(Leipzig) SQLAlchemy Course (English)
30.09.2014(Leipzig) Camelot Course (English)
09.10.-10.10.2014 (Dublin) Advanced Python (English)
13.10.-16.10.2014 (Warsaw) Python for Non-Programmers (Polish)
16.10.-17.10.2014 (Leipzig) Cython in Depth (English)
31.10.2014(Herentals) SQLAlchemy Course (English)
03.11.-05.11.2014 (Herentals) Python for Programmers (English)
03.11.-05.11.2014 (Warsaw) Python for Programmers (Polish)
17.11.-19.11.2014 (Warsaw) Advanced Django (Polish)
24.11.-26.11.2014 (Freiburg) Professional Testing with Python (English)
24.11.-26.11.2014 (Krakow) Advanced Python (Polish)
08.12.-10.12.2014 (Krakow) Introduction to Django (Polish)

Berlin - Germany
Dublin - Ireland
Freiburg - Germany
Herentals - Belgium
Krakow - Poland
Leipzig - Germany
Warsaw - Poland



More information at http://www.python-academy.com

Follow us on Twitter: @pyacademy

--
Dr.-Ing. Mike Müller, M.Sc.
- Geschäftsführer (CEO) -

Python Academy GmbH  Co. KG
Zur Schule 20
04158 Leipzig
Germany

Sitz (Registered Office): Leipzig
Amtsgericht (Registration Court): Leipzig
HRA (Commercial Register No.): 16004

Persönlich haftende Gesellschafterin
(Personally Liable Partner):
py solutions GmbH
Sitz (Registered Office): Leipzig
Amtsgericht (Registration Court): Leipzig
HRB (Commercial Register No.): 25781
Geschäftsführer (Managing Director): Dr. Mike Müller

Tel: +49 341 260 3370
Fax: +49 341 520 4495
E-Mail: mmuel...@python-academy.de
WWW: http://www.python-academy.com







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

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


mimedecode.py version 2.6.0

2014-06-11 Thread Oleg Broytman
Hello!

mimedecode.py

WHAT IS IT

   Mail users, especially in non-English countries, often find that mail
messages arrived in different formats, with different content types, in
different encodings and charsets. Usually this is good because it allows us to
use appropriate format/encoding/whatever. Sometimes, though, some unification
is desirable. For example, one may want to put mail messages into an archive,
make HTML indices, run search indexer, etc. In such situations converting
messages to text in one character set and skipping some binary attachments is
much desirable.

   Here is the solution - mimedecode.py.

   This is a program to decode MIME messages. The program expects one input
file (either on command line or on stdin) which is treated as an RFC822
message, and decodes to stdout or an output file. If the file is not an RFC822
message it is just copied to the output one-to-one. If the file is a simple
RFC822 message it is decoded as one part. If it is a MIME message with multiple
parts (attachments) all parts are decoded. Decoding can be controlled by
command-line options.


Version 2.6.0 (2014-06-08)

   Make options -e/-i to work with multipart subparts.

   Add option -I to completely ignore a part - no headers, no body,
   no warning.

   Open all output files in binary mode. Output os.linesep instead of '\n'.

   Test --save-headers|body|message masks one after another to allow
   saving a message or a subpart to more than one file.

WHAT'S NEW in version 2.5.0 (2014-03-18)

   Add option --set-header=header:value to set header's value (only at the top
level).

   Add option --set-param=header:param=value to set header parameter's value
(only at the top level). The header must exist.

   Add option -B to skip content-transfer-decoding binary attachments.

   Add options --save-headers, --save-body and --save-message to save decoded
headers/bodies/messages to files.

   Add option -O to set the destination directory for output files.

   Fix a minor bug: if a multipart message (or a subpart) lacks any textual
content - avoid putting an excessive newline.


WHERE TO GET
   Home page: http://phdru.name/Software/Python/#mimedecode
git clone http://git.phdru.name/mimedecode.git
git clone  git://git.phdru.name/mimedecode.git

   Requires: Python 2.2.2+, m_lib 2.0+.

   Recommends: configured mailcap database.

   Documentation: http://phdru.name/Software/Python/mimedecode.html
  (also included in the package in html, man and txt formats).

AUTHOR
   Oleg Broytman p...@phdru.name

COPYRIGHT
   Copyright (C) 2001-2014 PhiloSoft Design.

LICENSE
   GPL

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: eGenix pyOpenSSL Distribution 0.13.3.1.0.1.8

2014-06-11 Thread eGenix Team: M.-A. Lemburg

ANNOUNCING

   eGenix.com pyOpenSSL Distribution

 Version 0.13.3.1.0.1.8


 An easy-to-install and easy-to-use distribution
 of the pyOpenSSL Python interface for OpenSSL -
available for Windows, Mac OS X and Unix platforms


This announcement is also available on our web-site for online reading:
http://www.egenix.com/company/news/eGenix-pyOpenSSL-Distribution-0.13.3.1.0.1.8.html


INTRODUCTION

The eGenix.com pyOpenSSL Distribution includes everything you need to
get started with SSL in Python.

It comes with an easy-to-use installer that includes the most recent
OpenSSL library versions in pre-compiled form, making your application
independent of OS provided OpenSSL libraries:

http://www.egenix.com/products/python/pyOpenSSL/

pyOpenSSL is an open-source Python add-on that allows writing SSL/TLS-
aware network applications as well as certificate management tools:

https://launchpad.net/pyopenssl/

OpenSSL is an open-source implementation of the SSL/TLS protocol:

http://www.openssl.org/


NEWS

This new release of the eGenix.com pyOpenSSL Distribution updates the
included OpenSSL version to the latest OpenSSL 1.0.1h version and adds
a few more context options:

New in OpenSSL
--

 * Updated included OpenSSL libraries from OpenSSL to 1.0.1h. See
   http://www.openssl.org/news/secadv_20140605.txt for a complete list
   of changes, most important:

   - CVE-2014-0224: An attacker can force the use of weak keying
 material in OpenSSL SSL/TLS clients and servers. This can be
 exploited by a Man-in-the-middle (MITM) attack where the attacker
 can decrypt and modify traffic from the attacked client and
 server.

   - CVE-2014-0221: By sending an invalid DTLS handshake to an OpenSSL
 DTLS client the code can be made to recurse eventually crashing
 in a DoS attack. Only applications using OpenSSL as a DTLS client
 are affected.

   - CVE-2014-3470: OpenSSL TLS clients enabling anonymous ECDH
 ciphersuites are subject to a DoS attack.

New in pyOpenSSL


 * Added the following new options for context.set_options():
   OP_TLSEXT_PADDING, OP_SAFARI_ECDHE_ECDSA_BUG,
   OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION,
   OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION.

 * Documented all supported context.set_options() options (to the
   extent possible using the OpenSSL documentation itself).

pyOpenSSL / OpenSSL Binaries Included
-

In addition to providing sources, we make binaries available that
include both pyOpenSSL and the necessary OpenSSL libraries for all
supported platforms: Windows x86 and x64, Linux x86 and x64, Mac OS X
PPC, x86 and x64.

We've also added egg-file distribution versions of our eGenix.com
pyOpenSSL Distribution for Windows, Linux and Mac OS X to the
available download options. These make setups using e.g. zc.buildout
and other egg-file based installers a lot easier.


DOWNLOADS

The download archives and instructions for installing the package can
be found at:

http://www.egenix.com/products/python/pyOpenSSL/


UPGRADING

Before installing this version of pyOpenSSL, please make sure that
you uninstall any previously installed pyOpenSSL version. Otherwise,
you could end up not using the included OpenSSL libs.

___
SUPPORT

Commercial support for these packages is available from eGenix.com.
Please see

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

for details about our support offerings.


MORE INFORMATION

For more information about the eGenix pyOpenSSL Distribution, licensing
and download instructions, please visit our web-site or write to
sa...@egenix.com.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jun 09 2014)
 Python Projects, Consulting and Support ...   http://www.egenix.com/
 mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/

2014-05-28: Released mxODBC.Connect 2.1.0 ... http://egenix.com/go56
2014-07-02: Python Meeting Duesseldorf ... 23 days to go

: Try our mxODBC.Connect Python Database Interface for free ! ::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at 

ANN: SIMPLE 1.1

2014-06-11 Thread Mok-Kong Shen


SIMPLE is a versatile dynamic modern variation of classical encryption
scheme with authentication.

http://s13.zetaboards.com/Crypto/topic/7201673/1/

As its name implies, it is fairly simple in program logic (and fairly
small in code size as well), albeit without compromising any high
security requirements that are to be satisfied.

For constructive critiques and comments I should be very grateful.

M. K. Shen
--
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: How do I get zlib installed on a python2.7 alt install?

2014-06-11 Thread dieter
Nzyme11 akcorr...@gmail.com writes:

 Installed python 2.7.7 on SLES from source to /opt/python2.7.

Usually, an extension module is build automatically during the Python
generation (from source) when its preconditions are met. This usually means,
that the relevant development packages are installed. In your case,
this would mean the zlib development package.

I expect (but did not verify) that a Python rebuild+reinstall
after the zlib development package installation will make
Python zlib module available (in this Python installation).

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


Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing

Rustom Mody wrote:

JFTR: Information processing and (physics) energy are about as convertible
as say: Is a kilogram smaller/greater than a mile?


Actually, that's not true. There is a fundamental
thermodynamic limit on the minimum energy needed to
flip a bit from one state to the other, so in that
sense there's a relationship between watts and
bits per second.

We're nowhere near reaching that limit with
current technology, though. In principle, our
CPUs could be a lot more energy-efficient.

(That doesn't mean they would convert a smaller
proportion of their energy input into heat. It
means they would need less energy input in the
first place).

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


asyncio - how to stop loop?

2014-06-11 Thread Frank Millman
Hi all

I have a 'start.py' script that kicks off my program by starting a number of 
services.

For now, I stop it by allowing the user to press enter, after which I 
close down the services and stop the program. (For production I imagine it 
would be better to run it in the background and send it some kind of signal 
to terminate, but for testing this suffices.)

As one of the services is a 'listening' loop, which would normally prevent 
access to the keyboard, I start it in a separate thread. For example, when I 
was using cherrypy as the server, I had -

server = cherrypy.wsgiserver.CherryPyWSGIServer((host, port), 
dispatcher)
threading.Thread(target=server.start).start()
input('Press enter to stop')
server.stop()

Now I am playing with asyncio, but I cannot get it to behave the same.

Here are my attempts. I use python 3.4.1, and I tested on Windows and 
Linux - the results are different on each platform.

First attempt - same as before

loop = asyncio.get_event_loop()
threading.Thread(target=loop.run_forever).start()
input('Press enter to stop')
loop.stop()
loop.close()

Windows traceback -

Exception in thread Thread-1:
Traceback (most recent call last):
  File C:\Python34\lib\threading.py, line 920, in _bootstrap_inner
self.run()
  File C:\Python34\lib\threading.py, line 868, in run
self._target(*self._args, **self._kwargs)
  File C:\Python34\lib\asyncio\base_events.py, line 184, in run_forever
self._run_once()
  File C:\Python34\lib\asyncio\base_events.py, line 795, in _run_once
event_list = self._selector.select(timeout)
AttributeError: 'NoneType' object has no attribute 'select'

With Linux, it does not terminate. If I press Ctrl_C, I get this traceback 
(hope there are no typos) -

Traceback (most recent call last):
  File /usr/local/lib/python3.4/threading.py, line 1294, in _shutdown
t.join()
  File /usr/local/lib/python3.4/threading.py, line 1060, in join
self._wait_for_tstate_lock()
  File /usr/local/lib/python3.4/threading.py, line 1076, in 
_wait_for_tstate_lock
elif lock.acquire(block, timeout):
KeyboardInterrupt


Second attempt - move the keyboard input to a separate thread

def stop_loop():
input('Press enter to stop')
loop.stop()
loop.close()

loop = asyncio.get_event_loop()
threading.Thread(target=stop_loop).start()
loop.run_forever()

With Windows, it works - the program closes cleanly.

With Linux, it does not terminate. If I press Ctrl_C, I get this traceback 
(hope there are no typos) -

Traceback (most recent call last):
  File test_async.py, line 20, in module
loop.run_forever()
  File /usr/local/lib/python3.4/asyncio.base_events.py, line 184, in 
run_forever
self._run_once()
  File /usr/local/lib/python3.4/asyncio.base_events.py, line 795, in 
_run_once
event_list = self._selector.select(timeout)
  File /usr/local/lib/python3.4/asyncio.selectors.py, line 424, in select
fd_event_list = self._epoll.poll(timeout, max_cv)
KeyboardInterrupt


Third attempt - get the loop to close itself (cannot use in practice, but 
see what happens)

def stop_loop():
loop.stop()
loop.close()

loop = asyncio.get_event_loop()
loop.call_later(2, stop_loop)
loop.run_forever()

Both platforms show the same traceback, after two seconds -

Traceback (most recent call last):
  File C:\Documents and Settings\frank\aib\aib_async\test_async.py, line 
29, in module
loop.run_forever()
  File C:\Python34\lib\asyncio\base_events.py, line 184, in run_forever
self._run_once()
  File C:\Python34\lib\asyncio\base_events.py, line 795, in _run_once
event_list = self._selector.select(timeout)
AttributeError: 'NoneType' object has no attribute 'select'

Can anyone suggest a way to get the loop to stop cleanly?

Thanks

Frank Millman



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


Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing

Steven D'Aprano wrote:
Everything *eventually* gets converted to heat, but not immediately. 
There's a big difference between a car that gets 100 miles to the gallon, 
and one that gets 1 mile to the gallon.


With a car, the engine converts some of its energy to
kinetic energy, which is subsequently dissipated as heat,
so it makes sense to talk about the ratio of kinetic
energy produced to energy wasted directly as heat.

But when you flip a bit, there's no intermediate form
of energy -- the bit changes state, and heat is produced.
So all of the heat is waste heat.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing

Chris Angelico wrote:

So, let me get this straight. A CPU has to have a fan, but a car
engine doesn't, because the car's moving at a hundred kays an hour. I
have a suspicion the CPU fan moves air a bit slower than that.


If the car were *always* moving at 100km/h, it probably
wouldn't need a fan.

In practice, all cars do have fans (even the ones that
aren't air-cooled), for the occasions when they're not
moving that fast.

(BTW, so-called water-cooled engines are really air-cooled
too, just not by air flowing directly over the engine
block. (Although marine engines may be an exception.))

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-11 Thread alister
On Wed, 11 Jun 2014 08:29:06 +1000, Tim Delaney wrote:

 On 11 June 2014 05:43, alister alister.nospam.w...@ntlworld.com wrote:
 
 
 Your error reports always seem to resolve around benchmarks despite
 speed not being one of Pythons prime objectives


 By his own admission, jmf doesn't use Python anymore. His only reason to
 remain on this emailing/newsgroup is to troll about the FSR. Please
 don't reply to him (and preferably add him to your killfile).
 

I couldn't kill file JMF I find his posts useful
Every time i find myself agreeing with him I know I have got it wrong.



-- 
The nice thing about Windows is - It does not just crash, it displays a
dialog box and lets you press 'OK' first.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First time I looked at Python was(...)

2014-06-11 Thread alister
On Tue, 10 Jun 2014 22:15:29 +0100, Carlos Anselmo Dias wrote:

 Hi...
 
 I don't understand the 'problem' of several people ...
 
 I created one post because I've several projects, I'm looking for one
 team of experienced experts in Python to work in my projects ... asap
 ... I provided one script(I'm not one expert in Python) to help people
 think and described the projects(briefly) ...

Congratulations
This is the first time in this whole thread that you have stated you are 
asking for programmers to assist with a project.

Thank you  this is the missing piece of information that we have become 
fed-up been asking for.

This is not a recruiting forum so you would be better of asking elsewhere.
when you do please help yourself by not only stating that you are trying 
to recruit programmer but also give some indication on the scope of the 
project





-- 
A compliment is something like a kiss through a veil.
-- Victor Hugo
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-11 Thread alister
On Wed, 11 Jun 2014 00:00:49 +, Steven D'Aprano wrote:

 On Wed, 11 Jun 2014 06:37:01 +1000, Chris Angelico wrote:
 
 I don't know a single piece of programming advice which, if taken as an
 inviolate rule, doesn't at some point cause suboptimal code.
 
 Don't try to program while your cat is sleeping on the keyboard.

My cat is a better programmer than I am !



-- 
Hors d'oeuvres -- a ham sandwich cut into forty pieces.
-- Jack Benny
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: First time I looked at Python was(...)

2014-06-11 Thread Carlos Anselmo Dias


On 06/11/2014 09:34 AM, alister wrote:

On Tue, 10 Jun 2014 22:15:29 +0100, Carlos Anselmo Dias wrote:


Hi...

I don't understand the 'problem' of several people ...

I created one post because I've several projects, I'm looking for one
team of experienced experts in Python to work in my projects ... asap
... I provided one script(I'm not one expert in Python) to help people
think and described the projects(briefly) ...

Congratulations
This is the first time in this whole thread that you have stated you are
asking for programmers to assist with a project.

Thank you  this is the missing piece of information that we have become
fed-up been asking for.

This is not a recruiting forum so you would be better of asking elsewhere.
when you do please help yourself by not only stating that you are trying
to recruit programmer but also give some indication on the scope of the
project







Hi ...

Good morning ...

What a confusion/headache(...)

I'm waiting for traffic of search engines in one subsection of one main 
section to step forward with the organization of what I described 
briefly I'd write ...



Like I explained there are 500 millions of thumbs to import and 20 
million of thumbs every month in that sub-section ...


I don't need assistance, I'll need one team of programmers to work ...

I'm not writing more posts/emails.

(...)

Best regards,
Carlos
--
https://mail.python.org/mailman/listinfo/python-list


Re: First time I looked at Python was(...)

2014-06-11 Thread Carlos Anselmo Dias


On 06/11/2014 05:42 AM, Michael Torrie wrote:

On 06/10/2014 03:15 PM, Carlos Anselmo Dias wrote:

Hi...

I don't understand the 'problem' of several people ...

I created one post because I've several projects, I'm looking for one
team of experienced experts in Python to work in my projects ... asap
... I provided one script(I'm not one expert in Python) to help people
think and described the projects(briefly) ...

Your e-mails are so difficult to parse and understand that your message
was lost in the noise.  In fact this is the first post of yours that I
can even partly understand.  Your unconventional and incorrect sentence
structure makes it very hard to understand you.  I doubt most people
reading your e-mails can even tell what you want and why you are writing.


People start calling me troll,etc- Are this people not insane? And I
don't understand their paranoia ...

After you post a dozen undecipherable posts (literally I cannot
understand them), and keep posting undecipherable, strange sentence
fragments, surely it's understandable why people are frustrated and
annoyed.  You excuse yourself by saying English isn't your first
language.  Well, we say, please correct your sentence structure, speak
simply and clearly, don't get upset, and you'll get people responding to
you positively.


Those who call me troll ... look at the mirror and criticize what I
wrote if you're capable of ... with sense and reasoning ... not like
someone absurd who is not capable of and tries to demonstrate that is
the greatest ... these people should get real ...

I'd criticize what you wrote if I could understand it.  I for one still
do not know what these projects of yours are, or what kind of help you
desire.  If you need to hire programming assistance, just say so.  State
your terms of hire.  There are freelancers on this list.  If you're
looking for free help, you might get some of that, especially if the
projects themselves will be open source.


The www,etc is full of ridiculous people with ridiculous ideas/projects 
...considering themselves the greatest,etc and are nothing but a bunch 
of absurd ... ones worst than the others ... SHIT to be more precise!


Copy/paste of 2 emails I sent (...)


---1st---

Hi ...

Good morning ...

What a confusion/headache(...)

I'm waiting for traffic of search engines in one subsection of one main 
section to step forward with the organization of what I described 
briefly I'd write ...



Like I explained there are 500 millions of thumbs to import and 20 
million of thumbs every month in that sub-section ...


I don't need assistance, I'll need one team of programmers to work ...

I'm not writing more posts/emails.

(...)

Best regards,
Carlos

---2nd 

If I was thinking that people were capable of understanding what's about 
... exceeding the barrier of databases, billions of files indexed,etc 
... look at that like client apis ... with logs, advertisement, etc 
integrated ... in main-sections with sub-sections ... with control of 
cache, web-services, etc ... I tried to resume it briefly and it's about 
what I described here ...


I want that people (can) think about it ... like I wrote ... when the 
sub-section of one main section starts receiving traffic from search 
engines ... it will be possible to think in other main sections, 
organize everything,etc ...


(...)

Best regards,
Carlos
--
https://mail.python.org/mailman/listinfo/python-list


基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread 1989lzhh
我正在写一个使用cython code作为后端的即时编译器名为cyjit,将python code 转换为cython code再编译为c 
extension导入.设计上主要参考numba.jit的思路,使用decorate来指定要编译的function,例如:
from cyjit import jit
@jit('int(int,int)')
def add(a,b):
return a+b
add(1,2)#compiled

@jit('int(int,int)',
locals='''
int c
''')
def add1(a,b):
c=add(a,b)# fast invoked
return c
add1(1,2)

目前还不支持类型推导,需要手动使用c的语法对局部变量进行定义。
编译过程是在jit函数中完成的,后续计划将编译过程移到函数运行时完成,实现重载。
目前支持编译cache,第一次运行需要编译,时间稍慢,再次运行直接导入编译好的extension,速度就很快了。

欢迎大家fork,pull,提建议。
https://github.com/liuzhenhai/cyjit



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


Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-11 Thread Ben Finney
alister alister.nospam.w...@ntlworld.com writes:

 On Wed, 11 Jun 2014 08:29:06 +1000, Tim Delaney wrote:
  By his own admission, jmf doesn't use Python anymore. His only
  reason to remain on this emailing/newsgroup is to troll about the
  FSR. Please don't reply to him (and preferably add him to your
  killfile).

 I couldn't kill file JMF I find his posts useful

That's fine, kill-filing his posts is a matter that affects only you.

But please do not reply to them, nor taunt him in unrelated posts; it
disrupts this forum.
Instead, give him no reason to think anyone is interested.

-- 
 \ “Too many pieces of music finish too long after the end.” —Igor |
  `\   Stravinskey |
_o__)  |
Ben Finney

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


Python's re module and genealogy problem

2014-06-11 Thread BrJohan

For some genealogical purposes I consider using Python's re module.

Rather many names can be spelled in a number of similar ways, and in 
order to match names even if they are spelled differently, I will build 
regular expressions, each of which is supposed to match  a number of 
similar names.


I guess that there will be a few hundred such regular expressions 
covering most popular names.


Now, my problem: Is there a way to decide whether any two - or more - of 
those regular expressions will match the same string?


Or, stated a little differently:

Can it, for a pair of regular expressions be decided whether at least 
one string matching both of those regular expressions, can be constructed?


If it is possible to make such a decision, then how? Anyone aware of an 
algorithm for this?

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


Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 19:50:20 +1200, Gregory Ewing wrote:

 Chris Angelico wrote:
 So, let me get this straight. A CPU has to have a fan, but a car engine
 doesn't, because the car's moving at a hundred kays an hour. I have a
 suspicion the CPU fan moves air a bit slower than that.

I'm not sure where Chris' message comes from, I can't see the original, 
so I'm guessing the context.

Air cooled cars don't just cool the engine when they are travelling at 
100kmh. Some air-cooled engines used a fan to blow extra air over the 
cooling fins, but many did not. Normal air flow is sufficient to keep 
them in a safe operating temperature, the hot engine warms the air, which 
flows away and is replaced by cooler air.

It's possible to design CPUs to work the same way. My wife is using a PC 
right now with a 1.66GHz Atom CPU and no CPU fan. Even though the power 
supply fan died, the machine is still running perfectly, with two laptop 
HDDs, and no overheating. 1.66GHz is plenty fast enough for web browsing, 
word processing, email, etc.

Go back 30 years, and I don't think that the average PC needed a CPU fan. 
Possibly not even a case fan. Just the normal air flow over a small heat 
sink was enough. And of course, your mobile phone has no room for a heat 
sink, unless it's tiny, and no fan. And people expect it to keep working 
even when shoved in their pocket.


 If the car were *always* moving at 100km/h, it probably wouldn't need a
 fan.

 In practice, all cars do have fans (even the ones that aren't
 air-cooled), for the occasions when they're not moving that fast.

That may be true of water-cooled engines *now*, but it's not a law of 
engineering. Many air-cooled engines do not (did not) require a fan, or 
only needed the extra cooling when stuck idling for long periods in hot 
weather. E.g. Beetles didn't use a fan. (A great idea for Germany, not so 
much for hot and dusty Southern California, as my wife can tell you.)


 (BTW, so-called water-cooled engines are really air-cooled too, just not
 by air flowing directly over the engine block. (Although marine engines
 may be an exception.))

Yes, technically water-cooled engines are cooled by air too. The engine 
heats a coolant (despite the name, usually not water these days) which 
then heats the air.


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Roy Smith
In article 53984cd2$0$29988$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Yes, technically water-cooled engines are cooled by air too. The engine 
 heats a coolant (despite the name, usually not water these days) which 
 then heats the air.

Not water???  I'm not aware of any water-cooled engines which use 
anything other than water.  Well, OK, it's really a solution of ethylene 
or propylene glycol in water, but the water is what does most of the 
heat transfer.  The glycol is just there to provide freezing point 
depression and boiling point elevation.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-11 Thread Roy Smith
In article NxUlv.352165$uI3.258913@fx18.am4,
 alister alister.nospam.w...@ntlworld.com wrote:

 On Wed, 11 Jun 2014 00:00:49 +, Steven D'Aprano wrote:
 
  On Wed, 11 Jun 2014 06:37:01 +1000, Chris Angelico wrote:
  
  I don't know a single piece of programming advice which, if taken as an
  inviolate rule, doesn't at some point cause suboptimal code.
  
  Don't try to program while your cat is sleeping on the keyboard.
 
 My cat is a better programmer than I am !

My girlfriend's cat is smarter than me!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's re module and genealogy problem

2014-06-11 Thread Robert Kern

On 2014-06-11 13:23, BrJohan wrote:

For some genealogical purposes I consider using Python's re module.

Rather many names can be spelled in a number of similar ways, and in order to
match names even if they are spelled differently, I will build regular
expressions, each of which is supposed to match  a number of similar names.

I guess that there will be a few hundred such regular expressions covering most
popular names.

Now, my problem: Is there a way to decide whether any two - or more - of those
regular expressions will match the same string?

Or, stated a little differently:

Can it, for a pair of regular expressions be decided whether at least one string
matching both of those regular expressions, can be constructed?

If it is possible to make such a decision, then how? Anyone aware of an
algorithm for this?


And if that isn't the best straight line for the old saying, I don't know what 
is.

  http://en.wikiquote.org/wiki/Jamie_Zawinski

Anyways, to your new problem, yes it's possible. Search for regular expression 
intersection for possible approaches. You will probably have to translate the 
regular expression to a different formalism or at least a different library to 
implement this.


Consider just listing out the different possibilities. All of your regexes 
should be well-behaved given the constraints of the domain (tightly bounded, 
at least). There are tools that help generate matching strings from a Python 
regex. This will help you QA your regexes, too, to be sure that they match what 
you expect them to and not match non-names.


  https://github.com/asciimoo/exrex

--
Robert Kern

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

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


My last message(...)

2014-06-11 Thread Carlos Anselmo Dias

Hi ...

So I'm not receiving more emails from Python mailing list or 
posting/sending more messages ...


I'm keeping your emails that I received to contact all of you when it 
will be time to step forward ...


If you want you can send me your cv or one small text to 
j...@premium-sponsor.com ... You can use my email too ...


If what I wrote is not enough(describing the projects,etc), to be honest 
I wouldn't write anything else besides that ...


I'm not really interested in what you did, I'm interested in what you're 
capable of doing and what you're capable of doing is integrated in one 
team of Python programmers to organize, manage, develop, implement 
everything related with ...


My messages are with the subject 'python team(...)' + 'First time I 
looked at Python was(...)'


(...)

Best regards,
Carlos
--
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 19:41:12 +1200, Gregory Ewing wrote:

 Steven D'Aprano wrote:
 Everything *eventually* gets converted to heat, but not immediately.
 There's a big difference between a car that gets 100 miles to the
 gallon, and one that gets 1 mile to the gallon.
 
 With a car, the engine converts some of its energy to kinetic energy,
 which is subsequently dissipated as heat, so it makes sense to talk
 about the ratio of kinetic energy produced to energy wasted directly as
 heat.
 
 But when you flip a bit, there's no intermediate form of energy -- the
 bit changes state, and heat is produced. So all of the heat is waste
 heat.

Not the point. There's a minimum amount of energy required to flip a bit. 
Everything beyond that is, in a sense, just wasted. You mentioned this 
yourself in your previous post. It's a *really* tiny amount of energy: 
about 17 meV at room temperature. That's 17 milli electron-volt, or 
2.7×10^-21 joules. In comparison, Intel CMOS transistors have a gate 
charging energy of about 62500 eV (1×10^-14 J), around 3.7 million times 
greater.

Broadly speaking, if the fundamental thermodynamic minimum amount of 
energy needed to flip a bit takes the equivalent of a single grain of 
white rice, then our current computing technology uses the equivalent of 
175 Big Macs.

(There are approximately 50 grains of rice in a gram, and a gram of rice 
is about 1.3 Calories. A Big Mac is about 550 Calories. You do the maths.)


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: asyncio - how to stop loop?

2014-06-11 Thread Ian Kelly
On Wed, Jun 11, 2014 at 1:19 AM, Frank Millman fr...@chagford.com wrote:
 First attempt - same as before

 loop = asyncio.get_event_loop()
 threading.Thread(target=loop.run_forever).start()
 input('Press enter to stop')
 loop.stop()
 loop.close()

Each event loop is hosted by a specific thread.  In this case you're
getting the event loop of the main thread and then trying to run it in
a separate thread, which is not a good idea.  You can run an event
loop in a separate thread, but you should install a separate event
loop for that thread if you do (and then when you interact with the
loop, do so in a thread-safe manner -- see below).

 Second attempt - move the keyboard input to a separate thread

 def stop_loop():
 input('Press enter to stop')
 loop.stop()
 loop.close()

 loop = asyncio.get_event_loop()
 threading.Thread(target=stop_loop).start()
 loop.run_forever()

One issue here is that (like most event loop implementations) event
loops are not thread-safe.  To make a call to the event loop across
threads, you should be using the call_soon_threadsafe method, e.g.
loop.call_soon_threadsafe(loop.stop).  You'll also want to make sure
that the event loop has actually stopped before you call loop.close --
see below.

 Third attempt - get the loop to close itself (cannot use in practice, but
 see what happens)

 def stop_loop():
 loop.stop()
 loop.close()

 loop = asyncio.get_event_loop()
 loop.call_later(2, stop_loop)
 loop.run_forever()

I think what's happening here is that per the docs loop.close should
not be called while the loop is running.  You've called loop.stop but
you're still inside a callback, which is a bit of a gray area.  You
probably don't need to call loop.close at all, but if you want to do
so I suggest putting it after the run_forever call, so you can be
certain the loop has stopped when it's called.

Putting all that together, you should have something like this:

def stop_loop():
input('Press enter to stop')
loop.call_soon_threadsafe(loop.stop)

loop = asyncio.get_event_loop()
threading.Thread(target=stop_loop).start()
loop.run_forever()
loop.close()  # optional
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's re module and genealogy problem

2014-06-11 Thread Thomas Rachel

Am 11.06.2014 14:23 schrieb BrJohan:


Can it, for a pair of regular expressions be decided whether at least
one string matching both of those regular expressions, can be constructed?

If it is possible to make such a decision, then how? Anyone aware of an
algorithm for this?


Just a feeling-based statement: I don't think that is easily possible.

Every RE can potentially match an infinite number of statements.

Just have a look at

re1 = re.compile('A43.*')
re2 = re.compile('.*[0-9][A-F]')

It can easily seen that the area these REs work on is different; they 
are orthogonal.


So there is an infinite number of strings these REs match.


Thomas

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


Re: Python's re module and genealogy problem

2014-06-11 Thread Mark H Harris

On 6/11/14 8:26 AM, Robert Kern wrote:

Anyways, to your new problem, yes it's possible. Search for regular
expression intersection for possible approaches.


I agree,  I would not use a decision (decision tree) but would consider 
a set of filters from most specific to least specific.


marcus


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


Re: OT: This Swift thing

2014-06-11 Thread Rustom Mody
On Wednesday, June 11, 2014 1:11:12 PM UTC+5:30, Gregory Ewing wrote:
 Steven D'Aprano wrote:
  Everything *eventually* gets converted to heat, but not immediately. 
  There's a big difference between a car that gets 100 miles to the gallon, 
  and one that gets 1 mile to the gallon.

 With a car, the engine converts some of its energy to
 kinetic energy, which is subsequently dissipated as heat,
 so it makes sense to talk about the ratio of kinetic
 energy produced to energy wasted directly as heat.

 But when you flip a bit, there's no intermediate form
 of energy -- the bit changes state, and heat is produced.
 So all of the heat is waste heat.

Actually the car-drive and the bit-flip are much more identical than
different.  Its just that the time-scales are minutes/hours in one
case and nanoseconds or less in the other so our powers of
visualization are a bit taxed.

In more detail:

One drives a car from A to B for an hour (assume no change in 
height above sea level so no potential difference).
All the energy that was there as petrol has been dissipated as heat.

A bit flips from zero to one. Pictorially
(this needs to be fixed-pitch font!):

   +-
   | 
   | 
   | 
---+ 

However in reality that 'square' wave is always actually sloped


   +--
  /  
 /
/
---+

Now for say CMOS technology, one may assume no currents in both zero
and one states (thats the C in CMOS). However when its neither zero
nor one (the sloping part) there will be current and therefore heat.

So just as the car burns energy in going from A to B, the flipflop
burns it in going from 0 to 1


Steven D'Aprano wrote:
 Not the point. There's a minimum amount of energy required to flip a bit.
 Everything beyond that is, in a sense, just wasted. You mentioned this
 yourself in your previous post. It's a *really* tiny amount of energy:
 about 17 meV at room temperature. That's 17 milli electron-volt, or
 2.7×10^-21 joules. In comparison, Intel CMOS transistors have a gate
 charging energy of about 62500 eV (1×10^-14 J), around 3.7 million times
 greater.
  
 Broadly speaking, if the fundamental thermodynamic minimum amount of
 energy needed to flip a bit takes the equivalent of a single grain of
 white rice, then our current computing technology uses the equivalent of
 175 Big Macs. 

Well thats in the same realm as saying that by E=mc² a one gram stone can yield
21 billion calories energy.

[Ive forgotten how the units stack up, so as usual relyin on google
instead of first principles:

http://en.wikipedia.org/wiki/Mass%E2%80%93energy_equivalence#Practical_examples
:-)
]

ie. from a a pragmatic/engineering pov we know as much how to use
Einstein's energy-mass-equivalence to generate energy as we know how
to use Landauer's principle to optimally flip bits.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's re module and genealogy problem

2014-06-11 Thread Michael Torrie
On 06/11/2014 06:23 AM, BrJohan wrote:
 For some genealogical purposes I consider using Python's re module.
 
 Rather many names can be spelled in a number of similar ways, and in 
 order to match names even if they are spelled differently, I will build 
 regular expressions, each of which is supposed to match  a number of 
 similar names.
 
 I guess that there will be a few hundred such regular expressions 
 covering most popular names.
 
 Now, my problem: Is there a way to decide whether any two - or more - of 
 those regular expressions will match the same string?
 
 Or, stated a little differently:
 
 Can it, for a pair of regular expressions be decided whether at least 
 one string matching both of those regular expressions, can be constructed?
 
 If it is possible to make such a decision, then how? Anyone aware of an 
 algorithm for this?

You might want to search for fuzzy matching algorithms. Years ago, there
was an algorithm called soundex that would generate fuzzy fingerprints
for words that would hide differences in spelling, etc.  Unfortunately
such an algorithm would be language dependent.  The problem you are
trying to solve is one of those very hard problems in computers and math.

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


Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-11 Thread Michael Torrie
On 06/10/2014 01:43 PM, alister wrote:
 On Tue, 10 Jun 2014 12:27:26 -0700, wxjmfauth wrote:
 BTW, very easy to explain.

Yeah he keeps saying that, but he never does explain--just flails around
and mumbles unicode.org.  Guess everyone has to have his or her
windmill to tilt at.


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


Re: 基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread mm0fmf

On 11/06/2014 10:37, 1989lzhh wrote:

我正在写一个使用cython code作为后端的即时编译器名为cyjit,将python code
转换为cython code再编译为c extension导入.设计上主要参考numba.jit的思路,
使用decorate来指定要编译的function,例如:
from cyjit import jit
@jit('int(int,int)')
def add(a,b):
 return a+b
add(1,2)#compiled

@jit('int(int,int)',
 locals='''
 int c
 ''')
def add1(a,b):
 c=add(a,b)# fast invoked
 return c
add1(1,2)

目前还不支持类型推导,需要手动使用c的语法对局部变量进行定义。
编译过程是在jit函数中完成的,后续计划将编译过程移到函数运行时完成,实现
重载。
目前支持编译cache,第一次运行需要编译,时间稍慢,再次运行直接导入编译好
的extension,速度就很快了。

欢迎大家fork,pull,提建议。

https://github.com/liuzhenhai/cyjit



You might say that but I couldn't possibly comment.



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


Re: Python's re module and genealogy problem

2014-06-11 Thread Nick Cash

On 06/11/2014 10:35 AM, Michael Torrie wrote:
 On 06/11/2014 06:23 AM, BrJohan wrote:
 For some genealogical purposes I consider using Python's re module.

 Rather many names can be spelled in a number of similar ways, and in 
 order to match names even if they are spelled differently, I will build 
 regular expressions, each of which is supposed to match  a number of 
 similar names.
 You might want to search for fuzzy matching algorithms. Years ago, there
 was an algorithm called soundex that would generate fuzzy fingerprints
 for words that would hide differences in spelling, etc.  Unfortunately
 such an algorithm would be language dependent.  The problem you are
 trying to solve is one of those very hard problems in computers and math.


Soundex is actually not horrible, but it is definitely only for English
names. Newer variants of Metaphone
(http://en.wikipedia.org/wiki/Metaphone) are significantly better, and
support quite a few other languages.  Either one would most likely be
better than the regex approach.

Side note: if your data happens to be in MySQL then it has a builtin
sounds_like() function that compares strings using soundex.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread Skip Montanaro
 You might say that but I couldn't possibly comment.

You could run the message through Google Translate. It's not
publication quality translation, but serves the needs in this
instance. (Gmail offers to translate the OP's message for me.)

Here's what GT produced (successfully translates the Chinese, but
destroys the code structure in the process - what's wrong with those
people at Google? wink):

 I'm writing a cython code using the compiler as a backend instant named 
 cyjit, the python code
 Convert cython code is then compiled c extension import. Designed primarily 
 reference numba. jit ideas,
 Use decorate to specify compile function, for example:
 from cyjit import jit
 @ Jit ('int (int, int)')
 def add (a, b):
 return a + b
 add (1,2) # compiled

 @ Jit ('int (int, int)',
 locals ='' '
 int c
 '' ')
 def add1 (a, b):
 c = add (a, b) # fast invoked
 return c
 add1 (1,2)

 Currently does not support the type of derivation, C syntax to use local 
 variables defined manually.
 Jit compilation process is done in the function of Follow-up plans to move to 
 complete the compilation process runtime functions to achieve overloading.
 Currently supports compilation cache, you need to compile the first run, 
 slower time, Run again compiled directly into the extension, the speed very 
 quickly.

 Welcome to fork, pull, and suggestions.

 https://github.com/liuzhenhai/ cyjit

The concept looks like of interesting.

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


Re: 基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread 1989lzhh
sorry,wrong version post

发自我的 iPhone

 在 Jun 12, 2014,0:16,mm0fmf n...@mailinator.com 写道:
 
 On 11/06/2014 10:37, 1989lzhh wrote:
 我正在写一个使用cython code作为后端的即时编译器名为cyjit,将python code
 转换为cython code再编译为c extension导入.设计上主要参考numba.jit的思路,
 使用decorate来指定要编译的function,例如:
 from cyjit import jit
 @jit('int(int,int)')
 def add(a,b):
 return a+b
 add(1,2)#compiled
 
 @jit('int(int,int)',
 locals='''
 int c
 ''')
 def add1(a,b):
 c=add(a,b)# fast invoked
 return c
 add1(1,2)
 
 目前还不支持类型推导,需要手动使用c的语法对局部变量进行定义。
 编译过程是在jit函数中完成的,后续计划将编译过程移到函数运行时完成,实现
 重载。
 目前支持编译cache,第一次运行需要编译,时间稍慢,再次运行直接导入编译好
 的extension,速度就很快了。
 
 欢迎大家fork,pull,提建议。
 
 https://github.com/liuzhenhai/cyjit
 
 You might say that but I couldn't possibly comment.
 
 
 
 -- 
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's re module and genealogy problem

2014-06-11 Thread Simon Ward


On 11 June 2014 13:23:14 BST, BrJohan brjo...@gmail.com wrote:
For some genealogical purposes I consider using Python's re module.

Rather many names can be spelled in a number of similar ways, and in 
order to match names even if they are spelled differently, I will build

regular expressions, each of which is supposed to match  a number of 
similar names.

As has been mentioned, you probably want to look at fuzzy matching algorithms 
rather than aiming at regular expressions, although a quick search suggests 
there has been some work on fuzzy matching with regular expressions[1].

Now, my problem: Is there a way to decide whether any two - or more -
of 
those regular expressions will match the same string?

If your regexes are truly regular expressions (see [2]*) then they represent 
regular languages[3], which are really sets. The intersection of these,  is 
another regular language. If you test the string against this it will also 
match both original languages.

(*this only mentions back references, but I think the look-ahead/behind 
assertions are also non-regular)

[1]: http://laurikari.net/tre/about/
[2]: 
https://en.wikipedia.org/wiki/Regular_expression#Patterns_for_non-regular_languages
[3]: https://en.wikipedia.org/wiki/Regular_language

Simon
-- 
Sent from Kaiten Mail. Please excuse my brevity.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python's re module and genealogy problem

2014-06-11 Thread Vlastimil Brom
2014-06-11 14:23 GMT+02:00 BrJohan brjo...@gmail.com:
 For some genealogical purposes I consider using Python's re module.
...

 Now, my problem: Is there a way to decide whether any two - or more - of
 those regular expressions will match the same string?

 Or, stated a little differently:

 Can it, for a pair of regular expressions be decided whether at least one
 string matching both of those regular expressions, can be constructed?
 --
 https://mail.python.org/mailman/listinfo/python-list

Hi,
i guess, you could reuse some available generators for strings
matching a given regular expression, see e.g.:
http://stackoverflow.com/questions/492716/reversing-a-regular-expression-in-python/
for example a pyparsing recipe:
http://stackoverflow.com/questions/492716/reversing-a-regular-expression-in-python/5006339#5006339

which might be general enough for your needs - of course, you cannot
use unbound quantifiers, backreferences, etc.

Then you can test for identical strings in the generated outputs -
e.g. using the set(...) and its intersection method.

You might also check a much more powerful regex library
https://pypi.python.org/pypi/regex

which, beyond other features, also supports the mentioned fuzzy matches, cf.

 regex.findall(r\bSm(?:ith){e3}\b, Smith Smithe Smyth Smythe Smijth)
['Smith', 'Smithe', 'Smyth', 'Smythe', 'Smijth']

(but, of course, you will have to be careful with this feature in
order to reduce false positives)

hth,
   vbr
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on SQL vs ORM

2014-06-11 Thread suamere

 I'm afraid I don't understand what all that means.
 
 
 
 But I invariably go for SQL over any abstraction paradigm.

When presented with options, these are the possible stances:

1. (Lead) Become educated on the options and decide on one.
2. (Follow) Become educated on the options and remain impartial.
3. Remain ignorant of the similarities/differences and decide on one.
4. (Get out of the way) Remain ignorant of the similarities/differences and 
remain impartial.

Of course, deciding on one could also be a case-by-case basis.  Maybe for one 
use you decide on one for one reason, and for the other case you decide on 
another option.

Thank you for choosing number 3 and casting a vote without understanding.  Any 
other stance is understandable, but like most people, you choose to hurt the 
social group you are participating in by making uninformed decisions.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Thoughts on SQL vs ORM

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 5:39 AM,  suam...@gmail.com wrote:
 When presented with options, these are the possible stances:

 1. (Lead) Become educated on the options and decide on one.
 2. (Follow) Become educated on the options and remain impartial.
 3. Remain ignorant of the similarities/differences and decide on one.
 4. (Get out of the way) Remain ignorant of the similarities/differences and 
 remain impartial.

 Of course, deciding on one could also be a case-by-case basis.  Maybe for one 
 use you decide on one for one reason, and for the other case you decide on 
 another option.

 Thank you for choosing number 3 and casting a vote without understanding.  
 Any other stance is understandable, but like most people, you choose to hurt 
 the social group you are participating in by making uninformed decisions.


That's not quite fair. Suppose I'm looking at working with a
PostgreSQL database, and I have five options:

1) Write SQL and use libpq (if C) or psycopg2 (if Python)
2) Use Fred's Fancy Feature-Rich Database Interface
3) Use Joe's Simple Database Interface
4) Use Nancy's Dict-Like Database Interface
5) Bypass all libraries and open a socket connection on port 5432

I have a fairly good understanding of what's needed for option 5, as
I've worked with Pike's PostgreSQL module. And it's a lot of work, so
I wouldn't do it. (That would be your choice 1, Lead.) But it's not
worth my time to learn three pieces of middle-ware before making my
decision, so I'm going to remain fairly ignorant of at least two of
them - I'd look at their quick-start guides and basic feature lists,
possibly pick one of them to explore in detail, and then make a
decision between that and the first option. Ultimately, I have to make
a decision, because code can't be impartial - either I'm using some
module or I'm not - and it's usually impossible to truly become
educated on all the options.

So I'd say there's more of a spectrum between your choices 1 and 3
than you imply. Perhaps I can word it this way: Choose one of the
options you know about, and the quality of the decision scales with
the number of other options you also know. (Which is why I like to
know huge numbers of programming languages. When I choose Python for a
job, it's because it's better than possibly a hundred other languages
that I could have chosen.)

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


Re: Is MVC Design Pattern good enough?

2014-06-11 Thread Terry Reedy

On 6/11/2014 2:27 PM, Stefan Ram wrote:

Mark Lawrence breamore...@yahoo.co.uk writes:

IDLE is available on all platforms and is written in tkinter.  But
personally I'd rather use the command line :)


   In the meantime, I have learned that tkinter in fact has
   become part of a standard Python implementations, and in
   fact it looks easier to use than Swing (but I have only
   looked at seven lines of Python-tkinter code so far).

   A naked-objects framework should be easy to implement
   because AFAIK it treats all objects the same, so one does
   only have to code a single View and Controller for a
   »generic object« and some general utility operations.


I though about trying naked-objects with tkinter and I think it should 
be reasonably possible. I have too much else to do but would like to see 
what could be done.


--
Terry Jan Reedy


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


Re: 基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread 1989lzhh


在 Jun 12, 2014,1:16,Skip Montanaro s...@pobox.com 写道:

 You might say that but I couldn't possibly comment.
 
 You could run the message through Google Translate. It's not
 publication quality translation, but serves the needs in this
 instance. (Gmail offers to translate the OP's message for me.)
 
 Here's what GT produced (successfully translates the Chinese, but
 destroys the code structure in the process - what's wrong with those
 people at Google? wink):
Thanks skip, I post the email into wrong mail list, I will rewrite it into 
English. :)
 
 I'm writing a cython code using the compiler as a backend instant named 
 cyjit, the python code
 Convert cython code is then compiled c extension import. Designed primarily 
 reference numba. jit ideas,
 Use decorate to specify compile function, for example:
 from cyjit import jit
 @ Jit ('int (int, int)')
 def add (a, b):
 return a + b
 add (1,2) # compiled
 
 @ Jit ('int (int, int)',
 locals ='' '
 int c
 '' ')
 def add1 (a, b):
 c = add (a, b) # fast invoked
 return c
 add1 (1,2)
 
 Currently does not support the type of derivation, C syntax to use local 
 variables defined manually.
 Jit compilation process is done in the function of Follow-up plans to move 
 to complete the compilation process runtime functions to achieve overloading.
 Currently supports compilation cache, you need to compile the first run, 
 slower time, Run again compiled directly into the extension, the speed very 
 quickly.
 
 Welcome to fork, pull, and suggestions.
 
 https://github.com/liuzhenhai/ cyjit

The translation's quality is quite good, I will edit it and post here again. 
Thanks
 
 The concept looks like of interesting.
 
 Skip
 -- 
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


A JIT compiler 'cyjit' using cython code as a backend

2014-06-11 Thread 1989lzhh
 I'm writing a JIT compiler named cyjit using cython code as a backend. It 
 designed primarily reference numba.jit. the jitted python function will be 
 converted to cython code then compiled to c extension.
 Use decorate to specify compiled function.

 for example:
 from cyjit import jit
 @ jit ('int (int, int)')
 def add (a, b):
 return a + b
 add (1,2) # compiled
 
 @ jit ('int (int, int)',
 locals ='' '
 int c
 '' ')
 def add1 (a, b):
 c = add (a, b) # fast invoked
 return c
 add1 (1,2)
 
 Currently cyjit does not support type defer, the local variables can be 
 defined manually using C syntax.
 Jit compilation process is done inside jit decorate. I am planing to
 move compilation process into function's runtime to achieve overload like 
 numba.jit.

 Currently cyjit supports compilation cache, the compilation will happen at 
 the first run, it will take longer time. When you run it again, it will load 
 the compiled extension directly. 
 
 Welcome to fork, pull, and suggestions.
 
 https://github.com/liuzhenhai/cyjit
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 08:48:36 -0400, Roy Smith wrote:

 In article 53984cd2$0$29988$c3e8da3$54964...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 Yes, technically water-cooled engines are cooled by air too. The engine
 heats a coolant (despite the name, usually not water these days) which
 then heats the air.
 
 Not water???  I'm not aware of any water-cooled engines which use
 anything other than water.  Well, OK, it's really a solution of ethylene
 or propylene glycol in water, but the water is what does most of the
 heat transfer.  The glycol is just there to provide freezing point
 depression and boiling point elevation.

Would you consider it fair to say that, say, vinegar is not water? 
Depending on the type of vinegar, it is typically around 5-10% acetic 
acid, and the rest water. Spirit vinegar can be as much as 20% acetic 
acid, which still leaves 80% water.

How about brandy, which is typically 35%-60% alcohol, with most of the 
rest being water? Or household bleach, which is typically a 3-6% solution 
of sodium hypochlorite? Or milk (85-90% water)? I think it is fair to 
describe those as not water. You shouldn't try to put out a fire by 
pouring a bottle of brandy on it.

Automotive cooling fluid in modern sealed radiators is typically a 
mixture of 50% anti-freeze and 50% water.

Back in the day, car radiators were *literally* water-cooled in the sense 
that the radiator was filled with 100% water. You filled it from the tap 
with drinking water. In an emergency, say broken down in the desert, you 
could drink the stuff from the radiator to survive. If you tried that 
with many modern cars, you would die a horrible death.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 08:28:43 -0700, Rustom Mody wrote:

 Steven D'Aprano wrote:

 Not the point. There's a minimum amount of energy required to flip a
 bit. Everything beyond that is, in a sense, just wasted. You mentioned
 this yourself in your previous post. It's a *really* tiny amount of
 energy: about 17 meV at room temperature. That's 17 milli
 electron-volt, or 2.7×10^-21 joules. In comparison, Intel CMOS
 transistors have a gate charging energy of about 62500 eV (1×10^-14 J),
 around 3.7 million times greater.
  
 Broadly speaking, if the fundamental thermodynamic minimum amount of
 energy needed to flip a bit takes the equivalent of a single grain of
 white rice, then our current computing technology uses the equivalent
 of 175 Big Macs.
 
 Well thats in the same realm as saying that by E=mc² a one gram stone
 can yield 21 billion calories energy.
[...]
 ie. from a a pragmatic/engineering pov we know as much how to use
 Einstein's energy-mass-equivalence to generate energy as we know how to
 use Landauer's principle to optimally flip bits.

You know, I think that the people of Hiroshima and Nagasaki and Chernobyl 
and Fukushima (to mention only a few places) might disagree.

We know *much more* about generating energy from E = mc^2 than we know 
about optimally flipping bits: our nuclear reactions convert something of 
the order of 0.1% of their fuel to energy, that is, to get a certain 
yield, we merely have to supply about a thousand times more fuel than 
we theoretically needed. That's about a thousand times better than the 
efficiency of current bit-flipping technology.

We build great big clanking mechanical devices out of lumps of steel that 
reach 25% - 50% of the theoretical maximum efficiency:

https://en.wikipedia.org/wiki/Thermal_efficiency

while our computational technology is something of the order of 0.1% 
efficient. I'm just pointing out that our computational technology uses 
over a million times more energy than the theoretical minimum, and 
therefore there is a lot of room for efficiency gains without sacrificing 
computer power. I never imagined that such viewpoint would turn out to be 
so controversial.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Gregory Ewing

Steven D'Aprano wrote:
Automotive cooling fluid in modern sealed radiators is typically a 
mixture of 50% anti-freeze and 50% water.


Sometimes it's even more than 50%, at which point
you really have an antifreeze-cooled engine. :-)

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


About python while statement and pop()

2014-06-11 Thread hito koto
Hello,all
I'm first time,

I want to make a while statement which can function the same x.pop () and 
without the use of pop、how can i to do?

i want to change this is code:

def foo(x):
y = []
while x !=[]:
y.append(x.pop())
return y
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:About python while statement and pop()

2014-06-11 Thread Dave Angel
hito koto hitokoto2...@gmail.com Wrote in message:
 Hello,all
 I'm first time,
 
 I want to make a while statement which can function the same x.pop () and 
 without the use of pop、how can i to do?

No idea what the question means. Are you just trying to rewrite
 the loop in a python implementation where pop is broken?
 


 
 i want to change this is code:
 
 def foo(x):
 y = []
 while x !=[]:
 y.append(x.pop())
 return y

Perhaps you're looking for the extend method. 

-- 
DaveA

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


Re: About python while statement and pop()

2014-06-11 Thread Vincent Vande Vyvre

Le 12/06/2014 05:12, hito koto a écrit :

Hello,all
I'm first time,

I want to make a while statement which can function the same x.pop () and 
without the use of pop、how can i to do?

i want to change this is code:

def foo(x):
 y = []
 while x !=[]:
 y.append(x.pop())
 return y

Something like that :

def foo(x):
return reversed(x)

--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte 
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager

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


Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre
vincent.vandevy...@swing.be wrote:
 Le 12/06/2014 05:12, hito koto a écrit :

 Hello,all
 I'm first time,

 I want to make a while statement which can function the same x.pop () and
 without the use of pop、how can i to do?

 i want to change this is code:

 def foo(x):
  y = []
  while x !=[]:
  y.append(x.pop())
  return y

 Something like that :

 def foo(x):
 return reversed(x)

That doesn't do the same thing, though. Given a list x, the original
function will empty that list and return a new list in reverse order,
but yours will return a reversed iterator over the original list
without changing it. This is more accurate, but still not identical,
and probably not what the OP's teacher is looking for:

def foo(x):
y = x[::-1]
x[:] = []
return y

If the mutation of x is unimportant, it can simply be:

def foo(x):
return x[::-1]

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


Lines on a tkinter.Canvas

2014-06-11 Thread Pedro Izecksohn
  The code available from:
http://izecksohn.com/pedro/python/canvas/testing.py
  draws 2 horizontal lines on a Canvas. Why the 2 lines differ on thickness and 
length?

  The Canvas' method create_line turns on at least 2 pixels. But I want to turn 
on many single pixels on a Canvas. How should I do this? Canvas has no method 
create_pixel or create_point.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 12:08 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I'm just pointing out that our computational technology uses
 over a million times more energy than the theoretical minimum, and
 therefore there is a lot of room for efficiency gains without sacrificing
 computer power. I never imagined that such viewpoint would turn out to be
 so controversial.

The way I understand it, you're citing an extremely theoretical
minimum, in the same way that one can point out that we're a long way
from maximum entropy in a flash memory chip, so it ought to be
possible to pack a lot more data onto a USB stick. The laws of physics
tend to put boundaries that are ridiculously far from where we
actually work - I think most roads have speed limits that run a fairly
long way short of c.

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


Re: OT: This Swift thing

2014-06-11 Thread Gene Heskett
On Wednesday 11 June 2014 22:11:53 Gregory Ewing did opine
And Gene did reply:
 Steven D'Aprano wrote:
  Automotive cooling fluid in modern sealed radiators is typically a
  mixture of 50% anti-freeze and 50% water.
 
 Sometimes it's even more than 50%, at which point
 you really have an antifreeze-cooled engine. :-)

There have been cases where that 50% may have been exceeded actually 
driving on the streets.

At least 3 decades back, not too long before caddy came out with the 
northstar engine, which was rigged to get you home at a reasonable speed 
even if the radiator had been holed  the coolant lost.  They used a wee 
bit of the knowledge gained from keeping Smokey Yunick is experimenting 
cash.  He had an old VW Rabbit that was both a parts car, and the test 
bed. Two cylinder motor, I suspect built on a Harley 78cid crankcase, no 
radiator, no air cooling.  Ceramic cylinders and pistons, it ran at a 
quite high internal temperature because the cylinders were insulated from 
losing heat by fiberglass blankets.  It displaced 78 cid, made about 150 
HP, and got well over 120 mpg running around in Daytona Beach.  The one 
magazine article said it hadn't lost a stoplight grand prix ever but 
Smokey stopped that by making whoever was driving it, 100% responsible for 
any tickets it collected.

It would have been gawdawful expensive to put it into production since 
those 2 cylinders  pistons cost more than the complete V8 Northstar 
engine.

I thought it was one radically cool idea at the time.  And I am amazed 
that something like it has not invaded the automotive world what with all 
the emphasis on both high mileage  decent horsepower caused by the high 
petro prices.  Today I'd imagine a new cat converter might need to be 
built because at those temps and compression ratio's, I can see a hugely 
illegal amount of the various nitrogen oxides the EPA wouldn't tolerate. 

Cheers, Gene Heskett
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
Genes Web page http://geneslinuxbox.net:6309/gene
US V Castleman, SCOTUS, Mar 2014 is grounds for Impeaching SCOTUS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About python while statement and pop()

2014-06-11 Thread hito koto
2014年6月12日木曜日 12時58分27秒 UTC+9 Chris Angelico:
 On Thu, Jun 12, 2014 at 1:40 PM, Vincent Vande Vyvre
 
 vincent.vandevy...@swing.be wrote:
 
  Le 12/06/2014 05:12, hito koto a écrit :
 
 
 
  Hello,all
 
  I'm first time,
 
 
 
  I want to make a while statement which can function the same x.pop () and
 
  without the use of pop、how can i to do?
 
 
 
  i want to change this is code:
 
 
 
  def foo(x):
 
   y = []
 
   while x !=[]:
 
   y.append(x.pop())
 
   return y
 
 
 
  Something like that :
 
 
 
  def foo(x):
 
  return reversed(x)
 
 
 
 That doesn't do the same thing, though. Given a list x, the original
 
 function will empty that list and return a new list in reverse order,
 
 but yours will return a reversed iterator over the original list
 
 without changing it. This is more accurate, but still not identical,
 
 and probably not what the OP's teacher is looking for:
 
 
 
 def foo(x):
 
 y = x[::-1]
 
 x[:] = []
 
 return y
 
 
 
 If the mutation of x is unimportant, it can simply be:
 
 
 
 def foo(x):
 
 return x[::-1]
 
 
 
 ChrisA


I want to use while statement,

for example:
 def foo(x):
... y = []
... while x !=[]:
... y.append(x.pop())
... return y
...
 print foo(a)
[[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
 a
[]   but this is empty 
 so,I want to leave a number of previous (a = [[1, 2, 3, 4],[5, 6, 7, 8, 
 9],[10]])

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


Re: About python while statement and pop()

2014-06-11 Thread Chris Angelico
On Thu, Jun 12, 2014 at 2:56 PM, hito koto hitokoto2...@gmail.com wrote:
 I want to use while statement,

This sounds like homework. Go back to your teacher/tutor for
assistance, rather than asking us to do the work for you; or at very
least, word your question in such a way that we can help you to learn,
rather than just give you the answer.

Second problem: You're using Google Groups. This makes your posts
messy, especially when you quote someone else's text. Please either
fix your posts before sending them, or read and post by some other
means, such as the mailing list:

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

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


Re: About python while statement and pop()

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 21:56:06 -0700, hito koto wrote:

 I want to use while statement,
 
 for example:
 def foo(x):
 ... y = []
 ... while x !=[]:
 ... y.append(x.pop())
 ... return y
 ...
 print foo(a)
 [[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
 a
 []   but this is empty
 so,I want to leave a number of previous (a = [[1, 2, 3, 4],[5, 6, 7,
 8, 9],[10]])


I wouldn't use a while statement. The easy way is:

py a = [[1, 2, 3, 4],[5, 6, 7, 8, 9],[10]]
py y = a[::-1]
py print y
[[10], [5, 6, 7, 8, 9], [1, 2, 3, 4]]
py print a
[[1, 2, 3, 4], [5, 6, 7, 8, 9], [10]]

If you MUST use a while loop, then you need something like this:


def foo(x):
y = []
index = 0
while index  len(x):
y.append(x[i])
i += 1
return y


This does not copy in reverse order. To make it copy in reverse order, 
index should start at len(x) - 1 and end at 0.



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


[issue21715] Chaining exceptions at C level

2014-06-11 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The proposed patch introduces new private function which chains previously 
fetched and current exceptions. This will help in correct implementing at C 
level an equivalent of following Python idioms:

try:
...
finally:
...

and

try:
...
except:
...
raise

--
components: Interpreter Core
messages: 220236
nosy: benjamin.peterson, pitrou, serhiy.storchaka, stutzbach
priority: normal
severity: normal
stage: patch review
status: open
title: Chaining exceptions at C level
type: enhancement
versions: Python 3.4, Python 3.5

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



[issue21706] Add base for enumerations (Functional API)

2014-06-11 Thread Dmitry Korchemny

Dmitry Korchemny added the comment:

I think that the situation when you want start numbering from 0 is rather 
common, especially when you need to define bit fields as enumeration or when 
you need to implement an interface with other languages (e.g., C).

--

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



[issue21624] Idle: polish htests

2014-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Refinement 1: in doing coverage for UndoDelegator, I noticed that the htest 
function is counted as missing (uncovered). Both of the following in 
.coveragerc work to ignore the block: name prefix; comment suffix.
def htest_.*:
.*# htest #
The second is more practical for alphabetical order in htest. It is also less 
work to change. The particular form marks it as not a normal comment.

Refinement 2: put all imports that are specific to the htest function at the 
top of the function. Since the function is only called once per process, there 
is no efficiency consideration. I decided that after the tkinter import at the 
top got me (wasting time) looking through UndoDelegator for a widget call that 
might be the source of the leak. The changes can wait until we edit the file 
anyway, or at least write a test.

However, the docstring at the top of htest.py should be changed.

--

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



[issue19561] request to reopen Issue837046 - pyport.h redeclares gethostname() if SOLARIS is defined

2014-06-11 Thread Thomas Klausner

Changes by Thomas Klausner t...@giga.or.at:


--
nosy: +wiz

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



[issue21703] IDLE: Test UndoDelegator

2014-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

cls.percolator.close() cut leaks in half.

test_idle leaked [237, 237, 237, 237] references, sum=948
test_idle leaked [95, 97, 97, 97] memory blocks, sum=386

test_idle leaked [130, 130, 130, 130] references, sum=520
test_idle leaked [60, 62, 62, 62] memory blocks, sum=246

I prefixed name with 'x' and all leaks disappeared. When I run the test, a tk 
box is left. My guess is that something is being created with 
tkinter._default_root as master. I do not think it is in UndoDelegator, so I 
would look at Percolator, WidgetDirector, Delegator, and the new test file. 

---
See review comment for increasing coverage to about 80%, which is very good.

---
When unittest call precedes htest.run call, need exit=False or htest is skipped 
by unittest exiting process. Part of testing is running tests from module. Even 
with the addition, htest is not running right (buttons in main windows are not 
right). The might be an effect of the unittest not being properly terminated. 
It is still true after I added the missing re import. Htest runs fine by 
itself. See #21624 for changes.  Revised code:

def _undo_delegator(parent):  # htest #
import re
import tkinter as tk
from idlelib.Percolator import Percolator
root = tk.Tk()
root.title(Test UndoDelegator)
width, height, x, y = list(map(int, re.split('[x+]', parent.geometry(
root.geometry(+%d+%d%(x, y + 150))

text = tk.Text(root)
text.config(height=10)
text.pack()
text.focus_set()
p = Percolator(text)
d = UndoDelegator()
p.insertfilter(d)

undo = tk.Button(root, text=Undo, command=lambda:d.undo_event(None))
undo.pack(side='left')
redo = tk.Button(root, text=Redo, command=lambda:d.redo_event(None))
redo.pack(side='left')
dump = tk.Button(root, text=Dump, command=lambda:d.dump_event(None))
dump.pack(side='left')

root.mainloop()

if __name__ == __main__:
import unittest
unittest.main('idlelib.idle_test.test_undodelegator', verbosity=2,
  exit=False)
from idlelib.idle_test.htest import run
run(_undo_delegator)

--

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



[issue11783] email parseaddr and formataddr should be IDNA aware

2014-06-11 Thread Milan Oberkirch

Milan Oberkirch added the comment:

Ping :)

--
nosy: +zvyn

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 11a920a26f13 by Vinay Sajip in branch '3.4':
Issue #21709: Remove references to __file__ when part of a frozen application.
http://hg.python.org/cpython/rev/11a920a26f13

New changeset 149cc6364180 by Vinay Sajip in branch 'default':
Closes #21709: Merged fix from 3.4.
http://hg.python.org/cpython/rev/149cc6364180

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue12989] Consistently handle path separator in Py_GetPath on Windows

2014-06-11 Thread STINNER Victor

STINNER Victor added the comment:

Hum, it would be nice to have a unit test for this change.

--

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



[issue21703] IDLE: Test UndoDelegator

2014-06-11 Thread Saimadhav Heblikar

Saimadhav Heblikar added the comment:

It was WidgetRedirector which was leaking.
cls.percolator.redir.close() added in tearDownClass fixes the leak.

saimadhav@debian:~/dev/34-cpython$ ./python -m test -R :: -uall test_idle 
[1/1] test_idle
beginning 9 repetitions
123456789
.
1 test OK.

The attached patch also ensures that when UndoDelegator.py is run, unittest is 
called with exit=False, so that htest is run.
The htest display is also corrected, and works the same way as without 
unittest.(with correct buttons etc).

Only problem remaining is when UndoDelegator is run,


can't invoke event command:  application has been destroyed
while executing
event generate $w ThemeChanged
(procedure ttk::ThemeChanged line 6)
invoked from within
ttk::ThemeChanged

--
Added file: 
http://bugs.python.org/file35564/test-undodelegator-refleak-fixed.diff

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



[issue21716] 3.4.1 download page link for OpenPGP signatures has no sigs

2014-06-11 Thread grossdm

Changes by grossdm m...@douglasmgross.com:


--
components: Windows
nosy: grossdm
priority: normal
severity: normal
status: open
title: 3.4.1 download page link for OpenPGP signatures has no sigs
type: enhancement
versions: Python 3.4

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



[issue21703] IDLE: Test UndoDelegator

2014-06-11 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Great. I will review the next patch (with the change in the comment) tomorrow. 
The ttk theme changed message comes up often. I believe it is specific to debug 
builds. Perhaps you could keep track of when it occurs so we can make a guess 
at the cause. I believe I asked Serhiy once and he did not then know why. I 
believe I grepped at least one of tkinter and _tkinter for ttk and did not fine 
anything. It does not cause buildbot failures, but may be involved with one of 
the warnings. It does suggest at least a minor bug, though, and it would be 
nice to fix.

The environment change warning, at least on windows, is probably from module 
tkinter._fix imported in tkinter.

--

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



[issue20577] IDLE: Remove FormatParagraph's width setting from config dialog

2014-06-11 Thread Tal Einat

Tal Einat added the comment:

What do you mean with the comment regarding pep8?

--

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Hi Vinaj,

thanks for the patch, but it doesn't really help outside of py2exe. The 
sys.frozen flag is not an official Python API and it's unlikely to become one, 
since you can freeze the whole application or just parts of it, which 
sys.frozen would not be able to address.

Instead, the modules in the stdlib should be aware of the fact that __file__ is 
not always available and provide fallback solutions.

Could you please use a fix that works for Python tools in general ?

E.g. instead of doing an equal test inf .findCaller() it may be better to use a 
regular expression or you could patch the __init__ module's co_filename into 
the module as _srcfile (after it's fully initialized).

Thanks.

--

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



[issue11783] email parseaddr and formataddr should be IDNA aware

2014-06-11 Thread Milan Oberkirch

Changes by Milan Oberkirch milan...@oberkirch.org:


--
nosy: +jesstess
Added file: http://bugs.python.org/file35565/issue11783.patch

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Vinay Sajip

Vinay Sajip added the comment:

 Could you please use a fix that works for Python tools in general?

I suggested an alternative implementation altogether in Issue #16778, but it 
was suggested that we wait for frame annotations. I'm not sure what the 
schedule for that is.

 The sys.frozen flag is not an official Python API and it's unlikely to become 
 one

Would using imp.is_frozen('logging') rather than hasattr(sys, 'frozen') meet 
your requirement here? I'm not saying it's the ideal solution, but perhaps it 
will do until frame annotations arrive and we can avoid using filenames 
altogether?

--

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 11.06.2014 11:25, Vinay Sajip wrote:
 
 Vinay Sajip added the comment:
 
 Could you please use a fix that works for Python tools in general?
 
 I suggested an alternative implementation altogether in Issue #16778, but it 
 was suggested that we wait for frame annotations. I'm not sure what the 
 schedule for that is.
 
 The sys.frozen flag is not an official Python API and it's unlikely to 
 become one
 
 Would using imp.is_frozen('logging') rather than hasattr(sys, 'frozen') meet 
 your requirement here? I'm not saying it's the ideal solution, but perhaps it 
 will do until frame annotations arrive and we can avoid using filenames 
 altogether?

I don't think any of this is needed here. _srcfile is only used to
identify the caller's stack frame and needs to be set to the co_filename
of the stack frame used by the logging.__init__ module.

Here's a sketch of what I had hinted at in my last reply:

def _get_module_filename():
return getLogger.func_code.co_filename

You simply use the .co_filename attribute of one of the module's functions
to get useable value for __file__.

--

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



[issue21717] Exclusive mode for ZipFile and TarFile

2014-06-11 Thread Antony Lee

New submission from Antony Lee:

I noticed that while lzma and bz2 already support the x (create a new file, 
raise if it already exists) flag, zipfile and tarfile don't know about it yet.  
It would be an useful addition, just as it is useful for regular open.

A quick look at both modules show that this likely only requires a little bit 
more than updating the checks in the corresponding constructors to allow x 
mode, as the modes are passed (nearly) transparently to the open() builtin.

--
components: Library (Lib)
messages: 220249
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Exclusive mode for ZipFile and TarFile
versions: Python 3.4, Python 3.5

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Vinay Sajip

Vinay Sajip added the comment:

 _srcfile is only used to identify the caller's stack frame

Not quite. It's also used to indicate whether findCaller() should be called at 
all: setting it to None avoids calling findCaller(), which might be desirable 
in some performance-sensitive scenarios.

So if you mean just call _get_module_filename() instead of accessing 
_srcFile, that won't do. If you mean set _srcFile to the return value of 
_get_module_filename(), that might work, if I e.g. move the _srcFile 
definition to after addLevelName (say) and do just

_srcFile = addLevelName.__code__.co_filename

How does that sound?

--

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



[issue21629] clinic.py --converters fails

2014-06-11 Thread Larry Hastings

Larry Hastings added the comment:

Confirmed.

--
assignee:  - larry
stage:  - needs patch

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 11.06.2014 12:32, Vinay Sajip wrote:
 
 Vinay Sajip added the comment:
 
 _srcfile is only used to identify the caller's stack frame
 
 Not quite. It's also used to indicate whether findCaller() should be called 
 at all: setting it to None avoids calling findCaller(), which might be 
 desirable in some performance-sensitive scenarios.
 
 So if you mean just call _get_module_filename() instead of accessing 
 _srcFile, that won't do. If you mean set _srcFile to the return value of 
 _get_module_filename(), that might work, if I e.g. move the _srcFile 
 definition to after addLevelName (say) and do just
 
 _srcFile = addLevelName.__code__.co_filename
 
 How does that sound?

That's what I meant, yes. Please also add some comment explaining
why this is done in this way.

FWIW: Given that __file__ is not always set, it may be worthwhile
introducing some generic helper to the stdlib which uses the
.co_filename attribute to get the compile time filename as fallback
in case __file__ is not set.

Thanks,
-- 
Marc-Andre Lemburg
eGenix.com

--

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



[issue11783] email parseaddr and formataddr should be IDNA aware

2014-06-11 Thread Milan Oberkirch

Milan Oberkirch added the comment:

Here comes an updated patch based on 'email_address_idna.patch' without 
breaking smtplib (as the previous patches did).

--
Added file: http://bugs.python.org/file35566/issue11783-rdm-fixed.patch

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Vinay Sajip

Vinay Sajip added the comment:

 Please also add some comment explaining why this is done in this way.

Natürlich :-)

 it may be worthwhile introducing some generic helper to the stdlib

Wouldn't you have to pass in a function (or code object) from a specific 
module, though? It seems more logical to have __file__ set, even for frozen 
modules (after all, if it's there in a code object's co_filename, is there some 
reason it shouldn't be exposed as a module attribute? (Even though it isn't at 
the moment.)

--

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



[issue21629] clinic.py --converters fails

2014-06-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6b2db7fc17f7 by Larry Hastings in branch '3.4':
Issue #21629: Fix Argument Clinic's --converters feature.
http://hg.python.org/cpython/rev/6b2db7fc17f7

--
nosy: +python-dev

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



[issue21709] logging.__init__ assumes that __file__ is always set

2014-06-11 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 11.06.2014 13:22, Vinay Sajip wrote:
 
 Vinay Sajip added the comment:
 
 Please also add some comment explaining why this is done in this way.
 
 Natürlich :-)

Prima :-)

 it may be worthwhile introducing some generic helper to the stdlib
 
 Wouldn't you have to pass in a function (or code object) from a specific 
 module, though? It seems more logical to have __file__ set, even for frozen 
 modules (after all, if it's there in a code object's co_filename, is there 
 some reason it shouldn't be exposed as a module attribute? (Even though it 
 isn't at the moment.)

Well, I guess passing in a reference to the module would suffice. The
function could then look around for functions, methods, etc. to find
a usable code object.

I agree that having a __file__ attribute in frozen modules would
be helpful, since it's obviously not widely known that this
attribute does not always exist (just grep the stdlib as example,
in particular the test suite).

The module object's PyModule_GetFilenameObject() even reports a missing
__file__ attribute as a SystemError.

Perhaps something to discuss on python-dev.

--

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



[issue21629] clinic.py --converters fails

2014-06-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8b4b8f5d7321 by Larry Hastings in branch 'default':
Issue #21629: Merge from 3.4.
http://hg.python.org/cpython/rev/8b4b8f5d7321

--

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



[issue21629] clinic.py --converters fails

2014-06-11 Thread Larry Hastings

Changes by Larry Hastings la...@hastings.org:


--
resolution:  - fixed
stage: needs patch - resolved
status: open - closed

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



[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd

2014-06-11 Thread Larry Hastings

Larry Hastings added the comment:

With this patch applied the test passes.  (Patch is against 3.4 branch.)  Look 
good?

--
keywords: +patch
Added file: http://bugs.python.org/file35567/larry.bad.zipfile.1.diff

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



[issue3068] IDLE - Add an extension configuration dialog

2014-06-11 Thread Tal Einat

Tal Einat added the comment:

Ned, many thanks for the review and detailed feedback!

Here are responses to your comments

1. Thanks for the code suggestion regarding the menudefs! That's a good catch. 
I have an OSX box for such testing.

2. I'll check this out. Could you perhaps explain or point me to resources 
regarding how to run IDLE with various Tk implementations on OSX?

3. Unfortunately, IDLE's config mechanism doesn't have special support for 
options with only several valid values, as would have been ideal for 
ParenMatch's style parameter. As it is, these are just considered strings, 
and no explicit error occurs if an invalid value is specified. Without 
upgrading the config mechanism itself, the config dialog has no way of 
supplying the valid values and/or validating user input of such values. This 
could be useful, but should be considered a separate issue IMO. I would be 
happy to add relevant support to the dialog once the underlying support is 
implemented.

4. Regarding having thing updated only on new windows or after restart, AFAIK 
that is currently the case with many options in the existing config dialog. 
Ideally the behavior would be consistent for all config options, and even more 
ideally all config changes would take effect immediately. However, that would 
require major changes to IDLE. Again, I think this is outside the scope of this 
issue.

5. I completely agree that the button for boolean options looks horrible. 
Suggestions for a better Tk widget to use are welcome!

Finally, regarding

--

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



[issue21712] fractions.gcd failure

2014-06-11 Thread Mark Dickinson

Mark Dickinson added the comment:

Agreed with Tim.

Oddly enough[1], remembering that with binary floating-point numbers, what you 
see is not what you get[2], it turns out that 8.881784197001252e-16 (= 
Fraction(1, 1125899906842624)) is in fact *exactly* the right answer, in that 
it's a generator for the additive subgroup of the rationals generated by 2.7 (= 
Fraction(3039929748475085, 1125899906842624)) and 107.3 
(=Fraction(7550566250263347, 70368744177664)).

[1] Actually not so odd, given that % is a perfectly exact operation when 
applied to two positive finite floats.
[2] https://docs.python.org/2/tutorial/floatingpoint.html

--

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



[issue13564] ftplib and sendfile()

2014-06-11 Thread Giampaolo Rodola'

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


Added file: http://bugs.python.org/file35568/ftplib-sendfile5.patch

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



[issue13564] ftplib and sendfile()

2014-06-11 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Updated patch which uses the newly added socket.sendfile() method (issue 17552).

--
assignee:  - giampaolo.rodola
type: enhancement - performance
versions: +Python 3.5 -Python 3.4

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



[issue13559] Use sendfile where possible in httplib

2014-06-11 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Patch in attachment uses the newly added socket.sendfile() method (issue 17552).

--
keywords: +patch
type: enhancement - performance
Added file: http://bugs.python.org/file35569/httplib-sendfile.patch

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



[issue21718] sqlite3 cursor.description seems to rely on incomplete statement parsing for detection

2014-06-11 Thread mike bayer

New submission from mike bayer:

Per DBAPI and pysqlite docs, .description must be available for any SELECT 
statement regardless of whether or not rows are returned.  However, this fails 
for SELECT statements that aren't simple SELECTs, such as those that use CTEs 
and therefore start out with WITH::

import sqlite3
conn = sqlite3.connect(:memory:)

cursor = conn.cursor()
cursor.execute(
create table foo (id integer primary key, data varchar(20))
)

cursor.execute(
insert into foo (id, data) values (10, 'ten')
)

cursor.execute(
with bar as (select * from foo)
select * from bar where id = 10
)

assert cursor.description is not None


cursor.execute(
with bar as (select * from foo)
select * from bar where id = 11
)

assert cursor.description is not None


the second statement returns no rows and cursor.description is None.   
Libraries like SQLAlchemy which rely on this to determine that the statement 
supports fetchone() and similar are blocked.

--
components: Library (Lib)
messages: 220263
nosy: zzzeek
priority: normal
severity: normal
status: open
title: sqlite3 cursor.description seems to rely on incomplete statement parsing 
for detection
type: behavior

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



[issue21693] Broken link to Pylons in the HOWTO TurboGears documentation

2014-06-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9438a8aa3622 by Senthil Kumaran in branch '2.7':
#21693 - Fix the broken link for pylons project.
http://hg.python.org/cpython/rev/9438a8aa3622

New changeset 08fa17130fb3 by Senthil Kumaran in branch '3.4':
#21693 - Fix the broken link for pylons project.
http://hg.python.org/cpython/rev/08fa17130fb3

--
nosy: +python-dev

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



[issue21693] Broken link to Pylons in the HOWTO TurboGears documentation

2014-06-11 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Fixed these. Thanks for the report.

--
nosy: +orsenthil
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue21719] Returning Windows file attribute information via os.stat()

2014-06-11 Thread Ben Hoyt

New submission from Ben Hoyt:

I asked recently on python-dev [1] about adding a st_winattrs attribute to 
stat result objects on Windows, to return the full set of Windows file 
attribute bits, such as hidden or compressed status. Copying from that 
thread for a bit more context here:

Python's os.stat() simply discards most of the file attribute
information fetched via the Win32 system calls. On Windows, os.stat()
calls CreateFile to open the file and get the dwFileAttributes value,
but it throws it all away except the FILE_ATTRIBUTE_DIRECTORY and
FILE_ATTRIBUTE_READONLY bits. See CPython source at [2].

Given that os.stat() returns extended, platform-specific file
attributes on Linux and OS X platforms (for example,
st_blocks, st_rsize, etc), it seems that Windows is something of a
second-class citizen here.

There are several questions on StackOverflow about how to get this
information on Windows, and one has to resort to ctypes. For example,
[3].

To solve this problem, I think we should add a st_winattrs attribute to the 
object returned by os.stat() on
Windows. And we should add the relevant Win32 FILE_ATTRIBUTE_* constants to the 
stat module.

Then, similarly to existing code like hasattr(st, 'st_blocks') on
Linux, you could write a cross-platform function to determine if a
file was hidden, something like so:

def is_hidden(path):
if startswith(os.path.basename(path), '.'):
return True
st = os.stat(path)
return getattr(st, 'st_winattrs', 0)  FILE_ATTRIBUTE_HIDDEN != 0

There was general support for this idea on python-dev (see [4] [5] [6]), so I'd 
love to see this in Python 3.5.

Basically we need to add a st_winattrs integer attribute to the win32_stat 
struct in posixmodule.c and add the FILE_ATTRIBUTE_* constants to _stat.c, as 
well as adding Windows-specific tests and documentation.

I've never compiled CPython on Windows, but I aim to provide a patch for this 
at some stage soonish. Feedback and other patches welcome in the meantime. :-)

[1] https://mail.python.org/pipermail/python-dev/2014-June/134990.html
[2] https://github.com/python/cpython/blob/master/Modules/posixmodule.c#L1462
[3] http://stackoverflow.com/a/6365265
[4] https://mail.python.org/pipermail/python-dev/2014-June/134993.html
[5] https://mail.python.org/pipermail/python-dev/2014-June/135006.html
[6] https://mail.python.org/pipermail/python-dev/2014-June/135007.html

--
components: Library (Lib)
messages: 220266
nosy: benhoyt, ethan.furman, zach.ware
priority: normal
severity: normal
status: open
title: Returning Windows file attribute information via os.stat()
type: enhancement
versions: Python 3.5

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



[issue21720] TypeError: Item in ``from list'' not a string message

2014-06-11 Thread David Szotten

New submission from David Szotten:

```
 __import__('fabric.', fromlist=[u'api'])
Traceback (most recent call last):
  File stdin, line 1, in module
```

accidentally ended up with something like this via some module that was using 
`unicode_literals`. stumped me for a second until i realised that my variable 
was a string, but not `str`. would be nice with a custom error message if this 
is a unicode string, explicitly mentioning that these must not be unicode or 
similar

--
messages: 220267
nosy: davidszotten
priority: normal
severity: normal
status: open
title: TypeError: Item in ``from list'' not a string  message
type: enhancement
versions: Python 2.7

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



[issue21718] sqlite3 cursor.description seems to rely on incomplete statement parsing for detection

2014-06-11 Thread R. David Murray

R. David Murray added the comment:

It is true that the sqlite interface does not support WITH currently.  It is an 
interesting question whether or not we could change this as a bug fix or 
not...I suppose it depends on whether or not it changes any behavior other than 
making .description work.

--
nosy: +r.david.murray

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



[issue21714] Path.with_name can construct invalid paths

2014-06-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I think raising ValueError is the way to go. Would you like to try writing a 
patch for it?

--
nosy: +pitrou
stage:  - needs patch
type:  - behavior

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



[issue21721] socket.sendfile() should use TransmitFile on Windows

2014-06-11 Thread Giampaolo Rodola'

New submission from Giampaolo Rodola':

This is a follow up of issue 17552 which adds a new socket.sendfile() method 
taking advantage of high-performance os.sendfile() on UNIX.
The same thing could be done for Windows by using TransmitFile:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740565(v=vs.85).aspx

--
messages: 220270
nosy: akira, asvetlov, christian.heimes, giampaolo.rodola, gvanrossum, 
josh.rosenberg, josiah.carlson, neologix, pitrou, python-dev, rosslagerwall, 
yselivanov
priority: normal
severity: normal
stage: needs patch
status: open
title: socket.sendfile() should use TransmitFile on Windows
type: enhancement
versions: Python 3.5

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



[issue21696] Idle: test syntax of configuration files

2014-06-11 Thread Saimadhav Heblikar

Saimadhav Heblikar added the comment:

Attaching a patch to test the default configuration files. config-keys.def will 
be added once the issues related to it[1] are resolved.
In this patch, test that the configHandler module can successfully extract the 
values. For places where numeric values are expected, ensure that the values 
are correct. For strings, it only ensures that the values are reasonably 
correct.





[1] https://mail.python.org/pipermail/idle-dev/2014-June/003431.html

--
keywords: +patch
Added file: http://bugs.python.org/file35570/test-configuration.diff

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



[issue21719] Returning Windows file attribute information via os.stat()

2014-06-11 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Instead of the somewhat cryptic name winattrs, I suggest to call it 
st_file_attributes, as it is called in the Windows API (actually, 
GetFileAttributesEx calls it dwFileAttributes, but st_file_attributes could be 
considered a Pythonic spelling of that).

--
nosy: +loewis

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



[issue21205] Add a name to Python generators

2014-06-11 Thread STINNER Victor

STINNER Victor added the comment:

gen_qualname.patch: add a new __qualname__ attribute to generators and change 
how the name is set: use the name of the function, instead of using the name of 
the code.

Incompatible changes of this patch:

- repr(generator) now shows the qualified name instead of the name
- generator name comes from the function name which may be different

If the function has a name different than the code (if the function name was 
changed, for example by @functools.wraps), the generator now gets the name from 
the function, no more from the code object. IMO it's the expected behaviour, 
and it's more useful.

I'm writing on email to python-dev to discuss these changes.

--
keywords: +patch
title: Unable to make decorated generator object to inherit generator 
function's __name__ - Add a name to Python generators
Added file: http://bugs.python.org/file35571/gen_qualname.patch

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



[issue21719] Returning Windows file attribute information via os.stat()

2014-06-11 Thread Ben Hoyt

Ben Hoyt added the comment:

Fair call -- st_file_attributes sounds good to me, and matches the prefix of 
the FILE_ATTRIBUTES_* constants better too.

--

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



[issue21719] Returning Windows file attribute information via os.stat()

2014-06-11 Thread STINNER Victor

STINNER Victor added the comment:

 Instead of the somewhat cryptic name winattrs, I suggest to call it 
 st_file_attributes (...)

On Windows, os.stat() calls GetFileInformationByHandle() which fills a 
BY_HANDLE_FILE_INFORMATION structure, and this structure has a dwFileAttributes 
attribute. The os.stat() calls also GetFileType().
http://msdn.microsoft.com/en-us/library/windows/desktop/aa364952%28v=vs.85%29.aspx

So I agree that os.stat().st_file_attributes is less surprising for Windows 
developers and it is more homogenous with FILE_ATTRIBUTE_xxx constants.

--
nosy: +haypo

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



  1   2   >