analitics

Pages

Saturday, August 10, 2013

How to deal with environment variables using python script.

Any OS like Linux, Unix, Windows has environment variables.

Also any variables which must not be committed on a public code can be used in this way.

You can give this variables to your application.

Let's see one simple example about how to do that:

import os
ENV_VAR = os.environ.get("ENV_VAR", None)
if not ENV_VAR:
        print "not ENV_VAR"
if ENV_VAR:
        print "yes ! is ENV_VAR"

Now you can give this ENV_VAR to the script or not. See next...

usertest@home:~$ ENV_VAR=true python demo-env.py 
yes ! is ENV_VAR
usertest@home:~$ python demo-env.py 
not ENV_VAR

With Python 3 on Unix, environment variables are decoded using the file system encoding.

Tuesday, July 30, 2013

The new pygobject come with version 3.9.5 .

GObject is a object system used by GTK+, GStreamer and other libraries.

The new PyGObject 3.9.5 provides a convenient wrapper for use in Python programs when
accessing GObject libraries.

The news come from Simon Feltman - pygtk digest: I am pleased to announce version 3.9.5 of the Python bindings for
GObject. This is the third release of the 3.9.x series which will
eventually result in the stable 3.10 release for GNOME 3.10.

The new release is available from ftp.gnome.org.