Re: [Tutor] SSH with Python

2008-02-27 Thread Eric Brunson
Tom wrote: I have a webfaction server (highly recommended btw) and I'm trying to use automate some tasks over ssh but I'm not having much luck with pyssh http://pyssh.sourceforge.net/ . Some of the docs mention methods that don't exist in the version I downloaded, such as pyssh.run. I'm

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-27 Thread Eric Brunson
Alan Gauld wrote: "bob gailer" [EMAIL PROTECTED] wrote i don't really understand that. you are trying to say that the tests from the online judge are not "exactly good" ? Yes that's exactly what I'm saying. At least one test case has a non-decimal

Re: [Tutor] SSH with Python

2008-02-27 Thread Eric Brunson
Eric Walstad wrote: Eric Brunson wrote: Tom wrote: I have a webfaction server (highly recommended btw) and I'm trying to use automate some tasks over ssh but I'm not having much luck with pyssh http://pyssh.sourceforge.net/ . Some of the docs mention methods

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-27 Thread Eric Brunson
Alan Gauld wrote: Eric Brunson [EMAIL PROTECTED] wrote Alan Gauld wrote: Glad we both noted the smileys. :-) However, there is a bit of a serious point here too in that users never ask for data validation (at least mine never do!) they just expect it. So I still maintain that any

Re: [Tutor] designing POOP

2008-02-07 Thread Eric Brunson
bhaaluu wrote: What is the equivalent of JUnit in Python? The article says that JUnit is used for unit tests, or you can write your own. Since I don't have a clue, writing my own is probably out the question. Also I'm not familiar with Java, and am just learning Python OOP, so I'm not getting

Re: [Tutor] cx_Oracle help

2008-02-05 Thread Eric Brunson
Greg Lindstrom wrote: Hello, I'm trying to help out a friend and am stumped. Can you help me out? Thanks, --greg Hi Greg, I fought with this for a long, long time when I was trying to get cx_Oracle to work with the latest Oracle Instant Client (which I like to call Oracle Instant Crap)

Re: [Tutor] os.system() problem

2008-02-05 Thread Eric Brunson
Aditya Lal wrote: On 04/02/08 10:42 PM, Eric Brunson [EMAIL PROTECTED] wrote: dave selby wrote: Hi all, I am not sure if this is a Python or bash issue :). In bash if I execute 'motion' with the following ... [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ motion /dev/null [1

Re: [Tutor] Bad time to get into Python?

2008-02-04 Thread Eric Brunson
Dotan Cohen wrote: On 03/02/2008, Kent Johnson [EMAIL PROTECTED] wrote: I did a little research on the question of running the same script unmodified in Python 2.6 and 3.0. It seems that there is no consensus opinion and it may depend on your personal tolerance for compatibility cruft.

Re: [Tutor] os.system() problem

2008-02-04 Thread Eric Brunson
dave selby wrote: Hi all, I am not sure if this is a Python or bash issue :). In bash if I execute 'motion' with the following ... [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ motion /dev/null [1] 10734 [EMAIL PROTECTED]:~/.kde/share/apps/kmotion$ I get what I expect, a background

Re: [Tutor] PHP Python suggestions....

2008-02-04 Thread Eric Brunson
Michael Langford wrote: OT Aside: Anyone ever used PSP pages? Seems like a good substitute for PHPish tasks, but I've not seen many users. I have, but I find generating my HTML with classes I wrote to be more to my tastes. I did PHP for years and I'm just not a fan of the way it mixes

Re: [Tutor] Please comment on

2008-01-31 Thread Eric Brunson
I think the page is a little busy, but relatively clean overall. I don't like the popup that makes me interact with the page when I load it. Is that what you were looking for or would you like to be a little more specific? pee one wrote: Please comment on

Re: [Tutor] ssh script

2008-01-23 Thread Eric Brunson
washakie wrote: Hello, I'm trying to write a script which will allow me to create a reverse tunnel from a remote machine using SSH -R I know the reverse tunnel script works on it's own run from the shell, but I don't want to leave it open always... does anyone have any ideas on how to make

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

2008-01-18 Thread Eric Brunson
Ole Jensen wrote: Hi I made a small python program at home and tried to send by email attachments to my studymates. The attachment however shows up as a strange text the first lines look like this: M1F]R_AG(#(@+2 R(=E;F5R871OF5R([EMAIL PROTECTED]R#0H@5!I[EMAIL PROTECTED])4!O

Re: [Tutor] MySQLdb install issue

2008-01-15 Thread Eric Brunson
There is at least on client library that the mysql package needs to link against. You either need to install the libraries on the client machine or else build the package statically linked on the server machine and move it over prebuilt. John wrote: Hello, Does anyone know how to

Re: [Tutor] Rs: help, thanks very much.

2008-01-15 Thread Eric Brunson
Did you read the entire discussion at http://www.ibiblio.org/g2swap/byteofpython/read/local-variables.html? What did you understand and not understand? Sincerely, e. bill.wu wrote: i am new guy. i ask a easy question. why the first one havex,the second one doesn't have x. what is

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Eric Brunson
Olivier Lefevre wrote: Are you talking about the prompt? Yes. But if you refer to a loop when would you ever be evaluating expressions inside a loop without assigning them? Some method calls return a value that you may not be interested in but which will still be

Re: [Tutor] Suppressing output in interactive mode

2008-01-11 Thread Eric Brunson
Olivier Lefevre wrote: Then assign the return value to a variable and never use it. That feels obfuscated; definitely not an elegant solution. When I'm done with interactive development and save the substance to a script I'd have to chase these bogus assignments to junk variables and

Re: [Tutor] run in deamon mode?

2008-01-10 Thread Eric Brunson
Allen Fowler wrote: Thank you for all the great tips... I'll try a few and see what works. I must say that I'm a bit surprised that the Python Std library does not have a module for this. Are all python scripts expected to be small user-mode utilities? I really agree with you on that.

Re: [Tutor] send file/mail to imap

2007-12-28 Thread Eric Brunson
Tim's pretty spot on in his ruminations below, I just wanted to add a few comments. Read inline. Tim Golden wrote: Tim Michelsen wrote: I have a mbox file locally on my notebook. I would like to send this file to my IMAP account using python. Ummm. There seem to be two possible

Re: [Tutor] Careful Dictionary Building

2007-12-28 Thread Eric Brunson
doug shawhan wrote: *sigh* Ignore folks. I had forgotten about .has_key(). Actually, you don't even need that, simply write: if record[0] in dict: # Do your thing. But don't use dict as a variable name, it's a builtin function name. On Dec 28, 2007 11:22 AM, doug shawhan [EMAIL

Re: [Tutor] Using 'join ' function to create a string

2007-12-21 Thread Eric Brunson
lechtlr wrote: Hi there, I would like to know what is the best way to create a string object from two different lists using 'join' function. For example, I have X = ['a', 'b', 'c', 'd', 'e'] and Y = [1, 2, 3, 4, 5]. From X and Y, I want to create a string Z = 'a:1, b:2, c:3, d:4, e:5'.

Re: [Tutor] Something I don't understand

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

Re: [Tutor] Parsing DICOMRT file

2007-12-12 Thread Eric Brunson
Bryan Fodness wrote: I am trying to parse a DICOMRT file, which is a radiation therapy DICOM file. I'm a little late to the party, but you may want to take a look at this: http://mypage.iu.edu/~mmiller3/python/#dycom First, I get different outputs from the two methods below. for

Re: [Tutor] Noob question

2007-12-10 Thread Eric Brunson
Hi Amit, This is fairly inefficient. Because strings in python are immutable this approach causes a new string to be created every iteration. While it may not be an issue with just 3 strings, it is much better to create your list and use .join() to create the concatenation after the list

Re: [Tutor] How is tuple pronounced?

2007-12-10 Thread Eric Brunson
earlylight publishing wrote: Is it tuh-ple (rhymes with supple) or is it two-ple (rhymes with nothing that I can think of)? As a mathematician, I've always heard it pronounced toople, even though when you put a prefix on it (quintuple, sextuple, octuple) it becomes tuhple. We're

Re: [Tutor] Sleeping it out

2007-12-08 Thread Eric Brunson
Yes, import sys, then sys.stdout.flush() when you need it. Ricardo Aráoz wrote: Hi, I have this code : import time L = [i for i in xrange(20)] for n, i in enumerate(L) : if n%3 == 0 and n 0 : print 'waiting 3 seconds' time.sleep(3) print i I'm using Py 2.51

Re: [Tutor] Sleeping it out

2007-12-08 Thread Eric Brunson
Alan Gauld wrote: Eric Brunson [EMAIL PROTECTED] wrote Yes, import sys, then sys.stdout.flush() when you need it. This was my initial idea but it doesn't work in the IDE because it is not really using sys.stdout. In fact the normal print works fine from the command prompt

Re: [Tutor] python precision output?

2007-12-06 Thread Eric Brunson
Andre Walker-Loud wrote: Hi there, Hi Andre, First of all, please don't start a new thread by replying to an existing thread, RFC compliant email readers will thread your post along with the original posting based on headers other than the Subject. :-) I don't think you'll ever get

Re: [Tutor] how to accept an integer?

2007-12-05 Thread Eric Brunson
Mahesh N wrote: I dun understand the mistake. My aim is to accept an integer number. The python lookup in IDLE asks for a string object but the interpreter returns with the following error message. Some one pls explain. Thank You PS : I understand that i can do type conversion after

Re: [Tutor] lstrip removes '/' unexpectedly

2007-12-03 Thread Eric Brunson
Ricardo Aráoz wrote: Danny Yoo wrote: Hello: I'm seeing some strange behavior with lstrip operating on string representations of *nix-style file paths Example: s = '/home/test/' s1 = s.lstrip('/home') s1 'test/' ## '/test/' was expected! '/' was unexpectedly

Re: [Tutor] lstrip removes '/' unexpectedly

2007-11-30 Thread Eric Brunson
Tim Johnson wrote: Hello: I'm seeing some strange behavior with lstrip operating on string representations of *nix-style file paths Example: s = '/home/test/' s1 = s.lstrip('/home') s1 'test/' ## '/test/' was expected! '/' was unexpectedly removed Hi Tim, I believe

Re: [Tutor] PyQt segfault

2007-11-30 Thread Eric Brunson
Tiago Saboga wrote: First, I just noticed I sent a non-working version of the code. The line print (The same if Aux.mystring==Aux.mystring2 else Different) should be print (The same if Aux.mystring==Aux.compare else Different) Sorry for that. This comboboxsegfault.py doesn't seem to

Re: [Tutor] Starting a browser instance and passing a parameter to it.

2007-11-29 Thread Eric Brunson
Kent Johnson wrote: Don Taylor wrote: Alan Gauld wrote: What are you using for the XML-RPC server? Doesn't that need to be a web server of some sort anyhow? XML-RPC communicates using http... I am using simpleXMLRPCServer. Yes, XML-RPC does use http as its transport

Re: [Tutor] Starting a browser instance and passing a parameter to it.

2007-11-29 Thread Eric Brunson
Don Taylor wrote: Eric Brunson wrote: Definitely, or even just CGIHTTPServer. No, I don't think so. I am not a RESTafarian. :-) Forgive my inexperience with the SimpleXMLRPCServer, but I didn't think it provided state any more than any other connection oriented server

Re: [Tutor] Q1: Any way for script to intercept a HUP signal ?

2007-11-16 Thread Eric Brunson
dave selby wrote: Is there a way for a Python script to intercept a HUP signal sent to it ? Cheers Dave Yes, using a signal handler: http://docs.python.org/lib/module-signal.html Let us know if you need clarification on anything after you read the section.

Re: [Tutor] Q2: logging not working as expected

2007-11-16 Thread Eric Brunson
I can't get the python 2.5.1 logging module to use your logging.conf, can you create a simpler example? dave selby wrote: I am trying to use the python logging module. At first glance it looks pretty complicated but having Ggooled a lot I have come up with a trial script of ...

Re: [Tutor] Q2: logging not working as expected

2007-11-16 Thread Eric Brunson
Kent Johnson wrote: dave selby wrote: I was trying to get logging to report to Syslog, that failed so I changed it to write to a file 'python.log' . When I execute my test script 'python.log' appears but contains no messages and no error messages are generated. Anybody any ideas as to

Re: [Tutor] Memory consumption question

2007-11-15 Thread Eric Brunson
I'm sorry, but a Reuben with no 'kraut is just a corned beef sandwich. :-) Marc Tompkins wrote: And here's another reason to use new-style: I forgot the sauerkraut! Oh, the horror! On Nov 15, 2007 1:42 PM, Marc Tompkins [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I thought

Re: [Tutor] global is bad but ...

2007-11-13 Thread Eric Brunson
Kent Johnson wrote: Dinesh B Vadhia [EMAIL PROTECTED] wrote: Consider a data structure (say, an array) that is operated on by a bunch of functions The described way is to place the statement 'global' in line 1 of each function. On the other hand, wiser heads say that the use of

Re: [Tutor] Calling a function within a function within a class...

2007-11-09 Thread Eric Brunson
Trey Keown wrote: Hey all... I'm creating a module for my program, and I need to call a function. Here's how it's set up: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- class DoStuff: def Thing1(self): def ThingToCall(self): print It worked! def

Re: [Tutor] In-place expansion of list members... possible?

2007-11-07 Thread Eric Brunson
Marc Tompkins wrote: This question has probably been asked and answered many times, but I can't figure out how to word my question to get relevant results from Google. So I thought I'd try some human beings, eh? I'm working with delimited files (ANSI X12 EDI nonsense, to be precise.)

Re: [Tutor] In-place expansion of list members... possible?

2007-11-07 Thread Eric Brunson
Kent Johnson wrote: Marc Tompkins wrote: I'm working with delimited files (ANSI X12 EDI nonsense, to be precise.) First I load the records to a list: tmpSegs = inString.split(self.SegTerm) Now, I want to replace each string in that list with a string: for seg in

Re: [Tutor] In-place expansion of list members... possible?

2007-11-07 Thread Eric Brunson
John Fouhy wrote: On 08/11/2007, Marc Tompkins [EMAIL PROTECTED] wrote: Now, I did already (intellectually) understand this: A list is an array of pointers to objects, what you've done here is create a new name referencing an item in the list, then making that new name point to

Re: [Tutor] New Introductory Book

2007-11-06 Thread Eric Brunson
Michael H. Goldwasser wrote: Thanks to the many voices supporting our decision to post to Tutor. We only posted to the most directly relevant mailing lists (announce, tutor, edusig). As an introductory book, it seemed quite appropriate for tutor. In fact, the topic of our (developing) book

Re: [Tutor] List comp question

2007-11-03 Thread Eric Brunson
Ricardo Aráoz wrote: Kent Johnson wrote: I am building a list like this: tree = [] for top in tops: l2 = level2(top) if l2: tree.append((top, l2)) I would really like to turn this into a list comprehension: tree = [ (top, level2(top)) for

Re: [Tutor] Turning multiple Popen calls into a function

2007-11-01 Thread Eric Brunson
jay wrote: Hello, If I have multiple Popen calls I need to make, how can I turn these into a function? Since you're only interested in the output of the last command on the pipeline, I don't see a reason to keep track of them all. I'd do something like this: def pipeline( *commandlist ):

Re: [Tutor] perplexing error with shelve REVISED

2007-10-31 Thread Eric Brunson
Orest Kozyar wrote: Please post the entire traceback (omitting duplicate lines). Sorry, I should have included the traceback. I've revised the sample script so that it generates the traceback when run. The sample script is at the very bottom of this email. ### SCRIPT OUTPUT

Re: [Tutor] perplexing error with shelve REVISED

2007-10-31 Thread Eric Brunson
Orest Kozyar wrote: Please post the entire traceback (omitting duplicate lines). Sorry, I should have included the traceback. I've revised the sample script so that it generates the traceback when run. The sample script is at the very bottom of this email. It appears you have a

Re: [Tutor] Looking for suggestions for improving chessTimer.py code

2007-10-29 Thread Eric Brunson
Dick Moores wrote: At 05:03 AM 10/29/2007, bhaaluu wrote: On 10/29/07, Dick Moores [EMAIL PROTECTED] wrote: Seems I should clarify that. I'm not looking for a script that echoes the key pressed. So I'll change that last line to Could you show a script using it that, say, prints

Re: [Tutor] Looking for suggestions for improving chessTimer.py code

2007-10-29 Thread Eric Brunson
Dick Moores wrote: At 07:54 AM 10/29/2007, Eric Brunson wrote: Dick Moores wrote: At 05:03 AM 10/29/2007, bhaaluu wrote: On 10/29/07, Dick Moores [EMAIL PROTECTED] wrote: Seems I should clarify that. I'm not looking for a script that echoes the key pressed. So

[Tutor] Offtopic: Re: killing bash, sshd... dangerous?

2007-10-28 Thread Eric Brunson
John wrote: No, mostly just playing around with scripting and I have a problem sometimes with cygwin where logging out from bash session Hi John, This is a known bug. The fix is to install a real operating system. For more info, please see one of the following: http://distrowatch.com

Re: [Tutor] rounding to the nearest 0.5

2007-10-25 Thread Eric Brunson
Bryan Fodness wrote: Is there a built-in function that will round to the nearest 0.5? Not that I know of, but round( 2 * n ) / 2 will give you what you're looking for. ___

Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Eric Brunson
bob gailer wrote: Alex Ezell wrote: I am working on building a SOAP client. Unfortunately, one of the methods the SOAP server provides is named import. The SOAP server is written in PHP. So, my problem is that Python really doesn't like me using the word import to call the SOAP method.

Re: [Tutor] where is the function from

2007-10-24 Thread Eric Brunson
linda.s wrote: How can I know where a function such as abc is from (from which module)? abc built-in function abc You could: 1. look it up in the index of the library reference (http://www.python.org/doc/current/lib/genindex.html), 2. try pydoc, 3. examine

Re: [Tutor] A new Kent essay: A Brief Introduction to Beautiful Soup

2007-10-23 Thread Eric Brunson
That's funny. Knowing Alan is from the UK, when I saw Kent was from Manchester I thought he was Alan's countrymate. You know the British (at least my cousins) make fun of us for always having to say our state. Paris, Texas, Boston, Mass, Tampa, FL. But, we just have so many more towns,

Re: [Tutor] standard output: Broken pipe

2007-10-22 Thread Eric Brunson
Martin Walsh wrote: Eric Brunson wrote: I'm coming in late to the discussion and thought that someone would explain it succinctly, but there have been so many correct statements which I feel fail to nail down the problem that I thought I'd chime in. Hi Eric, Thank you for your

Re: [Tutor] pgdb and unicode

2007-10-22 Thread Eric Brunson
Kent Johnson wrote: Ismael Farfán Estrada wrote: Hi there. I have a small system in production with wxPython and PostgreSQL running on a machine with Centos 5. At first everytihing was running ok but now a weird bug was discovered: they can't insert characters like á é í ó ú ä ë ñ

Re: [Tutor] Negative Signed Binary Conversion

2007-10-22 Thread Eric Brunson
Why not find the sign, calculate the binary of the absolute value, then make the result negative (twos complement) if necessary? Just a thought. [EMAIL PROTECTED] wrote: Hi, I'm trying to get this binary converter working, but I can't seem to get the negatives to work properly. If the

Re: [Tutor] Negative Signed Binary Conversion

2007-10-22 Thread Eric Brunson
So far I've gotten five copies of this. It could be mailman doing something wrong, but if you're resending because you don't see your reply, please be patient, this list is not always instantaneous. I think you're missing the gist of what I'm saying. Calculate the binary of the absolute.

Re: [Tutor] Negative Signed Binary Conversion

2007-10-22 Thread Eric Brunson
No worries. I said it could be mailman, and apparently it was. :-) [EMAIL PROTECTED] wrote: Hi, I also got this email five times, and several rejection emails from the moderator. I'm very sorry for this, but I swear I only sent the email once. If this Apology email is also sent multiple

Re: [Tutor] standard output: Broken pipe

2007-10-22 Thread Eric Brunson
Martin Walsh wrote: Michael Langford wrote: This signal is not something you care about. All SIGPIPE means is that the source of the signal found itself writing to a pipe with no sender. Your line signal.signal(signal.SIGPIPE, signal.SIG_DFL) means use the default signal handler for

[Tutor] Offtopic Reply, was: Negative Signed Binary Conversion

2007-10-22 Thread Eric Brunson
You know, Alan, I remember you commenting that you had some flakey behavior from this list a few of weeks ago, then over the weekend I received about two dozen emails from threads as far back as August. Something is definitely wonky (technical term ;-) about this list server. Alan Gauld

Re: [Tutor] standard output: Broken pipe

2007-10-21 Thread Eric Brunson
I'm coming in late to the discussion and thought that someone would explain it succinctly, but there have been so many correct statements which I feel fail to nail down the problem that I thought I'd chime in. Here's the important concepts to understand. The pipe is a construct of the shell,

Re: [Tutor] populating an array or using a dictionary

2007-10-19 Thread Eric Brunson
Bryan Fodness wrote: The data file is larger than shown, and I was wondering if it would be better to populate an array or create a dictionary. Which would be easier? A dictionary is an array with an index, if you need an index into your data, use a dictionary, if not use an array.

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Eric Brunson
Allen Fowler wrote: I seem to be having an issue with __getattr__() being called even if the proporite already exists... I thought that this was not supposed to happen. I think you've misunderstood. __getattr__() should always be called, it allows you to intercept and reimplement the

Re: [Tutor] __getattr__(): Is this right?

2007-10-15 Thread Eric Brunson
Allen Fowler wrote: */Eric Brunson [EMAIL PROTECTED]/* wrote: Allen Fowler wrote: I seem to be having an issue with __getattr__() being called even if the proporite already exists... I thought that this was not supposed to happen. I think you've

Re: [Tutor] internet access

2007-10-11 Thread Eric Brunson
I used to run an old linux laptop with two NICs as my firewall, but I played a bit with DD-WRT and now I'm an evangelist. DD-WRT is based on an embedded Linux kernel and provides a great set of features, including time based filters, web GUI, ssh access and a real unix command line as well

Re: [Tutor] internet access

2007-10-11 Thread Eric Brunson
Alan Gauld wrote: shawn bright [EMAIL PROTECTED] wrote messenger (gaim) all night if i didn't. i have a cron script that checks the hour of day, if later than x pm. does os.system(/etc/init.d/network stop) os.system(chmod a-x /etc/init.d/network) ( so that a reboot doesn't override

Re: [Tutor] Increase speed

2007-10-09 Thread Eric Brunson
Øyvind wrote: Hello. I have written a simple application that does a number of simple calculations. In psudo-code it looks something like below. The program works fine. However, it seems like I need a supercomputer to finish the resultwithin a reasonable timeframe, as the var.txt contains a

Re: [Tutor] Logging with proper format

2007-10-08 Thread Eric Brunson
Kent Johnson wrote: Eric Brunson wrote: claxo wrote: dont indent the line after '\', that means 0 indent s = 'hello\ boy' Or, arguably better: s = '''hello boy''' That is a different string, it contains a newline, the original does not: In [20]: s = 'hello

Re: [Tutor] Updating MySQL Database

2007-10-08 Thread Eric Brunson
wormwood_3 wrote: Thanks to everyone who responded for the information and tips. * That line I had: for line in inputlist: updatequery = update resultstable set fqdn = line.split(,)[1] where ip = line.split(,)[0]; was totally bogus. I was typing and thinking, and not

Re: [Tutor] File Writing Permission?

2007-10-07 Thread Eric Brunson
David Millar wrote: Hi everyone, I'm working on making a Debian package for a game I'm working on, and it works fine, but I've run into a problem with my script now. The script is placed in /usr/bin so all users on the system have access, but even though it will run fine, I can't save

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eric Brunson
Happy Deer wrote: Thank all for the discussion. Maybe I can separate my question into two. First, I have experience in Matlab, where I can use eval. I wonder whether someone knows about it. Second, if I just want to return data[:,1], ...data[:,-1] separately without knowing ahead how

Re: [Tutor] a code question, but don't know question's name

2007-10-07 Thread Eric Brunson
] What do you expect data[:,1] and data[:,-1] to return? On 10/7/07, *Eric Brunson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Happy Deer wrote: Thank all for the discussion. Maybe I can separate my question into two. First, I have experience in Matlab, where

Re: [Tutor] corresponding command in Python to eval in Matlab

2007-10-07 Thread Eric Brunson
A good python coder would probably not choose to pollute his name space like that. My choice would be to assign the elements of data to a dictionary indexed by the strings in varlist like this: vardict = dict( zip( varlist, data ) ) and reference var1 as: vardict['var1'] Happy Deer wrote:

Re: [Tutor] Logging with proper format

2007-10-07 Thread Eric Brunson
claxo wrote: dont indent the line after '\', that means 0 indent s = 'hello\ boy' Or, arguably better: s = '''hello boy''' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] corresponding command in Python to eval in Matlab

2007-10-07 Thread Eric Brunson
to think in Python rather than thinking in Matlab and transliterating. Eric Brunson wrote: A good python coder would probably not choose to pollute his name space like that. My choice would be to assign the elements of data to a dictionary indexed by the strings in varlist like this: vardict

Re: [Tutor] How can I get ASCII of 'a' and '1'?

2007-10-06 Thread Eric Brunson
Or, if you're on a real operating system (i.e. linix) you can type man ascii. ;-) bhaaluu wrote: Here's a handy reference file for ASCII. (See attached file) ___ Tutor

Re: [Tutor] ÍøÒ×ÓÊÏä×Ô¶¯»Ø ¸´: Re: How can I get ASCII of 'a' and '1 '?

2007-10-06 Thread Eric Brunson
What is that, Perl? ;-) [EMAIL PROTECTED] wrote: Äú·¢¸øÎÒµÄÐżþÒѾ­ÊÕµ½¡£ ÍøÒ×163ÓÊÏä--ÖÐÎÄÓÊÏäµÚһƷÅÆ£¬2000Õ׳¬´ó¿Õ¼ä£¬Ö§³Ö³¬´ó¸½¼þ£¬È«¹úΨһ24Сʱ¿Í»§·þÎñ¡£ »¶Ó­ÄúÀ´×¢²áʹÓá£ÍøÒ×ÓʼþÖÐÐÄ£ºhttp://mail.163.com

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(12), from math

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 so that

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
Alan Gauld wrote: Eric Brunson [EMAIL PROTECTED] wrote import timeit t = timeit.Timer( 12 ** .5 ) print t.timeit(1000) 2.29147315025 t = timeit.Timer( sqrt(12), from math import sqrt ) print t.timeit(1000) 7.17679214478 Looks like ** is about

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 didn't mention 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.append(s)

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 to a

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)). If

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] 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 https://www.spoj.pl/problems/classical/sort=0,start=0 I have written my solution and tested it and 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

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( '10001') 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 more or less

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 of

Re: [Tutor] Class Inheritance

2007-09-14 Thread Eric Brunson
() Traceback (most recent call last): File stdin, line 1, in module AttributeError: A instance has no attribute 'method3' When you derive a subclass from another class all methods of the parent class are available Is that clear? On 9/13/07, *Eric Brunson* [EMAIL PROTECTED] mailto:[EMAIL

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 list z for

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 child objects

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

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-BIN, Python

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 Gauld [EMAIL PROTECTED] Sent: Tuesday, 11 September, 2007 5:32:33 AM Subject: Re: [Tutor

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 urllib2

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

  1   2   >