Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
Sorry, sloppy cutting and pasting. Should be: Referring to the original post: > > > >>> dir(A) > > ['__doc__', '__module__'] > > >>> dir(B) > > ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', > > '__hash__', '__init__', '__module__', '__new__', '__reduce__', > > '__reduce_

Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
Referring to the original post: > >>> dir(B) > ['__doc__', '__module__'] > >>> dir(B) > ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', > '__hash__', '__init__', '__module__', '__new__', '__reduce__', > '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__'] >

Re: [Tutor] Memory consumption question

2007-11-15 Thread Kent Johnson
OK, the analogy is cute, but I really don't know what it means in Python. Can you give an example? What are the parts of an old-style class that have to be 'ordered' separately? How do you 'order' them concisely with a new-style class? Thanks, Kent Marc Tompkins wrote: > I thought of an analog

Re: [Tutor] Memory consumption question

2007-11-15 Thread Eric Brunson
I'm sorry, but a Reuben with no 'kraut is just a corned beef sandwich. :-) Marc Tompkins wrote: > And here's another reason to use new-style: I forgot the sauerkraut! > Oh, the horror! > > On Nov 15, 2007 1:42 PM, Marc Tompkins <[EMAIL PROTECTED] > > wrote: > >

Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
And here's another reason to use new-style: I forgot the sauerkraut! Oh, the horror! On Nov 15, 2007 1:42 PM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > I thought of an analogy I like better than my sign-painting one: ordering > a sandwich. > Imagine: you're at the deli, and your waitron asks w

Re: [Tutor] class accessing another's updated property

2007-11-15 Thread Alan Gauld
"Alan Gauld" <[EMAIL PROTECTED]> wrote > > class Master: > > class PublishedMaster(Master): > > class client: > > This allows the subscriber classes to be informed of any changes I should have pointed out that the code I posted was not tested and should be treated as pseudo code - albeit very

Re: [Tutor] manipulating data

2007-11-15 Thread Tiger12506
If you run this code # f = open('test1.mlc') for line in f: print f.split() # You will see that about halfway through the file there is an empty list. I assume that there was nothing on that line, in which case, there is no [0] value. In which case, you need to put in a try: except IndexError

Re: [Tutor] width

2007-11-15 Thread bhaaluu
In pack() add: expand=YES, fill=X, expand=YES, fill=Y or expand=YES, fill=BOTH Example: from Tkinter import * root = Tk() Button(root, text='Red', bg="red", fg="white", command=root.quit).pack(expand=YES,fill=X) Button(root, text='Green', bg="green", fg="white", command=root.quit).pack(expand=YES

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Alan Gauld
"bob gailer" <[EMAIL PROTECTED]> wrote > modname = raw_input() > exec "import " + modname > > That can be a security risk, in that a use could > enter "time; import os; os.rmdir('some_valuable_directory')" Even more risky is the fact that modules can contain executable code that is run when t

Re: [Tutor] width

2007-11-15 Thread bhaaluu
As to the WHY it works like it does? http://effbot.org/tkinterbook/pack.htm On Nov 15, 2007 4:40 PM, linda.s <[EMAIL PROTECTED]> wrote: > I wonder why the widths are different for the three labels? > Thanks, > Linda > > from Tkinter import * > > root = Tk() > > w = Label(root, text="Red", bg="red

Re: [Tutor] class accessing another's updated property

2007-11-15 Thread Alan Gauld
"ted b" <[EMAIL PROTECTED]> wrote >I want class One to be able to access access class > Two's value property after its been updated. Everytime > I try (by running, say testTwo().value) I get the > __init__ value. Others have explained that you need to use instances or class attributes. I'll tack

Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
I thought of an analogy I like better than my sign-painting one: ordering a sandwich. Imagine: you're at the deli, and your waitron asks what you want. (Granted, this is a silly example.) "Classic" order: "I'd like a sandwich with two slices of rye bread, Russian dressing, corned beef, and Swiss

[Tutor] width

2007-11-15 Thread linda.s
I wonder why the widths are different for the three labels? Thanks, Linda from Tkinter import * root = Tk() w = Label(root, text="Red", bg="red", fg="white") w.pack() w = Label(root, text="Green", bg="green", fg="white") w.pack() w = Label(root, text="Blue", bg="blue", fg="white") w.pack() main

[Tutor] selection

2007-11-15 Thread linda.s
Hi, I wonder how to hold the ctrl key and button-1 to do multiple selection of the following items? Thanks, Linda import Tkinter s = Tkinter.Scrollbar() L = Tkinter.Listbox() s.pack(side=Tkinter.RIGHT, fill=Tkinter.Y) L.pack(side=Tkinter.LEFT, fill=Tkinter.Y) s.config(command=L.yview) L.config(

Re: [Tutor] Memory consumption question

2007-11-15 Thread Kent Johnson
Marc Tompkins wrote: > I didn't mean that exactly literally - for goodness' sake, this is a > high-level, object-oriented, interpreted language! We're not writing > machine language here. Yes, I was thinking I should re-word my email, it was worded a bit too strongly... > What I did mean, and

[Tutor] Little subclass understanding problem

2007-11-15 Thread Michael H. Goldwasser
Oops... Just finished sending my earlier response and realize that I overlooked an issue. The code from http://viner.tv/go?set is potentially errant. When invoking the base class constructor, self should have been explcitly sent as a parameter, using the syntax class Set(list):

Re: [Tutor] Little subclass understanding problem

2007-11-15 Thread Kent Johnson
Tom wrote: > I am trying to understand what happens in the following scenario: > > class Sub_class(Base_class): > def __init__(self, data): > Base_class.__init__(self, data) > > as in: > > # snippet from http://viner.tv/go?set > class Set(list): > def __init__(self, value = []):

[Tutor] Little subclass understanding problem

2007-11-15 Thread Michael H. Goldwasser
On Thursday November 15, 2007, Tom wrote: >I am trying to understand what happens in the following scenario: > >class Sub_class(Base_class): >def __init__(self, data): >Base_class.__init__(self, data) > >as in: > ># snippet from http://viner.tv/go?

Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
I didn't mean that exactly literally - for goodness' sake, this is a high-level, object-oriented, interpreted language! We're not writing machine language here. What I did mean, and will probably still not express as clearly as I'd like, is that when you create a "classic" class, lots of options

[Tutor] Little subclass understanding problem

2007-11-15 Thread Tom
I am trying to understand what happens in the following scenario: class Sub_class(Base_class): def __init__(self, data): Base_class.__init__(self, data) as in: # snippet from http://viner.tv/go?set class Set(list): def __init__(self, value = []): list.__init__([]) The l

Re: [Tutor] Memory consumption question

2007-11-15 Thread Marc Tompkins
Thus spake Bart Cramer: > I have a question... : > > >>> class A: pass > ... > >>> class B(object) : pass > ... > >>> dir(A) > ['__doc__', '__module__'] > >>> dir(B) > ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', > '__hash__', '__init__', '__module__', '__new__', '__redu

Re: [Tutor] Memory consumption question

2007-11-15 Thread Kent Johnson
Marc Tompkins wrote: > class B is a "new-style' class, meaning that it inherits from a base, > pre-existing class (in this case "object", which is as basic and generic > as you can get!). class A has to start from nothing, which is why it > consumes more memory yet has less functionality. I d

Re: [Tutor] manipulating data

2007-11-15 Thread Kent Johnson
Bryan Fodness wrote: > I try this, > > f = open('TEST1.MLC') > > fields = {} > > for line in f: > if line.split()[0] == 'Field': > field = int(line.split()[-1]) > elif line.split()[0] == 'Leaf': > fields[field] = line.split()[-1] > else: > line = f.next() > >

Re: [Tutor] manipulating data

2007-11-15 Thread Michael H. Goldwasser
On Monday November 12, 2007, Bryan Fodness wrote: >I try this, > >f = open('TEST1.MLC') > >fields = {} > >for line in f: >if line.split()[0] == 'Field': >field = int(line.split()[-1]) >elif line.split()[0] == 'Leaf': >fields[fie

Re: [Tutor] manipulating data

2007-11-15 Thread Bryan Fodness
I try this, f = open('TEST1.MLC') fields = {} for line in f: if line.split()[0] == 'Field': field = int(line.split()[-1]) elif line.split()[0] == 'Leaf': fields[field] = line.split()[-1] else: line = f.next() and get, Traceback (most recent call last): Fil

[Tutor] Memory consumption question

2007-11-15 Thread Bart Cramer
Dear all, I have a question... : >>> class A: pass ... >>> class B(object) : pass ... >>> dir(A) ['__doc__', '__module__'] >>> dir(B) ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Remco Gerlich
The input() function calls eval() on the value you give it. Eval() can evaluate any _expression_. That's generally insecure and not recommended - people could type in anything, as you're trying to do :-) But anyway, that is why 'import ...' directly doesn't work, import is a statement, not an expr

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread bob gailer
Mihai Iacob wrote: Hello, I was wondering if there is a way to import modules using the input() command. If i try to do it directly it gives me an error: input() import time The input function takes a character string and attempts to

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Kent Johnson
Mihai Iacob wrote: > Hello, > > I was wondering if there is a way to import modules > using the input() command. If i try to do it directly > it gives me an error: > input() > import time > > Traceback (most recent call last): > File "", line 1, in > input() > File "", line 1 >

[Tutor] How to import modules using the input() command

2007-11-15 Thread Mihai Iacob
Hello, I was wondering if there is a way to import modules using the input() command. If i try to do it directly it gives me an error: >>> input() import time Traceback (most recent call last): File "", line 1, in input() File "", line 1 import time ^ SyntaxError: invalid s

Re: [Tutor] parsing an array

2007-11-15 Thread Kent Johnson
sith . wrote: > a = [[1,1],[3,1.5],[5,0]] > for i in range(len(a)) : This should use range(1, len(a)). You don't want i to take on the value 0. > if a[i][1] > a[i-1][1] : When i==0 this compares a[0] to a[-1] which is the *last* element of the list; a[0][1] > a[-1][1] so it prints 'greater

[Tutor] parsing an array

2007-11-15 Thread sith .
greater !! greater !! smaller only the second and third "greater" and "smaller" output are correct as 1.5 is larger than 1 and 0 is smaller than 1.5. What is i[1] greater than?

[Tutor] parsing an array

2007-11-15 Thread sith .
a = [[1,1],[3,1.5],[5,0]] for i in range(len(a)) : if a[i][1] > a[i-1][1] : print 'greater !!' else: print "smaller" greater !! greater !! smaller Thanks for taking the time to help me Aditya. I tried the code but have encountered a problem. In this new list, [

[Tutor] [OT] Vacancy - python systems programmer

2007-11-15 Thread Stephen Nelson-Smith
All, I may shortly be in the position of being able to hire a python systems programmer for a short contract (1-2 days initially to spike an ongoing project). The ideal person will have the following: * Solid experience of Python for systems programming and database interaction * Familiarity wit

[Tutor] selecting elements from a list that do not meet selection criteria

2007-11-15 Thread ted b
Is there a way i can select all elements from a list that do not meet selection criteria. I want to be able to select elements that have values of, say, < 1 but only if at least one of the elements has a value of > 0. What i mean is, for example, in the code below, if one of the elements of "list

Re: [Tutor] Interactive Menu Woes

2007-11-15 Thread Bryan Magalski
I wish I would have read your response before posting to Evert Rol's response. They compliment each other in both explanation and detail. I thank you as well for your contribution, as I said in my response to Evert, I will post my script completed when I get home. Thank you. --Bryan -

Re: [Tutor] CSV TO LDIF

2007-11-15 Thread Kent Johnson
sacha rook wrote: > I am using the csv module to parse the csv, anyone got any suggestions > for creating the ldif file from this? http://python-ldap.sourceforge.net/doc/python-ldap/ldif-example.html Kent ___ Tutor maillist - Tutor@python.org http:/

Re: [Tutor] Interactive Menu Woes

2007-11-15 Thread Bryan Magalski
Awesome, awesome, awesome. I will check my script when I get home from work, but your explanation is top notch! I think I understand it now. Thank you. I will post my corrected script and the answers when I get home from work tonight. Many thanks! - Original Message From: Evert Ro

Re: [Tutor] selecting elements from a list that do not meet selection criteria

2007-11-15 Thread Kent Johnson
ted b wrote: > Is there a way i can select all elements from a list > that do not meet selection criteria. I want to be able > to select elements that have values of, say, < 1 but > only if at least one of the elements has a value of > > 0. I'm not sure if you mean > 0 or >1, you seem to say both

Re: [Tutor] retrieve data from an online database without knowing the url

2007-11-15 Thread Kent Johnson
pileux systeme wrote: > Hello, > > I was wondering whether it was possible to write a program which could > directly write some word in a box and click 'search' on a typical online > database without using the url. (e.g. is there a way to write a program > which would write some keyword, say 't

Re: [Tutor] class accessing another's updated property

2007-11-15 Thread Yoram Hekma
On Wed, Nov 14, 2007 at 04:43:28AM -0800, ted b wrote: > I want class One to be able to access access class > Two's value property after its been updated. Everytime > I try (by running, say testTwo().value) I get the > __init__ value. The update method fro class Two is > called elsewhere in the pro

Re: [Tutor] retrieve data from an online database without knowing the url

2007-11-15 Thread Yoram Hekma
On Thu, Nov 15, 2007 at 04:06:31AM +0100, pileux systeme wrote: > Hello, > > I was wondering whether it was possible to write a program which could > directly write some word in a box and click 'search' on a typical online > database without using the url. (e.g. is there a way to write a program

Re: [Tutor] Obtaining image date of creation

2007-11-15 Thread pyprog
On jeu, 2007-11-15 at 04:17 +0100, pyprog wrote: > > >>> import Image > >>> ouv=Image.open('path_to_your_picture_with_exif_data__jpeg') > >>> exifdata=imgExif._getexif() A little error : >>> import Image >>> ouv=Image.open('path_to_your_picture_with_exif_data__jpeg') >>> exifdata=ouv._getexif(

Re: [Tutor] Interactive Menu Woes

2007-11-15 Thread Evert Rol
> Thank you for your suggestion. I did not create the original > script, so it will stay as is and my addition for the menu has been > adjusted. > > Now that I can make a clear distinction of what I am returning, I > am getting a new error that leads me that I am trying to call a > functio

Re: [Tutor] retrieve data from an online database without knowing the url

2007-11-15 Thread Evert Rol
> I was wondering whether it was possible to write a program which > could directly write some word in a box and click 'search' on a > typical online database without using the url. (e.g. is there a way > to write a program which would write some keyword, say 'tomato' on > google and click

[Tutor] CSV TO LDIF

2007-11-15 Thread sacha rook
Hi I have a csv of users that I want to update their records in edirectory. I am quite happy to use the ldap import utility to pull an ldif file into edirectory to update information. I am using the csv module to parse the csv, anyone got any suggestions for creating the ldif file from this

Re: [Tutor] parsing an array

2007-11-15 Thread Aditya Lal
On Nov 15, 2007 12:37 PM, sith . <[EMAIL PROTECTED]> wrote: > a = [[1,2],[3,1.5],[5,6]] > for i in a: > print i > if i[1]>i[0]: > print "second index is larger" > else: > print "second index is smaller" > [1, 2] > second index is larger > [3, 1.5] > second index is smal