Re: [Tutor] Money matters

2007-06-28 Thread Tiger12506
otal by ten, 55, then divide by a 100. In that order. Of course you will still have problems. For example do it over and over and you will overflow your integer, but nevermind. Am I rambling? Ooops. HTH, tiger12506 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Here's what you need

2007-07-02 Thread Tiger12506
Dear elis: I just read the large volume of messages that you have sent causing mild confusion and misunderstanding relating to your OCR project. You have expressed wishes to learn python quickly, and to take a class. Therefore, I suggest you look here - any of these are more than enough of

Re: [Tutor] Automating Windows (Maintenance)

2007-07-02 Thread Tiger12506
> "Daniel McQuay" <[EMAIL PROTECTED]> wrote > >> I wondering if any one uses Python to do such things as defragment, >> clean up >> temp files, check for hard drive errors, check for unusual processes >> running, and so on. Watch and be amazed... import os os.system('defrag.

Re: [Tutor] how long?

2007-07-08 Thread Tiger12506
> Thorsten Kampe wrote: >> * Ben Waldin (Tue, 3 Jul 2007 19:46:42 +1200) >>> How long will it take until I successfully create my own working program >>> that is useful? I have crated the address book ones in the tutors and >>> just want to know how long it takes before I start to create my own

Re: [Tutor] How can I escape a pound symbol in my script?

2007-07-08 Thread Tiger12506
> ron wrote: >> in the US, # is a symbol for weight, not currency. > > I didn't know that; I assumed it was only > used for ordinal numbering (as in Item #3). > > # How do you write out, with a quick symbol, "I'm going to >> buy 3# of potatoes? This - #3 - means Number 3 This - 3# - means 3 pounds

Re: [Tutor] help with translating a c function to a python function

2007-07-08 Thread Tiger12506
>> i have a c function from some modbus documentation that i need to >> translate into python. >> unsigned short CRC16(puchMsg, usDataLen) >> unsigned char *puchMsg ; >> unsigned short usDataLen ; >> { >> unsigned char uchCRCHi = 0xFF ; >> unsigned char uchCRCLo = 0xFF ; >> unsigned u

Re: [Tutor] Fastest way to iterate through a file

2007-07-09 Thread Tiger12506
It seems to me that what you need is this. http://www.python.net/crew/mhammond/win32/Downloads.html I think the key that you are missing here is that python does not include functions that you ask without downloading something special. Check the link, download those extensions, and read the docu

Re: [Tutor] I/O error (?)

2007-07-11 Thread Tiger12506
> no, no, the values are coming from all over the place, so having to > remember > which member of the list that function is tied to may be more of a > headache > > I get the technique though Would you do us a huge favor in helping you and send us your code, the code where these values are comi

Re: [Tutor] Question about code reviews

2007-07-12 Thread Tiger12506
>> >> > Do you know of any service or person that could do a code review >> > for me? >> >> Perhaps if you were more specific about what you are looking for in the >> review? If you merely want something to check your code for possible >> errors and how well you stick to standards, then look i

Re: [Tutor] (no subject)

2007-07-13 Thread Tiger12506
If you just draw rectangles, you would have to track the mouse cursor and check to see if it's within the boundaries of a rectangle manually. I suggest using buttons. It will be easier to know when the mouse is over them. > Hello, > >The attached code makes a number of colored rectangles vi

Re: [Tutor] class question

2007-07-13 Thread Tiger12506
> === > class BankAccount(object): >def __init__(self, initial_balance=0): >self.balance = initial_balance >def deposit(self, amount): >self.balance += amount >def withdraw(self, amount): >self.balance -= amount >def overdr

Re: [Tutor] interpreter restarts

2007-07-13 Thread Tiger12506
Interesting... This is something very strange. I've been able to reproduce the phenomenon that elis described. Here's how to reproduce the error. 1) Open a new edit window in IDLE 2) type in code - do NOT save 3) Select Run Module from the Run menu 4) Save file when prompted When the IDLE shell

Re: [Tutor] class question

2007-07-13 Thread Tiger12506
> Your second way seems to make more sense. And instead of raising the > error, why not just print it: There is a very good reason for this and it's important that you understand it to write good code. If you use a print statement, you break the benefit of encapsulation. If you were to use tha

Re: [Tutor] class question

2007-07-13 Thread Tiger12506
Ooops, didn't see Alan's post before I sent this... JS >> Your second way seems to make more sense. And instead of raising the >> error, why not just print it: > > There is a very good reason for this and it's important that you > understand > it to write good code. If you use a print statement,

[Tutor] curses

2007-07-16 Thread Tiger12506
curses does not run on my Windows XP computer. Is this supposed to be a Linux only module? Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\curses\__init__.py", line 15, in from _curses import * ImportError: No module named _curses JS __

Re: [Tutor] interpreter restarts

2007-07-16 Thread Tiger12506
> But there's an exception to that - if you right-click a file in Windoze > and 'edit' it, > IDLE won't open up its subprocess, and as such, it can't restart the > interpreter session because it's running in the same > process as IDLE, and to restart the interpreter would mean restarting > IDLE. >

Re: [Tutor] curses

2007-07-16 Thread Tiger12506
> There IS a way to try Linux, Python, and curses WITHOUT > installing anything to the hard-drive of your MSWindowsXP > computer, and that is to download a Linux LiveCD ISO image, > and make a bootable CD from that image. Your computer > BIOS should be setup to boot from a CD. *That* is the proble

Re: [Tutor] reading random line from a file

2007-07-16 Thread Tiger12506
Perhaps ~this~ is what you are worried about performance-wise? Image NameMem Usage - python.exe11,096 K That's not too bad considering ~this~ explorer.exe 14,356 K svchost.exe24,000 K And I worry about the mp3 player I wrote in C using 2,520 K

Re: [Tutor] tutor

2007-07-16 Thread Tiger12506
> please think about your first programming class, and then think about how > long it took the prof to teach the concept of array. > > yes, it's about a week, if he is really good. [gentle rant] Yes, and I find that most idiots in math classes NEVER gain the concept of multiplying fractions (longe

Re: [Tutor] reading random line from a file

2007-07-16 Thread Tiger12506
If you truly wish to kill yourself trying to make it as efficient memory as possible, then you can follow this example. (This is more like what I would write in C). The getrandomline function picks a random byte between the beginning and the end of the file, then backs up until the beginning of the

Re: [Tutor] interpreter restarts

2007-07-16 Thread Tiger12506
Hmmm. You should read closer ;-) > It sounds like python_icon.exe is a fake executable that just contains the > icon for python programs... > hence the name. Perhaps. If that's the case though, someone needs to talk to the guys who design the setup file for python. It is an inefficient waste of

[Tutor] IDLE Usage - was Interpreter Restarts

2007-07-16 Thread Tiger12506
> Luke, Jacob, et. al... > > Dumb question (may be slightly off course from what you two were > discussing), but are you both describing how to get the IDLE to run along > with the editor? I may just be getting too many things confused. I've > tried to run IDLE, but that's not working. I have

Re: [Tutor] reading random line from a file

2007-07-17 Thread Tiger12506
> wow thats pretty cool :) it's a bit above my level but it's interesting > :) thanks I'm deeply flattered! Thank you. >> # >> from os import stat os.stat returns a tuple whose 7th member is the size of the file. (python docs) >> from random impor

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-17 Thread Tiger12506
Yeah. But she's running Windows. Perhaps vim is scary to some Windows users. (I thought it was scary and annoying. Are all those ~ characters really in the file or not? I kept second guessing the editor.) --Sara, could you give an example of how it doesn't work? Just what happens? Just what doe

Re: [Tutor] File parse

2007-07-17 Thread Tiger12506
> I'm trying to parse a file and extract 'src=172.16.148.27 dst=10.52.10.10' > out of each line that contains 10.52.10.10, but get lost with writing the > information and am not sure if I should .re at all. Could you send a few lines of "in.txt"? I can help better. > import re > > infile = open("

Re: [Tutor] File parse

2007-07-17 Thread Tiger12506
> Here you go. > > I've been working on something like this, but it's mixing the 2. Thanks > for > helping me. Okay. But you still haven't given me a few lines of your input file. The "in.txt" that you are using in your code. > import re > > infile = open("in.txt","r") > outfile = open("out.tx

Re: [Tutor] File parse

2007-07-17 Thread Tiger12506
>I sent a sample of the file "testin.txt" in the last email. Here are the > lines themsevles: Oh! Sorry. I didn't look in the attachments - I expected the lines in the email. My mistake. Try this ~~ :-P ## import re infile = open("testin.txt","r") outfile = open(

Re: [Tutor] reading random line from a file

2007-07-18 Thread Tiger12506
Yuck. Talk about a one shot function! Of course it only reads through the file once! You only call the function once. Put a second print randline(f) at the bottom of your script and see what happens :-) JS > This method only keeps one line in memory, only reads through the file > once, and doe

Re: [Tutor] reading random line from a file

2007-07-18 Thread Tiger12506
> import os > import random > > text = 'shaks12.txt' > if not os.path.exists(text): > os.system('wget http://www.gutenberg.org/dirs/etext94/shaks12.txt') > > def randline(f): >for i,j in enumerate(file(f, 'rb')): Alright. But put randline in a loop and you open a lot of file handles. Thank g

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Tiger12506
> results.write(c.getoutput('svnadmin lslocks ' + eval(row))) Mmm... I want to add that the eval function tries to execute whatever is in the argument passed as python expressions. >>> eval('1+2') 3 >>> row = 4 >>> 1+row 5 >>> eval('1+row') 5 >>> JS __

Re: [Tutor] Python Image library

2007-07-18 Thread Tiger12506
You know the height and the width of the image, no? So you know that every 'width' number of pixels will start a new row. So if you wanted say the fifth row down, second pixel, how would you find it? The 1st line: 'width' number of pixels The 2nd line: 'width' number of pixels The 3rd line: 'wi

Re: [Tutor] Python Image library

2007-07-18 Thread Tiger12506
> if you start counting at the 0th row and 0th column, this will give you > the 4th row and 2nd column. > if you're counting from the 1st row and 1st column, this will give you > the 5th row and 3rd column. >> That number is the index to use to get the pixel at coords (2,5) >> > So this is act

Re: [Tutor] if and things

2007-07-18 Thread Tiger12506
> man that looks totally pythonic. What you had is correct though. Good job. JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if and things

2007-07-18 Thread Tiger12506
It's nice to see you haven't given up. A few suggestions to make you code a little more creative. > import time > > import ImageGrab # Part of PIL > from ctypes import * > > # Load up the Win32 APIs we need to use. > class RECT(Structure): > _fields_ = [ >('left', c_ulong), >('top', c_u

Re: [Tutor] reading random line from a file

2007-07-19 Thread Tiger12506
> I think the best strategy for this problem would be to build an index of > the offset of the start of each line, and then randomly select from this > list. > that makes each line equally probable, and you can set up your class so > that the index is only built on the first call to the function. >

Re: [Tutor] about importing a module

2007-07-19 Thread Tiger12506
I'm pretty sure that the one in the current directory gets imported first. However, it is much simpler to just change the name of the module in the current directory. JS > hello there, > > if i have a module that is in the same directory as the file that imports > it, > but that module has the

Re: [Tutor] about importing a module

2007-07-19 Thread Tiger12506
If the module has been imported before your code is run, it will be the library module (very important if working in IDLE which importants many modules, for example). But if it has not been imported before, the module in the current directory is imported first. You can check if a module has been

Re: [Tutor] python: how do I create a list of definitions?

2007-07-19 Thread Tiger12506
> I don't understand dict Think of dict as a dictionary. Literally. You have a word, you look up it's definition in the dictionary. A dictionary is made up of key, value pairs. So for your example: a_dict = {2243 : 'e', 2234 : 'p', 2235 : 'lol', 'how

Re: [Tutor] about importing a module

2007-07-23 Thread Tiger12506
>> If the module has been imported before your code is run, it will be the >> library module (very important if working in IDLE which importants many >> modules, for example). > So... how does IDLE go about importanting a module? ;) It's not *how* IDLE imports the module, but that fact that IDL

Re: [Tutor] another question ( unrelated )

2007-07-23 Thread Tiger12506
Perhaps everyone is trying too hard. Instead of trying to re-initialize the thread on error, let the thread create a new seperate thread and destroy itself naturally. Maybe a shot in the dark? :-/ JS ___ Tutor maillist - Tutor@python.org http://mai

Re: [Tutor] Generators

2007-07-23 Thread Tiger12506
> Please forgive my instrusion with some simple questions. I don't have any > formal training in programming so I have to get some guidance to some > terminology from time to time. What is a generator and what is its > purpose? Think of a generator as a list whose contents haven't been finished

Re: [Tutor] Generators

2007-07-23 Thread Tiger12506
> I am new to Python but not new to programming languages. I have seen this > "while 1" a lot. In fact in other languages I would expect "while 1" to > be > the same as "while TRUE". I have used that in other languages, but in the > definition below I would expect the "yield b..." to continue o

Re: [Tutor] Python program design

2007-07-23 Thread Tiger12506
> Then I would need to get the file size (but this is giving me an error at > the moment) >for name in files: >s = sum(getsize(join(root, name) >print s (syntax error here. I have not figured it out yet. There > are spaces in the path/filename combo) > (code to parse the file

Re: [Tutor] reading random line from a file

2007-07-23 Thread Tiger12506
> Significance of number 4096 : > file is stored in blocks of size 2K/4K/8K (depending > upon the machine). file seek for an offset goes block > by block rather than byte by byte. Hence for file size > < 4096 (assuming you have 4K block size), you will > anyway end up scanning it entirely so as wel

Re: [Tutor] Python program design

2007-07-24 Thread Tiger12506
>> The line should be >> s = getsize(join(root, name)) >> >> which will print the file size for each "name in files" > > > I got it a bit later. It didn't like me trying to apply it in a print > statement but if I assigned it first and the printed it, no issue. This should give you no problem ~ pr

Re: [Tutor] Text matching and replacing

2007-07-24 Thread Tiger12506
def findTestDirectories(path): os.chdir(path) directory_listing = os.listdir(os.getcwd()) -- Change this to directory_listing = os.listdir(path) Why look up the current directory when you have *just* set what it is? test_record_directories = [] fo

Re: [Tutor] Logging module

2007-07-25 Thread Tiger12506
> I found the problem. It was rather simple actually. I didn't have remote > logging enabled for syslog. Even though I was logging to localhost, for > some reason, it wouldn't work until I gave syslogd a -r at startup. > Thanks localhost is still remote, in that sockets are used to reach it. Th

Re: [Tutor] Text matching and replacing

2007-07-25 Thread Tiger12506
> Cheers for the critique I'll take you points on board .especially > this schoolboy error It's not an error, really. It will work. Just... not intuitive Errors are things that do not work. > One thing to note about the re expression is that the products are not > these were just substitutes

Re: [Tutor] Sum of Scores

2007-07-26 Thread Tiger12506
> bhaaluu wrote: >> Greetings, >> >> Beautiful! Thank you SO much for all the variations. >> I'm so sure I'll have much to learn from them. This >> is exactly the kind of stuff I'm currently studying. I assume this is for me. Thank you kindly! :-) >> I have a question for the list. >> After I po

Re: [Tutor] Livewires questions

2007-07-26 Thread Tiger12506
> Based on your guidance, I figured it out. I need to use a return > statement, which I had not encountered before. Now I wrote my > definitions in this way: > > def collided(): >if player_x == robot_x+0.5 and player_y == robot_y+0.5: > return True This could be simplified more. He

Re: [Tutor] Sum of Scores

2007-07-26 Thread Tiger12506
Note that OP constructed his list so that some values are weighted according to the user's decision (Aggressive or defensive), Just let's not forget that brilliance~ ;-) Suggestions below. > Here is a snippet that might work for one batter: > > #!/usr/bin/env python > # cricket.py > # 2007-07-2

Re: [Tutor] function declaration problems perhaps?

2007-07-25 Thread Tiger12506
> By the way, this is an important and fundamental subject about > Python. When I teach classes on Python, I always need to explain > Python's execution model, and I always struggle with it. So, > anything you can tell me that would help me teach this will be much > appreciated. > > Dave The way

Re: [Tutor] What exactly is [::-1]?

2007-07-26 Thread Tiger12506
> What are typeseq objects. Searching the python site on "typeseq" draws a > blank. > > Dick Moores I believe that means "sequence" type. list tuple string are the builtins I debated with myself about dict, decided that it doesn't fit the description. That should be all ordered sequence types.

Re: [Tutor] Sum of Scores

2007-07-27 Thread Tiger12506
Hmmm... interesting tie to another post... >>> x = timeit.Timer('random.random()','import random') >>> x.timeit(300) 1.0161026052194018 >>> y = timeit.Timer('random()','from random import random') >>> y.timeit(460) 1.0004307810070827 Dictionary lookups do take HUGE amounts of time. Intere

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Tiger12506
> ...some credit. I taught myself to program, from scratch, without access > to (or time for) any courses whatsoever... 5 years now...core > language...certain standard modules pretty well... complaint...won't get > much further...without a computer science degree. Wow. I'm so *shocked*. Most p

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Tiger12506
>> cPickle/Pickle question is AFAIR documented, > > But not in a manner totally clear to a newbie. An experienced > programmer will figure out that a C implementation is faster but > what does that meabn when your only reference is a few weeks > of Python? And why is there two modules if one is bet

Re: [Tutor] Which GUI?

2007-07-27 Thread Tiger12506
> As between Tkinter and wxPython, I started on Tkinter, but have been won > over to wxPython, although I've only played with it so far. The problem > with wxPython is that it's poorly documented, but there's a book out on it > now that you should beg, borrow or steal if you plan on using it. Tki

Re: [Tutor] os.path.exists(path) returns false when the pathactually exists!

2007-07-28 Thread Tiger12506
> Adam wrote: > >>From the library documentation: > Return True if path refers to an existing path. Returns False for > broken symbolic links. On some platforms, this function may return > False if permission is not granted to execute os.stat() on the > requested file, even if the path physically e

Re: [Tutor] putting python to use

2007-07-28 Thread Tiger12506
>> >> /usr/sbin/advxrun2.0 # starts server then >> open (path) apache.config for input ? >> > > I don't really understand what you want to do. If you want to write a > script that runs other programs, look at os.system() > http://docs.python.org/lib/os-process.html#l2h-2761 > > What do you mean b

Re: [Tutor] Sum of Scores

2007-07-28 Thread Tiger12506
>> > Well, I was trying to emphasize that it was, for pretty much all >> > intents >> > and purposes, infinite. >> >> Nope-nope-nope you're wrong :-)~ > > > The way I understood the 'period' of the random function was that after x > calls to the function, you would start getting the same pattern

Re: [Tutor] Sum of Scores

2007-07-30 Thread Tiger12506
> So normally, after the period is up, it would choose a new seed? or does > it repeat after the period whether or not the time has changed? It would repeat whether or not the time has changed, naturally. How would the algorithm know when the period has finished? The mersenne twister is based o

Re: [Tutor] attribute error - quick addition

2007-07-30 Thread Tiger12506
> Thanks Alan and Kent (for the sorting notes)! > > Alan...I guess I thought outfile2 had data. { i.e., > outfile2=open('missmeas.dat','w') } Argghh!!! No, no, no! Attribute Error! No matter how much data you have in the file, you will *never* be able to call sort on it, because file objects d

Re: [Tutor] comparing lists, __lt__ and __gt__

2007-07-30 Thread Tiger12506
> That having been saisd their is another use for >> which is to append > output to a file, as in: > > print 'hello world' >> myfile > > sends the string to myfile instead of to stdout. (Although I couldn't > get this to > work when I tried it!) > > Alan G. >From Dive Into Python Section 10.2

Re: [Tutor] os.path.exists(path) returns false when the pathactually exists!

2007-07-30 Thread Tiger12506
> Just to check, try to do away with the backslashes. Windows will accept > a path with forward slashes just as well: > > os.path.exists("c:/winnt/file_name") > > Nope, even, with the use of forward slashes in the path, it still returns > false > > What am I doing wrong here ? > > This is driving

Re: [Tutor] C program

2007-07-31 Thread Tiger12506
Hello people of the world. This question is not a Python related question, but I thought I might just throw it in here and see if there are any C old-timers who could help out. I have a string with space and I would like to remove the space before comparing but I don't know how to go about doin

Re: [Tutor] os.path.exists(path) returns false when the path actually exists!

2007-08-02 Thread Tiger12506
> I have never understood Microsoft changing things from one release to > another. In the beginning extensions were IIRC always visible. > > Every time I configure a computer I have to spend a lot of time undoing > the initial settings so my users can get their work done! Even though I completely

Re: [Tutor] os.path.exists(path) returns false when the path actually exists!

2007-08-02 Thread Tiger12506
>> Granted, all of these are just visual sugar and are completely worthless. >> But they have provided Microsoft with much money because more useless >> people >> can use computers. It is because these people do not wish to learn, do >> not >> have the capacity, or just plain would rather pay thr

Re: [Tutor] [OT] Re: os.path.exists(path) returns false when the path actually exists!

2007-08-02 Thread Tiger12506
>> But they have provided Microsoft with much money because more useless >> people can use computers. > > That's a little harsh, isn't it? A person using a computer is not useless > by virtue of not wanting to program or understand technical details, but > rather just wanting to use it for its fun

Re: [Tutor] Which GUI?

2007-08-02 Thread Tiger12506
I did that once for a very good fiction book I wanted to read. <$2. for transfer. It was worth it to me. Agreed. Definitely a good system. JS > On Thu, Aug 02, 2007 at 12:48:05PM -0400, scott wrote: >> >> We do have a inter-library exchange here as well, but I have never used >> it and don't kno

Re: [Tutor] Python Editors .. which do you reccomend for a amateur?

2007-08-04 Thread Tiger12506
It is found in python25\lib\site-packages\wx-2.6-msw-unicode\wx\py pyAlaMode.py I'm sure there are shortcuts, but that's where it is. JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Tiger12506
Nice idea. Written style is average. Other tutors have discussed issues with performance, style, etc. I thought I would mention that whenever I am asked to give my opinion on a script, I compare it to something I have written/would write. In this case, I have already written. In my version, it

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Tiger12506
> The modern way seems to be to look at the change amount given by the > cash register and count that out starting with dollars... So true... tsk tsk. That's because the teenagers that give you the change do not know how to count it back. What a great idea to write a program that can show them ho

Re: [Tutor] superscript with easydialogs

2007-08-06 Thread Tiger12506
> It turns out, no, Unicode won't work, but using x\99 for the TM character > does, at least on my system (no idea if this will be universal): That's strange. Windows is Unicode based! All text operations done in Windows are first converted to unicode, calculated, and then back. That's even been

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Tiger12506
> Traceback (most recent call last): > File "domainspotter.py", line 150, in >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 r

Re: [Tutor] Checking for custom error codes

2007-08-07 Thread Tiger12506
> This is exactly what I needed, awesome! Looks like this is what you were > saying to do?: > http://docs.python.org/tut/node10.html#SECTION001050 Why ~ exactly! A link tells a thousand words. (Or maybe more.) So does that mean that a link is inherently more valuable than a pictu

Re: [Tutor] how to sort a dictionary by values

2007-08-07 Thread Tiger12506
> Just curious: Is there a reason to use __getitem__() over itemgetter (used > in the example in my reply)? __getitem__ is a method builtin to a dict object. itemgetter 1) has to be imported 2) is more generically used, therefore probably using a more generic/slower algorithm JS

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] 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 tutori

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

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

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 scenario

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 = > > self.attr1 = attr1 > > return self.attr1 > > > such that: > > foo_instanc

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

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] 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 tha

Re: [Tutor] Fw: Wrong version of Python being executed

2007-11-20 Thread Tiger12506
I haven't seen anybody write down the full picture so that we are not misled. Windows chooses which python to use in this manner. 1) If you double click on a .py file in windows, it looks in the registry for the command string that pertains to "open". The .py extension has a default value that

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: Sent: Wednesday, November 28, 2007 4:00 PM Subject: [Tutor]

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 head

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 >> se

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 fu

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] 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] 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] 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. > > T

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

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

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 be

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 bee

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

  1   2   >