23rd May, 2008

OSDC 2008 Call For Papers

Filed under: General — admin @ 1:37 pm

In case you haven’t seen this elsewhere;

Call for Papers
Open Source Developers’ Conference 2008
2nd – 5th December 2008, Sydney, Australia

The Open Source Developers’ Conference 2008 is a conference run by open source developers, for developers and business people. It covers numerous programming languages across a range of operating systems, and related topics such as business processes, licensing, and strategy. Talks vary from introductory pieces through to the deeply technical. It is a great opportunity to meet, share, and learn with like-minded individuals.

This year, the conference will be held in Sydney, Australia during the first week of December (2nd – 5th). If you are an Open Source maintainer, developer or user, the organising committee would encourage you to submit a talk proposal on open source tools, solutions, languages or technologies you are working with.

For more details and to submit your proposal(s), goto: http://osdc.com.au/2008/papers/cfp.html

If you have any questions or require assistance with your submission, please don’t hesitate to ask!

We recognise the importance of Open Source in providing a medium for collaboration between individuals, researchers, business and government. In recognition of this and ensure a high standard of presentations, we intend to peer-review all submitted papers.

OSDC 2008 Sydney (Australia) – Key Program Dates:

30 Jun – Initial proposals (short abstract) due
21 Jul – Proposal acceptance
15 Sep – Accepted paper submissions
13 Oct – Reviews completed
27 Oct – Final paper submission cutoff

For all information, contacts and updates, see the OSDC conference web site at http://osdc.com.au/2008/

Also if you are interested in sponsoring, please see: http://www.osdc.com.au/2008/sponsors/opportunities.html

9th May, 2008

Opening a file in Python

Filed under: General — admin @ 9:01 pm

I’m sure I read this somewhere recently, but my scratchy memory and command of Google can’t bring it back to me.

Is there a Python idiom for accepting either a file name or a file object as a function parameter?

The closest I can get is this;

def my_function(file_name_or_object):
    try:
        open(file_name_or_object)
    except TypeError:
        file = file_name_or_object
    return file

Any improvements on this are more than welcome.

Trouble Getting a Date

Filed under: database,python — admin @ 8:04 am

I’m having trouble with dates. This can be summed up in a couple of high level issues;

1. Date support in relational databases is insane, or at the best inconsistent.

As far as I can tell the ANSI SQL-92 standard defines date, time, interval and timestamp data types. Which doesn’t help when SQL Server only implements something called ‘datetime’ – at least I think so, have you tried accessing any sort of manual for a Microsoft product online? Blimey, I thought billg had embraced this web thing years ago. Oracle has the ‘date’ data type (which is actually a time stamp) and MySQL, well they’ve gone and outdone everyone by implementing DATETIME, DATE, TIMESTAMP, TIME, and YEAR.

2. The Python DB-API does not cope with date data type ambiguity well.

When it comes to the date question the Python DB-API states (and I quote) ” … may use mx.DateTime”, which if you ask me isn’t much of a standard. This needs to change so that all DB-API modules return consistent datetime objects, not such a big issue as datetime has been part of the standard library since, what, Python 2.3?

Sadly even if we fix this it won’t work with Sqlite as it doesn’t consistently support data typing. In my experiments regardless of what sort of date you insert into the database you get a unicode string back. Don’t believe me? Try this in Python 2.5;

>>> from sqlite3 import dbapi2 
>>> db = dbapi2.connect('test_db')
>>> cursor = db.cursor()
>>> cursor.execute('create table date_test (id integer not null primary key autoincrement, sample_date DATE NOT NULL)'
>>> stmt = "INSERT INTO date_test (sample_date) VALUES (?)"
>>> cursor.execute(stmt, (1234, ))
>>> import datetime
>>> cursor.execute(stmt, (datetime.date(2008, 3, 10), ))
>>> cursor.execute(stmt, ('My name is Earl', ))
>>> db.commit()
>>> cursor.execute("SELECT * FROM date_test")
>>> results = cursor.fetchall()
>>> for item in results:
...     print item[1], type(item[1])
1234 
2008-03-10 
My name is Earl 
>>>

But note that it is fine for integers.

3. The people writing the Python standard library modules are on crack.

Outside of the database world and within the batteries included Python standard library some modules use datetime, others time and there are even uses of calendar.

O.K. I’ll accept that maybe the module authors aren’t on full strength crack, because the time module just exposes underlying posix functions. But the people who wrote those were on something strong and hallucinogenic. I table the following function signatures from section 14.2 of the Python Library Reference 2.5 as an example;

strftime(format[, t ]) 
strptime(string[, format ])

This has bitten me twice in the last twenty four hours and frankly I’m not happy.

I appreciate that there are historical reasons for having inconsistent function signatures but can someone please fix this in Python 3.0. All we need is a single module that can access the underlying system clock and then convert between a number of different representations of that and other epoch driven dates. How hard can it be? As far as I can tell this is not part of the proposed standard library re-organisation. I think it should be.

Powered by WordPress