Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Steve Willoughby
Dragos Ionescu wrote: - Original Message From: bob gailer [EMAIL PROTECTED] To: David [EMAIL PROTECTED] Cc: tutor@python.org Sent: Saturday, October 4, 2008 10:15:10 PM Subject: Re: [Tutor] bug in exam score conversion program Lots of good responses. And now for something completely

Re: [Tutor] bug in exam score conversion program

2008-10-04 Thread Steve Willoughby
Dragos Ionescu wrote: Original Message From: Steve Willoughby [EMAIL PROTECTED] To: Dragos Ionescu [EMAIL PROTECTED] Cc: bob gailer [EMAIL PROTECTED]; David [EMAIL PROTECTED]; tutor@python.org Sent: Saturday, October 4, 2008 11:04:30 PM Subject: Re: [Tutor] bug in exam score conversion

Re: [Tutor] Hands-on beginner's project?

2008-10-03 Thread Steve Willoughby
and connections between them exists in _data_ instead of _code_. Something to simmer on the back burner until you're ready for that step. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread Steve Willoughby
to? What's the bigger context this fits into? Although you *can* do this sort of thing, it quite often ends up not being the most elegant thing to do. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware

Re: [Tutor] assigning values to dictionary

2008-10-03 Thread Steve Willoughby
might be: for major_key, subdict in my_dict.iteritems(): print The stuff stored under, major_key, is: for minor_key, value in subdict.iteritems(): print (%s) %s=%s % (major_key, minor_key, value) Thanks, JJ On Fri, 2008-10-03 at 10:39 -0700, Steve Willoughby wrote: On Fri, Oct

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread Steve Willoughby
and let us know. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread Steve Willoughby
to people as it stands now. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread Steve Willoughby
environments things get reused in ways you don't expect, and even if not, get used to good programming habits). -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] dealing with user input whose value I don't know

2008-10-02 Thread Steve Willoughby
David Bill Campbell wrote: On Thu, Oct 02, 2008, Steve Willoughby wrote: On Fri, Oct 03, 2008 at 01:38:48AM +0800, David wrote: Does that mean input() is obsolete (after all, Zelle's book is not the freshest on the shelf)? Or do they have different uses? Depends on how

Re: [Tutor] Hello again. and another question.

2008-10-02 Thread Steve Willoughby
there? -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Hello again. and another question.

2008-10-02 Thread Steve Willoughby
: print grades_file_2, %.2f % grade grades_file_2.close() -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] list to csv

2008-09-30 Thread Steve Willoughby
Arun Tomar wrote: hi! I've a list new_array = ['n1', 'm1', 'p1', 'n2', 'm2', 'p2', 'n3', 'm3', 'p3'] I am trying to convert this to a csv in 3 columns so that the final output would look something like this n1,m1,p1 n2,m2,p2 n3,m3,p3 This can easily be done with the csv module in the

Re: [Tutor] re.compile concatenating two searh words

2008-09-29 Thread Steve Willoughby
literally looking for this pattern in your program. pat.findall(a) findall is really for finding all the occurrences of a pattern in a string, not all the matching strings in a list. you can do this in a filter() to get what I think you're trying to accomplish. -- Steve Willoughby| Using

Re: [Tutor] range/for list change behavior

2008-09-29 Thread Steve Willoughby
Don Parris wrote: Hi all, After a rather long (and unfortunate) break from tinkering with Python, I am back at it. I am working through the book Learning Python (based on 2.2/2.3 - I use 2.5), and in the chapter on while/for loops, ran across the following example: L = [1, 2, 3, 4, 5]

[Tutor] How to replace instances

2008-09-25 Thread Steve Collins
I've written a save/load function for a simple program using cPickle. Upon saving, a master list, to which all instances are added in their __init__, is pickled. when the program starts, if the user wishes to load, a variable load is set to one, and the pickled list is loaded. All the classes

Re: [Tutor] How to replace instances

2008-09-25 Thread Steve Collins
On 9/25/08, Kent Johnson [EMAIL PROTECTED] wrote: On Thu, Sep 25, 2008 at 4:24 AM, Steve Collins [EMAIL PROTECTED] wrote: However, some of the instances refer explicitly to other instances instances. It's obvious why this causes problems. It occurred to me to simply replace the instances

Re: [Tutor] WHAT IS THE DIFFERENCE BETWEEN FILTER AND REDUCE FUNCTION

2008-09-24 Thread Steve Willoughby
, this computes (1*2)*3)*4)*5)*6) = 720 So our factorial function could have been implemented like this using reduce: def factorial(n): return reduce(lambda x,y: x*y, range(1,n+1)) HTH HAND steve ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] A question about how python handles numbers larger than it's 32 bit limit

2008-09-23 Thread Steve Willoughby
on the end or use long() to construct one explicitly, unless you really want it to be long type from the beginning. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor

Re: [Tutor] please explain this error

2008-09-23 Thread Steve Willoughby
. But NFS doesn't represent that case well so a temporary filename is used.) Unless your Python program is what's holding the offending file(s) open... any idea what's keeping the file in use? -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt

Re: [Tutor] array of different datatypes

2008-09-22 Thread Steve Willoughby
Dinesh B Vadhia wrote: I have looked (honestly!) and cannot see an array structure to allow different datatypes per column. I need a 2 column array with column 1 = an integer and column 2 = chars, and after populating the array, sort on column 2 with column 1 sorted relatively. If by array

Re: [Tutor] array of different datatypes

2008-09-22 Thread Steve Willoughby
Dinesh B Vadhia wrote: Thanks Steve. How do you sort on the second element of each list to get: a' = [[42, 'fish'], [1, 'hello'] [2, 'world'] ] something like this would do the trick: a_prime = sorted(a, key=(lambda i: i[1])) sorted(a) returns a new list consisting

Re: [Tutor] pexpect

2008-09-20 Thread Steve Poe
('#', 2) 23 tn.read_until('#', 2) 24 tn.write('show call history voice last 100\n') HTH, Steve On Sep 20, 2008, at 8:43 AM, James wrote: Folks, Does anyone here have experience with pexpect? I'm trying to write a pexpect script which will log into a network device, gather statistics

Re: [Tutor] not operator

2008-09-18 Thread Steve Willoughby
, and None. I'd really strongly encourage the first form. Your mileage may vary, of course. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] Shell scripting

2008-09-17 Thread Steve Willoughby
is a silly pseudo code example: bash command | some-python-script.py | some.other-script.sh thanks in advance-Patrick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Steve Willoughby| Using billion

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
an existing network RPC call or something, to as complicated as creating a web service on windows that the linux client(s) connect to. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
a simple Linux-side Python script which would connect to the web service and request it to run. Be careful, though. What you're describing is fraught with security issues and vulnerabilities that need to be skillfully addressed. -- Steve Willoughby| Using billion-dollar satellites [EMAIL

Re: [Tutor] WMI

2008-09-17 Thread Steve Willoughby
On Wed, Sep 17, 2008 at 11:37:39AM -0600, Spencer Parker wrote: Yes...you do have it all correct. Luckily this is all behind a private network that is firewalled. There is no way to get to this network unless you are physically on site. Since there isn't even VPN access to this network

Re: [Tutor] For Loops and nested loops

2008-08-16 Thread Steve Willoughby
, n): remember what n means in range(1, n). You may have a fencepost error (off-by-one), depending on what you intended to happen here. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor

Re: [Tutor] simple python scrip for collocation discovery

2008-08-16 Thread Steve Willoughby
without doing the work for you because we don't do homework exercises for people :) -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-16 Thread Steve Willoughby
document (like an auto-generated template from the IDE). They're just tools. Pick the ones that work for the jobs you need to get done, but don't assume that the other ones are pointless. They may either have points you don't need, or you may not have realized their importance yet. --steve

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-16 Thread Steve Willoughby
Steve Willoughby wrote: Likewise, there's a reason the IDE environments like Visual Studio or Eclipse, and pointy-clicky-WYSIWYG editing tools exist. They're much easier for beginners to learn, not as intimidating, but in the end they For example, I use pyWin or IDLE all the time if I want

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-15 Thread Steve Willoughby
a new language is always a good thing to do if it changes how you look at programming. Only knowing how to edit text in one fashion with one tool makes as much sense as only knowing one way to write a program, in one language. --steve ___ Tutor maillist

Re: [Tutor] RE expressions

2008-08-15 Thread Steve Willoughby
Johan Nilsson wrote: 'text http:\123\interesting_adress\etc\etc\ more text' Does this really use backslashes in the text? The standard for URLs (if that's what it is) is to use forward slashes. For your RE, though, you can always use [...] to specify a range including whatever you like.

Re: [Tutor] RE expressions

2008-08-15 Thread Steve Willoughby
Steve Willoughby wrote: Johan Nilsson wrote: In [74]: p.findall('asdsa123abc\123jggfds') Out[74]: ['123abcS'] By the way, you're confusing the use of \ in strings in general with the use of \ in regular expressions and the appearance of \ as a character in data strings encountered by your

Re: [Tutor] os.path.walk vs unix find command

2008-08-15 Thread Steve Willoughby
Kent Johnson wrote: Is os.popen(find) faster or slower than os.path.walk to find file pattern in the The general answer to is find faster than os.[path.]walk faster is it depends. Find is optimized, compiled, and fast at what it does. However, what it does is somewhat limited. If you want

Re: [Tutor] Beginner problem: name 'convertToFahrenheit' is not defined

2008-08-15 Thread Steve Willoughby
Joseph Bae wrote: Thanks for the help! I have managed to get a good temperature converter program working! I am working on beefing it up a bit with some exception handling and an and-or trick. The error handling works okay but I am having problems using and-or. Here's my updated code: def

Re: [Tutor] What has Editor X got that PyWin32 hasn't?

2008-08-12 Thread Steve Willoughby
Jaggo wrote: Why do you use your editor rather than using Pywin? What feature has editor X got that PyWin hasn't? (That is, other than My editor runs on unix / linux; while that does count for something it is rather irrelevant to my current situation.) I use a different editor (in my case vim)

[Tutor] hello.py: line 1: print: command not found

2008-08-11 Thread steve
Hi In order to execute python script by fedora terminal ; insert #! /bin/env python as the first line in the script. Python scripts end with a file extension of .py, as indicated above. It is also possible in Unix to automatically launch the Python interpreter without explicitly invoking it

Re: [Tutor] Scan Directory for files

2008-08-02 Thread Steve Poe
Fred, What is/are the exact error message(s)? You may want to look at the module glob. Steve Ar e you typing this in the python interpreter or On Aug 1, 2008, at 10:41 PM, Fred @ Mac wrote: Hello, new to python, so please go easy on me! I am using for f in os.listdir(watch_dir

[Tutor] understanding join

2008-07-30 Thread Steve Poe
: string ='ab' so, if I type: print string.join(string) aabb but if string is 'abc' print string.join(string) aabcbabcc print string ='a' returns on a in this example, whit string='a ' returns aa. So, I am not catching the pattern. Thanks. Steve

Re: [Tutor] checking for expected types from input file

2008-07-30 Thread Steve Poe
('ReferencePositionX').isdigit() =='True': refx = float(INPUT['ReferencePositionX'])/10 refy = float(INPUT['ReferencePositionY'])/10 refz = float(INPUT['ReferencePositionZ'])/10 Steve On Jul 30, 2008, at 6:43 PM, Bryan Fodness wrote: I am populating a dictionary from an input file, and would

[Tutor] key/value order in dictionaries

2008-07-30 Thread Steve Poe
(4) key/value pairs, the display order is the same as I entered the them. With 5 or more key/value dictionaries, the printed result is not sequential. Any thoughts? Steve ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman

Re: [Tutor] List indexing problem

2008-07-25 Thread Steve Willoughby
Mike Meisner wrote: I need to do some statistical analysis by binning values into an array. Being new to Python, I tried to use a list of lists. I've extracted just the minimum code that I'm having trouble with: What you need to remember is that Python works with *objects*, and variables

Re: [Tutor] Newbie

2008-07-24 Thread Steve Willoughby
To answer the specific question about square roots below, Python's square root function is in the math module. You can either include this module and invoke it like this: import math . . . y = math.sqrt(x) -or- if you want the sqrt() function brought into your main namespace, you can do it

Re: [Tutor] Raw string

2008-07-20 Thread Steve Willoughby
Neven Goršić wrote: Hi! In every manual and book I read only one way to make a raw string: re:\mm tests\1. exp files\5.MOC-1012.exp. I don't know how to make a string raw string if it is already contained in a variable. s.raw() or something like that ... Actually, there's no such thing as a

Re: [Tutor] Raw string

2008-07-20 Thread Steve Willoughby
bob gailer wrote: I'm guessing you want x.raw() # to display r\t Is that true. That's the only way I can interpret your question. Hm... or did you (speaking to the OP) intend for your script to interpret strings you're reading from another source, like user input or a text file, and

Re: [Tutor] Online class/education for Python?

2008-07-20 Thread Steve Poe
Joe, It's an online class without a specific time. The class runs for six weeks with two assignments per week. Steve On Sun, Jul 20, 2008 at 3:51 PM, Joe Bennett [EMAIL PROTECTED] wrote: What time where the classes? Web site seems to be missing that info... -Joe On Sun, Jul 20, 2008

[Tutor] Online class/education for Python?

2008-07-19 Thread Steve Poe
Anyone taken or know of any online classes teaching Python? I know O'Reilly Press teaches online technical courses, through the University of Illinois, but no Python . Thanks. Steve ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman

[Tutor] Guidance on jump-starting to learn Python

2008-07-17 Thread Steve Poe
. Python Programming for the Absolute Beginner, Second Edition. Thanks so much for your advice/help in advance. Steve ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Another assert() question

2008-07-13 Thread Steve Willoughby
Dick Moores wrote: Yes! A rule, not logic. I'm not contradicting Kent, just helping myself understand. First the rule, then logic in the application of the rule. And I assume the rule is there in Python because it makes things work better. Yes, so a statement like if foo: becomes an idiom

Re: [Tutor] Script Name/Path Information

2008-07-05 Thread Steve Willoughby
Monika Jisswel wrote: import sys #a module that gives access to the system import os#a module that gives access to the os print sys.argv[0] #prints file name of the script print os.getcwd() #print current working directory print os.getcwd()+sys.argv[0] # but os.getcwd()

Re: [Tutor] Removing files based upon time stamps

2008-06-25 Thread Steve Willoughby
You might also want to consider using the path walk facility in Python's standard lib as well, so you can recurse into subdirectories doing this (if that is helpful) -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware

Re: [Tutor] Removing files based upon time stamps

2008-06-25 Thread Steve Willoughby
On Thu, Jun 26, 2008 at 04:53:14AM +0700, Lie Ryan wrote: I'm not sure what caused your problem, but... Look at where you're checking the file time. You're not checking the file itself, but '.' (the time of the current directory). -- Steve Willoughby| Using billion-dollar satellites

Re: [Tutor] Tkinter on OS X

2008-06-21 Thread Steve Willoughby
Shrutarshi Basu wrote: I've been writing a simple Tkinter interface to one of my programs. But it looks rather bad on OS X leopard. I was wondering why that was the case, since it seemed to take up at least some GUI elements (like button styles). I then came upon the following page:

Re: [Tutor] env variable

2008-06-03 Thread Steve Middendorf
From: [EMAIL PROTECTED] To: tutor@python.org Date: Tue, 3 Jun 2008 15:39:18 -0400 Subject: [Tutor] env variable have a question about setting up an env. variable. i own a macbook pro laptop running mac os x 10.5.2. i downloaded MacPython 2.5. my problem

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
On Thu, May 8, 2008 10:51, Dick Moores wrote: html body Could someone tell me what's wrong with this regex?brbr The main thing is that you're forgetting that a RE matches anywhere in the string. \b\d+/\d+/\d{2,4}\b matches 4/4/2009 12/12/555 \b\d{1,2}/\d{1,2}\b matches 4/4/2009 4/4/12345

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
Changing to br ttregex = rquot;^\d+/\d+/\d{2,4}$|^\d{1,2}/\d{1,2}$quot;brbr /ttdid the job, and I learned several important points.brbr Thanks, Kent and Steve!brbr Dickbr /body /html ___ Tutor maillist - Tutor@python.org http://mail.python.org

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
On Thu, May 8, 2008 12:40, Dick Moores wrote: At 11:46 AM 5/8/2008, Steve Willoughby wrote: Be aware that \d{2,4} matches 2, 3 or 4 digits, which may be different than what you're looking for, since 1/12/234 would match Yes, I wanted to permit that. In my script, mxDateTime turns 1/12/234

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
On Thu, May 8, 2008 14:40, Dick Moores wrote: At 01:30 PM 5/8/2008, Steve Willoughby wrote: On Thu, May 8, 2008 12:40, Dick Moores wrote: But here's a chance to ask: What regex would match 2-digit strings and 4-digit strings only? ^\d\d(\d\d)?$ Ah. And so ^\d\d(\d\d)?(\d\d)?$ matches all

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
On Thu, May 8, 2008 16:32, Steve Willoughby wrote: On Thu, May 8, 2008 14:40, Dick Moores wrote: At 01:30 PM 5/8/2008, Steve Willoughby wrote: On Thu, May 8, 2008 12:40, Dick Moores wrote: But here's a chance to ask: What regex would match 2-digit strings and 4-digit strings only? ^\d\d(\d

Re: [Tutor] regex newbie question

2008-05-08 Thread Steve Willoughby
Dick Moores wrote: At 04:32 PM 5/8/2008, Steve Willoughby wrote: On Thu, May 8, 2008 14:40, Dick Moores wrote: At 01:30 PM 5/8/2008, Steve Willoughby wrote: On Thu, May 8, 2008 12:40, Dick Moores wrote: But here's a chance to ask: What regex would match 2-digit strings and 4-digit strings

Re: [Tutor] Cosmetic question about printing

2008-05-06 Thread Steve Willoughby
On Tue, May 6, 2008 11:35, Dick Moores wrote: Could someone just come right out and do it for me? I'm lost here. That '*' is just too magical..nbsp; Where did you guys learn about '%*s'? Does the '%s' still mean a string? Python's % operator (for string formatting) is derived from the C

Re: [Tutor] Cosmetic question about printing

2008-05-06 Thread Steve Willoughby
now :) And glad to help. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Project Euler Problem 6

2008-04-24 Thread Steve Willoughby
of the first why use the list comprehension here, instead of simply saying: return sum(range(1,101) ** 2 -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor

Re: [Tutor] SQLite LIKE question

2008-04-11 Thread Steve Willoughby
), it will know to properly quote or escape special characters in those data values. Some modules use ? as the place holder, others use %s (even for numeric values, interestingly enough). Check with your documentation. --steve ___ Tutor maillist - Tutor

Re: [Tutor] Python, CGI and CSS

2008-04-10 Thread Steve Willoughby
located in the cgi-bin folder. It's likely your web server is set up to *execute* (not deliver as text) files in your cgi-bin directory. Thanks! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Steve

Re: [Tutor] parse emails as they come in

2008-04-02 Thread Steve Willoughby
linuxian iandsd wrote: ok - as i mentioned in my first email i use procmail to put THE BODY of all incoming mail into a file (that is one per incoming email as i use the variable $date-$time in the name). now this file can contain only one email but it can also contain 2 or more (this

Re: [Tutor] parse emails as they come in

2008-04-02 Thread Steve Willoughby
script, you'd say something like :0 *Subject:.*pattern to look for |/home/me/scriptname For more information see procmailrc(5) and procmailex(5). Your Python script will see the message input on stdin. On Wed, Apr 2, 2008 at 7:18 AM, Steve Willoughby [EMAIL PROTECTED] wrote: linuxian iandsd

Re: [Tutor] parse emails as they come in

2008-04-02 Thread Steve Willoughby
format might not be wrong? Some error checking might be good to add at some point. On Wed, Apr 2, 2008 at 9:50 AM, Steve Willoughby [EMAIL PROTECTED] wrote: linuxian iandsd wrote: well, i don't know how to pipe the file to my script !! It's how procmail works. Presuming you

Re: [Tutor] Using split with a backslash

2008-04-02 Thread Steve Willoughby
='-42.0001\29.8001' LeafJawPositions '-42.0001\x029.8001' x1, x2 = LeafJawPositions.split('\x0') ValueError: invalid \x escape x1, x2 = LeafJawPositions.split('\') Try x1, x2 = LeafJawPositions.split('\\') -- Steve Willoughby| Using billion-dollar satellites [EMAIL

Re: [Tutor] parse emails as they come in

2008-04-01 Thread Steve Willoughby
of problems with properly quoting data (what if a ';' is in one of the data fields?), as well as making it unnecessary to carry out another post-processing step of gathering this script's output and stuffing it into MySQL. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED

Re: [Tutor] from __future__ import division

2008-03-23 Thread Steve Willoughby
Dinesh B Vadhia wrote: I spent fruitless hours trying to get a (normal) division x/y to work and then saw that you have to declare: normal division x/y works just as expected, with one caveat: remember that if you divide two *integer* values, you will get an *integer* division operation

Re: [Tutor] returning two values

2008-03-21 Thread Steve Willoughby
elis aeris wrote: is it possible to return two values? Yes and no. You can return a value, but that value may itself be a tuple of values. Or a list, dictionary or other kind of object. how do I create an empy int array of 10? If an int array has 10 things in it, it's not empty. You don't

Re: [Tutor] list

2008-03-21 Thread Steve Willoughby
elis aeris wrote: arra = [0] * 10 ? If you want a list of ten zeroes, yes. A couple of suggestions: Find a tutorial introduction to Python such as those on python.org, or google for dive into python, and go through the examples in there. Also, use the interactive Python interpreter to try out

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread Steve Willoughby
. non_null = 'Trondheim' which is a True value. If you said: if non_null: print non_null, 'is not null' else: print it's null The result would be to print: Trondheim is not null Hope that helps steve On Mar 20, 2008, at 4:32 PM, Guba wrote: Dear list

Re: [Tutor] comparison bug in python (or do I not get it?)

2008-02-29 Thread Steve Willoughby
Kent Johnson wrote: Hans Fangohr wrote: In [2]: 2 in [1,2,3] == True On a slightly different tangent from the other answers you've received to this question, if you're using a conditional expression, don't compare it explicitly with True or False, just state the condition: if 2 in [1,2,3]:

Re: [Tutor] Change dictionary value depending on a conditional statement.

2008-02-11 Thread Steve Willoughby
Kent Johnson wrote: Try list.append({'id': 'name', 'link': ('YY','XX')[total 0]}) I'd caution against that, though. It's clever and cute, sure, but the meaning of it is obfuscated enough to be unpythonic because [total 0] as a subscript doesn't mean anything unless you know you're

Re: [Tutor] import sys; sys.exit()

2008-01-10 Thread Steve Willoughby
a ValueError, the code here will deal gracefully with that, and carry on. Any other exception will still be handled normally. There's a lot more detail, but that's the basic gist of it. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware

Re: [Tutor] constants, flags or whatever

2007-12-19 Thread Steve Willoughby
Dave Kuhlman wrote: On Wed, Dec 19, 2007 at 09:41:13PM -0500, bob gailer wrote: 1 - I see no value in introducing variables. I'd just use string constants: action = moving . . if action == jumping: etc. I agree. But, some people do prefer something that looks a bit like an enum.

Re: [Tutor] How is tuple pronounced?

2007-12-10 Thread steve reighard
On Dec 10, 2007 11:14 PM, earlylight publishing [EMAIL PROTECTED] wrote: Is it tuh-ple (rhymes with supple) or is it two-ple (rhymes with nothing that I can think of)? How unscrupulous of you! ___ Tutor maillist - Tutor@python.org

Re: [Tutor] network - send one line of text

2007-11-23 Thread Steve Willoughby
Michael Langford wrote: On 11/23/07, elis aeris [EMAIL PROTECTED] wrote: is it possible to do this with python? a server script to listen for a client script, it sends a line of text to server when a given criteria is met. Sounds like python may not be simplest path to solving your

Re: [Tutor] assignment question

2007-11-11 Thread Steve Willoughby
Ryan Hughes wrote: Hello, Why does the following not return [1,2,3,4] ? x = [1,2,3].append(4) print x None because the append() method doesn't return a copy of the list object; it just modifies the list itself. so your code constructs a list object with 3 elements, appends a fourth

Re: [Tutor] Difference between Perl and Python

2007-11-04 Thread Steve Willoughby
Varsha Purohit wrote: Hello everyone, I wanted to know what are the differences between perl and python, since both of them are scripting languages... There is plenty of difference between them and between all the other scripting languages. Look beyond the notion of scripting and look

Re: [Tutor] internet access

2007-10-11 Thread Steve Willoughby
This is where it's an advantage to setting up an old PC as a firewall for your network. Stick Linux on it, set up your filtering rules, and let it sit between your home network and the outside world. You can then have it block that PC's access to the Internet via cron scripts, possibly even

Re: [Tutor] Updating MySQL Database

2007-10-07 Thread Steve Willoughby
Rick Pasotto wrote: (ip,fqdn) = line.split(',') updatequery = update resultstable set %s where ip = %s % (fqdn,ip) cursor.execute(updatequery) connection.close() Alternatively you could do: connection = MySQLdb.connect(db=self.todatabase,host-self.host,

Re: [Tutor] Sending Email

2007-10-03 Thread Steve Willoughby
. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sending Email

2007-10-03 Thread Steve Willoughby
in the sendmail() parameter but not in the To: or Cc: headers, and they are blind-carbon-copied. -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED] | to hunt for Tupperware. ___ Tutor maillist - Tutor@python.org http://mail.python.org

Re: [Tutor] Sending Email

2007-10-03 Thread Steve Willoughby
On Wed, Oct 03, 2007 at 02:09:07PM -0700, Steve Willoughby wrote: On Wed, Oct 03, 2007 at 05:02:52PM -0400, Kent Johnson wrote: One gotcha is that msg must also include From and Two headers. A slightly longer example is here: http://docs.python.org/lib/SMTP-example.html Yes, that's

Re: [Tutor] Really basic web templating

2007-09-30 Thread Steve Willoughby
a script which serves the page if it exists, or creates a blank one if it doesn't. You can use Python's string template module as an easy way to format up variable text into style templates you set up as text files, or use a database backend, or whatever. --steve -Sam

Re: [Tutor] Just bought Python in a Nutshell

2007-09-14 Thread Steve Holden
, and contains enough information that almost every Python programmer will find it a useful addition to his or her bookshelf. You will enjoy it whether you choose to read from the beginning or just dip in. regards Steve -- Steve Holden+1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd

Re: [Tutor] Apache, CGI-BIN, Python

2007-09-09 Thread Steve Willoughby
Ryan wrote: I am running a Linux box and cannot find my Apache cgi-bin to put some python scripts in. I know I probably have to create one but don't know where and how. On Linux under Apache 2.2, I've seen it in /usr/lib/cgi-bin which always struck me as weird, but there you go. On BSD, it

Re: [Tutor] Python / CGI

2007-09-07 Thread Steve Willoughby
John wrote: Steve, If you're interested in just banging out a Python app, though, my experience was writing a calendaring tool for a group of my friends who get together [...] This sounds very cool, is it something you could post? Okay. It's not the greatest

Re: [Tutor] rewriting script

2007-09-07 Thread Steve Willoughby
Christopher Spears wrote: I have written a script that reads and displays text files: #!/usr/bin/env python 'readTextFile.py -- read and display text file' import os # get filename while True: fname = raw_input('Enter file name: ') print if os.path.exists(fname):

Re: [Tutor] Importing Excel sheet data

2007-09-06 Thread Steve Willoughby
saradhi dinavahi wrote: I am new to the Python Programming. I want to Import Excel sheet data using Python. Can any one please provide me the code and explain the basic steps and method of executing the code. If you can get your Excel data into CSV format, the csv module others have already

Re: [Tutor] Python / CGI

2007-09-06 Thread Steve Willoughby
in the normal calendar view. The whole thing only took 318 lines of straight Python code, including all the HTML displayed on all those forms. The calendar module is your friend for apps like this, by the way :) -- Steve Willoughby| Using billion-dollar satellites [EMAIL PROTECTED

Re: [Tutor] Plz help me from this

2007-09-05 Thread Steve Willoughby
() and os.chown() to make the changes. (Note that os.chown() changes the owner and/or group in one call.) HTH --steve ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Plz help me from this

2007-09-05 Thread Steve Willoughby
Carlos Daniel Ruvalcaba Valenzuela wrote: Yes is very possible to do this with python. Checkout the os.system and os.popen functions to run external commands (chmod, chown). While those are ways of calling external commands, it is best to use built-in language features like os.chmod() and

Re: [Tutor] Random module.. or?

2007-08-07 Thread steve reighard
values) into a normally distributed random value. Check out Wikipedia's normal distribution entry. The math is really juicy. You may end up with a recipe for the Python Cookbook. Have fun. Steve ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] MONEY MATTERS

2007-03-22 Thread Steve Oldner
day, I will have free time to work on my million dollar app. (LOL!) Thanks, Steve Oldner -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kirk Bailey Sent: Wednesday, March 21, 2007 10:14 PM To: tutor@python.org Subject: [Tutor] MONEY MATTERS ok, SHOULD

[Tutor] Printing labels

2007-03-07 Thread Steve Maguire
. To print the labels the way I want, I will need extended control over the printer: positioning the printer precisely and changing fonts, colors, and background colors. Is there a public python library that could give me this level of control? Thanks Steve

<    1   2   3   4   >