Re: Accessing parallel port interrupts using python or any c python binding ?

2008-04-20 Thread Gabriel Genellina
En Mon, 21 Apr 2008 01:09:59 -0300, kapardhi bvn <[EMAIL PROTECTED]> escribió:

> Any body can tell me an efficient way of reading parallel port at high
> speed.
> this is basically to extend ISA and other bus interfacing.

See pyparallel (part of the pyserial package)

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Accessing parallel port interrupts using python or any c python binding ?

2008-04-20 Thread kapardhi bvn
Any body can tell me an efficient way of reading parallel port at high
speed.
this is basically to extend ISA and other bus interfacing.
please help
thanks in advance
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python Binding

2007-05-12 Thread Georg Grabler
You are completely right wihtin this. It's some time i didn't reply, but
i've taken a look on pyrex and swig now which did cost me some time, and
they really make it easier. SWIG provides more possibilities and bindings
for other languages too, though - i must say i've been faster with pyrex,
for some reason it fits me better.

I'd like to use swig, but for some reason i've troubles defining a
completely new type, so a type which is not a wrapper type, but a type
provided to python.

Kind regards,
Georg

Stefan Behnel wrote:

> STiAT wrote:
>> Why do you all suggest other things than the way suggested by python?
> 
> Because going to Paris is not the only way to get french bread?
> 
> Why would you want to write all that ugly glue code by hand that Pyrex
> generates for free? Module descriptors? Class descriptors? Method
> descriptors? Reference counting? That's what Pyrex saves you from.
> Honestly.
> 
> From what I read in your mail, that's exactly the kind of thing you're
> having trouble with. Wouldn't you prefer concentrating on your real code
> instead?
> 
> 
>> I havn't got a real problem writing the code in C, actually, it looked
>> as if it would give me several possibilities i wouldn't have with
>> pyrex (like binding more library functions to one provided python
>> function and so on).
> 
> No idea what you mean in your parentheses, but I don't think there are
> many "possibilities" you "wouldn't have with Pyrex".
> 
> We used Pyrex to write lxml, a wrapper around the huge API of libxml2 and
> libxslt. It's some 11000 lines of Pyrex code by now, but the generated C
> code is some 67000 lines in total. Even if it's somewhat verbose and
> generic in places, I wouldn't have wanted to write that by hand.
> 
> Stefan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-08 Thread Stefan Behnel
STiAT wrote:
> Why do you all suggest other things than the way suggested by python?

Because going to Paris is not the only way to get french bread?

Why would you want to write all that ugly glue code by hand that Pyrex
generates for free? Module descriptors? Class descriptors? Method descriptors?
Reference counting? That's what Pyrex saves you from. Honestly.

>From what I read in your mail, that's exactly the kind of thing you're having
trouble with. Wouldn't you prefer concentrating on your real code instead?


> I havn't got a real problem writing the code in C, actually, it looked
> as if it would give me several possibilities i wouldn't have with
> pyrex (like binding more library functions to one provided python
> function and so on).

No idea what you mean in your parentheses, but I don't think there are many
"possibilities" you "wouldn't have with Pyrex".

We used Pyrex to write lxml, a wrapper around the huge API of libxml2 and
libxslt. It's some 11000 lines of Pyrex code by now, but the generated C code
is some 67000 lines in total. Even if it's somewhat verbose and generic in
places, I wouldn't have wanted to write that by hand.

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-08 Thread STiAT
Hello,

I've basically had plans on just extending python for the wrapper.
That basically works fine, i just don't get along by the types
provided (http://docs.python.org/ext/ext.html).

Anyway, i want to extend python for types. The problem i currently
experience is the following.

Guess what - i have a base class, doing some wrapping. Currently,
called pybtest (just testing around though).
Now, i'd need a configuration object, accessable in python. By using
the library, it should be possible to access it using
pybtest.config.insertValue('xyz') as an example, but i havn't found
any way to archive this yet.

If i write config as an own (external) type, i can't get it into the
pybtest object for some reason. It's compiled as an extra "config.so",
and with the test script i need to do import config. Anyway, it's not
in the pybtest object., i've to build up a config and pass it by to
the pybtest binding, so it can set it's internal configuration
structures.

If i try to compile it within the pybtest, i can't use ext_modules,
and as expected, i can't do another pybtestinit function, so it's
quite useless, at least with the knowledge i could get out of the
documentation.

By just making a include file of the type, including the type
definition adding up some functions to pybtest, i actually can access
it, without the wanted functionality of pybtest.config.

Why do you all suggest other things than the way suggested by python?
I havn't got a real problem writing the code in C, actually, it looked
as if it would give me several possibilities i wouldn't have with
pyrex (like binding more library functions to one provided python
function and so on). I havn't had a closer look to SWIG yet.

It looks as if i could just provide single objects or modules, and no
additional object into a module.

Does anyone have closer knowledge on this?
Btw: Sorry for the long delay time, i had to describe the things
closer, and had to take a deeper look into the bindings than i had
before.

Kind regards,
Georg

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-06 Thread Nick Craig-Wood
Georg Grabler <[EMAIL PROTECTED]> wrote:
>  There's a C library which i'd like to have python bindings for. I havn't
>  known anything before about how to write python bindings for a C library.
> 
>  I succeeded now by using distutils to write the first bindings for functions
>  and similar.
> 
>  Now, it seems as something is blocking my brain. For the library, i
>  need "custom" types, so types defined in this library (structures),
>  including pointers and similar.
> 
>  I've been thinking about what i will need to represent this lists in python.
>  I thought about creating an external python object, providing "information"
>  i get from the list in C structures which can be converted.
> 
>  Basically, it are list of packages, which have several attributes (next,
>  prev, etc). But i don't know how to supply a proper list from the binding /
>  object written in C.
> 
>  Any suggestions or hints about this?

Sounds like a job for ctypes which is bundled with py 2.5.

  http://docs.python.org/lib/module-ctypes.html

It is great for access C libraries (assuming you have a shared library
(.so or .dll).

You'll end up writing python code rather than C code which you'll
enjoy!

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-06 Thread Stefan Sonnenberg-Carstens
Stefan Behnel schrieb:
> Georg Grabler wrote:
>   
>> There's a C library which i'd like to have python bindings for. I havn't
>> known anything before about how to write python bindings for a C library.
>>
>> I succeeded now by using distutils to write the first bindings for functions
>> and similar.
>>
>> Now, it seems as something is blocking my brain. For the library, i
>> need "custom" types, so types defined in this library (structures),
>> including pointers and similar.
>>
>> I've been thinking about what i will need to represent this lists in python.
>> I thought about creating an external python object, providing "information"
>> i get from the list in C structures which can be converted.
>>
>> Basically, it are list of packages, which have several attributes (next,
>> prev, etc). But i don't know how to supply a proper list from the binding /
>> object written in C.
>>
>> Any suggestions or hints about this?
>> 
>
> Use Pyrex. It's a Python-like language that was designed to write extension
> modules in C and it's great for writing wrappers.
>
> http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
>
> An example wrapper is described here:
>
> http://ldots.org/pyrex-guide/
>
> Hope it helps,
> Stefan
>   
Hi,
use SWIG.
It is a no-brainer for simple libs. wxPython relies heavily on it.
I worked with some times and it is really straightforward.
See this: http://www.swig.org/Doc1.1/HTML/Python.html
Cheers,
Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-06 Thread Stefan Sonnenberg-Carstens
Stefan Behnel schrieb:
> Georg Grabler wrote:
>   
>> There's a C library which i'd like to have python bindings for. I havn't
>> known anything before about how to write python bindings for a C library.
>>
>> I succeeded now by using distutils to write the first bindings for functions
>> and similar.
>>
>> Now, it seems as something is blocking my brain. For the library, i
>> need "custom" types, so types defined in this library (structures),
>> including pointers and similar.
>>
>> I've been thinking about what i will need to represent this lists in python.
>> I thought about creating an external python object, providing "information"
>> i get from the list in C structures which can be converted.
>>
>> Basically, it are list of packages, which have several attributes (next,
>> prev, etc). But i don't know how to supply a proper list from the binding /
>> object written in C.
>>
>> Any suggestions or hints about this?
>> 
>
> Use Pyrex. It's a Python-like language that was designed to write extension
> modules in C and it's great for writing wrappers.
>
> http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/
>
> An example wrapper is described here:
>
> http://ldots.org/pyrex-guide/
>
> Hope it helps,
> Stefan
>   

Hi,
use SWIG.
It is a no-brainer for simple libs. wxPython relies heavily on it.
I worked with some times and it is really straightforward.
See this: http://www.swig.org/Doc1.1/HTML/Python.html
Cheers,
Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Binding

2007-05-05 Thread Stefan Behnel
Georg Grabler wrote:
> There's a C library which i'd like to have python bindings for. I havn't
> known anything before about how to write python bindings for a C library.
> 
> I succeeded now by using distutils to write the first bindings for functions
> and similar.
> 
> Now, it seems as something is blocking my brain. For the library, i
> need "custom" types, so types defined in this library (structures),
> including pointers and similar.
> 
> I've been thinking about what i will need to represent this lists in python.
> I thought about creating an external python object, providing "information"
> i get from the list in C structures which can be converted.
> 
> Basically, it are list of packages, which have several attributes (next,
> prev, etc). But i don't know how to supply a proper list from the binding /
> object written in C.
> 
> Any suggestions or hints about this?

Use Pyrex. It's a Python-like language that was designed to write extension
modules in C and it's great for writing wrappers.

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/

An example wrapper is described here:

http://ldots.org/pyrex-guide/

Hope it helps,
Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Binding

2007-05-05 Thread Georg Grabler
Hello everybody.

There's a C library which i'd like to have python bindings for. I havn't
known anything before about how to write python bindings for a C library.

I succeeded now by using distutils to write the first bindings for functions
and similar.

Now, it seems as something is blocking my brain. For the library, i
need "custom" types, so types defined in this library (structures),
including pointers and similar.

I've been thinking about what i will need to represent this lists in python.
I thought about creating an external python object, providing "information"
i get from the list in C structures which can be converted.

Basically, it are list of packages, which have several attributes (next,
prev, etc). But i don't know how to supply a proper list from the binding /
object written in C.

Any suggestions or hints about this?

Thank you,
Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread Ian Parker
In message <[EMAIL PROTECTED]>, Alex 
Li <[EMAIL PROTECTED]> writes
>Thanks Michel, I will give it a try.
>
>Alex
>
>
>

You could simply generate the .dot files from python and do os.startfile 
on the dot file (which is what I do because it is remarkably easy!)

Regards
-- 
Ian Parker
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread Alex Li
On Mar 6, 3:20 pm, "Istvan Albert" <[EMAIL PROTECTED]> wrote:
>
> https://networkx.lanl.gov/wiki/pygraphviz

Thanks Albert.  I looked into pygraphviz as well but it requires
compiling C extension, and there is no Windows compilation instruction
(though it probably won't be hard).

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread bearophileHUGS
Alex Li:
> Now, I am sure we will redo it in C# after my "prototype";

Sadly this happens often, they don't want to keep using two languages
when one may suffice. On the other hand, you may even find a way to
adapt your Python code to IronPython, so maybe you can avoid the
translation to C#.

Bye,
bearophile

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread Istvan Albert
On Mar 6, 3:18 pm, "Istvan Albert" <[EMAIL PROTECTED]> wrote:

> try the networkx package, it includes the pygraphviz module that can
> generate dot files:
>
> https://networkx.lanl.gov/wiki

should've checked it before posting, it seems nowadays is actually a
separate package

https://networkx.lanl.gov/wiki/pygraphviz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread Istvan Albert
On Mar 5, 5:16 pm, "Alex Li" <[EMAIL PROTECTED]> wrote:

> I tried to avoid.  Any suggestions?

try the networkx package, it includes the pygraphviz module that can
generate dot files:

https://networkx.lanl.gov/wiki

Istvan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread Alex Li
Thanks all for your suggestions.

Nick: I am trying to avoid generate the dot file manually so that I
can minimize bugs coz by me ;)

SPE: Unfortunately that may be too radical ;)  I work in a corporate
environment (read: MS shop) and my group wants to generate a
dependency graph of our system.  I was trying to take this opportunity
to introduce some python to the group.  They were amazed when I came
up with the script in a few hours and were willing to try it out by
installing python, yapgvb, and graphviz.  But it won't work on python
2.5!  It's kind of a bummer to tell them to install an older version
of python.

On second look, I will try pydot again.  Despite no release for a long
time, it seems to be reasonably complete.  Now, I am sure we will redo
it in C# after my "prototype"; but that will just prove the advantages
of python in terms of code size and productivity :)


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-06 Thread SPE - Stani's Python Editor
On Mar 6, 8:39 am, "Nick Vatamaniuc" <[EMAIL PROTECTED]> wrote:
> On Mar 5, 5:16 pm, "Alex Li" <[EMAIL PROTECTED]> wrote:
>
> > Hello,
>
> > I would like to use Python 2.5 on Windows with Graphviz to generate
> > graphs.  I used yapgvb but it only requires Python 2.4 (won't work
> > with Python 2.5).  Other packages like pydot seems to be unmaintained
> > or requires custom building to be used on Windows (pygraphviz), which
> > I tried to avoid.  Any suggestions?
>
> > Thanks in advance,
> > Alex
>
> Alex,
> You can always pipe your dot file directly to the dot or neato
> executables using the subprocess method then read the output. This way
> you don't have to install yapgvb or other adapters and it will work
> with Python 2.5. But you will need to compose your dot file as a giant
> character buffer...
> -Nick V.

Not really a solution, but you can always install a virtual machine
with Ubuntu (or other linux flavour) where pydot is available for
python2.5 (sudo apt-get install python-pydot).

Stani

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-05 Thread Nick Vatamaniuc
On Mar 5, 5:16 pm, "Alex Li" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I would like to use Python 2.5 on Windows with Graphviz to generate
> graphs.  I used yapgvb but it only requires Python 2.4 (won't work
> with Python 2.5).  Other packages like pydot seems to be unmaintained
> or requires custom building to be used on Windows (pygraphviz), which
> I tried to avoid.  Any suggestions?
>
> Thanks in advance,
> Alex

Alex,
You can always pipe your dot file directly to the dot or neato
executables using the subprocess method then read the output. This way
you don't have to install yapgvb or other adapters and it will work
with Python 2.5. But you will need to compose your dot file as a giant
character buffer...
-Nick V.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-05 Thread Alex Li
Thanks Michel, I will give it a try.

Alex



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Graphviz Python Binding for Python 2.5 on Windows?

2007-03-05 Thread M�ta-MCI
Hi!

You can also use/call GraphViz by COM.
It's run OK with P2.3 - 2.4 & 2.5 

@-salutations

Michel Claveau


-- 
http://mail.python.org/mailman/listinfo/python-list


Graphviz Python Binding for Python 2.5 on Windows?

2007-03-05 Thread Alex Li
Hello,

I would like to use Python 2.5 on Windows with Graphviz to generate
graphs.  I used yapgvb but it only requires Python 2.4 (won't work
with Python 2.5).  Other packages like pydot seems to be unmaintained
or requires custom building to be used on Windows (pygraphviz), which
I tried to avoid.  Any suggestions?

Thanks in advance,
Alex

-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] clnum-1.4 Class Library For Numbers Python Binding

2006-11-19 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating
point numbers in real and complex form to Python. Also provides
arbitrary precision floating point replacements for the functions in the
math and cmath standard library modules.

Home page: http://calcrpnpy.sourceforge.net/clnum.html

Changes in 1.4

* Fixed anomaly where an exact zero was converted using default
precision in multiply and divide routines.

* Added function to approximate a number as a rational with the size of
the numerator and denominator constrained.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] clnum-1.3 Class Library For Numbers Python Binding

2006-08-19 Thread david_wahler
I'll be out of the office until approximately August 20th. If you have any 
questions, please email [EMAIL PROTECTED]

-- David Wahler


-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] clnum-1.3 Class Library For Numbers Python Binding

2006-08-19 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating
point numbers in real and complex form to Python. Also provides
arbitrary precision floating point replacements for the functions in the
math and cmath standard library modules.

Home page: http://calcrpnpy.sourceforge.net/clnum.html

Changes in 1.3

* Added combinatorial functions.

* Improved the performance of converting very large Python longs.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] clnum-1.2.1 Class Library For Numbers Python Binding

2006-06-11 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating
point numbers in real and complex form to Python. Also provides
arbitrary precision floating point replacements for the functions in the
math and cmath standard library modules.

Home page: http://calcrpnpy.sourceforge.net/clnum.html

Changes in 1.2.1

Updated the unit test so it works on both 32 and 64 bit platforms.  Only
the source package was updated since there are no other changes.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] clnum-1.2 Class Library For Numbers Python Binding

2006-05-06 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating
point numbers in real and complex form to Python. Also provides
arbitrary precision floating point replacements for the functions in the
math and cmath standard library modules.

Home page: http://calcrpnpy.sourceforge.net/clnum.html

Changes in 1.2

* Make compatible with Python 2.5 on 64-bit platforms.

* Windows installer now available.

* Include documentation for building clnum on Windows.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-20 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
> I don't have any problems with simply printing the characters from
> Python (outside of ncurses), but using the ncurses functions for
> printing these characters is problematic.

I see. I can't get this to work, either, and neither with libncursesw.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-20 Thread Martin v. Löwis
Thomas Dickey wrote:
> Both libraries respond to locale.  But ncurses only deals in single-byte
> encodings, e.g., ISO-8859-1 through ISO-8859-15.  ncursesw supports that,
> but adds support for multi-byte encodings, e.g., UTF-8.  For the latter,
> one can also have characters that combine (a printable character combined
> with other characters that overlay it or combine to form a new character).
> 
> ncurses stores the character data in one byte per cell.
> ncursesw requires more than one byte per cell.
> That's the reason for two libraries.
> 
> But since ncurses (not ncursesw) doesn't know about multibyte encoding,
> it can't do anything related to the locale for those.

How could I tell the difference? I'm trying to render UTF-8 text with
ncurses (5.5) on Debian unstable, and it seems to work just fine.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-20 Thread bmcnally
Can someone explain what I'm doing wrong? The following code snipet
produces an error about addch() expecting an int:

u = u'\u2591'
s = u.encode("UTF-8")
stdscr.addch((y+1), (x+1), s, curses.color_pair(1))

If I try this instead:

u = u'\u2591'
s = u.encode("UTF-8")
stdscr.addstr((y+1), (x+1), s, curses.color_pair(1))

I don't get what I expect to print out on the screen.

I don't have any problems with simply printing the characters from
Python (outside of ncurses), but using the ncurses functions for
printing these characters is problematic.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-20 Thread Thomas Dickey
"Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> Thomas Dickey wrote:
>>>ncurses expects byte strings (although I'm uncertain as to what
>>>impact multi-byte encodings have in ncurses).
>> 
>> 
>> It depends on whether python's curses binding is linked with the 
>> wide-character
>> flavor (ncursesw) or the normal one.  If it's linked with ncursesw, strings 
>> are
>> interpreted according to the locale settings.

> Are you sure? According to ncurses' INSTALL file, the purpose of
> ncursesw is to provide wide character support, not locale support.
> It's two libraries just for binary compatibility issues.

Well, of course I'm _sure_.  But my explanation may be poor.

Both libraries respond to locale.  But ncurses only deals in single-byte
encodings, e.g., ISO-8859-1 through ISO-8859-15.  ncursesw supports that,
but adds support for multi-byte encodings, e.g., UTF-8.  For the latter,
one can also have characters that combine (a printable character combined
with other characters that overlay it or combine to form a new character).

ncurses stores the character data in one byte per cell.
ncursesw requires more than one byte per cell.
That's the reason for two libraries.

But since ncurses (not ncursesw) doesn't know about multibyte encoding,
it can't do anything related to the locale for those.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-19 Thread Martin v. Löwis
Thomas Dickey wrote:
>>ncurses expects byte strings (although I'm uncertain as to what
>>impact multi-byte encodings have in ncurses).
> 
> 
> It depends on whether python's curses binding is linked with the 
> wide-character
> flavor (ncursesw) or the normal one.  If it's linked with ncursesw, strings 
> are
> interpreted according to the locale settings.

Are you sure? According to ncurses' INSTALL file, the purpose of
ncursesw is to provide wide character support, not locale support.
It's two libraries just for binary compatibility issues.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-19 Thread Thomas Dickey
"Martin v. Löwis" <[EMAIL PROTECTED]> wrote:

> ncurses expects byte strings (although I'm uncertain as to what
> impact multi-byte encodings have in ncurses).

It depends on whether python's curses binding is linked with the wide-character
flavor (ncursesw) or the normal one.  If it's linked with ncursesw, strings are
interpreted according to the locale settings.

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-19 Thread Martin v. Löwis
Brian McNally wrote:
> Thanks for responding to my question. I'm still a little confused
> though. How can I encode unicode strings as UTF-8? My terminal does
> support UTF-8, but from looking at Python's ncurses API, it looks like
> all of the methods for displaying characters want an ASCII code (which
> seems to be an integer between 0 -255).

If u is a Unicode string, you do

   s = u.encode("UTF-8")

to get a byte string s.

You are mistaken assuming that the ncurses API requires ASCII, and you
are mistaken assuming ASCII is a sequence of integer values 0..255.

ASCII (the American Standard Code for Information Interchange) is
encoded using a sequence of bytes in the range 0..127.

UTF-8 is encoded using a sequence of bytes in the range 0..255
(as is Latin-1, windows-1252, and any other character encoding/charset).

ncurses expects byte strings (although I'm uncertain as to what
impact multi-byte encodings have in ncurses).

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is the Python binding for ncurses unicode capable?

2006-01-18 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
> I can't tell from the documentation, but I'd like to try and print
> unicode characters through Python's binding to ncurses. From reading
> the documentation on the curses module, it doesn't appear that this is
> possible:
> 
> http://python.org/doc/2.4.2/lib/module-curses.html
> 
> Am I missing something, or is the binding only capable of ASCII?

Neither, nor. There isn't any ncurses API for Unicode - just API
for "wide characters" (wchar_t); Python doesn't use this API.
That doesn't mean it's restricted to ASCII. If your terminal
supports UTF-8, you can output UTF-8 just fine to it, using
Python. Just encode the Unicode strings as UTF-8.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Is the Python binding for ncurses unicode capable?

2006-01-18 Thread bmcnally
I can't tell from the documentation, but I'd like to try and print
unicode characters through Python's binding to ncurses. From reading
the documentation on the curses module, it doesn't appear that this is
possible:

http://python.org/doc/2.4.2/lib/module-curses.html

Am I missing something, or is the binding only capable of ASCII?

-- 
http://mail.python.org/mailman/listinfo/python-list