Re: 'Advanced' list comprehension? query

2007-08-08 Thread scottishguy
Thanks for some great explanations and alternatives!

I'll go with the any() approach, as its nice and readable (my
noShowList is quite small compared to myList).  Thanks, John, for the
'make it obvious' tip.

As an exercise, if I now wanted to show the entries where the
'noShowList' matches, what would be the best option (using list
comprehension)

i.e. ['item one', 'item three']

My original version:
print [x for x in myList for y in noShowList if y in x]

Version based on previous answer:
print [x for x in myList if any(y in x for y in noShowList)]

Cheers!

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


Re: Mac OSX sqlite problem. Missing?

2007-09-11 Thread scottishguy
On Sep 11, 2:46 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> On Sep 10, 1:51 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > Diez B. Roggisch wrote:
>
> > > Are you by any chance using the python 2.3 when issuing that import
> > > statement?
>
> > > Diez
>
> > Unfortunately not :(
>
> > ibook:~/project1$ python -V
> > Python 2.5
> > ibook:~/project1$ python
> > Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
> > [GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
> > Type "help", "copyright", "credits" or "license" for more information.>>> 
> > import sqlite
>
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > ImportError: No module named sqlite
>
> Isn't it sqlite3 (instead of sqlite)?
>
> Python 2.5.1c1 (r251c1:54692, Apr 17 2007, 21:12:16)
> [GCC 4.0.0 (Apple Computer, Inc. build 5026)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.>>> 
> import sqlite3
> >>> sqlite3.Connection
>
> >>> sqlite3.Connection.__doc__
>
> 'SQLite database connection object.'
>
>
>
> I also see it under that name in the repository:
>
>http://svn.python.org/view/python/trunk/Lib/sqlite3/
>
> --
> Hope this helps,
> Steven

The problem is that the user is trying to install the turbogears
framework, and 'tg-admin' tries to import sqlite (not sqlite3)

He's getting this error:
 'import sqlite.  ImportError: No module named sqlite'.

Without changing the turbogears code, what should he do? Set up a
symbolic link from 'sqlite3' to 'sqlite' ?

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