<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
            "http://my.netscape.com/publish/formats/rss-0.91.dtd">

<rss version="0.91">

<channel>
<title>python-Tutor archive @ ASPN</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/python-Tutor</link>
<description>Discussion for folks who want to ask questions regarding how to learn computer programming with the Python language. </description>
<language>en-us</language>
<copyright>Copyright 2005, ActiveState</copyright>
<managingEditor>aspn-feedback@activestate.com</managingEditor>
<webMaster>aspn-feedback@activestate.com</webMaster>

<image>
<title>python-Tutor @ ASPN Mail Archive</title>
<url>http://ASPN.ActiveState.com/ASPN/img/logo_78x25.gif</url>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Browse/Threaded/python-Tutor</link>
</image>

<item>
<title>Re: [Tutor] Use iterator to refer to an object's attribute?</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116987</link>
<description>&lt;PRE>>> I wanted to make the methods flexible
enough that I wouldn't have to 
>> edit every method if the module list ever changed.  I guess I don't 
>> understand how a dictionary works in this situation.
>
> I don;t understand what you don;t understand here. Can you expand on 
> why you don't think a dictionary would work?

This remark was based on one of my earlier designs.  It didn't work 
there, so I abandoned dictionaries.  The library reference says:
"Only values containing lists, dictionaries or other mutable types 
(that are compared by value rather than by object identity) may not be 
used as keys."
This added to the problem, at least in the design I attempted it in.

>> I originally had tuples, but you can't access individual elements.
>
> What makes you think so?
>
>>>> t = (1,2,3)
>>>> print t[0]
> 1

I didn't work before when I used it as an index.  Now it does.	I must 
have done something different originally.  But you are right.  This 
works:
 >>> mylist = ['one', 'two', 'three']
 >>> t = (0,1,2)
 >>> print mylist[t[0]]
one

>>>> I have object "db.mb".  I have iterator "shortmod" with a value of  
>>>> "mb". Why can't I call "db.shortmod"?
>>>
>>> You can use db.getattr(shortmod)
>> That doesn't work.  It tells me "Database instance has no attribute 
>> 'getattr'".
>
> Its actually a special method so needs the underscores __getattr__
> and accessed via a function. I got my syntax muddled:
>
> getattr(db, shortmod)
>
> is how it should be written.

That works!  I knew there had to be a way!

Thanks for the help!
Ron

_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Tutor Digest, Vol 26, Issue 71</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116986</link>
<description>&lt;PRE>Terry:

> -----Original Message-----
> Date: Thu, 20 Apr 2006 10:14:23 -0700 (PDT)
> From: Terry Carroll &lt;carroll@...
> Subject: Re: [Tutor] FW: Splitting a number into even- and odd-
>	numbered digits
> To: tutor@...
> Message-ID:
>	&lt;Pine.LNX.4.44.0604201000430.19166-100000@...
> Content-Type: TEXT/PLAIN; charset=US-ASCII
> 
&lt;&lt;snip>>
> >
> > I could not find a way to include these requirements in a single,
simple
> > expression.
> 
> I really liked John Fouhy's approach, or at least a variation of it:
> 
> >>> def odd_even(s):
> ...	 '''
> ...	 Returns a tuple of two strings taken from s.  The first string
is
> ...	 the odd-numbered characters (counting from the right), and the
> ...	 second is the even-numbered characters.
> ...	 '''
> ...	 return (s[::-2][::-1], s[-2::-2][::-1])
> ...
> >>> odd_even("1234567")
> ('1357', '246')
> >>> odd_even("2345")
> ('35', '24')
> >>> odd_even("1")
> ('1', '')
> >>>
> 
> John's original solution returned values with the digits in reverse
> order; but that's easily changed by reslicing each string with [::-1].

By golly you're right!	That is a very slick solution.	It didn't occur
to me to re-reverse the strings like that.  Thanks to both you and John.


Regards,
 
Barry
barry.carroll@...
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed


_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Parsing html user HTMLParser</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116925</link>
<description>&lt;PRE>> I need help here, I'm struggling with html parsing method, up until now 
> I can only put and html file as instance. I have no experience with 
> this, I want to read the childs inside this document and modify the 
> data. What can I do if I start from here?

Hi Titvirak,

You might want to take a look at a different module for parsing HTML.  A 
popular one is BeautifulSoup:

     http://www.crummy.com/software/BeautifulSoup/

Their quick-start page shows how to do simple stuff.  There are a few 
oddities with BeautifulSoup, but on the whole, it's pretty good.

Good luck to you!
_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>[Tutor] Apology (Was: Re: Splitting a number into even- and odd-	numbered digits)</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116924</link>
<description>&lt;PRE>Greetings:

> -----Original Message-----
> From: tutor-bounces@... [mailto:tutor-bounces@... On
Behalf
> Of tutor-request@...
> Sent: Thursday, April 20, 2006 10:57 AM
> To: tutor@...
> Subject: Tutor Digest, Vol 26, Issue 71
> 
&lt;&lt;snip>>
> 
> Today's Topics:
> 
>    1. Re: Config file parsing (Kent Johnson)
>    2. FW: Splitting a number into even- and odd- numbered digits
>	(Carroll, Barry)
>    3. Re: Tutor FAQ? (Eric Walker)
>    4. Re: Splitting a number into even- and odd- numbered digits
>	(Carroll, Barry)
>    5. Re: Splitting a number into even- and odd- numbered digits
>	(Carroll, Barry)
>    6. Re: FW: Splitting a number into even- and odd- numbered
>	digits (Terry Carroll)
>    7. Re: Tutor FAQ? (Alan Gauld)
>    8. Re: Tutor FAQ? (Mike Hansen)
> 
&lt;&lt;snip>>
>

I apologize for the multiple postings.	The first two resulted in this
reply:

> From: postmaster@... [mailto:postmaster@...
> Sent: Thursday, April 20, 2006 9:55 AM
> To: Carroll, Barry
> Subject: RE: [Tutor] FW: Splitting a number into even- and odd-
numbered
> digits
> 
> MDaemon has indentified your message as spam.  It will not be
delivered.
> 
> From	    : tutor-bounces@...
> To	    : een673@...
> Subject   : ***SPAM*** Score/Req: 10.0/9.0 - [Tutor] FW: Splitting a
> number into even- and odd- numbered digits
> Message-ID:
> &lt;2BBAEE949D384D40A2B851287ADB6A432C365E@...
> 
> Yes, score=10.0 required=9.0 tests=BAYES_99 autolearn=no
version=3.0.4
> **********
> *   10 BAYES_99 BODY: Bayesian spam probability is 99 to 100% *
> [score: 0.9972]

Taking the message at its word, I resent the post.  I don't know what
triggered the response, or why the posts were delivered anyway.  

Regards,
 
Barry
barry.carroll@...
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed



_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Tutor FAQ?</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116923</link>
<description>&lt;PRE>> Thanks! I do sleep but I have my email tied in to my clock 
> radio so whenever an email arrives on the tutor list I am 
> awakened to answer it ;)

Hmmm.. I wouldn't be surprised if there's an X10 module that does that. =)

[...]

> Maybe this could be integrated with the main Python FAQ in a 
> beginner's section? Fredrik Lundh is experimenting with a FAQ 
> wiki here:
> http://pyfaq.infogami.com/

I'll take a look at this.

> Sounds good to me. Are you volunteering?

Yes, I'll get the ball rolling. I'll most likely do something on the site
above. I'll post to this list when I have something worth looking at.

Mike

_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Tutor FAQ?</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116854</link>
<description>&lt;PRE>> I'd like to send a big Thank You to Danny, Alan, Kent and others

Over the years there have been many, some have moved from
tutor list to c.l.python others have just got too busy. Others reappear
and then disappear again at intervals. (Who remembers Ivan, Gregor,
Magnus etc etc.)

> answering questions on the tutor list.(Do these guys sleep? They must work
> in shifts.)

I live in the UK, Kent and Danny in the US so that gives
a 5-7 hour time shift for free! :-)

> if a Tutor FAQ would be helpful. I don't believe one exists.

It's been discussed several times but no-one ever quite got round to it.

If you want to make a worthwhile contribution to the Python
community that would be a good starting point!

My tutor tries to answer the most common questions but its
not so easy to findthe answers when buried inside a prose topic
page.

> the tutor list along with their answers? It would be a FAQ about the tutor
> list as well as common questions to the tutor list.

Agreed.

> FAQ about the Tutor List would include
> FAQ for common questions to the list would include
>
> I'm sure you can come up with more of the common questions.

And then "all" it takes is someone to collate them and provide the
answers. The Active State searchable artchive should be a
good starting point.

> like a reasonable idea?

Absolutely, are you volunteering? :-)

Alan G.

_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] FW: Splitting a number into even- and odd- numbered digits</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116853</link>
<description>&lt;PRE>On Thu, 20 Apr 2006, Carroll, Barry
wrote:

> > The first step in the calculation is to split the input into two
> strings:
> > the even- and odd- numbered digits, respectively.  The least
> significant
> > digit is defined as odd.
>  
> I forgot to include two important requirements:
> 
>     1. the length of the input string is arbitrary,
>     2. the order of the digits must be maintained.
> 
> I could not find a way to include these requirements in a single, simple
> expression.  

I really liked John Fouhy's approach, or at least a variation of it:

>>> def odd_even(s):
...    '''
...    Returns a tuple of two strings taken from s.  The first string is
...    the odd-numbered characters (counting from the right), and the
...    second is the even-numbered characters.
...    '''
...    return (s[::-2][::-1], s[-2::-2][::-1])
...
>>> odd_even("1234567")
('1357', '246')
>>> odd_even("2345")
('35', '24')
>>> odd_even("1")
('1', '')
>>>

John's original solution returned values with the digits in reverse 
order; but that's easily changed by reslicing each string with [::-1].

_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Splitting a number into even- and odd- numbered digits</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116821</link>
<description>&lt;PRE>Greetings:

Unfortunately, my problem description was incomplete.  I forgot to
include two important requirements:

    1. the length of the input string is arbitrary,
    2. the order of the digits must be maintained.

I could not find a way to include these requirements in a single, simple
expression.  I decided to make an explicit test for string length, which
simplified matters. I came up with this:

>>>>>>>
>>> def odd_even(x):
...	if len(x) % 2 == 1:
...	    return x[::2], x[1::2]
...	else:
...	    return x[1::2], x[::2]

>>> odd_even('987654321')
('97531', '8642')

>>> odd_even('98765432')
('8642', '9753')
>>> 
>>>>>>>

which is an improvement, I think, on my original.  
 
Thanks to those who provided suggestions.  This is the most useful list
I've ever found.

Regards,
 
Barry
barry.carroll@...
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed


_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Splitting a number into even- and odd- numbered digits</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116820</link>
<description>&lt;PRE>Greetings:

First of all, thanks to those who contributed suggestions.  

Unfortunately, my description was incomplete.
 
> I am writing a function that accepts a string of decimal digits,
> calculates a checksum and returns it as a single character string.
> The first step in the calculation is to split the input into two
strings:
> the even- and odd- numbered digits, respectively.  The least
significant
> digit is defined as odd.
 
I forgot to include two important requirements:

    1. the length of the input string is arbitrary,
    2. the order of the digits must be maintained.

I could not find a way to include these requirements in a single, simple
expression.  I decided to make an explicit test for string length, which
simplified matters. I came up with this:

>>>>>>>
>>> def odd_even(x):
...	if len(x) % 2 == 1:
...	    return x[::2], x[1::2]
...	else:
...	    return x[1::2], x[::2]

>>> odd_even('987654321')
('97531', '8642')

>>> odd_even('98765432')
('8642', '9753')
>>> 
>>>>>>>

which is an improvement, I think, on my original.  
 
> >>>>>>>
> >>> s = '987654321'
> >>> odd = ''
> >>> for c in s[::-2]:
> ...	  odd = c + odd
> ...
> >>> s = s[:-1]
> >>> even = ''
> >>> for c in s[::-2]:
> ...	  even = c + even
> ...
> >>> odd
> '97531'
> >>> even
> '8642'
> >>>>>>>
 
Thanks again.  This is the most useful list I've ever found.

Regards,
 
Barry
barry.carroll@...
541-302-1107
________________________
We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed


_______________________________________________
Tutor maillist	-  Tutor@...
http://mail.python.org/mailman/listinfo/tutor
&lt;/PRE></description>
</item>

<item>
<title>Re: [Tutor] Tutor FAQ?</title>
<link>http://ASPN.ActiveState.com/ASPN/Mail/Message/python-Tutor/3116806</link>
<description>&lt;PRE>Kent Johnson wrote:
> Mike Hansen wrote:
>   
>> I'd like to send a big Thank You to Danny, Alan, Kent and others(whos names
>> escape me) for being such an asset to the Python community by relentlessly
>> answering questions on the tutor list.(Do these guys sleep? They must work
>> in shifts.) This list is one of the most civilized and responsive lists I
>> have ever read. When many pop onto the list and ask what may seem like some
>> of the most obvious questions, you guys calmly answer and nudge them in the
>> right direction without ever losing your patience. It's a great list.
>>     
>
> Thanks! I do sleep but I have my email tied in to my clock radio so 
> whenever an email arrives on the tutor list I am awakened to answer it ;)
>   
>> Anyway, I've been reading the list for a couple of years now, and I wonder
>> if a Tutor FAQ would be helpful. I don't believe one exists. Should there be
>> something on the Python wiki that would list the most common questions to
>> the tutor list along with their answers? It would be a FAQ about the tutor
>> list as well as common questions to the tutor list.
>>     
>
> I wonder about this sometimes too. I think it would be good to have a 
> place to collect this stuff.
>
> Maybe this could be integrated with the main Python FAQ in a beginner's 
> section? Fredrik Lundh is experimenting with a FAQ wiki here:
> http://pyfaq.infogami.com/
>
>   
>> FAQ about the Tutor List would include
>> - The policy on answering homework assignment
>> - Why the reply-to is set that way.
>> - Post code and exact error message.
>> (A lot of this might be in that initial message you get from mailman when
>> joining the list, but it might be a good idea to put it on the wiki)
>>
>> FAQ for common questions to the list would include
>> - ord() and chr()
>> - Common GUI programming questions
>> - String module is deprecated, use string methods
>> - ???
>>
>> I'm sure you can come up with more of the common questions. Does this sound
>> like a reasonable idea?
>>     
>
> Sounds good to me. Are you volunteering?
>
> Kent
>
> _______________________________________________
> Tutor maillist  -  Tutor@...
> http://mail.python.org/mailman/listinfo/tutor
>
>   
Hey guys the FAQ thing sound great. I found what I think is the best 
pyQT tutorial around.
Took me like 10 minutes and I am off and running.
http://www.cs.usfca.edu/~afedosov/qttut/
&lt;/PRE></description>
</item>

</channel>
</rss>