On 13/6/2013 3:22 μμ, Sibylle Koczian wrote:
Am 13.06.2013 09:11, schrieb Νικόλαος Κούρας:
On 13/6/2013 4:55 πμ, Steven D'Aprano wrote:

The "and" operator works in a similar fashion. Experiment with it and
see
how it works for yourself.

I read yours psots many times,all of them, tryign to understand them.


But you didn't do what he recommended, did you? And it's really the best
or possibly the only way to understanding.

Try it out in the interactive Shell, using Stevens examples connected
with 'and' instead of 'or'.

I try and try to work it out but i can't understand it even in theory.

==================

        if '-' not in ( name and month and year ):
cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) )
        elif '-' not in ( name and year ):
cur.execute( '''SELECT * FROM works WHERE clientsID = (SELECT id FROM clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, year) )
        elif '-' not in ( month and year ):
cur.execute( '''SELECT * FROM works WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (month, year) )
        elif '-' not in year:
cur.execute( '''SELECT * FROM works WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year )

======================

i just want 4 cases to examine so correct execute to be run:

i'm reading and reading and reading this all over:

if '-' not in ( name and month and year ):

and i cant comprehend it.

While it seems so beautiful saying:

if character '-' ain't contained in string name , neither in string month neither in string year.

But it just doesn't work like this.

Since ( name and month and year ) are all truthy values, what is returned by this expression to be checked if it cotnains '=' within it?



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to