Are there Python modules that allow a program to write to the screen?

2021-04-25 Thread Stephen Tucker
Hi,

I have old software written in GWBASIC that I use to plot diagrams on the
screen.

In Windows 10, I have to resort to using the DOSBox emulator to run it.

I would dearly like to re-write it in Python - ideally Python 2.7.

What, if anything, is available?

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


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread dn via Python-list
This message is not meant as a personal attack.

The intention is to offer criticism of the way a vague question and its
apparently non-specific replies, have produced less than satisfying
'results' - for everyone.


A broad question can be good. I ask them too(!) 'Good', in the sense
that its open-ness allows for a wide-range of replies.

At the same time, the 'problem' with such a width, is that many options
proffered will not suit the specific case. You possess sufficient
understanding of 'the problem' to judge that point. Based (only) upon
what was told in the posted-question, does anyone else?

Thus, can such replies be considered "errors" or "mistakes",
particularly when they are volunteered - and doubly-so when they do
answer some version of an understanding, of some interpretation, of the
vague wording, of the original question?

Don't all problem-solving approaches, such as brain-storming, reject
more ideas than they 'keep' - by definition?


The difficulty with open-ended questions lacking 'anchors', such as
'which database', is that respondents must make assumptions, eg my
earlier response. Obviously, it was useless to you. It was rendered a
complete waste-of-time (both yours and mine), by the single word
"PostgreSQL"! When could I realise that? When did you?

Arguing later, about the appropriateness (or otherwise) of such
assumptions, does not lead to a solution. Similarly, the adding of
previously-unmentioned, but material constraints. How do they affect the
respondent? Positively or negatively? What does the manner in which
these are expressed do for your reputation?


Note also the final exclamation mark of my first response, indicating
the expectation that the provided list be heavily-subject to *your*
interpretations of 'open' and 'ad-hoc' - and my ability to only make
vague assumptions of what you really want...

(it was NOT a question-mark!)


All access to the DB (in this application user-access) should be
controlled by a coordination of VIEWs and ACLs - and thus read-only to
such an application. @Alan offered a serious warning about "risk".
Meantime, I had presumed such as unnecessary. Which view was correct?
Which unnecessary or unhelpful? What in the original question proves such?

A competent DBA would be horrified by the assumption that a user won't
ever access the DB merely because (s)he doesn't "knows SQL", ie
"security by obscurity"!

Further, the very lack of access and security controls is a good reason
not to use SQLite; but the reply to such a suggestion might say that
SQLite/single-user is only a reduced-environment dev/test-tool and thus
irrelevant to the end-user environment. Both 'sides' of which are based
upon yet another assumption!
(NB not a question requesting, or requiring, a written answer!))


Similarly, you defined F/LOSS for me, even though I had indicated
recognition of the $free aspect of the spec: "costs ... to include". As
you probably realise, many others define the term differently, hence
"for varying definitions" - allowing that some will accept Oracle on the
grounds of offering a $free advantage, but also that the corporation
certainly does not follow "open source" principles required/desired by
many others.


You have presumed to explain "ad hoc" to someone who trains the
full-range of users/professionals in the use and management of Databases
- and thus understands it (also) as a term which has a single
'dictionary definition' and yet has come to mean slightly different
things to different people. Similarly, you appear to question warnings
from a(nother) person who has sufficient experience to have quite
literally 'forgotten more about DBs than you (appear to) have learned'.
Were such statements made with assumptions about the respondent? How
could you know about our knowledge/experience - one way or the other?
How could anyone else, about you?


Please notice how the first use of the word "spreadsheet", which can
(now) be assumed to be material in your thinking, does not occur until
the *fourth* exchange.

Hence @Peter's response moving the conversation in a quite different
direction!
(and hopefully one that is more helpful to you)


Is it possible that you have criticised responses, rather than allowing
for the fact that your respondents have necessarily made assumptions?
Would it be more reasonable to assess that any 'fault' is in the
assumption, and that such assumption is directly related to the
wide-open expression of the question? Have your replies appreciated the
freely-given advice and motivation behind them, or have they (perhaps)
had the effect of de-motivating the very people who seek to be helpful
(to you)?

Please note: The questions (above) are Socratic and rhetorical. No reply
is requested or required. They ask you to think about maintaining
constructive relationships. You certainly do not need to explain
yourself to us (nor us to you). Per the opening comment, the idea behind
this message is that we become better at helping each other.

Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Rich Shepard

On Sun, 25 Apr 2021, Peter J. Holzer wrote:


What should that sql query builder build the queries from? Or in other
words what is the user supposed to input?


Peter,


From the dialog box offering tables, columns, and rows from which a SELECT

statement will be constructed.

This is not a console application with a CLI; it has a GUI so there's no
direct access to the backend db from within the application.

Regards,

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


Re: async watch directory for new files

2021-04-25 Thread Gene Heskett
On Saturday 24 April 2021 16:13:50 Zoran wrote:

> > inotifywait contains several variations of a notifier, I use it
> > rather heavly here to automate such goings on as my incoming e-mail.
>
> Can you be more specific about inotifywait?
> Do you have an link or something?

No need for a link or URL, it should be available from the repo's of your 
distro.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Peter J. Holzer
On 2021-04-25 00:05:44 +0100, Alan Gauld via Python-list wrote:
> On 24/04/2021 15:24, Rich Shepard wrote:
> > My web searches are not finding what I need to include in an application I'm
> > building: an ad-hoc sql query builder.

What should that sql query builder build the queries from? Or in other
words what is the user supposed to input?


> > End users will want to query their data for reports not included in the
> > built-in queries.
> 
> I assume you understand the huge risks involved in such a tool.
> Letting users loose on their own data (and possibly other peoples)
> allows for huge potential damage/data loss etc.
> 
> You can reduce the risk by finding ways to limit the access
> to read-only and tightly controlling which tables etc can be
> accessed.

Yes.

> But many SQL builder tools don't do that and simply
> provide a way to create queries, including drop table,

The SQL builder tool isn't the right place to do this. Access privileges
need to be managed in the database.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Rich Shepard

On Sun, 25 Apr 2021, Alan Gauld via Python-list wrote:


I assume you understand the huge risks involved in such a tool. Letting
users loose on their own data (and possibly other peoples) allows for huge
potential damage/data loss etc.


Alan,

I disagree about the risk. Regardless of the form of the Select statement it
does not delete any rows. Users will be able to specify attributes (columns)
and instances (rows) but not delete or update any table.


You can reduce the risk by finding ways to limit the access to read-only
and tightly controlling which tables etc can be accessed.



But many SQL builder tools don't do that and simply provide a way to
create queries, including drop table, delete from etc. (Quite reasonably
since they are usually aimed at DBAs rather than ordinary users)


That's if the inclusion of the tool allows it.

Of course, if the user knows SQL they could do what they want directly on
the database ignoring the application entirely. If they knew enough to do
this they would be using a database rather than a spreadsheet in the first
place. :-)

Regards,

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


Re: async watch directory for new files

2021-04-25 Thread Zoran
Anyway, thanks for participating.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: async watch directory for new files

2021-04-25 Thread Zoran
> inotifywait contains several variations of a notifier, I use it rather 
> heavly here to automate such goings on as my incoming e-mail. 

Can you be more specific about inotifywait?
Do you have an link or something?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "py.ini" question

2021-04-25 Thread Alan Gauld via Python-list
On 24/04/2021 15:23, Gisle Vanem wrote:
> I have a question about the Python launcher;
>c:\Windows\py.exe and the py.ini file.
> 
> I have both Python 3.6 (32-bit) and Python 3.8 (64-bit)
> installed. And I have a 'c:\Users\Gisle\AppData\Local\py.ini'
> with this only:
>[defaults]
>python=3.6

I don't really use python on Windows so don't use this file.

However, based on some of the other responses, what happens
if you don't specify a version? ie. just type

py -c "...

And also what happens if you add an explicit python3 line as
in Barry's example:

[defaults]
python=3.6
python3=3.6

As I say, pure speculation on my part. But if it helps...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: Ad-hoc SQL query builder for Python3?

2021-04-25 Thread Alan Gauld via Python-list
On 24/04/2021 15:24, Rich Shepard wrote:
> My web searches are not finding what I need to include in an application I'm
> building: an ad-hoc sql query builder.
> 
> End users will want to query their data for reports not included in the
> built-in queries.

I assume you understand the huge risks involved in such a tool.
Letting users loose on their own data (and possibly other peoples)
allows for huge potential damage/data loss etc.

You can reduce the risk by finding ways to limit the access
to read-only and tightly controlling which tables etc can be
accessed. But many SQL builder tools don't do that and simply
provide a way to create queries, including drop table,
delete from etc. (Quite reasonably since they are usually
aimed at DBAs rather than ordinary users)

As a minimum ensure you have auto-backup processes in
place every time the tool is opened.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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


Re: "py.ini" question

2021-04-25 Thread Ralf M.

Am 25.04.2021 um 16:30 schrieb Mats Wichmann:


On 4/24/21 2:57 PM, Chris Angelico wrote:
On Sun, Apr 25, 2021 at 5:57 AM Gisle Vanem  
wrote:


With 'py -3.6' or 'py 3.8' I get the expected.
But with 'py -3':
    Python 3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit 
(AMD64)] on win32


I believe that's because you're asking for "the latest in the 3.x 
series".


unless differently described by the ini file, which is what the OP is 
trying to do.


I just added a 3.10 alpha to my Windows setup (I don't do my programming 
there, so there hadn't been any need), and set up an ini file to leave 
3.9 as the default and all works as expected - py -0, py, py -3, py 
-3.10 all given me the one I would expect to get based on that setup (-0 
shows 3.9-64 starred, despite 3.10-64 being "the latest).


Personally stumped why it's not working for Gisle.


I think the problem / misunderstanding is that Gisle put in py.ini only
 [defaults]
 python=3.6

and expected this to make py -3 start 3.6. However py -3 looks for a key 
named 'python3' and, not finding it, uses default behaviour (ignoring 
the 'python' key), i.e. starts the most modern stable 3.x.


The py.ini documentation is a bit hard to find in the help file and hard 
to understand as the interesting part talks about environment variables 
and shebang line commands, not py.ini settings and py.exe parameters. 
However, the behaviour is the same in both cases and the relevant 
example is:


"If PY_PYTHON=3.1-32, the command python will use the 32-bit 
implementation of 3.1 whereas the command python3 will use the latest 
installed Python (PY_PYTHON was not considered at all as a major version 
was specified.)"


I tried the (rather insane) py.ini
 [defaults]
 python=3.7
 python2=3.8
 python4=2.7
and it works as documented (py -3 shows default behaviour as there is no 
'python3' in py.ini):


C:\>py
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 
64 bit(AMD64)] on win32

C:\>py -2
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 
bit (AMD64)] on win32

C:\>py -3
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 
bit (AMD64)] on win32

C:\>py -4
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:19:08) [MSC v.1500 32 
bit (Intel)] on win32





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


Re: async watch directory for new files

2021-04-25 Thread Chris Angelico
On Mon, Apr 26, 2021 at 4:56 AM Zoran  wrote:
>
> > 
> >
> > Implementations are usually just callback-based. (Apologies for the
> > generic link, I haven't needed this in Python yet: anyway, those are the
> > keywords.)
>
> :) before asking a question here I googled the subject a lot.

We couldn't tell that from your question.

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


Re: async watch directory for new files

2021-04-25 Thread Zoran
>  
> 
> Implementations are usually just callback-based. (Apologies for the 
> generic link, I haven't needed this in Python yet: anyway, those are the 
> keywords.) 

:) before asking a question here I googled the subject a lot.
Anyway, the simplest solution is this one:

import asyncio
import pathlib
from watchgod import awatch, Change

watch_dir = pathlib.Path(r'C:\Users\User\watch_folder')


async def main():
async for changes in awatch(str(watch_dir)):
while changes:
change_type, path = changes.pop()
if change_type == Change.added:
print('processing:', path)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

watchgod library is quite young. I hope that there will be no suprises.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "py.ini" question

2021-04-25 Thread Mats Wichmann



On 4/24/21 2:57 PM, Chris Angelico wrote:

On Sun, Apr 25, 2021 at 5:57 AM Gisle Vanem  wrote:


With 'py -3.6' or 'py 3.8' I get the expected.
But with 'py -3':
Python 3.8.9 (default, Apr 13 2021, 15:54:59)  [GCC 10.2.0 64 bit (AMD64)] 
on win32


I believe that's because you're asking for "the latest in the 3.x series".


unless differently described by the ini file, which is what the OP is 
trying to do.


I just added a 3.10 alpha to my Windows setup (I don't do my programming 
there, so there hadn't been any need), and set up an ini file to leave 
3.9 as the default and all works as expected - py -0, py, py -3, py 
-3.10 all given me the one I would expect to get based on that setup (-0 
shows 3.9-64 starred, despite 3.10-64 being "the latest).


Personally stumped why it's not working for Gisle.
--
https://mail.python.org/mailman/listinfo/python-list