Offer HN: I'll help you learn Python
21–30 of 51 posts
Re: Offer HN: I'll help you learn Python
#22I've been trying to get an answer to my Python question: http://news.ycombinator.com/item?id=1841536 Maybe you can take a look at that?
Looks to me like you're trying to shoehorn everything into the one list, which is going to make your code hard to write. Something to note is that you're adding blank strings ('') to your list to pad it out, which is a bit of a warning sign that your data structure is wrong. Rather than do that, I'd use a dictionary keyed off either an id or the original text, store the user input as a list after that, then sort out…
In your example, if I understand correctly; it is assumed that there is a list of 3 "Hello World"s. In reality, each should be entered and then displayed (I use Mako templates).
This looks like a simple problem but I was unable to make it work. Thanks again.
Re: Offer HN: I'll help you learn Python
#23Earlier quoted context omitted.
Looks to me like you're trying to shoehorn everything into the one list, which is going to make your code hard to write. Something to note is that you're adding blank strings ('') to your list to pad it out, which is a bit of a warning sign that your data structure is wrong. Rather than do that, I'd use a dictionary keyed off either an id or the original text, store the user input as a list after that, then sort out…
Thanks. I am sorry that my question is not clear. In this case, the user enters a string s in a form and I append that to an empty list L = [] then I test if the last saved string is the same as the new string. If same, I write it on the same column; if not the cursor moves to next column (I was trying to do this with tables) and as long as the user types the same string the cursor stays on the same column. If a new…
list = [ ['Hello World', 'Hello World'], ['Hello Universe', ...], ... ]
you'll need to display the first item of each on one row, then the second, and so on, which is a hassle.
Another way might be to pregenerate your list of lists with blank items (assuming that you know how many different strings you have and how many tries they get) then track the current row and column number. If they enter it successfully then your current row increments by one. If they choose a different one, then increment your column and reset
But you seem to be overly focused on the details of your implementation (ie. rows and columns), rather than the simplest way to achieve what you want. A third way would be to have each series on a separate page, so you only need to track the current string. Once they're ready, they can click a button to get to the next one/enter a new string.
A fourth way - don't use a table, use with a set width and display-inline. Each has the previous entries separated by line breaks, with a form for the final one. With this sort of structure you can process each list in turn, without having to worry about indexing.
Re: Offer HN: I'll help you learn Python
#24My question is: I don't know any Python and would like to start learning it. Should I bypass Python2 altogether and start with Python3 or stick with Python2?
If you would like to use App Engine (great & free!), then stick with Python 2.5 for now.
Re: Offer HN: I'll help you learn Python
#25If you are interested in learning python+django intensively for a week with a few people, I'm co-teaching a class with Dave Beazley in Chicago next month. There is still a few seats left. http://www.dabeaz.com/chicago/index.html
Re: Offer HN: I'll help you learn Python
#26Plug: I'm just in the final stages of finishing an introductory Python book, Hello! Python: http://manning.com/briggs/ . It's a bit different, in that I'm using real world projects (Hunt the Wumpus, Django, web scraping, writing games) to demonstrate how to program, rather than just having a laundry list of features and stepping through them one by one. Think of it as Land of Lisp , but in Python rather than CL.
Do you think there is any interest in such an ebook?
Re: Offer HN: I'll help you learn Python
#27My question is: I don't know any Python and would like to start learning it. Should I bypass Python2 altogether and start with Python3 or stick with Python2?
Anyway, there isn't a whole lot of difference between python 2 and 3, really. The "proper" way of coding in python2 is very similar to python3.
Re: Offer HN: I'll help you learn Python
#28Plug: I'm just in the final stages of finishing an introductory Python book, Hello! Python: http://manning.com/briggs/ . It's a bit different, in that I'm using real world projects (Hunt the Wumpus, Django, web scraping, writing games) to demonstrate how to program, rather than just having a laundry list of features and stepping through them one by one. Think of it as Land of Lisp , but in Python rather than CL.
Re: Offer HN: I'll help you learn Python
#29Plug: I'm just in the final stages of finishing an introductory Python book, Hello! Python: http://manning.com/briggs/ . It's a bit different, in that I'm using real world projects (Hunt the Wumpus, Django, web scraping, writing games) to demonstrate how to program, rather than just having a laundry list of features and stepping through them one by one. Think of it as Land of Lisp , but in Python rather than CL.
That's a great idea. I've thought of writing something like that myself, but with a focus on learning Django (for people who already know Python.) Do you think there is any interest in such an ebook?
If you're serious about it I can put you in touch with someone at Manning. They're always looking for new authors and reviewers.
Re: Offer HN: I'll help you learn Python
#30Link: irc://irc.freenode.net:6667/HNpython