Re: [Tutor] seeking help to a problem w/ sockets

2008-04-27 Thread tiger12506
How is the window being closed? By someone forcing it to close? Or terminating the process? If someone is just closing the window you can setup an atexit handler that will close the socket before it finishes. However, if the process is being terminated, then you will have to use one of the

Re: [Tutor] Little problem with math module

2008-04-21 Thread tiger12506
my problem is, INSIDE the funcion...the variable erro is correct, but when i return it to the test...and the test prints itcomes out 0.0. Its disturbing...i didnt found a way of solving this. err is defined in the function so it thinks it's a local variable. You can set it to change only

Re: [Tutor] Why next vs. __next__ ?

2008-04-21 Thread tiger12506
It's actually considered a mistake. The original rationale is spelled out in PEP 234 - see the Resolved Issues section: http://www.python.org/dev/peps/pep-0234/ It is being renamed to __next__() in Python 3.0 and there will be a builtin next() method that calls it. Instead of iterator.next()

Re: [Tutor] Little problem with math module

2008-04-21 Thread tiger12506
and then using modulename.erro when he uses the actual value. - Original Message - From: Kent Johnson [EMAIL PROTECTED] Cc: tutor@python.org Sent: Monday, April 21, 2008 9:33 PM Subject: Re: [Tutor] Little problem with math module tiger12506 wrote: my problem is, INSIDE the funcion

Re: [Tutor] Calling super classs __init__?

2008-03-21 Thread tiger12506
... was it there in previous versions of python? - Original Message - From: Andreas Kostyrka [EMAIL PROTECTED] To: tiger12506 [EMAIL PROTECTED] Cc: tutor@python.org Sent: Friday, March 21, 2008 4:25 AM Subject: Re: [Tutor] Calling super classs __init__? class A(object): v=lambda self

Re: [Tutor] Help this newbie

2008-03-20 Thread tiger12506
This is Windows I presume? Try: cd\python25 python C:\Elliot\filename.py But for windows you shouldn't have to. You can just double-click the file. On the other hand, if you mean 'import' as it means in the context of the actual python language, then you would put the line import filename at

Re: [Tutor] Calling super classs __init__?

2008-03-20 Thread tiger12506
Woah. Either you're leaving out essential info, or python got a lot more complicated. Firstly, super returns all base classes. How? Does it return a tuple of them, or a container object, or is this something horribly worse such as syntactic sugar? It doesn't make sense for it to return a

Re: [Tutor] my first project: a multiplication trainer

2008-03-16 Thread tiger12506
choice() returns a random element from the list of choices, not its index. One could call pop() instead of del, but del is probably a little faster, and doesn't return a value that we wouldn't use anyway. pop() wouldn't give us a random element, unless passed a random argument, such as

Re: [Tutor] my first project: a multiplication trainer

2008-03-15 Thread tiger12506
Considering the fact that choices[x] == x, shouldn't it be : del choices[proxyq] choices = [9,2,1,3,6,4,7,8,5,0] for idx, x in enumerate(choices): print idx == x False False False True False False False False False False Not always. ___ Tutor

Re: [Tutor] How to open IE7 to a certain URL?

2008-02-29 Thread Tiger12506
time.sleep is not exactly accurate, so I would suggest that you use this method, short 5 minutes or so and then do a sleep(10) or so in a loop to get closer to the time. import time b = '20:00:00' (bhour, bmin, bsec) = b.split(':') bsec = int(bsec) + int(bmin)*60 + int(bhour)*360 while True:

Re: [Tutor] Python oddity

2008-02-28 Thread Tiger12506
i'd like to know, too. my take so far is * don't make any copies if you can avoid doing so, * make shallow copies if need be, * make deep copies only if you can't think of any other way to accomplish what you're up to. Yep. That's pretty much it, for space reasons, mostly. Imagine a list

Re: [Tutor] Truncate First Line of File

2008-02-27 Thread Tiger12506
This is bill's method written out in code which is the python you seek, young warrior! inname = 'inputfile' outname = 'outfile' infile = open(inname,'r') outfile = open(outname,'w') infile.readline() line = infile.readline() while line != : outfile.write(line) infile.close() outfile.close()

Re: [Tutor] Python oddity

2008-02-27 Thread Tiger12506
Python lists are mutable. All mutable objects will behave in the fashion you described, whereas immutable objects -- tuples, integer, floats, etc. -- will behave in the fashion that you expect. This is because python keeps references to objects. When you say bb = aa, you are really saying,

Re: [Tutor] how to display terminal messages in dialog windowusingtkinter

2008-02-22 Thread Tiger12506
If you literally want print statements to appear in a dialog then no, you can't do that (so far as I know!). But if you want the Tkinter Alan??? Redirect standard output. It doesn't have to be a file object. It can be any object with a write method.

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-20 Thread Tiger12506
Similar to the TerminateProcess function in win32api, there is the TerminateThread function which you can use if you know the handle of the thread, but it seems that you can only get the thread handle if you are calling from that thread, or if you were the one who created it (and saved the

Re: [Tutor] DATA TYPES

2008-02-20 Thread Tiger12506
As I understand it python is not a strongly typed language so no declaration of variables is necessary. My question is this: If I use a variable in a program that stores certain numbers and I'm porting it to say ... java where I must first declare the variables before I use them how do

Re: [Tutor] DATA TYPES

2008-02-20 Thread Tiger12506
I was thinking more or less along the same lines, but - you don't need the copy() Hehehe, did you try it Kent? - locals is a dict mapping names to values, so something like for name, value in locals().iteritems(): print varname: %s type: %s (name,type(value)) And this returns

Re: [Tutor] results not quite 100 percent yet

2008-02-20 Thread Tiger12506
As far as I can see, these routines give me the results I'm looking for. I get a distribution of four negative numbers, four positive integers in the range 10 to 110, and nothing is placed in room 6 or room 11: I'll throw a couple of thoughts out there since I know that you appreciate to see

Re: [Tutor] Suggestions to improve this first effort?

2008-02-16 Thread Tiger12506
infile$ = ad.txt outfile$ = ad.csv infile=sys.argv[1] outfile=sys.argv[1]+.csv And these will give two different results. The QBasic version says ad.txt ad.csv whereas the python version will give ad.txt ad.txt.csv so you need to say infile = sys.argv[1] outfile = sys.argv[1][:-3]+'csv'

Re: [Tutor] read from standard input

2008-02-14 Thread Tiger12506
while 1 2: while 1: or while True: is more common x = raw_input() raw_input() always return a string, no matter what you type in. if type(x) != int or x == 11: type(x) is always type 'str' x can never be 11, but can possibly be '11'. (Notice quotes indicating string instead of

Re: [Tutor] designing POOP

2008-02-14 Thread Tiger12506
Now I'm curious. MVC is one of the oldest, best established and well proven design patterns going. It first appeared in Smalltalk in the late 1970's and has been copied in almost every GUI and Web framework ever since. I've used it on virtually(*) every GUI I've ever built(**) to the extent

Re: [Tutor] designing POOP

2008-02-12 Thread Tiger12506
This is all fine and dandy, but the video game is pretty worthless unless it can show us what the score is. There are two ways to go about this. A) Give the video game a display which it updates, or B) Tear open the case of the video game and look at the actual gears that increment the

Re: [Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread Tiger12506
I'm having issues when I test my software on XP, but not Linux. When I run the progam it fails after running for a while but not at exactly the same point each time. It fails in one of two ways, the user interface either completely disappears, or gives a OS error message unhanded exception

Re: [Tutor] designing POOP

2008-02-11 Thread Tiger12506
bhaaluu [EMAIL PROTECTED] wrote States, getters-setters, direct access... I'm still in toilet-training here/ 8^D Can you provide some simple examples that illustrate exactly what and why there is any contention at all? One clear example I can think of that shows the views is this:

Re: [Tutor] Change dictionary value depending on a conditionalstatement.

2008-02-10 Thread Tiger12506
list = [] total = 0 if total 0: ... x = {'id': 'name', 'link': 'XX'} ... list.append(x) ... else: ... y = {'id': 'name', 'link': 'YY'} ... list.append(y) ... Yeah. list = [] x = {'id':'name'} if total 0: x['link'] = 'XX' else: x['link'] = 'YY' list.append(x)

Re: [Tutor] designing POOP

2008-02-08 Thread Tiger12506
This is something that one can only gain from experience? I really had to struggle to get the Light class to work at all. I have no idea how many times I started over. But I do feel that I am starting to learn some of this stuff. This surprises me... I guess it does take experience. What is

Re: [Tutor] Cobra

2008-02-08 Thread Tiger12506
It's dangerous posting something like this on a python website. ;-) It has definite strengths over python, it seems, and some things I do not like. Particularly interesting is the compilation directly to exe. Damn. I'm am seriously impressed with that. Cobra appears too new to learn and switch

Re: [Tutor] designing POOP

2008-02-08 Thread Tiger12506
There is nothing like growing a program to the point where you don't know how it works or how to change it to make you appreciate good design Amen. I was recently fighting with an example of a multi-client, simple server that I wanted to translate into assembly. Not only was the code

Re: [Tutor] Adding network play to an open source game.

2008-02-08 Thread Tiger12506
I wish to warn you that I've never done anything like this before, but I have a couple of thoughts here. First thought is, network games tend to be slow because sending state information to everyone with enough frames per second to make it decent game play is a lot of information to send... So

Re: [Tutor] Pixelize ubuntu python script acting odd.

2008-02-07 Thread Tiger12506
Some suggestions throughout def runThrough(): walk = os.walk(/media/sda1/Documents/Pictures/2007) #location of the pics I want to use count = 0 for root, dirs, files in walk: try: for x in files: if x.lower().find(.jpg) -1: #If it's a .jpg...

Re: [Tutor] Anyone fancy giving me some tips and an expert opinion??

2008-02-07 Thread Tiger12506
I'll throw in a couple of ideas, but I won't pretend to be an expert. ;-) I have written what i see as a pretty decent script to resolve this question: Write an improved version of the Chaos program from Chapter 1 that allows a user to input two initial values and the number of iterations

Re: [Tutor] designing POOP

2008-02-07 Thread Tiger12506
There's a couple of errors in here that no one has addressed yet because the question was geared towards programming style... So now I will address them. Or undress them, I suppose. ;-) #!/user/bin/python From the testing laboratory of: b h a a l u u at g m a i l dot c o m 2008-02-07

Re: [Tutor] Import error in UNO

2008-02-05 Thread Tiger12506
muhamed niyas [EMAIL PROTECTED] wrote Also i set 'C:\Program Files\OpenOffice.org 2.0\program' in PATH evvironment variable. Close but not quite. You need to set the module folder in your PYTHONPATH environment variable. PATH is where the python interpreter lives PYTHONPATH is

Re: [Tutor] Traversing python datatypes via http

2008-02-05 Thread Tiger12506
Is it possible to traverse say python lists via http:// say there is a list in the memory can we traverse the list using list/next list/prev list/first list/last is there a pythonic library to do that? thanks That's a very unlikely request. There are a few ways to interpret this

Re: [Tutor] Hello and newbie question about self

2008-02-05 Thread Tiger12506
I probably won't need to start writing classes but I really want to finish the book before I start coding something. One of the greatest mistakes of my life was to completely finish a programming book before I started coding something. It is why I cannot write a Visual Basic program to this

Re: [Tutor] [tutor]Imagechop error

2008-02-02 Thread Tiger12506
Hello everyone, I am tryin to use the imagechop module but i am not able to implement it successfully. I want to compare two images and give the resultant of the image using difference module. i am tryin to save the resultant image. But i am getting some wierd error. It gives error in

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread Tiger12506
Hello there all. I have a need to make a hi byte and lo byte out of a number. so, lets say i have a number 300, and need this number to be represented in two bytes, how do i go about that? First question. Why would you need to do this in python? Second question. If you could do that, how

Re: [Tutor] [ctypes-users] calls to windll.user32

2008-01-24 Thread Tiger12506
Something like this happens with Pygame and IDLE. In Windows if you right click on a Python file and choose the Edit with IDLE option IDLE is started with a single process. If the program is run and it does its own windowing then it conflicts with Tkinter, used by IDLE. Start IDLE

Re: [Tutor] (no subject)

2008-01-24 Thread Tiger12506
Hi i have been fooling around in python a bit and looked at a couple of tutorials, but something i wonder about: is it posible to make python make an output in a windows tekstbox for instance to make several adjustments to my network settings at once, by running a python program and if it is,

Re: [Tutor] Dos and os.walk with Python

2008-01-24 Thread Tiger12506
I've had little experience with dos. I believe I should use the COMPACT, and then the MOVE dos command... Would it go something like this? You could use these but you'd be better just using Python to do it via the shutil and os modules and avoid the DOS commands completely IMHO. Python

Re: [Tutor] Projects (fwd)

2008-01-23 Thread Tiger12506
up to a thousand (not tested) words = {0:'zero', 1:'one', 2:'two', 3:'three', ... , 10:'ten', 11:'eleven', 12:'twelve', ..., 19:'nineteen', 20:'twenty', , 90:'ninety', 100:'one hundred' } def digitToString(n) : try : retStr = words[n] except KeyError : if

Re: [Tutor] Projects (fwd)

2008-01-23 Thread Tiger12506
This could be written much more efficiently. It can be done with only these lists~ ones = ['zero','one','two','three','four','five','six','seven','eight','nine'] teens = ['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'] What is it with

Re: [Tutor] Projects (fwd)

2008-01-23 Thread Tiger12506
Isn't dictionary access faster than list access? Why are three lists 'much more efficient'? Oh no, no, no. Dictionaries are faster when you are *searching through* for a particular value. If you already know the index of the item in the list, lists are much faster. Dictionaries are hash

Re: [Tutor] dictionaries, objects and scoping...

2008-01-22 Thread Tiger12506
Just a thought~ The built-in id() function can be useful in helping to sort out stuff. Returns a unique identifier for each object created so you can test whether a different name is a different object or just a different name for the same object. (This is what the 'is' operator does... Note:

Re: [Tutor] Obssfurcatedpuytthonlessons nneeded

2008-01-19 Thread Tiger12506
I aam writing some software which calls for some unreadable code in it to let me secretly set a registration key- it is to be shareware. I know this can be done, but have not the foggiest clue of how todo it. Any links, articles, pointers? This is impossible to do completely, and while

Re: [Tutor] data structure question

2008-01-18 Thread Tiger12506
snip class Task(object): def __init__(self, cargo, children=[]): self.cargo = cargo self.children = children def __str__(self): s = '\t'.join(self.cargo) return s def add_child(self,child): self.children = self.children + [child] This is an excellent start. self.children =

Re: [Tutor] Converting binary file date into a file?

2008-01-18 Thread Tiger12506
Many email clients encode attachments in base-64. I think there are standard modules in python which should be able to decode this. Hi I made a small python program at home and tried to send by email attachments to my studymates. The attachment however shows up as a strange text the

Re: [Tutor] data structure question

2008-01-18 Thread Tiger12506
def recursive_print(self, level=0): print \t*level + self.cargo for x in self.children: recursive_print(x,level+1) Whoops. should be for x in self.children: x.recursive_print(level+1) ___ Tutor maillist -

Re: [Tutor] Input

2008-01-15 Thread Tiger12506
Try regular expressions in the re module. This should make this code below much much simpler. Downside is you have to learn a slightly different syntax. Upside is - regular expressions are very powerful. Last week someone had an issue with raw_input() and how to get input for a number. So I

Re: [Tutor] Input

2008-01-15 Thread Tiger12506
Of course I know and use reg. exps., the point of the function is not to validate input but to force the proper input. So? Are you going to try to tell me that you can force particular input without actually determining if its valid or not first? ;-) Just a thought.

Re: [Tutor] Why Won't My Pizza Fall?

2008-01-14 Thread Tiger12506
[Background from Alan] If some other factor were to determine its behhaviour more closely - such as determining whether the Pizza was within the coordinate boundaries or in collision with another Pizza then that could be implemented via a message protocol. Thus the context object should

Re: [Tutor] Why Won't My Pizza Fall?

2008-01-12 Thread Tiger12506
Hey There Everyone, I'm following an example in a book and I can't find the error that's preventing this program from running. It's just an example of how to get a sprite moving. The images are all in the right folder. I can run the program and get a stationary sprite to appear. The

Re: [Tutor] getting filen basename without extension

2008-01-11 Thread Tiger12506
I would always use the os functions to find the basename, but You could exploit the fact that Windows considers the extension to be whatever is after the last . character. fn = fn[:fn.rfind(.)] What I found is this: import os myfile_name_with_path = 'path/to/my/testfile.txt' basename =

Re: [Tutor] replacing CreateProcess command for Vista compatibility?

2008-01-10 Thread Tiger12506
WindowsError: [Errno 193] %1 is not a valid Win32 application This line says that %1 is not a valid application. Windows uses %1 to mean the first argument on the command line to the program. Without seeing any code, it would be difficult to tell where this is being introduced, but the

Re: [Tutor] how to open a file using os.system

2008-01-09 Thread Tiger12506
hi i am developing a GUI application using TKINTER i want to open a file from the askopenfile(which is a tkFileDialog) using OS.SYSTEM. i have already created the file open dilog using tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file') Now i want to open a file from

Re: [Tutor] Scope and elegance

2008-01-08 Thread Tiger12506
Thanks Tiger12506! This has helped me understand the function(*tuple) syntax, as well as providing me with a concrete example. James Cool. ;-) Here's another, totally unrelated to counters and boards. Kinda the opposite use of the * syntax I used earlier. def printall(*li): for x in li

Re: [Tutor] subclassing strings

2008-01-08 Thread Tiger12506
to the user of the object. For an implemented simple example just say the word. HTH, Tiger12506 PS. Anyone who's interested. A significant study of C has brought me to these conclusions. immutable - implemented with static buffer mutable - implemented with linked list Anyone know a little more detail

Re: [Tutor] [tutor] Pil image related question -- resending messagewithout attachments

2008-01-07 Thread Tiger12506
I assume you realize that jpeg is a lossy format and that consecutively resizing the same image will no doubt end poorly in image quality. Also, I assume that you have a better understanding of the NEAREST and BICUBIC options than I do because you are apparently comparing them. I do know that

Re: [Tutor] classes and the deepcopy function

2008-01-07 Thread Tiger12506
Hi I was trying to learn about classes in Python and have been playing around but I am having a problem with the deepcopy function. I want to have a function that returns a clean copy of an object that you can change without it changing the original, but no matter what I do the original

Re: [Tutor] Review and criticism of python project

2008-01-07 Thread Tiger12506
Tiger12506 wrote: Ouch. Usually in OOP, one never puts any user interaction into a class. That seems a bit strongly put to me. Generally user interaction should be separated from functional classes but you might have a class to help with command line interaction (e.g. the cmd module

Re: [Tutor] Scope and elegance

2008-01-07 Thread Tiger12506
I like this. class Counter: def __init__(self): self.score = 0 def incr(x, y): self.score += 2*x+3*y class Board: def __init__(self): self.counter = Counter() self.curcoords = (0,0) def update(self) self.counter.incr(*self.curcoords) Whatever OOP term is used to

Re: [Tutor] Tkinter OptionMenu question

2008-01-04 Thread Tiger12506
Try the .add_command(...) method. Hello list! I was wondering if any of you could help me with this: I've got a small GUI connected to a SQLite DB. My OptionMenu pulls a category list from the DB, and there's a field to add a new Category if you need to. Now, I'd like the have the

Re: [Tutor] Program review

2008-01-04 Thread Tiger12506
This~~ works, but may be a little inefficient. Especially the double addr.strip() here. Given, it doesn't really matter, but I like even better Perhaps a use of sets here... particularly intersection somehow... Whoops, I'm not versed in sets (blush) I meant difference_update

Re: [Tutor] Program review

2008-01-04 Thread Tiger12506
After quickly looking over the code, I find it has a good foundation, it seems to have been designed very solidly. I haven't looked very closely, but if the messages are mostly alike with just one or two slight differences, you might consider dynamically creating the messages (from a customer

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread Tiger12506
Cool! Code! (gullom voice - we must look at code, yesss) Hi there. What this section area does is takes a data file that is comma separated and imports - there is a unique ID in the first field and a code in the second field that corresponds to a certain section of information. What I

Re: [Tutor] providing a Python command line within a Tkinter appl

2008-01-02 Thread Tiger12506
eval will seriously limit you in this instance because eval only works on expressions, not statements. (Assignment won't work, for example). You can use exec though. (in which case, you wouldn't necessarily want a result back) just fyi text =my_get_pythoncommand() # text is the line of

Re: [Tutor] How to stop a script.

2007-12-28 Thread Tiger12506
Ctrl+c will issue a KeyboardInterrupt which breaks out of programs such as the one you described. (The only situation it doesn't is when the program catches that exception. You won't see that 'til you get your sea legs ;-) ___ Tutor maillist -

Re: [Tutor] Py2Exe Tutorial

2007-12-24 Thread Tiger12506
I am wondering if there is a good tutorial on Py2Exe and its functions? I have not been able to find one. I have samples but that is not good enough. It would be nice to have something explain all the functions for including directories, modules and all that stuff when making an

Re: [Tutor] Cant write new line at end of file append

2007-12-21 Thread Tiger12506
- Original Message - From: dave selby [EMAIL PROTECTED] To: Python Tutor tutor@python.org Sent: Friday, December 21, 2007 12:03 PM Subject: [Tutor] Cant write new line at end of file append Hi all, I need to write a newline at the end of a string I am appending to a file. I tried

Re: [Tutor] Python Challenge 2

2007-12-21 Thread Tiger12506
I did this and got this string :- i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url Is that the answer because it does not solve the

Re: [Tutor] Regular Expression

2007-12-21 Thread Tiger12506
I need to pull the highligted data from a similar file and can't seem to get my script to work: Script: import re infile = open(filter.txt,r) outfile = open(out.txt,w) patt = re.compile(r~02([\d{10}])) You have to allow for the characters at the beginning and end too. Try this.

Re: [Tutor] Something I don't understand

2007-12-18 Thread Tiger12506
Below, student_seats is a list of the class student. Why does this code set every student.row to zero when there is only one student in the list with row 5? It still sets them all to zero if I change the test to 200 when there are no student.rows 200. But if I change the test to 1 then

Re: [Tutor] Required method to make foo(*Vector(0,0,0)) work.

2007-12-18 Thread Tiger12506
Sorry I wasn't quite sure how to explain it it's a vector class i've written myself. I've worked it out now, I was using a vector as part of a quaternion and wanted to be able to pass a vector or individual numbers so it seemed the easiest way to be able to use the *sequence syntax.

Re: [Tutor] Placing entire Application inside a class

2007-12-18 Thread Tiger12506
It is helpful for GUI applications because of what it says about halfway down the page, within __init__ you can bind certain messages to methods of the class. I would not say that it is recommended persé but I'm sure that there are those out there that cannot write a program without putting it

Re: [Tutor] user-given variable names for objects

2007-12-15 Thread Tiger12506
Mmm, to nit-pick a little, dictionaries are iterables, not iterators. They don't have a next() method. I'm a little fuzzy on the details of that, I will have to look over some reference material again. [a for a in eventData if eventData[a] time.time()] This is more efficient. The keys

Re: [Tutor] upper and lower case input for file name

2007-12-15 Thread Tiger12506
earlylight publishing [EMAIL PROTECTED] wrote I don't know if this'll help or not but I just learned about this: file = raw_input(info).lower file = raw_input(prompt).lower() # note the parens! The .lower is supposed to convert any input to lower case. It will indeed. There is also

Re: [Tutor] binary translator

2007-12-15 Thread Tiger12506
Hey i have created a program that turns a string into a binary one. But when i began to test the program it turned out that it could not handle some special characters (e.g ÆØÅ). Could someone please help me? These special characters have different values than those you have put into your

Re: [Tutor] Python Versions

2007-12-14 Thread Tiger12506
My apologies for mistaking your gender. Because English does not have adequate neutral gender indication, I tend to use the male as such, as they do in Spanish, and perhaps many other languages. At any rate, that's how it's written in the Bible. I presumed that it was an issue with raw input

Re: [Tutor] Python Versions

2007-12-14 Thread Tiger12506
Despite what your english teacher might have tried to make you believe, they were wrong about the lack of a neutral in english. Just like ending sentences with prepositions has always been done and always will be done, the use of they to refer to someone of indeterminate gender has been well

Re: [Tutor] what is the difference

2007-12-13 Thread Tiger12506
johnf [EMAIL PROTECTED] wrote if self._inFlush: return self._inFlush = True AND if not self._inFlush: ... self._inFlush = True else: return I can not see the difference but the second one acts differently in my code. The first has no else clause so the

Re: [Tutor] user-given variable names for objects

2007-12-13 Thread Tiger12506
I may sound like a know-it-all, but dictionaries *are* iterators. [a for a in eventData if eventData[a] time.time()] This is more efficient. The keys method creates a list in memory first and then it iterates over it. Unnecessary. Che M [EMAIL PROTECTED] wrote Although I was not familiar

Re: [Tutor] Python Versions

2007-12-13 Thread Tiger12506
Hey Tiger, your system clock is set incorrectly and your e-mail was flagged as being sent 12/12/2008, causing it to appear after an e-mail sent as a reply - confusing. Please remedy this situation ;P -Luke Whoops!! I have to mess with my clock occasionally to test the integrity of date

Re: [Tutor] Python Versions

2007-12-12 Thread Tiger12506
The OP has not specified what his problems specifically are, but earlylight publishing described his problem before, and he was not understanding why the prompt was expecting immediate keyboard input when he typed in raw_input(). So a noob cannot figure out why it is advantageous to have a

Re: [Tutor] Beat me over the head with it

2007-12-10 Thread Tiger12506
Write a python script that prints out what 2+2 is NOW!!! And after you've done that, write one that does my chemistry homework, IMMEDIATELY! Bonk! ;-) JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Button 1 Motion Event

2007-12-04 Thread Tiger12506
From your description, it sounds like the number of ovals placed depends only on when the B1-Motion even is sent to your Canvas object. If you want these a little more even, you might take the drawing code out of the function that's bound to the mouse event, so that whenever you process you a

Re: [Tutor] lstrip removes '/' unexpectedly

2007-12-03 Thread Tiger12506
## s = '/home/test/' s1 = s.lstrip('/ehmo') s1 'test/' ## Take a closer look at the documentation of lstrip, and you should see that what it takes in isn't treated as a prefix: rather, it'll be treated as a set of characters. But then

Re: [Tutor] [wxPython-users] passing file name from one script to theGUI class

2007-12-03 Thread Tiger12506
I do not currently have wx installed, but I can see the errors... I think some information will help you more than answers in this instance. When you 'import clases_calling', what you are doing is creating a new namespace. Inside that namespace is the class 'funct'. In your code, you call the

Re: [Tutor] List processing question - consolidating duplicateentries

2007-11-28 Thread Tiger12506
s=set() [s.add(tuple(x)) for x in myEntries] myEntries = [list(x) for x in list(s)] This could be written more concisely as... s = set(tuple(x) for x in myEntries) myEntries = [list(x) for x in list(s)] Generator expressions are really cool. Not what the OP asked for exactly. He wanted to

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
Sounds like an excuse for a global (aggh!) variable. Or more properly, wrap all of the relevant functions in a class and use a class variable for your puzzle - Original Message - From: Devon MacIntyre [EMAIL PROTECTED] To: tutor@python.org Sent: Wednesday, November 28, 2007 4:00 PM

Re: [Tutor] Variables and Functions

2007-11-28 Thread Tiger12506
Okay. Class is not a module. It is a keyword that defines a new type. Similar to an integer, or a string. But in the case of a class, you define what happens when you add, subtract, open, close, etc. by defining methods of a class. A classic example is a car. class Car: running = 0

Re: [Tutor] Memory consumption question

2007-11-16 Thread Tiger12506
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

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

Re: [Tutor] Class Attribute Overloading?

2007-08-15 Thread Tiger12506
Sorry about that. I want something like: class foo: def __init__(self): self.attr1 = None def get_attr1(self): if not self.attr1: attr1 = get value from DB, very expensive query self.attr1 = attr1 return self.attr1 such

Re: [Tutor] open multiple files

2007-08-15 Thread Tiger12506
Hi everyone - I'm beginning to learn how to program in python. I need to process several text files simultaneously. The program needs to open several files (like a corpus) and output the total number of words. I can do that with just one file but not the whole directory. I tried glob but

Re: [Tutor] Security [Was: Re: Decoding]

2007-08-14 Thread Tiger12506
The point is that even though eval(raw_input()) is not a security threat, Alan's suggestion of myscript.py some.txt might be. And even though the script written will not be a security issue, the *coding practice* that it teaches will lead to times when he does encounter that tiny set of scenarios

Re: [Tutor] Security [Was: Re: Decoding]

2007-08-13 Thread Tiger12506
foo = raw_input(...) x = eval(foo) Is an exception, in almost[*] every scenario I can think of. (and is the context eval was being used as far as I can see without reading the whole thread) [*] One scenario that seems unlikely but possible is a scenario where a machine has been

Re: [Tutor] Security [Was: Re: Decoding]

2007-08-13 Thread Tiger12506
On Monday 13 August 2007 22:39, Tiger12506 wrote: foo = raw_input(...) x = eval(foo) ... Let your program run on your machine and I'll walk by, type in this string, and hit enter. We'll see how much of an exception it is when you can't boot your XP machine anymore. ;-) Who cares

Re: [Tutor] Losing the expressivenessofC'sfor-statement?/RESENDwith example

2007-08-10 Thread Tiger12506
It seems this is a delightful exchange of rude threats and insults. ;-) My question is: If you love C syntax so much, why don't you program in C and leave us python people alone? And also: It is not the responsibility of the docs to ease the way for C programmers. That is what a specific

Re: [Tutor] WinPdb?

2007-08-09 Thread Tiger12506
Dick Moores wrote: (I posted this to the python-list 24 hours ago, and didn't get a single response. How about you guys?) You mean this list? Cause if you mean this list, then you didn't post it correctly. I don't believe he did. There are seperate python-lists, comp.lang.python, one

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Tiger12506
Traceback (most recent call last): File domainspotter.py, line 150, in module runMainParser() File domainspotter.py, line 147, in runMainParser td.run() File domainspotter.py, line 71, in run checkdomains.lookup() File domainspotter.py, line 108, in lookup from rwhois

  1   2   >