Jump to content

Object Persistence in LabPython


Recommended Posts

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

 

 

 

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.