Array

Interacting with the IronPython Environment

Must Read

Android Software Development Kit

Android provides great mobile tooling for Java developers to use along with Eclipse or similar editors to write native...

Consolidate Your Debts With Home Equity Loans

Your home is your biggest asset. It does not just provide you shelter; it also comes to your aid...

Banks Freezing Home Equity Line of Credit – Is Your Equity Lost

What would you do if your bank called to tell you that your home equity line of credit had...

Affiliate Marketing Guide – The benefits of being an affiliate marketer

Affiliate Marketing has almost no production costs. It is therefore great for people who want to work from home...

13 Exceptional Tips to Effectively Promote Your Business on Facebook

Post Content That is Informative and EngagingCreate content that encourages click-throughs or boosts discussion. Unless they're interesting enough to...

Thoughts on Paying For College Beyond Just Loans

You've made it through all of it - high school, prom, applications - and now you have finally been...
Admin
test

At this point, you know how to create basic functions; determine which modules, objects, and functions are available for use; and import external modules as needed. The last major basic task you need to know about is interacting with the IronPython environment. Knowing this information will help you create better applications. The following sections provide an overview of many environmental needs you’ll have when using IronPython.

Obtaining Version Information

You may find a need to programmatically process the version information for a particular IronPython installation. Perhaps your application requires a newer version of IronPython. You can obtain this information programmatically using the sys.version attribute. The following  code shows a simple method for checking the IronPython version.

import sys
print sys.version

Of course, your concern may revolve around Windows. In this case, you can use sys.getwindowsversion() to obtain the information you need. The output is an array containing the following five values:

  • Major version
  • Minor version
  • Build
  • Platform
  • String describing installation (such as the current service pack)

Changing sys.path Values

The sys.path attribute is an array containing paths to various parts of IronPython. You can use sys.path to locate or modify the path for IronPython. For example, if you type print sys .path[0] and press Enter, you obtain the path for the currently executing application. The standard list provides these locations:

  • Executing application path (blank if the interpreter can’t determine the location)
  • IronPython library directory
  • IronPython DLL directory
  • IronPython executable directory
  • IronPython site-packages directory

The interpreter always searches these paths, looking for any modules you want to import or other resources your application requires. You can add or remove entries as necessary.

Obtaining Command Line Arguments

An application can receive command line arguments when it executes and then processes those arguments, just as you would do with any other application. IronPython uses a similar approach to that of C and C++. You use the sys.argv array to obtain a list of the arguments passed at the command line. For example, if you type print sys.argv[0], you see the first command line argument passed to the application. The sys.argv array is blank when you start the interpreter without specifying a module to execute.

If you’re getting the idea that loading the sys module provides all kinds of power for your application, you’re right. You can see a complete list of the sys module functions and attributes at http://docs.python.org/library/sys.html. Of course, you’ll see additional examples as the book progresses.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest News

Digital Marketing for Beginners

Digital marketing for starter, Let to basic learning about connecting with your audience in the right place...

What are 7 things poor people do that the rich don’t?

1. poor people watch TV in which people read books how many hours you spend in front of the TV and when...

Top 18 best small business ideas for beginners starting

A small business can be frightening and requires plenty of careful planning there are many small business ideas which can be beneficial...

Summer that makes you happy

We saw were already here I've been thinking about some of the things. I used to do with my husband even though...

4 Point to helpful tips specifically for caregivers

What you need to take a vacation. I know it sounds impossible creative and try to make it work for you almost...

More Articles Like This