Re: [Tutor] gzip (fwd)

2004-12-02 Thread Danny Yoo
at 'zip' is attempting to do. Do you see anything else when you execute the program? Does anything else come out of standard error? Good luck to you. -- Forwarded message -- Date: Fri, 3 Dec 2004 10:24:15 +0600 From: Ramkumar Parimal Alagan <[EMAIL PROTEC

Re: [Tutor] comapring lists

2004-12-03 Thread Danny Yoo
On Thu, 2 Dec 2004, Jacob S. wrote: > If you or anybody else is interested, I've written a script for codes like > kids in junior high use to write notes to each other with... Hi Jacob, Cool! Do you mind if I make some comments on the code? If you do mind... um... skip this message. *grin*

Re: [Tutor] Help

2004-12-03 Thread Danny Yoo
On Thu, 2 Dec 2004, Daniel wrote: > I need to know how to run another module through one Hi Daniel, Have you had a chance to look at one of the tutorials on: http://www.python.org/moin/BeginnersGuide_2fNonProgrammers I'm guessing that youe trying to use modules; most of the tutorials sh

Re: [Tutor] unittest.makeSuite question

2004-12-03 Thread Danny Yoo
actually very powerful. As a concrete example, we can write a module that dynamically aggregates all unit tests in a directory into a single suite: ### """test_all.py: calls all the 'test_*' modules in the current directory. Danny Yoo ([EMAIL PROTECTED]) """

Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-03 Thread Danny Yoo
> >Yowza; that's some bug. Danny, do you happen to know the bug number? > >I can't find it on sourceforge. > > It's been like that since 2.3 as far as I know. It generates a > connection to localhost to run code in a separate environment. Hi Mike, I wish I knew what the problem was in better d

Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-03 Thread Danny Yoo
On Fri, 3 Dec 2004, Mike Hansen wrote: > That rooted out the problem. A while ago, I changed the colors to kind > of match my VIM color theme(ps_color). When I did > idlelib.PyShell.main(), IDLE came up with my custom color theme. > However, there was a bunch of warnings about my theme. From IDL

Re: [Tutor] Upgrade to 2.4

2004-12-05 Thread Danny Yoo
On Sat, 4 Dec 2004, William Allison wrote: > I compiled Python 2.3.4 from source, but now I would like to upgrade to > 2.4. There doesn't seem to be a "make uninstall" target for 2.3.4. > Will compiling 2.4 overwrite the older version, or will I have two > versions of Python on my system? Hi

Re: [Tutor] eval and exec

2004-12-05 Thread Danny Yoo
> I don't want to introduce insecurity. But also I want to really > understand what the problem is -- especially because I teach python. Hi Marilyn, Here is an example of a string that can cause a StackOverflow error to happen: ### s = "(lambda loop: loop(loop)) (lambda self: self(self))" eva

Re: [Tutor] eval and exec

2004-12-05 Thread Danny Yoo
On Sun, 5 Dec 2004, Alan Gauld wrote: > > And I can't see the security problem, unless there's a security > > problem already, like if I allowed incoming email to dictate the > > parameters that I send through the socket. The email provides data > > for argv[1:] but argv[0] is hard-coded. > > >

Re: [Tutor] Removing a row from a tab delimitted text

2004-12-06 Thread Danny Yoo
On Mon, 6 Dec 2004, kumar s wrote: > Here is how my file looks: > > Name=3492_at > Cell1=481 13 (The space between (481 and 13 is tab) > Cell1=481 13 > Cell1=481 13 > Name=1001_at > Cell1=481 13 > Cell2=481 12 > Cell1=481 13 > Cell1=481 13 > Cell2=481 12 > Name=1002_at > Cell3=482 12 > Cell1=481

Re: [Tutor] Python 2.3.5 out in January??

2004-12-07 Thread Danny Yoo
On Tue, 7 Dec 2004, Kent Johnson wrote: > I think the idea is to back-port bugfixes from 2.4 to 2.3. Then that is > the end of the line for 2.3. Yes. The policy for bugfix releases is in PEP 6: http://www.python.org/peps/pep-0006.html Here's what they say about bugfix releases: """

Re: [Tutor] embedding python in a C app on a linux box...

2004-12-07 Thread Danny Yoo
On Tue, 7 Dec 2004, Jason Child wrote: > Ok, so I have a decent grasp of python and have coded quite a few > scripts. I must say that the language rocks. I would like to embed > python into a C app to provide some scripting support. Hi Jason, We have to first mention that most of us here are

Re: [Tutor] Connecting to interactive program

2004-12-07 Thread Danny Yoo
On Tue, 7 Dec 2004, Vincent Nijs wrote: > Has anyone ever tried to send commands to a running interactive python > session from, say, the command line or another app? Yes. This sort of thing can be done through an "expect" script. http://expect.nist.gov/ There's a port of expect for Pyth

Re: [Tutor] Problem with python2.4.

2004-12-09 Thread Danny Yoo
On Thu, 9 Dec 2004, Jacob S. wrote: > Nothing I can do can fix my problem. It appears as though > pythonw.exe is not working properly in the python 2.4 distribution. [some text cut] > The symptoms: I click on edit with > idle--which runs the command "C:\python24\pythonw.exe" > "C:\python

Re: [Tutor] cgi with system calls

2004-12-14 Thread Danny Yoo
On Tue, 14 Dec 2004, Nik wrote: > ok, problem solved (well, partly - at least as much as I need it to be). > > status = os.system('ps') doesn't set status equal to the output text, it > sets it to the return of the call (in this case '0'). What I really want > to do is > > status = os.popen('ps'

RE: [Tutor] Regexp Not Matching on Numbers?

2004-12-14 Thread Danny Yoo
On Tue, 14 Dec 2004, Gooch, John wrote: > I am used to ( in Perl ) the entire string being searched for a match > when using RegExp's. I assumed this was the way Python would do it do, > as Java/Javascript/VbScript all behaved in this manner. However, I found > that I had to add ".*" in front of

Re: [Tutor] sorting and editing large data files

2004-12-16 Thread Danny Yoo
On Thu, 16 Dec 2004, Scott Melnyk wrote: > I recently suffered a loss of programming files (and I had been > putting off my backups...) Hi Scott, [Side note that's not really related to Python: if you don't use a version control system to manage your software yet, please learn to use one. The

Re: [Tutor] least squares

2004-12-16 Thread Danny Yoo
On Thu, 16 Dec 2004, mdcooper wrote: > I am trying to run a least squares program (written by Konrad Hinsen) Hi Matthew, You're assuming that we know who Konrad Hinsen is. *grin* Ok, when you're referring to the least-squared code, are you referring to a module in Scientific Python? Please p

RE: [Tutor] least squares

2004-12-17 Thread Danny Yoo
On Thu, 16 Dec 2004, mdcooper wrote: > I am trying to get a corrolation between a large number of variables and for > many similar equations : >(Ca1 * xa^2) + (Ca2 * ya^2) + (Ca3 * za^2) + ... = ta >(Cb1 * xb^2) + (Cb2 * yb^2) + (Cb3 * zb^2) + ... = tb > > which is solved to get: >(

Re: [Tutor] dbcp module

2004-12-17 Thread Danny Yoo
On Fri, 17 Dec 2004, Rene Bourgoin wrote: > Yes i believe im looking for the python version of the Jakarta databse > connection pool!! Hi Rene, I haven't looked at this too closely yet, but there are projects out there for connection pools. For example: http://sqlrelay.sourceforge.net/

Re: [Tutor] dbcp module

2004-12-17 Thread Danny Yoo
On Fri, 17 Dec 2004, Rene Bourgoin wrote: > Ive been learning to interact with databases using python and i was > looking for ways to return a SELECT query result in a plain format. what > i mean by plain format is : > > name numberaddress > Fred Smith 2125553243 1 main st

Re: [Tutor] dbcp module

2004-12-17 Thread Danny Yoo
On Fri, 17 Dec 2004, Kent Johnson wrote: > The recipe you cite has the pp() function and an example of its use. It > sounds like that is what you want. Part of the pandemonium was my fault. I completely missed your earlier post here: http://mail.python.org/pipermail/tutor/2004-December/0

Re: [Tutor] maximum value in a Numeric array

2004-12-10 Thread Danny Yoo
On Fri, 10 Dec 2004, Ertl, John wrote: > I am trying to get the maximum value in a 2-D array. I can use max but > it returns the 1-D array that the max value is in and I then I need to > do max again on that array to get the single max value. > > There has to be a more straightforward way...I h

[Tutor] Fwd: python tutor needed

2010-04-21 Thread Danny Yoo
Forwarding for Lumka: -- Forwarded message -- From: Lumka Msibi Date: Tue, Apr 20, 2010 at 2:51 PM Subject: Fwd: python tutor needed To: Danny Yoo , "dany.yoo" This communication is intended for the addressee only. It is confidential. If you have received this com

Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-20 Thread Danny Yoo
On Sat, 18 Dec 2004, Jacob S. wrote: > I think I'm going to burst out in tears. Mike Hansen gave the solution > to the very problem I'm having, yet, when I used the console version and > deleted the custom color theme, it stopped giving me error messages, but > it still won't start up without th

Re: [Tutor] Matrix

2004-12-20 Thread Danny Yoo
On Sun, 19 Dec 2004, Bugra Cakir wrote: > I want to create a matrix in Python. For example 3x4 how can i > create this? thanks Hi Bugra, Just for reference, here's the relevant FAQ about how to do matrices in Python: http://python.org/doc/faq/programming.html#how-do-i-create-a-multidimension

Re: [Tutor] Python 2.4 IDLE Windows 2000

2004-12-20 Thread Danny Yoo
On Mon, 20 Dec 2004, Jacob S. wrote: > 1) Delete .idlerc directory > 2) Uninstall and reinstall python2.4 Hi Jacob, Ok, so there was probably something really screwy with the stuff in .idlerc. Can you send me a tarball or zip of it in private email? I just want to make sure that the issue t

Re: [Tutor] Comments appreciated

2004-12-27 Thread Danny Yoo
On Sun, 26 Dec 2004, Jacob S. wrote: > > The only thing that's missing is that this script can't handle paths > > like ~/dir/junkthis > > I believe you're looking for os.path.expanduser("~/dir/junkthis") > > BTW, trashcan IS a module level variable because it's defined at the module > level. Why

Re: [Tutor] Comments appreciated

2004-12-27 Thread Danny Yoo
[Jacob] > > BTW, trashcan IS a module level variable because it's defined at the > > module level. Why it says it's local is beyond me. [Danny] > Ah, you must be running into the global/local gotcha. [long rambling text cut] Wait, wait. Forget everything I said. *grin* I should have read the

Re: [Tutor] Parsing a block of XML text

2004-12-31 Thread Danny Yoo
On Fri, 31 Dec 2004, kumar s wrote: > I am trying to parse BLAST output (Basic Local Alignment Search Tool, > size around more than 250 KB ). [xml text cut] Hi Kumar, Just as a side note: have you looked at Biopython yet? http://biopython.org/ I mention this because Biopython comes wit

Re: [Tutor] Parsing a block of XML text

2005-01-01 Thread Danny Yoo
On Fri, 31 Dec 2004, kumar s wrote: > http://www.python.org/doc/lib/dom-example.html > > Frankly it looked more complex. could I request you to explain your > pseudocode. It is confusing when you say call a function within another > function. Hi Kumar, A question, though: can you try to expla

Re: [Tutor] O.T.

2005-01-01 Thread Danny Yoo
On Thu, 30 Dec 2004, Anna Ravenscroft wrote: > Anna Martelli Ravenscroft > 42, 2 children (13 and 11) live with their dad > Married this July to the martelli-bot (we read The Zen of Python at our > wedding!). We currently live in Bologna, Italy. Hi Anna, Congratulations! Say hi to Alex for m

Re: [Tutor] How to put my functions in an array

2005-01-01 Thread Danny Yoo
On Sat, 1 Jan 2005, Jacob S. wrote: > funct = {'Add Virt':addvirt,'Remove Virt':remvirt,'More > Stuff':more,"Extras":extra} > def addvirt(): > pass > def remvirt(): > pass > def more(): > pass Hi Jacob, Quick gotcha note: the definition of the 'funct' dictionary has to g

Re: [Tutor] Am I storeing up problems ?

2005-01-02 Thread Danny Yoo
On Sun, 2 Jan 2005, Dave S wrote: > My matrix 'self.data' consists of a list of 110 items, each item is a > dictionary of 250 keys, each key holds two lists, one of four items, one > of 12 items. Hi Dave, Hmmm... what kind of data is being copied here? Python's data structures are desigined f

[Tutor] The Game of Life

2005-01-03 Thread Danny Yoo
On Mon, 3 Jan 2005, Brian van den Broek wrote: > >> (Aside: one nonobvious example where copying can be avoided is in > >> Conway's Game of Life: when we calculate what cells live and die in > >> the next generation, we can actually use the 'Command' design pattern > >> to avoid making a tempor

Re: [Tutor] regex problem

2005-01-04 Thread Danny Yoo
On Tue, 4 Jan 2005, Michael Powe wrote: > def parseFile(inFile) : > import re > bSpace = re.compile("^ ") > multiSpace = re.compile(r"\s\s+") > nbsp = re.compile(r" ") > HTMLRegEx = > > re.compile(r"(<|<)/?((!--.*--)|(STYLE.*STYLE)|(P|BR|b|STRONG))/?(>|>) > ",re.I) > >

Re: [Tutor] The Game of Life

2005-01-05 Thread Danny Yoo
> > Just as a warning, none of what I'm going to code here is original at > > all: I'm rehashing a main idea off of a paper called "Using the Game > > of Life to Introduce Freshman Students to the Power and Elegance of > > Design Patterns": > > > > http://portal.acm.org/citation.cfm?id=103529

Re: [Tutor] The Game of Life question

2005-01-05 Thread Danny Yoo
On Wed, 5 Jan 2005, Kooser, Ara S wrote: >They picked a project to model the flow of smallpox in a city and > surroundings areas. So I saw the game of life and thought maybe they > could modify it for use as a smallpox model. Hi Ara, Oh! My apologies for not posting the file as a comple

Re: [Tutor] automatically finding site-packages and python2.3 in a linux machine

2005-01-06 Thread Danny Yoo
On Thu, 6 Jan 2005, Fred Lionetti wrote: > I'm working on creating an installer for my program using install > shield, and I'd like to know how one can automatically determine if > Python 2.3 is installed on a linux machine, and where site-packages is > located (so that I can install my own file

Re: [Tutor] replacement for constants from other languages in Python?

2005-01-06 Thread Danny Yoo
On Thu, 6 Jan 2005, Alan Gauld wrote: > > I'm _very_ used to using C style constants (preprocessor #define > > directives) or C++ const keyword style, for a variety of reasons. > > > > I've yet to see anything covering 'how to work around the lack of > > constants in Python'...can anyone point m

Re: [Tutor] automatically finding site-packages and python2.3 in a linux machine

2005-01-06 Thread Danny Yoo
> > I'm working on creating an installer for my program using install > > shield, and I'd like to know how one can automatically determine if > > Python 2.3 is installed on a linux machine Hi Fred, Sorry about ignoring parts of your question! Unix has default places for putting binaries like P

Re: [Tutor] trouble getting a list to update

2005-01-06 Thread Danny Yoo
On Thu, 6 Jan 2005, Vincent Wan wrote: > I wrote a program to repeatedly: > a: print a list of integers eg 0 0 0 0 0 0 0 0 0 0 > b: change each integer in the list to 1 with a .05% chance > > I run the program and over itterations more 1's appear as they should. > > However, the chan

Re: [Tutor] trouble getting a list to update

2005-01-06 Thread Danny Yoo
On Thu, 6 Jan 2005, Vincent Wan wrote: > On Jan 6, 2005, at 12:59 PM, Danny Yoo wrote: > > Can you show us a snippet of the file output? I'm not immediately > > seeing anything particular with your debugging output statements: > > > Like the computer, I don't

Re: [Tutor] Problem with a variable in a CGI program

2005-01-07 Thread Danny Yoo
On Fri, 7 Jan 2005, Mark Kels wrote: > I started to read the following code (I will start working on it when > this problem is fixed) and it looks OK while I read it. But for some > reason it doesn't work... Hi Mark, Ok, let's take a look at the error message: > Traceback (most recent call

Re: [Tutor] Problem with a variable in a CGI program

2005-01-07 Thread Danny Yoo
> But now I have much weirder problem... > I got this error: > > C:\>maillist.py > File "C:\maillist.py", line 84 > >^ > SyntaxError: invalid syntax > > And the weird thing is that the program has only 83 lines... For some > re

Re: [Tutor] XP and python 2.4, some progress

2005-01-09 Thread Danny Yoo
On Sat, 8 Jan 2005, Jeffrey Thomas Peery wrote: > I wasn't able to get the IDLE started in windows XP. I had it working then I > upgraded to 2.4, then it didn't work so I switched back to 2.3, still didn't > work so I'm back to 2.4. I did some looking around and I was able to get > the IDLE sta

Re: [Tutor] Input to python executable code and design question

2005-01-10 Thread Danny Yoo
> >To help you out. You need some sort of error checking to be sure that > >within your given range you won't get something like a math domain > >error. > > > > > Yes, I thought that: > try: > #function > exception: > pass Hi Ismael, Python's keyword for exception handling is 'except'

Re: [Tutor] Slightly OT - Python/Java

2005-01-10 Thread Danny Yoo
On Tue, 11 Jan 2005, Liam Clarke wrote: > > > (Why can't a non-static method comparison be called from a static > > > reference? What does that mean anyway? > > > > Er... What was your code like? (before and after correcting > > the error) Hi Liam, It's actually easier to see the reas

Re: [Tutor] Is there a way to force update the screen in tkinter?

2005-01-10 Thread Danny Yoo
On Mon, 10 Jan 2005, R. Alan Monroe wrote: > I don't have the code here at home, but today I tried my first > experiments in Tkinter. I set up a button that fired off a function to > resize a rectangle in a canvas, with a for loop. Only problem is that > the screen isn't repainted in all the ste

Re: [Tutor] Python with MySQL ?

2005-01-11 Thread Danny Yoo
On Tue, 11 Jan 2005, Mark Kels wrote: > How can I send SQL querys to a MySQL database with a python-CGI program ? Hi Mark, You'll want to grab a "Python DB API" module for MySQL. The best one I've seen for MySQL is 'MySQLdb': http://sourceforge.net/projects/mysql-python and you should

Re: [Tutor] Time script help sought!

2005-01-11 Thread Danny Yoo
On Tue, 11 Jan 2005, kevin parks wrote: > but as always you may notice a wrinkle some items have many times > (here 6) indicated: > > Item_3TAPE_139:4110:41 > Item_3TAPE_1410:4711:19 > Item_3TAPE_1511:2111:55 > Item_3TAPE_1611:58

Re: [Tutor] FW: hi

2005-01-11 Thread Danny Yoo
On Wed, 12 Jan 2005, Gopinath V, ASDC Chennai wrote: > > I'm a Novice in python.can u tell me if there is a frontend available > > .if yes where can i download it from Hello Gopinath, Can you explain what you mean by "frontend"? The word "frontend" suffers from being too generic to be able

RE: [Tutor] FW: hi (fwd)

2005-01-12 Thread Danny Yoo
>> Can you explain what you mean by "frontend"? The word "frontend" >> suffers from being too generic to be able to tell what you mean. > I meant a GUI like Microsofts Visual Basic [Keeping Tutor@python.org in CC. Please use Reply-to-all in replies, so that we can keep the conversation on l

Re: [Tutor] class instance with identity crisis

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Barnaby Scott wrote: > I was wondering how you can get an instance of a class to change itself > into something else (given certain circumstances), but doing so from > within a method. So: > > class Damson: > def __str__(self): > return 'damson' > > def dry(s

Re: [Tutor] TypeError I don't understand

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Vincent Wan wrote: > running my program gives me "TypeError: len() of unsized object" Hi Vincent: Ah! Whenever you see something like this, check to see where reassignments to the variable occur: it's possible that one of the assignments isn't doing what you think it's d

Re: [Tutor] what's a concise way to print the first elements in a nested list

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Orri Ganel wrote: > >>> stuff = [[0,'sdfsd','wrtew'], [1, 'rht','erterg']] > >>> stuff > [[0, 'sdfsd', 'wrtew'], [1, 'rht', 'erterg']] > >>> print [stuff[i][0] for i in range(len(stuff))] > [0, 1] Hi Orri, An alternative way to write this is: ### print [row[0] for row

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Marilyn Davis wrote: > When stuff was read from the exim socket, it was stored in a tempfile, > so that I could release the exim process, then I lseek to the front of > the tempfile and have it handy. I see from all my debugging and logging > that the file descriptor for th

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
> Just double checking something: are you dealing with threads? Hi Marilyn, Argh, that was a dumb question. Pretend I didn't ask it that way. *grin* I meant to ask: How do you deal with threads? Is the temporary file a global resource that the threads all touch? If so, have you done any sy

Re: [Tutor] sockets, files, threads

2005-01-12 Thread Danny Yoo
On Wed, 12 Jan 2005, Marilyn Davis wrote: > I was looking at my use of file objects and file descriptors and I wrote > this sample program and was very surprised by the result -- which makes > me think there's something here that I don't understand. Where did my > 'ooo' go? > > #! /usr/bin/env p

Re: [Tutor] flattening a list

2005-01-12 Thread Danny Yoo
> > def flatten(a): > >if not isinstance(a,(tuple,list)): return [a] > >if len(a)==0: return [] > >return flatten(a[0])+flatten(a[1:]) > The only problem with this if it is to big or to deeply nested then it > will overflow the stack? Yes, it can overflow in its current incarnation.

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Danny Yoo
On Thu, 13 Jan 2005, kumar s wrote: > My list looks like this: List name = probe_pairs > Name=AFFX-BioB-5_at > Cell1=96 369 N control AFFX-BioB-5_at > Cell2=96 370 N control AFFX-BioB-5_at > Cell3=441 3 N control AFFX-BioB-5_at > Cell4=441 4

Re: [Tutor] Tix and Table printing

2005-01-13 Thread Danny Yoo
On Thu, 13 Jan 2005, Guillermo Fernandez Castellanos wrote: > Is there any "table" frame that I am unaware of? Hi Guillermo, There are some recipes for making a Tkinter table widget; here's one: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266 There's a Tkinter wiki page t

Re: [Tutor] communication between java and python?

2005-01-13 Thread Danny Yoo
On Thu, 13 Jan 2005, joeri honnef wrote: > I'm trying to communicate between Python and Java and using os.popen(). > But thing dont work...The Java program reads strings from stdin and the > python program just writes to stdout. Hi Joeri, You may want to look at: http://www.python.org/do

Re: [Tutor] file-like object

2005-01-14 Thread Danny Yoo
On Fri, 14 Jan 2005, Chad Crabtree wrote: > I have created a file-like object out of a triple quoted string. I was > wondering if there is a better way to implement readline than what I > have below? It just doesn't seem like a very good way to do this. > > class _macroString(object): > def

Re: [Tutor] file-like object

2005-01-14 Thread Danny Yoo
On Fri, 14 Jan 2005, Terry Carroll wrote: > > class _macroString(object): > > def __init__(self,s): > > self.macro=s > > self.list=self.macro.split("\n") > > for n,v in enumerate(self.list): > > self.list[n]=v+'\n' > > Is this for loop a safe technique, wh

Re: [Tutor] Faster procedure to filter two lists . Please help

2005-01-14 Thread Danny Yoo
On Fri, 14 Jan 2005, kumar s wrote: > >>>for i in range(len(what)): > ele = split(what[i],'\t') > cor1 = ele[0] > for k in range(len(my_report)): > cols = split(my_report[k],'\t') > cor = cols[0] > if cor1 == cor: >

Re: [Tutor] sockets, files, threads

2005-01-15 Thread Danny Yoo
> I have only wrapped my lock around file-descriptor creations. Should I > wrap it around closings too? Or the whole open -> close transaction? > It sounds like error-prone work to do the latter. What am I missing? Hi Marilyn, Can you send a link to the source code to the Tutor list? I'm ge

Re: [Tutor] RE:

2005-01-17 Thread Danny Yoo
> > >>> stuff = [[0,'sdfsd','wrtew'], [1, 'rht','erterg']] > > >>> stuff > > [[0, 'sdfsd', 'wrtew'], [1, 'rht', 'erterg']] > > >>> print [stuff[i][0] for i in range(len(stuff))] > > [0, 1] > > > > An alternative way to write this is: > > > > ### > > print [row[0] for row in stuff] > > ### > >

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
Hi Marilyn, [Long program comments ahead. Please forgive me if some of the comments are overbearing; I'm trying to get over a cold, and I'm very grumpy. *grin*] Some comments on the code follow. I'll be focusing on: > http://www.maildance.com/python/doorman/py_daemon.py One of the import

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
On Tue, 18 Jan 2005, Danny Yoo wrote: > In fact, as far as I can tell, none of the Spawn() threads are > communicating with each other. As long as your threads are working > independently of each other --- and as long as they are not writing to > global variables --- you do no

Re: [Tutor] sockets, files, threads

2005-01-18 Thread Danny Yoo
On Tue, 18 Jan 2005, Marilyn Davis wrote: > while 1: > if log.level & log.calls: > log.it("fd%d:py_daemon.py: Waiting ...", self.descriptor) > try: > client_socket, client_addr = self.server_socket.accept() > except (EOF

Re: [Tutor] A somewhat easier way to parse XML

2005-01-19 Thread Danny Yoo
On Wed, 19 Jan 2005, Max Noel wrote: > I've just spent the last few hours learning how to use the DOM XML > API (to be more precise, the one that's in PyXML), instead of revising > for my exams :p. My conclusion so far: it sucks (and so does SAX because > I can't see a way to use it for OO

Re: [Tutor] Popen and sending output to a file

2005-01-19 Thread Danny Yoo
On Wed, 19 Jan 2005, Ertl, John wrote: > I am using the subprocess.Popen from 2.4. I can launch a job from > python and the output from the job goes to the screen but now I would > like to have the output go to a file. I could do the crude > > subprocess.Popen("dtg | cat > job.out", shell=True

Re: [Tutor] sockets, files, threads

2005-01-19 Thread Danny Yoo
On Wed, 19 Jan 2005, Marilyn Davis wrote: > class Exim: > def __init__(self): > self.fdin = None > self.err_flush = [] > self.stdout, self.stdin, self.stderr = popen2.popen3('%s -t' % > MAILER) > self.fdin = self.stdin.fileno() > self.fdout = s

Re: [Tutor] Ooer, OT Lisp

2005-01-21 Thread Danny Yoo
On Thu, 20 Jan 2005, Bill Mill wrote: > There is no "standard" implementation of lisp, so sockets and os access > all vary by implementation. Furthermore, the docs are sketchy and hard > to read with all of the lisps I've tried. Hi Liam, Scheme is a recent dialect of Lisp that seems to be well

Re: [Tutor] Importing multiple files as a single module?

2005-01-21 Thread Danny Yoo
On Fri, 21 Jan 2005, Kent Johnson wrote: > I think this will work: > in foo/__init__.py put > from Bar import Bar > from Baz import Baz > > or whatever variations of this you like. > > Any names defined in the package __init__.py are available to other code > as package attribute. Hi Max, For

Re: [Tutor] Combination

2005-01-21 Thread Danny Yoo
On Fri, 21 Jan 2005, Guillermo Fernandez Castellanos wrote: > I'm trying to take a list and find all the unique combinations of that > list. > > I mean: > if I enter (1,2,3,4,5) and I watn combinations of 3, I want to find: > (1,2,3) but then not (2,1,3), (3,1,2),... > (1,2,4) > (1,2,5) > (2,3,5

Re: [Tutor] Combination

2005-01-21 Thread Danny Yoo
On Fri, 21 Jan 2005, Danny Yoo wrote: > > I mean: > > if I enter (1,2,3,4,5) and I watn combinations of 3, I want to find: > > (1,2,3) but then not (2,1,3), (3,1,2),... > > (1,2,4) > > (1,2,5) > > (2,3,5) > > (3,4,5) > > > There is a clean rec

Re: [Tutor] read line x from a file

2005-01-22 Thread Danny Yoo
On Sat, 22 Jan 2005, Kent Johnson wrote: > Jay Loden wrote: > > One simple solution is to do: > > > > fle = open(file) > > contents = file.readlines() > > file.close() > > print contents[x] #or store this in a variable, whatever > > That is the simplest solution. If your file gets bigger and yo

Re: [Tutor] Python Scripting

2005-01-22 Thread Danny Yoo
On Sat, 22 Jan 2005, Ali Polatel wrote: >I want to ask you something that I am really curious about. >Can I design web-pages with python or use py files to write html? Hi Ali, Almost every programming language allows us to write strings into files, so from an academic standpoint, 'yes

Re: [Tutor] Changing (Unix) environment for python shell/popen() commands

2005-01-23 Thread Danny Yoo
On Sun, 23 Jan 2005, Scott W wrote: > I've got to shell out from my python code to execute a command, but > _must_ set the environment at the same time (or prior to execution). > > I saw some comments about setting os.environ[], but > didn't seem to be seeing this work in subsequent calls using

Re: [Tutor] sorting a 2 gb file

2005-01-25 Thread Danny Yoo
On Tue, 25 Jan 2005, Scott Melnyk wrote: > I have an file in the form shown at the end (please forgive any > wrapparounds due to the width of the screen here- the lines starting > with ENS end with the e-12 or what have you on same line.) > > What I would like is to generate an output file of

Re: [Tutor] Read file line by line

2005-01-25 Thread Danny Yoo
On Tue, 25 Jan 2005, Gilbert Tsang wrote: > Hey you Python coders out there: > > Being a Python newbie, I have this question while trying to write a > script to process lines from a text file line-by-line: > > #!/usr/bin/python > fd = open( "test.txt" ) > content = fd.readline() > while (content

Re: [Tutor] Read file line by line

2005-01-25 Thread Danny Yoo
> There's nothing that really technically prevents us from doing an > assignment as an expression, but Python's language designer decided that > it encouraged a style of programming that made code harder to maintain. > By making it a statement, it removes the possiblity of making a mistake > like

Re: [Tutor] sorting a 2 gb file

2005-01-25 Thread Danny Yoo
On Tue, 25 Jan 2005, Max Noel wrote: > >> My data set the below is taken from is over 2.4 gb so speed and > >> memory considerations come into play. > >> > >> Are sets more effective than lists for this? > > > > Sets or dictionaries make the act of "lookup" of a key fairly cheap. > > In the two-

Re: [Tutor] Advise...

2005-01-26 Thread Danny Yoo
On Wed, 26 Jan 2005, Bill Kranec wrote: > There has been alot of talk on this list about using list comprehensions > lately, and this could be one of those useful places. While I don't > have time to experiment with real code, I would suggest changing your > function to look like: > > steps = [

Re: [Tutor] Advise...

2005-01-26 Thread Danny Yoo
> > There has been alot of talk on this list about using list comprehensions > > lately, and this could be one of those useful places. While I don't > > have time to experiment with real code, I would suggest changing your > > function to look like: > > > > steps = [ min_x + i*delta_x for i in r

Re: [Tutor] Unique Items in Lists

2005-01-26 Thread Danny Yoo
On Wed, 26 Jan 2005, Srinivas Iyyer wrote: > I have a list with 4 columns and column1 elements are unique. I wanted > to extract unique elements in column3 and and place the other elements > of the column along with unique elements in column 4 as a tab delim > text. > > Table: > > col1col2

Re: [Tutor] Convert string to variable name

2005-01-26 Thread Danny Yoo
On Wed, 26 Jan 2005, Tony Giunta wrote: > This is something I've been trying to figure out for some time. Is > there a way in Python to take a string [say something from a raw_input] > and make that string a variable name? Hi Tony, Conceptually, yes: you can collect all those on-the-fly vari

Re: [Tutor] Safely buffering user input

2005-01-27 Thread Danny Yoo
On Thu, 27 Jan 2005, Miles Stevenson wrote: > I'm trying to practice safe coding techniques. I just want to make sure > that a user can't supply a massive argument to my script and cause > trouble. I'm just trying only accept about 256 bytes: > > buffer(sys.argv[1], 0, 256) ^^ Hi Miles,

Re: [Tutor] Please Help with Python Script for Xbox Media Center

2005-01-28 Thread Danny Yoo
On Fri, 28 Jan 2005, Rodney Butler wrote: > I have written a script that is designed to load when you start your > xbox, it gets a list of your music playlists then lets you select which > one to load, shuffle and play, then the script exits. What I need is > for the script to automatically sel

Re: [Tutor] range function

2005-01-29 Thread Danny Yoo
On Sat, 29 Jan 2005, Srinivas Iyyer wrote: > I have bunch of coordinates for various vectors. > > small vecs: > > name cord. Xcord. Y Sector no. > smvec175 1001aa > smvec225 50 1aa > smvec3135 1551ab > > large vecs:

Re: [Tutor] question regarding python exception handling

2005-01-30 Thread Danny Yoo
On Sat, 29 Jan 2005, Roy wrote: > I am learning about python exception handling. I am reading "Python in a > Nutshell". In the chapter of exception handling, it says: Note that the > try/finally form is distinct from the try/except form: a try statement > cannot have both except and finally clau

Re: [Tutor] Using exec with dict

2005-01-30 Thread Danny Yoo
On Mon, 31 Jan 2005, [ISO-8859-1] André Roberge wrote: > >/ I have a "robot" that can do some actions like "move()" and > />/ "turn_left()". I can program this robot using python like this: > />/ > />/ .def move_and_turn(): > [snip]// > />/ The question I have is: how do I do this with an

Re: [Tutor] Append function

2005-01-31 Thread Danny Yoo
On Sun, 30 Jan 2005, kumar s wrote: > I have a bunch of files where the first column is always the same. I > want to collect all those files, extract the second columns by file wise > and write the first column, followed by the other columns(extracted from > files) next to each other. Hi Kumar

Re: [Tutor] files in a directory

2005-01-31 Thread Danny Yoo
> Now that I am reading many files at once, I wanted, to > have a tab delim file op that looks like this: > > My_coors Int_file 1 Int_file2 > IntFile3 > 01:26 34 235 > 245.45 > 04:42 342.4452.445.5 > 02:56 45.4

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
On Sun, 30 Jan 2005, Glen wrote: > As a Python/Tkinter newbie, I thought I was getting on ok... > then I hit this problem. > > I have a canvas (c1) > A group of objects are drawn on c1 and given a tag > c1.addtag_all('group_A') > Another group of objects are drawn, I wish to tag these 'gr

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
On Mon, 31 Jan 2005, Danny Yoo wrote: > I think that getting this right will take some more work. Here's a > definition of a function called find_withouttag(): [Code cut] Oh! Never mind; this can be a lot simpler. According to the "Gotchas" section of: http://t

Re: [Tutor] Newbie struggling with Tkinter/canvas tags

2005-01-31 Thread Danny Yoo
> Now I've just got to work out how to tag a list of id's... There > doesn't seem to be a way to tag a known id, it has to be tagged by > reference from an id above or below which seems odd! Hi Glen, Have you tried the addtag_withtag() method? It looks like it should be able to do what you're

Re: [Tutor] Comparing files, Counting Value

2005-01-31 Thread Danny Yoo
Hi Michiyo, Ok, let's take a look at the code. > i=open("file 1") #value data > o=open("file 2") #look-up file > l=open("result", 'w')#result We strongly recommend renaming these names to ones that aren't single characters. It's difficult to tell here what 'i', 'o', and 'l' mean, outside of

  1   2   3   4   5   6   7   8   9   10   >