Re: [Tutor] Python Fails to Change Directory

2012-04-14 Thread Steven D'Aprano
Andrew Jahn wrote: Hi all, I am attempting to use a Python program to change into a specified directory before executing some commands. However, when I call the Python program from my Unix shell (tcsh) using a command such as "python myprogram.py" It runs without changing directory. Just to cl

[Tutor] Python Fails to Change Directory

2012-04-14 Thread Andrew Jahn
Hi all, I am attempting to use a Python program to change into a specified directory before executing some commands. However, when I call the Python program from my Unix shell (tcsh) using a command such as "python myprogram.py" It runs without changing directory. Just to clarify, the lines of c

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Steven D'Aprano
Bod Soutar wrote: How about something like this mylist = ['serverA', 'serverB', 'serverC', 'serverD','serverE', 'serverF', 'serverG'] tempstr = "" count = 0 for item in mylist: count += 1 if count == 3: tempstr += (i + "\n") count = 0 else: tempstr += (i +

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Dave Angel
On 04/14/2012 01:55 PM, Tom Tucker wrote: > All, > Thanks for the help. Please try to post your messages AFTER the part you're quoting. Another very useful feature is enumerate(). Instead of doing for item in mylist: count += 1 if count... do something like: for index, item in enum

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
All, Thanks for the help. On Sat, Apr 14, 2012 at 1:33 PM, Bod Soutar wrote: > > > On 14 April 2012 18:29, Bod Soutar wrote: > >> >> >> On 14 April 2012 16:27, Tom Tucker wrote: >> >>> >>> Hello all. Any suggestions how I could easily iterate over a list and >>> print the output 3 across (whe

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Bod Soutar
On 14 April 2012 18:29, Bod Soutar wrote: > > > On 14 April 2012 16:27, Tom Tucker wrote: > >> >> Hello all. Any suggestions how I could easily iterate over a list and >> print the output 3 across (when possible)? One method I was considering >> was removing the recently printed item from the

Re: [Tutor] Questions Regarding Sockets

2012-04-14 Thread Alan Gauld
On 14/04/12 17:41, Khalid Al-Ghamdi wrote: 1- In line (15), what are these variables tcpCliSock,addr supposed to hold and do? The socket object and the IP address of the client that is connecting to the server. When a client connects to a server the server assigns a new temporary socket conn

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Bod Soutar
On 14 April 2012 16:27, Tom Tucker wrote: > > Hello all. Any suggestions how I could easily iterate over a list and > print the output 3 across (when possible)? One method I was considering > was removing the recently printed item from the list, checking list length, > etc. Based on the remain

Re: [Tutor] Questions Regarding Sockets

2012-04-14 Thread Bod Soutar
On 14 April 2012 17:41, Khalid Al-Ghamdi wrote: > Hi All, > > (python 3.2 on windows) > > I have a couple of questions regarding the below code: > > 1- In line (15), what are these variables tcpCliSock, addr supposed to > hold and do? > 2- Why do I have to specify the buffer size and what does it

Re: [Tutor] Iterate Suggestion

2012-04-14 Thread Alan Gauld
On 14/04/12 16:27, Tom Tucker wrote: Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? Using the step size argument to range: L = range(12) >>> for n in range(0,len(L),3): ...print L[n],L[n+1],L[n+2] ... 0 1 2 3 4 5 6 7 8 9

[Tutor] Questions Regarding Sockets

2012-04-14 Thread Khalid Al-Ghamdi
Hi All, (python 3.2 on windows) I have a couple of questions regarding the below code: 1- In line (15), what are these variables tcpCliSock, addr supposed to hold and do? 2- Why do I have to specify the buffer size and what does it mean? 3- When I try to run the below code and its corresponding

[Tutor] Problem with mechanize and forms

2012-04-14 Thread Karim Gorjux
Hi all, I have a problem with mechanize and I can't get out from it. I have this code: br = mechanize.Browser() br.open('http://.example.com/formpage.html') forms = br.forms() for i in forms: print type(i) I get all the forms on the page. But I can't get any of these forms! I ne

[Tutor] Iterate Suggestion

2012-04-14 Thread Tom Tucker
Hello all. Any suggestions how I could easily iterate over a list and print the output 3 across (when possible)? One method I was considering was removing the recently printed item from the list, checking list length, etc. Based on the remaining length of the list I would then print X across. Ya