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


Groups > comp.lang.python > #81522

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

Date 2014-11-25 18:20 +0000
From MRAB <python@mrabarnett.plus.com>
Subject Re: Fwd: Python Signal/Slot + QThred code analysis
References (2 earlier) <5473E188.5020608@gmail.com> <CAAp0bGtYCEWNLV7tnR6O5N706_3AkO9XRBs1pNP8TCxfctUyow@mail.gmail.com> <5474A333.2090207@mrabarnett.plus.com> <CAAp0bGsGLsWoXQnqFYN3KLeUsmcD5ujF80sasM16wx70zQ1xUA@mail.gmail.com> <CAAp0bGvhhWcLO76UQ+nXZuhazjJr9wsjwBkuCX78O4K=em9wuQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.16291.1416939659.18130.python-list@python.org> (permalink)

Show all headers | View raw


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__

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web