[issue31465] Allow _PyType_Lookup() to raise exceptions

2017-09-25 Thread Stefan Behnel

Stefan Behnel added the comment:

Any comments on this?

--

___
Python tracker 

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



[issue31584] Documentation Language mixed up

2017-09-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Indeed a problem! Seems to affect Python 2.7 docs. If not mistaken, Julien 
worked on the language switcher. Maybe he has some clue ...

--
nosy: +Mariatta, mdk
priority: normal -> high
stage:  -> needs patch

___
Python tracker 

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



[issue31579] Reference leak in enumerate

2017-09-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +3747

___
Python tracker 

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



[issue31579] Reference leak in enumerate

2017-09-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +3746

___
Python tracker 

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



[issue31585] Refactor the enumerate.__next__ implementation

2017-09-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Having separate code paths was an intentional decision.  I prefer to keep it 
that way.

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

___
Python tracker 

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



[issue31585] Refactor the enumerate.__next__ implementation

2017-09-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +3745
stage:  -> patch review

___
Python tracker 

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



[issue31585] Refactor the enumerate.__next__ implementation

2017-09-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Currently the large and complex part of enum_next() and enum_next_long() in 
Objects/enumobject.c is duplicated. This increases the code size and makes 
harder maintaining the code. The proposed patch refactors the implementation 
and removes the code duplication.

--
components: Interpreter Core
messages: 303006
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Refactor the enumerate.__next__ implementation
type: enhancement
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



[issue31579] Reference leak in enumerate

2017-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 0e950dd22b075b4809c84afda8aede02b76ac0fa by Serhiy Storchaka in 
branch 'master':
bpo-31579: Fixed a possible leak in enumerate() with large indices. (#3753)
https://github.com/python/cpython/commit/0e950dd22b075b4809c84afda8aede02b76ac0fa


--

___
Python tracker 

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



[issue31584] Documentation Language mixed up

2017-09-25 Thread asl

New submission from asl:

Some of the documentation language are mixed up.

eg:
Japanese on the English page https://docs.python.org/2.7/faq/design.html
French on the Japanese https://docs.python.org/ja/2.7/faq/design.html

It seem to affect multiple pages:
https://docs.python.org/2.7/bugs.html
https://docs.python.org/2.7/distributing/index.html
https://docs.python.org/2.7/extending/index.html
https://docs.python.org/2.7/extending/extending.html
The c-api pages https://docs.python.org/2.7/c-api/index.html
The faq pages https://docs.python.org/2.7/faq/index.html

And possibly others.

--
assignee: docs@python
components: Documentation
messages: 303004
nosy: asl, docs@python
priority: normal
severity: normal
status: open
title: Documentation Language mixed up
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



[issue31580] Defer compiling regular expressions

2017-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

lru_cache() is not used for reasons. The patch makes using cached patterns 
slower by adding an overhead of 4 additional checks. It makes resolving 
attributes of a deferred patterns slower. All this slows down a straight call 
to re.search(pattern, s).

Errors in regular expression now raised only on first use of the pattern. This 
is a drawback from educational and debugging points of view.

The patch also breaks warnings emitted during compiling regular expressions. 
Now they report wrong source line and use wrong line for caching in case of 
-Wonce.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue31581] Reduce the number of imports for functools

2017-09-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Go ahead.

--

___
Python tracker 

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



[issue31583] 2to3 call for file in current directory yields error

2017-09-25 Thread Denis Osipov

Changes by Denis Osipov :


--
keywords: +patch
pull_requests: +3744
stage:  -> patch review

___
Python tracker 

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



[issue31583] 2to3 call for file in current directory yields error

2017-09-25 Thread Denis Osipov

New submission from Denis Osipov:

2to3 doesn't work if called for file in current directory with --add-suffix 
option.

$ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W 
--add-suffix=3 test2to3.py
Running Debug|x64 interpreter...
WARNING: --write-unchanged-files/-W implies -w.
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Refactored test2to3.py
--- test2to3.py (original)
+++ test2to3.py (refactored)

--some changes--

Traceback (most recent call last):
  File "D:/repos/cpython/Tools/scripts/2to3", line 5, in 
sys.exit(main("lib2to3.fixes"))
  File "D:\repos\cpython\lib\lib2to3\main.py", line 259, in main
options.processes)
  File "D:\repos\cpython\lib\lib2to3\refactor.py", line 687, in refactor
items, write, doctests_only)
  File "D:\repos\cpython\lib\lib2to3\refactor.py", line 282, in refactor
self.refactor_file(dir_or_file, write, doctests_only)
  File "D:\repos\cpython\lib\lib2to3\refactor.py", line 728, in refactor_file
*args, **kwargs)
  File "D:\repos\cpython\lib\lib2to3\refactor.py", line 339, in refactor_file
write=write, encoding=encoding)
  File "D:\repos\cpython\lib\lib2to3\refactor.py", line 505, in processed_file
self.write_file(new_text, filename, old_text, encoding)
  File "D:\repos\cpython\lib\lib2to3\main.py", line 84, in write_file
os.makedirs(output_dir)
  File "D:\repos\cpython\\lib\os.py", line 221, in makedirs
mkdir(name, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''


It works well if I use absolute path for target file or set -o:

$ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W 
--add-suffix=3 /d/MyPythonScripts/test2to3.py

$ /d/repos/cpython/python.bat /d/repos/cpython/Tools/scripts/2to3 -n -W 
--add-suffix=3 -o . test2to3.py

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 303001
nosy: denis-osipov
priority: normal
severity: normal
status: open
title: 2to3 call for file in current directory yields error
type: behavior
versions: Python 3.6, Python 3.7

___
Python tracker 

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



Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Ned Batchelder

On 9/25/17 10:20 PM, Steve D'Aprano wrote:

On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote:
[...]




We've been asked nicely by the list mod to stop :)

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


[issue31582] Add _pth breadcrumb to sys.path documentation

2017-09-25 Thread Traveler Hauptman

New submission from Traveler Hauptman:

Python on windows (winpython) was not adding PYTHONPATH to sys.path as 
documented and I could not understand why.

It took a lot of time, web searches, and finally a tour through the code to 
find out about _pth; which is well documented but difficult to find out about 
if you don't know about it beforehand.

Please improve the sys.path documentation to say that it depends on either 
PYTHONPATH or the *._pth file. Better yet, link to the actual sys.path 
heuristics.

--
assignee: docs@python
components: Documentation
messages: 303000
nosy: Traveler Hauptman, docs@python
priority: normal
severity: normal
status: open
title: Add _pth breadcrumb to sys.path documentation
type: enhancement

___
Python tracker 

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



[issue31581] Reduce the number of imports for functools

2017-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Initially my patch for issue30152 included the change in collections. But it 
was removed on Raymond's request.

--
nosy: +rhettinger, serhiy.storchaka

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Bill

Tim Golden wrote:

On 25/09/2017 20:40, Marko Rauhamaa wrote:

Rhodri James :

On 25/09/17 15:26, Marko Rauhamaa wrote:

That's not what I said. I said all expressions *evaluate to* pointers.


This may well be true in particular implementations, but it is an
implementation detail so Chris' point still stands.  Another
implementation could evaluate expressions to indices (as BCPL used to
treat its globals), pieces of string or cheese, who knows?


Those are all pointers.

A pointer is something that points to a data object.


(Slight sigh). Can I step in as a list owner and ask the people who 
are so very fond of debating this topic again and again: please let it 
drop.


Threads such as this can remain interesting when the discussion 
generates a better understanding of the subject matter as the 
contributors are forced to articulate their positions leading to some 
kind of convergence of understanding.


However, even if this were the only iteration of this debate, it would 
be clear by now that there's no chance of a simple "I see what you 
mean" moment. And this is far from the only iteration, even in the 
past few months.


I feel for your need to demonstrate the validity of your respective 
positions. But it has moved on from being an enlightening debate and 
into the realms of mere tedium.


Thanks.

TJG


Perhaps it would be better to amass examples and let them speak for 
themselves?

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


[issue31581] Reduce the number of imports for functools

2017-09-25 Thread INADA Naoki

Changes by INADA Naoki :


--
keywords: +patch
pull_requests: +3743
stage:  -> patch review

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Bill

Chris Angelico wrote:

On Tue, Sep 26, 2017 at 5:35 AM, Marko Rauhamaa  wrote:

Chris Angelico :


On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa  wrote:
Sorry, that was my bad in the terminology. But where do you get that
all Python expressions evaluate to pointers?

What do they evaluate to if not pointers? Anton's "identities" would
work, too. "Address" would do, as well. I have previously proposed the
term "leash." Call it "link" or "handle" or "arrow" if you want to.

The term used isn't important. What's important is to understand that
each expression and subexpression produces and operates on pointers.

They evaluate to objects. Not to pointers to objects. Not to
references to objects. To objects. Expressions evaluate to actual
objects, and when you assign "name = value", you bind the name to the
object that value evaluates to.

ChrisA


And when you pass a reference r to a function, a copy of the reference 
is passed. So even if you reassign *that* copy of r to refer to another 
object, upon return, r still still refers to whatever it did 
originally.  ::: case closed :::, I think.

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


[issue31581] Reduce the number of imports for functools

2017-09-25 Thread INADA Naoki

New submission from INADA Naoki:

Makes `import functools` about 1.5 ms faster.

* heapq is used only when Counter.most_common(n).
* types and waakref is used only for singledispatch.

master:

import time:   - _functools 76 us (self 76 us)
import time:   - _operator 110 us (self 110 us)
import time: - operator 469 us (self 359 us)
import time: - keyword 174 us (self 174 us)
import time:   - _heapq 189 us (self 189 us)
import time: - heapq 400 us (self 211 us)
import time: - itertools 137 us (self 137 us)
import time: - reprlib 231 us (self 231 us)
import time: - _collections 142 us (self 142 us)
import time:   - collections 3006 us (self 1456 us)
import time: - collections.abc 191 us (self 191 us)
import time:   - types 518 us (self 327 us)
import time:   - weakref 577 us (self 577 us)
import time: - functools 4903 us (self 729 us)

patched:

import time:   - _functools 74 us (self 74 us)
import time:   - _operator 100 us (self 100 us)
import time: - operator 460 us (self 361 us)
import time: - keyword 174 us (self 174 us)
import time: - itertools 139 us (self 139 us)
import time: - reprlib 226 us (self 226 us)
import time: - _collections 85 us (self 85 us)
import time:   - collections 2593 us (self 1512 us)
import time: - functools 3369 us (self 703 us)

--
components: Library (Lib)
messages: 302998
nosy: inada.naoki
priority: normal
severity: normal
status: open
title: Reduce the number of imports for functools
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



Re: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Michael Torrie
On 09/25/2017 06:38 PM, Kryptxy via Python-list wrote:
> Is there any way that the GUI program is opened, and immediately the
> control returns to calling program, instead of keeping the terminal
> busy?

Yes. This is a classic situation where you want to first fork() the
process, then exec() the new app.  There are a few steps to do this
properly, so google for "python fork exec".

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


[issue31580] Defer compiling regular expressions

2017-09-25 Thread R. David Murray

R. David Murray added the comment:

I agree with Raymond.  It would be strange to have the API that is obviously 
designed to pre-compile the regex not pre-compile the regex.

If the concern is that a non-precompiled regex might get bumped out of the 
cache but you want a way to only compile a "bunch of stuff" on demand, then the 
thing to do would be to make a proposal for a new API that does that, and we'll 
discuss the merits :)

It seems to me that contexts that care about startup time can use the deferred 
compile API, whether the new (it it is accepted) or existing one.  If an 
application cares about startup time and is using re.compile at startup, then 
that is an application performance bug.

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



[issue31580] Defer compiling regular expressions

2017-09-25 Thread Raymond Hettinger

Raymond Hettinger added the comment:

ISTM, the whole point is to compile in advance.  When I worked during high 
frequency trading, that was essential to news trading where you *really* didn't 
want to pay the compilation cost at the time the regex was used.  This proposal 
takes away the user's only control over when the regex is compiled. 

FWIW, if a user doesn't explicitly invoke re.compile() and instead uses a 
straight call to re.search(pattern, s), then the pattern is compiled on 
first-use and cached for future use.  In other words, we already have a simple 
and clear way to auto-compile on first use.  I recommend against taking away 
the only option to specify otherwise.

--
nosy: +rhettinger

___
Python tracker 

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



Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 02:54 am, Ned Batchelder wrote:
[...]

Heh, its hard to avoid getting sucked into the sinkhole of definitional debates,
isn't it? :-)

[...]
> But in this line:
> 
>  x = 2 + 2
> 
> You can say,
> 
>  the value of x is 4

If we're talking about the highest level abstraction level, namely the Python
code, that would be the right answer. Provided that we understand that as
short-hand for:

>  the value of x is an int object with a value of 4

However:

> or,
> 
>  the value of x is a reference to an int object with a value of 4,

while that's true from a certain perspective, it's not the high-level Python
perspective. Its that of the implementation.

It's a perfectly valid perspective, and its often not just useful but (almost)
necessary. Some behaviours of Python are difficult to understand unless we dip
down an abstraction level and look at the implementation.


> and in some ways, each of those is a correct statement. They are
> different perspectives on the same complicated abstract relationships
> inside your program.  Most of the disagreements in this thread stem from
> someone picking one of those three statements and insisting that it is
> *the* right statement, or from differing interpretations of words like
> value, reference, pointer, alias, etc.

This topic has been discussed a lot over the last few weeks/months, and that's
something I've  also said: it is useful if not necessary to discuss different
levels of abstractions, but one needs to be clear when you are doing so.

We all take verbal short-cuts from time to time, and I'll often use language
like

"evaluating the expression returns a reference (a pointer) to the object ..."

(language which Marko would, I think, agree with) if I feel it brings insight to
the question being discussed. From a purely pedantic point of view, I'll say
I'm slightly naughty to do so, because I'm crossing abstractions without being
explicit about it. "Explicit is better than implicit."

So we all do it. I have no problem with people taking short-cuts or crossing
abstractions and even mixing explanations from different levels, provided it
brings insight and clarity to the question rather than confusion.

Its better to be explicit about it when you do so ("under the hood, the
interpreter uses a pointer to the object...") but we're all only human and
sometimes we make implicit assumptions.

But I do have to wonder about people who insist on keeping an inflexible,
single-minded point of view even in the face of confusion. To use your analogy
from below, it is as if they were absolutely, categorically denying that
pressing the gas pedal (accelerator pedal) has anything to do with the car
moving, because its the engine that makes it move, and that's the only right
answer.

Its fine to discuss what happens in different abstraction layers, but be clear
about it when you do.


> Software gets complicated because it involves multiple levels of
> abstraction layered on top of each other.  We might as well be arguing
> like this:
> 
>  A: "The gas pedal makes the car go"
> 
>  B: "Nonsense! The gas pedal supplies fuel to the engine, it's the 
> engine that makes the car go"
[snip]

Indeed. 


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


[issue31580] Defer compiling regular expressions

2017-09-25 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
keywords: +patch
pull_requests: +3742
stage:  -> patch review

___
Python tracker 

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



[issue31580] Defer compiling regular expressions

2017-09-25 Thread Barry A. Warsaw

New submission from Barry A. Warsaw:

It's a very common pattern to see the following at module scope:

cre_a = re.compile('some pattern')
cre_b = re.compile('other pattern')

and so on.  This can cost you at start up time because all those regular 
expressions are compiled at import time, even if they're never used in practice 
(e.g. because say whatever condition tickles the compiled regex never gets 
exercised).

It occurred to me that if re.compile() deferred compilation of the regexp until 
first use, you could speed up start up time.  But by how much?  And at what 
cost?

So I ran a small experiment (pull request to be submitted) using the `perf` 
module on `pip --help`.  I was able to cut down the number of compiles from 28 
to 9, and a mean startup time from 245ms to 213ms.

% python -m perf compare_to ../base.json ../defer.json 
Mean +- std dev: [base] 245 ms +- 19 ms -> [defer] 213 ms +- 21 ms: 1.15x 
faster (-13%)

`pip install tox` reduces the compiles from 231 to 75:

(cpython 3.7) 231 0.06945133209228516
(3.7 w/defer)  75 0.03140091896057129

So what's the cost?  Backward compatibility.  `re.compile()` doesn't return a 
compiled regular expression object now, but instead a "deferred" proxy.  When 
the proxy is used, then it does the actual compilation.  This can break 
compatibility by deferring any exceptions that compile() might raise.  This 
happens a fair bit in the test suite, but I'm not sure it's all that common in 
practice.  In any case, I've also added a re.IMMEDIATE (re.N -- for "now") flag 
to force immediate compilation.

I also modified the compilation to use an actual functools.lru_cache.  This 
way, if maxcache gets triggered, the entire cache won't get blown away.

So, whether this is a good idea or not, I open this and push the branch for 
further discussion.

--
assignee: barry
components: Library (Lib)
messages: 302995
nosy: barry
priority: normal
severity: normal
status: open
title: Defer compiling regular expressions
type: performance
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



[issue18257] Two copies of python-config

2017-09-25 Thread R. David Murray

R. David Murray added the comment:

Since it hasn't been an issue for a few releases, I say we close it.  If there 
is some problem remaining, it probably deserves its own tracker issue anyway.

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



Re: Printing a Chunk Of Words

2017-09-25 Thread Steve D'Aprano
On Tue, 26 Sep 2017 10:15 am, Cai Gengyang wrote:

> """
[snip text]
> """
> 
> If I simply want to print a chunk of words and a paragraph like the above,
> what command should I use ?


Print to the terminal? Use print().

Print to an actual printer? There's no built-in command in Python to do so, and
to be honest, I'm not sure how to do it.




-- 
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: Running a GUI program haults the calling program (linux)

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 10:38 AM, Kryptxy via Python-list
 wrote:
> I want to run a GUI program (transmission-gtk) from python. This is what I do:
>
> import subprocess
> subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, 
> stderr=subprocess.PIPE)
>
> Where `link` is some magnetic link.
>
> This command opens transmission-gtk, but it haults the calling program, and 
> keeps the terminal busy till the time GUI is running.
> As soon as GUI is closed, the control goes back to the program.
>
> Is there any way that the GUI program is opened, and immediately the control 
> returns to calling program, instead of keeping the terminal busy?
>
> (I know transmission-remote can be used for adding torrents. Looking for a 
> way around for transmission-gtk specifically).

I'm not sure why you can't signal it, but I'll take that parenthesized
comment as an indication that you know about (a) the
transmission-remote command, and/or (b) the fact that transmission-gtk
can be remote-controlled fairly effectively. (For instance, I have a
script that puts Transmission into turtle mode, then does something,
and then takes Transmission out of turtle mode. It's two lines of
shell script to do it.)

So, you want to "fire-and-forget" a GUI program. Or more generally,
_any_ program. My suspicion here is that, since Popen shouldn't be
blocking, that you're filling up one of your pipes. Can you try
removing the stdout and stderr parameters, and see what that does? You
should be able to fire off a subprocess and then carry on with the
program. It might make a lot of noise, if transmission produces a ton
of output; but if that happens, try std{out,err}=subprocess.DEVNULL
instead of PIPE - unless you're specifically trying to read the
output?

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


Running a GUI program haults the calling program (linux)

2017-09-25 Thread Kryptxy via Python-list
I want to run a GUI program (transmission-gtk) from python. This is what I do:

import subprocess
subprocess.Popen(['transmission-gtk', link], stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)

Where `link` is some magnetic link.

This command opens transmission-gtk, but it haults the calling program, and 
keeps the terminal busy till the time GUI is running.
As soon as GUI is closed, the control goes back to the program.

Is there any way that the GUI program is opened, and immediately the control 
returns to calling program, instead of keeping the terminal busy?

(I know transmission-remote can be used for adding torrents. Looking for a way 
around for transmission-gtk specifically).

Thank you!
Regards.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Printing a Chunk Of Words

2017-09-25 Thread Rick Johnson
On Monday, September 25, 2017 at 7:15:41 PM UTC-5, Cai Gengyang wrote:
> """
>  Boolean Operators
>   
> True and True is True
> True and False is False
> False and True is False
> False and False is False
> 
> True or True is True
> True or False is True
> False or True is True
> False or False is False
> 
> Not True is False
> Not False is True
> 
> """
> 
> If I simply want to print a chunk of words and a paragraph
like the above, what command should I use ?

Well, being that what you have there is a "multi-line string
literal", then you can pass it the print function (py3).

## Begin: Python2.x interactive session ##
>>> print """this is my
totally awesome multi-line
string"""
this is my
totally awesome multi-line
string
## End: Python2.x interactive session ##

Although, i would assign a name to it first, as passing
around literals is not practical.

## Begin: Python2.x interactive session ##
>>> s = """this is my
totally awesome multi-line
string"""
>>> print s
this is my
totally awesome multi-line
string
## End: Python2.x interactive session ##

However, if your intention is to evaluate each line of the
"paragraph" (as you called it), then you have to do a little
more work.

## Begin: Python2.x interactive session ##
>>> for line in s.splitlines(True):
... print repr(line)
'this is my\n'
'totally awesome multi-line\n'
'string'

Which is a start...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Printing a Chunk Of Words

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 10:15 AM, Cai Gengyang  wrote:
> """
>  Boolean Operators
> 
> True and True is True
> True and False is False
> False and True is False
> False and False is False
>
> True or True is True
> True or False is True
> False or True is True
> False or False is False
>
> Not True is False
> Not False is True
>
> """
>
> If I simply want to print a chunk of words and a paragraph like the above, 
> what command should I use ?

You already have them in triple quotes. Toss a 'print(...)' around it,
and it'll print.

If that's not what you mean, then be more specific :) :) :)

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


Printing a Chunk Of Words

2017-09-25 Thread Cai Gengyang
"""
 Boolean Operators
  
True and True is True
True and False is False
False and True is False
False and False is False

True or True is True
True or False is True
False or True is True
False or False is False

Not True is False
Not False is True

"""

If I simply want to print a chunk of words and a paragraph like the above, what 
command should I use ?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue14799] Tkinter ttk tests hang on linux

2017-09-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

A year or so ago, I asked people on python-list who could to run the gui tests 
on their linux boxes and report.  About 6 did and with one possible exception, 
and not that reported here, everyone reported success.  So, unless someone can 
report otherwise, I think this should be closed.

I think we should regularly ask the community to help with gui tests.

--

___
Python tracker 

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



Re: Calling methods without objects?

2017-09-25 Thread Thomas Jollans
On 26/09/17 01:04, Thomas Jollans wrote:
>
> In [1]: class C:
>
>...: def m(self):
>
>...: return True
I'll have to give my MUA a stern talking to about the importance of
whitespace. Anyway, you know what I mean.
>
>...:

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


[issue31415] Add -X option to show import time

2017-09-25 Thread INADA Naoki

INADA Naoki added the comment:

how can I make it more machine readable?

On 2017年9月25日(月) 19:39 Christian Heimes  wrote:

>
> Christian Heimes added the comment:
>
> +1 for an option to profile import time.
>
> I have a minor complain: The output format is not machine-friendly, which
> makes it harder to perform automatic analysis. I created #31574 / PR3749 to
> add dtrace probes.
>
> --
> nosy: +christian.heimes
>
> ___
> Python tracker 
> 
> ___
>
-- 
Inada Naoki 

--

___
Python tracker 

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



[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

The proposed change seems fine. Merged and backported.
Thanks everyone!

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

___
Python tracker 

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



[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 26b940f762f0b306ff894601003f51a8d036e285 by Mariatta (Miss 
Islington (bot)) in branch '3.6':
bpo-31571: Remove duplicated info in Lexical Analysis documentation (GH-3691) 
(GH-3754)
https://github.com/python/cpython/commit/26b940f762f0b306ff894601003f51a8d036e285


--

___
Python tracker 

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



[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Roundup Robot

Changes by Roundup Robot :


--
keywords: +patch
pull_requests: +3741

___
Python tracker 

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



[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 4a2d00cb4525fcb3209f04531472ba6a359ed418 by Mariatta (Guilherme 
Caminha) in branch 'master':
bpo-31571: Remove duplicated info in Lexical Analysis documentation (GH-3691)
https://github.com/python/cpython/commit/4a2d00cb4525fcb3209f04531472ba6a359ed418


--

___
Python tracker 

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



Re: TypeError with map with no len()

2017-09-25 Thread Thomas Jollans
On 25/09/17 18:44, john polo wrote:
> Python List,
>
> I am trying to make practice data for plotting purposes. I am using
> Python 3.6. The instructions I have are
>
> import matplotlib.pyplot as plt
> import math
> import numpy as np
> t = np.arange(0, 2.5, 0.1)
> y1 = map(math.sin, math.pi*t)

If you use np.sin instead of math.sin, you don't have to use map: Most
numpy functions operate elementwise on arrays (for example, you're
multiplying math.pi with an array - something that wouldn't work with a
list).

Here's the numpy way of doing this:

t = np.arange(0, 2.5, 0.1)
y1 = np.sin(np.pi * t)

Without using numpy at all, this might be

t = [i * 0.1 for i in range(25)]
y1 = [math.pi * a for a in t]

> plt.plot(t,y1)
>
> However, at this point, I get a TypeError that says
>
> object of type 'map' has no len()
>
> In [6]: t
> Out[6]:
> array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7, 0.8,  0.9,  1. ,
> 1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8, 1.9,  2. ,  2.1,
> 2.2,  2.3,  2.4])
> In [7]: y1
> Out[7]: 
> In [8]: math.pi*t
> Out[8]:
> array([ 0.,  0.31415927,  0.62831853,  0.9424778 , 1.25663706,
> 1.57079633,  1.88495559,  2.19911486,  2.51327412, 2.82743339,
> 3.14159265,  3.45575192,  3.76991118,  4.08407045, 4.39822972,
> 4.71238898,  5.02654825,  5.34070751,  5.65486678, 5.96902604,
> 6.28318531,  6.59734457,  6.91150384,  7.2256631 , 7.53982237])
>
> At the start of creating y1, it appears there is an array to iterate
> through for the math.sin function used in map(), but y1 doesn't appear
> to be saving any values. I expected y1 to hold a math.sin() output for
> each item in math.pi*t, but it appears to be empty. Am I
> misunderstanding map()? Is there something else I should be doing
> instead to populate y1?
>
>
> John
>

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


[issue14799] Tkinter ttk tests hang on linux

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

Unsetting priority.

--
nosy: +lukasz.langa
priority: critical -> 

___
Python tracker 

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



[issue27163] IDLE entry for What's New in Python 3.6

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

Unsetting priority since it's not Critical and RMs look at open Critical bugs 
when releasing 3.6.3 and so on.

--
nosy: +lukasz.langa
priority: critical -> 

___
Python tracker 

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



[issue29406] asyncio SSL contexts leak sockets after calling close with certain Apache servers

2017-09-25 Thread Łukasz Langa

Changes by Łukasz Langa :


--
assignee:  -> yselivanov

___
Python tracker 

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



[issue29624] Python 3.5.3 x86 web installer cannot install launcher

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

This is marked as "critical". Looks like it's fixed. Can we close it?

--
nosy: +lukasz.langa

___
Python tracker 

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



[issue29406] asyncio SSL contexts leak sockets after calling close with certain Apache servers

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

This is marked as Critical so either we should change the priority or fix it 
soon :)

--
nosy: +lukasz.langa

___
Python tracker 

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



Re: Calling methods without objects?

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 8:49 AM, Stefan Ram  wrote:
> |>>> from random import randint
> |
> |>>> randint
> |>
> |
> |>>> randint.__self__
> |
> |
> |>>> randint( 2, 3 )
> |2
>
>   It seems I am calling the method »randint« of the object at
>   »0x389798«, but I do not have to write the object into the
>   call!?
>
>   So, is there some mechanism in Python that can bind a method
>   to an object so that the caller does not have to specify the
>   object in the call?
>
>   If so, how is this mechanism called?

>>> stuff = []
>>> add_stuff = stuff.append
>>> add_stuff("spam")
>>> add_stuff("eggs")
>>> add_stuff("sausage")
>>> add_stuff("spam")
>>> stuff
['spam', 'eggs', 'sausage', 'spam']

In a typical method call, "obj.meth(args)", the "obj.meth" part is
itself a valid expression, and it evaluates to a bound method object.
I suppose you could call that mechanism "method binding" if you like,
but mainly it's just attribute lookup.

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


[issue14499] Extension module builds fail with Xcode 4.3 on OS X 10.7 due to SDK move

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

Not critical anymore. Probably safe to close?

--
nosy: +lukasz.langa
priority: critical -> 

___
Python tracker 

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



[issue18257] Two copies of python-config

2017-09-25 Thread Łukasz Langa

Łukasz Langa added the comment:

Downgrading the priority, it's not a deferred blocker for sure. I think we 
could probably just close it?

--
nosy: +lukasz.langa
priority: deferred blocker -> 

___
Python tracker 

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



[issue30755] locale.normalize() and getdefaultlocale() convert C.UTF-8 to en_US.UTF-8

2017-09-25 Thread Matthew Woodcraft

Matthew Woodcraft added the comment:

(For PEP 537 please read PEP 538, sorry)

--

___
Python tracker 

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



[issue30755] locale.normalize() and getdefaultlocale() convert C.UTF-8 to en_US.UTF-8

2017-09-25 Thread Matthew Woodcraft

Matthew Woodcraft added the comment:

I've investigated a bit more.

First, I've tried with Python 3.7.0a1 . As you'd expect, PEP 537 means
this behaviour now also occurs when no locale environment variables at
all are set.


Second, I've looked through locale.py a bit. I believe what it calls the
"aliasing engine" is applied for:

 - getlocale()
 - getdefaultlocale()
 - setlocale() when passed a tuple, but not when passed a string


This leads to some rather odd results.

With 3.7.0a1 and no locale environment variables:

  >>> import locale
  >>> locale.getlocale()
  ('en_US', 'UTF-8')

  # getlocale() is lying: the effective locale is really C.UTF-8
  >>> sorted("abcABC", key=locale.strxfrm)
  ['A', 'B', 'C', 'a', 'b', 'c']


Third, I've checked on a system which does have en_US.UTF-8 installed,
and (as you'd expect) instead of crashing it gives wrong results:

  >>> import locale
  >>> locale.setlocale(locale.LC_ALL, ('C', 'UTF-8'))
  'en_US.UTF-8'
  >>> locale.getlocale()
  ('en_US', 'UTF-8')

  # now getlocale() is telling the truth, and the user isn't getting the
  # collation they requested
  >>> sorted("abcABC", key=locale.strxfrm)
  ['a', 'A', 'b', 'B', 'c', 'C']

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



[issue30152] Reduce the number of imports for argparse

2017-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks all!

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

___
Python tracker 

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



[issue30152] Reduce the number of imports for argparse

2017-09-25 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 81108375d9b2ccd0add1572da745311d4dfac505 by Serhiy Storchaka in 
branch 'master':
bpo-30152: Reduce the number of imports for argparse. (#1269)
https://github.com/python/cpython/commit/81108375d9b2ccd0add1572da745311d4dfac505


--

___
Python tracker 

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



[issue31579] Reference leak in enumerate

2017-09-25 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +3740

___
Python tracker 

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



[issue31579] Reference leak in enumerate

2017-09-25 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

There is a possible leak of the value emitted by an underlying iterator in 
enumerate.__next__.

Proposed PR fixes it.

--
assignee: rhettinger
components: Interpreter Core
messages: 302978
nosy: rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Reference leak in enumerate
type: resource usage
versions: Python 3.6, Python 3.7

___
Python tracker 

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



Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 18:29, Steve D'Aprano wrote:

> 
> Regardless of whether I'm using Python, Swift, Java, C, Pascal or Scheme, if I
> write something like:
> 
> x = Parrot(name="Polly")
> 
> (using Python syntax for simplicity) and somebody tries to tell me that the
> value of x is anything but a Parrot instance named "Polly", I have no time for
> that sort of nonsense. They might as well tell me that I'm typing this 
> response
> on an elephant.

And if you write it like that, implying that the assignment semantics is the
same for all these languages, I'm not surprises people get confused.

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


Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
On 25-09-17 21:44, Ned Batchelder wrote:
> On 9/25/17 5:32 AM, Antoon Pardon wrote:
>> Can you explain, what you mean by "Pass-By-Reference" as far a I understand,
>> pass by reference means that the parameter of the function becomes an alias
>> of the argument, so that if the entity is mutated through one name that
>> mutation is visible through the other name.
>>
>>> function(x, y)  # allowed
>>> function(namespace.x, module.y)  # allowed
>>> function(x + 1, 2)  # FORBIDDEN: can't pass expressions or constants
>> Pass by reference, doesn't imply the above is forbidden. A language can
>> define, that the "x + 1" will produce an new entity and that a reference
>> to that entity will be passed.
>>
> 
> Wikipedia has the right definition of call by reference 
> (https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_reference):
> 
>/Call by reference/ (also referred to as /pass by reference/) is an
>evaluation strategy where a function receives an implicit reference
> to
>a variable used as argument, rather than a copy of its value. This
>typically means that the function can modify (i.e. assign to
>)
>the variable used as argument—something that will be seen by its caller.
> 
> The key idea here is that it is a reference to a *variable* that is passed, 
> not a reference to a value.  Python has no references to variables, so it 
> cannot support call by reference.   Because Python passes references to 
> values, it is easy to call it
> "call by reference," but that is not what the term means.

And what would such a reference to a variable be exactly? If you mean the name,
languages like Pascal don't have that either. If you mean a reference to
an object/entity, Python has those.

It also says: This typically means that the function can modify the variable
used as argument, something Python can do that.

> 
> The Wikipedia definition unfortunately includes "rather than a copy of its 
> value," as if those are the only two options (a common misunderstanding).
> 
> Elsewhere in this thread, someone asserted that to be call by reference, you 
> have to be able to write a swap(x,y) function.  True call-by-reference would 
> make this possible.  Python cannot do it.

That is because assignments in python don't make modifications to what
the name refers to. If you can't modify the object because the semantics
of the assignment don't do that, you can't use the impossibility of
a swap for inferring that we don't have true call by reference.

You can't write a swap in smalltalk either but the smalltalk documentation
specifies that arguments are call by reference.

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


Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico :

> On Tue, Sep 26, 2017 at 5:36 AM, Marko Rauhamaa  wrote:
>> Chris Angelico :
>>> You need *some* support for your assertion that there are pointers,
>>
>> What would convince you?
>
> Evidence, or a statement from the documentation.

I mean, what piece of Python code could decide if I'm right or wrong?


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


[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage:  -> patch review
versions: +Python 3.6

___
Python tracker 

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



Re: [Tutor] beginning to code

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:51 AM, Stefan Ram  wrote:
> Ned Batchelder  writes:
>>Wikipedia has the right definition of call by reference
>
>   Assertions can be right or wrong.
>
>   Definitions cannot be right or wrong.

You have made two assertions. One of them is right. The other is wrong. :-)

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


[issue31530] Python 2.7 readahead feature of file objects is not thread safe

2017-09-25 Thread STINNER Victor

STINNER Victor added the comment:

> Iteration on Python 2 files is fragile, now is not the time to fix 
> fundamental bugs in Python 2.

Right. I don't have a strong preference for Serhiy's PR 3672.

--

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:36 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> You need *some* support for your assertion that there are pointers,
>
> What would convince you?

Evidence, or a statement from the documentation.

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


[issue31577] crash in os.utime() in case of a bad ns argument

2017-09-25 Thread Oren Milman

Changes by Oren Milman :


--
keywords: +patch
pull_requests: +3739
stage:  -> patch review

___
Python tracker 

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



[issue31577] crash in os.utime() in case of a bad ns argument

2017-09-25 Thread Oren Milman

Oren Milman added the comment:

I opened a PR.
I think another fix might be to use
PyLong_Type.tp_as_number->long_divmod() instead of PyNumber_Divmod().

--

___
Python tracker 

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



[issue31170] Update to expat 2.2.4 (expat: utf8_toUtf8 cannot properly handle exhausting buffer)

2017-09-25 Thread STINNER Victor

STINNER Victor added the comment:

Oh, it seems like Steve Dower found an issue on Windows: PR 3751.

I reopen the issue.

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

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Rhodri James :
> On 25/09/17 15:26, Marko Rauhamaa wrote:
>> That's not what I said. I said all expressions *evaluate to* pointers.
>
> This may well be true in particular implementations, but it is an
> implementation detail so Chris' point still stands.  Another
> implementation could evaluate expressions to indices (as BCPL used to
> treat its globals), pieces of string or cheese, who knows?

Those are all pointers.

A pointer is something that points to a data object.


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


Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 5:35 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa  wrote:
>> Sorry, that was my bad in the terminology. But where do you get that
>> all Python expressions evaluate to pointers?
>
> What do they evaluate to if not pointers? Anton's "identities" would
> work, too. "Address" would do, as well. I have previously proposed the
> term "leash." Call it "link" or "handle" or "arrow" if you want to.
>
> The term used isn't important. What's important is to understand that
> each expression and subexpression produces and operates on pointers.

They evaluate to objects. Not to pointers to objects. Not to
references to objects. To objects. Expressions evaluate to actual
objects, and when you assign "name = value", you bind the name to the
object that value evaluates to.

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


[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Guilherme Praciano Karst Caminha

Guilherme Praciano Karst Caminha added the comment:

In that case, I believe the PR I've opened should be fine?

--

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Marko Rauhamaa
Chris Angelico :

> On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa  wrote:
> Sorry, that was my bad in the terminology. But where do you get that
> all Python expressions evaluate to pointers?

What do they evaluate to if not pointers? Anton's "identities" would
work, too. "Address" would do, as well. I have previously proposed the
term "leash." Call it "link" or "handle" or "arrow" if you want to.

The term used isn't important. What's important is to understand that
each expression and subexpression produces and operates on pointers.

>> It also uses circular definitions when talking about dicts and lists:
>>
>>That object is then asked to assign the assigned object to the given
>>attribute
>>
>>the sequence is asked to assign the assigned object to its item with
>>that index.
>
> Technically, that's correct. When you use a statement like:
>
> foo[bar] = quux
>
> what it does is ask the object *foo* to assign *quux* to the item
> represented by *bar*.

What is missing is the definition of that assignment in the specific
case of dicts and lists. The recursive definition must be well-founded.
It covers variables ("names") but leaves the two other fundamental cases
(dicts and lists) undefined.

(I'm actually guessing the definition is missing because the author
couldn't find good language for the cases. Apparently, "dict attribute
binding" and "list element binding" weren't attractive enough.)

> But you have yet to show how you can jump from "name binding" to
> "pointer" using anything from the Python documentation.

There's nothing to show. It's a simple matter of terminology.

"Binding" is a passable synonym for "pointer."


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


[issue31530] Python 2.7 readahead feature of file objects is not thread safe

2017-09-25 Thread Guido van Rossum

Guido van Rossum added the comment:

It should be like 'if key in dct: del dct[key]'. It may fail when two
threads do this but the *internal* state of dct should not be compromised.

On Sep 25, 2017 2:45 AM, "Antoine Pitrou"  wrote:

>
> Antoine Pitrou added the comment:
>
> Le 25/09/2017 à 11:39, STINNER Victor a écrit :
> >
> > Antoine: "I'm wary of raising an exception.  Assuming Benjamin's patch
> is correct, I vote for it."
> >
> > Can you please elaborate? You are fine with the fact that iter(file) in
> two thread can return the same line?
>
> AFAIU it already could.  Iteration on Python 2 files is fragile, now is
> not the time to fix fundamental bugs in Python 2.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le 25/09/2017 à 20:55, Neil Schemenauer a écrit :
> 
> I think the basic idea makes a lot of sense, i.e. have a generation that is 
> never collected.  An alternative way to implement it would be to have an 
> extra generation, e.g. rather than just 0, 1, 2 also have generation 3.  The 
> collection would by default never collect generation 3.  Generation 4 would 
> be equivalent to the frozen generation.  You could still force collection by 
> calling gc.collect(3).

API-wise it would sound better to have a separate gc.collect_frozen()...

Though I think a gc.unfreeze() that moves the frozen generation into the
oldest non-frozen generation would be useful too, at least for testing
and experimentation.

> I think issue 3110 (https://bugs.python.org/issue31105) is also related.  The 
> current GC thresholds are not very good.  I've look at what Go does and the 
> GC collection is based on a relative increase in memory usage.  Python could 
> do perhaps something similar.  The accounting of actual bytes allocated and 
> deallocated is tricky because the *_Del/Free functions don't actually know 
> how much memory is being freed, at least not in a simple way.

Yeah... It's worse than that.  Take for example a bytearray object.  The
basic object (the PyByteArrayObject structure) is quite small.  But it
also has a separately-allocated payload that is deleted whenever
tp_dealloc is called.  The GC isn't aware of that payload.  Worse, the
payload can (and will) change size during the object's lifetime, without
the GC's knowledge about it ever being updated. (*)

IMHO, the only reliable way to use memory footprint to drive the GC
heuristic would be to force all allocations into our own allocator, and
reconcile the GC with that allocator (instead of having the GC be its
own separate thing as is the case nowadays).

(*) And let's not talk about hairier cases, such as having multiple
memoryviews over the same very large object...

PS: every heuristic has its flaws.  As I noted on python-(dev|ideas),
full GC runtimes such as most Java implementations are well-known for
requiring careful tuning of GC parameters for "non-usual" workloads.  At
least reference counting makes CPython more robust in many cases.

--

___
Python tracker 

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



[issue20827] IDLE : Display function argument list in ClassBrowser

2017-09-25 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Having fixed the nested functions and classes issue, and thought some more, I 
have two other concerns with adding signatures in the browser, and a different 
solution.

1. Time: When requested, the browser window comes up immediately with the 
module node.  There is a noticeable delay before the top level items are 
displayed, and it is longer than before.  Since pyclbr was already patched to 
deliver the information on nested items, this puzzles me, and I want to 
investigate the cause before possible slowing display even longer.

2. Space: For browser tree items, base 'Tree' is expanded to 
'idlelib.tree.Tree'.  With one base, this will usually not an issue.  With 
multiple bases, it could be, in the sense of making the single line too long.  
Signatures, like calls, can well be too long for a single line.

Alternatives:

1. Module Browser opens the file.  Single clicking a line in the browser moves 
the selection highlight in the browser.  Double clicking a line expands or 
contract the node if it is expandedable, and it highlights the corresponding 
line in the editor. So the new feature is not *necessary* for a user to get the 
information.

But we can make it easier.  First, move the editor highlight when moving the 
browser hightlight.  Second, move both highlights with the Up and Down keys 
(instead of just scrolling.  Expand/contract with Right and Left keys.  Third, 
with a bit more work, the entire header could be highlighted.  Fourth, position 
browser box and editor side-by-side with tops aligned, instead of overlapping.  
(Note: the positioning would be automatic if IDLE had side-by-side tabbed 
panes.)

2. Signatures might be displayed in a pop-up box.  But I like 1. above better.

So I am inclined to reject adding to the Python-code browser in favor of 
improving the coordination between browser and editor.

If we ever add the ability to browse imported modules by introspection, then 
making signatures, *and* docstrings, would be needed -- and easy.  (This would 
be be aimed at, but not limited to, non-Python coded modules.)

--

___
Python tracker 

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



[issue31571] Redundand information on Doc/reference/lexical_analysis.rst

2017-09-25 Thread Guido van Rossum

Guido van Rossum added the comment:

That's *really* old. Please clean up as you see fit!

On Sep 24, 2017 10:33 PM, "Serhiy Storchaka"  wrote:

Serhiy Storchaka added the comment:

Guido, in 60f2f0cf8e10c94693dfea8937b7feabeffe5744 you added the phrase
"Note that numeric literals do not include a sign; ..." in the "Numeric
literals" section. Did you mean moving it from the "Floating point
literals" section or creating a duplicate?

--

___
Python tracker 

___

--

___
Python tracker 

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



[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-25 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I like the idea of a gen 4 that never gets collected.  This would have been 
useful for the original problem that inspired me to add the `generation` 
argument to `gc.collect()`.  The nice thing about this, is just as you suggest: 
you could force a collection of gen 4 by `gc.collect(3)`.

It's unfortunate that you'd have to add a bit to handle this, but maybe you're 
right that we only really need three generations.

--

___
Python tracker 

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



[issue31578] Unexpected Floating Point Division Result

2017-09-25 Thread R. David Murray

R. David Murray added the comment:

In the absence of the appropriate __future__ import, the python2 division 
operator uses integer division.

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



[issue31558] gc.freeze() - an API to mark objects as uncollectable

2017-09-25 Thread Neil Schemenauer

Neil Schemenauer added the comment:

I think the basic idea makes a lot of sense, i.e. have a generation that is 
never collected.  An alternative way to implement it would be to have an extra 
generation, e.g. rather than just 0, 1, 2 also have generation 3.  The 
collection would by default never collect generation 3.  Generation 4 would be 
equivalent to the frozen generation.  You could still force collection by 
calling gc.collect(3).  Whether that generation should be collected on shutdown 
would still be a question.

If this gets implemented, it will impact the memory bitmap based GC idea I have 
been prototyping.  Currently I am thinking of using two bits for each small GC 
object.  The bits would mean: 00 - untracked, 01 - gen 0, 10 - gen 1, 11 - gen 
2.  With the introduction of a frozen generation, I would have to use another 
bit I think.

Another thought is maybe we don't actually need 3 generations as they are 
currently used.  We could have gen 0 which is collected frequently and gen 1 
that is collected rarely.  The frozen objects could go into gen 2 which are not 
automatically collected or have a user adjustable collection frequency.  
Collection of gen 1 would not automatically move objects into gen 2.

I think issue 3110 (https://bugs.python.org/issue31105) is also related.  The 
current GC thresholds are not very good.  I've look at what Go does and the GC 
collection is based on a relative increase in memory usage.  Python could do 
perhaps something similar.  The accounting of actual bytes allocated and 
deallocated is tricky because the *_Del/Free functions don't actually know how 
much memory is being freed, at least not in a simple way.

--

___
Python tracker 

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



[issue31578] Unexpected Floating Point Division Result

2017-09-25 Thread hw

New submission from hw:

To reproduce:
>>> 480/1000/13.0
Actual result: 0.0

Expected result: 0.03692307692307692
Adding the zero decimal to any other combinations of the numbers produces the 
expected floating point result.

Working as expected in Python 3

--
components: Interpreter Core
messages: 302966
nosy: Hw
priority: normal
severity: normal
status: open
title: Unexpected Floating Point Division Result
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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 4:30 AM, Antoon Pardon
 wrote:
> On 25-09-17 20:01, Chris Angelico wrote:
>> On Tue, Sep 26, 2017 at 3:54 AM, Antoon Pardon
>>  wrote:
>>> On 25-09-17 19:31, Chris Angelico wrote:
 If by "identity" you mean the integer values returned by id(), then
 nope, you're still wrong - there is no mapping from identities to
 values. There is a mapping from name to object/value, and from an
 object, you can determine its identity. If you like, there's a mapping
 from values to identities, but not the other way around.
>>>
>>> I'm describing this at a conceptual level.
>>
>> At what conceptual level are the identities an in-between state
>> instead of being something you see from the object?
>>
 Unless, of course, you can find something in the Python documentation
 that supports this two-step indirection?
>>>
>>> The fact that the Python documentation describes its sematics differently
>>> doesn't contradict that this is a useful model.
>>
>> You need *some* support for your assertion that there are pointers,
>> and you have absolutely none.
>
> I think you have me confused with Marko Rauhamaa. He makes an assertion
> about pointers. I don't.

My bad. It sounded like you were agreeing with Marko, and arguing the
same assertion.

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


[issue31569] inconsistent case of PCbuild/ directory

2017-09-25 Thread Steve Dower

Changes by Steve Dower :


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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 20:01, Chris Angelico wrote:
> On Tue, Sep 26, 2017 at 3:54 AM, Antoon Pardon
>  wrote:
>> On 25-09-17 19:31, Chris Angelico wrote:
>>> If by "identity" you mean the integer values returned by id(), then
>>> nope, you're still wrong - there is no mapping from identities to
>>> values. There is a mapping from name to object/value, and from an
>>> object, you can determine its identity. If you like, there's a mapping
>>> from values to identities, but not the other way around.
>>
>> I'm describing this at a conceptual level.
> 
> At what conceptual level are the identities an in-between state
> instead of being something you see from the object?
> 
>>> Unless, of course, you can find something in the Python documentation
>>> that supports this two-step indirection?
>>
>> The fact that the Python documentation describes its sematics differently
>> doesn't contradict that this is a useful model.
> 
> You need *some* support for your assertion that there are pointers,
> and you have absolutely none.

I think you have me confused with Marko Rauhamaa. He makes an assertion
about pointers. I don't.

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


Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Rhodri James

On 25/09/17 15:26, Marko Rauhamaa wrote:

Chris Angelico :


On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa  wrote:

In Python, all expressions evaluate pointers.


And that's an assertion that isn't backed by anything in the Python
specification. Where do you get that all Python expressions are
pointers?


That's not what I said. I said all expressions *evaluate to* pointers.


This may well be true in particular implementations, but it is an 
implementation detail so Chris' point still stands.  Another 
implementation could evaluate expressions to indices (as BCPL used to 
treat its globals), pieces of string or cheese, who knows?



As for the specification, it doesn't make use of the word "pointer:"


There's a reason for that...


The (English) expression:

The name is bound to the object.

is just another way of saying:

A pointer to the object is stored in the variable.


It really isn't.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Call by binding [was re: [Tutor] beginning to code]

2017-09-25 Thread ROGER GRAYDON CHRISTMAN
I would claim that these two paragraphs do not agree.

What is stored in the variable in Pascal?

In declared variables and value parameters, the value itself.
Let's just temporarily stipulate that for reference parameters
and pointer variables actually store a pointer to the object.

Where is it recorded whether this is a pointer to an integer
or a float or a character or a thingamajig?

Neither in the value nor the assumed pointer to the variable.
In Pascal (and most compiled languages) that value type
is maintained separately by the compiler, and then discarded
in the compiled code.

In the case of Python, the 'pointer' you refer to also has
no type information.  Instead, the type of the value is
frequently inferred at run-time, based on additional
information stored with the value.   There is no equivalent
information available at run-time in Pascal.

Now, when you say 'Python's assignment semantics
are wholly contained by those of Pascal', please show me
the equivalent Pascal code to mimic the following
(and not by defining a brand new complex object type
in Pascal, since I am not doing so in Python).

x = 5
x = 'abc'

I think the larger discussion was about value and reference parameters.
Yes you can do both of those in Pascal.
But if you were stuck with just those two choices,
which applies to this function definition?

def add_to_self(arg):
   arg += arg
x = 'abc'
add_to_self(x)
# now x = 'abcabc'
x = 5
add_to_self(x)
# x is still 5

is 'arg' a value parameter or a reference parameter?
Can you replicate this behavior in Pascal without any if statement,
since, as you say, the semantics are wholly contained by
those of Pascal (aside from the += operator itself not
appearing in the Pascal language)

Roger Christman
Pennsylvania State Universtiy

On Mon, Sep 25, 2017 12:00 PM, python-list@python.org wrote:
>
   A pointer to the object is stored in the variable.
>
>Of course, I'm using terminology that is not conventional in Python
>circles. However, I'm doing it to demonstrate that there's nothing
>particularly different between Python's assignment semantics and those
>of, say, Pascal. Python's assignment semantics are wholly contained by
>those of Pascal.
>
>

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


Re: TypeError with map with no len()

2017-09-25 Thread john polo

On 9/25/2017 12:03 PM, Paul Moore wrote:

You're using Python 3, and I suspect that you're working from
instructions that assume Python 2. In Python 3, the result of map() is
a generator, not a list (which is what Python 2's map returned). In
order to get an actual list (which appears to be what you need for
your plot call) you just need to call the list constructor:

y1 = list(map(math.sin, math.pi*t))

Although given that you're using numpy, it may be that there's a more
idiomatic numpy way of doing this. I'm not a numpy expert though, so I
can't help on that.

Paul

Paul,
Thank you very much for the explanation.

best regards,
John
--
https://mail.python.org/mailman/listinfo/python-list


[issue31574] Add dtrace hook for importlib

2017-09-25 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 19:31, Chris Angelico wrote:
> On Tue, Sep 26, 2017 at 3:04 AM, Antoon Pardon
>  wrote:
>> On 25-09-17 16:29, Marko Rauhamaa wrote:
>>> Antoon Pardon :
>>>
 Op 25-09-17 om 15:16 schreef Marko Rauhamaa:
> No, I'm not. I'm talking about pointers in the abstract sense, both in
> case of Python and Pascal. Neither language gives any hint as to the
> physical nature of the pointer.

 Yes you are. Python doesn't have pointers at the language level. So if
 you start talking pointers you are talking about implementations
 however abstract.
>>>
>>> It is difficult to say what is the "native" Python term for the thing.
>>> "Binding," maybe? The language spec fails to give it a name.
>>>
>>> However, when comparing different languages, you had better unify the
>>> terminology or you'll be confused by purely terminological issues.
>>
>> Fine, you have two mappings, a mapping from names to identities and a
>> mapping from identities to values. In languages like C, Pascal, ...
>> an assignment changes the mapping between the identities and the
>> values. In languages like Python, Smalltalk, ... an assignment
>> changes the mapping between the names and the identities.
> 
> If by "identity" you mean the integer values returned by id(), then
> nope, you're still wrong - there is no mapping from identities to
> values. There is a mapping from name to object/value, and from an
> object, you can determine its identity. If you like, there's a mapping
> from values to identities, but not the other way around.

I'm describing this at a conceptual level.

> Unless, of course, you can find something in the Python documentation
> that supports this two-step indirection?

The fact that the Python documentation describes its sematics differently
doesn't contradict that this is a useful model.

-- 
Antoon Pardon.


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


[issue22140] "python-config --includes" returns a wrong path (double prefix)

2017-09-25 Thread Michał Górny

Changes by Michał Górny :


--
nosy: +mgorny

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 12:26 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> On Mon, Sep 25, 2017 at 7:41 PM, Marko Rauhamaa  wrote:
>>> In Python, all expressions evaluate pointers.
>>
>> And that's an assertion that isn't backed by anything in the Python
>> specification. Where do you get that all Python expressions are
>> pointers?
>
> That's not what I said. I said all expressions *evaluate to* pointers.

Sorry, that was my bad in the terminology. But where do you get that
all Python expressions evaluate to pointers?

> As for the specification, it doesn't make use of the word "pointer:"
>
>https://docs.python.org/3/reference/simple_stmts.html#assignme
>nt-statements>
>
> Instead, it uses (English) expressions like:
>
>is bound to the object
>is rebound
>
> when talking about "names" (aka variables).

Yeah exactly. It doesn't say anything about them being pointers.
Because they aren't.

> It also uses circular definitions when talking about dicts and lists:
>
>That object is then asked to assign the assigned object to the given
>attribute
>
>the sequence is asked to assign the assigned object to its item with
>that index.

Technically, that's correct. When you use a statement like:

foo[bar] = quux

what it does is ask the object *foo* to assign *quux* to the item
represented by *bar*.

> The (English) expression:
>
>The name is bound to the object.
>
> is just another way of saying:
>
>A pointer to the object is stored in the variable.

Where does this come from? If the name "Rosuav" refers to me, does
that mean, in English, that there is a pointer to me stored in the
variable named "Rosuav"? English isn't implemented in C or Pascal.

> Of course, I'm using terminology that is not conventional in Python
> circles. However, I'm doing it to demonstrate that there's nothing
> particularly different between Python's assignment semantics and those
> of, say, Pascal. Python's assignment semantics are wholly contained by
> those of Pascal.

As long as you start by defining everything in terms of Pascal, yes,
you can then prove that everything is contained in Pascal semantics.
But you have yet to show how you can jump from "name binding" to
"pointer" using anything from the Python documentation.

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


Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 2:52 AM, Tim Chase
 wrote:
> On 2017-09-26 02:29, Steve D'Aprano wrote:
>> x = Parrot(name="Polly")
>>
>> (using Python syntax for simplicity) and somebody tries to tell me
>> that the value of x is anything but a Parrot instance named "Polly",
>
> So this is a Polly-morphic constructor?

Steve actually said:

> Regardless of whether I'm using Python, Swift, Java, C, Pascal or Scheme, if I
> write something like:

So it's actually Polly-glot.

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


Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Chris Angelico
On Tue, Sep 26, 2017 at 3:04 AM, Antoon Pardon
 wrote:
> On 25-09-17 16:29, Marko Rauhamaa wrote:
>> Antoon Pardon :
>>
>>> Op 25-09-17 om 15:16 schreef Marko Rauhamaa:
 No, I'm not. I'm talking about pointers in the abstract sense, both in
 case of Python and Pascal. Neither language gives any hint as to the
 physical nature of the pointer.
>>>
>>> Yes you are. Python doesn't have pointers at the language level. So if
>>> you start talking pointers you are talking about implementations
>>> however abstract.
>>
>> It is difficult to say what is the "native" Python term for the thing.
>> "Binding," maybe? The language spec fails to give it a name.
>>
>> However, when comparing different languages, you had better unify the
>> terminology or you'll be confused by purely terminological issues.
>
> Fine, you have two mappings, a mapping from names to identities and a
> mapping from identities to values. In languages like C, Pascal, ...
> an assignment changes the mapping between the identities and the
> values. In languages like Python, Smalltalk, ... an assignment
> changes the mapping between the names and the identities.

If by "identity" you mean the integer values returned by id(), then
nope, you're still wrong - there is no mapping from identities to
values. There is a mapping from name to object/value, and from an
object, you can determine its identity. If you like, there's a mapping
from values to identities, but not the other way around.

Unless, of course, you can find something in the Python documentation
that supports this two-step indirection?

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


[issue31423] Error while building PDF documentation

2017-09-25 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Sorry!! Yesterday morning I received 50+ emails all about document download 
page is 404. Reading those again, turns out these are older emails from a week 
before, somehow just showing up in my mailbox.
I think everything is good here. :)

Thanks!

--

___
Python tracker 

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



Re: [Tutor] beginning to code

2017-09-25 Thread Antoon Pardon
On 25-09-17 15:37, Ned Batchelder wrote:
> On 9/25/17 9:15 AM, Antoon Pardon wrote:
>> Op 25-09-17 om 14:53 schreef Ned Batchelder:
>>> On 9/25/17 8:24 AM, Steve D'Aprano wrote:
 On Mon, 25 Sep 2017 08:05 pm, Antoon Pardon wrote:

> Pass by reference doesn't imply being able to
> write a swap function.
 Really. Do you have a counter-example?


> A swap function as possible in pascal requires two conditions.
>
> 1) Pass by reference
> 2) Copy-over assignment.
 I don't know what you think "copy-over assignment" means, but none of
 DuckDuckGo, Google, Bing or Yahoo finds that term except in your post.




>>> Would we be able to end these interminable debates if we just agree
>>> that we all know how it works, and it isn't important to come up with
>>> a simple name for what it is?
>> I'm not sure that Steve knows how it works. When he denies that the 
>> assignment is
>> an alias operation in Python that casts an important doubt.
> 
> I can assure you that Steve knows how it works. Again, the disagreement is 
> almost certainly over the semantics of the word "alias."

Sorry, what he wrote contradicts that. Maybe he was just really confused
at that moment, but it still needed correction. If the assignment is
an alias operator then after the statements

a = 1
b = a
b = 2

a is not 2. He is not using the assignment as an alias operation in
that last assignment but as a copy operation that will overwrite the
value that b refers to.

>>> It seems clear to me that "value" and "reference" are wildly vague
>>> terms, used slightly differently by each language, and by different
>>> people even in the same language if they have different perspectives.
>> Well in that case and considering your remark above, maybe the residents
>> shouldn't be so eager to deny to newbees that python has call by reference.
> 
> You're still trying to get people to agree to a label like "call by 
> reference."  This is where the disagreement comes from.
> 
No I'm trying to make them stop disagreeing to a label like call by reference.
They may personnaly prefer an other label but this is not about them, this
is about the newbe. And if someone can explain the newbe what is going on
in terms of "call by reference", something the newbe understands, then that
is what is important and those that prefer an other lable should at that
moment not interfere and possibly cause confusion.

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


[issue31574] Add dtrace hook for importlib

2017-09-25 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +lukasz.langa

___
Python tracker 

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



Re: Call by binding [was Re: [Tutor] beginning to code]

2017-09-25 Thread Antoon Pardon
On 25-09-17 16:29, Marko Rauhamaa wrote:
> Antoon Pardon :
> 
>> Op 25-09-17 om 15:16 schreef Marko Rauhamaa:
>>> No, I'm not. I'm talking about pointers in the abstract sense, both in
>>> case of Python and Pascal. Neither language gives any hint as to the
>>> physical nature of the pointer.
>>
>> Yes you are. Python doesn't have pointers at the language level. So if
>> you start talking pointers you are talking about implementations
>> however abstract.
> 
> It is difficult to say what is the "native" Python term for the thing.
> "Binding," maybe? The language spec fails to give it a name.
> 
> However, when comparing different languages, you had better unify the
> terminology or you'll be confused by purely terminological issues.

Fine, you have two mappings, a mapping from names to identities and a
mapping from identities to values. In languages like C, Pascal, ...
an assignment changes the mapping between the identities and the
values. In languages like Python, Smalltalk, ... an assignment
changes the mapping between the names and the identities.

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


Re: TypeError with map with no len()

2017-09-25 Thread Paul Moore
You're using Python 3, and I suspect that you're working from
instructions that assume Python 2. In Python 3, the result of map() is
a generator, not a list (which is what Python 2's map returned). In
order to get an actual list (which appears to be what you need for
your plot call) you just need to call the list constructor:

y1 = list(map(math.sin, math.pi*t))

Although given that you're using numpy, it may be that there's a more
idiomatic numpy way of doing this. I'm not a numpy expert though, so I
can't help on that.

Paul

On 25 September 2017 at 17:44, john polo  wrote:
> Python List,
>
> I am trying to make practice data for plotting purposes. I am using Python
> 3.6. The instructions I have are
>
> import matplotlib.pyplot as plt
> import math
> import numpy as np
> t = np.arange(0, 2.5, 0.1)
> y1 = map(math.sin, math.pi*t)
> plt.plot(t,y1)
>
> However, at this point, I get a TypeError that says
>
> object of type 'map' has no len()
>
> In [6]: t
> Out[6]:
> array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7, 0.8,  0.9,  1. ,
> 1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8, 1.9,  2. ,  2.1,
> 2.2,  2.3,  2.4])
> In [7]: y1
> Out[7]: 
> In [8]: math.pi*t
> Out[8]:
> array([ 0.,  0.31415927,  0.62831853,  0.9424778 , 1.25663706,
> 1.57079633,  1.88495559,  2.19911486,  2.51327412, 2.82743339,
> 3.14159265,  3.45575192,  3.76991118,  4.08407045, 4.39822972,
> 4.71238898,  5.02654825,  5.34070751,  5.65486678, 5.96902604,
> 6.28318531,  6.59734457,  6.91150384,  7.2256631 , 7.53982237])
>
> At the start of creating y1, it appears there is an array to iterate through
> for the math.sin function used in map(), but y1 doesn't appear to be saving
> any values. I expected y1 to hold a math.sin() output for each item in
> math.pi*t, but it appears to be empty. Am I misunderstanding map()? Is there
> something else I should be doing instead to populate y1?
>
>
> John
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TypeError with map with no len()

2017-09-25 Thread Grant Edwards
On 2017-09-25, john polo  wrote:
> Python List,
>
> I am trying to make practice data for plotting purposes. I am using 
> Python 3.6. The instructions I have are
>
> import matplotlib.pyplot as plt
> import math
> import numpy as np
> t = np.arange(0, 2.5, 0.1)
> y1 = map(math.sin, math.pi*t)
> plt.plot(t,y1)
>
> However, at this point, I get a TypeError that says
>
> object of type 'map' has no len()

you probably need to convert y1 from a 'map' object (a type of an
iterator) to an array.

y1 = map(math.sin, math.pi*t)
y1 = np.fromiter(y1, float)

-- 
Grant Edwards   grant.b.edwardsYow! Will this never-ending
  at   series of PLEASURABLE
  gmail.comEVENTS never cease?

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


Re: TypeError with map with no len()

2017-09-25 Thread Peter Otten
john polo wrote:

> Python List,
> 
> I am trying to make practice data for plotting purposes. I am using
> Python 3.6. The instructions I have are
> 
> import matplotlib.pyplot as plt
> import math
> import numpy as np
> t = np.arange(0, 2.5, 0.1)
> y1 = map(math.sin, math.pi*t)
> plt.plot(t,y1)
> 
> However, at this point, I get a TypeError that says
> 
> object of type 'map' has no len()
> 
> In [6]: t
> Out[6]:
> array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7, 0.8,  0.9,  1. ,
>  1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8, 1.9,  2. ,  2.1,
>  2.2,  2.3,  2.4])
> In [7]: y1
> Out[7]: 
> In [8]: math.pi*t
> Out[8]:
> array([ 0.,  0.31415927,  0.62831853,  0.9424778 , 1.25663706,
>  1.57079633,  1.88495559,  2.19911486,  2.51327412, 2.82743339,
>  3.14159265,  3.45575192,  3.76991118,  4.08407045, 4.39822972,
>  4.71238898,  5.02654825,  5.34070751,  5.65486678, 5.96902604,
>  6.28318531,  6.59734457,  6.91150384,  7.2256631 , 7.53982237])
> 
> At the start of creating y1, it appears there is an array to iterate
> through for the math.sin function used in map(), but y1 doesn't appear
> to be saving any values. I expected y1 to hold a math.sin() output for
> each item in math.pi*t, but it appears to be empty. Am I
> misunderstanding map()? Is there something else I should be doing
> instead to populate y1?

map() is "lazy" in Python 3, i. e. it calculates the values when you iterate 
over it, not before:

>>> def noisy_square(x):
... print("calculating {0} * {0}".format(x))
... return x * x
... 
>>> squares = map(noisy_square, [1, 3, 2])
>>> for y in squares:
... print(y)
... 
calculating 1 * 1
1
calculating 3 * 3
9
calculating 2 * 2
4

While you can convert y1 to a list with

y1 = list(y1)

the better approach is to use numpy:

y1 = np.sin(t * math.pi)

Now y1 is a numpy.array and can be fed to pyplot.plot() directly.

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


Re: TypeError with map with no len()

2017-09-25 Thread Ned Batchelder

On 9/25/17 12:44 PM, john polo wrote:

Python List,

I am trying to make practice data for plotting purposes. I am using 
Python 3.6. The instructions I have are


import matplotlib.pyplot as plt
import math
import numpy as np
t = np.arange(0, 2.5, 0.1)
y1 = map(math.sin, math.pi*t)
plt.plot(t,y1)

However, at this point, I get a TypeError that says

object of type 'map' has no len()

In [6]: t
Out[6]:
array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7, 0.8,  0.9, 1. ,
    1.1,  1.2,  1.3,  1.4,  1.5,  1.6,  1.7,  1.8, 1.9,  2. , 2.1,
    2.2,  2.3,  2.4])
In [7]: y1
Out[7]: 
In [8]: math.pi*t
Out[8]:
array([ 0.    ,  0.31415927,  0.62831853,  0.9424778 , 1.25663706,
    1.57079633,  1.88495559,  2.19911486,  2.51327412, 2.82743339,
    3.14159265,  3.45575192,  3.76991118,  4.08407045, 4.39822972,
    4.71238898,  5.02654825,  5.34070751,  5.65486678, 5.96902604,
    6.28318531,  6.59734457,  6.91150384,  7.2256631 , 7.53982237])

At the start of creating y1, it appears there is an array to iterate 
through for the math.sin function used in map(), but y1 doesn't appear 
to be saving any values. I expected y1 to hold a math.sin() output for 
each item in math.pi*t, but it appears to be empty. Am I 
misunderstanding map()? Is there something else I should be doing 
instead to populate y1?


In Python 2, map() produced a list. In Python 3, it returns a lazy 
iterator instead.  You can run the iterator with list():


    y1 = list(map(math.sin, math.pi*t))

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


Re: Grumpy-pants spoil-sport [was Re: [Tutor] beginning to code]

2017-09-25 Thread Tim Chase
On 2017-09-26 02:29, Steve D'Aprano wrote:
> x = Parrot(name="Polly")
> 
> (using Python syntax for simplicity) and somebody tries to tell me
> that the value of x is anything but a Parrot instance named "Polly",

So this is a Polly-morphic constructor?

-tkc


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


calling __del__ [was Re: [Tutor] beginning to code]

2017-09-25 Thread Steve D'Aprano
On Sun, 24 Sep 2017 09:13 am, Bill wrote:

[context snipped for brevity]
> I agree (I was a bit hasty in my choice of words); but if they didn't
> "have" these references, it would be difficult, though not impossible,
> to refer to them.   Also keep in mind that the garbage collector keeps
> track, generally, of how many there are for each object!   So from the
> gc's point of view, objects (definitely) "have" references.

Unfortunately there's some ambiguity in the English word "have". Webster's
dictionary (1913) lists at least twelve distinct meanings. WordNet lists
nineteen.

If we consider "have" in the sense of possession, then objects don't have
references. If they did, you could ask an object what names they were known as,
and they could tell you:

# this doesn't work!
a = 99
b = c = a
a.names()
# returns ['a', 'b', 'c']


You can't do that in Python.

But in another sense, ironically one which isn't listed by either Webster's or
WordNet, objects do have references. The closest meaning I see is:

7: have a personal or business relationship with someone; "have
   a postdoc"; "have an assistant"; "have a lover"

Its not a *personal* or *business* relationship, but there is a relationship
between the reference and the object.


> Next, what will Egg.__del__() do? : )

For the record, you shouldn't call dunder ("Double UNDERscore") methods directly
unless you know what you're doing. You should consider them for Python's use
only, unless explicitly told differently.

Calling __del__ directly is *especially* fraught with problems. It does not
delete the object. It just runs the destructor, but leaving the object alive
but in a potentially unusable state.


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


[issue31475] Bug in argparse - not supporting utf8

2017-09-25 Thread Josh Rosenberg

Josh Rosenberg added the comment:

Based on the OP's patch, it looks like they have a problem where they have 
non-ASCII text in their output strings (either due to using non-ASCII switches, 
or using non-ASCII help documentation), but sys.stdout/sys.stderr are 
configured for some encoding that doesn't support said characters, so they're 
getting exceptions when the help message is sent to the screen automatically 
(e.g. by running with --help).

It's only sort of a bug in Python: Fundamentally, the problem is a script that 
assumes arbitrary Unicode support being run under a locale that doesn't provide 
it. The solution provided is bad though: It shouldn't be trying to force UTF8 
output regardless of locale.

A simple repro, at least on Linux-like systems, would be to run Python with 
LANG=C (and no other LC variables set), then do:

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-f', help=chr(233)) # help is 'é'
parser.print_help()

While the patch as given is wrong (with the exception of Windows weirdness, 
blithely ignoring/second-guessing the locale is a terrible idea), it's not a 
terrible idea to fix this in some way; if nothing else, it might make sense to 
have some fallback approach when the exception is raised (e.g. encoding the 
output with errors='ignore' or the like) so running scriptname.py --help at 
least provides *some* output even with incompatible locales, rather than dying 
with an error in the help message handling code itself.

--
nosy: +josh.r
status: pending -> open

___
Python tracker 

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



  1   2   3   >