inclusive-lower-bound, exclusive-upper-bound (was Re: Range Operation pre-PEP)
Andrew Maizels
andrew at one.net.au
Fri May 11 22:40:13 EDT 2001
Aahz Maruch wrote:
>
> In article <3AFC5DF2.AB13724C at one.net.au>,
> Andrew Maizels <andrew at one.net.au> wrote:
> >
> >For example, I like Python's use of new-line as a statement separator,
> >but in Pixy you can embed relational database queries directly into your
> >code, and given the target application domain (business applications
> >like accounting, customer service etc), I expect they'll be one of the
> >commonest constructs in Pixy programs. Unfortunately, queries have a
> >tendency to be quite lengthy, and trying to squash them into one line or
> >having line-contination markers all over the place both seem like bad
> >ideas.
>
> That's why Python has triple quotes.
Sorry, I wasn't quite clear: these queries are part of the language, not
embedded SQL.
So, if I have an accounts database with customer records containing
name, address, account balance etc, and item records containing date,
due data, amount, open amount, customer number etc, and I wanted to send
a letter to every customer with a balance of more than $50 over 60 days,
I could write something like:
open database accounts for read.
import send_polite_email, send_polite_letter from send_letter.
var c, i are buffer.
var over60 is decimal.
for c in customer
where c.balance <= 50:
-- can safely ignore customers with balance <= $50
over60 := 0.
for i in item
where i.custnum = c.custnum and
i.duedate < today - 60 and
i.open <> 0:
over60 += i.open.
end.
if over60 > 50 then do:
if c.email <> ""
then send_polite_email(c.email,c.name,c.balance,over60).
else send_polite_letter(c.address,c.name,c.balance,over60).
end.
end.
Pixy's syntax is still in flux, but that will give you the idea.
Andrew.
--
There's only one game in town.
You can't win.
You can't break even.
You can't quit the game. -- The four laws of thermodynamics.
More information about the Python-list
mailing list