Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread Michael Torrie via Python-list
On 12/22/23 20:16, rbowman via Python-list wrote:
> On Fri, 22 Dec 2023 17:27:58 -0700, Michael Torrie wrote:
> 
>> Using the py launcher as your Windows association with .py and.pyw files
>> you can have multiple versions of python installed and everything works
>> as it should, according to your shebang, just like on Unix.
> 
> Does that work with virtualenv or conda? I'm slowly getting up to speed 
> with those.

I don't know. I imagine py is aware of venv if you run it from the
command line within the activated venv.  But I doubt it is if you launch
the python script by double-clicking on it from Explorer.

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


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-23 Thread Michael Torrie via Python-list
On 12/22/23 20:56, Thomas Passin via Python-list wrote:
> It's just better not to make assumptions about which version of Python 
> will be running. Just specify it yourself when you can, and then you can 
> be sure.

Precisely, which is why the shebang is so useful, even on Windows with
py launcher.  For example, set the shebang to:

#!/usr/bin/python3.6

And py launcher will always try to run it with Python 3.6.

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


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Michael Torrie via Python-list
On 12/22/23 07:02, Thomas Passin via Python-list wrote:
> On my Windows 10 machine, Python scripts run without a shebang line. 
> Perhaps Windows 11 has added the ability to use one, but then you would 
> need to use the actual location of your Python executable.

Yes if you associate .py or .pyw with python.exe (or pythonw.exe), then
things work as you describe.  However it's no longer recommended to do
that.

Instead---and I think this is the default now when you install
python---you should associate both .py and .pyw files with the py
launcher (py.exe) and it will examine the shebang line of the script and
determine which version of python to run. As I said this should work
regardless of the path listed in the shebang.  Note that the shebang is
meaningless to Windows itself, and Windows Explorer. It is only
meaningful to the py launcher.  So it's customary to just use a
unix-style shebang in your python scripts.  So either #!/usr/bin/python3
or #!/usr/bin/env python3 as you would in unix.

Using the py launcher as your Windows association with .py and.pyw files
you can have multiple versions of python installed and everything works
as it should, according to your shebang, just like on Unix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2023-12-22 Thread Michael Torrie via Python-list
On 12/22/23 11:42, Thomas Passin via Python-list wrote:
> There is some important context that is missing here.  Python on Windows 
> does not normally install to that location.  That is not even a Windows 
> path, neither by directory name nor by path separators.

No, that's just the way the py launcher on Windows has always worked in
the past. This way you can take a script from a nix system and drop it
in Windows and it has half a chance of running through the launcher,
from Windows explorer, or by running py myscript.py at the command
propmpt.  The Py launcher essentially ignores (or used to ignore) the
path in the shebang and focuses on what version of Python it should fire
up.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: on a tail-recursive square-and-multiply

2023-11-07 Thread Michael Torrie via Python-list
On 11/7/23 18:26, Julieta Shem via Python-list wrote:
> For the first time I'm trying to write a tail-recursive
> square-and-multiply and, even though it /seems/ to work, I'm not happy
> with what I wrote and I don't seem to understand it so well.
> 
> --8<---cut here---start->8---
> def sam(b, e, m, acc = 1):
>   if e == 0:
> return acc
>   if is_even(e):
> return sam(remainder(b * b, m), e//2, m, acc)
>   else:
> return sam(b, e - 1, m, remainder(b * acc, m))
> --8<---cut here---end--->8---

I don't see any definition of "remainder()"  When you post to the list,
please provide short but complete code, including a demonstration of
using the code provided. That will help others understand what you are
trying to do, and perhaps comment on your concerns.

> You see, I tried to use an accumulator, but I'm only accumulating when
> the exponent is odd.  When it's even, I feel I'm forced to change the
> base into b * b mod m and leave the accumulator alone.  This feels so
> unnatural to me.  I feel I broke some symmetry there.  I'm having to
> think of two cases --- when I change the accumulator and when I change
> the base.  That seems too much for my small head.  Can you help?

I don't really understand the code either, so I cannot help much.

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


Re: Checking if email is valid

2023-11-04 Thread Michael Torrie via Python-list
On 11/4/23 02:51, Simon Connah via Python-list wrote:
> Wow. I'm half tempted to make a weird email address to see how many websites 
> get it wrong.
> 
> Thank you for the link.

Nearly all websites seem to reject simple correct email addresses such
as myemail+sometext@example.domain.  I like to use this kind of email
address when I can to help me filter out the inevitable spam that comes
from companies selling off my address even after claiming they won't.

So I suspect that nearly all websites are going to reject other kinds of
weird email addresses you can create that are actually correct.

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


Re: Checking if email is valid

2023-11-02 Thread Michael Torrie via Python-list
On 11/2/23 00:42, Simon Connah via Python-list wrote:
> Basically I'm writing unit tests and one of them passess in a string 
> with an invalid email address. I need to be able to check the string 
> to see if it is a valid email so that the unit test passess.

If you truly have managed to code an RFC-compliant verifier, I commend you.

> Valid as in conforms to the standard. Although having looked at the
> standard that might be more difficult than originally planned.

You'll have to read the relevant RFCs.  Lots of corner cases!  From what
I can see virtually no one on the internet gets it right, judging by the
number of times I have valid email addresses flagged as not valid by
poor algorithms.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Checking if email is valid

2023-11-01 Thread Michael Torrie via Python-list
On 11/1/23 04:09, Simon Connah via Python-list wrote:
> Hi,
> 
> I'm building a simple project using smtplib and have a question. I've been 
> doing unit testing but I'm not sure how to check if an email message is 
> valid. Using regex sounds like a bad idea to me and the other options I found 
> required paying for third party services.
> 
> Could someone push me in the right direction please? I just want to find out 
> if a string is a valid email address.

If I had a nickle for every time a web site claimed my email address
wasn't valid I'd be a rich person.  Seems like most attempts at solving
this little problem fall short!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-26 Thread Michael Torrie via Python-list
On 10/26/23 10:41, Michael Torrie wrote:
> By the way you definitely can step
> through MicroPython code one line at a time with a remote debugger, say
> with Visual Studio Code.

I meant to edit that bit out.   After doing a bit more research, it
appears remote debugging with MicroPython may not be possible or easy.
But the MicroPython lists and forums will know more about that than I
do.  But there are some nice IDEs for developing code in MicroPython and
deploying it to devices.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-26 Thread Michael Torrie via Python-list
On 10/26/23 06:34, o1bigtenor wrote:
> Interesting - - - -  ". . . see if it runs." - - - that's the issue!
> When the code is accessing sensors there isn't an easy way to
> check that the code is working until one has done the all of the
> physical construction. If I'm trying to control a pulsation system
> using square waves with distinct needs for timing etc I hadn't
> seen any way of 'stepping through the code' (phrase you use later).

Having dabbled in embedded electronics, all I can say is you will just
have to build it and try to get it working.  Failure is always an
option.  If I understand you correctly, this is for a hobby interest, so
go at it and have fun.

Stepping through code is a basic part of debugging in any language.
They all have tools for it. Google for python debugging.

"distinct needs for timing?"  Did you forget to tell us you need to use
MicroPython?  Certainly MicroPython running on a microcontroller with
help from hardware timers certainly can do it, but this mailing list is
not the place to ask about it.  Instead you'll have to visit a forum on
MicroPython or CircuitPython.  By the way you definitely can step
through MicroPython code one line at a time with a remote debugger, say
with Visual Studio Code.

> I have been following this list for some time. Don't believe that I've ever
> seen anything where anyone was referred to 'Idle'.  In reading other user
> group threads I have heard lots about java and its ide - - - don't remember,
> again, any re: an ide for python.

Idle has been mentioned on several occasions, but probably more on the
python-tutor list.  I find it hard to believe that searching for Python
IDEs really came up blank.  There are even IDEs for MicroPython and
embedded devices.  I found a nice list with a quick search.

> Even in maker threads - - - say for arduino - - its 'use this cut and
> paste method
> of programming' with no mention of any kind of ide when it was microPython - -
> although being a subset of python it Idle may not work with it.

You keep dropping little details that, had you included them in the
first post, would have helped avoid a lot of answers that ultimately
aren't going to be useful to you.  Are you working MicroPython or with
regular Python on a PC?  That makes a big difference in where you go to
get help and what kind of help we can provide here.

> Oh well - - - I am working on things!

That is good.  I wish you success.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question(s)

2023-10-25 Thread Michael Torrie via Python-list
On 10/25/23 05:51, o1bigtenor via Python-list wrote:
> Looks like I have another area to investigate. (grin!)
> Any suggestions?

Seems to me you're trying to run before you have learned to walk.

Slow down, go to the beginning and just learn python, write some code,
see if it runs.  Go through the tutorial at
https://docs.python.org/3/tutorial/index.html

Your first and most basic tool is the python interpreter.  It will tell
you when you try to run your code if you have syntax errors.  It's true
that some errors the linters will catch won't show up as syntax errors,
but cross the bridge when you get to it.  Once you have a basic grasp of
Python syntax, you can begin using some of the tools Python has for
organizing code: Functions and modules (eventually packages).
Eventually when your logic is placed neatly into functions, you can then
write other python programs that import those functions and feed
different parameters to them and test that the output is what you
expect. That is known as a test.

Nothing wrong with geany as an editor.  However, you might find the
Python Idle IDE useful (it usually installs with Python), as it lets you
work more interactively with your code, inspecting and interacting with
live python objects in memory.  It also integrates debugging
functionality to let you step through your code one line at a time and
watch variables and how they change.

When you encounter isses with your code (syntax or logical) that you
can't solve, you can come to the list, show your code and the full
output of the interpreter that shows the complete error message and back
trace and I think you'll get a lot of helpful responses.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where I do ask for a new feature

2023-10-20 Thread Michael Torrie via Python-list
On 10/19/23 19:32, Bongo Ferno via Python-list wrote:
> 
>> You can actually just do that with simple assignment! 
>>
>> short_view = my_object.stuff.long_stuff.sub_object 
>> print(short_view.some_method()) 
> 
> but then have to delete the variable manually
> 
> del short_view 

Why? It's just a name in the namespace that you can bind to a function
object.  You can ignore it or rebind it later to something else. There's
no need to del it, although you can. I'm not sure why you want to del
it.  It's not like a memory leak or something like that.

I suspect we might also have a misunderstanding of what python variables
are and how they work, which is why I did not use the word, "reassign"
but rather "bind" or "rebind."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Is npyscreen still alive?

2023-04-24 Thread Michael Torrie
On 4/24/23 08:04, Grant Edwards wrote:
> Is putty running on Windows a "modern terminal emulator" in this
> context?  After observing some of the local IT types work, I suspect
> that will be a common use-case for the app I'm working on.

Yes, Putty qualifies as a "modern terminal emulator."  It supports UTF-8
and unicode fonts.  And the mouse events work as well.  The only catch
is the default font is courier new which seems to not have some of the
line drawing characters in it. But if I change to something like
Cascadia Code it looks very good.

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


Re: Is npyscreen still alive?

2023-04-24 Thread Michael Torrie
On 4/21/23 15:57, Barry wrote:
> Maybe this, recently lwn.net article, https://textual.textualize.io/
> I was planning to check it out.

Textual definitely looks slick and modern.  And with a modern terminal
emulator it works quite well and is responsive.  I'd definitely consider
it for a TUI.

But on the Linux console, or on an older terminal, not so much.
Textual's really designed for smallish unicode fonts in a windowed
environment, not any kind of real, old-school text mode.  Just something
to keep in mind.  99% of terminal users are using a modern terminal
emulator these days, with full color and unicode, which is the target of
textual.

Curses-based programs don't look great on anything, but they do look
consistent on more primitive terminals.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Christoph Gohlke and compiled packages

2023-04-11 Thread Michael Torrie
On 4/11/23 11:48, Oscar Benjamin wrote:
> You can hardly blame a lot of people for doing this. A seb search for
> "download python" gives this as the first hit:
> https://www.python.org/downloads/

Very true, but it points to the difference between how people install
Python on Windows compared to Linux, which is what Chris was probably
referring to when he said Windows was a nightmare to support.  Usually
when a full version bump of python hits my distros, all the other
packages that need to be rebuilt get rebuilt and install along with the
new python package.  Or often the older version of Python is patched and
continued to be used, not requiring new packages.  So most linux users
never have to go searching for an appropriate version of Numpy, etc.

Whereas Windows only recently has gained a package manager, and as near
as I can tell is not widely used outside of serious developers who use
Visual Studio.  And to make matters worse, MS offers Python in the
Windows Store, which is its own thing and causes much confusion with
users who often end up with more than one version of Python installed.
And nevermind the MingW/MSVC split that affects the distribution of
pre-built binaries, although MS's move to the universal C runtime dll
system might fix this finally (unless C++ is involved).

These are all extremely hard problems to solve, and every solution has
its drawbacks, including the packaging systems used by Linux.
Especially by an open source organization like the PSF.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Gui Frontend

2023-04-02 Thread Michael Torrie
On 2023-04-02 9:09 a.m., Dietmar Schwertberger wrote:
>> I've tried wxGlade but never could get into it, or wxWidgets in general.
> 
> Which version? Up to 0.7.2 I agree.

Been a long time. I was initially turned off by the event handling
system of wx compared to the signals and slots of Gtk and Qt.

> For me QtQuick and QML are a step backwards by some ten years when
> it comes to development speed.
> It's as much 'fun' as doing GUIs with HTML and JavaScript.
> Unfortunately, The Qt Company refused to provide an API for QtQuick to
> be able to use it without QML.
> Anyway, desktop development has long moved out of their focus
> (around 15 years ago when Nokia acquired Trolltech). It's not where
> their commercial customers are.

There are a number of desktop apps built in QtQuick.  KDE is
transitioning to QtQuick and it's been alright, not without some
consistency issues.  The Cura slicer is another example of a complete
desktop app written in QtQuick which looks and feels quite nicely on all
platforms.

For me, more and more I need to be able to run on mobile as well as
desktop.  Qt, GTK, or wx are just not good fits when you need that kind
of portability.

But traditional Qt will be with us or decades yet.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Gui Frontend

2023-04-02 Thread Michael Torrie
On 2023-04-02 9:09 a.m., Dietmar Schwertberger wrote:
> That's what I hated with Qt Designer: it does not output Python code 
> but  a .ui file.
> This was the point where I could not recommend it to anyone.

Well the thing is you don't need to generate Python code at all.  Qt
provides a UI loader class that loads the UI file at run time, builds
the objects in memory, and connects all your signals for you.  So much
nicer than code generation.


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


Re: Windows Gui Frontend

2023-04-02 Thread Michael Torrie
On 4/1/23 09:37, Eryk Sun wrote:
> Here are a few of the GUI toolkit libraries in common use:
> 
> * tkinter (Tk)
> * PyQt (Qt)
> * PySide (Qt)
> * wxPython (wxWidgets)
> * PyGObject (GTK)
> 
> tkinter is included in Python's standard library.

Another good one is Kivy.  Especially if you ever want to target mobile
in the future.  https://kivy.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Gui Frontend

2023-04-02 Thread Michael Torrie
On 4/2/23 05:09, Dietmar Schwertberger wrote:
> I also did evaluate all the GUI builder from time to time between
> 2000 and 2016 to find one that I could recommend to colleagues,
> but could not find one. Then I started contributing to wxGlade
> and I can say that since a few years it's as easy again to
> build GUIs as it was with VB6.
> 
> I don't want to go back to coding GUIs manually. For most use
> cases it's a waste of time and often it does not result in the
> best GUI as it's not so easy to try out and rearrange elements.

But any modern GUI toolkit has sizers and layout managers. If you're
manually placing elements you cannot deal with HiDPI or changing window
sizes.  Rearranging happens automatically when using sizers and layout
managers.

That said, the future of GUIs is declarative, using XAML or some other
domain-specific language like QML.  Examples of this include QtQuick
(the long-term direction Qt is heading), and the various dot Net GUI
toolkits now popular including MS' own MAUI, WPF, Avalonia.

GUI designer tools (Qt Creator, Visual Studio) can be used to assist and
help layout the skeleton, but ultimately the GUI is defined by code. And
it works very well, is adaptive, and can automatically size and
rearrange. If you want portability to mobile devices, this is where it's at.

I've tried wxGlade but never could get into it, or wxWidgets in general.
 I used to use GTK a lot and did use Glade back then, and dynamically
loaded the UI definition files at run time.  Lately used more Qt with
QtDesigner, and even extended Designer to support using some custom
widgets I made.

but the future of Qt is clearly QtQuick, so I've been learning that.
Has its warts, but in general I like the declarative paradigm.  It's a
learning curve.  Overall it's fairly powerful, flexible and portable.  I
have used the designer in Qt Creator a bit, but it's often faster and
just as intuitive to write it in QML, since you're going to be dropping
into QML frequently anyway to set properties (not unlike having to set
widget properties in Qt Designer.  So I guess it's 6s using the
graphical designer vs straight Qt.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows Gui Frontend

2023-04-01 Thread Michael Torrie
On 4/1/23 15:33, Thomas Passin wrote:
> OTOH, Qt isn't free for commercial use and the OP seems to be 
> speculating on coming up with a product to sell at some point.

Careful. That's not actually true, even though the marketing team at Qt
lets people believe it is.  Qt is licensed under the LGPL, which you can
definitely use in a proprietary, close-source app, provided you use the
dynamically-linked version (which PySide does of course) and do not
modify it.

Qt's commerical licensing is very hostile to small companies, I can say
that much.  It's too bad really.  But the LGPL will work for most
companies, except for those that might wish to use the embedded version,
such as in cars where being able to abide by the terms of the LGPL
becomes difficult.


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


Re: Rob Cliffe should stop sending me rude email messages.

2023-02-27 Thread Michael Torrie
On 2/27/23 09:17, Grant Edwards wrote:
> On 2023-02-27, Michael Torrie  wrote:
> 
>> I've been putting off sending this message for days, but the list noise
>> level is now to the point that it has to be said.
> 
> Ah, I've finially realized why some of those threads have seemed so
> disjointed to me. Years ago, I plonked all posts which are (like Hen
> Hanna's) submitted via Googole Groups.
> 
> I highly recommend it.
> 
> FWIW, here's the "score" rule for doing that with srln:
> 
> Score:: =-
>   Message-ID: .*googlegroups.com

Thanks for the tip and reminder.  I'll add that to my gmail filter.

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


Re: Rob Cliffe should stop sending me rude email messages.

2023-02-27 Thread Michael Torrie
I've been putting off sending this message for days, but the list noise
level is now to the point that it has to be said.

Often it is better to contact someone directly and privately rather than
publicly embarrass them by calling them out. You've made it clear,
however, that publicly calling you out is necessary. No doubt you will
think my post rude as well, even though the tone is moderate and
deliberate.  Sometimes things need to said and others need to be asked
to make changes. That's just part of communication in real, grown-up life.

Everyone that's responded to you has patiently attempted to answer your
questions and engage with you despite your unorthodox and very difficult
communications style.  I can assure you that not one person who's
replied to you has been rude or insulting, yet I cannot say the same
about your own disparaging comments in reply.  The only ad homimems I've
seen have come from you.

We are frustrated and exasperated with your unwillingness to read,
learn, and understand, yes, definitely!  Although your posts are quite a
bit less frustrating than those trying to turn Python into Java.  We can
probably handle trying to turn Python into LISP! :)

Do you understand why your posts have been causing frustration?  This is
an existing community that you've chosen to join.  Many of the people
you've insulted here, including dn have been participating and helpfully
contributing to this list for many years.

Please stop posting messages about how you think people have been rude
to you. Besides being off-topic they are simply false.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why doesn't Python (error msg) tell me WHAT the actual (arg) values are ?

2023-02-23 Thread Michael Torrie
On 2/23/23 01:08, Hen Hanna wrote:
>  Python VM  is seeing an "int" object (123)   (and telling me that)   ...   
> so it should be easy to print that "int" object 
> What does  Python VMknow ?   and when does it know it ?
It knows there is an object and its name and type.  It knows this from
the first moment you create the object and bind a name to it.
> it seems like  it is being playful, teasing (or mean),and   hiding  the 
> ball from me

Sorry you aren't understanding.  Whenever you print() out an object,
python calls the object's __repr__() method to generate the string to
display.  For built-in objects this is obviously trivial. But if you
were dealing an object of some arbitrary class, there may not be a
__repr__() method which would cause an exception, or if the __repr__()
method itself raised an exception, you'd lose the original error message
and the stack trace would be all messed up and of no value to you.  Does
that make sense?  Remember that Python is a very dynamic language and
what might be common sense for a built-in type makes no sense at all for
a custom type.  Thus there's no consistent way for Python to print out
the information you think is so simple.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: why is a search thru a Tuple slower ? ---- (meaningless indentations)

2023-02-20 Thread Michael Torrie
On 2/20/23 18:01, Hen Hanna wrote:
> is Comp.Lang.Python very active
Fairly.  Apparently the cool kids are using the Python Discourse forum.

> why is a linear search  thru  a Tuple  slower 
>  (than  thru a  (corresponding)   List ) ???

I cannot say, unfortunately.  Perhaps doing some analysis of the byte
code with the disasm module could tell you what the interpreter is doing
and why it is slower.  Since tuples are read only, I cannot think of any
reason to use them for large, generated structures. A list is far better
in my opinion.  I use tuples mainly for bundling small amounts of
information together, such as coordinates, or returning multiple values
from a function.

> sometimes,  i 'd  like to put  meaningless indentations
> like  i do (twice)  below
>  ( how can it do this ?)

Fortunately you cannot.  Such indents are syntax errors.

And I have to say it makes your emails very hard to read and understand
when you indent your sentences as you do.  Looks poetic but hard to read.

Also your python example code was not run-able either thanks to those
two extra indents which are syntax errors.  It's always helpful to post
complete and working code examples when asking for help or wanting to
get discussion on a piece of code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is [comprehension] the right word???

2023-02-20 Thread Michael Torrie
On 2/20/23 18:06, Hen Hanna wrote:
> is [comprehension]   the right word???
>
> i swear  i never heard the word  before
>   getting into Python  a few years ago.

Seems as though the term was borrowed from formal mathematics set theory.

A simple search reveals that the term "list comprehension" predates
Python.  Back to 1977 to be exact. The term was first coined by Phil
Wadler in the late 70s or early 80s.

https://en.wikipedia.org/wiki/List_comprehension
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tuple Comprehension ???

2023-02-20 Thread Michael Torrie
On 2/20/23 20:36, Hen Hanna wrote:
> For a while,  i've been curious about a  [Tuple   Comprehension] 

I've never heard of a "Tuple comprehension."  No such thing exists as
far as I know.

> So  finally   i tried it, and the result was a bit surprising...
> 
> 
> X= [ x for x in range(10) ]
> X= ( x for x in range(10) )
> print(X)
> a= list(X)
> print(a)

What was surprising? Don't keep us in suspense!

Using square brackets is a list comprehension. Using parenthesis creates
a generator expression. It is not a tuple. A generator expression can be
perhaps thought of as a lazy list.  Instead of computing each member
ahead of time, it returns a generator object which, when iterated over,
produces the members one at a time.  This can be a tremendous
optimization in terms of resource usage.  See
https://docs.python.org/3/reference/expressions.html#generator-expressions.
 Also you can search google for "generator expression" for other examples.

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


Re: Precision Tail-off?

2023-02-17 Thread Michael Torrie
On 2/17/23 15:03, Grant Edwards wrote:
> Every fall, the groups were again full of a new crop of people who had
> just discovered all sorts of bugs in the way 
> implemented floating point, and pointing them to a nicely written
> document that explained it never did any good.

But to be fair, Goldberg's article is pretty obtuse and formal for most
people, even programmers.  I don't need lots of formal proofs as he
shows.  Just a summary is sufficient I'd think.  Although I've been
programming for many years, I have no idea what he means with most of
the notation in that paper.

Although I have a vague notion of what's going on, as my last post
shows, I don't know any of the right terminology.

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


Re: Precision Tail-off?

2023-02-17 Thread Michael Torrie
On 2/17/23 03:27, Stephen Tucker wrote:
> Thanks, one and all, for your reponses.
> 
> This is a hugely controversial claim, I know, but I would consider this
> behaviour to be a serious deficiency in the IEEE standard.

No matter how you do it, there are always tradeoffs and inaccuracies
moving from real numbers in base 10 to base 2.  That's just the nature
of the math.  Any binary floating point representation is going to have
problems.  There are techniques for mitigating this:
https://en.wikipedia.org/wiki/Floating-point_error_mitigation
It's interesting to note that the article points out that floating point
error was first talked about in the 1930s.  So no matter what binary
scheme you choose there will be error. That's just the nature of
converting a real from one base to another.

Also we weren't clear on this, but the IEEE standard is not just
implemented in software. It's the way your CPU represents floating point
numbers in silicon.  And in your GPUs (where speed is preferred to
precision).  So it's not like Python could just arbitrarily do something
different unless you were willing to pay a huge penalty for speed.  For
example the decimal module which is arbitrary precision, but quite slow.

Have you tried the numpy cbrt() function?  It is probably going to be
more accurate than using power to 0..

> Perhaps this observation should be brought to the attention of the IEEE. I
> would like to know their response to it.
Rest assured the IEEE committee that formalized the format decades ago
knew all about the limitations and trade-offs.  Over the years CPUs have
increased in capacity and now we can use 128-bit floating point numbers
which mitigate some of the accuracy problems by simply having more
binary digits. But the fact remains that some rational numbers in
decimal are irrational in binary, so arbitrary decimal precision using
floating point is not possible.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Precision Tail-off?

2023-02-14 Thread Michael Torrie
On 2/14/23 00:09, Stephen Tucker wrote:
> I have two questions:
> 1. Is there a straightforward explanation for this or is it a bug?
To you 1/3 may be an exact fraction, and the definition of raising a
number to that power means a cube root which also has an exact answer,
but to the computer, 1/3 is 0.333 repeating in decimal,
which is some other fraction in binary.  And even rational numbers like
0.2, which are precise and exact, are not in binary
(0.01010101010101010101).  0.2 is .0011011011011011011 on and on forever.

IEEE floating point has very well known limitations.  All languages that
use IEEE floating point will be subject to these limitations.  So it's
not a bug in the sense that all languages will exhibit this behavior.

> 2. Is the same behaviour exhibited in Python 3.x?
Yes. And Java, C++, and any other language that uses IEEE floating point.

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


Re: Am I banned from Discuss forum?

2023-02-10 Thread Michael Torrie
On 2/10/23 14:10, Marco Sulla wrote:
> I was banned from the mailing list and Discuss forum for a very long time.
> Too much IMHO, but I paid my dues.
> 
> Now this is my state in the forum:
> - I never posted something unrespectful in the last months
> - I have a limitation of three posts per threads, but only on some threads
> - Some random posts of mine are obscured and must be restored manually by
> moderators
> - I opened a thread about the proposal of a new section called
> Brainstorming. It was closed without a reason.
> - I can't post links
> - Two discussions I posted in section Idea were moved to Help, without a
> single line of explanation.
> 
> If I'm not appreciated, I want to be publicly banned with a good reason, or
> at least a reason.

Your posts are showing up on the mailing list here just it seems.  I
didn't know there was a Discourse forum.  Is it supposed to be sync with
the mailing list and USENET?  Or is it intended to replace this mailing
list?  I rarely see Python devs on this list, so maybe they've chosen to
hang out exclusively in Discourse, which would be unfortunate.

The Discourse format has never appealed to me. It's way to unstructured
and gamified.  I much prefer the mailing list, but alas it seems like
most open source projects are moving to Discourse.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-27 Thread Michael Torrie
On 1/25/23 19:50, Jach Feng wrote:
> To me, argparse has been just a tool which I can use in a CLI app. 

argparse is just a tool for dealing with command-line *flags*, which are
common in command-line tools.  argparse interprets the command line as a
bunch of flags because that's what it's designed to do.  I find it
baffling that you expect some other behavior from argparse.

You don't need or want argparse in this situation. sys.argv has
everything you need in it. Use it directly!

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


Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-24 Thread Michael Torrie
On 1/23/23 18:58, Jach Feng wrote:
> More pathonic, but don't work. The '--' must be at index 1:-)

I'm very confused.  Why are you even using argparse, since if you put --
at index 1 then argparse wont't do any argument parsing at all.  If all
you want is the expression on the command line, just access it directly.
 If it's spread out with spaces, you can do something like this to put
it back together:

expression = " ".join(sys.argv[1:]

Otherwise the standard unix way of doing this is to require the user to
either provide the -- himself, or put the expression in quotes so it's
one unit.



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


Re: How to make argparse accept "-4^2+5.3*abs(-2-1)/2" string argument?

2023-01-22 Thread Michael Torrie
On 1/22/23 11:44, Stefan Ram wrote:
> Jach Feng  writes:
>> e:\Works\Python>py infix2postfix.py "-4^2+5.3*abs(-2-1)/2"
> 
>   Well, it's a nice exercise! But I only made it work for the
>   specific example given. I have not tested whether it always
>   works.

Haha.  Yes a nice exercise, but has nothing to do with the original
question which is how to convince argparse to accept a string like that
without thinking it's a switch.  Many unix utilities treat "--" as a
special argument that turns off argument parsing for the rest of the
command line. Maybe argparse follows this convention too; I don't know.
But if it did you'd do:

infix2postfix.py -- "-4^2+5.3*abs(-2-1)/2"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A natural magnet for the craziest TKinter lovers out there

2023-01-18 Thread Michael Torrie
On 1/18/23 18:01, Dan Kolis wrote:
> Hangs after maybe between 4 and 50 screen rewrites. sometimes CTRL C under 
> Ubuntu starts it up again. Click go rewrites al the fonts the thing can find 
> in a few windows Repeated.
> 

Not sure what you mean by "screen rewrites."

I ran your test program here and it generates 25 windows on my machine,
and I can click "run" at least half a dozen times. I tried closing the
font windows before clicking run again, and also just leaving the
windows up and generating many more windows.  300 windows. No hangs here
at all. Fedora 35 with Mate Desktop on X11 with compositing enabled.

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


Re: Improvement to imports, what is a better way ?

2023-01-18 Thread Michael Torrie
On 1/18/23 14:42, Dan Kolis wrote:
> 
>> I don't think you've described this. I don't know what you mean here. 
> 
> When I trace it in VSCode the imports seem like they endlessly suspend 
> scanning and go to other ones over and over. Like "Whats this doing ?"
> 

Nothing to worry about there. Python knows what it's doing! :)  Lots of
modules import other modules, so there will be a spanning tree of sorts.
 Each module will only actually be formally imported once.  The rest is
just setting up name spaces.  Yes it all adds to run time latency, but
it certainly won't lead to any leaks.

Definitely there's no need to import a module's dependencies; it will do
that itself.  Just import what your own module explicitly needs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What should go to stdout/stderr and why Python logging write everything to stderr?

2023-01-03 Thread Michael Torrie
On 1/3/23 11:45, Keith Thompson wrote:
> MRAB  writes:
> [...]
>> The purpose of stderr is to display status messages, logging and error
>> messages, even user prompts, and not mess up the program's actual 
>> output. This is important on a *nix system where you might be piping
>> the output of one program into the input of another.
> 
> I would expect user prompts to be written to stdout, or perhaps to some
> system-specific stream like the current tty, not to stderr.  If a
> program has user prompts, it probably doesn't make sense to pipe its
> output to the input of another.

I can't think of a specific example, but I know I have piped the output
of a program while at the same time interacting with a prompt on stderr.
 A rare thing, though.

Maybe some day an interface and shell syntax will be developed to
interact with an arbitrary number of standard streams.  Current piping
syntax really only works well with one stream and even trying to use
stderr and stdout with pipes and filters in a shell is awkward.




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


Re: Fwd: About the Python

2023-01-02 Thread Michael Torrie
On 1/1/23 22:27, Ramya M wrote:
> This is from JNN College of Engineering, Shimoga. we are facing some
> problems while using python. Please can you resolve this issue.

Without any further information on your part, we can only guess at what
the problems might be.  Crystal ball says that Thomas' suggestion will
probably solve your problem. But since we don't know what the problems
even are, this is just a wild guess.

> We are using python 3.11.1 (64 bit) for windows 10. but while installing
> the "numpy and matplotlib" packages we are getting errors. In some cases
> after installation of the above said packages we are getting errors while
> working.

You'll need to provide more information than that.  What are these
errors?  Copy and paste the text into your message. Attachments are not
allowed on this list.

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


Re: Subject: problem activating python

2022-12-17 Thread Michael Torrie
On 12/17/22 15:45, Anne wrote:
>I tried several times to install and use python for youtube views with Tor
>using Youtube tutorials but I keep getting error after error. Please help
>me.
>regards Dimpho

Given the lack of any information in your post, I can only assume you're
trying to get Python installed on Windows.  Please read this page and
post here if you have any questions:
https://docs.python.org/3/using/windows.html

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


Re: Any PyQt developers here?

2022-10-29 Thread Michael Torrie
On 10/28/22 21:31, DFS wrote:
> I found one person that said they did it but their syntax didn't work. 
> But it doesn't throw an error either.
> 
> model.setData(model.index(tblRow, col), font, Qt.FontRole)

I wouldn't expect that to work but it's understandable why it didn't
throw an error.  setData() is used to edit the contents of the model at
the provided index. Remember a model can store anything. All this does
is replace whatever was at that index with a Font object instance.  I'm
puzzled why you keep trying to mess with the model when it's the view
that does the actual font setting.  Remember that a single model can be
used with more than one view at the same time, each view implementing
its own style. Thus a model has no information like fonts in it, nor
should it, other than perhaps HTML text markup that the view will render.

Did you consult the folk on the PyQt mailing list? Or even the main Qt
lists?  This isn't language-specific stuff you're asking about.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick question about CPython interpreter

2022-10-17 Thread Michael Torrie
On 10/14/22 16:25, DFS wrote:
> -
> this does a str() conversion in the loop
> -
> for i in range(cells.count()):
>if text == str(ID):
>  break
> 
> 
> -
> this does one str() conversion before the loop
> -
> strID = str(ID)
> for i in range(cells.count()):
>if text == strID:
>  break
> 
> 
> But does CPython interpret the str() conversion away and essentially do 
> it for me in the first example?

No.

You can use the dis module to show you what CPython is doing under the hood.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Find the path of a shell command

2022-10-13 Thread Michael Torrie
On 10/11/22 22:00, Paulo da Silva wrote:
> Hi!
> 
> The simple question: How do I find the full path of a shell command 
> (linux), i.e. how do I obtain the corresponding of, for example,
> "type rm" in command line?
> 
> The reason:
> I have python program that launches a detached rm. It works pretty well 
> until it is invoked by cron! I suspect that for cron we need to specify 
> the full path.
> Of course I can hardcode /usr/bin/rm. But, is rm always in /usr/bin? 
> What about other commands?

There are certain standards that suggest where to look.  For example,
there's the Linux Filesystem Hiearchy Standard 3.0:
https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch03s04.html

In short, you want to hard code /bin for a command like rm.  And yes it
will always be in /bin on any standard Linux OS.

Despite modern distros making /bin and /usr/bin the same directory, if
the target OS is anywhere close to the standard, you can always find the
basic commands in /bin.  I would not hard code any script to use
/usr/bin for any basic commands and I would not use anything other than
/bin/sh or /bin/bash as the shell script shebang if you want any sort of
portability.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 3.10 vs breakage

2022-08-26 Thread Michael Torrie
On 8/26/22 14:37, gene heskett wrote:
> Greetings all;
> 
> Its now become obvious that 3.10 has broken some things. I can't build 
> linuxcnc with it. And
> Octoprint has quit talking to 3d printers, now pronterface won't buy it, 
> can't find a 4.0.7
> version of wxPython with it sitting there staring at us.

I have Fedora 35 here, nearing it's end of life. It has Python 3.10.6,
and wxPython 4.0.7.  I installed Pronterface 2.0.0 from the Fedora repos
and it runs fine as near as I can tell.  So there's no inherent
incompatibility with Python 3.10 and wxPython 4.0.7.

> Whats chances of a fixed version for bookworm? Or even a bugs fixed 
> release for bullseye?

Seems like it is a distro-specific problem; I cannot replicate your
error with pronterface on Fedora 35.

I have no idea why octoprint won't work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Conecting to MySQL

2022-08-14 Thread Michael Torrie
On 8/8/22 19:26, Guilherme Campos wrote:
> Hello folks,
> 
> trying to connect to MYSQL it appears the error msg below:
> InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306'
> (111 Connection refused)
> [image: conexao.png]
> How can i fix that.?

MySQL can listen on a local unix socket (named pipe in Windows), an
internet TCP/IP port, or both.  If your MySQL is running, it could be
listening on the local socket or named port, which has a different url
than localhost:3306.  MySQL can be configured to also listen on a TCP/IP
port, which is what you code is apparently expecting.

Although the fact that your MySQL Workbench cannot connect either
suggests that MySQL is not running at all.

Configuring MySQL is a bit beyond the scope of this list, although I'm
sure there are people here who know how to do it.  What OS are you using?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request for assistance (hopefully not OT)

2022-05-21 Thread Michael Torrie
On 5/21/22 06:19, o1bigtenor wrote:
> more useful - - - - well - - - - I don't have to wonder why 'linux' is
> used as much
> by the general populace as it is. The community likes to destroy
> itself - - - it
> is a pity - - - - the community has so much to offer.

As far as community goes, the Linux community (whatever that might refer
to) is pretty typical of all communities, including communities that
surround proprietary systems like Windows. For those that realize that
communication is two-way and individual effort is required, the
community is a wonderful resource of help and support.  For those that
approach it with impatience and demands for support without evidence of
individual effort, community members respond with much less alacrity.
This is true of *all* communities of all types.

I think in the Windows world people don't seem to have as many community
problems because most people simply aren't a part of the community--the
most impatient, grumpy people seem to have enough young relatives they
can coax to solve their problems for them.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "py" command for Linux and Mac?

2022-05-20 Thread Michael Torrie
On 5/12/22 11:59, De ongekruisigde wrote:
> On 2022-05-12, Mats Wichmann  wrote:
>> On 5/12/22 10:25, Dan Stromberg wrote:
>>> Hi folks.
>>>
>>> I heard there's a Windows-like "py" command for Linux (and Mac?).
>>>
>>> I'm finally getting to porting a particular project's Python 2.7 code to
>>> 3.x, and one of the first steps will probably be changing a lot of "python2
>>> script.py" to use #!/usr/bin/env python2 and chmod +x.  Then we can update
>>> the scripts one at a time to use #!/usr/bin/env python3.
>>>
>>> However, would this be Linux-and-Mac-only?  I'm not at all sure this code
>>> will ever move to Windows, but in case it does, would a "py" command work
>>> on all 3 if I use #!/usr/bin/env py?
>>
>> The py command (python lanucher) respects shebang lines.
> 
> Linux by itself respects shebang lines, so you don't need a separate
> launcher program. Just put e.g.:

Dan knows this already. His question is about whether the shebang should
instead refer to a py launcher so that this script will run on Windows
or Linux.

And of course the answer given by the grandparent is that Dan should use
a normal linux shebang line in his scripts and on Windows the py
launcher will read that shebang and guestimate the proper python
interpreter to use and execute the script with that. Thus if I'm reading
this correctly, a Linux shebang line should function as expected on
Windows when python files are associated and launched with the py.exe
launcher, even though there's no such thing as /usr/bin/python3 on
Windows.  Py launcher makes it work as if there was.


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


Re: Request for assistance (hopefully not OT)

2022-05-17 Thread Michael Torrie
On 5/17/22 05:20, o1bigtenor wrote:
> What can I do to correct this self-inflicted problem?

Those are always the fun ones.  Reminds me of when I was first learning
Linux using Red Hat Linux 5.0 or 5.1.  This was long before nice
dependency-solving tools like apt.  I wanted to install and run
StarOffice, but it needed a newer libc (this was during the painful
transition from libc5 to glibc6).  I ended up removing libc which
*everything depends on, trying to get the glibc update installed.
Needless to say that broke the entire system. Nothing but a reinstall
could be done in those days.

Anyway, good luck. I think you can rescue it yet following the advice
others have given.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-11 Thread Michael Torrie
On 3/11/22 11:03, Marco Sulla wrote:
> Anyway I think I'll not install Debian, because it's LTS releases are
> not long enough for me. I don't know if there's a distro based on
> Debian that has a long LTS support, Ubuntu apart.

Both Debian stable and Ubuntu LTS state they have a five year support
life cycle.  Ubuntu will support longer if you pay for it.  Do you
require more than five years?

Anyway, use whatever works for you.

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


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-10 Thread Michael Torrie
On 3/10/22 12:42, Marco Sulla wrote:
> PS: Is it just my impression or is there a plebiscite for Debian?

A vote?  No I don't think so.  Not sure what you mean.  The reason we're
all suggesting Debian is because you specifically said you want a LTS
Debian-like distro. Can't get any more Debian-like than Debian!  Debian
with XFCE should give you the same experience as Xubuntu, and is always
supported for a very long time.

Personally I run Fedora with Mate or KDE and I upgrade the OS every
12-18 months, usually skipping a version or two.  I did consider Centos
8 stream, but I needed something a little newer for various reasons.

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


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-10 Thread Michael Torrie
On 3/10/22 06:03, Marco Sulla wrote:
> I tried Debian on a VM, but I found it too much basical. A little
> example: it does not have the shortcut ctrl+alt+t to open a terminal
> that Ubuntu has. I'm quite sure it's simple to add, but I'm starting
> to be old and lazy...

Debian has the same desktop environments available for install as the
rest of the distros.  Gnome 3, Mate, LXDE, XFCE, KDE, etc.  Whatever
works for you on Ubuntu should work on Debian.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PSA: Linux vulnerability

2022-03-09 Thread Michael Torrie
On 3/9/22 13:05, Marco Sulla wrote:
> So my laziness pays. I use only LTS distros, and I update only when
> there are security updates.
> PS: any suggestions for a new LTS distro? My Lubuntu is reaching its
> end-of-life. I prefer lightweight debian-like distros.

Maybe Debian itself?

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


Re: Best way to check if there is internet?

2022-02-07 Thread Michael Torrie
On 2/7/22 12:51, Chris Angelico wrote:
> Some day, we'll have people on Mars. They won't have TCP connections -
> at least, not unless servers start supporting connection timeouts
> measured in minutes or hours - but it wouldn't surprise me if some
> sort of caching proxy system is deployed.
> 
> On the other hand, it also wouldn't surprise me if we do everything at
> a high level instead - have a Martian PyPI mirror, Debian package
> mirror, etc, etc, etc - and then build a mirror synchronization
> protocol that uses UDP.
> 
> Either way, though: would a person on Mars "have the internet"? Yes,
> but not the internet as we know it...

Fun fact.  The team running the Ingenuity helicopter on mars has shell
access to Linux running on the copter.  Obviously not interactive in the
normal sense of course, but they can batch shell commands and pass them
through the communication network to the rover, which relays them to the
copter.  Standard out is relayed back to earth at the next opportunity.
 Currently they use this remote shell access to compress all the images
after each flight and use ffmpeg to create video sequences from stills
on the copter computer itself.  They also used it to do some hacks to
temporarily fix the watchdog timing issue they had initially.  One of
the Linux gurus on the project has given several interviews to the Linux
Unplugged podcast. Fastinating stuff!

It's likely they have a python interpreter onboard as well.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Inkscape

2022-01-10 Thread Michael Torrie
On 1/10/22 8:27 AM, Mandy and Michael Wilson via Python-list wrote:
> I wonder if you can help me out please.  I have recently added an 
> extension into Inkscape called Axidraw which should enable me to 
> hatchfill text, unforunately I am unable to use this facility as when I 
> open a canvas in Inkscape and go to the axidraw extension I receive a 
> message saying that I require Python 3.6 or greater.  I have downloaded 
> and installed Python 3.10.1 but I am still receiving the same message. 
> Can you please tell me what I am doing wrong ?  I look forward to 
> hearing from you.

Most likely you'll need to ask the folks on the Inkscape forums or
mailing list.  Very few of us have any working understanding of how
Python is used within Inkscape.

What operating system are you using?  If you're running Windows, then
installing Python 3.10 will have no effect on Inkscape because inkscape
does not know about any other installed versions of Python.  It's built
with and ships with a specific version of Python inside of Inkscape.  So
it seems to me like you need to install the latest version of Inkscape,
which should come with the latest supported version of Python inside of it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Michael Torrie
On 11/25/21 9:08 AM, Ulli Horlacher wrote:

> I cannot submit my executables, because the Windows Virus scannners
> deletes them as soon as I compile my program!

I forgot to post this link:
https://support.microsoft.com/en-us/windows/add-an-exclusion-to-windows-security-811816c0-4dfd-af4a-47e4-c301afe13b26
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Michael Torrie
On 11/25/21 9:08 AM, Ulli Horlacher wrote:
> I cannot submit my executables, because the Windows Virus scannners
> deletes them as soon as I compile my program!

Add an exclusion rule to your machine. While this is not an option for
your end users, this will certainly allow you to work on the problem,
submitting the exe to the various virus vendors.

> And I need a Microsoft login to submit a file!
> I do not have such a login.

I sympathize.  But if you want to develop for Windows, you might just
have to get one.

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


Re: pyinstaller wrong classified as Windows virus

2021-11-25 Thread Michael Torrie
On 11/25/21 2:20 AM, Ulli Horlacher wrote:
> When I compile my programs with pyinstaller, Windows classifies them as
> virus and even deletes them!
> 
> pyinstaller.exe --onefile --noconsole -i fex.ico fextasy.py
> 187 INFO: PyInstaller: 4.7
> 187 INFO: Python: 3.10.0
> 218 INFO: Platform: Windows-10-10.0.19041-SP0
> 218 INFO: wrote P:\W10\fextasy.spec
> (...)
> 14392 INFO: Copying 0 resources to EXE
> 14392 INFO: Emedding manifest in EXE
> 14392 INFO: Updating manifest in P:\W10\dist\fextasy.exe
> 14533 INFO: Updating resource type 24 name 1 language 0
> 14579 INFO: Appending PKG archive to EXE
> 18836 INFO: Building EXE from EXE-00.toc completed successfully.
> 
> https://fex.flupp.org/fop/ylds7Y9d/X-20211125101112.png
> 
> What can I do?

False positive virus detection is pretty common with pyinstaller from
what I can see on the Googles.  It's actually very common problem with
less-popular compilers and languages too. Not sure what it is that trips
them all up.

Submit your exe to virustotal.com and then the only real solution is to
submit it to each major antivirus vendor as a false positive and hope
things get changed.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About get_axes() in Pandas 1.2.3

2021-11-22 Thread Michael Torrie
On 11/22/21 2:03 AM, Mahmood Naderan via Python-list wrote:
> Hi
> 
> I asked a question some days ago, but due to the lack of minimal
> producing code, the topic got a bit messy. So, I have decided to ask
> it in a new topic with a clear minimum code.
> import pandas as pd
> import csv,sys
> import matplotlib
> import matplotlib.pyplot as plt
> 
> df = pd.read_csv('test.batch.csv')
> print(df)
> 
> print("matplotlib version = ",  matplotlib.__version__)
> print("pandas version = ", pd.__version__)
> print("sys version", sys.version_info)
> 
> fig,axes = plt.subplots(2,1, figsize=(20, 15))
   ^
I can help you narrow it down a bit. The problem actually occurs inside
this function call somehow. You can verify this by doing this:

fig,axes = plt.subplots(2,1, figsize=(20, 15))
print ("axes[0].get_figure()=",axes[0].get_figure())

You'll find that get_figure() is returning None, when it should be
returning Figure(2000x1500). So plt.subplots is not doing something
properly which was corrected at some point. Oddly enough, with pandas
1.1.4 and matplotlib 3.2.2 (which is what my system has by default),
there is no error, although the graph is blank.

In my venv, when I upgrade matplotlib from 3.3.4 to 3.5, the problem
also goes away.  3.4.0 also works.

Honestly your solution is going to be to provide a virtual environment
with your script.  That way you can bundle the appropriate dependencies
without modifying anything on the host system.

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


Re: get_axes not present?

2021-11-21 Thread Michael Torrie
On 11/19/21 10:38 AM, Mahmood Naderan wrote:
>> And what is the result of plot()?  Is it a valid object, or is it None?
> 
> Well the error happens on the plot() line. I tried to print some information 
> like this:
> 
> Any thoughts on that?

It's not really possible for us to know what is happening since none of
us are in front of your computer with your code in front of us.  I
cannot run any of your posted code excerpts.  The best way to get
assistance here on the list is to create a minimal, self-contained,
run-able, example program that you can post in its entirety here that
demonstrates the issue. Otherwise all anyone can do is make guesses.

Did you read through the exception message?  It is providing a lot of
information. The message is saying that matplotlib is trying to call
.get_figure() on a self.axes list item, but that is not a valid object,
but is None. The question is, why is that list full of Nones?  Farther
up the traceback it notes that on line 66 of process_csv.py, you make a
call to plot_data() passing it the axes. Perhaps there's something wrong
with the axes object or list you are passing in there.  Did you print
that out to make sure that df, cnt, and axes all contain valid things?

All I can tell you is to use the standard debugging techniques you would
use for any problem.  Use either a debugger or print()'s to print out
the contents and types of each variable to verify they contain the data
you think they do.  If you have nested function calls, break them out
separately so you can examine the inputs and outputs of each of them.
If necessary, trace your way through the matplotlib code, but almost
certainly you'll find the problem is in bad data you are passing to
matplotlib.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: get_axes not present?

2021-11-18 Thread Michael Torrie
On 11/18/21 10:54 AM, Mahmood Naderan via Python-list wrote:
> As you can see I put the result of plot() to ax1 and then use some functions, 
> e.g. set_ylabel().

And what is the result of plot()?  Is it a valid object, or is it None?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request to advise error for python.

2021-10-15 Thread Michael Torrie
On 10/15/21 5:37 PM, 정성학(대학원생-자동차IT융합전공) via Python-list
wrote:
> Dear Sir,
> 
> resend request

Unfortunately your message is still blank. Attachments such as
screenshots are not visible to this list.  Whenever you ask questions on
the list it is helpful to:
- state the operating system you are using
- which installer you are using and where you downloaded it from
- copy and paste any text error messages you saw
- state any information you found doing an internet search for the error
message you saw.

If you are on Windows, please be sure to read this document:
https://docs.python.org/3/using/windows.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: spyder does not work under root! [linux]

2021-10-13 Thread Michael Torrie
On 10/13/21 12:09 PM, Paulo da Silva wrote:
> spyder and eric are both python editors/debuggers! Why are they related
> with web browsers?!

Good point. I was going off of the chromium bug report. My bad.  I
mistook Spyder for Selenium, which is a web scraping scripting engine
that does use a real browser.  Oops.

However, for better or worse, browser engines power all kinds of apps
these days, including IDEs. I do not know if Spyder is powered by
Chromium or not.  VS Code, for example,  is powered by a web browser engine.

As to Eric and Qt, I can't speak to that.


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


Re: spyder does not work under root! [linux]

2021-10-11 Thread Michael Torrie
On 10/8/21 4:32 PM, Paulo da Silva wrote:
> Às 22:56 de 08/10/21, Paulo da Silva escreveu:
>> Hi!
>>
>> I need to debug a python3 script under root. I tried spyder but it does
>> not work.
>>
>> Running as root without --no-sandbox is not supported. See
>> https://crbug.com/638180.
>>
>> Thanks for any comments including alternative solutions to debug as root.
>>
> I also tried with eric and curiously it gave the same message!!
> 
> This seems crazy.

Not so crazy. It's incredibly dangerous to run a web browser as root.
There's no reason I can think of for running a python script driving a
web browser as root.  Python scripts can easily be run as an arbitrary
user, perhaps from a bash wrapper script using su, or being started from
systemd.

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


Re: argparse: delimiter for argparse list arguments

2021-08-03 Thread Michael Torrie
On 8/2/21 1:43 PM, Sven R. Kunze wrote:
> Hi everyone,
> 
> maybe, I am missing something here but is it possible to specify a 
> delimiter for list arguments in argparse:
> 
> https://docs.python.org/3/library/argparse.html
> 
> Usually, '--' is used to separate two lists (cf. git).

I've not seen this syntax in git. Are you referring the the double and
triple dot notation git uses?  Can you give me an example of how git
uses -- as a list separator?

Typically -- on a command line means that's the end of the any special
switches and anything else, even if it looks like a command-line switch,
should not be parsed, and passed straight through as a normal parameter.

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


Re: curses apps on MS Windows?

2021-06-14 Thread Michael Torrie
On 6/13/21 11:44 AM, Grant Edwards wrote:
> There's been a surprising amount of discussion lately about using
> curses libraries on Windows OS. I'm surprised by this, because I don't
> think I've ever even seen a Windows curses application.
> 
> Are there examples of popular curses applications for Windows?

None that I know of, but then again the Windows console was horrible.
With the advent of the new Windows Terminal, Windows 10 now has a
first-class terminal system with all the capabilities of any Unix
terminal. So who knows, maybe curses might actually find a use on
Windows!  MS seems to be giving the idea of terminal applications a bit
of love.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python ...

2021-05-28 Thread Michael Torrie
On 5/27/21 12:29 PM, hw wrote:
> When the idea is to learn something, it's not exactly helpful to abandon 
> that idea when encountering the first obstacle or when someone tells you 
> you don't like it as much as they do ...

We've had many new users approach the mailing list over the years.
Always, early on, one can tell what the chances of success are, and
which will end poorly.  This is why I questioned whether Python was a
good fit for you. Your attitude early on kind of raised alarm bells.
We've seen this before.  Many people on this list have patiently
answered you questions.  And while you seem to be holding on longer than
many, it's not clear to me you want to learn Python.  If your goal is to
learn and use python for some purpose, whining about how it acts
differently than you think it should, or how you would do something
different than Guido did, is not helpful to that purpose.  Why would you
think it is?  My prediction is your attitude will cause you to abandon
Python very soon, and you'll go away from this list with a sour taste in
your mouth, which is unfortunate, but completely of your own making.

Python is a powerful and expressive language and one I really enjoy
using, probably more so than any language I've ever used over the
decades.  It has warts of course.  Python makes a very poor C, Java, or
even Perl.  It's not for everyone or every purpose.

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


Re: imaplib: is this really so unwieldy?

2021-05-27 Thread Michael Torrie
On 5/27/21 10:42 AM, hw wrote:
> What do you do with it when importing it?  Do you somehow design your 
> programs as modules in some way that makes them usable as some kind of 
> library funktion?

Yes, precisely.  Typically I break up my python projects into logical
modules, which are each kind of like a library in their own right.  The
if __name__=="__main__" idiom is really handy for this. It lets me build
testing into each module. If I run the module directly, it can execute
tests on the functions in that module. If it's imported, the code inside
the if __name__=="__main__" block is not executed.  Sometimes I'll have
a python file that can run standalone, using command-line arguments, or
be imported by something else and used that.  All depends on my needs at
the moment, but this mechanism is very powerful.

Note that any py file is loaded and executed when imported.  So any
module-level initialization code gets run whether a file is imported or
run directly (which is why the if __name__=="__main__" idiom works).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python ...

2021-05-25 Thread Michael Torrie
On 5/24/21 9:53 PM, hw wrote:
> That seems like an important distinction.  I've always been thinking of 
> variables that get something assigned to them, not as something that is 
> being assigned to something.

Your thinking is not incorrect.  Assignment is how you set a variable to
something.  For the most part the details of how the variables work
doesn't matter all that much.  An expression in Python works about the
same as it does in other languages.  Where it becomes important to
understand the name binding mechanism is in situations like you found
yourself.  What happens, for example, when you do something like
float=5? Hence the discussion about name shadowing.

The reason I brought up the distinction of how python's variables work
compared to a language like C is because under the hood Python's
assignment doesn't "alter" the variable.  Assignment replaces it
entirely in the name space.  This is consistent with a more formal
definition of variable found in lambda calculus.  I learned in uni there
are some formal languages that don't allow any variable names to be
rebound at all, which makes formal proofs and analysis easier. But I
digress.

There are also implications for parameter passing.  All of this is in
the language reference documentation of course.  But even still there
have been many arguments about whether Python is pass by value or pass
by reference.  Consider:

def foo(bar):
bar += 1

a = 5
foo(a)
print(a)

or

def frob(foo):
foo.append('bar')

a = [ 'one', 'two' ]
frob(a)
print(a)

The truth is Python might be said to "pass by object."  In other words
when you call a function, it goes through the names table and extracts
references to all the objects involves with the arguments and passes
those objects to the function.  Objects that are mutable can be changed
by a function, and those changes are visible in the code that called it,
since both caller and callee are dealing with the *same object*, just by
different names (aliases).  Strings and other values like ints are
*immutable*.  They cannot be changed.  Assignment will not change them,
only overwrite the names in the locals table.

> I would think of it as assigning a string to a variable and then 
> changing the content of the variable by assigning something else to the 
> same variable.  When variables are typeless, it doesn't matter if a 
> string or an integer is assigned to one (which is weird but can be very 
> useful).

Yes that's how it's done in many lower-level languages.  Python does not
assign that way, though. It's not clearing the contents and placing
something else there. Instead assignment overwrites the binding in the
name table, connecting the name to the new string object that was
created. The old object is dereferenced, and the garbage collector will
eventually remove it.

> It seems much more practical to assign different strings to the same 
> variable rather than assigning a different variable to each string, or 
> to assign a string to a variable and then to assign an integer to it.

How exactly would one overwrite an integer in memory with a string,
though?  You would have to either preallocate a lot of memory for it in
case something large were to be written to the variable, or you'd
allocate it on the heap on demand and use a reference for it.  Under the
hood, Python does the second.  How else would you do it?

> Isn't that what variables are for?

In the formal sense, variables are just names that stand in for values.
 Don't get too hung up on the mechanics of how one implements that as
being a formal part of the definition, and don't think that one
language's implementation of variables is the only way to do it.

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


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 8:42 AM, Schachner, Joseph wrote:
> OMG that is awful abuse of Python!  You have overloaded two Python
> keywords by making variables of that name.

Nitpick. hw did not overload keywords. Python does not allow keywords to
be overloaded.  Instead hw overwrote type names.  Upon learning that
type names are not keywords and can be overwritten, hw aw asked a
legitimate question: why does Python allow you to do that?  I don't
believe the OP found the answer acceptable, though.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 8:37 AM, Chris Angelico wrote:
> We're talking about many different things. 

Indeed.

The context of that original question about whether this was shadowing
or not seemed to be specifically about the num=input(); num=int(num)
example that Cameron Simpson posted.  Although hw was not clear on that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 8:21 AM, Michael Torrie wrote:
> Given your posts thus far, hw, I don't think Python is a good fit for
> you. You're better off learning a language that more closely aligns with
> the statically-typed languages you already know.

That was unnecessarily harsh; my apologies.  I can see now that you
might be comparing some features to Perl, which is a more dynamic
language.  I see in your recent posts that you are trying to understand
how Python works, and that is good.  Hopefully you'll find Python a
dynamic and useful tool.  If not, that's perfectly okay. Use the right
tool for the job.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 8:17 AM, hw wrote:
> What does python actually do in the first example?  Does it overshadow a 
> variable or does it change one?  If it overshadows a variable, it would 
> be dubious, if it doesn't, it won't be dubious.

Are you referring to this?

  num = input("Enter a number: ")
  num = int(num)

No it is not "overshadowing" a variable.  You cannot get back to the
original string value for num.

> There are more alternatives:  Python might create a new variable with 
> the same name and forget about the old one.  Or it doesn't forget about 
> the old one and the old one becomes inaccessible (unless you have a 
> reference to it, if there is such a thing in python).  How do you call that?

Python variables are not memory boxes like in a compiled language.  They
are names bound to objects, as Mr Simpson alluded to.  So in the first
line, the name num is bound to a string.  In the second line, the name
is re-bound to an int object.  Furthermore, if num had come from the
global name scope, either of these lines would create a local name num
that does shadow the name from the global scope.

Hope that helps.


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


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 8:24 AM, Chris Angelico wrote:
> On Tue, May 25, 2021 at 12:18 AM hw  wrote:
>> There are more alternatives:  Python might create a new variable with
>> the same name and forget about the old one.  Or it doesn't forget about
>> the old one and the old one becomes inaccessible (unless you have a
>> reference to it, if there is such a thing in python).  How do you call that?
> 
> It's the latter option: create a new variable, and the old one becomes
> inaccessible. That's called "shadowing". It's how scoping works in
> most languages (called "lexical scope").

Is it really shadowing, though?  The old one is not only inaccessible,
it's possibly reaped by the garbage collector, no?  Both nums are in the
same scope so the one overwrote the other in the name table.  Or am I
missing something.

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


Re: learning python ...

2021-05-24 Thread Michael Torrie
On 5/24/21 7:34 AM, hw wrote:
> Perhaps you can't see how both examples are different because you're 
> looking at things from a python perspective.

Sorry but they aren't all that different.  In both cases you're
shadowing printf.  The difference is that C is a statically-typed,
compiled language, so the compiler complains that an int is not
callable, whereas  Python is a dynamic language so lookups are done at
run time, not compile time.

I don't know your background, but it sounds like you've not had a lot of
experience with dynamic languages. Certainly you have never used a
language like Scheme or LISP!  Or Smalltalk!

What is your purpose here?  Why are you learning Python when it's
apparently that you have very little desire to understand the hows and
whys of Python and its idioms and paradigms, and to find its strengths.
 You've encountered some things that to you are unexpected.  That
happens when learning any language.

Unfortunately from time to time we see someone come to the list
apparently trying to do battle with the language; rather than learn how
to work with the language they try to twist python to their preconceived
notions of what a proper language should be, whether that's by getting
hung up on a specific criticism of the grammar, or by trying to program
Python in another language (often Java).  Such encounters always lead to
frustration and such posters most often walkaway disillusioned and even
bitter.  It's a bit of an odd thing to watch, and always sad because the
outcome simply hinges on the attitude of the person learning the
language. Someone that works with the language finds it's a very
expressive and powerful tool.

Given your posts thus far, hw, I don't think Python is a good fit for
you. You're better off learning a language that more closely aligns with
the statically-typed languages you already know.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python install failing. Install log is available.

2021-05-21 Thread Michael Torrie
On 5/21/21 8:25 AM, Mats Wichmann wrote:
> An install for all users will drop it into someplace different - by 
> default at the top of the drive, so e.g. C:\Python39.

I just did an install of 3.9 on Windows 10. There was an option to
install the launcher for all users but no option for installing Python
for all users if you go through with the default install options.  When
I chose to install the launcher for all users, it still installed Python
in the my user local AppData... path.

In order to select to install for all users, I had to choose custom
options during the install. Then I could choose to install for all
users, and it let me select a path which defaulted to C:\Program
Files\Python39.  As well I selected to place Python in the path, which
it did.

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


Re: OT: Autism in discussion groups (was: Re: Proposal: Disconnect comp.lang.python from python-list)

2021-05-09 Thread Michael Torrie
On 5/9/21 11:26 AM, Abdur-Rahmaan Janhangeer wrote:
> Out of curiosity, how do people without a Code of Conduct
> manage and prevent abuse in between people? I was about
> to organise something last year but did not find a better solution
> than a code of conduct to ensure smoothness. Well the idea was a
> before-hand signed code of conduct. It becomes more of  an
> agreement, a pact of good conduct. But i wonder how you
> handle banning it altogether? Like what happens in the case of
> abuse. What if you ban and people ask why? How do organisers
> justify their actions? Even if a code of conduct rings not great with
> some people, at least it can serve as a hint and guiding principles.

An interesting perspective on codes of conduct and SELF:
https://podcast.asknoahshow.com/80, partial transcript at
http://techrights.org/2019/06/15/jeremy-sands-and-imposed-coc/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: Autism in discussion groups (was: Re: Proposal: Disconnect comp.lang.python from python-list)

2021-05-08 Thread Michael Torrie
On 5/8/21 6:23 PM, Jason C. McDonald wrote:
> Usually, I find when people dump on CoCs, they're just angry at
> accountability. I haven't known anyone yet who was a productive
> member of Python and opposed to the CoC, at least in principle
> and aim.

I disagree.  Many people are opposed to CoCs for a variety of reasons
including the fact that many CoCs are political in nature.  Others
oppose them for legal liability reasons.  On his radio show Ask Noah (a
radio show about Linux), Noah has interviewed several people who oppose
CoCs for political and legal reasons.  The Southeast Linux Fest in
particular explicitly decided not to have a CoC for mostly legal reasons
(which he described in episode 80).

I do agree asking people to simply not be stupid doesn't seem to work
these days for whatever reason.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: Autism in discussion groups (was: Re: Proposal: Disconnect comp.lang.python from python-list)

2021-05-08 Thread Michael Torrie
On 5/8/21 3:28 PM, Mirko via Python-list wrote:
> 
> I apologize for this OT post, especially because it's in reply to an
> at least partly troll post, but I just can't resist. Sorry.
> 
> P.S.: *NOT* among the core symptoms of (the high-functioning levels)
> of ASS is the inability to learn. Mind that! (And that includes
> social norms.)

Thank you for posting such an insightful comment. No need to apologize.
 I really appreciate it. I think you are exactly correct.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bloody rubbish

2021-05-06 Thread Michael Torrie
On 5/5/21 8:58 PM, Joe Pfeiffer wrote:
> Mr Flibble  writes:
> 
>> Python is slow and significant whitespace is patently absurd.
> 
> Why am I not surprised to learn your "fast" implementation turns out to
> be something other than python?

And it's bizarre that the OP, since he despises Python so much, and
finds its syntax absurd, would even bother to make any sort of
implementation of it.

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


Re: library not initialized (pygame)

2021-05-02 Thread Michael Torrie
On 5/2/21 1:23 PM, Quentin Bock wrote:
> the error apparently comes from the first instructions variable saying
> library not initialized not sure why, its worked before but not now :/

I don't get that error on my Fedora 32 machine.  The script ultimately
doesn't run because it can't find the icon png file. But the window
briefly appears and it seems like pygame is being initialized properly.


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


Re: cant use certain commands, leading to more problems

2021-04-28 Thread Michael Torrie
On 4/28/21 4:00 AM, Rasig Kosonmontri wrote:
> so i heard that the microsoft store's version of python tends to hide
> itself. and so i uninstalled it
> but when i typed in to a powershell it just directs me to the
> mircrosoft store's page
> i then disabled it from doing that and install python from python.org
>  myself
> but for some weird reason this time it doesnt work at all, 'python' is
> somehow not recognized as a cmdlet, bash or command. this also happens with
> gitbash and cmd

If you installed Python from an installer from python.org, did you tell
it to put itself into your system PATH? If not, try manually adding the
bin folder where it installed to to your system path.

As to gitbash, that's an issue with your PATH as well, probably.

> ive tried repairing python but still doesnt work
> if you guys have an idea or a solution to this please let me know or help
> me through

Definitely read through the installation documentation:
https://docs.python.org/3/using/windows.html


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


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

2021-04-26 Thread Michael Torrie
On 4/26/21 12:38 AM, Stephen Tucker wrote:
> 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.
> 

Probably this is off-topic for me to say on a Python list, but why not
see if you can compile your GWBASIC program in FreeBASIC[1].  It
supports all graphics commands and screen modes of yesterday and can do
them in a window on modern operating systems.

As for Python, you may find that something like SDL or PyGame provides
primitives that are not far off of what you had in GWBASIC all those
years ago.  As ChrisA has said, Python 2.7 is *not* recommended for any
new projects.

[1] https://www.freebasic.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: question about basics of creating a PROXY to MONITOR network activity

2021-04-10 Thread Michael Torrie
On 4/10/21 8:52 AM, cseb...@gmail.com wrote:
> 
>> Is it even possible to be secure in that way? This is, by definition, 
>> a MITM, and in order to be useful, it *will* have to decrypt 
>> everything. So if someone compromises the monitor, they get 
>> everything. 
> 
> Chris
> 
> I hear all your security concerns and I'm aware of them.  I *really* don't 
> want to have to
> fight SSL.  Encryption was the biggest concern and I'd rather not mess with 
> it to do something 
> useful.
> 
> I've never used CloudFlare but if I'm not mistaken, it can be considered a 
> useful "MITM" service?
> Do they have to decrypt traffic and increase the attack surface to be useful?

Cloudfare does not do any kind of MITM stuff.  Cloudfare requires some
set up on the part of the server owner, and that takes several forms.
One recommended method is have Cloudfare sign a special certificate that
you install on your web server, which encrypts between your server and
Cloudfare.  Then you provide cloudfare with an SSL certificate and key
to use when they serve up your site to the world.

> I just want to create a "safe" MITM service so to speak.

For my own purposes, sometimes I'll create a limited, wildcard
certificate signed by my own authority which works only in my own
browser (this is the same technique used by certain regimes to MITM the
entire country!).  The proxy then uses that certificate.  It's useful
for some debugging tasks.  Or alternatively I'll create a proxy intended
to run on localhost only that proxies an encrypted source to a local,
non-encrypted channel.  For example, I might want to examine why a
connection to an IMAPS port is failing.  So I'll proxy IMAPS to IMAP so
I can sniff the IMAP locally to find out why the interaction is failing.

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


Re: firewall in python

2021-03-28 Thread Michael Torrie
On 3/28/21 12:33 PM, Quentin Bock wrote:
> Is it possible to create a firewall inside python and then run that instead
> of the windows defender firewall? If so how would that work or how would
> that be made?

Probably not.  The firewall is part of the kernel since it works
directly with the network drivers and the packets in memory (to avoid
copying data).  MS has an API for interacting with it, and controlling
and extending its behavior using an API:
https://docs.microsoft.com/en-us/windows-hardware/drivers/network/windows-filtering-platform-architecture-overview

This is what third-party firewall managers use.

Possibly Python could interact with portions of the firewall engine via
the callout API.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python documentation

2021-03-28 Thread Michael Torrie
On 3/28/21 12:28 PM, Michael Torrie wrote:
> You want to use an obsolete version of Python and an obsolete version of
> Qt.  That's totally fine!  But why are you angry when people, who are
> strictly volunteers, are unable to help much here other than to strongly
> recommend you reconsider?

Oops. You weren't ever asking for help.  My bad.

However there was understandable push back to documenting and promoting
an obsolete distribution of Python 2 (and Qt4 no less!) to new users.
Definitely not something the documentation should be doing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python documentation

2021-03-28 Thread Michael Torrie
On 3/27/21 1:02 PM, pyt...@blackward.eu wrote:
> You say: "The point is that there are those who use Python 2 and
> don't want to move to Python 3, claiming that it's easier to switch
> from Python 2 to some other language than from Python 2 to Python 3.
> That's what seems questionable." And I say, forcing people to do
> things they do not want to do is a little more questionable. There
> are reasons, why people "don't want to move to Python 3".
Sorry but that's not the way it works.  No one forces anyone to use
Python.  And no one forces anyone to move to Python 3.  But Python 2 is
not supported any longer, and you're on your own.  Plain and simple.
This is no different than if you chose to stay with, for example, an
obsolete version of some proprietary software package.  Lots of VB6
users out there still, but you can't seriously expect MS support or
official VB forums to be able to provided assistance do you?

You want to use an obsolete version of Python and an obsolete version of
Qt.  That's totally fine!  But why are you angry when people, who are
strictly volunteers, are unable to help much here other than to strongly
recommend you reconsider?

> Maybe you should concentrate more on developing 
> Python 3 a little more attractive then in burning witches?

And indeed Python 3 is a very attractive platform to move to!

> But for my part, this discussion is ended, it does not lead to anything. 
> At least in this point I agree with Chris.

Yes many new posters seem to come along and end up in this rut.  The
lack of emotional subtext in a mailing list doesn't help communication I
admit. I've been in your shoes before and I know how frustrating it can
be to not get the answers I want to hear, but I have to admit my own
attitude determined the outcome of some of the more frustrating
exchanges I've been a part of.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: convert script awk in python

2021-03-26 Thread Michael Torrie
On 3/25/21 1:14 AM, Loris Bennett wrote:
> Does any one have a better approach?

Not as such.  Running a command and parsing its output is a relatively
common task. Years ago I wrote my own simple python wrapper function
that would make it easier to run a program with arguments, and capture
its output.  I ended up using that wrapper many times, which saved a lot
of time.

When it comes to converting a bash pipeline process to Python, it's
worth considering that most of pipelines seem to involve parsing using
sed or awk (as yours do), which is way easier to do from python without
that kind of pipelining. However there is a fantastic article I read
years ago about how generators are python's equivalent to a pipe.
Anyone wanting to replace a bash script with python should read this:

https://www.dabeaz.com/generators/Generators.pdf

Also there's an interesting shell scripting language based on Python
called xonsh which makes it much easier to interact with processes like
bash does, but still leveraging Python to process the output.
https://xon.sh/ .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: port to PDOS (especially mainframe)

2021-03-23 Thread Michael Torrie
On 3/23/21 5:19 AM, Paul Edwards wrote:
> Thanks for the tip. I don't actually need it to be
> light. I just need it to be C90-compliant.

I guess the point with MicroPython is that since it can build on all
sorts of microcontrollers, a) it has a simpler build system and b) it is
definitely statically compiled. But I'm not sure whether it would be
applicable here.

> I tried typing in "python" to see if it
> came with Cygwin, but I got some stupid Windows
> store thing come up.

Cygwin does have python available.  You can select the python packages
when installing or install later by running the cygwin's setup.exe.  In
Windows 10 by default if you don't have any python interpreter
installed, Windows 10 will direct to you to the windows store to install
Python when you try to run the python interpreter.  That is why you saw
something about the Windows store.  Just by way of explanation.

> Ok, I'm assuming that I can run without DLLs
> being involved. There are presumably other
> targets with no concept of DLLs.

Possibly but they would be rarely used targets and not documented well.
 There is a basic wiki page from a few years ago on the subject, but
light on details: https://wiki.python.org/moin/BuildStatically. The
mailing list conversation the page links to is over ten years old.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New Python implementation

2021-02-16 Thread Michael Torrie
On 2/16/21 10:58 AM, Ben Bacarisse wrote:
> Attempts at a universal compiler stalled in the 1980s (though there may
> have been some new developments since I stopped looking) because
> expressing the semantics of different languages is so very hard.  In
> fact, much of the interest in pursuing the idea came from benefits that
> would be derived simply from having a language's semantics formally
> described.
> 
> I don't think there is anything to see here.  If the author had come up
> with some new ways to tackle any of the problems, he would be telling> people 
> about these, not saying "be patient" (and bad-mouthing CPython).

Indeed, in all seriousness if he is successful, I look forward to
reading his PhD dissertation, because it would be worthy of a PhD,
especially if he made some breakthroughs in metacompiler design.  His
comments don't give me hope, though.

Seems a bit paradoxical to me to, on the one hand, express a desire to
build a Python implementation, but on the other hand, mock Python as a
toy language.  Why bother with Python at all?

I wish him luck and maybe he'll eventually come back to the community
with something to show and impress with.

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


Re: Pyautogui troubles

2021-01-31 Thread Michael Torrie
On 1/30/21 2:58 PM, Philipp Daher via Python-list wrote:
> Dear Python-Team,
> 
> I have just repaired python after running my program which imports pyautogui, 
> closing and reopening it and then getting this: ModuleNotFoundError: No 
> module named „pyautogui“. Repairing didn’t work and I still get that message. 
> All I did was closing the perfectly working program in 3.9.1 and reopening it 
> in 3.9.1, but after the reopen I got the message. I’ve tried looking for 
> solutions in at least seven developer forums, nothing worked. If it helps, I 
> have Python  3.8 installed on my PC also.
> 
> I hope you can fix my troubles.

I've never heard of pyautogui. It's not something that ships with Python
if I'm not mistaken. Is this something you installed?  Note that just
because you installed a module under 3.8 does not mean it will
automatically be available in 3.9.1. You'll probably have to install it
using 3.9.1's pip.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-27 Thread Michael Torrie
On 1/27/21 11:42 AM, C W wrote:
> For learning purposes, here's the files:
> https://www.dropbox.com/sh/a3iy40rcvib4uvj/AAADmlM2i6NquWC1SV0nZfnDa?dl=0
> 
> Yes, you are correct about "employee" and "person" discrepancies. For now,
> the list comprehension is where I get stuck.
> 
> I'd like to know how the experts on here are approaching and debugging
> this.
> 
> Bonus if no debugger or breakpoint. Just the good ol' run the function and
> evaluate/print output for problems.

Like I said, the key is in the traceback.  It told you exactly what the
problem was. And seeing your full code I can now tell you why.  There is
no "created_at" field in the person dict (I noticed it's now called neo
in the code you just posted).  The dict is created directly from JSON
and there is no "created_at field anywhere in the JSON, which is why
you're getting that error.

I don't really understand much of the code you posted. There doesn't
seem to be any link between the MySQL database and the NEODatabase class
and instances.  Something is missing and it looks vaguely java-esque,
which may not be your best way to work in Python. I'm not sure what
you're trying to do so I can't really say much about it.

If you want to play with a database abstraction, there are several
libraries available, including SQLchemy.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-27 Thread Michael Torrie
On 1/26/21 10:19 PM, C W wrote:
> Traceback (most recent call last):
>File "/Users/Mike/Documents/Mike/main.py", line 95, in 
>   main()
>File "/Users/Mike/Documents/Mike/main.py", line 86, in main
>   args = get_feed()
>File "/Users/Mike/DocumentsMike/main.py", line 32, in get_feed
>   result = [PERSONatabase.get_person(raw_person) for raw_neo in
> raw_objects]
>File "/Users/Mike/Documents/Mike/main.py", line 32, in 
>   result = [NEODatabase.get_person(raw_person) for raw_neo in
> raw_objects]
>File "/Users/Mike/Documents/Mike/database.py", line 24, in get_person
>   return PERSONDatabase(person['created_at'],
> KeyError: 'created_at'

The actual error is the last part, which is a KeyError on line 24.  A
key error usually is from a dictionary-like object and it means the
requested key is not found in that object.  In other words, this person
object has no "created_at" key.  Hope that makes sense.

I do not know why the code you posted refers to "employee" but the
traceback refers to "person."

In any case the trace back shows you what called what until the error
occurred. You can trace the execution of the code simply by following
it.  main() called get_feed() which set up a list comprehension, which
calls get_person() which is where the error is occurring.  I'm not
following the list comprehension stuff; I don't know why python is first
referring to PERSONatabase and then refers to NEODatabase.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-26 Thread Michael Torrie
On 1/26/21 8:30 PM, Grant Edwards wrote:
> Me too (MS in CSci), but I can't remember the last time I used a
> debugger. 

I use a debugger frequency in C++, and sometimes C.  Even running a
debugger on an attached device like an Arduino is sometimes very useful.
Good debuggers let you do things like conditional breakpoints and watch
expressions.  Helpful for tracking down hard-to-find and less frequent
conditions.  Sure you could print stuff out, which I do, but sometimes
it's more convenient to do it with the debugger.

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


Re: How do you debug in Python? Coming from a Matlab and R user. I'm already aware of pdb.

2021-01-26 Thread Michael Torrie
On 1/26/21 8:37 PM, C W wrote:
> I have a naive question. How do I use traceback or trace the stack? In
> particular, I'm using VS Code with Python interactive console.

Show us the traceback here and we can help you interpret it.  Copy and
paste it from the VS Code console.

> Say, I want to print the value of employee['name']. Can I do it? 

Yes I would think so.

> My understanding is that these classes are just "skeletons". I must
> create an instance, assign values, then test?

Can't you just do something like this?

class NEODatabase:
def __init__(self, id, created_at, name, attend_date, distance):
self._id = id
self.created_at = created_at
self.name = name
self.attend_date = attend_date
self.distance = distance

@classmethod
def get_person(self, employee):
print (employee['name'])

return PERSONDatabase(employee['created_at'],
  employee['id'],
  employee['name'],
  employee['attend_date'],
  employee['distance'])

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


Re: Issues with running python in Command prompt

2021-01-20 Thread Michael Torrie
On 1/19/21 10:40 PM, Mladen Gogala via Python-list wrote:
> I generally advise
> using Cygwin and installing the Cygwin version of Python. Your OS will 
> look like a POSIX compatible system, and you will be able to use Unix/
> Linux tools like bash, less. vi, awk, grep and alike. You will also be 
> able to use "/" as a directory separator which is really helpful when it 
> comes to regular expressions.

I've used cygwin for many years.  I would not use cygin if I were the
OP.  This is probably for more advanced users with particular needs.  I
recommend sticking to the official windows version of Python, and
following the detailed instructions on the web page Mats Wichmann
referred to.

You can use escape characters in regular expression on any platform
Python runs on.  Python has a whole host of features to deal with the
directory separator differences on Windows vs everybody else.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which method to check if string index is queal to character.

2020-12-28 Thread Michael Torrie
On 12/28/20 1:27 PM, Richard Damon wrote:
> Validating that it meets the SYNTAX of an email address isn't THAT hard,
> but there are a number of edge cases to worry about.

Yes one would think that, but in my experience half of all web sites get
it wrong, insisting that my perfectly valid and RFC-compliant email
address is not a proper email address.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which method to check if string index is queal to character.

2020-12-28 Thread Michael Torrie
On 12/28/20 10:46 AM, Marco Sulla wrote:
> On Mon, 28 Dec 2020 at 17:37, Bischoop  wrote:
>>
>> I'd like to check if there's "@" in a string and wondering if any method
>> is better/safer than others. I was told on one occasion that I should
>> use is than ==, so how would be on this example.
>>
>> s = 't...@mail.is'
> 
> You could do simply
> 
> if "@" in s:
> 
> but probably what you really want is a regular expression.

https://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx/

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


Re: Which method to check if string index is queal to character.

2020-12-28 Thread Michael Torrie
On 12/28/20 10:37 AM, Bischoop wrote:
> A valid email address consists of an email prefix and an email domain,
> both in acceptable formats. The prefix appears to the left of the @ symbol.
> The domain appears to the right of the @ symbol.
> For example, in the address exam...@mail.com, "example" is the email prefix,
> and "mail.com" is the email domain.

Seems so simple, yet at least half the web sites I try to use get it
wrong.  There's an entire RFC on this topic.  Drives me crazy when a web
site insists that myaddress+suf...@domain.com is not a valid address.
It certainly is!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Installing Python (2.7) 'by hand' on Ubuntu - possible?

2020-12-22 Thread Michael Torrie
On 12/22/20 9:44 AM, Chris Green wrote:
> I have it running on 20.04 (with a couple of compatibility packages
> from a PPA) but I know I start hitting problems as soon as I move to
> 20.10.  So that does sound like an excellent idea.  Where can I find
> information about building container type things like snap?

Good question.  A quick search reveals this potential starting place:
https://ubuntu.com/tutorials/create-your-first-snap

Also
https://snapcraft.io/docs/python-plugin
https://snapcraft.io/docs/python-apps

That's all I know. Sorry I suggested a solution I know nothing about!


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


Re: Installing Python (2.7) 'by hand' on Ubuntu - possible?

2020-12-22 Thread Michael Torrie
On 12/22/20 8:10 AM, Chris Green wrote:
> I have (as discussed here) a printer utility that uses Python 2 and I
> can't update it to Python 3 because it has a .so library file which is
> compiled for Python 2.  I think I have exhausted all the possibilities
> for converting it to Python 3 so now I'm looking at how to keep it
> working on my [x]ubuntu Linux systems as Python 2.7 becomes unsupported.
> 
> How realistic/possible would it be to run the utility in a separate
> environment with its own copies of Python2 and any modules and
> libraries needed?  I would install these 'by hand', i.e. not using
> 'apt' so they would stay as installed even as my system gets upgraded. 
> 
> There would obviously be *some* dependencies on the system libraries
> but I think they'd be pretty low level and thus their interfaces would
> be very unlikely to change for a long time so I should be able to run
> my old Python2.7 and the Python modules needed for the utility for
> quite a few years anyway (the printer it supports will wear out
> eventually!).

Probably your best bet is to build a container image (perhaps a snap)
around with a distro that has Python 2.7 in it to house your app. That
way you've got everything you need including the required system
libraries.  Right now you could build a image of it based on Ubuntu
20.04 which has python 2.7 as an optional installable package.

Sure you could build Python 2.7 for as long as the compatible compilers
and other dependent libraries are available.  I expect RHEL to keep
building python 2.7 for another 10 years.  Ubuntu 20.04 will continue to
ship python 2.7 as an optional package for another 5 years at least.

There are ways even besides containers that work. With some scripts to
set up custom library paths and trees of custom libraries, you can run
old binary software on newer distros even. With some help from the
interwebs, I am able to run WordPerfect 8 for Linux on my Fedora 32 box.
 That was released back in the kernel 2.0 days, before the transition to
glibc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Review, suggestion etc?

2020-12-17 Thread Michael Torrie
On 12/17/20 9:10 AM, Bischoop wrote:
> Could you expand here, I rather don't know how I could do it different
> way apart from if maritals == 'Yes' or maritals == 'No' or is it what
> you meant?

I think he's hinting at using a loop instead.

while maritals != 'Yes' and maritals != 'No':
maritals = input('Married: Yes/No ?: ').title()

I think I got the logical condition right. Sometimes those are tricky!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error

2020-12-07 Thread Michael Torrie
On 12/7/20 11:30 AM, MRAB wrote:
> There's no need to remove Python 3.9 first; Python 3.8 can be installed 
> alongside it.

Since the original poster is invoking python.exe directly, probably as
per the instructions in the book he's following, I fear having two
versions of python installed will just lead to confusion.  In his case,
I think it's best to just have Python 3.8 installed.  Although
pgzrun.exe will almost certainly execute the correct version of Python,
so probably wouldn't matter either way.

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


  1   2   3   4   5   6   7   8   9   10   >