[Tutor] Hello! Questions

Alan Gauld alan.gauld at btinternet.com
Wed Feb 17 05:13:56 EST 2016

On 16/02/16 20:19, Marco Soldavini wrote:

> Is this the right place to knock down problems one by one?

Yes, although we are limited in scope to Python language
and standard library so for anything specific to openopc
you will probably need to ask on its support forum/list.

> I already tested this with some values of various kind (real, boolean,
> strings). Basically each tag is read with a fixed sample time from a stream
> opened in OPC and recorded onto an array in python.

Please be precise when describing data types.
Python does have an array module but its more usual to
use the built-in list type for this kind of thing.

> Is it better I explain you the main picture? I am not here for spoon
> feeding but just tips and suggestion and maybe solution to particular
> problems I might find on the track.

Yes, that's fine. Your description so far seems sufficient,
if we need more context later we will ask for it.

> The lib I am using is openopc.
> My first question is about data types, data structures in general and how
> to organize an efficient loop for recording data.

> while (stop condition false)
>    read data
>    write data into local array or something
>    wait sample time

That's a good start. What is the question?
You say you know how to read data fro openopc, so the
first loop line should be fine.
Storing into a list involves the append method:


and the wait will probably be openopc specific
but if not you can use the time.sleep() function.

If you have anything more specific please ask.
Post your code as you go.
Include the full error text if you get any.
And tell us the Python version and OS too.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list