Re: xkcd.com/353 ( Flying with Python )
Blue-Maned_Hawk wrote: HenHanna wrote: https://xkcd.com/1306/ what does SIGIL mean? I'd define a sigil as a mandatory symbol used to indicate the properties of a name. if i'm getting this right... Sigil is part of the language spec, whereas (in Lisp in the old days), there was a convention of using var-name like *foo* to indicate it's a dynamic variable. and sometimes **foo** for and %foo% or %%foo%% was used for ... -- https://mail.python.org/mailman/listinfo/python-list
Re: xkcd.com/353 ( Flying with Python )
On 3/29/2024 11:21 PM, HenHanna wrote: https://xkcd.com/353/ ( Flying with Python ) https://xkcd.com/1306/ what does SIGIL mean? -- (i got it...Thanks!) Other xkcd that you like? my fav. one may be the one about [Bad-ass Hacker] [Nice-ass car]. Does he use Python? i wonder. -- https://mail.python.org/mailman/listinfo/python-list
Re: A technique from a chatbot
On 03/04/2024 13.45, Gilmeh Serda wrote: On 2 Apr 2024 17:18:16 GMT, Stefan Ram wrote: first_word_beginning_with_e Here's another one: def ret_first_eword(): ... return [w for w in ['delta', 'epsilon', 'zeta', 'eta', 'theta'] if w.startswith('e')][0] ... ret_first_eword() 'epsilon' Doesn't work in the case where there isn't a word starting with 'e': >>> def find_e( l ): ... return [w for w in l if w.startswith('e')][0] ... >>> l = ['delta', 'epsilon', 'zeta', 'eta', 'theta'] >>> find_e(l) 'epsilon' >>> l = ['The','fan-jet','airline'] >>> find_e(l) Traceback (most recent call last): File "", line 1, in File "", line 2, in find_e IndexError: list index out of range >>> -- Michael F. Stemper If it isn't running programs and it isn't fusing atoms, it's just bending space. -- https://mail.python.org/mailman/listinfo/python-list
Re: A technique from a chatbot
r...@zedat.fu-berlin.de (Stefan Ram) writes: > It can lead to errors: > > def first_word_beginning_with_e( list_ ): > for word in list_: > if word[ 0 ]== 'e': return word > something_to_be_done_at_the_end_of_this_function() > > The call sometimes will not be executed here! > So, "return" is similar to "break" in that regard. That can be solved with finally: def first_word_beginning_with_e( list_ ): try: for word in list_: if word[ 0 ]== 'e': return word finally: print("something_to_be_done_at_the_end_of_this_function()") -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Needed With a Python Gaming Module
On 4/3/2024 3:06 PM, WordWeaver Evangelist via Python-list wrote: Hello everyone! It has been a l-o-n-g time -- nine years in fact --since I last participated on this mailing list. [snip] 3. You are very familiar with the Jython 2 environment, which I am told is based on Python 2 and NOT Python 3. Yes, Jython 2 is currently more or less even with Python 2.7. You are presumably writing or hosting this in a java environment, and you may not realize that you can call Jython code from a java class (calling java classes from Jython code is dead simple). For example, I have some java servlet classes that invoke Jython classes and call their methods. If that sounds useful for your project, I can let you know how to do it. [more snips...] -- https://mail.python.org/mailman/listinfo/python-list
Help Needed With a Python Gaming Module
Hello everyone! It has been a l-o-n-g time -- nine years in fact --since I last participated on this mailing list. At that time, I was trying to write a door/external for my PC-ANSI, Macintosh-based BBS. Thanks to some of the folks here, I got it done although I eventually lost the module a number of years later when I left BBSing behind, because I assumed it to be dead. Anyway, just recently I put my BBS back online again for the fourth time since 1993, and I am again endeavoring to write a new python-based external -- a game -- for my BBS. Before I continue, let me inform you that I am 70 years old, I am NOT a programmer, and I do not know any programming languages. Yes, I am a newbie, a noob, a greenhorn. :) So, if anyone here is willing to help me, you are going to need a lot of patience . like ChatGPT :) Following the coding example of another open-source external that was written for my BBS, I have made some significant progress, thanks in large part to spending hours and hours chatting with ChatGPT over the past two days. However, due my lack of expertise, and even though ChatGPT had me try all sorts of functions and codes and methods, there is one very perplexing issue which has prevented me from further development on my game. Even ChatGPT couldn't figure it out. But before I get into the meat of the matter and waste everyone's time here, I need to address several questions to all of you Python brainiacs. ) Is there anyone -- or any group of someones -- amongst this noble assemblage, who meets all of the following qualifications: 1. You are very familiar with Mac OS 9.2.2 2. You are either moderately or very familiar with Hermes II BBS software. 3. You are very familiar with the Jython 2 environment, which I am told is based on Python 2 and NOT Python 3. If you meet all three of those qualifications, then you may possibly be able to help me to overcome the mysterious obstacle I am now facing. Once I see what kind of responses I get, I will be very happy to share my nagging problem with you. Thank you for taking the time to read this. Here is to hoping that my coding genius is out there, ready and eager to come to my aid. Thank you in advance. Kind regads, Bill Kochman -- https://mail.python.org/mailman/listinfo/python-list
Re: Already Subscribed and Confirmed, But ....
On 4/3/24 07:15, WordWeaver Evangelist via Python-list wrote: > Hello. I already subscribed to this list several days ago. In fact, I did it two times, and > I received the email with the confirmation link in it, which I clicked on and was confirmed. > > Despite this fact, each time that I try to post a message to the list. I get a response from > the python bot stating that I need to register before I can post to the list. As I said, I > already did that, and I was confirmed. I still have the email here. Well, this post made it through fine. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Already Subscribed and Confirmed, But ....
Hello. I already subscribed to this list several days ago. In fact, I did it two times, and I received the email with the confirmation link in it, which I clicked on and was confirmed. Despite this fact, each time that I try to post a message to the list. I get a response from the python bot stating that I need to register before I can post to the list. As I said, I already did that, and I was confirmed. I still have the email here. What must I do to work this out, as I have some important issues I need to discuss. Thank you. King regards, Bill Kochman -- https://mail.python.org/mailman/listinfo/python-list
Re: Trying to use pyinstaller under python 3.11, and, recently started receiving error message about specific module/distribution
Ok, last update for now - checked out the following page on pyinstaller.org, and, ended up posting to the mailing list, so, let's see: https://pyinstaller.org/en/latest/when-things-go-wrong.html Jacob Kruger +2782 413 4791 "Resistance is futile!...Acceptance is versatile..." On 2024/04/02 17:11, Barry wrote: On 1 Apr 2024, at 15:52, Jacob Kruger via Python-list wrote: Found many, many mentions of errors, with some of the same keywords, but, no resolutions that match my exact issue at all. Try asking the pyinstaller developers. I think there is a mailing list. Barry As in, most of them are mentioning older versions of python, and, mainly different platforms - mac and linux, but, various google searches have not mentioned much of using it on windows, and having it just stop working. Now did even try shifting over to python 3.12, but, still no-go. If launch pyinstaller under python 3.10 on this exact same machine, pyinstaller runs - just keep that older version hovering around for a couple of occasional tests, partly since some of my target environments are still running older versions of python, but anyway. Also, not really relevant, but, cx_freeze is perfectly able to generate executables for this same code, but, then not combining all output into a single file - will stick to that for now, but, not always as convenient, and, still wondering what changed here. Jacob Kruger +2782 413 4791 "Resistance is futile!...Acceptance is versatile..." On 2024/03/31 14:51, Barry wrote: On 31 Mar 2024, at 13:24, Jacob Kruger via Python-list wrote: pkg_resources.DistributionNotFound: The 'altgraph' distribution was not found and is required by the application I think I have seen this error being discussed before… A web search for pyinstaller and that error leads to people discussing why it happens it looks like. Barry -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
RE: A technique from a chatbot
Sadly, Thomas, this is not even all that new. I have seen people do searches on the internet for how to do one thing at a time and then cobble together some code that does something but perhaps not quite what they intended. Some things are just inefficient such as reading data from a file, doing some calculations, writing the results to another file, reading them back in and doing more calculations and writing them out again and so on. Yes, there can be value in storing intermediate results but why read it in again when it is already in memory? And, in some cases, why not do multiple steps instead of one at a time and so on. How many people ask how to TEST the code they get, especially from an AI-like ...? -Original Message- From: Python-list On Behalf Of Thomas Passin via Python-list Sent: Wednesday, April 3, 2024 7:51 AM To: python-list@python.org Subject: Re: A technique from a chatbot On 4/3/2024 1:27 AM, AVI GROSS via Python-list wrote: > I am a tad confused by a suggestion that any kind of GOTO variant is bad. The suggestion runs counter to the reality that underneath it all, compiled programs are chock full of GOTO variants even for simple things like IF-ELSE. > > Consider the code here: > >>> def first_word_beginning_with_e( list_ ): >>> for word in list_: >>> if word[ 0 ]== 'e': return word >>> something_to_be_done_at_the_end_of_this_function() > > If instead the function initialized a variable to nothing useful and in the loop if it found a word beginning with e and it still contained nothing useful, copied it into the variable and then allowed the code to complete the loop and finally returned the variable, that would simply be a much less efficient solution to the problem and gain NOTHING. There are many variants you can come up with and when the conditions are complex and many points of immediate return, fine, then it may be dangerous. But a single return is fine. > > The function does have a flaw as it is not clear what it should do if nothing is found. Calling a silly long name does not necessarily return anything. > > Others, like Thomas, have shown other variants including some longer and more complex ways. > > A fairly simple one-liner version, not necessarily efficient, would be to just use a list comprehension that makes a new list of just the ones matching the pattern of starting with an 'e' and then returns the first entry or None. This shows the code and test it: > > text = ["eastern", "Western", "easter"] > > NorEaster = ["North", "West", "orient"] > > def first_word_beginning_with_e( list_ ): >return(result[0] if (result := [word for word in list_ if word[0].lower() == 'e']) else None) > > print(first_word_beginning_with_e( text )) > print(first_word_beginning_with_e( NorEaster )) > > Result of running it on a version of python ay least 3.8 so it supports the walrus operator: > > eastern > None The OP seems to want to return None if a match is not found. If a Python function ends without a return statement, it automatically returns None. So nothing special needs to be done. True, that is probably a special case, but it suggests that the problem posed to the chatbot was not posed well. A truly useful chatbot could have discussed many of the points we've been discussing. That would have made for a good learning experience. Instead the chatbot produced poorly constructed code that caused a bad learning experience. > [snip...] -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: A technique from a chatbot
On 4/3/2024 1:27 AM, AVI GROSS via Python-list wrote: I am a tad confused by a suggestion that any kind of GOTO variant is bad. The suggestion runs counter to the reality that underneath it all, compiled programs are chock full of GOTO variants even for simple things like IF-ELSE. Consider the code here: def first_word_beginning_with_e( list_ ): for word in list_: if word[ 0 ]== 'e': return word something_to_be_done_at_the_end_of_this_function() If instead the function initialized a variable to nothing useful and in the loop if it found a word beginning with e and it still contained nothing useful, copied it into the variable and then allowed the code to complete the loop and finally returned the variable, that would simply be a much less efficient solution to the problem and gain NOTHING. There are many variants you can come up with and when the conditions are complex and many points of immediate return, fine, then it may be dangerous. But a single return is fine. The function does have a flaw as it is not clear what it should do if nothing is found. Calling a silly long name does not necessarily return anything. Others, like Thomas, have shown other variants including some longer and more complex ways. A fairly simple one-liner version, not necessarily efficient, would be to just use a list comprehension that makes a new list of just the ones matching the pattern of starting with an 'e' and then returns the first entry or None. This shows the code and test it: text = ["eastern", "Western", "easter"] NorEaster = ["North", "West", "orient"] def first_word_beginning_with_e( list_ ): return(result[0] if (result := [word for word in list_ if word[0].lower() == 'e']) else None) print(first_word_beginning_with_e( text )) print(first_word_beginning_with_e( NorEaster )) Result of running it on a version of python ay least 3.8 so it supports the walrus operator: eastern None The OP seems to want to return None if a match is not found. If a Python function ends without a return statement, it automatically returns None. So nothing special needs to be done. True, that is probably a special case, but it suggests that the problem posed to the chatbot was not posed well. A truly useful chatbot could have discussed many of the points we've been discussing. That would have made for a good learning experience. Instead the chatbot produced poorly constructed code that caused a bad learning experience. [snip...] -- https://mail.python.org/mailman/listinfo/python-list
RE: A missing iterator on itertools module?
Antoon, Even if the suggested solution offers a partial result, you would need specific requirements to determine what should be done if one or more of the parts being cycled is shorter than the others. Stopping at that point is one option. Another is to continue but only interleave ones still producing and in the same order. There is a function in itertools called zip_longest() that might be considered as it keeps going but substitutes a customizable value for "missing" parts. You could then, perhaps, make a change so that sentinel is not passed along. -Original Message- From: Python-list On Behalf Of Antoon Pardon via Python-list Sent: Wednesday, April 3, 2024 5:11 AM To: python-list@python.org Subject: Re: A missing iterator on itertools module? Op 28/03/2024 om 17:45 schreef ast via Python-list: > Hello > > Suppose I have these 3 strings: > > s1 = "AZERTY" > s2 = "QSDFGH" > s3 = "WXCVBN" > > and I need an itertor who delivers > > A Q W Z S C E D C ... > > I didn't found anything in itertools to do the job. The documentation mentions a roundrobin recipe. > > So I came up with this solution: > > > list(chain.from_iterable(zip("AZERTY", "QSDFGH", "WXCVBN"))) > > ['A', 'Q', 'W', 'Z', 'S', 'X', 'E', 'D', 'C', 'R', 'F', 'V', 'T', 'G', > 'B', 'Y', 'H', 'N'] But if your strings are not equal, this will only produce a partial result. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: A missing iterator on itertools module?
Op 28/03/2024 om 17:45 schreef ast via Python-list: Hello Suppose I have these 3 strings: s1 = "AZERTY" s2 = "QSDFGH" s3 = "WXCVBN" and I need an itertor who delivers A Q W Z S C E D C ... I didn't found anything in itertools to do the job. The documentation mentions a roundrobin recipe. So I came up with this solution: list(chain.from_iterable(zip("AZERTY", "QSDFGH", "WXCVBN"))) ['A', 'Q', 'W', 'Z', 'S', 'X', 'E', 'D', 'C', 'R', 'F', 'V', 'T', 'G', 'B', 'Y', 'H', 'N'] But if your strings are not equal, this will only produce a partial result. -- https://mail.python.org/mailman/listinfo/python-list