[Tutor] Difference between 'yield' and 'print'

2007-01-16 Thread raghu raghu
Is there any difference between yield and print in python script?i have written a script based on fibonacci series where in i used yield and print in two different scripts: the script is given below: def fib(n): a,b = 0,1 while a<=n: print a a,b = b,a+b for x in fib(4): print

Re: [Tutor] dealing with 406 HTTP response (fwd)

2007-01-16 Thread Danny Yoo
> Danny - thanks! it works though I am not sure I fully understand what i > did :-) Hi Tsila, When you have time, you may want to take a closer look at how HTTP works. Here's one place you can look: http://www.jmarshall.com/easy/http/ If you are writing applications for HTTP, you should

[Tutor] mutability, __new__

2007-01-16 Thread Terry Carroll
[hijacking the "question about object oriented programming and inheritance using datetime module" thread here] On Tue, 16 Jan 2007, Kent Johnson wrote: > I think you are missing the line >datetime.date.__init__(self, year, month, day) > somewhere in here. Yeah; sloppy of me. > I am ver

Re: [Tutor] dealing with 406 HTTP response (fwd)

2007-01-16 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 17 Jan 2007 02:08:48 +0100 From: Tsila Hassine <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] dealing with 406 HTTP response Danny - thanks! it works though I am not sure I fully understand what i did :-) I am iverri

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Dick Moores
At 12:45 PM 1/16/2007, Kent Johnson wrote: >Dick Moores wrote: >>Thanks, Kent. So I go with working up "an algorithm for first >>converting n to an int (for >>example, multiplying the above n by 1000), converting to a string, >>putting the decimal point back in between indices 2 and 3, then using

Re: [Tutor] dealing with 406 HTTP response

2007-01-16 Thread Danny Yoo
On Tue, 16 Jan 2007, Tsila Hassine wrote: > has anybody dealt with a 406 reponse through a urllib.FancyURLopener > class ? I have a code that downloads images from websites and soemsites > respond with an 406 which I don't know how to handle Hi Tsila, Have you looked at the description of a

Re: [Tutor] Clustering?

2007-01-16 Thread Alan Gauld
"Carlos" <[EMAIL PROTECTED]> wrote >>> from cluster import * >>> data = [12,34,23,32,46,96,13] >>> cl = HierarchicalClustering(data, lambda x,y: abs(x-y)) >>> cl.getlevel(10) # get clusters of items closer than 10 [96, 46, [12, 13, 23, 34, 32]] > I would like to give it a try because I have

[Tutor] dealing with 406 HTTP response

2007-01-16 Thread Tsila Hassine
Dear pythoners, has anybody dealt with a 406 reponse through a urllib.FancyURLopener class ? I have a code that downloads images from websites and soemsites respond with an 406 which I don't know how to handle thanks! Tsila ___ Tutor maillist - Tuto

[Tutor] Subprocess popen problem depending on how I start program

2007-01-16 Thread pytutor . 20 . 247ob
Hi, I'm writing a program that downloads audio streams from the net, to do this I use mplayer and tcpdump, which I kick off as detached processes (if thats the correct terminology), I do it this way because i'm using pygtk and I dont want the program to wait for the processes to finish otherwise th

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Dick Moores
At 12:47 PM 1/16/2007, you wrote: >On Tue, 2007-01-16 at 12:28 -0800, Dick Moores wrote: > > So I go with working up "an algorithm for first > > converting n to an int (for > > example, multiplying the above n by 1000), converting to a string, > > putting the decimal point back in between indices 2

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Python
On Tue, 2007-01-16 at 12:28 -0800, Dick Moores wrote: > So I go with working up "an algorithm for first > converting n to an int (for > example, multiplying the above n by 1000), converting to a string, > putting the decimal point back in between indices 2 and 3, then using > that string as n (the

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Kent Johnson
Dick Moores wrote: > Thanks, Kent. So I go with working up "an algorithm for first > converting n to an int (for > example, multiplying the above n by 1000), converting to a string, > putting the decimal point back in between indices 2 and 3, then using > that string as n (thereby avoiding the use

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Terry Carroll
On Tue, 16 Jan 2007, Dick Moores wrote: > Here's a function I wrote some time ago, and just discovered that in > one important category of cases, long numbers with a decimal point, > it doesn't do what I intended. > > = > def numberRounding(n,

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Dick Moores
At 12:16 PM 1/16/2007, Kent Johnson wrote: >Dick Moores wrote: > > Here's a function I wrote some time ago, and just discovered that in > > one important category of cases, long numbers with a decimal point, > > it doesn't do what I intended. > > > >

Re: [Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Kent Johnson
Dick Moores wrote: > Here's a function I wrote some time ago, and just discovered that in > one important category of cases, long numbers with a decimal point, > it doesn't do what I intended. > > = > def numberRounding(n, significantDigits=4):

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-16 Thread Kent Johnson
Terry Carroll wrote: > An example is if you wanted to create a "birthdate" class, which was just > like a regular date, but also included the birthstone that corresponded to > the date. We could create a "birthdate" module that included a > "Birthdate" class: > > ### > > import da

[Tutor] How to convert a long decimal into a string?

2007-01-16 Thread Dick Moores
Here's a function I wrote some time ago, and just discovered that in one important category of cases, long numbers with a decimal point, it doesn't do what I intended. = def numberRounding(n, significantDigits=4): """ Rounds a n

Re: [Tutor] question about object oriented programming and inheritance using datetime module

2007-01-16 Thread Terry Carroll
On Mon, 15 Jan 2007, Kent Johnson wrote: > [EMAIL PROTECTED] wrote: > > > My class inherits from the date class, but I > > have to type 'from datetime import date' before I can initialize the > > class definition. Is there some way to avoid this ? > > No, and really there is no reason to wan

Re: [Tutor] Array indexing

2007-01-16 Thread Joe Abbey
On 1/16/07, Dave Kuhlman <[EMAIL PROTECTED]> wrote: On Tue, Jan 16, 2007 at 11:28:49AM -0500, Joe Abbey wrote: > Hello, > > I'm using Active Python v2.4.3.11 on a Windows XP machine. > > Probably more relevant is that I'm just learning Python, as in I've been > writing Python for less than 24 ho

Re: [Tutor] Clustering?

2007-01-16 Thread Carlos
Hallo , Andre thanks a lot for your help, seems to me like my script can work with your function. I found this searching the internet: cluster 1.1.1b2 python-cluster is a "simple" package that allows to create several groups (clusters) of objects from a list >>> from cluster import * >>> da

Re: [Tutor] Array indexing

2007-01-16 Thread Dave Kuhlman
On Tue, Jan 16, 2007 at 11:28:49AM -0500, Joe Abbey wrote: > Hello, > > I'm using Active Python v2.4.3.11 on a Windows XP machine. > > Probably more relevant is that I'm just learning Python, as in I've been > writing Python for less than 24 hours. > > While trying to implement a PE parser, I ra

Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Michael Lange
On Tue, 16 Jan 2007 09:56:27 + (GMT) ALAN GAULD <[EMAIL PROTECTED]> wrote: > > --- Asrarahmed Kadri <[EMAIL PROTECTED]> wrote: > > > Is there a method that redraws the toplevel windows that is > > holding the widgets > > Yes, you can issue an update() command to any widget. > Usually yo

Re: [Tutor] Array indexing

2007-01-16 Thread Danny Yoo
> While trying to implement a PE parser, I ran into the following problem: > > #** START CODE*** > data = file.read(128); > directoryTable = struct.unpack('', data); > i=0; > print "Export table 0x%08X + 0x%08x" % (directoryTable

[Tutor] Array indexing

2007-01-16 Thread Joe Abbey
Hello, I'm using Active Python v2.4.3.11 on a Windows XP machine. Probably more relevant is that I'm just learning Python, as in I've been writing Python for less than 24 hours. While trying to implement a PE parser, I ran into the following problem: #** START CODE*

Re: [Tutor] it is about definitions

2007-01-16 Thread Kent Johnson
Andreas Kostyrka wrote: > * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [070116 15:19]: >> is there a difference between: >> >> class foo: >> >> and >> >> class foo(): > This is a SyntaxError. In Python 2.5 it is allowed and creates an old-style class, the same as if the parentheses are omitted. Kent

Re: [Tutor] it is about definitions

2007-01-16 Thread Danny Yoo
On Tue, 16 Jan 2007, Andreas Kostyrka wrote: > * [EMAIL PROTECTED] <[EMAIL PROTECTED]> [070116 15:19]: >> >> is there a difference between: >> >> class foo: >> >> and >> >> class foo(): > This is a SyntaxError. Hi Andreas, We should ask Emilia why she's asking this question. This particular

Re: [Tutor] import and unittest

2007-01-16 Thread Duncan Gibson
> I wondered if it was possible to do something like this: > > src/ >-a_module/ >-sub_module/ > test/ >-a_module/ >-sub_module/ Why not really keep the test code with the main code? # module code here # if __name__ == '__main__': import unittest class TestModul

Re: [Tutor] Clustering?

2007-01-16 Thread Andre Engels
2007/1/16, Carlos <[EMAIL PROTECTED]>: Hello to everybody, I have a question that I think is a little related to clustering, I have a list of lists, like this: List = [[1,5],[6,8],[48,10],[99,56]] The list is composed by a large number of lists not just four, and each 'interior' list contains

Re: [Tutor] import and unittest

2007-01-16 Thread Kent Johnson
Thomas Coopman wrote: > Hi, > > the documentation of pyunit > say that it is good to place the unittest in a seperate module. > I wondered if it was possible to do something like this: > > src/ > -a_module/ > -sub_module/ > test/ > -a_module/ > -sub_module/ > > So the te

Re: [Tutor] python query

2007-01-16 Thread Kent Johnson
Alexander Kapshuk wrote: > Dear All, > > > > My name is Alexander Kapshuk. I’m interested in learning to program in > Python. I have very little programming experience. I’ve learnt some > basics of programming with Logo. > > I’ve downloaded Python 2.5 for Windows XP Professional. > > I woul

Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread ALAN GAULD
--- Asrarahmed Kadri <[EMAIL PROTECTED]> wrote: > Is there a method that redraws the toplevel windows that is > holding the widgets Yes, you can issue an update() command to any widget. Usually you don't need to as Tkinter figures out when things have changed and updates itself, but occasi

Re: [Tutor] python query

2007-01-16 Thread Mike Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Alexander Kapshuk > Sent: Tuesday, January 16, 2007 2:50 AM > To: tutor@python.org > Subject: Re: [Tutor] python query > > Dear All, > > > > My name is Alexander Kapshuk. I'm interested in learn

Re: [Tutor] it is about definitions

2007-01-16 Thread Andreas Kostyrka
* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [070116 15:19]: > > is there a difference between: > > class foo: > > and > > class foo(): This is a SyntaxError. > > or between these function definitions: > > def bar(): > > and > > def bar: This too. Andreas ___

[Tutor] Clustering?

2007-01-16 Thread Carlos
Hello to everybody, I have a question that I think is a little related to clustering, I have a list of lists, like this: List = [[1,5],[6,8],[48,10],[99,56]] The list is composed by a large number of lists not just four, and each 'interior' list contains two numbers that are the location of an

[Tutor] it is about definitions

2007-01-16 Thread emilia12
is there a difference between: class foo: and class foo(): or between these function definitions: def bar(): and def bar: ? thanks in advance E. - Станете част от Европейското On-line семейство! Регистрирайте .EU домейн на изключителна цена от 15,90 лв.! w

Re: [Tutor] import and unittest

2007-01-16 Thread thomas coopman
On Tue, 16 Jan 2007 10:06:37 - "Alan Gauld" <[EMAIL PROTECTED]> wrote: > > "Thomas Coopman" <[EMAIL PROTECTED]> wrote > . > > I wondered if it was possible to do something like this: > > > > src/ > >-a_module/ > >-sub_module/ > > test/ > >-a_module/ > >-sub_module/ > >

Re: [Tutor] import and unittest

2007-01-16 Thread Alan Gauld
"Thomas Coopman" <[EMAIL PROTECTED]> wrote . > I wondered if it was possible to do something like this: > > src/ >-a_module/ >-sub_module/ > test/ >-a_module/ >-sub_module/ > I don;t see any reason why not although its slightly more work. Personally I tend to keep the test

Re: [Tutor] python query

2007-01-16 Thread Alexander Kapshuk
Dear All, My name is Alexander Kapshuk. I'm interested in learning to program in Python. I have very little programming experience. I've learnt some basics of programming with Logo. I've downloaded Python 2.5 for Windows XP Professional. I would appreciate any advice on what to do next

Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Alan Gauld
"Michael Lange" <[EMAIL PROTECTED]> wrote > If you only want to be able to resize the graph elements > into half and double size it is probably easiest to use the > Canvas.scale() method for this, like > from Tkinter import * c=Canvas() c.pack(fill='both', expand=1) r = c.

Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Michael Lange
On Tue, 16 Jan 2007 00:33:20 - "Alan Gauld" <[EMAIL PROTECTED]> wrote: > > "Asrarahmed Kadri" <[EMAIL PROTECTED]> wrote > > > I want to provide with a functionality of changing the font size, in > > this > > case the width of the lines. > Its not really the font size. fonts only apply to te

Re: [Tutor] Change the font size of the lines and rectangle on aTkinter Canvas

2007-01-16 Thread Asrarahmed Kadri
I want to change the coordinates because I was under the wrong impression; when I gave some thought then only I realised that the COORDINATES need to be changed in order to increase the dimensions of the GRAPH and in turn the entire frame, canvas, and the toplevel window that is holding the frame

[Tutor] import and unittest

2007-01-16 Thread Thomas Coopman
Hi, the documentation of pyunit say that it is good to place the unittest in a seperate module. I wondered if it was possible to do something like this: src/ -a_module/ -sub_module/ test/ -a_module/ -sub_module/ So the test are in a complete different directory than the code