[Tutor] widget value initialization
Radiobuttons and entries in child windows do not display their initial state. Try the attached example. (Notice some attempted remedies commented out because they didn't work.) If anyone can make this work I'd be very grateful. Regards Tom Kuiper #!/usr/bin/python # This is an extension of an example (first part) in An Introduction to # Tkinter by Fred Lundh # From http://www-acc.kek.jp/WWW-ACC-exp/KEKB/control/Activity/Python/TkIntro/introduction/button.htm # See also http://www.pythonware.com/library/tkinter/introduction/x6969-patterns.htm from Tkinter import * master = Tk() MODES = [ ("Monochrome", "1"), ("Grayscale", "L"), ("True color", "RGB"), ("Color separation", "CMYK") ] def make_buttons(): global v f = Frame(master) f.pack() v = StringVar() v.set("L") # initialize for text, mode in MODES: b = Radiobutton(f, text=text, variable=v, value=mode) b.pack(anchor=W) make_radio() # child.mainloop() child.update_idletasks def make_radio(): global w global child child = Tk() w = StringVar() w.set("N") # initialize g = Frame(child) g.pack() y = Radiobutton(g, text="Yes", variable=w, value="Y") y.pack(side=LEFT) n = Radiobutton(g, text="No", variable=w, value="N") n.pack(side=LEFT) make_buttons() master.mainloop() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Guest at Foothill College?
Would you be able to come talk to beginning Python students at Foothill College, Middlefield campus in Palo Alto? The students are working on a real world project and can really benefit from a guest from industry who can critique their work and answer questions about your career. You would not have to prepare anything, just a 10 minute phone conversation with me will bring you up to speed on their project and enable you to give the students good feedback when you watch their presentations. Then, you could just respond to their questions about Python and your career. The whole thing shouldn't take more than an hour. Here are the dates you could choose from: Wednesdays at Middlefield campus in Palo Alto 21 Nov, 6 pmdesign/architecural review 28 Nov, 6 pm code review 5 Dec, 6 pm code review 12 Dec, 6 pm code review Let me know as soon as possible if you are interested, and don't hesitate to ask me for more details. Thanks so much for considering this! -Elaine Haight faculty, CTIS haightElaine at foothill.edu Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] affecting all classes if one class is affected by an event - pygame
I am trying to figure out how to make a class instance respond the same way as another class instance if the other is affected by some event. I have been playing around with inheritance, and have tried other stuff, but i am somewhat of a newbie and I have been having difficulty (but you guys, particularly Kent, have really been helping me a lot : For example, in the pygame code below, i have set it up so that the boxes will stop if they are above the barrier and hit it. Well, that's what i want to happen, but if one of the boxes hits the barrier, the other box keeps going. Is there a way i can have both boxes stop if either of them hit the barrier. I was hoping there was a way that i could have the info from one class get passed to the other classes so i could stop the other box (or stop all or only some other boxes if i add lots more). Should i make another class? Another method? Globals? Here's the code: #/usr/bin/env python import pygame from pygame.locals import * pygame.init() class testBox1(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image=pygame.Surface((25,25)) self.image.fill((255,0,0)) self.rect=self.image.get_rect() self.rect.center = (30,90) def update(self): # check for user input and move left, right, up or down keys = pygame.key.get_pressed() if keys[pygame.K_w]: self.rect.center = (self.rect.centerx, self.rect.centery-4) if keys[pygame.K_s]: self.rect.center = (self.rect.centerx, self.rect.centery+4) if keys[pygame.K_a]: self.rect.center = (self.rect.centerx-4, self.rect.centery) if keys[pygame.K_d]: self.rect.center = (self.rect.centerx+4, self.rect.centery) # see if the rect hit the barrier self.checkPos() def checkPos(self): # if box rect moves below barrier's rect, halt box's position if ((self.rect.bottom > testBarrier().rect.top) and (self.rect.top < testBarrier().rect.top)): if ((testBarrier().rect.right > self.rect.right > testBarrier().rect.left) or (testBarrier().rect.right > self.rect.left > testBarrier().rect.left)): self.rect.bottom = testBarrier().rect.top class testBox2(testBox1): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image=pygame.Surface((25,25)) self.image.fill((0,0,255)) self.rect=self.image.get_rect() self.rect.center = (80,50) class testBarrier(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image=pygame.Surface((30,4)) self.image.fill((0,0,0)) self.rect=self.image.get_rect() self.rect.center = (50,150) def main(): screen = pygame.display.set_mode((100,300)) pygame.display.set_caption("testing") background=pygame.Surface(screen.get_size()) background=background.convert() background.fill((255,255,255)) screen.blit(background, (0,0)) box1=testBox1() box2=testBox2() barrier=testBarrier() allSprites=pygame.sprite.Group(box1, box2, barrier) clock=pygame.time.Clock() keepGoing=True while keepGoing: clock.tick(30) for event in pygame.event.get(): if event.type==pygame.QUIT: keepGoing=False allSprites.clear(screen, background) allSprites = pygame.sprite.OrderedUpdates (barrier, box1, box2) allSprites.update() allSprites.draw(screen) pygame.display.flip() if __name__ == "__main__": main() Thanks for all your help!!! :) -ted Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] affecting all classes if one class is affected by an event - pygame
ted b wrote: > I am trying to figure out how to make a class instance > respond the same way as another class instance if the > other is affected by some event. I have been playing > around with inheritance, and have tried other stuff, > but i am somewhat of a newbie and I have been having > difficulty (but you guys, particularly Kent, have > really been helping me a lot : > > For example, in the pygame code below, i have set it > up so that the boxes will stop if they are above the > barrier and hit it. Well, that's what i want to > happen, but if one of the boxes hits the barrier, the > other box keeps going. Is there a way i can have both > boxes stop if either of them hit the barrier. I was > hoping there was a way that i could have the info from > one class get passed to the other classes so i could > stop the other box (or stop all or only some other > boxes if i add lots more). Should i make another > class? Another method? Globals? I don't understand what in the code below makes the box stop - does it just hit the barrier and stick there? And you want the other box to stop wherever it is at the time? Here are some suggestions: You only need one class for the boxes, the only difference is the initialization parameters; these can be passed in as parameters. For example, class Box(pygame.sprite.Sprite): def __init__(self, color, center): pygame.sprite.Sprite.__init__(self) self.image=pygame.Surface((25,25)) self.image.fill(color) self.rect=self.image.get_rect() self.rect.center = center box1=Box((255,0,0), (30,90)) box2=Box((0,0,255), (80,50)) To stop all the boxes, maybe you want a Box class attribute which is a flag: class Box(...): moving = True Then in the Box methods you can refer to Box.moving. HTH, Kent > > Here's the code: > > #/usr/bin/env python > > import pygame > > from pygame.locals import * > > pygame.init() > > class testBox1(pygame.sprite.Sprite): >def __init__(self): > pygame.sprite.Sprite.__init__(self) > self.image=pygame.Surface((25,25)) > self.image.fill((255,0,0)) > self.rect=self.image.get_rect() > self.rect.center = (30,90) > >def update(self): > # check for user input and move left, right, up > or down > keys = pygame.key.get_pressed() > if keys[pygame.K_w]: > self.rect.center = (self.rect.centerx, > self.rect.centery-4) > if keys[pygame.K_s]: > self.rect.center = (self.rect.centerx, > self.rect.centery+4) > if keys[pygame.K_a]: > self.rect.center = (self.rect.centerx-4, > self.rect.centery) > if keys[pygame.K_d]: > self.rect.center = (self.rect.centerx+4, > self.rect.centery) > # see if the rect hit the barrier > self.checkPos() > >def checkPos(self): > # if box rect moves below barrier's rect, halt > box's position > if ((self.rect.bottom > testBarrier().rect.top) > and (self.rect.top < testBarrier().rect.top)): > if ((testBarrier().rect.right > > self.rect.right > testBarrier().rect.left) or > (testBarrier().rect.right > self.rect.left > > testBarrier().rect.left)): > self.rect.bottom = testBarrier().rect.top > > class testBox2(testBox1): >def __init__(self): > pygame.sprite.Sprite.__init__(self) > self.image=pygame.Surface((25,25)) > self.image.fill((0,0,255)) > self.rect=self.image.get_rect() > self.rect.center = (80,50) > > class testBarrier(pygame.sprite.Sprite): >def __init__(self): > pygame.sprite.Sprite.__init__(self) > self.image=pygame.Surface((30,4)) > self.image.fill((0,0,0)) > self.rect=self.image.get_rect() > self.rect.center = (50,150) > > def main(): >screen = pygame.display.set_mode((100,300)) > >pygame.display.set_caption("testing") > >background=pygame.Surface(screen.get_size()) >background=background.convert() >background.fill((255,255,255)) >screen.blit(background, (0,0)) > >box1=testBox1() >box2=testBox2() >barrier=testBarrier() > >allSprites=pygame.sprite.Group(box1, box2, barrier) > >clock=pygame.time.Clock() >keepGoing=True >while keepGoing: > clock.tick(30) > for event in pygame.event.get(): > if event.type==pygame.QUIT: > keepGoing=False > > allSprites.clear(screen, background) > allSprites = pygame.sprite.OrderedUpdates > (barrier, box1, box2) > allSprites.update() > allSprites.draw(screen) > > pygame.display.flip() > > if __name__ == "__main__": >main() > > Thanks for all your help!!! :) > -ted > > > > > Be a better sports nut! Let your teams follow you > with Yahoo Mobile. Try it now. > http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ > ___ > Tutor maill
[Tutor] Read-ahead for large fixed-width binary files?
I've been writing a lot of utility programs for my clients who are users of a certain legacy database application - exporting, reporting, pretty label printing, etc. The database is normalized into 45 files, each of which contains fixed-length records (ranging from 80 bytes to 1024). A few of those files contain relatively few records, while others - depending how long the users have worked with the application - may contain millions of records; the transaction file is generally the largest and consists of 256-byte records. (Before anybody asks, yes! I know that the best way to do this would be to use the database engine that created the files. Unfortunately, that's not really an option.) I am NOT writing back to the data file. I seem to have two alternatives - read the file one record at a time (which means I spend a ridiculous amount of time waiting for the disk), or read the whole thing at once and process it in memory (which, depending on the user's machine, will probably choke on a 250MB transaction file.) My question is this: does anybody know of an equivalent to "readlines(sizehint)" for non-delimited, binary files? I've Googled and Googled until I'm groggy, but I don't seem to find what I want. Thanks! -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Read-ahead for large fixed-width binary files?
OK, I feel quite foolish... almost immediately after hitting 'send' I realized I can implement this myself, using 'read(bigsize)' - currently I'm using 'read(recordsize)'; I just need to add an extra loop around my record reads. Please disregard... On Nov 16, 2007 11:10 AM, Marc Tompkins <[EMAIL PROTECTED]> wrote: > I've been writing a lot of utility programs for my clients who are > users of a certain legacy database application - exporting, reporting, > pretty label printing, etc. The database is normalized into 45 files, > each of which contains fixed-length records (ranging from 80 bytes to > 1024). A few of those files contain relatively few records, while > others - depending how long the users have worked with the application > - may contain millions of records; the transaction file is generally > the largest and consists of 256-byte records. > > (Before anybody asks, yes! I know that the best way to do this would > be to use the database engine that created the files. Unfortunately, > that's not really an option.) > I am NOT writing back to the data file. > > I seem to have two alternatives - read the file one record at a time > (which means I spend a ridiculous amount of time waiting for the > disk), or read the whole thing at once and process it in memory > (which, depending on the user's machine, will probably choke on a > 250MB transaction file.) > > My question is this: does anybody know of an equivalent to > "readlines(sizehint)" for non-delimited, binary files? I've Googled > and Googled until I'm groggy, but I don't seem to find what I want. > > Thanks! > > -- > www.fsrtechnologies.com > -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Q1: Any way for script to intercept a HUP signal ?
Is there a way for a Python script to intercept a HUP signal sent to it ? Cheers Dave -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Q1: Any way for script to intercept a HUP signal ?
dave selby wrote: > Is there a way for a Python script to intercept a HUP signal sent to it ? > > Cheers > > Dave > > Yes, using a signal handler: http://docs.python.org/lib/module-signal.html Let us know if you need clarification on anything after you read the section. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Q2: logging not working as expected
I can't get the python 2.5.1 logging module to use your logging.conf, can you create a simpler example? dave selby wrote: > I am trying to use the python logging module. At first glance it looks > pretty complicated but having Ggooled a lot I have come up with a > trial script of ... > > logging.config.fileConfig("logging.conf") > logger = logging.getLogger() > logger.critical("Test Message") > > Where 'loggin.conf' contains ... > > [loggers] > keys=root,hdk1,hkd2 > > [handlers] > keys=SysLog,hand02 > > [formatters] > keys=SysLog > > [logger_root] > level=NOTSET > handlers=SysLog > > [logger_hkd1] > level=DEBUG > propagate=1 > qualname=hkd1 > handlers=SysLog > channel=hkd1 > parent=(root) > > [logger_hkd2] > level=DEBUG > propagate=1 > qualname=hkd2 > handlers=hand02 > channel=hkd2 > parent=(root) > > [handler_hand02] > class=FileHandler > level=DEBUG > formatter=SysLog > args=('python.log', 'w') > > [handler_SysLog] > class=handlers.SysLogHandler > level=DEBUG > formatter=SysLog > args=(('localhost', handlers.SYSLOG_UDP_PORT), > handlers.SysLogHandler.LOG_USER) > > [formatter_SysLog] > format=%(filename)s[%(process)d]: %(levelname)s: %(message)s > > I was trying to get logging to report to Syslog, that failed so I > changed it to write to a file 'python.log' . When I execute my test > script 'python.log' appears but contains no messages and no error > messages are generated. > > Anybody any ideas as to what I am doing wrong ? > > Cheers > > Dave > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Q2: logging not working as expected
Kent Johnson wrote: > dave selby wrote: > >> I was trying to get logging to report to Syslog, that failed so I >> changed it to write to a file 'python.log' . When I execute my test >> script 'python.log' appears but contains no messages and no error >> messages are generated. >> >> Anybody any ideas as to what I am doing wrong ? >> > > The root logger is still logging only to Syslog. What if you make the > root logger just output to hand02? > > You might try cutting your config down to just the root logger and file > handler, get that working, then expand. > Good advice, Kent. When in doubt, simplify. Sometimes I find the answer to my problems just trying to reduce it down to a simple test case to post to a forum like this. :-) e. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Q2: logging not working as expected
dave selby wrote: > I was trying to get logging to report to Syslog, that failed so I > changed it to write to a file 'python.log' . When I execute my test > script 'python.log' appears but contains no messages and no error > messages are generated. > > Anybody any ideas as to what I am doing wrong ? The root logger is still logging only to Syslog. What if you make the root logger just output to hand02? You might try cutting your config down to just the root logger and file handler, get that working, then expand. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Q2: logging not working as expected
I am trying to use the python logging module. At first glance it looks pretty complicated but having Ggooled a lot I have come up with a trial script of ... logging.config.fileConfig("logging.conf") logger = logging.getLogger() logger.critical("Test Message") Where 'loggin.conf' contains ... [loggers] keys=root,hdk1,hkd2 [handlers] keys=SysLog,hand02 [formatters] keys=SysLog [logger_root] level=NOTSET handlers=SysLog [logger_hkd1] level=DEBUG propagate=1 qualname=hkd1 handlers=SysLog channel=hkd1 parent=(root) [logger_hkd2] level=DEBUG propagate=1 qualname=hkd2 handlers=hand02 channel=hkd2 parent=(root) [handler_hand02] class=FileHandler level=DEBUG formatter=SysLog args=('python.log', 'w') [handler_SysLog] class=handlers.SysLogHandler level=DEBUG formatter=SysLog args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER) [formatter_SysLog] format=%(filename)s[%(process)d]: %(levelname)s: %(message)s I was trying to get logging to report to Syslog, that failed so I changed it to write to a file 'python.log' . When I execute my test script 'python.log' appears but contains no messages and no error messages are generated. Anybody any ideas as to what I am doing wrong ? Cheers Dave -- Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Q2: logging not working as expected
Dave, Fix your typo here > [loggers] > keys=root,hdk1,hkd2 Should be hkd1 I believe, otherwise the config file is rejected by the logging module. > args=(('localhost', handlers.SYSLOG_UDP_PORT), > handlers.SysLogHandler.LOG_USER) LOG_USER is not a defined priority by default in syslog, unless it is something you have custom defined. I would suggest using one of the LOCAL[1-6] levels instead. > logging.config.fileConfig("logging.conf") > logger = logging.getLogger('hkd1') > logger.info('Test Messages') Finally, call using the qualified name 'hkd1'. It works for me after that... Although I agree with others, simplification does wonders for debugging. Jay On Nov 16, 2007 3:09 PM, dave selby <[EMAIL PROTECTED]> wrote: > I am trying to use the python logging module. At first glance it looks > pretty complicated but having Ggooled a lot I have come up with a > trial script of ... > > logging.config.fileConfig("logging.conf") > logger = logging.getLogger() > logger.critical("Test Message") > > Where 'loggin.conf' contains ... > > [loggers] > keys=root,hdk1,hkd2 > > [handlers] > keys=SysLog,hand02 > > [formatters] > keys=SysLog > > [logger_root] > level=NOTSET > handlers=SysLog > > [logger_hkd1] > level=DEBUG > propagate=1 > qualname=hkd1 > handlers=SysLog > channel=hkd1 > parent=(root) > > [logger_hkd2] > level=DEBUG > propagate=1 > qualname=hkd2 > handlers=hand02 > channel=hkd2 > parent=(root) > > [handler_hand02] > class=FileHandler > level=DEBUG > formatter=SysLog > args=('python.log', 'w') > > [handler_SysLog] > class=handlers.SysLogHandler > level=DEBUG > formatter=SysLog > args=(('localhost', handlers.SYSLOG_UDP_PORT), > handlers.SysLogHandler.LOG_USER) > > [formatter_SysLog] > format=%(filename)s[%(process)d]: %(levelname)s: %(message)s > > I was trying to get logging to report to Syslog, that failed so I > changed it to write to a file 'python.log' . When I execute my test > script 'python.log' appears but contains no messages and no error > messages are generated. > > Anybody any ideas as to what I am doing wrong ? > > Cheers > > Dave > > -- > > Please avoid sending me Word or PowerPoint attachments. > See http://www.gnu.org/philosophy/no-word-attachments.html > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] selecting elements from a list that do not meet selection criteria
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. > > What i mean is, for example, in the code below, if one > of the elements of "list 'a'" has a value greater than > 1, then i want to print all the other elements in the > list (i.e., class One and class Three) and to do > otherStuff associated with those classes. Right now, > it prints those elements that *do* have values of > 0, > (i.e. class Two). But in situations where all of the > classes have values set to 0, then i don't want > anything selected. > > I don't want to just use something like "if x.value() > != 0" or "if x.value() < 1" since those would give > results if all elements were less than 1, and i only > want to select elements of the list that are less than > 1 if at least one of the elements is > 1. > > Here's the sample code: > > class One: >def value(self): > return 0 > > class Two: >def value(self): > return 1 > > class Three: >def value(self): > return 0 > > a = [One(), Two(), Three()] > > for x in a: >if x.value() > 0: > print x > x.otherStuff() > > Thanks in advance!!! :))) > >>> doit = [1,2,0,-1,-3,-5,-7] >>> dont = [0,-1,-3,-5,-7,-9,-11] >>> [i for i in dont if max(dont) > 0 and i < 1] [] >>> [i for i in doit if max(doit) > 0 and i < 1] [0, -1, -3, -5, -7] HTH ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] affecting all classes if one class is affected by an event - pygame
Thus spake ted b: I am trying to figure out how to make a class instance respond the same way > as another class instance if the other is affected by some event. I have > been playing around with inheritance, and have tried other stuff, but i am > somewhat of a newbie and I have been having difficulty (but you guys, > particularly Kent, have really been helping me a lot : > > For example, in the pygame code below, i have set it up so that the boxes > will stop if they are above the barrier and hit it. Well, that's what i want > to happen, but if one of the boxes hits the barrier, the other box keeps > going. Is there a way i can have both boxes stop if either of them hit the > barrier. I was hoping there was a way that i could have the info from one > class get passed to the other classes so i could stop the other box (or stop > all or only some other boxes if i add lots more). Should i make another > class? Another method? Globals? > You need to have some way for information to be passed around between objects, or communicated to them by some central authority (which is much, much simpler to implement.) You're already collecting your objects into "allSprites"; go ahead and use that. This needs tuning, but off the top of my head I'd say: 1) add a bool attribute (let's call it "collided") to your sprites; in __init__ for each object add: self.collided = False 2) in your checkPos method, if there was a collision, set self.collided = True Also, don't do the actual reversal / stopping here - add another method to do it, like so: def oopsie(self): pass # replace this with whatever you want to have happen 3) put this somewhere in your "while KeepGoing:" loop: collision - False for sprite in AllSprites: # run through the list of sprites once to check if sprite.collided: collision = True sprite.collided = False # reset this sprite's flag for next time if collision: # if there was a collision, for sprite in AllSprites: # then run through the list of sprites again and update them sprite.oopsie() I agree with Kent - don't derive Box2 from Box1; use parameters to initialize them. I've never looked at pygame - some of this might already be built-in, but this is how I'd go about it. Enjoy! -- www.fsrtechnologies.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Memory consumption question
> 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 He is setting up the analogy so that python is the waiter (or waitress) taking the order. A "Reuben" in this case is a new-style class, whereas the whole list of sandwich components is also a reuben but expressed in old style class language. So, basically, he's saying that new style classes have more initial components but take up less room than old style classes because the waitress has less to write on her notepad. As for what has to be ordered seperately, he is treating the concept of a class abstractly as a sandwich. So he's saying that python has to "write less on the order pad" in order to create a new-style class because it's been restructured like that, whereas python writes all the stuff down, even for an empty class. Whether that's actually true or not, i do not know. I personally cannot imagine that a simple restructuring of classes can make that drastic a change. Here's the only way I can imagine it - in C++. C++ comes with virtual methods, i.e. methods of a base class that can function properly if the child does not provide that method in its definition. So I presume that he is thinking along the lines of old-style classes are C-structured based, whereas new-style classes are C++ based (even if they're not written in C++) with virtual methods - where you only need one copy of the methods in memory for all new-style classes. Maybe I'm way out in left field. I do not know. That is one explanation that I have provided myself so that I feel I have an understanding. Interpret it as you will. JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Read-ahead for large fixed-width binary files?
"Marc Tompkins" <[EMAIL PROTECTED]> wrote > realized I can implement this myself, using 'read(bigsize)' - > currently I'm using 'read(recordsize)'; I just need to add an extra > loop around my record reads. Please disregard... If you just want to navigate to a specific record then it might be easier to use seek(), that will save you having to read all the previous records into memory. HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] repeat
Hi All This has probably been asked before but can I get some clarification on why Python does not have a repeat...until statement, and does that mean repeat...until is bad practice? I was trying to get Python on the standard langauge list for my state secondary school system but they say a langauge must have a test last structure in it to be considered. Thanks Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor