Re: [Tutor] plotting pixels

2010-09-19 Thread Bill Allen
On Sun, Sep 19, 2010 at 2:40 AM, Lie Ryan wrote: > > More slowly and takes huge amount of memory. A single Tk canvas object > takes at least 14 words (= 114 bytes in 64-bit OS = 56 bytes in 32-bit > OS) + the amount of data is needed to store the `kind of object`. That's > much larger than the id

Re: [Tutor] plotting pixels

2010-09-19 Thread Steven D'Aprano
Hello Ken, On Sun, 19 Sep 2010 04:18:06 am Ken Oliver wrote: > > body{font-size:10pt;font-family:arial,sans-serif;background-co >lor:#ff;color:black;}p{margin:0px;} > > > http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What are "singletons" good for?

2010-09-19 Thread Steven D'Aprano
On Mon, 20 Sep 2010 02:09:37 am Alan Gauld wrote: > "Steven D'Aprano" wrote > > > < much sense about singleton v global> > > > > and think this makes their code "better". (I blame the Go4 for > > making a > > religion out of design patterns which exist only to work around > > Java's > > limitation

Re: [Tutor] FW: Can this be done easly

2010-09-19 Thread Roelof Wobben
> From: andreeng...@gmail.com > Date: Sun, 19 Sep 2010 20:54:01 +0200 > Subject: Re: [Tutor] FW: Can this be done easly > To: rwob...@hotmail.com > CC: tutor@python.org > > On Sun, Sep 19, 2010 at 8:33 PM, Roelof Wobben wrote: > >> Hello, >> >> I changed

Re: [Tutor] FW: Can this be done easly

2010-09-19 Thread Andre Engels
On Sun, Sep 19, 2010 at 8:33 PM, Roelof Wobben wrote: > Hello, > > I changed the programm to this : > > import unittest > class Point: >    def __init__(self, x=0, y=0): >        self.x = x >        self.y = y > > class Rectangle(object): >    def __init__(self, base_point, width=0, length=0): >

Re: [Tutor] FW: Can this be done easly

2010-09-19 Thread Roelof Wobben
> To: tutor@python.org > From: __pete...@web.de > Date: Sun, 19 Sep 2010 20:07:05 +0200 > Subject: Re: [Tutor] FW: Can this be done easly > > Roelof Wobben wrote: > >> For this exercise : >> >> 3.Write a function named move_rect that takes a Rectangle and

Re: [Tutor] FW: Can this be done easly

2010-09-19 Thread Andre Engels
On Sun, Sep 19, 2010 at 7:02 PM, Roelof Wobben wrote: > > > > >> From: rwob...@hotmail.com >> To: __pete...@web.de >> Subject: RE: [Tutor] Can this be done easly >> Date: Sun, 19 Sep 2010 17:01:22 + >> >> >> >> >> ---

Re: [Tutor] FW: Can this be done easly

2010-09-19 Thread Peter Otten
Roelof Wobben wrote: > For this exercise : > > 3.Write a function named move_rect that takes a Rectangle and two > parameters named dx and dy. It should change the location of the rectangle > by adding dx to the x coordinate of corner and adding dy to the y > coordinate of corner. > > Is this on

[Tutor] FW: Can this be done easly

2010-09-19 Thread Roelof Wobben
> From: rwob...@hotmail.com > To: __pete...@web.de > Subject: RE: [Tutor] Can this be done easly > Date: Sun, 19 Sep 2010 17:01:22 + > > > > > >> To: tutor@python.org >> From: __pete...@web.de >> Date: Sun, 19

Re: [Tutor] Can this be done easly

2010-09-19 Thread Peter Otten
Roelof Wobben wrote: >> Hint: why does this work: >> >>> def __init__(self, x=0, y=0): >> >> ...while this doesnt: >> >>> def _init_(self, base_point, width=0, length=0): >> >> Peter > Maybe because base_point has no value ? No. One __init__ has two underscores (correct) on each side, the other

Re: [Tutor] Can this be done easly

2010-09-19 Thread Alan Gauld
"Roelof Wobben" wrote When I change everything to this : class Rectangle(object): def _init_(self, base_point, width=0, length=0): self.base_point = base_point self.width = width self.length = length punt = Point(3,4) rechthoek = Rectangle (punt,20,30) I get this mes

Re: [Tutor] What are "singletons" good for?

2010-09-19 Thread Alan Gauld
"Steven D'Aprano" wrote < much sense about singleton v global> and think this makes their code "better". (I blame the Go4 for making a religion out of design patterns which exist only to work around Java's limitations.) In fact the original design patterns were based around Smalltalk'

Re: [Tutor] Can this be done easly

2010-09-19 Thread Roelof Wobben
> To: tutor@python.org > From: __pete...@web.de > Date: Sun, 19 Sep 2010 18:04:25 +0200 > Subject: Re: [Tutor] Can this be done easly > > Roelof Wobben wrote: > >> When I change everything to this : > >> I get this message : >> >> Traceback (most recent c

Re: [Tutor] Can this be done easly

2010-09-19 Thread Peter Otten
Roelof Wobben wrote: > When I change everything to this : > I get this message : > > Traceback (most recent call last): > File "C:\Users\wobben\workspace\oefeningen\src\test.py", line 13, in > > rechthoek = Rectangle (punt,20,30) > TypeError: object.__new__() takes no parameters Hint:

Re: [Tutor] Can this be done easly

2010-09-19 Thread Roelof Wobben
> Date: Sun, 19 Sep 2010 14:19:46 +0200 > From: knack...@googlemail.com > To: tutor@python.org > Subject: Re: [Tutor] Can this be done easly > > Am 19.09.2010 10:49, schrieb Roelof Wobben: >> >> >> Hello, >> >> I have this programm : >> >> class Point: >>

Re: [Tutor] What are "singletons" good for?

2010-09-19 Thread Steven D'Aprano
On Sun, 19 Sep 2010 02:50:42 am Knacktus wrote: > Hey all, > > the usual explanation for the usage of a Singleton goes like this: > > "Use a singleton if you want to make sure, that only one instance of > a class exists." > > But now I ask myself: Why should I call the constructor of a class > more

Re: [Tutor] Can this be done easly

2010-09-19 Thread Knacktus
Am 19.09.2010 10:49, schrieb Roelof Wobben: Hello, I have this programm : class Point: def __init__(self, x=0, y=0): self.x = x self.y = y class Rectangle(Point): def _init_(self, width=0, length=0): self.width = width self.length = length Yo

Re: [Tutor] Remove a dictionary entry

2010-09-19 Thread Peter Otten
Steven D'Aprano wrote: > On Sat, 18 Sep 2010 07:13:13 pm Peter Otten wrote: > >> You should never iterate over a list or dictionary and add or remove >> items to it at the same time. That is a recipe for disaster even if >> it doesn't fail explicitly. > > That's a bit strong. It's quite possible

Re: [Tutor] Remove a dictionary entry

2010-09-19 Thread Peter Otten
M. 427 wrote: > Version 4 : (2 steps) > > # step 1 : list keys of unwanted rows > sck=[] # list of single children keys in dictionary > for k in d.keys() : > if len(d[k]) < 2 : > sck.append(k) > # step 2 : delete all d rows w

[Tutor] Can this be done easly

2010-09-19 Thread Roelof Wobben
Hello, I have this programm : class Point: def __init__(self, x=0, y=0): self.x = x self.y = y class Rectangle(Point): def _init_(self, width=0, length=0): self.width = width self.length = length punt = Point(3,4) rechthoek = Rectang

Re: [Tutor] plotting pixels

2010-09-19 Thread Lie Ryan
On 09/19/10 09:39, ALAN GAULD wrote: >> It appears that the Tk canvas widget does not support simply plotting > a pixel. > > Correct, and I agree it seems odd, but in practice drawing either lines or > ovals of one-pixel do the equivalent job - albeit a little more slowly. More slowly and takes

Re: [Tutor] Remove a dictionary entry

2010-09-19 Thread M. 427
Version 4 : (2 steps) # step 1 : list keys of unwanted rows sck=[] # list of single children keys in dictionary for k in d.keys() : if len(d[k]) < 2 : sck.append(k) # step 2 : delete all d rows whose key is listed in sck