On 2014-11-25 15:48, Juan Christian wrote:
On Tue Nov 25 2014 at 1:42:24 PM MRAB <pyt...@mrabarnett.plus.com
<mailto:pyt...@mrabarnett.plus.com>> wrote:
I think that the problem there is that strings don't have an __exit__
method.

I don't understand what you said, what you mean by that? =/

The traceback says:

Traceback (most recent call last):
File "D:\Documents\PyCharm\Trader\Trader\core\outpost.py", line 18, in run with soup.select('div.stat_box div.value')[0].get_text().replace(',', '') as trades, \
AttributeError: __exit__

As you can see, it does:

    soup.select('div.stat_box div.value')[0].get_text()

which, presumably, returns a string, and then it calls the .replace
method on that string, which returns a string.

That string is then bound to 'trades'.

The problem is that this occurs in the expression part of a 'with'
statement.

If you look at this simpler example:


>>> with 'some string' as a_name:
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: __exit__


An even simpler example:


>>> with 'somestring':
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: __exit__

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

Reply via email to