Menu

Libraries and Functions

James Waldby

Prev: Auxiliary variables
Next: Re: qput,
qini,
qwin,
qese

Libraries and Functions provided to user code

During startup, qenqote imports modules datetime, re, subprocess, and sys into the user-execution namespace. Note that code snippets in qenqote scripts can also import modules. It is common sense to do such imports in top-level <def>s rather than button-level. It also makes sense to put lengthy or frequently re-used code into modules that you then can import into qenqote scripts. The Python modules tutorial tells how to do so.

In v0 qenqote, user variables and functions defined outside function scope can be accessed in other user code and functions. However, apparently due to binding issues global apparently does not function in user code. Thus, qini(), for example, returns its results as a tuple, instead of as global variables. This issue may be resolved in a future release.

If you prefer modules other than datetime, re, subprocess, and sys to be automatically available to user code, edit the line after # Initialize userspace near the end of qenqote. If you have well-debugged code being used in many scripts, you may wish to modify qenqote to import your code, in the same way that qenqote imports qput, qini, qwin, qese, qSetClippy from qenqoteUserInit.py.

The initialization just mentioned makes four functions available to in user-
defined code:

  • qput(s) -- Write s to clipboard
  • qini(i,f) -- Read clipboard & compute qi,qf,qv,qt,qu
  • qwin(n) -- Show result if n&2, Show-globals if n&4
  • qese(w,s,c) -- Create w forms for 'Treat URL' menu

Details follow, in qput,
qini,
qwin, and
qese

Prev: Auxiliary variables