Python Forum
Function Annotation got NameError: name 'xxx' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function Annotation got NameError: name 'xxx' is not defined
#3
(Oct-22-2019, 02:08 PM)ichabod801 Wrote:
PEP 3107 Wrote:All annotation expressions are evaluated when the function definition is executed, just like default values.
This all seems consistent with PEP 3107. Annotations are expressions which are evaluated. In order to evaluate anything in Python, all the names must be defined. This precludes circular annotations like you are trying to do.


Thanks for your advice, but this type of circular reference is valid requirement, right? eg. two type of classes with parent and child relation. In other static languages, with type definition in advance, there is no any problem. On another hand, In above case that I showed, python allows circular reference inside function and it works without function annotation, but it's not allowed in function annotation, which will limit the usage of function annotation, do you have any solution except python 2 style type remarks which I used now?
Reply


Messages In This Thread
RE: Function Annotation got NameError: name 'xxx' is not defined - by Lance - Oct-22-2019, 11:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm getting a NameError: ...not defined. vonArre 2 354 Mar-24-2024, 10:25 PM
Last Post: vonArre
  Decorators @ annotation drcl 3 447 Feb-24-2024, 06:12 AM
Last Post: Gribouillis
  Variable is not defined error when trying to use my custom function code fnafgamer239 4 630 Nov-23-2023, 02:53 PM
Last Post: rob101
  Printing the variable from defined function jws 7 1,394 Sep-03-2023, 03:22 PM
Last Post: deanhystad
Question How to annotation type? gamecss 4 1,042 Jul-27-2023, 03:03 AM
Last Post: gamecss
  Getting NameError for a function that is defined JonWayn 2 1,138 Dec-11-2022, 01:53 PM
Last Post: JonWayn
Question Help with function - encryption - messages - NameError: name 'message' is not defined MrKnd94 4 2,959 Nov-11-2022, 09:03 PM
Last Post: deanhystad
  How to print the output of a defined function bshoushtarian 4 1,341 Sep-08-2022, 01:44 PM
Last Post: deanhystad
  [split] NameError: name 'csvwriter' is not defined. Did you mean: 'writer'? cathy12 4 3,406 Sep-01-2022, 07:41 PM
Last Post: deanhystad
  NameError: name ‘app_ctrl’ is not defined 3lnyn0 0 1,537 Jul-04-2022, 08:08 PM
Last Post: 3lnyn0

Forum Jump:

User Panel Messages

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