Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81522 > unrolled thread

Re: Fwd: Python Signal/Slot + QThred code analysis

Started byMRAB <python@mrabarnett.plus.com>
First post2014-11-25 18:20 +0000
Last post2014-11-25 18:20 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Fwd: Python Signal/Slot + QThred code analysis MRAB <python@mrabarnett.plus.com> - 2014-11-25 18:20 +0000

#81522 — Re: Fwd: Python Signal/Slot + QThred code analysis

FromMRAB <python@mrabarnett.plus.com>
Date2014-11-25 18:20 +0000
SubjectRe: Fwd: Python Signal/Slot + QThred code analysis
Message-ID<mailman.16291.1416939659.18130.python-list@python.org>
On 2014-11-25 15:48, Juan Christian wrote:
> On Tue Nov 25 2014 at 1:42:24 PM MRAB <python@mrabarnett.plus.com
> <mailto:python@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__

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web