Re: [Tutor] Remove a number from a string

2005-08-24 Thread Alan G
>> s = ' '.join(s.split()[1:]) > > or just > s = s.split(None, 1)[1] Neat, I hadn't noticed the maxsplit parameter before. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] IndexError and appending to lists [Was: Re: Need Helpon Assignment]

2005-08-24 Thread Alan G
Hi Tom, Glad you got it working with Danny's help. I'll throw in some style points too. > input = open('/home/tom/Python/Input/SPY3.txt', 'r') > N=0 > s = 'boo' > while s: >s = input.readline() >if s == '':break You might find it easier to use a for loop. you could for example use fo

Re: [Tutor] Counting help

2005-08-24 Thread Scott Oertel
Kent Johnson wrote: Scott Oertel wrote: The next problem I have though is creating the dict, i have a loop, but i can't figure out how to compile the dict, it is returning this: ('Joey Gale', ('Scott Joe', 'This is lame' ))) listofnames = [] while (cnt < number[1][0]): if

[Tutor] Source PC MAC address

2005-08-24 Thread Johan Geldenhuys
Hi List, I am doing some networking programming and would like to limit access to my socket server on the the source devices' MAC address. I know the IP from where the connection is coming, but how could I find out what the MAC of the source device is? Any quick answers / ideas? Is there a buil

Re: [Tutor] Source PC MAC address

2005-08-24 Thread Pierre Barbier de Reuille
Socket is built up on IP, not on Ethernet: you have no way of finding a MAC address using sockets simply because it may not exist one ! (if you're not on an Ethernet network) You need to access lower levels of network and probably access directly the network packet as your network card is sending i

[Tutor] Website Retrieval Program

2005-08-24 Thread Daniel Watkins
I'm currently trying to write a script that will get all the files necessary for a webpage to display correctly, followed by all the intra-site pages and such forth, in order to try and retrieve one of the many sites I have got jumbled up on my webspace. After starting the writing, someone introduc

Re: [Tutor] Website Retrieval Program

2005-08-24 Thread Orri Ganel
Daniel Watkins wrote: >I'm currently trying to write a script that will get all the files >necessary for a webpage to display correctly, followed by all the >intra-site pages and such forth, in order to try and retrieve one of the >many sites I have got jumbled up on my webspace. After starting th

Re: [Tutor] try except continue (fwd)

2005-08-24 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 24 Aug 2005 11:24:44 -0700 From: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] try except continue hi Danny, I finally had a chance to review your explanation of continue you wrote a while b

Re: [Tutor] Website Retrieval Program

2005-08-24 Thread Luis N
On 8/24/05, Daniel Watkins <[EMAIL PROTECTED]> wrote: > I'm currently trying to write a script that will get all the files > necessary for a webpage to display correctly, followed by all the > intra-site pages and such forth, in order to try and retrieve one of the > many sites I have got jumbled u

Re: [Tutor] Website Retrieval Program

2005-08-24 Thread Kent Johnson
Daniel Watkins wrote: > I'm currently trying to write a script that will get all the files > necessary for a webpage to display correctly, followed by all the > intra-site pages and such forth, in order to try and retrieve one of the > many sites I have got jumbled up on my webspace. After starting

Re: [Tutor] try except continue (fwd)

2005-08-24 Thread Smith, Jeff
The problem with the original solutions is that strings are immutable so if not line.strip(): continue doesn't actually remote the new line from the end so when you do print line you get two new lines: one from the original and one from the print command. You either need import sys fo

[Tutor] Recursive function calling

2005-08-24 Thread Bernard Lebel
Hello, Sorry in advance for the long email. I have a two-part script. The first parts creates a structure made of nested lists. Some of these lists have only strings, other have other lists. Anyway the point is to ultimately write this structure as a XML file. Here is the script that builds the

[Tutor] Working with files

2005-08-24 Thread Scott Oertel
How do I use the built in file objects to insert text into a file at a certain location? i.e. something, 2, chance, weee nothing, happened, crap, nice need to search for "something" and insert, "what," before it thanks for the feedback you guys are great :) -Scott Oertel -Py2.4 _

Re: [Tutor] Working with files

2005-08-24 Thread Bob Gailer
At 02:55 PM 8/24/2005, Scott Oertel wrote: >How do I use the built in file objects to insert text into a file at a >certain location? > >i.e. > >something, 2, chance, weee >nothing, happened, crap, nice > > need to search for "something" and insert, "what," before it Here's the algorithm. If y

[Tutor] Hello

2005-08-24 Thread Eric Walker
all, Hello... I just finished a class given by Mark Lutz and I love python. Now I need to find a project to hone my skills. I am sure I will be sending lots of questions to this list. I used to use perl but now Its gone. I am now a Python guy... Hail Guido

Re: [Tutor] Hello

2005-08-24 Thread John Purser
In Python that's Guido.Hail('All') -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Eric Walker Sent: Wednesday, August 24, 2005 16:49 To: tutor@python.org Subject: [Tutor] Hello all, Hello... I just finished a class given by Mark Lutz and I love python.

Re: [Tutor] Working with files

2005-08-24 Thread Byron
Bob Gailer wrote: > read the file into a string variable (assuming the file is not humungus) > find the location of "something" in the string > assemble a new string consisting of: >the original string up to the location (index) of "something" >"what" >the rest of the original string >

[Tutor] Importing modules/classes

2005-08-24 Thread Hans Dushanthakumar
Hi Am trying to get my head around classes in python. I have a file dummy_class.py with a class definition in it, as foloows class dummy_class: def __init__(self): print "__init__" def run(self): print "run" Now, I have another file test_dummy.py, which only has th

Re: [Tutor] Working with files

2005-08-24 Thread Scott Oertel
Byron wrote: Bob Gailer wrote: read the file into a string variable (assuming the file is not humungus) find the location of "something" in the string assemble a new string consisting of: the original string up to the location (index) of "something" "what" the rest of the

Re: [Tutor] Hello

2005-08-24 Thread John Purser
You know, I got that backwards and I can't tell you how much it's bugging me! All.Hail('Guido') Thanks. John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Purser Sent: Wednesday, August 24, 2005 16:52 To: 'Eric Walker'; tutor@python.org Subject:

Re: [Tutor] Importing modules/classes

2005-08-24 Thread Danny Yoo
> class dummy_class: > def __init__(self): > print "__init__" > > def run(self): > print "run" > > > Now, I have another file test_dummy.py, which only has the foll 2 lines > > import dummy_class > d=dummy_class() Hi Hans, In Python, modules are containers. They can co

Re: [Tutor] IndexError and appending to lists [Was: Re: Need Helpon Assignment]

2005-08-24 Thread Tom Strickland
Alan, Thanks for your comments. I see how I can simplify my code, but I've run into a problem trying to do so. If I replace the "while" loop with a "for" loop as you suggest, the program won't enter the loop unless "s" is initialized so that it's in "input". How do I do that? Also, near the en

Re: [Tutor] Hello

2005-08-24 Thread Jesse Lands
On Wed, 24 Aug 2005 16:49:17 -0700 (PDT) Eric Walker <[EMAIL PROTECTED]> wrote: > all, > Hello... I just finished a class given by Mark Lutz > and I love python. Now I need to find a project to > hone my skills. I am sure I will be sending lots of > questions to this list. I used to use perl but

Re: [Tutor] Importing modules/classes

2005-08-24 Thread Hans Dushanthakumar
Me again :) Just to make sure that I understand it right, 1) the __init__ method in a class is invoked when a object is instantiated from a class 2) the run method is invoked when a class derived from "threading.Thread" is "start"ed Is that right? The snippet below, ><-- import thr

[Tutor] Differences in running a multithreaded script under IDLE and otherwise

2005-08-24 Thread Hans Dushanthakumar
Hi, While running the foll script by double-clicking it (under WinXP), it runs as expected. However, when I run it via IDLE, it hangs after a few secs (no runtime errors - just hangs). Why does this happen? Cheers Hans import threading class incr_num(threading.Thread): num = '' d

[Tutor] checking substrings in strings

2005-08-24 Thread Frank Hoffsümmer
Hello, I would like to check if a certain word exists in a given string. since I learned to love lists, I used if myword in mystring: ...didnt work. I have now resorted to if mystring.find(myword) >1: is this really the canonical way to check if myword exists in mystring? it feels somewhat "u

[Tutor] Handling binary file

2005-08-24 Thread Julie Lai
I have opened a file in binary mode. The 9th, 10th and 11th bytes contain the time in seconds. In order to get this value in decimal I did the following:   timeinsec = bytes[9] * 65536 + bytes[10] * 256 + bytes{11]   Would someone please advise if there is a better way to do this?   Thanks, Julie.

Re: [Tutor] IndexError and appending to lists [Was: Re: Need Helpon Assignment]

2005-08-24 Thread Alan G
> "for" loop as you suggest, the program won't enter the loop unless > "s" is initialized so that it's in "input". How do I do that? for s in input: means that s takes on each value in input. input is your file. Thus s takes on the value of each line in the input file. You don't need to initiali

Re: [Tutor] Importing modules/classes

2005-08-24 Thread Alan G
> Am trying to get my head around classes in python. Looks like you have the classes bit figured out! :-) > import dummy_class > d=dummy_class() But you have a problem with namespaces. the class 'dummy_class' is inside the module 'dummy_class' So when you import the module that allows you to