0
# Step 1: Download the data.
url = 'http://mattmahoney.net/dc/'


def maybe_download(filename, expected_bytes):
  """Download a file if not present, and make sure it's the right size."""
  if not os.path.exists(filename):
    filename, _ = urllib.request.urlretrieve(url + filename, filename)
  statinfo = os.stat(filename)

In the above, what does filename, _ refer to? The second underscore especially.

Ry-
  • 218,210
  • 55
  • 464
  • 476
Beverlie
  • 461
  • 1
  • 6
  • 19

1 Answers1

2

It’s a convention for an ignored value. _ is a valid variable name like any other, but the writer’s intent is to say “I’m unpacking a two-value tuple and only using the first value”.

Ry-
  • 218,210
  • 55
  • 464
  • 476