Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-04 Thread Dave Angel
On 10/03/2012 11:11 PM, boB Stepp wrote: > Thanks to all who responded. > . > What happens if str() or repr() is not supported by a particular > object? Is an exception thrown, an empty string returned or something > else I am not imagining? Let's try it and see: >>> class A:pass ... >>> a = A()

Re: [Tutor] modifying lists of lists

2012-10-04 Thread Dave Angel
On 10/03/2012 11:52 PM, Ed Owens wrote: > You are fundamentally correct about my confusion, though I'm trying to work > with tuples as the lowest level, which may not be relevant here. The tuples are an example of an immutable object. An immutable object (which contains only immutable objects) may

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-04 Thread Steven D'Aprano
On 04/10/12 13:39, boB Stepp wrote: But not always. For example: py> from decimal import Decimal as D py> x = D("1.23") py> print(str(x)) 1.23 py> print(repr(x)) Decimal('1.23') These contrasting examples are very illuminating. So in print(str(x)) the object, D("1.23"), is being converted

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-04 Thread Steven D'Aprano
On 04/10/12 13:11, boB Stepp wrote: What happens if str() or repr() is not supported by a particular object? Is an exception thrown, an empty string returned or something else I am not imagining? I don't think that is possible, at least not by accident or neglect. In Python 3, everything inher

[Tutor] MAXIMUM LOOP LOGIC

2012-10-04 Thread medusa
Hello i got stuck with the last bit of my programming practice. Can somebody help me? Write a program to read through a mail log, and figure out who had the most messages in the file. The program looks for “From” lines and takes the second parameter on those lines as the person who sent the m

[Tutor] Newbie help with .pyc

2012-10-04 Thread tfahey1
Hey everyone, I am a Maya user, so I only come into contact with Python scripting on a surface level, but I downloaded a python script from a CG website that I would like to check out but I am getting an error when it is run. The only file included was a .pyc file. I'm wondering if there should al

Re: [Tutor] modifying lists of lists

2012-10-04 Thread eryksun
On Thu, Oct 4, 2012 at 7:21 AM, Dave Angel wrote: > > This is how eryksun knew that a shallow copy was good enough. And for a > shallow copy, using the slice notation is perfect. > J42 = [H[:1]] print J42[0] > [(1, 2)] print id(J42[0]) > 13964568 > > (Note that my shallow copy is n

Re: [Tutor] Why difference between printing string & typing its object reference at the prompt?

2012-10-04 Thread eryksun
On Wed, Oct 3, 2012 at 11:11 PM, boB Stepp wrote: > > What happens if str() or repr() is not supported by a particular > object? Is an exception thrown, an empty string returned or something > else I am not imagining? The __str__ method inherited from "object" calls __repr__. For a class, __repr

Re: [Tutor] Newbie help with .pyc

2012-10-04 Thread Steven D'Aprano
On 05/10/12 01:21, tfahey1 wrote: Hey everyone, I am a Maya user, so I only come into contact with Python scripting on a surface level, but I downloaded a python script from a CG website that I would like to check out but I am getting an error when it is run. Would you like us to guess what e

Re: [Tutor] need help new to python

2012-10-04 Thread Joel Goldstick
On Wed, Oct 3, 2012 at 11:38 AM, wrote: > Hi im new to python and im stuck on my homework. I have to define the > functions appropriately in the python file so they all test and work but im > not even sure where to begin or what to I could really use some help. Ive > attached the file. > > Thank

Re: [Tutor] [Tkinter-discuss] displaying an image

2012-10-04 Thread Matthew Ngaha
> You need to install PIL to use the tutorial you are doing. > > http://www.pythonware.com/products/pil/ the site says " The current free version is PIL 1.1.7. This release supports Python 1.5.2 and newer, including 2.5 and 2.6. A version for 3.X will be released later. " i have python 3. all the

[Tutor] rounding up to the nearest multiple of 8

2012-10-04 Thread Albert-Jan Roskam
Hi,   The function below works, but it's such a kludge! Is there a way to make this more elegant? As said in the docstring, I want to round up a given integer to the nearest multiple of 8. I was thinking of something like math.ceil.   def _getPadding(charlen):     """ Helper function to replace n

Re: [Tutor] Tutor Digest, Vol 104, Issue 24

2012-10-04 Thread Aceway
your last for iterater maybe should like this: for key,values in messages: if max is None or values>max: sender=key max=values 在 2012-10-5,1:13,tutor-requ...@python.org 写道: > Send Tutor mailing list submissions to >tutor@python.org > > To subscribe or unsubscribe via t

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-04 Thread Joel Goldstick
On Thu, Oct 4, 2012 at 3:47 PM, Albert-Jan Roskam wrote: > Hi, > > The function below works, but it's such a kludge! Is there a way to make this > more elegant? > As said in the docstring, I want to round up a given integer to the nearest > multiple of 8. I was thinking > of something like math.

Re: [Tutor] MAXIMUM LOOP LOGIC

2012-10-04 Thread eryksun
On Wed, Oct 3, 2012 at 12:11 AM, medusa wrote: > > After all the data has been read the program looks through the dictionary > using a maximum loop > > Instead of printing off a number beside the email, i got another email and i > dont know how to fix it. >

Re: [Tutor] Hello Can someone looked at my problem? stuck

2012-10-04 Thread Walter Prins
On 3 October 2012 04:39, Palice Fan wrote: > Hello > i got stuck with the last bit of my programming practice. > Can somebody help me? > Write a program to read through a mail log, and figure out who had the most > messages in the file. The program looks for “From” lines and takes the > second pa

Re: [Tutor] MAXIMUM LOOP LOGIC

2012-10-04 Thread Brian van den Broek
On 4 Oct 2012 13:22, "medusa" wrote: > > Hello > > i got stuck with the last bit of my programming practice. > Instead of printing off a number beside the email, i got another email and i > dont know how to fix it. > Hi, Is your code

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-04 Thread eryksun
On Thu, Oct 4, 2012 at 4:04 PM, Joel Goldstick wrote: > my_string = "123" pad = 8 - len(my_string) % 8 my_string = my_string + " " * pad my_string > '123 ' If len(my_string) is already a multiple of 8, the above sets pad to 8: >>> s = "12345678" >>> pad = 8 - len(

[Tutor] I Need Help With Using Tkinter/Console/Creating GUIs

2012-10-04 Thread tayo rotimi
Hi, I recently started learning as a python programming 'absolute beginner'. I have Python 3.2 installed on my laptop, and I have learned to a point where I need to create GUIs. I understand from the text book I am reading that all I need to have access to the Tkinter toolkits in a window-OS is

Re: [Tutor] I Need Help With Using Tkinter/Console/Creating GUIs

2012-10-04 Thread Steven D'Aprano
On 05/10/12 07:30, tayo rotimi wrote: Hi, I recently started learning as a python programming 'absolute beginner'. I have Python 3.2 installed on my laptop, and I have learned to a point where I need to create GUIs. I understand from the text book I am reading that all I need to have access t

Re: [Tutor] [Tkinter-discuss] displaying an image

2012-10-04 Thread Oscar Benjamin
On 4 October 2012 20:31, Matthew Ngaha wrote: >> You need to install PIL to use the tutorial you are doing. >> >> http://www.pythonware.com/products/pil/ > > the site says > " > The current free version is PIL 1.1.7. This release supports Python > 1.5.2 and newer, including 2.5 and 2.6. A version

Re: [Tutor] Newbie help with .pyc

2012-10-04 Thread ken brockman
I wonder if they might be a way for some on this forum to dispense advice and help others without the totally snide and obnoxious attitude? if it is so painfully annoying for you to deal with, why subject yourself to it? I suspect it is the sheer joy of showing others how bright you are and jus

Re: [Tutor] Newbie help with .pyc

2012-10-04 Thread Ashfaq
Hey Ken, Steve has just made some innocent fun. He is eager to help the guy. Please don't be so harsh. Sincerely Ashfaq ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] [Tkinter-discuss] displaying an image

2012-10-04 Thread eryksun
On Thu, Oct 4, 2012 at 3:31 PM, Matthew Ngaha wrote: >> You need to install PIL to use the tutorial you are doing. >> >> http://www.pythonware.com/products/pil/ > > the site says > " > The current free version is PIL 1.1.7. This release supports Python > 1.5.2 and newer, including 2.5 and 2.6. A v

Re: [Tutor] [Tkinter-discuss] displaying an image

2012-10-04 Thread eryksun
On Fri, Oct 5, 2012 at 12:39 AM, eryksun wrote: > > # apt-get install build-essential python3-dev tk8.5-dev \ > libjpeg8-dev liblcms1-dev libfreetype6-dev I forgot zlib: # apt-get install build-essential python3-dev tk8.5-dev \ libjpeg8-dev liblcms1-dev libfreetype6-dev z

Re: [Tutor] rounding up to the nearest multiple of 8

2012-10-04 Thread Steven D'Aprano
On Thu, Oct 04, 2012 at 05:26:13PM -0400, eryksun wrote: > On Thu, Oct 4, 2012 at 4:04 PM, Joel Goldstick > wrote: > > > my_string = "123" > pad = 8 - len(my_string) % 8 > my_string = my_string + " " * pad > my_string > > '123 ' > > If len(my_string) is already a multiple