bchao1 / bullet

🚅 Interactive prompts made simple. Build a prompt like stacking blocks.
https://pypi.org/project/bullet/
MIT License
3.55k stars 113 forks source link

added a bullet dict class as #27 requested #30

Open CurtisPreston99 opened 5 years ago

CurtisPreston99 commented 5 years ago

the way this works is you define a dict the keys are shown to the user but the values are returned when selected. i think this would be nice to have. added it to client file as class BulletDict, and set up in init, also added an example feel free to give me advice on how to improve this class

rcfox commented 5 years ago

(I should point out that I have no authority on this project, I'm just a random guy commenting on someone else's repo.)

After sleeping on this, it seems like it would be best if this were rolled into the main classes. (Sorry for the runaround) It's simple enough to detect the type of variable being passed into the constructor.

It also seems like list choices would be the special case. If you get a list, you could just make a dict out of it: {c: c for c in choices} With that, we could standardize the rest of the code on dictionaries.

rcfox commented 5 years ago

Actually, it would probably be better to store choices as a list of (key, value) pairs. That way duplicate list items won't be lost, and you avoid the weirdness of trying to index into a dictionary at a certain position.

CurtisPreston99 commented 5 years ago

thats okay im just trying to improve my code, it was my new years resolution to contribute to things, also im still at University so learning better ways of doing things is always nice. also that two list idea seams pretty good so you would just have a list for displaying and a list for return values

tdh8316 commented 5 years ago

You should use tools such as PEP8 to maintain a consistent code style.

I think pylint, yapf would be good for this :)

CurtisPreston99 commented 5 years ago

You should use tools such as PEP8 to maintain a consistent code style.

I think pylint, yapf would be good for this :)

ah okay ill look into this