Python Programming, news on the Voidspace Python Projects and all things techie.
Release: ConfigObj 4.5.2 and validate 0.3.2
There was a bug in release 4.5.1 of ConfigObj, so there is now an updated release:
The bug affected the use of None as a default value in configspecs and is now fixed.
What are ConfigObj and Validate?
ConfigObj is a simple to use but powerful configuration file management library. Features include:
Nested sections to any depth
List and multiline values
Integrated with a powerful validation system
- including automatic type checking/conversion
- repeated sections
- and allowing default values
All comments in a file are preserved when writing
The order of keys/sections is preserved
A powerful unrepr mode for storing basic datatypes
validate is the module (optional) used for config file validation and type marshalling. It can be used outside of ConfigObj for matching string values against a text specification which also does type conversion.
Changes in ConfigObj 4.5.x
Distribution now includes validate 0.3.2 so None as a default value in configspecs works again.
BUGFIX: Unicode configspecs now work.
ConfigObj will now guarantee that files will be written terminated with a newline.
ConfigObj will no longer attempt to import the validate module, until/unless you call ConfigObj.validate with preserve_errors=True. This makes it faster to import.
New methods restore_default and restore_defaults. restore_default resets an entry to its default value (and returns that value). restore_defaults resets all entries to their default value. It doesn't modify entries without a default value. You must have validated a ConfigObj (which populates the default_values dictionary) before calling these methods.
BUGFIX: Proper quoting of keys, values and list values that contain hashes (when writing). When list_values=False, values containing hashes are triple quoted.
Added the reload method. This reloads a ConfigObj from file. If the filename attribute is not set then a ReloadError (a new exception inheriting from IOError) is raised.
BUGFIX: Files are read in with 'rb' mode, so that native/non-native line endings work!
Minor efficiency improvement in unrepr mode.
Added missing docstrings for some overridden dictionary methods.
Added the reset method. This restores a ConfigObj to a freshly created state.
Removed old CHANGELOG file.
Changes in Validate 0.3.2
BUGFIX: None as a default value handled correctly.
BUGFIX: Unicode checks no longer broken.
Improved performance with a parse cache.
New get_default_value method. Given a check it returns the default value (converted to the correct type) or raises a KeyError if the check doesn't specify a default.
Added 'tuple' check and corresponding 'is_tuple' function (which always returns a tuple).
BUGFIX: A quoted 'None' as a default value is no longer treated as None, but as the string 'None'.
BUGFIX: We weren't unquoting keyword arguments of length two, so an empty string didn't work as a default.
BUGFIX: Strings no longer pass the 'is_list' check. Additionally, the list checks always return lists.
A couple of documentation bug fixes.
Removed CHANGELOG from module.
IronPython in Action Available for Pre-Order
Well, I almost feel like a real author now. IronPython in Action is now available for pre-order from Amazon:
I even have my name in the URL.
Not a bad description but I think I need to work on my bio.
In 2005, Microsoft quietly announced an initiative to bring dynamic languages to the .NET platform. The starting point for this project was a .NET implementation of Python, dubbed IronPython. After a couple years of incubation, IronPython is ready for real-world use. It blends the simplicity, elegance, and dynamism of Python with the power of the .NET framework.
IronPython in Action offers a comprehensive, hands-on introduction to Microsoft's exciting new approach for programming the .NET framework. It approaches IronPython as a first class .NET language, fully integrated with the .NET environment, Visual Studio, and even the open-source Mono implementation. You'll learn how IronPython can be embedded as a ready-made scripting language into C# and VB.NET programs, used for writing full applications or for web development with ASP. Even better, you'll see how IronPython works in Silverlight for client-side web programming.
IronPython opens up exciting new possibilities. Because it's a dynamic language, it permits programming paradigms not easily available in VB and C#. In this book, authors Michael Foord and Christian Muirhead explore the world of functional programming, live introspection, dynamic typing and duck typing, metaprogramming, and more.
IronPython in Action explores these topics with examples, making use of the Python interactive console to explore the .NET framework with live objects. The expert authors provide a complete introduction for programmers to both the Python language and the power of the .NET framework. The book also shows how to extend IronPython with C#, extending C# and VB.NET applications with Python, using IronPython with .NET 3.0 and Powershell, IronPython as a Windows scripting tool, and much more.
I'm working on the edits after the second review (which included a very generous review from a famous Pythonista - but as they are theoretically anonymous I'm not sure if it is 'good form' to talk about it? I'll probably ask his permission). After that, four more chapters from me and one more from Christian and it is done!
If you can't wait to read it though, you can get access to the two-thirds of the book that are ready through the Manning Early Access Program.
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.