Python
  Home arrow Python arrow Page 8 - Python 101 (part 5): Snake Oil For The...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Python 101 (part 5): Snake Oil For The Soul
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2001-07-09

    Table of Contents:
  • Python 101 (part 5): Snake Oil For The Soul
  • Air In A Bottle
  • Treading The Right Path
  • Standing In Line
  • Learning To Write
  • Desperately Seeking Python
  • String Theory
  • Pop() Goes The Weasel

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Python 101 (part 5): Snake Oil For The Soul - Pop() Goes The Weasel


    (Page 8 of 8 )

    The pop() function allows you to remove an item from the end of a list,

    >>> list ['red', 'green', 'blue', 'red', 'yellow', 'blue', 'black', 'white', 'green'] >>> len(list) 9 >>> list.pop() 'green' >>> len(list) 8 >>>
    and the str() function converts a list into a printable string.

    >>> list ['red', 'green', 'blue', 'red', 'yellow', 'blue', 'black', 'white', 'green'] >>> str(list) "['red', 'green', 'blue', 'red', 'yellow', 'blue', 'black', 'white', 'green']" >>>
    Finally, the max() and min() methods return the largest and smallest itemwithin a string, list or tuple.

    >>> # list >>> friends = ["Rachel", "Ross", "Joey", "Phoebe", "Monica", "Chandler"] >>> max(friends) 'Ross' >>> min(friends) 'Chandler' >>> # string >>> alphabet = "abcdefghijklmnopqrstuvwxyz" >>> min(alphabet) 'a' >>> max(alphabet) 'z' >>> # tuple >>> num = (1,2,3) >>> max(num) 3 >>> min(num) 1 >>>
    And that's about it for the moment. In this article, you learnt how to opena connection between your Python program and a file residing on yourfilesystem. You then learnt how to use built-in Python methods to read datafrom and to that file, together with some additional methods and propertiesthat might come in useful. Finally, you've also added to your store ofPython knowledge with a look at some of the new features available inPython 2.x.

    Over the next few article, we'll be elevating our view a little, with alook at the Python framework for software abstractions like functions,classes and modules. Specifically, in the next article, I'll be showing youhow to build your own functions, and also discussing return values andarguments in the context of a Python program. Make sure you don't miss thatone!
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway