japanese encoding iso-2022-jp in python vs. perl

2007-10-23 Thread kettle
Hi, I am rather new to python, and am currently struggling with some encoding issues. I have some utf-8-encoded text which I need to encode as iso-2022-jp before sending it out to the world. I am using python's encode functions: -- var = var.encode("iso-2022-jp", "replace") print var -- I am

Re: japanese encoding iso-2022-jp in python vs. perl

2007-10-24 Thread kettle
Thanks Leo, and everyone else, these were very helpful replies. The issue was exactly as Leo described, and I apologize for not being aware of it, and thus not quite reporting it correctly. At the moment I don't care about round-tripping between half-width and full-width kana, rather I need only

dictionary of dictionaries

2007-12-09 Thread kettle
Hi, I'm wondering what the best practice is for creating an extensible dictionary-of-dictionaries in python? In perl I would just do something like: my %hash_of_hashes; for(my $i=0;$i<10;$i++){ for(my $j=0;$j<10;$j++){ ${$hash_of_hashes{$i}}{$j} = int(rand(10)); } } but it seem

Re: dictionary of dictionaries

2007-12-09 Thread kettle
On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote: > > Hi, > > I'm wondering what the best practice is for creating an extensible > > dictionary-of-dictionaries in python? >

Re: dictionary of dictionaries

2007-12-10 Thread kettle
On Dec 10, 6:58 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > kettle wrote: > > On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote: > >> > Hi, > >> > I&

Re: dictionary of dictionaries

2007-12-10 Thread kettle
On Dec 10, 6:58 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > kettle wrote: > > On Dec 9, 5:49 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Sun, 09 Dec 2007 00:35:18 -0800, kettle wrote: > >> > Hi, > >> > I&

socket script from perl -> python

2008-02-07 Thread kettle
Hi I have a socket script, written in perl, which I use to send audio data from one server to another. I would like to rewrite this in python so as to replicate exactly the functionality of the perl script, so as to incorporate this into a larger python program. Unfortunately I still don't really

Re: socket script from perl -> python

2008-02-07 Thread kettle
On Feb 8, 12:08 am, Bjoern Schliessmann wrote: > kettle wrote: > > Hi I have a socket script, written in perl, which I use to send > > audio data from one server to another. I would like to rewrite > > this in python so as to replicate exactly the functionality of the >

Re: socket script from perl -> python

2008-02-07 Thread kettle
On Feb 8, 4:01 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > kettle <[EMAIL PROTECTED]> writes: > > # pack $length as a 32-bit network-independent long > > my $len = pack('N', $length); > [...] > > the sticking point seems to be the $len variable. >

python tr equivalent (non-ascii)

2008-08-13 Thread kettle
Hi, I was wondering how I ought to be handling character range translations in python. What I want to do is translate fullwidth numbers and roman alphabet characters into their halfwidth ascii equivalents. In perl I can do this pretty easily with tr: tr/\x{ff00}-\x{ff5e}/\x{0020}-\x{007e}/;

Re: python tr equivalent (non-ascii)

2008-08-13 Thread kettle
On Aug 13, 5:18 pm, kettle <[EMAIL PROTECTED]> wrote: > Hi, > I was wondering how I ought to be handling character range > translations in python. > > What I want to do is translate fullwidth numbers and roman alphabet > characters into their halfwidth ascii equivalents.

Re: python tr equivalent (non-ascii)

2008-08-13 Thread kettle
On Aug 13, 5:33 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > kettle wrote: > > I was wondering how I ought to be handling character range > > translations in python. > > > What I want to do is translate fullwidth numbers and roman alphabet > > characters in