Re: Behavior of auto in Enum and Flag.

2017-04-02 Thread Chris Angelico
On Mon, Apr 3, 2017 at 2:49 PM, Oren Ben-Kiki  wrote:
> "If the exact value is unimportant you may use auto instances and an
> appropriate value will be chosen for you."
>
> Choosing a value that conflicts with BAZ in above cases doesn't seem
> "appropriate" for a value that is "unimportant".
>
> The docs also state "Care must be taken if you mix auto with other values."
> - fair enough. But:
>
> First, why require "care" if the code can take care of the issue for us?
>
> Second, the docs don't go into further detail about what exactly to avoid.
> In particular, the docs do not state that the automatic value will only
> take into account the previous values, and will ignore following values.

Sounds to me like the current behaviour is compliant with what the
docs say, and as such, I would be disinclined to change the code.
Perhaps a documentation clarification would suffice?

"""Care must be taken if you mix auto with other values. In
particular, using auto() prior to explicitly-set values may result in
conflicts."""

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


[issue29863] Add a COMPACT constant to the json module

2017-04-02 Thread Berker Peksag

Berker Peksag added the comment:

+1. See msg287773 for my reasoning.

--
nosy: +berker.peksag

___
Python tracker 

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



RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote. on April 02, 2017 7:41 PM
> 
> "Deborah Swanson"  writes:
> 
> > Chris Angelico wrote, on April 02, 2017 6:37 PM
> > > 
> > > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson
> > > > Maybe I'm having another "dumb day" [.]
> >
> > Well, wouldncha know it, I never tried using a colon. That's what I 
> > get for just trying to guess.
> 
> Yes, guessing *is* dumb when the reference documentation is 
> available 
>  lays-for-lists-sets-and-dictionaries>.
> I was sure you'd have been reading the manual before 
> guessing, but I'll know better in future :-)
> 
> -- 
>  \   "A computer once beat me at chess, but it was no 
> match for me |
>   `\ at kick boxing." 
> -Emo Philips |
> _o__) 
>  |
> Ben Finney
> 

Oh, come on. That's a fairly obscure citation in the docs, one that
would take a good deal of experience and time reading through them to
know was there, experience and years with Python that I don't have. But
you knew that ... ;)

Deborah

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


Traversal help

2017-04-02 Thread R. Bryan Smith
Hello,

I am working with Python 3.6.  I’ve been trying to figure out a solution to my 
question for about 40 hrs with no success and hundreds of failed attempts.  
Essentially, I have bitten off way more than I can chew with processing this 
file.  Most of what follows, is my attempt to inform as best I can figure.

I have a JSONL (new line) file that I downloaded using requests and the 
following code: 
with open(fname, 'wb') as fd:
for chunk in r.iter_content(chunk_size=1024):
fd.write(chunk)

The file was in gzip format (the encoding on the API says - UTF-8) to a windows 
8 (it’s current, but 8) machine.
These files are rather large, maybe around 4GB.
I used the ‘shebang' for ‘UTF-8’ at the top of my Python program: # -*- 
encoding: utf-8 -*-

After I save the file, I read it using this:
def read_json(path):
'''Turns a normal json LINES (cr) file into an array of objects'''
temp_array = []
f = codecs.open(path, 'r', 'utf-8', ‘backslashreplace')
for line in f:
record = json.loads(line.strip('\n|\r'))
temp_array.append(record)
return temp_array

I am working on a Linux server to partitioning the List returned above, there 
are three linked levels of detail (A, B, C) that can exist in any collection 
within the JSON and each Collection can contain wildly varying and/or repeating 
fields.  The data contained within is scraped from websites all over the world. 
 I wanted to ‘traverse' the file structure and found an algorithm that I think 
will work:

def traverser(obj, path=None, callback=None):
if path is None:
path = []

if isinstance(obj, dict):
value = {k: traverser(v, path+[k], callback)
 for k, v in obj.items()}
elif isinstance(obj, list):
value = [traverser(elem, path+[[]], callback)
 for elem in obj]
else:
value = obj

if callback is None:
return value
else:
return callback(path, value)

The only problem and the subsequent question that follows is:  I have yet to 
successfully decode / How do I then ‘collect’ each of these objects while I am 
traversing the JSON New Line Collection into some sort of container (handling 
encoding errors) so that I can then write to a csv file (w/ ‘utf-8’ and won’t 
error out when I try to import it into a IBM ‘utf-8’ encoded DB)?  Actually, 
after that, I would like to learn how to grab a specific element, if present in 
each Collection, whenever I need it, as well - but, that can wait.

I’ve tried using the JSON module on the JSONL file, but the structure is really 
complicated and changing with lot’s of different control and spacing 
characters, in addition to some odd (potentially non-unicode characters).  
Here’s the schema: http://json-schema.org/fraft-04/schema# 
 

I’m not a programmer, but I am learning through assimilation.  Any help is 
greatly appreciated.  Even if it’s pointing me to documentation that can help 
me learn what to consider and lead me to what to do.  

Thank you,
R. Smith

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


Behavior of auto in Enum and Flag.

2017-04-02 Thread Oren Ben-Kiki
The current behavior of `auto` is to pick a value which is one plus the
previous value.

It would probably be better if `auto` instead picked a value that is not
used by any named member (either the minimal unused value, or the minimal
higher than the previous value). That is, in this simple case:

class MyEnum(Enum):
FOO = 1
BAR = auto()
BAZ = 2

It would be far better for BAR to get the value 3 rather than today's value
2.

In the less simple case of:

class MyEnum(Enum):
FOO = 2
BAR = auto()
BAZ = 3

Then BAR could be either 1 or 4 - IMO, 1 would be better, but 4 works as
well.

After all, `auto` is supposed to be used when:

"If the exact value is unimportant you may use auto instances and an
appropriate value will be chosen for you."

Choosing a value that conflicts with BAZ in above cases doesn't seem
"appropriate" for a value that is "unimportant".

The docs also state "Care must be taken if you mix auto with other values."
- fair enough. But:

First, why require "care" if the code can take care of the issue for us?

Second, the docs don't go into further detail about what exactly to avoid.
In particular, the docs do not state that the automatic value will only
take into account the previous values, and will ignore following values.

However, this restriction is baked into the current implementation:
It is not possible to just override `_generate_next_value_` to skip past
named values which were not seen yet, because the implementation only
passes it the list of previous values.

I propose that:

1. The documentation will be more explicit about the way `auto` behaves in
the presence of following values.

2. The default behavior of `auto` would avoid generating a conflict with
following values.

3. Whether `auto` chooses (A) the minimal unused value higher than the
previous value, or (B) the minimal overall unused value, or (C) some other
strategy, would depend on the specific implementation.

3. To allow for this, the implementation will include a
`_generate_auto_value_` which will take both the list of previous ("last")
values (including auto values) and also a second list of the following
("next") values (excluding auto values).

4. If the class implements `_generate_next_value_`, then
`_generate_auto_value_` will invoke `_generate_next_value_` with the
concatenation of both lists (following values first, preceding values
second), to maximize compatibility with existing code.

Thanks,

Oren Ben-Kiki
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29926] time.sleep ignores _thread.interrupt_main()

2017-04-02 Thread Martin Panter

Martin Panter added the comment:

BTW pthread_kill was only added to Python 3.3, so is not available for Python 
2. I’m not sure what the best fix for 2.7 would be. Maybe it’s not worth it, or 
maybe you can find another way to a signal to the user process or its main 
thread without interfering with any background threads that Idle needs. But I 
don’t know enough about how Idle works to offer a solution.

--

___
Python tracker 

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



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

Michael Selik added the comment:

This would also enable negative indexing, which currently raises "IndexError: 
no such group".

Edit: I meant whole numbers, not natural numbers.

--
versions: +Python 3.7

___
Python tracker 

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



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

Changes by Michael Selik :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
type:  -> enhancement

___
Python tracker 

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



[issue29965] MatchObject __getitem__() should support slicing and len

2017-04-02 Thread Michael Selik

New submission from Michael Selik:

Currently, slicing a MatchObject causes an IndexError and len() a TypeError. 
It's natural to expect slicing and len to work on objects of a finite length 
that index by natural numbers.

--
messages: 291050
nosy: selik
priority: normal
severity: normal
status: open
title: MatchObject __getitem__() should support slicing and len

___
Python tracker 

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



[issue29926] time.sleep ignores _thread.interrupt_main()

2017-04-02 Thread Martin Panter

Martin Panter added the comment:

Hi Terry, this patch is what I imagined a fix would look like for Linux. I am 
not familiar with Idle (internally nor externally), so there may be 
improvements you can make.

It works as I expected for normal blocking functions and a tight “for” loop: it 
interrupts any blocking call, and triggers the usual SIGINT handler. If SIGINT 
has a Python handler (e.g. by default), that gets called which usually raises 
KeyboardInterrupt.

My change has a major flaw: it seems to deadlock something if you interrupt 
“input()” or “sys.stdin.readline()”. Perhaps you might have a better clue what 
the problem is. With the default SIGINT handler, this is what I see in the Idle 
window:

>>> input()  # Press Ctrl+C
Traceback (most recent call last):  <-- cursor flashing at end of line

If SIGINT is ignored, or the Python handler doesn’t raise an exception, Ctrl+C 
seems to have the effect of inputting a newline:

>>> input()  # Press Ctrl+C
''
>>> sys.stdin.readline()  # Press Ctrl+C
'\n'

--
keywords: +patch
nosy: +martin.panter
Added file: http://bugs.python.org/file46771/int-unix.patch

___
Python tracker 

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



Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson"  writes:

> Chris Angelico wrote, on April 02, 2017 6:37 PM
> > 
> > On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson 
> > > Maybe I'm having another "dumb day" […]
>
> Well, wouldncha know it, I never tried using a colon. That's what I
> get for just trying to guess.

Yes, guessing *is* dumb when the reference documentation is available
.
I was sure you'd have been reading the manual before guessing, but I'll
know better in future :-)

-- 
 \   “A computer once beat me at chess, but it was no match for me |
  `\ at kick boxing.” —Emo Philips |
_o__)  |
Ben Finney

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


RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Ben Finney wrote, on April 02, 2017 6:38 PM
> 
> "Deborah Swanson"  writes:
> 
> > It seems like this should be easy to rewrite as a dict 
> comprehension:
> >
> > records_idx = {}
> > for idx, label in enumerate(records[0]):
> > records_idx[label] = idx
> 
> How about this::
> 
> records_idx = {
> label: idx
> for (idx, label) in enumerate(collection_of_labels)
> }
> 
> You may have tripped on the ambiguity of the comma in its 
> surrounding context. I always prefer to put parens around the 
> items I intend to be comma-separated, to remove that ambiguity.
> 
> -- 
>  \"[It's] best to confuse only one issue at a time." 
> -Brian W. |
>   `\  Kernighan, Dennis M. Ritchie, _The C programming 
> language_, 1988 |
> _o__) 
>  |
> Ben Finney

That's a neat way to think about the problem. Me, I was guessing all the
way, and pleasantly surprised when the 3-statement concoction I came up
with worked.

Thanks Ben!

Deborah

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


RE: Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
Chris Angelico wrote, on April 02, 2017 6:37 PM
> 
> On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson 
>  wrote:
> > It seems like this should be easy to rewrite as a dict 
> comprehension:
> >
> > records_idx = {}
> > for idx, label in enumerate(records[0]):
> > records_idx[label] = idx
> >
> > Maybe I'm having another "dumb day", or maybe I've just been 
> > struggling with this (larger) problem for too long, but eveything I 
> > try to get an equivalent dict comprehension for the 3 lines above is

> > not working.
> 
> Should be this:
> 
> records_idx = {label: idx for idx, label in enumerate(records[0])}
> 
> That's a direct translation of your code.
> 
> ChrisA

Well, wouldncha know it, I never tried using a colon. That's what I get
for just trying to guess.

Thanks Chris

Deborah

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


[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-02 Thread Dominic Mayers

Dominic Mayers added the comment:

I started to look at the documentation to see what would need to be changed, 
assuming that we agree for a change in the API. Just for the purpose of this 
discussion, I created a patch that only change the comments in socketserver.py.

--

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-02 Thread Dominic Mayers

Changes by Dominic Mayers :


--
keywords: +patch
Added file: http://bugs.python.org/file46770/Issue29947_for_discussion.patch

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-02 Thread Dominic Mayers

Changes by Dominic Mayers :


Removed file: http://bugs.python.org/file46768/factorymixinclass

___
Python tracker 

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



[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Kinebuchi Tomohiko

Kinebuchi Tomohiko added the comment:

I created backporting pull requests for 2.7, 3.5 and 3.6.

--

___
Python tracker 

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



Re: Two variable dictionary comprehension

2017-04-02 Thread Ben Finney
"Deborah Swanson"  writes:

> It seems like this should be easy to rewrite as a dict comprehension:
>
> records_idx = {}
> for idx, label in enumerate(records[0]):
> records_idx[label] = idx

How about this::

records_idx = {
label: idx
for (idx, label) in enumerate(collection_of_labels)
}

You may have tripped on the ambiguity of the comma in its surrounding
context. I always prefer to put parens around the items I intend to be
comma-separated, to remove that ambiguity.

-- 
 \“[It's] best to confuse only one issue at a time.” —Brian W. |
  `\  Kernighan, Dennis M. Ritchie, _The C programming language_, 1988 |
_o__)  |
Ben Finney

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


Re: Two variable dictionary comprehension

2017-04-02 Thread Chris Angelico
On Mon, Apr 3, 2017 at 11:26 AM, Deborah Swanson
 wrote:
> It seems like this should be easy to rewrite as a dict comprehension:
>
> records_idx = {}
> for idx, label in enumerate(records[0]):
> records_idx[label] = idx
>
> Maybe I'm having another "dumb day", or maybe I've just been struggling
> with this (larger) problem for too long, but eveything I try to get an
> equivalent dict comprehension for the 3 lines above is not working.

Should be this:

records_idx = {label: idx for idx, label in enumerate(records[0])}

That's a direct translation of your code.

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


Two variable dictionary comprehension

2017-04-02 Thread Deborah Swanson
It seems like this should be easy to rewrite as a dict comprehension:

records_idx = {}
for idx, label in enumerate(records[0]):
records_idx[label] = idx

Maybe I'm having another "dumb day", or maybe I've just been struggling
with this (larger) problem for too long, but eveything I try to get an
equivalent dict comprehension for the 3 lines above is not working.

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


Re: All people deserve respect. Ideas are not people.

2017-04-02 Thread Michael Torrie
On 04/02/2017 06:00 PM, Alex Kaye wrote:
> Michael,  Thanks for your comment.
> 
> However, If one derails from the core subject
> 
> they need to be in another stream.  Alex

I think you'll find that the subject line was changed by Ben Finney to
reflect the new direction he was taking it, which is the usual and
expected list etiquette.  The change of subject line puts it in "another
stream" as you say.  Steve D'Aprano should have probably changed it a
long time ago. And of course RR should have been plonked by Steven and
others a long time ago also.  But I digress.

Again I am very glad Ben posted what he did and glad to show my support
for what he said, though it will likely fall on deaf ears.

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


[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Kinebuchi Tomohiko

Changes by Kinebuchi Tomohiko :


--
pull_requests: +1145

___
Python tracker 

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



[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Martin Panter

Martin Panter added the comment:

We could change this to a documentation issue if you have any suggestions to 
make the documentation clearer.

I understand the “time” module is mainly a wrapper or emulator of the OS’s own 
strptime, mktime, etc functions, which explains some of these quirks.

--

___
Python tracker 

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



Re: All people deserve respect. Ideas are not people.

2017-04-02 Thread Michael Torrie
On 04/02/2017 05:10 PM, Ben Finney wrote:
> 
> Ideas are not people, and are not innate to the person who holds them.
> An idea is not deserving of respect; that respect must not be assumed,
> it must be earned.
> 
> More importantly, ideas inform behaviour. That is what makes robust
> criticism of bad ideas so important.
> 
> Once an idea is expressed or demonstrated through behaviour, that idea
> or behaviour is not innately deserving of respect, and it becomes fair
> game for open criticism.
> 
> What we need to always keep in mind is that the *idea* should be
> criticised, without attacking the *person*.

Very well said.  Thank you.

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


[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Kinebuchi Tomohiko

Changes by Kinebuchi Tomohiko :


--
pull_requests: +1144

___
Python tracker 

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



[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Kinebuchi Tomohiko

Changes by Kinebuchi Tomohiko :


--
pull_requests: +1143

___
Python tracker 

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



All people deserve respect. Ideas are not people. (was: Text-mode apps)

2017-04-02 Thread Ben Finney
Terry Reedy  writes:

> On 4/2/2017 12:26 PM, Steve D'Aprano wrote:
> > Not all Americans, perhaps not even a majority or a plurality, are Ugly
> > Americans, but there are enough of them to screw it up for everyone else.
>
> Shall we discuss Ugly Australians, or whatever the appropriate epithet
> would be?

Provided that, just as Steven has done, the discussion criticises ideas,
attitudes, and behaviours: that would not be bigotry nor prejudice at
all.

It's a difficult distinction, but an essential one: we *must* be free
always to hold ideas and behaviours to harsh criticism when warranted,
no matter who holds or does them, while respecting the dignity and
rights and individuality of all persons.

> > It's an ugly stereotype, not because it is a stereotype, but because
> > it embodies a set of ugly attitudes and behaviours.
>
> I am sure I have seen similar things written by various other people
> justifying their prejudices.

Prejudice on the basis of a person's innate traits has no place in civil
society.

Ideas are not people, and are not innate to the person who holds them.
An idea is not deserving of respect; that respect must not be assumed,
it must be earned.

More importantly, ideas inform behaviour. That is what makes robust
criticism of bad ideas so important.

Once an idea is expressed or demonstrated through behaviour, that idea
or behaviour is not innately deserving of respect, and it becomes fair
game for open criticism.

What we need to always keep in mind is that the *idea* should be
criticised, without attacking the *person*.

-- 
 \   “Value your freedom or you will lose it, teaches history. |
  `\ “Don't bother us with politics,” respond those who don't want |
_o__)to learn.” —Richard M. Stallman, 2002 |
Ben Finney

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


[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Paul Pinterits

Paul Pinterits added the comment:

No no, the docs are correct. This was definitely my mistake. I'm just trying to 
say that it's rather confusing how there's only partial support for time zones. 
When I saw that there is support for parsing the time zone offset, I assumed 
that the functions provided in the time module would be enough to solve my 
problem - having to rely on the datetime module to have proper time zone 
support caught me by surprise. It's quite counterintuitive.

--

___
Python tracker 

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



Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Terry Reedy

On 4/2/2017 1:59 PM, Ganesh Pal wrote:

> 'someone' wrote

Whenever you feel the urge to write range(len(whatever)) -- resist that
temptation, and you'll end up with better Python code ;)



Thanks for this suggestion but for my better understanding can explain
this further even Steve did point the same mistake.


Before 2.2, one could only iterate through a sequence of integers, or 
something that pretended to be such.  So the way to iterate though a 
finite sequence of non-ints was


for i in range(len(seq)):
item = seq[i]


The current iterator protocol allows one to separate item access or 
generation from item processing and to hide the former in an iterator. 
One then says in the header what collection of items one want to process 
and in what order (one at a time) and in the body what one wants to do 
with them.


for item in seq:  # items of seq in normal order


for item in iterable:  # not restricted to sequences, default order


Some other variations in the new form.

for item in reversed(iterable):  # finite collection in reversed order


for i, item in enumerate(seq):


for item1, item2 in zip(seq1, seq2):
 

--
Terry Jan Reedy

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


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Terry Reedy

On 4/2/2017 12:26 PM, Steve D'Aprano wrote:

On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote:


On 4/1/2017 12:00 PM, Steve D'Aprano wrote:


example of the Ugly American.


As an American I resent your promotion and perpetuation of an ugly
ethno-centric stereotype.


I'm glad you didn't try to describe it as a *unfair* or *unjustified*


I refrained because it would be off-topic and a diversion from my point: 
all bigotry is inappropriate here on this list, including anti-Americanism.


(I actually think raw bigoty is inappropriate everywhere.  While there 
are places to discuss the relative average beauty and niceness of 
various groups of people, this is not one of them.  Even comparisons of 
computer languages is not the main focus of this list.)



stereotype, because (let's face it) after November 8th 2016, that simply
wouldn't fly.


The 'Ugly American' meme is at least 60 years old.  National bigotry is 
as old as nations.


Yesterday, Chris Angelico, I believe it was, asked someone to stop 
including anti-Jew messages in posts here.  So I asked the same of you 
regarding your anti-American expression.



Not all Americans, perhaps not even a majority or a plurality, are Ugly
Americans, but there are enough of them to screw it up for everyone else.


Shall we discuss Ugly Australians, or whatever the appropriate epithet 
would be?



It's an ugly stereotype, not because it is a stereotype, but because it

> embodies a set of ugly attitudes and behaviours.

I am sure I have seen similar things written by various other people 
justifying their prejudices.



--
Terry Jan Reedy

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


[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Martin Panter

Martin Panter added the comment:

As far as I can see, the documentation only claims that “mktime” converts local 
time. If you saw a suggestion that it supports arbitrary time zones, please 
point it out.

--

___
Python tracker 

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



Re: Temporary variables in list comprehensions

2017-04-02 Thread breamoreboy
On Sunday, April 2, 2017 at 1:08:17 AM UTC+1, Robert L. wrote:

> I don't believe in western morality, i.e. don't kill civilians or children
> The only way to fight a moral war is the Jewish way: Destroy their holy sites.
> Kill men, women, and children (and cattle). --- Rabbi Manis Friedman
> web.archive.org/web/20090605154706/http://www.momentmag.com/Exclusive/2009/2009-06/200906-Ask_Rabbis.html
> archive.org/download/DavidDukeVideo/TheZionistMatrixOfPowerddhd.ogv

Completely agree with Steven D'Aprano so would the moderators please ban Robert 
L with immediate effect.

Kindest regards.

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


[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Paul Pinterits

Paul Pinterits added the comment:

I see. You're right, it does make a difference.

However, this behaviour is quite unexpected. Perhaps I just didn't read the 
docs carefully enough, but it wasn't clear to me that the time module had such 
half-baked support for time zones.

An unsuspecting user, like me, reads the documentation on strptime, which 
directs you to strftime. There you read that %z is a supported directive. Along 
the way you've come across the conversion table, which tells you that mktime() 
can convert struct_time objects to timestamps. But then when you try to parse a 
time string, the information gets lost somewhere along the way:

>>> mktime(strptime("+", "%z")) == mktime(strptime("+0200", "%z"))
True

If you visit the section about struct_time objects, you find this footnote:
"Changed in version 3.3: tm_gmtoff and tm_zone attributes are available on 
platforms with C library supporting the corresponding fields in struct tm."

But even after reading that, I'd still expect the tm_gmtoff attribute to have 
some sort of effect and not get silently discarded.

--

___
Python tracker 

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



[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Martin Panter

Martin Panter added the comment:

Are you sure? It works for me:

>>> strptime("+0200", "%z").tm_gmtoff
7200
>>> strptime("+", "%z").tm_gmtoff
0

The "struct_time" class is documented as a named tuple, but the time zone 
offset is not one of the tuple elements, so isn’t going to be checked for 
equality.

--
nosy: +martin.panter
resolution:  -> works for me
stage:  -> test needed

___
Python tracker 

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



Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Gene Heskett
On Sunday 02 April 2017 12:26:40 Steve D'Aprano wrote:

> On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote:
> > On 4/1/2017 12:00 PM, Steve D'Aprano wrote:
> >> example of the Ugly American.
> >
> > As an American I resent your promotion and perpetuation of an ugly
> > ethno-centric stereotype.
>
> I'm glad you didn't try to describe it as a *unfair* or *unjustified*
> stereotype, because (let's face it) after November 8th 2016, that
> simply wouldn't fly.

While I too detest that label, I will have to admit that I am one of the 
conservatives, believing our Constitution and Bill of Rights have been 
used as TP by the "establishment" over the last 65+ years, who enabled 
that surprise.

Wash., DC has been turned into a polluted swamp that needed drained and 
cleaned up, and the Donald was the only one that wasn't part of the same 
old, same old, bull crap establishment, and with enough money to run.

However, I'll be the first to admit I am less than impressed with his 
efforts vis-a-vis global warming. He, I suspect, will be a 1 term 
president unless he starts listening to the technical people's warnings.

I'd also make the prediction that the 2020 winner will _not_ be from the 
establishment. Maybe not even from the two party system. I am hoping 
that this will cause all (surviving) parties to do some navel gazing, 
and contemplating not how to enrich the constituent businesses they own 
under the table, but maybe, actually work for the common good. Taking 
money completely out of the equation would be one way, but you could 
hear the gored oxen that would wound fatally clear out to Pluto, without 
a radio.

Human avarice being what it is, whether I'll live long enough to see that 
happen isn't up to me. At 82, it doesn't look like near as big a chance 
as it did when I was 60.
>
> Not all Americans, perhaps not even a majority or a plurality, are
> Ugly Americans, but there are enough of them to screw it up for
> everyone else.
>
Generally, I try to stay out of the Ugly camp. Then I look in the mirror 
and know its hopeless. :(

[...]

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


Re: Temporary variables in list comprehensions

2017-04-02 Thread Robert L.
On 1/8/2017, Steven D'Aprano wrote:

> Suppose you have an expensive calculation that gets used two or
> more times in a loop. The obvious way to avoid calculating it
> twice in an ordinary loop is with a temporary variable:
> 
> result = []
> for x in data:
> tmp = expensive_calculation(x)
> result.append((tmp, tmp+1))
> 
> 
> But what if you are using a list comprehension? Alas, list comps
> don't let you have temporary variables, so you have to write
> this:
> 
> [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]
> 
> Or do you? ... no, you don't!
> 
> [(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]

[2,3,5].map{|n| tmp = Math.sqrt n; [tmp, tmp+1]}

 ===> 
[[1.4142135623730951, 2.414213562373095],
 [1.7320508075688772, 2.732050807568877],
 [2.23606797749979, 3.23606797749979]]


-- 
I don't believe in western morality, i.e. don't kill civilians or children
The only way to fight a moral war is the Jewish way: Destroy their holy sites.
Kill men, women, and children (and cattle). --- Rabbi Manis Friedman
web.archive.org/web/20090605154706/http://www.momentmag.com/Exclusive/2009/2009-06/200906-Ask_Rabbis.html
archive.org/download/DavidDukeVideo/TheZionistMatrixOfPowerddhd.ogv
-- 
https://mail.python.org/mailman/listinfo/python-list


Tcp Socket Receive

2017-04-02 Thread specx
Hello,
�
I have a tcp server coded with python and my packets include a 2 bytes header 
which is just the length of the following data. The problem is how can I be 
sure I received 2 bytes and not just one byte. In Qt, I use bytesAvailable 
function. However, here I just use sock.recv(2) but it can fetch less than 2 
since the parameter is the maximum length. Do we have any method?
�
Greetz

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


[issue29964] %z directive has no effect on the output of time.strptime

2017-04-02 Thread Paul Pinterits

New submission from Paul Pinterits:

%z is listed as a supported directive in the python 3 documentation 
(https://docs.python.org/3.5/library/time.html#time.strftime), but it doesn't 
actually do anything:

>>> from time import strptime
>>> strptime('+', '%z') == strptime('+0200', '%z')
True

As far as I can tell, there aren't any footnotes saying that %z might not be 
supported on some platforms, like it was back in python 2.

In case it matters, I'm using python 3.5.3 on linux.

--
components: Library (Lib)
messages: 291041
nosy: Paul Pinterits
priority: normal
severity: normal
status: open
title: %z directive has no effect on the output of time.strptime
type: behavior
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



Cheetah 3.0.0a1

2017-04-02 Thread Oleg Broytman
Hello! I'm happy to announce I revived development of Cheetah.
Unfortunately I have to fork the project.

I'm pleased to announce version 3.0.0a1, the first alpha of the upcoming
release of branch 3.0 of CheetahTemplate3.


What's new in CheetahTemplate3
==

Contributors for this release are Adam Karpierz and Jonathan Ross Rogers.

- !!!THIS RELEASE REQUIRES RECOMPILATION OF ALL COMPILED CHEETAH TEMPLATES!!!
- Stop supporting Python older than 2.7.
- Update code to work with Python 3.3+. Tested with 3.3, 3.4, 3.5 and 3.6.
- Run tests at Travis (Linux) and AppVeyor (w32) with Python 2.7, 3.3, 3.4,
  3.5 and 3.6; x86 and x64.
- Fix a bug in multiple inheritance (#extend Parent1, Parent2).
  Pull request by Jonathan Ross Rogers.


What is CheetahTemplate3


Cheetah3 is a free and open source template engine.
It's a fork of the original CheetahTemplate library.

Python 2.7 or 3.3+ is required.


Where is CheetahTemplate3
=

Site:
http://cheetahtemplate.org/

Development:
https://github.com/CheetahTemplate3

Download:
https://pypi.python.org/pypi/Cheetah3/3.0.0a1

News and changes:
http://cheetahtemplate.org/news.html

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


[issue23033] Disallow support for a*.example.net, *a.example.net, and a*b.example.net in certificate wildcard handling.

2017-04-02 Thread Christian Heimes

Christian Heimes added the comment:

Ned, Benjamin,

are you ok with a backport to 2.7 and 3.6? Substring (aka partial) matching of 
wildcards is a MAY feature according to RFC 6125 
https://tools.ietf.org/html/rfc6125#section-6.4.3 . They are a violation of 
CA/B Form's baseline requirements, so no publicaly trusted cert may contain a 
CN or SAN entry with a partial wildcard. Several libraries and languages do not 
implement the feature either. Improper wildcard matching caused a bunch of 
security issues and CVEs in Python.

--
nosy: +benjamin.peterson, ned.deily

___
Python tracker 

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



Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
>
>
> Whenever you feel the urge to write range(len(whatever)) -- resist that
> temptation, and you'll end up with better Python code ;)
>
>
Thanks for this suggestion but for my better understanding can  explain
this further even Steve did point the same mistake.


>
> Instead of artificially blowing up your database change its structure. For
> example:
>
>
Good point Actually , I might be heading towards this, let me ask this in a
fresh email thread
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
On Sun, Apr 2, 2017 at 10:35 PM, Steve D'Aprano 
wrote:

>
> Why is payment a string?
>
> Yes it should be int


>
> > The value salary3 ,salary4,salary4 is to be generated in the loop . Iam
> > trying to optimize the above code , by looping as shown below
>
> In the above example, you have strings "salary3", "salary4", "salary5", but
> in the code below, you use 0, 1, 2 instead.
>
> Which do you intend to use?
>
>  It must be Salary1,Salary2



> payment_list = [100, 200, 400, 500]
>
> employees = {}
> employees['emp_01'] = {}
> for salary, payment in enumerate(payment_list, 3):
> # I don't know why salary starts at 3 instead of 1 or 0.
> salary = 'salary' + str(salary)
> employees['emp_01'][salary] = dict(
> sex="f", status="single", exp="4", grade="A", payment=payment
> )
>
> from pprint import pprint
> pprint(employees)
>
>
> {'emp_01': {'salary3': {'exp': '4',
> 'grade': 'A',
> 'payment': 100,
> 'sex': 'f',
> 'status': 'single'},
> 'salary4': {'exp': '4',
> 'grade': 'A',
> 'payment': 200,
> 'sex': 'f',
> 'status': 'single'},
> 'salary5': {'exp': '4',
> 'grade': 'A',
> 'payment': 400,
> 'sex': 'f',
> 'status': 'single'},
> 'salary6': {'exp': '4',
> 'grade': 'A',
> 'payment': 500,
> 'sex': 'f',
> 'status': 'single'}}}
>
>
>
>
Thanks ;
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27863] multiple issues in _elementtree module

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 9c2c42c221d7996070c0c0a2a114ab42fe3ddb9d by Serhiy Storchaka in 
branch '2.7':
bpo-27863: Fixed multiple crashes in ElementTree. (#765) (#903) (#963)
https://github.com/python/cpython/commit/9c2c42c221d7996070c0c0a2a114ab42fe3ddb9d


--

___
Python tracker 

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



Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Steve D'Aprano
On Mon, 3 Apr 2017 02:13 am, Ganesh Pal wrote:

> Dear Python friend
> 
> 
> I have a nested  data dictonary in the below format and I need to store
> 1000 of  entries which are in teh below format
> 
> 
 X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="200")
 X['emp_01']['salary4'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="400")
 X['emp_01']['salary5'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="400")

Why is payment a string?


> I only thing thats is changing is payment and I have payment_list as a
> list
> [100,200,400,500]:

And here payment is an int.


> The value salary3 ,salary4,salary4 is to be generated in the loop . Iam
> trying to optimize the above code , by looping as shown below

In the above example, you have strings "salary3", "salary4", "salary5", but
in the code below, you use 0, 1, 2 instead.

Which do you intend to use?


 X = {}
 X['emp_01'] ={}
 for salary in range(len(payment_list)):
> ... X['emp_01'][salary] =  dict(sex="f", status="single", exp="4",
> grade="A",payment=payment_list[salary])


You should almost never need to write `range(len(payment_list))`.


payment_list = [100, 200, 400, 500]

employees = {}
employees['emp_01'] = {}
for salary, payment in enumerate(payment_list, 3):
# I don't know why salary starts at 3 instead of 1 or 0.
salary = 'salary' + str(salary)
employees['emp_01'][salary] = dict(
sex="f", status="single", exp="4", grade="A", payment=payment
)

from pprint import pprint
pprint(employees)


{'emp_01': {'salary3': {'exp': '4',
'grade': 'A',
'payment': 100,
'sex': 'f',
'status': 'single'},
'salary4': {'exp': '4',
'grade': 'A',
'payment': 200,
'sex': 'f',
'status': 'single'},
'salary5': {'exp': '4',
'grade': 'A',
'payment': 400,
'sex': 'f',
'status': 'single'},
'salary6': {'exp': '4',
'grade': 'A',
'payment': 500,
'sex': 'f',
'status': 'single'}}}




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Basic Nested Dictionary in a Loop

2017-04-02 Thread Peter Otten
Ganesh Pal wrote:

> Dear Python friend
> 
> 
> I have a nested  data dictonary in the below format and I need to store
> 1000 of  entries which are in teh below format
> 
> 
 X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="200")
 X['emp_01']['salary4'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="400")
 X['emp_01']['salary5'] = dict(sex="f", status="single", exp="4",
> grade="A",payment="400")
> 
> 
> I only thing thats is changing is payment and I have payment_list as a
> list
> [100,200,400,500]:
> 
> 
> The value salary3 ,salary4,salary4 is to be generated in the loop . Iam
> trying to optimize the above code , by looping as shown below
> 
> 
 X = {}
 X['emp_01'] ={}
 for salary in range(len(payment_list)):

Whenever you feel the urge to write range(len(whatever)) -- resist that 
temptation, and you'll end up with better Python code ;)

> ... X['emp_01'][salary] =  dict(sex="f", status="single", exp="4",
> grade="A",payment=payment_list[salary])
> ...
 X
> {'emp_01': {0: {'grade': 'A', 'status': 'single', 'payment': 100, 'exp':
> '4', 'sex': 'f'}, 1: {'grade': 'A', 'status': 'single', 'payment': 200,
> 'exp': '4', 'sex': 'f'}, 2: {'grade': 'A', 'status': 'single', 'payment':
> 400, 'exp': '4', 'sex': 'f'}, 3: {'grade': 'A', 'status': 'single',
> 'payment': 500, 'exp': '4', 'sex': 'f'}}}

> 
> 
> Any other suggestion ,   Please let me know  I am on python 2.7 and Linux

Instead of artificially blowing up your database change its structure. For 
example:

X["emp_01"] = dict(
sex="f", 
status="single", 
exp="4", 
grade="A",
payments=[100, 200, 400, 500]
)

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


In Python and Windows environment how to supress certain key press and send some other key event for it

2017-04-02 Thread Krishnan Shankar
Hi All,

I was trying to build a VIM like shortcuts in windows. For example,

IF i press CAPSLOCK & h: It should "{Left}" move one to left. If CAPSLOCK &
b: It should "{Ctrl Down}{Left}{Ctrl Up}" move one word left etc.

I was successful in sending the key event. I used libraries like,

1. pynput
2. keyboard

for the same.

But i was unable to supress the Initial key event (ex: Caplock & h)

I tried using the keyboard to listen for key press events and supress them
as below.

>
import keyboard

def move_one_left():
"""
Wrapper for CAPS LOCK + b. The function sends LEFT ARROW Event
:return:
"""
keyboard.send(75)

def move_one_word_left():
"""
Wrapper for CAPS LOCK + b. The function sends LEFT ARROW Event
:return:
"""
keyboard.send('ctrl+left')

def main():
"""
This is the main loop which reads the key pressed.
According to the hotkey registered the function hooked is called.
The corresponding function will be the wrapped combination send back.
For example: CAPS + b is wrapped to Moving to left.
The main loop exits when Ctrl + c is done. So that is not registered.
:return:
"""
try:
# Start of the main loop
# Registering the hotkeys
# CAPS LOCK + H
keyboard.add_hotkey('caps lock+h', move_one_left, suppress=True)
# CAPS LOCK + B
keyboard.add_hotkey('caps lock+b', move_one_word_left,
suppress=True)

while True:
# Read the key pressed
print (keyboard.read_key())
except KeyboardInterrupt:
print("User has exited the program")

if __name__ == "__main__":
main()

<


This is working for sending the event for key press but the initial
keypress is also being send. The supress=True is not working.

Am I doing something wrong or is there any better way to supress the
initial key event and send another key event in place of that.


Regards,
Krishnan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Steve D'Aprano
On Sun, 2 Apr 2017 04:41 pm, Terry Reedy wrote:

> On 4/1/2017 12:00 PM, Steve D'Aprano wrote:
> 
>> example of the Ugly American.
> 
> As an American I resent your promotion and perpetuation of an ugly
> ethno-centric stereotype.

I'm glad you didn't try to describe it as a *unfair* or *unjustified*
stereotype, because (let's face it) after November 8th 2016, that simply
wouldn't fly.

Not all Americans, perhaps not even a majority or a plurality, are Ugly
Americans, but there are enough of them to screw it up for everyone else.

It's an ugly stereotype, not because it is a stereotype, but because it
embodies a set of ugly attitudes and behaviours.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Basic Nested Dictionary in a Loop

2017-04-02 Thread Ganesh Pal
Dear Python friend


I have a nested  data dictonary in the below format and I need to store
1000 of  entries which are in teh below format


>>> X['emp_01']['salary3'] = dict(sex="f", status="single", exp="4",
grade="A",payment="200")
>>> X['emp_01']['salary4'] = dict(sex="f", status="single", exp="4",
grade="A",payment="400")
>>> X['emp_01']['salary5'] = dict(sex="f", status="single", exp="4",
grade="A",payment="400")


I only thing thats is changing is payment and I have payment_list as a list
[100,200,400,500]:


The value salary3 ,salary4,salary4 is to be generated in the loop . Iam
trying to optimize the above code , by looping as shown below


>>> X = {}
>>> X['emp_01'] ={}
>>> for salary in range(len(payment_list)):
... X['emp_01'][salary] =  dict(sex="f", status="single", exp="4",
grade="A",payment=payment_list[salary])
...
>>> X
{'emp_01': {0: {'grade': 'A', 'status': 'single', 'payment': 100, 'exp':
'4', 'sex': 'f'}, 1: {'grade': 'A', 'status': 'single', 'payment': 200,
'exp': '4', 'sex': 'f'}, 2: {'grade': 'A', 'status': 'single', 'payment':
400, 'exp': '4', 'sex': 'f'}, 3: {'grade': 'A', 'status': 'single',
'payment': 500, 'exp': '4', 'sex': 'f'}}}
>>>


Any other suggestion ,   Please let me know  I am on python 2.7 and Linux

Regards,
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-04-02 Thread Andrew Nester

Andrew Nester added the comment:

>From my perspective current behaviour is a bit frustrate that's why it would 
>be nice to have this issue fixed, but I would say it's critic one.
At the same time it doesn't introduce any BC breaking changes and kind safe

--

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2017-04-02 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1142

___
Python tracker 

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



[issue15083] Rewrite ElementTree tests in a cleaner and safer way

2017-04-02 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue15083] Rewrite ElementTree tests in a cleaner and safer way

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 68903b656d4e1011525a46cbd1338c6cbab83d6d by Serhiy Storchaka in 
branch '2.7':
bpo-15083: Convert ElementTree doctests to unittests. (#906)
https://github.com/python/cpython/commit/68903b656d4e1011525a46cbd1338c6cbab83d6d


--

___
Python tracker 

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



[issue29416] Path.mkdir can get into a recursive error loop

2017-04-02 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-02 Thread R. David Murray

R. David Murray added the comment:

Yes, the difficulty in renaming the parameter was why I suggested a doc change 
only.  I'm not sure it it is worth it to go through a deprecation cycle for 
socketserver to change the name, though it certainly would be nice.  Martin and 
I could make that decision, but it would be better to get input from other 
devs.  And, if we make this the documentation issue, we should open a separate 
issue for the parameter rename.

--

___
Python tracker 

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



[issue29169] update zlib to 1.2.11

2017-04-02 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests:  -1029

___
Python tracker 

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



[issue29897] itertools.chain behaves strangly when copied with copy.copy

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes, this issue is tricky, and I don't have .

If implement __copy__ for builtin compound iterators I would implement 
filter.__copy__ and map.__copy__ something like:

def __copy__(self):
cls, *args = self.__reduce__()
return cls(*map(copy, args))

If the underlying iterators properly support copying, the copying of filter and 
map iterators will be successful. If they don't support copying, the copying of 
filter and map iterators should fail, and don't accumulate elements in the 
tee() object.

But there are open questions.

1. This is a behavior change. What if any code depends on the current behavior? 
This is silly, copy(filter) and copy(map) could just return the original 
iterator if this is a desirable behavior.

2. Depending on the copy module in the method of the builtin type looks 
doubtful. Should we implement copy.copy() in C and provide a public C API?

3. If make a copying of limited depth, shouldn't we use a memo as for 
deepcopy() to prevent unwanted duplications? Otherwise the copied `map(func, 
it, it)` would behave differently from the original. This example is not so 
silly as looked.

4. Is it possible to implement the copying for all compound iterators? For 
example the copying of chain() should change the state of the original object 
(by using __setstate__), so that it makes copies of subiterators before using 
them.

Perhaps all this deserves a PEP.

--

___
Python tracker 

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



[issue29963] Remove obsolete declaration PyTokenizer_RestoreEncoding in tokenizer.h

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Good catch Jim! Seems the implementation was removed in Python 3. This is a 
private header, so no need to backport the change.

--
nosy: +serhiy.storchaka
stage:  -> patch review
type:  -> enhancement

___
Python tracker 

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



[issue29963] Remove obsolete declaration PyTokenizer_RestoreEncoding in tokenizer.h

2017-04-02 Thread Jim Fasarakis-Hilliard

Changes by Jim Fasarakis-Hilliard :


--
pull_requests: +1141

___
Python tracker 

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



[issue29963] Remove obsolete declaration PyTokenizer_RestoreEncoding in tokenizer.h

2017-04-02 Thread Jim Fasarakis-Hilliard

New submission from Jim Fasarakis-Hilliard:

Couldn't trace exactly when it was removed from tokenizer.c but the 
corresponding declaration in the header file survived.

I'm not sure how to tag this small clean-up.

--
messages: 291033
nosy: Jim Fasarakis-Hilliard
priority: normal
severity: normal
status: open
title: Remove obsolete declaration PyTokenizer_RestoreEncoding in tokenizer.h
versions: Python 3.7

___
Python tracker 

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



[issue26793] uuid causing thread issues when forking using os.fork py3.4+

2017-04-02 Thread Andre Merzky

Andre Merzky added the comment:

This one might be related:

https://bugs.python.org/issue27889

--
nosy: +Andre Merzky

___
Python tracker 

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



Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Chris Angelico
On Sun, Apr 2, 2017 at 9:12 PM, bartc  wrote:
> But people, when unrestrained, will /always/ want to do something that may
> not be practical. For example, why bother with the separate concepts
> 'filename' and 'file'; just have the file contents /as/ the filename! If
> there are no limits on how long a filename is or what characters it can
> have, then people will take advantage.
>

This is possible. It's called a "content-based file system", and it's
the basis of tools like git, for example. But it's not the entire
solution; you still need some way to tell a program which blob to
react to.

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


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread bartc

On 01/04/2017 22:35, Marko Rauhamaa wrote:

Chris Angelico :


there is no way within Python to have a string that can represent two
strings, which is what directory separators do.


Really? Try:

   >>> repr(("a", "b"))
   "('a', 'b')"

There! A string that represents two strings.

Note, however, that Python programs generally don't restrict themselves
to expressing objects via strings. There are even objects with no string
representation at all.

A pathname is a list of strings. Python could naturally express it as
just that:

  [ "usr", "bin", "python3" ]


I'm not really proposing any change to the status quo. What's done is
done. However, I do think it is awkward to ban one particular, very
common character while allowing all the rest.


Space is quite common as well, especially in titles of things chosen by 
non-technical users. That also needs special treatment.


There are quite a few other characters with special meanings that people 
might want to use. It's not just stroke.


But people, when unrestrained, will /always/ want to do something that 
may not be practical. For example, why bother with the separate concepts 
'filename' and 'file'; just have the file contents /as/ the filename! If 
there are no limits on how long a filename is or what characters it can 
have, then people will take advantage.


Or they will want to use the full path of one file, as the part of the 
filename of another; is each "/" a separator, or part of the embedded path?


Anyway, I'm sure out of the million unicode characters, there must be 
something that /looks/ like a stroke, but isn't a stroke. Just to add to 
the confusion.



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


[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your patch Kinebuchi. Do you mind to backport it to other 
branches?

--
stage: patch review -> backport needed

___
Python tracker 

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



[issue19225] lack of PyExc_BufferError doc

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset e8c763128fb459c5c98194e4312f31493c0f12df by Serhiy Storchaka 
(cocoatomo) in branch 'master':
bpo-19225: Add a table of warning names and missed exception names in C API doc 
(#881)
https://github.com/python/cpython/commit/e8c763128fb459c5c98194e4312f31493c0f12df


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29654] SimpleHTTPRequestHandler should support browser cache

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your contribution Pierre.

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



[issue29654] SimpleHTTPRequestHandler should support browser cache

2017-04-02 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 351adda54bed3afbbf6db7725699679e68722d7d by Serhiy Storchaka 
(Pierre Quentel) in branch 'master':
bpo-29654 : Support If-Modified-Since HTTP header (browser cache) (#298)
https://github.com/python/cpython/commit/351adda54bed3afbbf6db7725699679e68722d7d


--
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: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Marko Rauhamaa
Christian Gollwitzer :

> Am 01.04.17 um 19:38 schrieb Steve D'Aprano:
>> Next: convince keyboard manufacturers to move the caret from SHIFT-6
>> to a plain, unshifted key. Buggared if I'm going to hit shift every
>> time I want to use an absolute path...
>
> ...which is reality for a lot more people than you might think. On a
> German keyboard, / is Shift-7. Same for \ {} [] which require
> carpal-tunneling combinations with the right Alt key "Alt Gr".
> Especially bad are shortcutrs like Ctrl+\ which appear in some
> software.

Same with the Finnish keyboard. It's a crime against ergonomy. That's
why I have remapped my keyboard for my personal needs (languages,
programming).


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


[issue29897] itertools.chain behaves strangly when copied with copy.copy

2017-04-02 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

It is a tricky issue. How deep do you go?what if you are chaining several
of the itertools? Seems like we're entering a semantic sinkhole here.

Deepcopy would be too deep...
The original copy support in these objects stems from the desire to support
pickling.

On 1 Apr 2017 16:12, "Raymond Hettinger"  wrote:

>
> Raymond Hettinger added the comment:
>
> Serhiy, feel free to take this in whatever direction you think is best.
>
> --
> assignee:  -> serhiy.storchaka
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Christian Gollwitzer

Am 01.04.17 um 19:38 schrieb Steve D'Aprano:

^home^steve^document.txt


I'm sure I'd get used to it in a few years...

Next: convince keyboard manufacturers to move the caret from SHIFT-6 to a
plain, unshifted key. Buggared if I'm going to hit shift every time I want
to use an absolute path...


...which is reality for a lot more people than you might think. On a 
German keyboard, / is Shift-7. Same for \ {} [] which require 
carpal-tunneling combinations with the right Alt key "Alt Gr". 
Especially bad are shortcutrs like Ctrl+\ which appear in some software.


Christian

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


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Chris Angelico
On Sun, Apr 2, 2017 at 4:41 PM, Terry Reedy  wrote:
> On 4/1/2017 12:00 PM, Steve D'Aprano wrote:
>
>> example of the Ugly American.
>
>
> As an American I resent your promotion and perpetuation of an ugly
> ethno-centric stereotype.

There are ugly Americans and there are non-ugly Americans. Rick is a
prime example of the former.

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


Re: Text-mode apps (Was :Who are the "spacists"?)

2017-04-02 Thread Terry Reedy

On 4/1/2017 12:00 PM, Steve D'Aprano wrote:


example of the Ugly American.


As an American I resent your promotion and perpetuation of an ugly 
ethno-centric stereotype.


--
Terry Jan Reedy

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


[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-04-02 Thread Dominic Mayers

Dominic Mayers added the comment:

I did not think very far when said that renaming the parameter could not 
possibly break the code ! Oh well ! But, renaming the parameter was not 
important in itself.  It was to make the situation clearer and easier for those 
who write the documentation. Martin mentioned that it is a big change for the 
API. This is what I had in mind. And yes, I should have used 'factory 
function', not 'factory instance'. Oh well ! I am glad things are working and 
that we will move ahead to resolve this issue.

--

___
Python tracker 

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



[issue29957] unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher

2017-04-02 Thread Benjamin Peterson

Benjamin Peterson added the comment:


New changeset 11fa3c7cd1b151e302d4eee0369cafbaf151c8fb by Benjamin Peterson 
(Michael Selik) in branch 'master':
bpo-29957: change LBYL key lookup to dict.setdefault (#938)
https://github.com/python/cpython/commit/11fa3c7cd1b151e302d4eee0369cafbaf151c8fb


--

___
Python tracker 

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