Re: [Tutor] Class Inheritance, Beat it into the Ground

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 03:41:04 pm David Hutto wrote: > In previous post I asked about turtle module importing from tkinter. > But what I don't understand is why does Tkinter default it's casnvas > to ScrolledCanvas in turtle.py, and then as a 'metaclass' for > ScrolledCanvas in turtle it calls TK.Fr

[Tutor] Class Inheritance, Beat it into the Ground

2010-04-23 Thread David Hutto
In previous post I asked about turtle module importing from tkinter. But what I don't understand is why does Tkinter default it's casnvas to ScrolledCanvas in turtle.py, and then as a 'metaclass' for ScrolledCanvas in turtle it calls TK.Frame, which could have been set as a default within Tkinter

[Tutor] About property() - For Marco Rompré

2010-04-23 Thread Ricardo Aráoz
Hi Marco (and everybody), in another thread you showed your code and made extensive use of property(). Wrongful use I might say. Let's see an example: >>> class C(object): ... def __init__(self): self._x = None ... def getx(self): return self._x - 10 ... def setx(self, value): self.

[Tutor] NLTK needs YAML?

2010-04-23 Thread Michael Scharf
Dear Friends, I'm new to the list, and new to Python. The last time I've tried anything like the below was 20 years ago on a NeXT machine, and I had no clue what I was doing then, either. I've gotten IDLE up and have done some hello worlding. I am now trying to get the NLTK working on my new iM

Re: [Tutor] Hi everybody stuck on some error need help please thank you!!

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 01:33:46 pm Marco Rompré wrote: > I tried to enter model = Modele (nom_fichier) but it still does not > work. What does "still does not work" mean? Please copy and paste the error you get. > And for the list I don't understand very well, Open an interactive session and

Re: [Tutor] Hi everybody stuck on some error need help please thank you!!

2010-04-23 Thread Marco Rompré
I tried to enter model = Modele (nom_fichier) but it still does not work. And for the list I don't understand very well, Do you know where I can pay someone to help with my programming. Because I feel to annoy tutors with my basic stuff On Fri, Apr 23, 2010 at 11:22 PM, Steven D'Aprano wrote: > O

Re: [Tutor] Hi everybody stuck on some error need help please thank you!!

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 01:07:11 pm Marco Rompré wrote: > Here's my code: [...] > class Modele: > """ > La definition d'un modele avec les magasins. > """ > def __init__(self, nom_fichier, magasins =[]): > self.nom_fichier = nom_fichier > self.magasins = magasins [...]

Re: [Tutor] self.attribute and import attribute

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 12:27:12 pm Joson wrote: > Hi all, > I have a problem about variables efficiency. 99% of the time, you waste more of your time than you save by worrying about tiny efficiencies. Saving 1 minute in a program that runs for 3 minutes is worthwhile. Saving 0.0002 seconds in a pro

[Tutor] Hi everybody stuck on some error need help please thank you!!

2010-04-23 Thread Marco Rompré
Hi everybody, I would appreciate your help on this one In this program I want to create 2 concepts each with 2 or 3 properties My first concept is magasin(shop in french) and my shop has 3 attributes: nom(name in french), items and ville (city in french) the second one is items and its 2 attributes

[Tutor] self.attribute and import attribute

2010-04-23 Thread Joson
Hi all, I have a problem about variables efficiency. As below, I import f from config.py, Then f is appended to app1.py global variables. In class App, there're two ways to use this variable. One is "self.file =f", then use self.file; the other is using "f" directory. Which way is high efficient?

Re: [Tutor] Binary search question

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 10:37:15 am Steven D'Aprano wrote: > For the record, here's some timing benchmarks to see how badly it > turned out: [...] > 0.0346097946167 > 0.461233854294 > 3.04955101013 > 5.70547604561 > > For comparison, here's the timing on a plain binary search: Oops, I hit send too soo

Re: [Tutor] Binary search question

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 09:41:05 am Alan Gauld wrote: > "Emile van Sebille" wrote > > >> For completeness sake, on a 1 item list, using the in operator > >> takes *in the worst case* around 7 seconds. > > > > Well on my system checking for the last element of a 100k item list > > returns true almo

Re: [Tutor] Would you please help me understand my error

2010-04-23 Thread Marco Rompré
Bien, >for starters please get rid of all those set_ methods. They are > doing nothing, it's not pythonic. Just assign the value straight away. > e.g.: from """ item01.set_prix("999.99") """ to """ item01.prix = "999.99" """ > Our teacher showed us this method and in our exercise we had

Re: [Tutor] Class Inheritance

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 01:22:54 am David Hutto wrote: > I'm new, I touched the Holy lib, and > didn't check to reset the original Tkinter directory before posting. > Won't happen again. I'm sorry we got off on the wrong foot, you caught me at a time when I was frustrated about other things, and afte

Re: [Tutor] Binary search question

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 09:11:21 am Robert Berman wrote: > Wow. I feel I have just been b…h slapped across the face. There's no need to be so sensitive. > I think > Hugo’s test results pretty much confirmed ‘in’ is not the way to go If that is the *only* thing you have learned from this email threa

Re: [Tutor] smtplib help required

2010-04-23 Thread James Chapman
D'Oh! Of course!  I feel like a right pillock now. Cheers for that though. -- James At Saturday, 24-04-2010 on 0:39 Jerry Hill wrote: On Fri, Apr 23, 2010 at 6:41 PM, James Chapman wrote: > Hi there gurus and everyone else. This is my first post to this group, and > I'm turning here because I

Re: [Tutor] smtplib help required

2010-04-23 Thread Alan Gauld
"James Chapman" wrote import smtplib and when I run it, I get this: import email.utils ImportError: No module named utils And I can also confirm that email.utils exists Definitely looks like a fault in the install/configure setup. Is there an __init__.py file in the emails folder? B

Re: [Tutor] Binary search question

2010-04-23 Thread Alan Gauld
"Emile van Sebille" wrote For completeness sake, on a 1 item list, using the in operator takes *in the worst case* around 7 seconds. Well on my system checking for the last element of a 100k item list returns true almost upon hitting the enter key. Surely 7 seconds for a list 1/10th the

Re: [Tutor] smtplib help required

2010-04-23 Thread Jerry Hill
On Fri, Apr 23, 2010 at 6:41 PM, James Chapman wrote: > Hi there gurus and everyone else. This is my first post to this group, and > I'm turning here because I'm stumped and search engines are not helping. > I've used smtplib for a few things already and while wanting to use it again > today, I'm

Re: [Tutor] Binary search question

2010-04-23 Thread Alan Gauld
"Robert Berman" wrote But, even though my years of experience using Python is less than 4 I would be reluctant to use 'in' just based on what I have been reading from those who took the time to answer my post. Just my $0.02 worth. It depends, if you are transmitting the data across a slow ne

Re: [Tutor] Binary search question

2010-04-23 Thread Steven D'Aprano
On Sat, 24 Apr 2010 07:21:13 am Alan Gauld wrote: > "Emile van Sebille" wrote > > > It's expensive enough that for a list this size I'd convert it to a > > dict and use in on that. eg, > > > > a = range(10) > > d = dict(zip(a,a)) > > Surely that would depend on how often you do the search? >

Re: [Tutor] Binary search question

2010-04-23 Thread Robert Berman
From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor-bounces+bermanrl=cfl.rr@python.org] On Behalf Of Ricardo Aráoz Sent: Friday, April 23, 2010 6:33 PM To: Hugo Arts Cc: tutor@python.org; Emile van Sebille Subject: Re: [Tutor] Binary search question Hugo Arts wrote: On Fri, Apr 2

Re: [Tutor] Would you please help me understand my error

2010-04-23 Thread Ricardo Aráoz
Marco Rompré wrote: > Its supposed to be a object magasin (shop in french) with some golf > items in it > > > class Magasin: > """ > Le concept magasin pour la gestion d'inventaire des items de golf. > """ > def __init__(self, nom ="", items =[] ): > self.nom = nom >

Re: [Tutor] Binary search question

2010-04-23 Thread Robert Berman
> -Original Message- > From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor- > bounces+bermanrl=cfl.rr@python.org] On Behalf Of Hugo Arts > Sent: Friday, April 23, 2010 5:55 PM > To: Emile van Sebille > Cc: tutor@python.org > Subject: Re: [Tutor] Binary search question > >

[Tutor] smtplib help required

2010-04-23 Thread James Chapman
Hi there gurus and everyone else. This is my first post to this group, and I'm turning here because I'm stumped and search engines are not helping. I've used smtplib for a few things already and while wanting to use it again today, I'm having weird things happen. Basically, my code looks like thi

Re: [Tutor] Binary search question

2010-04-23 Thread Emile van Sebille
On 4/23/2010 2:55 PM Hugo Arts said... For completeness sake, on a 1 item list, using the in operator takes *in the worst case* around 7 seconds. :) Well on my system checking for the last element of a 100k item list returns true almost upon hitting the enter key. Surely 7 seconds for a

Re: [Tutor] Binary search question

2010-04-23 Thread Ricardo Aráoz
Hugo Arts wrote: > On Fri, Apr 23, 2010 at 11:33 PM, Emile van Sebille wrote: > >> On 4/23/2010 2:21 PM Alan Gauld said... >> >>> "Emile van Sebille" wrote >>> It's expensive enough that for a list this size I'd convert it to a dict and use in on that. eg, a = r

[Tutor] Would you please help me understand my error

2010-04-23 Thread Marco Rompré
Its supposed to be a object magasin (shop in french) with some golf items in it class Magasin: """ Le concept magasin pour la gestion d'inventaire des items de golf. """ def __init__(self, nom ="", items =[] ): self.nom = nom self.items = items def set_nom(se

Re: [Tutor] Binary search question

2010-04-23 Thread Hugo Arts
On Fri, Apr 23, 2010 at 11:33 PM, Emile van Sebille wrote: > On 4/23/2010 2:21 PM Alan Gauld said... >> >> "Emile van Sebille" wrote >>> >>> It's expensive enough that for a list this size I'd convert it to a >>> dict and use in on that. eg, >>> >>> a = range(10) >>> d = dict(zip(a,a)) >>> >>

Re: [Tutor] Binary search question

2010-04-23 Thread Emile van Sebille
On 4/23/2010 2:21 PM Alan Gauld said... "Emile van Sebille" wrote It's expensive enough that for a list this size I'd convert it to a dict and use in on that. eg, a = range(10) d = dict(zip(a,a)) Surely that would depend on how often you do the search? If its a one off occurence I'd ex

Re: [Tutor] Binary search question

2010-04-23 Thread Alan Gauld
"Emile van Sebille" wrote It's expensive enough that for a list this size I'd convert it to a dict and use in on that. eg, a = range(10) d = dict(zip(a,a)) Surely that would depend on how often you do the search? If its a one off occurence I'd expect the overhead of zipping and co

Re: [Tutor] Binary search question

2010-04-23 Thread Alan Gauld
"Hugo Arts" wrote A binary search requires data to be sorted, but works in O(log n), so It will always be faster than a naive linear search like the in operator performs. Being picky but 'in' could be faster if the item searched for happens to be very near the front of the list. "Always" is

Re: [Tutor] Binary search question

2010-04-23 Thread Robert Berman
Thank you all for your ideas and suggestions. The detailed explanations were most useful. Robert Berman What you don't see with your eyes, don't invent with your mouth. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscript

Re: [Tutor] Binary search question

2010-04-23 Thread Hugo Arts
On Fri, Apr 23, 2010 at 5:29 PM, Emile van Sebille wrote: > > > It's expensive enough that for a list this size I'd convert it to a dict and > use in on that.  eg, > > a = range(10) > d = dict(zip(a,a)) > > 5 in d > you will want to nuance that statement just a little. If you're going to

Re: [Tutor] Binary search question

2010-04-23 Thread Emile van Sebille
On 4/23/2010 7:05 AM Robert Berman said... Hi, Given a list, list1 having 100,000 non repeating, sorted integers , which of the following methods is fastest to find an item fully understanding the item may or may not be in the list: The binary search method which is the standard search for such

Re: [Tutor] Binary search question

2010-04-23 Thread Hugo Arts
On Fri, Apr 23, 2010 at 4:05 PM, Robert Berman wrote: > Hi, > > Given a list, list1 having 100,000 non repeating, sorted integers ,  which of > the following methods is fastest to find an item fully understanding the item > may or may not be in the list: The binary search method which is the stand

Re: [Tutor] Binary search question

2010-04-23 Thread Christian Witts
Robert Berman wrote: Hi, Given a list, list1 having 100,000 non repeating, sorted integers , which of the following methods is fastest to find an item fully understanding the item may or may not be in the list: The binary search method which is the standard search for such a small sample size,

[Tutor] Binary search question

2010-04-23 Thread Robert Berman
Hi, Given a list, list1 having 100,000 non repeating, sorted integers , which of the following methods is fastest to find an item fully understanding the item may or may not be in the list: The binary search method which is the standard search for such a small sample size, or the more python type

Re: [Tutor] Class Inheritance

2010-04-23 Thread Steven D'Aprano
On Fri, 23 Apr 2010 04:54:11 pm David Hutto wrote: [...] > > Something is screwy there. I believe you have broken your > > installation by making changes to files without having any > > understanding of what you are doing. > > My original post was incorrect: the first error should be: > > C:\Users\

Re: [Tutor] sys.path and the path order

2010-04-23 Thread Dave Angel
Garry Willgoose wrote: My question is so simple I'm surprised I can't find an answer somewhere. I'm interested if I can rely on the order of the directories in the sys.path list. When I'm running a file from the comand line like python tellusim.py The string in entry sys.path[0] appears to b

Re: [Tutor] Class Inheritance

2010-04-23 Thread Alan Gauld
"David Hutto" wrote While experimenting with Tkinter(python2.6), when from Tkinter import* is used I came across the following error: File "C:\Python26\lib\lib-tk\Tkinter.py", line 44, in from turtle import * Huh? Why is Tkinter.py importing from turtle? It doesn't in my Pyt