Scott Hanselman

One of Microsoft's Best-Kept Secrets - Python Tools for Visual Studio (PTVS)

July 2, '13 Comments [78] Posted in Open Source | Python
Sponsored By
Python Tools for VS
 

I've talked some about the sweet support for node and PHP in Azure. You can also File | New | Node.js express application in WebMatrix, or run WordPress and get intellisense as well.

"I installed windows just so i can use PTVS" - Comment on Hacker News

But I'm consistently shocked that folks forget about Python at Microsoft. I am a C# person, myself, but the Developer Division at Microsoft loves their languages. C++, VB, C#, F#, etc and they aren't messing about when they get serious about a language.

One of the least-known and most-kick-butt free products we have is PTVS - Python Tools for Visual Studio. Whether you're just interested in learning Python or you're a hardcore PhD who wants mixed-language Python and C++ debugging or somewhere in between, you gotta check this out. (Seriously, the mixed-mode debugging thing can't be overstressed...)

The Misconceptions

  • Microsoft? Python?  Oh, it must be all about IronPython, that's dead, right?
    • IronPython is a community-run project and just put an 2.7.4 alpha out last month.  PTVS fully supports IronPython, but the most advanced support is for standard CPython!
  • PTVS needs VisualStudio? I don't have any money.
    • PTVS, combined with the Integrated/isolated VS Shell is completely and perpetually free.  And with the advent of VS2013, they've combined them into a single installer: https://pytools.codeplex.com/releases (at bottom of page).

This is Real

Here's my VS2013 after installing PyTools (PTVS). I've got IronPython which is Python running under the .NET CLR, but I've also got Django apps as well as a regular CPython or making a new project from existing code.

Python inside VS

You can see that PTVS knows what Python engines I have installed, and I can easily switch between them. Here you can see that VS is refreshing the auto-completion (intellisense) databases for each version.

A list of Python Interpreters

There's also a complete REPL inside Visual Studio for each:

Python REPL inside VS

Developing Django Apps in Visual Studio

Maybe you're a Django (one of Python's Web Frameworks) web developer, you can use VS to develop your app.

Go File New | Django App, then make a new Python Virtual Environment from the Solution Explorer, and watch Visual Studio freaking installed pip for you (the Python package manager). It's very seamless.

Adding a Virtual Python Environment

Which gives me this:

Python in my VS and I'm FREAKING OUT

Then I right click on "dev" and just like NuGet (except this is Python, so pip) I install django:

Installing Django

Django is massive, so this took a while, but still! And.....I've accomplished Hello World in Django. Well, Hello Django, at least, launched from Visual Studio.

Hello Django

You should feel free to go and run through the whole Django Tutorial if you like and even deploy your app to Azure! You can host Django on a regular Azure Web Site, or a Virtual Machine if you want more control.

You can even interactively debug Python running in Azure on Linux from your Visual Studio instance! Check out Steve do just that at PyCon in this YouTube video.

There's a bunch of great educational and quick start Tutorials on the Python Tools YouTube Channel, they are a great resource to bookmark.

You can attach to remote Python processes over SSL and debug if you like.

Setting up Python Debugging

It's Really Integrated

Let's get real here for a second. Lots of projects plug stuff into Visual Studio. You may have made it this far into the post and be saying "oh, wah wah, this thing sets up some batch files and some syntax highlighting and calls itself a full-featured Python IDE."

Um, no. This is the best of VS and the best of Python and I'm blown away. Check this out. PTVS knows that I'm doing unit testing here and they've integrated Python Unit Testing with the VS Unit Testing UI.

Unit Testing in Python and VS? My heart can't take it!

This is debugging, remote debugging, cross language debugging, tool tips, watches, locals, call stacks, unit testing, full REPL with inline graphics, profiling, cloud publish, best of class CPython support, and so much more.

Nailed it

If you're into Python or knows someone who is, for reals, drink it in and get on board at https://pytools.codeplex.com. Check out their samples. They've got Python talking to Kinect, Python talking to Excel and more. Their PTVS Documentation is really good as well.

Just getting started? Well, go Learn Python The Hard Way.

Installing PTVS

Here's the complete install instrucitons. You need VS, the PTVS, and some Python.

PTVS is free

Finally, explore the Resources and Docs for Python Tools for Visual Studio, including, but not limited to Editing, Refactoring, Unit Tests, Django, IPython notebook and Azure cloud computing, Kinect for Python and Pyvot - an Excel to Python bridge.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Hanselminutes Podcast 197 - The Dynamic Language Runtime, IronRuby and IronPython with Jimmy Schementi

February 4, '10 Comments [1] Posted in DLR | Podcast | Python | Ruby
Sponsored By

image My one-hundred-and-ninety-seventh podcast is up. Scott sits down with Jimmy Schementi to find out what's the scoop with the DLR. Is it baked? What do I need to do to get started? What's the status of IronRuby - is it done? Will IronPython be a first class language or is it already? All these questions and more will be answered.

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

Download: MP3 Full Show

Links from the Show

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is our sponsor for this show.

Check out their UI Suite of controls for ASP.NET. It's very hardcore stuff. One of the things I appreciate aboutTelerik is their commitment tocompleteness. For example, they have a page about their Right-to-Left support while some vendors have zero support, or don't bother testing. They also are committed to XHTML compliance and publish their roadmap. It's nice when your controls vendor is very transparent.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Hanselminutes Podcast 159 - IronPython in Action with Michael Foord

April 25, '09 Comments [5] Posted in DLR | Podcast | Python
Sponsored By

ironpythoninaction My one-hundred-and-fifty-ninth podcast is up. Michael Foord makes his living as a Python programmer. More specifically has an IronPython programmer. He chats with me about his company's use of IronPython, the DLR and why they picked Python over C# or VB.

40% OFF COUPON: Michael's hooked me up with a 40% off coupon for a limited time for Hanselminutes listeners. Just buy the book with coupon code "ironpython40".

Links from the Show

Subscribe: Subscribe to Hanselminutes Subscribe to my Podcast in iTunes

Do also remember the complete archives are always up and they have PDF Transcripts, a little known feature that show up a few weeks after each show.

Telerik is a sponsor for this show!

Building quality software is never easy. It requires skills and imagination. We cannot promise to improve your skills, but when it comes to User Interface, we can provide the building blocks to take your application a step closer to your imagination. Explore the leading UI suites for ASP.NET and Windows Forms. Enjoy the versatility of our new-generation Reporting Tool. Dive into our online community. Visit www.telerik.com.

As I've said before this show comes to you with the audio expertise and stewardship of Carl Franklin. The name comes from Travis Illig, but the goal of the show is simple. Avoid wasting the listener's time. (and make the commute less boring)

Enjoy. Who knows what'll happen in the next show?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

.NET 4.1 Preview - New Base Class Library (BCL) Extension Methods - RFC

April 1, '09 Comments [16] Posted in ASP.NET | DLR | Javascript | Learning .NET | Microsoft | Musings | Open Source | PHP | Programming | Python | Silverlight | Source Code | Tools | VB | Web Services | Windows Client | XML
Sponsored By

As web programmers, we use a lot of strings to move data around the web. Often we’ll use a string to represent a date or an integer or a boolean. Basically "1" in instead of 1, or "April 1, 2009" rather than a proper ISO-8601 formatted culture-invariant date.

While these strings are flying around via HTTP it's not a huge deal, but sometimes this loose, even sloppy, use of strings can leak into our own code. We might find ourselves leaving the data times as strings longer and longer, or not even bothering to convert them to their proper type at all. This problem is made worse by the proliferation of JSON, and schema-less/namespace-less XML (that I've often called "angle-bracket delimited files" as they're no more useful than CSVs in that point.

.NET 4.0 is pretty much locked down, but version 4.1 still has some really cool "Futures" features that are being argued about. If we don't know the type of a string, or we want to leave the string, as a string, longer than usual, what if we had an class that could be both a string and another type, essentially deferring the decision until the variable is observed. For example:

StringOr<int> userInput= GetUserInput("Quantity"); 
string szUserInput=userInput.StringValue; 
int intUserInput=userInput.OtherValue;

Sometimes you just don't know, or can't know.

This reminds me of a similar, but orthogonal physics concept, that of the Heisenberg Uncertainty Principle. Sometimes you know that an object is a string, and sometimes you know how long it is, but you can’t know both at the same time.

One of my favorite jokes goes:

Heisenberg gets pulled over by the police. The officer asks, “Do you know how fast you were going?” Heisenberg answers, “No, but I know exactly where I am!”

This library doesn't solve THAT issue, with respect to strings, but we’ve got folks in DevDiv working on this and many other metaphysical - and physical - problems as they apply to computer science.

Big thanks to Eilon, who's working hard to get this pushed into the .NET 4.1 Base Class Library. Visit Eilon's blog for more details on this new library, more code, graphics and details on how Intellisense will handle this new case.

Hopefully, someone is working to make this important new library Open Source.

Your thoughts, Dear Reader?

Related Posts

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

IronPython and the DLR march on

March 22, '08 Comments [12] Posted in ASP.NET | ASP.NET MVC | DLR | Python | Ruby | Silverlight
Sponsored By

I've got a number of emails complaining that folks haven't heard much from the DLR (Dynamic Language Runtime) and things like IronPython and IronRuby.

I think it's due to mostly one thing, the fact that the ASP.NET Futures Page still says July 2007. That's one of the reasons I personally fought to have the ASP.NET MVC not use a Date in its name. It just makes things look, ahem, dated.

I'm working to get that page updated, but I just wanted to make sure folks know that there's lots going on around the DLR. I talked to Mahesh on a video call just yesterday.

There's lots going on and here's some collected resources for you:

Once you've had fun with all that, you might look at John's Dynamic Silverlight in ASP.NET MVC article.

Here's John and Jimmy's talk on Dynamic Silverlight at Mix08:

All other goodness is at http://dynamicsilverlight.net/. Enjoy.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Page 1 of 1 in the Python category

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.