Before posting make sure to read the FAQ, and be sure to follow its rules as well.
This thread is meant as another FAQ which is specialized in this forum, the Python forum, particular, and the language itself. If you read this before creating a thread or a post you may avoid asking already frequently asked questions.
I want to learn Python, what do I do?
Python is an interpreted language. This means that your sourcecode will not be compiled into machine code, like C++ and many other languages, but it will be interpreted by a program: an interpreter. There is many implementations of Python, but the official one is called CPython, and is also simply known as the official Python.
This is the basic tool every Python programmer needs in order to get started programming. Other tools include debuggers for debugging and IDEs for easily management of sourcecode and interpreting.
When you have the tools you need, you only need to learn the language. This can be done in multiple ways. One can learn a lot completely free directly from the internet, and from this knowledge achieved from the internet being able to create beautiful applications. If you however don't mind paying some cash, or need in-depth information, one of the best choices is to get your hands on a book. Books will normally go more into details, than most websites will.
The best choice is to join a programming-class or course. In this way you'll be able to ask your teacher the questions you have on mind, and try out new stuff in a positive environment
Is this tool better than that tool?
This is mostly a matter of taste. Different people prefer different tools: maybe because it's faster; maybe because it's easier to use; maybe because it looks good; etc. So, if you're asking such question you must be prepared to get many different replies, which all states different things.
Investigating and collecting information about different tools is a better solution. In that way you learn about the different tools, and you also find out whether they fit you or not. If you finally end up with two or maybe three tools, and cannot choose, then you can go to the forums and ask us for our opinion. In that way you will get specific replies to the tools you're considering, and not some tools you don't even know about.
You can find a list of tools, books, websites, and other general resources for Python in the Python resource thread.
You yet to let me down v0id!
#!CrunchBang Linux ~$ apt-get into it | #!(Statler:R20101205): OpenBox | Like Linux?
“The cure for boredom is curiosity. There is no cure for curiosity.”
How to handle user input using Command Line Interface?
There are two global functions: input() and raw_input. First evaluates input as Python expression and is unsafe. You typically have to use raw_input(). Example:
Must read: 7. Input and Output — Python v2.7.1 documentationCode:age = int(raw_input("Please enter your age: ")) # reads user age from prompt and converts it to integer
How to handle output to the user using CLI?
There is a built-in function print(). Your first attempt to show user his age may look like this:
This happens because Python does not know how to concatenate str and int:Code:print("Your age: " + age) # results in TypeError
But better way is using String formatting:Code:print("Your age: " + str(age)) # note type conversion from integer to string
During debugging you can use string formatting to display content of dict, list, etc:Code:print("Your age: %d" % age) # code looks cleaner, python automatically handles type conversion
Code:user_1 = {'name': 'Vladimir', 'site': 'forum.codecall.net'} print 'User_1 name: ' + user_1['name'] # this print 'User_1 site: ' + user_1['site'] # is ugly print 'user_1 = %r' % user_1 # nice way
Last edited by Vladimir; 12-05-2010 at 12:36 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks