Re: [Tutor] unichr not working as expected

2013-07-22 Thread Jim Mooney
On 22 July 2013 21:00, Steven D'Aprano wrote: > > (By the way, you're very naughty. The code you show *cannot possibly > generate the error you claim it generates*. Bad Jim, no biscuit!) > I know. I need a personal github. When I get frustrated I try so many things in quick succession I lose tra

Re: [Tutor] unichr not working as expected

2013-07-22 Thread Jim Mooney
Steven D'Aprano When Python starts up, it needs to set the encoding used, but you *cannot* > set it to arbitrary encodings. Setting it to arbitrary encodings can cause > all sorts of weird, hard to diagnose bugs, so to prevent that, Python > deletes the setdefaultencoding function after using it.

Re: [Tutor] unichr not working as expected

2013-07-22 Thread Steven D'Aprano
On 23/07/13 04:14, Jim Mooney wrote: I tried translating the odd chars I found in my dos tree /f listing to symbols, but I'm getting this error. The chars certainly aren't over 1, The ord is only 13 - so what's wrong here? def main(): zark = '' for x in "ÀÄÄÄ": zark +=

Re: [Tutor] unichr not working as expected

2013-07-22 Thread Steven D'Aprano
On 23/07/13 05:22, Jim Mooney wrote: I already changed to u for the char, so I got a bigger number, and only subtracted 3 from umlaut, which should have given me the dos line-drawing dash, but now my problem is I can't seem to set encoding for that: import sys sys.setdefaultencoding('cp437') g

Re: [Tutor] close, but no cigar

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 6:13 PM, Dave Angel wrote: > On 07/22/2013 02:27 PM, Jim Mooney wrote: > >> Okay, I'm getting there, but this should be translating A umlaut to an old >> DOS box character, according to my ASCII table, but instead it's print >> small 'u': >> >> def main(): >> zark = '

Re: [Tutor] 3 Dimensional Dictionaries

2013-07-22 Thread Sunil Tech
On Tuesday, July 23, 2013, Sunil Tech wrote: > THANK YOU ALL for your time. > > The first format which I pasted was from the DB > > The second format(exactly the same), is to be sent to the view. > > If the logic can be fitted in One or two methods it'll help me to easily understand & to apply. >

Re: [Tutor] close, but no cigar

2013-07-22 Thread Dave Angel
On 07/22/2013 02:27 PM, Jim Mooney wrote: Okay, I'm getting there, but this should be translating A umlaut to an old DOS box character, according to my ASCII table, but instead it's print small 'u': def main(): zark = '' for x in "ÀÄÄÄ": print(unichr(ord(u'x')-3), end=' ') re

Re: [Tutor] close, but no cigar

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 3:22 PM, Jim Mooney wrote: > On 22 July 2013 14:11, Marc Tompkins wrote: > >> >> One way to deal with this is to specify an encoding: >> newchar = char.decode('cp437').encode('utf-8') >> > > Works fine, but I decided to add a dos graphics dash to the existing dash > to

Re: [Tutor] close, but no cigar

2013-07-22 Thread Alan Gauld
On 22/07/13 23:22, Jim Mooney wrote: # -*- coding: utf-8 -*- Will that always work? Setting coding in a comment? Or am I looking at a Linux hash line? Same concept. It's a special comment that will only take effect when at the top of a file. Actually, I'm not sure how it plays with the hash-

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
On 22 July 2013 15:12, Alan Gauld wrote: When I used an old VT220 on a VAX I always used to reverse the display to > show black characters on a light (green or amber) screen. It used to freak > out my colleagues who were traditionalist green on black men... > I think a lot of old sonar guys went

Re: [Tutor] close, but no cigar

2013-07-22 Thread Jim Mooney
On 22 July 2013 14:11, Marc Tompkins wrote: > > One way to deal with this is to specify an encoding: > newchar = char.decode('cp437').encode('utf-8') > Works fine, but I decided to add a dos graphics dash to the existing dash to expand the tree visually. Except I got a complaint from IDLE th

Re: [Tutor] slashes in paths

2013-07-22 Thread Alan Gauld
On 22/07/13 22:50, Jim Mooney wrote: I'm sticking to 20 pt Lucida Console on a big, full screen DOS box with navy letters and cyan background. If you have a big screen might as well use it. Why the DOS box defaults to being so tiny is beyond me. Depends what you mean by tiny. On a 1024x768 di

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
> Just to clarify, tree isn't completely Unicode naive. It writes > Unicode to the console, presuming you're using a font that supports > it, such as Consolas. > I'm sticking to 20 pt Lucida Console on a big, full screen DOS box with navy letters and cyan background. If you have a big screen migh

Re: [Tutor] slashes in paths

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 2:34 PM, eryksun wrote: > > Just to clarify, tree isn't completely Unicode naive. It writes > Unicode to the console, presuming you're using a font that supports > it, such as Consolas. > Interesting! Indeed - I just moved my test Cyrillic file to a different folder (so

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
On 22 July 2013 14:15, Marc Tompkins wrote: > > > You could do worse... Again, my issue with TREE is that it willfully > throws away information (non-ASCII characters in filenames) before passing > it on to you. As a result, the tree you print out may not correspond to > the actual filesystem s

Re: [Tutor] close, but no cigar

2013-07-22 Thread Jim Mooney
On 22 July 2013 14:11, Marc Tompkins wrote: The error's in your error message: Python has decoded the string properly, > but (since you haven't specified an encoding) is trying to encode to the > default, which in Python < 3 is 'ascii'... which has a great big blank > space where all characters

Re: [Tutor] slashes in paths

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 2:00 PM, Jim Mooney wrote: > so I should just walk the python27 tree and write my own box drawing > chars? Or is there a more global alternative to DOS box-drawing chars to > illustrate a tree structure, other than graphic processing? > You could do worse... Again, my is

Re: [Tutor] close, but no cigar

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 1:55 PM, Jim Mooney wrote: > On 22 July 2013 13:45, Marc Tompkins wrote: > >> >> inFileName = "/Users/Marc/Desktop/rsp/tree.txt" >> with open(inFileName, 'r') as inFile: >> inString = inFile.read().decode('cp437') >> print inString >> >> I already t

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
On 22 July 2013 12:48, Marc Tompkins wrote: > > > You'd be better off skipping TREE entirely and going pure-Python. TREE - > being Unicode-naive - can't deal with any foreign-alphabet characters > beyond the few baked in alongside the box-drawing characters; they all get > turned into question m

Re: [Tutor] close, but no cigar

2013-07-22 Thread Jim Mooney
On 22 July 2013 13:45, Marc Tompkins wrote: > > inFileName = "/Users/Marc/Desktop/rsp/tree.txt" > with open(inFileName, 'r') as inFile: > inString = inFile.read().decode('cp437') > print inString > > I already tried something similar and got an error: with open('../pytree

Re: [Tutor] close, but no cigar

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 11:27 AM, Jim Mooney wrote: > Okay, I'm getting there, but this should be translating A umlaut to an old > DOS box character, according to my ASCII table, but instead it's print > small 'u': > > def main(): > zark = '' > for x in "ÀÄÄÄ": > print(unichr(ord(u

Re: [Tutor] slashes in paths

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 11:57 AM, Jim Mooney wrote: > I had a bad feeling I'd end up learning Unicode ;') > >> >> >> It's not as painful as you might think! Try it - you'll like it! >> Actually, once you start getting used to working in Unicode by default, >> having to deal with programs that are

Re: [Tutor] unichr not working as expected

2013-07-22 Thread Jim Mooney
On 22 July 2013 11:52, Alan Gauld wrote: > On 22/07/13 19:14, Jim Mooney wrote: > > zark += unichr(ord(x)-45) >> >> >> unichr() arg not in range(0x1) (narrow Python build) >> > > > What if ord() is returning a value less than 45? > What does unichr() do with negative vales?> > > Jus

Re: [Tutor] Cannot understand what this means

2013-07-22 Thread ALAN GAULD
CCing the list. Please always use ReplyAll to include the list. Alan Gauld Author of the Learn To Program website http://www.alan-g.me.uk/ > > From: #PATHANGI JANARDHANAN JATINSHRAVAN# >To: Alan Gauld >Sent: Monday, 22 July 2013, 17:14 >Subject: RE: [Tutor] C

Re: [Tutor] 3 Dimensional Dictionaries

2013-07-22 Thread Sunil Tech
THANK YOU ALL for your time. The first format which I pasted was from the DB The second format(exactly the same), is to be sent to the view. If the logic can be fitted in One or two methods it'll help me to easily understand & to apply. so I request you to help... On Sunday, July 21, 2013, Al

[Tutor] close, but no cigar

2013-07-22 Thread Jim Mooney
Okay, I'm getting there, but this should be translating A umlaut to an old DOS box character, according to my ASCII table, but instead it's print small 'u': def main(): zark = '' for x in "ÀÄÄÄ": print(unichr(ord(u'x')-3), end=' ') result: u u u u -- Jim What the Nations of the

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
I had a bad feeling I'd end up learning Unicode ;') > > > It's not as painful as you might think! Try it - you'll like it! > Actually, once you start getting used to working in Unicode by default, > having to deal with programs that are non-Unicode-aware feels extremely > irritating. > I'll have

Re: [Tutor] unichr not working as expected

2013-07-22 Thread Alan Gauld
On 22/07/13 19:14, Jim Mooney wrote: zark += unichr(ord(x)-45) unichr() arg not in range(0x1) (narrow Python build) What if ord() is returning a value less than 45? What does unichr() do with negative vales?> Just a guess... -- Alan G Author of the Learn to Program web site h

Re: [Tutor] slashes in paths

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 11:30 AM, Jim Mooney wrote: > On 22 July 2013 11:26, Marc Tompkins wrote: > >> >> >> >> If you haven't already read it, may I suggest Joel's intro to Unicode? >> http://www.joelonsoftware.com/articles/Unicode.html >> > > I had a bad feeling I'd end up learning Unicode ;')

Re: [Tutor] slashes in paths

2013-07-22 Thread Marc Tompkins
On Mon, Jul 22, 2013 at 10:47 AM, Jim Mooney wrote: I forgot about TREE. But figured piping C:\Python27>tree /f > pytree.txt > might be illuminating. I piped since it took forever to print because I > have python(x,y). Unfortunately, I got tiny numbers and A with umlauts > instead of the nice path

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
On 22 July 2013 11:26, Marc Tompkins wrote: > > > > If you haven't already read it, may I suggest Joel's intro to Unicode? > http://www.joelonsoftware.com/articles/Unicode.html > I had a bad feeling I'd end up learning Unicode ;') -- Jim ___ Tutor ma

[Tutor] unichr not working as expected

2013-07-22 Thread Jim Mooney
I tried translating the odd chars I found in my dos tree /f listing to symbols, but I'm getting this error. The chars certainly aren't over 1, The ord is only 13 - so what's wrong here? def main(): zark = '' for x in "ÀÄÄÄ": zark += unichr(ord(x)-45) print(zark) unichr(

Re: [Tutor] slashes in paths

2013-07-22 Thread Jim Mooney
On 22 July 2013 03:51, eryksun wrote: > On Sun, Jul 21, 2013 at 9:18 PM, Marc Tompkins > wrote: > > CP/M itself didn't use '/' switches in its internal CCP commands, even > if some 3rd party programs did. Neither did COMMAND.COM in Tim > Paterson's 86-DOS. Microsoft added the switches (but Pater