[Tutor] "List" object is not callable
Hello, I found this simple script online but when I execute it I get the following error: "TypeError: 'list' object is not callable" Here is the code sample:import subprocess ls_output= subprocess.check_output(['dir']) I searched online and found a another similar code sample (http://www.opentechguides.com/how-to/article/python/57/python-ping-subnet.html) but when I run it on my system I get the same error.Any feedback is very much appreciated. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] "List" object is not callable
Thank you all for your responses. I am using Py 2.7 and this time I copied and pasted the code from here: http://www.opentechguides.com/how-to/article/python/57/python-ping-subnet.html to my system but received the same error when I ran it. You can see the error screenshot here: https://unsee.cc/sonezima/ Thank you. On Saturday, April 30, 2016 11:12 PM, Steven D'Aprano wrote: On Sat, Apr 30, 2016 at 06:51:17PM +0000, Jason N. via Tutor wrote: > Hello, > I found this simple script online but when I execute it I get the > following error: "TypeError: 'list' object is not callable" Here is > the code sample: > > import subprocess > ls_output= subprocess.check_output(['dir']) The code snippet works fine. Please check that the code you send is exactly the same as the code you are actually trying to run. Do not just retype the code from memory, copy and paste it. Also, please copy and paste the full traceback that you get, not just the final error message. Everything from the first "Traceback" line to the end. Finally, you should tell us what version of Python you are running, on what operating system (Linux, Mac OS, Windows XP, Windows 10, Android, something else), and whether you are using the standard Python interactive interpreter or something else (IDLE, iPython, Anaconda, PyCharm, etc.). -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] "List" object is not callable
Hello, I figured out the issue. It was a silly mistake - i was not running the correct code; instead was running code from another program which was active on a second tab. Thank you. On Sunday, May 1, 2016 4:15 PM, Jason N. via Tutor wrote: Thank you all for your responses. I am using Py 2.7 and this time I copied and pasted the code from here: http://www.opentechguides.com/how-to/article/python/57/python-ping-subnet.html to my system but received the same error when I ran it. You can see the error screenshot here: https://unsee.cc/sonezima/ Thank you. On Saturday, April 30, 2016 11:12 PM, Steven D'Aprano wrote: On Sat, Apr 30, 2016 at 06:51:17PM +0000, Jason N. via Tutor wrote: > Hello, > I found this simple script online but when I execute it I get the > following error: "TypeError: 'list' object is not callable" Here is > the code sample: > > import subprocess > ls_output= subprocess.check_output(['dir']) The code snippet works fine. Please check that the code you send is exactly the same as the code you are actually trying to run. Do not just retype the code from memory, copy and paste it. Also, please copy and paste the full traceback that you get, not just the final error message. Everything from the first "Traceback" line to the end. Finally, you should tell us what version of Python you are running, on what operating system (Linux, Mac OS, Windows XP, Windows 10, Android, something else), and whether you are using the standard Python interactive interpreter or something else (IDLE, iPython, Anaconda, PyCharm, etc.). -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Dictionary Question
Hello, Wanted to ask if its possible to have a dictionary that can be looked up by either values? For example, mydic = {"A: "Apple", "B": "Banana"}When user inputs "A" I want "Apple" to come. But if the user enter "Apple" I want "A" to respond. Please let me know the best way to handle this type cause instead of just created duplicate entries to cover all possibilities. Thank you. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dictionary Question
Thank you all for your responses. A quick follow up, what is the best way to make dictionary requests case in-sensitive? For example, "Apple and "apple" should bring back the same dictionary response. Thank you. On Monday, May 2, 2016 6:57 PM, Bob Gailer wrote: On May 2, 2016 5:27 PM, "Jason N. via Tutor" wrote: > > Hello, > Wanted to ask if its possible to have a dictionary that can be looked up by > either values? > For example, > mydic = {"A: "Apple", "B": "Banana"}When user inputs "A" I want "Apple" to > come. But if the user enter "Apple" I want "A" to respond. I think this would depend on how big the data set is and how often you want to look things up. Two other Solutions: Create a class which internally manages two dictionaries. If things are really big create a database using for example sqlite. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor