[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ossig] Python 2.3 is out!



Importing from zip archives (ala java jar),
Simple word searching in strings,
Generators, Sets (as standard datatype), oh my!

http://www.python.org/doc/2.3/whatsnew/

Elaboration of the string thing above:
--------------------------------------
The in operator now works differently for strings.
Previously, when evaluating X in Y where X and Y are
strings, X could only be a single character. That's
now changed; X can be a string of any length, and X in
Y will return True if X is a substring of Y. If X is
the empty string, the result is always True.

>>> 'ab' in 'abcd'
True
>>> 'ad' in 'abcd'
False
>>> '' in 'abcd'
True

Note that this doesn't tell you where the substring
starts; if you need that information, use the find()
string method. 
------------------

This is useful and quick if you want to see if a
certain substring exists in another string:

import xyz

mystring = xyz.getmystring(someEmail)
if "milk powder factory" in mystring:
  print "Yes, we have proof they have WMD's!"


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com


------------------------------------------------------------
To unsubscribe: send mail to ossig-request@mncc.com.my
with "unsubscribe ossig" in the body of the message