Changeset 388 for python/vendor/current/Doc/includes
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/Doc/includes
- Files:
-
- 3 added
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Doc/includes/email-alternative.py
r2 r388 1 #! /usr/bin/python1 #!/usr/bin/env python 2 2 3 3 import smtplib -
python/vendor/current/Doc/includes/email-dir.py
r2 r388 106 106 fp.close() 107 107 else: 108 s = smtplib.SMTP( )108 s = smtplib.SMTP('localhost') 109 109 s.sendmail(opts.sender, opts.recipients, composed) 110 110 s.quit() -
python/vendor/current/Doc/includes/email-mime.py
r2 r388 27 27 28 28 # Send the email via our own SMTP server. 29 s = smtplib.SMTP( )29 s = smtplib.SMTP('localhost') 30 30 s.sendmail(me, family, msg.as_string()) 31 31 s.quit() -
python/vendor/current/Doc/includes/email-simple.py
r2 r388 20 20 # Send the message via our own SMTP server, but don't include the 21 21 # envelope header. 22 s = smtplib.SMTP( )22 s = smtplib.SMTP('localhost') 23 23 s.sendmail(me, [you], msg.as_string()) 24 24 s.quit() -
python/vendor/current/Doc/includes/email-unpack.py
r2 r388 36 36 try: 37 37 os.mkdir(opts.directory) 38 except OSError ,e:38 except OSError as e: 39 39 # Ignore directory exists error 40 40 if e.errno != errno.EEXIST: -
python/vendor/current/Doc/includes/minidom-example.py
r2 r388 20 20 21 21 def getText(nodelist): 22 rc = ""22 rc = [] 23 23 for node in nodelist: 24 24 if node.nodeType == node.TEXT_NODE: 25 rc = rc + node.data26 return rc25 rc.append(node.data) 26 return ''.join(rc) 27 27 28 28 def handleSlideshow(slideshow): -
python/vendor/current/Doc/includes/sqlite3/complete_statement.py
r2 r388 24 24 if buffer.lstrip().upper().startswith("SELECT"): 25 25 print cur.fetchall() 26 except sqlite3.Error ,e:26 except sqlite3.Error as e: 27 27 print "An error occurred:", e.args[0] 28 28 buffer = "" -
python/vendor/current/Doc/includes/sqlite3/ctx_manager.py
r2 r388 9 9 10 10 # con.rollback() is called after the with block finishes with an exception, the 11 # exception is still raised and must be ca tched11 # exception is still raised and must be caught 12 12 try: 13 13 with con: -
python/vendor/current/Doc/includes/sqlite3/execute_1.py
r2 r388 1 1 import sqlite3 2 2 3 con = sqlite3.connect("mydb") 4 3 con = sqlite3.connect(":memory:") 5 4 cur = con.cursor() 5 cur.execute("create table people (name_last, age)") 6 6 7 7 who = "Yeltsin" 8 8 age = 72 9 9 10 cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) 10 # This is the qmark style: 11 cur.execute("insert into people values (?, ?)", (who, age)) 12 13 # And this is the named style: 14 cur.execute("select * from people where name_last=:who and age=:age", {"who": who, "age": age}) 15 11 16 print cur.fetchone() -
python/vendor/current/Doc/includes/sqlite3/executemany_2.py
r2 r388 1 1 import sqlite3 2 import string 2 3 3 4 def char_generator(): 4 import string 5 for c in string.letters[:26]: 5 for c in string.lowercase: 6 6 yield (c,) 7 7 -
python/vendor/current/Doc/includes/sqlite3/rowclass.py
r2 r388 1 1 import sqlite3 2 2 3 con = sqlite3.connect(" mydb")3 con = sqlite3.connect(":memory:") 4 4 con.row_factory = sqlite3.Row 5 5 6 6 cur = con.cursor() 7 cur.execute("select name_last, age from people")7 cur.execute("select 'John' as name, 42 as age") 8 8 for row in cur: 9 assert row[0] == row["name _last"]10 assert row["name _last"] == row["nAmE_lAsT"]9 assert row[0] == row["name"] 10 assert row["name"] == row["nAmE"] 11 11 assert row[1] == row["age"] 12 12 assert row[1] == row["AgE"] -
python/vendor/current/Doc/includes/sqlite3/shared_cache.py
r2 r388 2 2 3 3 # The shared cache is only available in SQLite versions 3.3.3 or later 4 # See the SQLite documentat on for details.4 # See the SQLite documentation for details. 5 5 6 6 sqlite3.enable_shared_cache(True) -
python/vendor/current/Doc/includes/sqlite3/shortcut_methods.py
r2 r388 18 18 print row 19 19 20 # Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. 21 print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" 20 print "I just deleted", con.execute("delete from person").rowcount, "rows" -
python/vendor/current/Doc/includes/sqlite3/text_factory.py
r2 r388 3 3 con = sqlite3.connect(":memory:") 4 4 cur = con.cursor() 5 6 # Create the table7 con.execute("create table person(lastname, firstname)")8 5 9 6 AUSTRIA = u"\xd6sterreich" … … 18 15 cur.execute("select ?", (AUSTRIA,)) 19 16 row = cur.fetchone() 20 assert type(row[0]) ==str17 assert type(row[0]) is str 21 18 # the bytestrings will be encoded in UTF-8, unless you stored garbage in the 22 19 # database ... … … 30 27 u"\xe4\xf6\xfc".encode("latin1"),)) 31 28 row = cur.fetchone() 32 assert type(row[0]) ==unicode29 assert type(row[0]) is unicode 33 30 34 31 # sqlite3 offers a built-in optimized text_factory that will return bytestring … … 37 34 cur.execute("select ?", (AUSTRIA,)) 38 35 row = cur.fetchone() 39 assert type(row[0]) ==unicode36 assert type(row[0]) is unicode 40 37 41 38 cur.execute("select ?", ("Germany",)) 42 39 row = cur.fetchone() 43 assert type(row[0]) ==str40 assert type(row[0]) is str -
python/vendor/current/Doc/includes/tzinfo-examples.py
r2 r388 72 72 tt = (dt.year, dt.month, dt.day, 73 73 dt.hour, dt.minute, dt.second, 74 dt.weekday(), 0, -1)74 dt.weekday(), 0, 0) 75 75 stamp = _time.mktime(tt) 76 76 tt = _time.localtime(stamp)
Note:
See TracChangeset
for help on using the changeset viewer.