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/
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 ?
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]]
&
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
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
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
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
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
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,
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
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
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
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
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
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
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
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
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
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
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
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,
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
> 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
>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
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'
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
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'
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
very hard for me to understand the difference between
try...except and try...finally
--
http://mail.python.org/mailman/listinfo/python-list
very hard for me to understand the difference between
try...except and try...finally
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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 = [ ]
> &
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(
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
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
&
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
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
is there any sample code to triangulation? many thanks!
--
http://mail.python.org/mailman/listinfo/python-list
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?
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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):
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
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 =
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
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
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
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
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
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', ' ',
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
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
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
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
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
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):
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
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
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?
thanks a lot!
--
http://mail.python.org/mailman/listinfo/python-list
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
65 matches
Mail list logo