ads

How to interact with Python (Python for Hackers Part -2)

If you haven't installed python yet. Here's how you can install python in your computer.

Now that you have installed Python, the next thing that you need to do is to learn how you can use it to explore features or to test a code. You can use Python using the script mode if you want to see how entire files or applications are interpreted.


To interact using Python, you can use the IDLE (Integrated Development Environment), which will pull up the Python shell window, or the command line in Windows.

Interacting Using the Command Prompt

The Windows command line (or the Terminal in Linux and Mac OS X) is the simplest and
straightforward way to start using Python. With this tool, you will be able to see how Python operates based on how it reacts to every command that you enter on the >>> prompt, which is also known as the interpreter prompt.



Take note that this might not be the most preferred way by hackers when it comes to interacting with this programming language, but this method will allow you to easily explore Python’s features.

To explore how Python operates, take a look at how the print command can be used to display
“Python is for hacking.”

•Pull up the Python command line.



•Once you see the >>> prompt, key in:

    print(“Python is for hacking.”)
 

•Hit Enter to end the command. Right after that, Python will display your requested text on the following line.

What will happen if you did something wrong with your command? If you used a faulty syntax, such as an incomplete statement or a misspelled command, you will get a display error that looks like this:


How to Exit Python

If you want to quit the Python prompt, use any of these commands:

Ctrl + Z, and then hit Enter
Or

Key in “quit()”
Or
Key in “exit()”

Interacting using the IDLE

When you are using a programming language, such as Python, you will need to develop your code using an integrated development environment or IDE. An IDE is an application that will provide you all the tools that you need to develop a software. Usually, these tools are a text editor that
will help you tweak the source code that you are working on, a debugger, and a set of tools for build automation which you can use through a GUI (graphical user interface). IDEs will also allow you to use integration with version control libraries that you can source from third parties, which means that you can pull up codes that are created by others and then mix and match them with your own code to get the results that you want.


You can get your preferred IDE from a third-party source, such as educational sites for programming languages, or from the developers of the language themselves. Python.org, for example, provides you a free IDE that you can use as a starting point to development, if you are
not sure which IDE will work best with your coding style.

The IDLE tool that comes with your installation package serves as a platform where you can efficiently key in your codes and interact with Python. You can easily pull up IDLE by clicking on its icon on your desktop, the Start Menu or locating it on the install folder.

IDLE allows you to use these features:

•The Python shell window which allows you to make use of color-coded code input and
output and get error messages if you input a wrong statement.

•A debugger that comes with stepping, local and global namespace viewing, and persistent breakpoints

•Browsers and configuration

•A text editor that allows you to use multiple windows, colorizing for Python, auto- completion, undo, and other features

Using IDLE will allow you to use two windows (the Shell and the Editor) which you can use simultaneously. You can also have output windows that have a different context menu and title. The menus that you can use in IDLE will change depending on the window that you have selected. The options that belong to each menu are straightforward, which means that you will not have a hard time understanding what each of them do even if you are new to programming.

Here are the menus and the window that they are associated with.



•File (for Editor and Shell windows)

This menu contains the following options:
1. New
2. Open
3. Recent Files
4. Open Module
5. Class Browser
6. Path Browser
7. Save
8. Save As
9. Save Copy As
10. Print Window
11. Close
12. Exit

•Edit (for Editor and Shell)

This menu contains the following options:
1. Undo
2. Redo
3. Cut
4. Copy
5. Paste
6. Select All
7. Find
8. Find Again
9. Find Selection
10. Find in Files
11. Replace
12. Go to Line
13. Show Completions
14. Expand Word
15. Show Call Tip
16. Show Surrounding Parens

•Format (Editor Window)

1. Indent Region
2. Dedent Region
3. Comment Out Region
4. Uncomment Region
5. Tabify Region
6. Untabify Region
7. Toggle Tabs
8. New Indent Width
9. Format Paragraph
10. Strip Trailing Whitespace

•Run (Editor window)

1. Python Shell
2. Check Module
3. Run Module

•Shell Menu (Shell window)

1. View Last Restart
2. Restart Shell
3. Interrupt Execution

•Debug (Shell window)

1. Go to File/Lie
2. Debugger
3. Stack Viewer
4. Auto-Open Stack Viewer

•Options (Editor and Shell windows)

1. Configure IDLE
2. Code Context (available only in Editor)

•Windows

1. Zoom Height

•Help

1. About IDLE
2. IDLE Help
3. Python Docs
4. Turtle Demo

Other Things You Can Use


You can write your codes in other IDEs or text editors other than IDLE, depending on your needs. There is no real guideline in choosing where you should type out and save your codes – as long as the editor that you are using helps you code comfortably and comes with syntax highlighting which
will help you visualize your code, then you will be able to achieve your hacking goals and create the code that you want to use in the future.

Interpreter Provided by Us for free

As many people don't have a computer but have keen interest in learning I always try to make out a way of learning for them with ease. As of learning Python I have added a Python Interpreter in my website where you can practice python coding. 
 

Here are other editors and their features that you might want to check out:

PyCharm Educational Edition


If you want to focus on learning Python instead of concentrating on how you should be navigating your windows, then this is the editor for you. You can pull up existing codes in the editor to learn how certain programs are written, or learn using the tutorial that comes with it.


You can download this free editor from www.jetbrains.com.

Sublime Text


Sublime Text allows you to use a package manager, which essentially works for any
person that is used to typing in word processors. It also comes with features such as code folding, which hides lines of codes that you are not working on. Take note that this is not a free software, but it does come with a trial period that does not have a time limit.

VIM


This free software will allow you to do lots of customizing, which is great if you are an 

experienced programmer that wants to work using settings that you are most comfortable with. Another plus factor to this software is that it has an extended history of usage, which means that you have a community of users that you can easily tap when you need some help.

If you are new to programming, this might feel like a daunting text editor to use, but the
steep learning curve will pay off in the end. By learning how to code through hacking
right away, you will be able to get a good grasp of Python as you experience it using
different tools that were already made by other hackers.

Coda


This software comes with a free trial for a week and then will cost $99 afterwards. Coda is not a text editor that is devoid of bells and whistles – it comes with features like SSH connectivity, code controls to connect automatically to a hub, and a Terminal interface. If you are gunning to develop a web app for your hacks, then this is probably the IDE that will work best for you.

Now that you have your development environment setup, it’s time for you to start learning about Python’s basic concepts. For that, stay tuned with this course as daily or alternatively articles will be uploaded on this course.

Post a Comment

0 Comments