5 ms·
Checking the code: https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L1638 https://github.com/andymccurdy/redis-py/blob/master/redis/cl... It
by raverbashing 14y ago
Checking the code: https://github.com/andymccurdy/redis-py/blob/master/redis/client.py#L1638 https://github.com/andymccurdy/redis-py/blob/master/redis/cl...
It implements __len__ so there's your answer
- Goopplesoft 14y agoThanks, ill update the code in a bit.
- raverbashing 14y agoGreat, sorry if I was too harsh in the original post
- mhahn 14y agoI would argue that it is more readable to do: if request.pipeline.command_stack: request.pipeline.execute() rather than if len(request.pipeline) > 0: request.pipeline.execute() thoughts?
- raverbashing 14y agoThe 1st example is better (Yes, if len returns 0 it's evaluated as false, just tested this) But for the 2nd I would prefer if not len(request.pipeline):
- mhahn 14y agoif len(request.pipeline): you want to execute only if it has a length. cool though, I am using pipelines for something at work and read this post and realized I was executing even if there was nothing to execute!
- raverbashing 14y agoOh, of course =) I don't know why I put the 'not' there