[Tutor] more scraping and saving

2011-01-03 Thread Tommy Kaas
Hi - I was helped the other day in an attempt to scrape and save a simple web page. I'm using what I learned and trying another. It should be very simple, but I only get the first row of names saved. Can anybody help with an explanation? (It's a public list of names of doctors with knows conne

[Tutor] How does it work?

2011-01-03 Thread Neo Vector
Hi All, Could you explain me how does it work, pls? == >>>r = '' >>>for c in 'abcd': r = c + r ... ... >>>r 'dcba' == Best Regards, Neo Vector ___ Tutor maillist - Tutor@python

Re: [Tutor] How does it work?

2011-01-03 Thread Shrivats
On Mon, Jan 03, 2011 at 10:52:26PM +0800, Neo Vector wrote: > Hi All, Hello, > Could you explain me how does it work, pls? Sure, I'm not telling you how that works. However, I'll alter your code snippet a little bit and see if you can understand after that. > == > >>>

Re: [Tutor] How does it work?

2011-01-03 Thread Shrivats
On Mon, Jan 03, 2011 at 08:32:18PM +0530, Shrivats wrote: > On Mon, Jan 03, 2011 at 10:52:26PM +0800, Neo Vector wrote: > > Hi All, > Hello, > > Could you explain me how does it work, pls? > > Sure, I'm not telling you how that works. However, I'll alter your code > snippet > a little bit and se

Re: [Tutor] How does it work?

2011-01-03 Thread Alan Gauld
"Neo Vector" wrote Could you explain me how does it work, pls? == r = '' r is an empty string for c in 'abcd': c takes the value of each letter in turn r = c + r strings can be added such that the result is the concatenation of the two strings.

[Tutor] How does it work?

2011-01-03 Thread Patty
- Original Message - From: "Patty" To: "Alan Gauld" Sent: Monday, January 03, 2011 9:05 AM Subject: Re: [Tutor] How does it work? Hi Folks - I read this code and tried to parse it as a pop quiz for myself ;) and have a question, maybe 2 clarifications, below: - Original Mess

Re: [Tutor] How does it work?

2011-01-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Patty wrote: for c in 'abcd': .. When I first looked at this - I thought that the variable 'c' would have had to be initialized first earlier in the program. And I thought that the programmer would input a single char or a single space. I wasn't thinking counti

Re: [Tutor] How does it work?

2011-01-03 Thread Alan Gauld
"Patty" wrote for c in 'abcd': c takes the value of each letter in turn When I first looked at this - I thought that the variable 'c' would have had to be initialized first earlier in the program. It is initialized earluier - in the for statement, each time through the loop it gets r

Re: [Tutor] How does it work?

2011-01-03 Thread Patty
Yes, I knew there was something I wasn't getting. This is the explanation I was looking for - and I'm sorry about the incorrect indentation. And I agree with Alan that 'foreach' would have been a good name for this type of loop. I need to sort out 'loop structures' in my notes and read up on

[Tutor] matplotlib.pylab.plotfile formatting help

2011-01-03 Thread Sean Carolan
I've got a csv file that contains two data fields, the short name of a month and an integer. I'm experimenting with pylab and ipython to get a feel for how pylab works. I'm able to generate a bar graph from my data, but there are two problems with it: 1. I don't want "2011" appended to the mont

[Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
I'm just have a little fun here, but I bet that comments will help further elighten me on the subtleties of python. consider the following console session: >>> L = ['foo','bar'] >>> locals()[L[0]] = L[1] >>> foo 'bar' >>> 'foobar' in locals() False >>> 'foo' in locals() True >>> locals() {'__built

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Alan Gauld
"Tim Johnson" wrote consider the following console session: L = ['foo','bar'] locals()[L[0]] = L[1] foo 'bar' locals() {'__builtins__': , 'L': ['foo', 'bar'], '__package__': None, '__name__': '__main__', 'foo': 'bar', '__doc__': None} I could initialize variables in a local scope, or I co

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Steven D'Aprano
Tim Johnson wrote: I'm just have a little fun here, but I bet that comments will help further elighten me on the subtleties of python. consider the following console session: L = ['foo','bar'] locals()[L[0]] = L[1] This will not do what you think it does. In general, local variables are not

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Steven D'Aprano [110103 15:03]: > Tim Johnson wrote: >> I'm just have a little fun here, but I bet that comments will help >> further elighten me on the subtleties of python. >> >> consider the following console session: > L = ['foo','bar'] > locals()[L[0]] = L[1] > > This will not do wh

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Alan Gauld [110103 14:47]: > > "Tim Johnson" wrote > >> consider the following console session: > L = ['foo','bar'] > locals()[L[0]] = L[1] > foo >> 'bar' > locals() >> {'__builtins__': , 'L': ['foo', >> 'bar'], '__package__': None, '__name__': '__main__', 'foo': 'bar', >> '__do

[Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
Hi all, I have a solitaire game in which I use a "Pile" class. This class is meant to hold a bunch of cards, so I subclass it for the deck, the ace stacks, and the seven main stacks, defining rules and methods for each but also relying on the parent Pile class's methods and attributes. However, I k

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Alan Gauld
"Tim Johnson" wrote Now, Alan, do you know anything about PHP? If you do, can you comment on the PHP extract() function? I know enough basic PHP to read a page with code in it and get the general drift. I've never written a line of it and have learned enough about it that I don't want to

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alan Gauld
"Alex Hall" wrote class parent(object): def __init__(self, l=None): if l is None: l=[] l is a local variable inside init(). You wanted self.l... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.alan-g.me.uk/ ___ Tutor ma

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Walter Prins
On 4 January 2011 00:47, Alex Hall wrote: > class parent(object): > def __init__(self, l=None): > if l is None: l=[] > Missing "self". Perhaps you meant: class parent(object): def __init__(self, l=None): if l is None: self.l=[] else: self.l=l Walter __

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Wayne Werner
On Mon, Jan 3, 2011 at 6:47 PM, Alex Hall wrote: > Hi all, > I have a solitaire game in which I use a "Pile" class. This class is > meant to hold a bunch of cards, so I subclass it for the deck, the ace > stacks, and the seven main stacks, defining rules and methods for each > but also relying on

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Vern Ceder
On Mon, Jan 3, 2011 at 7:47 PM, Alex Hall wrote: > Hi all, > I have a solitaire game in which I use a "Pile" class. This class is > meant to hold a bunch of cards, so I subclass it for the deck, the ace > stacks, and the seven main stacks, defining rules and methods for each > but also relying on

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
On 1/3/11, Wayne Werner wrote: > On Mon, Jan 3, 2011 at 6:47 PM, Alex Hall wrote: > >> Hi all, >> I have a solitaire game in which I use a "Pile" class. This class is >> meant to hold a bunch of cards, so I subclass it for the deck, the ace >> stacks, and the seven main stacks, defining rules and

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Walter Prins
Sorry, my last post was too hasty. You also had a problem calling super. It should be like this: class parent(object): def __init__(self, l=None): if l is None: self.l=[] else: self.l=l class child(parent): def __init__(self, *args, **kwords): super(child, self).__init__(*args, **kwor

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Alex Hall
On 1/3/11, Walter Prins wrote: > Sorry, my last post was too hasty. You also had a problem calling super. > It should be like this: > > class parent(object): > def __init__(self, l=None): >if l is None: self.l=[] >else: self.l=l > > class child(parent): > def __init__(self, *args, **kwo

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Hugo Arts
On Tue, Jan 4, 2011 at 2:06 AM, Alan Gauld wrote: > > "Tim Johnson" wrote > >>  Now, Alan, do you know anything about PHP? If you do, can you >>  comment on the PHP extract() function? > > I know enough basic PHP to read a page with code in it and get the general > drift. I've never written a lin

Re: [Tutor] subclass not inheriting attributes?

2011-01-03 Thread Walter Prins
On 4 January 2011 01:16, Vern Ceder wrote: > I believe you need to pass the object both to super() and to the method > itself, as in: > > super(parent, self).__init__(self, *args, **kwords) > > See the example at > http://docs.python.org/library/functions.html?highlight=super#super > > HTH, > > V

Re: [Tutor] Initialize values from a text input file

2011-01-03 Thread Tim Johnson
* Hugo Arts [110103 17:12]: > On Tue, Jan 4, 2011 at 2:06 AM, Alan Gauld wrote: > > > > "Tim Johnson" wrote > > > >>  Now, Alan, do you know anything about PHP? If you do, can you > >>  comment on the PHP extract() function? > > > > I know enough basic PHP to read a page with code in it and get