[issue25051] 'compile' refuses BOM.

2015-09-10 Thread Piotr

New submission from Piotr:

Similar to Issue 679880

>>> compile(open("bom3.py").read(), "bom3.py", 'exec')
Traceback (most recent call last):
  File "", line 1, in 
  File "bom3.py", line 1
# coding: utf-8
  ^
SyntaxError: invalid character in identifier

--
components: Unicode
files: bom3.py
messages: 250357
nosy: Karulis, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: 'compile' refuses BOM.
type: compile error
versions: Python 3.4
Added file: http://bugs.python.org/file40423/bom3.py

___
Python tracker 

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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

open() uses locale encoding by default. You should specify correct encoding 
explicitly for portability and unambiguity.

>>> compile(open("bom3.py", encoding="utf-8-sig").read(), "bom3.py", 'exec')
 at 0xb707a7a0, file "bom3.py", line 2>

--
nosy: +serhiy.storchaka
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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

open() uses locale encoding by default. You should specify correct encoding 
explicitly for portability and unambiguity.

>>> compile(open("bom3.py", encoding="utf-8-sig").read(), "bom3.py", 'exec')
 at 0xb707a7a0, file "bom3.py", line 2>

--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread Antoon Pardon
Op 09-09-15 om 19:55 schreef Steven D'Aprano:
> In fairness to the C creators, I'm sure that nobody back in the early
> seventies imagined that malware and security vulnerabilities would be as
> widespread as they have become. But still, the fundamental decisions made
> by C are lousy. Assignment is an expression?

What is wrong with that?

-- 
Antoon Pardon


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


Re: Getting response over logging socket

2015-09-10 Thread dieter
Larry Martell  writes:

> I have an app that uses the logging package with a SocketHandler to
> send messages. Now I've been asked to change it so that it can receive
> a response for each log message sent. It appears there is no way to do
> this with logging package. Is that true?

You are right.


There are different connotations associated with the term "logging".

One connatation is to inform related parties about events of potential
interest in the current execution. The parties may or may not be
interested. It is of no importance for the current execution whether
some party has processed the event. This is the model, the Python
standard handlers adhere to.

Another connatation is used for transaction management. Those
systems often use a sequentially written "log" and some operations
must only proceed after this "log" has definitely been updated.
For this type of "logging", you need a feedback that the logging
operation has completed successfully.

The Python logging targets the first connatation. For the second
connotation, there are likely better approaches than the standard
Python logging framework (look for "transaction", "transactional").


> Can I not receive data over a
> socket used in a logging handler?

Almost surely, you can develop your own logging handler which
performs a handshake with the logging target. Note that
the logging destination, too, will need to be modified for this.

I assume, however, there will be better approaches that using the
Python logging framework -- e.g. transactional safe message queues.

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


Question about import

2015-09-10 Thread Frank Millman

Hi all

My project comprises a number of modules, split into packages. Modules 
frequently need to access the contents of other modules, in the same or in a 
different package. I am getting better at it, but I still occasionally bump 
my head against circular imports, and have to fiddle around until it settles 
down again. Not ideal, I know.


I have just noticed something odd, and I wondered if it might provide a 
solution, or if it is a dangerous sidetrack. Here is a simple example -


/test
| start.py
 /a
 | aa.py
 /b
 | bb.py

start.py
   import a.aa
   import b.bb
   a.aa.aaa()
   b.bb.bbb()

aa.py
   import b
   def aaa():
   print('in aaa')
   b.bb.()
   def ():
   print('in ')

bb.py
   import a
   def bbb():
   print('in bbb')
   a.aa.()
   def ():
   print('in ')

c:\test>start.py
in aaa
in 
in bbb
in 

The surprising thing is that, within aa.py, I just have to say 'import b', 
and I can access 'b.bb.', and the same applies to 'bb.py'.


That makes me wonder if, in my project, I can import all modules inside 
'start.py', and then just use 'import package_name' inside each module?


Another question - I thought that, because aa.py and bb.py are in different 
sub-directories, I would have to set them up as packages by adding 
'__init__.py' to each one, but it works fine without that. What am I 
missing?


I am using python 3.4.

Any comments appreciated.

Frank Millman


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


Re: Silly question about pip

2015-09-10 Thread breamoreboy
On Wednesday, September 9, 2015 at 10:06:31 AM UTC+1, wxjm...@gmail.com wrote:
> Le mardi 8 septembre 2015 21:02:31 UTC+2, wxjm...@gmail.com a écrit :
> > Le mardi 8 septembre 2015 20:18:20 UTC+2, Irmen de Jong a écrit :
> > > On 8-9-2015 17:54, wxjmfa...@gmail.com wrote:
> > > > win7 / py433
> > > > 
> > > > How to downgrade from the latest pip (7.1.2) to
> > > > the previous one?
> > > > I'm sorry, I do not remember the numerous msgs
> > > > I saw when updating. (Yesterday)
> > > > 
> > > > (I'm serious)
> > > > 
> > > > Now, what?
> > > > 
> > > 
> > > I think:
> > > 
> > > $ pip install --upgrade pip==7.0.0
> > > 
> > > 
> > > would do the trick, where you substitute the required version number for 
> > > 7.0.0.
> > > 
> > > 
> > > Irmen
> > 
> > Addendum (your question)
> > 
> > > pip install --upgrade pip
> > 
> > which probably selects the latest version
> 
> 
> ---
> > pip install --upgrade pip==6.0.8
> 
> is indeed a valid command
> except I'm seeing the same previous mess.

The minor snag is we're not seeing your mess.  However as I'm getting really 
good vibes from my crystal ball today, I'd guess that you're getting a known 
problem on Windows with a permissions error, but the pip upgrade has actually 
worked fine.  Am I close?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can't use Python Launcher on Windows after update to 3.5

2015-09-10 Thread Tim Golden
On 10/09/2015 00:52, Mark Lawrence wrote:
> I've installed 3.5 for all users so it's in C:\Program Files
> 
> From
> https://docs.python.org/3.5/using/windows.html#from-the-command-line it
> says "System-wide installations of Python 3.3 and later will put the
> launcher on your PATH. The launcher is compatible with all available
> versions of Python, so it does not matter which version is installed. To
> check that the launcher is available, execute the following command in
> Command Prompt:", but:-
> 
> C:\Users\Mark\Documents\MyPython>py -3.4
> 'py' is not recognized as an internal or external command,
> operable program or batch file.
> 
> Further running ftype shows nothing for Python, assoc just gives this
> .pyproj=VisualStudio.Launcher.pyproj.14.0.  Surely this is wrong?
> 
> Before I go to the bug tracker to raise an issue could somebody please
> confirm what I'm seeing, thanks.
> 

Well I've just installed 64-bit 3.5.0rc4 via the web installer (ie this:
https://www.python.org/ftp/python/3.5.0/python-3.5.0rc4-amd64-webinstall.exe)
onto a machine with 64-bit 3.4.2 already installed. I went for the
default install.

It all seems to be ok and py -3.4 --version gives  me "Python 3.4.2" as
expected. assoc/ftype both look ok. c:\windows\py.exe has the versions &
dates I expect.

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


Re: Python handles globals badly.

2015-09-10 Thread Marko Rauhamaa
Antoon Pardon :

> Op 09-09-15 om 19:55 schreef Steven D'Aprano:
>> In fairness to the C creators, I'm sure that nobody back in the early
>> seventies imagined that malware and security vulnerabilities would be
>> as widespread as they have become. But still, the fundamental
>> decisions made by C are lousy. Assignment is an expression?
>
> What is wrong with that?

C is an extremely strong language. However, I also think they made some
slightly regrettable choices, some of which later standards have
alleviated. One of my main issues with C has been the intentional
confusion between arrays and pointers. Also, the type notation is
clearly inferior to that of Pascal.

The greatest blessing C has bestowed upon programmers is the void
pointer. While C++ programmers (among others) have built a ridiculous
cathedral (templates) to capture the same universal notion, C
programmers just shrug their shoulders and store the reference in a void
pointer variable.


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


[issue24965] Implement PEP 498: Literal String Formatting

2015-09-10 Thread Eric V. Smith

Eric V. Smith added the comment:

I discussed it with Guido and added 'F' to the PEP.

--

___
Python tracker 

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



[issue25050] windows installer does not allow 32 and 64 installs side by side

2015-09-10 Thread Adam Groszer

New submission from Adam Groszer:

Installed with python-3.4.3.msi first, then wanted a 64bit side-by-side )of 
course in an other folder)

Wanted to install python-3.4.3.amd64.msi, the first thing this one did is 
removed the 32bit install :-(

--
components: Installation, Windows
messages: 250356
nosy: Adam.Groszer, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: windows installer does not allow 32 and 64 installs side by side
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue25049] Strange behavior under doctest: staticmethods have different __globals__

2015-09-10 Thread Jurjen N.E. Bos

New submission from Jurjen N.E. Bos:

I found a pretty obscure bug/documentation issue.
It only happens if you use global variables in static methods under doctest.
The thing is that this code fails under doctest, while anyone would expect it 
to work at first sight:

class foo:
@staticmethod
def bar():
"""
>>> GLOBAL = 5; foo.bar()
5
"""
print(GLOBAL)

The cause of the problem is that the static method has a __globals__ that for 
reasons beyond my understanding is not equal to the globals when run under 
doctest.
This might be a doctest bug, or there might be a reason for it that I don't 
get: than it must be documented, before it stupifies others.
The behaviour is the same under python 2 and 3.
The attached file shows all (written for Python 3, but can be trivially adapted 
for python 2), including the workaround.

--
components: Library (Lib)
files: t.py
messages: 250355
nosy: jneb
priority: normal
severity: normal
status: open
title: Strange behavior under doctest: staticmethods have different __globals__
type: enhancement
Added file: http://bugs.python.org/file40422/t.py

___
Python tracker 

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



[issue25052] Test

2015-09-10 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Just for testing if I can create a *new* issue.

--
messages: 250360
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Test

___
Python tracker 

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



numpy

2015-09-10 Thread chenc...@inhand.com.cn

hi:
   I have to use numpy package. My python runs on my embedded arm 
device. So, how do i cross compile numpy?

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


devpi-server-2.3.0: changed pypi caching, semantic versioning

2015-09-10 Thread holger krekel
devpi-server-2.3: more resilient pypi caching, semantic versioning


The devpi-server-2.3 release brings two important changes:

- We don't use the XMLRPC "changelog" interface of pypi.python.org
  anymore.  Instead devpi-server now re-checks with pypi every 30 minutes
  and will serve cached contents in between.  If pypi is not reachable
  and we still have cached contents we continue serving the cached content
  so that we can survive pypi outages.

- we switched to semantic versioning so that only major version number
  increases signal the need for an export/import cycle.  If you have
  a devpi-server-2.2.X installation you are not required to export/import.
  However, there has been a regression with the execnet-1.4.0 release
  which was fixed with the now current execnet-1.4.1 release.  If you
  have freshly setup devpi-server and used execnet-1.4.0 at that time
  you will need to do an export with execnet-1.4.0 and then import 
  with execnet-1.4.1 installed.

Note also that we released new micro releases of devpi-client and devpi-web
which are pure bugfixing releases.

For many more changes and fixes, please see the respective CHANGELOG of the
respective packages.

For docs and quickstart tutorials see http://doc.devpi.net

many thanks to Florian Schulze who any of the new features.  And special
thanks go to the two still unnamed companies who funded major parts of
the above work.

have fun,

holger krekel, merlinux GmbH


2.3.0 (2015-09-10)
--

- switched to semantic versioning. Only major revisions will ever require an
  export/import cycle.

- fix issue260: Log identical upload message on level "info"

- Log upload trigger message on level "warn"

- The PyPI changelog isn't watched for changes anymore.
  Instead we cache release data for 30 minutes, this can be adjusted with the
  ``--mirror-cache-expiry`` option.

- fix issue251: Require and validate the "X-DEVPI-SERIAL" from master in
  replica thread

- fix issue258: fix FileReplicationError representation for proper logging

- fix issue256: if a project removes all releases from pypi or the project is
  deleted on pypi, we get a 404 back. In that case we now return an empty list
  of releases instead of returning an UpstreamError.

- Change nginx template to serve HEAD in addition to GET requests of files
  directly instead of proxying to devpi-server

- make keyfs cache size configurable via "--keyfs-cache-size" option and
  increase the default size to improve performance for installations with many
  writes
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


[issue25043] document socket constants for Bluetooth

2015-09-10 Thread Tim Tisdall

Changes by Tim Tisdall :


Added file: http://bugs.python.org/file40426/bdaddr_35_1.patch

___
Python tracker 

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



textfile: copy between 2 keywords

2015-09-10 Thread Gerald
Hey,

is there a easy way to copy the content between 2 unique keywords in a .txt 
file?

example.txt

1, 2, 3, 4
#keyword1
3, 4, 5, 6
2, 3, 4, 5
#keyword2 
4, 5, 6 ,7


Thank you very much


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


Re: textfile: copy between 2 keywords

2015-09-10 Thread Steven D'Aprano
On Thu, 10 Sep 2015 09:18 pm, Gerald wrote:

> Hey,
> 
> is there a easy way to copy the content between 2 unique keywords in a
> .txt file?
> 
> example.txt
> 
> 1, 2, 3, 4
> #keyword1
> 3, 4, 5, 6
> 2, 3, 4, 5
> #keyword2
> 4, 5, 6 ,7
> 
> 
> Thank you very much


Copy in what sense? Write to another file, or just copy to memory?

Either way, your solution will look something like this:

* read each line from the input file, until you reach the first keyword;
* as soon as you see the first keyword, change to "copy mode" and start
copying lines in whatever way you feel is best;
* until you see the second keyword, then stop.


E.g.

with open("input.txt") as f:
# Skip lines as fast as possible.
for line in f:
if line == "START\n":
break
# Instead of copying, I'll just print the lines. That's sort of a copy.
for line in f:  # This will pick up where the previous for loop ended.
if line == "STOP\n":
break
print(line)
# If you like, you can just finish now.
# Or, we can read the rest of the lines.
for line in f:  # continue from just after the STOP keyword.
pass  # This is a waste of time...
print("Done!")



-- 
Steven

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


Re: Python handles globals badly.

2015-09-10 Thread Steven D'Aprano
On Thu, 10 Sep 2015 04:23 am, Emile van Sebille wrote:

> On 9/9/2015 10:55 AM, Steven D'Aprano wrote:
> 
>> (I wanted to link to the "Everything Is Broken" essay on The Medium, but
>> the page appears to be gone.
> 
> Is this it?
> http://www.sott.net/article/280956-Everything-is-broken-on-the-Internet

Looks like that's a mirror of the original, which is the one Laura found:

https://medium.com/message/everything-is-broken-81e5f33a24e1


Thanks guys. I don't know why I couldn't get to it earlier.



-- 
Steven

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


[issue25021] product_setstate() Out-of-bounds Read

2015-09-10 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Thanks, I'll get this committed and merged asap.

--

___
Python tracker 

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



[issue25044] bring BTPROTO_SCO inline with other Bluetooth protocols

2015-09-10 Thread Tim Tisdall

Tim Tisdall added the comment:

Yes, then any existing implementations will continue to work.

One sticky issue with all of this... there's no existing tests as per #7687 .

--

___
Python tracker 

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



[issue25021] product_setstate() Out-of-bounds Read

2015-09-10 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> kristjan.jonsson

___
Python tracker 

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



[issue24984] document AF_BLUETOOTH socket address formats

2015-09-10 Thread Tim Tisdall

Tim Tisdall added the comment:

oops.  yeah, I got my terminology wrong.  It accepts only a byte-string.

--

___
Python tracker 

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



[issue25054] Capturing start of line '^'

2015-09-10 Thread Matthew Barnett

Matthew Barnett added the comment:

After matching '^', it advances so that it won't find the same match again (and 
again and again...).

Unfortunately, that means that it sometimes misses some matches.

It's a known issue.

--

___
Python tracker 

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



[issue24272] PEP 484 docs

2015-09-10 Thread Berker Peksag

Changes by Berker Peksag :


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

___
Python tracker 

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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread eryksun

eryksun added the comment:

You're passing an already decoded string, so the BOM is treated as text. 
Instead open the file in binary mode, i.e. open("bom3.py", "rb"). This way the 
BOM will be detected when decoding the source bytes. Here's an example that 
passes the source as a bytes object:

>>> source = b'\xef\xbb\xbf#coding: utf-8\nprint("spam")'
>>> code = compile(source, '', 'exec')
>>> exec(code)
spam

Or you could also decode the file contents without the BOM via open("bom3.py", 
encoding="utf-8-sig").

--
nosy: +eryksun
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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

Lib/test/test_tokenize.py contains a test for a Python script encoded to UTF-8 
and starting with the UTF-8 BOM, 
Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt.

--

___
Python tracker 

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



[issue25051] 'compile' refuses BOM.

2015-09-10 Thread Piotr

Piotr added the comment:

Ok I have tried it(I had to remove ЉЊЈЁЂ from *.txt - my cp is 1250):

c:\tmp>type test.py
compile(open("tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt").read(), 
"bom3.py", 'exec')

c:\tmp>c:\Python34\python.exe test.py
Traceback (most recent call last):
  File "test.py", line 1, in 

compile(open("tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt").read(), 
"bom3.py", 'exec')
  File "bom3.py", line 1
# -*- coding: utf-8 -*-
  ^
SyntaxError: invalid character in identifier


Is it something in my setup?

--

___
Python tracker 

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



[issue25054] Capturing start of line '^'

2015-09-10 Thread R. David Murray

R. David Murray added the comment:

^ finds an empty match at the beginning of the string, $ finds an empty match 
at the end.  I don't see the bug (but I'm not a regex expert).

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



[issue25043] document socket constants for Bluetooth

2015-09-10 Thread Tim Tisdall

Changes by Tim Tisdall :


--
keywords: +patch
Added file: http://bugs.python.org/file40424/bdaddr_36_1.patch

___
Python tracker 

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



[issue25043] document socket constants for Bluetooth

2015-09-10 Thread Tim Tisdall

Changes by Tim Tisdall :


Added file: http://bugs.python.org/file40425/bdaddr_34_1.patch

___
Python tracker 

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



[issue7687] Bluetooth support untested

2015-09-10 Thread Tim Tisdall

Changes by Tim Tisdall :


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



[issue23270] Use the new __builtin_mul_overflow() of Clang and GCC 5 to check for integer overflow

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

Implementation for any compiler using the new builtin if available:
http://thread.gmane.org/gmane.linux.kernel/204

--

___
Python tracker 

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



[issue23270] Use the new __builtin_mul_overflow() of Clang and GCC 5 to check for integer overflow

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

Implementation for any compiler using the new builtin if available:
http://thread.gmane.org/gmane.linux.kernel/204

--

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread R. David Murray

R. David Murray added the comment:

Test issue update.

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



[issue25054] Capturing start of line '^'

2015-09-10 Thread Alcolo Alcolo

New submission from Alcolo Alcolo:

Why
re.findall('^|a', 'a') != ['', 'a'] ?

We have:
re.findall('^|a', ' a') == ['', 'a']
and
re.findall('$|a', ' a') == ['a', '']

Capturing '^' take the 1st character. It's look like a bug ...

--
components: Regular Expressions
messages: 250364
nosy: Alcolo Alcolo, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Capturing start of line '^'
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue25053] Possible race condition in Pool

2015-09-10 Thread Stanislaw Izaak Pitucha

New submission from Stanislaw Izaak Pitucha:

This is something that happened once and I cannot reproduce anymore. In an 
IPython session I've done the following (see session below), which resulted in 
pool.map raising its internal exceptions in cases where it shouldn't. Then it 
worked again. (see in/out 29)

Running exactly the same lines again did not result in the same behaviour. I 
tried multiple times in the same session as well as new sessions. Looks like a 
weird race / corruption.

I'm on Ubuntu's '3.4.3 (default, Mar 26 2015, 22:03:40) \n[GCC 4.9.2]'. Running 
with 2 virtualised cores (vmware). 64-bit system.

In [21]: import multiprocessing
In [22]: p=multiprocessing.Pool()
... (unrelated, checked p.map? and other helps)
In [26]: class A(object):
def a(self, i):
print("boo", i, multiprocessing.current_process())
   : 
In [27]: obj = A()
In [28]: p.map(obj.a, [1,2,3,4])
Process ForkPoolWorker-1:
Process ForkPoolWorker-2:
Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/multiprocessing/pool.py", line 108, in worker
task = get()
  File "/usr/lib/python3.4/multiprocessing/pool.py", line 108, in worker
task = get()
  File "/usr/lib/python3.4/multiprocessing/queues.py", line 357, in get
return ForkingPickler.loads(res)
AttributeError: Can't get attribute 'A' on 
  File "/usr/lib/python3.4/multiprocessing/queues.py", line 357, in get
return ForkingPickler.loads(res)
AttributeError: Can't get attribute 'A' on 
boo 3 
boo 4 

^CProcess ForkPoolWorker-4:
Process ForkPoolWorker-3:
Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/multiprocessing/process.py", line 254, in _bootstrap
self.run()
  File "/usr/lib/python3.4/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3.4/multiprocessing/pool.py", line 108, in worker
task = get()
  File "/usr/lib/python3.4/multiprocessing/pool.py", line 108, in worker
task = get()
  File "/usr/lib/python3.4/multiprocessing/queues.py", line 354, in get
with self._rlock:
  File "/usr/lib/python3.4/multiprocessing/queues.py", line 355, in get
res = self._reader.recv_bytes()
  File "/usr/lib/python3.4/multiprocessing/synchronize.py", line 96, in 
__enter__
return self._semlock.__enter__()
KeyboardInterrupt
  File "/usr/lib/python3.4/multiprocessing/connection.py", line 216, in 
recv_bytes
buf = self._recv_bytes(maxlength)
  File "/usr/lib/python3.4/multiprocessing/connection.py", line 416, in 
_recv_bytes
buf = self._recv(4)
  File "/usr/lib/python3.4/multiprocessing/connection.py", line 383, in _recv
chunk = read(handle, remaining)
KeyboardInterrupt
---
KeyboardInterrupt Traceback (most recent call last)
 in ()
> 1 p.map(obj.a, [1,2,3,4])

/usr/lib/python3.4/multiprocessing/pool.py in map(self, func, iterable, 
chunksize)
258 in a list that is returned.
259 '''
--> 260 return self._map_async(func, iterable, mapstar, chunksize).get()
261 
262 def starmap(self, func, iterable, chunksize=None):

/usr/lib/python3.4/multiprocessing/pool.py in get(self, timeout)
591 
592 def get(self, timeout=None):
--> 593 self.wait(timeout)
594 if not self.ready():
595 raise TimeoutError

/usr/lib/python3.4/multiprocessing/pool.py in wait(self, timeout)
588 
589 def wait(self, timeout=None):
--> 590 self._event.wait(timeout)
591 
592 def get(self, timeout=None):

/usr/lib/python3.4/threading.py in wait(self, timeout)
551 signaled = self._flag
552 if not signaled:
--> 553 signaled = self._cond.wait(timeout)
554 return signaled
555 finally:

/usr/lib/python3.4/threading.py in wait(self, timeout)
288 try:# restore state no matter what (e.g., KeyboardInterrupt)
289 if timeout is None:
--> 290 waiter.acquire()
291 gotit = True
292 else:

KeyboardInterrupt: 

In [29]: p.map(obj.a, 

Re: Python handles globals badly.

2015-09-10 Thread Steven D'Aprano
On Thu, 10 Sep 2015 05:18 am, Chris Angelico wrote:

> On Thu, Sep 10, 2015 at 5:14 AM, Laura Creighton  wrote:
>> In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes:
>>>To get started, you need some other sort of kick.
>>
>> Having Brian Kernighan write a really nice book about you, helps a lot.
> 
> It kinda does. And of course, it also helps to have a time machine, so
> you can launch your language when there are less languages around.
> Today, you compete for attention with myriad languages that simply
> didn't exist when C was introduced to an unsuspecting world.

I don't think that's quite right. I think, if anything, there were more
languages in the 1970s than now, it's just that they tended to be
proprietary, maybe only running on a single vendor's machine. But even if
I'm mistaken, I think that there is near-universal agreement that the
single biggest factor in C's popularity and growth during the 1970s and 80s
is that it was tied so intimately to Unix, and Unix was taking over from
mainframes, VAX, etc.



-- 
Steven

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


[issue25043] document socket constants for Bluetooth

2015-09-10 Thread Tim Tisdall

Tim Tisdall added the comment:

I'm not sure how to unit test a constant...  it's just a string.  If you're 
asking for a unit test for when you'd actually make use of the constant, I 
haven't been able to figure out that situation yet.  It seems like in Bluez 
4.101 it's used to issue a command to all interfaces (but in contexts I don't 
quite understand), but in Bluez 5.XX there's no example or documentation of its 
use (it remains as a constant, though).  [looking through the Bluez git, I 
found where the constant was added in 2004 and the log message is simply "Add 
BDADDR_ALL constant"; 
http://git.kernel.org/cgit/bluetooth/bluez.git/commit/?id=c7b26f3e5d03e1d54dfb945e5ca0c041da524348
 ]

--

___
Python tracker 

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



[issue25041] document AF_PACKET socket address format

2015-09-10 Thread Adam

Changes by Adam :


--
nosy: +azsorkin

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
type:  -> behavior

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread Michael Torrie
On 09/10/2015 01:27 AM, Antoon Pardon wrote:
> Op 09-09-15 om 19:55 schreef Steven D'Aprano:
>> In fairness to the C creators, I'm sure that nobody back in the early
>> seventies imagined that malware and security vulnerabilities would be as
>> widespread as they have become. But still, the fundamental decisions made
>> by C are lousy. Assignment is an expression?
> 
> What is wrong with that?

Makes for a common error of putting an assignment in a conditional
expression like:

if (a=4) this_is_always_true();

GCC will give you a warning over that these days.  But many C
programmers still adopt a notation of

if (4 == a) do_something();

to protect them if they accidentally leave out one =.  If assignment was
not an expression, then the compiler would properly error out every time
you used a solitary = in the conditional of an if statement.

Python strikes a good compromise.  You can chain = in an assignment
statement, but you can't use them in a conditional expression.

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


[issue25054] Capturing start of line '^'

2015-09-10 Thread Alcolo Alcolo

Alcolo Alcolo added the comment:

Naively, I thinked that ^ is be considered as a 0-length token (like $, \b, 
\B), then after capturing it, we can read the next token : 'a' (for the input 
string "a").

I use a simple work around: prepending my string with ' ' (because ' ' is 
neutral with my regex results).

--

___
Python tracker 

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



[issue25055] Test

2015-09-10 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Just test if the tracker works for me now.

--
messages: 250375
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Test

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Test.

--
nosy: +serhiy.storchaka
status: open -> closed

___
Python tracker 

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



[issue25050] windows installer does not allow 32 and 64 installs side by side

2015-09-10 Thread Steve Dower

Steve Dower added the comment:

This is an issue with 3.4.3 only, and I suspect it was something funny in the 
build config that should just work with 3.4.4 - adding Martin to make sure.

Basically, the upgrade code in the 32-bit installer was (I think) the code used 
for dev snapshots. Both installers are supposed to remove dev snapshots, so the 
64-bit installer will remove it.

If you install the 64-bit version first then you can have both.

--
nosy: +loewis

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: closed -> open

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Test.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: Question about import

2015-09-10 Thread Ian Kelly
On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman  wrote:
> That makes me wonder if, in my project, I can import all modules inside
> 'start.py', and then just use 'import package_name' inside each module?

You can, but for readability and reuse I think it's better to be
explicit in each module and import the fully qualified module names
that are needed, rather than relying on some other module to import
them for you.

> Another question - I thought that, because aa.py and bb.py are in different
> sub-directories, I would have to set them up as packages by adding
> '__init__.py' to each one, but it works fine without that. What am I
> missing?

That surprises me also, but I suspect it's because they're
subdirectories of the current working directory rather than packages
found on the sys.path.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25057] Make parameter of io.base to be positional and keyword

2015-09-10 Thread shiyao.ma

New submission from shiyao.ma:

The parameters for io.[Text]IOBase.seek are currently positional only, as 
discussed in http://bugs.python.org/issue25030.

We make the parameters to be both positional and keyword based.

--
files: patch.diff
keywords: patch
messages: 250382
nosy: berker.peksag, ezio.melotti, introom
priority: normal
severity: normal
status: open
title: Make parameter of io.base to be positional and keyword
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file40427/patch.diff

___
Python tracker 

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



[issue21657] pip.get_installed_distributions() Does not return packages in the current working directory

2015-09-10 Thread David Fraser

David Fraser added the comment:

Filed with pypa at https://github.com/pypa/pip/issues/3091

--
nosy: +davidfraser

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread jkn
On Thursday, 10 September 2015 13:18:39 UTC+1, Steven D'Aprano  wrote:
> On Thu, 10 Sep 2015 05:18 am, Chris Angelico wrote:
> 
> > On Thu, Sep 10, 2015 at 5:14 AM, Laura Creighton  wrote:
> >> In a message of Thu, 10 Sep 2015 05:00:22 +1000, Chris Angelico writes:
> >>>To get started, you need some other sort of kick.
> >>
> >> Having Brian Kernighan write a really nice book about you, helps a lot.
> > 
> > It kinda does. And of course, it also helps to have a time machine, so
> > you can launch your language when there are less languages around.
> > Today, you compete for attention with myriad languages that simply
> > didn't exist when C was introduced to an unsuspecting world.
> 
> I don't think that's quite right. I think, if anything, there were more
> languages in the 1970s than now, it's just that they tended to be
> proprietary, maybe only running on a single vendor's machine. But even if
> I'm mistaken, I think that there is near-universal agreement that the
> single biggest factor in C's popularity and growth during the 1970s and 80s
> is that it was tied so intimately to Unix, and Unix was taking over from
> mainframes, VAX, etc.
> 
> 
> 
> -- 
> Steven

In 'The Design and Evolution of C++', Bjarne Stroustrup writes about a 
principle that was applied to C with classes (an early embodiment of C++):

"C with Classes has to be a weed like C or Fortran because we cannot afford to
take care of a rose like Algol68 or Simula. If we deliver an implementation and
go away for a year, we want to find several systems running when we come back.
That will not happen if complicated maintenance is needed or if a simple port
to a new machine takes longer than a week". (pp. 37)

I think the 'C is a weed' observation one is a good one to explain the
proliferation. I say this as a good thing, and as a programmer in C, C++ and 
Python.

Jon N



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


Re: textfile: copy between 2 keywords

2015-09-10 Thread Jussi Piitulainen
Gerald writes:

> Hey,
>
> is there a easy way to copy the content between 2 unique keywords in a
> .txt file?
>
> example.txt
>
> 1, 2, 3, 4
> #keyword1
> 3, 4, 5, 6
> 2, 3, 4, 5
> #keyword2 
> 4, 5, 6 ,7

Depending on your notion of easy, you may or may not like itertools.
The following code gets you the first keyword and the lines between but
consumes the second keyword. If I needed more control, I'd probably
write what Steven D'Aprano wrote but as a generator function, to get the
flexibility of deciding separately what kind of copy I want in the end.

And I'd be anxious about the possibility that the second keyword is not
there in the input at all. Steven's code and mine simply take every line
after the first keyword in that case. Worth a comment in the code, if
not an exception. Depends.

Code:

from itertools import dropwhile, takewhile
from sys import stdin

def notbeg(line): return line != '#keyword1\n'
def notend(line): return line != '#keyword2 \n' # sic!

if __name__ == '__main__':
print(list(takewhile(notend, dropwhile(notbeg, stdin

Output with your original mail as input in stdin:

['#keyword1\n', '3, 4, 5, 6\n', '2, 3, 4, 5\n']
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue15012] test issue

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

victor test

--
nosy: +haypo

___
Python tracker 

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



Re: textfile: copy between 2 keywords

2015-09-10 Thread Vlastimil Brom
2015-09-10 13:18 GMT+02:00 Gerald :
> Hey,
>
> is there a easy way to copy the content between 2 unique keywords in a .txt 
> file?
>
> example.txt
>
> 1, 2, 3, 4
> #keyword1
> 3, 4, 5, 6
> 2, 3, 4, 5
> #keyword2
> 4, 5, 6 ,7
>
>
> Thank you very much

Hi,
just to add another possible approach, you can use regular expression
search for this task, e.g.
(after you have read the text content to an input string):

>>> import re
>>> input_txt ="""1, 2, 3, 4
... #keyword1
... 3, 4, 5, 6
... 2, 3, 4, 5
... #keyword2
... 4, 5, 6 ,7"""
>>> re.findall(r"(?s)(#keyword1)(.*?)(#keyword2)", input_txt)
[('#keyword1', '\n3, 4, 5, 6\n2, 3, 4, 5\n', '#keyword2')]
>>>

like in the other approaches, you might need to specify the details
for specific cases (no keywords, only one of them, repeated keywords
(possible in different order, overlapping or "crossed"), handling of
newlines etc.

hth,
   vbr
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25056] no support for Bluetooth LE in socket

2015-09-10 Thread Tim Tisdall

New submission from Tim Tisdall:

When Bluetooth LE support was added to Bluez they expanded sockaddr_l2 (the 
struct for making L2CAP connections) to include a l2_bdaddr_type.  Since the 
existing code initializes the struct with 0's the type is set to regular 
Bluetooth (BDADDR_BREDR).  An additional optional argument is needed to allow 
it to also be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM which indicate it's a 
LE connection to be made.

--
components: Library (Lib)
messages: 250376
nosy: Tim.Tisdall
priority: normal
severity: normal
status: open
title: no support for Bluetooth LE in socket
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue15012] test issue

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Test again.

--
nosy: +serhiy.storchaka
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: Question about import

2015-09-10 Thread Peter Otten
Ian Kelly wrote:

> On Thu, Sep 10, 2015 at 1:12 AM, Frank Millman  wrote:
>> That makes me wonder if, in my project, I can import all modules inside
>> 'start.py', and then just use 'import package_name' inside each module?
> 
> You can, but for readability and reuse I think it's better to be
> explicit in each module and import the fully qualified module names
> that are needed, rather than relying on some other module to import
> them for you.
> 
>> Another question - I thought that, because aa.py and bb.py are in
>> different sub-directories, I would have to set them up as packages by
>> adding '__init__.py' to each one, but it works fine without that. What am
>> I missing?
> 
> That surprises me also, but I suspect it's because they're
> subdirectories of the current working directory rather than packages
> found on the sys.path.

So even the experts cannot keep up with all those nifty new features:

https://www.python.org/dev/peps/pep-0420/ (Implicit Namespace Packages)

I'm waiting to see the language collapse under all its nice and -- seen in 
isolation -- incredibly useful additions. 

C++ we're coming :(

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


Re: Question about import

2015-09-10 Thread Ian Kelly
On Thu, Sep 10, 2015 at 8:47 AM, Peter Otten <__pete...@web.de> wrote:
> Ian Kelly wrote:
>> That surprises me also, but I suspect it's because they're
>> subdirectories of the current working directory rather than packages
>> found on the sys.path.
>
> So even the experts cannot keep up with all those nifty new features:
>
> https://www.python.org/dev/peps/pep-0420/ (Implicit Namespace Packages)

I've seen that before, but forgot about it. I wouldn't call myself an
expert, though; I haven't been using Python regularly for the past
couple of years, so I am getting a bit rusty.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python handles globals badly.

2015-09-10 Thread random832
On Thu, Sep 10, 2015, at 11:59, Steven D'Aprano wrote:
> Although, I'm not sure that I agree with the idea that "everything is an
> expression". I think that's a category mistake, like asking for the speed
> of dark[1], or for a bucket of cold. Some things are functional by
> nature,
> and other things are imperative; some may be both, but I don't think that
> assignment is one. I think that assignment is imperative, not functional,
> and forcing it to return a value is artificial.

Why shouldn't imperative things be expressions? Why should all
expressions return a value?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24272] PEP 484 docs

2015-09-10 Thread Berker Peksag

Berker Peksag added the comment:

By the way, for some reason the changes in revision e361130782d4 are not in 
Doc/library/typing.rst.

For example,

io documentation on current default branch: 
https://hg.python.org/cpython/file/default/Doc/library/typing.rst#l376
io documentation on current 3.5 branch: 
https://hg.python.org/cpython/file/3.5/Doc/library/typing.rst#l376
Updates to the io documntation in revision e361130782d4: 
https://hg.python.org/cpython/rev/e361130782d4#l1.67

Also, my clone is up-to-date:

changeset:   97855:d433d74e0377
tag: tip
user:Victor Stinner 
date:Thu Sep 10 16:00:06 2015 +0200
files:   Python/pytime.c
description:
pytime: oops, fix typos on Windows

--

___
Python tracker 

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



Re: textfile: copy between 2 keywords

2015-09-10 Thread Christian Gollwitzer

Am 10.09.15 um 13:18 schrieb Gerald:

Hey,

is there a easy way to copy the content between 2 unique keywords in a .txt 
file?

example.txt

1, 2, 3, 4
#keyword1
3, 4, 5, 6
2, 3, 4, 5
#keyword2
4, 5, 6 ,7


If "copying" does mean copy it to another file, and you are not obliged 
to use Python, this is unmatched in awk:


Apfelkiste:Tests chris$ cat kw.txt
1, 2, 3, 4
#keyword1
3, 4, 5, 6
2, 3, 4, 5
#keyword2
4, 5, 6 ,7
Apfelkiste:Tests chris$ awk '/keyword1/,/keyword2/' kw.txt
#keyword1
3, 4, 5, 6
2, 3, 4, 5
#keyword2

Consequently, awk '/keyword1/,/keyword2/' kw.txt  > kw_copy.txt

would write it out to kw_copy.txt

Beware that between the two slashes there are regexps, so if you have 
metacharacters in your keywords, you need to quote them.


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


Re: Can't use Python Launcher on Windows after update to 3.5

2015-09-10 Thread Mark Lawrence

On 10/09/2015 11:20, Tim Golden wrote:

On 10/09/2015 00:52, Mark Lawrence wrote:

I've installed 3.5 for all users so it's in C:\Program Files

From
https://docs.python.org/3.5/using/windows.html#from-the-command-line it
says "System-wide installations of Python 3.3 and later will put the
launcher on your PATH. The launcher is compatible with all available
versions of Python, so it does not matter which version is installed. To
check that the launcher is available, execute the following command in
Command Prompt:", but:-

C:\Users\Mark\Documents\MyPython>py -3.4
'py' is not recognized as an internal or external command,
operable program or batch file.

Further running ftype shows nothing for Python, assoc just gives this
.pyproj=VisualStudio.Launcher.pyproj.14.0.  Surely this is wrong?

Before I go to the bug tracker to raise an issue could somebody please
confirm what I'm seeing, thanks.



Well I've just installed 64-bit 3.5.0rc4 via the web installer (ie this:
https://www.python.org/ftp/python/3.5.0/python-3.5.0rc4-amd64-webinstall.exe)
onto a machine with 64-bit 3.4.2 already installed. I went for the
default install.

It all seems to be ok and py -3.4 --version gives  me "Python 3.4.2" as
expected. assoc/ftype both look ok. c:\windows\py.exe has the versions &
dates I expect.

TJG



So I ran the 64-bit 3.5.0rc4 via the web installer and still no joy. 
Ran repair with same and it's business as usual.  I'm not that bothered, 
it's here for the record should anybody else come searching, so chalk it 
up to experience and move on.  Thanks anyway :)


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

Mark Lawrence

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


Re: Python handles globals badly.

2015-09-10 Thread Steven D'Aprano
On Thu, 10 Sep 2015 04:59 am, random...@fastmail.us wrote:

> On Wed, Sep 9, 2015, at 13:55, Steven D'Aprano wrote:
>> In fairness to the C creators, I'm sure that nobody back in the early
>> seventies imagined that malware and security vulnerabilities would be as
>> widespread as they have become. But still, the fundamental decisions made
>> by C are lousy. Assignment is an expression?
> 
> Whoa, hold on. The problem with C assignment isn't that it's an
> expression, it's that it's spelled "=" and can be used in contexts where
> one would normally do an equality comparison.

Yes, that's what I'm referring to.

Although, I'm not sure that I agree with the idea that "everything is an
expression". I think that's a category mistake, like asking for the speed
of dark[1], or for a bucket of cold. Some things are functional by nature,
and other things are imperative; some may be both, but I don't think that
assignment is one. I think that assignment is imperative, not functional,
and forcing it to return a value is artificial.


> In some languages (Lisp/Scheme/etc come to mind), *everything* is an
> expression. But assignment is spelled with, generally, some variant of
> "set" [setq, set!, etc].

Yes, that at least avoids the possibility of mistaking = for == or similar.



[1] Obviously it's faster than light, since wherever the light arrives, it
finds the dark got there first.


-- 
Steven

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


[issue25024] Allow passing "delete=False" to TemporaryDirectory

2015-09-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm inclined to reject this idea too.

--
nosy: +georg.brandl, ncoghlan, pitrou, serhiy.storchaka

___
Python tracker 

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



[issue24900] Raising an exception that cannot be unpickled causes hang in ProcessPoolExecutor

2015-09-10 Thread Benedikt Reinartz

Benedikt Reinartz added the comment:

That would touch 2, but as this is happening in the exception handling already 
that would need to be catched and handled by itself. However, one could then do 
without a "pickle -> unpickle" dance.

--

___
Python tracker 

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



[issue25024] Allow passing "delete=False" to TemporaryDirectory

2015-09-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

The idea looks ok to me, but you'd have to provide a patch.

--

___
Python tracker 

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



[issue25058] Right square bracket argparse metavar

2015-09-10 Thread Juan Jimenez-Anca

New submission from Juan Jimenez-Anca:

When trying to assign the metavar in add_argument() method of argparse module 
I'm unable to include characters after a right square bracket.

Trying to set something like this:

metavar="[host:database:collection:]field"

would raise an AssertionError, which includes:

File "/usr/lib64/python3.4/argparse.py", line 329, in _format_usage
assert ' '.join(opt_parts) == opt_usage

However, the following is accepted:

metavar="[host:database:collection:]field"

--
components: Library (Lib)
messages: 250388
nosy: cortopy
priority: normal
severity: normal
status: open
title: Right square bracket argparse metavar
type: behavior
versions: Python 3.4

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread Chris Angelico
On Fri, Sep 11, 2015 at 2:31 AM,   wrote:
> On Thu, Sep 10, 2015, at 11:59, Steven D'Aprano wrote:
>> Although, I'm not sure that I agree with the idea that "everything is an
>> expression". I think that's a category mistake, like asking for the speed
>> of dark[1], or for a bucket of cold. Some things are functional by
>> nature,
>> and other things are imperative; some may be both, but I don't think that
>> assignment is one. I think that assignment is imperative, not functional,
>> and forcing it to return a value is artificial.
>
> Why shouldn't imperative things be expressions? Why should all
> expressions return a value?

I'm not sure what the point would be of having an expression that
doesn't return a value. The point of assignment-as-an-expression is
that you can do other things with the result:

while ((ch=getchar()) != EOF)

In Python, we have a couple of cases where that's done with the 'as' keyword:

with open(fn) as in_file:

except KeyError as e:

and there've been proposals now and then to have the same thing added
to if and while, which actually isn't hard:

while getchar() as ch:

but the trouble is that you can check for falsiness, but nothing else.
(In C, EOF is an integer outside the range 0..255, such that it's
distinct from any byte value. It's usually -1.) If assignment is an
expression, you can capture a value and keep going - something like
this:

stash = [None]
while (stash.__setitem__(0, getchar()) or stash[0]) != -1:
ch = stash[0]

It's ugly, but it does work - because the setitem call is an
expression. However, for this to succeed, the expression MUST yield a
value. Otherwise it doesn't make sense, and the difference between
expression and statement is a purely technical/theoretical one. (In
this case, the value of the "assignment" expression is always None,
which is less useful than C's policy of returning the value itself;
but at least I know what it's going to be, so I can use the "or
stash[0]" notation.)

Having assignment be a statement (and therefore illegal in a loop
condition) makes sense. Having it be an expression that yields a
useful or predictable value makes sense. Having it be an expression,
but not returning a value, doesn't.

(I'm not going to get into the argument here about whether assignment
SHOULD be a statement or an expression. There are plenty of languages
to choose from, so you can have it both ways if you like.)

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


[issue25054] Capturing start of line '^'

2015-09-10 Thread Matthew Barnett

Matthew Barnett added the comment:

Just to confirm, it _is_ a bug.

It tries to avoid getting stuck, but the way it does that causes it to skip a 
character, sometimes missing a match it should have found.

--

___
Python tracker 

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



[issue25053] Possible race condition in Pool

2015-09-10 Thread Davin Potts

Davin Potts added the comment:

I have been able to reproduce the behavior you described under 3.5 under one 
set of circumstances so far.

When attempting to use classes/functions/other not defined in an importable 
module, an AttributeError is expected as you observed.  The viability of that 
existing Pool to perform further useful work has been compromised and no 
promises are made regarding its continued behavior.

In general, the recommendations in 
https://docs.python.org/3.4/library/multiprocessing.html#multiprocessing-programming
 hold to avoid these situations.

Understanding the exact set of circumstances to provoke situations where viable 
work can continue with a locally-defined (not in an importable module) 
function/class is perhaps worth further investigation.

That said, multiple places in the multiprocessing docs (including the 
introductory paragraphs) provide the guidance to always use functions/classes 
whose definitions are importable.  Hence, I'm inclined to mark this mentally as 
"interesting" but on the bug tracker as "not a bug".  Any objections?

--
nosy: +davin

___
Python tracker 

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



Re: textfile: copy between 2 keywords

2015-09-10 Thread Jussi Piitulainen
Vlastimil Brom writes:

> just to add another possible approach, you can use regular expression

Now you have three problems: whatever the two problems are that you are
alleged to have whenever you decide to use regular expressions for
anything at all, plus all the people piling on you to tell that a Jamie
Zawinski once said that whenever you decide to use regular expressions
to solve a problem, you end up with two problems.

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


[issue25058] Right square bracket argparse metavar

2015-09-10 Thread Juan Jimenez-Anca

Juan Jimenez-Anca added the comment:

My apologies for the formatting of the last line. This is my issue corrected:

When trying to assign the metavar in add_argument() method of argparse module 
I'm unable to include characters after a right square bracket.

Trying to set something like this:

metavar="[host:database:collection:]field"

would raise an AssertionError, which includes:

File "/usr/lib64/python3.4/argparse.py", line 329, in _format_usage
assert ' '.join(opt_parts) == opt_usage

However, the following is accepted:

metavar="[host:database:collection:] field"

--

___
Python tracker 

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



[issue25060] BUILD_MAP stack effect suboptimal

2015-09-10 Thread Antoine Pitrou

New submission from Antoine Pitrou:

In PyCompile_OpcodeStackEffect() compile.c:

case BUILD_MAP:
return 1;

But starting from 3.5, BUILD_MAP pops 2*oparg objects from the stack.

--
components: Interpreter Core
messages: 250391
nosy: benjamin.peterson, georg.brandl, pitrou
priority: normal
severity: normal
status: open
title: BUILD_MAP stack effect suboptimal
type: resource usage
versions: Python 3.5, Python 3.6

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread Steven D'Aprano
On Thu, 10 Sep 2015 04:26 am, Sven R. Kunze wrote:

> Just to understand it the way you want it to be understood: what do you
> mean by "technical excellence"?

That's one of those things that are difficult to define precisely. All I can
do is give some partial examples, and counter-examples.

Lisp embodies a form of mathematical elegance and simplicity that one might
call technical excellence. Forth does too, despite their completely
different syntax and computational model.

BASIC does not.

ML's type-checker displays technical excellence:

http://perl.plover.com/yak/typing/notes.html

Haskell, which inherits the same sort of type-checker, does too.

Inform 7's natural language syntax and inference engine displays technical
excellence. APL's mathematics syntax does not, as it doesn't even follow
the same rules that mathematicians expect. (APL, I'm lead to believe, is
evaluated purely from left-to-right -- or was it right to left? -- so that
1+2*3 gives 9 rather than 7 like mathematicians expect.)

Credit where credit is due: although I think that in the broader computing
ecosystem it does more harm than good, the efforts put into optimization by
C compilers show technical excellence. If there's a cycle that can be
shaved, good C compilers like gcc and clang will find it.

It's hard (impossible?) to think of a language that gets *everything* right,
because so much of that depends on subjective factors, but I think that
languages can display technical excellence in a particular subset of
features. It's not "all or nothing" -- a language can be excellent in one
area, and poor in another.


[...]
>> (I wanted to link to the "Everything Is Broken" essay on The Medium, but
>> the page appears to be gone. This makes me sad. BTW, what's the point of
>> Google's cache when it just redirects to the original, missing, page?)
>
> Do you mean https://medium.com/message/everything-is-broken-81e5f33a24e1 ?

Yes, that's the one, thanks.



-- 
Steven

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


Re: numpy

2015-09-10 Thread Laura Creighton
In a message of Thu, 10 Sep 2015 18:11:08 +0800, "chenc...@inhand.com.cn" write
s:
>hi:
>I have to use numpy package. My python runs on my embedded arm 
>device. So, how do i cross compile numpy?
>-- 
>https://mail.python.org/mailman/listinfo/python-list

Ask that one here:
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Do you even have a floating point processor?  I'm not an
expert but I don't think that it makes sense to try to run
numpy anywhere that doesn't have one.

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


[issue25059] Mistake in input-output tutorial regarding print() seperator

2015-09-10 Thread Saimadhav Heblikar

New submission from Saimadhav Heblikar:

Feel free to make changes to the patch if you want to improve the sentence 
structure.

--
assignee: docs@python
components: Documentation
messages: 250390
nosy: docs@python, sahutd
priority: normal
severity: normal
status: open
title: Mistake in input-output tutorial regarding print() seperator
versions: Python 3.5, Python 3.6

___
Python tracker 

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



[issue25059] Mistake in input-output tutorial regarding print() seperator

2015-09-10 Thread R. David Murray

R. David Murray added the comment:

Well, it's a tutorial.  I'm not sure it makes sense to introduce sep at that 
point, that's more appropriate for when the user is more advanced and looking 
at the reference documentation.  (Frankly, I've *never* used that feature, and 
I've been using python for longer than it has had that feature :)  

I could see changing 'always' to 'by default' and leaving it at that, though.

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



[issue25059] Mistake in input-output tutorial regarding print() seperator

2015-09-10 Thread Saimadhav Heblikar

Saimadhav Heblikar added the comment:

Agreed with both David Murray and Eric.

--

___
Python tracker 

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



[issue25059] Mistake in input-output tutorial regarding print() seperator

2015-09-10 Thread Saimadhav Heblikar

Changes by Saimadhav Heblikar :


Added file: http://bugs.python.org/file40428/issue25059

___
Python tracker 

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



[issue25059] Mistake in input-output tutorial regarding print() seperator

2015-09-10 Thread Eric V. Smith

Eric V. Smith added the comment:

+1 on the "by default" change.

--
nosy: +eric.smith

___
Python tracker 

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



Re: RPI.GPIO Help

2015-09-10 Thread John McKenzie

 MRAB:

 Thanks for replying. I got so hyper focused on solving my hardware 
problems, and excited that I did, that I forgot details from previous 
comments. Thanks for your post.

 Off to make things global...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Context-aware return

2015-09-10 Thread Sven R. Kunze

http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode


On 10.09.2015 19:54, Steven D'Aprano wrote:

I have a function which is intended for use at the interactive interpreter,
but may sometimes be used non-interactively. I wish to change it's output
depending on the context of how it is being called.

If the function is being called as if it were a procedure or command, that
is the return result is just ignored, I want to return one thing. But if it
is being called where the return result goes somewhere, I want to return
something else. Most importantly, I don't want to pass a flag to the
function myself, I want the function to know its own context.

I don't mind if it is CPython only, or if it is a bit expensive.


E.g.

def func():
 do_stuff()
 if procedure:  # FIXME what goes here???
 return "Awesome"
 else:
 return 999

Now I can do this:


x = func()
assert x == 999

L = [1, 2, func(), 4]
assert L[2] == 999

func()
# interactive interpreter prints "Awesome"

Is such a thing possible, and if so, how would I do it?

If I did this thing, would people follow me down the street booing and
jeering and throwing things at me?


Probably. ;)

But it it solve a problem, why not.


Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


Re: Python handles globals badly.

2015-09-10 Thread Steven D'Aprano
On Fri, 11 Sep 2015 02:31 am, random...@fastmail.us wrote:

> On Thu, Sep 10, 2015, at 11:59, Steven D'Aprano wrote:
>> Although, I'm not sure that I agree with the idea that "everything is an
>> expression". I think that's a category mistake, like asking for the speed
>> of dark[1], or for a bucket of cold. Some things are functional by
>> nature,
>> and other things are imperative; some may be both, but I don't think that
>> assignment is one. I think that assignment is imperative, not functional,
>> and forcing it to return a value is artificial.
> 
> Why shouldn't imperative things be expressions?

Sometimes they might be. But in general, I think it is meaningless to expect
a imperative command to have a return result. The whole point of an
imperative command is that it operates by side-effect.

For example, what would `del x` return if it were an expression instead of a
statement? I can think of two reasonable alternatives, but both feel a bit
wrong to me.

(1) Return True if x was successfully unbound, False if it wasn't. Except
that raising an exception seems more Pythonic, in which case returning True
seems redundant. It will *always* return True, unless there's an exception.
So why bother? We only bother because there's no way to *not* return a
result if "everything is an expression".

(2) Return None, like functions do by default. But again, it only returns
None, not because None is a meaningful thing to return, but because we
don't actually have a way to say "it doesn't return anything".

Or os.abort. The docs for that say:

Help on built-in function abort in module posix:

abort(...)
abort() -> does not return!

Abort the interpreter immediately.  This 'dumps core' or otherwise fails
in the hardest way possible on the hosting operating system.


So, what would os.abort() return, if everything is an expression?

Obviously one can always find some arbitrary value for expressions to
return, in order to keep the invariant "all expressions return something".
But I dislike the arbitrariness of it. Some things aren't conceptually
functional expressions, they're imperative commands that (like Pascal
procedures, or Python statements) don't naturally have a return result.



> Why should all expressions return a value?

Because that's the definition of an expression in this context. An
expression is evaluated to either return a result, or raise an exception.



-- 
Steven

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


Re: Context-aware return

2015-09-10 Thread Sven R. Kunze
I need to add: you need to look up the stack to see if you have been 
called by __main__ and if __main__.__file__ is missing.


Implementation: I would write decorator for your func.

Best,
Sven

PS: did I say it would probably be a bad idea? If not, it would probably 
be a bad idea.


PPS: what is the reason for this special behavior?

On 10.09.2015 20:03, Sven R. Kunze wrote:
http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode 




On 10.09.2015 19:54, Steven D'Aprano wrote:
I have a function which is intended for use at the interactive 
interpreter,
but may sometimes be used non-interactively. I wish to change it's 
output

depending on the context of how it is being called.

If the function is being called as if it were a procedure or command, 
that
is the return result is just ignored, I want to return one thing. But 
if it

is being called where the return result goes somewhere, I want to return
something else. Most importantly, I don't want to pass a flag to the
function myself, I want the function to know its own context.

I don't mind if it is CPython only, or if it is a bit expensive.


E.g.

def func():
 do_stuff()
 if procedure:  # FIXME what goes here???
 return "Awesome"
 else:
 return 999

Now I can do this:


x = func()
assert x == 999

L = [1, 2, func(), 4]
assert L[2] == 999

func()
# interactive interpreter prints "Awesome"

Is such a thing possible, and if so, how would I do it?

If I did this thing, would people follow me down the street booing and
jeering and throwing things at me?


Probably. ;)

But it it solve a problem, why not.


Best,
Sven


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


Re: Context-aware return

2015-09-10 Thread Sven R. Kunze

On 10.09.2015 20:14, Ben Finney wrote:

"Sven R. Kunze"  writes:


http://stackoverflow.com/questions/2356399/tell-if-python-is-in-interactive-mode

I'm pretty sure Steven knows full well the answer to that question,
which is not anything like the one he asked. Would you care to read the
question he did ask?

You are right. I turned out to me harder that I first thought.

My initial guess was like: use AST. But now I see, it would be hard to 
get the source code.


So, what actually could work, would be faking the interactive 
interpreter wrapping it up and thus have control over the source code 
typed in.


Best,
Sven
--
https://mail.python.org/mailman/listinfo/python-list


[issue25061] Add native enum support for argparse

2015-09-10 Thread desbma

Changes by desbma :


--
components: +Library (Lib)

___
Python tracker 

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



[issue25063] shutil.copyfileobj should internally use os.sendfile when possible

2015-09-10 Thread desbma

New submission from desbma:

Sorry if it has already been discussed, or if this is a stupid idea.

By looking at the signature, my thought was that the only use of 
shutil.copyfileobj was to wrap the use of sendfile, and use a fallback if it is 
not available on the system or not usable with "fake" Python files (not having 
a file descriptor, eg. like gzip.GzipFile).

By looking at the implementation, I was surprised that it does not try to call 
os.sendfile.

--
components: Library (Lib)
messages: 250401
nosy: desbma
priority: normal
severity: normal
status: open
title: shutil.copyfileobj should internally use os.sendfile when possible

___
Python tracker 

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



Re: Python handles globals badly.

2015-09-10 Thread Chris Angelico
On Fri, Sep 11, 2015 at 4:13 AM, Steven D'Aprano  wrote:
> Sometimes they might be. But in general, I think it is meaningless to expect
> a imperative command to have a return result. The whole point of an
> imperative command is that it operates by side-effect.
>
> For example, what would `del x` return if it were an expression instead of a
> statement? I can think of two reasonable alternatives, but both feel a bit
> wrong to me.
>
> (1) Return True if x was successfully unbound, False if it wasn't. Except
> that raising an exception seems more Pythonic, in which case returning True
> seems redundant. It will *always* return True, unless there's an exception.
> So why bother? We only bother because there's no way to *not* return a
> result if "everything is an expression".
>
> (2) Return None, like functions do by default. But again, it only returns
> None, not because None is a meaningful thing to return, but because we
> don't actually have a way to say "it doesn't return anything".

Yes, or: (3) Return the old value that x contained, the way dict.pop()
does. That makes it a "destructive retrieval" rather than simply a
destruction operation.

> Or os.abort. The docs for that say:
>
> Help on built-in function abort in module posix:
>
> abort(...)
> abort() -> does not return!
>
> Abort the interpreter immediately.  This 'dumps core' or otherwise fails
> in the hardest way possible on the hosting operating system.
>
>
> So, what would os.abort() return, if everything is an expression?

Since this is in the os module, and is thus a thin wrapper around
lower-level operations, I could imagine it returning an error code
(the way the C-level exec functions do - if they succeed, they don't
return, but if they fail, they return an error number); in Python,
it'd be best to have it either abort the process (and thus not
return), or raise an exception (and thus not return).

But abort functions are a rarity. It's not a problem to have a rule
"all functions must return something" (as Python does), and then have
functions that never actually use the normal return path:

def raise_(exc): raise exc
raise_stopiteration = iter([]).__next__
raise_typeerror = lambda: ""()

Calling one of these functions is *syntactically* an expression, but
at run time, it'll never actually get as far as producing a value. If
it's at all possible for the operation to, based on run-time
information, NOT abort, then it absolutely has to be able to return.

> Because that's the definition of an expression in this context. An
> expression is evaluated to either return a result, or raise an exception.

I'd define it more simply: An expression always produces a result.
It's possible that, during the evaluation of an expression, an
exception will be raised; if that happens, evaluation stops. Doesn't
matter whether the expression itself caused that, or if an OS-level
signal did (eg triggering KeyboardInterrupt), or if the expression was
"yield 1" and an exception got thrown in. But yes, an expression is
something that generates a result; a statement isn't.

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


[issue25003] os.urandom() should call getrandom(2) not getentropy(2) on Solaris

2015-09-10 Thread STINNER Victor

Changes by STINNER Victor :


--
title: os.urandom() should call getrandom(2) not getentropy(2) -> os.urandom() 
should call getrandom(2) not getentropy(2) on Solaris

___
Python tracker 

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



[issue25003] os.urandom() should call getrandom(2) not getentropy(2)

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

> Yes, the syscall was failing with EINVAL.

Sorry, I don't understand. Do you mean that calling a non-existant syscall on 
Solaris fails with EINVAL? Calling the getrandom() syscall on Solaris < 11.3 
fails with EINVAL?

--

___
Python tracker 

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



[issue23517] datetime.utcfromtimestamp rounds results incorrectly

2015-09-10 Thread STINNER Victor

STINNER Victor added the comment:

Alexander: can you please review attached round_half_even_py34.patch? It's the 
minimum patch to fix datetime/timedelta rounding for Python 3.4 (and 3.5).

--

___
Python tracker 

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



[issue24272] PEP 484 docs

2015-09-10 Thread Guido van Rossum

Guido van Rossum added the comment:

I suck at merge. :-( No idea what happened. To fix it, I have now just
copied the file again from the larry branch and committed that in 3.5, then
merged up to 3.6 (default).

changeset:   97856:8a7814a3613b
branch:  3.5
parent:  97847:6c8e2c6e3a99
user:Guido van Rossum 
date:Thu Sep 10 10:52:11 2015 -0700
summary: Restore doc updates to typing.rst by Ivan Levkivskyi and
Daniel Andrade Groppe.

changeset:   97857:7fc4306d537b
tag: tip
parent:  97855:d433d74e0377
parent:  97856:8a7814a3613b
user:Guido van Rossum 
date:Thu Sep 10 10:54:10 2015 -0700
summary: Restore doc updates to typing.rst by Ivan Levkivskyi and
Daniel Andrade Groppe.

--

___
Python tracker 

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



Re: Context-aware return

2015-09-10 Thread Ben Finney
Steven D'Aprano  writes:

> I have a function which is intended for use at the interactive
> interpreter, but may sometimes be used non-interactively. I wish to
> change it's output depending on the context of how it is being called.
> […]
>
> x = func()
> assert x == 999
>
> L = [1, 2, func(), 4]
> assert L[2] == 999
>
> func()
> # interactive interpreter prints "Awesome"
>
> Is such a thing possible, and if so, how would I do it?

That makes my skin creep. In the name of all the tea I've sacrificed to
Python over the years, I pray this isn't possible.

> If I did this thing, would people follow me down the street booing and
> jeering and throwing things at me?

First thing in the morning I will purchase a head of cabbage and store
it in a warm place to make it rot, on the off chance you find some
obscure way to achieve your benighted goal, just so I can be first in
line to throw it as you pass.

If ever I have to worry that some arbitrary Python function, unbenownst
to me, might have a branch that will make it behave differently
depending on *whether I bind a reference to its return value*, then I'll
know you are sent to us as an evil spirit to make all software suck.

-- 
 \   “Nothing exists except atoms and empty space; everything else |
  `\  is opinion.” —Democritus |
_o__)  |
Ben Finney

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


[issue3548] subprocess.pipe function

2015-09-10 Thread desbma

Changes by desbma :


--
nosy: +desbma

___
Python tracker 

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



[issue25003] os.urandom() should call getrandom(2) not getentropy(2) on Solaris 11.3 and newer

2015-09-10 Thread STINNER Victor

Changes by STINNER Victor :


--
title: os.urandom() should call getrandom(2) not getentropy(2) on Solaris -> 
os.urandom() should call getrandom(2) not getentropy(2) on Solaris 11.3 and 
newer

___
Python tracker 

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



[issue25061] Add native enum support for argparse

2015-09-10 Thread desbma

New submission from desbma:

I often find myself using the following pattern with argparse:

import argparse
import enum

CustomEnumType = enum.Enum("CustomEnumType",
   ("VAL1", "VAL2", "VAL3", ...))

arg_parser = argparse.ArgumentParser(...)
...
arg_parser.add_argument("-p",
"--param",
type="string",
action="store",
choices=tuple(t.name.lower() for t in CustomEnumType),
default=CustomEnumType.VAL1.name.lower(),
dest="param"
...)
args = arg_parser.parse_args()
args.param = CustomEnumType[args.param.upper()]

I think it would be a great addition to be able to pass the enum type to the 
add_argument 'type' parameter directly, and have it validate the input and 
store the resulting enum.

--
messages: 250399
nosy: desbma
priority: normal
severity: normal
status: open
title: Add native enum support for argparse
type: enhancement

___
Python tracker 

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



[issue25062] Doc linter error: [2] library/typing.rst:358: default role used

2015-09-10 Thread STINNER Victor

New submission from STINNER Victor:

The Docs buildbot is red since the changeset 
7fc4306d537b5feedb7f9dac54d96ed378c093a7.

http://buildbot.python.org/all/builders/Docs%203.x/builds/52

--
assignee: docs@python
components: Documentation
messages: 250400
nosy: docs@python, gvanrossum, haypo
priority: normal
severity: normal
status: open
title: Doc linter error:  [2] library/typing.rst:358: default role used
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: Context-aware return

2015-09-10 Thread Laura Creighton
In a message of Fri, 11 Sep 2015 03:54:14 +1000, "Steven D'Aprano" writes:

>def func():
>do_stuff()
>if procedure:  # FIXME what goes here???
>return "Awesome"
>else:
>return 999
>
>Now I can do this:
>
>
>x = func()
>assert x == 999
>
>L = [1, 2, func(), 4]
>assert L[2] == 999
>
>func()
># interactive interpreter prints "Awesome"
>
>Is such a thing possible, and if so, how would I do it?

Why, why, why do you want such a horrid thing?
I have an function that isn't always doing what I want.
I make a reference to it, so I can print it from time to time,
and do some other things to try to see why sometimes I am getting
an unwanted result.

I can no longer debug my problem.
You are seriously proposing this?

>If I did this thing, would people follow me down the street booing and
>jeering and throwing things at me?

I might start ahead of time, just for thinking of it ...

There has got to be a better way to get what you want -- or perhaps
for you to want something saner.

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


  1   2   >