Question: Im using auto layout for this imageView and I don't have a height set in the constraints thinking it would resize to the image height but it doesn't seem to work. Here is a pic: 

[![http://imgur.com/JtpTKVx](https://i.stack.imgur.com/aE88ym.jpg)](https://i.stack.imgur.com/aE88ym.jpg)

I want to remove the red space which is the background and just have the image

it is in a UITableViewCell which i want to size according to the image size.

Answer: 
For something like this I would keep it simple and read from one file and write to another. 

```
with open('/path/to/myfile') as infile:
   with open('/path/to/output', 'w') as outfile:
      for line in infile:
         if line.rstrip().endswith('='):
             outfile.write('#' + line + '\n')
         else:
             outfile.write(line + '\n')

```
Here is some code that you can run like:

```
python comment.py < infile > outfile

```

comment.py:

```
import sys

# stdin/stdout live in sys
# "for line in file" reads each line of the file, returning the text
# of the line including the trailing newline
for line in sys.stdin:
    if line.strip().endswith('='):
        line = "#" + line
    # print command adds a trailing newline, so we have to use all but
    # the last character of our input line
    print(line[:-1])

```

You can get a lot fancier using the `re` module for regular expressions.

Given infile:

```
V12 = 'hello'
V23 = 'world'
V34 =

```

produces:

```
V12 = 'hello'
V23 = 'world'
#V34 =

```