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
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
for s
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
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
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'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
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 the
-- 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
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 up on
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
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
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
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
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 you know
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
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.
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
write the
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 the
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
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
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 contain possibly
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 end of
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 now
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 started
Is that right?
The snippet below,
--
import
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 = ''
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
26 matches
Mail list logo