As well as many bugfixes, the other positives for me are:
- In some cases code execution is faster, and it launches 2.5 times faster.
- Since I do alot of my IronPython work with Mono, I can now finally exit using Control-D
I am an "old" computer engineer & programmer, not old enough to have a punch card story but old enough to - have owned a Zx-81 - programmed in Motorola 6809 assembler - remember when 64K was lots of RAM - fixed a hard disk by replacing the platter
import imp
import sys
moduleName = 'socket'
moduleSource = './Lib.ip/socket.py'
newModule = imp.new_module(moduleName)
execfile(moduleSource, newModule.__dict__)
sys.modules[moduleName] = newModule
import socket
The Sydney Python group is having its first meeting for the year on Thursday July 27.
Usual time and new place:
Thursday, July 27, 2006 (6:30 PM - 8:30 PM)
The "new" University of Sydney School of IT Building.
Thanks to Bob Kummerfeld for arranging this.
The venue is approx 1 km from both Central and Redfern stations.
Use the entrance from the University side, not the Cleveland St side. If you come from City Rd, enter the Seymour Centre forecourt and follow the curve of the new building down to the foyer entrance.
http://www.cs.usyd.edu.au/~dasymond/index.cgi?p=Map
Please reply to this message (or click the appropriate radio button on http://upcoming.org/event/89388) if you will be coming.
Talks:
Graham Dumpeton on what is coming in the next major version of mod_python (3.3). This version of mod_python should represent a significant improvement over previous versions in certain areas with ramifications on stability. New features have also been added which make mod_python a bit more flexible than it is now and more useable in the way that Apache modules should be able to be used. Result is that mod_python can truly be used for more than just a jumping off point for stuff like WSGI and all those Python web frameworks that
keep popping up every day.
I will be giving a talk on my experiences in using IronPython with .NET and Mono.
The talks will be 15-20 minutes in length with plenty of time for questions.
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import *
class MyForm(Form):
def __init__(self):
Form.__init__(self)
Button1 = Button()
Button1.Top = 10
Button1.Left = 10
Button1.Text = "One"
Button2 = Button()
Button2.Top = 50
Button2.Left = 10
Button2.Text = "Two"
ctrls = [Button1, Button2]
self.Controls.AddRange(ctrls)
f = MyForm()
Application.Run(f)
ctrls = [Button1, Button2]to:
ctrls = System.Array[System.Windows.Forms.Control]( (Button1, Button2) )
import Systemafter the
import clrline.
from sqlalchemy import *The option echo is set so we can view the generated SQL.
engine = create_engine("sqlite://filename=mydb",echo=True)
entries = Table('entries', engine,
Column('entry_id', Integer, primary_key = True),
Column('title', String(255), nullable = True),
Column('content', String(), nullable = True),
Column('status', String(10), nullable = False),
Column('creation_date', DateTime()),
Column('publish_date', DateTime())
)
comments = Table('comments', engine,
Column('comment_id', Integer, primary_key = True),
Column('entry_id', Integer, ForeignKey("entries")),
Column('comment', String(255), nullable = False),
Column('submitter', String(60), nullable = False),
Column('submit_date', DateTime())
)
# Create the tables
entries.create()
comments.create()
Now load some data. entries.insert().execute(entry_id=1,Get some data with a simple select with where clause and order by
title="My first blog entry",
content="A blogging I will go.....",
status="published",
creation_date="2006-04-17 08:15:30",
publish_date="2006-04-17 08:25:00")
entries.insert().execute(entry_id=2,
title="My second blog entry",
content="Another day, another blog entry....",
status="draft",
creation_date="2006-04-18 09:35:30")
comments.insert().execute(comment_id=1,
entry_id=1,
comment="The entry needs more substance.",
submitter="joe.blogger@home.net",
submit_date="2006-04-17 09:05:00")
comments.insert().execute(comment_id=2,
entry_id=1,
comment="I disagree with the first comment.",
submitter="jane.doe@rip.net",
submit_date="2006-04-17 09:05:00")
cursor = entries.select(entries.c.status=='published',Now a simple join
order_by=[entries.c.publish_date]).execute()
rows = cursor.fetchall()
for row in rows:
# Get column data by index
title = row[1]
# by column name
content = row['content']
# by column accessor
status = row.status
cursor = comments.select(comments.c.entry_id==entries.c.entry_id).execute()which generates the following SQL:
SELECT comments.comment_id, comments.entry_id, comments.comment,Of course, this quick overview only scratches the surface of what you can do with SQLAlchemy. It also has support for outer joins, subqueries, unions, updates and deletes. See here for more in depth documentation.
comments.submitter, comments.submit_date
FROM comments, entries
WHERE comments.entry_id = entries.entry_id