Is this a "gotcha" in Python?

Chris Angelico rosuav at gmail.com
Sat Apr 20 16:16:30 EDT 2019


On Sun, Apr 21, 2019 at 2:14 AM Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:
>         Only use short (single character) names for items that only exist as
> loop control, and are not rebound within the loop, nor used outside of the
> scope of that loop (but can be reused in another subsequent loop
> control)...
>
> >>> for l in range(50):
> ...     print l,
> ...
> 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
> 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
> >>>
>

Be aware that this is using an old form of Python syntax, not
supported by current versions. To try this example in a modern version
of Python, write it like this:

for l in range(50):
    print(l, end=" ")

ChrisA


More information about the Python-list mailing list