![]() |
Using dictionary keys with embedded '.' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Using dictionary keys with embedded '.' (/thread-908.html) |
Using dictionary keys with embedded '.' - Larz60+ - Nov-13-2016 How to use wierd dictionary keys like "0-._.-._.-._.-._.-._.-._.-0" (This is not one of mine) do all the special charatcers have to be escaped? RE: Using dictionary keys with embedded '.' - Ofnuts - Nov-13-2016 No, a dictionary key can be any string... You don't need to escape anything, beyond what is needed for string literals, if your key names are in your source code. RE: Using dictionary keys with embedded '.' - Larz60+ - Nov-13-2016 Thanks RE: Using dictionary keys with embedded '.' - nilamo - Nov-15-2016 Yes, special characters would need to be escaped. But none of those are special characters :p >>> items = {"\n": "i'm a value!", "can't \"quote\" me!": "...oh"} >>> items {'\n': "i'm a value!", 'can\'t "quote" me!': '...oh'}...I guess our syntax highlighter can't quite handle nested strings. |