On Mar 5, 10:19 am, "sjdevn...@yahoo.com" wrote:
> On Mar 5, 10:53 am, Pete Emerson wrote:
>
>
>
>
>
> > Thanks for your response, further questions inline.
>
> > On Mar 4, 11:07 am, Tim Wintle wrote:
>
> > > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > > I am looking for advice
On Mar 5, 10:53 am, Pete Emerson wrote:
> Thanks for your response, further questions inline.
>
> On Mar 4, 11:07 am, Tim Wintle wrote:
>
> > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > I am looking for advice along the lines of "an easier way to do this"
> > > or "a more python
On Fri, 2010-03-05 at 07:53 -0800, Pete Emerson wrote:
> Thanks for your response, further questions inline.
>
> On Mar 4, 11:07 am, Tim Wintle wrote:
> > On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > > I am looking for advice along the lines of "an easier way to do this"
> > > or "a
On Mar 5, 7:00 am, Duncan Booth wrote:
> Jean-Michel Pichavant wrote:
> > And tell me how not using regexp will ensure the /etc/hosts processing
> > is correct ? The non regexp solutions provided in this thread did not
> > handled what you rightfully pointed out about host list and commented
> >
Thanks for your response, further questions inline.
On Mar 4, 11:07 am, Tim Wintle wrote:
> On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> > I am looking for advice along the lines of "an easier way to do this"
> > or "a more python way" (I'm sure that's asking for trouble!) or
> > "peo
Jean-Michel Pichavant wrote:
> And tell me how not using regexp will ensure the /etc/hosts processing
> is correct ? The non regexp solutions provided in this thread did not
> handled what you rightfully pointed out about host list and commented
> lines.
It won't make is automatically correct,
Duncan Booth wrote:
Jean-Michel Pichavant wrote:
You've already been given good advices.
Unlike some of those, I don't think using regexp an issue in any way.
Yes they are not readable, for sure, I 100% agree to that statement, but
you can make them readable very easily.
# not readable
Jean-Michel Pichavant wrote:
> You've already been given good advices.
> Unlike some of those, I don't think using regexp an issue in any way.
> Yes they are not readable, for sure, I 100% agree to that statement, but
> you can make them readable very easily.
>
> # not readable
> match = re.se
Pete Emerson wrote:
I've written my first python program, and would love suggestions for
improvement.
I'm a perl programmer and used a perl version of this program to guide
me. So in that sense, the python is "perlesque"
This script parses /etc/hosts for hostnames, and based on terms given
on t
On Thu, 2010-03-04 at 10:39 -0800, Pete Emerson wrote:
> I am looking for advice along the lines of "an easier way to do this"
> or "a more python way" (I'm sure that's asking for trouble!) or
> "people commonly do this instead" or "here's a slick trick" or "oh,
> interesting, here's my version to
Great responses, thank you all very much. I read Jonathan Gardner's
solution first and investigated sets. It's clearly superior to my
first cut.
I love the comment about regular expressions. In perl, I've reached
for regexes WAY too much. That's a big lesson learned too, and from my
point of view
On Mar 4, 1:39 pm, Pete Emerson wrote:
> I've written my first python program, and would love suggestions for
> improvement.
>
> I'm a perl programmer and used a perl version of this program to guide
> me. So in that sense, the python is "perlesque"
>
> This script parses /etc/hosts for hostnames,
On Thu, Mar 4, 2010 at 10:39 AM, Pete Emerson wrote:
>
> #!/usr/bin/python
>
More common:
#!/usr/bin/env python
> import sys, fileinput, re, os
>
> filename = '/etc/hosts'
>
> hosts = []
>
> for line in open(filename, 'r'):
> match = re.search('\d+\.\d+\.\d+\.\d+\s+(\S+)', line)
>
On Mar 4, 2:30 pm, MRAB wrote:
> Pete Emerson wrote:
> > I've written my first python program, and would love suggestions for
> > improvement.
>
> > I'm a perl programmer and used a perl version of this program to guide
> > me. So in that sense, the python is "perlesque"
>
> > This script parses /
Pete Emerson wrote:
I've written my first python program, and would love suggestions for
improvement.
I'm a perl programmer and used a perl version of this program to guide
me. So in that sense, the python is "perlesque"
This script parses /etc/hosts for hostnames, and based on terms given
on t
I've written my first python program, and would love suggestions for
improvement.
I'm a perl programmer and used a perl version of this program to guide
me. So in that sense, the python is "perlesque"
This script parses /etc/hosts for hostnames, and based on terms given
on the command line (argv)
On May 10, 6:56 pm, Steven D'Aprano wrote:
> > 4. What's the python way to emit warnings? (The script below should
> > warn the user that arguments after the first one are ignored.)
>
> import warnings
> warnings.warn("The end of the world is coming!")
The warnings module is used for warnings
On May 11, 12:30 pm, Nick Craig-Wood wrote:
> def __init__(self):
> usage = '''Usage: %prog [options] YYMMDD
> %prog -h|--help
> '''
> parser = OptionParser(usage=usage)
> parser.add_option("-n", "--no-newline", dest="nonl",
> action
kj wrote:
>
> Below is my very firs python script.
>
> This was just a learning exercise; the script doesn't do anything
> terribly exciting: for an argument of the form YYMMDD (year, month,
> day) it prints out the corresponding string YYMMDDW, where W is a
> one-letter abbreviation for th
Thank you all very much! I really appreciate it.
kynn
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
--
http://mail.python.org/mailman/listinfo/python-list
In <0216ec41$0$20647$c3e8...@news.astraweb.com> Steven D'Aprano
writes:
>On Sun, 10 May 2009 12:52:21 +, kj wrote:
>> 1. The name of the BadArgument exception class defined in the script
>>does not seem to me sufficiently specific. If one were to import the
>>script in order to reu
kj wrote:
Below is my very firs python script.
This was just a learning exercise; the script doesn't do anything
terribly exciting: for an argument of the form YYMMDD (year, month,
day) it prints out the corresponding string YYMMDDW, where W is a
one-letter abbreviation for the day of the week
Andre Engels wrote:
On Sun, May 10, 2009 at 5:56 PM, Steven D'Aprano
wrote:
5. The variable wd is meant to be "global" to the script. In other
languages I've programmed in I've seen some typographic convention
used for the name of such variables (e.g. all caps) to signal this
widened
Steven D'Aprano wrote:
On Sun, 10 May 2009 12:52:21 +, kj wrote:
5. The variable wd is meant to be "global" to the script. In other
languages I've programmed in I've seen some typographic convention
used for the name of such variables (e.g. all caps) to signal this
widened sco
On Sun, May 10, 2009 at 5:56 PM, Steven D'Aprano
wrote:
>> 5. The variable wd is meant to be "global" to the script. In other
>> languages I've programmed in I've seen some typographic convention
>> used for the name of such variables (e.g. all caps) to signal this
>> widened scope. Do
On Sun, 10 May 2009 12:52:21 +, kj wrote:
> 1. The name of the BadArgument exception class defined in the script
>does not seem to me sufficiently specific. If one were to import the
>script in order to reuse its wkday_abbrev function, I'd like this
>exception's name to be more un
Below is my very firs python script.
This was just a learning exercise; the script doesn't do anything
terribly exciting: for an argument of the form YYMMDD (year, month,
day) it prints out the corresponding string YYMMDDW, where W is a
one-letter abbreviation for the day of the week. E.g.
% wd
Lex Hider wrote:
> try:
> opts, args = getopt.getopt(sys.argv[1:], "l:",
> ["latest=", "notfound"])
> except getopt.GetoptError:
> sys.exit(2)
> #usage()
>
> for opt, arg in opts:
> if opt in (
Lex Hider wrote:
> Any tips on the code quality and use of python would be appreciated. I've
> got a feeling the overall structure is up the creek.
[...]
>for opt, arg in opts:
>if opt in ("-l", "--latest"):
>latest = int(arg)
>elif opt in ("--notfound"):
>
Le vendredi 08 septembre 2006 13:56, Maric Michaud a écrit :
> [EMAIL PROTECTED] jeu sep 07 09:17:51:~/test$ export HOME=/etc
> [EMAIL PROTECTED] ven sep 08 13:53:17:/home/maric/test$ cd ~
> [EMAIL PROTECTED] ven sep 08 13:53:22:~$ pwd
> /etc
> [EMAIL PROTECTED] ven sep 08 13:55:46:~$ python -c 'im
Le vendredi 08 septembre 2006 13:41, Sybren Stuvel a écrit :
> > HOME = os.path.expanduser("~")
>
> I wouldn't use this. Just use os.environ['HOME']. In most cases it
> turns out to be the same directory, but it adds more flexibility. If
> someone wants your app to read/write to another directory,
Lex Hider enlightened us with:
> Any tips on the code quality and use of python would be appreciated.
> I've got a feeling the overall structure is up the creek.
I'll post some remarks about the code ;-)
> HOME = os.path.expanduser("~")
I wouldn't use this. Just use os.environ['HOME']. In most c
Lex Hider wrote:
> Hi,
> Apologies if this is against etiquette. I've just got my first python app up
> and running. It is a podcast aggregator depending on feedparser. I've really
> only learnt enough to get this up and running.
>
> Any tips on the code quality and use of python would be apprec
Hi,
Apologies if this is against etiquette. I've just got my first python app up
and running. It is a podcast aggregator depending on feedparser. I've really
only learnt enough to get this up and running.
Any tips on the code quality and use of python would be appreciated. I've got
a feeling th
Someone else actually got me some help, the end result he hooked me up with was:
# function to evaluate all possible IPs
def findIPs():
ipFile = open("IPList.txt", 'w')
for octet1 in range(256):
for octet2 in range(256):
for octet3 in range(256):
for octet4 in range(256):
ipAddress = '%03.d.%03.
* Ed Hotchkiss <[EMAIL PROTECTED]> [2005-09-15 20:36]:
> But then I still get the error with the len(x) statement .. hmm
Ahh. In the future, it will help us help you, if you make it clear that
there was an error, and *paste the exact error* into your mail.
For example, I'm guessing the error you
Sweet, time to play with python for a whole day today :P
On 9/16/05, Gary Wilson Jr <[EMAIL PROTECTED]> wrote:
Ed Hotchkiss wrote:> def ZeroThrough255():> x = 0> while x <= 255:
> if len(x) == 1:> mySet = '00' + str(x)> elif len(x) ==
Ed Hotchkiss wrote:
> def ZeroThrough255():
> x = 0
> while x <= 255:
> if len(x) == 1:
> mySet = '00' + str(x)
> elif len(x) == 2:
> mySet = '0' + str(x)
> else:
> mySet = x
>
Ed Hotchkiss wrote:
> But then I still get the error with the len(x) statement .. hmm
That's because integers don't have a length. But if you follow James'
advice, you don't need to calculate lengths of anything.
--
Robert Kern
[EMAIL PROTECTED]
"In the fields of hell where the grass grows high
But then I still get the error with the len(x) statement .. hmm
On 9/15/05, James Stroud <[EMAIL PROTECTED]> wrote:
Try the % operator with strings.For instance: "%03.d" % 5py> "%03.d" % 5
'005'This operator, from what I have experienced, has the same properties as theunix printf. In python, I
Try the % operator with strings.
For instance: "%03.d" % 5
py> "%03.d" % 5
'005'
This operator, from what I have experienced, has the same properties as the
unix printf. In python, I think its called "string formatting".
James
On Thursday 15 September 2005 20:33, Ed Hotchkiss wrote:
> So I ha
So I have a script, first part of a script that I am making to determine each possible combination of IP addresses that are out there.
This part is just to get the end of the IP (the last 3 digits). So, they are from 0 - 255. I just want to print 0 - 255, HOWEVER
If the number is only say ...
42 matches
Mail list logo