2.9.5. Explanation of less familiar Python statements from Topic 5 – SSL

retval += linebuf[:nlindex + len(newlinestring)]

Found in the basic-wrap.py program on pages 328-329. This program make extensive use of string slices. The slice (for both strings and lists) is a very powerful mechanism, that is probably under appreciated by beginning programmers. In this program, slices are used with a buffer to select either the initial or ending part of the buffer relative an index.

See also

Previous topic

2.9.4. Explanation of less familiar Python statements from Topic 4 – E-mail

Next topic

2.9.6. Explanation of less familiar Python statements from Topic 6 – Servers

This Page