2015-05-11 19:40 GMT+02:00 Manlio Perillo <manlio.peri...@gmail.com>:
> On Mon, May 11, 2015 at 6:53 PM, Carlo Miron <mi...@python.it> wrote: >> >> Il 11 maggio 2015 17:58, Manlio Perillo <manlio.peri...@gmail.com> ha >> scritto: >> >> [...] >> >> > In yaml puoi avere anche dell'indentazione all'inizio di ogni riga, che >> > viene ignorata. >> >> If the first characters after the opening delimiter are a backslash >> and a newline, then they will both be trimmed along with all >> whitespace and newlines up to the next non-whitespace character or >> closing delimiter. >> > >> [...] > > Se insisti abbastanza, puoi scrivere il kernel di Linux in brainfuck... :-) Manlio, scusa, cosa c'entra? >> # The following strings are byte-for-byte equivalent: >> str1 = "The quick brown fox jumps over the lazy dog." >> >> str2 = """ >> The quick brown \ >> >> >> fox jumps over \ >> the lazy dog.""" >> >> key3 = """\ >> The quick brown \ >> fox jumps over \ >> the lazy dog.\ >> """ > > Il problema è " they will both be trimmed", quindi se fai il load + dump di > quel documento, ottieni un testo diverso; che è lo stesso problema di YAML. Perdonami, mi deve essere sfuggita la mail in cui esprimevi questo tuo requisito. A questo punto non ho più il coraggio di farti notare che una stringa racchiusa da tre apici singoli mantiene il formato tra dumps() e load() :P >>> print(pytoml.loads(r'''str2 = """ ... The quick brown \ ... ... ... fox jumps over \ ... the lazy dog."""''')["str2"]) The quick brown fox jumps over the lazy dog. >>> print(pytoml.loads(r"""str2 = ''' ... The quick brown \ ... ... ... fox jumps over \ ... the lazy dog.'''""")["str2"]) The quick brown \ fox jumps over \ the lazy dog. © -- |:**THE BEER-WARE LICENSE** (Revision 42): | <mi...@python.it> wrote this mail. As long as you retain | this notice you can do whatever you want with this stuff. | If we meet some day, and you think this stuff is worth it, | you can buy me a beer in return. | --Carlo Miron : _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python