Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
It's not that I'm flattening the inventory for the player visibility, I was just talking about how I thinking of flattening it temporarily for the searching. Either way, these definitely help.
URL: https
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
@7For what it's worth, knowing them generalizes to JS, C#, C++, and several other languages.
URL: https://forum.audiogames.net/post/593596/#p593596
--
Audiogames-reflector mailing list
Audiogames-reflector
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
That’s it. Looking at generators next.
URL: https://forum.audiogames.net/post/593580/#p593580
--
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
Actually, to modify Amerikranian's code slightly (untested, but should be correct):def recursive_search(chunk):
for key in chunk:
if isinstance(chunk[key], dict):
yield from recursive_search
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
If you wanted nested containers you either end up doing something like what I suggested in post 2, or you do post 4, which is 90% or so of what I suggested in post 2, just minus some of the data model.What 4
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
Right. Playing with recursion for 10 or so minutes yields this for expanding all the dictionariesdef recursive_search(chunk):
full_data = {}
for key in chunk:
if isinstance(chunk[key], dict
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
The order of items is unimportant. If at some point items need to be sorted, such as if I have a filterable Inventory Menu, there is another player method, sort_inventory, that handles that.The issue is not putting
Re: Python: Confusion on the Way I Might Pull This List Comprehention Off
You won't have much luck with list comprehensions here. It's technically possible to use them but isn't worth it and will be an unreadable mess.You're inventing trees, if that's helpful. If you just say that all
Python: Confusion on the Way I Might Pull This List Comprehention Off
Hello,I was messing around with some RPG style code out of boredom. Many other questions will follow as I continue to make it.Anyway, I was coding an inventory type system. The inventory is lain out as follows:The