[Tutor] Re: Tutor Digest, Vol 13, Issue 65

gerardo arnaez garnaez at gmail.com
Tue Mar 22 22:32:23 CET 2005


Hello,
Im a newbie python user,
love the way it "just makes sense"
but Im also a working doctor and have been thinking about coumadin
and how to dose it.

I am not sure where to ask this, so I am going to ask on this list for
two reasons
1. I intend to use python to prototype it.
2. There must some serious math dudes on this list or at least know
enough math to let me know what I am talking about or point me in the
right direction.

The question is,
When I adjust coumadin doses I normal have to use whole or half pills
of the medicien the patient already has.
Fer Instance, if a pt takes 5mg of coumadin a day, that's 35mg of coumadin week
and suppose I do a test that says thye are not taking enough coumadin
and to increase the dose by 10%, ie add another 3.5mg but have it
split evenly over the week or at least every other day.
normall, I would say ok
Take 5mg coumadine everty but on mon and thurs day take 7.5mg 
(Note the patient only has 5mg tabs, which they can split to make dose
adjust my 2.5)

My question is,
How would I solve this using math instead of geustimating it.
What kind of math am I talking about here?

If this is the wrong list, please point in the right direction.
i've tried googlie for help, but I dont know enough to even formulate it into a
a search expression

Thanks all

G



On Tue, 22 Mar 2005 19:30:17 +0100 (CET), tutor-request at python.org
<tutor-request at python.org> wrote:
> Send Tutor mailing list submissions to
>        tutor at python.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>        tutor-request at python.org
> 
> You can reach the person managing the list at
>        tutor-owner at python.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
> 
> Today's Topics:
> 
>   1. Re: OT - SQL methodology. (Kent Johnson)
>   2. Re: Very Newbie (Kent Johnson)
>   3. Re: Looking for a Pythonic way to pass variable number of
>      lists to zip() (Kent Johnson)
>   4. Visual Python from Active State (rkashyap at sympatico.ca)
>   5. Python cgi doesn't get data from html form as expected
>      (Vicki Stanfield)
>   6. Re: Python cgi doesn't get data from html form as expected
>      (Michael Lasky)
>   7. Re: Python cgi doesn't get data from html form as expected
>      (Vicki Stanfield)
>   8. Re: Python cgi doesn't get data from html form as expected
>      (Kent Johnson)
>   9. Re: Looking for a Pythonic way to pass variable (C Smith)
>  10. Re: primes - sieve of odds (C Smith)
>  11. Re: Looking for a Pythonic way to pass variable (Kent Johnson)
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Tue, 22 Mar 2005 06:00:16 -0500
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] OT - SQL methodology.
> Cc: Tutor Tutor <tutor at python.org>
> Message-ID: <423FFAC0.2010703 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Liam Clarke wrote:
> > Hi,
> >
> > This is a SQL query for the advanced db gurus among you (I'm looking at Kent...)
> 
> Uh oh, you're in trouble if you think I'm an "advanced db guru" :-)
> >
> > After I've run an insert statement, should I get the new primary key
> > (it's autoincrementing) by using PySQLite's cursor.lastrowid in a
> > select statement, or is there a more SQLish way to do this?
> 
> AFAIK there is no standard SQL way to do this, it is database-dependent. Python DB-API provides a
> portable interface using lastrowid; I would use that.
> 
> You don't have to do another select, lastrowid is an attribute of the cursor itself. It calls the
> SQLite function sqlite_last_insert_rowid().
> 
> > In the SQL books I've got, they always seem to have an optional select
> > statement on the end of inserts/updates, and I was thinking maybe I
> > could do it that way also, but I can't figure out a logical way of
> > putting
> >
> > 'select primary_key from foo where primary_key value > every other
> > primary_key value'
> 
> Use cursor.lastrowid, that's what it is for.
> 
> Kent
> 
> ------------------------------
> 
> Message: 2
> Date: Tue, 22 Mar 2005 06:09:03 -0500
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Very Newbie
> Cc: tutor at python.org
> Message-ID: <423FFCCF.9000508 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Terry Johnson wrote:
> > Hey to the tutors. I am a newbie of course about the only background is
> > some old qbasic and very little c and perl. I have been wanting to write
> >  my own Web Server Program and when I saw a few times mentioned around
> > python about it I am starting to check into it. If the is anyone who has
> > done such a thing or can oint me in the best direction for learning
> > about it please respond. Thanks in Advance
> 
> There are many options for doing this. For a very simple server you might look at the standard
> library modules mentioned by Lutz; there is also a CGIHTTPServer module. You can also write CGI
> programs in Python for use with another web server such as Apache. Basic information about writing
> CGI's in Python is here:
> http://www.python.org/topics/web/basic-cgi.html
> 
> Beyond that, the options multiply. This web page lists many of them:
> http://www.python.org/moin/WebProgramming
> Snakelets is one that is oriented toward ease of learning.
> Quixote, CherryPy and Twisted are probably the most popular.
> 
> If you give us some more information we might be able to help you narrow down the options a little.
> Is this just for fun and learning or will it be a production site eventually? Do you want to create
> dynamic content or just serve static web pages?
> 
> Ultimately though the selection is a matter of finding an alternative you are comfortable with.
> 
> Kent
> 
> ------------------------------
> 
> Message: 3
> Date: Tue, 22 Mar 2005 07:47:27 -0500
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Looking for a Pythonic way to pass variable
>        number of       lists to zip()
> Cc: p <tutor at python.org>
> Message-ID: <424013DF.7070401 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Shidai Liu wrote:
> > On Mon, 21 Mar 2005 22:51:31 -0800, Sean Perry <shaleh at speakeasy.net> wrote:
> >>arg_list = []
> >># fill up arg_list
> >>zipped = zip(*arg_list)
> >>
> >
> > I met a similar question.
> > what if one has L = [[1,2],[3,4]], K = [100, 200]
> 
> What do you want to do with these lists?
> 
> > How to 'zip' a List like [[1,2,100], [3,4,200]]?
> 
>  >>> zip(*[[1,2,100], [3,4,200]])
> [(1, 3), (2, 4), (100, 200)]
> 
> If that's not what you mean, please give an example of the input *and results* you want.
> 
> Kent
> 
> ------------------------------
> 
> Message: 4
> Date: Tue, 22 Mar 2005 8:58:06 -0500
> From: <rkashyap at sympatico.ca>
> Subject: [Tutor] Visual Python from Active State
> To: <tutor at python.org>
> Message-ID:
>        <20050322135806.GRSL1796.tomts6-srv.bellnexxia.net at mxmta.bellnexxia.net>
> 
> Content-Type: text/plain; charset=iso-8859-1
> 
> Hi,
> 
> I would like to get comments on Pros/Cons of using Visual Python.
> 
> On another note, I have created a couple of MS Access databases for my work.  At a recent conference, a lot of people have expressed an interest in using these as products for their own use.  I am looking for ways to code a mechanism to have license keys for evaluation (30day/60day trial, and fully licensed version, etc.).
> 
> I would like to use this opportunity to jump into using Python as the development platform if possible.  Most of the work I do is in the MS Office Professional.
> 
> regards,
> 
> Ramkumar
> 
> ------------------------------
> 
> Message: 5
> Date: Tue, 22 Mar 2005 14:02:17 -0000 (GMT)
> From: "Vicki Stanfield" <vicki at stanfield.net>
> Subject: [Tutor] Python cgi doesn't get data from html form as
>        expected
> To: tutor at python.org
> Message-ID: <1154.216.37.46.162.1111500137.squirrel at 216.37.46.162>
> Content-Type: text/plain;charset=iso-8859-1
> 
> I have recently started doing cgi in Python and have run into a problem. I
> have an html form which has various widgets which accept data. I also have
> this in that html file:
> 
> <form action="formdata.py" method="post">
> 
> formdata.py runs but doesn't seem to contain the data from the form. I'm
> not sure of the format for the for with regard to FieldStorage btw. Here
> is the contents of formdata.py:
> 
> ----------------
> #! /usr/bin/python
> import cgitb, os, sys
> cgitb.enable()
> 
> import cgi
> 
> print "Content-Type: text/html\n\n"
> print "<html><head></head><body>"
> form = cgi.FieldStorage()
> for each in form:
>        print "each"
> print form['fname'].value, form['lname'].value
> #print "address:", form['addr'].value()
> print "</body></html>"
> ------------------
> 
> ------------------------------
> 
> Message: 6
> Date: Tue, 22 Mar 2005 09:21:05 -0600
> From: Michael Lasky <mlasky1 at cox.net>
> Subject: Re: [Tutor] Python cgi doesn't get data from html form as
>        expected
> To: tutor at python.org
> Message-ID: <1111504866.17299.2.camel at localhost.localdomain>
> Content-Type: text/plain
> 
> I haven't done too much web stuff (or much of anything) with python, but
> I looked into your question a bit (researching other's problems may help
> me avoid them =)).  A quick search brought up this page which seems to
> have information which may help you.
> 
> http://gnosis.cx/publish/programming/feature_5min_python.html
> 
> Hope that helps.
> Best Regards,
> Michael Lasky
> 
> On Tue, 2005-03-22 at 14:02 +0000, Vicki Stanfield wrote:
> > I have recently started doing cgi in Python and have run into a problem. I
> > have an html form which has various widgets which accept data. I also have
> > this in that html file:
> >
> > <form action="formdata.py" method="post">
> >
> > formdata.py runs but doesn't seem to contain the data from the form. I'm
> > not sure of the format for the for with regard to FieldStorage btw. Here
> > is the contents of formdata.py:
> >
> > ----------------
> > #! /usr/bin/python
> > import cgitb, os, sys
> > cgitb.enable()
> >
> > import cgi
> >
> > print "Content-Type: text/html\n\n"
> > print "<html><head></head><body>"
> > form = cgi.FieldStorage()
> > for each in form:
> >         print "each"
> > print form['fname'].value, form['lname'].value
> > #print "address:", form['addr'].value()
> > print "</body></html>"
> > ------------------
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> 
> ------------------------------
> 
> Message: 7
> Date: Tue, 22 Mar 2005 15:33:40 -0000 (GMT)
> From: "Vicki Stanfield" <vicki at stanfield.net>
> Subject: Re: [Tutor] Python cgi doesn't get data from html form as
>        expected
> To: "Michael Lasky" <mlasky1 at cox.net>
> Cc: tutor at python.org
> Message-ID: <4738.216.37.46.162.1111505620.squirrel at 216.37.46.162>
> Content-Type: text/plain;charset=iso-8859-1
> 
> > I haven't done too much web stuff (or much of anything) with python, but
> > I looked into your question a bit (researching other's problems may help
> > me avoid them =)).  A quick search brought up this page which seems to
> > have information which may help you.
> >
> > http://gnosis.cx/publish/programming/feature_5min_python.html
> >
> > Hope that helps.
> > Best Regards,
> > Michael Lasky
> 
> I don't see anything in that page that changes what I am doing. I can get
> rid of everything that has to do with retrieving data from
> cgi-FieldStorage, and the code executes fine although I get a blank page.
> I have revised the code somewhat, but the initial problem of
> cgi.FieldStorage being empty is still there. I don't get an error now,
> just an empty page. Here is the revised code:
> 
> #! /usr/bin/python
> print "Content-Type: text/html\n\n"
> print
> print "<html><head></head><body>\n\n"
> 
> import cgitb, os, sys
> cgitb.enable()
> sys.strerr = sys.stdout
> 
> import cgi
> 
> form = cgi.FieldStorage()
> field_list = '<ul>\n'
> for field in form.keys():
>    field_list = field_list + '<li>%s</li>\n' % field
> field_list = field_list + '</ul>\n'
> print field_list
> print "</body></html>\n\n"
> 
> ------------------------------
> 
> Message: 8
> Date: Tue, 22 Mar 2005 10:58:55 -0500
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Python cgi doesn't get data from html form as
>        expected
> Cc: tutor at python.org
> Message-ID: <424040BF.9070706 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> Vicki Stanfield wrote:
> > I don't see anything in that page that changes what I am doing. I can get
> > rid of everything that has to do with retrieving data from
> > cgi-FieldStorage, and the code executes fine although I get a blank page.
> > I have revised the code somewhat, but the initial problem of
> > cgi.FieldStorage being empty is still there. I don't get an error now,
> > just an empty page. Here is the revised code:
> >
> >  #! /usr/bin/python
> > print "Content-Type: text/html\n\n"
> > print
> > print "<html><head></head><body>\n\n"
> >
> > import cgitb, os, sys
> > cgitb.enable()
> > sys.strerr = sys.stdout
> >
> > import cgi
> >
> > form = cgi.FieldStorage()
> > field_list = '<ul>\n'
> > for field in form.keys():
> >     field_list = field_list + '<li>%s</li>\n' % field
> > field_list = field_list + '</ul>\n'
> > print field_list
> > print "</body></html>\n\n"
> 
> Please post the HTML for the form you are submitting and the HTML from a View Source on the result.
> 
> Kent
> 
> ------------------------------
> 
> Message: 9
> Date: Tue, 22 Mar 2005 08:59:36 -0600
> From: C Smith <smichr at hotmail.com>
> Subject: Re: [Tutor] Looking for a Pythonic way to pass variable
> To: tutor at python.org
> Message-ID: <BAY101-DAV11A3B228F1D54EC47048FBC14E0 at phx.gbl>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> 
> On Tuesday, Mar 22, 2005, at 05:01 America/Chicago,
> tutor-request at python.org wrote:
> 
> > I met a similar question.
> > what if one has L = [[1,2],[3,4]], K = [100, 200]
> > How to 'zip' a List like [[1,2,100], [3,4,200]]?
> >
> I would do something like:
> 
> ###
> for i in range(len(L)):
>   L[i].append(K[i])
> ###
> 
> /c
> 
> ------------------------------
> 
> Message: 10
> Date: Tue, 22 Mar 2005 11:37:11 -0600
> From: C Smith <smichr at hotmail.com>
> Subject: Re: [Tutor] primes - sieve of odds
> To: tutor at python.org
> Message-ID: <BAY101-DAV12AFBD9B03492E7EE99D82C14E0 at phx.gbl>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
> 
> Hi Gregor,
> 
> I had done the same thing.  I also noted that assigning (or inserting)
> an element into a list is faster than creating a new list:
> l.insert(0,2) is faster than l = [2]+l.
> 
> ###
> def sieve (maximum):
>      if maximum < 2: return []
>      limit = int(maximum**0.5)
>      nums = range(1,maximum+1,2)
>      nums[0] = None
>      for p in nums:
>          if p:
>              if p > limit: break
>              nums[(p*p)//2::p] = [False]*(1+(maximum//p- p)//2)
>      nums[0] = 2
>      return filter(None, nums)
> ###
> /c
> 
> > Hi Sean!
> >
> > Thanks for your measurements.
> > In the meantime I did another amendment,
> > leaving out the even numbers from the sieve.
> > It goes like this:
> >
> > def sieve(maximum):
> >      nums = range(3, maximum+1, 2)
> >      for p in nums:
> >          if p:
> >              if p*p > maximum: break
> >              start = (p*p-2)//2
> >              nums[start::p] = [False]*(1+((maximum-3)//2-start)//p)
> >      return [2] + filter(None, nums)
> >
> > Perhaps not very elegant. But approximately twice as fast as
> > the former version.
> 
> ------------------------------
> 
> Message: 11
> Date: Tue, 22 Mar 2005 13:30:09 -0500
> From: Kent Johnson <kent37 at tds.net>
> Subject: Re: [Tutor] Looking for a Pythonic way to pass variable
> Cc: tutor at python.org
> Message-ID: <42406431.2040103 at tds.net>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> C Smith wrote:
> >
> > On Tuesday, Mar 22, 2005, at 05:01 America/Chicago,
> > tutor-request at python.org wrote:
> >
> >> I met a similar question.
> >> what if one has L = [[1,2],[3,4]], K = [100, 200]
> >> How to 'zip' a List like [[1,2,100], [3,4,200]]?
> >>
> > I would do something like:
> >
> > ###
> > for i in range(len(L)):
> >   L[i].append(K[i])
> > ###
> 
> Oh, the light goes on :-) Thanks C Smith!
> 
> Here is another way:
>  >>> L = [[1,2],[3,4]]
>  >>> K = [100, 200]
>  >>> [ x+[y] for x, y in zip(L, K) ]
> [[1, 2, 100], [3, 4, 200]]
> 
> Note C Smith's approach modifies L to include the items in K; my approach makes a new list.
> 
> Kent
> 
> ------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> End of Tutor Digest, Vol 13, Issue 65
> *************************************
>


More information about the Tutor mailing list