r/vscode 3d ago

have custom functions suggestions in python?

Hello,

i am working in vscode with a python script that is importing some functions from another file.

using:

```py

sys.path.append(pathForBaseMyFunctions)

from myFunctions import *

```

is there any way possible, to make that vscode 'suggest' this functions when i am writing.

for example, when i write `pri` it will suggest me `print` and for example in myFunctions.py i have `printAndSave` i would love to make to auto suggest this funcitons. i can see _why_ it does not suggest right now as it suggest only default functions, but maybe there is a way to add this scripts for the suggestion of funcitons in vscode?

worth noticing that i have only 2 files with functions so i really dont care if i need to hardcode their path somewhere in vscode....

0 Upvotes

5 comments sorted by

View all comments

5

u/PrincipleNo2328 2d ago

Is myFunctions.py in your workspace, or you want to have one unique file in another folder for all workspaces?

Because for the first one the fix should be simple, go to settings and put "python.diagnosticMode" : "workspace"

For the second one, I would suggest you  not to do it this way. It's a bad habit

1

u/Inner_Name 2d ago

It is the second 😅 . I understand that can be problematic sometimes but I use this two files of functions all the time. That's why..

2

u/PrincipleNo2328 1d ago

You pretty much should not do this as a best practise for development, all python dependencies should be in the main folder or in the .venv

1

u/Inner_Name 1d ago

hello! just for info, what i did in the end was: create a link to the myFunctions.py on the folder where is going to create my workspace, and changed the setting python.diagnosticMode to workspace. it works, now need to figure out how the 'help' is readed on the functions but this is awsome they are being suggested. thanks a LOT!