OPC and Matrikon

OPC OPC is a software interface standard that allows Windows programs to communicate with industrial hardware devices. OPC is implemented in server/client pairs. The OPC server is a software program that converts the hardware communication protocol used by a PLC into the OPC protocol. The OPC client software is any program that needs to connect […]

pywinservice, running a simple Python script as a windows service

pywinservice, running a simple Python script as a windows service Code: https://github.com/spawnmarvel/pywinservice Make a virtualenv, store your code there. Make a run.py file, in that file you can start / call a database, a webcrawler, http, mail or whatever code you want to execute. When you are done with coding your scripts, test this: Make […]

Django database API foreign key 102

https://docs.djangoproject.com/en/2.0/topics/db/queries/   Our models have now changed and a new model has been added to e-lo. In RawText, we store the input, in BlobText we store the functions from TextBlob lib. If we remove the instance from the first table, we also need to remove it from the second. Ref on_delete = models.CASCADE Lets add […]

Leviathan Thomas Hobbes

http://www.sparknotes.com/philosophy/leviathan/summary/ Leviathan rigorously argues that civil peace and social unity are best achieved by the establishment of a commonwealth through social contract. Hobbes’s ideal commonwealth is ruled by a sovereign power responsible for protecting the security of the commonwealth and granted absolute authority to ensure the common defense. In his introduction, Hobbes describes this commonwealth […]

Django database API migrations and models 101

Django API Once you’ve created your data models, Django automatically gives you a database-abstraction API that lets you create, retrieve, update and delete objects. This document explains how to use this API. Refer to the data model reference for full details of all the various model lookup options. https://docs.djangoproject.com/en/2.0/topics/db/queries/ So our testmodel is a simple […]

Python doc 3.4 Looping

enumerate(): Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. The __next__() method of the iterator returned by enumerate() returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over iterable. zip(): Make an iterator that aggregates elements […]

Python doc 3.4 Dictionaries

https://docs.python.org/3.5/tutorial/datastructures.html Another useful data type built into Python is the dictionary (see Mapping Types — dict). Dictionaries are sometimes found in other languages as “associative memories” or “associative arrays”. Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always […]

Python doc 3.4 Tuples and Sequences

https://docs.python.org/3.5/tutorial/datastructures.html A tuple consists of a number of values separated by commas, for instance: On output tuples are always enclosed in parentheses, so that nested tuples are interpreted correctly; they may be input with or without surrounding parentheses, although often parentheses are necessary anyway (if the tuple is part of a larger expression). It is […]

Python doc 3.4 List comprehensions

https://docs.python.org/3.5/tutorial/datastructures.html List comprehensions provide a concise way to create lists. Common applications are to make new lists where each element is the result of some operations applied to each member of another sequence or iterable, or to create a subsequence of those elements that satisfy a certain condition. A list comprehension consists of brackets containing […]

Python doc 3.4 Using Lists as Stacks and Queues 103

https://docs.python.org/3.5/tutorial/datastructures.html The list methods make it very easy to use a list as a stack, where the last element added is the first element retrieved (“last-in, first-out”). To add an item to the top of the stack, use append(). To retrieve an item from the top of the stack, use pop() without an explicit index. […]