[issue12029] Catching virtual subclasses in except clauses

2015-10-21 Thread R. David Murray

R. David Murray added the comment:

Note from discussion on duplicate issue 25448: when this is fixed, the 
try/except documentation should be updated to indicate that the except clause 
test is equivalent to 'issubclass', so that the handling of virtual subclasses 
are implied by the doc.  (The current proposed patch contains no doc changes.)

Apparently this also affects pypy.

--
nosy: +alex, fijal, r.david.murray

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Steven D'Aprano

Steven D'Aprano added the comment:

I'm not entirely satisfied that the way it is calculated by C++11/C99 is 
correct. (Although I can see the appeal of the C version.) Mathematically, 
complex multiplication (a+bj)*x should be identical to (a+bj)*(x+0j), but 
obviously in the presence of NANs that is no longer the case. So it isn't clear 
to me that Python is wrong to allow NANs to "infect" the real part after 
multiplication.

Before changing the behaviour, I'd like to hear from someone who might be able 
to comment on what the IEEE-754 standard may have to say about this.

--
nosy: +steven.daprano

___
Python tracker 

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



PyPi bug?

2015-10-21 Thread Nagy László Zsolt
Today I have tried to register and upload a new package by executing

setup.py register


I was asked if I want to save the creditentials in a .pypirc file and I
answered yes.

Next I wanted to run

setup.py upload

and I got this error:


Traceback (most recent call last):
  File "C:\Python\Projects\some_package\setup.py", line 15, in 
classifiers=['Topic :: Security', 'Topic :: Internet :: WWW/HTTP'],
  File "C:\Python35\lib\distutils\core.py", line 148, in setup
dist.run_commands()
  File "C:\Python35\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
  File "C:\Python35\lib\distutils\dist.py", line 973, in run_command
cmd_obj.ensure_finalized()
  File "C:\Python35\lib\distutils\cmd.py", line 107, in ensure_finalized
self.finalize_options()
  File "C:\Python35\lib\distutils\command\upload.py", line 46, in
finalize_options
config = self._read_pypirc()
  File "C:\Python35\lib\distutils\config.py", line 83, in _read_pypirc
current[key] = config.get(server, key)
  File "C:\Python35\lib\configparser.py", line 798, in get
d)
  File "C:\Python35\lib\configparser.py", line 396, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
  File "C:\Python35\lib\configparser.py", line 445, in _interpolate_some
"found: %r" % (rest,))
configparser.InterpolationSyntaxError: '%' must be followed by '%' or
'(', found
: *'

Instead of the many stars, of course there is the password. The problem
might be that the password contains a % character, and it was
incorrectly saved by distutils.

Can somebody please confirm that this is a bug in distutils? The we
probably have to submit a bug report.

Thanks,

   Laszlo

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


[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Francesco Biscani

Francesco Biscani added the comment:

The best reference I could find so far is in the C99 standard:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

Annex G is titled "IEC 60559-compatible complex arithmetic". In G.3.1 it is 
written:

"""
A complex or imaginary value with at least one infinite part is regarded as an 
infinity (even if its other part is a NaN).
"""

Later on, in G.5.1.4, it is stated:

"""
The * and / operators satisfy the following infinity properties for all real, 
imaginary, and complex operands:

- if one operand is an infinity and the other operand is a nonzero finite 
number or an infinity, then the result of the * operator is an infinity;
- if the first operand is an infinity and the second operand is a finite 
number, then the result of the / operator is an infinity;
- if the first operand is a finite number and the second operand is an 
infinity, then the result of the / operator is a zero;
"""

So to recap, according to these definitions:

- inf + nanj is a complex infinity,
- (inf + nanj) * (2 + 0j) should give a complex infinity (i.e., a complex 
number in which at least one component is inf).

I am not saying that these rules are necessarily "mathematically correct". I am 
aware that floating point is always a quagmire to get into, and the situation 
here is even more complex (eh!) than usual.

But it seems to me that Python, or CPython at least, follows a pattern of 
copying (or relying on) the behaviour of C for floating-point operations, and 
it seems like in the case of complex numbers this "rule" is broken. It 
certainly caught me by surprise anyway :)

--

___
Python tracker 

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



[issue24379] operator.subscript

2015-10-21 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
priority: normal -> high

___
Python tracker 

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



[issue25210] Special-case NoneType() in do_richcompare()

2015-10-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5c7dd88cd0c5 by Berker Peksag in branch 'default':
Issue #25210: Add some basic tests for the new exception message
https://hg.python.org/cpython/rev/5c7dd88cd0c5

--

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Eric V. Smith

Eric V. Smith added the comment:

Saksham: Also, it would be best to take this discussion of how to produce a 
patch to the python-committers mailing list: 
https://mail.python.org/mailman/listinfo/python-committers

--

___
Python tracker 

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



[issue25449] Test OrderedDict subclass

2015-10-21 Thread Eric Snow

Eric Snow added the comment:

Regarding dict.__setitem__, see issue #24726.  Raymond outlined what needs to 
be fixed.

--

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Saksham Agrawal

Saksham Agrawal added the comment:

I read the first 6 chapters of the devguide.

Now how should I proceed.

--

___
Python tracker 

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



[issue24379] operator.subscript

2015-10-21 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This is causing a reference leak problem:  
https://mail.python.org/pipermail/python-dev/2015-October/141993.html

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue25449] Test OrderedDict subclass

2015-10-21 Thread Eric Snow

Changes by Eric Snow :


--
stage: commit review -> patch review

___
Python tracker 

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



[issue24726] OrderedDict has strange behaviour when dict.__setitem__ is used.

2015-10-21 Thread Eric Snow

Eric Snow added the comment:

FTR, this will likely involve more than just fixing odict_repr().

--

___
Python tracker 

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



[issue24726] OrderedDict has strange behaviour when dict.__setitem__ is used.

2015-10-21 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: 2.7.9: PhotoImage get/put

2015-10-21 Thread Randy Day
In article , 
tjre...@udel.edu says...

[snip]

> > I made my 'root' Tk instance global, and
> > call root.update_idletasks() after the
> > .put

> I did not see the original post, but the alternative way to animate is 
> to use root.after(milliseconds, callback, *args) at the end of callbacks 
> to allow the event loop to process other events before re-calling the 
> same or another callback.

I could see that being useful for creating
a steady frame rate in longer animations.
I'll put that one in my Python toolbox as well.


--- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Eric V. Smith

Eric V. Smith added the comment:

Saksham: First we need our "experts" to decide what, if any, change is needed. 
If we decide that a change is needed, at that point we'd look at a patch.

--

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Berker Peksag

Berker Peksag added the comment:

> Also, it would be best to take this discussion of how to produce a patch to 
> the python-committers mailing list:

or the core-mentorship list: 
https://mail.python.org/mailman/listinfo/core-mentorship :)

--
nosy: +berker.peksag

___
Python tracker 

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



If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread bigred04bd3
So here what I have, I have a 3 IF's within the same level.  If one IF is 
satisfied, I would like to "skip" the other IFs and continue with my code.

# 4 second open
if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell 
+ 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 
0 and wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 3, column=3).value == 0:
open += 3
open_seconds += 4
start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate
break
# 3 second open
if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet1.cell(row=cell 
+ 2, column=2).value == 0 and wb1_sheet1.cell(row=cell + 2, column=3).value == 
0:
open += 3
start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate
open_seconds += 3
continue
# 2 second open
if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
wb1_sheet1   .cell(row=cell + 1, column=3).value == 0:
open += 3
start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate
open_seconds += 2


if any but the last IF is true, then all IFs will be true...that's my problem.

any help would be great
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20504] cgi.FieldStorage, multipart, missing Content-Length

2015-10-21 Thread Berker Peksag

Berker Peksag added the comment:

The attached patch(cgi.patch) doesn't fix the problem for me: cgi-bug.py still 
fails with a TypeError. Here is a patch with a test to fix the problem.

With issue20504.diff applied:

$ ./python t.py 
5

(Only changed the "assert len(fields["my-arg"].file.read()) == 5" line with 
"print(len(fields["my-arg"].file.read()))")

--
nosy: +berker.peksag
stage:  -> patch review
versions: +Python 3.6 -Python 3.3
Added file: http://bugs.python.org/file40833/issue20504.diff

___
Python tracker 

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



Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread John Gordon
In <50a6789a-3965-430b-9a91-b08adcedf...@googlegroups.com> 
bigred04...@gmail.com writes:

> So here what I have, I have a 3 IF's within the same level.  If one IF is s=
> atisfied, I would like to "skip" the other IFs and continue with my code.

> # 4 second open
> if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
> wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and 
> wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and 
> wb1_sheet1.cell(row=cell + 2, column=3).value == 0 and 
> wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
> wb1_sheet1.cell(row=cell + 3, column=3).value == 0:
> open += 3
> open_seconds += 4
> start = wb1_sheet1.cell(row=cell + 4, column=2).coord=
> inate
> break
> # 3 second open
> if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a=
> nd wb1_sheet1.cell(row=cell + 1, column=3).value == 0 and wb1_sheet=
> 1.cell(row=cell + 2, column=2).value == 0 and wb1_sheet1.cell(row=
> =cell + 2, column=3).value == 0:
> open += 3
> start = wb1_sheet1.cell(row=cell + 3, column=2).coord=
> inate
> open_seconds += 3
> continue
> # 2 second open
> if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 a=
> nd wb1_sheet1   .cell(row=cell + 1, column=3).value == =
> 0:
> open += 3
> start = wb1_sheet1.cell(row=cell + 2, column=2).coord=
> inate
> open_seconds += 2


> if any but the last IF is true, then all IFs will be true...that's my probl=
> em.

It looks like all three of your if statements start out with this condition:

if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 1, column=3).value == 0

So you could reorganize your code by putting an if statement at the top
that only checks this condition.  Then, indented underneath, you can
check for the other conditions.

And be sure to use "else" and "elif" when they are appropriate.

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

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


Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread bigred04bd3
O...MG I cannot believe I just asked this question ha.  I ended up 
realizing I need to use an elif after I took a break from it and re read 
everything...Brain fart, thanks for replies.

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


[issue25417] Minor typo in Path.samefile docstring

2015-10-21 Thread Berker Peksag

Berker Peksag added the comment:

Fixed, thank you Antony.

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +tim.peters

___
Python tracker 

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



[issue25417] Minor typo in Path.samefile docstring

2015-10-21 Thread Antony Lee

Antony Lee added the comment:

Actually there's also an extra dot at the end of the first line of the 
docstring (redundant with the one on the second line).

--

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Eric V. Smith

Eric V. Smith added the comment:

> Berker Peksag added the comment:
> 
>> Also, it would be best to take this discussion of how to produce a patch to 
>> the python-committers mailing list:
> 
> or the core-mentorship list: 
> https://mail.python.org/mailman/listinfo/core-mentorship :)

Argh! That's of course what I meant. Apologies all around.

--

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Mark Dickinson

Mark Dickinson added the comment:

Changing Python versions and issue type: the current behaviour is certainly 
deliberate, so a proposal to change it would be a feature request, which could 
only land in Python 3.6 or later.

--
type: behavior -> enhancement
versions:  -Python 2.7, Python 3.4, Python 3.5

___
Python tracker 

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



Re: How to rearrange array using Python?

2015-10-21 Thread Martin Schöön
Den 2015-10-20 skrev Ian Kelly :
>>
>> Anyone into CSP willing to offer me a hint?
>
> I assume that your variables are the individuals and the domains of
> those variables are the rooms. Based on the python-constraint docs,
> your constraint could look something like this:
>
> from collections import Counter
>
> ROOM_SIZE = {
> 'A': 3,
> 'B': 3,
> 'C': 4,
> 'D': 4,
> 'E': 5,
> }
>
> def room_size_constraint(*v):
> counter = Counter(v.values())
> return all(count <= ROOM_SIZE[room]
> for room, count in counter.items())
>
> problem.addConstraint(room_size_constraint)

Bingo!
Just what I needed but didn't know where to look for. Now I 'only' have
to read
https://docs.python.org/dev/library/collections.html#counter-objects
to understand what's really going on in the code :-)

Then I will try less benign examples.

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


[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Mark Dickinson

Mark Dickinson added the comment:

Thanks for the update.

I'm not too worried about performance: I suspect that any additional overhead 
would be lost in the overhead of the Python machinery. It would be worth 
profiling to check, of course, before any change went in. I'd expect that most 
performance critical code of this type would be using NumPy/SciPy anyway.

I'm still unsure about whether the code is worth changing: I do agree that the 
behaviour suggested by C99 Annex G is (in the abstract) an improvement on 
Python's current behaviour, and compatibility with C would be a plus. On the 
other side, introducing an incompatibility with other versions of Python and 
with NumPy isn't ideal. For me, the potential benefits don't really overcome 
the drawbacks here, but I'd like to hear other opinions.

--

___
Python tracker 

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



[issue25417] Minor typo in Path.samefile docstring

2015-10-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7d65be20e0d8 by Berker Peksag in branch '3.5':
Issue #25417: Fix typo in Path.samefile() docstring
https://hg.python.org/cpython/rev/7d65be20e0d8

New changeset 0b09a866da77 by Berker Peksag in branch 'default':
Issue #25417: Fix typo in Path.samefile() docstring
https://hg.python.org/cpython/rev/0b09a866da77

--
nosy: +python-dev

___
Python tracker 

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



[issue25449] Test OrderedDict subclass

2015-10-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

New patch adds PurePythonOrderedDictSubclassTests, moves all tests except 
test_key_change_during_iteration from CPythonOrderedDictTests to 
OrderedDictTests to test Python implementation too, fixes a bug in values and 
items iteration that caused test_issue24347 to fail, and adds additional 
explicit checks for values() and items() to test_issue24347.

--
type: enhancement -> behavior
Added file: http://bugs.python.org/file40832/odict_subclass_test_2.patch

___
Python tracker 

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



[issue25454] operator.methodcaller should accept additional arguments during the call

2015-10-21 Thread Evgeny Kapun

New submission from Evgeny Kapun:

Currently, operator.methodcaller behaves like this:

def methodcaller(name, *args, **kwargs):
def caller(obj):
return getattr(obj, name)(*args, **kwargs)
return caller

That is, it is possible to supply arguments when the object is created but not 
during the call. I think that it will be more useful if it behaved like this:

def methodcaller(name, *args, **kwargs):
def caller(obj, *args2, **kwargs2):
return getattr(obj, name)(*args, *args2, **kwargs, **kwargs2)
return caller

--
components: Extension Modules
messages: 253307
nosy: abacabadabacaba
priority: normal
severity: normal
status: open
title: operator.methodcaller should accept additional arguments during the call
type: enhancement
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Mark Dickinson

Mark Dickinson added the comment:

If the proposal is to add C99 Appendix G-style handling of nan+nanj results for 
complex multiplication, that doesn't seem unreasonable to me, though I'm not 
particularly convinced that the gain in complexity is worth it.  So -0 from me. 
Whatever happens, I'd hope that the complex multiplication operation 
remains simple and easily explainable, not degenerating into a mass of special 
cases.

I'd be opposed to adding special-case handing for float-by-complex 
multiplication (i.e., doing anything other than promoting the float to a 
complex by introducing a zero imaginary part, and then doing normal complex 
multiplication).  But I don't think that's what Francesco is proposing.

FWIW, NumPy semantics follow those of Python, though that's hardly an 
independent data point.

In answer to Steven, IEEE 754 has precisely nothing to say on this subject: it 
simply doesn't cover complex arithmetic.

Francesco: by the way, I'd be interested to see the C source that gave you `inf 
+ nan*j` for this.  How did you initialise the arguments to the multiplication? 
C99 has a significant issue here (fixed in C2011), namely that there's no 
standard way to create a complex value with given real and imaginary parts.  
(Using real_part + I*imaginary_part doesn't count, because in the absence of 
the Imaginary type, which few compilers seem to implement, the real part of the 
"I" constant mucks up the arithmetic w.r.t. infinities, NaNs and signed zeros.)

--

___
Python tracker 

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



A high-level cross-platform API for terminal/console access

2015-10-21 Thread Peter Brittain
I have recently been working on a terminal/console animation package 
(https://github.com/peterbrittain/asciimatics). Beyond the high-level animation 
methods/objects it provides, it also needed to be cross-platform and and simple 
to install with pip (including any dependencies).

This cross-platform requirement meant I needed a curses equivalent for Windows. 
 This appears to have been a regular issue over the years and I've looked 
around at previous answers on the web and this newsgroup.  Now while there's 
some pretty neat stuff out there, nothing actually gave me everything I needed.

1) colorama only gives you colours and cursor positioning, but no input, 
resizing or screen-scraping options.

2) blessings/blessed provide better (but incomplete) APIs than the curses 
package, but no Windows support unless you use colorama (which is still limited 
as above).

3) console (from effbot.org) is a native installer and so fails the pip test.  
It does however show direct use of the win32 API is a tenable approach.

4) The other packages I found were either dead projects or relied on a native 
installation of an open source implementation of curses - with no pip install 
option available.

I therefore started writing a consistent wrapper API (the Screen object) that 
uses the curses package on Unix variants and pywin32 to access the Windows 
console API.  

Over the last few months I've rounded out the features and proved that 
asciimatics works identically on Linux (various distros), OSX and Windows 7-10. 
  I know that there are still some rough edges due to the history of the 
project and so I've been deprecating old APIs in preparation for creating a 
completely clean API when I create the next major (v2.x) release.

I suspect that it could be even better though, so am looking for feedback and 
ideas from the community - both on the high-level animation features and the 
low-level cross-platform terminal API.  

Is there something you can see that could be usefully improved?  All feedback 
welcome.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Francesco Biscani

Francesco Biscani added the comment:

Hi Mark,

the original code is C++, and the inf + nanj result can be reproduced by the 
following snippet:

"""
#include 
#include 

int main(int argc, char * argv[]) {
  std::cout << std::complex(3,0) / 0. << '\n';
  return 0;
}
"""

Here is the C99 version:

"""
#include 
#include 
#include 

int main(int argc, char * argv[]) {
  double complex a = 3.0 + 0.0*I;
  printf("%f + i%f\n", creal(a/0.), cimag(a/0.));
  return 0;
}
"""

This is on Linux x86_64 with GCC 4.9. Clang gives the same result. Adding the 
"-ffast-math" compilation flag changes the result for the C version but 
apparently not for the C++ one.

The original code came from an implementation of a special function f(z) which 
has a pole near the origin. When computing f(0), the C++ code returns 
inf+nan*j, which is fine (in the sense that it is a complex infinity of some 
kind). I then need to use this result in a larger piece of code which at one 
point needs to compute 1/f(0), with the expected result being 0 mathematically. 
This works if I implement the calculation all within C/C++, but if I switch to 
Python when computing 1/f(0) I get nan + nan*j as a result.

Of course I could do all sorts of stuff to improve this specific calculation 
and avoid the problems (possibly improving the numerical behaviour near the 
pole via a Taylor expansion, etc. etc. etc.).

Beware that implementing C99 behaviour will result in a noticeable overhead for 
complex operations. In compiled C/C++ code one usually has the option to switch 
on/off the -ffast-math flag to improve performance at the expense of 
standard-conformance, but I imagine this is not feasible in Python.

--

___
Python tracker 

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



[issue25455] Some repr implementations don't check for self-referential structures

2015-10-21 Thread Evgeny Kapun

New submission from Evgeny Kapun:

Implementations of repr for some of the types in the standard library doesn't 
check for self-referential structures. As a result, when calling repr() on such 
objects, Python crashes due to infinite recursion.

Example:
>>> import functools
>>> x = functools.partial(min)
>>> x.__setstate__((x, (), {}, {}))
>>> repr(x)
Segmentation fault

Another example:
>>> import xml.etree.ElementTree
>>> x = xml.etree.ElementTree.Element('')
>>> x.tag = x
>>> repr(x)
Segmentation fault

One more example:
>>> import io
>>> class X(io.TextIOWrapper): __slots__ = 'name'
>>> x = X(open('/dev/null'))
>>> x.name = x
>>> repr(x)
Segmentation fault

--
components: Extension Modules
messages: 253309
nosy: abacabadabacaba
priority: normal
severity: normal
status: open
title: Some repr implementations don't check for self-referential structures
type: crash
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue25450] Python 3.5 starts in C:\Windows\system32 as current directory

2015-10-21 Thread Steve Dower

Changes by Steve Dower :


--
assignee:  -> steve.dower

___
Python tracker 

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



Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Denis McMahon
On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote:

> So here what I have, I have a 3 IF's within the same level.  If one IF
> is satisfied, I would like to "skip" the other IFs and continue with my
> code.

c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
 wb1_sheet1.cell(row=cell + 1, column=3).value == 0

c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and 
 wb1_sheet1.cell(row=cell + 2, column=3).value == 0

c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
 wb1_sheet1.cell(row=cell + 3, column=3).value == 0

if c1:
if c2:
if c3:
# c1 && c2 && c3
# 4 second open
else:
# c1 && c2
# 3 second open
else:
# only c1
# 2 second open

Each condition only gets evaluated once.

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


Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Grant Edwards
On 2015-10-21, Denis McMahon  wrote:
> On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote:
>
>> So here what I have, I have a 3 IF's within the same level.  If one IF
>> is satisfied, I would like to "skip" the other IFs and continue with my
>> code.
>
> c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and 
>  wb1_sheet1.cell(row=cell + 1, column=3).value == 0
>
> c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and 
>  wb1_sheet1.cell(row=cell + 2, column=3).value == 0
>
> c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
>  wb1_sheet1.cell(row=cell + 3, column=3).value == 0
>
> if c1:
> if c2:
> if c3:
> # c1 && c2 && c3
> # 4 second open
> else:
> # c1 && c2
> # 3 second open
> else:
> # only c1
> # 2 second open

if c1 && c2 && c3:
pass   # 4 seconds
elif c1 && c2:
pass   # 3 seconds
elif c1:
pass   # 2 seconds

Or if you want to be particulary obtuse:

seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None)

> Each condition only gets evaluated once.

OK.

-- 
Grant Edwards   grant.b.edwardsYow! You were s'posed
  at   to laugh!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24726] OrderedDict has strange behaviour when dict.__setitem__ is used.

2015-10-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

__repr__() allocates a list with the size len(od) and fills it iterating linked 
list. If the size of linked list is less then the size of the dict, the rest of 
the list is not initialized.

Even worse things happened when the size of linked list is greater then the 
size of the dict. Following example causes a crash:

from collections import OrderedDict
od = OrderedDict()
class K(str):
def __hash__(self):
return 1

od[K('a')] = 1
od[K('b')] = 2
print(len(od), len(list(od)))
K.__eq__ = lambda self, other: True
dict.__delitem__(od, K('a'))
print(len(od), len(list(od)))
print(repr(od))

Proposed patch fixes both issues.

--
components: +Extension Modules -Library (Lib)
keywords: +patch
stage: test needed -> patch review
type: behavior -> crash
versions:  -Python 2.7, Python 3.4
Added file: 
http://bugs.python.org/file40834/odict_repr_after_dict_setitem_delitem.patch

___
Python tracker 

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



Re: A high-level cross-platform API for terminal/console access

2015-10-21 Thread Laura Creighton
In a message of Wed, 21 Oct 2015 11:30:25 -0700, Peter Brittain writes:
>I have recently been working on a terminal/console animation package 
>(https://github.com/peterbrittain/asciimatics). Beyond the high-level 
>animation methods/objects it provides, it also needed to be cross-platform and 
>and simple to install with pip (including any dependencies).
>
>This cross-platform requirement meant I needed a curses equivalent for 
>Windows.  This appears to have been a regular issue over the years and I've 
>looked around at previous answers on the web and this newsgroup.  Now while 
>there's some pretty neat stuff out there, nothing actually gave me everything 
>I needed.
>
>1) colorama only gives you colours and cursor positioning, but no input, 
>resizing or screen-scraping options.
>
>2) blessings/blessed provide better (but incomplete) APIs than the curses 
>package, but no Windows support unless you use colorama (which is still 
>limited as above).
>
>3) console (from effbot.org) is a native installer and so fails the pip test.  
>It does however show direct use of the win32 API is a tenable approach.
>
>4) The other packages I found were either dead projects or relied on a native 
>installation of an open source implementation of curses - with no pip install 
>option available.
>
>I therefore started writing a consistent wrapper API (the Screen object) that 
>uses the curses package on Unix variants and pywin32 to access the Windows 
>console API.  
>
>Over the last few months I've rounded out the features and proved that 
>asciimatics works identically on Linux (various distros), OSX and Windows 
>7-10.   I know that there are still some rough edges due to the history of the 
>project and so I've been deprecating old APIs in preparation for creating a 
>completely clean API when I create the next major (v2.x) release.
>
>I suspect that it could be even better though, so am looking for feedback and 
>ideas from the community - both on the high-level animation features and the 
>low-level cross-platform terminal API.  
>
>Is there something you can see that could be usefully improved?  All feedback 
>welcome.
>-- 

Did you try https://pypi.python.org/pypi/UniCurses ?

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


Re: A high-level cross-platform API for terminal/console access

2015-10-21 Thread eryksun
On 10/21/15, Peter Brittain  wrote:
>>
>> Did you try https://pypi.python.org/pypi/UniCurses ?
>>
>
> Yes - it failed to install with pip and also looked like a dead project when
> I followed the project home page URL.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Also check out the curses module that's available on Christoph Gohlke's site:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A high-level cross-platform API for terminal/console access

2015-10-21 Thread Peter Brittain
> 
> Did you try https://pypi.python.org/pypi/UniCurses ?
> 

Yes - it failed to install with pip and also looked like a dead project when I 
followed the project home page URL.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24782] Merge 'configure extensions' into main IDLE config dialog

2015-10-21 Thread Mark Roseman

Mark Roseman added the comment:

The extra width appears to be coming from the canvas inside 
VerticalScrolledFrame; the canvas gets the default size and the frame adjusts 
to fit its contents (the canvas and the scrollbar). If you really want to 
reduce the size, add a "-width" option where that canvas is being created.

--

___
Python tracker 

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



Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Denis McMahon
On Wed, 21 Oct 2015 20:07:21 +, Grant Edwards wrote:

> On 2015-10-21, Denis McMahon  wrote:
>> On Wed, 21 Oct 2015 10:31:04 -0700, bigred04bd3 wrote:
>>
>>> So here what I have, I have a 3 IF's within the same level.  If one IF
>>> is satisfied, I would like to "skip" the other IFs and continue with
>>> my code.
>>
>> c1 = wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and
>>  wb1_sheet1.cell(row=cell + 1, column=3).value == 0
>>
>> c2 = wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and
>>  wb1_sheet1.cell(row=cell + 2, column=3).value == 0
>>
>> c3 = wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and
>>  wb1_sheet1.cell(row=cell + 3, column=3).value == 0
>>
>> if c1:
>> if c2:
>> if c3:
>> # c1 && c2 && c3 # 4 second open
>> else:
>> # c1 && c2 # 3 second open
>> else:
>> # only c1 # 2 second open
> 
> if c1 && c2 && c3:
> pass   # 4 seconds
> elif c1 && c2:
> pass   # 3 seconds
> elif c1:
> pass   # 2 seconds
> 
> Or if you want to be particulary obtuse:
> 
> seconds = {0b111:4, 0b110:3, 0b100:2}.get(c1<<2 | c2<<1 | c3<<0, None)

Not really valid, because #seconds n is simply a marker to indicate which 
branch of the OP's code to execute.

>> Each condition only gets evaluated once.
> 
> OK.

Yes, but in the structure I suggest, you can move the conditions back 
into the if statements and they still only each get evaluated once. Viz 
my alternative to the OP's code:

if wb1_sheet1.cell(row=cell + 1, column=2).value == 0 and wb1_sheet1.cell
(row=cell + 1, column=3).value == 0:

if wb1_sheet1.cell(row=cell + 2, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 2, column=3).value == 0:

if wb1_sheet1.cell(row=cell + 3, column=2).value == 0 and 
wb1_sheet1.cell(row=cell + 3, column=3).value == 0:

open += 3 
open_seconds += 4 
start = wb1_sheet1.cell(row=cell + 4, column=2).coordinate

else:

open += 3 
open_seconds += 3
start = wb1_sheet1.cell(row=cell + 3, column=2).coordinate 

else:

open += 3 
open_seconds += 2
start = wb1_sheet1.cell(row=cell + 2, column=2).coordinate 

Not trying to be obtuse here, trying to suggest a practical solution.

Of course, the benefit of reducing the number of times each lookup into 
the worksheet is performed by reducing the number of times each 
comparison evaluated is going to depend on the computational and memory 
manipulation cost of doing so (I assume the workbook is loaded in memory, 
so no IO costs), and how frequently this set of comparisons is being 
performed.

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


Re: If one IF is satisfied, skip the rest in the nest...

2015-10-21 Thread Ian Kelly
On Wed, Oct 21, 2015 at 11:31 AM,   wrote:
> So here what I have, I have a 3 IF's within the same level.  If one IF is 
> satisfied, I would like to "skip" the other IFs and continue with my code.

I think you're looking for the elif keyword. An elif branch will only
be considered if the previous branches were false.

if a:
do_something()
elif b:
do_something_else()
elif c:
do_something_different()
-- 
https://mail.python.org/mailman/listinfo/python-list


select.poll and ppoll

2015-10-21 Thread Steven D'Aprano
Using Python 2.6, don't hate me.

I have select.poll, but I'm looking for something like ppoll instead. From 
the Linux man page:


   ppoll()
   The relationship between poll() and ppoll() is analogous to the
   relationship  between  select(2)  and  pselect(2):  like  pselect(2), 
   ppoll()  allows  an  application to safely wait until either a file
   descriptor becomes ready or until a signal is caught.


Technically, *I* don't want this, it's one of my work-colleagues. He says:

"My high-level goal is to run a callback function whenever the alsa mixer 
level changes.  The C alsa API provides snd_mixer_elem_set_callback, but the 
Python API (import alsaaudio) seems to need me to get poll(2) descriptors"



-- 
Steve

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


[issue25417] Minor typo in Path.samefile docstring

2015-10-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 642a7be9f384 by Berker Peksag in branch '3.5':
Issue #25417: Remove the extra dot from docstring
https://hg.python.org/cpython/rev/642a7be9f384

New changeset 4cd2ae001d30 by Berker Peksag in branch 'default':
Issue #25417: Remove the extra dot from docstring
https://hg.python.org/cpython/rev/4cd2ae001d30

--

___
Python tracker 

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



Re: variable scope of class objects

2015-10-21 Thread JonRob
@Dennis,


Thanks for your example.  My structure is very similar.  Perhaps I was
reading too much into Luca's below statement regarding declaring
variables.

Regards,
JonRob




Luca wrote...
>Please, note that declaring a variable in the constructor is only a 
>convention: in Python you can add a variable to an object of a class 
>wherever you want in your code (even if it is very dangerous and 
>discouraged).


 





On Tue, 20 Oct 2015 20:18:35 -0400, Dennis Lee Bieber
 wrote:

>On Tue, 20 Oct 2015 17:33:21 -0400, jon...@mail.python.org declaimed the
>following:
>
>>
>>
>>Hello Luca,
>>
>>I very much appreciated your comments.  And I understand the
>>importance of "doing something right"  (i.e. convention).
>>
>>This leads me to another question.
>>
>>Because I am interfacing with an I2C sensor I have many register
>>definations to include (30 register addresses and  26 Variables to be
>>red from some of those registers.
>>In your comment you mentioned that convention is to declare variables
>>(and constants?)  in the construction (__ini__).
>>I am concerned that the sheer number of varialbe / constants would
>>make it difficult to read.
>>
>
>   "Constants" are typically defined at module level, using all capitals
>as a hint to the reader (Python does not have anything that one might
>consider a true constant -- other than the language defined singletons:
>None, and maybe by now True and False).
>
>   Register addresses are likely "constants". Not sure about your "26
>Variables"... Do they map directly to registers, or are they extracted as
>fields from the values returned -- that is, a register may have two or more
>"variables"? Do you read ALL registers on command and hold the values (note
>my usage -- values can be held in lists or dictionaries using a single
>"variable") for later retrieval by the user, or only read A register on
>command by the user and return that value.
>
>-=-=-=-=-
>#  registers for a fictitious motion sensor
>GYROXREG = 0x0010
>GYROYREG = 0x0011
>GYROZREG = 0x0001
>...
>MAGZREG = 0x0100
>
>class SensorA(I2C):#I'm assuming class I2C provides read/write functions
>   _registers = [GYROXREG, GYROYREG, GYROZREG,
>   ..., MAGZREG]
>   def __init__(self, SCLpin, SDApin, slaveAddress):
>   self._SCL = SCLpin
>   self._SDA = SDApin
>   self._addr = slaveAddress
>   self.update()   #initial load of values
>   def update(self):
>   #basically a loop over all addresses
>   #I'm not going to try to pseudo code the full I2C protocol
>   self.values = {}#yes, a dictionary
>   for reg in _registers:
>   aValue = self.read(self._SCL, self._SDA, self._addr, 
> reg)
>   #inherited from I2C class
>   self.values[reg] = aValue
>
>
>mySensor = SensorA(21, 22, 0x6)
>
>while True
>   mySensor.update()
>   print ("Gyro X: %s, Y: %s, Z: %s"
>   % (mySensor.values[GYROXREG],
>   mySensor.values[GYROYREG],
>   mySensor.values[GYROZREG]))
>   time.sleep(1.0)
>
>
>   
>   
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23981] Update test_unicodedata.py to use script_helpers

2015-10-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fbd83224e132 by Berker Peksag in branch '3.5':
Issue #23981: Update test_unicodedata to use script_helpers
https://hg.python.org/cpython/rev/fbd83224e132

New changeset 6315abbf5f71 by Berker Peksag in branch 'default':
Issue #23981: Update test_unicodedata to use script_helpers
https://hg.python.org/cpython/rev/6315abbf5f71

--
nosy: +python-dev

___
Python tracker 

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



[issue23981] Update test_unicodedata.py to use script_helpers

2015-10-21 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patch, Christie.

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

___
Python tracker 

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



[issue25017] htmllib deprecated: Which library to use? Missing sane default in docs

2015-10-21 Thread Nan Wu

Nan Wu added the comment:

Updated the patch. The typo was fixed too. Thanks for the catching.

--
Added file: http://bugs.python.org/file40831/htmllib_deprecation_warning_2.patch

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Ezio Melotti

Ezio Melotti added the comment:

Saksham, if you would like to work on this issue you can check the devguide for 
more information.

--
components: +Interpreter Core
nosy: +eric.smith, ezio.melotti, lemburg, mark.dickinson, stutzbach
versions: +Python 3.4, Python 3.5, Python 3.6 -Python 3.3

___
Python tracker 

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



[issue25446] smtplib.py AUTH LOGIN code messed up sending login and password data since 3.5

2015-10-21 Thread R. David Murray

R. David Murray added the comment:

Thanks, but special-casing login in the 'auth' method means that the auth 
method isn't working right, since special-casing defeats the whole purpose of 
the auth mechanism.

I think we need to change the logic in auth so that it is checking for a 334 
even if it has been provided an initial response.  That is, outdent the block 
that starts with the '# Server replies...' comment.  Once that is done, 
auth_login becomes:

  def auth_login(self, challenge=None)
  if challenge is None:
  return encode_base64(self.user.encode('ascii'))
  else:
  return self.password

We may also need to add a try/except around the base64.decodebytes in auth.

And we need a unit test that demonstrates the current failure.

I'm also wondering now about the ascii encoding on the challenge and response.  
Someone should check the RFC to see if those are limited to ascii or if they 
can contain other bytes.  If they are limited to ascii we should stick in a 
comment to that effect with a pointer to the relevant RFC section.

--

___
Python tracker 

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



Re: Defamation

2015-10-21 Thread Laura Creighton
In a message of Wed, 21 Oct 2015 10:30:35 +1100, "Steven D'Aprano" writes:
>On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote:
>> No, we are removing them because we want to.
>
>Who are "we"? You're not talking about *you and me*.

Anybody who was involved in deciding whether or not to remove them.
You, me, Ralf, Skip, Tim Golden, Terry, anybody else who is interested.



>If that's the case, that would be fantastic, but are you *sure* it works
>like that? Skip Montanaro made it clear that removing posts from the
>archives regenerates URLs for the whole month:
>
>http://www.gossamer-threads.com/lists/python/python/1176035

Yes. And if you read the rest of the thread you will see how it was proposed
to avoid that problem, with a placeholder, and thereafter Skip wrote a 
script that implemented exactly that.

>-- 
>Steven

What I am objecting to is the 'slippery slope' argument.  That, there
are bad laws some places, and some bad reasons to remove postings
doesn't mean that we should attempt to duck the responsibility of
using our own discernment by instituting a mindless policy.  That only
_buries_ the need for making a judgment call, and makes it harder to
make the right one when the right one is 'remove this thing'.

Laura

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


[issue14373] C implementation of functools.lru_cache

2015-10-21 Thread Matt Joiner

Changes by Matt Joiner :


--
nosy:  -anacrolix

___
Python tracker 

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



[issue25452] Add __bool__() method to subprocess.CompletedProcess

2015-10-21 Thread Richard Neumann

New submission from Richard Neumann:

The class subprocess.CompletedProcess is currently lacking a __bool__() method.

It might be a practical feature to have the possibility to evaluate a 
CompletedProcess instance in an if/else block without the necessity to handle 
the exception raised by CompletedProcess.check_returncode().

Hence, I suggest adding the method

def __bool__(self):
return self.returncode == 0

to the class.

--
components: Library (Lib)
messages: 253282
nosy: conqp
priority: normal
severity: normal
status: open
title: Add __bool__() method to subprocess.CompletedProcess
type: enhancement
versions: Python 3.5

___
Python tracker 

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



Re: Defamation

2015-10-21 Thread Ralf Hildebrandt
> According to Ralf, python.org is hosted in the Netherlands, 

One could change that.

> I want to buy peanut butter, but I don't, because I know that when it comes
> to peanut butter I have no self-control and would eat the entire jar in a
> single sitting. So I simply don't buy it in the first place, and the
> problem is solved.

That's what I do when it comes to candy in general )

-- 
Ralf Hildebrandt   Charite Universitätsmedizin Berlin
ralf.hildebra...@charite.deCampus Benjamin Franklin
http://www.charite.de  Hindenburgdamm 30, 12203 Berlin
Geschäftsbereich IT, Abt. Netzwerk fon: +49-30-450.570.155
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Francesco Biscani

New submission from Francesco Biscani:

The C++11/C99 standards define a complex infinity as a complex number in which 
at least one of the components is inf. Consider the Python snippet:

>>> complex(float('inf'),float('nan'))*2
(nan+nanj)

This happens because complex multiplication in Python is implemented in the 
most straightforward way, but the presence of a nan component "infects" both 
components of the result and leads to a complex nan result. See also how 
complex multiplication is implemented in Annex G.5.1.6 of the C99 standard.

It feels wrong that a complex infinity multiplied by a real number results in a 
complex nan. By comparison, the result given here by C/C++ is inf+nan*j.

Note also this:

>>> complex(float('inf'),float('nan'))+2  
(inf+nanj)

That is, addition has a different behaviour because it does not require mixing 
up the components of the operands.

This behaviour has unexpected consequences when one interacts with math 
libraries implemented in C/C++ and accessed via Python through some wrapping 
tool. For instance, whereas 1./(inf+nan*j) is zero in C/C++, it becomes in 
Python

>>> 1./complex(float('inf'),float('nan'))  
(nan+nanj)

--
messages: 253283
nosy: Francesco Biscani
priority: normal
severity: normal
status: open
title: Arithmetics with complex infinities is inconsistent with C/C++
type: behavior
versions: Python 2.7, Python 3.3

___
Python tracker 

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



[issue25453] Arithmetics with complex infinities is inconsistent with C/C++

2015-10-21 Thread Saksham Agrawal

Saksham Agrawal added the comment:

Hi

Would like to work on this bug...but I am new, would like some guidance

Please help me

--
nosy: +Saksham Agrawal

___
Python tracker 

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



Re: 2.7.9: PhotoImage get/put

2015-10-21 Thread Randy Day
In article , 
illusiontechniq...@gmail.com says...
 
[snip]

> If you want to pass arguments to a command called when a button is
> clicked, you have to use 'lambda' in tkinter.

Thanks. I just skimmed over lambda before now...

> You can't expect a delay to happen during the mainloop() of the
> program. To interrupt the mainloop(), use: parent.after(n,someCommand)
> Where 'n' is some amount of milliseconds. Just have the parent widget
> or the root frame call it.

When I read your post, I realized I'm doing 
a crude animation. After a bit of searching 
on 'python canvas animation', I found a 
reference to how it's done:

I made my 'root' Tk instance global, and 
call root.update_idletasks() after the 
.put

It works great! Now back to the lambdas 
(Ralph the Wonder Lambda, Earl J Lambda, 
Mike Q Lambda III, et al?).

--- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 2.7.9: PhotoImage get/put

2015-10-21 Thread Randy Day
In article , 
em...@fenx.com says...

[snip]

> I have no idea why, but here are some ideas I'd try out.
 
> So is it refreshing upon completion of the loop, or upon exit from 
> process()?

It turns out I need to call root.update_idletasks()
for my root Tk object to get it to refresh after
I put the pixel.

It works great now.

--- news://freenews.netfront.net/ - complaints: n...@netfront.net ---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What does it mean for Python to have “constants”?

2015-10-21 Thread Nagy László Zsolt

Dennis Lee Bieber  writes:
>> (Python does not have anything that one might consider a true constant
>> -- other than the language defined singletons: None, and maybe by now
>> True and False).
> Python now deals with those by making the names keywords::
>
> >>> True = object()
>   File "", line 1
> SyntaxError: can't assign to keyword
> >>> False = object()
>   File "", line 1
> SyntaxError: can't assign to keyword
> >>> None = object()
>   File "", line 1
> SyntaxError: can't assign to keyword
>
> which seems to rather avoid the question of whether they are “constants”
> as would be understood by newcomers experienced with that term in other
> languages.
>
This is true for Python 3, but the OP wrote his program in Python 2. In
Python 2, you can do this (unfortunately):

>>> True, False = False, True
>>> if False:
... print("DOH!")
...
DOH!


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


[issue25449] Test OrderedDict subclass

2015-10-21 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The patch was not ready for commit. The problem is that test_issue24347 fails 
in CPythonOrderedDictSubclassTests. The failure is random, you need to run test 
several times to encounter it.

Experimenting with this test I found other bug probably related to issue24347.

>>> from collections import OrderedDict
>>> od = OrderedDict()
>>> dict.__setitem__(od, 1, 2)
>>> od
OrderedDict([])

I expected rather raising an exception or showing an empty OrderedDict, that 
exposing NULL.

--

___
Python tracker 

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



[issue25450] Python 3.5 starts in C:\Windows\system32 as current directory

2015-10-21 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
title: IDLE: Save path automatically choses C:\Windows\system32 -> Python 3.5 
starts in C:\Windows\system32 as current directory
versions: +Python 3.6

___
Python tracker 

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



Re: 2.7.9: PhotoImage get/put

2015-10-21 Thread Terry Reedy

On 10/21/2015 1:50 AM, Randy Day wrote:


When I read your post, I realized I'm doing
a crude animation. After a bit of searching
on 'python canvas animation', I found a
reference to how it's done:

I made my 'root' Tk instance global, and
call root.update_idletasks() after the
.put


I did not see the original post, but the alternative way to animate is 
to use root.after(milliseconds, callback, *args) at the end of callbacks 
to allow the event loop to process other events before re-calling the 
same or another callback.


--
Terry Jan Reedy

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


[issue25450] Python 3.5 starts in C:\Windows\system32 as current directory

2015-10-21 Thread eryksun

eryksun added the comment:

> 'Start in:' is blank and for what ever reason, the default is ...system32. 

When the "Start in" field of a .lnk shortcut is blank, the child process 
inherits the working directory of the parent process (i.e. the process that 
runs the shortcut), unless the parent passes some other directory to 
ShellExecute. 

If you copy the shortcut to the desktop, for example, Explorer sets the working 
directory to the desktop. If it's run from the command prompt, cmd uses its own 
working directory. When run from the Start menu, the child inherits Explorer's 
working directory, %SystemRoot%\System32.

The old installer (pre-3.5) sets "Start in" to the installation directory. IMO, 
a better choice would be "%USERPROFILE%". The Windows shell expands the 
environment variable to the current user's profile directory when it runs the 
shortcut. 

I'm not keen on using a profile subdirectory such as "Documents" or "Desktop", 
since a user can relocate most of the special folders in his or her profile. 
Unfortunately the "Start in" field won't accept shell: locations such as 
"shell:Personal" or "shell:Desktop". It would be nice if it did, since those 
take into account relocated folders.

--
nosy: +eryksun

___
Python tracker 

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



[issue25450] Python 3.5 starts in C:\Windows\system32 as current directory

2015-10-21 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Thanks for the explanation.  When I did the test with Command Prompt, I 
happened to be in /Users/Terry, which is where C.P. starts.  %USERPROFILE% is 
what I was thinking of but could not precisely remember.  It worked when put in 
that box.

I think adding /Documents would be a mistake because many users (including me) 
put Python stuff in other subdirectories.

A minor mystery.  Changing Start in: for the Python icon requires admin 
permission; for the IDLE icon, not.

--

___
Python tracker 

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



[issue25017] htmllib deprecated: Which library to use? Missing sane default in docs

2015-10-21 Thread Martin Panter

Martin Panter added the comment:

Also beware it should be :mod: not :mode: :)

--

___
Python tracker 

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



Re: Defamation

2015-10-21 Thread Terry Reedy

On 10/21/2015 2:53 AM, Laura Creighton wrote:

In a message of Wed, 21 Oct 2015 10:30:35 +1100, "Steven D'Aprano" writes:

On Wed, 21 Oct 2015 01:44 am, Laura Creighton wrote:

No, we are removing them because we want to.


Who are "we"? You're not talking about *you and me*.


Anybody who was involved in deciding whether or not to remove them.
You, me, Ralf, Skip, Tim Golden, Terry, anybody else who is interested.




If that's the case, that would be fantastic, but are you *sure* it works
like that? Skip Montanaro made it clear that removing posts from the
archives regenerates URLs for the whole month:

http://www.gossamer-threads.com/lists/python/python/1176035


Yes. And if you read the rest of the thread you will see how it was proposed
to avoid that problem, with a placeholder, and thereafter Skip wrote a
script that implemented exactly that.


The moderators intend and try to delete such posts as those under 
discussion before they reach the list, by both automatic and manual 
filtering.  They are doing pretty well, but some posters have actively 
evaded this process (and give us training examples to improve the 
process).  I think that posts that would have unquestionably been 
deleted before being distributed are fair game to be replaced at least 
in our archive after the fact.  I appreciate the people who have done 
this cleanup work.


--
Terry Jan Reedy

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


[issue25451] PhotoImage transparency methods

2015-10-21 Thread None Becoming

New submission from None Becoming:

The transparency methods of tkinter.PhotoImage seem to be missing.
Presumably, they would go something like:

def transparency_get(self, x, y):
"""Returns a boolean indicating if the pixel at (x,y) is transparent. """

return self.tk.call(self.name, 'transparency', 'get', x, y)

def transparency_set(self, x, y, boolean=True):
"""Make pixel at (x,y) transparent if boolean is true, opaque otherwise. """

self.tk.call(self.name, 'transparency', 'set', x, y, boolean)

--
components: Tkinter
messages: 253281
nosy: None Becoming
priority: normal
severity: normal
status: open
title: PhotoImage transparency methods
type: enhancement

___
Python tracker 

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