Re: type annotations for xpath list

2020-04-08 Thread Martin Alaçam
Hi,

Thanks for the answer. I just discovered the problem had nothing to do with
xpath, but with the initial value of the descriptor.
This fixed it:

self._pi: List[etree.Element] = []


On Thu, Apr 9, 2020 at 2:29 AM DL Neil via Python-list <
python-list@python.org> wrote:

> On 9/04/20 10:02 AM, Martin Alaçam wrote:
> > Hello,
> >
> > I have the following descriptor:
> >
> >  self._pi = None
> >  @property
> >  def pi(self) -> list:
> >  self._pi = self._root.xpath('processing-instruction()')
> >  return self._pi
> >
> > Mypy says: "Incompatible return value type (got "None", expected
> > "List[Any]")"
> > The xpath expression always returns a list, if it doesn't find anything
> it
> > is an empty list. I am just getting started with type hinting, would
> > appreciate any help.
>
>
> Out of interest, what happens if you change the function to:
>
> self._pi:list = self._root.xpath('processing-instruction()')
>
> Mypy *seems* to be remembering the type from the outer namespace and
> noting that the function's use of the same name differs. (yes, you had
> probably worked-out that for yourself)
>
>
> Interestingly-enough, in a recent (off-line) communication with another
> list-member, we noted similar behavior from (?) a linter or was it Black
> ("the uncompromising code formatter"), and concluded that because using
> the same identifier in both 'inner' and 'outer' name-spaces can lead to
> awkward 'gotchas' in certain situations, a general advice/'rule' of:
> 'don't do it' is being applied.
>
> Perhaps there is another/a better reason that someone else will provide...
>
>
> Disclaimers:
> - Python typing (and thus: mypy) has a somewhat experimental approach
> and is not a required part of the language, nor even particularly
> integrated into the language, as-such.
> - linters are useful to some people, particularly those which have an
> option to turn-off individual aspects which otherwise become 'nagging'.
> - some find Black useful, but to me its "uncompromising" philosophy
> seems non-pythonic (IMHO) - and I won't recommend anything that thinks
> it should make decisions because I'm too stupid (see also Apple, MSFT,
> Google, ...).
> - the latter assessment may be correct, but not IMHO.
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type annotations for xpath list

2020-04-08 Thread DL Neil via Python-list

On 9/04/20 10:02 AM, Martin Alaçam wrote:

Hello,

I have the following descriptor:

 self._pi = None
 @property
 def pi(self) -> list:
 self._pi = self._root.xpath('processing-instruction()')
 return self._pi

Mypy says: "Incompatible return value type (got "None", expected
"List[Any]")"
The xpath expression always returns a list, if it doesn't find anything it
is an empty list. I am just getting started with type hinting, would
appreciate any help.



Out of interest, what happens if you change the function to:

self._pi:list = self._root.xpath('processing-instruction()')

Mypy *seems* to be remembering the type from the outer namespace and 
noting that the function's use of the same name differs. (yes, you had 
probably worked-out that for yourself)



Interestingly-enough, in a recent (off-line) communication with another 
list-member, we noted similar behavior from (?) a linter or was it Black 
("the uncompromising code formatter"), and concluded that because using 
the same identifier in both 'inner' and 'outer' name-spaces can lead to 
awkward 'gotchas' in certain situations, a general advice/'rule' of: 
'don't do it' is being applied.


Perhaps there is another/a better reason that someone else will provide...


Disclaimers:
- Python typing (and thus: mypy) has a somewhat experimental approach 
and is not a required part of the language, nor even particularly 
integrated into the language, as-such.
- linters are useful to some people, particularly those which have an 
option to turn-off individual aspects which otherwise become 'nagging'.
- some find Black useful, but to me its "uncompromising" philosophy 
seems non-pythonic (IMHO) - and I won't recommend anything that thinks 
it should make decisions because I'm too stupid (see also Apple, MSFT, 
Google, ...).

- the latter assessment may be correct, but not IMHO.
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Troubling running my Python

2020-04-08 Thread Terry Reedy

On 4/8/2020 3:12 PM, Lorraine Healy wrote:


I have downloaded the 3.8 64 bit python program to my PC but the
interpreter will not run. It seems to have 'repaired' itself when I ran the
setup again but the interpreter still  won't run.
Is there a reason for this?


You are rerunning the installer instead of running the program that was 
installed.  See other response on how to do the latter.



--
Terry Jan Reedy

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


type annotations for xpath list

2020-04-08 Thread Martin Alaçam
Hello,

I have the following descriptor:

self._pi = None
@property
def pi(self) -> list:
self._pi = self._root.xpath('processing-instruction()')
return self._pi

Mypy says: "Incompatible return value type (got "None", expected
"List[Any]")"
The xpath expression always returns a list, if it doesn't find anything it
is an empty list. I am just getting started with type hinting, would
appreciate any help.

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


Re: Fwd: Troubling running my Python

2020-04-08 Thread bob gailer



On 4/8/2020 3:35 PM, Michael Torrie wrote:

Assuming Windows here.
The Python interpreter does nothing without a python program to run (to
interpret).  Thus if you simply double click on python.exe it will do
nothing.


That does not match my experience. I get the interactive prompt:

Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 
bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.
>>>

Bob Gailer

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


Re: Fwd: Troubling running my Python

2020-04-08 Thread bob gailer



On 4/8/2020 3:12 PM, Lorraine Healy wrote:

-- Forwarded message -
From: Lorraine Healy 
Date: Wed, Apr 8, 2020 at 12:11 PM
Subject: Troubling running my Python
To: 


Hi,

I have downloaded the 3.8 64 bit python program to my PC but the
interpreter will not run. It seems to have 'repaired' itself when I ran the
setup again but the interpreter still  won't run.
Is there a reason for this? Do you require a screenshot?


Which operating system are you using?

Exactly what do you do to "run the intepreter"? Copy and paste your 
actions and any messages.


Bob Gailer

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


Re: Fwd: Troubling running my Python

2020-04-08 Thread Michael Torrie
On 4/8/20 1:12 PM, Lorraine Healy wrote:
> Hi,
> 
> I have downloaded the 3.8 64 bit python program to my PC but the
> interpreter will not run. It seems to have 'repaired' itself when I ran the
> setup again but the interpreter still  won't run.
> Is there a reason for this? Do you require a screenshot?

Assuming Windows here.

The Python interpreter does nothing without a python program to run (to
interpret).  Thus if you simply double click on python.exe it will do
nothing.  Instead you need to create python programs using a text
editor, which you can then run from a command prompt.

Usually included with the Python install is a program called "Idle"
which is an integrated editor, debugger, and runtime environment.  Look
for it in your start menu.

Most python programmers prefer to use a text editor they like, and run
programs from the command prompt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Troubling running my Python

2020-04-08 Thread DL Neil via Python-list

I have downloaded the 3.8 64 bit python program to my PC but the
interpreter will not run. It seems to have 'repaired' itself when I ran the
setup again but the interpreter still  won't run.
Is there a reason for this? Do you require a screenshot?



Welcome to Python!

This is an FAQ because Python works differently to the way many 
MS-Windows users expect. Try: 
https://docs.python.org/3/using/windows.html and let us know if you have 
further questions.


The Python documentation is well worth investigation...
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Fwd: Troubling running my Python

2020-04-08 Thread Lorraine Healy
-- Forwarded message -
From: Lorraine Healy 
Date: Wed, Apr 8, 2020 at 12:11 PM
Subject: Troubling running my Python
To: 


Hi,

I have downloaded the 3.8 64 bit python program to my PC but the
interpreter will not run. It seems to have 'repaired' itself when I ran the
setup again but the interpreter still  won't run.
Is there a reason for this? Do you require a screenshot?

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


Re: ModuleNotFoundError, even though I can see module in dist-packages folder, Setuptools / EGG issue?

2020-04-08 Thread John Ladasky
On Wednesday, April 8, 2020 at 10:47:42 AM UTC-7, John Ladasky wrote:
> Hi folks,
> 
> Something broke in my Python installation in the past two or three days.  I'm 
> working in Ubuntu 19.10 and Python 3.7, without virtual environments.  
> 
> I have two modules of Python source code that I am developing.  I regularly 
> change this code and "distribute" it to myself using setuptools.  From the 
> command prompt in the module's base folder, I execute:
> 
>   python3 setup.py sdist
>   sudo python3 setup.py install
> 
> That process has been working for me for years.  But after recent rebuilds, 
> when I try to import those modules today, I get ModuleNotFoundErrors for each 
> of them.  I tried importing other modules that were installed by pip3.  They 
> work fine.
> 
> I looked in /usr/local/lib/python3.7/dist-packages.  The one thing that is 
> unique to my two packages is the .egg extension at the end of the file names. 
>  Oddly, one of the two modules is a single .egg archive file, and the other 
> is a normal folder with folders inside it, despite the .egg extension in the 
> name.
> 
> A third package of mine which I did not build recently appears as a normal 
> sub-folder within dist-packages, and it imports correctly.
> 
> What is setuptools supposed to do?  Why has its behavior apparently changed?  
> Hope someone can offer some advice.  Thanks.

Followup observation:

One of the two Python packages I'm building using setuptools depends on 
argparse 1.4.  The default version of argparse in my Python 3.7 distro is 1.1. 
 I watched setuptools fetch argparse 1.4 from the Net when I built it.

When I start my Python interpreter and import argparse, I get version 1.1.

I found an argparse 1.4 sub-folder in my site-packages folder.  It was built 
yesterday.  It has a .egg extension, just like my two modules that won't import.
-- 
https://mail.python.org/mailman/listinfo/python-list


ModuleNotFoundError, even though I can see module in dist-packages folder, Setuptools / EGG issue?

2020-04-08 Thread John Ladasky
Hi folks,

Something broke in my Python installation in the past two or three days.  I'm 
working in Ubuntu 19.10 and Python 3.7, without virtual environments.  

I have two modules of Python source code that I am developing.  I regularly 
change this code and "distribute" it to myself using setuptools.  From the 
command prompt in the module's base folder, I execute:

  python3 setup.py sdist
  sudo python3 setup.py install

That process has been working for me for years.  But after recent rebuilds, 
when I try to import those modules today, I get ModuleNotFoundErrors for each 
of them.  I tried importing other modules that were installed by pip3.  They 
work fine.

I looked in /usr/local/lib/python3.7/dist-packages.  The one thing that is 
unique to my two packages is the .egg extension at the end of the file names.  
Oddly, one of the two modules is a single .egg archive file, and the other is a 
normal folder with folders inside it, despite the .egg extension in the name.

A third package of mine which I did not build recently appears as a normal 
sub-folder within dist-packages, and it imports correctly.

What is setuptools supposed to do?  Why has its behavior apparently changed?  
Hope someone can offer some advice.  Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python - Suppress input while writing to window

2020-04-08 Thread Paraskevas Petsanas
Hi,
I am developing an app that monitors and corrects the user input based on some 
rules.
I am reading the events from keyboard with the keyboard python module.
I faced some problem when the user types very fast, as regards some overlays of 
text. By this I mean that when my app writes the correct input, the user 
continues writing and may writes before the corrector types the whole word.
I found, that I can start a keyboard hook with suppressed output to screen and 
tried to implements a solution.
In the above code I tried recreating the problem and tried giving the general 
idea. 

```
import keyboard
from collections import deque

string : str = ""
counter : int = 0
is_suppressed: bool = False # this indicates if letters are shown in the window 
or not
suppressed_string: str = ""
q = deque() # this is used as a buffer, and stores the words that are entered 
when the
# program is correcting


def keyboard_module_write_to_screen(is_suppressed, string):
for i in range(len(string) + 1):
print("--Pressing backspace--")
keyboard.press_and_release('backspace')
for i, char in enumerate (string): # simulating a calculation 
final_char_to_be_written = char.upper()
print("---WRITING THE CHAR -> {} 
---".format(final_char_to_be_written))
keyboard.write(final_char_to_be_written)
for i in range(30):
keyboard.write('*')
keyboard.write(' ')

def monitoring(event):
global counter, string, is_suppressed, suppressed_string

if (event.event_type == keyboard.KEY_DOWN): # and event.name != 
'backspace'):
print("-String entered : {}".format(event.name))

if (event.name == 'space'):
# if space is button a new word is entered
if (is_suppressed is True):
# if program occupied writing to the screen save the word 
to the buffer
q.appendleft(suppressed_string)
suppressed_string = ""

elif (is_suppressed is False):
# check and write first from the deque,
# write the word(s) that were stored in the buffer 
before writing current
# input string
# haven't find a way to do the above alongside the 
others
keyboard.unhook_all()
keyboard.hook(monitoring, suppress = True)

is_suppressed = True

keyboard_module_write_to_screen(is_suppressed, string)

keyboard.unhook_all()
keyboard.hook(monitoring, suppress = False)
is_suppressed = False
counter = 0
string = ""

elif (event.name in "abcdefghijklmnopqrstuvwxyz") :
if (is_suppressed is True):
suppressed_string = ''.join([suppressed_string, event.name])
print("## SUPPRESSED_STRING = {} 
#".format(suppressed_string))

counter = counter + 1
print("-- COUNTER is : {}".format(counter))
string = ''.join([string, event.name])
elif (event.name == "]"):
print(q)
elif (event.name == 'backspace'):
pass

keyboard.hook(monitoring, suppress = False)
```
The main thing I want to achieve is
1)while correcting - writing to the window, read events and save them to a 
buffer
2)when correcting - writing is done check the buffer, write it's content, but 
keep reading events
3)if buffer empty and currently not writing something, read events etc.
I didn't manage to make it work and produce the desired result.
Any advice on how to make it work, would be useful.
Thanks in advance for any help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NLP Project with Python

2020-04-08 Thread joseph pareti
if you want to do work in NLP there are numerous opportunities, especially
with the virus oubreak
see e.g.
https://www.cnbc.com/2020/03/03/bluedot-used-artificial-intelligence-to-predict-coronavirus-spread.html

Am Mi., 8. Apr. 2020 um 09:18 Uhr schrieb :

> Hello everyone
> I`m new to python. I need to select a project idea so that I can work with
> it during this semester. the project should be in the area of business and
> finance
> at first I was thinking of creating a project using NLP but I don`t know
> what exactly to create
> also I would like to create something related to blockchain, such as
> tracking the currency at which its sold and bought, customers reviews and
> the value of cryptocurrencies during this outbreak of the coronavirus
> I welcome all your ideas just please inspire me. I`m lost in my own
> thoughts.
> thanks in advance
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
-- 
https://mail.python.org/mailman/listinfo/python-list


NLP Project with Python

2020-04-08 Thread dreamyladygirl
Hello everyone
I`m new to python. I need to select a project idea so that I can work with it 
during this semester. the project should be in the area of business and finance
at first I was thinking of creating a project using NLP but I don`t know what 
exactly to create
also I would like to create something related to blockchain, such as tracking 
the currency at which its sold and bought, customers reviews and the value of 
cryptocurrencies during this outbreak of the coronavirus
I welcome all your ideas just please inspire me. I`m lost in my own thoughts.
thanks in advance 
-- 
https://mail.python.org/mailman/listinfo/python-list