[Tutor] Tuples / Critique of How to Think like a Computer Scientist [Was: Re: Tuples]

2006-04-12 Thread Danny Yoo
On Wed, 12 Apr 2006, Kaushal Shriyan wrote: > I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap09.htm > I did not understood the below Section at all :( Hi Kaushal, Ok, let's trying starting somewhere else and see at what point you get stuck. It'll also give you a chance to practic

Re: [Tutor] failing to learn python

2006-04-12 Thread Danny Yoo
On Wed, 12 Apr 2006, Payal Rathod wrote: > can I use Python. Everyone says it is a "general programming language", > but what in the world is a "general programming language"? One idea behind a "general purpose programming language" is that it's not specialized toward anything in particular.

Re: [Tutor] n00b question: dictionaries and functions.

2006-04-12 Thread Danny Yoo
On Wed, 12 Apr 2006, Jesse wrote: > def add(): >x = float(raw_input("Enter a number: ")) >y = float(raw_input("And a second number: ")) >print x + y > def subtract(): >x = float(raw_input("Enter a number: ")) >y = float(raw_input("And a second number: ")) >print x - y > >

Re: [Tutor] Python video?

2006-04-13 Thread Danny Yoo
On Wed, 12 Apr 2006, Hoffmann wrote: > I read this week on this forum about a kind of Python video in its > website. Which view is that, and where could I find it? I search in > Python website, but I didn't find it. Is it a 'demo' of the language? It's a video with gushing praise over Python,

Re: [Tutor] checking diagonals on a chessboard

2006-04-13 Thread Danny Yoo
> I'm building a genetic algorithm to solve the queen placement problem, > the complicated stuff I can do on my own, but I'm not getting one part. > suppose the queen is on a square, I can check that it is in the same row > or same col but the diagonals, are less straight-forward. I know I could

Re: [Tutor] Python video?

2006-04-13 Thread Danny Yoo
> I find Python411 an excellent podcast about Python: > http://www.awaretek.com/python/index.html > > and on general topics about IT: > http://www.itconversations.com/ Before its untimely demise, Dr Dobbs Journal used to do a lot with Technetcast: http://technetcast.ddj.com/ The site st

Re: [Tutor] (no subject)

2006-04-15 Thread Danny Yoo
> STOP SENDING ME MESSAGES I NEVER SIGNED UP TO YOUR MAILING LIST Followup --- unsubscribed. In the future --- and just so that others know --- if anyone has any administrative messages or "unsubscribe me" messages, send them to the administrators at: The administrative email address is:

Re: [Tutor] Didn't take long to hit my next wall!

2006-04-15 Thread Danny Yoo
> I am having problems amending records in my database. Hi John, The root of this problem is a matter of choosing variable names that are way too terse. In particular, note that you're using the variable 'c' as: c = 'PF1' but at the same time, you're also using: c = db.cursor()

Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
On Sat, 15 Apr 2006, Tiago Saboga wrote: > Can I use string formatting in my own functions, or is it stuck with builtins? > It doesn't make much sense for me, but I don't understand the following > error: > > In [1]: var = 456 > > In [2]: def printd(arg): > ...: print('>>> %s') % arg > .

Re: [Tutor] string formatting (%s)

2006-04-15 Thread Danny Yoo
> The parenthesization you had earlier forced Python into printing out > your template before it had an opportunity to plug arg into it. You > need to do the interpolation first. Gaaah. Brain freeze. I was pointing at the wrong code. *grin* I meant to look at the other statement that you h

Re: [Tutor] functions in Python

2006-04-17 Thread Danny Yoo
> Sorry, but you have confused me more ;) Can you give an simple example > of just function() ? Where can it be useful? > > And when you say it returns a value, what do you mean by that? return to > whom and what exactly? One view that's common is the idea that a function is a box that takes an

Re: [Tutor] functions in Python

2006-04-17 Thread Danny Yoo
On Mon, 17 Apr 2006, Payal Rathod wrote: > What is the difference between, > def f(x): > ... return x > ... f(4) > 4 > def f(x): > ... print x > ... f(4) > 4 > > Both give same results. Clarification. Both "show" the same results from the interpreter. From what yo

Re: [Tutor] functions in Python

2006-04-18 Thread Danny Yoo
> New at this but the f(x) with the return statement passes the value back > to be used in something. The one with the print statement just prints > it. Correct me if I am wrong experts > def f(x): > x = x + 1; > return x > > def g(x): > x=x + 1; > print x; Hi Eric, Yes, you've got it

Re: [Tutor] pyexpat

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Andre Engels wrote: > 2006/4/18, Kent Johnson <[EMAIL PROTECTED]>: >> Andre Engels wrote: >>> I am working for the Python Wikipediabot Framework >>> (http://www.sourceforge.net/pywikipedia). A user noted me to an >>> apparent deadlock in the XML parsing. I tried to get to th

Re: [Tutor] Olle-Olla

2006-04-18 Thread Danny Yoo
> Is it possible to replace the print statement with one of mine function ? Hi Janos, Yes; there are a set of reserved "keywords" that Python does not allow to be rebound as something else. It's a particular consequence of the way Python's language grammar is parsed. You'll want to watch ou

Re: [Tutor] Quick networking question

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Tino Dai wrote: > I am writing a script to do some simple networking. When I do a > close on the socket and exit the program, I getting a time wait on the > port, and the port can''t be utilized again until the time wait > disappears. How do I get port to shut down a

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Andre Roberge wrote: > Suppose I had a function like the following: > > def y_n(prompt="Answer yes or no"): >while True: >answer = raw_input(prompt) >if answer in ['y', 'Y', 'yes']: >print "You said yes!" >break >elif answe

Re: [Tutor] encode

2006-04-18 Thread Danny Yoo
On Wed, 19 Apr 2006, kakada wrote: > I wonder if we can check the encoding of text in one text file. user is > free to encode the file whether Latin1, utf-8, ANSI... In the general case, this is difficult, and "solving" it might be worse than not. See: http://www.joelonsoftware.com/art

Re: [Tutor] pyexpat

2006-04-19 Thread Danny Yoo
On Wed, 19 Apr 2006, Andre Engels wrote: > 2006/4/18, Danny Yoo <[EMAIL PROTECTED]>: > >> H Can you send a link to the text that's causing performance >> issues? It might be possible that someone here might isolate the >> performance prob

[Tutor] net ettiquette and sentence sorting/homework

2006-04-19 Thread Danny Yoo
>> * > i want to write a function which will sort the sentence by the length of > each word in the sentece, short length first.please help. Hi Nywbon, First: please do not reply to the whole email digest. The point of a reply is to continue a previous conver

Re: [Tutor] Re-instantiate within __init__

2006-04-19 Thread Danny Yoo
> I tried: > > class Omega: >def Display(self): >print self > > class Alpha(Omega): >def __init__(self): >self = Beta() > > class Beta(Omega): >def __init__(self): >pass > > objectus = Alpha() > objectus.Display() > > which prints > > <__main__.Alpha instance at

Re: [Tutor] Parsing html user HTMLParser

2006-04-20 Thread Danny Yoo
> I need help here, I'm struggling with html parsing method, up until now > I can only put and html file as instance. I have no experience with > this, I want to read the childs inside this document and modify the > data. What can I do if I start from here? Hi Titvirak, You might want to tak

Re: [Tutor] Bug in python, or is it just 3am

2006-04-21 Thread Danny Yoo
On Fri, 21 Apr 2006, ryan luna wrote: > HA! ignore me, im stupid, XD i knew i should have waited untill morning > =P, No bug, the number = number was just point to the old number which > was one number lower, sorry. night =P Get some sleep. *grin*

Re: [Tutor] Tutor FAQ?

2006-04-21 Thread Danny Yoo
> I assume Kent, Alan and Danny don't mind their answers being reused in > the wiki, but it would probably best to get explicit permission from > them (and other people) to re-use text from their answers. I give explicit permission for any of my replies to be reused this way. ___

Re: [Tutor] looking to hire a tutor

2006-04-21 Thread Danny Yoo
> How would I go about hiring a python tutor who: > > Spends time critiquing my code and providing detailed feedback. Hi Meenakshi, People here are usually suprisingly gracious with their time, and will be happy to look and critique code. You may want to try your hand at showing us some code.

Re: [Tutor] how can I use Set.interaction function on a dictionary

2006-04-23 Thread Danny Yoo
> 1. I have a dictionary with 4 keys and some repeated > values for each key. > dida > {'NM_001033044': [32842023, 32842023, 32842023, > 32842023, 32842023, 32842023, 32842023, 32842023, > 32842023, 32842023, 32842023, 32842023, 32843894, > 32843894, 32843894, 32843894, 32843894, 32843894, >

Re: [Tutor] Locking a specific variable

2006-04-23 Thread Danny Yoo
On Sun, 23 Apr 2006, Tino Dai wrote: > I am wondering if you could lock a specific variable with thread > locking. Let me illustrate: > > def ftpQueuePut(filename=""):: > if len(filename) > 0: > try: > fileQueue.put(filename,True,1)#Variable that I would like to > lock >

Re: [Tutor] hash.update( argv[0] )

2006-04-23 Thread Danny Yoo
On Sun, 23 Apr 2006, George Georgalis wrote: > Hi! I've been struggling to find a way up seed hash.update() with > the sha1 (or similar) of the file that is the program running. > > this is not a security task but rather a means to generate > reasonably unique filenames based on various paramete

Re: [Tutor] How use relative path of Linux environment in Python

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Keo Sophon wrote: > Do you have any idea of how to use relative path of Linux environment in > Python. For example, if a program would like to create an oupfile from > these assignment: outputfile = "~/Desktop/" + workingfile, while "~" is > the short cut to the path of c

Re: [Tutor] How use relative path of Linux environment in Python (fwd)

2006-04-24 Thread Danny Yoo
-- Forwarded message -- Date: Mon, 24 Apr 2006 14:28:34 +0700 From: Keo Sophon <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] How use relative path of Linux environment in Python On Monday 24 April 2006 14:24, you wrote: > On Mon, 2

Re: [Tutor] Locking a specific variable (fwd)

2006-04-24 Thread Danny Yoo
-- Forwarded message -- Date: Mon, 24 Apr 2006 07:32:04 -0400 From: Tino Dai <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Locking a specific variable Hey there Danny, I'm not quite sure I get it, but ok. *grin* I'll assume

Re: [Tutor] Looping over lists of objects

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Etrade Griffiths wrote: > just feeling my way into Python with a small app that reads data from > file, creates objects using that data, stores the objects in a list, > loops over the list doing comparison tests to filter out various > objects. Here is a code snippet: >

Re: [Tutor] Object defined by initialization parameters

2006-04-24 Thread Danny Yoo
On Mon, 24 Apr 2006, Andre Engels wrote: > Is it possible to define a class in such a way, that if twice an object > is made with the same initialization parameters, the same object is > returned in both cases? Yes. The idea is to have the "constructor" really be a function that delegates o

Re: [Tutor] Locking a specific variable (fwd)

2006-04-24 Thread Danny Yoo
> # The way I would like to do it, so we have two different instances of > the same variable, and only # one function can access it at a time. If a > function comes to that variable and finds a lock on it, # it will wait > until the lock is released. And the variable happens to be a queue Hi T

Re: [Tutor] hash.update( argv[0] )

2006-04-24 Thread Danny Yoo
> where outputVersion is a manual set variable in the program > (so I have to purge all the imageFile each time I adjust the > program. maybe this is going to work, less progressive approach ^^^ Hi George, Just to make sure: by "progressiv

Re: [Tutor] Setting a global variable on class initialisation

2006-04-27 Thread Danny Yoo
> I know that overall Global variables are bad idea, however, I have a > situation where on on initialisation of a class, I need to read in two > files and then populate two lists. Hi Max, Could you give more context to this problem? I'm not sure we get it yet. *grin* > The lists need to w

Re: [Tutor] Unicode Encode Error

2006-04-27 Thread Danny Yoo
> You're right, I realised after playing with Tim's example that the > problem was that I wasn't calling close() on the codecs file. Adding > this after the f.write(html_text) seems to flush the buffer which means > that the content now gets written to the file. Hi Frank, Quick note: it may be

Re: [Tutor] Unicode Encode Error

2006-04-27 Thread Danny Yoo
>>> You're right, I realised after playing with Tim's example that the >>> problem was that I wasn't calling close() on the codecs file. Adding >>> this after the f.write(html_text) seems to flush the buffer which >>> means that the content now gets written to the file. >> >> Quick note: it may

Re: [Tutor] Strange Question

2006-04-29 Thread Danny Yoo
> First, I think this is a wonderful list. I always see great advice and > great attitudes about helping. > > My post is not about evaluating code but instead trying to get a > reasonable judgment as to whether or not python is the best choice for > what I am trying to do. I have not learned

Re: [Tutor] Splitting strings into blocks

2006-04-30 Thread Danny Yoo
On Sun, 30 Apr 2006, Daniel Watkins wrote: > I'm currently working on a program to parse LaTeX style maths > expressions and provide an answer. For example, I have the expression > "2^\frac{1}{2}". I'm trying to work out a way to split this into it's > most basic blocks of LaTeX (i.e. 2^ and

Re: [Tutor] copying files and regular expressions

2006-05-01 Thread Danny Yoo
On Mon, 1 May 2006, Alfonso wrote: > I'm totally new to python. I would like to know, how can I copy files > using regular expressions (the equivalent in python to unix "cp > /home/mycount/*partialname* /home/mycount/directory/"). Hi Alfonso, Just as a pedantic note: the above pattern you're

Re: [Tutor] question about run time

2006-05-02 Thread Danny Yoo
> I have been using python for sometime...and occasionally I noticed > significant delay before the code would run but unitl now I have been > able to write it off to other things. Now I have a short script that I > wrote to check some files and print out a few lines. > > I have noticed that

Re: [Tutor] question about run time

2006-05-02 Thread Danny Yoo
Hi John, You can try something like the profiler, which will say where most of the program's time is being spent. We can find documentation on the Python profiler here: http://www.python.org/doc/lib/profile.html >From a rough, low-level standpoint, there are tools like 'top' on Linux

Re: [Tutor] counting number of inputs

2006-05-02 Thread Danny Yoo
On Tue, 2 May 2006, MICHELLE EVANS wrote: > I am trying to count the number of times a positive number is entered > from the user. But, the program must stop after 5 user inputs or a > negative number. That seems like a really arbitrary and silly thing to do, but ok. So... what question do

Re: [Tutor] Bitten by lexical closures

2006-05-03 Thread Danny Yoo
On Wed, 3 May 2006, Igor wrote: > And I thought I understood python pretty well. Until I got hit by this: > def f(x): > ... print x > cb = [lambda :f(what) for what in "1234"] for c in cb:c() > 4 > 4 > 4 > 4 Hi Igor, I think you're getting caught by something that isn't quite

Re: [Tutor] Memory Management etc

2006-05-04 Thread Danny Yoo
> I have a problem with a large programme that uses a lot of memory > (numerous large arrays which are dynamically extended). I keep getting > unpredictable crashes (on a machine with 1/2 GB memory) whereas on my > laptop (1 GB memory) it seems OK. Hi Philip, Can you be more specific about wh

Re: [Tutor] why different

2006-05-05 Thread Danny Yoo
On Fri, 5 May 2006, linda.s wrote: > I have two drives. The python24 is installed in c: and the code is in d: > drive (d:\data). > so what I did is: > d:\data> c:\python24\python test.py Hi Linda, Can you copy and paste the code to test.py? I suspect that the code does not contain a necessar

Re: [Tutor] python cgi and html streams

2006-05-05 Thread Danny Yoo
> I was hoping for something magical like: > > gulp = cgi.StreamIO(" > http://www.foo.com/cgi-bin/responder.cgi?foo=hi&bar=there&bat=buddy";).read() > > ... but for some reason not one of the python creators foresaw that I might > one day need them to do all the thinking, typing and other hard par

Re: [Tutor] Calling one python module from another

2006-05-05 Thread Danny Yoo
On Fri, 5 May 2006, Mitchel Carlsen wrote: > Is there an easy way to call on python module (called.py) from another > (calling.py)? I have been able to do this using 'rc = > os.system("called.py")' . Is this the suggested method? Hi Mitch, If you are looking for modules, you may want to ta

Re: [Tutor] Drifting Values in urllib.

2006-05-06 Thread Danny Yoo
On Sun, 7 May 2006, Alan Gauld wrote: >> Am I missing something fundamental here? I am not used to dictionaries >> swirling around like this. :-) > > Caveat: I didn't read this through thoroughly but... > > Dictionaries are not in any specific order, you cannot rely on the order > remaining co

Re: [Tutor] Drifting Values in urllib.

2006-05-06 Thread Danny Yoo
> parameters = urllib.urlencode > ({"id":"%s","origin":"%s","dest":"%s","class1":"85", "weight1":"185","custdata":"%s","respickup":"","resdel":"%s", "insidechrg":"","furnchrg":"","cod":""})%(id,origin,dest,custdata,resdel) Hi Doug, On closer look, I think there's a misunderstanding here. Accor

[Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-06 Thread Danny Yoo
Hi everyone, One of the major complaints that people have made about the "One Day of IDLE Toying" tutorial I've written is that the screenshots are badly outdated. http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ I was curious if anyone wanted to volunteer to provide fresh, updated

Re: [Tutor] How do I do cubic roots and cubic exponents (and higher roots and exponents) in Python?

2006-05-08 Thread Danny Yoo
> How do I do cubic (and higher) roots and exponents in Python? I already > took a look in Python and didn't find anything. Hi Nathan, I think you're looking for the '**' operator. Like addition and multiplication, it can take in two numbers. ## >>> 2 ** 2 4 >>> 2 ** 3 8 >>> 2 ** 4

Re: [Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-09 Thread Danny Yoo
> One of the major complaints that people have made about the "One Day of IDLE > Toying" tutorial I've written is that the screenshots are badly outdated. > >http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ > > I was curious if anyone wanted to volunteer to provide fresh, updated > Windo

Re: [Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-10 Thread Danny Yoo
>> One of the major complaints that people have made about the "One Day of >> IDLE Toying" tutorial I've written is that the screenshots are badly >> outdated. >> >>http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/ >> >> I was curious if anyone wanted to volunteer to provide fresh, updat

Re: [Tutor] Call for volunteer to help revise images for One Day of IDLE Toying

2006-05-11 Thread Danny Yoo
> I have sent the screen shot of the IDLE being selected from Windows XP start > menu to Danny, incase someone is making another screen shot. Lets wait till > he requests another one. Thank you Alan and Evans! I've updated with those screenshots, and added a small cosmetic change to refer to P

Re: [Tutor] How do I create the equivalent of a Java class in Python?

2006-05-13 Thread Danny Yoo
> How do I create the equivalent of a Java class in Python? I've been > looking at the reference, and it's been confusing to me at least. You may want to look at a tutorial on classes, like: http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm Does this help? Best of wishes!

Re: [Tutor] Running Java process doesn't return to subprocess.call

2006-05-15 Thread Danny Yoo
On Mon, 15 May 2006, Jerome Jabson wrote: > I'm running a Java process from my python script using the subprocess > module. But there seems to be some problem with the return code to > subprocess and the Java program is just hanging waiting for something. Hi Jerome, I see that you're using s

Re: [Tutor] Running Java process doesn't return to subprocess.call (fwd)

2006-05-16 Thread Danny Yoo
-- Forwarded message -- Date: Tue, 16 May 2006 11:50:32 -0700 (PDT) From: Jerome Jabson <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [Tutor] Running Java process doesn't return to subprocess.call Hi Danny, I actually changed that just before I sent the email to tutor,

Re: [Tutor] Running Java process doesn't return to subprocess.call (fwd)

2006-05-16 Thread Danny Yoo
> I actually changed that just before I sent the email to tutor, cause I'd > seen a reference on the web about a Java process in Zope hanging. And > the fix was to have errfile set to None. It did NOT fix the problem. It > actually cause a Java Expection now! :-( Hi Jerome, [Please keep tutor@

Re: [Tutor] User input

2006-05-22 Thread Danny Yoo
> The second version works. > > print "Total trip cost is US$", float(distance) / > (float(mpg) * float(galon_price)) Hi Matt, Although this works, we'll probably want to do the type conversions as early as possible. We can write a function input_float() that wraps up the float(raw_input()) s

Re: [Tutor] Download file from the web and store it locally.

2006-05-22 Thread Danny Yoo
On Mon, 22 May 2006, MATATA EMMANUEL wrote: > import urllib > import sys > # Get a file-like object from the web and store it locally. > url = "http://www.co.rowan.nc.us/enviroservs/downloads.htm"; > f = urllib.urlopen(url) > # connect to the remote > try: > remote = urllib.urlopen(url) > ex

Re: [Tutor] Download file from the web and store it locally.

2006-05-22 Thread Danny Yoo
On Mon, 22 May 2006, MATATA EMMANUEL wrote: > I just made some changes, but I still can't get my file saved on my local > drive: Ok. Up to what part of the program works? Don't just say it doesn't work: can you try isolating what parts are working as expected, and what parts aren't working a

Re: [Tutor] StringIO

2006-05-22 Thread Danny Yoo
> I want to use the module StringIO as read and write strings as files, I > looked into document but cannot understand. Could anyone give me a > simple example? > > something like: > from StringIO import * > fin = StringIO("abc") > . > How can I used fin? 'fin' is a file-like object at this

Re: [Tutor] (no subject)

2006-05-22 Thread Danny Yoo
On Mon, 22 May 2006, [EMAIL PROTECTED] wrote: > I am looking for Matthew White. How can I reach him. Hi Jennifer, We probably can not help you much with this. It would help very much if you could somehow explain why you posted this question here on Tutor. It is not obvious how this is rel

Re: [Tutor] Question on regular expressions

2006-05-24 Thread Danny Yoo
> perl -ple "s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt Hi Andrew, Give me a second. I'm trying to understand the command line switches: (Looking in 'perl --help'...) -p assume loop like -n but print line also, like sed -l[octal] enable line ending proce

Re: [Tutor] Question on regular expressions (fwd)

2006-05-24 Thread Danny Yoo
[forwarding to tutor, although it looks like Andrew's making some good headway from other messages] -- Forwarded message -- Date: Wed, 24 May 2006 14:59:43 -0400 From: Andrew Robert <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Qu

Re: [Tutor] class Writer

2006-05-24 Thread Danny Yoo
On Wed, 24 May 2006, Christopher Spears wrote: > I've been working my way through an online tutorial and came across the > following sample script: > > import sys > > class Writer: >def __init__(self, filename): >self.filename = filename >def write(self, msg): >f = file(

Re: [Tutor] Question on regular expressions

2006-05-25 Thread Danny Yoo
> for line in open(r'e:\pycode\out_test.txt','rb') : >output.write( re.sub(r'([^\w\s])', lambda s: chr(int(s.group(), > 16))) % ord(s.group()), line)) Let's add some whitespace. output.write(re.sub(r'([^\w\s])', lambda s: chr(

Re: [Tutor] a question about symbol

2006-05-28 Thread Danny Yoo
On Sun, 28 May 2006, linda.s wrote: > When I test the following code, > I got something like (use 80 as argument): > 80?F=27?C > Why '?' appear? Hi Linda, Let's compare the output to what we think is producing it. The very last statement in the program looks like the thing we want to watch:

Re: [Tutor] a question about symbol

2006-05-28 Thread Danny Yoo
>> Let's compare the output to what we think is producing it. The very >> last statement in the program looks like the thing we want to watch: >> >> print '%i\260F = %i\260C' % (int(fahrenheit), int(celsius+.5)) >> >> One thing that caught me off guard is the '\260' thing. Can you explain >

Re: [Tutor] Not Really Questions

2006-06-05 Thread Danny Yoo
On Sun, 4 Jun 2006, John Connors wrote: > The first one is lists... I can't for the life of me understand why a > list starts at zero. In everything else in life other than programming > the 1st item in a list is always 1. Edsger Dijkstra wrote a technical note on why zero is a more natural

Re: [Tutor] Offtopic observation

2006-06-07 Thread Danny Yoo
On Wed, 7 Jun 2006, doug shawhan wrote: > This marks the third time this week I have been typing in a question for > the group, and have made the answer apparent just by trying to explain > my question clearly. Yes. *grin* It's a very powerful technique. Writing does this for me as well.

Re: [Tutor] XML: Expletive Deleted

2006-06-09 Thread Danny Yoo
>>> from xml.dom.minidom import parse, parseString > >>> data = response.read() >>> connection.close() >>> response = parseString(data) >>> itemIDs = response.getElementsByTagName("ItemID") >>> response.unlink() ^ Hi Doug, What's going on here? Why unlink()? > Okay, no p

Re: [Tutor] connect to a remote machine - Linux

2006-06-11 Thread Danny Yoo
> I'm sorry. I think I didn't explain myself well. My problem is not with > the database.. The part I'm not sure how to do is connect to the remote > computer.. Hi Patricia, There's some confusion here. Let's get that out in the open. It sounds like you have a remote server. That server pr

Re: [Tutor] assignment statements in python

2006-06-12 Thread Danny Yoo
>> Assignment in Python is not a copy, it is a name binding. Assignment >> creates a name for an object. If you assign the same object to two >> names, they both are bound to the same thing. If the object is mutable, >> like a list, changes to the object will be seen regardless of which >> name

Re: [Tutor] critique my script!

2006-06-20 Thread Danny Yoo
On Tue, 20 Jun 2006, Christopher Spears wrote: > Here is a little gui I created: [gui code cut] Hi Christopher, Looks ok so far. One approach that has a lot of popularity behind it is called the "model-view-controller" approach. The idea is that we should be able to build up the graphical

Re: [Tutor] critique my script!

2006-06-20 Thread Danny Yoo
> doesn't do_nothing(), but does something more interesting, something like: > > # > view = View() > view.on_button_pressed = os.getcwd > # Gaaa. Quick revision: ## def print_cwd():

Re: [Tutor] Regular expressions

2006-06-26 Thread Danny Yoo
On Sun, 25 Jun 2006, ravi sankar wrote: >we are doing an intranet portral search.we had a look at the > tutorials for Regular expressions...we need an insight on how to > implement this.we r in the process of developing a unified search... If you have a question, please ask it directly.

Re: [Tutor] beginner: using optional agument in __init__ breaks my code

2006-06-26 Thread Danny Yoo
>> The values of optional arguments are only once evaluated (when Python >> reads the definition). If you place there mutable objects like e.g. a >> list most of the time the effect you see is not what you want. So you >> have to write it a bit different. >> >> def __init__(self, q = None):

Re: [Tutor] doubt in Regular expressions

2006-06-26 Thread Danny Yoo
> You are confusing me for the OP. Please read carefully next time before > you respond to the wrong person. > > I bumped because the OP's question was not specific and I thought I > talked about people making their requests or questions very specific if > they expect any useful replies. Hi E

Re: [Tutor] How to check a files size

2006-06-29 Thread Danny Yoo
>> Why isn't this function in the os module with the other file commands? > > I don't know why they are broken up in this way. The glob module also > has some file access commands. For the most part, the 'os' module follows the interface functions that C provides to access the operating system.

Re: [Tutor] saving output in a text file

2006-06-30 Thread Danny Yoo
Hi Hafsa, > Can you guide me how to save the output returned by a regular expression > group, into a text file? for instance for the following regular > expression: [regex cut] > If the above regular expression is searched for in a file, how can i > save the output matches from the group "na

Re: [Tutor] saving output in a text file

2006-06-30 Thread Danny Yoo
>def double(s): >"double: string -> string >doubles up the input string s." >return s + s Gaah. Typos. My apologies. Here's a correction to double() def double(s): """double: string -> string Doubles up the input string s. For example, double("

Re: [Tutor] saving output in a text file (fwd)

2006-07-01 Thread Danny Yoo
by a regular expression pattern, into the text file, how would we specify that in the write command. Regards, Hafsa ________ From: Danny Yoo <[EMAIL PROTECTED]> To: Hafsa raza <[EMAIL PROTECTED]> CC: tuto

Re: [Tutor] saving output in a text file (fwd)

2006-07-01 Thread Danny Yoo
> If we want to create a text file and write some text into it we use the > following command in Python: > > myfile = open("test.txt","w") "urn:schemas-microsoft-com:office:office" /> > > myfile.write("hello world") > > But what if instead of writing the text 'hello world', i want to write > the

Re: [Tutor] can't import module

2006-07-02 Thread Danny Yoo
> PYTHONPATH=/home/dave/my_files/my_gg/gg1.4/configs:/home/dave/my_files/my_gg/gg1.4/logs:/home/dave/my_files/my_gg/gg1.4/get_data:/home/dave/my_files/my_gg/gg1.4/gg_utils:/home/dave/my_files/my_gg/gg1.4/ipc:/home/dave/my_files/my_gg/gg1.4/process_data:/home/dave/my_files/my_gg/gg1.4/common_utils:/

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Danny Yoo
> I tried it by opening a file , but could find no way to do variable > variables Hi Brian, Look for the concept of dictionaries in Python. "Variable variables" in languages like PHP and Perl are doable in Python, but a dictionary usually handles such situations in a safer way. > and then

Re: [Tutor] I Give Up. - Follow up post

2006-07-04 Thread Danny Yoo
> Now, if I want to iterate over a list of machines , and check each > machine for whatever it was set for (in the config file) > So the config file requires http to be the first part of the string , > followed by something to make it unique (I.E. http1, http2, http3) Hi Brian, Have you consi

Re: [Tutor] Functional Programming

2006-07-06 Thread Danny Yoo
On Thu, 6 Jul 2006, Steve Nelson wrote: > I've just today starting thinking more about programming in a more > functional style, and came across the following article which I thought > was really good: > > http://www.amk.ca/python/writing/functional Hi Steve, The references on the bottom are

Re: [Tutor] activestate

2006-07-08 Thread Danny Yoo
On Thu, 6 Jul 2006, kevin parks wrote: > The same thing is happening again. The archive: > > http://aspn.activestate.com/ASPN/Mail/Browse/Threaded/python-Tutor > > seems stalled out at April 20th Hi Kevin, Sorry for the late response. I'm not as active on Python-tutor as I've been in the pas

Re: [Tutor] printing 00

2006-07-10 Thread Danny Yoo
> I created a function to print the Time object: > > def printTime(time): > print "%d:%d:%d" % (time.hours, time.minutes, > time.seconds) > > However, when I type '00', I get the following: time = Time(12,34.4,00) printTime(time) > 12:34:0 Hi Chris, You'll want to check some of th

Re: [Tutor] How can I copy files recursively?

2006-07-10 Thread Danny Yoo
> directory structure. Something like: > > source = '/ipodder' > dest = '/foo/bar' > for root, dirs, files in os.walk(source): >for f in files: >os.rename(os.path.join(root, f), os.path.join(dest, f)) A helper function here will be useful. We can simulate something like: find .

Re: [Tutor] Need Help

2006-07-11 Thread Danny Yoo
> By posting the entire homework problem, John Shappell did give the > impression that he wanted us to do the problem for him, but as John > Montgomery notes he is just looking for a hint in an area where he is > stuck. That is fine for the tutor list. Since we know it is homework we > can use

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Danny Yoo
> In fact I want to create a list of variables from the list of strings > > Example: ['var1', 'var2', 'var3'] - list of strings Ok, let's stop for the moment. Do you know about "dictionaries" yet? If not, we should point this out to you, because they solve the problem you describe.

Re: [Tutor] How do you implement a config file?

2006-07-15 Thread Danny Yoo
> I am writing a small python application that needs a few variables to be > end user configurable. Right now I just have the variables right up > front where the user can tweak them in the program code and a big > commented line that says "Nothing editable past this point." But I would > lik

Re: [Tutor] create 1000 000 variables

2006-07-16 Thread Danny Yoo
>> > In fact I want to create a list of variables from the list of strings >> > >> > Example: ['var1', 'var2', 'var3'] - list of strings >> >> Do you know about "dictionaries" yet? > Yes. I know about dictionaries. Hello, Can you show us an example of the kind of dictionary usage you've us

Re: [Tutor] about copy.copy

2006-07-18 Thread Danny Yoo
On Tue, 18 Jul 2006, linda.s wrote: > But in the following example, a/b/c change and it looks like there is > no difference. a=[[1,2,3], [4,5,6]] b=a c=copy.copy(a) Hi Linda, I find it easiest to explain this by going to box-and-pointer diagrams. Let me see if this will help y

Re: [Tutor] General programming question

2006-07-18 Thread Danny Yoo
On Tue, 18 Jul 2006, Christopher Arndt wrote: >> I have a general question about programming. My program that I have >> been writing is fully modularized. My question is: Is there a >> programming technique that would alleviate the passing of a huge number >> of variables. One of the things

Re: [Tutor] General programming question

2006-07-18 Thread Danny Yoo
> For example, let's say we have a program that deals with drawing shapes > like circles. One way we could imagine doing this is to represent a > circle as an x/y coordinate, a radius, and a color. In this situation, > things that work on circles will take in at least those three arguments:

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