Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Python Tools for Visual Studio: Python na Microsoftovom .NET-u

878 views

Published on

Published in: Technology, Education
  • Be the first to comment

  • Be the first to like this

Python Tools for Visual Studio: Python na Microsoftovom .NET-u

  1. 1. Python Python Tools for VS DLR i IronPython Zaklju£ak Python Tools for Visual Studio Python na Microsoftovom .NET-u Nikola Pleji¢ nikola@plejic.com http://nikola.plejic.com DevUG Zagreb, 27.10.2011.
  2. 2. Python Python Tools for VS DLR i IronPython Zaklju£akOutline 1 Python Uvod Kratak vodi£ kroz jezik 2 Python Tools for VS Instalacija 3 DLR i IronPython Dynamic Language Runtime Uporaba IronPythona
  3. 3. Python Python Tools for VS DLR i IronPython Zaklju£akPython? > print(Hello, world!) Hello, world!
  4. 4. Python Python Tools for VS DLR i IronPython Zaklju£akPython? • op¢eniti, objektno-orijentirani high-level jezik
  5. 5. Python Python Tools for VS DLR i IronPython Zaklju£akPython? • op¢eniti, objektno-orijentirani high-level jezik • dinami£ki, strongly typed
  6. 6. Python Python Tools for VS DLR i IronPython Zaklju£akPython? • op¢eniti, objektno-orijentirani high-level jezik • dinami£ki, strongly typed • fokus na £itljivost i jednostavnost sintakse
  7. 7. Python Python Tools for VS DLR i IronPython Zaklju£akThe Zen of Python import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases arent special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless youre Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, its a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- lets do more of those!
  8. 8. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest • nastao krajem 1989. godine
  9. 9. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest • nastao krajem 1989. godine • Guido van Rossum (BDFL Benevolent Dictator For Life)
  10. 10. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest • nastao krajem 1989. godine • Guido van Rossum (BDFL Benevolent Dictator For Life) • Python 2 vs. Python 3
  11. 11. Python Python Tools for VS DLR i IronPython Zaklju£akImplementacije • referentna implementacija CPython
  12. 12. Python Python Tools for VS DLR i IronPython Zaklju£akImplementacije • referentna implementacija CPython • Jython, IronPython, PyPy
  13. 13. Python Python Tools for VS DLR i IronPython Zaklju£akImplementacije • referentna implementacija CPython • Jython, IronPython, PyPy • raznorazni kompajleri (Pyjamas, Pyrex, Cython)
  14. 14. Python Python Tools for VS DLR i IronPython Zaklju£akOsnovni tipovi podataka • sve je objekt
  15. 15. Python Python Tools for VS DLR i IronPython Zaklju£akOsnovni tipovi podataka • sve je objekt • string vs. unicode • ne i u IronPythonu (string == unicode)
  16. 16. Python Python Tools for VS DLR i IronPython Zaklju£akOsnovni tipovi podataka • sve je objekt • string vs. unicode • ne i u IronPythonu (string == unicode) • liste, tuplei
  17. 17. Python Python Tools for VS DLR i IronPython Zaklju£akOsnovni tipovi podataka • sve je objekt • string vs. unicode • ne i u IronPythonu (string == unicode) • liste, tuplei • dictionaries
  18. 18. Python Python Tools for VS DLR i IronPython Zaklju£akComprehensions • list comprehensions
  19. 19. Python Python Tools for VS DLR i IronPython Zaklju£akComprehensions • list comprehensions • dictionary comprehensions
  20. 20. Python Python Tools for VS DLR i IronPython Zaklju£akComprehensions • list comprehensions • dictionary comprehensions • generatori • generator comprehensions
  21. 21. Python Python Tools for VS DLR i IronPython Zaklju£akObjektni model • klase
  22. 22. Python Python Tools for VS DLR i IronPython Zaklju£akObjektni model • klase • klase su objekti
  23. 23. Python Python Tools for VS DLR i IronPython Zaklju£akObjektni model • klase • klase su objekti • metaklase • [...] deeper magic than 99% of users should ever worry about. If you wonder whether you need them, you dont (the people who actually need them know with certainty that they need them, and dont need an explanation about why). ~ Tim Peters
  24. 24. Python Python Tools for VS DLR i IronPython Zaklju£ak’to nam treba? • distribucija Pythona • standardni interpreter, ActiveState, IronPython, ... 1 http://pytools.codeplex.com/ 2 http://ipython.org/ 3 MSI na https://github.com/zeromq/pyzmq/downloads
  25. 25. Python Python Tools for VS DLR i IronPython Zaklju£ak’to nam treba? • distribucija Pythona • standardni interpreter, ActiveState, IronPython, ... • Visual Studio ili besplatni Visual Studio Shell • ne i VS Express! 1 http://pytools.codeplex.com/ 2 http://ipython.org/ 3 MSI na https://github.com/zeromq/pyzmq/downloads
  26. 26. Python Python Tools for VS DLR i IronPython Zaklju£ak’to nam treba? • distribucija Pythona • standardni interpreter, ActiveState, IronPython, ... • Visual Studio ili besplatni Visual Studio Shell • ne i VS Express! 1 • Python Tools for Visual Studio 1 http://pytools.codeplex.com/ 2 http://ipython.org/ 3 MSI na https://github.com/zeromq/pyzmq/downloads
  27. 27. Python Python Tools for VS DLR i IronPython Zaklju£ak’to nam treba? • distribucija Pythona • standardni interpreter, ActiveState, IronPython, ... • Visual Studio ili besplatni Visual Studio Shell • ne i VS Express! 1 • Python Tools for Visual Studio 2 • IPython • alternativni (ne-samo-)Python shell • potreban pyzmq 2.1.4 3 1 http://pytools.codeplex.com/ 2 http://ipython.org/ 3 MSI na https://github.com/zeromq/pyzmq/downloads
  28. 28. Python Python Tools for VS DLR i IronPython Zaklju£ak’to dobivamo? • IntelliSense 4 samo u VS Ultimate :(
  29. 29. Python Python Tools for VS DLR i IronPython Zaklju£ak’to dobivamo? • IntelliSense • project management 4 samo u VS Ultimate :(
  30. 30. Python Python Tools for VS DLR i IronPython Zaklju£ak’to dobivamo? • IntelliSense • project management • debugger 4 samo u VS Ultimate :(
  31. 31. Python Python Tools for VS DLR i IronPython Zaklju£ak’to dobivamo? • IntelliSense • project management • debugger 4 • proling 4 samo u VS Ultimate :(
  32. 32. Python Python Tools for VS DLR i IronPython Zaklju£ak’to je DLR? • skup libraryja nad CLR-om koji olak²ava hostanje dinami£kih jezika
  33. 33. Python Python Tools for VS DLR i IronPython Zaklju£ak’to je DLR? • skup libraryja nad CLR-om koji olak²ava hostanje dinami£kih jezika • izvu£en iz ranih verzija IronPythona
  34. 34. Python Python Tools for VS DLR i IronPython Zaklju£ak’to je DLR? • skup libraryja nad CLR-om koji olak²ava hostanje dinami£kih jezika • izvu£en iz ranih verzija IronPythona • zajedni£ka podloga za sve dinami£ke jezike na .NET-u (IronRuby, IronScheme)
  35. 35. Python Python Tools for VS DLR i IronPython Zaklju£ak’to je DLR? • skup libraryja nad CLR-om koji olak²ava hostanje dinami£kih jezika • izvu£en iz ranih verzija IronPythona • zajedni£ka podloga za sve dinami£ke jezike na .NET-u (IronRuby, IronScheme) • pro²irenje postoje¢im stati£kim jezicima (dynamic dispatching @ C# 4.0)
  36. 36. Python Python Tools for VS DLR i IronPython Zaklju£ak’to je DLR? • skup libraryja nad CLR-om koji olak²ava hostanje dinami£kih jezika • izvu£en iz ranih verzija IronPythona • zajedni£ka podloga za sve dinami£ke jezike na .NET-u (IronRuby, IronScheme) • pro²irenje postoje¢im stati£kim jezicima (dynamic dispatching @ C# 4.0) • .NET Framework 4.0 + Mono 2.8+ po defaultu
  37. 37. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest IronPythona • Jim Hugunin, 2006.
  38. 38. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest IronPythona • Jim Hugunin, 2006. • danas: Microsoft (razvoj na CodePlexu)
  39. 39. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest IronPythona • Jim Hugunin, 2006. • danas: Microsoft (razvoj na CodePlexu) • open source (Apache 2.0)
  40. 40. Python Python Tools for VS DLR i IronPython Zaklju£akKratka povijest IronPythona • Jim Hugunin, 2006. • danas: Microsoft (razvoj na CodePlexu) • open source (Apache 2.0) • aktivno razvijan (zadnji release: 21.10.2011.)
  41. 41. Python Python Tools for VS DLR i IronPython Zaklju£akFeaturei • ≈ CPython 2.7 uz manje razlike, npr.: • string == unicode • Python podrºava vi²estruko naslježivanje, CLR ne podrºava
  42. 42. Python Python Tools for VS DLR i IronPython Zaklju£akFeaturei • ≈ CPython 2.7 uz manje razlike, npr.: • string == unicode • Python podrºava vi²estruko naslježivanje, CLR ne podrºava • integracija s .NET frameworkom
  43. 43. Python Python Tools for VS DLR i IronPython Zaklju£akFeaturei • ≈ CPython 2.7 uz manje razlike, npr.: • string == unicode • Python podrºava vi²estruko naslježivanje, CLR ne podrºava • integracija s .NET frameworkom • Silverlight scripting
  44. 44. Python Python Tools for VS DLR i IronPython Zaklju£akPri£anje s .NET-om # deklaracija referenci import clr clr.AddReference(System.Xml) # namespacevi import System from System.Xml import * xmldoc = XmlDocument() # alternativno: # import system # xmldoc = System.Xml.XmlDocument()
  45. 45. Python Python Tools for VS DLR i IronPython Zaklju£akPri£anje s .NET-om (smjer #2) 5 • DLR Hosting API (= free scripting!) 5 http://dlr.codeplex.com/wikipage?title=Docs%20and%20specsreferringTitle=Do
  46. 46. Python Python Tools for VS DLR i IronPython Zaklju£akPri£anje s .NET-om (smjer #2) 5 • DLR Hosting API (= free scripting!) • kompajliranje IronPython aplikacije u .NET assembly • While the assemblies produced by the IronPython Hosting APIs are true .NET assemblies, the dynamic nature of the Python language makes it dicult to use these from other .NET languages. In short, this means that attempting to import Python types into other .NET languages such as C# is not recommended. 5 http://dlr.codeplex.com/wikipage?title=Docs%20and%20specsreferringTitle=Do
  47. 47. Python Python Tools for VS DLR i IronPython Zaklju£akASP.NET i IronPython • WebForms uz ASP.NET Dynamic Language Support 6 http://github.com/jschementi/ironrubymvc
  48. 48. Python Python Tools for VS DLR i IronPython Zaklju£akASP.NET i IronPython • WebForms uz ASP.NET Dynamic Language Support • ASP.NET MVC • http://www.codevoyeur.com/Articles/Tags/ironpython.aspx • Rubyja²i su bolje pro²li 6 6 http://github.com/jschementi/ironrubymvc
  49. 49. Python Python Tools for VS DLR i IronPython Zaklju£akAlternative 7 • Boo • sintaksa inspirirana Pythonom • stati£ki tipiziran (type inferencing) • makroi 7 http://boo.codehaus.org/ 8 http://ironruby.net/ 9 http://ironscheme.codeplex.com/
  50. 50. Python Python Tools for VS DLR i IronPython Zaklju£akAlternative 7 • Boo • sintaksa inspirirana Pythonom • stati£ki tipiziran (type inferencing) • makroi 8 • IronRuby 7 http://boo.codehaus.org/ 8 http://ironruby.net/ 9 http://ironscheme.codeplex.com/
  51. 51. Python Python Tools for VS DLR i IronPython Zaklju£akAlternative 7 • Boo • sintaksa inspirirana Pythonom • stati£ki tipiziran (type inferencing) • makroi 8 • IronRuby 9 • IronScheme? • skoro-pa-R6RS Scheme 7 http://boo.codehaus.org/ 8 http://ironruby.net/ 9 http://ironscheme.codeplex.com/
  52. 52. Python Python Tools for VS DLR i IronPython Zaklju£akZaklju£ak • ozbiljan, dobro podrºan dinami£ki jezik na CLR-u i Monou
  53. 53. Python Python Tools for VS DLR i IronPython Zaklju£akZaklju£ak • ozbiljan, dobro podrºan dinami£ki jezik na CLR-u i Monou • vrlo solidan toolchain u razvoju
  54. 54. Python Python Tools for VS DLR i IronPython Zaklju£akZaklju£ak • ozbiljan, dobro podrºan dinami£ki jezik na CLR-u i Monou • vrlo solidan toolchain u razvoju • £emu sve to? • brzi prototyping • testiranje .NET assemblyja • skriptiranje .NET i Silverlight aplikacija
  55. 55. Python Python Tools for VS DLR i IronPython Zaklju£akZaklju£ak Hvala na paºnji! Nikola Pleji¢ nikola@plejic.com http://nikola.plejic.com/

×