Skip to main content

Professional IronPython

Professional IronPython

John Paul Mueller

ISBN: 978-0-470-54859-2

Apr 2010

480 pages

Select type: Paperback


Product not available for purchase


Thorough coverage of Microsoft’s new dynamic programming language: IronPython

IronPython is a powerful and vital part of any .NET developer's toolbox, and although it is several years old, very little literature exists on the topic. This essential resource fills that void and provides you with an in-depth understanding of IronPython.

A brief introduction walks you through the installation, usage, and tools of IronPython and also explains what makes IronPython different from other programming languages. Coverage quickly moves on to explaining how to use and work with the IronPython language, and an in-depth look at its environment sheds light on how it can be stand alone or with the .NET Framework. You'll see how IronPython can be used to create either desktop or Web-based applications and you’ll witness how it interacts with other existing technologies. In addition, coverage of advanced topics shares techniques for extending IronPython and making it a robust language.

  • Provides you with an in-depth look at IronPython, how it is different from other programming languages, what it is capable of, and how to maximize its potential
  • Explores how IronPython interacts with existing technologies and how it can perform administration tasks
  • Answers popular questions, such as how to extend IronPython and make it a more robust language
  • Tackles topics not addressed anywhere else, including executing IronPython using Mono

You'll want to devour every topic covered in Professional IronPython so you can get started working with this powerful programming language today.

Introduction xvii

Part I: Introducing IronPython

Chapter 1: Discovering IronPython 3

An Overview of IronPython 4

Getting IronPython 7

Understanding the Dynamic Language Runtime 11

Using the IronPython Console 12

Using the IronPython Windowed Environment 20

Creating Your First Application 21

Using IronPython Constructively 22

Chapter 2: Understanding the IronPython Basics 23

Using Visual Studio to Create IronPython Applications 24

Understanding the Use of Indentation and Capitalization in IronPython 31

Considering Data Types in IronPython 33

Exploring the IronPython Modules 36

Interacting with the IronPython Environment 40

Using IronPython Constructively 41

Chapter 3: Implementing Structured Language Elements 45

Stringing Statements Together 46

Selecting Between Options 48

Creating Loops 51

Performing Enumerations 53

Using IronPython Constructively 54

Chapter 4: Using Arrays and Collections 55

Working with Tuples, Lists, and Arrays 56

Working with the Collections Module 72

Using Dictionaries 74

Using IronPython Constructively 76

Chapter 5: Interacting with Structures and Objects 77

Working with Existing Objects 78

Creating New Objects 89

Using IronPython Constructively 93

Chapter 6: Using the Python Standard Library 97

Considering the Standard Library Features 98

Obtaining and Installing the Python Standard Library 100

Accessing the Standard Library from IronPython 102

Using the Standard Library Features 104

Using IronPython Constructively 115

Chapter 7: Accessing the .NET Framework 117

Importing the .NET Framework Assemblies 118

Using .NET Data Types 126

Interacting with .NET Framework Elements 128

Working with Generics 135

Using IronPython Constructively 137

Chapter 8: Creating Windows Forms Applications 139

Working without a Visual Designer 140

Defining Windows Forms 142

Interacting with Predefined and Custom Events 150

Using IronPython Constructively 159

Chapter 9: Interacting with COM Objects 161

An Overview of COM Access Differences with Python 162

Choosing a Binding Technique 164

Defining an Interop DLL 167

Performing Late Binding Using Activator.CreateInstance() 186

Performing Late Binding Using Marshal.GetActiveObject() 189

Using IronPython Constructively 191

Chapter 10: Using IronPython for Administration Tasks 193

Understanding the Command Line 194

Interacting with the Environment 207

Starting Other Command Line Applications 218

Providing Status Information 220

Using IronPython Constructively 222

Chapter 11: Developing AS P.NET Applications 223

Considering IronPython Web Application Compatibility 224

Obtaining ASP.NET Dynamic Language Support 224

Creating a Web Site 228

Building a Basic ASP.NET Site Using IronPython 229

Using IronPython Constructively 240

Chapter 12: Debugging IronPython Applications 241

Understanding IronPython Warnings 242

Obtaining Error Information 252

Debugging with the Python Debugger 256

Debugging with the CLR Debugger 260

Using Visual Studio for IronPython Debugging 262

Defining and Using Exceptions 263

Using IronPython Constructively 266

Chapter 13: Working with XML Data 271

Using the .NET XML Functionality 272

Using XMLUtil 276

Using the Python Modules 281

Using IronPython Constructively 286

Chapter 14: Interacting with the DLR 287

Obtaining DLR 288

Working with Hosting APIs 293

Understanding the Extensions to LINQ Expression Tree 298

Considering DynamicSite 300

Working with IDynamicObject 300

Understanding the ActionBinder 304

Understanding the Other DLR Features 305

Using IronPython Constructively 305

Chapter 15: Using IronPython from Other .NET Languages 307

Understanding the Relationship between Dynamic and Static Languages 308

Creating an Externally Accessible IronPython Module 309

Accessing the Module from C# 312

Accessing the Module from Visual Basic.NET 319

Developing Test Procedures for External Modules 321

Debugging the External Module 321

Using IronPython Constructively 324

Chapter 16: Extending IronPython Using C# 325

Understanding the Requirements for an Extension 326

Considering IronPython and Static Language Differences 327

Creating the Simple C# Extension 329

Using C# for User Interface Support 336

Using C# for Win32 Support 348

Using IronPython Constructively 356

Chapter 17: Extending IronPython Using Visual Basic .NET 359

Considering C# and VISUAL BASIC.NET Extension Similarities 360

Creating the Simple Visual Basic.NET Extension 360

Using Visual Basic.NET for User Interface Support 367

Using Visual Basic.NET for Database Support 377

Using IronPython Constructively 386

Using IronPython Chapter 18: for Application Testing 387

Understanding Why You Want to Use IronPython for Testing 388

Considering the Test Environment 389

Testing DLLs 392

Testing Applications 396

Performing Command Line Tests 402

Using IronPython Constructively 404

Chapter 19: Using IronPython with Mono 405

What Is Mono? 406

Obtaining and Installing Mono 410

Creating an IronPython Application with Mono 412

Interacting with Other .NET Languages under Mono 418

Using IronPython Constructively 418

Appendix A: IronPython Diff erences with CPython 421

Appendix B: CPython Extensions for IronPython 433

Index 439

Chapter 1: Discovering IronPython
Chapter 2: Understanding the IronPython Basics
Chapter 3: Implementing Structured Language Elements
Chapter 4: Using Arrays and Collections
Chapter 5: Interacting with Structures and Objects
Chapter 6: Using the Python Standard Library
Chapter 7: Accessing the .NET Framework
Chapter 8: Creating Windows Forms Applications
Chapter 9: Interacting with COM Objects
Chapter 10: Using Iron Python for Administration Tasks
Chapter 11: Developing ASP.NET Applications
Chapter 12: Debugging IronPython Applications
Chapter 13: Working with XML Data
Chapter 14: Interacting with the DLR
Chapter 15: Using Iron Pythom for Administration Tasks
Chapter 16: Extending IronPythom Using C#
Chapter 17: Extending IronPythom Using Visual Basic.NET
Chapter 18: Using IronPython for Application Testing
Chapter 19: Using IronPython with Mono