[issue2466] os.path.ismount doesn't work for mounts the user doesn't have permission to see

2016-08-18 Thread Xiang Zhang

Xiang Zhang added the comment:

David, issue2466_ismount_py2.7_port.patch does the py2.7 port. I also back port 
other ismount test cases not existing in py2.7.

--
nosy: +xiang.zhang
Added file: http://bugs.python.org/file44145/issue2466_ismount_py2.7_port.patch

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread bananaapple

bananaapple added the comment:

Hello Berker Peksag,

1. For now, I realize the comment of David.

This is not a bug of make_archive() implementation.

However, I think documentation is not clear to understand at the first time 
reading it.

Maybe it should be rephrased.

2. Actually, what I am looking in this function is able to output the archive 
to another directory rather than current directory.

But, this functionality is not provided.

I think this functionality will be useful if implemented.

What do you think about this?

Thank you for your explaination.

--

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread Berker Peksag

Changes by Berker Peksag :


--
versions: +Python 3.5, Python 3.6 -Python 3.4

___
Python tracker 

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



[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Neil Girdhar

Neil Girdhar added the comment:

Great patch.  Shouldn't Sequence be a "Reversible, Collection"?

--

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Agree with David, this is working as designed (and matching the behavior of say 
"tar -C"). But the documentation is not clear if not confusing.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread Berker Peksag

Berker Peksag added the comment:

Hi bananaapple, there are two things that need to be addressed:

1. We need to decide whether this is a bug in make_archive() implementation or 
not. See msg223572 and msg223668 for details. I personally agree with David's 
analysis in msg223668.

We can rephrase make_archive() documentation to clarify what root_dir exactly 
does.

2. If this is a bug in make_archive() implementation, we need to add a test 
case. You can take a look at Lib/test/test_shutil.py.

--
nosy: +berker.peksag

___
Python tracker 

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



[issue26988] Add AutoNumberedEnum to stdlib

2016-08-18 Thread Vedran Čačić

Vedran Čačić added the comment:

I don't think the problem is with (Auto)Enum at all. Problem is in a different 
place, and this is just a symptom.

Problem is that people make too many assumptions about `class` suite. Yes, type 
is default metaclass. But not every class should be constructed by type's rules 
- Python provides a very detailed and powerful mechanism for specifying a 
different set of rules, should you need it. This is what metaclass keyword 
argument should be all about. And that is the true reason why metaclass 
conflict is an issue: every metaclass is a DSL specification, and the same 
suite cannot be interpreted according to two different DSLs at the same time.

But since there's a widespread myth that users don't like to type, implementors 
use a trick, "class Spam(metaclass=SpamMeta): pass", and say to their users: 
"there, just inherit from Spam like you inherit from ordinary classes". That 
way, we spare them a few keystrokes, sparing them also of opportunity to learn 
that metaclasses _do_ change the semantics of what they see indented after the 
colon.

I wonder what Raymond's poll result would be if a normal way to write such code 
would expose the metaclass

class Color(metaclass=AutoEnum):
blue
yellow

? Raymond has many valid objections, but they all apply to "ordinary" classes, 
instances of type. Color is not an instance of type, or at least conceptually 
it isn't. type (as a metaclass in Python) means a blueprint, a way to construct 
new instances via __call__, and every instance of it has that behavior, some of 
which even customize it by defining __new__ and/or __init__. type is also 
special because its power of creation is transitive: its instances know how to 
produce their instances in almost the same way it does.

But nothing of it is mandatory, and in fact it just stands in the way when we 
try to define Enum (or singletons, or database models, or... whatever that is 
not really a Python type). We do inherit from type because it's easier, and 
then usurp and override its __call__ behavior to do something almost entirely 
different. (Don't you feel something is wrong when your __new__ method doesn't 
construct a new object at all?:) It's completely possible, but it's not the 
only way.

Maybe class is just too tainted a keyword. There was a thread on python-ideas, 
that we should have a new keyword, "make". "make m n(...)" would be a clearer 
way to write what's currently written "class n(..., metaclass=m)", with a much 
more prominent position for the metaclass, obviating the need for "just inherit 
from Spam" trick, and dissociating in people's minds the connections of 
arbitrary metaobjects with type. ("class" keyword could be just a shortcut for 
"make type" in that syntax.) But of course, a new keyword is probably too much 
to ask. (A mild effect can be gained by reusing keywords "class" and "from", 
but it looks much less nice.)

However, there is _another_ underused way metaclasses can communicate with the 
external world of users of their instances: keyword arguments. I wonder if 
Raymond's objections would be as strong if the autovivification was explicitly 
documented?

class Color(Enum, style='declarative'):
blue
yellow

Of course we can bikeshed about exact keyword argument names and values, but my 
point is that there is an unused communication channel for converting typical 
Python user's surprise "why does this code even work" into "hey, what does that 
style='declarative' mean?"

--
nosy: +veky

___
Python tracker 

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



[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

LGTM, but I'm on vacation through Monday.

--

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread bananaapple

bananaapple added the comment:

Or, Is there anything I could help?

I am glad to help fixing this issue.

--

___
Python tracker 

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



[issue22021] shutil.make_archive() root_dir do not work

2016-08-18 Thread bananaapple

bananaapple added the comment:

Sorry to bother.

But This patch is still not accepted.

I still suffer this issue.

Is anyone willing to review this patch?

Thanks

--
nosy: +bananaapple

___
Python tracker 

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



[issue27794] setattr a read-only property; the AttributeError should show the attribute that failed

2016-08-18 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +xiang.zhang

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread meInvent bbird
On Friday, August 19, 2016 at 5:37:32 AM UTC+8, Lawrence D’Oliveiro wrote:
> On Friday, August 19, 2016 at 3:10:26 AM UTC+12, Chris Angelico wrote:
> > What the OP was looking for was "I want my program to be able to debug
> > itself". That means the program has to be smart enough to figure out
> > its own problems.
> 
> Maybe it is, it just doesn’t agree with you on what those problems are. ;)


a company which write siri in iphone, has already wrote a program
which can write program itself after the program talks with users

it seems possible,

i find many default function when using dir(function) to see
so i guess that these default functions in openstack have its existence reason 
which i guess for program itself.

how to append a function or code in runtime in python?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue2466] os.path.ismount doesn't work for mounts the user doesn't have permission to see

2016-08-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset dd0f1fa809c5 by R David Murray in branch 'default':
Rewrap long lines in Misc/NEWS.
https://hg.python.org/cpython/rev/dd0f1fa809c5

--

___
Python tracker 

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



[issue2466] os.path.ismount doesn't work for mounts the user doesn't have permission to see

2016-08-18 Thread R. David Murray

R. David Murray added the comment:

Thanks, Robin.

The patch doesn't apply on 2.7.  I'll leave this open to see if anyone wants to 
do the 2.7 port.

--
nosy: +r.david.murray
stage: commit review -> needs patch
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



[issue2466] os.path.ismount doesn't work for mounts the user doesn't have permission to see

2016-08-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cbc78ca21977 by R David Murray in branch '3.5':
#2466: ismount now recognizes mount points user can't access.
https://hg.python.org/cpython/rev/cbc78ca21977

New changeset db9126139969 by R David Murray in branch 'default':
Merge: #2466: ismount now recognizes mount points user can't access.
https://hg.python.org/cpython/rev/db9126139969

--
nosy: +python-dev

___
Python tracker 

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



[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

I submit a simple solution in line with __subclasshook__ of other ABCs.
I added several tests, it looks like it is doing everything right.

Please review.

--
keywords: +patch
Added file: http://bugs.python.org/file44144/collection.diff

___
Python tracker 

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



[issue26944] android: test_posix fails

2016-08-18 Thread R. David Murray

Changes by R. David Murray :


--
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



[issue26944] android: test_posix fails

2016-08-18 Thread R. David Murray

R. David Murray added the comment:

Haypo: we are testing that our function wrapper (getgroups) returns something 
that we can parse as matching the results from the 'id' command.  This gives us 
a much more meaningful test than just testing that getgroups returns 
*something*.  That is, we are testing that it returns integers, and that they 
"look right".

In that light, I propose an alternate patch.

--
nosy: +r.david.murray
Added file: http://bugs.python.org/file44143/test_getgroups_3.patch

___
Python tracker 

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



[issue27731] Opt-out of MAX_PATH on Windows 10

2016-08-18 Thread Eryk Sun

Eryk Sun added the comment:

> anything running under the python.exe will get it for free.

py.exe may as well get the manifest setting, but it's not critical. It isn't 
common to store scripts in deeply nested paths. The same goes for the distlib 
launchers that pip uses for entry points since they have to open themselves.

--
nosy: +eryksun, vinay.sajip

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Lawrence D’Oliveiro
On Friday, August 19, 2016 at 3:10:26 AM UTC+12, Chris Angelico wrote:
> What the OP was looking for was "I want my program to be able to debug
> itself". That means the program has to be smart enough to figure out
> its own problems.

Maybe it is, it just doesn’t agree with you on what those problems are. ;)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: integer's methods

2016-08-18 Thread Lawrence D’Oliveiro
On Friday, August 19, 2016 at 12:59:09 AM UTC+12, ast wrote:
> I wonder why calling a method on an integer
> doesn't work ?

Sure it does.

>>> 2 + 5
7
>>> (2).__add__(5)
7
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue12713] argparse: allow abbreviation of sub commands by users

2016-08-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 97b28115bd08 by Vinay Sajip in branch 'default':
Closes #12713: Allowed abbreviation of subcommands in argparse.
https://hg.python.org/cpython/rev/97b28115bd08

--
nosy: +python-dev
resolution:  -> fixed
stage: test needed -> 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



[issue26988] Add AutoNumberedEnum to stdlib

2016-08-18 Thread John Hagen

John Hagen added the comment:

Ethan, thank you so much for all of your work.  Looking forward to any future 
collaboration.

--

___
Python tracker 

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



[issue26988] Add AutoNumberedEnum to stdlib

2016-08-18 Thread Ethan Furman

Ethan Furman added the comment:

Thank you, Raymond, David, Barry, John, etc. for your feedback.

While I really like AutoEnum I can see that that much magic doesn't need to 
exist in the stdlib.

Unfortunately, the alternatives aren't very pretty, so I'll leave the 
AutoNumberEnum as a recipe in the docs, and not worry about an 'auto' special 
value.

For those that love AutoEnum, it will be in the aenum third-party package.

--
resolution: fixed -> rejected
stage: resolved -> 

___
Python tracker 

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



[issue27796] Expose DirEntry constructor

2016-08-18 Thread Brendan Moloney

New submission from Brendan Moloney:

As per a discussion on python-ideas [1], the consensus is that we should allow 
users to create a DirEntry object themselves. This would just take a path and 
call stat on it and cache the result of that stat call.

Nick Coghlan mentioned possibly allowing a pre-existing stat result to 
optionally be passed into the constructor [2].

[1] https://mail.python.org/pipermail/python-ideas/2016-August/041716.html
[2] https://mail.python.org/pipermail/python-ideas/2016-August/041713.html

--
messages: 273063
nosy: moloney
priority: normal
severity: normal
status: open
title: Expose DirEntry constructor
type: enhancement
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



[issue26689] Add `has_flag` method to `distutils.CCompiler`

2016-08-18 Thread Sylvain Corlay

Sylvain Corlay added the comment:

Any chance to get this in for 3.6?

--

___
Python tracker 

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



[issue27731] Opt-out of MAX_PATH on Windows 10

2016-08-18 Thread Steve Dower

Steve Dower added the comment:

> Will it apply to third-party C extensions loaded into Python?

Yes, anything running under the python.exe will get it for free.

(Non-standard entry points will need to add the flag themselves.)

--

___
Python tracker 

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



[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum

Changes by Guido van Rossum :


--
stage: commit 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



[issue27731] Opt-out of MAX_PATH on Windows 10

2016-08-18 Thread STINNER Victor

STINNER Victor added the comment:

Steve Dower added the comment:
> No, the flag that we add to the binary is backwards compatible. Earlier
versions will just ignore it.

Cool.

--

___
Python tracker 

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



[issue26488] hashlib command line interface

2016-08-18 Thread STINNER Victor

STINNER Victor added the comment:

> There are so many existing tools that already do this I don't really see
why Python needs to become yet another one.  What is the value in doing
this?

Portability. You described UNIX. There is no such tool by default on
Windows for example (as Avid said).

--

___
Python tracker 

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



[issue13516] Gzip old log files in rotating handlers

2016-08-18 Thread Mark Grandi

Mark Grandi added the comment:

While I will say that is slightly easier than subclassing, it still requires a 
function, or a variation of that to be present in every project that wants to 
have a RotatingHandler + compression, and extra lines if you use 
logging.config.dictConfig, as you will need to reference an external function 
rather than just specifying the filename = *.gz

I don't see this this simple feature would add much maintainer overhead, as 
lzma.open, bz2.open and gz.open are all pretty simple to use and are all 
already in the stdlib

--

___
Python tracker 

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



[issue26984] int() can return not exact int instance

2016-08-18 Thread Mark Dickinson

Mark Dickinson added the comment:

> Could you please make a review Mark?

Sorry, Serhiy. I missed this. I've got some time off coming up, so I plan to 
look at this in the next few days.

--

___
Python tracker 

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



[issue26488] hashlib command line interface

2016-08-18 Thread Aviv Palivoda

Aviv Palivoda added the comment:

The use case that made me think about this feature was when I was working on a 
Windows PC and needed to calculate an md5 of a file. I agree that in a unix 
environment there are existing tools but on windows you usually don't have them.

--

___
Python tracker 

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



[issue26488] hashlib command line interface

2016-08-18 Thread Gregory P. Smith

Gregory P. Smith added the comment:

There are so many existing tools that already do this I don't really see why 
Python needs to become yet another one.  What is the value in doing this?

Just use the openssl command.  "openssl sha256 myfile"  Or any of the md5sum, 
sha1sum and other plethora of commands people also have installed.

Overall the change looks pretty good (i left a couple comments on the patch), 
i'm not going to object to it going in.  But I don't know why we're bothering.

--

___
Python tracker 

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



[issue27731] Opt-out of MAX_PATH on Windows 10

2016-08-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

This is great! Will it apply to third-party C extensions loaded into Python?

--
nosy: +pitrou

___
Python tracker 

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



[issue25785] TimedRotatingFileHandler missing rotations

2016-08-18 Thread Vinay Sajip

Changes by Vinay Sajip :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue26488] hashlib command line interface

2016-08-18 Thread Aviv Palivoda

Aviv Palivoda added the comment:

Hi, is there anything more I need to do on this patch? If not do you think this 
can be added in 3.6?

--

___
Python tracker 

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



[issue24905] Allow incremental I/O to blobs in sqlite3

2016-08-18 Thread Aviv Palivoda

Aviv Palivoda added the comment:

Thanks for the review Serhiy. Attached is the updated patch after the changes.

--
Added file: http://bugs.python.org/file44142/blob2.patch

___
Python tracker 

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



[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Ivan Levkivskyi

Ivan Levkivskyi added the comment:

On my machine 8 tests are always skipped:
test_devpoll test_kqueue test_msilib test_ossaudiodev
test_startfile test_winreg test_winsound test_zipfile64
All others tests pass OK.

The main part of the work is by Andrew Barnert, I only introduced small changes 
due to previous changes in Reversible and few minor things in response to 
previous comments.

Guido, thank you for applying the patch!

--

___
Python tracker 

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



[issue13516] Gzip old log files in rotating handlers

2016-08-18 Thread Vinay Sajip

Vinay Sajip added the comment:

You don't need a subclass - you can specify your own function to do it, as in 
the cookbook example:

https://docs.python.org/3/howto/logging-cookbook.html#using-a-rotator-and-namer-to-customize-log-rotation-processing

--

___
Python tracker 

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



[issue13516] Gzip old log files in rotating handlers

2016-08-18 Thread Mark Grandi

Mark Grandi added the comment:

I just ran into this myself, and would challenge the notion that just because 
few people complain about the fact that built in compression isn't built in for 
logging handlers (such as TimedRotatingFileHandler), that it isn't a needed 
feature. This is such a common feature in pretty much everything that it would 
be nice to have it built in rather than having a custom RotatingHandler 
subclass that just compresses the logs and does nothing else in every project I 
work with.

While not python, i searched github for logback/slf4j (java logging framework) 
entries for their equivilent of TimedRotatingFileHandler and I found quite a 
few results:

https://github.com/search?utf8=%E2%9C%93=fileNamePattern%2F%3E*.gz+language%3AXML=Code=searchresults

you don't even have to change the API of it, it could act the same way as the 
tarfile module, where if the 'filename' argument ends in one of "bz2", "gz" or 
'xz" then it is compressed with that compression type, and if not, then it 
doesn't compress it (what it does now)

and, that is how logback/slf4j does it as well 
(http://logback.qos.ch/manual/appenders.html#fwrpFileNamePattern)

--
nosy: +markgrandi

___
Python tracker 

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



Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Jussi Piitulainen
MRAB writes:

> On 2016-08-18 10:46, Jussi Piitulainen wrote:
>> Marko Rauhamaa writes:
>>
>>> Jussi Piitulainen wrote:
>>>
 That looks a bit funny if the "keyword" does not look like a word,
 but then programming languages do look funny, so why not:

(c ? t : e)  # ?-expression

(c -> t, e)  # ->-expression
>>>
>>> That ship has already sailed.
>>
>> Sorry, what?
>>
> You've missed the bus.
>
> The train has left the station.
>
> In other words, you're too late. :-)

Yes, I understood _that_. I just don't understand how it can be too late
to observe that "?-expression" looks a bit funny but not so funny that
it couldn't be used to refer to such expressions.

But never mind, even I have more interesting issues to think about :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 3:00 AM, Terry Reedy  wrote:
> On 8/18/2016 5:32 AM, Steven D'Aprano wrote:
>
>>> Beginners often do not understand that the body of a lambda expression
>>> is evaluated in a new local namespace, and only when the resulting
>>> function is called, the same as with a def statement.  They then neglect
>>> to capture current values when writing lambda expressions in a for loop.
>>
>>
>> Sure. But since the behaviour of def functions and lambda functions are
>> identical, writing a named def won't solve that problem.
>
>
> It will if people do not make the same mental mistake when writing a def,
> because they think def functions and 'lambdas' behave differently.
>
> I can't remember every seeing "my def function in a loop does not work
> right" while "my lambda in a loop does not work right" is distressingly
> common.  What I don't know is whether the sparsity of the former type of
> report is because those subject to the error get it right when they use def
> in a loop or because they never use def in a loop.

The latter. People who are confused about lambda in a loop are not
magically unconfused by def in a loop; in fact, I'd expect to see
*more* confusion, because those same people are likely to be confused
by the fact that a "declaration" can be done more than once and have
different effects. That is to say, a lambda function looks like it's
being created at the point where you use it, but a def function looks
like a declaration, which is independent of loops and stuff. I don't
have actual stats on how many people are confused by each, but I know
both points do cause confusion. Having def statements inside loops is
definitely [1] rarer than using lambda expressions inside loops.

ChrisA

[1] Pun intended. And I'm not sorry.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Terry Reedy

On 8/18/2016 5:32 AM, Steven D'Aprano wrote:


Beginners often do not understand that the body of a lambda expression
is evaluated in a new local namespace, and only when the resulting
function is called, the same as with a def statement.  They then neglect
to capture current values when writing lambda expressions in a for loop.


Sure. But since the behaviour of def functions and lambda functions are
identical, writing a named def won't solve that problem.


It will if people do not make the same mental mistake when writing a 
def, because they think def functions and 'lambdas' behave differently.


I can't remember every seeing "my def function in a loop does not work 
right" while "my lambda in a loop does not work right" is distressingly 
common.  What I don't know is whether the sparsity of the former type of 
report is because those subject to the error get it right when they use 
def in a loop or because they never use def in a loop.


--
Terry Jan Reedy

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


Re: type lookuperror

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 2:21 AM, Marko Rauhamaa  wrote:
>
> Yeah, I believe truly conscious machines will arise without being
> designed through technological evolution. First they'll develop
> electronics that can simulate brain cells; the clumsy gadgets will be
> used to replaced cells damaged by Parkinson's or Alzheimer's. Then,
> healthy people will start enhancing their brain functions by using the
> same technology. Over time, wetware will be replaced by hardware, and
> the hardware, in turn, will migrate to the cloud.

http://mtgsalvation.gamepedia.com/Esper

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


[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Pushed, let's see what the buildbots say.

--
resolution:  -> fixed
stage: patch review -> commit review

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Marko Rauhamaa
Chris Angelico :

> On Fri, Aug 19, 2016 at 1:28 AM, Marko Rauhamaa  wrote:
>> What is needed is an automated methodology to derive algorithmic
>> solutions to formally specified features. Since there are only a
>> handful of tools in a programmer's toolbox, that objective doesn't
>> seem at all impossible. The big question is, is it possible to
>> specify features formally without actually coding them?
>
> If you're specifying them formally, you're probably coding them. Any
> form sufficiently well-defined for a program to analyze is basically
> code already. It might be a goal-based syntax rather than action-based
> (eg contrast SQL's way of saying "these are the rows I want" with
> classic imperative programming), but it's still code, it's still
> software, it's still not the Singularity.

Yeah, I believe truly conscious machines will arise without being
designed through technological evolution. First they'll develop
electronics that can simulate brain cells; the clumsy gadgets will be
used to replaced cells damaged by Parkinson's or Alzheimer's. Then,
healthy people will start enhancing their brain functions by using the
same technology. Over time, wetware will be replaced by hardware, and
the hardware, in turn, will migrate to the cloud.

Steven Lisberger saw this already way back: https://en.wikipedia.org/wiki/Tron>.

Once we run on Google's server farms, we can back ourselves up as
snapshots and clone ourselves indefinitely. That will be one big
identity crisis. Even further along, maybe the intercommunication
between the virtual selves will blur the lines between individuals, and
we'll merge into a pantheistic Nirvana (or infernal pandemonium).


Marko


PS Long before, though, we'll likely get direct communication ports to
our brains and be liberated from mice and keyboards (first) and speakers
and displays (a bit later).
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 72b9f195569c by Guido van Rossum in branch 'default':
Anti-registration of various ABC methods.
https://hg.python.org/cpython/rev/72b9f195569c

--
nosy: +python-dev

___
Python tracker 

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



[issue27558] SystemError with bare `raise` in threading or multiprocessing

2016-08-18 Thread STINNER Victor

Changes by STINNER Victor :


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

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Larry Martell
On Thu, Aug 18, 2016 at 10:02 AM, Gene Heskett  wrote:
> On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:
>
>> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird 
> wrote:
>> > actually i would like to remove try except code in all function
>> >
>> > and i feel that try except code for a large block code can not
>> > show which function name , which line number error,
>> > if use try except for specified code block to show where it has
>> > error it will have many ugly try except code and need many human
>> > force to craft the code, i hope that code write once for program to
>> > program itself in future.
>> >
>> > actually this method i ask is not good enough since it will need
>> > to add many function wrapper.
>>
>> You can't get a program to program itself. That's called the
>> Singularity [1], and depending on your point of view, it's either
>> still in the future, or fundamentally impossible. In any case,
>> computers today cannot program themselves.
>
> That is a pretty broad statement to make, considering I have actually
> done it. On an RCA 1802 based (Cosmac Super Elf) computer. Every byte of
> static ram memory in those days (1978) was precious, (4k board kit was
> $250) so rather than having 30 nearly identical copies of a subroutine
> each doing a similar job but with different data, I actually overwrote 3
> or 4 bytes of a single subroutine to change what it did according to
> where it was in the main loop.  So when it was done with that pass, it
> put the original bytes back. Controlling a videotape machine at a tv
> station in northern kalipornia, it was dead stable, running from power
> failure to power failure.  And, I checked about 15 years later, and it
> was still in 10+ times a day use.  If memory was that precious today, it
> would still be a valid method to shrink a complex program.

Freshman year of college, 1977, final exam for a Fortran class. One of
the questions was to write some program but only use some specified
small amount of memory. I do not think anyone in the class was able to
do it. The only way to do it was to write self modifying code,
something that we had never covered in class.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27558] SystemError with bare `raise` in threading or multiprocessing

2016-08-18 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks for your work too! ;) I agree to close.

--

___
Python tracker 

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



[issue27587] Issues, reported by PVS-Studio static analyzer

2016-08-18 Thread STINNER Victor

STINNER Victor added the comment:

issue27587_pystate_addmodule_v2.diff LGTM.

--

___
Python tracker 

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



[issue27558] SystemError with bare `raise` in threading or multiprocessing

2016-08-18 Thread STINNER Victor

STINNER Victor added the comment:

Thanks Xiang Zhang. The fix is obvious and simple, but it wasn't easy to 
identify it ;-) I pushed the fix to Python 3.5 and default (3.6).

Python 2.7 doesn't crash, the bare "raise" statement raises the exception: 
TypeError('exceptions must be old-style classes or derived from BaseException, 
not NoneType',). I suggest to not touch Python 2.7 and close the issue.

--

___
Python tracker 

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



[issue27558] SystemError with bare `raise` in threading or multiprocessing

2016-08-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ba45fbb16499 by Victor Stinner in branch '3.5':
Fix SystemError in "raise" statement
https://hg.python.org/cpython/rev/ba45fbb16499

--
nosy: +python-dev

___
Python tracker 

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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson

Mark Dickinson added the comment:

FWIW, I'd suggest not changing this in 3.5; only in 3.6. It's a fairly harmless 
bug that's been with us throughout the 3.x series so far (and even back into 
2.x, if you start looking at behaviour with subclasses of `long`).

--

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 1:28 AM, Marko Rauhamaa  wrote:
> What is needed is an automated methodology to derive algorithmic
> solutions to formally specified features. Since there are only a handful
> of tools in a programmer's toolbox, that objective doesn't seem at all
> impossible. The big question is, is it possible to specify features
> formally without actually coding them?

If you're specifying them formally, you're probably coding them. Any
form sufficiently well-defined for a program to analyze is basically
code already. It might be a goal-based syntax rather than action-based
(eg contrast SQL's way of saying "these are the rows I want" with
classic imperative programming), but it's still code, it's still
software, it's still not the Singularity.

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


[issue25958] Implicit ABCs have no means of "anti-registration"

2016-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

The patch LGTM. Do all the tests pass? Who should be attributed in the commit 
message and the Misc/NEWS item?

--

___
Python tracker 

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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +xiang.zhang

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Marko Rauhamaa
Chris Angelico :
> What the OP was looking for was "I want my program to be able to debug
> itself". That means the program has to be smart enough to figure out
> its own problems. Self-modifying code isn't anywhere near that level
> of intelligence.

You are right that we're not nearly there yet (although genetic
programming is a bit of a similar thing).

What is needed is an automated methodology to derive algorithmic
solutions to formally specified features. Since there are only a handful
of tools in a programmer's toolbox, that objective doesn't seem at all
impossible. The big question is, is it possible to specify features
formally without actually coding them?


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


[issue26988] Add AutoNumberedEnum to stdlib

2016-08-18 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

Ethan, the suggestion has come up several times about using a dummy value such 
as the empty tuple to do autonumbering, thus looking more Pythonic.  I'm not a 
huge fan of the empty tuple, and I'm still not sure whether we need this, but I 
wonder if it would be possible to not have a new base class, but to put the 
smarts in the value to which the enums were assigned.  E.g. is this possible (a 
separate question than whether it's good :):

from enum import Enum, auto

class Color(Enum):
red = auto
green = auto
blue = auto

Apologies if this has already been suggested; this tracker thread is too long 
to read the whole thing. :(

--

___
Python tracker 

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



[issue26988] Add AutoNumberedEnum to stdlib

2016-08-18 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Temporarily, marking this as open so that more people can see the new comments.

For John, I'm not sure what I can say that will help you.  The goal of the 
standard libraries modules is to provide tools the use language we have, not to 
invent a new language the isn't really Python or Pythonic.  In the absence of 
an "enum" keyword, you have a number of ways to work within the language.

In this case (wanting auto numbering but not caring what the values are), you 
already have several ways to do it.  I your issue is not where the use case is 
met; instead, you just don't like how their spelled (because it isn't exactly 
how it it looks in C).

This already works:  Animal = Enum('Animal', ['ant', 'bee', 'cat', 'dog']).  
This is very flexible and lets you read the constants from many possible 
sources.

If you're attracted to multiline input, that is already possible as well:

Animal = Enum('Animal', '''
ant
bee
cat
dog
''')

It is clear that you're bugged by writing Animal twice, but that is how Python 
normally works and it is a very minor nuisance (it only occurs once when the 
enum is defined).  Note, you already are rewriting "Animal" every time you use 
the enum value (presumably many times):  board_ark(Animal.ant, Animal.bee)

This whole feature request boils down to wanting a currently existing feature 
to be spelled a little differently, in a way that doesn't look like normal 
Python.  Elsewhere, we resisted the temptation to alter the language 
look-and-feel to accommodate small spelling tweaks for various modules (i.e. we 
pass in normal strings to the regex module even though that sometimes requires 
double escaping, we pass in the class name to namedtuples even though that uses 
the class name twice, the xpath notation in passed into XML tools as strings 
even though parts of it look like regular langauge, we don't abuse the | 
operator to link together chains of itertools, etc)

Since the enum module already provides one way to do it, I recommend that we 
stick with that one way.  Creating too many variants does not help users.  
Using the core language in odd ways also does not help users.

--
status: closed -> open

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Chris Angelico
On Fri, Aug 19, 2016 at 12:02 AM, Gene Heskett  wrote:
> On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:
>
>> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird 
> wrote:
>> > and i feel that try except code for a large block code can not
>> > show which function name , which line number error,
>> > if use try except for specified code block to show where it has
>> > error it will have many ugly try except code and need many human
>> > force to craft the code, i hope that code write once for program to
>> > program itself in future.
>>
>> You can't get a program to program itself. That's called the
>> Singularity [1], and depending on your point of view, it's either
>> still in the future, or fundamentally impossible. In any case,
>> computers today cannot program themselves.
>
> That is a pretty broad statement to make, considering I have actually
> done it. [chomp details]

What you described there is an example of metaprogramming. The
thoughts behind the code all existed prior to the code modifying its
own bytes in memory. It's a fancy form of the same sorts of things
that can be done with monkeypatching and similar techniques.

What the OP was looking for was "I want my program to be able to debug
itself". That means the program has to be smart enough to figure out
its own problems. Self-modifying code isn't anywhere near that level
of intelligence.

(That's not to say self-modifying code isn't impressive, in its way. I
have great respect for it. But you have to plan it out in advance,
ergo it's not having the program program itself.)

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


[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

I thought about this some more. It won't work because when a class method
is called via super(), 'cls' is still set to the derived class (and in
general for class methods that's the right thing to do, just as it is for
regular methods that self is still the actual object). If you read my
previous long comment you'll understand that all the __subclasshook__
methods carefully return NotImplemented immediately if their 'cls' argument
is not the class where they are defined. So it won't work.

I also don't see the use case (you're not supposed to do this at home,
basically).

--

___
Python tracker 

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



[issue27598] Add SizedIterable to collections.abc and typing

2016-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Why don't you give it a try? I'd be happy to review a patch from you.

--

___
Python tracker 

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



Re: type lookuperror

2016-08-18 Thread Gene Heskett
On Thursday 18 August 2016 07:28:06 Chris Angelico wrote:

> On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird  
wrote:
> > actually i would like to remove try except code in all function
> >
> > and i feel that try except code for a large block code can not
> > show which function name , which line number error,
> > if use try except for specified code block to show where it has
> > error it will have many ugly try except code and need many human
> > force to craft the code, i hope that code write once for program to
> > program itself in future.
> >
> > actually this method i ask is not good enough since it will need
> > to add many function wrapper.
>
> You can't get a program to program itself. That's called the
> Singularity [1], and depending on your point of view, it's either
> still in the future, or fundamentally impossible. In any case,
> computers today cannot program themselves.

That is a pretty broad statement to make, considering I have actually 
done it. On an RCA 1802 based (Cosmac Super Elf) computer. Every byte of 
static ram memory in those days (1978) was precious, (4k board kit was 
$250) so rather than having 30 nearly identical copies of a subroutine 
each doing a similar job but with different data, I actually overwrote 3 
or 4 bytes of a single subroutine to change what it did according to 
where it was in the main loop.  So when it was done with that pass, it 
put the original bytes back. Controlling a videotape machine at a tv 
station in northern kalipornia, it was dead stable, running from power 
failure to power failure.  And, I checked about 15 years later, and it 
was still in 10+ times a day use.  If memory was that precious today, it 
would still be a valid method to shrink a complex program.

> So what exactly is it you're wanting? When an exception happens, the
> entire traceback is recorded, and unless you're throwing that away,
> it'll be shown to you. Just let the exception bubble all the way up to
> top level, and then read the traceback. Some IDEs can even help you
> step through the code to see context for each line of traceback;
> ipython is also pretty helpful with reading tracebacks. I advise
> getting to know the tools you have available, rather than trying to
> reinvent the wheel.

Re-inventing the wheel is not required when all it needs is a new valve 
stem.

> ChrisA
>
> [1] https://en.wikipedia.org/wiki/Technological_singularity


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27794] setattr a read-only property; the AttributeError should show the attribute that failed

2016-08-18 Thread Antti Haapala

Antti Haapala added the comment:

Unfortunately it seems that it is not that straightforward. The descriptor 
object doesn't know the name of the property. The error is raised in 
`property_descr_set`. However the error itself can be propagated from setting 
another property.

--

___
Python tracker 

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



[issue27794] setattr a read-only property; the AttributeError should show the attribute that failed

2016-08-18 Thread Emanuel Barry

Emanuel Barry added the comment:

The approach I'd take would be to change how {get,set,del}attr handle 
AttributeError; possibly by automatically filling in the information and giving 
a nicer error message. This would fix this as a side-effect (somewhat; some 
bits of code would need to change). How does that sound to core devs?

--
nosy: +ebarry

___
Python tracker 

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



[issue27795] Cygwin compile errors

2016-08-18 Thread R. David Murray

R. David Murray added the comment:

Yes, we know :(  There are a lot of issues in this tracker about mingw and 
cygwin.  If you can help review them, that would be fantastic.

--
nosy: +r.david.murray
resolution:  -> duplicate
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



[issue27794] setattr a read-only property; the AttributeError should show the attribute that failed

2016-08-18 Thread R. David Murray

R. David Murray added the comment:

If someone submits a patch in time, we'd probably accept it.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue27793] Double underscore variables in module are mangled when used in class

2016-08-18 Thread R. David Murray

R. David Murray added the comment:

This is working as designed 
(https://docs.python.org/3/tutorial/classes.html#private-variables):

"This mangling is done without regard to the syntactic position of the 
identifier, as long as it occurs within the definition of a class."

If you want to advocate changing that you'll have to start a thread on 
python-ideas, but I don't think the benefit would be worth the cost.

--
nosy: +r.david.murray
resolution:  -> not a bug
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



[issue27795] Cygwin compile errors

2016-08-18 Thread Kaeptm Blaubaer

New submission from Kaeptm Blaubaer:

If I try to compile Python 3.5 with Cygwin, I get a lot of errors.

--
components: Build, Windows
messages: 273031
nosy: Kaeptm Blaubaer, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Cygwin compile errors
type: compile error
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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson

Mark Dickinson added the comment:

Ah, it looks as though this is already fixed in master, and it's probably not 
worth fixing for 3.5. Closing.

--
status: open -> closed

___
Python tracker 

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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson

Mark Dickinson added the comment:

Whoops; no, it's not fixed. 3.6 introduced a fast path that has the side-effect 
of fixing this issue for the `True % 2` case, but not for all cases:

>>> False % 2
False
>>> True % 2
1
>>> class MyInt(int): pass
... 
>>> type(MyInt(0) % 6)

>>> type(MyInt(1) % 6)


--
resolution: out of date -> 
status: closed -> open

___
Python tracker 

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



[issue27727] Update Tools/freeze to use .vcxproj files

2016-08-18 Thread Kaeptm Blaubaer

Kaeptm Blaubaer added the comment:

That's right, in checkextensions_win32.py a .vcxproj parsing algorithm must be 
added, and in extensions_win32.ini the values must be updated, for example the 
builtin extensions from .dsp to .vcxproj

--
versions: +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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson

Changes by Mark Dickinson :


--
resolution:  -> out of date

___
Python tracker 

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



Re: Error in while loop code for packing items

2016-08-18 Thread MRAB

On 2016-08-18 14:10, GP wrote:

On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote:

GP wrote:


[snip]


However, when you really want to remove all items you instead assign a new
empty list

for item in items:
print(item)
items = []



Thanks Peter for the information. It helps to find the source of error .

What I wanted was to remove the items that was packed so that the code  can 
check for the next items that match the criteria and then pack those and delete 
them  and keep on repeating until all the items are packed. This is where I am 
getting stuck.

The simplest way is to iterate over the list of items and, for each 
item, if it fits the shelf, put it on the shelf, else put it into a list 
of the 'unused' items.


At the end of a pass, you'll have a shelf of items and a list of the 
remaining items.


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


[issue27794] setattr a read-only property; the AttributeError should show the attribute that failed

2016-08-18 Thread Antti Haapala

New submission from Antti Haapala:

Today we had an internal server error in production. I went to see the sentry 
logs for the error, and was dismayed: the error was `AttributeError: can't set 
attribute`, and the faulting line was `setattr(obj, attr, value)` that happens 
in a for-loop that uses computed properties coming from who knows.

Well, I quickly ruled out that it was because the code was trying to set a 
value to a read-only property descriptor, the only problem was to find out 
*which of all these read-only properties* was it trying to set:

Python 3.6.0a3+ (default, Aug 11 2016, 11:45:31) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo:
... @property
... def bar(self): pass
... 
>>> setattr(Foo(), 'bar', 42)
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: can't set attribute

Could we change this for Python 3.6 so that the message for this could include 
the name of the property just like `AttributeError: has no attribute 'baz'` 
does?

--
messages: 273027
nosy: ztane
priority: normal
severity: normal
status: open
title: setattr a read-only property; the AttributeError should show the 
attribute that failed
type: enhancement

___
Python tracker 

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



Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread MRAB

On 2016-08-18 10:46, Jussi Piitulainen wrote:

Marko Rauhamaa writes:


Jussi Piitulainen wrote:


That looks a bit funny if the "keyword" does not look like a word,
but then programming languages do look funny, so why not:

   (c ? t : e)  # ?-expression

   (c -> t, e)  # ->-expression


That ship has already sailed.


Sorry, what?


You've missed the bus.

The train has left the station.

In other words, you're too late. :-)

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


Re: integer's methods

2016-08-18 Thread BartC

On 18/08/2016 14:01, Marko Rauhamaa wrote:

"ast" :


123.bit_length()

SyntaxError: invalid syntax


I fell into that trap myself.

CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".


Or use (123).bit_length() which looks slightly less odd.

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


Re: Error in while loop code for packing items

2016-08-18 Thread GP
On Thursday, August 18, 2016 at 5:59:43 PM UTC+5:30, Peter Otten wrote:
> GP wrote:
> 
> The error and your second snippet aren't compatible, so I assume the 
> exception is raised by
> 
> > for k in range(0,len(shelf)):
> >   q1=ListDictItem[k]
> >   q2 = ListDictItem.pop(k) #deletes the items that are packed.
> 
> > Error message:Traceback (most recent call last):
> >   File "C:\Project\Python\ReadExcel-xlrd.py", line 201, in 
> > q1=ListDictItem[k]
> > IndexError: list index out of range.
> 
> Take a moment to understand what happens if you iterate over the loop index 
> like above:
> 
> items = ["foo", "bar", "baz"]
> 
> for k in range(len(items)):
> item = items[k]
> print(item)
> items.pop(k)
> 
> You start with k=0, item is set to items[0], i. e. "foo", that is printed 
> and then items.pop(0) removes "foo" from the list which now looks like
> 
> items = ["bar", "baz"]
> 
> Now k=1, item is set to items[1], ie. "baz" ("bar" is never processed), 
> "baz" is printed and then items.pop(1) removes "baz" and the list becomes
> 
> items = ["bar"]
> 
> Now k=2, so when you access items[2] from a list with only one item you get 
> the IndexError. To make similar code work you need a while loop:
> 
> while items:
> item = items.pop(0)
> print(item)
> 
> However, when you really want to remove all items you instead assign a new 
> empty list
> 
> for item in items:
> print(item)
> items = []


Thanks Peter for the information. It helps to find the source of error .

What I wanted was to remove the items that was packed so that the code  can 
check for the next items that match the criteria and then pack those and delete 
them  and keep on repeating until all the items are packed. This is where I am 
getting stuck.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: integer's methods

2016-08-18 Thread Lutz Horn

CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".


Ok, this works:

>>> 123 .bit_length()
7

But it looks really strange. Let's use a variable instead of an integer 
literal.


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


[issue27587] Issues, reported by PVS-Studio static analyzer

2016-08-18 Thread Berker Peksag

Berker Peksag added the comment:

Here is an updated patch.

--
Added file: 
http://bugs.python.org/file44141/issue27587_pystate_addmodule_v2.diff

___
Python tracker 

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



Re: integer's methods

2016-08-18 Thread ast


"Marko Rauhamaa"  a écrit dans le message de 
news:87k2fefcyu@elektro.pacujo.net...

"ast" :


123.bit_length()

SyntaxError: invalid syntax


I fell into that trap myself.

CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".


Marko


Indeed.

Maybe because of a confusion with the decimal point.

Thx 


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


Re: integer's methods

2016-08-18 Thread Lutz Horn

Am 08/18/2016 um 02:58 PM schrieb ast:

123.bit_length()

SyntaxError: invalid syntax


You are not calling a method here because the parser is not finished.

The parser thinks you want to write a float with the value 1.bit_length
which is not valid Python syntax.

Lutz


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


Re: integer's methods

2016-08-18 Thread Igor Korot
Hi,

On Thu, Aug 18, 2016 at 8:58 AM, ast  wrote:
> Hello
>
> I wonder why calling a method on an integer
> doesn't work ?

123 is not an integer. Its an integer constant. ;-)

Thank you.

>
 123.bit_length()
>
> SyntaxError: invalid syntax
>
 123.to_bytes(3, 'big')
>
> SyntaxError: invalid syntax
>
> but it works with a variable
>
 i = 123
 i.bit_length()
>
> 7
>
 i=123
 i.to_bytes(3, 'big')
>
> b'\x00\x00{'
>
> I am working with pyhton 3.5.1
>
> thx
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: integer's methods

2016-08-18 Thread Marko Rauhamaa
"ast" :

 123.bit_length()
> SyntaxError: invalid syntax

I fell into that trap myself.

CPython's lexical analyzer can't handle a dot after an integer literal
so you must add a space in between "123" and ".".


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


[issue27776] PEP 524: Make os.urandom() blocking on Linux

2016-08-18 Thread Nick Coghlan

Nick Coghlan added the comment:

I have a few requests for clarification and confirmation as review comments, 
but overall +1 from me.

(I'd still like a warning when we need to block in order to make life easier 
for system administrators attempting to debug any apparent system hangs, but as 
per the security-sig discussion, I can pursue that in a follow-up RFE and a 
separate patch, while this patch implements the PEP precisely as accepted)

--
nosy: +ncoghlan

___
Python tracker 

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



integer's methods

2016-08-18 Thread ast

Hello

I wonder why calling a method on an integer
doesn't work ?


123.bit_length()

SyntaxError: invalid syntax


123.to_bytes(3, 'big')

SyntaxError: invalid syntax

but it works with a variable


i = 123
i.bit_length()

7


i=123
i.to_bytes(3, 'big')

b'\x00\x00{'

I am working with pyhton 3.5.1

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


Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Marko Rauhamaa
Chris Angelico :
> Folks, read the whole thread before posting :)

Corollary:

   Folks, start a new thread before posting :)


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


PyDev 5.2.0 Released

2016-08-18 Thread Fabio Zadrozny
Release Highlights:
---

* **Important** PyDev now requires Java 8 and Eclipse 4.5 onwards.

* PyDev 4.5.5 is the last release supporting Java 7 and Eclipse 3.8.
* See: `update sites page`_ for the update site of older versions of
PyDev.
* See: the **PyDev does not appear after install** section on `the
download page`_ for help on using a Java 8 vm in Eclipse.

* Inital support for code-completion using **PEP 484 static type
declarations**.

* **Debugger**

* Fixed racing condition where the variables view would not be properly
shown in the debugger -- which made an additional select of the stack
required in order to show the variables (#PyDev-672).
* Reusing the existing stack from the thread in the debugger (so that
the expanded state of the variables is properly kept on step over).
* Fixed issue changing attribute of local variable in the variables
view (#PyDev.Debugger-56).
* Fixed issue on attach to process: it required the pydevd_tracing to
be at the top-level and it was moved to _pydevd_bundle (restored it to be a
public API).

* **Indentation**

* The default indent mode now changed to better follow PEP 8 guidelines:

* Indenting directly after {, [, ( will add one indent level.
* Indenting after another token in a line with a {, [, ( will
indent to the {, [, ( level.

* It's possible to restore previous indent modes (which either always
indented to the parenthesis level or always indented a single level) in the
preferences > PyDev > Editor > Typing.

* **Interactive console**

* IPython 5 now supported in interactive console (#PyDev-710).
* Fixed issue executing single line with multiple statements in console.
* Fixed issue executing a multiple line statement in Jython.

* **Others**

* The (fast) parser which detects the outline of a Python module now
handles mixed indentation (and additional fixes which could result in log
entries such as "Did not expect to find item below node: Assign...").
* Support for unpacking generalizations (PEP 448) which could still
result in a syntax error for the Python 3 grammar (#PyDev-701).
* Fixed error in code analysis when the code is connected to an RTC
source control (#PyDev-184, patch by Wesley Barroso Lopes)

What is PyDev?
---

PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and
IronPython development.

It comes with goodies such as code completion, syntax highlighting, syntax
analysis, code analysis, refactor, debug, interactive console, etc.

Details on PyDev: http://pydev.org
Details on its development: http://pydev.blogspot.com


What is LiClipse?
---

LiClipse is a PyDev standalone with goodies such as support for Multiple
cursors, theming, TextMate bundles and a number of other languages such as
Django Templates, Jinja2, Kivy Language, Mako Templates, Html, Javascript,
etc.

It's also a commercial counterpart which helps supporting the development
of PyDev.

Details on LiClipse: http://www.liclipse.com/



Cheers,

--
Fabio Zadrozny
--
Software Developer

LiClipse
http://www.liclipse.com

PyDev - Python Development Environment for Eclipse
http://pydev.org
http://pydev.blogspot.com

PyVmMonitor - Python Profiler
http://www.pyvmmonitor.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error in while loop code for packing items

2016-08-18 Thread Peter Otten
GP wrote:

The error and your second snippet aren't compatible, so I assume the 
exception is raised by

> for k in range(0,len(shelf)):
>   q1=ListDictItem[k]
>   q2 = ListDictItem.pop(k) #deletes the items that are packed.

> Error message:Traceback (most recent call last):
>   File "C:\Project\Python\ReadExcel-xlrd.py", line 201, in 
> q1=ListDictItem[k]
> IndexError: list index out of range.

Take a moment to understand what happens if you iterate over the loop index 
like above:

items = ["foo", "bar", "baz"]

for k in range(len(items)):
item = items[k]
print(item)
items.pop(k)

You start with k=0, item is set to items[0], i. e. "foo", that is printed 
and then items.pop(0) removes "foo" from the list which now looks like

items = ["bar", "baz"]

Now k=1, item is set to items[1], ie. "baz" ("bar" is never processed), 
"baz" is printed and then items.pop(1) removes "baz" and the list becomes

items = ["bar"]

Now k=2, so when you access items[2] from a list with only one item you get 
the IndexError. To make similar code work you need a while loop:

while items:
item = items.pop(0)
print(item)

However, when you really want to remove all items you instead assign a new 
empty list

for item in items:
print(item)
items = []



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


[issue27793] Double underscore variables in module are mangled when used in class

2016-08-18 Thread avraf

New submission from avraf:

import re

__no_spaces_pattern   = r'\S+'
__match_chars_until_space = re.compile(__no_spaces_pattern).match
__match_chars_from_last_space = re.compile(__no_spaces_pattern + '$').match

def __get_chars_until_space(name):
return __match_chars_until_space(name).group()

def __get_chars_from_last_space(name):
return __match_chars_from_last_space(name).group()

__random_unique_five_digit_number = 12345
__random_id_generator = lambda: __random_unique_five_digit_number


class Person(object):
def __init__(self, name):
self.name = name

@property
def first_name(self):
return __get_chars_until_space(self.name)

@property
def last_name(self):
return __get_chars_from_last_space(self.name)


I get this error when importing and running in another file.
It seems python mangles every occurrence of double underscores seen in a class. 
Even if the double underscores variable appears in the body of a method and 
belongs to the module.

This behavior is very unexpected.

Traceback (most recent call last):
  File "beef.py", line 5, in 
print bob.first_name
  File 
"/home/dude/style/static_private_methods/real_static_private_functions.py", 
line 22, in first_name
return __get_chars_until_space(self.name)
NameError: global name '_Person__get_chars_until_space' is not defined

--
messages: 273023
nosy: avraf
priority: normal
severity: normal
status: open
title: Double underscore variables in module are mangled when used in class
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue27778] PEP 524: Add os.getrandom()

2016-08-18 Thread Nick Coghlan

Nick Coghlan added the comment:

Given docs (with the Linux-only platform support disclaimer), +1 for this as an 
initial implementation.

Providing it on Solaris as well can be a separate patch, but it's less 
important there (since /dev/urandom and os.urandom() are already blocking APIs)

--
nosy: +ncoghlan

___
Python tracker 

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



[issue27573] code.interact() should print an exit message

2016-08-18 Thread Armin Rigo

Armin Rigo added the comment:

...ah, upon closer inspection, we don't use the ``interact()`` method anyway.  
We already copied and tweaked this method: one problem was that it gives no way 
to run without printing at least one '\n' of banner at the beginning.  Then a 
more important tweak was made when we added multiline input with `pyrepl` by 
default.  So feel free to ignore my request.

(Multiline input is great, btw, if you use the interactive Python a lot.  That 
would be a completely different patch---if I thought that there's a good chance 
of it not languishing forever on this bug tracker, which I honestly don't think 
is the case...)

--

___
Python tracker 

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



[issue27573] code.interact() should print an exit message

2016-08-18 Thread Armin Rigo

Armin Rigo added the comment:

I'm fine with `exitmsg`.  I guess it would be a flag (not `None` as you wrote), 
defaulting to `True`?

--

___
Python tracker 

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



[issue27792] bool % int has inconsistent return type.

2016-08-18 Thread Mark Dickinson

New submission from Mark Dickinson:

Seen on reddit [1]: 

>>> True % 1
0
>>> True % 2
True

I believe that we should be returning an int in both these cases; this looks 
like a longobject.c fast path gone wrong.

[1] 
https://www.reddit.com/r/learnpython/comments/4y5bh1/can_someone_explain_why_true_1_0_but_true_2_true/

--
messages: 273020
nosy: mark.dickinson
priority: normal
severity: normal
stage: needs patch
status: open
title: bool % int has inconsistent return type.
type: behavior
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



Error in while loop code for packing items

2016-08-18 Thread GP



I have a list dictionary of items:
ListDictItem = [ {'Item No': 1,'Weight':610,'Quantity':2},{'Item No': 
2,'Weight':610,'Quantity':2},{'Item No': 3,'Weight':500,'Quantity':2},{'Item 
No': 4,'Weight':484,'Quantity':2},{'Item No': 
5,'Weight':470,'Quantity':2},{'Item No': 6,'Weight':440,'Quantity':2},{'Item 
No': 7,'Weight':440,'Quantity':2},{'Item No': 8,'Weight':400,'Quantity':2}]

I would like to pack the items in shelves such that the total weight of each 
shelf is less than a particular value. 

I have created a list of weights from above like this:
ItemWeigths: [610.0, 610.0, 500.0, 484.0, 470.0, 440.0,440, 400.0]


and a code which creates the first shelf :

shelves=[]
ShelvesWeightTotal = sum(shelves)
shelf=[]
new=[]
ShelfToPack=[]


for i in range(0,len(ItemWeigths)):
while ShelvesWeightTotal <=WeightOfObject:
  shelf += [ItemWeigths[i]]
  ShelvesWeightTotal = sum(shelf)

for k in range(0,len(shelf)):
  q1=ListDictItem[k]
  q2 = ListDictItem.pop(k) #deletes the items that are packed.
  shelves.append(q1)
  new.append(q2)   

ShelfToPack.append(shelves)

This code works but when I try to create other shelves, I made a while 
statement over the items that are remaining ,(while ItemsRemaining !=0) and I 
get an error for the code. The details are below:

Code:

while ListDictItem != []:

   for i in range(0,len(ItemsToCutLength)):
   while ShelvesLengthTotal <=LengthOfObject:
  shelves += [ItemWeigths[i]]
  ShelvesLengthTotal = sum(shelves)

   for k in range(0,len(shelves)):
  q1=ItemsToCut[k]
  q2 = ListDictItemt.pop(k) #deletes the items that are packed.
  shelf.append(q1)
  new.append(q2)   
   ListDictItem==ListDictItem 
ShelfToPack.append(shelf)


Error message:Traceback (most recent call last):
  File "C:\Project\Python\ReadExcel-xlrd.py", line 201, in 
q1=ListDictItem[k]
IndexError: list index out of range.


I would like the ShelfToPack list look like :

[[{'Item No': 1,'Weight':610,'Quantity':2},{'Item No': 
2,'Weight':610,'Quantity':2},{'Item No': 3,'Weight':500,'Quantity':2},{'Item 
No': 4,'Weight':484,'Quantity':2}],[{..},...{..}],[{..},...{..}]]

Any suggestion in pointing the error or to improve the code will be appreciated.

Thanks in advance!! 

Cheers!
GP
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26984] int() can return not exact int instance

2016-08-18 Thread Mark Dickinson

Changes by Mark Dickinson :


--
assignee:  -> mark.dickinson

___
Python tracker 

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



Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Chris Angelico
On Thu, Aug 18, 2016 at 7:32 PM, Steven D'Aprano
 wrote:
> So I don't see any
> benefit over this:
>
>  for section_name, line_number in text.parser.toc:
>  drop.add_command(label=section_name, command=lambda
>   line=line_number: text.yview(line))
>
> except that it is easier to fit in 79 columns :-)

Which is a VERY important benefit when you realize what's just
happened to your code. Wrapping after "command=lambda" and before
"line=linenumber" majorly obscures what's going on here. Here's a
better way to wrap that:

 for section_name, line_number in text.parser.toc:
 drop.add_command(label=section_name,
command=lambda line=line_number: text.yview(line))

However, this isn't an indictment of lambda, just proof that anyone
can misalign stuff by mistake.

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


Re: type lookuperror

2016-08-18 Thread Chris Angelico
On Thu, Aug 18, 2016 at 7:55 PM, meInvent bbird  wrote:
> actually i would like to remove try except code in all function
>
> and i feel that try except code for a large block code can not
> show which function name , which line number error,
> if use try except for specified code block to show where it has error
> it will have many ugly try except code and need many human force
> to craft the code, i hope that code write once for program to program itself
> in future.
>
> actually this method i ask is not good enough since it will need
> to add many function wrapper.

You can't get a program to program itself. That's called the
Singularity [1], and depending on your point of view, it's either
still in the future, or fundamentally impossible. In any case,
computers today cannot program themselves.

So what exactly is it you're wanting? When an exception happens, the
entire traceback is recorded, and unless you're throwing that away,
it'll be shown to you. Just let the exception bubble all the way up to
top level, and then read the traceback. Some IDEs can even help you
step through the code to see context for each line of traceback;
ipython is also pretty helpful with reading tracebacks. I advise
getting to know the tools you have available, rather than trying to
reinvent the wheel.

ChrisA

[1] https://en.wikipedia.org/wiki/Technological_singularity
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >