Re: [Tutor] How create a grade book
magnus at thinkware.se
Fri Jun 4 12:59:37 EDT 2004
> I have just began to use python from the intactive screen. I wrote a small
> program that ran fine. Now I want to write a program that accept use input and
> perform calculations. Specifically, I want to write a grade book that
> conisist of student name, grade, subjects, average, date, and objective. However, I
> don't know how to connect pyton to visual basic by COM.
I don't think COM will make that any easier, but you *can* certainly
make Python work with COM. You need some kind of interface though.
Plain Python doesn't interact with COM. The most COMmon way is to
use the win32all extensions. The Python download page for Windows link
to them. (It's included if you use ActiveState Python).
Here is some excerpts of code from a program that writes stuff in an
Excel sheet. You need to add some data in the variables etc to make it
xl = win32com.client.Dispatch('Excel.Application')
xl.Visible = True
for sheetNo in range(MIN_SHEET,MAX_SHEET+1):
sheet = xl.Worksheets[sheetNo-1]
for row in range(MIN_ROW, MAX_ROW+1):
for col in range(MIN_COL,MAX_COL+1):
values = persons.get((sheetNo, row, col), 'X')
sheet.Cells(row, col).Value = values[:65000]
sheet.Cells(row, col).Value = '.'
This was the closest example I had at hand. I don't really have time
to write you a proper, working example now. I hope you can read through
the noise and extract something intelligent from it.
There's a book called "Python Programming on Win32" which explains the
issues well, and a mailing list available through
Another option is to use ctypes:
but I don't know how mature that is.
> I tried to set a com
> server and I have had no luck. Is it because i'm using the XP operating
Well, if you used Linux, you wouldn't even try, so perhaps? ;) Seriously,
this *should* work on XP.
It's very difficult to for anyone to see what you are doing wrong if
you don't show us your code.
> Also, If you have any example code for setting-up a database file or
> which do you recommend using with python. I have many more questions but I think
If you come to the EuroPython Conference at Chalmers University of Technology
in Göteborg, Sweden next week, you can listen to my talk about database programming
on Wednesday morning. :) Or if you can't I should be able to provide you with my
presentaion as a PDF by then, but it's not quite done yet. I'll try to remember to
post them on my site and to announce it here.
> this is a load. Please, Please respond because I really want to learn this
> language. Thanks Cliff
If you are familiar with SQL, you could start with pysqlite.
See http://pysqlite.sourceforge.net/ You can get some examples of its
use at http://pysqlite.sourceforge.net/manual.html
If you want to access some database through ODBC you probably want mxODBC.
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/ mailto:magnus at thinkware.se
More information about the Tutor