Re: [Tutor] Ingenious script (IMO)

2007-08-11 Thread bob gailer
Dick Moores wrote: > At 07:13 AM 8/11/2007, bob gailer wrote: > >> Dick Moores wrote: >> >>> Here's the script that hands over change in the traditional way. >>> <http://www.rcblue.com/Misc/changeMakerKent_Traditional.py> >>> >&

Re: [Tutor] Ingenious script (IMO) CORRECTION

2007-08-11 Thread bob gailer
bob gailer wrote: >coin = coins[idx][coinCount[deno] > 1] # CORRECTION > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Decoding

2007-08-12 Thread bob gailer
Eric Walker wrote: > newbie here, > Welcome > I just tried playing around with the dec function and > I get errors. Please always post the traceback (error message), and the code you are using. > Correct me if I am wrong. After getting > the input, What input is dec() expecting? As I read it

Re: [Tutor] Finding a row match within a numpy array

2007-08-13 Thread bob gailer
Andy Cheesman wrote: > Dear nice people > > I'm trying to match a row (b) within a large numpy array (a). My most > successful attempt is below > > hit = equal(b, a) > total_hits = add.reduce(hit, 1) > max_hit = argmax(total_hits, 0) > answer = a[max_hit] > > where ... > a = array([[ 0, 1, 2, 3]

Re: [Tutor] Finding a row match within a numpy array

2007-08-13 Thread bob gailer
bob gailer wrote: > Andy Cheesman wrote: > >> Dear nice people >> >> I'm trying to match a row (b) within a large numpy array (a). My most >> successful attempt is below >> >> hit = equal(b, a) >> total_hits = add.reduce(hit, 1) >

Re: [Tutor] Class Attribute "Overloading?"

2007-08-15 Thread bob gailer
Vincent Gulinao wrote: > > Sorry, I just started experimenting on Python classes... > > Is there any way a reference to a class attribute > ([class].[attribute]) be treated like a method ([class].[method]())? > Attributes are objects. A method is an object. If you want to know something more spec

Re: [Tutor] KeyError list?

2007-08-15 Thread bob gailer
Rob Andrews wrote: > Is there a comprehensive list of dictionary KeyError meanings? > >>> d = {1:2} >>> d[1] 2 >>> d[2] KeyError AFAIK that's it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Problem with assigning list elements

2007-09-14 Thread bob gailer
[EMAIL PROTECTED] wrote: > I'm having a problem assigning numbers to a 2-D list. > > for the 2d list z for example, when I type in > > z[0][0]=67 > > every zeroth element of every sublist will be set to 67, instead of just > element > [0,0] being set to 67. > > If z = [[1,2],[3,4]] > > then z[0][0

Re: [Tutor] summing arrays, along a dimension

2007-09-14 Thread bob gailer
John wrote: > >>> d > array([[0, 0, 1], >[1, 2, 3], >[2, 2, 4], >[3, 6, 8]]) > >>> e=reshape((d[:,-2]+d[:,-1]),(4,1)) > >>> e > array([[ 1], >[ 5], >[ 6], >[14]]) > > is there a better way to accomplish this? Which module are you using? In APL we'd

Re: [Tutor] Replacing "source" in Bash Scripting

2007-09-28 Thread bob gailer
James wrote: > Hi. > > I'm re-writing a rather complex bash script I've been using for years > in Python. The bash script uses a relatively simple configuration > file in order to get pertinent information before it runs. The > configuration file is relatively simple: about 30 variables are

Re: [Tutor] case insensitivity

2007-09-28 Thread bob gailer
Christopher Spears wrote: > I wrote a script that checks if two strings match. > The script ignores case. > > #!/usr/bin/env python > > string_a = raw_input("Enter a string: ") > string_b = raw_input("Enter another string: ") > > if cmp(string_a.lower(), string_b.lower()) == 0: > Simpler: if s

Re: [Tutor] for vs while

2007-09-28 Thread bob gailer
James wrote: > All, > > I have a dumb question...hopefully someone can shed some light on the > difference between for and while in the situation below. > > I'm trying to iterate through a list I've created. The list consists > of a command, followed by a 'logging' message (a message printed t

Re: [Tutor] creating the equivalent of string.strip()

2007-09-30 Thread Bob Nienhuis
BTW, GMail brings up some interesting sponsored links when the subject line has string.strip in it ( :-0) On 9/30/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > > "wesley chun" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> > I'm not sure how to proceed. My biggest stumbling >

Re: [Tutor] Variables in workspace

2007-10-13 Thread bob gailer
Eli Brosh wrote: > > Hello > I am working with python interactively using IDLE. > > Since starting, I defined some variables: > s='string' > a=1 > b=[1,2] > c=1.02 > > and so on. > > Now, I want to know which variables are in my workspace. > That is, is there a command similar to "who" in MATLAB ?

Re: [Tutor] Variables in workspace

2007-10-13 Thread bob gailer
Kent Johnson wrote: > bob gailer wrote: >> The del statement is the way to delete variables. Since dir() gives >> you their names one needs use eval. >> >> for varName in dir(): >> eval 'del ' + varName > > I think del globals()[varName] would

Re: [Tutor] newbie question (teaching you to fish?)

2007-10-15 Thread bob gailer
Ramkumar Kashyap wrote: > Hi all, > > I have just started learning to program and am working through the > Beginning Python from Wrox. > > I am working through one of the examples in the books on dictionaries. > Here is the example. > > >>> menu_specials = {"breakfast" : "sausage and eggs", > ...

Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread bob gailer
Alex Ezell wrote: > I am working on building a SOAP client. Unfortunately, one of the > methods the SOAP server provides is named "import." The SOAP server is > written in PHP. > > So, my problem is that Python really doesn't like me using the word > "import" to call the SOAP method. This seems un

Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread bob gailer
Dick Moores wrote: > Please give me constructive criticism of > > 1 - lapCounter is not used. 2 - simplify: if lapTimeFlag == False: print "Total Time is", secsToHMS(totalTime) print

Re: [Tutor] Looking for suggestions for improving chessTimer.py code

2007-10-30 Thread bob gailer
I also encourage you to jump into classes. Yes there is a learning curve. It is IMHO worth it. Borrowing from Kent Johnson: class Player(object): def __init__(self, name, moveCounter, remainingTime): self.name = name self.moveCounter = moveCounter self.remainingTime = remaining

Re: [Tutor] perplexing error with shelve REVISED

2007-10-30 Thread Bob Gailer
Orest Kozyar wrote: > I have a program which queries an online database (Medline) for XML data. > It caches all data using shelve to avoid hitting the database too many > times. For some reason, I keep getting a RuntimeError: maximum recursion > depth exceeded when attempting to add a certain reco

Re: [Tutor] perplexing error with shelve

2007-10-30 Thread bob gailer
Orest Kozyar wrote: > I have a program which queries an online database (Medline) for XML data. > It caches all data using shelve to avoid hitting the database too many > times. For some reason, I keep getting a RuntimeError: maximum recursion > depth exceeded when attempting to add a certain reco

Re: [Tutor] dictionary append

2007-11-01 Thread bob gailer
Dinesh B Vadhia wrote: > Hello! I'm creating a dictionary called keywords that has multiple > entries each with a variable list of values eg. > > keywords[1] = [1, 4, 6, 3] > keywords[2] = [67,2] > keywords[3] = [2, 8, 5, 66, 3, 23] > etc. > > The keys and respective values (both are integers

Re: [Tutor] Elegant argument index sort

2007-11-08 Thread bob gailer
Dinesh B Vadhia wrote: > I'm sorting a 1-d (NumPy) matrix array (a) and wanting the index > results (b). I can't tell from your comments and code what you want. Please provide a better explanation and give an example of input and output numbers. Also I am not familiar with argsort. > This is wh

Re: [Tutor] parsing an array

2007-11-13 Thread bob gailer
Aditya Lal wrote: > [snip] > for i in a[:] will make i point to the elements of the list To be more precise: a[:] is a copy of the list the for statement assigns each list element in turn to i. Assign is not exactly the same as point. ___ Tutor maillis

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread bob gailer
Mihai Iacob wrote: Hello, I was wondering if there is a way to import modules using the input() command. If i try to do it directly it gives me an error: input() import time The input function takes a character string and attempts to

Re: [Tutor] repeat

2007-11-17 Thread bob gailer
Michael wrote: > Hi All > > This has probably been asked before but can I get some clarification on > why Python does not have a repeat...until statement, and does that mean > repeat...until is bad practice? I was trying to get Python on the > standard langauge list for my state secondary school

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

2007-11-23 Thread bob gailer
elis aeris 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. > > > i just need to send text alone, and then code it best kept simple, > > is this possible to do with python? see

Re: [Tutor] python 2.4 reading files - unexpected behaviour

2007-11-23 Thread bob gailer
John Gerdeman wrote: > Hello, > > I got a csv file, in which I have to count the occurrences of certain > numbers in columns. I can do this for one arbitrary column, but not for > all. > > The problem I encountered is as follows. Iterating through the rows of a > file works, but as soon as I try t

Re: [Tutor] error binding parameter 1

2007-11-24 Thread bob gailer
Dinesh B Vadhia wrote: > Hello! Can anyone see what the problem with this code snippet is? > > Dinesh > > > image_filename = str(dir_list[i]) > image_file = dir_path + image_filename >

Re: [Tutor] pipeline - what is it and how do I use it?

2007-11-25 Thread bob gailer
elis aeris wrote: > I need to keep a bit of python code ready to run at anytime, in the > ram, but this is what I need to do > > I am using two languages at the same time, because python doesn't > really have any effective way of simulating keyboard and mouse events, > > so I need to run auto it

Re: [Tutor] (no subject)

2007-11-27 Thread bob gailer
Latasha Marks wrote: > Design a program to keep track of the scores of bowlers as they bowl a > game. The program must prompt each bowler to bowl. The program begins > by allowing the bowlers to enter their names. Each frame is tracked > and properly displayed as the game progresses. I agree wit

Re: [Tutor] List processing question - consolidating duplicate entries

2007-11-27 Thread bob gailer
Richard Querin wrote: > I'm trying to process a list and I'm stuck. Hopefully someone can help > me out here: > > I've got a list that is formatted as follows: > [Name,job#,jobname,workcode,hours] > > An example might be: > > [Bob,07129,projectA,4001,5]

Re: [Tutor] windows api

2007-12-02 Thread bob gailer
elis aeris wrote: > this code uses windows api, but where do I find documentation about > how to use them? Hmm - looks like something from Experts Exchange. If you are asking for the Windows API Reference, try: http://msdn2.microsoft.com/en-us/library/aa383749.aspx ctypes is a Python module tha

Re: [Tutor] windows api

2007-12-02 Thread bob gailer
elis aeris wrote: > i know that site, i program in c++ on windows. > > however, the syntax in different. how do I find out python's way of > using it? This is a ctypes question; See http://python.net/crew/theller/ctypes/ especially the Documentation links. ___

Re: [Tutor] help

2007-12-03 Thread bob gailer
Andrew Critchley wrote: > I recently downloaded the newer version of python, the 2.5.1 one, and > when ever i try to make an input what ever i type into the brackets > appears on the next line and when i try to add the next line it > carries on from the input,This is what happens: > > I type t

Re: [Tutor] How to iterate and update subseqent items in list

2007-12-06 Thread bob gailer
ted b wrote: > Can you suggest a good way to iterate through the > remainder of list and update them? > > Ex: > Thing1.value = 0 > Thing2.value = 1 > Thing3.value = 0 > Thing4.value = 0 > > Things = [Thing1, Thing2, Thing3, Thing4] > > I want to iterate through 'Things' and if > 'Thing.value' > 0,

Re: [Tutor] Still Can't Find Timed While Loops

2007-12-07 Thread bob gailer
earlylight publishing wrote: > Hello all, > > I now have my bit of code in while loop form and it works! It's great > but not exactly what I wanted to do. I've been googling my heart out > and I find lots of info on while loops and lots of info on timers that > will execute an action AFTER a

Re: [Tutor] Still Can't Find Timed While Loops

2007-12-07 Thread bob gailer
bhaaluu wrote: > On Dec 7, 2007 10:41 AM, bob gailer <[EMAIL PROTECTED]> wrote: > >> earlylight publishing wrote: >> >>> Hello all, >>> >>> I now have my bit of code in while loop form and it works! It's great >>> but

Re: [Tutor] Parsing DICOMRT file

2007-12-11 Thread bob gailer
Bryan Fodness wrote: > I am trying to parse a DICOMRT file, which is a radiation therapy > DICOM file. > > First, I get different outputs from the two methods below. > > for line in file('file.dcm', 'rb'): > print line > > inp = open('file.dcm', 'rb') > print inp.readlines() I agree.

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread bob gailer
jon vs. python wrote: > Hi everyone, > I have a file with this content: > > "1 > 1 > 1 > 1 > 1 > 1 > 1 > 2 > 1 > 1" > > I wanted a little script that would print the line containing "2" and > every line containing "1" after it. I've tried this: > > >>> def p(): > f = file("prueba.txt",'r') >

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread Bob Gailer
[snip] now ponder this: f=file("prueba.txt.log") for startline in f: if startline.find("2") != -1: for endline in f: print endline # etc. ___ Tutor maillist - Tutor@python.org htt

Re: [Tutor] Nested, line by line, file reading

2007-12-16 Thread bob gailer
Luis N wrote: > On Dec 16, 2007 10:17 PM, jon vs. python <[EMAIL PROTECTED]> wrote: > >> Hi everyone, >> I have a file with this content: >> >> "1 >> 1 >> 1 >> 1 >> 1 >> 1 >> 1 >> 2 >> 1 >> 1" >> >> I wanted a little script that would print the line containing "2" and every >> line containing "1

Re: [Tutor] constants, flags or whatever

2007-12-19 Thread bob gailer
Jim Morcombe wrote: > In a program, I want to set some kind of variable or object to > indicate what "mode" the program is currently in. > What is the most elegant way of doing this? > > Jim > --- > constant: moving = "m" >

Re: [Tutor] Using 'join ' function to create a string

2007-12-21 Thread bob gailer
lechtlr wrote: > Hi there, > > I would like to know what is the best way to create a string object > from two different lists using 'join' function. For example, I have X > = ['a', 'b', 'c', 'd', 'e'] and Y = [1, 2, 3, 4, 5]. From X and Y, I > want to create a string Z = 'a:1, b:2, c:3, d:4, e:5

Re: [Tutor] python CLI parser

2007-12-21 Thread bob gailer
Martin Marcher wrote: > Hello, > > could you have a short review of my CLI package. > .bz2??? What does that extension mean? (For us Windows folk). Or could you attach a simple zip file? [snip] ___ Tutor maillist - Tutor@python.org http://mail.pyt

Re: [Tutor] war cards

2007-12-24 Thread bob gailer
max baseman wrote: > hello all, i have been rolling the idea of writing a simple script to > play the classic card game war. i thought it would be good for me > because their is no skill in the game. while thinking of how to write > it i got stuck on one bit, how do i make it so that their is

Re: [Tutor] How Do I Make Imports Work

2007-12-27 Thread bob gailer
[EMAIL PROTECTED] wrote: > Hi, > Here is the offending code and error. > > # elevator_system.py > # By Jim Homme > # Simulate the behavior of a group of elevators. > # Try to import and get error. > # The module and this file are in the same directory. > import elevator > # The elevator module > #

Re: [Tutor] Microsoft Access

2007-12-27 Thread bob gailer
Jim Morcombe wrote: > Are there any simple tutorials on using MS Access from Python? Your question is ambiguous. Do you want to manipulate the data using SQL or do you want to open an Access session as a COM server and control it? ___ Tutor maillist -

Re: [Tutor] is it legal to have a class within a def

2008-01-02 Thread bob gailer
johnf wrote: > def someMethod(): >class MyClass(object): >. > if something: > . > return someval > > Legal? Well the police won't come after you! Python allows a class statement anywhere. So this use is part of the language. So the question becomes "why

Re: [Tutor] Review and criticism of python project

2008-01-03 Thread bob gailer
GTXY20 wrote: > > Hello all, > > Is there a forum or group where I can upload my python project for review? Others on this list can guide you to web sites for uploading code. If the program is relatively small you can just email it to this list as body text. How small? For me I'd rather wade thru

Re: [Tutor] Review and criticism of python project

2008-01-04 Thread bob gailer
GTXY20 wrote: > > There are no errors per se - the script is doing what it needs to I > guess I just want to check it for compliance - for some reason I think > itis a mess and should be much cleaner. > > I am only concerned with one particular area of the complete project - > it is 229 line

Re: [Tutor] classes and the deepcopy function

2008-01-05 Thread bob gailer
Michael wrote: > Hi Michael > > Thanks for the quick reply, I think I get it. So becuase I did not > declare them withing the init method using self they are shared by every > object that is created, even completely brand new ones? > > Is it normal practice to declare your variables in a class? I

Re: [Tutor] classes and the deepcopy function

2008-01-06 Thread bob gailer
Michael wrote: > Okay > > Just when I think I am getting it you throw this in. You're welcome. > So why does a become local to each variable but b seem global? > A better way to ask that is "why does a become an instance property but b remain a class property?" f.a = 3 This is an assignment

Re: [Tutor] Urgent: Help

2008-01-07 Thread bob gailer
? Are you overwhelmed with life and struggling to get through? Or do you just want to get a passing grade and don't care about learning programming and Python? It might help us if we understood why you are seeking help. Bob ___ Tutor maillis

Re: [Tutor] Urgent: Help

2008-01-07 Thread bob gailer
Please reply to the list not just me. We all participate and learn. Shumail Siddiqui wrote: > I know this assignment is not too hard, but I have been greatly > overwhelmed with work as I have been taking a 19 credits recently. I > kind of have an approach to this by importing random numbers and

Re: [Tutor] New 2 Python- Script 'kill' function/Ubuntu File Browser hide hidden files

2008-01-13 Thread bob gailer
Ian Egland wrote: > Hello, I am new to Python (and OO programming in general) and I have a > script that I made through a tutorial. > > # -*- coding: utf-8 -*- > # Copyright (C) 2007-2008 Ian Egland > # From the Non-Programmer's Guide to Python By Josh Cogliati > # 5.3 Exercise 1 > # Modify the pa

Re: [Tutor] Reading Input Data

2008-01-15 Thread bob gailer
list to x then you can refer to x[0], x[1], ...x[n]. Also you have created lists within your list, to no apparent purpose; Consider: x = [float(line.split(',')[1]) for line in open("file.csv")] Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] tree/node class/module

2008-01-15 Thread bob gailer
oked up the links therein but the titles sound promising. We could roll our own if all else fails. [snip] Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] A faster x in S

2008-01-15 Thread bob gailer
set is 1000 times faster than list! >>> f(6499,100,d) 0.31300020217895508 And dict is (as expected) about the same as set. So 100,000,000 lookups should take about 30 seconds. Not bad, eh? Let's explore another angle. What range are the integers in (min and max)? Bob ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Programming Ideas, need some focus

2008-01-16 Thread bob gailer
pipetest.test("Short") pipetest.test("Longer than 10") Running the above should display: 5 Short 14 Is that clear? Is that interesting? There are a lot of stages to be developed; many of them are much more complex, so this could provide for a step-by-step evolution of your skills.

Re: [Tutor] Interview questions in python and wxpython

2008-01-19 Thread bob gailer
Varsha Purohit wrote: > Hello All, >I have an interview in python program development. Can i know > some interview questions in python ? If you know any website where i > can refer that would be helpful. My first engineering job interview went thus: "We need someone to help us design ant

Re: [Tutor] Interview questions in python and wxpython

2008-01-19 Thread bob gailer
Jeff Younker wrote: >> Your meta-mission is to propose ideas, state assumptions and ask >> questions. >> > > Is the track infinite in the sense that it resides on an infinite > plane yes > , or is it infinite > in the sense that it is circular, wrapping around the entire planet > and mee

Re: [Tutor] Interview questions in python and wxpython

2008-01-19 Thread bob gailer
Ricardo Aráoz wrote: > > Ok, I'll bite. > First, the instructions make no sense. There is no left and right! In a > railroad there is forward and backwards, and these are relative to the > directions the cars dropped at which I assume will be random. So "move > fwd" has the same meaning as "move bc

Re: [Tutor] Projects (fwd)

2008-01-23 Thread bob gailer
Danny Yoo wrote: > [snip] > First, it ignores zero, which is a cardinal sin. Or is it an ordinal sin? [snip] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutor Digest, Vol 47, Issue 64

2008-01-24 Thread bob gailer
[EMAIL PROTECTED] wrote: > Stop sending your mails > > Send Tutor mailing list submissions to > >> tutor@python.org >> Did you notice the instructions that appeared at the top of what you just sent? Only you can manage your subscription. >> To subscribe or unsubscribe via the World

Re: [Tutor] Hi

2008-01-25 Thread bob gailer
Firoze Khan wrote: > Hi, > I want Tutors mailing List If you want to subscribe visit: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] replacing range with xrange

2008-01-28 Thread bob gailer
Kent Johnson wrote: > bob gailer wrote: > > >> I disagree based on PEP 3100 (http://www.python.org/dev/peps/pep-3100/) >> >> Built-in Namespace: >> - Make built-ins return an iterator where appropriate (e.g. range(), >> zip(), map(), filter(), etc.)

Re: [Tutor] replacing range with xrange

2008-01-28 Thread bob gailer
(e.g. range(), zip(), map(), filter(), etc.) To be removed: - xrange(): use range() instead -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] replacing range with xrange

2008-01-28 Thread bob gailer
an iterator and range > returning a list. That seems to me more in keeping > with the names too. > FWIW on my computer l = range(3000) takes under 0.19 seconds l = list(xrange(300)) under 0.27. So I don't think performance is an issue. -- Bob Gailer 919-636-4239 Ch

Re: [Tutor] [tutor] Question on multithreading

2008-01-29 Thread bob gailer
ed response time code behind the pause/resume button: pause = not pause # toggle if not pause: cond.notify() -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] results not quite 100 percent yet

2008-01-30 Thread bob gailer
tore room instances in the destinations rather than indexes. At this point you no longer need indexes! -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to compare the first line from multiple files

2008-01-31 Thread bob gailer
e all in the same directory. >> I know what the first line should be (or I can take the first line >> from the first file as the reference.) -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question regarding list editing (in place)

2008-02-05 Thread bob gailer
tem > that starts with X." > dirs = [dir for dir in dirs if not dir.startswith(u'.')] -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] designing POOP

2008-02-07 Thread bob gailer
Also beware the difference between reassigning and extending: class F: a = 3 b = [] def __init__(self, a, b): self.a = a self.b.append(b) def show(self): print self.a, self.b f1=F(1,2) f2=F(3,4) f1.show() # 1 [2, 4] f2.show() # 3 [2, 4] -- Bob Gailer 919-636-4239 Chapel

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

2008-02-11 Thread bob gailer
se: > ... y = {'id': 'name', 'link': 'YY'} > ... list.append(y) > ... > > I would like to change the key 'link' value depending on the value of > 'total' so for example if t

Re: [Tutor] [Python-Help] [EMAIL PROTECTED]

2008-02-11 Thread bob gailer
en no break happens. In the second else pairs with if and is invoked each time the divisor test fails. If that does not help you decide which is correct (it should) then run the 2 programs examine the results and that should reveal which gives you what you want. -- Bob Gailer 919-636-4239 Cha

Re: [Tutor] Closing file objects when object is garbage collected?

2008-02-12 Thread bob gailer
t the interface to the file contents. > into a string > and close the file immediately because the files can potentially be > large, and I'm dealing with many files at a time. > > -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tu

Re: [Tutor] Binary chop function - this works, but I'm not sure why

2008-02-14 Thread bob gailer
0 or 1 as the index? I > think there is something about recursion here that I'm not fully > comprehending. > > > > > > _______

Re: [Tutor] most efficient way to do this

2008-02-14 Thread bob gailer
Alan gave the "best" answer. FWIW I offer an intermediate improvement: for location in locations: new_loc.append(location + add_on) -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Suggestions to improve this first effort?

2008-02-16 Thread bob gailer
ntinue > elif s==".endblock": > s="\n" > s2=s2[:-1]+s > f2.write(s2) > s2="" > continue > s2=s2+"\""+s+"\"&qu

Re: [Tutor] Noob requesting help...

2008-02-16 Thread bob gailer
Marc Tompkins wrote: > John, Luke, Marc... can we get a Matthew to join this thread? You thinking of Matthew Dixon Coles? But then wouldn't Paul want to get into the Act? -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist

Re: [Tutor] Noob requesting help...

2008-02-18 Thread bob gailer
This seems to focus on the NT, but from a Python Tutor List perspective I think we are OT. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Change mouse cursor position

2008-02-19 Thread bob gailer
ftware? Or are you trying to control the mouse in another application? > > O.S. Linux Debian Sid > Python: 2.4=< -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Change mouse cursor position

2008-02-19 Thread bob gailer
e. If not please explain your situation in more detail. And in future questions please give the relevant details in the original posting. Discovery processes like this are costly to everyone involved. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-19 Thread bob gailer
s, or running in an "infinite loop". So which is it or is it something else? -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-19 Thread bob gailer
Tony Cappellini wrote: > On Feb 19, 2008 2:02 PM, bob gailer <[EMAIL PROTECTED]> wrote: > >> Tony Cappellini wrote: >> >>> When I executing a program external to the main program in a thread, >>> and that thread hangs, can the thread be terminat

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-24 Thread bob gailer
on your own computer. Can you do that? Do you know how? When you run it you will discover an error. Fix that and try again. [snip] -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code) WAIT!!!

2008-02-24 Thread Bob Gailer
Hold the phone! Ignore previous email. Working... -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-24 Thread Bob Gailer
OK I maintain what I wrote earlier: Did you run the code yourself? It would appear that you did not. Before submitting to an online judge run the code on your own computer. Can you do that? Do you know how? When you run it you will discover an error. Fix that and try again. [snip] -- Bob

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-24 Thread bob gailer
Andrei Petre wrote: > Hello, > > I wrote a code for a problem and submitted to an online judge url please, and link to the specific problem -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.p

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-26 Thread bob gailer
er is or which test case it is in but there is at least one bad character, and it is < chr(32) (i.e. a control character). After revising my program to eliminate these bad characters I now get wrong answer. So now I revise my algorithm. -- Bob Gailer 919-636-4239 Chap

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-26 Thread bob gailer
,5,8) otherwise if possible remove 2 digits (the lower the better) (the candidates are, for r ==2-1,4,7 r==1-2,5,8) otherwise impossible checkout: if we removed a '5' from the list, append it join and print the list -- Bob Gailer 919-636-4239 Chapel Hill, NC _

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-26 Thread bob gailer
er is or which test case it is in but there is at > >least one bad character, and it is < chr(32) (i.e. a control character). > >i don't understand , in your > > i don't really understand that. you are trying to say that the tests > from the online judge are not &qu

Re: [Tutor] crashed with Runtime Error: NZEC (non-zero exit code)

2008-02-27 Thread bob gailer
tion times off the results page. Eventually one might garner enough information. Of course that might get the attention of the site operators and lead to a change in how things are run to discourage automated testing. -- Bob Gailer 919-636-4239 Chapel Hill, NC __

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

2008-03-01 Thread bob gailer
or __len__() method, when that method returns the integer zero or bool value False.3.1 All other values are considered true -- so objects of many types are always true. -- Bob Gailer 919-636-4239 Chapel Hill, NC ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help with slice

2008-03-04 Thread bob gailer
t (which are lists), return the > third item. > That is wishful reading. No basis in reality. List[:] gives you a shallow copy of List. [2] then refers to the 3rd element of that copy. Try: [sublist[2] for sublist in List] -- Bob Gailer 919-636-4239 Chapel Hill, NC _

Re: [Tutor] help with slice

2008-03-04 Thread bob gailer
bob gailer wrote: > washakie wrote: > >> Could someone please explain 'slices' also for dictionaries? >> >> basically, I'd like to know how you would call every 3rd element in a list >> of lists... >> Call? Do you mean that these elemen

Re: [Tutor] hello can you help me solve this problem

2008-03-05 Thread bob gailer
esign) you've written and tell us where you are stuck we are glad to help. > Also, I don't quite understand how this works. Do you e mail me with your > response or is there a website I need to visit to see my question and your > response posted? > We email you and the tutor

Re: [Tutor] Const on Python

2008-03-05 Thread bob gailer
le > to help :-) > > best regards > > katcipis > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- Bob Gailer 919-636-4239 Chapel Hill, NC _

Re: [Tutor] Problem with Learning Python example

2005-08-11 Thread Bob Gailer
will be yours, >faithful and true, to the last beat of his heart. You owe >it to him to be worthy of such devotion."-- Unknown > > (Best viewed with a mono-spaced font.) > >-BEGIN PGP SIGNATURE- >Version: GnuPG v1.2.7 (GNU/Linux) > >iD8DBQ

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