process.popen with Japanese args => UTF8 JAVA

2014-03-08 Thread Jun Tanaka
Hello, I have tried to process.popen to run java program with Japanese language. test.java is compiled with utf8 '日本語' below means Japanese in Japanese. but it does not work. Anyone who knows this matter well. Please help. Jun python code> sentence = '日本語' filename = 'japanes

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Sommers
On Sun, 09 Mar 2014 03:50:49 +, Steven D'Aprano wrote: > ... UTF-16 ... the letter "A" is stored as two bytes 0x0041 (or 0x4100 > depending on your platform's byte order) ... At the risk of being pedantic, the two bytes are 0x00 and 0x41, and the order in which they appear in memory depends o

Re: gdb unable to read python frame information

2014-03-08 Thread Wesley
Anybody has suggestions? This really makes me crazy... -- https://mail.python.org/mailman/listinfo/python-list

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Ned Batchelder
On 3/8/14 9:08 PM, Dan Stromberg wrote: OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common implementation options would probably hel

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Chris Angelico
On Sun, Mar 9, 2014 at 2:01 PM, Roy Smith wrote: > In article <531bd709$0$29985$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> There are various common ways to store Unicode strings in RAM. >> >> The first, UTF-16. >> [...] >> Another option is UTF-32. >> [...] >> Another opt

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Rustom Mody
On Sunday, March 9, 2014 8:20:49 AM UTC+5:30, Steven D'Aprano wrote: > No version of Python has, to my knowledge, used UTF-8 internally. Some > other languages, such as Go and Haskell, do, and consequently string > processing is slow for them. Haskell: Its more like: "Heres the menu, take your p

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Roy Smith
In article <531bd709$0$29985$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > There are various common ways to store Unicode strings in RAM. > > The first, UTF-16. > [...] > Another option is UTF-32. > [...] > Another option is to use UTF-8 internally. > [...] > In Python 3.3, CPyt

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Chris Angelico
On Sun, Mar 9, 2014 at 1:08 PM, Dan Stromberg wrote: > OK, I know that Unicode data is stored in an encoding on disk. > > But how is it stored in RAM? > > I realize I shouldn't write code that depends on any relevant > implementation details, but knowing some of the more common > implementation op

Re: Tuples and immutability

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 5:45 PM, Gregory Ewing wrote: > Ian Kelly wrote: > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to change. > > > That would be

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread Steven D'Aprano
On Sat, 08 Mar 2014 18:08:38 -0800, Dan Stromberg wrote: > OK, I know that Unicode data is stored in an encoding on disk. > > But how is it stored in RAM? There are various common ways to store Unicode strings in RAM. The first, UTF-16, treats every character [aside: technically, a code point]

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread MRAB
On 2014-03-09 02:40, MRAB wrote: On 2014-03-09 02:08, Dan Stromberg wrote: OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common imple

Re: Tuples and immutability

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 5:40 PM, Gregory Ewing wrote: > Ian Kelly wrote: >> >> class LessThanFilter: >> >> def __init__(self, the_list): >> self._the_list = the_list >> >> def __getitem__(self, bound): >> return [x for x in self._the_list if x < bound] >> >> >> filter = Less

Re: How is unicode implemented behind the scenes?

2014-03-08 Thread MRAB
On 2014-03-09 02:08, Dan Stromberg wrote: OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common implementation options would probably h

How is unicode implemented behind the scenes?

2014-03-08 Thread Dan Stromberg
OK, I know that Unicode data is stored in an encoding on disk. But how is it stored in RAM? I realize I shouldn't write code that depends on any relevant implementation details, but knowing some of the more common implementation options would probably help build an intuition for what's going on i

Re: Balanced trees

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 1:21 PM, Marko Rauhamaa wrote: > If I had to choose between a hash table and AVL (or RB) tree in the > standard library, it would definitely have to be the latter. It is more > generally usable, has fewer corner cases and probably has an equal > performance even in hash tabl

Re: Tuples and immutability

2014-03-08 Thread Gregory Ewing
Ian Kelly wrote: I already mentioned this earlier in the thread, but a balanced binary tree might implement += as node insertion and then return a different object if the balancing causes the root node to change. That would be a really bad way to design a binary tree implementation. What if th

Re: Tuples and immutability

2014-03-08 Thread Gregory Ewing
Ian Kelly wrote: class LessThanFilter: def __init__(self, the_list): self._the_list = the_list def __getitem__(self, bound): return [x for x in self._the_list if x < bound] filter = LessThanFilter([10, 20, 30, 40, 50]) filter[25] += [15, 17, 23] Should that last line

Re: Balanced trees

2014-03-08 Thread Roy Smith
In article <87eh2ctmht@elektro.pacujo.net>, Marko Rauhamaa wrote: > If I had to choose between a hash table and AVL (or RB) tree in the > standard library, it would definitely have to be the latter. It is more > generally usable, has fewer corner cases and probably has an equal > performance

Re: Python programming

2014-03-08 Thread John Ladasky
On Friday, March 7, 2014 4:38:54 PM UTC-8, Dennis Lee Bieber wrote: > On Fri, 7 Mar 2014 10:03:35 -0800 (PST), John Ladasky > declaimed the following: > >> More than once, I have queried Google with the phrase "Why isn't FORTRAN >> dead yet?" For some reason, it lives on. I can't say that I u

Re: Balanced trees

2014-03-08 Thread Marko Rauhamaa
Mark Lawrence : > I believe that there are advantages to leaving specialist data > structures on pypi or other sites, plus it means Python in a Nutshell > can still fit in your pocket and not a 40 ton articulated lorry, > unlike the Java equivalent. An ordered map is a foundational data structure

Re: Balanced trees

2014-03-08 Thread Mark Lawrence
On 08/03/2014 19:58, Dan Stromberg wrote: On Sat, Mar 8, 2014 at 12:34 AM, Marko Rauhamaa wrote: Ian Kelly : I already mentioned this earlier in the thread, but a balanced binary tree might implement += as node insertion and then return a different object if the balancing causes the root node

Re: Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Dan Stromberg
On Sat, Mar 8, 2014 at 12:34 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> I already mentioned this earlier in the thread, but a balanced binary >> tree might implement += as node insertion and then return a different >> object if the balancing causes the root node to change. > > True. > > Speaking

Re: Python performance

2014-03-08 Thread Ned Batchelder
On 3/8/14 7:53 AM, JCosta wrote: I did some work in c# and java and I converted some application to Python; I noticed Python is much slower than the other languages. Is this normal ? Thanks Your question, and the replies so far in this thread, have overlooked the difference between language

Re: Python performance

2014-03-08 Thread Mark Lawrence
On 08/03/2014 18:30, JCosta wrote: Sábado, 8 de Março de 2014 12:53:57 UTC, JCosta escreveu: I did some work in c# and java and I converted some application to Python; I noticed Python is much slower than the other languages. Is this normal ? Thanks ... Thanks for the help (C

Re: Python performance

2014-03-08 Thread JCosta
Sábado, 8 de Março de 2014 12:53:57 UTC, JCosta escreveu: > I did some work in c# and java and I converted some application to Python; I > noticed Python is much slower than the other languages. > > > > Is this normal ? > > Thanks ... Thanks for the help (Chris, Tim and Marko) an

Re: Python performance

2014-03-08 Thread Marko Rauhamaa
JCosta : > I did some work in c# and java and I converted some application to > Python; I noticed Python is much slower than the other languages. > > Is this normal ? Yes. The main reason is the dot notation, which in C through Java is implemented by the compiler as a fixed offset to a memory str

Re: How to extract contents of inner text of html tag?

2014-03-08 Thread Jason Friedman
> for line in all_kbd: >if line.string == None: I modified your code slightly: for line in all_kbd: print(line) sys.exit() if line.string == None: Running the new script yields: $ python shibly.py cp -v --remove-destination /usr/share/zoneinfo/ \ /etc/localtim

Re: Critic: New Python Front Page

2014-03-08 Thread Nils-Hero Lindemann
Hello, > The source for the site is on github, and they are taking and resolving > issues there: https://github.com/python/pythondotorg/issues Thanks for pointing me to the right place. I copypasted my mail to ... https://github.com/python/pythondotorg/issues/266 also i added a comment to ... ht

Re: gdb unable to read python frame information

2014-03-08 Thread Wesley
So, let me clarify here, in order to try, I get a clean machine. Centos 6.5 64bit. Now , I try this: 1. install gdb 7.7 from source , with configure option --with-python 2. install python 2.6.6 from source, with configure option --with-pydebug 3. run a python script 4. from command line, gdb py

Re: gdb unable to read python frame information

2014-03-08 Thread Wesley
Now I use gdb python -p then, import libpython py-bt is null, py-locals raise here: Unable to locate python frame What's going on... -- https://mail.python.org/mailman/listinfo/python-list

Re: Assertions are bad, m'kay?

2014-03-08 Thread Steven D'Aprano
On Fri, 07 Mar 2014 16:15:36 -0800, Dan Stromberg wrote: > On Fri, Mar 7, 2014 at 3:11 AM, Steven D'Aprano > wrote: > > >> Assertions are not bad! They're just misunderstood and abused. > >> You should read this guy's blog post on when to use assert: >> >> http://import-that.dreamwidth.org/676

Re: gdb unable to read python frame information

2014-03-08 Thread Mark Lawrence
On 08/03/2014 13:32, Wesley wrote: python debuginfo is installed... Still,py-bt, py-locals.etc cannot read python frame If you don't provide context people are less likely to help you. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Re: Critic: New Python Front Page

2014-03-08 Thread Ned Batchelder
On 3/8/14 8:31 AM, Ned Batchelder wrote: On 3/8/14 7:44 AM, Nils-Hero Lindemann wrote: Hi, (Please forgive (or correct) my mistakes, i am non native) http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ * Formatting bug * Needs breadcrumb navigation ("Where am i?") (i c

Re: Python performance

2014-03-08 Thread Tim Chase
On 2014-03-08 04:53, JCosta wrote: > I did some work in c# and java and I converted some application to > Python; I noticed Python is much slower than the other languages. > > Is this normal ? It depends. Did you write C#/Java in Python (i.e., use C# or Java idioms in Python), or did you write P

Re: gdb unable to read python frame information

2014-03-08 Thread Wesley
1. install gdb from source with configure option --with-python 2. install python from source with configure option --with-pydebug 3. Got error in gdb here: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] (gdb) py-bt Undefined command: "py-bt". Try "help". (gdb)

Re: gdb unable to read python frame information

2014-03-08 Thread Wesley
python debuginfo is installed... Still,py-bt, py-locals.etc cannot read python frame -- https://mail.python.org/mailman/listinfo/python-list

Re: Critic: New Python Front Page

2014-03-08 Thread Ned Batchelder
On 3/8/14 7:44 AM, Nils-Hero Lindemann wrote: Hi, (Please forgive (or correct) my mistakes, i am non native) http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ * Formatting bug * Needs breadcrumb navigation ("Where am i?") (i came there via http://theory.stanford.edu/~

Re: Python performance

2014-03-08 Thread Chris Angelico
On Sat, Mar 8, 2014 at 11:53 PM, JCosta wrote: > I did some work in c# and java and I converted some application to Python; I > noticed Python is much slower than the other languages. > > Is this normal ? > Thanks The first thing to look at is the conversion. If you convert idiomatic Java code i

Re: spam (wasRe: extract from json)

2014-03-08 Thread Chris Angelico
On Sun, Mar 9, 2014 at 12:13 AM, Mark Lawrence wrote: > On 08/03/2014 03:49, Chris Angelico wrote: >> >> On Sat, Mar 8, 2014 at 2:21 PM, wrote: >>> >>> I think it's better if you (CENSORED) off. >> >> >> Teddybubu, please understand that the above comment is from a spammer >> and does not reflec

spam (wasRe: extract from json)

2014-03-08 Thread Mark Lawrence
On 08/03/2014 03:49, Chris Angelico wrote: On Sat, Mar 8, 2014 at 2:21 PM, wrote: I think it's better if you (CENSORED) off. Teddybubu, please understand that the above comment is from a spammer and does not reflect the prevailing attitude of this list. I don't like to make content-free post

Python performance

2014-03-08 Thread JCosta
I did some work in c# and java and I converted some application to Python; I noticed Python is much slower than the other languages. Is this normal ? Thanks -- https://mail.python.org/mailman/listinfo/python-list

Critic: New Python Front Page

2014-03-08 Thread Nils-Hero Lindemann
Hi, (Please forgive (or correct) my mistakes, i am non native) http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ * Formatting bug * Needs breadcrumb navigation ("Where am i?") (i came there via http://theory.stanford.edu/~amitp/yapps/) * blue background makes top links i

How to recovery the default "Library/Python/" folder on Mac?

2014-03-08 Thread Harry Wood
How to recovery the default "Library/Python/" folder on Mac? I delete it by some mistakes..., I have tried the following steps: - Step 1. Download and install Python DMG from Python.org . Result: There are no Python folders under Library after I installed the Python DMG. - S

Re: Balanced trees

2014-03-08 Thread Marko Rauhamaa
Ian Kelly : > Peeking at the code, it appears to use a heapq-based priority queue. > Why would a balanced binary tree be better? AFAIK, a heap queue doesn't allow for the deletion of a random element forcing you to leave the canceled timers in the queue to be deleted later. In a very typical sce

Re: Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Ian Kelly
On Sat, Mar 8, 2014 at 1:34 AM, Marko Rauhamaa wrote: > Speaking of which, are there plans to add a balanced tree to the > "batteries" of Python? Timers, cache aging and the like need it. I'm > using my own AVL tree implementation, but I'm wondering why Python > still doesn't have one. None curre

Balanced trees (was: Re: Tuples and immutability)

2014-03-08 Thread Marko Rauhamaa
Ian Kelly : > I already mentioned this earlier in the thread, but a balanced binary > tree might implement += as node insertion and then return a different > object if the balancing causes the root node to change. True. Speaking of which, are there plans to add a balanced tree to the "batteries"