Contents

From IronPython Cookbook

(Difference between revisions)
(Network Protocols)
 
(23 intermediate revisions not shown)
Line 6: Line 6:
For more information and resources, see the [[Useful Links]] page.
For more information and resources, see the [[Useful Links]] page.
-
===Downloads===
 
-
You can download binaries and sources of IronPython 1.1.2, 2.0, 2.6 and FePy (IronPython Community Edition) from:
 
-
 
-
* The [[Downloads]] page
 
===Adding Entries===  
===Adding Entries===  
Line 20: Line 16:
Please note that for long examples and articles it is acceptable to link to external articles or blog entries. For shorter examples, please post them here on the Wiki.
Please note that for long examples and articles it is acceptable to link to external articles or blog entries. For shorter examples, please post them here on the Wiki.
 +
All pages: http://www.ironpython.info/index.php/Special:AllPages
===Core Concepts===
===Core Concepts===
* [[IronPython]]
* [[IronPython]]
-
* [[FePy: The IronPython Community Edition]]
 
* [[The DLR: Dynamic Language Runtime]]
* [[The DLR: Dynamic Language Runtime]]
* [[The .NET Framework]]
* [[The .NET Framework]]
Line 47: Line 43:
===Pro IronPython===
===Pro IronPython===
-
* [http://www.apress.com/book/view/1430219629/ Pro IronPython] Book from APress (written by Alan Harris)
+
* [http://www.amazon.com/gp/product/1430219629?ie=UTF8&tag=voidspace-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=1430219629 Pro IronPython] Book from APress (written by Alan Harris)
==Contents==
==Contents==
===Getting Started===
===Getting Started===
 +
 +
* [http://www.voidspace.org.uk/ironpython/embedding.shtml Getting Started with IronPython]
 +
* [http://www.voidspace.org.uk/ironpython/python-for-programmers.shtml Python for .NET Programmers]
* [[Interactive Interpreter]]
* [[Interactive Interpreter]]
* [[Using the Python Standard Library]]
* [[Using the Python Standard Library]]
Line 57: Line 56:
* [http://wiki.python.org/moin/SimplePrograms Simple Python Examples] - A set of ''very'' simple examples of Python syntax, illustrating constructs like conditionals, loops, functions and classes.
* [http://wiki.python.org/moin/SimplePrograms Simple Python Examples] - A set of ''very'' simple examples of Python syntax, illustrating constructs like conditionals, loops, functions and classes.
* [[Typed Arrays in IronPython]]
* [[Typed Arrays in IronPython]]
-
* [[Deployment]] - How to deploy IronPython scripts.
+
* [[Deployment]] - How to deploy IronPython scripts
-
* [http://www.dotnetspider.com/kb/Article3142.aspx Creating properties in IronPython]
+
 
 +
If you are looking for an IDE or editor to use with IronPython then you will find this article helpful:
 +
 
 +
* [http://www.voidspace.org.uk/ironpython/tools-and-ides.shtml IronPython Tools & IDEs]
 +
 
 +
It covers using IronPython with IronPython Studio, Visual Studio, SharpDevelop, the Wing IDE, Eclipse with PyDev and assorted other editors. It also looks at standard development tools for Python and IronPython.
===.NET===
===.NET===
Line 93: Line 97:
* [[Basic Handwriting Recognition]] - Using the InkOverlay class to enable basic handwriting functionality
* [[Basic Handwriting Recognition]] - Using the InkOverlay class to enable basic handwriting functionality
* [[Preview All Installed Voices]] - A simple app to preview all the voices installed on your system
* [[Preview All Installed Voices]] - A simple app to preview all the voices installed on your system
 +
* [[HTML Encoder]] - A simple WinForm script which can encode or decode HTML and copy it to the clipboard
===Silverlight===
===Silverlight===
Line 99: Line 104:
* [[Profiling]] - A quick and low-impact way to get some rudimentary performance data in a silverlight application.
* [[Profiling]] - A quick and low-impact way to get some rudimentary performance data in a silverlight application.
 +
* [http://www.trypython.org/ Try Python] - an IronPython Silverlight application for learning Python
===Databases===
===Databases===
Line 106: Line 112:
* [[A DataGridView with a Database as the DataSource]] - with textboxes to enter connection string and a query, you can view the results of any SQL query in a DataGridView (an example of data-binding). Goes through setting up MySQL for the example.
* [[A DataGridView with a Database as the DataSource]] - with textboxes to enter connection string and a query, you can view the results of any SQL query in a DataGridView (an example of data-binding). Goes through setting up MySQL for the example.
* [http://hex-dump.blogspot.com/2006/09/ironpython-and-adonet-part-1.html Database access using ADO.Net] - Examples for loading and querying data using Odbc and SQLite providers.
* [http://hex-dump.blogspot.com/2006/09/ironpython-and-adonet-part-1.html Database access using ADO.Net] - Examples for loading and querying data using Odbc and SQLite providers.
-
* [http://hex-dump.blogspot.com/2006/10/ironpython-and-adonet-part-2.html Database access using Python DBAPI] - Connecting to the database and executing basic DDL and SQL statements via the Python DB-API instead of directly accessing ADO.Net.
+
* [http://hex-dump.blogspot.com/2006/10/ironpython-and-adonet-part-2.html Database access using Python DBAPI] - Connecting to the database and executing basic DDL and SQL statements via the Python DB-API instead of directly accessing ADO.Net (This 2006 example uses the FePy dbapi tools.)
 +
* [http://sourceforge.net/projects/adodbapi adodbapi - A newer module for DBAPI access] - The above discussion of DB-API access is great. Please read it! However, the tools to which it refers are not quite PEP249 compliant.  This one is fully compliant, has several extensions, is fully updated for IronPython 2.6, and will work with JET (a.k.a. Access) databases, Microsoft SQL server, MySQL, and others.
* [[Accessing SQL Server]] - Use IronPython to access a SQL Server.
* [[Accessing SQL Server]] - Use IronPython to access a SQL Server.
* [[Oracle & OleDb]] - Accessing an Oracle Server using OleDb
* [[Oracle & OleDb]] - Accessing an Oracle Server using OleDb
Line 186: Line 193:
* [[Active Directory and RefreshCache]] - enable ironpython to get attributes like TokenGroups from AD
* [[Active Directory and RefreshCache]] - enable ironpython to get attributes like TokenGroups from AD
* [[Reading Eventlogs]] - use ironpython to get eventlogs with the System.Diagnostics Library
* [[Reading Eventlogs]] - use ironpython to get eventlogs with the System.Diagnostics Library
 +
* [[VimWrap]] - convenience wrapper around the VMWare API
 +
* [[Adding Exchange Snapin to IronPython]] - managing exchange from IronPython
===.NET 3.0===
===.NET 3.0===
Line 195: Line 204:
* [[WPF GUI using XamlReader]] - Create the layout for a WPF application in XML
* [[WPF GUI using XamlReader]] - Create the layout for a WPF application in XML
* [[XAML GUI Events Example]] - Creates a GUI using a XAML definition and dynamically hooks up event handlers.
* [[XAML GUI Events Example]] - Creates a GUI using a XAML definition and dynamically hooks up event handlers.
 +
* [[ XAML Crazy Windows]] - Creates a crazy shaped, transparent window, and attaches event handlers.
 +
* [[ WPF Metaclass ]] - An example of a very useful metaclass to use for WPF.
===Graphics & Multimedia===
===Graphics & Multimedia===
* [[Direct3D - Creating a Device]]
* [[Direct3D - Creating a Device]]
 +
* [[Direct3D - Creating a Device with SlimDX]] -  SlimDX is an efficient, simple, and lean wrapper that fully encompasses all of DirectX.
* [[Direct3D with Vertices]]
* [[Direct3D with Vertices]]
* [[Animated Direct3D with Matrices]]
* [[Animated Direct3D with Matrices]]
Line 203: Line 215:
* [[Texture Mapping in Direct3D]]
* [[Texture Mapping in Direct3D]]
* [[XNA Example with a Bouncing Sprite]]
* [[XNA Example with a Bouncing Sprite]]
 +
* [[XNA Example - Luminance]]
* [[Reading and Writing JPG Metadata with .NET 3]]
* [[Reading and Writing JPG Metadata with .NET 3]]
* [[Multi-colored Bar Chart with ZedGraph]] - saved as an image file
* [[Multi-colored Bar Chart with ZedGraph]] - saved as an image file
Line 221: Line 234:
* [[Creating Python Modules from CSharp]] - using PythonContext, CodeContext, SourceUnit, PythonDictionary and friends.
* [[Creating Python Modules from CSharp]] - using PythonContext, CodeContext, SourceUnit, PythonDictionary and friends.
* [[Checking Python Syntax without Executing]]
* [[Checking Python Syntax without Executing]]
 +
* [[Using Python Classes from .NET/CSharp IP 2.6]]
 +
* [[Using Compiled Python Classes from .NET/CSharp IP 2.6]]
Note: most of the pages below are for embedding IronPython 1, or out of date tutorials for pre-release versions of IronPython 2. An up-to-date set of tutorials on embedding IronPython 2 (including interacting with dynamic objects) can be found at [http://www.voidspace.org.uk/ironpython/embedding.shtml Embedding IronPython].
Note: most of the pages below are for embedding IronPython 1, or out of date tutorials for pre-release versions of IronPython 2. An up-to-date set of tutorials on embedding IronPython 2 (including interacting with dynamic objects) can be found at [http://www.voidspace.org.uk/ironpython/embedding.shtml Embedding IronPython].
Line 242: Line 257:
* [[Introspecting .NET Types and Methods from IronPython]]
* [[Introspecting .NET Types and Methods from IronPython]]
*[http://www.voidspace.org.uk/ironpython/dynamically_compiling.shtml Dynamically Compiling and Using C# from IronPython]
*[http://www.voidspace.org.uk/ironpython/dynamically_compiling.shtml Dynamically Compiling and Using C# from IronPython]
-
* [[Reading CSV Files]]
+
* [[Reading CSV Files]]by Seo Sanghyeon
-
* [[Access Unmanaged Code with Dynamic P/Invoke]] - using ctypes for IronPython by Seo Sanghyeon
+
* [[Overridable Properties]]
* [[Overridable Properties]]
* [[Enumerations]] in IronPython
* [[Enumerations]] in IronPython
Line 255: Line 269:
* [[SCons on IronPython]] - Running the [http://www.scons.org/ SCons build system] using IronPython
* [[SCons on IronPython]] - Running the [http://www.scons.org/ SCons build system] using IronPython
* [[Tweet]] - Use [http://www.twitter.com Twitter] from IronPython.
* [[Tweet]] - Use [http://www.twitter.com Twitter] from IronPython.
 +
* [[Random String Generation]] - Generate a random string
* [[Self-executable scripts]] - Making IronPython scripts self-executable
* [[Self-executable scripts]] - Making IronPython scripts self-executable

Current revision as of 17:26, 5 May 2011

Contents

The IronPython Cookbook

This wiki contains useful example code for working with IronPython and the .NET framework.

The internet is already awash with quality examples of Python code, but .NET examples for IronPython are only just starting to arrive - so this will be the main focus of the recipes here.

For more information and resources, see the Useful Links page.


Adding Entries

If you want to add an entry, the easiest way is to add a link (in the relevant section) on this page, and then follow the link to create the new page. You will need to be logged in to edit pages, but setting up an account is easy.

If there isn't already an appropriate section, then add your link to Misc or create a new section.

If you need reminding about wiki markup format, there is a guide on the Help page. Or find an existing page on the wiki that looks like the one you want to make, click the Edit link and use that as a template.

Please note that for long examples and articles it is acceptable to link to external articles or blog entries. For shorter examples, please post them here on the Wiki.

All pages: http://www.ironpython.info/index.php/Special:AllPages

Core Concepts


For the people involved, see People in IronPython.

IronPython in Action

IronPython in Action

IronPython in Action is a book on IronPython, written by Michael Foord and Christian Muirhead for Manning Publications.

The first five chapters are an introduction to .NET, a Python tutorial, and then a walkthrough creating an example structured Python application.

The rest of the book covers working with various parts of the .NET framework (ASP, databases, web services, WPF, shell scripting, working with Windows and so on), getting deeper into Python (testing, protocols, metaclasses and so on) and also embedding and extending IronPython.

Chapters 1 and 7 are free to download:

Pro IronPython

Contents

Getting Started

If you are looking for an IDE or editor to use with IronPython then you will find this article helpful:

It covers using IronPython with IronPython Studio, Visual Studio, SharpDevelop, the Wing IDE, Eclipse with PyDev and assorted other editors. It also looks at standard development tools for Python and IronPython.

.NET

Windows Forms

Silverlight

For a good introduction to using IronPython with Silverlight (including code, live examples and downloads), visit The Voidspace Silverlight Pages.

  • Profiling - A quick and low-impact way to get some rudimentary performance data in a silverlight application.
  • Try Python - an IronPython Silverlight application for learning Python

Databases

SqlServer 2005 Management Objects

Network Protocols

Interop

System

Win32 & Windows Specific

System Administration and automation

.NET 3.0

Graphics & Multimedia

Embedding

Note: most of the pages below are for embedding IronPython 1, or out of date tutorials for pre-release versions of IronPython 2. An up-to-date set of tutorials on embedding IronPython 2 (including interacting with dynamic objects) can be found at Embedding IronPython.

XML

Misc

Tools and Utilities

  • Web IDE - Try out Python in your browser.
  • SilverShell - Slick IronPython Shell that runs in a browser and also on the desktop
  • IronEditor - Win Forms based editor for DLR based languages.
  • IronPython add-in - An IronPython add-in for Redgate's .Net Reflector Redgate
  • Davy's IronPython Editor - DIE (Davy's Ironpython Editor) is a clutter free IronPython code editor along the lines of SPE or DrPython.

Compatibility

These sections document the compatibility of various Python application and libraries with IronPython.

TOOLBOX
LANGUAGES