On Nov 9, 2008, at 7:00 PM, News123 wrote:
Hi,
I was googling quite some time before finding the answer to my
question:
'what are the names for the encodings supported by python?'
I found the answer at http://python.active-venture.com/lib/
node127.html
Now my question:
Can I find the same info in the standard python doc or query python
with
a certain command to print out all existing codings?
Look under the heading "Standard Encodings": http://docs.python.org/library/codecs.html
Note that both the page you found (which appears to be a copy of the
Python documentation) and the reference I provide say, "Neither the
list of aliases nor the list of languages is meant to be exhaustive".
I guess one reason for this is that different Python implementations
could choose to offer codecs for additional encodings. 3 2659
On Nov 11, 2008, at 9:10 AM, News123 wrote:
Hi Philip,
Your answer touches exaclty one point, which I was slightly afraid of:
- The list is not exhaustive
- python versions might have implemented different codecs.
This is why I wondered whether there's any way of querying python
for a
list of codecs it supports.
Try this:
Python 2.5.1 (r251:54863, Nov 17 2007, 21:19:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright" , "credits" or "license" for more information.
>>import encodings.alias es
encodings.ali ases.aliases
"aliases" in the encodings.alias es module is a dict mapping alias
names (the dict keys) to encodings (the dict values). Thus, this will
give you the list of supported encodings:
>>set(encodings .aliases.aliase s.values())
The encodings module isn't in the documentation (?!?); I found it when
looking through the Python source code. For that reason I can't say
more about how it works. You may want to experiment to see if
encodings added via codecs.register () show up in the
encodings.alias es.aliases dict.
Have fun
Philip
>
Philip Semanchuk wrote:
>> On Nov 9, 2008, at 7:00 PM, News123 wrote:
>>Hi,
I was googling quite some time before finding the answer to my question: 'what are the names for the encodings supported by python?'
I found the answer at http://python.active-venture.com/lib/node127.html
Now my question:
Can I find the same info in the standard python doc or query python with a certain command to print out all existing codings?
Look under the heading "Standard Encodings": http://docs.python.org/library/codecs.html
Note that both the page you found (which appears to be a copy of the Python documentation) and the reference I provide say, "Neither the list of aliases nor the list of languages is meant to be exhaustive".
I guess one reason for this is that different Python implementations could choose to offer codecs for additional encodings.
-- http://mail.python.org/mailman/listinfo/python-list
On Nov 11, 2008, at 1:08 PM, News123 wrote:
Hi Philip,
Thanks for your answer:
The fact, that a module 'encodings' exists was new to me.
We both learned something new today. =)
encodings.alias es.aliases has however one problem.
It helps to locate all encoding aliases, but it won't find entries for
which no aliases exist:
Ooops, I hadn't thought about that.
What gives me a list of quite some encodings on my host is the shell
command
ls /usr/lib/python2.5/encodings | sed -n 's/\.py$//p' | sort
(soma false hits, bit this is fine for me purposes)
I don't know if really all encodings are represented with a .py file
and
if all encodigns have to be in this directory, but it's a start.
Using shell commands is not that pythonic:
I could try to rewrite this in python by
1.) determine from which directory encodings was imported and
then using the glob module to list all .py files located there.
Yes, I'd thought about this but I agree with you that it seems
unpythonic and fragile. Unfortunately I can't think of anything better
at this point.
Good luck
Philip
>
Philip Semanchuk wrote:
>> On Nov 11, 2008, at 9:10 AM, News123 wrote:
>>Hi Philip,
Your answer touches exaclty one point, which I was slightly afraid of: - The list is not exhaustive - python versions might have implemented different codecs.
This is why I wondered whether there's any way of querying python for a list of codecs it supports.
Try this: Python 2.5.1 (r251:54863, Nov 17 2007, 21:19:53) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright" , "credits" or "license" for more information.
>>>>import encodings.alias es > encodings.a liases.aliases
"aliases" in the encodings.alias es module is a dict mapping alias names (the dict keys) to encodings (the dict values). Thus, this will give you the list of supported encodings:
>>>>set(encodin gs.aliases.alia ses.values())
The encodings module isn't in the documentation (?!?); I found it when looking through the Python source code. For that reason I can't say more about how it works. You may want to experiment to see if encodings added via codecs.register () show up in the encodings.alias es.aliases dict.
Have fun Philip
>>> Philip Semanchuk wrote:
On Nov 9, 2008, at 7:00 PM, News123 wrote:
Hi, > I was googling quite some time before finding the answer to my question: 'what are the names for the encodings supported by python?' > I found the answer at http://python.active-venture.com/lib/node127.html > > Now my question: > Can I find the same info in the standard python doc or query python with a certain command to print out all existing codings?
Look under the heading "Standard Encodings": http://docs.python.org/library/codecs.html
Note that both the page you found (which appears to be a copy of the Python documentation) and the reference I provide say, "Neither the list of aliases nor the list of languages is meant to be exhaustive".
I guess one reason for this is that different Python implementati ons could choose to offer codecs for additional encodings. -- http://mail.python.org/mailman/listinfo/python-list
-- http://mail.python.org/mailman/listinfo/python-list
On Nov 11, 11:19 am, Philip Semanchuk <phi...@semanch uk.comwrote:
On Nov 11, 2008, at 1:08 PM, News123 wrote:
Hi Philip,
Thanks for your answer:
The fact, that a module 'encodings' exists was new to me.
We both learned something new today. =)
encodings.alias es.aliases has however one problem.
It helps to locate all encoding aliases, but it won't find entries for
which no aliases exist:
Ooops, I hadn't thought about that.
What gives me a list of quite some encodings on my host is the shell
command
ls /usr/lib/python2.5/encodings | sed -n 's/\.py$//p' | sort
(soma false hits, bit this is fine for me purposes)
I don't know if really all encodings are represented with a .py file
and
if all encodigns have to be in this directory, but it's a start.
Using shell commands is not that pythonic:
I could try to rewrite this in python by
1.) determine from which directory encodings was imported and
then using the glob module to list all .py files located there.
Yes, I'd thought about this but I agree with you that it seems
unpythonic and fragile. Unfortunately I can't think of anything better
at this point.
Good luck
Philip
....snip...
If it's of any help, in a post on 2007-07-22 by Peter Otten,
(though I can't get a url for it at the moment) he took the
same approach. From a saved copy of that post:
import encodings
import os
import glob
def encodings_from_ modulenames():
ef = os.path.dirname (encodings.__fi le__)
for fn in glob.glob(os.pa th.join(ef, "*.py")):
fn = os.path.basenam e(fn)
yield os.path.splitex t(fn)[0] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marko Faldix |
last post by:
Hello,
with Python 2.3 I can write umlauts (a,o,u umlaut) to a file with this piece
of code:
import codecs
f = codecs.open("klotentest.txt", "w", "latin-1")
print >>f, unicode("My umlauts are ä, ö, ü", "latin-1")
|
by: John Roth |
last post by:
PEP 263 is marked finished in the PEP index, however
I haven't seen the specified Phase 2 in the list of changes
for 2.4 which is when I expected it.
Did phase 2 get cancelled, or is it just not in the
changes document?
John Roth
|
by: F. GEIGER |
last post by:
I'm on WinXP, Python 2.3.
I don't have problems with umlauts (ä, ö, ü and their uppercase instances)
in my wxPython-GUIs, when displayed as static texts. But when filling
controls with text containing umlauts, or in the Python console, or when
writing to files umlauts are escaped:
Python 2.3.4 (#53, May 25 2004, 21:17:02) on
win32
Type "help", "copyright", "credits" or "license" for more information.
|
by: Quentin Crain |
last post by:
Hello All:
I am being told by my systems people that the load on
the NFS servers is nasty. Our python installs are up
on NFS. Also, on a bureaucratic note, I have very
little input/control into the python builds (sigh).
I have found the following (linux):
strace -f -F python2.2.2 -c 'pass' |& fgrep '(No such
|
by: packrat |
last post by:
I am attempting to build a Bugzilla server on OS X.
All of this is new to me, working with the Perl, MySQL, and Bugzilla,
so I have been
banging my head often.
Software error:
When I run the bugzilla 'checksetup.pl' file, I get the following:
-------------------------------------------------------------------
| |
by: M Jared Finder |
last post by:
I'm confused. XML looks to be extremely simple to read and write (so
simple that I feel confidant I could program serialization and
deserailization from a DOM document in an about an hour), yet I see
many serializing tools available (Xerces and .NET's System.Xml appear
to be the most popular). What functionality do these tools provide
that makes them useful over rolling my own parser?
-- MJF
|
by: Bugs |
last post by:
I believe I read in a relatively recent thread that the reason
python24.dll is so large compared to previous releases is that all the
language encodings are linked into the library?
Are there any plans for future releases to split the encodings out so
that, for example, if someone wanted to make a smaller executable using
py2exe without all the language encodings, they could do so?
I suppose one could always compile their own version...
|
by: henk-jan ebbers |
last post by:
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive:...
|
by: Mark Tolonen |
last post by:
"News123" <news123@free.frwrote in message
news:491779b1$0$19313$426a74cc@news.free.fr...
The first hit from googling "site:python.org encodings":
http://www.python.org/doc/2.5.2/lib/standard-encodings.html
-Mark
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |