KxSystems / pyq

PyQ — Python for kdb+
http://code.kx.com/q/interfaces
Apache License 2.0
190 stars 49 forks source link

Multiple lines of q codes in Jupyter #66

Closed jljs closed 6 years ago

jljs commented 6 years ago

Questions

Which operating system are you using (if Linux, please provide flavour of it, i.e RedHat, CentOS or Ubuntu), is it 32-bit, or 64-bit?

Red Hat Enterprise Linux Server release 6.9 (Santiago)

Which version of PyQ are you running? You can use pyq --versions or pip list | grep pyq.

PyQ 4.1.3 Which version of kdb+ are you using, is it 32-bit or 64-bit? KDB+ 3.4 (2016.10.10) l64 If on 64-bit, is your QLIC set? Please provide output env | grep QLIC on linux/macOS, or set|grep QLIC on Windows. QLIC=/opt/kx/3.4 Did you use virtual environment to install PyQ? If not, why?

Yes with Anaconda

Where is your QHOME? Please provide output env | grep QHOME on linux/macOS, or set|grep QHOME on Windows.

QHOME=/opt/kx/3.4 Do you use Conda? If so, what version?

Yes. conda 3.14.1

Hi,

What would be the correct syntax if I wish to write multiple lines of q codes (e.g. defining a q function that spam multiple lines) in Jupyter? %q seems to parse single line at a time only.

For example the function definition below will not work in Jupyter.

%q .funCust:{[a] %q b:a+1; %q :b; %q };

Thanks

Jeffrey

antipisa commented 6 years ago

Use %%q for inline q.

jljs commented 6 years ago

Do you mean %%q .funCust:{[a] b:a+1; :b; };

antipisa commented 6 years ago

Yes, but the last bracket needs to be indented by one space. %%q is the multi in line function you are looking for.

See section 1.4.5: https://media.readthedocs.org/pdf/pyq/latest/pyq.pdf