asyncio: What is the difference between tasks, futures, and coroutines?

Dave Angel davea at davea.name
Fri May 8 07:53:21 EDT 2015


On 05/08/2015 02:42 AM, Chris Angelico wrote:
> On Fri, May 8, 2015 at 4:36 PM, Rustom Mody <rustompmody at gmail.com> wrote:
>> On Friday, May 8, 2015 at 10:39:38 AM UTC+5:30, Chris Angelico wrote:
>>> Why have the concept of a procedure?
>>
>> On Friday, Chris Angelico ALSO wrote:
>>> With print(), you have a conceptual procedure...
>>
>> So which do you want to stand by?
>
> A procedure, in Python, is simply a function which returns None.
> That's all. It's not any sort of special concept. It doesn't need to
> be taught. If your students are getting confused by it, stop teaching
> it!

One thing newbies get tripped up by is having some path through their 
code that doesn't explicitly return.  And in Python that path therefore 
returns None.  It's most commonly confusing when there are nested ifs, 
and one of the "inner ifs" doesn't have an else clause.

Anyway, it's marginally more useful to that newbie if the compiler would 
produce an error instead of later seeing a runtime error due to an 
unexpected None result.

I don't think Python would be improved by detecting such a condition and 
reporting on it.  That's a job for a linter, or a style guide program.

No different than the compile time checks for variable type that most 
languages impose.  They don't belong in Python.

-- 
DaveA



More information about the Python-list mailing list