[issue23865] Fix possible leaks in close methods

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fe340c2a220e by Serhiy Storchaka in branch '2.7':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/fe340c2a220e

New changeset 7f8cd879687b by Serhiy Storchaka in branch '3.4':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/7f8cd879687b

New changeset 1fb83fa2cdef by Serhiy Storchaka in branch 'default':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/1fb83fa2cdef

--

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



[issue24125] Fix for #23865 breaks docutils

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fe340c2a220e by Serhiy Storchaka in branch '2.7':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/fe340c2a220e

New changeset 7f8cd879687b by Serhiy Storchaka in branch '3.4':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/7f8cd879687b

New changeset 1fb83fa2cdef by Serhiy Storchaka in branch 'default':
Issue #24125: Saved error's line and column numbers when an error is occured
https://hg.python.org/cpython/rev/1fb83fa2cdef

--
nosy: +python-dev

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



[issue24009] Get rid of rare format units in PyArg_Parse*

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d65233f630e1 by Serhiy Storchaka in branch 'default':
Issue #24009: Got rid of using rare y# format unit in TextIOWrapper.tell().
https://hg.python.org/cpython/rev/d65233f630e1

--
nosy: +python-dev

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



Re: Writing list of dictionaries to CSV

2015-05-06 Thread Cecil Westerhof
Op Wednesday 6 May 2015 07:32 CEST schreef Kashif Rana:

 thanks for the feedback. I think its problem with excel itself,
 showing wrong value. Because when I opened the csv file in text
 editor, I can see correct value but opening in excel showing wrong
 value. What I can do to see correct in excel as well.

A Python mailing list is not the right place to ask that. You can
better use a Microsoft (office) mailing list.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2015-05-06 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.4, Python 3.5 -Python 3.1, Python 3.2

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

One issue with your code - what would you expect str(test) to produce? 
dir/test.txt or dir\test.txt? That's the point of the flavour - is it a 
Windows path or a Unix path?

Agreed that an easier method of creating Path subclasses that handle this type 
of thing would be useful, but any solution needs to make sure that developers 
don't overlook the Windows vs Unix implications.

Can you give an actual use case (as opposed to the toy example)?

--
nosy: +paul.moore

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



Re: Encrypt python files

2015-05-06 Thread Albert-Jan Roskam via Python-list

-
On Wed, May 6, 2015 11:04 AM CEST Steven D'Aprano wrote:

On Wednesday 06 May 2015 17:23, Palpandi wrote:

 On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:
 Hi,
 
 What are the ways to encrypt python files?
 
 No, I just want to hide the scripts from others.

Why, are you ashamed of your code?

Python is free, open source software. Hiding the code from others is not a 
priority for the developers of the language. Besides, you can't hide the 
code unless you only operate the application via a web service, or similar. 
As soon as you give people a copy of the code, whether it is binary code or 
source code, they have a copy of it and can look at it and work out how what 
it does.

If hiding the code was good for security, why are there so many viruses 
and spybots and worms and other malware for Windows?

No, as far as I am concerned, trying to hide the code is a waste of time 
with Python. But if you absolutely must, you can distribute the .pyc files 
instead of the .py files, and that will discourage casual tinkerers from 
poking around in the program. The .pyc file is compiled to byte-code rather 
than source code, so it's not readable without running it through a 
decompiler.

I used the marshal module before as a faster alternative to shelve (I 
marshalled a huge dictionary). I always understood marshal files require the 
*exact* same interpreter version (incl. built number). Do the same limitations 
apply for .pyc files? Isn't it the same format?

We have a VCS with an option to use private repos. I am always wary of users 
who want to use this feature. Why would you not want to share your code with 
your colleagues? Embarrassed about unreadable crappy code, perhaps?  


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


ANN: python-blosc 1.2.7 released

2015-05-06 Thread Francesc Alted
=
Announcing python-blosc 1.2.7
=

What is new?


Updated to use c-blosc v1.6.1.  Although that this supports AVX2, it is
not enabled in python-blosc because we still need a way to devise how to
detect AVX2 in the underlying platform.

At any rate, c-blosc 1.6.1 fixed an important bug in the blosclz codec that
a release was deemed important.

For more info, you can have a look at the release notes in:

https://github.com/Blosc/python-blosc/wiki/Release-notes

More docs and examples are available in the documentation site:

http://python-blosc.blosc.org


What is it?
===

Blosc (http://www.blosc.org) is a high performance compressor
optimized for binary data.  It has been designed to transmit data to
the processor cache faster than the traditional, non-compressed,
direct memory fetch approach via a memcpy() OS call.

Blosc is the first compressor that is meant not only to reduce the size
of large datasets on-disk or in-memory, but also to accelerate object
manipulations that are memory-bound
(http://www.blosc.org/docs/StarvingCPUs.pdf).  See
http://www.blosc.org/synthetic-benchmarks.html for some benchmarks on
how much speed it can achieve in some datasets.

Blosc works well for compressing numerical arrays that contains data
with relatively low entropy, like sparse data, time series, grids with
regular-spaced values, etc.

python-blosc (http://python-blosc.blosc.org/) is the Python wrapper for
the Blosc compression library.

There is also a handy tool built on Blosc called Bloscpack
(https://github.com/Blosc/bloscpack). It features a commmand line
interface that allows you to compress large binary datafiles on-disk.
It also comes with a Python API that has built-in support for
serializing and deserializing Numpy arrays both on-disk and in-memory at
speeds that are competitive with regular Pickle/cPickle machinery.


Installing
==

python-blosc is in PyPI repository, so installing it is easy:

$ pip install -U blosc  # yes, you should omit the python- prefix


Download sources


The sources are managed through github services at:

http://github.com/Blosc/python-blosc


Documentation
=

There is Sphinx-based documentation site at:

http://python-blosc.blosc.org/


Mailing list


There is an official mailing list for Blosc at:

bl...@googlegroups.com
http://groups.google.es/group/blosc


Licenses


Both Blosc and its Python wrapper are distributed using the MIT license.
See:

https://github.com/Blosc/python-blosc/blob/master/LICENSES

for more details.



  **Enjoy data!**

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

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


[issue24009] Get rid of rare format units in PyArg_Parse*

2015-05-06 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Note that these format characters can also be used outside of CPython.

--
nosy: +ronaldoussoren

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



Json Comaprision

2015-05-06 Thread pra devOPS
Hi All:


I wanted to compare two json files ignoring few of the keys in the json
files.

Can anybody suggest me few things?

Thanks,
Siva
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Encrypt python files

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 17:23, Palpandi wrote:

 On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:
 Hi,
 
 What are the ways to encrypt python files?
 
 No, I just want to hide the scripts from others.

Why, are you ashamed of your code?

Python is free, open source software. Hiding the code from others is not a 
priority for the developers of the language. Besides, you can't hide the 
code unless you only operate the application via a web service, or similar. 
As soon as you give people a copy of the code, whether it is binary code or 
source code, they have a copy of it and can look at it and work out how what 
it does.

If hiding the code was good for security, why are there so many viruses 
and spybots and worms and other malware for Windows?

No, as far as I am concerned, trying to hide the code is a waste of time 
with Python. But if you absolutely must, you can distribute the .pyc files 
instead of the .py files, and that will discourage casual tinkerers from 
poking around in the program. The .pyc file is compiled to byte-code rather 
than source code, so it's not readable without running it through a 
decompiler.


-- 
Steve

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


Re: DRM is self-defeating (was: Encrypt python files)

2015-05-06 Thread Albert-Jan Roskam via Python-list

-
On Wed, May 6, 2015 9:41 AM CEST Ben Finney wrote:

Palpandi palpandi...@gmail.com writes:

 On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:

  What are the ways to encrypt python files?

 No, I just want to hide the scripts from others.

Which others? You can hide the scripts from them by never showing those
others the scripts. If you don't trust a recipient, don't let them
receive the file.

snip

The only feasible solution is to distribute files only to those
recipients you want to have them, and can trust to do with them as you
ask. If you don't trust a recipient, don't hand the files to them.

Can tools like py2exe or cx_freeze also be used to obfuscate python source code?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: DRM is self-defeating (was: Encrypt python files)

2015-05-06 Thread Chris Angelico
On Wed, May 6, 2015 at 6:24 PM, Albert-Jan Roskam via Python-list
python-list@python.org wrote:
The only feasible solution is to distribute files only to those
recipients you want to have them, and can trust to do with them as you
ask. If you don't trust a recipient, don't hand the files to them.

 Can tools like py2exe or cx_freeze also be used to obfuscate python source 
 code?

But barely. At very worst, you suppress your comments and variable
names, but all your actual functionality is all there still - it has
to be, or it won't run.

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


[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread levkivskyi

New submission from levkivskyi:

The matrix multiplication operator @ is going to be introduced in Python 3.5 
and I am thinking about the following idea:

The semantics of matrix multiplication is the composition of the corresponding 
linear transformations.
A linear transformation is a particular example of a more general concept - 
functions.
The latter are frequently composed with (wrap) each other. For example:

plot(real(sqrt(data)))

However, it is not very readable in case of many wrapping layers. Therefore, it 
could be useful to employ
the matrix multiplication operator @ for indication of function composition. 
This could be done by such (simplified) decorator:

class composable:

def __init__(self, func):
self.func = func

def __call__(self, arg):
return self.func(arg)

def __matmul__(self, other):
def composition(*args, **kwargs):
return self.func(other(*args, **kwargs))
return composable(composition)

I think using such decorator with functions that are going to be deeply wrapped
could improve readability.
You could compare (note that only the outermost function should be decorated):

plot(sorted(sqrt(real(data_array vs. (plot @ sorted @ sqrt @ real) 
(data_array)

I think the latter is more readable, also compare

def sunique(lst):
return sorted(list(set(lst)))

vs.

sunique = sorted @ list @ set

Apart from readability, there are following pros of the proposed decorator:

1. Similar semantics as for matrix multiplication.
2. Same symbol for composition as for decorators.
3. The symbol @ resembles mathematical notation for function composition: ∘

I think it could be a good idea to add such a decorator to the stdlib functools 
module.

--
components: Library (Lib)
messages: 242653
nosy: levkivskyi
priority: normal
severity: normal
status: open
title: Add 'composable' decorator to functools (with @ matrix multiplication 
syntax)
type: enhancement
versions: Python 3.5

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



Re: Throw the cat among the pigeons

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 14:05, Steven D'Aprano wrote:

[...]

Here are those anomalous timing results again:

 code = fact(5)
 t1 = Timer(code, setup=from __main__ import factorial_while as fact)
 t2 = Timer(code, setup=from __main__ import factorial_reduce as fact)
 t3 = Timer(code, setup=from __main__ import factorial_forloop1 as fact)
 t4 = Timer(code, setup=from __main__ import factorial_forloop2 as fact)
 for t in (t1, t2, t3, t4):
 print(min(t.repeat(repeat=3, number=2)))
 
 
 which takes about two minutes on my computer, and prints:
 
 8.604736926034093  # while loop
 10.786483339965343  # reduce
 10.91099695302546  # for loop
 10.821452282369137  # silly version of the for loop
[...]
 What is surprising is that for very large input like this, the while loop
 is significantly faster than reduce or either of the for-loops. I cannot
 explain that result.

I re-ran the results on a different computer, and got similar results:

7.364120149984956
9.26512472704053
9.141491871327162
9.16900822892785

The while loop is surprisingly faster for calculating fact(5). A thought 
came to mind: the while loop is different from the other three versions, in 
that it performs the multiplications from n down to 2, rather than 2 up to 
n. Maybe that has something to do with it?

Introducing version five of the factorial:

def factorial_reduce2(n):
assert n = 0
return reduce(mul, range(n, 1, -1), 1)

t5 = Timer(code, setup=from __main__ import factorial_reduce2 as fact)
for t in (t1, t2, t3, t4, t5):
print(min(t.repeat(repeat=3, number=2)))



And results:

7.36792928725481  # while loop
9.271950023248792  # reduce, counting up
9.14769447594881  # for loop
9.154150342568755  # silly for loop
7.430811045691371  # reduce, counting down


My interpretation of this is that the difference has something to do with 
the cost of multiplications. Multiplying upwards seems to be more expensive 
than multiplying downwards, a result I never would have predicted, but 
that's what I'm seeing. I can only guess that it has something to do with 
the way multiplication is implemented, or perhaps the memory management 
involved, or something. Who the hell knows?


Just to be sure:

def factorial_forloop3(n):
assert n = 0
result = 1
for i in range(n, 1, -1):
result *= i
return result

t6 = Timer(code, setup=from __main__ import factorial_forloop3 as fact)
print(min(t6.repeat(repeat=3, number=2)))


which prints 7.36256698705256.


Lesson to be learned: what you think is important may not be, and what you 
think is irrelevant may be.



Historical fact: for a period of about 60 years, long after the trick to 
curing and preventing scurvy was known, the British navy suffered greatly 
from scurvy again (although not to the same degree as they had been in the 
17th and 18th centuries). The problem was due to confusion between *lemons* 
and *limes*. The navy started by using the term lime for both lemons and 
sweet limes from the Mediterranean, as well as West Indian limes: three 
different citrus fruit. To cut costs and encourage British commerce, the 
navy gradually stopping buying lemons from Spain and swapped over almost 
entirely to West Indian limes. Unfortunately limes, and especially West 
Indian limes, have significantly less Vitamin C than lemons, and the 
sailors' daily allowance was about 75% less effective on ships that used 
limes than for those that used Spanish lemons. Scurvy, which had practically 
be eradicated in the 1850s and 60s, returned, and was a significant factor 
in World War One. (Especially for the French and Russian armies.)

This simple confusion wasn't sorted out until the 1920s, long after Vitamin 
C was isolated and named. Apparently nobody noticed, or cared, that the two 
different fruit tasted different and looked different, or concluded that 
perhaps they had different medicinal properties.

But then, for many decades, vinegar and dilute sulphuric acid were 
recommended as cures for scurvy *solely* on the basis that they were acidic 
just like proven cures oranges, lemons and sauerkraut.



-- 
Steven

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


Re: Encrypt python files

2015-05-06 Thread David Palao
Hello,
I'm afraid your question is either not well defined (or not well
enough) or wrong for this list, at least as I understand it.
Could you please explain it better?

Best

2015-05-06 8:37 GMT+02:00 Palpandi palpandi...@gmail.com:
 Hi,

 What are the ways to encrypt python files?
 --
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Throw the cat among the pigeons

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 15:58, Ian Kelly wrote:

 On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 Only the minimum is statistically useful.
 
 I disagree. The minimum tells you how fast the code *can* run, under
 optimal circumstances. The mean tells you how fast it *realistically*
 runs, under typical load. Both can be useful to measure.

Er, not even close. Running code using timeit is in no way the same as 
running code for real under realistic circumstances. The fact that you are 
running the function or code snippet in isolation, in its own scope, via 
exec, rather than as part of some larger script or application, should be a 
hint. timeit itself has overhead, so you cannot measure the time taken by 
the operation alone, you can only measure the time taken by the operation 
within the timeit environment. We have no reason to think that the 
distribution of noise under timeit will be even vaguely similar to the noise 
when running in production.

The purpose of timeit is to compare individual algorithms, in as close as 
possible to an equal footing with as little noise as possible. If you want 
to profile code used in a realistic application, use a profiler, not timeit. 
And even that doesn't tell you how fast the code would be alone, because the 
profiler adds overhead.

Besides, typical load is a myth -- there is no such thing. A high-end 
Windows web server getting ten thousand hits a minute, a virtual machine 
starved for RAM, a Mac laptop, a Linux server idling away with a load of 0.1 
all day... any of those machines could run your code. How can you *possibly* 
say what is typical? The very idea is absurd.



-- 
Steve

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


[issue24125] Fix for #23865 breaks docutils

2015-05-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


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

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



[issue20178] Derby #9: Convert 52 sites to Argument Clinic across 11 files

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For Modules/_curses_panel.c there is special issue, #20171, with the patch.

issue20178-sqlite-01.patch is applied almost clearly, but due to changes to 
Argument Clinic it should be updated. Perhaps more functions can be converted 
(functions that don't use PyArg_Parse* are worth to be converted too).

--

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



Re: Writing list of dictionaries to CSV

2015-05-06 Thread Chris Angelico
On Wed, May 6, 2015 at 3:32 PM, Kashif Rana kashifran...@gmail.com wrote:
 thanks for the feedback. I think its problem with excel itself, showing wrong 
 value. Because when I opened the csv file in text editor, I can see correct 
 value but opening in excel showing wrong value. What I can do to see correct 
 in excel as well.


Simple fix: Ditch Excel.

Slightly more complicated fix: Open the file, then select everything,
and tell Excel that it's plain text. You can't say that in the CSV
file.

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


[issue12202] Check status returns in msilib.SummaryInformation.GetProperty()

2015-05-06 Thread Mark Lawrence

Mark Lawrence added the comment:

The code change to _msi.c is minimal, the bulk of the patch is additional test 
code.  I think we could still use this.  Thoughts?

See also #1104.

--
components: +Windows
nosy: +BreamoreBoy, steve.dower, tim.golden, zach.ware

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



DRM is self-defeating (was: Encrypt python files)

2015-05-06 Thread Ben Finney
Palpandi palpandi...@gmail.com writes:

 On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:

  What are the ways to encrypt python files?

 No, I just want to hide the scripts from others.

Which others? You can hide the scripts from them by never showing those
others the scripts. If you don't trust a recipient, don't let them
receive the file.

I suspect you are asking “how can I distribute Python modules to people
without those people being able to read them”? You can't, because
executing the file requires reading its contents.

Anyone who has a machine that can execute the file has a machine that
must, by necessity, read its contents.


This is the dilemma of those who think they want Digital Restrictions
Management (DRM): attempting to treat recipients as untrustworthy, while
still telling them they can use the files.

If you a person is in possession of the file you're trying to restrict,
on a machine they possess, with a key needed to unlock the content, then
that person is in possession of everything needed to unlock the content.

On the other hand, if one of those (e.g. the key to unlock the content)
is missing, then the file is useless for whatever you're saying the
recipient can do with it.

The only feasible solution is to distribute files only to those
recipients you want to have them, and can trust to do with them as you
ask. If you don't trust a recipient, don't hand the files to them.


On the other hand, if you're asking something else, you will need to be
much more explicit. You have not helped us understand what you want thus
far.

-- 
 \“This sentence contradicts itself — no actually it doesn't.” |
  `\   —Douglas Hofstadter |
_o__)  |
Ben Finney

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


Encrypt python files

2015-05-06 Thread Palpandi
Hi,

What are the ways to encrypt python files?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Encrypt python files

2015-05-06 Thread Steven D'Aprano
On Wednesday 06 May 2015 16:37, Palpandi wrote:

 Hi,
 
 What are the ways to encrypt python files?

The same as the ways to encrypt any other file. Your encryption program 
shouldn't care whether you are encrypting text files, JPEGs, mp3 audio 
files, executable binary code, Python scripts, or a giant file of all ASCII 
nulls. It will just encrypt the file regardless of what kind of file it is.

What encryption program are you using?



-- 
Steve

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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Changes by Christophe BAL projet...@gmail.com:


--
title: Direct sub-classing of pathless.Path - Direct sub-classing of 
pathlib.Path

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



[issue24124] Two versions of instructions for installing Python modules

2015-05-06 Thread Nick Coghlan

Nick Coghlan added the comment:

As far as I'm aware, it's only confusing if you're poking around in the source 
tree, rather than using the built docs at docs.python.org (where the link to 
the legacy docs is now hidden away inside the distutils module docs).

The legacy docs remain in place to preserve existing deep links and because 
they're the only current documentation of various distutils details that are 
needed to *implement* tools like pip and setuptools.

In a more ideal world, we'd have a distutils expert with the time to go through 
the legacy docs, cull the outdated stuff, and lift the rest up into the 
distutils module documentation, but all the folks that might plausibly have the 
expertise to do that also have far more interesting things to do with their 
time :(

--

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



Re: DRM is self-defeating (was: Encrypt python files)

2015-05-06 Thread Chris Angelico
On Wed, May 6, 2015 at 5:41 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 The only feasible solution is to distribute files only to those
 recipients you want to have them, and can trust to do with them as you
 ask. If you don't trust a recipient, don't hand the files to them.

in today's world, that basically gives two good options:

1) Distribute your code far and wide, let every man and his dog clone
your source code, and license it so they're allowed to; or
2) Host your code on a server that people don't get access to, and
have them interact with it remotely.

Either way works really well. You can have closed-source software that
people never directly see, yet benefit from (and potentially pay you),
or you can let people see everything they're running. The problem only
comes when you try to hybridize.

(Aside: Most people carry mobile phones they don't truly own/control,
so they're restricted by what the device manufacturer offers them.
Despite looking superficially like the first case, it's really more
like the second.)

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


Re: Throw the cat among the pigeons

2015-05-06 Thread Ian Kelly
On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Only the minimum is statistically useful.

I disagree. The minimum tells you how fast the code *can* run, under
optimal circumstances. The mean tells you how fast it *realistically*
runs, under typical load. Both can be useful to measure.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Encrypt python files

2015-05-06 Thread Palpandi
On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:
 Hi,
 
 What are the ways to encrypt python files?

No, I just want to hide the scripts from others.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21800] Implement RFC 6855 (IMAP Support for UTF-8) in imaplib.

2015-05-06 Thread Maciej Szulik

Maciej Szulik added the comment:

Yes, I can update that (that IMAP testing bug - 
http://bugs.python.org/issue22137, is taking me longer than I expected it ;)). 
I just want to make sure if I understand you correctly what's needs to be done 
is removing the utf8_enable code from init, we will enable ascii by default and 
only explicit call to enable method will enable it, am I missing something?

--

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



[issue23880] Tkinter: getint and getdouble should support Tcl_Obj

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Committed in the default branch only. If other issues with Tcl/Tk 8.5 or 8.6 
will be reported, we could apply general solution instead of particular 
workarounds in maintained branches too.

--
assignee:  - serhiy.storchaka
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue23880] Tkinter: getint and getdouble should support Tcl_Obj

2015-05-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cb80dd82d3da by Serhiy Storchaka in branch 'default':
Issue #23880: Tkinter's getint() and getdouble() now support Tcl_Obj.
https://hg.python.org/cpython/rev/cb80dd82d3da

--
nosy: +python-dev

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Steven D'Aprano

Steven D'Aprano added the comment:

I don't think this is a bug. I think it is just a case that you have to be 
careful when calling functions, you actually do call the function. And that it 
returns what you think it does.

I think the critical point is this:

It turned our that I forgot to return the decorator and instead got the 
default None. But my tests didn't warn me about that.

The solution to that is to always have a test that your decorator actually 
returns a function. That's what I do.

--
nosy: +steven.daprano

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



Re: Bitten by my C/Java experience

2015-05-06 Thread Gregory Ewing

BartC wrote:


So why pretend that ++ and -- don't exist?


Probably because Python would gain very little from
having them.

Main uses of ++ in C are things like integer for
loops:

   for (i = 0; i  10; i++) {...

and stepping through arrays:

   a[i++] = b[j++];

Python code usually operates at a higher level than
that.

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


Re: Encrypt python files

2015-05-06 Thread Steven D'Aprano
On Wed, 6 May 2015 07:45 pm, Albert-Jan Roskam wrote:

 I used the marshal module before as a faster alternative to shelve (I
 marshalled a huge dictionary). I always understood marshal files require
 the *exact* same interpreter version (incl. built number). Do the same
 limitations apply for .pyc files? Isn't it the same format?

marshal is currently up to version 4 of the (otherwise undocumented) file
format. Obviously that's much less than the number of minor versions of
Python, so, no, marshal does not change every release.

https://docs.python.org/3/library/marshal.html

.pyc files, on the other hand, have a magic number which changes for each
minor release of Python. I think that, in principle, it could change in a
point release (say, between 3.4.1 and 3.4.2) but in practice I don't
believe that has ever happened. I think it is safe to assume that pyc files
will be portable across any minor release (e.g. 3.4.x for any x) but not
across changes to the minor or major release.

I don't think that is an outright promise, but it is a strong convention.

And of course, other implementations may not even use .pyc files, if they
don't use the same sort of byte code. E.g. Jython compiles to JVM byte
code:

foo.py
foo$py.class


Nick Coghlan has a very good blog post about the uses of pyc only
distributed software:

http://www.curiousefficiency.org/posts/2011/04/benefits-and-limitations-of-pyc-only.html

And Ned Batchelder has a good discussion of their internals:

http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html



-- 
Steven

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


[issue24134] assertRaises can behave differently

2015-05-06 Thread Magnus Carlsson

New submission from Magnus Carlsson:

Hi

I have a little issue with the current assertRaises implementation. It seems 
that it might produce a little different results depending on how you use it.

self.assertRaises(IOError, None)

will not produce the same result as:

with self.assertRaises(IOError):
None()

In the first case everything will be fine due to the fact that assertRaises 
will actually return a context if the second callable parameters is None. The 
second case will throw a TypeError 'NoneType' object is not callable.

I don't use None directly, but replace it with a variable of unknown state and 
you get a little hole where problems can creep in. In my case I was testing 
function decorators and that they should raise some exceptions on special 
cases. It turned our that I forgot to return the decorator and instead got the 
default None. But my tests didn't warn me about that.

Bottom line is that if I use the first assertRaises(Exception, callable) I 
can't rely on it to check that the callable is actually something callable.

I do see that there is a benefit of the context way, but in my opinion current 
implementation will allow problems to go undetected. 

My solution to this would be to rename the context variant into something 
different:
with self.assertRaisesContext(Exception):
do_something()

A side note on this is that reverting back to the original behavior would allow 
you to reevaluate issue9587 for returning the actual exception.

--
components: Library (Lib)
messages: 242658
nosy: magnusc
priority: normal
severity: normal
status: open
title: assertRaises can behave differently
type: behavior
versions: Python 2.7

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



Re: Json Comaprision

2015-05-06 Thread Mark Lawrence

On 05/05/2015 20:55, pra devOPS wrote:

Hi All:


I wanted to compare two json files ignoring few of the keys in the json
files.

Can anybody suggest me few things?

Thanks,
Siva



https://docs.python.org/3/library/json.html#module-json

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


[issue2292] Missing *-unpacking generalizations

2015-05-06 Thread Thomas Wouters

Thomas Wouters added the comment:

FYI, I meant last Monday, but I forgot it was May 4th (Dutch Memorial day) and 
May 5th (Dutch Liberation day), so that got in the way :P

Should we keep this bug open for docs changes, or is there a separate issue for 
that?

--

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



[issue24122] Install fails after configure sets the extending/embedding install directory to NONE

2015-05-06 Thread Matthias Klose

Matthias Klose added the comment:

fixed for 3.4 and 3.5.

--
resolution:  - fixed
status: open - closed

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



Re: Bitten by my C/Java experience

2015-05-06 Thread Chris Angelico
On Wed, May 6, 2015 at 11:11 PM,  random...@fastmail.us wrote:
 On Mon, May 4, 2015, at 18:02, BartC wrote:
 (I think I would have picked up ++ and -- as special tokens even if
 increment/decrement ops weren't supported. Just because they would
 likely cause errors through misunderstanding.)

 There's precedent for not doing this in C itself - even though =+
 (from very early versions of C, also =-, =*, =) no longer acts as an
 add-in-place operator, it's not recognized as a special token to prevent
 errors either.

Given that the in-place operators changed to +=, -=, etc very early
on, I doubt there's anyone who is actually confused by them. And it'd
be extremely annoying to have to stop and think about parsing rules
when taking or dereferencing pointers:

/* This works */
x = y;

/* Why shouldn't this? */
x=y;

To the greatest extent possible, spaces around assignment operators
should be the domain of style guides, not syntax.

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


Re: Bitten by my C/Java experience

2015-05-06 Thread BartC

On 06/05/2015 12:19, Gregory Ewing wrote:

BartC wrote:


So why pretend that ++ and -- don't exist?


Probably because Python would gain very little from
having them.

Main uses of ++ in C are things like integer for
loops:

for (i = 0; i  10; i++) {...

and stepping through arrays:

a[i++] = b[j++];

Python code usually operates at a higher level than
that.


I think even in Python it is sometimes necessary to increment things (as 
the OP did).


But I had in mind not implementing ++ and --, but detecting them and 
issuing a warning, so forcing someone to type + + or to use 
parentheses, which is unlikely to be much of an imposition as how often 
are two unary pluses going to be used together?



--
Bartc


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


[issue24134] assertRaises can behave differently

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Possible solution is to use special sentinel instead of None.

--
keywords: +patch
nosy: +ezio.melotti, michael.foord, rbcollins, serhiy.storchaka
stage:  - patch review
versions: +Python 3.4, Python 3.5
Added file: http://bugs.python.org/file39305/assert_raises_sentinel.patch

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



[issue24136] document PEP 448

2015-05-06 Thread Benjamin Peterson

New submission from Benjamin Peterson:

PEP 448 has been implemented (#2292), but the documentation hasn't been 
updated. Updating the documentation will improve looking through

Doc/reference/*

and making sure the documentation (and grammar) for calls and assignments is 
updated for PEP 448's new syntax.

I'm marking this as easy because it might be a good first bug.

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 242668
nosy: benjamin.peterson, docs@python
priority: high
severity: normal
stage: needs patch
status: open
title: document PEP 448
type: enhancement
versions: Python 3.5

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



[issue2292] Missing *-unpacking generalizations

2015-05-06 Thread Benjamin Peterson

Benjamin Peterson added the comment:

On Wed, May 6, 2015, at 09:15, Thomas Wouters wrote:
 
 Thomas Wouters added the comment:
 
 FYI, I meant last Monday, but I forgot it was May 4th (Dutch Memorial
 day) and May 5th (Dutch Liberation day), so that got in the way :P
 
 Should we keep this bug open for docs changes, or is there a separate
 issue for that?

#24136

--

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

It looks like something in the QueryInformationJobObject API has changed with 
Windows 10. The code says:

ok = QueryInformationJobObject(job, JobObjectExtendedLimitInformation,
  info, sizeof(info), rc);
if (!ok || (rc != sizeof(info)) || !job)
error(RC_CREATE_PROCESS, LJob information querying failed);


This call looks right to me based on the MSDN documentation.

Two possibilities I can think of:
1. Bug in Windows 10, which should be reported to Microsoft.
2. the size of the JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure has changed 
in Windows 10, and the SDK used to build Python 2.7 doesn't have the new 
definition.

Do you get the same problem with Python 3.4? If so, that might indicate a 
VS2008 issue. (I don't think this is likely as I checked 
sizeof(JOBOBJECT_EXTENDED_LIMIT_INFORMATION) in VS 2008 and VS 2010 and both 
said 144...)

--

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



[issue24134] assertRaises can behave differently

2015-05-06 Thread Magnus Carlsson

Magnus Carlsson added the comment:

The solution to that is to always have a test that your decorator actually 
returns a function. That's what I do.

Yes, I agree that with more tests I would have found the problem, but sometimes 
you forget things. And to me I want the tests to fail by default or for cases 
that are unspecified.

I think the sentinel solution would come a long way of solving both the issue 
that I reported but still keep the context solution intact.

Out of curiosity, would it be a solution to have the sentinel be a real 
function?

def _sentinel():
pass

--

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



Re: Throw the cat among the pigeons

2015-05-06 Thread Chris Angelico
On Wed, May 6, 2015 at 11:12 PM, Dave Angel da...@davea.name wrote:
 I had guessed that the order of multiplication would make a big difference,
 once the product started getting bigger than the machine word size.

 Reason I thought that is that if you multiply starting at the top value (and
 end with multiplying by 2) you're spending more of the time multiplying
 big-ints.

 That's why I made sure that both Cecil's and my implementations were
 counting up, so that wouldn't be a distinction.

 I'm still puzzled, as it seems your results imply that big-int*int is faster
 than int*int where the product is also int.

Are you using Python 2 or Python 3 for your testing? In Py3, there's
no type difference, and barely no performance difference as you cross
the word-size boundary. (Bigger numbers are a bit slower to work with,
but not hugely.)

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


[issue23888] Fixing fractional expiry time bug in cookiejar

2015-05-06 Thread ssh

ssh added the comment:

Wouldn't int(float(expires) * 1e6) set the date much further in the future? I'm 
not sure why you'd do that unless the plan is to change the internal time unit 
to microseconds (which seems like a much bigger change, and overkill for 
handling this special case). Cookie strings operate at the second granularity, 
so I'm not sure if the sub-second precision is required.

I took a quick look at curl's code and test cases, and they use a time_t 
structure which doesn't have subsecond precision. Fractional time is not a part 
of their test cases.

https://github.com/bagder/curl/blob/6f8046f7a4bd3d6edcc53c2eec936105ec424d54/tests/libtest/lib517.c

https://github.com/bagder/curl/blob/664b9baf67c2c22ebaf3606298ca9c4ce0b382d2/lib/parsedate.c#L331

Wget also appears to do something similar:

http://bzr.savannah.gnu.org/lh/wget/trunk/annotate/head:/src/cookies.c#L387

--

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



[issue23815] Segmentation fault when create _tkinter objects

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

PyType_Ready() is called inside PyType_FromSpec().

--

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



Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel

On 05/06/2015 09:55 AM, Chris Angelico wrote:

On Wed, May 6, 2015 at 11:12 PM, Dave Angel da...@davea.name wrote:

I had guessed that the order of multiplication would make a big difference,
once the product started getting bigger than the machine word size.

Reason I thought that is that if you multiply starting at the top value (and
end with multiplying by 2) you're spending more of the time multiplying
big-ints.

That's why I made sure that both Cecil's and my implementations were
counting up, so that wouldn't be a distinction.

I'm still puzzled, as it seems your results imply that big-int*int is faster
than int*int where the product is also int.


Are you using Python 2 or Python 3 for your testing? In Py3, there's
no type difference, and barely no performance difference as you cross
the word-size boundary. (Bigger numbers are a bit slower to work with,
but not hugely.)



Both Cecil and I are using 3.x  I'm using 3.4 in particular.  And I know 
int covers both big-int and int32.  that's why I called it big-int, 
rather than long.


I was, however, mistaken.  it's not that threshold that we're crossing 
here, but another one, for MUCH larger numbers.  factorial of 10 and 
of 20 have 456473 and 97350 digits, respectively.  In binary, that 
would be about 190k bytes and 404k bytes, respectively.


I was seeing factorial of 20 taking about 4.5 times as long as 
factorial of 10.  All the other increments seemed fairly proportional.


I'll bet the difference is something like the memory allocator using a 
different algorithm for blocks above 256k.  Or the cache logic hitting a 
threshold.


If it's caching, of course the threshold will differ wildly between 
machine architectures.


If it's the memory allocator, that could easily vary between Python 
versions as well.





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


[issue24134] assertRaises can behave differently

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated patch includes tests for the function is None. There were no tests for 
assertRaises(), the patch adds them, based on tests for assertWarns().

 Why not sentinel = Object()?

Only for better repr in the case the sentinel is leaked. Other variants are to 
make it named object, such as a function or a class, as Magnus suggested.

--
Added file: http://bugs.python.org/file39306/assert_raises_sentinel_2.patch

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Steve Dower

Steve Dower added the comment:

Null is a valid value for job here (indicates the current process's job), so 
that's probably the check that's failing. When I can sit down with a VM and a 
debugger I'll check, but that won't be until next week.

--

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

Cheers. I missed a bit of code, job comes from job = CreateJobObject(NULL, 
NULL) so it shouldn't be NULL unless that call failed.

Rather than speculate though, I'll leave it with you. Shout if I can help.

--

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



[issue21800] Implement RFC 6855 (IMAP Support for UTF-8) in imaplib.

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

An explicit call to enable with an argument string that contains 'UTF8=ACCEPT'. 
 I did not go far enough through the BNF to determine if enable can be passed 
more than one capability at a time, but I suspect it can.  In which case we 
should factor out the capability parsing such that we can reuse it for parsing 
the enable argument.

--

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



[issue24133] Add 'composable' decorator to functools (with @ matrix multiplication syntax)

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

This should be taken to python-ideas (and probably pypi) first.  You can reopen 
if there is agreement that this should be done.  IMO it should not be done for 
3.5 in any case.

--
nosy: +r.david.murray
resolution:  - later
stage:  - resolved
status: open - closed
versions: +Python 3.6 -Python 3.5

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



Re: Bitten by my C/Java experience

2015-05-06 Thread Rustom Mody
On Wednesday, May 6, 2015 at 6:09:08 PM UTC+5:30, Antoon Pardon wrote:
 Op 05-05-15 om 18:24 schreef Rustom Mody:
 
  Yeah I happen to me in that minuscule minority that regards '= denotes 
  assignment' a bigger mistake than ++
 
 Nice to know I'm not alone. I Especially think it is a mistake, because
 it is then used as a reason for not allowing something like
 
   if a = b - 1:
 
 arguing it would lead to some difficult bugs.
 
 Which in my mind is arguing backwards. Either you think an assigment
 in a condition is useful or harmful. In the first case you then look
 for an assignment token or assignment syntax that is not that likely
 to lead to difficult to discover bugs instead of letting a possible
 misleading token or syntax prevent you from implementing something
 useful.
 
 In the second case you just state why you think an assignment in a
 condition is harmful. No need to hide behind awkward syntax.

Nice to know we agree though I am not sure I agree with your agreement :-)

In APL assignment is ← goto is → [and of course equality and negated equality
are = and ≠ ]
But if you've seen hair-raising APL one-liners with multiple ← and even → 
stuffed in...

No on second thoughts we probably agree... I am just in the second camp:
assignment in conditions is trouble; no need for syntax to argue that
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24134] assertRaises can behave differently

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

Why not sentinel = Object()? 

+1 for the patch, once tests are added.

This may break code in maintenance releases, but presumably that will be 
finding real bugs.  It is hard to imagine someone intentionally passing None to 
get the context manager behavior, even though it is documented in the doc 
strings (but not the main docs, I note).  If anyone can find examples of that, 
though, we'd need to restrict this to 3.5.

--
nosy: +r.david.murray

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



[issue24135] Policy for altering sys.path

2015-05-06 Thread R. David Murray

R. David Murray added the comment:

My guess, unfortunately, is give up.  There is too much code in the field that 
replaces sys.path with a regular list.  What you propose is effectively an 
impossible social engineering problem.  You may well also run into issues where 
the Python C code calls list methods directly even if sys.path is a subclass of 
list. (I don't know that that is true, but there are certainly places where the 
C code does that kind of thing).

Could you get consensus to change stdlib and pip practice?  That's at least 
conceivable.  I guess python-ideas would be the place to start for that.  I'm 
going to close the issue, since this would be a PEP level change if you are 
successful.  (Frankly, I don't think you are likely to be successful, but I 
don't hang out on python-ideas so I might be wrong :)

--
nosy: +r.david.murray
resolution:  - not a bug
stage:  - resolved
status: open - closed

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

The Path classes were not designed to be subclassable by the user.
I'm not against making subclassing easier, but someone will have to propose a 
viable approach for that.

--
versions: +Python 3.5 -Python 3.4

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



Re: Bitten by my C/Java experience

2015-05-06 Thread Gregory Ewing

Steven D'Aprano wrote:

The first one just does a name lookup and then throws the result away. The 
second one looks up names a and b, then adds them together, throwing away 
the result.


Actually, it's worse than that. :-) It's possible for a to
have an __add__ method with a side effect, although that
would be evil.

It's also possible for merely looking up a name to have
a side effect, if it's done in the right context -- but
that would be even more evil.

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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Hello.

I will give a real example in 5 hours after my job. I will try tomorrow a
solution to ease the subclassing using another dedicazted class PathPlus,
sorry for the name. The idea would be to use this new class for
customization, and also to define WindowsPath and PosixPath sub-classing
this new class. By default PathPlus would be an empty class. I do not know
if this works well. Maybe my idea is a bad one.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 13:05 GMT+02:00 Antoine Pitrou rep...@bugs.python.org:


 Antoine Pitrou added the comment:

 The Path classes were not designed to be subclassable by the user.
 I'm not against making subclassing easier, but someone will have to
 propose a viable approach for that.

 --
 versions: +Python 3.5 -Python 3.4

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


--

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



Re: Bitten by my C/Java experience

2015-05-06 Thread Antoon Pardon
Op 05-05-15 om 18:24 schreef Rustom Mody:

 Yeah I happen to me in that minuscule minority that regards '= denotes 
 assignment' a bigger mistake than ++

Nice to know I'm not alone. I Especially think it is a mistake, because
it is then used as a reason for not allowing something like

  if a = b - 1:

arguing it would lead to some difficult bugs.

Which in my mind is arguing backwards. Either you think an assigment
in a condition is useful or harmful. In the first case you then look
for an assignment token or assignment syntax that is not that likely
to lead to difficult to discover bugs instead of letting a possible
misleading token or syntax prevent you from implementing something
useful.

In the second case you just state why you think an assignment in a
condition is harmful. No need to hide behind awkward syntax.

-- 
Antoon Pardon

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


[issue24134] assertRaises can behave differently

2015-05-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The patch looks like a nice improvement.

--
nosy: +rhettinger

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



[issue24135] Policy for altering sys.path

2015-05-06 Thread Thomas Güttler

New submission from Thomas Güttler:

I am missing a policy how sys.path should be altered.

We run a custom sub class of list in sys.path. We set it in sitecustomize.py

This instance get replace by a common list in lines like this:

sys.path = glob.glob(os.path.join(WHEEL_DIR, *.whl)) + sys.path

The above line is from pip, it similar things happen in a lot of packages.

Before trying to solve this with code, I think the python community should 
agree an a policy for altering sys.path.

What can I do to this done?

We use Python 2.7.

--
messages: 242664
nosy: Thomas Güttler
priority: normal
severity: normal
status: open
title: Policy for altering sys.path

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



Re: Bitten by my C/Java experience

2015-05-06 Thread random832
On Mon, May 4, 2015, at 18:02, BartC wrote:
 (I think I would have picked up ++ and -- as special tokens even if 
 increment/decrement ops weren't supported. Just because they would 
 likely cause errors through misunderstanding.)

There's precedent for not doing this in C itself - even though =+
(from very early versions of C, also =-, =*, =) no longer acts as an
add-in-place operator, it's not recognized as a special token to prevent
errors either.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Henrik Heimbuerger

Henrik Heimbuerger added the comment:

I can confirm this issue for pip 6.1.1 on Windows 10.0.10074 for both Python 
2.7.9 as well as 3.4.3.

As a workaround, using python -m pip works fine (as suggested on 
http://stackoverflow.com/a/26428562/6278 for a different issue).

--
nosy: +hheimbuerger

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



Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel

On 05/06/2015 02:26 AM, Steven D'Aprano wrote:

On Wednesday 06 May 2015 14:05, Steven D'Aprano wrote:



My interpretation of this is that the difference has something to do with
the cost of multiplications. Multiplying upwards seems to be more expensive
than multiplying downwards, a result I never would have predicted, but
that's what I'm seeing. I can only guess that it has something to do with
the way multiplication is implemented, or perhaps the memory management
involved, or something. Who the hell knows?



I had guessed that the order of multiplication would make a big 
difference, once the product started getting bigger than the machine 
word size.


Reason I thought that is that if you multiply starting at the top value 
(and end with multiplying by 2) you're spending more of the time 
multiplying big-ints.


That's why I made sure that both Cecil's and my implementations were 
counting up, so that wouldn't be a distinction.


I'm still puzzled, as it seems your results imply that big-int*int is 
faster than int*int where the product is also int.


That could use some more testing, though.

I still say a cutoff of about 10% is where we should draw the line in an 
interpretive system.  Below that, you're frequently measuring noise and 
coincidence.


Remember the days when you knew how many cycles each assembly 
instruction took, and could simply add them up to compare algorithms?



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


Re: Bitten by my C/Java experience

2015-05-06 Thread Steven D'Aprano
On Wed, 6 May 2015 10:40 pm, BartC wrote:

 But I had in mind not implementing ++ and --, but detecting them and
 issuing a warning, 

That's a job for a linter, not the compiler. The compiler should be as
flexible as possible in what it accepts:


a   ,b=12+3 *  4,hello  .  upper   ()


is perfectly legal code. The compiler shouldn't force you to write good
looking code, apart from what is prohibited altogether.

Both + and - are unary prefix operators, so you can apply + and - to any
expression -- even an expression that already has a unary prefix operator:

py - --- +++ + - - + -- +++ --- 999
-999


Is that ugly, horrible code that nobody in their right mind would use in
production? Absolutely. But the compiler can and should accept it, and
linters (or human reviewers) should warn about it.



-- 
Steven

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


[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file39308/long_free_list.patch

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



PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-06 Thread Stefan Zimmermann
Hi.

I don't like that subprocess.Popen(['command']) only works on Windows if there 
is a command.exe in %PATH%. As a Windows user you would normally expect that 
also command.bat and command.cmd can be run that way.

There are simple workarounds like Popen(..., shell=True) but that is a heavy 
overhead for .exe files.

Currently I use pywin32 and call Popen([win32api.FindExecutable('command')[1]]) 
as a workaround. This has zero overhead.

It should be default for Popen to call FindExecutable internally.

Was this discussed before?
Is it worth a PEP?
Or at least an issue?

Cheers,
Stefan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [SciPy-User] Is there existing code to log-with-bells-on for runtime algorithm diagnostics?

2015-05-06 Thread Rob Clewley
Just to follow up on this thread, for interested readers' future reference...

On Tue, Apr 21, 2015 at 4:22 PM, Robert Kern robert.k...@gmail.com wrote:
 On Tue, Apr 21, 2015 at 8:02 PM, Rob Clewley rob.clew...@gmail.com wrote:
 In fact, I'm trying to build a general purpose tool for exploring the
 inner workings of numerical algorithms for teaching and learning
 purposes, e.g. for graduate student training or for figuring out
 parameter choices in difficult applications.

 The term you want to search for is structured logging.

 http://www.structlog.org/en/stable/
 http://eliot.readthedocs.org/en/stable/
 https://twiggy.readthedocs.org/en/latest/logging.html#structured-logging
 http://netlogger.lbl.gov/


I posted a new blog entry about my prototypical diagnosis and
visualization tools for python numerical algorithms, built over
matplotlib:
http://robclewley.github.io/logging-and-diagnostic-tools-for-numeric-python-algorithms/

They utilize structlog, and I hooked up a noSQL DB (tinydb) to the
logging to enable search capabilities of the log post-mortem. Comments
and PRs most welcome.

Thanks to everyone for the pointers.
-Rob
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CHALLENGE HELP - GOOGLE DEVELOPER DAY

2015-05-06 Thread Denis McMahon
On Tue, 05 May 2015 09:59:03 -0700, worship.brother wrote:

 Archaeologists have found a scroll with the following texts:

First you need to visit the hidden Temple of Offler, where you will find 
the Tears of Offler (they're the big gems set into the statue just above 
the teeth) after making your way through the maze with the big rolling 
ball, spiky pit, deadfall and spinning blade traps.

Then you offer the tears off Offler up on the altar of Cthulhu[1].

Either your brain will melt when Cthulhu appears to you, or you will be 
blessed with the inspiration to write the code to solve your problem.

If the latter, and the code doesn't work, show us the code and we might 
be able to make suggestions for you.

[1] If you thought getting Offler's Tears was hard, wait until you try 
reaching the altar of Cthulhu.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Writing list of dictionaries to CSV

2015-05-06 Thread Denis McMahon
On Tue, 05 May 2015 22:32:28 -0700, Kashif Rana wrote:

 thanks for the feedback. I think its problem with excel itself, showing
 wrong value. Because when I opened the csv file in text editor, I can
 see correct value but opening in excel showing wrong value. What I can
 do to see correct in excel as well.

You need to format your CSV date into a date format that Excel 
understands when it imports it.

First thing to try would be to export some dates from excel as CSV and 
see what format excel puts them in.

The see if excel recognises them as dates when you re-import the same 
file.

If excel recognises it's own csv exported dates, reformat your dates to 
match the excel ones when you generate the csv.

Otherwise, you might need to convert the dates to a numeric value and 
tell excel to format the field as date after input.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Larry Hastings

Larry Hastings added the comment:

10**3 doesn't show off this hack as much as other numbers would; the hack only 
operates from 257 to the max in that will fit in a single long digit (32767 
on 32-bit, 2**30 on 64-bit).

Anyway, freelist for one-digit longs seems nearly as good, and it's a lot more 
general-purpose, so I'm much more interested in that.

--

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



Re: Json Comaprision

2015-05-06 Thread John Gordon
In mailman.164.1430902487.12865.python-l...@python.org pra devOPS 
siv.dev...@gmail.com writes:

 I wanted to compare two json files ignoring few of the keys in the json
 files.

 Can anybody suggest me few things?

Load each json file into a python object, delete the keys you don't care
about, and compare the two objects.

-- 
John Gordon Imagine what it must be like for a real medical doctor to
gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'.

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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Here are for example two extra methods that I have implemented.

def __sub__(cls, path):

This magic method allows to use ``onepath - anotherpath`` instead of the
long
version ``onepath.relative_to(anotherpath)`` given by ``pathlib.Path``.

return cls.relative_to(path)

def _ppath_common_with(cls, paths):

This method returns the path of the smaller common folder of the current
path
and at least one paths.

python::
from mistool import os_use

path   = os_use.PPath(/Users/projects/source/doc)
path_1 = os_use.PPath(/Users/projects/README)
path_2 = os_use.PPath(/Users/projects/source/misTool/os_use.py)

print(path.common_with((path_1, path_2)))

if not isinstance(paths, (list, tuple)):
paths = [paths]

commonparts = list(cls.parts)

for onepath in paths:
i = 0

for common, actual in zip(commonparts, onepath.parts):
if common == actual:
i += 1
else:
break

commonparts = commonparts[:i]

if not commonparts:
break

commonpath = pathlib.Path()

for part in commonparts:
commonpath /= part

return commonpath

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 14:13 GMT+02:00 Christophe BAL rep...@bugs.python.org:


 Christophe BAL added the comment:

 Hello.

 I will give a real example in 5 hours after my job. I will try tomorrow a
 solution to ease the subclassing using another dedicazted class PathPlus,
 sorry for the name. The idea would be to use this new class for
 customization, and also to define WindowsPath and PosixPath sub-classing
 this new class. By default PathPlus would be an empty class. I do not know
 if this works well. Maybe my idea is a bad one.

 *Christophe BAL*
 *Enseignant de mathématiques en Lycée **et développeur Python amateur*
 *---*
 *French math teacher in a Lycée **and **Python **amateur developer*

 2015-05-06 13:05 GMT+02:00 Antoine Pitrou rep...@bugs.python.org:

 
  Antoine Pitrou added the comment:
 
  The Path classes were not designed to be subclassable by the user.
  I'm not against making subclassing easier, but someone will have to
  propose a viable approach for that.
 
  --
  versions: +Python 3.5 -Python 3.4
 
  ___
  Python tracker rep...@bugs.python.org
  http://bugs.python.org/issue24132
  ___
 

 --

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


--

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



[issue23346] shutil.rmtree doesn't work correctly on FreeBSD.

2015-05-06 Thread sumpfralle

sumpfralle added the comment:

I experience the same issue on a virtualized server (based on Virtuozzo) with 
Linux kernel 2.6.32.

The following command fails:

 echo import os; os.listdir(os.open('/tmp', os.O_RDONLY)) | python3
 Traceback (most recent call last):
   File stdin, line 1, in module
 OSError: [Errno 22] Invalid argument

--
nosy: +sumpfralle

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



[issue1222585] C++ compilation support for distutils

2015-05-06 Thread Erik Hvatum

Erik Hvatum added the comment:

The 2012-12-31 of this patch (currently the latest) has the surprising effect 
of causing distutils CFLAGS to be dropped.  See for reference: 
https://bugs.gentoo.org/show_bug.cgi?id=548776

The issue I am experiencing is resolved by changing the section of the patch 
that reads:

+-(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, 
ar_flags) = \
+-get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+-'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 
'ARFLAGS')
++(cc, cxx, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, 
ar_flags) = \
++get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 
'LDCXXSHARED',
++'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++
++cflags = ''
++cxxflags = ''

to:

+-(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, 
ar_flags) = \
+-get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
+-'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 
'ARFLAGS')
++(cc, cxx, cflags, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, 
ar_flags) = \
++get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 
'LDCXXSHARED',
++'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
++
++cxxflags = cflags

This change causes the CFLAGS outputted by python-config --cflags to be used 
by distutils, as they are without the patch applied.  To me, losing those 
CFLAGS, especially when building plain C python extensions, seems like a 
significant regression.

--
nosy: +ehvatum
versions: +Python 3.4 -Python 3.5

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



[issue1222585] C++ compilation support for distutils

2015-05-06 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy:  -brian.curtin

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



Re: extracting zip item to in-memory

2015-05-06 Thread Dave Angel

On 05/06/2015 04:27 PM, noydb wrote:

I have a zip file containing several files and I want to extract out just the 
.xml file.  I have that code.  Curious if this xml file can be extracted into 
memory.  If so, how to?  I only need to move the file around, and maybe read 
some tags.

Thanks for any help!

python 2.7



See https://docs.python.org/2.7/library/zipfile.html#zipfile.ZipFile.open

To open a particular member and get back a file-like object.

Once you have that, you can use the  read() method of that object.

Once you've coded this, if it doesn't work, post what you've got with a 
description of what doesn't work, and somebody here will be able to fix 
it up.



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


Re: extracting zip item to in-memory

2015-05-06 Thread Mark Lawrence

On 06/05/2015 21:27, noydb wrote:

I have a zip file containing several files and I want to extract out just the 
.xml file.  I have that code.  Curious if this xml file can be extracted into 
memory.  If so, how to?  I only need to move the file around, and maybe read 
some tags.

Thanks for any help!

python 2.7



https://docs.python.org/2/library/xml.html#module-xml

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Throw the cat among the pigeons

2015-05-06 Thread Mark Lawrence

On 06/05/2015 17:17, Ian Kelly wrote:

On Wed, May 6, 2015 at 1:08 AM, Steven D'Aprano


Besides, typical load is a myth -- there is no such thing. A high-end
Windows web server getting ten thousand hits a minute, a virtual machine
starved for RAM, a Mac laptop, a Linux server idling away with a load of 0.1
all day... any of those machines could run your code. How can you *possibly*
say what is typical? The very idea is absurd.


Agreed.



I must disagree with this, on the grounds that a typical load of old 
cobblers are frequently spouted on this list.  Practicality beats purity 
any day of the week.  But no, this '=' is misused, it should have been 
':='.  Who really cares, if you don't like the language, pick another 
one, there's thousands of them to choose from.  Ah, another chance for 
me to plug the virtues of CORAL 66 and CORAL 250.  Capability violation 
anybody?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Throw the cat among the pigeons

2015-05-06 Thread Dave Angel

On 05/06/2015 11:36 AM, Alain Ketterlin wrote:

Yes, plus the time for memory allocation. Since the code uses r *=
..., space is reallocated when the result doesn't fit. The new size is
probably proportional to the current (insufficient) size. This means
that overall, you'll need fewer reallocations, because allocations are
made in bigger chunks.


That sounds plausible, but  a=5; a*=4  does not update in place. It 
calculates and creates a new object.  Updating lists can work as you 
say, but an int is immutable.


It's an optimization that might be applied if the code generator were a 
lot smarter, (and if the ref count is exactly 1), but it would then be 
confusing to anyone who used id().


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


Re: Encrypt python files

2015-05-06 Thread Emile van Sebille

On 5/6/2015 12:23 AM, Palpandi wrote:

On Wednesday, May 6, 2015 at 12:07:13 PM UTC+5:30, Palpandi wrote:

Hi,

What are the ways to encrypt python files?


No, I just want to hide the scripts from others.



See http://stackoverflow.com/questions/261638/how-do-i-protect-python-code

Emile

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


Re: Bitten by my C/Java experience

2015-05-06 Thread Mark Lawrence

On 06/05/2015 17:03, Steven D'Aprano wrote:

On Wed, 6 May 2015 10:40 pm, BartC wrote:


But I had in mind not implementing ++ and --, but detecting them and
issuing a warning,


That's a job for a linter, not the compiler. The compiler should be as
flexible as possible in what it accepts:


a   ,b=12+3 *  4,hello  .  upper   ()


is perfectly legal code. The compiler shouldn't force you to write good
looking code, apart from what is prohibited altogether.

Both + and - are unary prefix operators, so you can apply + and - to any
expression -- even an expression that already has a unary prefix operator:

py - --- +++ + - - + -- +++ --- 999
-999


Is that ugly, horrible code that nobody in their right mind would use in
production? Absolutely. But the compiler can and should accept it, and
linters (or human reviewers) should warn about it.



Linters were mentioned a day or two back.  Take a horse to water...

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

 What is the good way to propose a patch ?

If you have a patch, attach it here, and it will get reviewed.

--

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



extracting zip item to in-memory

2015-05-06 Thread noydb
I have a zip file containing several files and I want to extract out just the 
.xml file.  I have that code.  Curious if this xml file can be extracted into 
memory.  If so, how to?  I only need to move the file around, and maybe read 
some tags.

Thanks for any help!

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


Re: Writing list of dictionaries to CSV

2015-05-06 Thread Tim Chase
On 2015-05-06 19:08, MRAB wrote:
 You could tell it to quote any value that's not a number:
 
   w = csv.DictWriter(f, pol_keys,
 quoting=csv.QUOTE_NONNUMERIC)
 
 It looks like all of the values you have are strings, so they'll
 all be quoted.
 
 I would hope that Excel will then treat it as a string; it would be
 stupid if it didn't! :-)

Sadly, Excel *is* that stupid based on the tests I tried just now. :-(

Regardless of whether Mar 2015 is quoted or unquoted in the source
CSV file, Excel tries to outwit you and mangles the presentation.

-tkc



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


[issue22906] PEP 479: Change StopIteration handling inside generators

2015-05-06 Thread Yury Selivanov

Yury Selivanov added the comment:

Hi Chris! Can I somehow help with the patch?

--
nosy: +yselivanov

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



Re: Writing list of dictionaries to CSV

2015-05-06 Thread Tim Chase
On 2015-05-06 12:27, Ian Kelly wrote:
 On Wed, May 6, 2015 at 12:22 PM, Tim Chase
 python.l...@tim.thechases.com wrote:
  On 2015-05-06 19:08, MRAB wrote:
  You could tell it to quote any value that's not a number:
 
w = csv.DictWriter(f, pol_keys,
  quoting=csv.QUOTE_NONNUMERIC)
 
  It looks like all of the values you have are strings, so they'll
  all be quoted.
 
  I would hope that Excel will then treat it as a string; it would
  be stupid if it didn't! :-)
 
  Sadly, Excel *is* that stupid based on the tests I tried just
  now. :-(
 
  Regardless of whether Mar 2015 is quoted or unquoted in the
  source CSV file, Excel tries to outwit you and mangles the
  presentation.
 
 Quoting a value in csv doesn't mean it's a string; it just means
 that it's a single field.
 
 You *can* force Excel to treat a value as a string by prefixing it
 with an apostrophe, though.

Excel takes the apostrophe in the CSV file and puts it in the
content, rather than stripping it as an escape/formatting character:

  c:\temp type test.csv
  'Mar 2015,Mar 2015,3,2015
  Apr 2015,Apr 2015,4,2015
  2015-12,2015-12,12,2015
  c:\temp start test.csv

A1 has the unformatted text, but includes the apostrophe in the
value.  B1, A2, and B2 get munged like the OP described to the form
Apr-15.  The items in row #3 come through untouched.

At least on Excel 2003 on WinXP which is what I happen to have on
hand.

-tkc




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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

I have no problem with that - it's a style choice certainly.

As I said, I'd like to see simpler subclassing of pathlib objects. I just think 
it'll be quite hard to do (given the complexities of classes for Windows/Unix 
as well as pure and concrete paths). So if it's just about examples like this, 
I personally would take the easier route and just go with standalone functions. 
If someone else felt strongly enough to design and implement a subclassing 
solution, that's fine though.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

Are you the author of path lib ?

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 21:01 GMT+02:00 Paul Moore rep...@bugs.python.org:


 Paul Moore added the comment:

 I have no problem with that - it's a style choice certainly.

 As I said, I'd like to see simpler subclassing of pathlib objects. I just
 think it'll be quite hard to do (given the complexities of classes for
 Windows/Unix as well as pure and concrete paths). So if it's just about
 examples like this, I personally would take the easier route and just go
 with standalone functions. If someone else felt strongly enough to design
 and implement a subclassing solution, that's fine though.

 --

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


--

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This regression was just discussed in issue24076. General suggestion about free 
list for small ints was proposed. It could speed up other integer computations, 
but comprehensive benchmarking results are needed.

See also similar issue23507 for tuples. Perhaps we need general solution for 
fast specialized free lists.

--

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



ANN: PyTables 3.2.0 (final) released!

2015-05-06 Thread Francesc Alted
===
 Announcing PyTables 3.2.0
===

We are happy to announce PyTables 3.2.0.

***
IMPORTANT NOTICE:

If you are a user of PyTables, it needs your help to keep going.  Please
read the next thread as it contains important information about the
future (or the lack of it) of the project:

https://groups.google.com/forum/#!topic/pytables-users/yY2aUa4H7W4

Thanks!
***


What's new
==

This is a major release of PyTables and it is the result of more than a
year of accumulated patches, but most specially it fixes a couple of
nasty problem with indexed queries not returning the correct results in
some scenarios.  There are many usablity and performance improvements
too.

In case you want to know more in detail what has changed in this
version, please refer to: http://www.pytables.org/release_notes.html

You can install it via pip or download a source package with generated
PDF and HTML docs from:
http://sourceforge.net/projects/pytables/files/pytables/3.2.0

For an online version of the manual, visit:
http://www.pytables.org/usersguide/index.html


What it is?
===

PyTables is a library for managing hierarchical datasets and
designed to efficiently cope with extremely large amounts of data with
support for full 64-bit file addressing.  PyTables runs on top of
the HDF5 library and NumPy package for achieving maximum throughput and
convenient use.  PyTables includes OPSI, a new indexing technology,
allowing to perform data lookups in tables exceeding 10 gigarows
(10**10 rows) in less than a tenth of a second.


Resources
=

About PyTables: http://www.pytables.org

About the HDF5 library: http://hdfgroup.org/HDF5/

About NumPy: http://numpy.scipy.org/


Acknowledgments
===

Thanks to many users who provided feature improvements, patches, bug
reports, support and suggestions.  See the ``THANKS`` file in the
distribution package for a (incomplete) list of contributors.  Most
specially, a lot of kudos go to the HDF5 and NumPy makers.
Without them, PyTables simply would not exist.


Share your experience
=

Let us know of any bugs, suggestions, gripes, kudos, etc. you may have.




  **Enjoy data!**

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

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


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

For that type of function, I'd suggest you use a standalone function rather 
than subclassing and methods or operator overloading. You don't gain enough to 
be worth the complexity of having to subclass path objects. And duck typing 
means that your function works for any subclass of (Pure)Path without change.

--

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



[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Christophe BAL

Christophe BAL added the comment:

I don't agree with you. I prefer to add new functionalities to the paths I
use. This is the power of OOP. It is easier and cleaner to use
*mypath.common_with(otherpath)*  than  *common_with(**mypath, **other path)*
.

Python is highly OOP, so you can't say *don't use subclassing in your
case*. As a user, I should have the possibility to use the method I want.

Another example is the use of  *onepath - anotherpath*  instead of
*onepath.relative_to(**another path)* . That's the power of the magic
method to add this kind of feature.

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a Lycée **and **Python **amateur developer*

2015-05-06 20:21 GMT+02:00 Paul Moore rep...@bugs.python.org:


 Paul Moore added the comment:

 For that type of function, I'd suggest you use a standalone function
 rather than subclassing and methods or operator overloading. You don't gain
 enough to be worth the complexity of having to subclass path objects. And
 duck typing means that your function works for any subclass of (Pure)Path
 without change.

 --

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


--

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



[issue24138] Speed up range() by caching and modifying long objects

2015-05-06 Thread Mark Lawrence

Mark Lawrence added the comment:

How does this apply where people like me scarcely if ever use range, it's 
standard for loops?  There are plenty of recipes using itertools that show that 
you don't need range, is this really needed?  No axe to grind, just curious.

--
nosy: +BreamoreBoy

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



[issue24127] Fatal error in launcher: Job information querying failed

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

Adding Jason Coombs and Vinay Sajip, as if this needs a fix to the launcher 
code, then the launchers used by distlib and setuptools (for exe wrappers of 
console entry points) will need to be changed as well.

It would be really useful if all 3 projects used a single codebase - having to 
duplicate fixes like this is annoying.

--
nosy: +jason.coombs

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



Re: Writing list of dictionaries to CSV

2015-05-06 Thread Ian Kelly
On Wed, May 6, 2015 at 12:22 PM, Tim Chase
python.l...@tim.thechases.com wrote:
 On 2015-05-06 19:08, MRAB wrote:
 You could tell it to quote any value that's not a number:

   w = csv.DictWriter(f, pol_keys,
 quoting=csv.QUOTE_NONNUMERIC)

 It looks like all of the values you have are strings, so they'll
 all be quoted.

 I would hope that Excel will then treat it as a string; it would be
 stupid if it didn't! :-)

 Sadly, Excel *is* that stupid based on the tests I tried just now. :-(

 Regardless of whether Mar 2015 is quoted or unquoted in the source
 CSV file, Excel tries to outwit you and mangles the presentation.

Quoting a value in csv doesn't mean it's a string; it just means that
it's a single field.

You *can* force Excel to treat a value as a string by prefixing it
with an apostrophe, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24132] Direct sub-classing of pathlib.Path

2015-05-06 Thread Paul Moore

Paul Moore added the comment:

 Are you the author of path lib ?

Nope, that's Antoine.

--

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



  1   2   >