Re: Is there a way to set several list elements a same value with one line code

2015-12-03 Thread Denis McMahon
On Thu, 03 Dec 2015 16:30:25 -0800, Robert wrote: > Hi, > > I remember that there is a way to set several list elements a same value > with > one line code. Excuse me, I don't remember the accurate syntax on the > code snippet. But the basic format looks like this. > > 1. There is a four-eleme

How to bounce the ball forever around the screen

2015-12-03 Thread phamtony33
from Tkinter import * window = Tk() canvas = Canvas(window, width=500, height=500, background="green") canvas.pack() def move_ball(speed_x, speed_y): box = canvas.bbox("ball") x1 = box[0] y1 = box[1] x2 = box[2] y2 = box[3] if x1 <= 0:

Re: HELP PLEASE printing single characters!

2015-12-03 Thread Larry Hudson via Python-list
On 12/02/2015 04:08 PM, John Strick wrote: On Wednesday, December 2, 2015 at 12:58:30 PM UTC-6, Dylan Riley wrote: hi all, I have been trying to figure out all day why my code is printing single characters from my list when i print random elements using random.choice the elements in the list a

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-03 Thread Chris in Makati
On Thu, 3 Dec 2015 09:16:32 + (UTC), Juha Nieminen wrote: >In comp.lang.c++ Chris in Makati wrote: >> On Wed, 2 Dec 2015 08:57:44 + (UTC), Juha Nieminen >> wrote: >> >>>In comp.lang.c++ Steve Hayes wrote: You download things FROM a computer, you upload them TO a computer. >>> >>>

Re: Is there a way to set several list elements a same value with one line code

2015-12-03 Thread Robert
On Thursday, December 3, 2015 at 7:59:16 PM UTC-5, MRAB wrote: > On 2015-12-04 00:30, Robert wrote: > > Hi, > > > > I remember that there is a way to set several list elements a same value > > with > > one line code. Excuse me, I don't remember the accurate syntax on the code > > snippet. But

Re: Is there a way to set several list elements a same value with one line code

2015-12-03 Thread MRAB
On 2015-12-04 00:30, Robert wrote: Hi, I remember that there is a way to set several list elements a same value with one line code. Excuse me, I don't remember the accurate syntax on the code snippet. But the basic format looks like this. 1. There is a four-element list, such as: bb=[[[

Is there a way to set several list elements a same value with one line code

2015-12-03 Thread Robert
Hi, I remember that there is a way to set several list elements a same value with one line code. Excuse me, I don't remember the accurate syntax on the code snippet. But the basic format looks like this. 1. There is a four-element list, such as: bb=[[[]],[[]],[[]],[[]]] 2. An assignment lin

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Oscar Benjamin
On 3 Dec 2015 16:50, "Terry Reedy" wrote: > > On 12/3/2015 10:18 AM, Adam Funk wrote: >> >> On 2015-12-03, Adam Funk wrote: >> >>> I'm having trouble with some input files that are almost all proper >>> UTF-8 but with a couple of troublesome characters mixed in, which I'd >>> like to ignore instea

Re: Idle, tk and MacOS

2015-12-03 Thread Laura Creighton
In a message of Thu, 03 Dec 2015 20:34:10 +0100, Laura Creighton writes: >This in to webmaster. Somebody got an error message about their >Tcl/Tk when they started using IDLE. > >They went to https://www.python.org/download/mac/tcltk/ >and, yes indeed, their tk is 8.5.9, their OS is 10.8.5 so th

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Laura Creighton
In a message of Thu, 03 Dec 2015 19:17:51 +, Adam Funk writes: >On 2015-12-03, Laura Creighton wrote: > >> In a message of Thu, 03 Dec 2015 15:12:15 +, Adam Funk writes: >>>I'm having trouble with some input files that are almost all proper >>>UTF-8 but with a couple of troublesome characte

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Laura Creighton wrote: > In a message of Thu, 03 Dec 2015 15:12:15 +, Adam Funk writes: >>I'm having trouble with some input files that are almost all proper >>UTF-8 but with a couple of troublesome characters mixed in, which I'd >>like to ignore instead of throwing ValueError.

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Terry Reedy wrote: > fileinput is an ancient module that predates iterators (and generators) > and context managers. Since by 2.7 open files are both context managers > and line iterators, you can easily write your own multi-file line > iteration that does exactly what you want.

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Peter Otten wrote: > def my_hook_encoded(encoding, errors=None): > import io > def openhook(filename, mode): > mode = mode.replace('U', '').replace('b', '') or 'r' > return io.open( > filename, mode, > encoding=encoding, newline='',

Idle, tk and MacOS

2015-12-03 Thread Laura Creighton
This in to webmaster. Somebody got an error message about their Tcl/Tk when they started using IDLE. They went to https://www.python.org/download/mac/tcltk/ and, yes indeed, their tk is 8.5.9, their OS is 10.8.5 so they have a problem. They downloaded the patch from ActiveState, and did _somet

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Robin Koch
Am 03.12.2015 um 18:23 schrieb Terry Reedy: On 12/3/2015 11:00 AM, Robin Koch wrote: Am 03.12.2015 um 10:02 schrieb Gary Herron: On 12/02/2015 10:55 PM, Robert wrote: Hi, I read the tutorial on "Why is join() a string method instead of a list or tuple method?" at link: https://docs.python.o

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Robin Koch
Am 03.12.2015 um 18:42 schrieb Mark Lawrence: On 03/12/2015 17:01, Robin Koch wrote: Am 03.12.2015 um 17:25 schrieb Ian Kelly: On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: Now *I* am confused. Shouldn't it be ", ".join(['1', '2', '4', '8', '16']) instead? Without any importing? That

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Mark Lawrence
On 03/12/2015 17:01, Robin Koch wrote: Am 03.12.2015 um 17:25 schrieb Ian Kelly: On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: Now *I* am confused. Shouldn't it be ", ".join(['1', '2', '4', '8', '16']) instead? Without any importing? That would be the normal way to write it. The FAQ e

Re: Does Python 2.7 do Open Office

2015-12-03 Thread Terry Reedy
On 12/3/2015 11:00 AM, Seymore4Head wrote: On Thu, 3 Dec 2015 00:47:42 +, MRAB wrote: On 2015-12-02 23:50, Seymore4Head wrote: I have a text file I would like to search through but I have tried it before. I don't remember why they are not compatible together, but I wanted to ask to make

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Terry Reedy
On 12/3/2015 11:00 AM, Robin Koch wrote: Am 03.12.2015 um 10:02 schrieb Gary Herron: On 12/02/2015 10:55 PM, Robert wrote: Hi, I read the tutorial on "Why is join() a string method instead of a list or tuple method?" at link: https://docs.python.org/2/faq/design.html#why-must-self-be-used-ex

Re: Are there any plans to support nCurses 6.0 with Python?

2015-12-03 Thread eclectic959
On Thursday, December 3, 2015 at 8:44:30 AM UTC-5, Mark Lawrence wrote: > On 03/12/2015 12:30, eclectic...@gmail.com wrote: > > The GNU Project has announced the release of nCurses 6.0. > > > > With it, Python curses would be able to support 256 colors instead of the > > current 8 or 16. > > > > I

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Robin Koch
Am 03.12.2015 um 17:25 schrieb Ian Kelly: On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: Now *I* am confused. Shouldn't it be ", ".join(['1', '2', '4', '8', '16']) instead? Without any importing? That would be the normal way to write it. The FAQ entry is suggesting the string module fun

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Terry Reedy
On 12/3/2015 10:18 AM, Adam Funk wrote: On 2015-12-03, Adam Funk wrote: I'm having trouble with some input files that are almost all proper UTF-8 but with a couple of troublesome characters mixed in, which I'd like to ignore instead of throwing ValueError. I've found the openhook for the encod

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Laura Creighton
In a message of Thu, 03 Dec 2015 15:12:15 +, Adam Funk writes: >I'm having trouble with some input files that are almost all proper >UTF-8 but with a couple of troublesome characters mixed in, which I'd >like to ignore instead of throwing ValueError. I've found the >openhook for the encoding >

urllib2.urlopen() crashes on Windows 2008 Server

2015-12-03 Thread Ulli Horlacher
I have a Python2 program which runs fine on Windows 7, but crashes on Windows 2008 Server R2 64 bit: downloading http://fex.belwue.de/download/7za.exe Traceback (most recent call last): File "", line 1992, in File "", line 180, in main File "", line 329, in get_ID File "", line 1627, in c

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Ian Kelly
On Thu, Dec 3, 2015 at 9:00 AM, Robin Koch wrote: > Now *I* am confused. > > Shouldn't it be > > ", ".join(['1', '2', '4', '8', '16']) > > instead? Without any importing? That would be the normal way to write it. The FAQ entry is suggesting the string module function as an alternative for those w

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread MRAB
On 2015-12-03 16:00, Robin Koch wrote: Am 03.12.2015 um 10:02 schrieb Gary Herron: On 12/02/2015 10:55 PM, Robert wrote: Hi, I read the tutorial on "Why is join() a string method instead of a list or tuple method?" at link: https://docs.python.org/2/faq/design.html#why-must-self-be-used-expl

Re: filter a list of strings

2015-12-03 Thread Terry Reedy
On 12/3/2015 7:28 AM, Mark Lawrence wrote: On 03/12/2015 01:15, c.bu...@posteo.jp wrote: I would like to know how this could be done more elegant/pythonic. I have a big list (over 10.000 items) with strings (each 100 to 300 chars long) and want to filter them. list = . for item in list[:]

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread MRAB
On 2015-12-03 15:12, Adam Funk wrote: I'm having trouble with some input files that are almost all proper UTF-8 but with a couple of troublesome characters mixed in, which I'd like to ignore instead of throwing ValueError. I've found the openhook for the encoding for line in fileinput.input(opt

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Peter Otten
Adam Funk wrote: > On 2015-12-03, Adam Funk wrote: > >> I'm having trouble with some input files that are almost all proper >> UTF-8 but with a couple of troublesome characters mixed in, which I'd >> like to ignore instead of throwing ValueError. I've found the >> openhook for the encoding >> >>

Re: Does Python 2.7 do Open Office

2015-12-03 Thread Seymore4Head
On Thu, 03 Dec 2015 01:54:16 +0100, Laura Creighton wrote: >In a message of Wed, 02 Dec 2015 18:50:34 -0500, Seymore4Head writes: >>I have a text file I would like to search through but I have tried it >>before. I don't remember why they are not compatible together, but I >>wanted to ask to make

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Robin Koch
Am 03.12.2015 um 10:02 schrieb Gary Herron: On 12/02/2015 10:55 PM, Robert wrote: Hi, I read the tutorial on "Why is join() a string method instead of a list or tuple method?" at link: https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls

Re: Does Python 2.7 do Open Office

2015-12-03 Thread Seymore4Head
On Thu, 3 Dec 2015 00:47:42 +, MRAB wrote: >On 2015-12-02 23:50, Seymore4Head wrote: >> I have a text file I would like to search through but I have tried it >> before. I don't remember why they are not compatible together, but I >> wanted to ask to make sure. >> >> I know I can convert the

Re: getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
On 2015-12-03, Adam Funk wrote: > I'm having trouble with some input files that are almost all proper > UTF-8 but with a couple of troublesome characters mixed in, which I'd > like to ignore instead of throwing ValueError. I've found the > openhook for the encoding > > for line in fileinput.input

getting fileinput to do errors='ignore' or 'replace'?

2015-12-03 Thread Adam Funk
I'm having trouble with some input files that are almost all proper UTF-8 but with a couple of troublesome characters mixed in, which I'd like to ignore instead of throwing ValueError. I've found the openhook for the encoding for line in fileinput.input(options.files, openhook=fileinput.hook_enc

Re: filter a list of strings

2015-12-03 Thread Jussi Piitulainen
Denis McMahon writes: > On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote: > >> def isbad(item): >> return ( 'Banana' in item or >> 'Car' in item ) >> >> def isgood(item) >> return not isbad(item) > > badthings = [ 'Banana', 'Car', ] > > def isgood(item) >

Re: filter a list of strings

2015-12-03 Thread Denis McMahon
On Thu, 03 Dec 2015 08:32:49 +0200, Jussi Piitulainen wrote: > def isbad(item): > return ( 'Banana' in item or > 'Car' in item ) > > def isgood(item) > return not isbad(item) badthings = [ 'Banana', 'Car', ] def isgood(item) for thing in badthings: if thi

Re: Are there any plans to support nCurses 6.0 with Python?

2015-12-03 Thread Mark Lawrence
On 03/12/2015 12:30, eclectic...@gmail.com wrote: The GNU Project has announced the release of nCurses 6.0. With it, Python curses would be able to support 256 colors instead of the current 8 or 16. I've discovered that a pre-release of Fedora 24 includes ncurses 6.0. It is not usable by Pyth

Are there any plans to support nCurses 6.0 with Python?

2015-12-03 Thread eclectic959
The GNU Project has announced the release of nCurses 6.0. With it, Python curses would be able to support 256 colors instead of the current 8 or 16. I've discovered that a pre-release of Fedora 24 includes ncurses 6.0. It is not usable by Python programs, such as my character-mode emulation of

Re: filter a list of strings

2015-12-03 Thread Mark Lawrence
On 03/12/2015 01:15, c.bu...@posteo.jp wrote: I would like to know how this could be done more elegant/pythonic. I have a big list (over 10.000 items) with strings (each 100 to 300 chars long) and want to filter them. list = . for item in list[:]: if 'Banana' in item: list.remove(

Re: filter a list of strings

2015-12-03 Thread Grobu
On 03/12/15 02:15, c.bu...@posteo.jp wrote: I would like to know how this could be done more elegant/pythonic. I have a big list (over 10.000 items) with strings (each 100 to 300 chars long) and want to filter them. list = . for item in list[:]: if 'Banana' in item: list.remove(it

Re: filter a list of strings

2015-12-03 Thread Jussi Piitulainen
writes: > Thank you for your suggestion. This will help a lot. > > On 2015-12-03 08:32 Jussi Piitulainen wrote: >> list = [ item for item in list >> if ( 'Banana' not in item and >> 'Car' not in item ) ] > > I often saw constructions like this > x for x in y if ... > But

Re: filter a list of strings

2015-12-03 Thread Peter Otten
Laura Creighton wrote: > In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes: >>Thank you for your suggestion. This will help a lot. >> >>On 2015-12-03 08:32 Jussi Piitulainen wrote: >>> list = [ item for item in list >>> if ( 'Banana' not in item and >>>

Re: python message

2015-12-03 Thread me
On 2015-12-02, jorge.conr...@cptec.inpe.br wrote: > I do not understand this message. Atached it my code. I'm new to Usenet, so maybe it's my fault. But I can't find any attachment in your message. Would you mind to post the code? -- https://mail.python.org/mailman/listinfo/python-list

Re: filter a list of strings

2015-12-03 Thread jmp
On 12/03/2015 10:27 AM, c.bu...@posteo.jp wrote: I often saw constructions like this x for x in y if ... But I don't understand that combination of the Python keywords (for, in, if) I allready know. It is to complex to imagine what there really happen. I understand this for x in y: if

Re: filter a list of strings

2015-12-03 Thread Laura Creighton
In a message of Thu, 03 Dec 2015 10:27:19 +0100, c.bu...@posteo.jp writes: >Thank you for your suggestion. This will help a lot. > >On 2015-12-03 08:32 Jussi Piitulainen wrote: >> list = [ item for item in list >> if ( 'Banana' not in item and >> 'Car' not in item ) ] > >I o

Re: filter a list of strings

2015-12-03 Thread Wolfgang Maier
On 03.12.2015 10:27, c.bu...@posteo.jp wrote: > > I often saw constructions like this >x for x in y if ... > But I don't understand that combination of the Python keywords (for, > in, if) I allready know. It is to complex to imagine what there really > happen. > > I understand this >for x

Re: filter a list of strings

2015-12-03 Thread Chris Angelico
On Thu, Dec 3, 2015 at 8:27 PM, wrote: > Thank you for your suggestion. This will help a lot. > > On 2015-12-03 08:32 Jussi Piitulainen wrote: >> list = [ item for item in list >> if ( 'Banana' not in item and >> 'Car' not in item ) ] > > I often saw constructions like thi

Re: filter a list of strings

2015-12-03 Thread c.buhtz
Thank you for your suggestion. This will help a lot. On 2015-12-03 08:32 Jussi Piitulainen wrote: > list = [ item for item in list > if ( 'Banana' not in item and > 'Car' not in item ) ] I often saw constructions like this x for x in y if ... But I don't understand that

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-03 Thread Juha Nieminen
In comp.lang.c++ Chris in Makati wrote: > On Wed, 2 Dec 2015 08:57:44 + (UTC), Juha Nieminen > wrote: > >>In comp.lang.c++ Steve Hayes wrote: >>> You download things FROM a computer, you upload them TO a computer. >> >>It's a matter of perspective. If a hacker breaks into your computer and

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-03 Thread Chris Angelico
On Thu, Dec 3, 2015 at 8:00 PM, David Brown wrote: > Even if the OP is telling the truth (and if Skybuck said that > grass is green, I'd recommend going outside to check) Here in Australia, we're coming up on summer, so grass is more likely to be yellowish-brown. Definitely don't believe people w

Re: static variables

2015-12-03 Thread Antoon Pardon
Op 02-12-15 om 21:30 schreef Ian Kelly: > A person can hold one opinion in some contexts and an opposing opinion > in others. Yes people are capable of that. It doesn't mean we shouldn't challenge them on that. There are many possibilities for people to act like that. One context can be sufficient

Re: Is Microsoft Windows secretly downloading childporn to your computer ?!

2015-12-03 Thread David Brown
On 03/12/15 07:24, Chris in Makati wrote: > On Wed, 2 Dec 2015 08:57:44 + (UTC), Juha Nieminen > wrote: > >> In comp.lang.c++ Steve Hayes wrote: >>> You download things FROM a computer, you upload them TO a computer. >> >> It's a matter of perspective. If a hacker breaks into your computer a

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Gary Herron
On 12/02/2015 10:55 PM, Robert wrote: Hi, I read the tutorial on "Why is join() a string method instead of a list or tuple method?" at link: https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls I have a problem on running the last line: --

Re: storing test logs under /var/log/

2015-12-03 Thread Cameron Simpson
On 03Dec2015 12:20, Ganesh Pal wrote: I would need few tips from your past experiences on how to store the test logs My requirement is to capture log under /var/log/ directory every time the test is run . Normally /var/log itself is only writable by root. Unless you are running your test

Re: 'string.join' is wrong in my Python console

2015-12-03 Thread Sijan Bhandari
On Thursday, December 3, 2015 at 12:40:52 PM UTC+5:45, Robert wrote: > Hi, > > I read the tutorial on "Why is join() a string method instead of a list > or tuple method?" > at link: > https://docs.python.org/2/faq/design.html#why-must-self-be-used-explicitly-in-method-definitions-and-calls > > I