Uploadable files

5 views
Skip to first unread message

David MacQuigg

unread,
Mar 10, 2010, 11:11:12 AM3/10/10
to PyWhip
Some time back, Andy suggested we provide a way to upload a batch of
exercises, without having to enter each part of every exercise into a
web form. Now that we are thinking about writing a function to
transfer the data from our old website, we could perhaps kill two
birds with one stone. The key is to define a simple format for the
data.

A well-written Python program, with docstrings including doctests and
a separate test function for other more complete tests that are not
included in the doctests, is pretty close to what we need in our
PyKata data, and has the advantage that it can be tested on the
author's computer before uploading to PyKata. To make it easy for the
import script to parse these files, we could add tags in the comments,
like # name:, # categories:, and # description:.

# name: list123FAIL
# categories: list logic
# description:
'''
Given a list of ints, return True if the sequence .. 1, 2, 3, ..
appears
anywhere in the list.

# .. translated from Nick Parlante's http://javabat.com/prob/p136041
~'''

def list123(nums):
'''Given a list of ints, return True if the sequence .. 1, 2, 3, ..
appears
anywhere in the list.

>>> list123([1, 1, 2, 3, 1])
True
>>> list123([1, 1, 2, 4, 1])
False
>>> list123('12345')
Traceback (most recent call last):
- - -
AssertionError
~'''
assert type(nums) == list

for i in range(len(nums) - 2):
if nums[i:i+3] == [1,2,3]: return True

return False

# skeleton:
'''
def list123(nums):
# Here is a solution that satisfies the example
# tests, but fails the more complete unit tests.
# Fix it.

assert type(nums) == list # make sure the arg is a list

for i in [1, 2, 3]:
if i not in nums: return False

return True
~'''
# other tests:
def tests():
'''
>>> list123([1, 3, 2, 1, 2, 1])
False
~'''

Any suggestions?

-- Dave

Andrew Harrington

unread,
Mar 10, 2010, 12:23:02 PM3/10/10
to pyw...@googlegroups.com
Yes, good idea, killing two birds at once, too.  I guess at present that we have few enough problems that we could upload each one as a single file fairly easily.  There is the issue of upload for transfer between sites of who owns the program, so #userID should be part.

I'm not sure about the various versions of tests:  We likely have some embedded in the description or skeleton, plus further public test seen when the code is submited, plus private tests.  We might want a varible or function named publicTests.  Presumably otherTests refers to the private tests, and privateTests might be a clearer name.

One other thing:  you put a link in the description.  I think we are looking for trouble allowing  external links in untrusted code that gets at best, automatically checked.  More on ideas of Sean and me in another post.

Andy


--
You received this message because you are subscribed to the Google Groups "PyWhip" group.
To post to this group, send email to pyw...@googlegroups.com.
To unsubscribe from this group, send email to pywhip+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pywhip?hl=en.




--
Andrew N. Harrington
 Director of Academic Programs
 Computer Science Department
 Loyola University Chicago
 512B Lewis Towers (office)
 Snail mail to Lewis Towers 416
 820 North Michigan Avenue
 Chicago, Illinois 60611

http://www.cs.luc.edu/~anh
Phone: 312-915-7982
Fax:    312-915-7998
g...@cs.luc.edu for graduate administration
u...@cs.luc.edu for undergrad administration
aha...@luc.edu as professor

David MacQuigg

unread,
Mar 12, 2010, 12:17:18 PM3/12/10
to PyWhip
Good suggestions, Andy. I've written a suggested format for an
uploadable file. See UploadFormat wiki page in http://code.google.com/p/pykata.
I've also entered this in our issue
tracker at that same address.
Reply all
Reply to author
Forward
0 new messages