cgiustini Posted July 17, 2013 Report Posted July 17, 2013 Hi, I have a question about LabPython. Suppose I am given a Python script that contains class definitions. I want to use LabPython to initialize such objects and manipulate them. Is there a way of achieving object persistence with LabPython? Here was my idea: I could create a wrapper Python script around the script with the class definitions. Let's say my class definition script code/pseudocode looks like this: class d bark_volume = 0 def bark(self) self.bark_volume = self.bark_volume+1 Now my wrapper could like this: i = 0; if(i == 0) import stuff if(i == 1) a = dog if(i==2) bark_volume(a) By changing the input variable i, I can import stuff, initialize an object of type dog, and then call methods on that class. By changing the variable i and making successive calls to the wrapper script from LabPython, I might be able to manipulate the object of type dog from the LabVIEW environment. Does this make any sense? Thanks, Carlo Quote
cgiustini Posted July 18, 2013 Author Report Posted July 18, 2013 I realize that I made some typos here. Now my wrapper could like this --> Now my wrapper could look like this For my wrapper script, the correct code for case if(i==2) is: if(i==2) bark(a) Quote
Rolf Kalbermatter Posted July 18, 2013 Report Posted July 18, 2013 This does not sound like any LabPython specific issue but a simple basic Python problem. Please refer to a Python discussion forum for such questions. They can be of a lot more assistance to you than I could. When creating LabPython about 15 years ago I knew Python much more from the embedding API than anything else and was just proficient enough in Python itself to write some simple scripts to test LabPython. Haven't used Python in any form and flavor since. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.