yieldandyield fromThis blog post gives a good introduction of how to use
yieldandyield fromin Python.add local path with conda
Similar to a normal IDE where a project root is required to import local modules, with emacs and lsp, I first need to include the path in the environment. To check current local paths, open a Python interpreter and use
1 2 3
import sys for p in sys.path: print(p)
To add a path with conda, use
conda develop <path>inside the environment, note that redundant paths should be avoided, e.g., if both~/src/and~/src/moduleaare present in the paths, there could be a module resolvation issue. After adding the path, need to activate conda environment and ananconda mode in emacs. To remove a path, useconda develop --uninstall <path>.pdb
pdbis a python debugger in emacs, to startpdbI first need to be in the buffer of the specific file, the keywords are similar to gdb:sgoes into a function,nskips entering inner functions,blists current breakpoints andb <line-number>set a breakpoint at the given line,ccontinues the execution until reaching a breakpoint. Sometimes, there is error in the python interpreter but works fine inpdb, restart the python interpreter process would likely solve the problem.
Python hints
This post is licensed under CC BY 4.0 by the author.