[Tutor] 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!   ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] is there any Python code for spatial tessellation?

2005-10-09 Thread Shi Mu
ax + by = c.) Plus the intersection coordinates of the two perpendicular bisectors: x,y On 10/8/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > On Sat, 8 Oct 2005, Shi Mu wrote: > > > is there any Python code for spatial tessellation? > > Are you looking for cod

[Tutor] line question

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

[Tutor] output question

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: [Tutor] output question

2005-10-14 Thread Shi Mu
return time.ctime(self.t) def __repr__(self): return time.ctime(self.t) def __call__(self,t=-1.0): if t < 0.0: self.t = time.time() else: self.t = t self.storetime() On 10/14/05, Kent Johnson <[EMAIL PROTECTED]> wro

[Tutor] setting

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

[Tutor] 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. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] what does %25f mean?

2005-10-24 Thread Shi Mu
what does %25f mean? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] dictionary

2005-10-24 Thread Shi Mu
I typed: landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} and when i checked landUse, I found it become: {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} why the order is changed? ___ Tutor maillist - Tutor@python.org http://mail.python

[Tutor] string

2005-10-24 Thread Shi Mu
what does the following sentence mean? does it mean i can not use double-quoted string? SyntaxError: EOL while scanning single-quoted string ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] 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? ___ Tutor maillist

[Tutor] about \

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 '\'?

[Tutor] help

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? ___ Tutor maillis

[Tutor] Matrix

2005-10-24 Thread Shi Mu
I can not understand the use of "cell in row" for two times 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 ___ Tutor maillist - Tutor@python.o

[Tutor] Tkinter

2005-10-29 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: [Tutor] Tkinter

2005-10-29 Thread Shi Mu
> wrote: > What kind of improvement you looking for? > > On 10/29/05, Shi Mu <[EMAIL PROTECTED]> wrote: > > 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 i

[Tutor] compare

2005-10-31 Thread Shi Mu
What does this line 11 mean in the following code? 1 # calc.py 2 def calc(seq): 3 maximum = 0 4 max_item = [] 5 for i in seq: 6 product = (i[0]*100 + i[1]*10 + i[2]) * (i[3]*10 + i[4]) 7 if product > maximum: 8maximum = product 9max_ite

[Tutor] pack

2005-11-04 Thread Shi Mu
what does pack mean in the following code? # File: hello1.py from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] pack

2005-11-04 Thread Shi Mu
eometry manager is "grid" > > If you don't specify anything, the widget will simply not be displayed.. > see here: > > http://effbot.org/tkinterbook/pack.htm > > > Hugo > > Shi Mu wrote: > > what does pack mean in the following code? >

Re: [Tutor] pack

2005-11-05 Thread Shi Mu
o > > have it displayed with the current geometry manager(which per default is > > the pack method) > > > > A geometry manager is just a way for arranging widgets into a window. > > Another geometry manager is "grid" > > > > If you don't spe

[Tutor] main

2005-11-05 Thread Shi Mu
It is very hard for me to understand why we need the following line? if __name__ == "__main__": ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] point and polygon

2005-11-06 Thread Shi Mu
why the following code report error? """ Is given point in polygon? """ def pointInPoly(point, pointsList): "Return True if point is contained in polygon (defined by given list of points.)" assert len(pointsList) >= 3, 'Not enough points to define a polygon (I require 3 or more.)

[Tutor] inside

2005-11-06 Thread Shi Mu
why the following code does not work? # determine if a point is inside a given polygon or not # Polygon is a list of (x,y) pairs. def point_inside_polygon(x,y,poly): n = len(poly) inside =False p1x,p1y = poly[0] for i in range(n+1): p2x,p2y = poly[i % n] if y > m

[Tutor] color vector

2005-11-06 Thread Shi Mu
why the following code does not work? """ Tkinter Color Vector Objects Just the bare minimum to create re-sizable and re-usable color icons in tkinter. """ import Tkinter as Tk import math """ Get points for a unit regular-polygon with n sides. """ def getregpoly(sides): points = [] ang

Re: [Tutor] inside

2005-11-06 Thread Shi Mu
just return the "Simple pointInPoly() test..." no return from point_inside_polygon(3,10,poly) On 11/6/05, Glen Wheeler <[EMAIL PROTECTED]> wrote: > > why the following code does not work? > > [snip script] > > Give us an error message, please. > ___ > T

Re: [Tutor] inside

2005-11-06 Thread Shi Mu
nformation - > > If there's an error message - copy and paste the error message > If there is no error message - tell us what you expected to happen, > and what happened instead. > > Regards, > > Liam Clarke > On 11/7/05, Shi Mu <[EMAIL PROTECTED]> wrote: > >

[Tutor] overlay

2005-11-06 Thread Shi Mu
Is there any sample code to calculate the overlaid area between two polygons? Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] draw lines

2005-11-06 Thread Shi Mu
I have a list of random points: [[x0,y0],[x1,y1],...,[xn,yn]] how can I use Tkinter to draw lines to connect them one by one based on the order in the list? Thanks a lot! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tuto

[Tutor] click and line

2005-11-06 Thread Shi Mu
I tried to write the follwoing code to draw lines on the anvas based on the clicked points but retur the message: >>> 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__

Re: [Tutor] click and line

2005-11-06 Thread Shi Mu
global lastX, lastY if lastX != "": c.create_line(lastX,lastY,event.x,event.y,fill="white") lastX = event.x lastY = event.y frame = c c.bind('',click) c.pack() root.mainloop() On 11/6/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > Hi Shi Mu, >

Re: [Tutor] click and line

2005-11-06 Thread Shi Mu
uot;) lastX = event.x lastY = event.y c.bind('',click) c.pack() root.mainloop() On 11/6/05, Shi Mu <[EMAIL PROTECTED]> wrote: > based on the following rewritten code, why the lines still can not be > drawn? (there is no error report and the canvas appears). > > f

Re: [Tutor] click and line

2005-11-06 Thread Shi Mu
frame = c needs to be put before the click function or the lines can not be drawn. On 11/6/05, Chris F.A. Johnson <[EMAIL PROTECTED]> wrote: > On Sun, 6 Nov 2005, Shi Mu wrote: > > > based on the following rewritten code, why the lines still can not be > > drawn? (there is

[Tutor] no error no result

2005-11-06 Thread Shi Mu
when I read some python sample codes. I found that several of them need "python -i" to run them or you will not get any result though the program does not report any error. I really can not understand it. Thanks! ___ Tutor maillist - Tutor@python.org ht

[Tutor] image

2005-11-07 Thread Shi Mu
why the follwoing 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_creat

Re: [Tutor] click and line

2005-11-07 Thread Shi Mu
Danny, You are right. Thanks for your great patience and kindness. Shi On 11/7/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > > it works now. > > Hi Shi Mu, > > Can you describe how you fixed it? The only diff between the two programs > that I see is that yo

[Tutor] geometry

2005-11-07 Thread Shi Mu
any python code for middle school geometry teaching use? for instance, calculate the polygon area size, overlaid area size? Thanks. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] geometry

2005-11-07 Thread Shi Mu
Because i am also teaching some introduction courses of programming in middle school, I prefer some 2D geometry codes. On 11/7/05, Chris or Leslie Smith <[EMAIL PROTECTED]> wrote: > > | any python code for middle school geometry teaching use? > | for instance, calculate the polygon area size, ove

Re: [Tutor] image

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

[Tutor] any code to draw parabola or curve?

2005-11-08 Thread Shi Mu
any code to draw parabola or curve? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] triangulation

2005-11-09 Thread Shi Mu
is there any sample code of triangulation? many thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] triangulation

2005-11-10 Thread Shi Mu
using python to do Fortune's sweeping line algorithm. Is python is not good in doing that kind of computation or some other reason? Thanks a lot for all of your responses!!! On 11/9/05, Gregor Lingl <[EMAIL PROTECTED]> wrote: > > > Alex Hunsley schrieb: > > Shi Mu wrote

Re: [Tutor] triangulation

2005-11-10 Thread Shi Mu
I see. maybe some websites are blocked to me. On 11/10/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > Hi Shi Mu, > > There are some direct ways you can find a delaunay triangulation > implementation in Python. In fact, the first Google hit to "triangulation > python&q

[Tutor] two ways

2005-11-10 Thread Shi Mu
what is the difference between the two ways of assigning the list? p=a vs. p=a[:] >>> a=range(5) >>> a [0, 1, 2, 3, 4] >>> p=a >>> p [0, 1, 2, 3, 4] >>> p=a[:] >>> p [0, 1, 2, 3, 4] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/li

Re: [Tutor] two ways

2005-11-10 Thread Shi Mu
thanks! On 11/10/05, Liam Clarke <[EMAIL PROTECTED]> wrote: > Hi Shi, > > For what you're doing, nothing at all. > > When you use a colon, slice syntax, it defaults to [start:end] so p = > a[:] is the same as > p = a[0:len(a)] > > Regards, > > Liam Clar

Re: [Tutor] two ways

2005-11-11 Thread Shi Mu
thanks! On 11/11/05, Gregor Lingl <[EMAIL PROTECTED]> wrote: > Liam Clarke schrieb: > > >Hi Shi, > > > >For what you're doing, nothing at all. > > > >When you use a colon, slice syntax, it defaults to [start:end] so p = > >a[:] is the same as > >p = a[0:len(a)] > > > > > > > But in fact there is a

Re: [Tutor] dictionary question

2005-11-11 Thread Shi Mu
On 11/11/05, Eric Walker <[EMAIL PROTECTED]> wrote: > All, > I have a dictionary say: > d = {'first':[]} > I am going through another list and depending on whats going on, > I want to add to the empty list. I have tried the following to noavail. > > d['first'] = d['first'].append("string") > > I wo

[Tutor] output question

2005-11-12 Thread Shi Mu
I got the output as: >>> Yes!!! This line will always print from the code: try: fsock = open("c:/TEMP/hello.txt") except IOError: print "The file does not exist, exiting gracefully" print "Yes!!! This line will always print" it means the code found there is hello.txt, why it does not show

Re: [Tutor] output question

2005-11-12 Thread Shi Mu
On 11/12/05, Liam Clarke <[EMAIL PROTECTED]> wrote: > Sorry Shi Mu, don't understand the question. > > So, you're successfull opening a file. Now, you need to read it > > for line in fsock: >print line > > or > > fsockData = fsock.read() > >

Re: [Tutor] output question

2005-11-12 Thread Shi Mu
On 11/12/05, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > So, you're successfull opening a file. Now, you need to read it > > > > > > for line in fsock: > > >print line > > > > > > Have a play with those. > > it works! thank

Re: [Tutor] output question

2005-11-12 Thread Shi Mu
efully" > > > > print "Yes!!! This line will always print" > > > I thought if the except situation does not happen, that means the try > > section works. At that time, I was a little confused that since the open > > statement works, why there is nothing s

[Tutor] about global definition

2005-11-21 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