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?!?
-
As a Native New Yorker, Eastern Standard Time or Eastern Daylight Time (don't axe me to define the difference!) is New York Time. I was actually going to put Swiss Time because that home for me. But what I was really after was to give everyone all of Sunday to complete their work. Anyway, you have until 8am New York Time to get it done. You can use http://worldtimeserver.com or the iOS Clock app to calculate your local time. As Martin sayz, we at IBM live this on a weekly basis and many IBMers have the muscle memory to be able tell you the current time in Bejing, Bangalore, New York, and Silicon Valley without pausing. International is part of who we are.
The repo should be open. You can drop the URL here in this thread.
@omz of course you are eligible to participate!! I like @Phuket2 will avoid looking at other submissions while I work on my own.
Rule 0 was implied in the initial write up: you must use the
inspect
module to get the structure of theui
module.There are two PEP8 rules that your output is allowed to break: you can put
pass
on the same line as the preceding line and you don't need blank lines if you don't want them.Thus you could have:
i_will_survive = True class DarkStar(object): def __init__(self): pass def draw(self): pass class TheOtherOne(): pass the_eleven = 11
-
Oh... I forgot, you need the
variables
in addition to the classes, functions, and methods to really get full auto completion.
-
@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.