¡@

Home 

python Programming Glossary: backslashes

“Unicode Error ”unicodeescape" codec can't decode bytes… Cannot open text files in Python 3

http://stackoverflow.com/questions/1347791/unicode-error-unicodeescape-codec-cant-decode-bytes-cannot-open-text-file

's' which is invalid. You either need to duplicate all backslashes or prefix the string with r to produce a raw string . share..

What exactly do “u” and “r”string flags in Python, and what are raw string litterals?

http://stackoverflow.com/questions/2081640/what-exactly-do-u-and-rstring-flags-in-python-and-what-are-raw-string-litte

the syntax of regular expression patterns is heavy with backslashes but never at the end so the except clause above doesn't matter.. some popularity to express native Windows file paths with backslashes instead of regular slashes like on other platforms but that's..

Escape SQL “LIKE” value for Postgres with psycopg2

http://stackoverflow.com/questions/2106207/escape-sql-like-value-for-postgres-with-psycopg2

pain if you're also escaping the string again with backslashes instead of using parameterisation and it's also incorrect according..

Adding backslashes without escaping [Python]

http://stackoverflow.com/questions/2179493/adding-backslashes-without-escaping-python

backslashes without escaping Python I need to escape a ampersand character..

Python regex - r prefix

http://stackoverflow.com/questions/2241600/python-regex-r-prefix

backslash is included in the string without change and all backslashes are left in the string. For example the string literal r n consists.. literal even a raw string cannot end in an odd number of backslashes . Specifically a raw string cannot end in a single backslash..

Python raw strings and trailing backslash

http://stackoverflow.com/questions/2870730/python-raw-strings-and-trailing-backslash

are prefixed with an r . This is great because I can use backslashes in regular expressions and I don't need to double everything.. for writing throwaway scripts on Windows so I can use backslashes there also. I know I can also use forward slashes but throwaway.. one backslash before the closing quote is an error but two backslashes gives you two backslashes Certainly I'm not the only one that..

cross-platform splitting of path in python

http://stackoverflow.com/questions/4579908/cross-platform-splitting-of-path-in-python

other_pieces Secondly Windows paths can contain slashes or backslashes or a mixture. Consequently using os.sep when parsing an unnormalised..

How to break a line of chained methods in Python?

http://stackoverflow.com/questions/4768941/how-to-break-a-line-of-chained-methods-in-python

Is there a better way of breaking it preferably without backslashes python coding style pep8 share improve this question You..

In Python, what does preceding a string literal with “r” mean?

http://stackoverflow.com/questions/4780088/in-python-what-does-preceding-a-string-literal-with-r-mean

backslash is included in the string without change and all backslashes are left in the string. For example the string literal r n consists.. literal even a raw string cannot end in an odd number of backslashes . Specifically a raw string cannot end in a single backslash..

Get a preview JPEG of a PDF on Windows?

http://stackoverflow.com/questions/502/get-a-preview-jpeg-of-a-pdf-on-windows

to whatever resolution you need. Obviously strip out the backslashes if you're writing out the whole command as one line. This is..

Python - Test directory permissions

http://stackoverflow.com/questions/539133/python-test-directory-permissions

correctly you have to use raw strings or escape the backslashes ' ' or use forward slashes instead. EDIT you can avoid slashes..

Why can't Python's raw string literals end with a single backslash?

http://stackoverflow.com/questions/647769/why-cant-pythons-raw-string-literals-end-with-a-single-backslash

end with a single backslash Technically any odd number of backslashes as described in the docs . r' ' File stdin line 1 r' ' ^ SyntaxError.. string literal It seems like the parser could just treat backslashes in raw strings as regular characters isn't that what raw strings.. literal even a raw string cannot end in an odd number of backslashes . Specifically a raw string cannot end in a single backslash..

Python, extract file name from path, no matter what the os/path format

http://stackoverflow.com/questions/8384737/python-extract-file-name-from-path-no-matter-what-the-os-path-format

'c' 'c' 1 There's one caveat Linux filenames may contain backslashes . So on linux r'a b c' always refers to the file b c in the.. it's usually safe to assume it's a windows path since backslashes are seldom used in Linux filenames but keep this in mind when..