Question: is it possible with pure JS to paste selected text into specified textarea? In my case, I want to select text in one of the textareas and when ctrl & A is pressed, selected text would paste into last (V1) textarea.

I have found similar case (<https://jsfiddle.net/QenBV/1/>), but it's only made for 1 input textarea, but I have large number of textareas.

```js
        function Addkey(e) {
            if (e.ctrlKey && e.keyCode == 65) {
                e.preventDefault();
                    document.execCommand("copy");
            }
        }

        document.addEventListener('keydown', Addkey, false);
```

```html
<textarea>Text1</textarea><br/>
<textarea>Text2</textarea><br/>
<textarea>Text3</textarea><br/>

<p></p>
<hr/>
<p></p>

<textarea id="V1"></textarea><br/>
```

Answer: 
That's simply not how the API is designed.

From [the definition of `object.__str__(self)`](https://docs.python.org/3/reference/datamodel.html#object.__str__):

> 
> Called by str(object) and the built-in functions format() and print() to compute the “informal” or nicely printable string representation of an object.
> 
> 
> 

Beyond those explicitly listed instances, there's no reason to expect that implicit conversion will occur.

And from [the definition of `io.TextIOBase.write(s)`](https://docs.python.org/3/library/io.html#io.TextIOBase.write):

> 
> Write the string s to the stream and return the number of characters written.
> 
> 
> 

So it's explicitly expecting a string, which is confirmed by the error message.

The simplest solution is to perform the conversion by using the `str()` function before passing it `write()` as an argument:

```py
fl.write(str(dan))

```
> 
> When I try to print it, everything goes fine, but writing `Person` to file fails
> 
> 
> 

Why not use `print` then?

```
print(dan, file=fl)

```

That will behave exactly like the print you are expecting (including a trailing newline), but write to a file instead of stdout.