Re: [Tutor] exec, execfile, rexec

2006-02-14 Thread Danny Yoo
> I hate to admit it, but there are times when fear should be listened to, > and I think this is one of them. So, I guess I'll move on to parsing it > myself. Seems a shame though. Hi DS, Yeah, I'd recommend listening to fear. *grin* Python's a powerful language, and I'd recommend erring on th

Re: [Tutor] map vs. list comprehension

2006-02-14 Thread Danny Yoo
> I read somewhere that the function 'map' might one day be deprecated in > favor of list comprehensions. > > But I can't see a way to do this in a list comprehension: > > >>> map (pow, [2, 2, 2, 2], [1, 2, 3, 4]) > [2, 4, 8, 16] Hi Michael, If my hands were forcibly tied to avoid map(), I'd

Re: [Tutor] python mechanize examples

2006-02-16 Thread Danny Yoo
> Yeah that's the module I'm talking about. I installed it and trying to > get it to work using the docs, but it would be good to see some actual > working examples. Hi Ron, I haven't played around with mechanize, but according to: http://wwwsearch.sourceforge.net/mechanize/#tests worki

Re: [Tutor] python mechanize examples

2006-02-17 Thread Danny Yoo
On Thu, 16 Feb 2006, Ron Nixon wrote: > Anyone have or know where I can find working examples of python's > mechanize modules. Try to reverse engineer a script to see how it works. Hi Ron, I'm assuming, for the moment, that you're talking about the third-party 'mechanize' module: http://w

Re: [Tutor] Need to write a python and call it within a python main program

2006-02-18 Thread Danny Yoo
> > I need to write a function that modifies its 4 imput values, > a,b,c,d according to the following rules. [program description cut] > I also need to find out how to write the main program that calls this > function repeatedly, testing the output values for the solution to the > equation. Hi K

Re: [Tutor] MySQLdb: at a complete loss

2006-02-18 Thread Danny Yoo
> db=MySQLdb.connect(host='localhost',user='root',passwd='081300',db='tut') > cursor=db.cursor() > name = raw_input("Please enter a Name: ") > color =raw_input("Please enter a Color: ") > cursor.execute("""INSERT INTO horses(name,color) > VALUES("%s","%s")"""%(name,color))

Re: [Tutor] unable to insert data into database

2006-02-18 Thread Danny Yoo
> I'm Tiago, from Brazil, I'm new to this list and, err, I'm getting into > python. Hi Tiago, Welcome aboard! > I'm very interested on the mysql module, and this thread sounds > interesting. I've tried pretty much the same code from the original > code, and I don't need to commit changes. All

Re: [Tutor] Need to write a python and call it within a python main program (fwd)

2006-02-18 Thread Danny Yoo
-- Forwarded message -- Date: Sat, 18 Feb 2006 15:02:47 -0500 (Eastern Standard Time) From: Kermit Rose <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Need to write a python and call it within a python main program From: Danny Yoo

Re: [Tutor] Need to write a python and call it within a python main program (fwd)

2006-02-18 Thread Danny Yoo
> I need help on the SYNTAX of Python > > I have programming experience in Fortran and a little bit of C. Ah, ok; let's see if we can transfer some concepts from your previous experience into Python. Just as a note: please use your email client's "Reply to All" feature so that our correspondenc

Re: [Tutor] C++ tutor

2006-02-20 Thread Danny Yoo
On Mon, 20 Feb 2006, Jason Wise wrote: > I am a grad student at Berkeley looking for a C++ tutor. Might you offer > any suggestions? Thank you, jason wise Hi Jason. I think you may want to ask on a C++ oriented forum rather than Python-tutor, as you'll probably get better help there. Because

Re: [Tutor] question...

2006-02-20 Thread Danny Yoo
On Mon, 20 Feb 2006, Samantha Warbey wrote: > I have blocks of text (in notebook files currently) that I need to read > 3 and analyse 3 characters at a time. [This is because I'm studying > genes and codons are three characters in length]. How do I do this using > python? I've currently only bee

Re: [Tutor] Generating small random integer

2006-02-20 Thread Danny Yoo
> I did try to read it from "cover to cover", but too quickly got into > places where I did not know what it talked about. Mind if we talk about some of those places? *grin* We might be able to help explain what the tutorial is trying to say, but you need to give us an opportunity. > So I am f

Re: [Tutor] MySQLdb : I finally got it to work.

2006-02-20 Thread Danny Yoo
> 1. With my configuration, I need quotes around the values that are to be > placed into the database, otherwise an error is raised example: ( n= > blue --> Error 1054:n Unknown column 'blue' in 'field list' ) > n = raw_input("Please enter a Name: ") > c =raw_

Re: [Tutor] Understanding the tutorial

2006-02-21 Thread Danny Yoo
> 2.1 Invoking the Interpreter > > *** > is written with the unix programmer in mind. > I do understand some unix, since I used to work on a unix system. But now > the only system > I have available is Microsoft windows. > In windows I invoke the interpreter by clicking on the Python icon, or

Re: [Tutor] Understanding the tutorial (fwd)

2006-02-21 Thread Danny Yoo
[Keeping tutor in CC] -- Forwarded message -- Date: Tue, 21 Feb 2006 17:49:34 -0500 (Eastern Standard Time) From: Kermit Rose <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Understanding the tutorial From: Danny Yoo Date: 02/21/06 16:38:2

Re: [Tutor] Locking a file in linux with Python

2006-02-22 Thread Danny Yoo
On Wed, 22 Feb 2006, Pat Martin wrote: > I am trying to find on the web how to lock a file with python in Linux. > I am trying to process a group of files that are continually being > written to and when I am working on one file I would like to be able to > lock it. Can anyone point me in the ri

Re: [Tutor] Locking a file in linux with Python

2006-02-22 Thread Danny Yoo
On Wed, 22 Feb 2006, Pat Martin wrote: > I had actually looked at that site, but when I do the commands > > testfile = open('testlock', 'a+') > fcntl.flock(mboxfile.fileno(), fcntl.LOCK_EX) > > in the interpreter and then try to access the file in another terminal > (I leave the interpreter open

Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Danny Yoo
On Thu, 23 Feb 2006, Patty wrote: > def addpercent(mp, lp): > conn = MySQLdb.connect(host = "localhost", user = "root", passwd = > "",db ="my_db") > cursor = conn.cursor() > cursor.execute (""" > UPDATE targets > SET mario_percent = %d, lizard_

Re: [Tutor] mod_python & mysqldb problem

2006-02-23 Thread Danny Yoo
> I downloaded the latest version of mysqldb and my code worked. btw, I > changed it to %s instead of %d. Hi Patty, That's great news! Does the whole thing work now, including the integration with mod_python? I'm following up and making sure that the problem was simply the stale copy of MySQL

Re: [Tutor] Finding items in a list

2006-02-24 Thread Danny Yoo
On Fri, 24 Feb 2006, Emily Patek wrote: > I am trying to break apart a list into several smaller lists based on > repeating nearly identical entries. For example, every so often there > is the word CLUSTER with a number after it, like CLUSTER 1. I can find > them one by one, but would like to

Re: [Tutor] Grepping a file for words in a list

2006-02-24 Thread Danny Yoo
On Fri, 24 Feb 2006, John Purser wrote: > I'm writing a system admin script in python that checks recently > accessed files for keywords like "failed, denied, error,..." etc. I'm > using popen to call grep -F but it's VERY slow. Can > anyone suggest a faster method to do this? Hi John, Thi

Re: [Tutor] Problem with threads

2006-02-25 Thread Danny Yoo
On Sat, 25 Feb 2006, David Cohen wrote: > I have a problem trying to use thread on python. I import the threading > module and execute this: > > def func_thread(): > something... > > new_thread = threading.Thread(target = func_thread) > new_thread.start() > > But the thread never really star

Re: [Tutor] software carpentry

2006-02-25 Thread Danny Yoo
> 1) Is subversion really a good tool for the beginning programmmer, or a > single programmer? If not which version control system would you > recommend? what about tortoiseSVN? Up til now i've just been saving > multiple filenames of my code. Hi Brian, Yes, learning to use a revision control sys

Re: [Tutor] RDT server for excel

2006-02-27 Thread Danny Yoo
On Mon, 27 Feb 2006, [ISO-8859-1] J�nos Juh�sz wrote: > I would like to make a small RDT Server as COM Server in python that can > be called from excel as =RDT("StockBalance.MyServer",,"17") I'v > tried to use google, but with not too much success. I just would like a > simple sample. Hi Ja

Re: [Tutor] Unexpected Behavior in unittest

2006-02-28 Thread Danny Yoo
> In this case, the assignment to lg.cs failed. > >> > F > == > FAIL: test_cs (__main__.cs_tryout) > -- > Traceback (most recent call last): >

Re: [Tutor] Unexpected Behavior in unittest

2006-02-28 Thread Danny Yoo
> I wish it were that simple. 'test3.py' is the name of the file > containing the test case class. I left the invocation out of my output > excerpt. It should look like this: Hi Barry, Ok. But still go back and make sure you're running the right file. The error message says that: > Trace

[Tutor] DOUBT -Its urgent!!!! (fwd)

2006-03-01 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 1 Mar 2006 17:12:47 +0100 (CET) From: Joaquin Sanchez Sanchez <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: DOUBT -Its urgent I have a doubt I have some modules in python, and in one of them, i have to dictionarys. In them, i have s

Re: [Tutor] Delete in .dat

2006-03-04 Thread Danny Yoo
On Sat, 4 Mar 2006, ryan luna wrote: > My question seems like itd be farly simple but i cant seem to get it to > work, My .dat file is a dictionary and i need to be able to only delete > a single word and its definition, heres what i have so far but it > doesn't work. Hi Ryan, By "doesn't work

Re: [Tutor] how to get the return value?

2006-03-05 Thread Danny Yoo
Hi Ingo, I'm coming into this thread a little late, but looking at your original program: http://mail.python.org/pipermail/tutor/2006-March/045505.html you may want to adjust your schedule function a bit to capture return values. As far as I can tell, the code throws them away when it call

Re: [Tutor] source file or installer

2006-03-06 Thread Danny Yoo
On Mon, 6 Mar 2006, linda.s wrote: > what are the benefits of building python from source file? any > difference if using installer? Hi Linda, If a binary installer is available for your platform, you'll probably want to stick with it. It provides the most convenient way to get Python. Som

Re: [Tutor] after signal handler

2006-03-06 Thread Danny Yoo
On Mon, 6 Mar 2006, Hameed U. Khan wrote: > I want to go back after signal handler to the isntruction where I was > stuck. Below is the code I'm trying to play with. Hi Hameed, Here's a small test program that shows that the signal handling does go back to where we left off:

Re: [Tutor] Analysing genetic code (DNA) using python

2006-03-06 Thread Danny Yoo
> I have many notepad documents that all contain long chunks of genetic > code. They look something like this: > > atggctaaactgaccaagcgcatgcgtgttatccgcgagaaagttgatgcaaccaaacag [data example cut] > Basically, I want to design a program using python that can open and > read these documents. Hello

Re: [Tutor] Are we the same?

2006-03-06 Thread Danny Yoo
On 6 Mar 2006 [EMAIL PROTECTED] wrote: > I just took this test on Tickle.com. To see how I scored, take the test. [advertisement cut] I don't mean to be dull, but what does this have to do with Python? If it doesn't have anything to do with learning Python or programming, let's keep it off th

Re: [Tutor] Are we the same?

2006-03-06 Thread Danny Yoo
On Mon, 6 Mar 2006, [ISO-8859-1] Hugo Gonz�lez Monteverde wrote: > I believe it is just spam pretending to be a legit invitation, that made > it to the list. Followup: Gavin later sent a reply apologizing to the list --- maybe he got a virus? --- but it didn't make it through since it was addre

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> I have a problem finding specific words. > I would like to filter out a word or replace it in a file. > I notices that the re module is good for finding patterns. Hi Tak, Although regular expressions might be overkill for this problem, it can't hurt to know about the Regex HOWTO: http://

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> regex allows us to specify certain conditions in the patterns > such as whether the characters are digits etc, and also whether > we are kooking for a word which is wat you want. > Specifically \W signifies a word boundary so > > \Whello\W > > will find hello as a word. Hi Alan, Using the non-

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> > Slightly more robust is the '\b' boundary assertion pattern: > > And I never understood why there were two... > > Which begs the question: under what circumstance would we prefer > to use \W instead of \b? In terms of code: ## >>> import re >>> re.search(r'(\W\w+\W)', 'hello|||').gro

Re: [Tutor] how does this list comprehension work?

2006-03-08 Thread Danny Yoo
On Wed, 8 Mar 2006, Christopher Spears wrote: > I copied this program from Learning Python and got it to work on Windows > XP: > > import sys, glob > print sys.argv[1:] > sys.argv = [item for arg in sys.argv for item in > glob.glob(arg)] > print sys.argv[1:] > > The key to the script is the list

Re: [Tutor] how to write a string into a specific line in a file

2006-03-08 Thread Danny Yoo
On Wed, 8 Mar 2006, andrew clarke wrote: > On Tue, Mar 07, 2006 at 11:18:27AM -, Alan Gauld wrote: > > > > I was wondering if it is possible to write a string to a specific line > > > in a file without reading in the whole file in as the below. > > > > Some languages, such as COBOL and some

[Tutor] Using os.popen()

2006-03-08 Thread Danny Yoo
Hi Victor, Meta notes: if you're replying to a message, please make sure that message is relevant to what you're asking. You just replied to the digest and included its whole contents back at the list, which is not useful. In this particular case, it makes more sense to send a new message to t

Re: [Tutor] Python interpreter/Xemacs and the py-execute-buffer

2006-03-09 Thread Danny Yoo
> I have been using Xemacs 21.4 Patch 13 on Windows XP with Python 2.4.2 > (final). Whenever I try to run a script inside the xemacs window using: > C-c C-c I get the following: Opening output file: Invalid argument, > C:\Documents and Settings\jkat\Local Settings\Temp;C:\Devel\emacsk2AS2x Hi Fra

Re: [Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Danny Yoo
> So I take a look into the source code .But I get confused about so many > files and functions . I want to ask that is there any stuff about the > interpreter design and coding ? [meta: my reply is really about Scheme, not Python. My apologies to the list, but it's my honest answer.] Hi Bo, Th

Re: [Tutor] Automatic software performance meter

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, [ISO-8859-1] J�nos Juh�sz wrote: > is it any easy way to mesaure a windows software response time from python > script ? > I think about a small python script that can open a win32 application, > insert a new order with sendkey, deliver the goods, do other things and > c

Re: [Tutor] Dynamically naming functions

2006-03-10 Thread Danny Yoo
> I want to use this in a few different places. For example Faces, the > Python Project Management Planner Tool Thingy, uses nested functions to > put tasks within a project: > > def MyProject(): > start = "2006-03-06" > resource = Me > > def Task1(): > start = "2006-03-13" > >

Re: [Tutor] *args consumption

2006-03-10 Thread Danny Yoo
> Am I missing some other usage where you wouldn't want to unpack the > *arg? If not, would the following "behind the scenes" behavior be > possible/preferred? > > ### > def foo(*arg): > pass > ### > > automatically does this > > ### > def foo(*arg): > if len(arg) == 1: > arg = arg[

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Edgar Antonio Rodriguez Velazco wrote: > Could you please explain this code?. > > f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1 Hi Edgar, This is terrible code. *grin* I know that this is the factorial function in disguise, but this is just Wrong. I don't think we sho

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
> The expression n-1 + abs(n-1) is always a true value... except in the > case where n is zero. Sorry, that's wrong of me, but you know what I mean. *grin* It zeros out when n-1 <= 0, that is, when n <= 1. ## >>> def test(n): ... return n-1 + abs(n-1) ... >>> for x in range(-5, 5): ...

Re: [Tutor] Cannot Understand

2006-03-10 Thread Danny Yoo
On Fri, 10 Mar 2006, Danny Yoo wrote: > > The expression n-1 + abs(n-1) is always a true value... except in the > > case where n is zero. > > Sorry, that's wrong of me, but you know what I mean. *grin* Ugh, the other thing I screwed up wrong was misreading: X and

Re: [Tutor] activestate

2006-03-11 Thread Danny Yoo
On Sat, 11 Mar 2006, kevin parks wrote: > I noticed a couple days ago that the active state archive seems to have > ceased. Is it going away? Hi Kevin, Can you check this again? It appears to look ok to me: http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/python-Tutor _

Re: [Tutor] need help tracing a syntax error

2006-03-11 Thread Danny Yoo
> I get the message > > syntax error > > > and it highlightsr2 > > in the line > > .If r2 == 1: Hi Kermit, Next time, rather than describe the error message here in paraphrase, please copy-and-paste it in. Your paraphrase of the situation here hides useful information. We would rather that

Re: [Tutor] scaling values

2006-03-14 Thread Danny Yoo
On Tue, 14 Mar 2006, kevin parks wrote: > is there a scaling function in python (or numeric or scipy) that can > scale a list of values to a high precision? > > x = [13, 71, 120, 88, 82, 100, 10, 65, 101, 45, 26] > > foo = scale(x, 0, 1.0) Hi Kevin, I'm still confused by the problem. Let's tr

Re: [Tutor] Iterate over letters in a word

2006-03-14 Thread Danny Yoo
> "Hello Tutors!" could be split into: > > "Hell" "o Tut" "ors!" > > and xor'd with "beer" > > I think I understand how xor works (thanks to an earlier post) but I'm > not sure how to iterate over each letter in a string. What is the > recommended way to do this? The xor bitwise operator works wi

Re: [Tutor] Iterate over letters in a word

2006-03-14 Thread Danny Yoo
> As a side note, remember that that xor-ing a key with a message is > trivial to break (it's just a variation on the Vigenere cipher first > published in 1568). So don't use if for any real applications. Hi Matthew, Counterpoint: think of "one-time pads". http://en.wikipedia.org/wiki/One-

Re: [Tutor] Iterate over letters in a word

2006-03-14 Thread Danny Yoo
> Yes - at the moment this is just a way for me to begin to get my head > around how cryptography works from anabsolutely ludicrously basic > position. This all started because I couldn't get my head around the > difference between an encryption algorithm and the key. I thought that > by writing

Re: [Tutor] Help with re.sub()

2006-03-16 Thread Danny Yoo
> I have a file that is a long list of records (roughly) in the format > > [EMAIL PROTECTED] > > So, for example: > > [EMAIL PROTECTED] > [EMAIL PROTECTED] > [EMAIL PROTECTED] > [EMAIL PROTECTED] > [EMAIL PROTECTED] > > > What I would like to do is run a regular expression against this and > w

Re: [Tutor] xemacs and python mode difficulty

2006-03-16 Thread Danny Yoo
> I would like to know the difference between ~/.emacs and > .xemacs\custom.el and also how to install the python module, so that I > can get syntax highlighting, the tab trick, C-c C-c, and the rest of the > old python mode functionality. HI Francesco, You may want to ask the xemacs folks about

Re: [Tutor] Python Control Flow Graph

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Brian C. Lum wrote: > I have been looking for a good way to convert python code into a control > flow graph. [text cut] Hi Brian, I think you may want to ask your question to the pypy folks, since your question is a bit specialized. Check out pypy, which is an implemenat

Re: [Tutor] function signatures for callbacks

2006-03-21 Thread Danny Yoo
> I have a piece of code that wants a callback from a client: > > The code looks like this right now: > > class pawprints: > def __init__(self, callback_fun = None) > ... > > > at the client calling site I have something like this: > > def printme(modulename, codename, lineno, line)

Re: [Tutor] function signatures for callbacks

2006-03-21 Thread Danny Yoo
> > It seems backwards to me because because if I get the function > > definition wrong in the client site then I get a traceback to the > > callback site - which is meant to be an opaque library that the client > > should not have to know about. > > Yes, what you're asking makes sense: we want to

Re: [Tutor] unicode issue?

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Matt Dempsey wrote: > I'm having a new problem with my House vote script. It's returning the > following error: > > Traceback (most recent call last): > File "C:/Python24/evenmorevotes", line 20, in -toplevel- > f.write > (nm+'*'+pt+'*'+vt+'*'+md['vote-result'][0]+'*'+

Re: [Tutor] unicode issue? (fwd)

2006-03-21 Thread Danny Yoo
> A friend of mine showed me where the unicode is showing up but we still > can't get script to work right. We tried encoding the appropriate > variable but it still is spitting back the error. Would I just have: > u'\u201c'.encode('utf8') in my script or should it be > md['vote-desc'][0].encode('

Re: [Tutor] how to get a line text from input file.

2006-03-21 Thread Danny Yoo
On Wed, 22 Mar 2006, Keo Sophon wrote: > i am new to programming language and python. I wonder how to get a line > text from input file. Hi Sophon, You may want to look at: http://wiki.python.org/moin/BeginnersGuide/NonProgrammers Many of the tutorials there talk about reading from files

Re: [Tutor] how to set a value to a block of memory

2006-03-21 Thread Danny Yoo
On Tue, 21 Mar 2006, Kent Johnson wrote: > > How can i set a value to a bytes of block of memory. In C, i think > > they use memset like this. Hi Sophon, Secondary question: why are you trying to do this? Are you trying to represent a collection or "array" of things? Some concepts in C aren

Re: [Tutor] how to set a value to a block of memory

2006-03-21 Thread Danny Yoo
> On Tue, 21 Mar 2006, Kent Johnson wrote: > > > How can i set a value to a bytes of block of memory. In C, i think > > > they use memset like this. Whoops, sorry about that Kent! I completely messed up the attribution when cutting-and-pasting.

Re: [Tutor] Hi

2006-03-21 Thread Danny Yoo
> I am new to python and I am going through the URL > http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going > through the Chapter 7 Strings, I am stuck with understanding slice which > is a part of a String, I am not able to understand how it functions Hello, A "slice" takes

Re: [Tutor] efficient method to search between two lists

2006-03-22 Thread Danny Yoo
> Although dictionary is superfast, due to duplications > in both columns of list_a, a dictionary option falls > out. Hi Srinivas, A dictionary method can work perfectly well. The assumption that I think is being made is that dictionary values are restricted to single values. But dictionaries a

Re: [Tutor] urlopen: where are the results?

2006-03-22 Thread Danny Yoo
On Wed, 22 Mar 2006, Kermit Rose wrote: > Anybody care to comment on the following? > > >>> from urllib2 import * Don't do this. *grin* Using 'from [modulename] import *' is not so good in Python because there's no warning if one of the contents in the module is overriding an existing definit

Re: [Tutor] i need help please read

2006-03-22 Thread Danny Yoo
On Wed, 22 Mar 2006, Tom Bachik wrote: > ok does anyone know how to righ a script were a box pops up then if it > goes over a number on the screen it pops up in the box become the input > number so you can alter the number that popped up in the box? if you do > can you right it and send it to me

Re: [Tutor] Renaming computers

2006-03-23 Thread Danny Yoo
On Thu, 23 Mar 2006 [EMAIL PROTECTED] wrote: > Could you point me in the right direction, after we have ghosted the > machines in college we have to rename them, I would like to try and > write a program that does this through matching the MAC address with the > computer but I'm quite new to pro

Re: [Tutor] Inner Class access to outer class attributes?

2006-03-23 Thread Danny Yoo
On Thu, 23 Mar 2006, stv wrote: > Hmmm, so every Sublocation object has a copy of the grouplocation data? Hi stv, Not exactly: each sublocation has a "reference" to the parent grouplocation. There's a distinction between a "reference" and a copy. Think of a reference as an arrow to the other

Re: [Tutor] Inner Class access to outer class attributes?

2006-03-23 Thread Danny Yoo
> So Curly has a list of references to friends. A model diagram of the > situation looks something like this: > > > larry --> { name,friends } > | | > V | > "Larry" [ x, x ] >

Re: [Tutor] i need help please read (fwd)

2006-03-23 Thread Danny Yoo
[forwarding to tutor] -- Forwarded message -- Date: Thu, 23 Mar 2006 15:15:11 -0800 From: Tom Bachik <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] i need help please read no it is not homework, i havent started y idea yet but my ques

Re: [Tutor] i need help please read (fwd)

2006-03-24 Thread Danny Yoo
> > you no like ask you a question or somthin. > > Danny was simply asking for more information so that we can > answer the question in a useful way. Hi Alan, But you're misinterpreting that part of message. Let's look back at the message: """no it is not homework, i havent started y idea y

Re: [Tutor] function signatures for callbacks

2006-03-24 Thread Danny Yoo
On Fri, 24 Mar 2006, Don Taylor wrote: > When I first read your response I did not see how it helped me, but now > I realise that it allows me to add some context to the exception message. > > I don't suppose that I can change the traceback to point at the > definition of f2 instead of shout() b

Re: [Tutor] function signatures for callbacks

2006-03-24 Thread Danny Yoo
> Ok I tried this and it is good. > > I don't think that I need the _internal_shout anymore as this code > already wraps the exception handling and I can decide what I want to > display in the above except statement. > > Unless I am missing something? Yup, nope. *grin* That was just there to sho

Re: [Tutor] What is wrong my code?

2006-03-24 Thread Danny Yoo
> leg1 = raw_input('Enter the first leg of the triangle: > ') > leg2 = raw_input('Enter the second leg of the > triangle: ') Hi Hoffmann, leg1 and leg2 here are strings, because raw_input() is guaranteed to return strings. You'll want to do something to turn those strings into numbers, since t

Re: [Tutor] What is wrong my code?

2006-03-24 Thread Danny Yoo
> #!/usr/bin/python > > import math > > print '''This program calculates the lenght of the > hypotenuse of a right triangle > given the lenghts of the two legs as > parameters.\n''' > > leg1 = input('Enter the first leg of the triangle: ') > leg2 = input('Enter the second leg of the triangle: '

Re: [Tutor] What is wrong my code?

2006-03-24 Thread Danny Yoo
> I did like your comments about input and raw_input. > What about if I use on my program: > > leg1 = int( raw_input('Enter the first leg of the > triangle: ') ) > leg2= int( raw_input('Enter the second leg of the > triangle: ') ) > > What do you think? This is better/safer, right? Hi Hoffmann, Y

Re: [Tutor] site-packages

2006-03-25 Thread Danny Yoo
On Sat, 25 Mar 2006, linda.s wrote: > I downloaded some modules and were told to put under > *\Python24\Lib\site-packages Hi Linda, Out of curiosity, which module? If we're being asked to copy files manually into site-packages, we should do a double check on this, because that's a slightly od

Re: [Tutor] Python help

2006-03-28 Thread Danny Yoo
On Tue, 28 Mar 2006, Natasha Menon wrote: > i need help on a terrible homework assignment. do ul offer hw help? Not directly. Your homework is really your own to do. Please try to avoid the temptation of just posting a homework question here and hoping that someone will do the work for you.

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-03-31 Thread Danny Yoo
> Then, the output is like so: > > >>> atoms = ["a","b","c"] > >>> tvas = tva_dict_maker(atoms) > >>> display_tvas(tvas) > a:Trueb:True c:True > a:Trueb:True c:False > a:Trueb:False c:True > a:Trueb:False c:False > a:False b:True c:True > a:False

Re: [Tutor] Inverted Index Algorithm

2006-03-31 Thread Danny Yoo
> The next step would be to introduce an index. I think again, the > simplest thing that could possibly work would be a literal index of > every word and every document in which it appears. This would save > processing time, but wouldn't be very intelligent. Yes, that's right, that's the idea

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread Danny Yoo
> > Have you read a Python tutorial? It seems like some of the things you > > are struggling with might be addressed in general Python material. > > > You consider a thing about me. If I ask something it is because I cannot > find the solution. I do not it by whim. Hello Jonas, Yes, but don't t

Re: [Tutor] BeautifulSoup - getting cells without new line characters

2006-04-01 Thread Danny Yoo
> And the solution to get the state and capital columns (where there are > anchors): > > for row in table('tr'): >for cell in row.fetch('a')[0:2]: >print cell.string Hi Jonas, That's good to hear! So does everything work for you then? __

Re: [Tutor] Bigrams and nested dictionaries

2006-04-03 Thread Danny Yoo
> You can check if the dictionary key exists prior to assigning to it: > > >>> if not D.has_key('c'): > ...D['c'] = {} > >>> D['c']['a'] = 1 Hi Victor, Another approach is to use the badly-named "setdefault()" method which is a close analogue to Perl's "autovivification" feature: ## >>>

Re: [Tutor] defined()

2006-04-03 Thread Danny Yoo
> > I'm interested in what use you would make of such a thing? > My business partner is a perl programmer. He uses defined() a lot, I > think, I've seen it in his code Hello! The common idiom in Perl, I think, is to at least declare the variable, even if one doesn't give an initial value

Re: [Tutor] What's the invalid syntax?

2006-04-05 Thread Danny Yoo
> What's the invalid syntax in the following code? I tried figuring it out > by myself, and I couldn't. > > The editor highlights the word year in the line: > > int year > > after I hit okay when this message pops up: > > Invalid syntax. Hi Nathan, I would believe the editor. *grin* Python does

Re: [Tutor] mysql store directory information

2006-04-06 Thread Danny Yoo
On Thu, 6 Apr 2006, Tiago Saboga wrote: > As a first part of a project, I need to store a directory tree in a > mysql db. I'm wondering if there is a canonical way of doing that. I > don't know if it's an appropriate question for this list, but I think > it's not only a choice of db design, but

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Danny Yoo
> Your post got me to take another bash and I obtained a recursive > solution. But, subject to the caveat that my recursive solution might > well be non-optimal, the non-recursive approach seems a bit better to > me. Opinions welcome :-) > > My recursive solution: > > def recursive_tva_dict_maker(a

Re: [Tutor] request for sugestions on fragement of code for generating truth-tables

2006-04-06 Thread Danny Yoo
> One way to get rid of the 'recursed' flag is to refactor slightly, and > break out the sorting in another helper function, like this: > > ## > def tva_dict_maker(atoms): > tvas = tiva_helper(atoms) ^^^ >

Re: [Tutor] Python performance resources & resouce usage hints

2006-04-07 Thread Danny Yoo
On Fri, 7 Apr 2006, Kent Johnson wrote: > Hugo Gonz�lez Monteverde wrote: > > You are not using the optional timeout and blocking which 'get' provides (!) > > > > Try setting it and see your CPU usage go down. This will implement > > blocking, and the queue will be used as soon as data is there.

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
On Fri, 7 Apr 2006, Jesse wrote: > Why is it that when one variable is assigned a value in terms of another > variable, assigning a new value to the first doesn't change the value of > the second? Hi Jesse, If you have a "variable" that depends on the values of other parameters, that's just be

Re: [Tutor] Beginner question (variables, namespaces...)

2006-04-07 Thread Danny Yoo
> > buy_containers = roundup(need/container) > > > Yeah, rather than code these as explicit variables, I'd strongly recommend > rewriting each of these as functions. Concretely: > > def buy_containers(stock, weekly_quota, container): > return roundup(need(stock, weekly_quota) - extra(stock,

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-07 Thread Danny Yoo
-- Forwarded message -- Date: Fri, 7 Apr 2006 21:05:33 -0600 From: Jesse <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Beginner question (variables, namespaces...) I tried redefining the "higher-order" variables as functions, bu

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-08 Thread Danny Yoo
> I tried redefining the "higher-order" variables as functions, but it > didn't quite work. Here's a simplified example: > > > var1 = 2 > > def timestwo(x): > return x*2 > > var2 = timestwo(var1) > print var1, var2 > var1 = 3 > print var1, var2 Try: ## print 2, timestwo(2) print 3, times

Re: [Tutor] Beginner question (variables, namespaces...) (fwd)

2006-04-08 Thread Danny Yoo
> > ..which is not what I'm aiming for. Maybe I'll have to follow Bob's > > advice and just store all of the variable assignments in a function, > > and then call the function every time I change one of the variables > > (based on user input). I could still leave the higher-order variables > > as f

Re: [Tutor] Question about list

2006-04-10 Thread Danny Yoo
On Mon, 10 Apr 2006, Hoffmann wrote: > I also would like to print the length of each element > of that list: > > spam! = 1 element > 2 = 1 element > ['Ted', 'Rock'] = 2 elements > > Could anyone, please, give me some hints? The problem is slightly weird, just because you need to clarify what i

Re: [Tutor] failing to learn python

2006-04-10 Thread Danny Yoo
> I am a parttime sys admin so I want system admin problem which usually I > do through shell scripts like parsing logs, generating reports, greping > with regexes etc. Hi Payal, You might also find David Mertz's book "Text Processing With Python" to be useful for you: http://gnosis.cx/T

Re: [Tutor] input with default value option

2006-04-10 Thread Danny Yoo
> With raw_input(), it allows to input value. Can it be used to input > value with default value option? Hi Phon, We can build your own function to do this. Bob showed how to set up code so that the default's taken if the user just presses enter in his reply. Let's take a look at it again:

Re: [Tutor] comp.lang.python newsgroup

2006-04-11 Thread Danny Yoo
[taking [EMAIL PROTECTED] out of CC] Hi Kaushal, Please do not crosspost between [EMAIL PROTECTED] and [EMAIL PROTECTED] They are different mailing lists. > I went to a http://www.python.org/community/lists.html and found the > below newsgroup > > How do i use this news group and access th

<    5   6   7   8   9   10   11   12   13   14   >