Python Programming, news on the Voidspace Python Projects and all things techie.

Resolver One 1.5 beta: The Python Console

emoticon:target We've just announced an invitation to try the beta of Resolver One 1.5. The major new feature in version 1.5 is an interactive Python console that lets you explore and interact with your spreadsheet objects.

Resolver One 1.5 Beta - spreadsheet with interactive Python console

You have full access to the spreadsheet scope - including any functions and classes you have defined in user code - and any changes you make in the console are immediately reflected in the spreadsheet display, so it is a really useful way of experimenting. The console itself has syntax highlighting, auto-indent and history. Much kudos to Kamil Dworakowski, my colleague who created the console.

The interactive Python interpreter

As Resolver One is a Python powered spreadsheet system (IronPython specifically of course), an interactive console has been an 'obvious idea' ever since we first released. We thought it would be a lot of work which is why we've not done it before; but when Kamil produced a prototype in a few days hacking we knew we had to do it. Smile

The console isn't the only new feature in 1.5. Another feature that Resolver One has needed for a long time is the ability to import and export CSV files, and at last it can! (It's nice to gradually cross items off my Resolver One wish-list.) You can also now drag and drop '.rsl' files onto Resolver One to open them.

A more important feature for working with user code is the new 'jump-to-line' dialog. When you have an error in your user-code the traceback in the output view pane (at the bottom of the Resolver One UI) will helpfully tell you which code section the error occurred in and which line number. Unfortunately there was no easy way to quickly jump to that line in the code editor (although the red error markers to the right of the code pane would show you all the error locations). This feature was made more complex by the fact that the code box includes all the generated code from your data and formulae (and the generated code can change if there are errors etc), so there was really no concept of a canonical 'line number' for any individual line of code.

The new goto-line dialog (activated by ctrl-g or from the menu) lets you choose which code section and specify the line number, which is really handy and much requested:

The new goto-line dialog in 1.5

Along with these features there are the usual host of minor features and bugfixes which will be announced when 1.5 final is out. To go alongside the 1.5 release will be a demo of distributing Resolver One calculation tasks on the Digipede grid computing platform. We're already working on features for 1.6, with more 'much-requested' functionality. Something else to look forward to. Smile

Other news: we've just announced the winner of the April round of the Resolver Systems Spreadsheet Challenge. The winner is is Greg Bray's Texas Holdem Poker Monte Carlo Simulator, a clever blend of compiled .NET code, IronPython, and Resolver One. Several of the entries for this round are up and available for download on the Resolver Exchange. Quite a few new spreadsheets have been added there recently, so if you are looking for examples of what Resolver One can do this is the place to look.

We're also now seeing people buy and use Resolver One because of the Numpy integration. Great!

Like this post? Digg it or it.

Posted by Fuzzyman on 2009-05-01 12:55:34 | |

Categories: , Tags: , ,

Python Magic Methods Reference

emoticon:acrobat Appendix B of IronPython in Action is a reference on all of the common magic methods in Python. The magic methods are those that start and end with double underscores, and are called 'magic' because instead of calling them directly they are usually called for you by the interpreter when objects that implement them are involved in certain operations. They are used to implement the Python protocols; for example the mapping and sequence protocols when an object is indexed, the context management protocol when an object is used with the with statement and the numeric protocols when an object is used in numeric operations. Python protocols are duck typed versions of interfaces in other languages (if the protocol methods are available then they will be called - not dependent on the type of the object). There is a mechanism introduced in Python 2.6 and 3.0, Abstract Base Classes, which is a bit more like interfaces in statically typed languages and makes it easier to know which protocols an object supports. In most cases just implementing the magic methods you need is sufficient without needing to use the ABC machinery.

Appendix B is a useful reference for Python and IronPython programmers alike and I've been given permission by Manning to put it online. As it was quite long I've gradually been putting up new sections over the last couple of weeks, and now it is complete!

As well as the magic methods (including magic functions, modules and attributes) it includes descriptions of the with statement, generator expressions and conditional expressions and the descriptor protocol. The full table of contents for the online guide is:

  • Object creation
    • Table B.1 Object creation
  • Comparison
    • Table B.2 Comparison methods
  • Miscellaneous
    • Table B.3 Miscellaneous methods
  • Containers and Iteration
    • Table B.4 Mapping and sequence protocol methods
    • Generator expressions and conditional expressions
  • Conversion to string
    • Table B.5 String conversion methods
  • Attribute access
    • Table B.6 Attribute access methods
  • Numeric types
    • Arithmetic operations
      • Table B.7 Binary arithmetic operations
      • Table B.8 Unary arithmetic operations
    • Conversion between numeric types
      • Table B.9 Type conversion
  • Context managers and the with statement
    • Table B.10 The context management protocol
  • The descriptor protocol
    • Table B.11 Descriptor protocol methods
  • Magic attributes
    • Table B.12 Python magic attributes
  • Functions and modules
    • Table B.13 Magic functions and modules

If I find the time I might put the other appendices online. If you like the reference you'll find it so much more useful in handy book format... Wink

Like this post? Digg it or it.

Posted by Fuzzyman on 2009-04-27 11:51:47 | |

Categories: , , , Tags: ,

Hosted by Webfaction