Home >Backend Development >Python Tutorial >Can I retrieve the original variable name when returning an enum from a function?

Can I retrieve the original variable name when returning an enum from a function?

Barbara Streisand
Barbara StreisandOriginal
2024-10-29 11:18:30359browse

Can I retrieve the original variable name when returning an enum from a function?

Retrieving Original Variable Names after Invocation

When returning enum variables from functions, is it possible to retain their original names (e.g., myEnum.SomeNameA) instead of just their values?

Short Answer: No

Long Answer:

While this is technically possible through complex hacks involving traceback and introspection, it's generally discouraged for production code.

To address the underlying requirement, consider exploring workarounds that translate the returned values back into their original names or representative strings. Provide additional code samples and context to facilitate further assistance.

The above is the detailed content of Can I retrieve the original variable name when returning an enum from a function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn