Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
Thanks for the links Steven! Regards Karim On 01/18/2011 10:49 PM, Steven D'Aprano wrote: Karim wrote: Same thing I don't know what to do with this object weakref :-[ as I don't know its meaning. That was my true question in fact; http://mindtrove.info/python-weak-references/ http://www.d

Re: [Tutor] Problems passing a parameter in a GUI

2011-01-18 Thread Dave Angel
On 01/-10/-28163 02:59 PM, David Holland wrote: Hi All, I hope this makes sense I am trying to write a GUI where you click on a button and each time you click on the button it shows in the entry text how many times you have clicked. However when I changed an earlier version of the code to pass

Re: [Tutor] Problems passing a parameter in a GUI

2011-01-18 Thread James Reynolds
I took another look at what you are trying to do, and if I wanted to count the number of times the button was pressed in the same way you are trying I would do something like this instead: from Tkinter import * class Application(Frame): """GUI App""" def __init__(self, master):

Re: [Tutor] Problems passing a parameter in a GUI

2011-01-18 Thread James Reynolds
You have other issues at play here, but to answer your question from below: You are calling the method "reveal" prior to creating the global object "secret_text" You can try moving: x= self.submit_bttn=Button(self, text="Submit", command=self.reveal(x)) below self.secret_text = "" You w

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Steven D'Aprano
Karim wrote: Same thing I don't know what to do with this object weakref :-[ as I don't know its meaning. That was my true question in fact; http://mindtrove.info/python-weak-references/ http://www.doughellmann.com/PyMOTW-ja/weakref/index.html -- Steven _

Re: [Tutor] Why super does not work !

2011-01-18 Thread Steven D'Aprano
Steven D'Aprano wrote: Alan G wrote: Or use a language where MI is the normal and idiomatic way to do things because the language assumes it and so it just works. There are very few such languages but Lisp is one :-) I'm sorry, but I don't believe you :/ That's a bit harsh... Let me rephra

[Tutor] Problems passing a parameter in a GUI

2011-01-18 Thread David Holland
Hi All, I hope this makes sense I am trying to write a GUI where you click on a button and each time you click on the button it shows in the entry text how many times you have clicked.  However when I changed an earlier version of the code to pass a parameter it errors. This works :- from Tkin

Re: [Tutor] OOP question

2011-01-18 Thread Steven D'Aprano
Ben Ganzfried wrote: Hey guys, I'm trying to get a version of Roulette working and I had a quick question. There's a quick answer and long answer. The quick answer is, you have to refer to self.odds, not just odds. The long answer is below: Here is my code: [...] Now whenever I try to ca

Re: [Tutor] Why super does not work !

2011-01-18 Thread Karim
On 01/17/2011 11:36 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: Hello, I implemented Observer DP on a listbox (Tkinter) as follows and I don't understand why super() is not working and Observable.__init__(self) is working, cf below: class ListObservable(Listbox, Observable)

[Tutor] Trying to import matplotlib : ImportError: No module named dateutil.rrule

2011-01-18 Thread Thierry Platini
Hello everyone, I am completely new in learning python and have a little background in programing. My problem occurs with the importation of matplotlib. I did download the module from http://sourceforge.net/projects/matplotlib/ . and I believe successfully install the corresping .egg file

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
On 01/18/2011 03:38 PM, bob gailer wrote: def __getattr__(self, name): return self.enums[name] Note this does not handle the upper/lower case issue. Thanks for the trick! works perfect! Regards Karim ___ Tutor maillist - Tutor@python

Re: [Tutor] OOP question

2011-01-18 Thread Nick Stinemates
Updated inline. Check the updated definiton of winAmount. Nick On Tue, Jan 18, 2011 at 9:25 AM, Ben Ganzfried wrote: > Hey guys, > > I'm trying to get a version of Roulette working and I had a quick > question. Here is my code: > > class Outcome: > > def __init__(self, name, odds): >

[Tutor] OOP question

2011-01-18 Thread Ben Ganzfried
Hey guys, I'm trying to get a version of Roulette working and I had a quick question. Here is my code: class Outcome: def __init__(self, name, odds): self.name = name self.odds = odds def winAmount(self, amount): return odds*amount def __eq__(self, other):

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread bob gailer
On 1/18/2011 9:34 AM, Karim wrote: Hello Bob, Thanks for this better and simple approach! To be perfect I would like to be able to do. >>> type = CategoryType() >>> type.TRANSISTOR Add to the class: def __getattr__(self, name): return self.enums[name] Note this does not handle t

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Steven D'Aprano
Tom Lin wrote: > But one precondition is not to use int(string, base). How would you > implement the conversion? It's not hard. You have two choices: each character of the string represents a bit, and should be either a "0" or a "1" (anything else is an error). In which case its numeric value is

Re: [Tutor] Why super does not work !

2011-01-18 Thread Steven D'Aprano
Alan G wrote: Steven D'Aprano pearwood.info> writes: fact that multiple inheritance itself is often the wrong thing to use, and even when it is right, it is often tricky to get it right. To put it another way: don't use multiple inheritance unless you have to, there are better ways, such as

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
于 2011-1-18 21:08, Christian Witts 写道: > On 18/01/2011 14:45, Tom Lin wrote: >> Hi guys, >> >> Please help me with this: >> Convert an IP address from binary string to decimal format.There are >> some preconditions: >> 1.IP address is in the form of '10010001100'.32 bits with no dot. >> 2.i

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
Hello Bob, Thanks for this better and simple approach! To be perfect I would like to be able to do. >>> type = CategoryType() >>> type.TRANSISTOR 0 I will use your enums declaration and the range part to use as keys for enums. And I will raise a KeyError in toString() to handle invalid littera

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread bob gailer
On 1/18/2011 8:08 AM, Karim wrote: I know this is ugly but until now it is the only way (with this side effect) I found to declare Enums class that I _understand_: *class CategoryType(object): """Implements the enumeration and prevent associated newly created instances to redefine enu

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Steven D'Aprano
Tom Lin wrote: > Hi guys, > > Please help me with this: We don't do homework. We'll give you some hints but not do the work. > Convert an IP address from binary string to decimal format.There are > some preconditions: > 1.IP address is in the form of '10010001100'.32 bits with no dot. >

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread bob gailer
On 1/18/2011 8:08 AM, Christian Witts wrote: On 18/01/2011 14:45, Tom Lin wrote: Hi guys, Please help me with this: Convert an IP address from binary string to decimal format.There are some preconditions: 1.IP address is in the form of '10010001100'.32 bits with no dot. 2.int(string, ba

Re: [Tutor] How to plot graph?

2011-01-18 Thread bob gailer
Thank you for seeking help. Next time please start a new thread rather than "hijacking" an existing one. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pytho

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
Hello Steven, (1) slots = [] doesn't do anything special. You have misspelled __slots__. Yes sorry my mistake :-[ (2) Classes don't become read only just because you add __slots__ to them. All you prevent is adding extra attributes, and why would you wish to do that? I know this is ugly

Re: [Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Christian Witts
On 18/01/2011 14:45, Tom Lin wrote: > Hi guys, > > Please help me with this: > Convert an IP address from binary string to decimal format.There are > some preconditions: > 1.IP address is in the form of '10010001100'.32 bits with no dot. > 2.int(string, base) is not allowed, You have to imp

[Tutor] Convert an IP address from binary to decimal

2011-01-18 Thread Tom Lin
Hi guys, Please help me with this: Convert an IP address from binary string to decimal format.There are some preconditions: 1.IP address is in the form of '10010001100'.32 bits with no dot. 2.int(string, base) is not allowed, You have to implement the conversion . 3.Performance should be c

Re: [Tutor] Why super does not work !

2011-01-18 Thread Karim
By the way Tkinter does not support super() seems to be an 'old style' class, this is perhaps the raison why MI does not work in this context: *Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>

Re: [Tutor] How to plot graph?

2011-01-18 Thread Wayne Werner
On Tue, Jan 18, 2011 at 4:30 AM, tee chwee liong wrote: > hi all, > > i'm new to python and this is advanced for me. is there a way to plot data > with python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis > as attached or below. > currently i'm using Python2.5 and Win XP. thank

Re: [Tutor] Tutor Digest, Vol 83, Issue 74

2011-01-18 Thread Art Cla Media
/tutor -- Message: 4 Date: Tue, 18 Jan 2011 07:35:30 +0100 From: Izz ad-Din Ruhulessin To: Hugo Arts Cc: tutor@python.org Subject: Re: [Tutor] Exactly duplicating strftime behavior? Message-ID:     Content-Type: text/plain; charset="iso-8859-1" Hi Hugo, Prob

[Tutor] How to plot graph?

2011-01-18 Thread tee chwee liong
hi all, i'm new to python and this is advanced for me. is there a way to plot data with python? i want to plot EyVt, EyHt on the Y-axis and Lane on the X-axis as attached or below. currently i'm using Python2.5 and Win XP. thanks a lot. Eg: Platform: PC Tempt : 25 TAP0 :0 TAP1 :1 +