Re: [Tutor] Question regarding syntax

2007-07-11 Thread Eric Brunson
Michael Klier wrote: > Dave Kuhlman wrote: > >> On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: >> >>> I'm editing some code from Mailman and seeing: >>> >>> legend = _("%(hostname)s Mailing Lists") >>> >>> > > I am no python pro but I guess that funtction _() ist just a

Re: [Tutor] How do you install EGG files

2007-07-11 Thread Eric Brunson
Terry Carroll wrote: > On Wed, 11 Jul 2007, shawn bright wrote: > > >> Hey there all, >> i got the news that storm was released as open source. Storm is a db orm for >> python. >> i have a downloaded package and i would like to play with it, but it does >> not come with any install instructions.

Re: [Tutor] Here is newbie doc on how to implement generators

2007-07-13 Thread Eric Brunson
Dave Kuhlman wrote: > I find iterators and generators fascinating. So, in order to try > to understand them better myself, I've written up some notes. I'm > hoping that these notes might help someone new to the generators > and iterators in Python. You can find it here: > > http://www.rexx.c

Re: [Tutor] Importing question

2007-07-13 Thread Eric Brunson
Dick Moores wrote: > At http://wiki.python.org/moin/SimplePrograms I found this code: > > > import itertools > > def iter_primes(): > # an iterator of all numbers between 2 and +infinity > numbers = itertools.count(2) > > # generate primes

Re: [Tutor] CGI Calculator

2007-07-16 Thread Eric Brunson
Darren Williams wrote: > Hi all, > > I am a Python convert coming from a JavaScript background Welcome to Python, Darren. > (as you can probably tell) and am currently writing my first > application using Python which will be a calculator for an online game > I used to play (thought it would

Re: [Tutor] CGI Calculator

2007-07-16 Thread Eric Brunson
Darren Williams wrote: > Ok, now i've modified my script but am getting another error, i've > commented a few useless (hopefully) lines out - > > #!/usr/bin/env python > > import cgitb; cgitb.enable() > import cgi > > [snip] > 17 while usedPockets > totalJunkies - labSpace * 17: > >

Re: [Tutor] CGI Calculator

2007-07-16 Thread Eric Brunson
JS programmer it shouldn't take very long. This is probably closer is what I infer you're looking for: while usedPockets > totalJunkies - labSpace * 17: Tokens = Tokens + 1 usedPockets = (usedPockets - totalJunkies + labSpace) * 17 totalJunkies = totalJunkies +

Re: [Tutor] CGI Calculator

2007-07-16 Thread Eric Brunson
kens: 1 Tokens: 2 ... Tokens: 6000 etc... > > Can you recommend any tutorials for me? > > ----- Original Message - > From: "Eric Brunson" <[EMAIL PROTECTED]> > To: "Darren Williams" <[EMAIL PROTECTED]> > Cc: > Sent: Monday, July 16,

Re: [Tutor] interpreter restarts

2007-07-17 Thread Eric Brunson
Sara, Stick with ssh, IDE's are a crutch. ;-) But that's just my opinion, others may differ. However, if you were running an X server on your local machine, you could use SSH to allow you to run GUI programs from your remote server. There are a couple of free X servers for Windoze, but runn

Re: [Tutor] Style question with classes and modules

2007-07-19 Thread Eric Brunson
Tino Dai wrote: > On 7/19/07, *Kent Johnson* <[EMAIL PROTECTED] > > wrote: > > > The two advantages that I can see are, I don't need to type as > much, and > > there would be a speed up in the execution of code. > > Why do you expect a speedup? > > > In th

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

2007-07-19 Thread Eric Brunson
elis aeris wrote: > like, I am doing string substitution: > > > if x = 2243: > string = string + "e" > if x = 2234: >string = string + "p" If I'm following correctly... How about using a dict: list = { 1: 'a', 2: 'b', 3: 'c', 2342: 'p', 4234: 'e' } if x in list: string += list[x]

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

2007-07-19 Thread Eric Brunson
Tiger12506 wrote: >> 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', >

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

2007-07-19 Thread Eric Brunson
Luke Paireepinart wrote: > elis aeris wrote: > >> like, I am doing string substitution: >> >> >> if x = 2243: >> > this will always evaluate to true. > Good eye, I missed that completely... However, that will actually throw an exception. >>> if x = 1: File "", line 1 if x = 1:

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-22 Thread Eric Brunson
Alan Gauld wrote: > "Dave Kuhlman" <[EMAIL PROTECTED]> wrote > > >> If you find yourself opening multiple sessions to the same >> UNIX/Linux box, you might want to look into screen, which enables >> you to create and switch between multiple sessions. >> > > >> For more on screen, do "man

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Eric Brunson
Alan Gauld wrote: > "Eric Brunson" <[EMAIL PROTECTED]> wrote > > >>>>http://en.wikipedia.org/wiki/GNU_Screen >>>> >>>> >> You can only see one screen at a time as far as I know. If you need >> split scree

Re: [Tutor] IDLE Usage - was Interpreter Restarts

2007-07-23 Thread Eric Brunson
Eric Brunson wrote: > Alan Gauld wrote: > >> "Eric Brunson" <[EMAIL PROTECTED]> wrote >> >> >> >>>>>http://en.wikipedia.org/wiki/GNU_Screen >>>>> >>>>> >>>>>

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Brunson
Philippe Niquille wrote: > > Hi > > > I have a hard time sorting an object list. Perhaps this is kind of a > noob question, but I would very much appreciate any help! > > > Using django I get a QuerySet of Score objects which are sorted by the > actual score, the actual score divided by the max.

Re: [Tutor] sorting objects in lists by 2 attr

2007-07-23 Thread Eric Brunson
is similar to querysets). > See http://www.djangosnippets.org/snippets/207/ > <http://www.djangosnippets.org/snippets/207/> for details. > > Philippe > > Am 23.07.2007 um 19:28 schrieb Eric Brunson: >> Philippe Niquille wrote: >>> >>> >>> Hi &g

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Eric Brunson
What does the command "which python" say? Khamid Nurdiev wrote: > Yes, I have the same problem with running python scripts from console > in Debian, the line "#! /usr/bin/python" doesn't help. I have to type > "python script.py" in order to run the script.py file. > > On 7/26/07, *Greg Lindstro

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tonu Mikk wrote: > Tiger12506 wrote: > >>> 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: >>

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tiger12506 wrote: >> 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 >> Gr

Re: [Tutor] Running Python on Gentoo

2007-07-26 Thread Eric Brunson
Greg Lindstrom wrote: > Eric Brunson wrote: > >> What does the command "which python" say? >> > [EMAIL PROTECTED] ~ $ which python > /usr/bin/python > > HTH, > --greg > > > Wow, Gentoo sucks more than I thought. ;-) I can't

Re: [Tutor] Pass variable on command line

2007-07-26 Thread Eric Brunson
jason wrote: > Hello, > > I have a situation where I have 2 lists > > List1 = ['blue', 'red', green'] > List2 = ['red', 'yellow', 'orange'] > > And I would like to pass the list name on the command line like so > > ./test.py List1 > > I know I can get the argument using sys.argv[1] > >

Re: [Tutor] Livewires questions

2007-07-26 Thread Eric Brunson
Tonu Mikk wrote: > Eric Brunson wrote: > >> Tiger12506 wrote: >> >> >>>> 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 >>>> definition

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
Andreas Kostyrka wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Barton David wrote: > >> I mean no offense and lay no blame. It's simply that I feel like I've >> been led up a nice gentle beach and suddenly I'm dodging boulders at the >> bottom of a cliff. >> >> I've learned to

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
Barton David wrote: > > *Eric Brunson* wrote: > > > It seems like new programmers today expect to be spoonfed their > > information like they were in grammar school. They don't know what it > > is to hack a Makefile to get a package to compile or break out an &g

Re: [Tutor] Remove certain tags in html files

2007-07-27 Thread Eric Brunson
Sebastien Noel wrote: > Hi, > > I'm doing a little script with the help of the BeautifulSoup HTML parser > and uTidyLib (HTML Tidy warper for python). > > Essentially what it does is fetch all the html files in a given > directory (and it's subdirectories) clean the code with Tidy (removes > dep

Re: [Tutor] Remove certain tags in html files

2007-07-27 Thread Eric Brunson
Eric Brunson wrote: > Sebastien Noel wrote: > >> Hi, >> >> I'm doing a little script with the help of the BeautifulSoup HTML parser >> and uTidyLib (HTML Tidy warper for python). >> >> Essentially what it does is fetch all the html files in a give

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
re plenty of people that make a living at those occupations that aren't the towering persona's of the field, but having talent will get you good faster and having no talent means you're going to have to work hard to achieve mediocrity. Now *this* thread has gone seriously phi

Re: [Tutor] Remove certain tags in html files

2007-07-27 Thread Eric Brunson
I've included. Hope this gets you started, e. Eric Brunson wrote: Eric Brunson wrote: Sebastien Noel wrote: Hi, I'm doing a little script with the help of the BeautifulSoup HTML parser and uTidyLib (HTML Tidy warper for python). Essentially what it does is fetch all t

Re: [Tutor] Which GUI?

2007-07-27 Thread Eric Brunson
scott wrote: > Hi, > > now that I have a very basic understanding of Python I would like to > take a look at programming in a GUI. Which GUI is generally the easiest > to learn? > > Easiest depends on your background. I was a Mac developer back in the day, so WXPython was easy for me

Re: [Tutor] Shelve del not reducing file size

2007-07-27 Thread Eric Brunson
Python is like democracy. It isn't perfect, but it's the best thing come up with so far. ;-) Barton David wrote: > Eric Brunson wrote: > > You seem like a smart guy that's having a bad day, so I'm cutting you > > slack. > > Thanks Eric. Yes I did in

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Alan Gauld wrote: > "Andreas Kostyrka" <[EMAIL PROTECTED]> wrote > > >>> a lot to build the Tacoma Narrows bridge... Similarly you don't >>> need >>> much math to build a GUI friont end to a database, but you need >>> >> I would question even that one can write a good GUI frontend to a >

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: > * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) > >> Barton David wrote: >> >>> *sigh* I'm really going off Python. >>> >> >> In what way is it Python's fault that the dbm database doesn't reclaim >> disk space? > > It's actually how most data

Re: [Tutor] Shelve del not reducing file size

2007-07-28 Thread Eric Brunson
Andreas Kostyrka wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Eric Brunson wrote: > >> On Sat, July 28, 2007 4:01 am, Thorsten Kampe wrote: >> >>> * Kent Johnson (Fri, 27 Jul 2007 08:06:33 -0400) >>> >>>

Re: [Tutor] don't repeat yourself; question about code optimization CORRECTION

2007-07-29 Thread Eric Brunson
[EMAIL PROTECTED] wrote: > > > On 7/23/07, *Bob Gailer* <[EMAIL PROTECTED] > > wrote: > > A correction to the code at the end. The test of > self.total_num_of_items > should precede the pop(0) > > > > Bob, I spent today studying what you've been telling me and

Re: [Tutor] build a really simple "json" api from a db

2007-07-30 Thread Eric Brunson
Picio wrote: > The beginning idea was to build a json API myself. Since I need only > to generate json from a db, maybe Django is too much. I'm a Django > beginner. I don't know Turbogears. > I've not found anything like: "how to build a json api". > Maybe MySqldb+simplejson is the enough? > Or > I

Re: [Tutor] attribute error - quick addition

2007-07-30 Thread Eric Brunson
Sara Johnson wrote: > No luck finding tutors. I don't make enough. Sara, Alan didn't say to find a tutor, he suggested you read a tutorial. You seem to be having problems with very basic python concepts and his suggestion was to take an hour or two and *read* some gentle introductions that w

Re: [Tutor] passing form data into a class

2007-07-31 Thread Eric Brunson
Dave Kuhlman wrote: > On Mon, Jul 30, 2007 at 08:32:55PM -0700, [EMAIL PROTECTED] wrote: > >> dear fellow Python enthusiasts, let's say I have a dictionary of keys and >> values obtained from a form submitted by a user. For each submitted form I >> will create the Application and Candidate clas

Re: [Tutor] Textual Captchas: Would like to show that bots can crack a simple text captcha

2007-08-01 Thread Eric Brunson
Kyle Brooks wrote: > Hi. > > Please look up captcha... I did not mean capture. > > Your response is hilarious, frankly, but not appropriate for this list :-) > Seeing that a) this is your second post here and b) you are the one asking the list for help, I don't think it's your place to decide

Re: [Tutor] gendata.py

2007-08-01 Thread Eric Brunson
What is it that you think makes it Unix specific? Que Prime wrote: > > This script appears to be written for Unix systems. Is there a way to > get it to work for PythonWin? > > from random import randint, choice > from string import lowercase > from sys import maxint > from time import ctime >

Re: [Tutor] Which GUI?

2007-08-02 Thread Eric Brunson
Richard Querin wrote: > On 8/2/07, Eric Brunson <[EMAIL PROTECTED]> wrote: > > >> Switching gears from linear to event driven programming is a pretty >> significant paradigm shift. Will this book help him get his head around >> that? >> >> &g

Re: [Tutor] Which GUI?

2007-08-02 Thread Eric Brunson
Richard Querin wrote: > On 8/2/07, scott <[EMAIL PROTECTED]> wrote: > > >> I was thinking about finding a copy of that book, so maybe starting >> WxPython would be easier then and not worry about Tkinter. Is "WxPython >> in Action" a very good book? >> >> > > I'm no programmer by trade, bu

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
Dick Moores wrote: > At 06:49 AM 8/6/2007, Kent Johnson wrote: > >> Dick Moores wrote: >> >>> http://www.rcblue.com/Python/changeMaker_revised_for_US_denominations.py >>> I'm still working at Python--been at it a while--and thought the >>> script was ingenious. Do the Tutors agree? Or is i

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
;__main__': comparetimings() Yields: 2.83604502678 0.000821828842163 3450.89498114 i.e. the division version runs about 3500 times faster for $100,000. It's a minor thing, but you asked how we'd improve the code. Math is a good thing to know. ;-) Dick Moores wrote: > On 8/6

Re: [Tutor] Ingenious script (IMO)

2007-08-06 Thread Eric Brunson
Dick Moores wrote: > At 10:16 AM 8/6/2007, Eric Brunson wrote: > > Your point about efficiency is well-taken. > >> def makechange( amount, denominations ): >> >> coins = {} >> for d in denominations: >> coins[d] = int( amount/d ) >>

Re: [Tutor] comparing two numpy arrays

2007-08-07 Thread Eric Brunson
Bob Gailer wrote: > Andy Cheesman wrote: > >> Hi people, >> >> If I've two numpy arrays, is there a non-looping way of finding common >> values. (the example below has identical shapes for the arrays but this >> may not be the case in my scenario) >> >> e.g >> a = array([0, 1, 2, 3, 4, 5, 6, 7,

Re: [Tutor] Large Scale Python websites

2007-08-07 Thread Eric Brunson
Alan Gauld wrote: > "OkaMthembo" <[EMAIL PROTECTED]> wrote > > >> Is anyone aware of any large scale web apps developed in Python? >> Please let >> me know of any that you know of... >> > > The Zope web site has many examples. > > But it depends how you define large scale. Most of the real

Re: [Tutor] subprocess and signals

2007-08-07 Thread Eric Brunson
Noufal Ibrahim wrote: > Hello everyone, >I've come across a situation which is somewhat confusing to me. >I googled for some details and came across another email thread on > this very list but couldn't really glean a solution out of it. > >I have a program (a compiled binary) for whic

Re: [Tutor] Losing the expressiveness of C's for-statement?/RESENDwith example

2007-08-07 Thread Eric Brunson
Stephen McInerney wrote: > Hi Alan, > > > [ snipage ] >> As to your particular case one non while option would be a generateor: >> >> def half(n): >> while int(n) > 0: >>n = n/2 >>yield n >> >> for x in half(300): print x, >> > > It's ok but it's visually clunky. while-l

Re: [Tutor] variable * raw_input

2007-08-09 Thread Eric Brunson
Dewight Kramer wrote: > Hello, > > So i am new to Python, and really to programming. I picked up book > and so far I like it. right now I am trying to figure out a problem > that I cant. > > It is a tipping program and I have assigned certain words to be a > certain % and then I ask the user

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

2007-08-14 Thread Eric Brunson
Michael Sparks wrote: > Tiger12506, > > > You are COMPLETELY missing the point. The __following__ code > > > foo = raw_input(...) > x = eval(foo) > > > ONLY works if the user has console access to the machine. > > If they have console access to the machine > AND you're wo

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

2007-08-14 Thread Eric Brunson
Michael Sparks wrote: > On Monday 13 August 2007 21:53, Kent Johnson wrote: > >> Hmm...could be a remote connection such as ssh, which precludes the >> sledgehammer though probably not the sort of mischief you can get into >> with eval()...perhaps there are untrusted remote connections where >>

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

2007-08-14 Thread Eric Brunson
Michael Sparks wrote: > On Monday 13 August 2007 21:53, Kent Johnson wrote: > >> Hmm...could be a remote connection such as ssh, which precludes the >> sledgehammer though probably not the sort of mischief you can get into >> with eval()...perhaps there are untrusted remote connections where >>

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

2007-08-14 Thread Eric Brunson
Luke Paireepinart wrote: > Eric Brunson wrote: >> Michael Sparks wrote: >> >>> On Monday 13 August 2007 21:53, Kent Johnson wrote: >>> >>>> Hmm...could be a remote connection such as ssh, which precludes the >>>> sledgehammer

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Eric Brunson
Dick Moores wrote: > When sending a reply to a post, to the list, should we also address > the reply to the author of the post to which we are replying? > (There's gotta be an easier way to say that..) If we do so, then the > author gets a duplicate of our reply. > > I've run some statistics (bu

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

2007-08-14 Thread Eric Brunson
ady compromised such that any damage done by eval(raw_input()) is trivial in comparison. I think the basic point that everyone has been making is: Using eval() on any uncontrolled input is a security risk, now matter what the source. Michael Sparks wrote: > On Tuesday 14 August 20

Re: [Tutor] Need help on "How to Think Like a Computer Scientist: Learning with Python".

2007-08-15 Thread Eric Brunson
I don't know of an answer key, but feel free to post questions about what you're having trouble with and we'd be happy to discuss various approaches among the list members. Vanneth Tea wrote: > Hello All, > > I am new to computer programming and chose to learn > Python. Now I am stuck with cer

Re: [Tutor] Getting Date/Time from a file and using it in calculations

2007-08-15 Thread Eric Brunson
[EMAIL PROTECTED] wrote: > Hello there > > Messing around with certain time and datetime objects, I have managed to > subtract a date/time from the present time thusly: > datetime is definitely a module that takes a little getting used to. > from time import * > (Bad form) > import datet

Re: [Tutor] Need to convert 1,987,087,234,456 to an int

2007-08-15 Thread Eric Brunson
Dick Moores wrote: > At 06:58 PM 8/15/2007, John Fouhy wrote: > >> You could do this: >> >> > def decomma(*t): > >> ... return int(''.join(str(i) for i in t)) >> > > What's that asterisk doing in decomma(*t)? Where do I go in the docs > to look it up? > > It's

Re: [Tutor] Efficiency of Doxygen on Python vs C++?

2007-08-17 Thread Eric Brunson
Stephen McInerney wrote: > Hi Alan, > > >>> My friend clarifies: "It's not the efficiency of doxygen that's the >>> question. The problem is that you can add fields to objects as you go in >>> Python so you need to do a deep analysis of the code to determine the >>> >> class >> >>>

Re: [Tutor] Efficiency of Doxygen on Python vs C++?

2007-08-17 Thread Eric Brunson
We're definitely on the same wavelength, Alan. :-) Alan Gauld wrote: > "Stephen McInerney" <[EMAIL PROTECTED]> wrote > > >> Eric, you misunderstood my point. >> I said you make a **token** assignment in the class defn simply >> to do two things: >> - 1) identify all the members in one place >

Re: [Tutor] Efficiency of Doxygen on Python vs C++?

2007-08-18 Thread Eric Brunson
Stephen McInerney wrote: > Kent, > > >>> I was asking if it's a recognized good programming practice to >>> declare and initialize *all* members in the class defn. >>> >> What do you mean by "initialize *all* members in the class defn"? >> > - obviously I meant to say do it in the __

Re: [Tutor] Convert bmp to mpeg

2007-08-21 Thread Eric Brunson
Per Jr. Greisen wrote: > Hi, > > I would like to make a method where I give a number of bmp-file as > argument and than create a mpeg format from these - is that possible > with python and which packages should I use? On my platform the ffmpeg suite is one of the de facto standards for creating

Re: [Tutor] subprocess and su

2007-08-21 Thread Eric Brunson
Tino Dai wrote: > Hi there, > > I'm have a tough time figuring out how to get su and subprocess > working. I have > > PIPE=subprocess.pipe > > sbp=subprocess.Popen(["su","-",stdin=PIPE,stdout=PIPE,close_fds=True,shell=True) > > > > how I thought that it was supposed to work was it would all

Re: [Tutor] A fun puzzle

2007-08-22 Thread Eric Brunson
R. Alan Monroe wrote: > I wrote a lame, but working script to solve this in a few minutes. A > fun puzzle. > > http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx > > Fun! for x in xrange(1, 100

Re: [Tutor] Converting code to string

2007-08-23 Thread Eric Brunson
Bernard Lebel wrote: > Hi Kent, > > When try your approach, I get an IOError. > > import inspect def myFunc(): > ... print 'hello world' > ... > s = inspect.getsource(myFunc) > Traceback (most recent call last): > File "", line 1, in ? > File

Re: [Tutor] capturing process's status with python

2007-08-23 Thread Eric Brunson
I'm a bit more of a Linux expert than a Python guru, so I don't know if there's a facility in python to do that. However, if you look in /proc, every running process has a directory corresponding to its PID and in that directory is a pseudo-file called "status" that you can get state informat

Re: [Tutor] Off Topic: xrange, WAS: Re: the and command

2007-08-24 Thread Eric Brunson
Kent Johnson wrote: > Dave Kuhlman wrote: > >> I thought xrange() returned an iterator. I was wrong. >> >> Actually xrange() returns an xrange object which, according to the >> docs, is "an opaque sequence". >> > > Interesting. So an xrange object is an iterable sequence, not an iterator.

Re: [Tutor] Equivalent of && in Python?

2007-08-27 Thread Eric Brunson
wormwood_3 wrote: > I have a script that reads some local system information, performs some > calculations, and then launches some terminal windows: > > # Spawn the 4 terminals, with needed positions and sizes, then exit > commands.getoutput("%s --geometry=%dx%d+%d+%d --working-directory=%s" % \ >

Re: [Tutor] Shared Class Attribute

2007-08-28 Thread Eric Brunson
Ricardo Aráoz wrote: > Hi, > Hi Ricardo, In the future, please start a new thread with a new email and not a reply to an existing thread. Compliant mail clients thread based on headers you may or may not see in your client, and this email is part of the thread you replied to called "[Tutor

Re: [Tutor] Shared Class Attribute

2007-08-28 Thread Eric Brunson
Ricardo Aráoz wrote: > Eric Brunson wrote: > >> Ricardo Aráoz wrote: >> >>> Hi, >>> >>> >> Hi Ricardo, >> >> In the future, please start a new thread with a new email and not a >> reply to an existing thread.

Re: [Tutor] Trouble with script not parsing out text

2007-08-29 Thread Eric Brunson
Tim Finley wrote: > I get the following when running a script. > > TypeError: argument 1 must be string or read-only character buffer, > not _sre.SRE_Pattern First, please post the entire error report when asking for help. In this case I can tell you what the problem is, but in others the con

Re: [Tutor] Starting classes

2007-08-31 Thread Eric Brunson
Ara Kooser wrote: > Hello, > I read Alan Gauld's and How to Think Like a Computer Scientist > section on classes. So I tried to write a simple room class. My goal > is to write a short text adventure using classes. Here is the code: > > class Area: > def _init_(self, name, description): >

Re: [Tutor] or synxtax in if statement

2007-08-31 Thread Eric Brunson
David Bear wrote: > I think I want to be lazy and express this > > if a == b | a = c > (if a equal b or a equals c) > using > > if a == b | c > > it seems to work.. but I'm not sure if it is correct -- and I haven't seen > any documentation on using this type of syntax. > > > The pipe is the "bi

Re: [Tutor] parsing response from SOAPpy request

2007-09-01 Thread Eric Brunson
Alan Gauld wrote: > "Sean Cronin" <[EMAIL PROTECTED]> wrote > > >> The response comes back as XML document but when I check it with >> type(result) it shows the the response is a string. >> > > Thats right the string is the XML document, just as if you had read it > from a file with the rea

Re: [Tutor] advanced sorting

2007-09-04 Thread Eric Brunson
What version of python are you using? chinni wrote: > > > In Advance Sorting by giving the keywords to sort the list.But, iam > getting the fallowing errors > > >>> x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a'] > >>> x.sort(key=len) > Traceback (most recent call last): > File "", l

Re: [Tutor] Python / CGI

2007-09-06 Thread Eric Brunson
Michael Connors wrote: > Hi, > If you have your own server to run it on, I think it would make sense > to use one of the Python web frameworks that are out there. I used > cherrypy for my first web-based python project and I found it very > easy to learn and develop in quickly. That's debatable

Re: [Tutor] Python / CGI

2007-09-06 Thread Eric Brunson
Kent Johnson wrote: > Eric Brunson wrote: > >> Michael Connors wrote: >> >>> Hi, >>> If you have your own server to run it on, I think it would make sense >>> to use one of the Python web frameworks that are out there. I used >>> cher

Re: [Tutor] making math problems mmmm fun

2007-09-10 Thread Eric Brunson
When you get done with this math problem you should consider a book on punctuation. Not using it makes your sentences run together and difficult to read. :-) Honestly, I just gave up after the first two lines. max baseman wrote: > haha :) yeah it's the new imp stuff i like parts of the idea but

Re: [Tutor] Apache, CGI-BIN, Python

2007-09-10 Thread Eric Brunson
Alan Gauld wrote: > "Ryan" <[EMAIL PROTECTED]> wrote > > >> I am running a Linux box and cannot find my Apache cgi-bin to put >> some >> python scripts in. I know I probably have to create one but don't >> know >> where and how. >> > > I think there are several places that you can create

Re: [Tutor] Fw: Apache, CGI-BIN, Python

2007-09-11 Thread Eric Brunson
ALAN GAULD wrote: > Forwarding to the list > > NB Use Reply-All when replying to the tutor list. > > Alan G. > > - Forwarded Message > From: Ryan <[EMAIL PROTECTED]> > To: Alan Gauld <[EMAIL PROTECTED]> > Sent: Tuesday, 11 September, 2007 5:32:33 AM > Subject: Re: [Tutor] Apache, CGI-B

Re: [Tutor] Fw: Apache, CGI-BIN, Python

2007-09-11 Thread Eric Brunson
Eric Brunson wrote: > ALAN GAULD wrote: > >> Forwarding to the list >> >> NB Use Reply-All when replying to the tutor list. >> >> Alan G. >> >> - Forwarded Message >> From: Ryan <[EMAIL PROTECTED]> >> To: Alan Gaul

Re: [Tutor] extract hosts from html write to file

2007-09-11 Thread Eric Brunson
sacha rook wrote: > Hi I wonder if anyone can help with the following > > I am trying to read a html page extract only fully qualified hostnames > from the page and output these hostnames to a file on disk to be used > later as input to another program. > > I have this so far > > import url

Re: [Tutor] Image Analysis

2007-09-11 Thread Eric Brunson
Just my opinion, but I didn't mind the attachments, I felt they added quite a bit to the discussion and I certainly appreciated the input on the application of the libraries. My opinion on your tone, I'll keep to myself. Dave Kuhlman wrote: > On Wed, Sep 12, 2007 at 01:57:35AM +0200, Eike Welk

Re: [Tutor] Class Inheritance

2007-09-13 Thread Eric Brunson
Lamonte Harris wrote: > Okay > > class A: >def __init__(self,x,y): > self.x = x > self.y = y > >def save(self,fn): > f = open(fn,"w") > f.write(str(self.x)+ '\n') > # convert to a string and add newline > f.write(str(self.y)+'\n') > return f # for

Re: [Tutor] evaluating AND

2007-09-13 Thread Eric Brunson
The first is how I would code it. Python guarantees that compound boolean statements are processed from left to right and also that the AND operator will "short circuit" the rest of the evaluation, since the rest of the line cannot change the falseness of the entire statement. Orest Kozyar wr

Re: [Tutor] Class Inheritance

2007-09-14 Thread Eric Brunson
ethod1 b.method2() OUTPUT> classB: method2 super(B,b).method2() OUTPUT> classA: method2 # super() only works because B is a subclass of "object" by virtue or A being derived from "object" b.method3() OUTPUT> classB: method3 a.method3() Traceback (most recent cal

Re: [Tutor] Problem with assigning list elements

2007-09-14 Thread Eric Brunson
That is not the expected behavior and not the behavior I see: Python 2.5.1 (r251:54863, May 1 2007, 13:27:01) [C] on sunos5 >>> z = [[1,2],[3,4]] >>> z[0][0]=100 >>> print z [[100, 2], [3, 4]] [EMAIL PROTECTED] wrote: > I'm having a problem assigning numbers to a 2-D list. > > for the 2d li

Re: [Tutor] Finding even and odd numbers

2007-09-19 Thread Eric Brunson
>>> t = timeit.Timer( '1000%2') >>> t.timeit(100) 0.25893402099609375 >>> t = timeit.Timer( '1000&1') >>> t.timeit(100) 0.2567589282989502 It's almost insignificantly faster. However as a programmer and a mathematician, I disagree with your position that the bitwise operation is mo

Re: [Tutor] Threading in Python

2007-09-19 Thread Eric Brunson
James wrote: > Thanks for the quick reply. > > Interesting. I'm a little overwhelmed with the different terminology > (fork, spawn, thread, etc.). I'm under the impression that I'm > supposed to use os.fork() or os.spawn() for something like what I'm > trying to do (start multiple instances

Re: [Tutor] Optimisation of prime number program (cont. from finding prime numbers)

2007-09-21 Thread Eric Brunson
Boykie Mackay wrote: > Ok,I have learnt how to generate prime numbers and how to 'split' > input.The above was to help me solve the second 'SPOJ' > challenge,PRIME1.The challenge can be found at > > > I have written my solution and tested it

Re: [Tutor] Quick question

2007-09-21 Thread Eric Brunson
There are quite a few ways to do what you want. Here's are a few variations on a theme: try: if not any( ( len(queuePacket['procSeq']), len(queuePacket['opacSeq']), len(queuePacket['keySeq']) ) ): # Do your stuff here do_stuff() except KeyE

Re: [Tutor] print array

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > Let a=(3,4,7), b=[3,4,7]. > If I type > print '%d + %d = %d' %(a) > I get > 3 + 4 = 7 > > But if I type print '%d + %d = %d' %(b), I get errors. > > If there is a way for doing this kind of type dirrectly from array. No, but it's trivial to convert an array

Re: [Tutor] questions about tuples

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > I want to do some loops. Each loop will generate a tuple. Eventually I > want to put tuples together in a higher level of tuple. Do you know > how to do this? > > Say a=(1,2,3), b=(4,3,2),c=(9,5,6). I want to get a tuple as ((1,2,3), > (4,3,2),(9,5,6)). >

Re: [Tutor] how to convert array into tuple

2007-09-26 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get > ((1,2),(3,4),(5,6)). What should I do? First, you read some documentation and tutorials on the language, then you iterate over the list and build tuples out of the elements. > > Thank you! >

Re: [Tutor] detecing palindromic strings

2007-09-28 Thread Eric Brunson
Christopher Spears wrote: > I'm trying to write a script that detects if a string > is palindromic (same backward as it is forward). This > is what I have so far: > > #!/usr/bin/env python > > my_str = raw_input("Enter a string: ") > > string_list = [] > > for s in my_str: > string_list.a

Re: [Tutor] A simple Question...

2007-10-02 Thread Eric Brunson
Alan Gauld wrote: > "Suzanne Peel" <[EMAIL PROTECTED]> wrote > > >> However both suggestions will only give me that name of the 1st file >> executed eg when I use execfile('EA_Owner.py') the name returned >> when >> the __file__ or sys.argv[0] is executed always EA_Owner.py . >> > > You

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
Elaine wrote: > Does anyone know which is the more efficient way of > finding a square root in Python: > > sqrt(x) or x ** 0.5 > I dunno, let's check: >>> import timeit >>> t = timeit.Timer( "12 ** .5" ) >>> print t.timeit(1000) 2.29147315025 >>> t = timeit.Timer( "sqrt(

Re: [Tutor] questions about previous emails

2007-10-05 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > I am a new-comer to [EMAIL PROTECTED] I guess a lot of my future > questions may have been asked by others already. > > As I am a new-comer, I don't have the previous emails. > > I wonder whether there is a way for searching for previous questions > and answers

  1   2   >