9. Dynamic but type safe The interpreter keeps track of all variables types Cannot do anything that's incompatible with the type of data you're working with Types can change Variable is simply a value bound to a name
13. Duck Typing class Duck: def quack(self): print("Quaaaaaack!") class Person: def quack(self): print("The person imitates a duck.") defin_the_forest(duck): duck.quack() def game(): donald = Duck() john = Person() in_the_forest(donald) in_the_forest(john) game()
14. List Comprehension What would be the values of listB? listA = [j for i in range(2, 8) for j in range(i*2, 50, i)]listB = [x for x in range(2, 50) if x not in listA] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
17. IronPython is: Open source Supports both .NET & Mono All CLR types are available Can call .NET code
18. IronPython IDEs VS2010 + IronPython extension #Develop Wing Eclipse + PyDev For more details see: http://www.voidspace.org.uk/ironpython/tools-and-ides.shtml
19. The interactive shell Run code on the fly Run .NET code on the fly >>> print "Hello, world" Hello, world >>> x = 12**2 >>> x/2 72 >>> # this is a comment
20. IronPython in the real world Use IronPython as part of your .NET applications WPF PowerShell ASP.NET Spark Silverlight Robotics Studio XNA Scripting engine
21. Where to start Download IronPython and give it a try TryPython - http://ironpython.net/try/ Read a book Add IronPython to your utility belt
22. Resources IronPython - http://ironpython.net/ IronPython on Codeplexhttp://ironpython.codeplex.com/ Books: Dive into Python - http://diveintopython.org/ IronPython in Action - http://www.ironpythoninaction.com/ Blogs: Voidspace techie blog: http://www.voidspace.org.uk/python/weblog/index.shtml Getting started with IronPython - http://blogs.microsoft.co.il/blogs/dhelper/archive/2009/05/01/beginning-ironpython-development-part-1-where-to-start.aspx Integration: ASP.NET: http://aspnet.codeplex.com/wikipage?referringTitle=Home&title=Dynamic%20Language%20Support SilverLight: http://www.voidspace.org.uk/ironpython/silverlight/index.shtml Spark: http://sparkviewengine.com/documentation/ironpython
Editor's Notes
Show in ipy:x = 5 x = x + 7 # x 12x = x + “spam” # errorx = 5 x = “eggs”x = x + “ and spam”