Re: [Tutor] Removing a file from a tar

2007-06-28 Thread Jacob S.
>* Adam A. Zajac <[EMAIL PROTECTED]> [2007-06-27 11:26]: >> I was reading over the documentation for the tarfile module and it >> occurred to me that there didn't seem to be a way to remove an >> individual file from the tar. >> >> For example, suppose I did this: >> >> import tarfile >> tar = tarf

Re: [Tutor] (no subject)

2007-06-22 Thread Jacob S.
Here the same thing >def rock(self): >value = "rock" >computer_guess == random.choice(["scissors", "paper", "rock"]) >def scissors(self): >value = "scissors" >computer_guess == random.choice(["scissors", "paper", "rock"]) > def paper(self): >value

[Tutor] capwords, maketrans

2007-06-13 Thread Jacob S.
Hi guys. I was just wondering what's going to happen to capwords and maketrans when the string module is finally terminated. Is python just not going to support those to functions anymore? Or are they going to suddenly be implemented as string methods at the last minute? Or are they on the list

[Tutor] Need help with wxListCtrl

2005-11-30 Thread Jacob S.
Resending due to change in subject line -- adding [Tutor] Also, I wish to point out now that I've noticed, the spacing on the diagram hasn't persisted If anyone wants a jpg or something, let me know. > Hi, long time no see. > > For you Spanish speakers: > > Yo tenía que aprender a poco españ

[Tutor] Need help with wxListCtrl

2005-11-30 Thread Jacob S.
Hi, long time no see. For you Spanish speakers: Yo tenía que aprender a poco español mientras no estaba aquí. Si ustedes son aburrido y me desean ayudar aprender más, mandan una -- ¿Qué desea decir "email"? Y no mandan el (email) en el (mailing list), por favor. (It would be much, much apprec

Re: [Tutor] class and methods/functions

2005-10-22 Thread Jacob S.
>> def nameCheck(self, value): >> > import re >> > tempREG = re.match('.*:.*',value) >> > return str(tempREG) != 'None' >> >> Still a syntax error here! >> > Code is working as I thought it would. What syntax error do I have? This could be written better. def nameCheck(s

Re: [Tutor] code improvement for beginner ?

2005-10-21 Thread Jacob S.
> Text mode is the default, you have to specify the 'b' if you want binary > mode. And open() seems to accept any mode quite happily: > > >>> f=open('build.xml', 'rt') > >>> f > > >>> f.close() > >>> f=open('build.xml', 'rabcd') > >>> f > > > Kent I'll bet you'll find that open() is coded somet

Re: [Tutor] Can anyone teach me...?

2005-10-21 Thread Jacob S.
>>>I use Delphi for most of my real-world heavy duty GUI work. >>> >> Have you tried Boa Constructor? It is quite similar to Delphi. It builds >> wxPython. > > I tried it a couple of years ago but couldn't get it to work! > > Even if I had it didn't offer many of the features of VB/Delphi such > as

Re: [Tutor] script question

2005-09-29 Thread Jacob S.
Why are you importing string?   1) You don't seem to use it anywhere 2) Use string methods instead   Jacob - Original Message - From: Chris Hallman To: tutor@python.org Sent: Wednesday, September 28, 2005 7:35 AM Subject: Re: [Tutor] script quest

Re: [Tutor] Quick way to find the data type

2005-09-29 Thread Jacob S.
I don't believe that eval() *would* work quite as intended either. For example: eval('a random string') SyntaxError and McGuire's method othermethod('a random string') 'a random string' Another example eval('file') othermethod('file') 'file' That is, of course, if I understood the McGuire

Re: [Tutor] Why won't it enter the quiz? (off topic)

2005-09-29 Thread Jacob S.
Wow! What an argument... A couple of comments on the code > {code} > > import random > > def add(a,b): >answer = a+b >guess = float(raw_input(a," + ",b," = ")) This is easier IMHO, but the same guess = float(raw_input("%s+%s="%(a,b))) >return answer, guess > > num1 = random.choice(ra

Re: [Tutor] threading problem in GUI

2005-09-16 Thread Jacob S.
> Hello there ! > i am having a problem with threading. > OK, i have this GUI app that i am building with pygtk. > there is a process (four actually, just working on getting one right now) > that needs to run in the background. > there is a button that starts the background function. But, it locks

Re: [Tutor] Website Retrieval Program

2005-09-16 Thread Jacob S.
> Daniel Watkins wrote: > >>I'm currently trying to write a script that will get all the files >>necessary for a webpage to display correctly, followed by all the >>intra-site pages and such forth, in order to try and retrieve one of the >>many sites I have got jumbled up on my webspace. After star

Re: [Tutor] hi

2005-09-16 Thread Jacob S.
If you would like to talk to me directly, (without the use of cluttering the list -- I mean, you can, they don't mind, but one-on-one is okay with me) I have very few things to do, and would be happy to help you out. I have a tad of experience in python (about a years' worth of fiddling, actual

Re: [Tutor] directory recursion

2005-09-16 Thread Jacob S.
Okay, how about this? # import os from fnmatch import fnmatch def simplewalkgen(toplevel): """Yields full paths of all the text files in all the subdirectories""" for root,dirs,files in os.walk(toplevel): for x in files: ok = os.path.join(r

Re: [Tutor] how to create a generic instance of an object?

2005-09-16 Thread Jacob S.
Two further suggestions. 1) Do you believe each class have to be in a seperate file? Is that habit from Perl? Try putting each class in one library file and then importing as needed/all into main script to be used as desired, maybe coexistent with the dictionary approach mentioned 2) Ho

Re: [Tutor] Where did those spaces come from?

2005-09-16 Thread Jacob S.
> As a file object, we can use the methods that files provide: > >http://www.python.org/doc/lib/bltin-file-objects.html > > But the one we'll probably want is 'write()': the write() method of a file > object lets us send content out, without any adulteration:

Re: [Tutor] CREATING A PR.EXE FROM A PR.PY

2005-09-16 Thread Jacob S.
For some odd reason I love doing this...   1) Save this code and run it as is 2) Screen instructions *should* be intuitive enough 3) When entering file name, include extension (it uses the difference between py and pyw to know if it needs console) 4) When done, there should be two ne

Re: [Tutor] Importing modules/classes

2005-09-16 Thread Jacob S.
> You need to call the init method of the inherited class(es) from > within your init. It's conventional to call the superclass > constructor > before doing your own initialisation so it should look like: > >def __init__(self, num): >Thread.__init__(self) >print "__init__: Num =

Re: [Tutor] GETTING AN _.EXE VERSION OF _.PY program to run on amachine that does not have Python installed on it.

2005-09-16 Thread Jacob S.
Might I suggest that you use the built in min() and max() because they are probably faster.   Jacob - Original Message - From: JackA To: tutor@python.org Sent: Monday, September 12, 2005 11:50 PM Subject: [Tutor] GETTING AN _.EXE VERSION OF _.PY pro

Re: [Tutor] running scripts with windows

2005-09-14 Thread Jacob S.
Well, if your python installation went correctly, all you should have to do is save the script with a .py extension and then double click on it.   Jacob   - Original Message - From: Ed Hotchkiss To: tutor@python.org Sent: Wednesday, September 14, 2005 4

Re: [Tutor] Generate 8 digit random number

2005-09-02 Thread Jacob S.
> Hey Tutors > > I saw a lot of responses...After analyze them I have resumed two > approaches > > 1.- Generate a random number from 0 to and fill this number with > zeros (Almost everyone's approach) > 2.- Generate 8 random numbers and join them (Pietro and someone else) > > Which one of

Re: [Tutor] Counting help

2005-09-02 Thread Jacob S.
I'll do this again, just because I like sending email. Very similar to Alan G.'s -- but with the do first, ask forgiveness later a = ["Joe Smith", "Joe Smith", "Jack Smith", "Sam Love", "Joe Smith"] b = {} for x in a: try: b[x] += 1 except KeyError: b[x] = 1 Access count like this, of co

Re: [Tutor] Sort a Set

2005-09-02 Thread Jacob S.
How about this? Not only does it count each element, but you can also get a sorted set without using set! a = [24,24,24,16,16,15,15] b = {} for i in a: try: b[i] += 1 except KeyError: b[i] = 1 print b li = b.keys() print li li.sort() print li li.reverse() print li has output {24: 3, 16

Re: [Tutor] Alternative File I/O for Tuples (fwd)

2005-07-01 Thread Jacob S.
- Original Message - From: "Don Parris" <[EMAIL PROTECTED]> To: Sent: Thursday, June 30, 2005 12:23 AM Subject: Re: [Tutor] Alternative File I/O for Tuples (fwd) > On Wed, 29 Jun 2005 14:09:41 -0400 > Kent Johnson <[EMAIL PROTECTED]> wrote: > >> Don Parris wrote: >> > ### playing with

Re: [Tutor] A more Pythonic way to do this

2005-07-01 Thread Jacob S.
>Good, good. I probably wouldn't have been able to help you if it was something so simple but that >screws up your program and makes it hard to find out just what is going on. Anyway good look with >anymore tidying on that you might be doing. Any chance of a copy?>>Adam   Denise, Can

Re: [Tutor] Help with Challenge number 5

2005-05-12 Thread Jacob S.
Okay, I've tried pickling, marshal, marshalling, serialization, and amazingly pi because I noticed that pickle was under the section 3.14 however, none of this worked, so, I hate to ask again but, could you go one step farther? Thanx, Jacob ___ Tuto

[Tutor] Help with Challenge number 5

2005-05-12 Thread Jacob S.
Is there anyone on the list right now who knows what to do with yes! pickle! on challenge number 5 -- Any hints appreciated. I've tried the most common combinations of yes and pickle in the url path, but to no avail. By the way, this means I solved challenge 4. TIA, Jacob __

Re: [Tutor] #NameError: global name is not defined

2005-05-12 Thread Jacob S.
> Hi, > > I'm having difficulty understanding why the following code doesn't work: > > > getfr.py > #import pymetar > # > #class wReport: > #def __init__(self,metarcode="CYYC"): #weather for calgary INTL > #self.METARCODE=metarcode > #rf=pymetar.ReportFetcher(self.METARCODE) > #

Re: [Tutor] Python riddles

2005-05-08 Thread Jacob S.
Ok, I'm stuck on #4 I tried using urllib like the source hints... but, when I run my automation of the process of typing in the new nothing, I run through about 15 pages, then I notice that they add an extra number in the text. 60167 or something like that This is encouraging. 1) I'm must be get

Re: [Tutor] Generator function question?

2005-05-08 Thread Jacob S.
> import sys > > def neverEndingStatus(currentChar_ = '|'): >while 1: >if currentChar_ == '|': >currentChar_ = '\\' >elif currentChar_ == '\\': >currentChar_ = '-' >elif currentChar_ == '-': >currentChar_ = '/' >elif currentCha

Re: [Tutor] font/text in pygame

2005-04-27 Thread Jacob S.
def displaybalance(): for score, name in mylist: slip = 30 - len(name) slip_amt = slip*" " print "%s%s%s" % (name,slip_amt,score) (I did this with the print command to make sure it would produce what I wanted, three strings for the three sample scores I put in this dummy

Re: [Tutor] crash - switching between text window andgraphics/gamewindow (high score)

2005-04-27 Thread Jacob S.
I haven't been following this thread, so apologies in advance if this is something you've already done --- Have you tried running the program from a command prompt? To do this, go to Start-->Run and type 'cmd'. Then change to the directory with your script in it ('cd ' followed by the full dire

Re: [Tutor] More Function Questions (Joseph Q.)

2005-04-17 Thread Jacob S.
Hi all, Another function question. def bar(x, y): return x + y bar(4, 5) So I can put anything I want in there. What good is a function like that? Alright, so what good is this function? def bar(x,y,z): ##Where in this case x, y, and z are strings return x+z+y bar("a","b","-") 'a-b' bar("1

Re: [Tutor] Has anyone ever tried to convert the textual output of thedis module to another language

2005-04-16 Thread Jacob S.
Just curious. Googling for 'python "dis module" convert "another language" ' only got two hits. So maybe no one is trying it? I was just daydreaming about a native python compiler, and wondered how feasible it would be. Well, from the way I understand the google search works, you would have to hit

Re: [Tutor] newbie intro to pickle

2005-04-15 Thread Jacob S.
Thanks, Tony, your example is much clearer (to me!) than that on the python page. A couple quick questions about it: So the .dump command is, in effect, saving the file, correct? which takes the object you're saving (in my case it would be high_scorelist), and ("filename",". what is the "w" ?)

Re: [Tutor] high score lists

2005-04-15 Thread Jacob S.
Re: pickle: Tried to look into how to use this - looks like it involves opening/closing files...? and dumping? and usr bins? ha ha. LOST. This might have to be another thread! Pickle is simple enough. # import pickle filename = "myfile.txt"## Change this with an appropriate fi

Re: [Tutor] high score lists

2005-04-15 Thread Jacob S.
You can think of the "key" option like this: when sort comes to compare elements x and y it gives you the option of telling *what* you want to compare about x and y. You might, for example, want to sort a list of strings based on their *length* not on their alphabetical position. To do so, wri

Re: [Tutor] Re: Defining a function (Joseph Q.)

2005-04-14 Thread Jacob S.
Also I would like to point out that def foo(*args): #this allows for any number of arguments to be passed. The *args is powerful when used correctly. *args is a list of any length of arguments being passed to the function and/or class, and the arguments passed can be any type/object you want to p

Re: [Tutor] Cell Bio Newbie Here

2005-04-11 Thread Jacob S.
Ok, it's a logic error in the while loop. Starting at the beginning: you can't compare the value of "password" until the user inputs the value, which is why it's requiring you to put password = "foobar" at the top. Otherwise, password has no value, and as far as the interpreter is concerned, it

Re: [Tutor] OO newbie

2005-04-07 Thread Jacob S.
2- what are the differences between self.__DoubleUnderscore self._SimpleUnderscore Double Underscores are way cooler! Here's why. Single underscores are just subtle clues to the user of the class that you aren't specifically supposed to call that function of the class. IOW, its used internally bu

Re: [Tutor] Can't find MSVCR71.dll

2005-04-06 Thread Jacob S.
The way I did it was google for "download msvcr71.dll" and found a good place to download the file-- < 500K --- then I put the dll file in C:\windows\system32 folder. Then it worked and I didn't worry about it anymore. Easy enough, and you don't have to worry about that specific problem eve

Re: [Tutor] Py2exe (Joseph Q.)

2005-04-05 Thread Jacob S.
Type this into the interpreter and post the results - copy and pasted, not hand typed. import sys for x in sys.path: print x## This is indented It should give you a list of paths -- these are all of the paths that python looks for modules in. My guess is that you don't have the fo

Re: [Tutor] Calendar question

2005-04-05 Thread Jacob S.
Also, I have been looking for some exercises to do using Python, obviously (and unfortunately) they need to be at a beginner level. Or better if anyone wants to send me one to do I would be very grateful I know a few exercises -- those that I have done. Some are beginner, some are difficult. Use

Re: [Tutor] Float precision untrustworthy~~~

2005-03-31 Thread Jacob S.
An early language translator app was fed 'Out of sight, out of mind' and then the result fed back in for reverse translation. The output was: 'Invisible, lunatic' Cute, Alan. I like it! Jeff - thanks for the insight. I guess I think more in theory than in reality sometimes. Kent - thanks for your

Re: [Tutor] Float precision untrustworthy~~~

2005-03-31 Thread Jacob S.
I understand what you are talking about, but I tend toward just making it one of the things to remember when working with floats. (I've been bitten a lot when I forget to use '==' instead of '=', too!) Yeah, but it threw me for a loop, because I could find *no*e way to compare a float and an int

Re: [Tutor] A Newbie Printing Question

2005-03-31 Thread Jacob S.
Cool! Does anybody know of... I guess a rather *thorough* tutorial of win32? for the very reason that I don't know that this existed, and there may be other things I can use that I'm missing... TIA, Jacob Richard Lyons wrote: I have little experience with programming. I have Python installed on

Re: [Tutor] A Newbie Printing Question

2005-03-31 Thread Jacob S.
1) For plain text use the old DOS trick of sending output direct to the PRN: file/device - I can't remember if this still works in XP but I can't think why not... The only reason I can think of is that Windows XP is not directly based on DOS, wereas the other versions were. In so doing, they h

[Tutor] Float precision untrustworthy~~~

2005-03-28 Thread Jacob S.
I've already deleted the recent thread-- But sometimes I agree with he who said that you can't trust floats at all. The scientific theory suggests that if an output is not what it should be, then the hypothesis is untrue. In this case, the hypothesis is the fact that float division should always

Re: [Tutor] re question

2005-03-27 Thread Jacob S.
Kent -- when pulling out just the numbers, why go to the trouble of splitting by "," first? import re pat = re.compile(r"[^\d.]*") t = """SigWind: 857hPa, , 21.0C, 20.1C, 210 @ 9kts SigWind: 850hPa±, , , , 205 @ 11kts Std Lvl: 850hPa, 1503m, 16.8C, 15.7C,

Re: [Tutor] Defining functions

2005-03-26 Thread Jacob S.
pt, no whitespace at the front, and no trailing \n) using sys.stdin.readline()? gabe On Fri, Mar 25, 2005 at 11:02:43AM -0500, Jacob S. wrote: Yeah. And they're thinking of removing raw_input() too. I think it's good to have a __builtin__ user input function. Why should we have to import

Re: [Tutor] Defining functions

2005-03-25 Thread Jacob S.
Yeah. And they're thinking of removing raw_input() too. I think it's good to have a __builtin__ user input function. Why should we have to import sys everytime we want user input? Almost every program that newbies write uses it, and advanced programmers also if they're using console programs.

Re: [Tutor] I need some guidance

2005-03-23 Thread Jacob S.
My two bits... Use the python interpreter a lot! Run through the examples in the tutorial, see the output piece by piece, then make small variations and see the output. For example, when the tutorial passes one variable to a function, change the variable and see the output. Then see if you can

Re: [Tutor] Filtering a String

2005-03-20 Thread Jacob S.
I'm trying to filter a file, to get rid of some characters I don't want in it. The easiest thing to do is use the string method replace. For example: char = "1" a = open("Myfile.txt","r") b = a.read() a.close() b = b.replace(char,"") a = open("Myfile.txt","w") ## Notice "w" so we can replace th

Re: [Tutor] Okay, something's funky

2005-03-19 Thread Jacob S.
Oh thanks!! Sometimes I just look blind... Jacob Jacob S. wrote: Hi everyone. Very simple set up for the problem, strange problem. class Deck: def __init__(self): self.cards = [] for suit in range(4): for rank in range(1,14): self.cards.append(Card(suit

[Tutor] Okay, something's funky

2005-03-19 Thread Jacob S.
Hi everyone. Very simple set up for the problem, strange problem. Cards.py ### ## Taken almost directly from Thinking Like a Computer Scientist class Card: suitList = ["Clubs","Diamonds","Hearts","Spades"] rankList = ["","Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"]

Re: [Tutor] Re: Convert doesn't work... I'm stumped

2005-03-16 Thread Jacob S.
Ahh... I found that out today. A little more rest, I guess. As for unit testing, I've seen it used, but I've never implemented it. I've tried doc string testing with doctest, but I find I can do better just using the interactive interpreter. (I don't know why. Impatience I guess. Maybe I just want

Re: [Tutor] Convert doesn't work... I'm stumped

2005-03-16 Thread Jacob S.
Oh, god!! I found my problem... I was using the inverses incorrectly -- in Advanced Calculus and I can't even do algebra correctly. To make a long story short, in the second functions I was putting the x in the denominator when it needs to be in the numerator... But! Your post is not in vain, D

[Tutor] Convert doesn't work... I'm stumped

2005-03-15 Thread Jacob S.
Okay, not a very descriptive subject, but here goes... This is the code ### from decimal import Decimal as D """Everything is first converted to meters, and then converted to the unit you want to extend usage. dic[unit] = (unittometers,meterstounit) """ dic =

Re: [Tutor] creating a tab delimited filename

2005-03-15 Thread Jacob S.
that is exactly what i am looking for, but how would i add this to my filename??? should i use this: output_file = open(os.path.join(self.Save_Session.GetValue(), time.strftime('%Y%m%d%H%M')), 'w') the self.Save_Session.GetValue() is generated by a dirdialog Uck,uck, uck, no... That's what Kent's

Re: [Tutor] re help

2005-03-14 Thread Jacob S.
roup_delimiter.join(addressgroups) fi = raw_input("Output file to use? ") fi = open(fi,"w") fi.write(newtext) fi.close() ### But your probably using re to study it, though. Just an alternative option. I'm trying to keep all the different

Re: [Tutor] and once i have learned how to program ?

2005-03-12 Thread Jacob S.
In IDLE, go to File, New Window. Type in your scripts there. Go to file, click save, and save it with a py extension ex. "myscript.py" Since you're on XP, you should be able to double click on it... If you can't, then you have to go into file associations and junk like that.

Re: [Tutor] (no subject)

2005-03-05 Thread Jacob S.
I want to third the whitespace and comments. Also, looking at your code I notice that each of your while 1: play = raw_input("What is your choice? ") #Aks use to enter a choice from the menu if play == '3': #If user picks 3 print "\nHave a nice day!\n" #Tell them to have a nice day sys.exit() #Then

Re: [Tutor] Linked List

2005-03-04 Thread Jacob S.
I'm taking a shot in the dark and answering here. Have you tried making a copy of the list, iterating over the copy, and changing the original based on the copy? Jacob Hi, Any body has any idea on how to implement a linked list in python? Ordinary python lists are not quite the same. what i need

Re: [Tutor] Recursive Tkinter buttons

2005-02-27 Thread Jacob S.
Yay! Thanks for the tips Michael/Alan - works a treat, although I must admit, I'm not sure what Lambda does. Adam Lambda is basically a function without a name that can be used inline. Take for example, this code. def funct(x): return sin(x) is the same as funct = lambda x: sin(x) There seems to

Re: [Tutor] How do you share a method (function) among several objects?

2005-02-27 Thread Jacob S.
Is it possible to put all of those objects in their own module, having the function you describe as a module defined function? For example pseudo code ### Lib.py ### def function(x): return stuff class C1: def __init__(self): init stuff def funct(self,arg): return func

[Tutor] Interpreter level objects

2005-02-23 Thread Jacob S.
Hi everyone! Let's see, my topic of discussion for today is this. If the psyco package can work on an interpreter level--I don't know if that's the right terminology, but this is what it does. Say I put the code import psyco psyco.full() in sitecustomize.py and run a random file that I have al

Re: Re: [Tutor] Problems with test cgi script on windows XP/Apache

2005-02-23 Thread Jacob S.
I find it's convenient to get rid of that problem. The easy thing to get to folder options You can 1) Go to control panel and click folder options 2) Open a folder, click the view menu, and choose folder options Either way it's the same screen. Now, in the middle tab, there is a checkmark about hal

Re: [Tutor] Fwd: Delivery Status Notification (Failure)

2005-02-14 Thread Jacob S.
- From: Liam Clarke <[EMAIL PROTECTED]> To: Tutor Tutor Date: Mon, 14 Feb 2005 15:09:24 +1300 Subject: Re: [Tutor] error message I was wondering about that also, I've only ever used .group() when I've got named groups using (?P) On Sun, 13 Feb 2005 21:04:22 -0500, Jacob S. <[EMAIL PRO

Re: [Tutor] Negative IF conditions

2005-02-14 Thread Jacob S.
And now for something only slightly different: education research shows that people process "positives" far more quickly and accurately than "negatives", so for readability I often code like: Well, that depends on whether we're optimists or pessimists... ;-) I probably process negatives alot fas

Re: [Tutor] error message

2005-02-13 Thread Jacob S.
Okay... Cool. Jacob group() defaults to returning group 0 which is the whole match. >>> import re >>> string = 'My phone is 410-995-1155' >>> pattern = r'\d{3}-\d{3}-\d{4}' >>> re.search(pattern,string).group() '410-995-1155' Kent ___ Tutor maillist

Re: [Tutor] Tweaking list comprehensions

2005-02-13 Thread Jacob S.
Hello, I am fine tuning list comprehensions (at least my understandng thereof), and I'm not near a Python interpreter at the moment, so I was wondering if someone could tell me if I did OK - def approachA(files): isHTML = [] for filename in files: if filename.endswith('.htm') or filename.endswith('

Re: [Tutor] error message

2005-02-13 Thread Jacob S.
Dive into Python, an excellent tutorial has a case study on this very same topic. The biggest problem that nobody has mentioned yet is the fact that group() will not have anything unless you explicitly tell it to group it. I.E. pattern = r'(\d{3})-(\d{3})-(\d{4})' You need the parenthesis to "c

Re: [Tutor] Downloading from http

2005-02-12 Thread Jacob S.
urllib or urllib2 or maybe httplib maybe? urlopen( url[, data]) Open the URL url, which can be either a string or a Request object. data should be a string, which specifies additional data to send to the server. In HTTP requests, which are the only ones that support data, it should be a

Re: [Tutor] References in loops

2005-02-12 Thread Jacob S.
Of all the odd quirks of python, this is the only thing that has bitten be in the butt. And several, several times. List comprehensions have similar limitations as python lambdas, however, so I guess the only way to execute several expressions on the item in the list would be to pass the item to

Re: [Tutor] Match on current line and next line. Possible?

2005-02-08 Thread Jacob S.
It's getting late, so if someone already suggested something like this, just pretend to smack me across the face, and I'll flinch later... import re fi = open('/somefile','r') ## Don't do readlines and bring the whole file in memory... match1 = re.compile('^Python') match2 = re.compile('^/tBLA

Re: [Tutor] manipulating a file

2005-02-08 Thread Jacob S.
import os srcfile = open('/var/log/httpd-access.log.bak', 'r') dstfile = open('/var/log/httpd-access.log', 'w') while 1: lines = srcfile.readlines() if not lines: break #print lines for i in lines: if len(i) < 2086: #print i dstfile.write(i) srcfile.c

Re: [Tutor] calling subroutines into program

2005-02-08 Thread Jacob S.
Liam Clarke wrote: oh? Is is the negative? No, the decimal fraction. It's easy enough to try it: Not exactly, it's a combination of string *and* decimal fraction. int('-945') -945 int('-945.0') Traceback (most recent call last): File "", line 1, in ? ValueError: invalid literal for int(): -945.0 i

Re: [Tutor] freeze

2005-02-05 Thread Jacob S.
Hey! Good question! I have no idea. Jacob Schmidt P.S. Here's a cool setup script for py2exe if you want to try it though. ### setup.py ### # Run the build process by entering 'setup.py py2exe' or # 'python setup.py py2exe' in a console prompt. from distutils.core import setup import py2exe impor

Re: [Tutor] Hex to Str - still an open issue

2005-02-04 Thread Jacob S.
The binary value is the same as the hex value. The binary representation is 00010100, but unfortunately Python doesn't support binary in its string formatting(although it does in int()! Uh, question. Why not? It seems that all simple types should be included. Since the computer stores it as bin

Re: [Tutor] freeze

2005-02-04 Thread Jacob S.
My two bits. 1) Download py2exe found here http://py2exe.sourceforge.net/ 2) Make a setup file -- intructions can be found through above link, I think. (Hey that rhymes!) 3) Ask if you want my totally cool automation technique 4) Ask more questions, go on we don't mind. HTH, Jacob Schmidt Hi, I i

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-04 Thread Jacob S.
an experience where a rogue process or editor has trashed the indentation in your Python and how you recovered from it. Only in mailing list emails!! I'll second that!!! Jacob Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-04 Thread Jacob S.
Now this is a concrete example of how lambda simplifies code, at least for me because it does not clutter my mental name space. Also it is much shorter. However it should be said that this is very much a question of taste. Agreed. Which would make it pointless to remove in a future release. ;-) H

Re: [Tutor] Better structure?

2005-02-03 Thread Jacob S.
Although, (and this will be rough) a list comprehension would be probably do the same thing j=[1, 2,3,4, 5,6,7,8] q = [if not item % 2 for item in j] I really think I've got that 'if not item % 2' wrong, as I can't test it, but I'd be hoping for print q [1, 3, 5, 7] Backwards. ;-) q = [item for it

Re: [Tutor] i have a question???

2005-02-03 Thread Jacob S.
rt math math.pi 3.1415926535897931 math.pi / 6 0.52359877559829882 type(math.pi) type(6) type(6.0) mike On Thu, 3 Feb 2005 16:04:25 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: >From what I understand, range() no longer allows you to use floats as arguments. (Or it gives you a deprication warnin

Re: [Tutor] Are you allowed to shoot camels? [kinda OT]

2005-02-03 Thread Jacob S.
MessageI hate to be a spoiled sport and do exactly what you said to not do. But I present two counter examples 1. The indentation IS the closure on flow statements. Indenting starts a flow, then removing indentation on next line closes the flow. Again its all about the language. If your English

Re: [Tutor] v.00001

2005-02-03 Thread Jacob S.
I should have thought of that! Here I looked at the concept of generators, what they can do, and totally overlooked a user defined range type function that allows floats. Any reason why range doesn't? Is it for speed, or to keep the arguments pure (without floating point errors)? Jacob There ar

Re: [Tutor] Better structure?

2005-02-03 Thread Jacob S.
You can also iterate over a copy of the list and change the original. i.e. a = range(10) for x in a[:]: if x % 2 == 0: a.remove(x) print a And yes, I did test it this time. Jacob >for x in string: >if x in chars: >string[i] = '' I just have a hangover from other

Re: [Tutor] i have a question???

2005-02-03 Thread Jacob S.
From what I understand, range() no longer allows you to use floats as arguments. (Or it gives you a deprication warning) This tutorial must be old. Not the only way, but. import math num = 0 while num <= 2*math.pi: ## Do stuff to figure pi/6 things num = num + math.pi/6.0 ## Don't forget .

Re: [Tutor] Better structure?

2005-02-02 Thread Jacob S.
Interesting topic. Jacob, Writing library code is a difficult and unrewarding task - I've been there so I sympathise, however... I wouldn't say that... So, how would one go about this in a non broken code way? Don't they have something like what I'm requesting. Its not broken, its just different to

Re: [Tutor] Better structure?

2005-02-01 Thread Jacob S.
g[len(stripstring):] as a method or something? Messy, just plain messy. Jacob Schmidt Jacob S. wrote: I don't know who's going crazy here... but I checked that straight from the python 2.4 interpreter... >>> a = "go on long buddy" >>> a.lstrip('gonl&#

Re: [Tutor] Tkinter questions

2005-02-01 Thread Jacob S.
I suggest looking at Introduction to Tkinter. http://www.pythonware.com/library/tkinter/introduction/index.htm HTH, Jacob Hello, I got some Tkinter questions that I need the answer for to complete a little project of mine: 1. How can I make the program to open in a X*Y sized window ? 2. How can I o

Re: [Tutor] Better structure?

2005-02-01 Thread Jacob S.
I don't know who's going crazy here... but I checked that straight from the python 2.4 interpreter... Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. a = "go on long buddy" a.lstrip("gonl") ' on lo

Re: [Tutor] Better structure?

2005-01-31 Thread Jacob S.
Ah, I like. BTW, it was a few months ago, not days... but the thought still counts. At least you remember. I was getting stumped by the difference in comparing y The check for seeing what the first word is made me slamp my forehead... Thanks! Jacob Schmidt On Mon, 31 Jan 2005, Jacob S. wrote

Re: [Tutor] Better structure?

2005-01-31 Thread Jacob S.
def start(): lots of lines... global xaxis global yaxis Its traditional to put global statements at the top of the function. Also you only need one line to list all of the global variables global radiusaxis global radiusaxis2 What, like global radiusaxis, radiusaxis2 Simil

[Tutor] Better structure?

2005-01-31 Thread Jacob S.
I think this thing is screaming for better structure, but previous attempts at using oop for it have failed. I think Derintegral is okay, I'm focusing on FunctionGrapher5.py--but you can comment on both. (To Johan Nilsson: I haven't had time to implement Simpson's rule instead of Reimann's sum y

Re: [Tutor] TypeError: can only concatenate list (not "str") to list

2005-01-31 Thread Jacob S.
You can also do... Umm, if you're going to make nmr and pbr the values you're printing, why are you printing the values? Nevermind, look at this instead. BTW, aren't rows the horizontal things on tables? nmr = nmrows[i] pbr = cols[0] print "%s\t%s" % (nmr,pbr) >nmr = nmrows[i] pbr = cols[0] prin

Re: [Tutor] carriage return on windows

2005-01-29 Thread Jacob S.
Thanks Kent and Max! Wow, I didn't know it did that. I'm too dumb to figure it out on my own I guess... Oh well! I found a cool new thing to play with at least! Thanks, Jacob On Jan 30, 2005, at 02:40, Jacob S. wrote: I don't think that's what he wants. I think he

Re: [Tutor] carriage return on windows

2005-01-29 Thread Jacob S.
I don't think that's what he wants. I think he wants to *overwrite* what's in the shell with new output. For example. Python 2.4 (#Stuff) ... Percent complete: 50 becomes... Python2.4(#Stuff) ... Percent complete: 51 so that the whole line is overwritten. In my experience, this is not possible

Re: [Tutor] Naming conventions (was: Should this be alist comprehension or something?

2005-01-29 Thread Jacob S.
_go_funny_, _and_code_hard_to_read_in_my_opinion. _u_n_d_e_r_s_c_o_r_e_s_ _a_r_e__u_g_l_y_ I got out of the habit of using them really fast. Also, __ & _ tend to have special meaning in Python (which is bad enough as it is), so I don't use them for that reason as well. Liam Clarke On Fri, 28 Jan 2005 22:5

  1   2   >