Question: I am trying to iterate over a bunch of .xml files in a directory.

For this purpose, I wrote a python script:

```
#!/usr/bin/python3.5

import os
import glob

pathToDirectory = '/home/anton/Documents/Repo_from_GitHub/ResiShared/templates/'

for filename in os.listdir(pathToDirectory):
    file = open(pathToDirectory.__add__(filename), "r")
    count = 0
    for line in file:
        if line.__contains__('xmlns="http://xml.juniper.net/xnm/1.1/xnm"') \
                | line.__contains__('xmlns="http://tail-f.com/ned/cisco-ios-xr"') \
                | line.__contains__('xmlns="http://tail-f.com/ned/arista-dcs"'):
            ++count
        elif line.__contains__('tags="replace"'):
            --count
        elif (line.__contains__('</config>') \
                | line.__contains__('</config-template>')) & count > 0:
                    print ('There are ' + str(count) + ' tags="replace" missing in the ' + file.name)

```

It is working without any bug spotted, but also I got no output from the last "elif", but it definitely should be.

Here is an example of .xml file:
[xml file example](https://docs.google.com/document/d/16xXuqSInnibXGO_FRniBj4JRoa3nqU3M3CPu6QHq314/edit?usp=sharing)

UPDATE:
I do not need any kind of XML parser here, core Python functionality should be enough.

Answer: 
python does not support `++` and `--` operators. Thus when you do `++count` and `--count` the value of `count` does not change whatsoever and `count > 0` is always `False`.

And note that it will not raise exception, because it's a valid code. `++count` is in fact applying unary operator `+` twice in a row (i.e. `+(+count)`). Same for `--` (`-(-count)`).

Given the xml sample file you expect that `line.__contains__('</config-template>')) & count > 0` is `True` but it is not.

All that said - I agree with @King'sjester comment and also why you call dunder methods like `__contain__()` directly? It makes the code less readable and IMHO ugly to say at least. I would take @mannojlds advice to look in more pythonic tools to parse xml files.

```
>>> line = 'spam'
>>> count = 0
>>> line.__contains__('eggs') & count > 0
False

```

EDITED to include explanation on unary operators.
As buran pointed out, there isn't a `++` operator in python, as a result the value of `count` stays at 0. Changing the following should fix your problem:

`++count` should be `count += 1`

`--count` should be `count -= 1`

The `|` symbol is the *bitwise* operator, instead you should use `or`.