sort in the list

2005-11-22 Thread Shi Mu
I use Python 2.3 to run the following code: >>> a=[[1,2],[4,8],[0,3]] >>> a.sort() >>> a [[0, 3], [1, 2], [4, 8]] >>> I wonder whether the sort function automatically consider the first element in the list of list as the sorting criteria or it just happens to be? Thanks! -- http://mail.python.org/

keys in dictionary

2005-11-21 Thread Shi Mu
I run the following code and got wrong message, but I still want to make [1,2],[4,3] and [6,9] to be keys of the dictionary or change the style a little bit. How to do that? Thanks! >>> p=[[1,2],[4,3],[6,9]] >>> n=dict([(x,[]) for x in p]) Traceback (most recent call last): File "", line 1, in ?

Re: sort the list

2005-11-21 Thread Shi Mu
On 11/21/05, Daniel Schüle <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > I have a list like [[1,4],[3,9],[2,5],[3,2]]. How can I sort the list > > based on the second value in the item? > > That is, > > I want the list to be: > > [[3,2],[1,4],[2,5],[3,9]] &

sort the list

2005-11-21 Thread Shi Mu
I have a list like [[1,4],[3,9],[2,5],[3,2]]. How can I sort the list based on the second value in the item? That is, I want the list to be: [[3,2],[1,4],[2,5],[3,9]] -- http://mail.python.org/mailman/listinfo/python-list

duplicate items in a list

2005-11-21 Thread Shi Mu
I used the following method to remove duplicate items in a list and got confused by the error. >>> a [[1, 2], [1, 2], [2, 3]] >>> noDups=[ u for u in a if u not in locals()['_[1]'] ] Traceback (most recent call last): File "", line 1, in ? TypeError: iterable argument required -- http://mail.py

global definition

2005-11-20 Thread Shi Mu
I have a code here. I understand i can not draw lines without the global definition of lastX and lastY. But still confused by its use. when should we use global definition? from Tkinter import * root = Tk() c = Canvas(root, bg='#0e2e0e', height=500, width=1000) frame = c lastX="" lastY="" def cl

about list

2005-11-20 Thread Shi Mu
How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: How to draw a dash line in the Tkinter?

2005-11-20 Thread Shi Mu
On 11/20/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Ben Bush wrote: > > > How to draw a dash line in the Tkinter? > > use the dash option. e.g. > >canvas.create_line(xy, fill="red", dash=(2, 4)) >canvas.create_line(xy, fill="red", dash=(6, 5, 2, 4)) > > (the tuple contains a number of

about dictionary

2005-11-20 Thread Shi Mu
d is a dictionary. >>> d {0: [[0, 1], [0, 2]], 1: [[0, 1], [1, 2], [1, 3]], 2: [[0, 2], [1, 2], [2, 3]], 3: [[1, 3], [2, 3]]} for the value under each key, if the possible connection is in the dictionary, for example, under key 0. 1 and 2 were found to have a pair in some other places so get [0,1,

about lambda

2005-11-20 Thread Shi Mu
what does the following code mean? It is said to be used in the calculation of the overlaid area size between two polygons. map(lambda x:b.setdefault(x,[]),a) Thanks! -- http://mail.python.org/mailman/listinfo/python-list

about sort and dictionary

2005-11-20 Thread Shi Mu
Got confused by the following code: >>> a [6, 3, 1] >>> b [4, 3, 1] >>> c {1: [[6, 3, 1], [4, 3, 1]], 2: [[6, 3, 1]]} >>> c[2].append(b.sort()) >>> c {1: [[6, 3, 1], [1, 3, 4]], 2: [[6, 3, 1], None]} #why c can not append the sorted b?? >>> b.sort() >>> b [1, 3, 4] -- http://mail.python.org/mailma

Re: about dictionary

2005-11-20 Thread Shi Mu
On 11/20/05, przemek drochomirecki <[EMAIL PROTECTED]> wrote: > > Uzytkownik "Peter Otten" <[EMAIL PROTECTED]> napisal w wiadomosci > news:[EMAIL PROTECTED] > > Shi Mu wrote: > > > > > how to do with it? > > > > Use Ben Finney

Re: about polygon

2005-11-20 Thread Shi Mu
On 11/20/05, Jan Voges <[EMAIL PROTECTED]> wrote: > Hi! > > Am Sun, 20 Nov 2005 03:55:21 -0800 schrieb Shi Mu: > > > Why I got a black polygon in the following code? > > How can I make it no-color filled? > > Use create_line instead: > c.create_line(60,60,100

Re: about dictionary

2005-11-20 Thread Shi Mu
On 11/20/05, Peter Otten <[EMAIL PROTECTED]> wrote: > przemek drochomirecki wrote: > > > Uzytkownik "Shi Mu" <[EMAIL PROTECTED]> napisal w wiadomosci > > news:[EMAIL PROTECTED] > > I have have the following code: > >>>> a=[3,5,8,0] &g

about polygon

2005-11-20 Thread Shi Mu
Why I got a black polygon in the following code? How can I make it no-color filled? Thanks! import Tkinter c = Tkinter.Canvas(width=220, height=220) c.pack() c.create_polygon(60,60,100,60,100,100,60,120) c.mainloop() -- http://mail.python.org/mailman/listinfo/python-list

Re: about dictionary

2005-11-20 Thread Shi Mu
On 20 Nov 2005 02:59:30 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > b = dict([(x,dict()) for x in a]) > Shi Mu wrote: > > I have have the following code: > > >>> a=[3,5,8,0] > > >>> b={} > > >>> > > How I can i as

about dictionary

2005-11-20 Thread Shi Mu
I have have the following code: >>> a=[3,5,8,0] >>> b={} >>> How I can i assign each item in a as the key in the dictionary b simultaneously? that is, b={3:[],5:[],8:[],0:[]} Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: about try and exception

2005-11-17 Thread Shi Mu
On 11/17/05, Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > On 11/17/05, Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote: > > > >> I would think that when the exception occurs the interpreter exits the > >> block of code it i

Re: about try and exception

2005-11-17 Thread Shi Mu
On 11/17/05, Carl J. Van Arsdall <[EMAIL PROTECTED]> wrote: > I would think that when the exception occurs the interpreter exits the > block of code it is currently in and enters the exception block. > > Thus the line n = 1/2 would never get executed. > > > -Carl > > Ben Bush wrote: > > I wrote the

Re: Tkinter's coordinates setting

2005-11-17 Thread Shi Mu
On 11/17/05, Steve Juranich <[EMAIL PROTECTED]> wrote: > On 11/17/05, Ben Bush <[EMAIL PROTECTED]> wrote: > > Tkinter's coordinates setting are: the left upper corner is the smallest X > > and Y, which is different from our usual think that Y is largest in that > > location. If i draw some lines on

Re: compare list

2005-11-15 Thread Shi Mu
On 11/15/05, Simon Brunning <[EMAIL PROTECTED]> wrote: > On 15/11/05, Shi Mu <[EMAIL PROTECTED]> wrote: > > it does not work. > > >>> len(set(lisA).intersection(set(lisB))) == 2 > > Traceback (most recent call last): > > File "", line 1,

Re: compare list

2005-11-15 Thread Shi Mu
On 11/15/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: > Shi Mu said unto the world upon 2005-11-15 01:30: > >>Hey Ben, > >> > >>first, as expected, the other two answers you received are better. :-) > >> > >>Sets are much better optimized

Re: compare list

2005-11-14 Thread Shi Mu
> Hey Ben, > > first, as expected, the other two answers you received are better. :-) > > Sets are much better optimized for things like membership testing than > are lists. I'm not competent to explain why; indeed, I keep > overlooking them myself :-( > > Unfortunately, the indents got screwed up

Re: directory listing

2005-11-12 Thread Shi Mu
>for x in listing: >if os.path.isdir(directory+os.sep+x): > dirs.append(x) > >return dirs > > Fredrik Lundh wrote: > > "Shi Mu" wrote: > > > >> print buildList() gets lo

Re: about array,arange

2005-11-12 Thread Shi Mu
On 11/12/05, Robert Kern <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > i got confused by the use of array and arange. > > arange get array and range get list, why we need the two different types? > > When you're asking questions about a third-party module, it'

Re: about widget construction kit

2005-11-12 Thread Shi Mu
On 11/12/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried again and got the follwoing message: > > *** cannot find Tcl/Tk headers and library files > > change the TCL_ROOT variable in the setup.py file > > but i have already inst

Re: about array,arange

2005-11-12 Thread Shi Mu
On 11/12/05, Robert Kern <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > i got confused by the use of array and arange. > > arange get array and range get list, why we need the two different types? > > When you're asking questions about a third-party module, it'

about array,arange

2005-11-12 Thread Shi Mu
i got confused by the use of array and arange. arange get array and range get list, why we need the two different types? -- http://mail.python.org/mailman/listinfo/python-list

about try statement

2005-11-12 Thread Shi Mu
very hard for me to understand the difference between try...except and try...finally -- http://mail.python.org/mailman/listinfo/python-list

Re: about widget construction kit

2005-11-12 Thread Shi Mu
very hard for me to understand the difference between try...except and try...finally -- http://mail.python.org/mailman/listinfo/python-list

Re: about widget construction kit

2005-11-11 Thread Shi Mu
On 11 Nov 2005 16:06:37 -0800, Martin Miller <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > > > 1. pass in the full path to the executable: > > > > > >cd tkinter3000-1.0-20031

x, y coordinates in Tkinter canvas

2005-11-11 Thread Shi Mu
got confused by x, y coordinates in Tkinter canvas. from left to right, does X increase? from top to bottom, does y increase? -- http://mail.python.org/mailman/listinfo/python-list

Re: directory listing

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > "Shi Mu" wrote: > > > but i am curious why the line of "print x" does not show > > anything. > > because your c:\temp directory is empty ? > > print buildList() gets lots of stuffs f

Re: about widget construction kit

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > > > I tried to install WCK(Widget Construction Kit (WCK)): > > > > > > > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > > > > Traceback (m

Re: directory listing

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried this and no error reported but nothing appear on the console, why? > > > > import os > > > > def buildList( directory='c:\TEMP' ): > > dirs = [ ] > &

Re: directory listing

2005-11-11 Thread Shi Mu
On 11 Nov 2005 22:00:04 GMT, Michael Konrad <[EMAIL PROTECTED]> wrote: > Richard Townsend <[EMAIL PROTECTED]> wrote: > > > On 11 Nov 2005 21:20:33 GMT, SU News Server wrote: > > > > Try passing the full pathname of each item to os.path.isdir() > > > > You can create the pathname using os.path.join(

Re: about widget construction kit

2005-11-11 Thread Shi Mu
On 11/11/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > I tried to install WCK(Widget Construction Kit (WCK)): > > > > C:\Python23>python tkinter3000-1.0-20031212\setup.py install > > Traceback (most recent call last): > > File &qu

about widget construction kit

2005-11-11 Thread Shi Mu
ut? On 11/11/05, Salvatore Di Dio <[EMAIL PROTECTED]> wrote: > If you mean trigonometrics calculus > give a try at > http://online.effbot.org/2004_09_01_archive.htm#tkinter-complex > and download too WCK http://effbot.org/zone/tkinter-index.htm > there is a demo on Lissajou &

Re: [Tutor] triangulation

2005-11-10 Thread Shi Mu
gt; > > > > > > >>Or, do you mean radio triangulation by directional signal propagation > >> > >> > > > > > > > >>Or, do you mean drawing a triangle in Tkinter? > >> > >> > > > >Or even triangulation of currency from EU

Re: triangulation

2005-11-09 Thread Shi Mu
Delaunay triangulations On 11/9/05, Robert Kern <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > is there any sample code to triangulation? many thanks! > > Triangulation of what? Scattered points in a plane? 2D manifolds > embedded in a 3D space? > > Delaun

triangulation

2005-11-09 Thread Shi Mu
is there any sample code to triangulation? many thanks! -- http://mail.python.org/mailman/listinfo/python-list

parabola

2005-11-08 Thread Shi Mu
Is there any sample code to draw parabola using Tkinter? -- http://mail.python.org/mailman/listinfo/python-list

any python module to calculate sin, cos, arctan?

2005-11-08 Thread Shi Mu
any python module to calculate sin, cos, arctan? -- http://mail.python.org/mailman/listinfo/python-list

Re: image

2005-11-08 Thread Shi Mu
yes. I use both cmd and pythonwin to run it. why both of them can not work? On 11/8/05, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Shi Mu wrote: > > > why the following code report the error: > > Traceback (most recent call last): > > File > > "C:\P

image

2005-11-08 Thread Shi Mu
why the following code report the error: 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 "C:\Python23\Examples\AppB\text.py", line 24, in ? text.image_create(EN

click event

2005-11-06 Thread Shi Mu
I have the following workable code and every time i click on the canvas, the coordinates are reported. i wonder how i can draw the lines when i click the canvas using these coordinates? from Tkinter import * root = Tk() c = Canvas(root, bg='#0e2e0e', height=500, width=1000) def click(event):

Re: Tk

2005-10-30 Thread Shi Mu
How can I make the main menu come first, and after clicking test/just try, "how are you" interface shows. Thanks a lot! from Tkinter import * from Tkinter import _cnfmerge class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf = _cnfmerge((cnf, kw)) self.widgetName

Tk

2005-10-28 Thread Shi Mu
When I run the following code, script kept running and I have to force it to stop. Could you check the code to give suggestions how to improve it? Thanks a lot! from Tkinter import * from Tkinter import _cnfmerge class Dialog(Widget): def __init__(self, master=None, cnf={}, **kw): cnf =

Re: cell and row

2005-10-25 Thread Shi Mu
27;defenestrate'] >>> for x in a[:]: ... if len(x) > 4: a.insert(0, x) ... >>> a ['defenestrate', 'window', 'defenestrate', 'defenestrate', 'cat', 'window', 'defenestrate'] On 10/25/05, Fred

cell and row

2005-10-25 Thread Shi Mu
I can not understand the use of "cell" and "row" in the code: # convert the matrix to a 1D list matrix = [[13,2,3,4,5],[0,10,6,0,0],[7,0,0,0,9]] items = [cell for row in matrix for cell in row] print items -- http://mail.python.org/mailman/listinfo/python-list

Re: pickle

2005-10-25 Thread Shi Mu
what does the following code mean? y = pickle.load(file("cnumber.pickle", "r")) also, I can not understand "f" in pickle.dump(x, f) On 10/25/05, marduk <[EMAIL PROTECTED]> wrote: > On Mon, 2005-10-24 at 23:55 -0700, Shi Mu wrote: > > I got a

pickle

2005-10-24 Thread Shi Mu
I got a sample code and tested it but really can not understand the use of pickle and dump: >>> import pickle >>> f = open("try.txt", "w") >>> pickle.dump(3.14, f) >>> pickle.dump([1,2,3,4], f) >>> f.close() -- http://mail.python.org/mailman/listinfo/python-list

difference after remove

2005-10-24 Thread Shi Mu
Is there any difference if I remove the '/' from the following statement? intMatrix2 = [[1,1,2,4,1,7,1,7,6,9],\ [1,2,5,3,9,1,1,1,9,1],\ [0,0,5,1,1,1,9,7,7,7]] print intMatrix2 I removed one '\' and it still works. So what is the use of '\'? -- http://mail.python.org/mailm

Print in PythonWin

2005-10-24 Thread Shi Mu
In the PythonWin's interactive window, why sometimes I need type the command two times to make it work? for example, I execute "print testList" two times to make it work. Why? >>> print testList >>> print testList ['w', 'e', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', 'l', 'e', 'a', 'r', 'n', ' ',

ABOUT FIND

2005-10-24 Thread Shi Mu
I got confused by the following information from the help for "FIND": find(s, *args) find(s, sub [,start [,end]]) -> in what does *args mean (especially the '*')? also, in the sub, why put a comma before start? what does 'in' mean? -- http://mail.python.org/mailman/listinfo/python-list

index and find

2005-10-22 Thread Shi Mu
what is the difference between index and find in the module of string? for both "find" and "index", I got the position of the letter. On 10/19/05, Shi Mu <[EMAIL PROTECTED]> wrote: > I have installed Python 2.3 and I type "help()" and then "Keywords&q

Re: path

2005-10-22 Thread Shi Mu
what is the differenc ebetween index and find in the module of string? for both "find" and "index", I got the position of the letter. -- http://mail.python.org/mailman/listinfo/python-list

path

2005-10-19 Thread Shi Mu
I have installed Python 2.3 and I type "help()" and then "Keywords". I get a list of words. And it says that I can enter any of the words to get more help. I enter "and" and I get the following error message: "Sorry, topic and keyword documentation is not available because the Python HTML document

path

2005-10-19 Thread Shi Mu
I have installed Python 2.3 and I type "help()" and then "Keywords". I get a list of words. And it says that I can enter any of the words to get more help. I enter "and" and I get the following error message: "Sorry, topic and keyword documentation is not available because the Python HTML document

output

2005-10-14 Thread Shi Mu
After I run the following python code, I expect to have the printing such as: The year is 2005 However, I got something like: The year is 2005 Fri Oct 14 17:43:31 2005 Fri Oct 14 17:43:31 2005 The year is 2005 What is the reason? The code follows: import time import now class today(now.now):

Re: line

2005-10-10 Thread Shi Mu
it is not a homework, just interested. On 10 Oct 2005 00:04:23 -0700, gsteff <[EMAIL PROTECTED]> wrote: > Why do you want to know? This list isn't a tool to get others to do > your homework. > > Greg > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman

line

2005-10-09 Thread Shi Mu
There are four points with coordinates: 2,3;4,9;1,6;3,10. How to use Python to draw one perpendicular bisector between (2,3) and (4,9); the other perpendicular bisector between (1,6)和(3,10); then, makes the output like: l1 a b c l2 a b c (Note: l indicates the perpendicular bisector with equation a

Re: is there any Python code for spatial tessellation?

2005-10-09 Thread Shi Mu
is there any course website about teaching python? for instance, some computer science courses website? On 10/8/05, Shi Mu <[EMAIL PROTECTED]> wrote: > is there any Python code for spatial tessellation? > thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

is there any Python code for spatial tessellation?

2005-10-08 Thread Shi Mu
is there any Python code for spatial tessellation? thanks a lot! -- http://mail.python.org/mailman/listinfo/python-list

divide

2005-10-06 Thread Shi Mu
I have three points in a rectangle and i wonder how to use PYTHON to divide the rectangle into three parts with each point located in the different part. For instance, Point A goes to Part I, Point B goes to Part II and Point C goes to Part III. And the distance between any point within Part I and