assignment with [:]

2008-12-27 Thread Ben Bush
Hi, I saw this line of code on a recent post: a1[:] = [x*3 for x in a1] Could somebody tells me what the [:] means? I can't find it anywhere. See context below if needed: On Dec 26, 4:46 pm, Tim Chase python.l...@tim.thechases.com wrote: What does *not* work is 3 * [0,1,2] As you

enter and event

2005-12-04 Thread Ben Bush
When I read python Manuel, I got confused by the following code: def turnRed(self, event): event.widget[activeforeground] = red self.button.bind(Enter, self.turnRed) I can not understand it. -- http://mail.python.org/mailman/listinfo/python-list

oval

2005-12-04 Thread Ben Bush
I tested the following code and wanted to get the message of oval2 got hit if I click the red one. But I always got oval1 got hit. from Tkinter import * root=Tk() canvas=Canvas(root,width=100,height=100) canvas.pack() a=canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')

Re: oval

2005-12-04 Thread Ben Bush
On 12/4/05, Diez B. Roggisch [EMAIL PROTECTED] wrote: Ben Bush wrote: I tested the following code and wanted to get the message of oval2 got hit if I click the red one. But I always got oval1 got hit. from Tkinter import * root=Tk() canvas=Canvas(root,width=100,height=100) canvas.pack

Re: oval

2005-12-04 Thread Ben Bush
thanks anyway. The python manual for event is very brief and it is hard for me to understand. -- Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: oval

2005-12-04 Thread Ben Bush
On 12/4/05, Peter Otten [EMAIL PROTECTED] wrote: Ben Bush wrote: On 12/4/05, Diez B. Roggisch [EMAIL PROTECTED] wrote: Ben Bush wrote: I tested the following code and wanted to get the message of oval2 got hit if I click the red one. But I always got oval1 got hit. from Tkinter

change color

2005-12-04 Thread Ben Bush
I tested the following code and wanted to make oval 2 become red after I hit the enter key but though the code did not report error, it did not change. from Tkinter import * root=Tk() canvas=Canvas(root,width=100,height=100) canvas.pack() canvas.create_oval(10,10,20,20,tags='oval1',fill='blue')

Re: drawline

2005-11-25 Thread Ben Bush
On 11/23/05, Magnus Lycka [EMAIL PROTECTED] wrote: Ben Bush wrote: I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions: It's good

Re: the first element in the list of list

2005-11-25 Thread Ben Bush
On 11/22/05, Fredrik Lundh [EMAIL PROTECTED] wrote: Ben Bush wrote: This question just came to my mind and not assigned by anyone. given that you and Shi Mu are asking identical questions, and that you've both started to send questions via direct mail, can you please ask your course

Re: Tkinter's coordinates setting

2005-11-22 Thread Ben Bush
On 11/21/05, Steve Juranich [EMAIL PROTECTED] wrote: On 11/17/05, Shi Mu [EMAIL PROTECTED] wrote: why subtract 1 from max_y - original_y?Because in the computer science world we like starting to count at 0.image_size = 1000original_y = 25 # Really the 26th pixel line.new_y = 1000 - 25 - 1 # 26

after sorted from the lists

2005-11-22 Thread Ben Bush
I have a list: [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] How to remove all the duplicate or same after sorted from the lists? That is, [1,2] and [2,1] are the same after sorting them. I want the result to be: [[1,2],[3,1],[1,4],[3,3]] -- http://mail.python.org/mailman/listinfo/python-list

the first element in the list of list

2005-11-22 Thread Ben Bush
I have a lis: [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] I want a code to test when the difference between the first element in the list of list is equal to or larger than 6, then move the previous lists to the end of the list. that is: [[14,0],[15,8],[1,3],[3,4],[5,6],[8,9]] --

Re: after sorted from the lists

2005-11-22 Thread Ben Bush
On 11/22/05, Ben Bush [EMAIL PROTECTED] wrote: I have a list: [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] How to remove all the duplicate or same after sorted from the lists? That is, [1,2] and [2,1] are the same after sorting them. I want the result to be: [[1,2],[3,1],[1,4],[3,3]] I want to set

Re: the first element in the list of list

2005-11-22 Thread Ben Bush
On 11/22/05, Fredrik Lundh [EMAIL PROTECTED] wrote: Ben Bush wrote: I have a lis: [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] I want a code to test when the difference between the first element in the list of list is equal to or larger than 6, then move the previous lists to the end

Re: after sorted from the lists

2005-11-22 Thread Ben Bush
On 11/22/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: ll = [[1,2],[2,1],[3,1],[1,4],[3,3],[1,4]] ls = [frozenset(i) for i in ll] ss = set(ls) ss set([frozenset([1, 3]), frozenset([1, 2]), frozenset([1, 4]), frozenset([3])]) [list(i) for i in ss] [[1, 3], [1, 2], [1, 4], [3]] why this

drawline

2005-11-22 Thread Ben Bush
I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions: First, Clicknum increases when every time I click the button. Is it possible to reset Clicknum to 0?

line order

2005-11-17 Thread Ben Bush
I run the following code and the red line and black line show at the same time. is there anyway to show the red line first, then the black line? for example, after I click the 'enter' key? from Tkinter import *tk = Tk()canvas = Canvas(tk, bg=white, bd=0,

Re: compare list

2005-11-15 Thread Ben Bush
On 11/15/05, Brian van den Broek [EMAIL PROTECTED] wrote: Ben Bush said unto the world upon 2005-11-15 01:24:top posting corrected and post trimmed Unfortunately, the indents got screwed up along the way. But the partof my code you asked about was:for item in list1:if item in list2:if item + 1

Re: compare list

2005-11-15 Thread Ben Bush
-packages\Pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File C:\temp\try.py, line 8, in ? from sets import Set as setImportError: cannot import name Set -- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-15 Thread Ben Bush
On 11/15/05, Simon Brunning [EMAIL PROTECTED] wrote: On 15/11/05, Ben Bush [EMAIL PROTECTED] wrote: an error reported: Traceback (most recent call last): File C:\Python23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File

Re: circle and point

2005-11-14 Thread Ben Bush
to implement this in Tkinter?-- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

extend

2005-11-14 Thread Ben Bush
to implement this in Tkinter?-- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

compare list

2005-11-14 Thread Ben Bush
or 6,5 so these comparison will return 1 but the comparison between lisD and lisA return 0. -- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Ben Bush
what does the following code mean? if item in list2:if item + 1 in list1 and item + 1 in list2: On 11/14/05, Brian van den Broek [EMAIL PROTECTED] wrote: Ben Bush said unto the world upon 2005-11-14 05:51: I have four lists: lisA=[1,2,3,4,5,6,9] lisB=[1,6,5] lisC=[5,6,3] lisD

Re: compare list

2005-11-14 Thread Ben Bush
Hijacking Brian's response since my newsserver never god Ben's originalrequest...:I would program this at a reasonably high abstraction level, based on sets -- since you say order doesn't matter, sets are more appropriatethan lists anyway.For example:def two_cont_in_common(x, y): common =

about invalid syntax

2005-11-14 Thread Ben Bush
When I run scripts in PythonWin, sometimes will get the message of invalid syntax error. How can I check which errorI made? For example, in VB, you might got the wrong place highlighted and help message too.-- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Ben Bush
(intersection) - 1): if intersection[i] == intersection[i+1] - 1: return True return FalseDuncan Why it is potentially very expensive for large lists? what does intersection mean in Duncan's code? Thanks a lot for your patience! -- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: about invalid syntax

2005-11-14 Thread Ben Bush
Bush [EMAIL PROTECTED] wrote: When I run scripts in PythonWin, sometimes will get the message of invalid syntax error. How can I check which errorI made? For example, in VB, you might got the wrong place highlighted and help message too. -- which IDE do you use to run Python?Thanks!Ben Bush

Re: compare list

2005-11-14 Thread Ben Bush
, your response to Alex would have been much more useful ifyou'd quoted the error rather than just asserting that you got anerror :-) Best,Brian vdB-- Thanks!Ben Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: compare list

2005-11-14 Thread Ben Bush
On 11/14/05, Ben Bush [EMAIL PROTECTED] wrote: Hijacking Brian's response since my newsserver never god Ben's originalrequest...:I would program this at a reasonably high abstraction level, based on sets -- since you say order doesn't matter, sets are more appropriatethan lists anyway.For

open source and pure python

2005-11-13 Thread Ben Bush
Is there any package written in pure python code? I know lots of packages borrow the functions from other languages such as C or FORTRAN. So it is still black box to me because I do not know these languages. Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: triangulation

2005-11-12 Thread Ben Bush
Is there any pure python ocde there thoguh it is slow? Not many people know C very well and it will be great to have some python code even for education use. Ben I know someone once mentioned that they tried writing one of theDelaunay triangulation algorithms in pure Python and abandoned it

circle and point

2005-11-12 Thread Ben Bush
is there any code to decide whether a point is located within the circle by three other points?Thanks!B. Bush -- http://mail.python.org/mailman/listinfo/python-list

Re: circle and point

2005-11-12 Thread Ben Bush
On 11/12/05, Robert Kern [EMAIL PROTECTED] wrote: Ben Bush wrote: is there any code to decide whether a point is located within the circle by three other points? # Converted from my C++ code.# C.f. http://www.ics.uci.edu/~eppstein/junkyard/circumcenter.htmldef circumcenter(x0, y0,x1, y1, x2, y2