what does 'for _ in range()' mean?

Skip Montanaro skip at pobox.com
Fri Jul 30 10:08:24 EDT 2004


    Heike> Dave Benjamin <ramen at lackingtalent.com> writes:
    >> In Python, it's possible to use _ multiple times in the same expression,

    Heike> There is, however, one objection to the use of _ as a placeholder
    Heike> for a dummy variable: it is used by the gettext module.  So if a
    Heike> program may be subject to internationalization, it is advisable
    Heike> to keep this name reserved, or you may run into problems.

Only if you use it as both a placeholder variable and call it as a function
within the same function, or have the misfortune to declare

    global _

in some function where it's used as a placeholder in a module whose other
functions call _("some string").

Skip



More information about the Python-list mailing list