Python Forum
assigned variable fails to show up
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
assigned variable fails to show up
#1
i have a big script with a line that assigns an IPv6 address string literal to the variable ipv6and the next line tries to print it:
ipv6 = 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128'
print('ipv6 =',repr(ipv6))
running it in Python 3.5.2 gets:
Output:
Traceback (most recent call last): File "get_ipv6.py", line 96, in <module> print('ipv6 =',repr(ipv6)) NameError: name 'ipv6' is not defined
then i add print() calls to dump out locals() and globals() and 'ipv6' just was just not in there. how can i go about debugging this?

these lines were not indented at all and not in any if statements or loops. it should have been straight unconditional execution.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Your two lines of code working well in a Python shell.

Your error message indicates that you use this lines near "line 96" in the file "get_ipv6.py". There error must be somewhere around there. Please post the complete function/methode where you use this two lines.
Reply
#3
this script is too large and has proprietary info and cloud credentials in it so posting it is not an option. i will have to do the debugging. i'm just asking for ideas.

i moved the assignment to near the top of the file, to be the first assignment right after the imports. now it works.

i copied that ipv6 assignment back to the original spot and changed the name to a new name. the new name does not show up. it's like Python is jumping over this position. i guess i should look for a goto somewhere. oh wait.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
Please use corrent upper case letters. Your text is hard to read.

I asked for the one function/methode. Not for the whole script.

And if you have credentials in cour script - it is your fault.
Reply
#5
it is not in a function or method. this is a script in the classic sense ... a quickie.

yes, it is my fault there are credentials in the file. i was in a hurry and didn't code in to read them from the agent.

i type only in lower case due to a personal disability. i do not agree with English's use of capitalization for other than proper names. the very first letters of Old English didn't have cases at all. Old English came from the Anglo-Frisian language which had a writing system first created by the Danish Vikings which used runes that have no cases.

i changed the name back in that 2nd assignment. now there are 2. i changed the string of the 2nd one to a different value. the print call to print out printed the 1st assignment's value.

i found the problem, an overrun comment just before it which emacs lets me move to it as if it were in column 1. but, it was at the far right end of the comment above. i blame that new "feature" in emacs that they added a few years ago that i have never liked.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PIL Image im.show() no show! Pedroski55 2 928 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  PIL Image im.show() no show! Pedroski55 6 4,740 Feb-08-2022, 06:32 AM
Last Post: Pedroski55
  How to assigned value to each different binary in python... ZYSIA 2 1,991 Jul-12-2021, 11:01 AM
Last Post: Gribouillis
  Function assigned at a button in tkinter riccardoob 9 4,102 Oct-06-2019, 11:14 AM
Last Post: riccardoob

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020