On Sat, Sep 18, 2010 at 9:26 PM, Bill Allen wrote:
>
>
>> Digging a little deeper it seems the idiomatic way to do this in Python
>> is to use PIL the Python Imaging Library to create a GIF or bitmap
>> image and then insert that into Tkinters cancvas as an image object.
>>
>> The Pil ImageDraw c
>
> Digging a little deeper it seems the idiomatic way to do this in Python
> is to use PIL the Python Imaging Library to create a GIF or bitmap
> image and then insert that into Tkinters cancvas as an image object.
>
> The Pil ImageDraw class has a point() ethod
>
> I've never tried this but it is
> 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.
> The primitive obviously exists in the underlying code,
I
On Sat, Sep 18, 2010 at 1:18 PM, Ken Oliver wrote:
>
>
>> On Fri, Sep 17, 2010 at 3:38 AM, Alan Gauld wrote:
>>
>>>
>>> For plotting pixels I would not use turtle graphics.
>>> That would be a fairly complicated option I'd have thought.
>>> A simple canvas would be easier.
>>>
>>> Alan G.
>>>
>>>
On 09/19/10 02:50, 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
> than once
> It appears that the Tk canvas widget does not support simply
> plotting a pixel. However, I can plot a line only one pixel long.
> I wonder why they do not simply provide the pixel plot primitive? I
> have seen very many graphics packages that do this and I have always
>
-Original Message- From: Bill Allen Sent: Sep 18, 2010 11:45 AM To: Alan Gauld Cc: tutor@python.org Subject: Re: [Tutor] plotting pixels
On Sat, Sep 18, 2010 at 10:44 AM, Bill Allen wrote:
On Fri, Sep 17, 2010 at 3:38 AM, Alan Gauld wrot
> Date: Sat, 18 Sep 2010 13:40:55 -0400
> From: bgai...@gmail.com
> To: rwob...@hotmail.com
> CC: tutor@python.org
> Subject: Re: [Tutor] next class problem
>
> On 9/18/2010 1:20 PM, Roelof Wobben wrote:
>>
>> Hello,
>>
>> I have this exercise :
>>
>> Rew
On 9/18/2010 1:20 PM, Roelof Wobben wrote:
Hello,
I have this exercise :
Rewrite the distance function from chapter 5 so that it takes two Points as
parameters instead of four numbers.
I have this solution :
class Point:
def __init__(self, x=0, y=0):
self.x = x
se
Hello,
I have this exercise :
Rewrite the distance function from chapter 5 so that it takes two Points as
parameters instead of four numbers.
I have this solution :
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
def distance(p1,p2):
dx
Yet another way is to iterate thru the dict collecting a list of keys
of items to be deleted.
Then iterate thru that list deleting from the dict.
--
Bob Gailer
919-636-4239
Chapel Hill NC
___
Tutor maillist - Tutor@python.org
To unsubscribe or cha
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
than once if I only want one instance?
After all, I decide
Hello ,
Thanks everyone.
I solved it by this :
class Point:
def __init__(self, x=0, y=0):
self.x = x
self.y = y
P=Point()
print P
print id(P)
and a calculator which can convert hex to decimal.
Roelof
>
>> From: st...@pearwood.info
On Sat, Sep 18, 2010 at 11:46 AM, Steven D'Aprano wrote:
> On Sun, 19 Sep 2010 12:16:47 am Fernando Karpinski wrote:
>> Hi, everyone. I need help when importing a file I created, with
>> the .py extension. I am trying to access its directory in DOS, and
>> after I do it, I type "import filename
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 to modify lists safely and
correc
On Sat, 18 Sep 2010 07:14:03 pm Roelof Wobben wrote:
> P=(Point)
This line does not do what you think it does. Brackets in Python are
used for two things, grouping and calling functions.
To call a function, or a class, you need to have the brackets *after*
the function:
P = Point() # what ab
On Sun, 19 Sep 2010 12:16:47 am Fernando Karpinski wrote:
>Hi, everyone. I need help when importing a file I created, with
> the .py extension. I am trying to access its directory in DOS, and
> after I do it, I type "import filename", but it is not working.
Define "not working".
My crystal ba
On Sat, Sep 18, 2010 at 10:44 AM, Bill Allen wrote:
>
>
> On Fri, Sep 17, 2010 at 3:38 AM, Alan Gauld wrote:
>
>>
>> For plotting pixels I would not use turtle graphics.
>> That would be a fairly complicated option I'd have thought.
>> A simple canvas would be easier.
>>
>> Alan G.
>>
>>
> Oh, I
On Fri, Sep 17, 2010 at 3:38 AM, Alan Gauld wrote:
>
> For plotting pixels I would not use turtle graphics.
> That would be a fairly complicated option I'd have thought.
> A simple canvas would be easier.
>
> Alan G.
>
>
Oh, I see! I did not realize that Tk had a canvas widget. That is nice. I
"Roelof Wobben" wrote
Create and print a Point object, and then use id to print the
object’s unique identifier. Translate the hexadecimal form into
decimal and
confirm that they match.
I initially had no idea what hexadecimal form the text is talking
about.
id returns a decimal form... T
"Alan Gauld" wrote
I ended up with this :
Version 3 :
for i,row in d[:].iteritems() : # BUG : TypeError: unhashable type
if len(row) < 2 :
del d[i]
You are getting too complicated.
You don't need the slice and you don't need iteritems.
You have a dictionary. When you iterate over
On Sat, Sep 18, 2010 at 10:16 AM, Fernando Karpinski
wrote:
>
>Hi, everyone. I need help when importing a file I created, with the .py
> extension. I am trying to access its directory in DOS, and after I do it, I
> type "import filename", but it is not working. I tried to do it by writing
> "i
Hi, everyone. I need help when importing a file I created, with the .py
extension. I am trying to access its directory in DOS, and after I do it, I
type "import filename", but it is not working. I tried to do it by writing
"import filename.py", but it didn't work either. I'm aware that after the
Hello,
I have this exercise :
Create and print a Point object, and then use id to print the
object’s unique identifier. Translate the hexadecimal form into decimal and
confirm that they match.
So I thought that this would solve it:
class Point:
def __init__(self, x=0, y=0):
self.x
M. 427 wrote:
> (I am very new to python)
> I built a dictionary d={} of lists similar to this :
>
> d = {
> 'a': ['apricot', 'apple'],
> 'b': ['beach', 'bear', 'bottle'],
> 'c': ['cold', 'cook', 'coleslaw'],
> 'd': ['deep'],
> 'e': ['expression', 'elephant']
> }
>
> Now i want to go through thi
"M. 427" <4...@free.fr> wrote
I ended up with this :
Version 3 :
for i,row in d[:].iteritems() : # BUG : TypeError: unhashable type
if len(row) < 2 :
del d[i]
You are getting too complicated.
You don't need the slice and you don't need iteritems.
You have a dictionary. When you ite
Thank you,
After reading the following documentations
http://docs.python.org/tutorial/datastructures.html#looping-techniques
http://docs.python.org/tutorial/controlflow.html#for-statements
I ended up with this :
Version 3 :
for i,row in d[:].iteritems() : # BUG : TypeError: unhashable type
if
27 matches
Mail list logo