[Tutor] How to implement function like this?

2007-10-23 Thread Yinghe Chen
Hello gurus, I have a question, a function like below, it is implemented by me, :) def funcA(tarray): a = [2,3,4] if len(tarray) >=3: return a[0],a[1], a[2] elif len(tarray) == 2: return a[0],a[1], funcB(1)[0] elif len(tarray) == 1:

Re: [Tutor] How to implement function like this?

2007-10-23 Thread Alan Gauld
"Yinghe Chen" <[EMAIL PROTECTED]> wrote > def funcA(tarray): > a = [2,3,4] >if len(tarray) >=3: > return a[0],a[1], a[2] >elif len(tarray) == 2: >return a[0],a[1], funcB(1)[0] >elif len(tarray) == 1: > return a[0], funcB(2)[0], funcB

Re: [Tutor] How to implement function like this?

2007-10-23 Thread Kent Johnson
Yinghe Chen wrote: > Hello gurus, > > I have a question, a function like below, it is implemented by me, :) > > def funcA(tarray): >a = [2,3,4] > if len(tarray) >=3: > return a[0],a[1], a[2] > elif len(tarray) == 2: > return a[0],a[1], funcB(1)[0]

Re: [Tutor] How to implement function like this?

2007-10-23 Thread Ricardo Aráoz
Yinghe Chen wrote: > Hello gurus, > > I have a question, a function like below, it is implemented by me, :) > > def funcA(tarray): >a = [2,3,4] > if len(tarray) >=3: > return a[0],a[1], a[2] > elif len(tarray) == 2: > return a[0],a[1], funcB(1)[0]

Re: [Tutor] calling a variable name

2007-10-23 Thread Ricardo Aráoz
Kent Johnson wrote: > Bryan Fodness wrote: >> Thank you. This works well. I am still trying to figure out the pros >> and cons of using an array, dictionary or list. > > Array is specialized, you probably want list or dict. > > Use list when you want a sequence of items indexed by sequential i

[Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Dick Moores
Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Eric Walstad
Dick Moores wrote: > That looks like a very nice, concise tutorial that should help soup noobs like me to get up and running quickly. I like the added value of comments like: "Under the hood, attribute access is actually a search for the first

Re: [Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Ted Roche
On 10/23/07, Dick Moores <[EMAIL PROTECTED]> wrote: > And if you're in the Manchester, New Hampshire, USA area, perhaps you can stop by Thursday night and witness Kent himself presenting his essay and a follow-on scrum using Beautiful Soup to pa

Re: [Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Eric Brunson
That's funny. Knowing Alan is from the UK, when I saw Kent was from Manchester I thought he was Alan's countrymate. You know the British (at least my cousins) make fun of us for always having to say our state. "Paris, Texas", "Boston, Mass", "Tampa, FL". But, we just have so many more towns

[Tutor] Logging in Linux

2007-10-23 Thread wormwood_3
Hello tutors, I have become familiar with the basic use of the logging module. I have a program that prints out warning messages as well as info messages as it runs, merely dumping them into stdout. When I make such a script into a cron job, I simply redirect this output to /dev/null. Now, wha

Re: [Tutor] calling a variable name

2007-10-23 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> Use list when you want a sequence of items indexed by sequential integers. >> Lists >> - preserve order >> - are fast for indexed lookup >> - are relatively slow (O(n)) for adding, deleting and searching (though >> for small lists this should not be a

Re: [Tutor] How to implement function like this?

2007-10-23 Thread Kent Johnson
Ricardo Aráoz wrote: > Yinghe Chen wrote: >> Hello gurus, >> >> I have a question, a function like below, it is implemented by me, :) >> >> def funcA(tarray): >>a = [2,3,4] >> if len(tarray) >=3: >> return a[0],a[1], a[2] >> elif len(tarray) == 2: >>

[Tutor] Complexity of list operations

2007-10-23 Thread Danny Yoo
>> Use list when you want a sequence of items indexed by sequential >> integers. Lists >> - preserve order >> - are fast for indexed lookup >> - are relatively slow (O(n)) for adding, deleting and searching (though >> for small lists this should not be a consideration) > > Are you sure they take O

Re: [Tutor] Complexity of list operations

2007-10-23 Thread Dave Kuhlman
On Tue, Oct 23, 2007 at 08:17:33PM -0400, Danny Yoo wrote: [helpful explanation snipped] > > That being said, if all our operations are applied only at the end of the > list, the time complexity of those two operations look better. We can > argue for O(1) behavior under that particular restri

Re: [Tutor] calling a variable name

2007-10-23 Thread Dave Kuhlman
On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote: [snip] > > Perhaps I was a bit hasty. > > Lists are implemented as arrays of references. I believe they are > - amortized O(1) for append - occasionally the list must be reallocated > and copied OK. I'm groping here. Wikipedia tel