Opened 8 years ago
Closed 8 years ago
#28623 closed Cleanup/optimization (worksforme)
Docs: handle_uploaded_file(f) .. what is "f"?
| Reported by: | Thomas Güttler | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 1.11 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
https://docs.djangoproject.com/en/1.11/topics/http/file-uploads/
def handle_uploaded_file(f):
with open('some/file/name.txt', 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
I talked with an other developer about this above code.
I can create a pull request.
It would be nice if you give me a matching name for this variable.
I started to stutter.
Why?
Because: What is "f"?
A more verbose name would be great.
Change History (3)
comment:1 by , 8 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 8 years ago
| Component: | Uncategorized → Documentation |
|---|---|
| Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 8 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Look at the usage code above:
handle_uploaded_file(request.FILES['file']). If you click on the docs forrequest.FILES, you'll see, "Each value inFILESis anUploadedFile." I'm not sure a more verbose name provides much benefit. If you read the Python docs for files, you'll see thatfis a common variable name, probably to avoid clashing with the Python built-infile. Also, the namehandle_uploaded_fileimplies that the argument (the thing being handled) is an uploaded file.