Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-20 Thread Liam Clarke
Hi, just an expansion on Brian's query, is there a variant of getattr for instance methods? i.e. class DBRequest: def __init__(self, fields, action): self.get(fields) def get(self, fields): print fields Instead of self.get in _init__, the value of action to call a

[Tutor] Create list of IPs

2005-02-20 Thread Ralfas Jegorovas
I am wondering how I would go about making a list of IPs between two set IPs. This is my initial code: def list2str(list): ip='' for part in list: if len(ip)!=0: ip=ip+'.'+part else: ip=ip+part return ip iplist = [] minip = ['1','0','0','1'] # startin

Re: [Tutor] Create list of IPs

2005-02-20 Thread Liam Clarke
Oops, also change this line for b in range(minip[3], 255): to for b in change(minip[3], 256): On Sun, 20 Feb 2005 23:43:07 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote: > Erp. > > > -- Forwarded message -- > From: Liam Clarke <[EMAIL PROTECTED]> > Date: Sun, 20 Feb 2005 23:4

Fwd: [Tutor] Create list of IPs

2005-02-20 Thread Liam Clarke
Erp. -- Forwarded message -- From: Liam Clarke <[EMAIL PROTECTED]> Date: Sun, 20 Feb 2005 23:42:43 +1300 Subject: Re: [Tutor] Create list of IPs To: Ralfas Jegorovas <[EMAIL PROTECTED]> Hi, you could save yourself some hassle and do >>> minipstr = '1.0.0.1' >>> maxipstr = '1.0.

Re: [Tutor] Instance into another instance

2005-02-20 Thread Kent Johnson
Ismael Garrido wrote: The idea of the class is to be able to create a "tree". Where each node can have subnodes, which in turn can have their subnodes... Are you creating a tree to represent XML data? There are many packages available that do this. You might want to look at ElementTree which is o

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-20 Thread Kent Johnson
Liam Clarke wrote: Hi, just an expansion on Brian's query, is there a variant of getattr for instance methods? i.e. class DBRequest: def __init__(self, fields, action): self.get(fields) def get(self, fields): print fields Instead of self.get in _init__, the value of

Re: Fwd: [Tutor] Create list of IPs

2005-02-20 Thread Kent Johnson
Liam Clarke wrote: Hi, you could save yourself some hassle and do minipstr = '1.0.0.1' maxipstr = '1.0.15.16' minip = map(int, minipstr.split('.')) maxip = map(int, maxipstr.split('.')) iplist = [] for a in range(minip[2], maxip[2]+1): ... if a < maxip[2]: ... for b in range(minip[

[Tutor] help with .get in Tkinter

2005-02-20 Thread Mark Kels
Hi all. First, here is the code I have a problem with (I got same problem in my project) : from Tkinter import * def go(): e.get() print e main=Tk() e=Entry(main) e.pack() b=Button(main,text='OK',command=go()).pack() main.mainloop() For some reason the function is called before I click th

Re: Fwd: [Tutor] Create list of IPs

2005-02-20 Thread lumbricus
> Liam Clarke wrote: [ snip ] > - increment an IP. This is the hardest part. Why? An ip (V4) is just an 32bit integer :-) The problem arises from the representation. Use something like "http://pynms.sourceforge.net/ipv4.html"; to switch between the various representations. > Kent HTH and Gree

[Tutor] Re: Create list of IPs

2005-02-20 Thread Roel Schroeven
Ralfas Jegorovas wrote: > I am wondering how I would go about making a list of IPs between two set > IPs. # First, list2str can be written shorter .def list2str(lst): .return '.'.join(map(str, lst)) # The inverse of that is also needed .def str2list(s): .return map(int, s.split('.')) # N

[Tutor] Time Controlled Execution

2005-02-20 Thread Varun Soundararajan
Hi, I want to know how to do this: I have an executable file, which reads input from stdin provided output at stdout or stderr. I have to run it for a specific period of time (say 5 secs), get the output and display it. If i use popen(), this way: from subprocess import * p = Popen(["test","test.ou

Re: [Tutor] help with .get in Tkinter

2005-02-20 Thread Michael Lange
On Sun, 20 Feb 2005 17:12:54 +0200 Mark Kels <[EMAIL PROTECTED]> wrote: > Hi all. > First, here is the code I have a problem with (I got same problem in > my project) : > from Tkinter import * > def go(): > e.get() > print e > > main=Tk() > e=Entry(main) > e.pack() > b=Button(main,text='O

Re: Fwd: [Tutor] Create list of IPs

2005-02-20 Thread R. Alan Monroe
>> Liam Clarke wrote: > [ snip ] >> - increment an IP. This is the hardest part. > Why? An ip (V4) is just an 32bit integer :-) Indeed. Some early versions of MacTCP for MacOS made you input the address as a single large decimal number :^) Alan ___

Re: Fwd: [Tutor] Create list of IPs

2005-02-20 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Liam Clarke wrote: [ snip ] - increment an IP. This is the hardest part. Why? An ip (V4) is just an 32bit integer :-) The problem arises from the representation. Use something like "http://pynms.sourceforge.net/ipv4.html"; to switch between the various representations.

Re: [Tutor] Instance into another instance

2005-02-20 Thread Kent Johnson
Ismael Garrido wrote: Kent Johnson wrote: Are you creating a tree to represent XML data? There are many packages available that do this. You might want to look at ElementTree which is one of the easiest to use. In fact, even if you aren't trying to represent XML you might find ElementTree useful

Re: [Tutor] help with .get in Tkinter

2005-02-20 Thread Alan Gauld
Mark, There are two problems here: > from Tkinter import * > def go():... > e=Entry(main) > e.pack() This is OK but... > b=Button(main,text='OK',command=go()).pack() Problem 1: This will store None in b because pack() always returns None. Problem 2: > For some reason the function is called b

[Tutor] Re: Fwd: Create list of IPs

2005-02-20 Thread Roel Schroeven
R. Alan Monroe wrote: >>>Liam Clarke wrote: > > >>[ snip ] > > >>>- increment an IP. This is the hardest part. > > >>Why? An ip (V4) is just an 32bit integer :-) > > > Indeed. Some early versions of MacTCP for MacOS made you input the > address as a single large decimal number :^) And you

Re: [Tutor] Attaching an uploaded file to an email

2005-02-20 Thread Martin Walsh
Tim Wilson wrote: Hi everyone, Hi Tim, I'm a newb, first time posting, so please take any of the following advice at face value # Collect form information form = cgi.FieldStorage() requestername = form["requestername"].value fromaddr = form["email"].value itemname = form["itemname"].value

[Tutor] Re: Create list of IPs

2005-02-20 Thread Ralfas Jegorovas
Thanks alot to everyone for your help! I'm not completely sure I understand how Roel's code works so I'll be doing a bit of research :-) (but it works :-D). Thanks again. All the best, Ralf ___ Tutor maillist - Tutor@python.org http://mail.python.org/

Re: [Tutor] dictionary dispatch for object instance attributes question

2005-02-20 Thread Liam Clarke
Ah, see, I should convince my bosses that I need a Python interpreter. Of course, then they'd ask what Python was, and why I was thinking about it at work Duh, I was just reading the docs, and I kept thinking that an attribute was just a class variable. Thanks, Kent, now I have all sorts of i

Re: [Tutor] Attaching an uploaded file to an email

2005-02-20 Thread Liam Clarke
Yeah, you really have to see a few examples to get the hang of creating MIME emails, this is one area where I think the Python docs, quite frankly, stink. I had enough trouble getting attachments from a MIME email, let alone adding one. (But, if I recall correctly, a MIME email has a distinct stru

[Tutor] Re: Create list of IPs

2005-02-20 Thread Greg T
> I am wondering how I would go about making a list of > IPs between two set > IPs. > This is my initial code: > > > > def list2str(list): > ip='' > for part in list: > if len(ip)!=0: > ip=ip+'.'+part > else: > ip=ip+part > return ip > > ip