Re: [Tutor] 2 questions......novice but not beginner

2005-09-27 Thread Danny Yoo
On Mon, 26 Sep 2005, Mike Pippin wrote: > I need to know how to allow the user to search their local drives and > directories in order to load a file...or if there are any pre-written > opensource functions that will also be well appreciated.. Second Hi Mike, This is not completely obvious

Re: [Tutor] Quick way to find the data type

2005-09-27 Thread Danny Yoo
> A quick way, yes. But also secure? No. > > >>> l = ['false', 'True', '3', '1.394'] > >>> l = [eval(x) for x in l] > >>> print l > [False, True, 3, 1.3939] > > but this fails when it encounters a string that eval can't handle, for > example 'false'. Also eval will evaluate any valid

Re: [Tutor] Quick way to find the data type

2005-09-27 Thread Danny Yoo
On Tue, 27 Sep 2005, Bernard Lebel wrote: > Well I understand all the security issues but unless I'm missing > something, I don't see anything wrong here. Hi Bernard, The other major problem with it, besides security, is that it can introduce certain error messages that will look inscrutable

Re: [Tutor] Quick way to find the data type

2005-09-27 Thread Danny Yoo
> >Let say I have a string. The value of the string might be 'False', > >'True', '3', '1.394', or whatever else. Is there a quick way to convert > >this string into the appropriate data type other than with try/except? > > eval()? Gaaa, don't say that word! *grin* (Sorry, I know I'm sounding l

Re: [Tutor] Prevent "Coder's Remorse"?

2005-09-28 Thread Danny Yoo
On Wed, 28 Sep 2005, Ron Phillips wrote: > Maybe it's just me. I am always haunted by "coder's remorse" (the > certainty that there's a more compact, beautiful, fun, maintainable way > to code anything I finish.) > > At any rate, I am currently working on a script to model an ordered > collecti

Re: [Tutor] call a def/class by reference

2005-09-28 Thread Danny Yoo
> Thanks for answering my question. What I'm hoping to avoid is an > explicit reference to any of the called functions within the program. > By doing it that way, it would avoid a maintenance problem of having to > remember to put a reference for every new function in the calling > program. In

Re: [Tutor] help with running graphics program

2005-09-28 Thread Danny Yoo
On Wed, 28 Sep 2005 [EMAIL PROTECTED] wrote: > I downloaded the graphics.py file and have it saved on my computer but > everytime I run the following program I seem to keep getting an error. [some text cut] > Traceback (most recent call last): > File "C:/Python24/circle", line 1, in -topleve

Re: [Tutor] Alan's responce frustrated beginner

2005-09-28 Thread Danny Yoo
On Wed, 28 Sep 2005, Rosalee Dubberly wrote: > I want to save this file, import it and make the changes, eggs = toast, spam > = jelly and change the values if needed. > > def firstpart(): >for n in range(0, 55): > if n % 3 == 0 or n % 7 == 0 or n % 11 == 0: > print 'eggs,', >

Re: [Tutor] drawing squares

2005-09-28 Thread Danny Yoo
On Wed, 28 Sep 2005 [EMAIL PROTECTED] wrote: > How would I get the following program to draw squares instead of circles? What have you tried so far? What part of your program is the part responsible for drawing circles? What happens if you change that part? To tell the blunt truth, the ques

Re: [Tutor] call a def/class by reference (fwd)

2005-09-28 Thread Danny Yoo
-- Forwarded message -- Date: Wed, 28 Sep 2005 17:11:07 -0700 From: DS <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] call a def/class by reference Danny Yoo wrote: > > >>Thanks for answering my question. What I'm hop

Re: [Tutor] drawing squares

2005-09-28 Thread Danny Yoo
> Otherwise, it really looks like you don't care about anything other than > getting a "right answer", and nothing demotivates a volunteer more than > being asked to do someone else's homework. We're interested in helping > people understand how to solve problems, but we're really not interested

Re: [Tutor] Flattening multi-dimentional list

2005-09-28 Thread Danny Yoo
On Wed, 28 Sep 2005, Bernard Lebel wrote: > I have this list wich is made of tuples. I wish I could "flatten" this > list, that is, to extract each element in the tuples and build a new > flat list with it. Is there any shortcut to do that or do I have to go > through some list comprehension-lik

Re: [Tutor] call a def/class by reference

2005-09-29 Thread Danny Yoo
> >From what I've read so far, globals are actively discouraged. A class > seems like the best approach. > > I'm actually pretty surprised that there isn't a built-in facility with > Python for referencing functions like this. In reading Python in a > Nutshell, prior to asking my questions here,

Re: [Tutor] call a def/class by reference

2005-09-29 Thread Danny Yoo
> Thanks so much to all of you that have answered my questions, including > Liam.Clarke-Hutchinson, whom I didn't acknowledge directly with an > email. I hope I'm not asking too many questions. Hi ds, You're doing perfectly fine. *grin* We got to see a lot of different approaches to that class

Re: [Tutor] Alan's responce frustrated beginner (fwd)

2005-09-30 Thread Danny Yoo
[Rosalee] >>> I want to save this file, import it and make the changes, eggs = >>> toast, . spam = jelly and change the values if needed. [Danny] >> It sounds like you're still stuck trying to input programs into Python. >> Are you using a "programming text editor"? If not, then you may want >>

Re: [Tutor] pywin32 under Win64

2005-10-02 Thread Danny Yoo
On Sun, 2 Oct 2005, Bernard Lebel wrote: > I'm considering switching to Windows 64bit. However I was wondering if > anyone on this list have been using the pywin32 extension (or any > win32com-related package/distribution for that matter) on Win64. > Possibly the pywin*32* thing is making me cau

Re: [Tutor] icq library

2005-10-03 Thread Danny Yoo
On Mon, 3 Oct 2005 [EMAIL PROTECTED] wrote: > > Is there an library to communicate with an ICQ-server including the most > important features line sending and receiving messages? > > I have already searched with google but i am not really able to find > exactrly that what i'm looking for. The T

Re: [Tutor] Mod_python greedy url matching

2005-10-05 Thread Danny Yoo
On Wed, 5 Oct 2005, Jay Loden wrote: > I'm having trouble with Apache and Mod_python - mod_python is set to use > /var/www/html and pass all *.htm files on to the handler I wrote. > Unfortunately, mod_python does a greedy match, so > /var/www/html/subdirectory/file.htm still gets passed to the h

Re: [Tutor] Line continuation with readlines

2005-10-05 Thread Danny Yoo
On Mon, 3 Oct 2005, Craig MacFarlane wrote: > Is there a way to make line continuation work with > the readlines function? > > i.e. > > this is \ > one line. Hi Craig, readline() doesn't look at the content of lines, so no, not out of the box. However, would it be satisfactory if you wr

Re: [Tutor] still not getting 'it'

2005-10-06 Thread Danny Yoo
On Wed, 5 Oct 2005, Rosalee Dubberly wrote: > I am having problems with changing the parameters in my second function. > I want the second function to run the same as the first, but take > different parameters. What am I doing wrong Hi Rosalee, [First, make sure you're subscribed to Tutor;

Re: [Tutor] class and methods/functions

2005-10-06 Thread Danny Yoo
Hi Eric, Quick comment on the last part of your program: > try: > getProjectNames() > except: > print "Got an Error" Don't do that. *grin* This is considered a misuse of exceptions. As a concrete example, say that we have a buggy program like this: ## >>> def showDivisions(n):

Re: [Tutor] still not getting 'it' (fwd)

2005-10-06 Thread Danny Yoo
Hi Rosalee, [Keeping tutor in the conversation. Please make sure you're using the "Reply-to-All" feature of your email client.] I'll respond to the message once it reaches the mailing list. -- Forwarded message -- Date: Thu, 06 Oct 2005 11:49:44 -0700 From: Rosalee Dubberly <[E

Re: [Tutor] still not getting 'it' (fwd)

2005-10-06 Thread Danny Yoo
> No the question doesn't seem to simple at all, I appreciate your help. I > have totally confused myself and I need to start from the beginning to > sort things out. Thanks for you time and help. > > >>>double = 2 * 5 > >>>print 'The sum of 2 times 5 equals', double > The sum of 2 times 5 equals

Re: [Tutor] Matching dictionary entries by partial key

2005-10-06 Thread Danny Yoo
On Thu, 6 Oct 2005, William O'Higgins Witteman wrote: > I'm trying to traverse a dictionary looking for partial matches of the > key, and I'm not sure how. Here's a sample dictionary: > > dict = {1234 : value1, 20051234 : value2, 20071234 : value3} > > Here's what I'm trying to do: > > for

Re: [Tutor] Simple Tkinter question

2005-10-06 Thread Danny Yoo
On Thu, 6 Oct 2005, Mike Cheponis wrote: > I'm trying to update an Entry's textvariable several times within my > Button handler, like so: > > from Tkinter import * > from time import * > > def my_update(): >for i in range(3): > tv.set("Now it's %d"%i) > sleep(1) > > root=Tk() > tv

Re: [Tutor] Simple Tkinter question (fwd)

2005-10-06 Thread Danny Yoo
-- Forwarded message -- Date: Thu, 6 Oct 2005 22:07:50 -0700 (PDT) From: Mike Cheponis <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Simple Tkinter question On Thu, 6 Oct 2005, Danny Yoo wrote: >> from Tkinter import * &

Re: [Tutor] Simple Tkinter question (fwd)

2005-10-07 Thread Danny Yoo
-- Forwarded message -- Date: Thu, 6 Oct 2005 23:55:26 -0700 (PDT) From: Mike Cheponis <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Simple Tkinter question Danny, I got it: from Tkinter import * from time import * def my_update():

Re: [Tutor] Tutor Digest, Vol 20, Issue 22

2005-10-07 Thread Danny Yoo
On Thu, 6 Oct 2005, sanjay sinha wrote: > Is there any work done in language convirsion from endlish to hindi and > vice versa Hi Sanjay, Machine Translation (MT) is Hard. I believe you're asking for some kind of automatic language translator, and I'm sure there is work being done, but it's

Re: [Tutor] Simple Tkinter question (fwd)

2005-10-07 Thread Danny Yoo
> Danny, I got it: > > from Tkinter import * > from time import * > > def my_update(): >for i in range(3): > tv.set("Now it's %d"%i) > root.update() > sleep(1) > > root=Tk() > tv=StringVar() > Entry(textvariable=tv).pack() > tv.set("Initial Value of StringVar") > Button(text="Upd

Re: [Tutor] Simple Tkinter question (fwd)

2005-10-07 Thread Danny Yoo
[Keeping Tutor in CC] -- Forwarded message -- Date: Fri, 7 Oct 2005 01:25:26 -0700 (PDT) From: Mike Cheponis <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] Simple Tkinter question (fwd) On Fri, 7 Oct 2005, Danny Yoo wrote: > Ok,

Re: [Tutor] pylibpcap

2005-10-07 Thread Danny Yoo
On Fri, 7 Oct 2005, Servando Garcia wrote: > I need to use pylibpcap. I am looking for any documentation at > all, tutorial would be nice. Hi Servando, Have you looked at the python-libpcap forum? That's probably be a better place to ask questions on pylibpcap: http://sourceforge.n

Re: [Tutor] Is it Posible? To Crack And HowTo

2005-10-07 Thread Danny Yoo
On Fri, 7 Oct 2005, Suranga Sarukkali wrote: > I've heard that Python is good for hacking and when I ask how to here on > python tutor mailing list answers were all about reading some article > I've already read before, [text cut] Here, read a little more. ESR has written an article on the ki

Re: [Tutor] Is it Posible? To Crack And HowTo

2005-10-07 Thread Danny Yoo
> > I've heard that Python is good for hacking and when I ask how to here > > on python tutor mailing list answers were all about reading some > > article I've already read before, Hi Suranga, I thought I already read this before too. http://mail.python.org/pipermail/tutor/2005-July/040002

Re: [Tutor] code improvement for beginner ?

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, lmac wrote: > i wonder if i could post some of my scripts and anyone can tell me if > there is a better way for coding the problem. In the way of some > teaching class. ;-) Sure, that's perfectly fine. If the script is very large, you may want to post it on the web and sen

Re: [Tutor] is there any Python code for spatial tessellation?

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, Shi Mu wrote: > is there any Python code for spatial tessellation? Are you looking for code to generate voronoi diagrams? http://en.wikipedia.org/wiki/Voronoi_diagram >From initial Google searches, it appears that there is a package called Qhull that pepole use to do V

Re: [Tutor] handling of tabular data

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, [ISO-8859-1] Frank Hoffs�mmer wrote: > I often find myself writing python programs to compute averages, min, > max, top10 etc of columns in a table of data In these programs, I always > capture each row of the table in a tuple the table is then represented > by a list of tupl

Re: [Tutor] code improvement for beginner ?

2005-10-08 Thread Danny Yoo
On Sat, 8 Oct 2005, lmac wrote: > Ok. Here we go. Wanted to start my page long ago. Now is the right time. > > http://daderoid.freewebspace24.de/python/python1.html Hi lmac, I'll pick out some stuff that I see; I'm sure others will be happy to give comments too. I'll try to make sure that all

Re: [Tutor] is there any Python code for spatial tessellation?

2005-10-10 Thread Danny Yoo
On Sun, 9 Oct 2005, Shi Mu wrote: > There are four points with coordinates: > 2,3;4,9;1,6;3,10. > How to use Python to draw one perpendicular bisector between (2,3) and (4,9); > the other perpendicular bisector between (1,6)$BOB(B(3,10); > then, makes the output like: > l1 a b c > l2 a b c > (

Re: [Tutor] handling of tabular data

2005-10-10 Thread Danny Yoo
On Sun, 9 Oct 2005, [ISO-8859-1] Frank Hoffs�mmer wrote: > thanks for your answers looks like SQL is the ticket for such > problems... because my data is updated quite often, it feels like an > overhead for me to store the data persistently, because then I would > have to manage updates to indiv

[Tutor] Undocumented 't' mode flag for open() [Was: Re: code improvement for beginner ?]

2005-10-10 Thread Danny Yoo
On Sun, 9 Oct 2005, Roel Schroeven wrote: > Danny Yoo wrote: > > Looking at pageimgs(): I'm not sure what 't' means in the open statement: > > > > f = open(filename, "rt") > > > > and I think that 't' might be a typo: I&#x

Re: [Tutor] Regex help

2005-10-10 Thread Danny Yoo
On Mon, 10 Oct 2005, Bill Burns wrote: > I'm looking to get the size (width, length) of a PDF file. Hi Bill, Just as a side note: you may want to look into using the 'pdfinfo' utility that comes as part of the xpdf package: http://www.foolabs.com/xpdf/ For example:

Re: [Tutor] Please look at my wordFrequency.py

2005-10-10 Thread Danny Yoo
> 3) No modularization. Couldn't see a reason to do so. Is there one or > two? Specifically, what sections should become modules, if any? Hi Dick, My recommendation is to practice using and writing functions. For example, this block here is a good candidate to box off as a named function: ###

Re: [Tutor] code improvement for beginner ?

2005-10-10 Thread Danny Yoo
> > The point of this restructuring is to allow you to add more image > > types without too much pain, since there's no more hardcoded array > > indexing against r1. It also simplifies to calls to imgreg from: > > > > if imgreg(r1[0],a) == 1: > > continue > > if imgreg(r1[1],a) =

Re: [Tutor] code improvement for beginner ? (fwd)

2005-10-11 Thread Danny Yoo
-- Forwarded message -- Date: Tue, 11 Oct 2005 20:55:24 +0200 From: lmac <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re:code improvement for beginner ? Danny Yoo wrote: > >>>The point of this restructuring is to allow you to add more im

Re: [Tutor] Struct headspinner

2005-10-12 Thread Danny Yoo
On Wed, 12 Oct 2005, Liam Clarke wrote: > Erm, can someone please aid me? I'm using Windows XP, haven't tested > this code on Linux yet, but, well watch this... > > '<' indicates little-endian, @ indicates native. i is an integer, q is a long. > > >>> struct.calcsize('<3i') > 12 > >>> struct.cal

Re: [Tutor] help with elif statements

2005-10-12 Thread Danny Yoo
On Wed, 12 Oct 2005 [EMAIL PROTECTED] wrote: > below is my code and everytime I input a value of 16 or more it keeps > returning sophomore. could anyone help me figure out what to change so > that it won't return sophmore for things greater than or equal to 16? If we have the following: ### Ps

Re: [Tutor] if-elif-else statements

2005-10-13 Thread Danny Yoo
On Thu, 13 Oct 2005 [EMAIL PROTECTED] wrote: > amount is supposed to equal fine because there are a couple of different > fines. there is a fine for going over 90mph that includes a penalty and > then there is a fine for just going over the speed limit as long as it > is under 90. Hi Andradel,

Re: [Tutor] First post

2005-10-14 Thread Danny Yoo
On Fri, 14 Oct 2005, Anthoni Shogan wrote: > this is my first post as a test.. Hi Anthoni, Ok, we see you. In general, it's usually not a good idea to write test messages on these kinds of mailing lists: it adds to the "noise" in the channel. Anyway, do you have a question about learning Pyt

Re: [Tutor] if-else statements

2005-10-14 Thread Danny Yoo
> I'm having some trouble with my if, else statements. Ok, let's pause for a moment: it seems like you're having problems with more fundamental problems than just simple if/else statements. In the past questions you've written: http://mail.python.org/pipermail/tutor/2005-October/041863.htm

Re: [Tutor] if-else statements

2005-10-14 Thread Danny Yoo
> > For some reason, the months that have 31 days work fine, but the > > months that have 28/30 do not work. > > How do you know that? > > Show us why you think there's a problem in the program. We have our own > opinions, of course, but it'll be very helpful if you try explaining how > you're th

Re: [Tutor] dictionaries in classes

2005-10-14 Thread Danny Yoo
On Fri, 14 Oct 2005, Luke Jordan wrote: > I'm trying to have functions to create, edit and store dictionaries > within a class. Here's a small example of a class: ## class Person: def __init__(self, name): self.name = name ## Let's try pickling an instance of it: #

Re: [Tutor] extract plain english words from html

2005-10-14 Thread Danny Yoo
On Fri, 14 Oct 2005, Marc Buehler wrote: > i have a ton of html files from which i want to extract the plain > english words, and then write those words into a single text file. Hi Marc, The BeautifulSoup parser should be able to do what you want: http://www.crummy.com/software/Beautiful

Re: [Tutor] if-else statements

2005-10-15 Thread Danny Yoo
On Sat, 15 Oct 2005, Andrew P wrote: > Well, on the bright side, at least Python is being taught in schools. [Warning: I get totally off-topic, opinionated, and cranky in the following rant. My apologies in advance!] Hi Andrew, But I get worried, though, that much teaching uses fragile techn

[Tutor] Focus on the functions [Was Re: if-else statements]

2005-10-15 Thread Danny Yoo
On Sat, 15 Oct 2005, Kent Johnson wrote: > > I really wish that someone would take a similar approach in writing a > > beginner Python tutorial that focuses on functions almost immediately, > > even before control flow. > > You might like John Zelle's book - he teaches functions before control >

Re: [Tutor] Focus on the functions [Was Re: if-else statements]

2005-10-16 Thread Danny Yoo
> Having studied the examples given here, I am beginning to get some > understanding of what is going on. If only I could find many more > examples like these, in simple English, I would be a very happy student. [Note: this is a fairly long post. Didn't know how to do the subject justice withou

Re: [Tutor] IDLE will not appear under Win95 (Python 2.4.2)

2005-10-16 Thread Danny Yoo
On Sat, 15 Oct 2005, Dave Shea wrote: > Python installed without a complaint. However, when I fire up IDLE, > there is an hour glass shown for a couple of seconds, then nothing else > happens. When I fire up Python (command line) no problem, the DOS box > opens and Python starts. I've tried re-s

Re: [Tutor] IDLE will not appear under Win95 (Python 2.4.2) (fwd)

2005-10-17 Thread Danny Yoo
[Keeping tutor in CC] -- Forwarded message -- Date: Mon, 17 Oct 2005 22:03:22 +1300 From: Dave Shea <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] IDLE will not appear under Win95 (Python 2.4.2) Hi Danny, Thanks for your note. I tried y

Re: [Tutor] string.split() into a list

2005-10-18 Thread Danny Yoo
On Tue, 18 Oct 2005, Kent Johnson wrote: > >l = [] > >a, l = string.split('|') > > How about > >>> s='1|2|3|4' > >>> l=s.split('|') > >>> a, l = l[0], l[1:] > >>> a > '1' > >>> l > ['2', '3', '4'] > ? Hi Randy, I think you're expecting Perl behavior. The Perl idiom for partiall

Re: [Tutor] define vars by iteration

2005-10-19 Thread Danny Yoo
On Wed, 19 Oct 2005, Luke Jordan wrote: > I've got a bunch of pickled class instances with > self.nameattributes, and I would like to assign the > instances themselves to variables > named whatever is stored in self.name using a function. > "Can't assign to

Re: [Tutor] iteration is overwriting the previous set value

2005-10-19 Thread Danny Yoo
On Thu, 20 Oct 2005, Jonas Melian wrote: > def _pre_save(self): > for field in [self.name, self.native_name]: > if not field.istitle(): > #print field.title() > field = field.title() > > The change I try to do there (field = field.title()) is not being > applie

Re: [Tutor] file opening and errors.

2005-10-20 Thread Danny Yoo
> open(FILE, $file) or die "Error: $!\n"; > > The $! is a perl variable that holds an error should the open fail, > example being : "No such file or directory". > > With python I have use a try except block but I have no idea how I would > get the same warning from python as I would from perl (th

Re: [Tutor] define vars by iteration

2005-10-20 Thread Danny Yoo
> Also, I have done what I'm trying to do successfully by populating a > dictionary with class instances named after self.name , > which, after the function runs, I can access this way > >>> classDictionary["Yard"] > > the thing is I would like to be able to get at Yard's at

Re: [Tutor] file.read..... Abort Problem

2005-10-20 Thread Danny Yoo
On Thu, 20 Oct 2005, Tomas Markus wrote: > I am trying to read a file with some 2500 lines and to do a scan for "not > allowed" characters in there (such as accented ones and so on). The problem > is that the file I am testing with has got one of those somewhere on line > 2100 (the hex value of

Re: [Tutor] file.read..... Abort Problem

2005-10-20 Thread Danny Yoo
> I was going to ask why you think regex is a sledgehammer for this one, Regex's are more complex because we have to then make sure that none of the testchars have any special meaning as regular expression metacharacters. If one of those test chars, for example, contained things like '-' or '\\',

Re: [Tutor] PYBSDDB help

2005-10-20 Thread Danny Yoo
Hi Toren, Ok, I see that you've asked your question on the pybsddb mailing list as well a few weeks ago, which is fine. http://lists.sourceforge.net/lists/listinfo/pybsddb-users Unfortunately, it looks like spammers have attacked that mailing list badly enough that it appears they've done s

Re: [Tutor] file.read..... Abort Problem (fwd)

2005-10-20 Thread Danny Yoo
[Keeping tutor in CC] -- Forwarded message -- Date: Thu, 20 Oct 2005 23:21:13 +0200 From: Tomas Markus <[EMAIL PROTECTED]> To: Danny Yoo <[EMAIL PROTECTED]> Subject: Re: [Tutor] file.read. Abort Problem Hi All, Just to let you know my ressults (+ one tiny questio

Re: [Tutor] perldoc - confused!

2005-10-21 Thread Danny Yoo
> I spent ages today trying to list all items in a directory, simple I now > know (os.listdir) but I was trying to use os.walk simply because I had > no idea that listdir existed. I only found listdir because I was > reading about walk You should have a 'pydoc' utility. It's also possible t

Re: [Tutor] Boolean math question

2005-10-22 Thread Danny Yoo
> > Anyone know of a good explanation of either how to perform boolean > > math in Python? What I am trying to do is AND two numbers together: > > > > e = 51 AND 15 > > > > 00110011 > > > > > > 0011 > > Use '&' rather than "AND": > > >>> e = 51 & 15 > >>> e > 3 For refe

Re: [Tutor] threading issues

2005-10-23 Thread Danny Yoo
On Sun, 23 Oct 2005, Chris Hallman wrote: > I made a mistake in my first email. I meant that I can't get fc to write > to the file. Here is the error: > > Traceback (most recent call last): > File "thread_test_ping.py", line 37, in ? > output.write(fc + " failures found.\n") > TypeError: uns

Re: [Tutor] Creating Programs (Basics?)

2005-10-23 Thread Danny Yoo
> > end of the chapter on "Error Handling" and I'm trying the sample ideas > > for creating my own programs. My problem is getting started! Is there > > a "step by step" method for creating programs or some basic guidelines > > for this? > > There are some books around on how to design programs wh

Re: [Tutor] what does %25f mean?

2005-10-24 Thread Danny Yoo
On Mon, 24 Oct 2005, Shi Mu wrote: > what does %25f mean? Hi Shi Mu, Without more context, I'd have to guess that this looks like a format string. Here's more information about them: http://www.python.org/doc/lib/typesseq-strings.html But can you show us where you saw this "%25f" thing

Re: [Tutor] dictionary

2005-10-24 Thread Danny Yoo
> > I typed: > > landUse = {'res': 1, 'com': 2, 'ind': 3, "other" :[4,5,6,7]} > > and when i checked landUse, I found it become: > > {'ind': 3, 'res': 1, 'other': [4, 5, 6, 7], 'com': 2} > > why the order is changed? > > the docs warn you about this. Hi Shi, By the way, here's a post from a lon

Re: [Tutor] problem with class overloading (maybe it's just me)

2005-10-24 Thread Danny Yoo
> this one fails: > [EMAIL PROTECTED]:~/wxpy$ cat helloWorld.py > > #!/usr/bin/python Hi Matt, Ah, good for showing that cat command: it gave enough hints that we can tell what's going on. Take out the leading empty space in your file; it's interfering with the magic line '#!/usr/bin/python'.

Re: [Tutor] python myspace module?

2005-10-25 Thread Danny Yoo
On Tue, 25 Oct 2005, Ed Hotchkiss wrote: > looking to write a myspace wrapper/module. what is the best way > (hopefully using the stdlib not an outside module) to connect to a > website and (if possible, otherwise ill have to code it?) access forms > with GET POST blah blah blah ... Hi Ed, We

Re: [Tutor] new user question about while loops

2005-10-26 Thread Danny Yoo
On Tue, 25 Oct 2005, Nick Eberle wrote: > My goal, create a program that flips a coin 100 times, at the end it > says the number of times it flipped heads and flipped tails. Hi Nick, Do you might if we simplify the problem slightly? Say that you're only flipping the coin two times. Can you

Re: [Tutor] new user question about while loops

2005-10-26 Thread Danny Yoo
> > My goal, create a program that flips a coin 100 times, at the end it > > says the number of times it flipped heads and flipped tails. > > Do you might if we simplify the problem slightly? Say that you're only > flipping the coin two times. Can you write code to say how many times > it flip

Re: [Tutor] new user question about while loops

2005-10-27 Thread Danny Yoo
> #assigning variables to track the amount of times heads or tails comes up > heads=0 > tails=1 > > AG> Why not make both zero, after all there have been no flips so far! Hi Alan, There is confusion here about the role of these variables. Despite what the comment says, I assume that 'heads' and

Re: [Tutor] File IO Help again

2005-10-27 Thread Danny Yoo
On Thu, 27 Oct 2005, Mike Haft wrote: > why can I not get the readline() or readlines() functions to work, I'm > told they are not defined whenever I try. Don't paraphrase. *grin* Show us what you did in terms of the code that you ran. Also, include the literal error message and its tracebac

Re: [Tutor] IDLE error msgs and line continuations?

2005-10-29 Thread Danny Yoo
On Thu, 27 Oct 2005, CPIM Ronin wrote: > When using IDLE, after hitting F5 to save and run, if an error occurs, > it merely flashes at the code location of the error. While I usually > figure out what is wrong, why don't I get the detailed text error > messages that the command line gives? > > A

[Tutor] Birthday paradox (was: Re: Random number generator (was: Can anyone help me?))

2005-10-29 Thread Danny Yoo
On Fri, 28 Oct 2005, Johan Geldenhuys wrote: > After I tested the previous code, I noticed that the odds is 1:49 that a > duplicate number can be found in the 6 digit range (and it happended) > and that 0 can also be found. Hi Johan, I'm not exactly sure how 1 in 49 are the odds of getting a d

Re: [Tutor] Birthday paradox (was: Re: Random number generator (was: Can anyone help me?))

2005-10-29 Thread Danny Yoo
> ## > >>> count_duplicates = 0 > >>> for i in range(10): > ... if has_duplication(make_roll(50, 6)): > ... count_duplicates = count_duplicates + 1 > ... > >>> count_duplicates > 1 > >>> 1.0 / 10 > 0.10001 > ## > > > Experimentally, we're seeing 1%, but that might j

Re: [Tutor] Code Readability (was: Recursion and List Comprehensions)

2005-10-29 Thread Danny Yoo
> > I agree. When writing for keeps (i.e. production code) I prefer > > clarity and ease of maintenance over 'elegance' or 'trickiness'. > > This exercise is intended, in part, to sharpen my understanding of > > Python idioms. If I can write highly idiomatic code that works, > > chances are bett

Re: [Tutor] help with prime number program

2005-10-30 Thread Danny Yoo
> I am trying to write a program that will figure out if a number is prime > or not. Currently this is the code that I have: [code cut] Hi Andrade1, As in your other previous homework programs, you seem to have some trouble with control flow. Have you considered talking with your professor or

Re: [Tutor] help with prime number program

2005-10-31 Thread Danny Yoo
On Mon, 31 Oct 2005, Kent Johnson wrote: > Norman Silverstone wrote: > > I am a beginner so, I hope what I give, makes sense. In it's simplest > > form what is wrong with :- > > > > n = input("Enter a number") > > if n % 2 != 0 and n % 3 != 0: > >print n, " Is a prime number" > > > This only

Re: [Tutor] Turning kwargs into scalars

2005-10-31 Thread Danny Yoo
On Mon, 31 Oct 2005, Steve Bergman wrote: > Say I have a function: > > def f(self, **kwargs) : > > and I want to take the key/value pairs and create a set of variables > with the names of the keys. > > For example, if I say: > > f(x=5, y=2) > > I want to create local variables 'x' and 'y' in the

Re: [Tutor] Random Q on Python's internals?

2005-10-31 Thread Danny Yoo
> I was perusing the standard library, and was wondering if anyone knew > how the internals of Python work, roughly or no. > > Basically, I assume os.pipe() resides in a DLL somewhere, yet when I > open up Python24.DLL in PEexplorer I can't find mention of pipes > anywhere... Hi Liam, os.pipe(

Re: [Tutor] Style/Conceptual Help

2005-11-02 Thread Danny Yoo
On Wed, 2 Nov 2005 [EMAIL PROTECTED] wrote: > I would be interested in some input/suggestions on the pythonicness of > the way I did things and on style, or anything else you see that I can > improve. Hi ebgreen, The only big thing I'd point out is that the buttonClick() method of the applicat

Re: [Tutor] Style/Conceptual Help

2005-11-02 Thread Danny Yoo
On Wed, 2 Nov 2005, Rob Dowell wrote: > Oh, and about the email addresses, ebgreen is an account I use when > doing email via a web interface (i.e. I'm not at home) and this is my > home address. [meta: list administration] Hi Rob, No problem. What you can do, if you want to avoid the modera

Re: [Tutor] avoid eval how???

2005-11-03 Thread Danny Yoo
On Thu, 3 Nov 2005, Pujo Aji wrote: > I have a dynamic functions which created by some algorithms during > runtime. These functions are in string type. When I want to use it, I > can use eval command. But can someone give me more suggestion about how > to handle this problem, I want to avoid eval

Re: [Tutor] avoid eval how???

2005-11-03 Thread Danny Yoo
> > I have a dynamic functions which created by some algorithms during > > runtime. These functions are in string type. When I want to use it, I > > can use eval command. But can someone give me more suggestion about > > how to handle this problem, I want to avoid eval. > > Why avoid? It seems th

Re: [Tutor] avoid eval how???

2005-11-03 Thread Danny Yoo
> You make some good points here but I suggest that, in the real world, > the risks are small. Hi Colin, But that's the point I'm trying to make; eval() is appropriate only for toy code. In real world code that's exposed to the world, using eval() is usually the wrong thing to do, because it re

Re: [Tutor] Sorting a dictionary

2005-11-04 Thread Danny Yoo
On Fri, 4 Nov 2005, Johan Geldenhuys wrote: > In my new project I needed a dictionary with TCP/UDP port numbers as > keys and the service for that key as the value. I got the info from the > services file in Linux and compiled a dictionary as I needed. > > The only thing that I want to do is to

Re: [Tutor] Sorting a dictionary

2005-11-04 Thread Danny Yoo
> ser_port = {'4401': 'ds-srvr', \ > '5427': 'sco-peer-tta', \ > '4446': 'n1-fwp', \ > '3734': 'synel-data', \ > '4447': 'n1-rmgmt', \ > '5745': 'fcopy-server', \ > '5990': 'wbem-exp-https', \ > '4026': 'as-debug', \ > '3724': 'battlenet'} Hi Johan, Just as a quick side note: all those

Re: [Tutor] construct

2005-11-04 Thread Danny Yoo
On Fri, 4 Nov 2005, Eric Walker wrote: > Whats the construct that allows to loop through a list and perform an > action? you also can add a test at the end. something like myfile = > [print name for name in yourlist, if ...] I need to look up how to use > the test command and I forgot the name

Re: [Tutor] Converting a String to a Tuple

2005-11-04 Thread Danny Yoo
On Fri, 4 Nov 2005, Carroll, Barry wrote: > My UDP client is receiving responses from the server, and now I need to > process them. A typical response string looks like this: > > "(0, ''),some data from the test system" > > The tuple represents the error code and message. If the command ha

Re: [Tutor] main

2005-11-05 Thread Danny Yoo
On Sat, 5 Nov 2005, Shi Mu wrote: > It is very hard for me to understand why we need the following line? if > __name__ == "__main__": Hi Shi Mu, It's tied to the concept of modules. Have you learned about modules yet? Python programs can be split into several modular pieces, and these "modu

Re: [Tutor] draw lines

2005-11-06 Thread Danny Yoo
On Sun, 6 Nov 2005, Shi Mu wrote: > I have a list of random points: [[x0,y0],[x1,y1],...,[xn,yn]] how can I > use Tkinter to draw lines to connect them one by one based on the order > in the list? Do you know how to draw a single line in Tkinter? Have you looked at the Canvas widget documentat

Re: [Tutor] click and line

2005-11-06 Thread Danny Yoo
Hi Shi Mu, Let's look at click(): ## def click(event): print event.x, event.y m1=event.x n1=event.y ## By default, variable names in functions are local. Do you know about local vs global variables? The assignments to m1 and n1 won't

Re: [Tutor] click and line

2005-11-07 Thread Danny Yoo
> it works now. Hi Shi Mu, Can you describe how you fixed it? The only diff between the two programs that I see is that you repositioned the setting of the frame variable. # mumak:~ dyoo$ diff t1.txt t2.txt 6c6 < --- > frame = c 16c16 < frame = c --- > ##

Re: [Tutor] no error no result

2005-11-07 Thread Danny Yoo
On Sun, 6 Nov 2005, Shi Mu wrote: > when I read some python sample codes. > I found that several of them need "python -i" to run them or you will > not get any result though the program does not report any error. > I really can not understand it. Hi Shi Mu, Ok, let's compare-and-constrast. Ca

<    2   3   4   5   6   7   8   9   10   11   >