Hi Alan, I did not receive personally your last email but I have read it on
the forum.
OK i understand now what you were talking about, sorry it took such a long
time for me to see the solution, the good thing about it is that I am
learning tons.
I will probably post soon again once I hit a wa
> OK Alan, I thing I have seen the light!!.
Almost. :-)
>
-
> def print_options():
>print "--"
>print "Options:"
>print "a. print options"
>print "f. quit the prog
Quoting John Carmona <[EMAIL PROTECTED]>:
> Is it that if you use "while 1:" you create a recursive function? Hope I
> am right.
No ...
Remember how functions can call other functions?
def add(x, y):
""" Add two integers together. """
return x+y
def mul(x, y):
""" Multiply two inte
OK Alan, I thing I have seen the light!!. Here is the script that Kent and
you asked me to look at modified:
-
def print_options():
print "--"
print "Options:"
print "a. print opt
> OK the situation is that I haven't still found out what the answer
is, I
> have noticed in the other hand that if I select the option "a" let's
say 4
> times, I need to enter the option "f" 4 times. I am curious to know
what the
> solution is. I have read your chapter on recursion but that did no
Hi Alan, sorry for not replying sooner I am right in the middle of setting
up a network at home. Thanks for your email.
OK the situation is that I haven't still found out what the answer is, I
have noticed in the other hand that if I select the option "a" let's say 4
times, I need to enter the
> can't see it really, i thought that the fact to have the "break"
command
> would terminate the script straight away.
break terminates the current loop, which is inside your print_options
function. print_options is called from inside print_options.
Research the term "recursion" and see if you ca
Thanks Kent, as far as I can see I get the same problem that on my script, i
need to enter "f" 3 to 4 times before I exit the programme. Hmmm, why, I
can't see it really, i thought that the fact to have the "break" command
would terminate the script straight away. If I enter "f" first then the
John Carmona wrote:
Thanks for the help Kent, Noel and Alan. Here is my final script (it
seems to be working ok but sometimes if I select "quit the programme", I
need to enter that option 2 or 3 times before it works, is this a bug
Try this program. Choose option a a few times, then choose f enou
Thanks for the help Kent, Noel and Alan. Here is my final script (it seems
to be working ok but sometimes if I select "quit the programme", I need to
enter that option 2 or 3 times before it works, is this a bug (I am running
Win XP), please feel free to comment if you thing that something could
John Carmona wrote:
Thanks Kent, it is working now. Is this what you meant in your reply?
Because if I set up the main code at the end of the script I was still
getting an error message.
Yes, that's what I meant, though you just need
task_options()
rather than
print task_options()
When you say pr
On Apr 23, 2005, at 15:44, John Carmona wrote:
Thanks Kent, it is working now. Is this what you meant in your reply?
Because if I set up the main code at the end of the script I was still
getting an error message.
Also, what do I need to use if for example I want my code to rerun
once I have co
Thanks Kent, it is working now. Is this what you meant in your reply?
Because if I set up the main code at the end of the script I was still
getting an error message.
Also, what do I need to use if for example I want my code to rerun once I
have computed let's say a volume. Right now the execut
> From: Feziwe Mpondo sanbi.ac.za>
>
> how to run a programm after you have typed in the commands
Depends on where you type those commands.
If you type them in the interactive interpreter, they are executed whenever you
press Enter. However, this method does not allow you to run the same progr
Joseph Quigley wrote:
class Message:
def init(self, p = 'Hello world'):
self.text = p
def sayIt(self):
print self.text
m = Message()
m.init()
m.sayIt()
m.init('Hiya fred!')
m.sayIt()
This is OK but a more conventional usage is to write an __init__() method. This is sometimes called
a
Joseph Quigley wrote on Fri, 08 Apr 2005 16:46:33 -0600:
> Now what are dictionaries and the __name__ really used for? A byte of
> python never got that through my thick skull.
Dictionaries associate a value with a certain key, sort of like a real
world dictionary where you can take a word and l
class Message:
def init(self, p = 'Hello world'):
self.text = p
def sayIt(self):
print self.text
m = Message()
m.init()
m.sayIt()
m.init('Hiya fred!')
m.sayIt()
> Well this OOP stuff is realy hard for me as I have never even
> programmed it took me a while just to understand defs.
Th
Kevin gmail.com> writes:
> Well this OOP stuff is realy hard for me as I have never even
> programmed it took me a while just to understand defs. However I am
> determined to learn how to do it. My biggest problem is with __init__
> I still don't understand how to use it. Though I did try somthin
> Well this OOP stuff is realy hard for me as I have never even
> programmed it took me a while just to understand defs.
That's OK, OOP is quite a strange concept for many folks. Its
actually easier to learn as a beginner than for folks who
have been programming without OOP for a long time!
> det
Well this OOP stuff is realy hard for me as I have never even
programmed it took me a while just to understand defs. However I am
determined to learn how to do it. My biggest problem is with __init__
I still don't understand how to use it. Though I did try somthing
different with my code rather the
Bob Gailer alum.rpi.edu> writes:
> At 12:22 PM 4/7/2005, Andrei wrote:
> >Kevin gmail.com> writes:
> >
> > > I am fooling around with classes and I was trying to create a very
> > > small one player text adventure. I made a class called commands here
> >I don't think you're making proper use of
> >I don't think you're making proper use of classes.
>
> IMHO there is no "proper use of classes".
It depends on whether the OP wants to pursue OOP. There are many uses
of classes that are not related to OOP. But if we are talking about
good OOP practie then there are some uses of classes that ar
At 12:22 PM 4/7/2005, Andrei wrote:
Kevin gmail.com> writes:
> I am fooling around with classes and I was trying to create a
very
> small one player text adventure. I made a class called commands
here
> it is:
> class Commands:
> def __init__(self):
> pass
> def quiting(self):
>
Kevin gmail.com> writes:
> I am fooling around with classes and I was trying to create a very
> small one player text adventure. I made a class called commands here
> it is:
> class Commands:
> def __init__(self):
> pass
> def quiting(self):
> sys.exit()
> I want to beab
And I wouldn't mind mentioning that re is slightly over kill for the
examples given.
Try this.
###
old_group_delimiter = "\n\n"
old_line_delimiter = "\n"
new_group_delimiter = "\n"
new_line_delimiter = ", "
fi = raw_input("Input file to use? ")
fi = open(fi,"r"
Ron Nixon wrote:
The following program takes text data like this:
Jimi Hendrix
2100 South Ave
Seattle, WA 55408
and changes it to this
Jimi Hendrix, 2100 South Ave,Seattle,WA,55488
and writes it to a file.
Hameed has shown you one solution. I would like to point out that if you plan to read this
Hi, Ron!
I am also a newbie in programming. But after reading your problem i
decided to solve it as a homework :). But there are few things you
didn't mentioned. Does all the addresses in first file have same
format. What seperates those addresses in the file. Assuming that all
address are on 3 l
The following program takes text data like this:
Jimi Hendrix
2100 South Ave
Seattle, WA 55408
and changes it to this
Jimi Hendrix, 2100 South Ave,Seattle,WA,55488
and writes it to a file. The problem I'm running into
is that it only writes this first address to a file
and there are several oth
actuary77 wrote:
Kent Johnson wrote:
>>> def rec(n,alist=[]):
... _nl=alist[:]
... print n,_nl
... if n == 0:
... print n,_nl
... return _nl
... else:
... _nl=_nl+[n]
... return rec(n-1,_nl)
...
>>> _nl = rec(4)
4 []
3 [4]
2 [4, 3]
1 [4, 3,
Problem solved. Thanks
--- Kent Johnson <[EMAIL PROTECTED]> wrote:
> Try it with non-greedy matches. You are matching
> everything from the first
> in one match. Also I think you want to escape the .
> before (you want just paragraphs that end
> in a period?)
>
> pattern = re.compile(""" hr
Try it with non-greedy matches. You are matching everything from the first
in one match. Also I think you want to escape the . before (you want just paragraphs that end
in a period?)
pattern = re.compile("""(.*?)\.""", re.DOTALL)
Kent
Ron Nixon wrote:
Trying to scrape a newspaper site for arti
Trying to scrape a newspaper site for articles using
this code whic ws done with help from the list:
import urllib, re
pattern = re.compile("""(.*).""", re.DOTALL)
page
=urllib.urlopen("http://www.startribune.com";).read()
for headline, body in pattern.findall(page):
print body
It should g
32 matches
Mail list logo