RE: [Tutor] Re: when to use properties?

2005-04-13 Thread Ryan Davis
I agree with Andrei: Use an instance variable until you need it to do something special, and then convert it to a property. Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrei Sent: Wednesday, April 13, 2005 2:41 AM To: tutor@python.org

RE: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Ryan Davis
Make a flowchart, by hand, on paper of what this program does. That should help explain the why. Basically, after 3 attempts, your "while" loop becomes an infinte loop. Once you are over the count, the user is never prompted for another password, so the password remains not equal to "unicorn"

RE: [Tutor] Talking to mssql?

2005-04-11 Thread Ryan Davis
I couldn't compile it either, but got it working by copying the MSSQL.py and bin/python2.3/mssqldb.pyd from the archive to my site-packages directory. He scarcely mentions that option at the bottom of the install page: http://www.object-craft.com.au/projects/mssql/install.html. Not sure if the b

RE: [Tutor] Talking to mssql?

2005-04-07 Thread Ryan Davis
I had the same question. The best I found is this: http://www.object-craft.com.au/projects/mssql/ but that has a lot of strong language saying "this isn't ready for use". I found it perfectly usable for simply running queries, but haven't tried to do anything more complicated with it. Not sure

[Tutor] database access to MSSQL

2005-04-06 Thread Ryan Davis
Does anyone know of a decent way to access a SQL Server 2000 database? I've gotten some versions working using dbi,odbc and defining a DSN on the computer, but I'd like to be able to specify a server, user, pass, and database in code. As far as I can tell, I'd have to define a DSN for every dat

RE: [Tutor] A simple question about creating a program

2005-03-30 Thread Ryan Davis
Sure. Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Sent: Wednesday, March 30, 2005 4:00 PM To: tutor@python.org Subject: [Tutor] A simple question about creating a program I was wondering, can you make a program the uses alot of cla

RE: [Tutor] Python and Javascript

2005-03-25 Thread Ryan Davis
HTML page? If not, making a GUI might be an alternative that sidesteps this altogether. Thanks, Ryan -Original Message- From: Mike Hall [mailto:[EMAIL PROTECTED] Sent: Friday, March 25, 2005 3:46 PM To: Ryan Davis Cc: tutor@python.org Subject: Re: [Tutor] Python and Javascript Ryan

RE: [Tutor] Python and Javascript

2005-03-25 Thread Ryan Davis
Depends on your environment. If your js is on a webpage, you can have it make http calls to a python web service. Look for articles on XMLHttpRequest in javascript to see some examples. I don't know how else that could be done, but I imagine there are other ways. Thanks, Ryan -Original M

RE: [Tutor] a shorter way to write this

2005-03-25 Thread Ryan Davis
A comprehension and range? # >>> list1 = [1 for x in range(0,96)] >>> len(list1) 96 # Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of jrlen balane Sent: Friday, March 25, 2005 2:03 PM To: Tutor Tutor Subject: [Tutor] a shorter way to write

RE: [Tutor] Defining functions

2005-03-24 Thread Ryan Davis
Did you put them in quotes? # If choice == 'c': ... # Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Carmona Sent: Thursday, March 24, 2005 5:52 PM To: tutor@python.org Subject: [Tutor] Defining functions Hi there, I have written

RE: [Tutor] List comprehensions

2005-03-23 Thread Ryan Davis
I'm not sure if you can or want to do this solely one list comprehension. You could make a helper function and use map: ### def helper(i): i.pop(3) return map(int, i) a = map(helper, x) ### Description of map: http://docs.python.org/lib/built-in-funcs.html I think map is a little clea

RE: [Tutor] Initializing with a call like: someClass.open("someFile")?

2005-02-21 Thread Ryan Davis
You could make the __init__ take the filename: def __init__(self, filename=None): #do whatever And then instantiate the object like: >>>x = someClass(filename="someFile") Alternatively, you could make the Open function a module level function, defined in someClass.py, but not in the actual c

RE: [Tutor] count words

2005-02-15 Thread Ryan Davis
You could use split() to split the contents of the file into a list of strings. ### >>> x = 'asdf foo bar foo' >>> x.split() ['asdf', 'foo', 'bar', 'foo'] ### Here's one way to iterate over that to get the counts. I'm sure there are dozens. ### >>> x = 'asdf foo bar foo' >>> counts = {} >>> for

RE: [Tutor] Larger program organization

2005-02-13 Thread Ryan Davis
s, Ryan -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Saturday, February 12, 2005 3:52 AM To: EJP; Ryan Davis; tutor@python.org Subject: Re: [Tutor] Larger program organization > without trying to make this one of those classic threads of great, > do you f

[Tutor] Larger program organization

2005-02-11 Thread Ryan Davis
pay for before I can make any reasonable argument. Thanks, Ryan Ryan Davis Director of Programming Services http://www.acceleration.net/   ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

RE: [Tutor] Syntax Check

2005-01-27 Thread Ryan Davis
Check out COG (http://www.nedbatchelder.com/code/cog/), a macro system for any language created by Ned Batchelder (http://www.nedbatchelder.com/). I'm not sure if that's what you're looking for, but allows some good macro capabilities. Thanks, Ryan -Original Message- From: [EMAIL PROT

RE: [Tutor] Importing multiple files as a single module?

2005-01-21 Thread Ryan Davis
I'm having the same problem, and am eager to hear the responses. As far as a "real" IDE, emacs works pretty well, and check out Komodo, the ActiveState IDE: http://www.activestate.com/Products/Komodo/ Thanks, Ryan -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] O

RE: [Tutor] import question (solved)

2005-01-10 Thread Ryan Davis
each script: >>> import sys >>> sys.path.append('../') Thank you all very much for you help. Thanks, Ryan -Original Message- From: Jacob S. [mailto:[EMAIL PROTECTED] Sent: Friday, January 07, 2005 9:37 PM To: Alan Gauld; Ryan Davis; Tutor@python.org Subject: Re:

RE: [Tutor] walking directories

2005-01-07 Thread Ryan Davis
I think you want to be doing something like: >>>for r,d,f in os.walk('.'): ... for filename in f: ... print os.path.join(r,filename) I think that would give you the full path of every file, and then you can open it, do a regex substitution or whatever close it and keep going. Th

[Tutor] import question

2005-01-07 Thread Ryan Davis
Hello all,   I'm just starting to use python seriously, and am having problems understanding exactly what is going on with import statements and the sys.path variable.   I'm trying to import classes and functions across several directories.  Here's a simple example of my filesystem: /D