Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64792
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Lists inside dictionary and how to look for particular value |
| Date | 2014-01-26 20:25 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <lc3qv2$gdf$3@dont-email.me> (permalink) |
| References | <4ef4e919-2db6-4ded-9894-fd3872c3d17c@googlegroups.com> |
On Sun, 26 Jan 2014 10:47:11 -0800, mick verdu wrote:
> z={ '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'] }
>
> My solution:
>
> z=raw_input("Enter Host, Mac, ip and time")
> t=z.split()
> t[0]=z[1:]
> for key in dic:
> if t[2] in dic[key]:
> del dic[t[0]]
> else:
> dic[t[0]] = t[1:]
>
>
> What I really want to achieve is:
>
>
> How to search for a particular value inside list. First, I want the user
> to input hostname and ip. e.g. PC1 and 192.168.0.1, then need to find
> out if 192.168.0.1 has already been assigned to some host in dictionary.
> In this case I would need to skip for search inside list of user input
> host.
>
> Forexample, if user inputs PC1 and 192.168.0.1 i would like to skip
> searching in above PC1's values. So it should detect matching only with
> different hosts and skip its own name.
>
> If i input PC4 and 192.168.0.1 then it should detect conflict with PC1.
> So PC4 would be deleted(As soon as user inputs new host it is saved in
> above database then if conflict with others deleted)
Can we step back a few stages.
What are you writing this software for? The network management at the
level you're trying to observe happens for the most part automatically at
the ip stack / network hardware level.
Do you think this database of which ip maps to which MAC is actually
going to have some human use? If so, what?
Or is this some sort of homework exercise as part of a programming course?
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Lists inside dictionary and how to look for particular value mick verdu <mickverdu@gmail.com> - 2014-01-26 10:47 -0800
Re: Lists inside dictionary and how to look for particular value Peter Otten <__peter__@web.de> - 2014-01-26 20:44 +0100
Re: Lists inside dictionary and how to look for particular value Tim Chase <python.list@tim.thechases.com> - 2014-01-26 14:00 -0600
Re: Lists inside dictionary and how to look for particular value mick verdu <mickverdu@gmail.com> - 2014-01-26 12:20 -0800
Re: Lists inside dictionary and how to look for particular value Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-27 12:08 +1300
Re: Lists inside dictionary and how to look for particular value Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-26 20:25 +0000
Re: Lists inside dictionary and how to look for particular value mick verdu <mickverdu@gmail.com> - 2014-01-26 12:28 -0800
Re: Lists inside dictionary and how to look for particular value mm0fmf <none@mailinator.com> - 2014-01-26 21:20 +0000
Re: Lists inside dictionary and how to look for particular value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-26 21:36 -0500
Re: Lists inside dictionary and how to look for particular value mick verdu <mickverdu@gmail.com> - 2014-01-26 15:54 -0800
Re: Lists inside dictionary and how to look for particular value Peter Otten <__peter__@web.de> - 2014-01-27 09:54 +0100
csiph-web