Re: Where I do ask for a new feature
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: Question(s)
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: Question(s)
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)
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: Checking if email is valid
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: Checking if email is valid
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
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: on a tail-recursive square-and-multiply
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: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more
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: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more
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
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
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: troglodytes
On 8/13/24 3:24 AM, Robin Becker via Python-list wrote: > I am clearly one of the troglodytes referred to in recent discussions around > the PSF. I've been around in python land > for far too long, my eyesight fails etc etc. > > I feel strongly that a miscarriage of justice has been made in the 3-month > banning of a famous python developer from > some areas of discourse. > > I have had my share of disagreements with others in the past and have been > sometimes violent or disrespectful in emails. > > I might have been in the kill list of some, but never banned from any mailing > lists. > > Honest dialogue is much better than imposed silence. > > -- grumblingly-yrs -- > Robin Becker Agreed. Here's a good summary of the issue: https://chrismcdonough.substack.com/p/the-shameful-defenestration-of-tim The PSF has really screwed this up. Really embarrassing, frankly. And sad. -- https://mail.python.org/mailman/listinfo/python-list
Re: FileNotFoundError thrown due to file name in file, rather than file itself
On 11/14/24 12:03 AM, Left Right wrote: >> On any Unix system this is untrue. Rotating a log file is quite simple: > > I realized I posted this without cc'ing the list: > http://jdebp.info/FGA/do-not-use-logrotate.html . > > The link above gives a more detailed description of why log rotation > on the Unix system is not only not simple, but is, in fact, > unreliable. Nothing in that article contradicts what I said about renaming log files. His argument is that renaming log files messes with tail -F, and therefore broken and unreliable. Which a pretty strange argument. tail -F might not see some data during the rotation, but the log files themselves don't miss anything, which was my contention. In all my years of sysadmin-ing I have never once worried about problems GNU tail might have with a file that gets rotated out from under you. Not sure why the author is so fixated on it. There are actual legitimate issues at play, such as a mechanism for informing the process to close the file (rotate usually requires processes to respond to SIGHUP). And of course the disk can fill up causing a denial of service of one kind or another. The latter is the biggest source of problems. Of course you could just log using the standard libc syslog facility. Or better yet, start your process from a systemd unit file and let the journal automatically log stderr. In both cases that would satisfy the technical objections of the author of that little treatise. -- https://mail.python.org/mailman/listinfo/python-list
Re: FileNotFoundError thrown due to file name in file, rather than file itself
On 11/12/24 12:10 PM, Left Right via Python-list wrote: > But, it's > impossible to reliably rotate a log file. There's always a chance > that during the rotation some log entries will be written to the file > past the point of rotation, but prior to the point where the next logs > volume starts. On any Unix system this is untrue. Rotating a log file is quite simple: simply rename the log file, then send a signal to the process to close the log file handle and open a new one. After that perhaps compress the rotated log file. Nothing is lost. This is standard practice in Unix. It is reliable. Perhaps the scenario you posit would happen on Windows. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to catch a fatal error in Python 2.7?
On 12/9/24 12:19 PM, marc nicole via Python-list wrote: > Hello, > > The fatal error exits the program with a code -1 while referencing the > memory address involved and nothing else. > > How to catch it in Python 2.7? Does the problem occur with Python 3.x? At this date, Python 2.7 is only supported by your vendor if you are using an enterprise Linux distribution. I don't think there is a way to recover from that error in your python script. It could be a bug in the Python interpreter (which will never be fixed in 2.7), or it could be a bug in a library somewhere. The latter is most likely. There's nothing you can do about it from a Python script to recover. > PS: please not I am not talking about exceptions but an error resulting > from the disconnection of my bluetooth microphone abruptly and leading to > the halting of the whole program, I need to be able to do something when it > occurs. > > Thanks for the help! -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/26/24 12:34 AM, aotto1968 via Python-list wrote: > sorry you don't understand the problem… > > > You managed to make a build of Python that attempts to link to a DLL > > I never touch the OpenSUSE python. the OpenSUSE python try to use my > sqalite3. The *only* mechanism that would cause the system python binary to try to load modules and libraries from your local install is your environment (environment variables). -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/25/24 3:55 PM, Chris Angelico via Python-list wrote: > On Thu, 26 Dec 2024 at 09:27, aotto1968 via Python-list > wrote: >> It is not only an *usage* error it is also an *security* error because: >> >> 1) "cnf" is using OS python >> 2) os "root" python >> 3) using **my** local non-root library I think he means the cnf is using the "root" OS python in /usr/bin, but /usr/bin/python3 is trying to import his local build of sqlite3, which cause it to fail. I assume he would like cnf to not try to import his local sqlite3, and instead use the normal system one. If this is the case, then somehow his local, non-root sqlite3 library is being picked up by the system version of python. Aotto might want to run the "env" command and see if there are any search paths that have to do with Python. I can see how this could be a security issue. If you can figure out what's happening you might want to open a ticket with the OpenSUSE developers. This is Python related, but it's not necessarily python's fault per se. -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/25/24 8:55 PM, Michael Torrie wrote: > This is Python related, but > it's not necessarily python's fault per se. It's also a good reminder to use venv. Then there's no way of activating your custom python with its custom sqlite3 library unless you explicitly activate the venv. -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/25/24 10:46 PM, Chris Angelico wrote: > Right. That's exactly what would happen if he'd built Python using > absolute paths to libraries, which is the normal way to do it. And so > the solution is to rebuild Python using absolute paths to libraries. You're right. Definitely appears to be a pretty major mis-configuration of his system. Not much we can do about that. -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/14/24 10:31 AM, aotto1968 via Python-list wrote: > The CORE problem is that python3 works well in *my* environment but the > installation is done as root and root does not use *my* environment. > > the mono build search for a working python3 and find *my* > > HOME/ext/x86_64-suse-linux-gnu/debug/bin/python3 > The build is fine but after switch to root for installation > > sudo make install > the root user call *my* python3 and fail. mono build is failing even before you get to running your python3. That's not something python developers can fix. -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/16/24 12:08 AM, aotto1968 via Python-list wrote: > If I read the answers I come to the conclusion that the "supporters" at > python doesn't ever understand the problem. Sorry you feel that way. Various people gave the best advice they could based on what you had provided. You were given some good advice and even a few very specific things to try to determine the root problem which you don't seem to have done. I've used linux for 30 years and I've never seen a relative path used for a linker search path. What provided this path to the linker? -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/13/24 1:56 PM, aotto1968 via Python-list wrote: > the problem is *not* to setup an environment variable, the problem is that > python is *not* > able to setup the *python* environment by it self. You're mistaken in this case. Nothing you've posted indicates the problem is in Python itself. Something isn't quite right with your linker and the linker search paths. LD_LIBRARY_PATH is one way to force the linker to use the correct search path. Python has no direct influence over the linker search paths, other than to list what shared libraries it is linked against, or to manually add paths to the linker in /etc/ld.so.conf.d/ during package installation. The ld.so linker is responsible for finding the files and linking them in, not Python. In your case it seems unable to do so, for whatever reason. Since your custom version of python3 does seem to link to the so properly, it seems as though something isn't right in the environment of the mono build process. Again, nothing to do with Python. The linker isn't even getting to the bit where it links in libpython3. -- https://mail.python.org/mailman/listinfo/python-list
Re: it's a shame... python error over error
On 12/14/24 2:56 AM, Peter J. Holzer via Python-list wrote: > So it might be because it's in a different directory ("HOME/ext/..." is > a relative path. That will not work in a different directory. Also > "HOME" is a strange choice for a directory name. Did you mean $HOME?) or > because the acceptance tests set up their own environment. > > I'd test the first idea first. Cd into > HOME/src/mono.git/acceptance-tests and try to invoke > HOME/ext/x86_64-suse-linux-gnu/debug/bin/python3 there. Indeed something is not right with his ld.so search paths. The original error report indicates the linker cannot even find the libpython so file, so this cannot be a problem with Python since the linker hasn't even found it. I don't see how he expects python to fix this configuration issue magically for mono's build scripts. -- https://mail.python.org/mailman/listinfo/python-list
Re: No module name mutagen
On Tue, Dec 31, 2024, 17:04 Tim Johnson via Python-list < python-list@python.org> wrote: > I am as of today, getting an import error for mutagen. Mutagen package > is installed at /root/.local/share/pipx/shared/lib/python3.12/site-packages > Pip-installed packages that go to /root/.local are only available when you run Python as root. Your normal user will never pick them up. So I'm not surprised it's not working. and indeed, that is the content of > /root/.local/share/pipx/shared/lib/python3.12/site-packages/pipx_shared.pth > Could you not apt install python3-mutagen? That will be accessible to all users. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to go about describing my software with a component diagram?
On 12/24/24 10:27 AM, marc nicole via Python-list wrote: > the diagram is also attached here This text-only mailing list does not allow attachments, just FYI. -- https://mail.python.org/mailman/listinfo/python-list