file open fails.
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Tue Mar 24 20:36:32 EDT 2009
On Tue, 24 Mar 2009 16:48:30 -0600, Wes James wrote:
> On Tue, Mar 24, 2009 at 4:32 PM, Wes James <comptekki at gmail.com> wrote:
>> On Tue, Mar 24, 2009 at 4:04 PM, Scott David Daniels
>> <Scott.Daniels at acm.org> wrote:
>>> Atul. wrote:
>>
>> <snip>
>>
>>> In your case, '\r' is a return (a single character), not two
>>> characters long. I think its sad that 'C:\Thesis' doesn't cause an
>>> error because there is no such character as '\T', but I am probably
>>> excessively pedantic.
>>
>> \T might mean the same thing as \t (tab), but I thought it would be
>> different...
>
>
> I guess not:
>
> http://docs.python.org/reference/lexical_analysis.html#string-literals
>
> Wonder why when I do print "test\Ttest" vs print "test\ttest" \T just
> get printed?
Did you read the section you just linked to? It says so right there:
"Unlike Standard C, all unrecognized escape sequences are left in the
string unchanged, i.e., the backslash is left in the string. (This
behavior is useful when debugging: if an escape sequence is mistyped, the
resulting output is more easily recognized as broken.) It is also
important to note that the escape sequences marked as “(Unicode only)” in
the table above fall into the category of unrecognized escapes for non-
Unicode string literals."
Since there is no standard escape \T then it gets treated as a literal
backslash + uppercase t.
--
Steven
More information about the Python-list
mailing list