Question: I'm trying to find if there's a way to search in lucene to say find all documents where there is at least one word that does not match a particualar word.

E.g. I want to find all documents where there is at least one word besides "test". i.e. "test" may or may not be present but there should be at least one word other than "test". Is there a way to do this in Lucene?

thanks,
Purushotham

Answer: 
Rather than *both* mutating and returning objects, the Python library chooses to have just one way of using the result of a mutator. From `import this`:

> 
> There should be one-- and preferably only one --obvious way to do it.
> 
> 
> 

Having said that, the more usual Python style for what you want to do is using *list comprehensions* or *generator expressions*:

```
[x for x in range(5) if x != 2 and x != 3]

```

You can also chain these together:

```
>>> [x for x in (x for x in range(5) if x != 2) if x != 3]
[0, 1, 4]

```

The above generator expression has the added advantage that it runs in *O(n)* time because Python only iterates over the `range()` once. For large generator expressions, and even for *infinite* generator expressions, this is advantageous.
In Python, essentially all methods that mutate the object return `None`.

That's so you don't accidentally think you've got a new object as a result.

You mention

> 
> I think even PHP allows these types of subsequent mutations with Strings.
> 
> 
> 

While I don't remember about PHP, with string manipulations, you **can** chain method calls, because **strings are immutable**, so **all string methods return a new string**, since they don't (can't) change the one you call them on.

```
>>> "a{0}b".format(3).center(5).capitalize().join('ABC').swapcase()
'a A3B b A3B c'

```