Newsgroups: comp.lang.python
From: Dave Angel <d...@davea.name>
Date: Wed, 19 Sep 2012 14:22:39 -0400
Local: Wed, Sep 19 2012 2:22 pm
Subject: Re: using text file to get ip address from hostname
On 09/19/2012 08:28 AM, Dan Katorza wrote:
> בתאריך יום רביעי, 19 בספטמבר 2012 12:11:04 UTC+3, מאת Dan Katorza:
Not at all like Chris advised. But it also doesn't help you understand
>> <SNIP> >> hi, ll like >> found a solution, >> it's not quite like Chris advised but it works. programming. Two concepts you're going to have to get a lot more comfortable with, in Python, or in some other language. One is loops, and the other is functions. >> #!/usr/bin/env python
This is one enormous top-level code, and when you needed to enclose it
>> #Get the IP Address >> import sys, socket, os
>> def restart_program():
>> print ("\n\n#########################################################")
>> mchoice = int(raw_input("Please enter your choice> "))
>> while mchoice == 2:
>> try:
>> print("\nFile {0} exists!".format(filename))
>> waction=raw_input("Please choose your action > ")
>> while waction !='A' and waction !='M' and waction !='E':
>> mchoice = int(raw_input("Please enter your choice> "))
>> while mchoice == 1:
>> waction=raw_input("Please choose your action > ")
>> while waction !='A' and waction !='M' and waction !='E':
in a loop, your answer is to start a new process! You also duplicate quite a few lines, rather than making a function for them, and calling it from two places. -- DaveA
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||