Code Snippets
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Wed Nov 1 16:33:27 EDT 2017
On 11/01/2017 06:25 PM, Stefan Ram wrote:
> import random
> ...
> random.random()
>
> Now, the user has to cut the import, paste it to the top
> of his code, then go back to the list of snippets, find
> the same snippet again, copy the expression, go to his code,
> then find the point where he wanted to insert the snippet again,
> and finally insert the snippet. And still there now is a
> risk of name collisions. So, it seems to me that __import__
> is just so much better!
..or suggest them to use an IDE instead? For instance in PyCharm you can type:
random.random() (squiggle appears under random)
<Alt-Enter>
(it suggests: Import This name) <Enter>
(it suggests: from random) <Enter>
done, an import random has been added at the top of my module.
Irmen
More information about the Python-list
mailing list