[Django] #28623: Docs: handle_uploaded_file(f) .. what is "f"?

11 views
Skip to first unread message

Django

unread,
Sep 21, 2017, 6:35:48 AM9/21/17
to django-...@googlegroups.com
#28623: Docs: handle_uploaded_file(f) .. what is "f"?
------------------------------------------+------------------------
Reporter: Thomas Güttler | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
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 started to stutter.

Why?

Because: What is "f"?

A more verbose name would be great.

--
Ticket URL: <https://code.djangoproject.com/ticket/28623>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 21, 2017, 6:36:45 AM9/21/17
to django-...@googlegroups.com
#28623: Docs: handle_uploaded_file(f) .. what is "f"?
--------------------------------+--------------------------------------

Reporter: Thomas Güttler | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Description changed by Thomas Güttler:

Old description:

> 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 started to stutter.
>
> Why?
>
> Because: What is "f"?
>
> A more verbose name would be great.

New description:

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.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28623#comment:1>

Django

unread,
Sep 25, 2017, 12:36:26 PM9/25/17
to django-...@googlegroups.com
#28623: Docs: handle_uploaded_file(f) .. what is "f"?
-------------------------------------+-------------------------------------

Reporter: Thomas Güttler | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* type: Uncategorized => Cleanup/optimization
* component: Uncategorized => Documentation


Comment:

Look at the usage code above:
`handle_uploaded_file(request.FILES['file'])`. If you click on the docs
for `request.FILES`, you'll see, "Each value in `FILES` is an
`UploadedFile`." I'm not sure a more verbose name provides much benefit.
If you read [https://docs.python.org/3/tutorial/inputoutput.html the
Python docs for files], you'll see that `f` is a common variable name,
probably to avoid clashing with the Python built-in `file`.

--
Ticket URL: <https://code.djangoproject.com/ticket/28623#comment:2>

Django

unread,
Sep 26, 2017, 7:25:59 PM9/26/17
to django-...@googlegroups.com
#28623: Docs: handle_uploaded_file(f) .. what is "f"?
-------------------------------------+-------------------------------------

Reporter: Thomas Güttler | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: Documentation | Version: 1.11
Severity: Normal | Resolution:
| worksforme

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => worksforme


--
Ticket URL: <https://code.djangoproject.com/ticket/28623#comment:3>

Reply all
Reply to author
Forward
0 new messages