A good place to look at : http://www.norvig.com/sudoku.html
On Mon, Apr 7, 2008 at 6:53 PM, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > W W wrote: > > On 4/7/08, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > > >> W W wrote: > >> What are you talking about? I don't understand what you mean by > "ignores > >> whitespace between dictionary elements." > >> > >> > >>> foo = {'1a': 1, '1b':2, '1c':3, > >>> '2a': 0, '2b': 9, '2c': 6} > >>> > > > > Exactly that. If you were to write: > > > > foo = {'1a': 1, '1b':2, '1c':3} > > foo['2a'] = 0 > > > > You would get a nifty error. > > > You mean that the dictionary _definition_ ignores whitespace between > elements? > That's quite different than the dictionary itself ignoring whitespace. > That implies that > foo['1b'] is the same element as foo['1 b'], hence the source of my > confusion. > > That's not a feature of dictionaries, but of the comma. > You can easily do the following: > x = [1, 2, > 3, 4] > if you want. > Same with tuples and various other things. > Python just realizes that if it doesn't see a closing brace/bracket, but > sees a comma, that more will probably be coming on the next line. > You can do the same thing with backslash, if your statement does not end > in a comma: for example, > x = 1 + 1 + \ > 2 + 3 + 5 \ > + 8 + 13 > > Also, did you test the code that "generates an error?" > It works fine for me. > >>> foo = {'1a': 'b'} > >>> foo['2b'] = 0 > >>> print foo['2b'] > 0 > >>> > > Hope that helps, > -Luke > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor