From milan.buska at yahoo.com Fri Sep 1 07:56:43 2023 From: milan.buska at yahoo.com (milan.buska at yahoo.com) Date: Fri, 1 Sep 2023 11:56:43 +0000 (UTC) Subject: [Tutor] building python modules with use pip References: <2079181162.4649287.1693569403441.ref@mail.yahoo.com> Message-ID: <2079181162.4649287.1693569403441@mail.yahoo.com> Hello. I'm a beginner so I want to ask. Is this way of building the module correct: name=python3-markupsafe _realname=MarkupSafe version=2.1.3 release=1 source=(https://files.pythonhosted.org/packages/source/M/$_realname/${_realname}-${version}.tar.gz) build() { ?? ?cd ${_realname}-${version} ?? ?/usr/bin/pip3 wheel -w dist --isolated --no-deps $PWD ?? ?PIP_CONFIG_FILE=/dev/null \ ?? ?/usr/bin/pip3 install \ ?? ??? ?--root-user-action=ignore \ ?? ??? ?--no-warn-script-location \ ?? ??? ?--ignore-installed \ ?? ??? ?--no-deps dist/*.whl \ ?? ??? ?--isolated \ ?? ??? ?--root=$PKG } Regards Milan -------------------------------------------------- Remember, no question is too stupid and no problem ??????????too small--We've all been beginners From PythonList at DancesWithMice.info Thu Sep 7 16:48:04 2023 From: PythonList at DancesWithMice.info (dn) Date: Fri, 8 Sep 2023 08:48:04 +1200 Subject: [Tutor] ANN: Wed 20 Sep: Terminal-based user interfaces (TUIs) with ease using Textual Message-ID: <9772f3e2-0c04-5684-fd8f-9e77067d7cd8@DancesWithMice.info> Rodrigo's back! Fresh from his successes at EuroPython... You are invited to join the next virtual NZPUG Auckland Branch meeting (Wed 20 Sep, 1830~2030 local, ie 0630~0830 UTC) Learn how to build powerful terminal-based user interfaces (TUIs) with ease using Textual - an open-source Python framework. Through this tutorial, you'll learn how to use features like Textual's built-in widgets, reactive attributes, and message-passing system, to start developing a simple TODO app that runs directly in your terminal. About Rodrigo Gir?o Serr?o: Rodrigo has presented to NZPUG Auckland Branch previously. He speaks frequently at various PyCons (Python Conferences) and other gatherings. As well as Python, he has been playing with APL, C++, and more. Combining programming and maths, he describes himself as a mathemagician. Rodrigo has always been fascinated by problem solving and that is why he picked up programming ? so that he could solve more problems. He also loves sharing knowledge, and that is why he spends so much time writing articles in his blog, writing on Twitter, and giving workshops and courses. During the week, Rodrigo can be found banging his head against the wall while trying to solve a Textual bug, as he works on Textual full-time. To RSVP (to receive the meeting-URL) and for more detail: https://www.meetup.com/nzpug-auckland/events/295433884/ The Auckland branch of the New Zealand Python Users Group meets twice monthly. You're very welcome to attend online or in-person (as available). Meeting location-details or URL will be sent to those who RSVP. We are a healthy mix of Python users. Students, academics, hobbyists, industry professionals, and many completely new to Python. The 'room' opens at 1815 (local time) with an opportunity to network with colleagues. Formal start is 1830. Aiming to finish by 2030. We are always keen to hear suggestions for meeting-topics, and to meet with folk who'd like to present or lead - eg a brief lightning talk, a practical coaching-session, a full lecture... Help is available if you've never done such a thing before! We follow the NZPUG Code of Conduct to create an inclusive and friendly environment. We express thanks to, and encourage you to investigate our sponsors: Catalyst Cloud, New Zealand Open Source Society, JetBrains, and IceHouse Ventures. -- Regards, =dn From ammungo at aggies.ncat.edu Thu Sep 14 13:17:32 2023 From: ammungo at aggies.ncat.edu (Ashley Mungo) Date: Thu, 14 Sep 2023 12:17:32 -0500 Subject: [Tutor] Keep getting error message when importing file saved to Jupyter Message-ID: [image: image.png] Hey Team, I keep getting the above message when I try to load a folder that is saved in Jupyter. I have already taken it out of read-only and updated the permissions but it still won't allow me to upload the folder. Help please! From townerobert1 at gmail.com Fri Sep 15 16:07:57 2023 From: townerobert1 at gmail.com (Robert Towne) Date: Fri, 15 Sep 2023 14:07:57 -0600 Subject: [Tutor] im having problems and need help Message-ID: Im having problems understanding this. Im running the while loop like it says; and it doesnt complete the loop. My question is, is it the formula thats wrong or my math. The % sign means to square the number? since i the to the second power is 64. Then it should return false. IDK what I am doing wrong, if you could help me understand where I am going wrong i would appreciate it thank you. def is_power_of_two(number): # This while loop checks if the "number" can be divided by two # without leaving a remainder. How can you change the while loop to # avoid a Python ZeroDivisionError? while number % 2 == 0: number = number / 2 # If after dividing by 2 "number" equals 1, then "number" is a power # of 2. if number == 1: return True return False # Calls to the function print(is_power_of_two(0)) # Should be False print(is_power_of_two(1)) # Should be True print(is_power_of_two(8)) # Should be True print(is_power_of_two(9)) # Should be False From leamhall at gmail.com Wed Sep 20 07:39:02 2023 From: leamhall at gmail.com (Leam Hall) Date: Wed, 20 Sep 2023 06:39:02 -0500 Subject: [Tutor] Keep getting error message when importing file saved to Jupyter In-Reply-To: References: Message-ID: <86d08ef7-9395-c5f3-3b06-e85c369f0cac@gmail.com> Hey Ashley, The mail list software strips off images, since they can be large and we have a worldwide audience. Can you post the message as text? Leam On 9/14/23 12:17, Ashley Mungo wrote: > [image: image.png] > > Hey Team, > I keep getting the above message when I try to load a folder that is saved > in Jupyter. I have already taken it out of read-only and updated the > permissions but it still won't allow me to upload the folder. Help please! -- Software Engineer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) From leamhall at gmail.com Wed Sep 20 07:47:06 2023 From: leamhall at gmail.com (Leam Hall) Date: Wed, 20 Sep 2023 06:47:06 -0500 Subject: [Tutor] im having problems and need help In-Reply-To: References: Message-ID: <0348bd2a-2974-f671-2039-5871b7a1fbfe@gmail.com> Robert, Sorry, your mail program killed the code indents. Also, "%" is the modulus/modulo operator, not the power. >>> 20 % 2 0 So, the while line: number % 2 == 0 Returns True if number is even. It says "If number / 2 leaves no remainder". Compare that to: >>> 20 % 3 2 Which says "20 / 3 leaves a remainder of 2". Hope that helps. Leam On 9/15/23 15:07, Robert Towne wrote: > Im having problems understanding this. Im running the while loop like it > says; and it doesnt complete the loop. > My question is, is it the formula thats wrong or my math. The % sign means > to square the number? > since i the to the second power is 64. Then it should return false. IDK > what I am doing wrong, if you could > help me understand where I am going wrong i would appreciate it thank you. > > def is_power_of_two(number): > # This while loop checks if the "number" can be divided by two > # without leaving a remainder. How can you change the while loop to > # avoid a Python ZeroDivisionError? > while number % 2 == 0: > number = number / 2 > # If after dividing by 2 "number" equals 1, then "number" is a power > # of 2. > if number == 1: > return True > return False > > # Calls to the function > print(is_power_of_two(0)) # Should be False > print(is_power_of_two(1)) # Should be True > print(is_power_of_two(8)) # Should be True > print(is_power_of_two(9)) # Should be False > _______________________________________________ > Tutor maillist - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Software Engineer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) From mistihamon at gmail.com Wed Sep 20 03:07:22 2023 From: mistihamon at gmail.com (Misti Hamon) Date: Wed, 20 Sep 2023 01:07:22 -0600 Subject: [Tutor] im having problems and need help In-Reply-To: References: Message-ID: Your math is incorrect. And as a result, you are running the whole code wrong. To start you out, the % is the modulo operator. Modulo returns the remainder portion of division, so, 5 % 3 would return 2 (3 goes into 5 1 time, with 2 remaining), 5 % 2 would return 1 (2 goes into 5 2 times with remainder 1). On Wed, Sep 20, 2023, 00:05 Robert Towne wrote: > Im having problems understanding this. Im running the while loop like it > says; and it doesnt complete the loop. > My question is, is it the formula thats wrong or my math. The % sign means > to square the number? > since i the to the second power is 64. Then it should return false. IDK > what I am doing wrong, if you could > help me understand where I am going wrong i would appreciate it thank you. > > def is_power_of_two(number): > # This while loop checks if the "number" can be divided by two > # without leaving a remainder. How can you change the while loop to > # avoid a Python ZeroDivisionError? > while number % 2 == 0: > number = number / 2 > # If after dividing by 2 "number" equals 1, then "number" is a power > # of 2. > if number == 1: > return True > return False > > # Calls to the function > print(is_power_of_two(0)) # Should be False > print(is_power_of_two(1)) # Should be True > print(is_power_of_two(8)) # Should be True > print(is_power_of_two(9)) # Should be False > _______________________________________________ > Tutor maillist - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > From leamhall at gmail.com Wed Sep 20 15:15:41 2023 From: leamhall at gmail.com (Leam Hall) Date: Wed, 20 Sep 2023 14:15:41 -0500 Subject: [Tutor] Fwd: im having problems and need help In-Reply-To: References: Message-ID: Hey Robert, no worries! If I am using whole numbers for division, like 3, and 20, then: 20 divided by 3 gives 6. 3 times 6 is 18, and if I am dividing into 20, there is 2 left over. So, 20 % 3 is 2, since there is 2 left over. When you say: if number % 2 == 0: You have already proven that the number is even. Does that help? Leam -------- Forwarded Message -------- Subject: Re: [Tutor] im having problems and need help Date: Wed, 20 Sep 2023 12:03:12 -0700 From: Robert Towne To: Leam Hall I'm lost on the modelo. % it's a reminder? I don't understand it. I ran it in print(number%2). No matter what the number was it would come out to 1 or 0. I'm thinking the % is like a pre program. If it's even or odd. I'm not sure. Though. I'm stuck. I can run a while loop. But I'm lost at this modulo %. On Wed, Sep 20, 2023, 4:48 AM Leam Hall > wrote: Robert, Sorry, your mail program killed the code indents. Also, "%" is the modulus/modulo operator, not the power. >>> 20 % 2 0 So, the while line: ? ? ?number % 2 == 0 Returns True if number is even. It says "If number / 2 leaves no remainder". Compare that to: >>> 20 % 3 2 Which says "20 / 3 leaves a remainder of 2". Hope that helps. Leam On 9/15/23 15:07, Robert Towne wrote: > Im having problems understanding this. Im running the while loop like it > says; and it doesnt complete the loop. > My question is, is it the formula thats wrong or my math. The % sign means > to square the number? > since i the to the second power is 64. Then it should return false. IDK > what I am doing wrong, if you could > help me understand where I am going wrong i would appreciate it thank you. > > def is_power_of_two(number): > # This while loop checks if the "number" can be divided by two > # without leaving a remainder. How can you change the while loop to > # avoid a Python ZeroDivisionError? > while number % 2 == 0: > number = number / 2 > # If after dividing by 2 "number" equals 1, then "number" is a power > # of 2. > if number == 1: > return True > return False > > # Calls to the function > print(is_power_of_two(0)) # Should be False > print(is_power_of_two(1)) # Should be True > print(is_power_of_two(8)) # Should be True > print(is_power_of_two(9)) # Should be False > _______________________________________________ > Tutor maillist? - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor -- Software Engineer? ? ? ? ? (reuel.net/resume ) Scribe: The Domici War? ? ?(domiciwar.net ) General Ne'er-do-well? ? ? (github.com/LeamHall ) _______________________________________________ Tutor maillist? - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor -- Software Engineer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) From borkenhagenmatthew at gmail.com Wed Sep 20 18:41:44 2023 From: borkenhagenmatthew at gmail.com (Matthew Borkenhagen) Date: Wed, 20 Sep 2023 16:41:44 -0600 Subject: [Tutor] wordcount.py provided exercise solution not working? Message-ID: Hello, In working through Google's Python Class ( https://developers.google.com/edu/python) I just ran the provided solution from Google for the exercise on dicts and files: wordcount.py When I run this program while in the proper directory at the command prompt, the program only prints *this result*: *usage: ./wordcount.py {--count | --topcount} file* My question is this--Is this provided solution ever reading a file? (What is the filename that it should be reading called? Where would this file be located? In the directory google-python-exercises\basic\solution or would I need to create a file myself for it to read in order to test the program?) I have copied and pasted the provided solution for this exercise below. Thanks, Matt Borkenhagen #!/usr/bin/python3 # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ """Wordcount exercise Google's Python class The main() below is already defined and complete. It calls print_words() and print_top() functions which you write. 1. For the --count flag, implement a print_words(filename) function that counts how often each word appears in the text and prints: word1 count1 word2 count2 ... Print the above list in order sorted by word (python will sort punctuation to come before letters -- that's fine). Store all the words as lowercase, so 'The' and 'the' count as the same word. 2. For the --topcount flag, implement a print_top(filename) which is similar to print_words() but which prints just the top 20 most common words sorted so the most common word is first, then the next most common, and so on. Use str.split() (no arguments) to split on all whitespace. Workflow: don't build the whole program at once. Get it to an intermediate milestone and print your data structure and sys.exit(0). When that's working, try for the next milestone. Optional: define a helper function to avoid code duplication inside print_words() and print_top(). """ import sys # +++your code here+++ # Define print_words(filename) and print_top(filename) functions. # You could write a helper utility function that reads a file # and builds and returns a word/count dict for it. # Then print_words() and print_top() can just call the utility function. #### LAB(begin solution) def word_count_dict(filename): """Returns a word/count dict for this filename.""" # Utility used by count() and Topcount(). word_count = {} # Map each word to its count input_file = open(filename, encoding='utf-8') for line in input_file: words = line.split() for word in words: word = word.lower() # Special case if we're seeing this word for the first time. if not word in word_count: word_count[word] = 1 else: word_count[word] = word_count[word] + 1 input_file.close() # Not strictly required, but good form. return word_count def print_words(filename): """Prints one per line ' ' sorted by word for the given file.""" word_count = word_count_dict(filename) words = sorted(word_count.keys()) for word in words: print(word, word_count[word]) def get_count(word_count_tuple): """Returns the count from a dict word/count tuple -- used for custom sort.""" return word_count_tuple[1] def print_top(filename): """Prints the top count listing for the given file.""" word_count = word_count_dict(filename) # Each item is a (word, count) tuple. # Sort them so the big counts are first using key=get_count() to extract count. items = sorted(word_count.items(), key=get_count, reverse=True) # Print the first 20 for item in items[:20]: print(item[0], item[1]) ##### LAB(end solution) # This basic command line argument parsing code is provided and # calls the print_words() and print_top() functions which you must define. def main(): if len(sys.argv) != 3: print('usage: ./wordcount.py {--count | --topcount} file') sys.exit(1) option = sys.argv[1] filename = sys.argv[2] if option == '--count': print_words(filename) elif option == '--topcount': print_top(filename) else: print('unknown option: ' + option) sys.exit(1) if __name__ == '__main__': main() From mats at wichmann.us Wed Sep 20 19:08:28 2023 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 20 Sep 2023 17:08:28 -0600 Subject: [Tutor] wordcount.py provided exercise solution not working? In-Reply-To: References: Message-ID: On 9/20/23 16:41, Matthew Borkenhagen wrote: > Hello, > > In working through Google's Python Class ( > https://developers.google.com/edu/python) I just ran the provided solution > from Google for the exercise on dicts and files: wordcount.py > When I run this program while in the proper directory at the command > prompt, the program only prints *this result*: > > *usage: ./wordcount.py {--count | --topcount} file* > > My question is this--Is this provided solution ever reading a file? (What > is the filename that it should be reading called? Where would this file > be located? In the directory google-python-exercises\basic\solution or > would I need to create a file myself for it to read in order to test the > program?) The filename is whatever you tell it. But, apparently, you *have* to select one of the options too (it's not "optional"). def main(): if len(sys.argv) != 3: print('usage: ./wordcount.py {--count | --topcount} file') sys.exit(1) option = sys.argv[1] filename = sys.argv[2] This says: if the script is not called with three arguments, print an error message and quit. By convention, the name of the program you just ran is sys.argv[0], so you have to supply two more arguments on the command line. The first will be the option you selected, and the second will be the filename to count the words in. From mats at wichmann.us Wed Sep 20 19:54:47 2023 From: mats at wichmann.us (Mats Wichmann) Date: Wed, 20 Sep 2023 17:54:47 -0600 Subject: [Tutor] wordcount.py provided exercise solution not working? In-Reply-To: References: Message-ID: <936d64b4-d8d9-9740-0981-82277d72af96@wichmann.us> On 9/20/23 17:33, Matthew Borkenhagen wrote: > Thank you Mats, that is very helpful.? Is a file provided by Google or > will I need to create one myself?? (Just use a text editor like > Notepad++?? Save it with a .txt extension?) the purpose of the script is to count words in a file - any file - so just point it at whatever file you want. You can create one, or use one that is already lying about. From borkenhagenmatthew at gmail.com Wed Sep 20 19:33:52 2023 From: borkenhagenmatthew at gmail.com (Matthew Borkenhagen) Date: Wed, 20 Sep 2023 17:33:52 -0600 Subject: [Tutor] wordcount.py provided exercise solution not working? In-Reply-To: References: Message-ID: Thank you Mats, that is very helpful. Is a file provided by Google or will I need to create one myself? (Just use a text editor like Notepad++? Save it with a .txt extension?) Matt Borkenhagen On Wed, Sep 20, 2023, 5:10 PM Mats Wichmann wrote: > On 9/20/23 16:41, Matthew Borkenhagen wrote: > > Hello, > > > > In working through Google's Python Class ( > > https://developers.google.com/edu/python) I just ran the provided > solution > > from Google for the exercise on dicts and files: wordcount.py > > When I run this program while in the proper directory at the command > > prompt, the program only prints *this result*: > > > > *usage: ./wordcount.py {--count | --topcount} file* > > > > My question is this--Is this provided solution ever reading a file? > (What > > is the filename that it should be reading called? Where would this file > > be located? In the directory google-python-exercises\basic\solution or > > would I need to create a file myself for it to read in order to test the > > program?) > > The filename is whatever you tell it. But, apparently, you *have* to > select one of the options too (it's not "optional"). > > def main(): > if len(sys.argv) != 3: > print('usage: ./wordcount.py {--count | --topcount} file') > sys.exit(1) > > option = sys.argv[1] > filename = sys.argv[2] > > This says: if the script is not called with three arguments, print an > error message and quit. By convention, the name of the program you just > ran is sys.argv[0], so you have to supply two more arguments on the > command line. The first will be the option you selected, and the second > will be the filename to count the words in. > > > _______________________________________________ > Tutor maillist - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > From ludo.a.joris at telenet.be Thu Sep 21 04:20:41 2023 From: ludo.a.joris at telenet.be (Ludo Joris) Date: Thu, 21 Sep 2023 10:20:41 +0200 (CEST) Subject: [Tutor] wordcount.py provided exercise solution not working? In-Reply-To: References: Message-ID: <1258136792.21339971.1695284441129.JavaMail.zimbra@telenet.be> Hi Matt, You already have a text file, yoyr Python script. Do this: ./wordcount.py --topcount wordcount.py # 14 = 12 for 10 the 9 and 7 word 7 a 6 def 5 in 5 if 5 word_count 4 utility 3 word/count 3 dict 3 this 3 count 3 line 3 first 3 word_count[word] 3 option 3 ----- On Sep 21, 2023, at 1:33 AM, Matthew Borkenhagen wrote: > Thank you Mats, that is very helpful. Is a file provided by Google or will > I need to create one myself? (Just use a text editor like Notepad++? Save > it with a .txt extension?) > Matt Borkenhagen > On Wed, Sep 20, 2023, 5:10 PM Mats Wichmann wrote: > > On 9/20/23 16:41, Matthew Borkenhagen wrote: > > > Hello, > > > In working through Google's Python Class ( > > > https://developers.google.com/edu/python) I just ran the provided > > solution > > > from Google for the exercise on dicts and files: wordcount.py > > > When I run this program while in the proper directory at the command > > > prompt, the program only prints *this result*: > > > *usage: ./wordcount.py {--count | --topcount} file* > > > My question is this--Is this provided solution ever reading a file? > > (What > > > is the filename that it should be reading called? Where would this file > > > be located? In the directory google-python-exercises\basic\solution or > > > would I need to create a file myself for it to read in order to test the > > > program?) > > The filename is whatever you tell it. But, apparently, you *have* to > > select one of the options too (it's not "optional"). > > def main(): > > if len(sys.argv) != 3: > > print('usage: ./wordcount.py {--count | --topcount} file') > > sys.exit(1) > > option = sys.argv[1] > > filename = sys.argv[2] > > This says: if the script is not called with three arguments, print an > > error message and quit. By convention, the name of the program you just > > ran is sys.argv[0], so you have to supply two more arguments on the > > command line. The first will be the option you selected, and the second > > will be the filename to count the words in. > > _______________________________________________ > > Tutor maillist - Tutor at python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > _______________________________________________ > Tutor maillist - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor From ESweetland at bosworthschool.co.uk Sat Sep 23 08:54:23 2023 From: ESweetland at bosworthschool.co.uk (Emma Sweetland) Date: Sat, 23 Sep 2023 12:54:23 +0000 Subject: [Tutor] question about subroutine Message-ID: I was wondering if someone could advise about what is going wrong with this subroutine. With some debugging prints, I know the problem is definitely on line 9 when new[row][column] is assigned a new value. That part is working but the problem is that it is also changing the corresponding value in grid which is the list from which new was originally copied (using append). This is happening despite the fact that new and grid have different addresses (ids) so I don't understand how a change to new is affecting grid. Any help gratefully received. Thank you. Emma Sweetland? Teacher - Mathematics E: ESweetland at bosworthcollege.com W: www.bosworthcollege.com M: T: +44 1604 239 995 [cid:c69baae0-d942-4dfa-b7be-09ed03472196] [cid:637d5568-d010-4e8d-9756-004cd338ad23] [cid:6374fa7e-d9ca-4eaf-bf20-d9e56505b5fd] [cid:857bfdde-db53-4e9d-8a20-9ca86c9a9b21] [cid:b198bc7c-c119-47a3-849f-8999861a6ba2] This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Bright Scholar (UK) Holdings Limited, trading as CATS Global Schools and/or subsidiary companies. In order to prevent fraudulent activity (including phishing), we will not request you to pay any invoices or monies into accounts other than the account stated within its own invoice(s). Any change to such accounts will be an exceptional occurrence and any such request, purported to be from us, should be subject to your own additional authentication or verification steps prior to making any such change or payment(s). This message has been scanned for malware by Office 365. www.office365.com From PythonList at DancesWithMice.info Sat Sep 23 17:15:08 2023 From: PythonList at DancesWithMice.info (dn) Date: Sun, 24 Sep 2023 10:15:08 +1300 Subject: [Tutor] question about subroutine In-Reply-To: References: Message-ID: <4e0e3f6b-1811-492a-ba0f-eea8254f644d@DancesWithMice.info> On 24/09/2023 00.54, Emma Sweetland wrote: > I was wondering if someone could advise about what is going wrong with this subroutine. With some debugging prints, I know the problem is definitely on line 9 when new[row][column] is assigned a new value. That part is working but the problem is that it is also changing the corresponding value in grid which is the list from which new was originally copied (using append). This is happening despite the fact that new and grid have different addresses (ids) so I don't understand how a change to new is affecting grid. Any help gratefully received. Thank you. Regret to advise that this list will not accept attachments. Please copy-paste code into the email message (and ensure formatting). It sounds like a misunderstanding about how Python handles 'variables'. Instead of a specific area of memory, Python ids are pointers. Thus, different lists could still point to the same values. https://docs.python.org/3/library/copy.html -- Regards, =dn From PythonList at DancesWithMice.info Sat Sep 23 17:18:20 2023 From: PythonList at DancesWithMice.info (dn) Date: Sun, 24 Sep 2023 10:18:20 +1300 Subject: [Tutor] question about subroutine In-Reply-To: References: Message-ID: <7cf7b8e6-a17e-4c2e-9138-a743a11f9588@DancesWithMice.info> On 24/09/2023 00.54, Emma Sweetland wrote: See also: Variables and objects in Python Trey Hunner 9 min. read ? Python 3.8?3.11 ? Feb. 28, 2022 https://www.pythonmorsels.com/pointers/ -- Regards, =dn From phillor9 at gmail.com Sat Sep 30 00:22:22 2023 From: phillor9 at gmail.com (Phil) Date: Sat, 30 Sep 2023 14:22:22 +1000 Subject: [Tutor] Tkinter button command question Message-ID: <44adeb62-b1d8-deec-a5cd-fde2b42a08b2@gmail.com> This is a confusing problem so I'll do my best to explain it clearly. I have created a Tkinter app that consists of two classes; an App and an Entry class. The entry class has a variable named self.a and is set like this: self.a = "". Each class has an identical function named solve(). The Entry class has a button defined as follows: ??????? solve_button = customtkinter.CTkButton( ??????????? self, ??????????? text="solve", ??????????? width=80, ??????????? #command=self.solve, ??????????? command=self.master.solve,? # This calls the App class solve function ??????? ) If the command calls the Entry class solve() then self.a = "x" (self.a is set to "x" before the solve button is pressed). If the command calls the App class solve then self.a = "", the initial value of self.a. I hope that someone can offer a working suggestion because I've reached the limit of my ability. By the way, my AI friend suggested "command=self.master.solve" but cannot offer a working solution that solves the problem. self.a = "x" when command=self.solve and self.x = "" when command=self.master.solve. I should mention that I have stepped through the code with the debugger and the App class solve() is called after the button is pressed and after self.a is set to "x". -- Regards, Phil From phillor9 at gmail.com Sat Sep 30 02:10:38 2023 From: phillor9 at gmail.com (Phil) Date: Sat, 30 Sep 2023 16:10:38 +1000 Subject: [Tutor] Re my Tkinter question - problem solved Message-ID: I hope this is caught before my previous question passes the moderation test. -- Regards, Phil From jpatierno1 at yahoo.com Fri Sep 29 21:50:17 2023 From: jpatierno1 at yahoo.com (Verizon!!) Date: Sat, 30 Sep 2023 01:50:17 +0000 (UTC) Subject: [Tutor] re code References: <982530493.1259878.1696038617950.ref@mail.yahoo.com> Message-ID: <982530493.1259878.1696038617950@mail.yahoo.com> I have a program coded in visual basic 6.0 and want to code it in python. I'm in Pompano Beach Florida and hoping that a python guru is close by. The program takes a comma delimited data file with 1400+ fields and pulls out specific fields applies some calcs and formulas and outputs a report From alan.gauld at yahoo.co.uk Sat Sep 30 08:17:12 2023 From: alan.gauld at yahoo.co.uk (Alan Gauld) Date: Sat, 30 Sep 2023 13:17:12 +0100 Subject: [Tutor] re code In-Reply-To: <982530493.1259878.1696038617950@mail.yahoo.com> References: <982530493.1259878.1696038617950.ref@mail.yahoo.com> <982530493.1259878.1696038617950@mail.yahoo.com> Message-ID: On 30/09/2023 02:50, Verizon!! via Tutor wrote: > I have a program coded in visual basic 6.0 and want to code it in python. That's fine, although for best results be open to new ways of thinking about the code, don;t try to "translate" the VB to Python. The idioms are very different. > Florida and hoping that a python guru is close by. This is the internet, the whole world is close-by. The tutor list works by you asking questions (or posting code for critique) and the list members responding with answers/comments. > The program takes a comma delimited data file with 1400+ fields That's a lot of fields, however the Python csv module can cope. > pulls out specific fields applies some calcs and formulas and outputs a report And if the calculations get complex you might also want to look at SciPy with Pandas(which can also read csv files and do data crunching and reports etc) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos From farazpak at gmail.com Sat Sep 30 04:38:23 2023 From: farazpak at gmail.com (Faraz Ahmad) Date: Sat, 30 Sep 2023 13:38:23 +0500 Subject: [Tutor] re code In-Reply-To: <982530493.1259878.1696038617950@mail.yahoo.com> References: <982530493.1259878.1696038617950.ref@mail.yahoo.com> <982530493.1259878.1696038617950@mail.yahoo.com> Message-ID: Of course, I will be there to help you. Now how I can help you. On Sat, Sep 30, 2023, 12:52 PM Verizon!! via Tutor wrote: > I have a program coded in visual basic 6.0 and want to code it in python. > I'm in Pompano Beach Florida and hoping that a python guru is close by. The > program takes a comma delimited data file with 1400+ fields and pulls out > specific fields applies some calcs and formulas and outputs a report > _______________________________________________ > Tutor maillist - Tutor at python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > From diana.katz at gmail.com Sat Sep 30 09:12:04 2023 From: diana.katz at gmail.com (Diana Katz) Date: Sat, 30 Sep 2023 09:12:04 -0400 Subject: [Tutor] Image processing Message-ID: <65C5231D-2326-4F35-8C38-2EC5AB10472C@gmail.com> Hi, My daughter has voltage data points from A homemade ultrasound that she is trying to convert into an ultrasound image. even a rudimentary picture. Is there any expert on here that can help us turning voltage signals into pixels? Knowledge of some high pass filtering too. Di k. Sent from my iPhone From threesomequarks at proton.me Sat Sep 30 14:26:33 2023 From: threesomequarks at proton.me (ThreeBlindQuarks) Date: Sat, 30 Sep 2023 18:26:33 +0000 Subject: [Tutor] re code In-Reply-To: References: <982530493.1259878.1696038617950.ref@mail.yahoo.com> <982530493.1259878.1696038617950@mail.yahoo.com> Message-ID: <3mgAqSojZ6xy5H_tYQkkoi5zGz4E0N9S8TUbtuVjkJ72ATqSs4ZmOOviS-BLu7INlAe3C-B7LAVlTDLMGphUtfg5NaiKErl-kzeoFkfFNaM=@proton.me> The request is a tad general and depending on what is required certainly sounds very doable as long as all that is needed is a CSV file properly formatted and some internal logic The request for someone nearby, as noted, may make more sense if you want someone to teach you in person or if the data is local and cannot be shared. But setting up someone to be paid or to volunteer to travel with you is arguably not an important aspect of this group. Some may be willing but others will more likely chime in fir more specific questions like. How do I read in a CSV into an appropriate data structure? As noted, some may suggest the pandas module. How do I discard most of the resulting columns? How do I make sure my columns are of the data type I need? How do I clean the data in various ways? How do I efficiently select subsets of the data, do columnist calculations, make graphs and save results and so on? As you already have a program in another language, then someone familiar with it could emulate ir or even improve on it, unless you also want new features. Your issue is not uncommon as so many older programs are kept around even as the underlying environment falls out of favor. So I suggest you aim for a recent version of Python, not version 2. Sent from Proton Mail mobile -------- Original Message -------- On Sep 30, 2023, 8:17 AM, Alan Gauld via Tutor wrote: > On 30/09/2023 02:50, Verizon!! via Tutor wrote: > I have a program coded in visual basic 6.0 and want to code it in python. That's fine, although for best results be open to new ways of thinking about the code, don;t try to "translate" the VB to Python. The idioms are very different. > Florida and hoping that a python guru is close by. This is the internet, the whole world is close-by. The tutor list works by you asking questions (or posting code for critique) and the list members responding with answers/comments. > The program takes a comma delimited data file with 1400+ fields That's a lot of fields, however the Python csv module can cope. > pulls out specific fields applies some calcs and formulas and outputs a report And if the calculations get complex you might also want to look at SciPy with Pandas(which can also read csv files and do data crunching and reports etc) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor From threesomequarks at proton.me Sat Sep 30 14:46:41 2023 From: threesomequarks at proton.me (ThreeBlindQuarks) Date: Sat, 30 Sep 2023 18:46:41 +0000 Subject: [Tutor] question about subroutine In-Reply-To: References: Message-ID: Without being able to see the code described, all I can share is my reaction to the phrase "subroutine". I assume you either mean some function you call or perhaps a stretch of code such as on a branch of an IF statement or the like. To me, it reminds me of very early days when a language like BASIC had a line like: GOSUB 500 Does that approach now sound so primitive so that few languages now use anything direct like a GOTO or at least deprecate it? Or do people now routinely still use phrases like subroutine? Sent from Proton Mail mobile -------- Original Message -------- On Sep 23, 2023, 8:54 AM, Emma Sweetland wrote: > I was wondering if someone could advise about what is going wrong with this subroutine. With some debugging prints, I know the problem is definitely on line 9 when new[row][column] is assigned a new value. That part is working but the problem is that it is also changing the corresponding value in grid which is the list from which new was originally copied (using append). This is happening despite the fact that new and grid have different addresses (ids) so I don't understand how a change to new is affecting grid. Any help gratefully received. Thank you. Emma Sweetland? Teacher - Mathematics E: ESweetland at bosworthcollege.com W: www.bosworthcollege.com M: T: +44 1604 239 995 [cid:c69baae0-d942-4dfa-b7be-09ed03472196] [cid:637d5568-d010-4e8d-9756-004cd338ad23] [cid:6374fa7e-d9ca-4eaf-bf20-d9e56505b5fd] [cid:857bfdde-db53-4e9d-8a20-9ca86c9a9b21] [cid:b198bc7c-c119-47a3-849f-8999861a6ba2] This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the originator of the message. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Bright Scholar (UK) Holdings Limited, trading as CATS Global Schools and/or subsidiary companies. In order to prevent fraudulent activity (including phishing), we will not request you to pay any invoices or monies into accounts other than the account stated within its own invoice(s). Any change to such accounts will be an exceptional occurrence and any such request, purported to be from us, should be subject to your own additional authentication or verification steps prior to making any such change or payment(s). This message has been scanned for malware by Office 365. www.office365.com _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor From leamhall at gmail.com Sat Sep 30 21:58:51 2023 From: leamhall at gmail.com (Leam Hall) Date: Sat, 30 Sep 2023 20:58:51 -0500 Subject: [Tutor] question about subroutine In-Reply-To: References: Message-ID: <4c68401f-8721-2e9a-007a-09d134cbc935@gmail.com> "sub" is the Perl equivalent of "def". On 9/30/23 13:46, ThreeBlindQuarks via Tutor wrote: > Without being able to see the code described, all I can share is my reaction to the phrase "subroutine". > Or do people now routinely still use phrases like subroutine? -- Software Engineer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) From threesomequarks at proton.me Sat Sep 30 22:36:18 2023 From: threesomequarks at proton.me (ThreeBlindQuarks) Date: Sun, 01 Oct 2023 02:36:18 +0000 Subject: [Tutor] question about subroutine In-Reply-To: <4c68401f-8721-2e9a-007a-09d134cbc935@gmail.com> References: <4c68401f-8721-2e9a-007a-09d134cbc935@gmail.com> Message-ID: Yes, Leam, PERL is quite an old language I used in the late 80's and beyond. But the SUB commandments is pretty much how a programmer creates functions to add to the built in functions. There are subtleties but I accept the name subroutine is used by many. I see it as a hybrid in a way. It lets you store commands somewhere else then pass control to there and return back with no value. In a sense it is a bit like what Pascal called a procedure but not really. Many other languages allow any function to return one or more kinds of things including nothing. In a sense, I find a primitive quality to the PERL add-on as the subroutine uses special notation to access arguments but sometimes allow you to change them. My comment in a forum about Python was that the usual terminology for functions might include the name method but I had not seen subroutine. Sent from Proton Mail mobile -------- Original Message -------- On Sep 30, 2023, 9:58 PM, Leam Hall wrote: > "sub" is the Perl equivalent of "def". On 9/30/23 13:46, ThreeBlindQuarks via Tutor wrote: > Without being able to see the code described, all I can share is my reaction to the phrase "subroutine". > Or do people now routinely still use phrases like subroutine? -- Software Engineer (reuel.net/resume) Scribe: The Domici War (domiciwar.net) General Ne'er-do-well (github.com/LeamHall) _______________________________________________ Tutor maillist - Tutor at python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor