what am I missing (syntax error)

Jorge Godoy godoy at ieee.org
Sun Mar 5 14:07:07 EST 2006


"orangeDinosaur" <trevis.crane at gmail.com> writes:

> Here's  a section of code:
>
> for x in occupants:
> 			if x not in uniqueUsers and not in staff: uniqueUsers.append(x)
> 			elif x in staff and not in uniqueStaff:	uniqueStaff.append(x)
>
> When I try to import the module with the function definition that
> contains this code, I get a syntax error pointing to the 'in' after the
> 'and not in staff'.  I can't figure out why this is bad syntax.  Both
> 'uniqueUsers' and 'staff' are lists.  

The question is: "what's not in XXX"?  x?  Something else?  You hve to
remember that the computer does only what you tell it to do:

if x not in uniqueUsers and x not in staff: ...

I also prefer using parenthesis to make things more clear and avoid precedence
surprises. 

-- 
Jorge Godoy      <godoy at ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.



More information about the Python-list mailing list