[docs] [issue36345] Deprecate Tools/scripts/serve.py in favour of python -m http.server -d

Berker Peksag report at bugs.python.org
Fri May 10 04:00:27 EDT 2019

Berker Peksag <berker.peksag at gmail.com> added the comment:

> I looked at other examples: they are nice but far from a "real application".

You can use the same argument for pretty much every example in the stdlib documentation :)

wsgiref is a low level module, users should use projects like WebOb instead. Also, a complete example would need to contain basic routing and middleware support (which is not easy to implement correctly)

> Would you mind to elaborate? I don't understand what you mean by "naming convention" here, sorry.

For example, the response() callable in the example is explicitly documented as start_response() in PEP 3333:


You can read PEP 3333 for more details.

> Do you mean that app() must not return FileWrapper? How do you return file content in that case?
> Maybe FileWrapper API should be clarified? It's surprising to read Python 3.8 mentioning compatibility with Python 2.1 :-)

The whole point of the API was to support both __getitem__ and __iter__ protocols at the same time without breaking user code. I've already deprecated the support for __getitem__ protocol (84a13fbda0d79789e3c9efcc9f64752261ce1e8d) because it wasn't working as expected (it ignores its 'index' argument)

Its only valid use case is to read a file chunk by chunk by using its blksize argument, but there are much better ways to achieve the same thing (use os.sendfile() or nginx :))

> Which kind of exceptions do you expect? The example checks if the file exists for example.

I'm talking about exceptions that can be raised by the application code, such as the one that I've mentioned (i.e. mimetypes) in my earlier comment.

Sorry, but it's not really a good example to put into documentation and it would be much better if we could save our bikeshedding bandwidth to other issues :)


Python tracker <report at bugs.python.org>

More information about the docs mailing list