Hackathon Challenge set by ccc (started new thread)
-
@ccc, I have some questions. I hope you don't mind I started a new thread here. Was not sure we're to put it, Pythonista or General. So to be safer I put it here.
Hackathon Challange: write code that uses the Python inspect module to find all the functions and methods in the ui module and auto generate a ui.py file that has those same functions and modules stubbed out (with pass statement) such that an editor like sublime or PyCharm on Windoze or a real computer (e.g. Mac) will do autocompletion on all functions and methods of Pythonista ui code. All winning entries must 1) deliver correct code completion for all ui methods and functions, 2) pass all PyCharm PEP8 compliance tests (esp. line length) and 3) be posted in a GitHub repo by 8am Eastern time on Monday 14 Dec 2015 time. If there are multiple entries that pass the above tests then the shortest number of (nonblank) lines of code wins.
Can you complete the challenge?!?
-
@ccc , I am in the dark already.
Variables?
def _bind_action(v, action_str, f_globals, f_locals, attr_name='action'):
pass
If I have the above, does that mean I have variables? Sorry as I say, first time for me.
-
There. (It's meant to generate a stub for
_ui
. Theui
module is written in Python and can be copied over from the app.)
-
I will try to roll away the dew...
I meant module level variables that type ahead in Pythonista would suggest like:
ui.ACTIVITY_INDICATOR_STYLE_WHITE_LARGE
.
-
GLHF! I'm lost however.
@ccc are you one of the IBM devs working on iOS enterprise apps?
-
last edited by
-
Ok, my one is here
I didn't exactly follow the challenge. But I am glad it's finished, can look at the other ones now.
-
@omz , the -2 is not about your submission, but about the edge cases in ui.py etc.... 😜
But out of interest, is the convert tabs tools menu item a call to inspect.cleandoc()?
In an ideal world, would you run that over your modules such as ui and dialogs when you publish, or do you do something else?
-
@Phuket2 I believe convert tabs uses this:
editor.open_file(os.path.abspath(os.path.join(sys.executable,'../pythonista_reindent.py')))
-
@JonB, ok thanks. Just doing this challenge got me thinking. I guess the best is not to think too much 😁 I learnt along time ago never to trust your input. But I had sort had forgotten that lesson. Learning and re-learning 👍
-
@JonB , sorry was a stupid question. I see now inspect.cleandoc() works on docstrings not the document/module
-
out of interest, is the convert tabs tools menu item a call to inspect.cleandoc()?
It's more or less what @JonB said.
In an ideal world, would you run that over your modules such as ui and dialogs when you publish, or do you do something else?
I don't really use anything to auto-format my code, I just try to make it look nice while I write it. I don't think any of my own Python code is PEP-8-compliant (I prefer tabs instead of spaces, and don't care that much about line length).
-
@omz said:
I don't really use anything to auto-format my code, I just try to make it look nice while I write it. I don't think any of my own Python code is PEP-8-compliant (I prefer tabs instead of spaces, and don't care that much about line length).
I break the exact same rules as you do in my code :) @ccc sometimes creates pull requests on my code just to shorten line lengths
-
LOL... https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds I have a little mind.
Remember, as the repo owner, you are always free to reject pull requests. ;-)
-
@Webmaster4o , you have to love it though 😀 @ccc beats me up on all sorts of what I thought was small stuff. But in the end it really has helped me. Well let's say helping....
-
@ccc but they're almost always things I want but didn't bother to do.
-
@ccc we need to see your repo within the next hour and half 😱
-
@ccc , do we get to see your repo?
-
So... I was not able to complete the hackathon myself. Year end at work is keeping me totally occupied so I got the first 30% done but had to abandon the effort. I will try to create another hackathon topic in the new year when I have more time to devote to it.
-
@ccc , that's a shame. But I understand. Was looking fwd to see what you had done. I know, I lost the plot somewhere 😁 It was still fun doing it though.
Look fwd to the next one in the new year
-
@ccc New hackathon topic: a fake
ui
module that actually makesTkinter
calls, but allows you to run UI scripts on a desktop computer! (This is unrealistic, but I'd love this support)