bunch icon indicating copy to clipboard operation
bunch copied to clipboard

Python 3 Support?

Open cdeil opened this issue 9 years ago • 8 comments

Does this Bunch implementation support Python 3?

I get some test errors with Python 3.4: https://gist.github.com/cdeil/5525c1ee193f1426ee8b

And Python 3 support is not listed via the setup.py classifiers: https://pypi.python.org/pypi/bunch/

If it doesn't support Python 3, could you please state this in the README?

cdeil avatar Dec 09 '14 14:12 cdeil

I've found this fork by @redodo: https://github.com/redodo/lunch https://pypi.python.org/pypi/lunch

But it also gives test errors on Python 3: https://gist.github.com/cdeil/fe6c116791c36b980dd1 and has the disadvantage that the lunch package on PyPI installs itself as bunch in site-packages, which is confusing.

@dsc Would you consider making a new bunch release if someone makes a pull request that give simultaneous Python 2 / 3 support?

cdeil avatar Dec 09 '14 15:12 cdeil

I'm also looking for Python 3 support.

femtotrader avatar Jan 16 '15 10:01 femtotrader

:+1:

iaintshine avatar Apr 30 '15 21:04 iaintshine

+1 (AttributeError: 'dict' object has no attribute 'iteritems') in bunchify(x)

fpn avatar Jul 14 '15 22:07 fpn

Even Bunch.repr() is broken on python3:

$ python3
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from bunch import Bunch
>>> a = Bunch(foo=123, bar=456)
>>> a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/workflow/venv/lib/python3.5/site-packages/bunch/__init__.py", line 200, in __repr__
    keys.sort()
AttributeError: 'dict_keys' object has no attribute 'sort'
>>>

This is because the keys() method in python3 returns an iterator (like iterkeys() in python2).

Solution: list(whatever.keys())

candlerb avatar Nov 10 '17 13:11 candlerb

You might use Munch (from @vmalloc) instead of Bunch https://github.com/Infinidat/munch see https://github.com/dsc/bunch/issues/32

femtotrader avatar Nov 10 '17 14:11 femtotrader

Thanks, I have switched to Munch now. It works fine, except I keep typing Much by accident :-)

candlerb avatar Nov 10 '17 14:11 candlerb

I submitted the fixes for that and my fork is already fixed https://github.com/olivecoder/bunch

olivecoder avatar Nov 21 '17 10:11 olivecoder