[Tutor] don't understand iteration

Clayton Kirkwood crk at godblessthe.us
Mon Nov 10 05:14:12 CET 2014



>-----Original Message-----
>From: Tutor [mailto:tutor-bounces+crk=godblessthe.us at python.org] On
>Behalf Of Dave Angel
>Sent: Sunday, November 09, 2014 5:10 PM
>To: tutor at python.org
>Subject: Re: [Tutor] don't understand iteration
>
>You forgot to state your Python version. I'll assume 3.4
>
>"Clayton Kirkwood" <crk at godblessthe.us> Wrote in message:
>> <!--
>> /* Font Definitions */
>> @font-face
>> 	{font-family:"Cambria Math";
>> 	panose-1:2 4 5 3 5 4 6 3 2 4;}
>> @font-face
>> 	{font-family:Calibri;
>> 	panose-1:2 15 5 2 2 2 4 3 2 4;}
>> /* Style Definitions */
>> p.MsoNormal, li.MsoNormal, div.MsoNormal
>> 	{margin:0in;
>> 	margin-bottom:.0001pt;
>> 	font-size:11.0pt;
>> 	font-family:"Calibri","sans-serif";}
>> a:link, span.MsoHyperlink
>> 	{mso-style-priority:99;
>> 	color:blue;
>> 	text-decoration:underline;}
>> a:visited, span.MsoHyperlinkFollowed
>> 	{mso-style-priority:99;
>> 	color:purple;
>> 	text-decoration:underline;}
>> span.EmailStyle17
>> 	{mso-style-type:personal-compose;
>> 	font-family:"Calibri","sans-serif";
>> 	color:windowtext;}
>> .MsoChpDefault
>> 	{mso-style-type:export-only;}
>> @page WordSection1
>> 	{size:8.5in 11.0in;
>> 	margin:1.0in 1.0in 1.0in 1.0in;}
>> div.WordSection1
>> 	{page:WordSection1;}
>> -->I have the following code: import urllib.request,re,stringmonths =
>['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May.', 'Jun.', 'Jul.', 'Aug.', 'Sep.',
>'Oct.', 'Nov.', 'Dec.']from urllib.request import urlopenfor line in
>urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):    line =
>line.decode('utf-8')  # Decoding the binary data to text.    if 'EST' in
>line or 'EDT' in line:  # look for Eastern Time         blah =
>re.search(r'<\w\w>(\w{3}\.)\s+(\d{2}),\s+(\d{2}).+([AP]M)\s+(E[SD]T)',
>line)                 (month, day, time, ap, offset) =
>blah.group(1,2,3,4,5)
>
>You apparently know you want exactly 5 items, and you want them in
>order, so you need 5 arguments,  in order. If you don't like what  you
>have, you can pass a list, if you precede it with an  asterisk.
>
>(month, day, time, ap, offset) = blah.group( *list (range (1, 6)))
>
>Should do it.
>

You are so smart. I am going to stop listening to all those people in Russia
and what they say about you. Where did you find that one? What does the '*'
do/why? And why the weird range thing?

Clayton
:<)))

>
>--
>DaveA
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>To unsubscribe or change subscription options:
>https://mail.python.org/mailman/listinfo/tutor





More information about the Tutor mailing list