Comments (14)
Where if any of is this used and relied upon internally?
On May 13, 2015 4:38 PM, "spaceone" [email protected] wrote:
BaseComponent/Manager implements bool/nonzero which returns True if
there are pending events.
As it is a API to inherit from BaseComponent this is error prone.
I needed a lot time to debug the lines:if arg:
foo()which failed but worked finally with if arg is not None: (where arg is a
component, e.g. event.value.manager).We should not overwrite pythons expected default behavior in the API and
instead hide internals like those.—
Reply to this email directly or view it on GitHub
#51.
from circuits.
At least in circuits/tests/core/test_core.py
from circuits.
Seems we removed this already
from circuits.
hmm? Nothing is done here, yet.
bool/nonzero is still implemented
And the mentioned test case also still contains:
27 while app:
28 app.flush()
from circuits.
Show me? I grepped the codebase and could not find anything that implements this!
from circuits.
circuits/circuits/core/manager.py
230 def __len__(self):
231 """x.__len__() <==> len(x)
232
233 Returns the number of events in the Event Queue.
234 """
235
236 return len(self._queue)
from circuits.
Ahh yes but this doesn't implement __nonzero__
. This gives you the queue length (no. of events in the queue) of a component (usually you want len(self.root)
)
from circuits.
You should still be able to implement your own __nonzero__
however in a component subclass.
from circuits.
>>> class Foo(object):
... def __len__(self):
... return 0
...
>>>
>>>
>>> f = Foo()
>>> bool(f)
False
from circuits.
So I'm proposing the following new public API(s):
.empty
.qsize
both properties.
Okay with this?
from circuits.
uhm, no? I would leave __len__
as it is. But i would implement __bool__
and __nonzero__
to return True.
from circuits.
Oh man! Is that what you meant all along? sigh We need to improve are communications! I was totally lost as to what you were proposing :)
Let's try this again!
git checkout -- .
``
LOL
from circuits.
All this work I did for nothing and all the tests passing too :) Haha :)
from circuits.
I'm really sorry :D You can use sed now to replace it: s/app.empty/len(app)/g.
Using properties here would be a disadvantage as they slow down the whole thing.
from circuits.
Related Issues (20)
- Fix tests on PYPY HOT 2
- Experiencing buffer issues when using SSL with web module HOT 6
- urlparse module can't be found HOT 1
- Fix circuits for Python >= 3.7 HOT 3
- Speed up more tests
- re-raise KeyboardInterrupt
- Drop Python 2 support HOT 9
- remove landscape.io tooling and references HOT 1
- SSL based tests fail on Ubuntu 20.04 HOT 3
- chunked multi-part web posts HOT 10
- 📣 Migrating off of Github 📣 HOT 5
- Migrate circuits.web HTTP parser to httoop HOT 7
- circuits.web.tools.validate_etags(autotags=True) is broken
- Migrate from Travis-CI to github actions HOT 2
- Fix Python 3.10 support HOT 2
- reduce possible XSS attack vector
- Integrate tornado
- allow coroutines with Python 3 syntax as async def functions HOT 4
- circuits.web error handling broken HOT 1
- circuits.web.tools.validate_etags(autotags=True) is broken
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circuits.