Re: [Tutor] help

2005-05-11 Thread Chris Smith
On Wednesday, May 11, 2005, at 08:09 America/Chicago, [EMAIL PROTECTED] wrote: > hi > i'm trying to extend a list program by adding a test, problem is after > getting the menu of taking the test i can't seem to get the test > running > i.e viewing of questions and answers. here's what i tried t

Re: [Tutor] character format

2005-05-11 Thread Chris Smith
On Wednesday, May 11, 2005, at 20:43 America/Chicago, [EMAIL PROTECTED] wrote: > I believe Max's guess was that the file is compressed with bzip (the > first > two characters will be BZ, as you found). Try doing: > import bz2 print bz2.decompress(data) > > Where data is a string co

Re: [Tutor] dicts&lists vs objects

2005-05-12 Thread Smith, Jeff
Those are good observations and I think answers part of the question. I think the other part is that even in OO code, how do you know what to make an object and what to just store in an existing data type like a list or dictionary. Personally, I use the "if it walks like a duck" rule. In other

[Tutor] I know you will hate this but...

2005-05-17 Thread Smith, Jeff
I'm working on a Python development project which spans multiple people. We are all working on Windows and using the PyWin IDE. Our code is revision controlled using Perforce. Already we had one instance where the logical structure of a file was destroyed because indentation levels were changed a

Re: [Tutor] Removing lines in string-table

2005-05-17 Thread Chris Smith
On Tuesday, May 17, 2005, at 08:35 America/Chicago, [EMAIL PROTECTED] wrote: > I have a string table (don't recall the right word used in Python > right now) and would like to remove every 'cell' that contains a > string '_thumb.jpg'. There are 1-> digits before the string if that > matters. I m

Re: [Tutor] I know you will hate this but...

2005-05-17 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrei >It seems problematic to me to NOT enforce standard *settings* (e.g. 4 spaces >per indentation level, no tabs). Any IDE can be used as long as the proper >settings are configured. Inconsistent indentation styles are very an

[Tutor] Perl equivalent of $#var

2005-05-17 Thread Smith, Jeff
Is there a more Pythonic way to get the Perl equivalent of $#var other than len(var) - 1 Thanks, Jeff ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Perl equivalent of $#var

2005-05-18 Thread Smith, Jeff
y and I would prefer if now == $#colors Keep in mind this is not an exact statement of the problem but I believe it captures the full context. Jeff -Original Message- From: Danny Yoo [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 17, 2005 6:00 PM To: Smith, Jeff Cc: tutor@python.org S

[Tutor] Process control and capturing output

2005-06-01 Thread Connor . Smith
Hi there - I'm trying to capture the output of a long-running command in the background (it's a CVS rdiff on a fairly big repository).  I need to capture the stdout from this command, and then parse it later for a report Defining the function: def rdiffApp (targetModule, buildFromStamp, buildT

[Tutor] Logging stdout and stderr

2005-06-17 Thread Connor . Smith
Hi there - I'm trying to log the results of a command that I'm running via the popen2 module to a file, while at the same time displaying its progress on the screen. So, at the end of the run, I should have the entire output (stdout and stderr) on the screen, but also have two file objects each

[Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
Consider a class with a lt of properties. I would like a member function which generates a dictionary where the keys are the property names and the values are the property values? Is this clear? How might I go about this? Jeff ___ Tutor maillist - T

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
ilto:[EMAIL PROTECTED] On Behalf Of Smith, Jeff Sent: Thursday, June 23, 2005 2:01 PM To: tutor@python.org Subject: [Tutor] Interesting problem Consider a class with a lt of properties. I would like a member function which generates a dictionary where the keys are the property names and the value

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
Here would be the usage: myinst = MyClass() print myinst.getprops_as_dict() would print {'var1': 1, 'var2': 2, 'var3': 3} Needless to say I want the instance values which might be different for each instance. I know that I could code it brute force, but I want to be able to add properties with

Re: [Tutor] Interesting problem

2005-06-23 Thread Smith, Jeff
, property): d[entry] = getattr(self, entry) return d Thanks! Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Thursday, June 23, 2005 4:39 PM To: Python Tutor Subject: Re: [Tutor] Interesting problem Smith,

Re: [Tutor] Windows user variable ?

2005-06-27 Thread Smith, Jeff
I would personally suggest using getpass.getuser() for maximum portability. Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Sunday, June 26, 2005 6:16 PM To: tutor@python.org Subject: Re: [Tutor] Windows user variable ? Qu

Re: [Tutor] Case ? (fwd)

2005-07-06 Thread Smith, Jeff
If you like the switch statement (which I do) and believe Python should have one (which I do) then you might take a look at this which someone posted when I asked this same question a few months ago: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410692 Jeff -Original Message- F

[Tutor] Buffering problem using subprocess module

2005-07-19 Thread Smith, Jeff
I am using the subprocess module in 2.4. Here's the fragment: bufcaller.py: import sys, subprocess proc = subprocess.Popen('python bufcallee.py', bufsize=0, shell=True, stdout=subprocess.PIPE) for line in proc.stdout: sys.stdout.write(line) bufcallee.py:

[Tutor] Something that Perl can do that Python can't?

2005-07-22 Thread Smith, Jeff
So here it is: handle unbuffered output from a child process. Here is the child process script (bufcallee.py): import time print 'START' time.sleep(10) print 'STOP' In Perl, I do: open(FILE, "python bufcallee.py |"); while ($line = ) {

Re: [Tutor] Something that Perl can do that Python can't?

2005-07-22 Thread Smith, Jeff
some sort of iteration over stdout, please let me know. Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Smith, Jeff Sent: Friday, July 22, 2005 4:37 PM To: Tutor Subject: [Tutor] Something that Perl can do that Python can't? So here it is: ha

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
Title: Message Although that works, I kinda prefer     del meals['breakfast'] since that explicitly indicates what is going on.   Speaking of which, I note that there is a pop for lists but no shift.  Is there a Python idiom for this or is it just val = mylist.shift() =>    (val, mylist)

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
lto:[EMAIL PROTECTED] Sent: Wednesday, August 03, 2005 9:15 AM Cc: tutor@python.org Subject: Re: [Tutor] Deleting an entry from a dictionary Smith, Jeff wrote: > Speaking of which, I note that there is a pop for lists but no shift. > Is there a Python idiom for this or is it just >

Re: [Tutor] Deleting an entry from a dictionary

2005-08-03 Thread Smith, Jeff
org Subject: Re: [Tutor] Deleting an entry from a dictionary Smith, Jeff wrote: > Ummm...that doesn't do what I asked. > > pop is a linguistic idiom for > > (val, mylist) = (mylist[-1], mylist[0:-1]) No, actually, not quite. >From the docs: s.pop([i]) same as x = s[i]; d

[Tutor] HTML/text formatting question

2005-08-03 Thread Smith, Jeff
I have a tool that outputs data in either html or text output. Currently I'm writing chucks like: if html: print '' print '' print '' print 'Differences %s: %s' % (htypestr, lbl1) if html: ... This seems clunky and my next step was going to be to define generic functions

Re: [Tutor] CVS for Python

2005-08-03 Thread Smith, Jeff
If this is a Windows box then I highly recommend CVSNT (http://www.cvsnt.com/) with TortoiseCVS (http://www.tortoisecvs.org/). I've heard good things about Subversion but haven't tried it yet and don't know how its Windows installation is. There is also a TortoiseSVN (http://www.tortoisesvn.org/)

[Tutor] How to test for a remainder from division

2007-05-14 Thread Matt Smith
Hi there, I'm trying to write a short function to test whether a year is a leap year or not. To do this I need to check whether the year divides exactly by 4, 100 and 400. I can't think of an easy way to test whether there is a remainder or not. The best I can come up with so far is: if (year / 4

Re: [Tutor] How to test for a remainder from division

2007-05-14 Thread Matt Smith
Hi, Thanks for all the help, I guessed that there would be a module out there providing a function to do this but wanted to go through the process as a learning exercise. The modulus operator was just what I was looking for, I had been trying to check for a difference between the division and the

[Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-18 Thread Matt Smith
Hi, I am trying to write a simple program to display Conway's Game Of Life. I have the bones of the program together but I'm struggling with the function that tests for and applies the rules of the game (the important bit). I have the current state of the game stored in a 2d matrix with each cell

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-18 Thread Matt Smith
On Fri, 2007-05-18 at 23:49 +0200, Rikard Bosnjakovic wrote: > Something like this: > > try: >the_index_outside_matrix_test() > except IndexError: > suppress_the_error() Thanks Rikard, I'm not sure how I would go about actually suppressing the error - what would suppress_the_error() actual

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-18 Thread Matt Smith
> > Is there a better way of doing this? > > Perhaps something like this: > > for n in (x, x+1, x-1): > for m in (y, y+1, y-1): > if matrix[n, m]: > neighbour_count = neighbour_count + 1 > I need to not text matrix[x][y] is there a simple way to exclude this from the possible combi

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-19 Thread Matt Smith
> the possible combinations of values from the two tuples? > see my other reply, Matt. > -Luke Hi Luke, Sorry if I'm missing something but which other reply? Matt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help with excetion handing and making my code more efficient needed please

2007-05-19 Thread Matt Smith
On Fri, 2007-05-18 at 17:03 -0500, Luke Paireepinart wrote: > see my other reply, Matt. > -Luke Apologies Luke, I have found your earlier post in the tutor archives - I don't seem to have received it from the list yet. Thanks for the help. Matt ___

[Tutor] SMS to Python

2007-05-22 Thread Smith, Jeff
I would like to be able to send an SMS message from my phone which is then picked up by a Python script and acted on. I'm fairly proficient in Python and networking, but don't know much about SMS messaging. Where's the best place to start? Thanks, Jeff _

[Tutor] Still having trouble with my game of life algorithm

2007-05-25 Thread Matt Smith
Hi, First of all, thanks to everyone who helped with my last post (http://mail.python.org/pipermail/tutor/2007-May/054360.html). I have re-written the function that applies the rules but it still doesn't return the expected result. I have been through it and corrected a couple of bugs bet as far a

[Tutor] More trouble debugging my game of life program

2007-06-03 Thread Matt Smith
d: #! /usr/bin/env python # Curses based Game of Life program # Written by Matt Smith import curses from copy import deepcopy def read_start(): # Read the starting configuration from a text file file = open('/home/matt/Python/game_of_life/r-pentomino.txt', 'r&

[Tutor] Suggestions for a first object orientated program

2007-06-03 Thread Matt Smith
Hi, I have been reading up on OOP in Python recently and feel ready to attempt my first program using OOP principals. Can anyone suggest a suitable first OOP project for me to get my teeth into? I haven't done any real GUI programming but I have started gutting to grips with the curses module und

Re: [Tutor] More trouble debugging my game of life program

2007-06-04 Thread Matt Smith
On Sun, 2007-06-03 at 18:09 -0400, Brian van den Broek wrote: > The first thing I would do to try to track down the problem would be > to try 15x30 and 30x15 matrices. If you have two cases where one > behaves as expected and one does not, it is usually very useful to try > to match the two cas

[Tutor] Invoking Python from Vim

2007-06-07 Thread Matt Smith
Hi, Bit of a Vim specific question this one but I hope someone might have an answer. I currently have the following line in my .gvimrc file (I'm using Ubuntu Linux): map :!gnome-terminal -e=python\ -i\ % This opens a window and runs the Python program I am working on. I don't really like the fa

[Tutor] DB switch

2007-06-29 Thread Smith, Jeff
We are converting a database from Oracle to SQL 2005. We have a Python script that currently uses Digital Creation's 'DCOracle' python module. Any guidance on how to convert this for use with SQL 2005 is appreciated. Jeff ___ Tutor maillist - Tutor

[Tutor] Running program from Python

2007-07-20 Thread Chris Smith
Howdy, I am working on some research. I'm trying to optimize the performance of an antenna. For the simulation of the antenna it would be easiest to use an antenna software package that I have in my lab. I know that Matlab can call the antenna software through a command called system. Matlab a

[Tutor] Running another program from Python

2007-07-20 Thread Chris Smith
Howdy, I am working on some research. I'm trying to optimize the performance of an antenna. For the simulation of the antenna it would be easiest to use an antenna software package that I have in my lab. I know that Matlab can call the antenna software through a command called system. Matlab a

Re: [Tutor] Losing the expressiveness of C'sfor-statement?/RESENDwith example

2007-08-07 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen McInerney From: [EMAIL PROTECTED]; tutor@python.org >>As to your particular case one non while option would be a generateor: >> >>def half(n): >> while int(n) > 0: >>n = n/2 >>yield n >> >>for x in half(300)

Re: [Tutor] Losing the expressiveness ofC'sfor-statement?/RESENDwith example

2007-08-10 Thread Smith, Jeff
Thank you for reminding me of that! I've just started with 2.5 but that one had slipped my memory and I've still been using X = (z and [y] or [w])[0] Thank! Jeff -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Friday, August 10, 2007 10:23 AM To: S

Re: [Tutor] Losing the expressiveness ofC'sfor-statement?/RESENDwith example

2007-08-10 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Stephen McInerney wrote: >> The C for-loop syntax itself is not error-prone at all. >> Unless you mean off-by-one errors etc., missing initializations, and >> those are mostly semantic not syntax-related. > Yeah other th

Re: [Tutor] Losing the expressivenessofC'sfor-statement?/RESENDwithexample

2007-08-10 Thread Smith, Jeff
That's a good point. He keeps indicating that the tutorial should make reference to C/C++/Java syntax specifically because that's what the rest of the known universe uses. To carry your example one step farther, it's like expecting a grade school Spanish text to have pointers for English speaker

Re: [Tutor] Losing the expressivenessofC'sfor-statement?/RESENDwith example

2007-08-10 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stephen McInerney > I didn't get much decent opinion on my central question: > "isn't this idiom more restrictive than C/C++/Java (aka the rest of the universe)," I thought you got plenty of decent opinion and most of was disagreement.

Re: [Tutor] or synxtax in if statement

2007-08-31 Thread Smith, Jeff
That definitely won't work. How could the language possibly determine if you meant a == b | a == c as opposed to the literal a == b | c What this becomes is a == (b | c) Also be aware that | is a "bitwise or" and not a logical "or" which may not be what you want. So your original expressio

[Tutor] How to keep trying something until it doesn't return an error?

2007-11-12 Thread Matt Smith
Hi there, I am currently working on a noughts and crosses program to try and teach myself some very simple AI programming and also to start to use OOP in Python. I am currently writing the framework for the game so I can then write a number of functions or a class to deal with the strategy sid

[Tutor] Use of sqrt() from math module

2007-12-01 Thread Matt Smith
Hi, I need to find the square root of a number in a program I am writing. I have imported the 'math' module so I thought I could just call sqrt(x) but I get an error message. Extact from my code and error message below. import sys, pygame, math ... if ypos >= 384 and velocity > 0:

Re: [Tutor] Use of sqrt() from math module

2007-12-01 Thread Matt Smith
Matt Smith wrote: > import sys, pygame, math > > ... > > if ypos >= 384 and velocity > 0: > impactvel = sqrt(velocity ** 2 + (2 * gravity * (ypos - 384 * > 160))) > > ... > > > Traceback (most recent call last): > File "",

Re: [Tutor] Use of sqrt() from math module

2007-12-01 Thread Matt Smith
Michael H.Goldwasser wrote: > After using "import math" you will need to use the qualified name > math.sqrt(blah) to call the square root function. That explains the > NameError when trying to use the unqualified name, sqrt. > > As to your first message, the ValueError that you are reporting wit

[Tutor] newbie code review please!

2008-02-03 Thread Tyler Smith
Hi, I'm a middling amateur coder in C and elisp, trying to wrap my head around python syntax. I've implemented the code for the markov chain random text generator from Kernighan and Pike's "The practice of programming", and I'd appreciate any tips on how to make it more pythonic. The code appears

Re: [Tutor] newbie code review please!

2008-02-04 Thread Tyler Smith
On Sun, Feb 03, 2008 at 04:35:08PM -0500, Kent Johnson made several helpful suggestions: Thanks! That cleaned up a lot. However, I couldn't figure out a way to do random.choice(word_hash[(w1, w2)]) on a dict with set-type values. The closest I could get was word_hash[(w1, w2)].pop(), but then I n

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Tyler Smith
On 2008-02-21, bhaaluu <[EMAIL PROTECTED]> wrote: > On Thu, Feb 21, 2008 at 7:32 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: >> >> > Other beginning programers shouldn't have any problems using >> > these routines. >> >> As long as they use the same number of rooms and entrance and exit >> room

Re: [Tutor] results not quite 100 percent yet

2008-02-21 Thread Tyler Smith
On 2008-02-20, bhaaluu <[EMAIL PROTECTED]> wrote: > As far as I can see, these routines give me the results > I'm looking for. I get a distribution of four negative numbers, > four positive integers in the range 10 to 110, and nothing > is placed in room 6 or room 11: > Just for the hell of it, he

Re: [Tutor] try except continue (fwd)

2005-08-24 Thread Smith, Jeff
The problem with the original solutions is that strings are immutable so if not line.strip(): continue doesn't actually remote the new line from the end so when you do print line you get two new lines: one from the original and one from the print command. You either need import sys fo

[Tutor] Problem building Python on HP-UX

2005-09-02 Thread Smith, Jeff
I'm trying to build Python 2.4.1 on HP-UX 11.00 with full tcl/tk IDLE support. So far, I haven't had any luck. I always wind up getting errors of the form: ld: DP relative code in file /ptg/devtools/hppa1.1/pre/lib/libtk8.4.a(tkWindow.o) - shared library must be position independent. Use +z or

Re: [Tutor] Can anyone help me?

2005-10-28 Thread Smith, Jeff
Aren't the odds just based on how many tickets you buy? The odds aren't affected by different people buying more tickets. If only one person buys a ticket in the entire lottery system, his odds of winning are the same as if two people play, and the same as if 20 million play. Jeff -Original

Re: [Tutor] Can anyone help me?

2005-10-28 Thread Smith, Jeff
AMTo: Smith, Jeff; Tutor@python.orgSubject: Re: [Tutor] Can anyone help me?At 07:28 AM 10/28/2005, Smith, Jeff wrote: Aren't the odds just based on how many tickets you buy?  The odds aren'taffected by different people buying more tickets.  If only one personbuys a ticke

[Tutor] Memory Management etc

2006-05-04 Thread Philip Smith
Hi   I use Activestate Python (2.4.3) in a Windows 32 bit environment.   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 G

Re: [Tutor] Memory Management etc

2006-05-04 Thread Philip Smith
yway Phil - Original Message - From: "Alan Gauld" <[EMAIL PROTECTED]> To: "Philip Smith" <[EMAIL PROTECTED]>; Sent: Thursday, May 04, 2006 11:48 PM Subject: Re: [Tutor] Memory Management etc >> I use Activestate Python (2.4.3) in a Windows 32 bit

Re: [Tutor] Memory Management etc

2006-05-04 Thread Philip Smith
is faster (this is a time-critical application). However I may translate the current version back into modular or class form and see if the problem vanishes. Regards Phil - Original Message - From: "Danny Yoo" <[EMAIL PROTECTED]> To: "Philip Smith" <[EMAIL P

Re: [Tutor] Tutor Digest, Vol 27, Issue 12

2006-05-04 Thread Philip Smith
combo >> > > > in my email program which sent the email.) >> > > > >> > > > >> > > > > >> > > > > >> > > > > # The following will sum the numbers and then >> > print the answer >> > &

Re: [Tutor] For loop question

2006-05-10 Thread Smith, Jeff
At least with Python there's only one obvious way to do something :-) I'll see your simplification and raise (or lower) you a line. Why not simply: for item in file('hosts.txt'): tn = telnetlib.Telnet(item.strip()) Jeff -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PRO

[Tutor] Refactoring

2006-05-10 Thread Philip Smith
This is a subject which seems to pop up periodically so apoliogies but I wonder whether anyone can help:   a)    Is there yet an alternative Python refactoring tool to bicycle repair man (bike)?   b)    If not is there any documentation on the appropriate use of bike?  I can't seem to get to

[Tutor] Truly generic database API

2006-06-06 Thread Smith, Jeff
I'm looking for a truly generic database API in that the underlying DB could be text, XML, SQL engine, etc. For instance, initially, the underlying database will probably be text files but we may at some point want to move to a real database server or possibly an XML file without having to recode

[Tutor] Calling a function by string name

2006-07-21 Thread Smith, Jeff
Title: Message I have an object and I want to call a method that I have constructed the name for in a string.   For example: str_method = 'myfun' obj.str_method   Of course, this fails.  I know I could probably do this with exec but is there a better way?   For context, the specific appli

Re: [Tutor] Calling a function by string name

2006-07-21 Thread Smith, Jeff
nal Message-From: Michael P. Reilly [mailto:[EMAIL PROTECTED] Sent: Friday, July 21, 2006 1:36 PMTo: Smith, JeffCc: tutor@python.orgSubject: Re: [Tutor] Calling a function by string nameOn 7/21/06, Smith, Jeff <[EMAIL PROTECTED]> wrote: I have an object and

[Tutor] The Self

2006-07-31 Thread Sebastian Smith
I am new to Python, real new. I am loving the language and learning fast but I have hit a wall with the 'self'. I have Googled and searched and read a few definitions but it still doesn't make sense to me. I would love to hear some of your 'layman's definitions' on the self. Thank you all, Ben.

[Tutor] Python and Gecko

2006-09-20 Thread Sebastian Smith
Hello All! I am not a Python expert at all but I am learning when I have time. I am currently working my way through 'wxPython in Action' and really liking it, I have been using Learning to Program as my central text. Anyway, I was wondering if there is anyway to use the Mozilla Gecko engine in P

[Tutor] error help

2006-10-07 Thread Chris Smith
ne tell me why I'm having these error or what I can do to get around them? Chris Smith #Functions for Numerical Program #-- ### The sine and cosine integrals are taken from Abramowitz and Stegun. ### Only use the first 6 terms of the summatio

Re: [Tutor] error help

2006-10-07 Thread Chris Smith
Thanks for the help. That was the problem. I guess I'd been looking at it so long I missed that. The error message wasn't helping me either. Chris Smith Geoframer wrote: > The main problem from what i can tell is that the number of '(' and ')' > you

[Tutor] numpy help

2006-11-03 Thread Chris Smith
solve the problem while elen636_hw5_2.py is the program that I'm actually running # Purpose: # This is a library of functions for ELEN 636 that # so far has the ability to calculate the Sine and # Cosine integrals as well as the mutual impedance # between tw

[Tutor] List and comprehension questions

2007-02-25 Thread Smith, Jeff
I'm getting use to using list iteration and comprehension but still have some questions. 1. I know to replace for i in range(len(list1)): do things with list1[i] with for li in list1: do things with li but what if there are two lists that you need to access in sync. Is the

[Tutor] Another list comprehension question

2007-02-26 Thread Smith, Jeff
I'm probably missing something simple here but is there anyway to accomplish the following with a list comprehension? def get_clists(): return [1, 2, 3] def get_clist(num): if num == 1: return ['a', 'b', 'c'] if num == 2: return ['x', 'y', 'z'] if num == 3:

Re: [Tutor] Another list comprehension question

2007-02-27 Thread Smith, Jeff
-Original Message- From: Bob Gailer [mailto:[EMAIL PROTECTED] Sent: Monday, February 26, 2007 3:53 PM To: Smith, Jeff Cc: tutor@python.org Subject: Re: [Tutor] Another list comprehension question >> files = list() >Or just files = [] I tend to prefer the former since it h

Re: [Tutor] Another list comprehension question

2007-02-27 Thread Smith, Jeff
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Fouhy Sent: Monday, February 26, 2007 4:00 PM To: Smith, Jeff Cc: tutor@python.org Subject: Re: [Tutor] Another list comprehension question On 27/02/07, Smith, Jeff <[EMAIL PROTECTED]> wrote:

[Tutor] Yet another list comprehension question

2007-03-02 Thread Smith, Jeff
I find a common thing to do is l = list() for i in some-iterator: if somefum(i) != list: l.append(somefun(i)) In other words, applying somefun to the results of the iterator return duplicates but I want the constructed list to contain none. l = [somefun(i) for i some-iterator] will

[Tutor] File locking

2007-03-12 Thread Smith, Jeff
I'm always disappointed when I find something that Python doesn't handle in a platform independent way. It seems to me that file locking is in that boat. 1. I don't see a way to atomically open a file for writing if and only if it doesn't exist without resorting to os.open and specialized platfo

[Tutor] Pmw BLT help

2007-03-24 Thread Chris Smith
ror: invalid command name "::blt::vector" I've read over the installation instructions and even reinstalled the software and that didn't help any. Could anyone help me out? C. Smith ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Pmw BLT help

2007-03-25 Thread Chris Smith
Alan Gauld wrote: > "Chris Smith" <[EMAIL PROTECTED]> wrote > > >>I'm trying to learn how to use Pmw.BLT > > >>line 16, in __init__ >>self.vector_x = Pmw.Blt.Vector() >> File "C:\Python24\lib\site-packages\Pmw\Pmw

[Tutor] noob python cgi

2008-03-15 Thread Tyler Smith
Hi, I'm writing a webpage as a learning exercise. My first objective is to allow myself to upload files to directories in /images/, and have cgi scripts automatically generate the pages that will allow users to navigate through the images. I have a very basic prototype that does what I want, at l

Re: [Tutor] noob python cgi

2008-03-16 Thread Tyler Smith
On 2008-03-16, Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Tyler Smith wrote: >> Hi, >> [snip explanation] >> Three files follow. First, the html index page, followed by the >> gallery picker, followed by the thumbnail displayer. >> >> Thanks! >

[Tutor] first call - newcomer

2008-10-05 Thread Anthony Smith
This is my first post - I will be brief... One: I have programmed before - but it has been DECADES...so just a few simple queries: 1. A brief (but complete) description regarding the use of script editor (I will be using command prompt in Windows), as: a. details about loa

Re: [Tutor] Translating FORTRAN (77?) to Python?

2009-01-16 Thread Smith, Jeff
There was an add-on to the GNU C compiler for FORTRAN77 at one time (g77). I don't know if it is still available to how well it works though. Jeff From: tutor-bounces+jsmith=medplus@python.org [mailto:tutor-bounces+jsmith=medplus@python.org] On Behalf

Re: [Tutor] Fw: Installing Pyserial for Python27 on Win 7

2010-11-24 Thread John Smith
Hi, Walter - Thanks to you, pyserial is installed and imports into Python. Not having double backslashes was the latest problem that you got me through. I am grateful for the support and education you have given me. Cheers, John ___ Tutor maillist

[Tutor] Pyserial and invalid handle

2010-11-28 Thread John Smith
Can anybody tell me why the handle below is invalid? I'm running Win7. TIA, John Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import serial >>> ser = serial.Serial('com1', timeout = 5)

Re: [Tutor] Pyserial and invalid handle

2010-11-28 Thread John Smith
On 11/28/2010 10:57 AM, Emile van Sebille wrote: On 11/28/2010 7:55 AM John Smith said... Can anybody tell me why the handle below is invalid? I'm running Win7. TIA, John Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright"

Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith
On 11/28/2010 8:06 PM, Walter Prins wrote: John, (snip stuff) Ugh, you're probably not going to like this. I've done some googling and it appears this may be a 64-bit issue with the "ctypes" module... apparently "64-bit ctypes can only import 64-bit libraries". See here: http://ur.ly/vSMQ Th

Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith
On 11/29/2010 4:20 PM, Emile van Sebille wrote: On 11/29/2010 1:44 PM John Smith said... But, when I tried it in Python, I got the same as before: >>> import serial >>> ser = serial.Serial(0, timeout = 1) out of curiosity, if you change the timeout above to 5 &

Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith
On 11/29/2010 5:56 PM, Emile van Sebille wrote: (snip) Hmmm... any chance you don't have administrative rights on the account performing this? I never got to Win7 (having stopped at XP) but I know it's got a reputation for excessive permission asking. You're right about that. It's like Win7 is

Re: [Tutor] Pyserial and invalid handle

2010-11-29 Thread John Smith
On 11/29/2010 9:41 PM, Rance Hall wrote: On Mon, Nov 29, 2010 at 8:21 PM, John Smith wrote: On 11/29/2010 5:56 PM, Emile van Sebille wrote: (snip) Hmmm... any chance you don't have administrative rights on the account performing this? I never got to Win7 (having stopped at XP) but I

Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith
On 11/30/2010 10:37 AM, Walter Prins wrote: Hello John (snip) In any case, to fix it let's delete all instances of pySerial and then install it again, as follows: 1.) Open up your Python "site-packages" folder in Windows Explorer, e.g. open up: E:\Python27\lib\site-packages 2.) Delete any fol

Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith
On 11/30/2010 6:23 PM, Walter Prins wrote: Hello John, (snip) Apparently so. Well, win32file is part of the PyWin32 package, which are a set of modules that wrap many Windows API's. I'm not sure why it was't/isn't required for PySerial 2.5 or whether as you say perhaps this module is include

Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread John Smith
On 11/30/2010 7:27 PM, Adam Bark wrote: On 01/12/10 01:00, John Smith wrote: Hi, Walter - I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm guessing that the AMD versions are for the AMD processor). However, all of the exe offerings have the same "Python not found i

[Tutor] Just Joined!

2011-05-12 Thread Alex Smith
Hi All, I just joined this list and am really new to python. I have an assignment to create a function with (a_string, width) which returns the a_string with all the lower case characters changed to upper case characters and vice versa and centered; was wondering if someone could point me in th

Re: [Tutor] Just Joined!

2011-05-12 Thread Alex Smith
t input: >>> swapcase.center('hello',10) Traceback (most recent call last):   File "", line 1, in     swapcase.center('hello',10) TypeError: an integer is required From: Wayne Werner To: Alex Smith Cc: "tutor@p

[Tutor] how obsolete is 2.2?

2011-09-07 Thread c smith
I found a book at the local library that covers python but it's 2.2. I already have been using 2.7 for basic stuff and would like to know if it's worth my time to read this book. Are there any glaring differences that would be easy to point out, or is it too convoluted? Also, am I correct in thinki

[Tutor] how obsolete is 2.2, and a pickle question

2011-09-07 Thread c smith
I found a book at the local library that covers python but it's 2.2. I already have been using 2.7 for basic stuff and would like to know if it's worth my time to read this book. Are there any glaring differences that would be easy to point out, or is it too convoluted? Also, am I correct in thinki

[Tutor] making lists of prime numbers

2011-09-14 Thread c smith
hi list, i am trying the MIT opencourseware assignments. one was to find the 1000th prime. since this isn't actually my homework, I modified the solution as I would like to collect lists of primes and non-primes up to N, also some log() ratio to one comparison. here is what I came up with on paper:

[Tutor] help with a recursive function

2011-09-27 Thread c smith
hi list, i understand the general idea of recursion and if I am following well written code I can understand how it works, but when I try to write it for myself I get a bit confused with the flow. I was trying to turn an ackerman function into python code for practice and I tried writing it like th

<    1   2   3   4   5   >