Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Cython Programming (Second Edition) - Second Edition

You're reading from  Learning Cython Programming (Second Edition) - Second Edition

Product type Book
Published in Feb 2016
Publisher Packt
ISBN-13 9781783551675
Pages 110 pages
Edition 2nd Edition
Languages
Author (1):
Philip Herron Philip Herron
Profile icon Philip Herron

Implementing a Tmux command


One caveat with Cython is that we cannot statically initialize structs like we can in C, so we need to make a hook so that we can initialize cmd_entry on Python startup:

cimport cmdpython

cdef public cmd_entry cmd_entry_python

With this, we now have a public declaration of cmd_entry_python, which we will initialize in a startup hook as follows:

cdef public void tmux_init_cython () with gil:
    cmd_entry_python.name = "python"
    cmd_entry_python.alias = "py"
    cmd_entry_python.args_template = ""
    cmd_entry_python.args_lower = 0
    cmd_entry_python.args_upper = 0
    cmd_entry_python.usage = "python usage..."
    cmd_entry_python.flags = 0
    #cmd_entry_python.key_binding = NULL
    #cmd_entry_python.check = NULL
    cmd_entry_python.execc = python_exec

Remember that because we declared this in the top level, we know it's on the heap and don't need to declare any memory to the structure, which is very handy for us. You've seen struct access before; the function...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}