Re: Improving syntax error messages

2018-04-26 Thread Terry Reedy

On 4/26/2018 4:22 PM, Serhiy Storchaka wrote:
What syntax errors did you see most often? Which of them looks the most 
weird? How would you like to improve their messages.


One way to research this would be to search stackoverflow.com for 
"[python] SyntaxError".  There are currently 8142 results, and they can 
be sorted newest first.


The general 'invalid syntax' message must be most common, and perhaps is 
the most puzzling.


--
Terry Jan Reedy

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


Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 21:18, Terry Reedy  wrote:
>> If my memory is correct, this is the default for path directories.
>
> The Python entries do, as added by the Windows Installer written by a
> Microsoft engineer, so this must at least be a correct alternative.

It's definitely acceptable - there's no doubt the pip 10.0.1 behaviour
is a bug (that's been fixed). No-one is arguing otherwise. The
suggestion to remove the backslashes was nothing more than a
workaround that can be used until the next release of pip.

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


Improving syntax error messages

2018-04-26 Thread Serhiy Storchaka
What syntax errors did you see most often? Which of them looks the most 
weird? How would you like to improve their messages.


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


Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Terry Reedy

On 4/26/2018 3:04 PM, Virgil Stokes wrote:


However, each entry in this Windows 10 path has a trailing backslash.


Some do, and some don't, which is the same on my Win10


If my memory is correct, this is the default for path directories.


The Python entries do, as added by the Windows Installer written by a 
Microsoft engineer, so this must at least be a correct alternative.


--
Terry Jan Reedy

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


Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 20:04, Virgil Stokes  wrote:
> IMHO it would have been useful to have "warning" somewhere in these
> messages.

Ha, I'd never even noticed that it didn't...

I think it's in a different colour, FWIW, but your point is good.
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Virgil Stokes

Thanks Paul for the prompt reply,

However, each entry in this Windows 10 path has a trailing backslash. If 
my memory is correct, this is the default for path directories.


IMHO it would have been useful to have "warning" somewhere in these 
messages.


On 2018-04-26 20:52, Paul Moore wrote:

On 26 April 2018 at 19:33, Virgil Stokes  wrote:

Why am I getting this message, that I need to consider adding this directory
to PATH when it is already in PATH?
Note, all of these *.exe files are in C:\Python36\Scripts.

The PATH entry ends with a backslash, which is confusing the check
done by pip. It's a known issue and has been fixed in the development
version of pip, so it'll be resolved in the next release. In the
meantime, you can either remove the redundant trailing backslash from
your PATH, or just ignore the warning.

Paul


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


Re: Installation of tensorflow via pip -- messages?

2018-04-26 Thread Paul Moore
On 26 April 2018 at 19:33, Virgil Stokes  wrote:
> Why am I getting this message, that I need to consider adding this directory
> to PATH when it is already in PATH?
> Note, all of these *.exe files are in C:\Python36\Scripts.

The PATH entry ends with a backslash, which is confusing the check
done by pip. It's a known issue and has been fixed in the development
version of pip, so it'll be resolved in the next release. In the
meantime, you can either remove the redundant trailing backslash from
your PATH, or just ignore the warning.

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


Installation of tensorflow via pip -- messages?

2018-04-26 Thread Virgil Stokes

First I upgraded my pip

*C:\Python36>python -m pip install --upgrade pip*
Collecting pip
  Downloading 
https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl 
(1.3MB)

    100% || 1.3MB 685kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
  Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.1

Then I upgraded tensorflow

*C:\Python36>python -m pip install --upgrade tensorflow*
...
...
...
The script tensorboard.exe is installed in 'C:\Python36\Scripts' which 
is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress 
this warning, use --no-warn-script-location.


...
...

The scripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, 
toco.exe and toco_from_protos.exe are installed in 'C:\Python36\Scripts' 
which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress 
this warning, use --no-warn-script-location.


However, this directory is in my PATH

*C:\Python36>path*
PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program 
Files (x86)\Intel\iCLS 
Client\;C:\Python36\Scripts\;C:\Python36\;C:\ProgramData\Oracle\Java\javapath;C:\Program 
Files (x86)\Common Files\Intel\Shared Files\cpp\bin\Intel64;C:\Program 
Files\Intel\iCLS 
Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program 
Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\MiKTeX 
2.9\miktex\bin\x64\;

...
...

Why am I getting this message, that I need to consider adding this 
directory to PATH when it is already in PATH?

Note, all of these *.exe files are in C:\Python36\Scripts.
--
https://mail.python.org/mailman/listinfo/python-list


Re: detect laptop open/close from within Python?

2018-04-26 Thread Thomas Jollans
On 26/04/18 17:37, Skip Montanaro wrote:
> I'm going through a bout of RSI problems with my wrists, so klst night
> I refreshed an old typing watcher program I wrote a couple decades ago
> (there's a comment about Python 1.4 in the code!):
> 
> https://github.com/smontanaro/python-bits/blob/master/watch.py
> 
> It's far from perfect and I'm sure miles behind more modern stuff, but
> it does the trick for me.
> 
> I noticed a feww minutes ago that when I opened my laptop it
> immediately locked the screen. It would be nice to get notified of
> open/close events on the laptop. Any idea if there is a signal I can
> catch (Ubuntu 17.10) or a Tk event I can respond to?

I think there's a dbus event that you should be able to listen for (but
I'll let you do the googling as to what that event is, exactly)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: detect laptop open/close from within Python?

2018-04-26 Thread Skip Montanaro
> Thanks, I do have that. Now to figure out when it changes state...
> Unfortunately, the timestamp on the file seems to update continuously,
> not just on state changes. Maybe /proc/acpi/wakeup will be of some
> use.

It appears that I can, at least some of the time. Might need to check
it more frequently than I check for human input, but that will likely
be good enough for my needs.

Thanks again for the pointer.

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


Re: detect laptop open/close from within Python?

2018-04-26 Thread Skip Montanaro
> No idea if it'll work on your system, but on my laptop, there's a
> pseudo-file /proc/acpi/button/lid/LID0/state that has whether the lid
> is open or closed.

Thanks, I do have that. Now to figure out when it changes state...
Unfortunately, the timestamp on the file seems to update continuously,
not just on state changes. Maybe /proc/acpi/wakeup will be of some
use.

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


Re: Data Integrity Parsing json

2018-04-26 Thread Alister via Python-list
On Wed, 25 Apr 2018 14:32:01 -0700, Sayth Renshaw wrote:

> Hi
> 
> Hoping for guidance trying to find some advanced articles or guides or
> topics for json parsing.
> 
> I can parse and extract json just dandy.
> 
> What I am trying to figure out is how I give myself surety that the data
> I parse out is correct or will fail in an expected way.
> 
> All the articles I search are just basic parsing tutorials.
> 
> Can you help with some advice or perhaps some saved away bookmarks you
> have that could be useful.
> 
> Cheers
> 
> Sayth

is there any reason you appear to be re-inventing the wheel rather than 
using the existing json module from the std library?



-- 
"Well, if you can't believe what you read in a comic book, what 
*___can*
you believe?!"
-- Bullwinkle J. Moose [Jay Ward]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: detect laptop open/close from within Python?

2018-04-26 Thread Chris Angelico
On Fri, Apr 27, 2018 at 1:37 AM, Skip Montanaro
 wrote:
> I'm going through a bout of RSI problems with my wrists, so klst night
> I refreshed an old typing watcher program I wrote a couple decades ago
> (there's a comment about Python 1.4 in the code!):
>
> https://github.com/smontanaro/python-bits/blob/master/watch.py
>
> It's far from perfect and I'm sure miles behind more modern stuff, but
> it does the trick for me.
>
> I noticed a feww minutes ago that when I opened my laptop it
> immediately locked the screen. It would be nice to get notified of
> open/close events on the laptop. Any idea if there is a signal I can
> catch (Ubuntu 17.10) or a Tk event I can respond to?
>

No idea if it'll work on your system, but on my laptop, there's a
pseudo-file /proc/acpi/button/lid/LID0/state that has whether the lid
is open or closed.

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


detect laptop open/close from within Python?

2018-04-26 Thread Skip Montanaro
I'm going through a bout of RSI problems with my wrists, so klst night
I refreshed an old typing watcher program I wrote a couple decades ago
(there's a comment about Python 1.4 in the code!):

https://github.com/smontanaro/python-bits/blob/master/watch.py

It's far from perfect and I'm sure miles behind more modern stuff, but
it does the trick for me.

I noticed a feww minutes ago that when I opened my laptop it
immediately locked the screen. It would be nice to get notified of
open/close events on the laptop. Any idea if there is a signal I can
catch (Ubuntu 17.10) or a Tk event I can respond to?

Thx,

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


Re: After update to pip 10 I get: Cache entry deserialization failed, entry ignored

2018-04-26 Thread Cecil Westerhof
tart...@gmail.com writes:

> On Wednesday, April 18, 2018 at 1:59:14 AM UTC-5, Cecil Westerhof wrote:
>> After I updated pip2/3 to 10 from 9 I sometimes get:
>> Cache entry deserialization failed, entry ignored
>> 
>> For example when I execute:
>> pip3 list --outdated
>> 
>> But not always.
>> 
>> What could be happening here? And how would I solve this?
>> 
>> -- 
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>
> It sounds like there's a bug in pip10 that makes the cache entries use a 
> different format for Python2 versus Python3.
> https://github.com/pypa/pip/issues/5250

I have seen that, but that did not work in my case.


> So either:
>
> * erase your cache directory. On *nix it's ~/.cache/pip.

That would make the usage of cache superfluous and I am wondering if
that is really the issue. See reply below.


> or
>
> * run pip with --no-cache-dir

Tried this, but it did not work.


> or
>
> * run pip with --cache-dir=X to set a different cache dir for Python2 vs 
> Python3.
>
> or
>
> * await a pip10 bugfix?

For the moment I do in my (tcl) script:
while {[catch ${command} errorStr opts]} {
incr errors
if {${debug}} {
puts 
puts ${opts}
puts 
}
if {${errors} >= ${maxTries}} {
error "Could not get ${pip} information with ${errors} tries"
}
}

There is not always a problem and if there is a problem it is never
more as once. (Till now.)
I use command because I do it for pip2 and pip3.
It is filled with:
# First 2 lines are a header
set command  {set outdated  \
  [lrange   \
   [split [exec ${pip} list --outdated] \n] \
   2 end]}
And pip is pip2 or pip3.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: After update to pip 10 I get: Cache entry deserialization failed, entry ignored

2018-04-26 Thread tartley
On Wednesday, April 18, 2018 at 1:59:14 AM UTC-5, Cecil Westerhof wrote:
> After I updated pip2/3 to 10 from 9 I sometimes get:
> Cache entry deserialization failed, entry ignored
> 
> For example when I execute:
> pip3 list --outdated
> 
> But not always.
> 
> What could be happening here? And how would I solve this?
> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

It sounds like there's a bug in pip10 that makes the cache entries use a 
different format for Python2 versus Python3.
https://github.com/pypa/pip/issues/5250


So either:

* erase your cache directory. On *nix it's ~/.cache/pip.

or

* run pip with --no-cache-dir

or

* run pip with --cache-dir=X to set a different cache dir for Python2 vs 
Python3.

or

* await a pip10 bugfix?
-- 
https://mail.python.org/mailman/listinfo/python-list