Reviving this thread 2.5 years after I started it just to share this satisfying moment. I was just spending a few hours furiously coding on my research <https://r.rachum.com/> using Python 3.10, and when I ran my code I got this traceback:
File "/home/ramrachum/.venvs/ray_env/lib/python3.10/site-packages/ray/rllib/algorithms/algorithm.py", line 1993, in log_result self.callbacks.on_train_result(algorithm=self, result=result) │ │ └ {'custom_metrics': {}, 'episode_media': {}, 'num_recreated_workers': 0, 'info': {'learner': {'policy_robot': {'learner_stats': {... │ └ PPO └ PPO File "/herring/nichos/nichos/snare/__init__.py", line 150, in on_train_result robot_move_by_state = get_move_by_state( File "/herring/nichos/nichos/snare/__init__.py", line 75, in get_move_by_state return dict(zip(states, moves, strict=True)) │ └ array([0, 1, 0, ..., 1, 0, 1]) └ <itertools.chain object at 0x7f08dc157610> ValueError: zip() argument 2 is longer than argument 1 It took a few seconds for me to understand... "Ah... This error is my error" :) On Mon, Apr 20, 2020 at 8:42 PM Ram Rachum <r...@rachum.com> wrote: > Here's something that would have saved me some debugging yesterday: > > >>> zipped = zip(x, y, z, strict=True) > > I suggest that `strict=True` would ensure that all the iterables have been > exhausted, raising an exception otherwise. > > This is useful in cases where you're assuming that the iterables all have > the same lengths. When your assumption is wrong, you currently just get a > shorter result, and it could take you a while to figure out why it's > happening. > > What do you think? >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/DPQEIIOAEGJKIVDHTAKQ6CJPCGS7C5G7/ Code of Conduct: http://python.org/psf/codeofconduct/