Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64262 > unrolled thread

Can post a code but afraid of plagiarism

Started byindar kumar <indarkumar59@gmail.com>
First post2014-01-18 14:21 -0800
Last post2014-01-24 19:42 -0500
Articles 20 on this page of 62 — 21 participants

Back to article view | Back to comp.lang.python


Contents

  Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-18 14:21 -0800
    Re: Can post a code but afraid of plagiarism Roy Smith <roy@panix.com> - 2014-01-18 17:27 -0500
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-18 14:32 -0800
      Re: Can post a code but afraid of plagiarism Roy Smith <roy@panix.com> - 2014-01-18 17:35 -0500
      Re: Can post a code but afraid of plagiarism Chris Angelico <rosuav@gmail.com> - 2014-01-19 09:42 +1100
      Re: Can post a code but afraid of plagiarism Ben Finney <ben+python@benfinney.id.au> - 2014-01-19 09:59 +1100
      Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-19 06:31 +0000
        Re: Can post a code but afraid of plagiarism Devin Jeanpierre <jeanpierreda@gmail.com> - 2014-01-18 22:45 -0800
        Re: Can post a code but afraid of plagiarism Dan Stromberg <drsalists@gmail.com> - 2014-01-19 21:21 -0800
        Re: Can post a code but afraid of plagiarism Chris Angelico <rosuav@gmail.com> - 2014-01-20 17:21 +1100
          Re: Can post a code but afraid of plagiarism Roy Smith <roy@panix.com> - 2014-01-20 09:08 -0500
            Re: Can post a code but afraid of plagiarism Rustom Mody <rustompmody@gmail.com> - 2014-01-20 08:11 -0800
            Re: Can post a code but afraid of plagiarism Terry Reedy <tjreedy@udel.edu> - 2014-01-20 16:56 -0500
            Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-21 00:47 +0000
              Re: Can post a code but afraid of plagiarism Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2014-01-21 10:32 +0000
                Re: Can post a code but afraid of plagiarism Dan Sommers <dan@tombstonezero.net> - 2014-01-21 13:49 +0000
        Re: Can post a code but afraid of plagiarism Ben Finney <ben+python@benfinney.id.au> - 2014-01-20 18:39 +1100
          Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-19 23:55 -0800
            Re: Can post a code but afraid of plagiarism Ben Finney <ben+python@benfinney.id.au> - 2014-01-20 19:17 +1100
              Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-22 00:51 +0000
                Re: Can post a code but afraid of plagiarism Rustom Mody <rustompmody@gmail.com> - 2014-01-21 19:01 -0800
                  Re: Can post a code but afraid of plagiarism Roy Smith <roy@panix.com> - 2014-01-21 22:46 -0500
            Re: Can post a code but afraid of plagiarism Chris Angelico <rosuav@gmail.com> - 2014-01-20 19:48 +1100
            Re: Can post a code but afraid of plagiarism bryan rasmussen <rasmussen.bryan@gmail.com> - 2014-01-20 10:19 +0100
            Re: Can post a code but afraid of plagiarism Alister <alister.ware@ntlworld.com> - 2014-01-20 09:36 +0000
            Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-22 00:01 +0000
          Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-22 00:51 +0000
            Re: Can post a code but afraid of plagiarism Neil Cerutti <neilc@norwich.edu> - 2014-01-22 13:34 +0000
        Re: Can post a code but afraid of plagiarism Chris Angelico <rosuav@gmail.com> - 2014-01-20 18:59 +1100
        Re: Can post a code but afraid of plagiarism Ben Finney <ben+python@benfinney.id.au> - 2014-01-20 19:10 +1100
    Re: Can post a code but afraid of plagiarism Ben Finney <ben+python@benfinney.id.au> - 2014-01-19 09:57 +1100
    Re: Can post a code but afraid of plagiarism Grant Edwards <invalid@invalid.invalid> - 2014-01-19 16:22 +0000
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 00:36 -0800
      Re: Can post a code but afraid of plagiarism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-22 08:53 -0500
      Re: Can post a code but afraid of plagiarism Rustom Mody <rustompmody@gmail.com> - 2014-01-22 08:48 -0800
      Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-23 00:01 +0000
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 00:39 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 08:33 -0800
      Re: Can post a code but afraid of plagiarism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-22 22:36 -0500
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 08:46 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 08:50 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 08:53 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 09:09 -0800
      Re: Can post a code but afraid of plagiarism Ned Batchelder <ned@nedbatchelder.com> - 2014-01-22 14:19 -0500
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 23:46 -0800
      Re: Can post a code but afraid of plagiarism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-23 20:26 -0500
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-22 23:57 -0800
      Re: Can post a code but afraid of plagiarism Asaf Las <roegltd@gmail.com> - 2014-01-23 01:46 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 02:10 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 13:15 -0800
      Re: Can post a code but afraid of plagiarism Emile van Sebille <emile@fenx.com> - 2014-01-23 13:28 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 13:34 -0800
      Re: Can post a code but afraid of plagiarism Emile van Sebille <emile@fenx.com> - 2014-01-23 13:49 -0800
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 13:56 -0800
      Re: Can post a code but afraid of plagiarism Piet van Oostrum <piet@vanoostrum.org> - 2014-01-24 15:13 +0100
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 19:15 -0800
      Re: Can post a code but afraid of plagiarism Rustom Mody <rustompmody@gmail.com> - 2014-01-23 21:57 -0800
      Re: Can post a code but afraid of plagiarism Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-24 08:13 +0000
    Re: Can post a code but afraid of plagiarism indar kumar <indarkumar59@gmail.com> - 2014-01-23 23:14 -0800
      Re: Can post a code but afraid of plagiarism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-24 09:01 -0500
      Re: Can post a code but afraid of plagiarism bob gailer <bgailer@gmail.com> - 2014-01-24 18:42 -0500
      Re: Can post a code but afraid of plagiarism Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-24 19:42 -0500

Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →


#64513

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-22 08:50 -0800
Message-ID<825d1da9-87ad-4ec9-9144-ff4e09f5a823@googlegroups.com>
In reply to#64262
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

I need to implement this with simple dictionarie. I know use of dictionaries, lists and tuples. But, I am not able to create a logic in a loop. I mean how the other hosts would get MAC and IP of subsequent hosts in each turn. 

[toc] | [prev] | [next] | [standalone]


#64514

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-22 08:53 -0800
Message-ID<bcedde42-98b8-44db-ba8f-21a9052e6b7c@googlegroups.com>
In reply to#64262
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

Any link related to such type of problems or logic would be helpful

[toc] | [prev] | [next] | [standalone]


#64515

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-22 09:09 -0800
Message-ID<5e6ffc86-b008-4aa1-b176-006342ffee28@googlegroups.com>
In reply to#64262
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

Just one hint and I have made the design for whole code. Just stuck at this part

[toc] | [prev] | [next] | [standalone]


#64528

FromNed Batchelder <ned@nedbatchelder.com>
Date2014-01-22 14:19 -0500
Message-ID<mailman.5849.1390418406.18130.python-list@python.org>
In reply to#64515
On 1/22/14 12:09 PM, 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
>
> Just one hint and I have made the design for whole code. Just stuck at this part
>

You should collect all your thoughts and write one message, not six in 
30 minutes.  That's just pestering.

-- 
Ned Batchelder, http://nedbatchelder.com

[toc] | [prev] | [next] | [standalone]


#64580

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-22 23:46 -0800
Message-ID<4c3009ee-bf97-4d93-83e6-0bc4b2a90e82@googlegroups.com>
In reply to#64262
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 for kind help.

I have following nested dictionary

hosts={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}], 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}


How can I print a particular tuple from this table?


What I am trying to do is
input1=raw_input("Please enter id of host and IP that you want to be resolved")
z=input1.split()
print("PC3 resolved"+' '+z[1]+' to'+hosts[z[0]][3] z[1])

#z[1] is ip entered and [z[0]][3] z[1] is the particular location of value(MAC) associated with IP that I want to print.


But failed to do so. How can I print that. Please guide

[toc] | [prev] | [next] | [standalone]


#64652

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-01-23 20:26 -0500
Message-ID<mailman.5924.1390526775.18130.python-list@python.org>
In reply to#64580
On Wed, 22 Jan 2014 23:46:36 -0800 (PST), indar kumar
<indarkumar59@gmail.com> declaimed the following:


>I have following nested dictionary
>
>hosts={'PC2': ['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}], 'PC1': ['01:01:01:01:01:01', '192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}
>
>
>How can I print a particular tuple from this table?
>
>
>What I am trying to do is
>input1=raw_input("Please enter id of host and IP that you want to be resolved")
>z=input1.split()
>print("PC3 resolved"+' '+z[1]+' to'+hosts[z[0]][3] z[1])
>

	This would be a lot easier for you to figure out if you do it in steps:

First extract all the data for the user provided host (and use tuple
assignment to give useful names to the input fields).

host, ip = raw_input("...").split()
aHost = hosts[host]
cache = aHost[3]
ipMap = cache[ip]
MAC = ipMap[0]

(If you really want the all-in-one: MAC = hosts[host][3][ip][0]		)

	Note that there is no error checking in that -- if the input has a typo
and doesn't find an entry the program will die with an exception.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#64583

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-22 23:57 -0800
Message-ID<a0636290-10bd-40f2-bbe1-74d42c58408c@googlegroups.com>
In reply to#64262
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

I just need to print first element of tuple not the whole

[toc] | [prev] | [next] | [standalone]


#64590

FromAsaf Las <roegltd@gmail.com>
Date2014-01-23 01:46 -0800
Message-ID<ceedebc9-3117-4bb8-a213-f65f14b458d6@googlegroups.com>
In reply to#64583
On Thursday, January 23, 2014 9:57:02 AM UTC+2, indar kumar wrote:
> On Saturday, January 18, 2014 3:21:42 PM UTC-7, indar kumar wrote:
> I just need to print first element of tuple not the whole

in hierarchies do steps level by level, that will make things much easier:

hosts={'PC2':['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}], 
       'PC1':['01:01:01:01:01:01', '192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}

print(hosts['PC2'])
print(hosts['PC2'][3])
print(hosts['PC2'][3]['192.168.0.2'])
print(hosts['PC2'][3]['192.168.0.2'][1])

[toc] | [prev] | [next] | [standalone]


#64591

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 02:10 -0800
Message-ID<84183d3c-e1ff-4925-8f6a-03776a984741@googlegroups.com>
In reply to#64262
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

Thank You 

I have found this forum very helping...GOD BLESS YOU ALL

[toc] | [prev] | [next] | [standalone]


#64634

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 13:15 -0800
Message-ID<e83b1b9f-5922-469d-99b8-f9e21e3364f9@googlegroups.com>
In reply to#64262
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

hosts={'PC2':['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}],'PC1':['01:01:01:01:01:01', '192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]} 


Hi,
I want to print a value before a particular value inside of a list associated with a key inside main dictionary(hosts) not the one inside nested dictionary.

Forexample,
I want the user to input ip e.g. 192.168.0.2 and then search through dictionary print MAC e.g.02:02:02:02:02:02 that is just before that IP. Note that host id(e.g.PC2) is not known user just inputs IP. 

[toc] | [prev] | [next] | [standalone]


#64635

FromEmile van Sebille <emile@fenx.com>
Date2014-01-23 13:28 -0800
Message-ID<mailman.5910.1390512555.18130.python-list@python.org>
In reply to#64634
On 1/23/2014 1:15 PM, 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
>
> hosts={'PC2':['02:02:02:02:02:02', '192.168.0.2', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}],'PC1':['01:01:01:01:01:01', '192.168.0.1', '200', {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531), '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}
>
>
> Hi,
> I want to print a value before a particular value inside of a list associated with a key inside main dictionary(hosts) not the one inside nested dictionary.
>
> Forexample,
> I want the user to input ip e.g. 192.168.0.2 and then search through dictionary print MAC e.g.02:02:02:02:02:02 that is just before that IP. Note that host id(e.g.PC2) is not known user just inputs IP.
>

Like this?:

 >>> hosts={'PC2':['02:02:02:02:02:02', '192.168.0.2', '200',
...               {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531)}],
...        'PC1':['01:01:01:01:01:01', '192.168.0.1', '200',
...               {'192.168.0.2': ('02:02:02:02:02:02', 1390461798.531),
...                '192.168.0.1': ('01:01:01:01:01:01', 1390461787.78)}]}
 >>>
 >>> searchfor = '192.168.0.1'
 >>>
 >>> print [ ii[0] for ii in hosts.values() if ii[1] == searchfor ]
['01:01:01:01:01:01']

[toc] | [prev] | [next] | [standalone]


#64636

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 13:34 -0800
Message-ID<fb94cc37-4967-49cb-9fd1-7a8e9b497a76@googlegroups.com>
In reply to#64262
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

Just the value e.g.01:01:01:01:01:01 not the list 

[toc] | [prev] | [next] | [standalone]


#64637

FromEmile van Sebille <emile@fenx.com>
Date2014-01-23 13:49 -0800
Message-ID<mailman.5911.1390513795.18130.python-list@python.org>
In reply to#64636
On 1/23/2014 1:34 PM, 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
>
> Just the value e.g.01:01:01:01:01:01 not the list
>

It may be time for you to work your way through the tutorial.

Emile

[toc] | [prev] | [next] | [standalone]


#64638

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 13:56 -0800
Message-ID<3cdf480e-e527-4c76-b87a-b6a34c9195fb@googlegroups.com>
In reply to#64262
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

Can I do the following to just get the value as string not the type list?

searchfor = '192.168.0.2'
z=[ii[0] for ii in hosts.values() if ii[1] == searchfor]
>>> str1 = ''.join(z)
>>> str1

[toc] | [prev] | [next] | [standalone]


#64686

FromPiet van Oostrum <piet@vanoostrum.org>
Date2014-01-24 15:13 +0100
Message-ID<m2d2jhjwm5.fsf@cochabamba.vanoostrum.org>
In reply to#64638
indar kumar <indarkumar59@gmail.com> writes:

> 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
>
> Can I do the following to just get the value as string not the type list?
>
> searchfor = '192.168.0.2'
> z=[ii[0] for ii in hosts.values() if ii[1] == searchfor]
>>>> str1 = ''.join(z)
>>>> str1

If you want to extract an element of a list use indexing, like mylist[0]. 

If you don't know these things or can't find this out yourself, you have a serious lack of knowledge about Python, or maybe about programming, and it is time to learn that first.
-- 
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

[toc] | [prev] | [next] | [standalone]


#64660

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 19:15 -0800
Message-ID<62acd633-3b45-4c4f-9e1c-1df56a11d28d@googlegroups.com>
In reply to#64262
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.



[toc] | [prev] | [next] | [standalone]


#64662

FromRustom Mody <rustompmody@gmail.com>
Date2014-01-23 21:57 -0800
Message-ID<77341c7d-7416-45e4-a71c-78ced6d0b03f@googlegroups.com>
In reply to#64660
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'}

[toc] | [prev] | [next] | [standalone]


#64665

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2014-01-24 08:13 +0000
Message-ID<52e220b8$0$29999$c3e8da3$5496439d@news.astraweb.com>
In reply to#64660
On Thu, 23 Jan 2014 19:15:51 -0800, indar kumar wrote:

> 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.

Then go right ahead and do so. You are learning Python, so this should be 
covered in your course. Did you follow the advice to work through the 
Python tutorial?

http://docs.python.org/2/tutorial/
http://docs.python.org/3/tutorial/

depending on whether you are using Python 2 or 3.

This is supposed to be your work, not ours. Start by writing down how you 
would solve this problem as a human being:

for each key:
    if the key is the one the user inputted, skip this key
    otherwise:
        get all the lists for this key
        for each list:
            search for the value        


Now change that to Python code. Don't just ask us to solve the problem 
for you.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#64664

Fromindar kumar <indarkumar59@gmail.com>
Date2014-01-23 23:14 -0800
Message-ID<14e7775c-2a79-46eb-8f25-d9ac7fc1eb01@googlegroups.com>
In reply to#64262
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

Yes now I want to search for an ip that user has input but skipping the key which user has input. e.g. user entered PC1 and 192.168.0.1. Now I want to scan through config_database to see if this ip is already in it. But PC1 192.168.0.1 is added to config_database before searching so I want to skip PC1 key during searching so that I can see if this Ip is not already associated with any other host.

[toc] | [prev] | [next] | [standalone]


#64684

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2014-01-24 09:01 -0500
Message-ID<mailman.5942.1390572085.18130.python-list@python.org>
In reply to#64664
On Thu, 23 Jan 2014 23:14:13 -0800 (PST), indar kumar
<indarkumar59@gmail.com> declaimed the following:

>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
>

	You can stop repeating that caveat for one thing, and provide some
context of what/who you are replying to.

>Yes now I want to search for an ip that user has input but skipping the key which user has input. e.g. user entered PC1 and 192.168.0.1. Now I want to scan through config_database to see if this ip is already in it. But PC1 192.168.0.1 is added to config_database before searching so I want to skip PC1 key during searching so that I can see if this Ip is not already associated with any other host.

	And what is stopping you? You don't know how to process all the entries
in the main dictionary, or you don't know how to skip an entry when you
find it?

-=-=-=-=- (more non-Python)

/*	Aba-guernqrq rzhyngvba bs Argjbex NEC genssvp	*/

argjbex. = ""
argjbex.0 = 0	/* ahzore bs qrsvarq ubfgf	*/
qb sberire
	fnl " "
	fnl " "
	fnl "Ragre pbasvthengvba punatr va gur sbez:"
	fnl "	ubfganzr ZNP VC gvzrbhg"
	cnefr chyy ubfganzr ubfgZNP ubfgVC ubfgGvzrbhg

	vs ubfganzr = "" gura
	qb
		qb u = 1 gb argjbex.0
			fnl "Ubfg " argjbex.u.ubfg argjbex.u.znp argjbex.u.vc
argjbex.u.gvzrbhg
			fnl "Pnpur"
			qb n = 1 gb argjbex.u.pnpur.0
				fnl "      " argjbex.u.pnpur.n.znp argjbex.u.pnpur.n.vc
			raq
			fnl " "
		raq
		rkvg
	raq

	pnyy NECCebor ubfganzr ubfgZNP ubfgVC

	vs inyvq gura
	qb
		pnyy hcqngr ubfganzr ubfgZNP ubfgVC ubfgGvzrbhg
		pnyy NECNaabhapr ubfganzr ubfgZNP ubfgVC
	raq
	ryfr
	qb
		pnyy erzbir ubfganzr
	raq
raq
	
NECCebor:	cebprqher rkcbfr argjbex. inyvq
	cnefr net ua uz uv
	fnl " "
	fnl "NEC Cebor: " uz " ss:ss:ss:ss:ss:ss 0.0.0.0 " uv
	qb u = 1 gb argjbex.0
		vs argjbex.u.ubfg <> ua gura
			vs argjbex.u.vc = uv gura
			qb
				inyvq = 0
				erghea
			raq
	raq
	inyvq = 1
	erghea

hcqngr:  cebprqher rkcbfr argjbex.
	cnefr net ua uz uv ug
	qb u = 1 gb argjbex.0
		vs argjbex.u.ubfg = ua gura
		qb
			fnl "Ubfg " ua " hcqngrq"
			argjbex.u.znp = uz
			argjbex.u.vc = uv
			argjbex.u.gvzrbhg = ug
			erghea
		raq
	raq
		
	u = argjbex.0 + 1
	fnl "Ubfg " ua " nqqrq gb argjbex"
	argjbex.u.ubfg = ua
	argjbex.u.znp = uz
	argjbex.u.vc = uv
	argjbex.u.gvzrbhg = ug
	argjbex.u.pnpur. = ""
	argjbex.u.pnpur.0 = 0
	argjbex.0 = u
	erghea

NECNaabhapr: cebprqher rkcbfr argjbex.
	cnefr net ua uz uv
	fnl " "
	fnl "NEC Naabhapr " ua uz " 0:0:0:0:0:0 " uv uv
	qb u = 1 gb argjbex.0
		vs argjbex.u.ubfg <> ua gura
		qb
			arj = 1
			qb n = 1 gb argjbex.u.pnpur.0
				vs argjbex.u.pnpur.n.znp = uz be argjbex.u.pnpur.n.vc = uv
gura
				qb
					fnl "Ubfg " argjbex.u.ubfg " hcqngrq " uz uv
					argjbex.u.pnpur.n.znp = uz
					argjbex.u.pnpur.n.vc = uv
					arj = 0
				raq
			raq
			vs arj gura
			qb
				n = argjbex.u.pnpur.0 + 1
				fnl "Ubfg " argjbex.u.ubfg " nqqrq " uz uv
				argjbex.u.pnpur.n.znp = uz
				argjbex.u.pnpur.n.vc = uv
				argjbex.u.pnpur.0 = n
			raq
		raq
	raq
	erghea
			
erzbir: cebprqher rkcbfr argjbex.
	cnefr net ua
	fnl "Ubfg " ua " erzbirq sebz argjbex"
	uy = 0
	qb u = 1 gb argjbex.0
		vs argjbex.u.ubfg = ua gura
			uy = u
	raq
	vs uy <> 0 gura
	qb
		qb ub = (uy + 1) gb argjbex.0
			uq = ub - 1
			argjbex.uq. = argjbex.ub.
		raq
		ur = argjbex.0
		argjbex.ur. = ""
		argjbex.0 = ur - 1
	raq
	erghea
-=-=-=-=-

	Does not have an independent look-up command but does have to do
look-ups to handle updates and errors.

C:\Users\Wulfraed\Documents>arp.rx


Enter configuration change in the form:
        hostname MAC IP timeout
me 2:1:3:4:6:5 192.168.0.1 50

ARP Probe:  2:1:3:4:6:5  ff:ff:ff:ff:ff:ff 0.0.0.0  192.168.0.1
Host  me  added to network

ARP Announce  me 2:1:3:4:6:5  0:0:0:0:0:0  192.168.0.1 192.168.0.1


Enter configuration change in the form:
        hostname MAC IP timeout
you 1:2:3:4:5:6 192.168.10.10 50

ARP Probe:  1:2:3:4:5:6  ff:ff:ff:ff:ff:ff 0.0.0.0  192.168.10.10
Host  you  added to network

ARP Announce  you 1:2:3:4:5:6  0:0:0:0:0:0  192.168.10.10 192.168.10.10
Host  me  added  1:2:3:4:5:6 192.168.10.10


Enter configuration change in the form:
        hostname MAC IP timeout
them 6:5:4:3:2:1 10.10.0.10 100

ARP Probe:  6:5:4:3:2:1  ff:ff:ff:ff:ff:ff 0.0.0.0  10.10.0.10
Host  them  added to network

ARP Announce  them 6:5:4:3:2:1  0:0:0:0:0:0  10.10.0.10 10.10.0.10
Host  me  added  6:5:4:3:2:1 10.10.0.10
Host  you  added  6:5:4:3:2:1 10.10.0.10


Enter configuration change in the form:
        hostname MAC IP timeout
false a:b:c:d:e:f 192.168.0.1 10

ARP Probe:  a:b:c:d:e:f  ff:ff:ff:ff:ff:ff 0.0.0.0  192.168.0.1
Host  false  removed from network


Enter configuration change in the form:
        hostname MAC IP timeout
me a:b:c:d:e:f 192.168.0.1 10

ARP Probe:  a:b:c:d:e:f  ff:ff:ff:ff:ff:ff 0.0.0.0  192.168.0.1
Host  me  updated

ARP Announce  me a:b:c:d:e:f  0:0:0:0:0:0  192.168.0.1 192.168.0.1
Host  you  added  a:b:c:d:e:f 192.168.0.1
Host  them  added  a:b:c:d:e:f 192.168.0.1


Enter configuration change in the form:
        hostname MAC IP timeout

Host  me a:b:c:d:e:f 192.168.0.1 10
Cache
       1:2:3:4:5:6 192.168.10.10
       6:5:4:3:2:1 10.10.0.10

Host  you 1:2:3:4:5:6 192.168.10.10 50
Cache
       6:5:4:3:2:1 10.10.0.10
       a:b:c:d:e:f 192.168.0.1

Host  them 6:5:4:3:2:1 10.10.0.10 100
Cache
       a:b:c:d:e:f 192.168.0.1


Press ENTER key to exit...
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


Page 3 of 4 — ← Prev page 1 2 [3] 4  Next page →

Back to top | Article view | comp.lang.python


csiph-web