Python at a glance
- An interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991
- It is a server side programming language.
- Targeted for almost all platforms
- A modular language like nodejs
- A indent sensitive language
Development environment setup
- Go to https://www.python.org/downloads/ and download latest (or earlier) version of Python for Windows OS
- Install this using run as administrator in your local machine with features pip, tcl/tk (for winform app), test suite, py launcher. For more to install python environment you can visit the link.
Checking Environment is OK or not
- Open command prompt
- To know python version execute python –version
- To know pip (python packages installer) version execute pip –version or execute pip list
- If you can see the result as screenshot below then it’s Okay.
- Otherwise there may be some problem during installation and Check system environment variable PATH value discussed in later section
System Environment Variables for Python
If this is correctly setup then system environment variable PATH will contain two directory path such as
- python.exe container directory. In my case it is C:\Program Files (x86)\Python37-32\
- pip.exe container directory. In my case it is C:\Program Files (x86)\Python37-32\Scripts\
If somehow these aren’t set automatically then you have to set those manually and check again using python –version and pip –version command
Python in Visual Studio 2017
.NET developer can easily work on it in visual studio 2017 or later and as well as earlier version with some workarounds.
If you can setup this environment correctly, You can see the environments in visual studio from menu View→Other Windows→Python Environments and Python Interactive Window as screenshot below
Create python project in VS 2017
Open Visual Studio and Go to File menu then New -> Project then as screenshot below
Installing package
As I said above, It is a modular language like nodejs. Here you can also install pip packages whatever you need. To install any package you have to right click on python environment node in your python project and select Install Python Package then search for your package ( in my case mssql) and click on your desired package link as shown below.
Python code snippet
You may not need to remember all of it’s code syntax. Visual studio will help you to insert code snippet into your place using Ctrl+K Ctrl+X.
Or you type any of it’s keywords such as for, if etc and press TAB, you will get full statement structure as shown below
Simple python program
- This program imports environ dictionary defined in os package.
- Gets all keys and prints the values and finally prints the count.
- None is same as null in other language
from os import environ
print("My Environment Information")
keys = environ.keys()
count = 0 for key in keys:
if environ[key] != None:
print(key + " = "+ environ[key])
count += 1 print("There are ", count, " information")
Code language: PHP (php)
Debugging & Watching is same as .NET program
You can set break point and debug as .Net program as well as can view any variable value in watch windows as below
To sum up, Python Development In Visual Studio 2017″ explores the features, benefits, and performance of using Python in Visual Studio 2017. It highlights the advantages of this development environment, including enhanced coding experience, improved productivity, and streamlined workflows. The blog provides a comprehensive guide to Python development in Visual Studio 2017, showcasing the tools and resources available to maximize coding efficiency. It emphasizes the seamless integration of Python and Visual Studio 2017, offering a rich ecosystem for developers to elevate their Python projects.
Related Links
https://www.python.org/
https://www.python.org/downloads/
https://docs.python.org/3/contents.html
Conclusion
I think this session may help for Python beginners as well as .NET guys.
Add a Comment