Message340452
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. |
|
Date |
User |
Action |
Args |
2019-04-17 22:34:23 | PushkarVaity | set | recipients:
+ PushkarVaity, ezio.melotti, mrabarnett |
2019-04-17 22:34:23 | PushkarVaity | set | messageid: <1555540463.86.0.601540134814.issue36653@roundup.psfhosted.org> |
2019-04-17 22:34:23 | PushkarVaity | link | issue36653 messages |
2019-04-17 22:34:23 | PushkarVaity | create | |
|