Re: [Tutor] ls *.py[co] >> .hidden

2015-05-22 Thread Danny Yoo
>> I thought we'd established that this was to
>> control visibility in the File Manager GUI
>> not the CLI? So an 'ls' flag isn't going to
>> help there.
>
>
> Yes, it was about the visibility in Nautilius. Much easier on the eye when 
> the bytecode files are not visible.


Ah, I was confused then.  Sorry: I just saw the word "Debian" and that
activated my Unix reptile brain.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] key detection

2015-05-22 Thread Brandon McCaig
Dave:

Sorry for the late reply, but it sounds like it could help a few people here...

On Wed, May 6, 2015 at 9:39 AM, Dave Angel  wrote:
> Many people don't realize that you can turn on a better screen copy feature
> for the CMD window (DOS box) in Windows.
>
> I've given up Windows, and no longer remember how, but the feature is called
> something like auto-copy and can be turned on for all DOS box windows.
>
> Once on, you select by dragging with the mouse, and insert by right-click.
> Still has to be a rectangle, but better than nothing when redirection lets
> you down.

The feature you're looking for is called "QuickEdit Mode". There is a
checkbox in the Options tab of the cmd.exe properties dialog. While
you're at it, I recommend configuring the cursor size and optionally
the command buffer size. Then switch tabs and see if you can configure
a better font. Then switch to the layout tab and hard-code a
full-screen size for the window. Everybody knows the stupid cmd.exe
window cannot be dynamically sized, but you can manually configure the
screen buffer and window size to get something much more friendly.
cmd.exe sucks, but if you take a few minutes to configure it then it
sucks considerably less. Add clink to make it suck a bit less still.

HTH.

Regards,


-- 
Brandon McCaig  
Castopulence Software 
Blog 
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Is there a way to use "with" across suite boundaries?

2015-05-22 Thread Jim Mooney Py3.4.3winXP
'''I was using with open...:, but I'm printing a header in one function,
calling a looping
function to print detail lines, then returning to the calling function to
print
the footer. But that didn't work since the with statement only seems to work
with the lexical suite and the file wasn't open in the detail print
function. Is there
a way around this, other than passing the file as I have here? Also, is it a
good idea to pass a file handle like that or is there a better way?

Using the below csv file  co2-sample.csv  to print a simple HTML table
(header omitted)
Since this is a file there are enclosing single quotes not visible:

"ANTIGUA AND BARBUDA",0,0,0,0,0
"ARGENTINA",37,35,33,36,39
"BAHAMAS, THE",1,1,1,1,1
"BAHRAIN",5,6,6,6,6
"SPANISH INQUISITION, THE, SILLY",10,33,14,2,8

Program follows (py3.4, winxp):'''

htbegin = '''


htest

table, td {border:2px solid black; border-collapse:collapse;}
td {padding:3px; background-color:pink;
text-align:right;font-family:verdana;}
td.l {text-align:left}





'''

htend = '''



'''

def make_lines():
co2 = open('co2-sample.csv')
ht = open('output.html', 'w')
linelist = []
print(htbegin, file=ht)
for line in co2:
newlist = line.rsplit(',', 5) # ending is regular so split it out
first
for token in newlist: # since split char inside quotes for
nation is problematic
linelist.append(token.strip('"')) # get rid of extra quotes
linelist[-1] = linelist[-1].strip()
fprint(linelist, ht)
linelist = []
co2.close()
print(htend, file=ht)
ht.close()


def fprint(linelist, ht):
# size formatting irrelevant for HTML
formatted_string = "{}{}{}{}{}{}".format(*linelist)
print(formatted_string, file=ht)
print('', file=ht)


if __name__ == "__main__":
make_lines()






-- 
Jim
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is there a way to use "with" across suite boundaries?

2015-05-22 Thread Peter Otten
Jim Mooney Py3.4.3winXP wrote:

> '''I was using with open...:, but I'm printing a header in one function,
> calling a looping
> function to print detail lines, then returning to the calling function to
> print
> the footer. But that didn't work since the with statement only seems to
> work with the lexical suite and the file wasn't open in the detail print
> function. Is there
> a way around this, other than passing the file as I have here? Also, is it
> a good idea to pass a file handle like that or is there a better way?

Something else must have gone wrong as

def make_lines():
with open('co2-sample.csv') as co2:
with open('output.html', 'w') as ht:
linelist = []
print(htbegin, file=ht)
for line in co2:
newlist = line.rsplit(',', 5)
for token in newlist:
linelist.append(token.strip('"'))
linelist[-1] = linelist[-1].strip()
fprint(linelist, ht)
linelist = []
print(htend, file=ht)

should run without error. Also possible:

with open('co2-sample.csv') as co2, open('output.html', 'w') as ht:
...

But may I suggest that you delegate parsing the CSV to the standard library? 
Then you can write

import csv

def make_lines():
with open('co2-sample.csv') as co2:
rows = csv.reader(co2)
with open('output.html', 'w') as ht:
print(htbegin, file=ht)
for linelist in rows:
fprint(linelist, ht)
print(htend, file=ht)

 
> Using the below csv file  co2-sample.csv  to print a simple HTML table
> (header omitted)
> Since this is a file there are enclosing single quotes not visible:
> 
> "ANTIGUA AND BARBUDA",0,0,0,0,0
> "ARGENTINA",37,35,33,36,39
> "BAHAMAS, THE",1,1,1,1,1
> "BAHRAIN",5,6,6,6,6
> "SPANISH INQUISITION, THE, SILLY",10,33,14,2,8
> 
> Program follows (py3.4, winxp):'''
> 
> htbegin = '''
> 
> 
> htest
> 
> table, td {border:2px solid black; border-collapse:collapse;}
> td {padding:3px; background-color:pink;
> text-align:right;font-family:verdana;}
> td.l {text-align:left}
> 
> 
> 
> 
> 
> '''
> 
> htend = '''
> 
> 
> 
> '''
> 
> def make_lines():
> co2 = open('co2-sample.csv')
> ht = open('output.html', 'w')
> linelist = []
> print(htbegin, file=ht)
> for line in co2:
> newlist = line.rsplit(',', 5) # ending is regular so split it out
> first
> for token in newlist: # since split char inside quotes for
> nation is problematic
> linelist.append(token.strip('"')) # get rid of extra quotes
> linelist[-1] = linelist[-1].strip()
> fprint(linelist, ht)
> linelist = []
> co2.close()
> print(htend, file=ht)
> ht.close()
> 
> 
> def fprint(linelist, ht):
> # size formatting irrelevant for HTML
> formatted_string = " 
class=l>{}{}{}{}{}{}".format(*linelist)
> print(formatted_string, file=ht)
> print('', file=ht)
> 
> 
> if __name__ == "__main__":
> make_lines()


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor