[New-bugs-announce] [issue36653] Dictionary Key is without ' ' quotes
PushkarVaity
report at bugs.python.org
Wed Apr 17 18:34:23 EDT 2019
New submission from PushkarVaity <iampushkar01 at gmail.com>:
I am using Python 3.7 with anaconda install.
I am trying to write out a dictionary with similar key's.
for ex: proc_dict = {'add': ('/home/file.tcl', 'args'), 'add': ('/home/file2.tcl', 'args'), 'sub': ('/home/file2.tcl', 'args')}
To do this, I am using the following class definition and functions:
class ProcOne(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
I am writing out the dictionary in the following way:
proc_dict[ProcOne(proc_name)] = (full_file, proc_args)
Now, the dictionary key as shown in the example at top is of string type. proc_name is the variable holding this string.
The values are tuples. Both elements in the tuple are strings.
When the dictionary is finally written out, the format is as below:
proc_dict = {add: ('/home/file.tcl', 'args'), add: ('/home/file2.tcl', 'args'), sub: ('/home/file2.tcl', 'args')}
Please note the difference from the first example.
The key values don't have a ' ' quote in spite of being a string variable type.
Since the string quotes are missing, it is very difficult to do post processing on this dictionary key.
I am a student and I though that this is an issue because now I am not able to compare the key value with a normal string because of the missing quotes. The in or not in checking operations do not evaluate to true/false because of the missing quotes.
Please let me know if this has never been reported before as I am just a novice programmer and would be a big boost to my morale :-)
Also, please let me know if this issue was already known or wasn't an issue at all.
----------
components: Regular Expressions
messages: 340452
nosy: PushkarVaity, ezio.melotti, mrabarnett
priority: normal
severity: normal
status: open
title: Dictionary Key is without ' ' quotes
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36653>
_______________________________________
More information about the New-bugs-announce
mailing list