Jan Novak added the comment:
New examples with the structured data.
Problems are with quotes and spaces inside { or [
cookie-script.com set those cookie data:
CookieScriptConsent={"action":"accept","categories":"[\\"performance\\"]"}
Py
Jan Novak added the comment:
It is interesting that pathlib.Path works fine:
>>> pathlib.Path('jpg').suffix
'.jpg'
>>> pathlib.Path('path/jpg').suffix
'.jpg'
--
_
Jan Novak added the comment:
Thank you all for discussion and partial solution in latest Python versions and
extending documentation.
For the future development of Python the initial question remains.
How to easy detect extensions for each file with standard python library
function. Without
Jan Novak added the comment:
Possible patch, load parts one by one:
http_cookie = 'id=12345; [object Object]=data; something=not_loaded'
for cookie_key in http_cookie.split(';'):
c.load(cookie_key)
print c
Set-Cookie: id=12345
Set-Cookie:
New submission from Jan Novak :
If brackets [] are around cookie name,
next cookie names are not loaded.
try:
import http.cookies as Cookie
except ImportError:
import Cookie
c = Cookie.SimpleCookie()
c.load('id=12345; [object Object]=data; something=not loaded')
print(c)
Note
Jan Novak added the comment:
Yes, dot behaviour is well documented.
But splitext() is a function to split name and extension, not take care about
hidden files.
Hidden files starting with dot is Unix like system feature.
https://en.wikipedia.org/wiki/Hidden_file_and_hidden_directory
Hidden
New submission from Jan Novak :
There are some old tickets about changing splitext() in 2007:
https://bugs.python.org/issue1115886
https://bugs.python.org/issue1681842
Present python documentation:
Leading periods on the basename are ignored; splitext('.cshrc') returns
('.cshrc
Jan Novak added the comment:
I made some new tests in P2.6.1
>>> import email.charset
>>> c=email.charset.Charset('utf-8')
>>> print c.input_charset, type(c.input_charset)
utf-8
>>> print c.output_charset, type(c.output_charset)
utf-8