Esempio n. 1
0
def threadFunction():
    for i in range( 100 ):
        SampleModule.myCppFunction( i )
Esempio n. 2
0
import sys
import math

sys.path.append("./bin")

import SampleModule as m

print("\n======= C++ Function vectorCumulativeSum ==========")

xs = [15.6, 8.51, 9.35, 10.6, 87.1]
ys = m.vectorCumulativeSum(xs)

print("xs = ", xs)
print("ys = ", ys)

print("\n======= C++  Function Tabulate1 ========")

m.tabulate1(-20.0, 10, 2.5, lambda x: x * x  - 4 * x + 10.5)




Esempio n. 3
0
#         Author: Kevin Harris
#  Last Modified: 04/29/05
#    Description: 
#------------------------------------------------------------------------------

import SampleModule
import threading
import time

#------------------------------------------------------------------------------
# Define a function and set it as a call-back so the application can call 
# into this script.
#------------------------------------------------------------------------------

def myPythonFunction( n ):
    print ("Main thread   - Application called myPythonFunction and passed: " + str( n ))

SampleModule.setCallback( myPythonFunction );

#------------------------------------------------------------------------------
# Define a function which will run in a separate Python thread.
#------------------------------------------------------------------------------

def threadFunction():
    for i in range( 100 ):
        SampleModule.myCppFunction( i )
	#time.sleep( 0.1 )

myThread = threading.Thread( target=threadFunction )
myThread.start()
Esempio n. 4
0
# **********---- Modules
# A module is a file containing Python definitions and statements. The file name is the
# module name with the suffix .py appended. Within a module, the module’s name (as a string)
# is available as the value of the global variable __name__.
# Every python file you create can be used as module
# The syntax to use a python file as module is import pythonfilename
import SampleModule
x = SampleModule.funNumbers(300)
print("printing the result of Fibonacci from an external file", x)
print("\n" * 2)

# Every python file we write has an global variable __name__ with value which sets itself to the filename
# Lets check for the SampleModule
print("__name__ of SampleModule is: ", SampleModule.__name__)
print("\n" * 2)

# By using modules you can call methods, classes, variables from the desired module
# If you are using a function frequently you can assign the function to a variable
y = SampleModule.funNumbers
print(
    "if you are using a function frequently you can assign the function to a variable"
)
print(y(400))
print("\n" * 2)

# Note: Modules are executed the first time the module name is encountered in an import statement
# Each Module has it its own private symbol table, which is used as the
# global symbol table by all functions defined in the module.
# Thus, the author of a module can use global variables in the module without worrying about
# accidental clashes with a user’s global variables.
# If you ever want to use the variables used in the module, you can use them by