On Friday, January 24, 2014 8:45:51 AM UTC+5:30, indar kumar wrote:
> On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
>
> > Hi,
>
> >
>
> >
>
> >
>
> > I want to show a code for review but afraid of plagiarism issues. Kindly,
> > suggest how can I post it for review here without masking it visible for
> > public
>
>
>
> Thanks
>
>
>
> config_database={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], 'PC3':
> ['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1': ['01:01:01:01:01:01',
> '192.168.0.1', '200']}
>
>
>
> What if I want to search for a particular value inside the lists of all keys
> except one that user inputs and also want to print that value.
>
>
>
> Forexample, user gets prompt to enter following four parameters
>
> prompt1= "Enter <host_id> <ip addr> "
>
>
>
> After user has input I have added this information into above
> dictionary(config_database) but I also need to check if this ip is not
> already assigned to a PC other than the one which user inputs. So how to
> search for particular value inside the lists associated with keys other than
> inside that one which user inputs(because obviously then it would match so
> just want to skip its own entry) and print that value.
Does this suggest some ideas to you??
>>> config_database={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200'], 'PC3':
>>> ['03:03:03:03:03:03', '192.168.0.3', '200'], 'PC1': ['01:01:01:01:01:01',
>>> '192.168.0.1', '200']}
>>> {pc:config_database[pc][1] for pc in config_database.keys()}
{'PC2': '192.168.0.2', 'PC3': '192.168.0.3', 'PC1': '192.168.0.1'}
Or even simpler
>>> {pc:config_database[pc][1] for pc in config_database}
{'PC2': '192.168.0.2', 'PC3': '192.168.0.3', 'PC1': '192.168.0.1'}
--
https://mail.python.org/mailman/listinfo/python-list