Live data from Hacker News

PythonMonk – Learn Python in the browser

pythonmonk.com

1–10 of 50 posts

Re: PythonMonk – Learn Python in the browser

#6
post #3

Tried the test to define unique. Wrote def unique(s): return list(set(s)) and it gave assertion errors. Nice presentation ... but incorrect Python implementation.

Thanks for pointing the mistake. Corrected the tests now.

Solution to that problem is correct. Sets weren't introduced yet.

Re: PythonMonk – Learn Python in the browser

#7
post #3

Tried the test to define unique. Wrote def unique(s): return list(set(s)) and it gave assertion errors. Nice presentation ... but incorrect Python implementation.

maybe you had a typo? or they have corrected this in the meantime? I just tried this problem and it was error free.

def unique(values): """Finds all unique elements of a list.

        >>> unique([])
        []
        >>> unique([1, 2, 1])
        [1, 2]
        >>> unique([1, 2, 1, 3, 4, 2])
        [1, 2, 3, 4]
    """
    # your code here
    return list(set(values))

it also works without the coercion to list. return set(values) is fine.

Re: PythonMonk – Learn Python in the browser

#8
post #2

It is 2013. Why are you teaching Python 2?

while I agree that we should be more proactive about migrating to Python 3, if you're trying to be pragmatic it is most useful to teach Python 2.7 since that is the most widely used version.

Python 3, in 2013, is not lacking in pragmatism. It's not new, or experimental. Someone just learning today is going to have to immediately turn around and relearn things because they started out with an old version.

Re: PythonMonk – Learn Python in the browser

#9
post #8

Earlier quoted context omitted.

while I agree that we should be more proactive about migrating to Python 3, if you're trying to be pragmatic it is most useful to teach Python 2.7 since that is the most widely used version.

Python 3, in 2013, is not lacking in pragmatism. It's not new, or experimental. Someone just learning today is going to have to immediately turn around and relearn things because they started out with an old version.

I'm teach Python professionally. People come to learn Python so that they can go back and use it at their work place. And almost all Python installations in productions are in Python 2. I'm sure it is going to change soon once Linux distributions make Python 3 their default version.

P.S. I'm the author of Python Primer on pythonmonk.com

Re: PythonMonk – Learn Python in the browser

#10
post #8

Earlier quoted context omitted.

while I agree that we should be more proactive about migrating to Python 3, if you're trying to be pragmatic it is most useful to teach Python 2.7 since that is the most widely used version.

Python 3, in 2013, is not lacking in pragmatism. It's not new, or experimental. Someone just learning today is going to have to immediately turn around and relearn things because they started out with an old version.

I don't know anyone who uses Python 3 in production. It's still seen as an experimental implementation.
Post reply on HN