[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Calling a field in the same table
- From: Drake Wilson <drake@...>
- Date: Sun, 25 Apr 2010 01:06:06 -0500
Quoth Luciano de Souza <luchyanus@predialnet.com.br>, on 2010-04-24 23:17:23 -0300:
> database =
> {
> filename = 'test.db',
> connection = sqlite3.open(database.filename)
> }
>
> An error shows up because I can't use "database.filename" inside the table "database".
The table isn't fully constructed yet. If you have specific order of
evaluation requirements you can create the table first and then add
entries to it one-by-one:
database = {}
database.filename = 'test.db'
database.connection = sqlite3.open(database.filename)
> I don't discuss if it's a good idea to call sqlite3.open as a field
> of a table. My doubt is: how to call another field of the same table
> inside the table?
You're not calling sqlite3.open as a field of this table; you're
calling it and then using the result as a value in a table
constructor. (You're accessing it as a field of the sqlite3 table,
but that's probably not what you meant.) Nor are you calling another
field of the same table, nor calling a function retrieved from another
field in the table; you're using another field of the table as an
argument in your call to sqlite3.open. Nor do you evaluate anything
"inside a table" per se when you are doing the above; you are
constructing the table, and evaluating various expressions to acquire
values with which to construct it. The assignment of the table
reference to the 'database' variable doesn't occur until the
construction is complete.
Be careful with the precision of your terms; sapient creatures may be
able to infer what you mean through a large set of possible
distortions, but the computer is not so intelligent.
> Luciano de Souza
---> Drake Wilson