Question: I want to Converted a Double to a string.
And display only the decimal places.

On this way:

```
Double: 123.465
String: 46

Double: 1123.465
String: 46

Double: 123.46555987
String: 46

```

Now is my question how can i do that and what is the best way?

Answer: 
```
def upload_handler(source):
    # this is creating a temp file and returning an os handle and name
    fd, filepath = tempfile.mkstemp(prefix=source.name, dir=MEDIA_ROOT)
    # this next line just clears the file you just made (which is already empty)
    with open(filepath, 'wb') as dest: 
        # this is a strange way to get a fobj to copy :)
        shutil.copyfileobj(source, dest)
        return MEDIA_URL + basename(dest.name)

```

prefix and suffix do just that, so if you don't want your filename to begin or end with the temporary characters, you need to use both prefix **and** suffix. For example, 

```
name = os.path.basename(source.name)
prefix, suffix = os.path.splitext(name)
_, filepath = tempfile.mkstemp(prefix=prefix, suffix=suffix, dir=MEDIA_ROOT)

```

but it would be better if you use [`tempfile.NamedTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile), as then the file-like object is returned (so you don't have to create fobj from the filename and the temp file is deleted by default when done). 

```
fobj, _ = tempfile.NamedTemporaryFile(prefix=prefix, suffix=suffix, dir=MEDIA_ROOT)
shutil.copyfileobj(source, fobj)

```
The name is random-generated because it's the purpose of `tempfile.mkstemp`. The file with that name is created because it's how `tempfile.mkstemp` works. It is also opened and the file descriptor is returned to you in `fd` which you ignore. You don't seem to understand how `tempfile.mkstemp` should be used and you probably need to use something else instead.