Testing Whether an Object is String-like

A simple and fast way to check whether something is a string or Unicode object is to use the built-ins isinstance and basestring, as follows

def isString(anObj):
         return isinstance(anObj,basestring)

Python Tutorials

Python tutorials for beginner to advance level programmer including video tutorials.

Video Tutorials

Categorized Tutorials

Beginners (20)

General and Advanced (14)

Internet: Django (9)

Extending and Embedding (8)

Games (7)

GUI Programming: General and Miscellaneous (10)

GUI Programming: Tkinter (10)

GUI Programming: wxPython and PythonCard (11)

GUI Programming: pyGTK and Gnome (16)

GUI Programming: QT and KDE (6)

HTML and XML (35)

Internet: Network and Web Programming (16)

Web Scraping, Screen Scraping (3)

Internet: CGI (5)

Python CGI FAQ

Internet: Web Frameworks-Turbogears and Cherry Pie (7)

Internet: Web Frameworks-Twisted (5)

Internet: Web Frameworks- Zope and Plone (5)

Internet: Web Frameworks-Other (4)

Internet: Django (9)

Jython (12)

Testing, Test Driven Programming and Unit Test (5)

Editors and IDE’s (7)

Mac and Apple (13)

Windows (14)

IronPython (7)

Decorators (6)

Generators and Iterators (7)

Database (12)

Biology and Bioinformatics (7)

Statistics(1)

Math, Science, and Physics (38)

OOP, Objects, and Object Orientation(6)

Descriptors(2)


Design Patterns(6)

Introspection(1)

Metaclasses(5)

Firedrop (2)

Weblog and Content Management System

  • Firedrop Plug-ins Tutorial Firedrop is a (Programmable with Plug-ins) Python (and Wax) Blog Client Manager Tool and Content Management System

Concurrent Programming (2)

Stackless Python (5)

Threads (11)

Threads and Concurrent Programming

  • Python Threads PDF file, click on “threads” at top of html page

Unicode (7)

  • Python Unicode Tutorial

Continuations (3)

Continuations

Regular Expressions (5)

Text and String Processing (4)

Linguistics and Natural Language Processing (5)

VPython (6)

Curses (3)

Searching and Sorting (4)

Python and Simulation (4)

  • Python as a Discrete Event Simulation environment
  • Quick and Painless Monte Carlo Simulation
  • Quick and Painless SimPy Tutorial SimPy is for Discrete Event Simulation

Search Engines and Social Software (7)

Python on Mobile Devices (2)

Flash (3)

  • A tutorial on connecting client-side Flash applications to Python XML-RPC web services
  • Embedding Flash in Python
  • Tutorial: Macromedia Flash served by Python

Robotics (3)

Functional Programming (5)

Genetic Algorithms and Python (1)

Date and Time Usage (1)

Neural Networks (3)

Pickle (1)

PyPy (1)

Miscellaneous Specific Topics (22)

Cryptography

Documentation and Reference (11)

Python Zip Compression

Send email using python script in Plone

If you dont want to hardcode the Mail Host id into your script and want to be able to send email to someone from within a (Script) Python this script will do it.

try:
    mailhost=getattr(context, context.superValues('Mail Host')[0].id)
except:
    raise AttributeError, "cant find a Mail Host object"

mMsg = 'a testful email message \n that contains a few line breaks. \n ~runyaga'
mTo = 'runyaga@abc.com'
mFrom = 'runyaga@xyz.com'
mSubj = 'mail subject'

mailhost.send(mMsg, mTo, mFrom, mSubj)

Random password generator Python script

A Simple and effective two line python code for password generator.

A short, readable password generator that can be launched from the command line. Just launch it from the shell and it will print out an 8-character password. You can also specify the length.

string_list = [ch for ch in string.digits if not ch in '10'] + \
               [ch for ch in string.ascii_uppercase if not ch in 'LO']  + \
                [ch for ch in string.ascii_lowercase if not ch in 'lo'] 

return string.join(random.sample(string_list,8),'')