PythonMonk – Learn Python in the browser
pythonmonk.com
PythonMonk – Learn Python in the browser
1–10 of 50 posts
Re: PythonMonk – Learn Python in the browser
#2Re: PythonMonk – Learn Python in the browser
#3 def unique(s):
return list(set(s))
and it gave assertion errors. Nice presentation ... but incorrect Python implementation.Re: PythonMonk – Learn Python in the browser
#4Re: PythonMonk – Learn Python in the browser
#5It is 2013. Why are you teaching Python 2?
Re: PythonMonk – Learn Python in the browser
#6Tried the test to define unique. Wrote def unique(s): return list(set(s)) and it gave assertion errors. Nice presentation ... but incorrect Python implementation.
Solution to that problem is correct. Sets weren't introduced yet.
Re: PythonMonk – Learn Python in the browser
#7Tried the test to define unique. Wrote def unique(s): return list(set(s)) and it gave assertion errors. Nice presentation ... but incorrect Python implementation.
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
#8It 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.
Re: PythonMonk – Learn Python in the browser
#9Earlier 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.
P.S. I'm the author of Python Primer on pythonmonk.com
Re: PythonMonk – Learn Python in the browser
#10Earlier 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.