+ Reply to Thread
Results 1 to 3 of 3

Thread: Python frequently asked questions

  1. #1
    v0id is offline Retired
    Join Date
    Apr 2007
    Posts
    2,937
    Blog Entries
    3
    Rep Power
    42

    Python frequently asked questions

    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.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2008
    Location
    ┌∩┐(◣_◢)┌∩┐
    Posts
    1,579
    Blog Entries
    1
    Rep Power
    26

    Re: Python frequently asked questions

    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.”

  4. #3
    Vladimir is offline Learning Programmer
    Join Date
    Nov 2010
    Posts
    79
    Rep Power
    5

    Re: Python frequently asked questions

    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:
    Code:
    age = int(raw_input("Please enter your age: ")) # reads user age from prompt and converts it to integer
    Must read: 7. Input and Output — Python v2.7.1 documentation

    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:
    Code:
    print("Your age: " + age) # results in TypeError
    This happens because Python does not know how to concatenate str and int:
    Code:
    print("Your age: " + str(age)) # note type conversion from integer to string
    But better way is using String formatting:
    Code:
    print("Your age: %d" % age) # code looks cleaner, python automatically handles type conversion
    During debugging you can use string formatting to display content of dict, list, etc:
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. PHP Guide: Fequently Asked Questions
    By Alexander in forum PHP Development
    Replies: 9
    Last Post: 01-31-2012, 11:14 PM
  2. C/C++ frequently asked questions
    By v0id in forum C and C++
    Replies: 18
    Last Post: 06-12-2011, 04:06 PM
  3. please read and help me with the few questions i have asked
    By hathaway919 in forum C# Programming
    Replies: 1
    Last Post: 06-28-2010, 12:08 PM
  4. Mine less asked questions
    By asafe in forum C and C++
    Replies: 2
    Last Post: 09-26-2009, 02:42 PM
  5. The less asked questions
    By ZekeDragon in forum C and C++
    Replies: 26
    Last Post: 09-26-2009, 01:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts