Python Forum
Using dictionary keys with embedded '.'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using dictionary keys with embedded '.'
#1
How to use wierd dictionary keys like "0-._.-._.-._.-._.-._.-._.-0" (This is not one of mine)
do all the special charatcers have to be escaped?
Reply
#2
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.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#3
Thanks
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding keys and values to a dictionary giladal 3 2,429 Nov-19-2020, 04:58 PM
Last Post: deanhystad
  access dictionary with keys from another and write values to list redminote4dd 6 3,162 Jun-03-2020, 05:20 PM
Last Post: DeaD_EyE
  Drop Keys From Dictionary donnertrud 8 3,610 May-30-2020, 11:39 AM
Last Post: DeaD_EyE
  Problem adding keys/values to dictionary where keynames = "property" and "value" jasonashaw 1 2,018 Dec-17-2019, 08:00 PM
Last Post: jasonashaw
  Checking if the combination of two keys is in a dictionary? mrsenorchuck 6 3,778 Dec-04-2019, 10:35 AM
Last Post: mrsenorchuck
  Retrieving dictionary keys within with another dictionay bazcurtis 8 2,728 Oct-29-2019, 10:06 PM
Last Post: bazcurtis
  json.dumps to keep dictionary keys batchenr 1 1,989 May-14-2019, 11:17 AM
Last Post: buran
  Reference new dictionary keys with a variable slouw 4 2,837 May-07-2019, 03:30 AM
Last Post: slouw
  Get specific key from multiple keys in python dictionary pradeepkumarbe 0 2,098 Mar-24-2019, 07:23 PM
Last Post: pradeepkumarbe
  Most efficient way to define sub keys of a dictionary? wrybread 1 2,071 Feb-21-2019, 12:23 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

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