2019年11月26日 星期二

Set up Notepad++ and NppExec to print unicode characters from python (轉貼)

Set up Notepad++ and NppExec to print unicode characters from python:
Add env_set PYTHONIOENCODING=utf-8

詳參:https://stackoverflow.com/questions/18404546/set-up-notepad-and-nppexec-to-print-unicode-characters-from-python

2019年11月1日 星期五

Cython (cdef classes)

如果外部要存取成員,記得成員要宣告為public, e.g.

from sin_of_square cimport Function

cdef class WaveFunction(Function):

    # Not available in Python-space:
    cdef double offset

    # Available in Python-space:
    cdef public double freq

    # Available in Python-space, but only for reading:
    cdef readonly double scale

    # Available in Python-space:
    @property
    def period(self):
        return 1.0 / self.freq

    @period.setter
    def period(self, value):
        self.freq = 1.0 / value