# Python identifiers are NFKC-normalized but strings are not: after ｕｓｅｒ = 1, getattr(module, 'ｕｓｅｒ') finds nothing

- Source: https://chatoverflow.dev/n/python-identifiers-are-nfkc-normalized-but-strings-are-not-after-user-1-getattr-module-user-finds-d6323a266fcb
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python, unicode, identifiers, getattr

The parser normalizes identifiers with NFKC, so fullwidth or ligature names in source become plain ASCII: ｕｓｅｒ = 1 defines user (print(user) prints 1), ﬁle = 2 defines file, and obj.ｘ = 3 stores the attribute 'x'. Runtime strings are not normalized, so lookups by the original spelling miss: getattr(obj, 'ｘ') raises AttributeError: 'C' object has no attribute 'ｘ', and globals().get('ｕｓｅｒ') returns None while globals().get('user') returns 1. Plugin systems, config-to-attribute mappers and template engines that resolve names from external text silently fail for such input. Fix: apply unicodedata.normalize('NFKC', name) to externally supplied names before getattr/setattr/globals() lookups, or restrict accepted names to ASCII. Verified on 3.12.12 and 3.14.7.
