[Tutor] Python Exercise

Kok Cheng Tan tkokchen at gmail.com
Sun Nov 28 03:43:52 CET 2010


Hi,

Thanks for the feedback.
I will add a trial section that doesn't require login so that new visitors
are able to give the website a try.

Regards,
Kok Cheng

---------- Forwarded message ----------
From: <tutor-request at python.org>
Date: Sun, Nov 28, 2010 at 2:41 AM
Subject: Tutor Digest, Vol 81, Issue 105
To: tutor at python.org


Send Tutor mailing list submissions to
       tutor at python.org

To subscribe or unsubscribe via the World Wide Web, visit
       http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
       tutor-request at python.org

You can reach the person managing the list at
       tutor-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

  1. Python Exercise (Kok Cheng Tan)
  2. Reload() in v3?  WAS Re: IDEs (Alan Gauld)
  3. Re: Reload() in v3?  WAS Re: IDEs (Alan Gauld)
  4. Re: Python Exercise (Mac Ryan)
  5. Re: normalize an array (Eike Welk)
  6. Python Exercise (patty at cruzio.com)
  7. Re: Python Exercise (Joel Schwartz)
  8. Re: normalize an array (John)


----------------------------------------------------------------------

Message: 1
Date: Sat, 27 Nov 2010 22:00:03 +0800
From: Kok Cheng Tan <tkokchen at gmail.com>
To: tutor at python.org
Subject: [Tutor] Python Exercise
Message-ID:
       <AANLkTi=eFHo9tvNdSEJH=xW2=Ca3T7KZrrK51-ph-cmh at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Hi,

I created this website for practising python online:
http://www.pyschools.com.
Hope to gather feedback from people here who are interesting in
teaching and learning python.

Regards,
Kok Cheng


------------------------------

Message: 2
Date: Sat, 27 Nov 2010 15:04:57 -0000
From: "Alan Gauld" <alan.gauld at btinternet.com>
To: tutor at python.org
Subject: [Tutor] Reload() in v3?  WAS Re: IDEs
Message-ID: <icr6ml$obn$1 at dough.gmane.org>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
       reply-type=response


"Steven D'Aprano" <steve at pearwood.info> wrote

> The other nine times out of ten *wink* I need to do debugging, and I
> swap tabs and work in my interactive Python interpreter.
>
> import filename  # first time only
> reload(filename)  # all subsequent times

I'm working on the v3 version of my tutor and while testing some
module code I tried to reload the module in IDLE... I got an error:

>>> import os
>>> reload(os)
Traceback (most recent call last):
 File "<pyshell#65>", line 1, in <module>
   reload(os)
NameError: name 'reload' is not defined
>>>

Has reload been removed in V3?
Whats the alternative? Does a repeated import auto-reload?

I'm surprised and confused...

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




------------------------------

Message: 3
Date: Sat, 27 Nov 2010 15:11:53 -0000
From: "Alan Gauld" <alan.gauld at btinternet.com>
To: tutor at python.org
Subject: Re: [Tutor] Reload() in v3?  WAS Re: IDEs
Message-ID: <icr73l$q2f$1 at dough.gmane.org>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
       reply-type=response


"Alan Gauld" <alan.gauld at btinternet.com> wrote
> Has reload been removed in V3?
> Whats the alternative? Does a repeated import auto-reload?
>
> I'm surprised and confused...

Found it, its been moved into the imp module.

You need to import imp and then do

imp.reload(foo)

>>> import os
>>> reload(os)
Traceback (most recent call last):
 File "<pyshell#65>", line 1, in <module>
   reload(os)
NameError: name 'reload' is not defined
>>> import imp
>>> imp.reload(os)
<module 'os' from 'C:\Python31\lib\os.py'>
>>>

I wonder why that was considered "a good idea"?

Alan G.



------------------------------

Message: 4
Date: Sat, 27 Nov 2010 18:12:59 +0100
From: Mac Ryan <quasipedia at gmail.com>
To: tutor at python.org
Subject: Re: [Tutor] Python Exercise
Message-ID: <20101127181259.770ea696 at jabbar>
Content-Type: text/plain; charset=US-ASCII

On Sat, 27 Nov 2010 22:00:03 +0800
Kok Cheng Tan <tkokchen at gmail.com> wrote:

> I created this website for practising python online:
> http://www.pyschools.com. Hope to gather feedback from people here
> who are interesting in teaching and learning python.

Here you go with the first suggestion: remove the need to log in!
(Haven't really watched at the site content, given that I - like 99% of
the Internet users - wouldn't bother to login just to roam around a
site).

Mac.


------------------------------

Message: 5
Date: Sat, 27 Nov 2010 18:44:25 +0100
From: Eike Welk <eike.welk at gmx.net>
To: tutor at python.org
Subject: Re: [Tutor] normalize an array
Message-ID: <201011271845.38868.eike.welk at gmx.net>
Content-Type: Text/Plain;  charset="iso-8859-1"

Hello John!

On Friday 26.11.2010 23:23:51 Peter Otten wrote:
> John wrote:
> > I know this is a simple problem, but I want to do it the most
> > efficient way (that is vectorized...)
> >
> > import numpy as np
> >
> > a = np.array(([1,2,3,4],[1,.2,3,4],[1,22,3,4]))
> > b = np.sum(a,axis=1)
> >
> > for i,elem in enumerate(a):
> >     a[i,:] = elem/b[i]
> >
> > suggestions?
>
> I'm not a numpy expert, but:
>
> (a.transpose()/np.sum(a, axis=1)).transpose()

The underlying feature of Peter's solution is called broadcasting. For a
detailed explanation look at:
http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html


Eike.


------------------------------

Message: 6
Date: Sat, 27 Nov 2010 09:17:21 -0800 (PST)
From: patty at cruzio.com
To: tutor at python.org
Subject: [Tutor] Python Exercise
Message-ID:
       <dc0a0d3334bc5d60c4114867f6b8f4e8.squirrel at cruziomail.cruzio.com>
Content-Type: text/plain;charset=iso-8859-15

Hi - I just wanted to add to Mac's comment.  I don't have Google
mail/gmail and don't want to create a mail account with them.  I was also
wondering if I should just try clicking on links anyway and changed my
mind and exited.

Regards,

Patty




> On Sat, 27 Nov 2010 22:00:03 +0800
> Kok Cheng Tan <tkokchen at gmail.com> wrote:
>
>> I created this website for practising python online:
>> http://www.pyschools.com. Hope to gather feedback from people here
>> who are interesting in teaching and learning python.
>
> Here you go with the first suggestion: remove the need to log in!
> (Haven't really watched at the site content, given that I - like 99% of
> the Internet users - wouldn't bother to login just to roam around a
> site).
>
> Mac.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>




------------------------------

Message: 7
Date: Sat, 27 Nov 2010 10:15:45 -0800
From: "Joel Schwartz" <joel at joelschwartz.com>
To: <tutor at python.org>
Subject: Re: [Tutor] Python Exercise
Message-ID: <007201cb8e5f$1d256b60$6501a8c0 at JLAPTOP>
Content-Type: text/plain;       charset="us-ascii"



> -----Original Message-----
> On Sat, 27 Nov 2010 22:00:03 +0800
> Kok Cheng Tan <tkokchen at gmail.com> wrote:
>
> > I created this website for practising python online:
> > http://www.pyschools.com. Hope to gather feedback from
> people here who
> > are interesting in teaching and learning python.
>
I logged in using my google account and the first page that came up was a
ranking of competitors in the site's Python Tournament. I would recommend
that you bring people to an introductory learning page after their first
sign in (if you keep the sign-in requirement, which I also think is a bad
idea) rather than a competition page--that is, unless you want to intimidate
some (many?) beginning programmers into looking elsewhere.

Joel




------------------------------

Message: 8
Date: Sat, 27 Nov 2010 19:41:41 +0100
From: John <washakie at gmail.com>
To: Eike Welk <eike.welk at gmx.net>
Cc: tutor at python.org
Subject: Re: [Tutor] normalize an array
Message-ID:
       <AANLkTimkNxXbYNJ7fmcPgUOLeVezw7c4VA3-1h5kBM7b at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Thank you both! Broadcasting is a concept I hadn't yet read about, but
knew was important for efficient python programming... thanks for the
link!


On Sat, Nov 27, 2010 at 6:44 PM, Eike Welk <eike.welk at gmx.net> wrote:
> Hello John!
>
> On Friday 26.11.2010 23:23:51 Peter Otten wrote:
>> John wrote:
>> > I know this is a simple problem, but I want to do it the most
>> > efficient way (that is vectorized...)
>> >
>> > import numpy as np
>> >
>> > a = np.array(([1,2,3,4],[1,.2,3,4],[1,22,3,4]))
>> > b = np.sum(a,axis=1)
>> >
>> > for i,elem in enumerate(a):
>> > ? ? a[i,:] = elem/b[i]
>> >
>> > suggestions?
>>
>> I'm not a numpy expert, but:
>>
>> (a.transpose()/np.sum(a, axis=1)).transpose()
>
> The underlying feature of Peter's solution is called broadcasting. For a
> detailed explanation look at:
> http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html
>
>
> Eike.
> _______________________________________________
> Tutor maillist ?- ?Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



--
Configuration
``````````````````````````
Plone 2.5.3-final,
CMF-1.6.4,
Zope (Zope 2.9.7-final, python 2.4.4, linux2),
Python 2.6
PIL 1.1.6
Mailman 2.1.9
Postfix 2.4.5
Procmail v3.22 2001/09/10
Basemap: 1.0
Matplotlib: 1.0.0


------------------------------

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 81, Issue 105
**************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101128/d483d229/attachment-0001.html>


More information about the Tutor mailing list