Re: [Tutor] Fwd: Need mentor

2010-08-09 Thread bob gailer
Exactly what do you want your mentor to do? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] problem loading and array from an external file

2010-08-09 Thread bob gailer
e() print("from MAIN") print(room_final) print() print("a PRINT_MAP call from MAIN") print_map() print() print() === partial sample output showing the current incorrect results: a PRINT_MAP call from MAIN +-+ |

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread bob gailer
it by hand. In fact, I think I will process the loop entirely by hand, just the logic, and see how the variables look that way. Glad I could help. PLEASE remember to always reply-all so a copy goes to the list. Thanks, Bill On Mon, Aug 9, 2010 at 10:08 PM, bob gailer wrote: On 8/9/20

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread bob gailer
textf] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] box drawing characters

2010-08-17 Thread bob gailer
On 8/17/2010 12:30 AM, Bill Allen wrote: I am looking for some guidance about how to best utilize box drawing characters(using unicode?) in as portable a way as possible in Python. Any good guides out there for this? Please tell us a bit more about your goals. -- Bob Gailer 919-636-4239

Re: [Tutor] List comprehension for dicts?

2010-08-20 Thread bob gailer
arly of for-loops, but not list comprehensions. The whole point is with a list comp, you're forced to iterate over the entire sequence, even if you know that you're done and would like to exit. Take a look at itertools.takewhile! result = [i%2 for i in itertools.takewhile(lamda x:i< 10, seq)]

Re: [Tutor] design of Point class

2010-08-20 Thread bob gailer
self[0] if len(self) == 2: self.y = self[1] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] design of Point class

2010-08-20 Thread bob gailer
def set(self, ix, value): if len(self)>= ix + 1: self[ix] = value else: raise AttributeError def getx(self): return self.get(0) def setx(self, value): self.set(0, value) x = property(getx, setx) def gety(self):

Re: [Tutor] design of Point class

2010-08-20 Thread bob gailer
raise AttributeError return g def set(ix): def s(self, value): if len(self) >= ix + 1: self[ix] = value else: raise AttributeError return s x = property(get(0), set(0)) y = property(get(1), set(1)) z = property(get(2), set(2)) -- Bob Gail

Re: [Tutor] design of Point class

2010-08-21 Thread bob gailer
On 8/20/2010 8:35 PM, bob gailer wrote: After yet more thought it gets even more better: I even added a unit test. class PointND(list): def __init__(self, *a_list): super(PointND, self).__init__(a_list) def getSet(ix): def chklen(self): if len(self) < ix + 1: ra

Re: [Tutor] newline problem

2010-08-21 Thread bob gailer
very digit is placed on another line. How can I prevent this ? print int(digit2), # add a comma Your algorithm is unnecessarily complicated. You don't need to count first. You don't need float. getal=13789 while getal > 0: getal, digit = divmod(getal, 10) print digit, But it is

Re: [Tutor] continuous running of a method

2010-08-23 Thread bob gailer
e. I would think this would be done with a while loop, but can't seem to get the details right. Even though a while will work, you will have tied up the CPU until the loop terminates. This is never a good idea. What is your higher level goal? -- Bob Gailer 919-636-4239 Chap

Re: [Tutor] design of Point class

2010-08-23 Thread bob gailer
On 8/23/2010 1:09 PM, Gregory, Matthew wrote: Bob Gailer wrote: class PointND(list): def __init__(self, *a_list): super(PointND, self).__init__(a_list) def getSet(ix): def chklen(self): if len(self)< ix + 1: raise AttributeError def get(s

Re: [Tutor] design of Point class

2010-08-23 Thread bob gailer
tSet(1, 'y') z = getSet(2, 'z') p = PointND(1,2,3) assert (p.x, p.y, p.z) == (1, 2, 3) p.x = 6; p.y = 9; p.z = 5 assert (p.x, p.y, p.z) == (6, 9, 5) try: p = PointND(1,2) p.z = 3 except AttributeError: print 'Passed all tests' -- Bob Gailer 919-636-4239 Ch

Re: [Tutor] exercise problem

2010-08-27 Thread bob gailer
help. How does this sound to you? Will you give it a try? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help, complete beginner please!

2010-08-27 Thread bob gailer
7;S', then enter = Door to the South." print "'E', then enter = Door to the East." print "'W', then enter = Door to the West." print "'Look at', then 'objects name'

Re: [Tutor] help, complete beginner please! CORRECTION

2010-08-28 Thread bob gailer
massive crystal chandelier. In front of you is round stone fountain, spewing water.""" return description -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] project euler prime factorization problem

2010-08-29 Thread bob gailer
python is just too advanced for me. I understand a lot of the teachings, but the examples seem unwieldy and esoteric. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Newbie - regex question

2010-08-30 Thread bob gailer
1-emai...@domain.com" To "stuff more stuff still more stuff word2-emai...@domain.com stuff after WORD2 " The following did not work newl = re.sub (r'WORD1-.*',"",line) Please remember to explain "did not work". Did you get an exception? Did you get

Re: [Tutor] Giving a name to a function and calling it, rather than calling the function directly

2010-09-04 Thread bob gailer
print "The coin landed on tails " + str(tosses - heads) + " times \n" print "The coin landed on heads " + str(heads) + " times \n" Or even simpler: import random tosses = 100 heads = sum(random.randint(0,1) for i in range(tosses)) print ... -- Bob Gai

Re: [Tutor] Arguments from the command line

2010-09-06 Thread bob gailer
int sys.argv $hg commit "This is a commit name" ['C:\\hg.py', 'commit', 'This is a commit name'] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] sort problem

2010-09-08 Thread bob gailer
On 9/8/2010 1:12 PM, Roelof Wobben wrote: If I understand it right You don't. What does "put two strings into 1 string" mean. Provide an example. What does the documentation say about join? What part of that do you not understand? -- Bob Gailer 919-636-4239

Re: [Tutor] exceptions problem

2010-09-10 Thread bob gailer
x , "is not a positive integer.Try again." return -1 return x y = readposint() print y while y == -1: readposint() print "You have entered : ", y > > Roelof Francesco Thank you. I never thought that you can use a float and a integer to look if the numbe

Re: [Tutor] exceptions problem

2010-09-11 Thread bob gailer
On 9/11/2010 6:56 AM, Peter Otten wrote: Steven D'Aprano wrote: On Sat, 11 Sep 2010 09:56:41 am bob gailer wrote: I never thought that you can use a float and a integer to look if the number is a integer. You can't. I made that comment in the context of the OPs function: def

Re: [Tutor] exceptions problem

2010-09-11 Thread bob gailer
1 Sep 2010 09:56:41 am bob gailer wrote: I never thought that you can use a float and a integer to look if the number is a integer. You can't. I made that comment in the context of the OPs function: def readposint(): x = raw_input("Please enter a positive integer :") try: if (

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
getting a different result. Here is where using the debugger and going step by step can help. I have no experience with the IDLE debugger. Perhaps others can offer advice on that. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Fwd: RE: wierd replace problem

2010-09-13 Thread bob gailer
Forwarding to the list. Date: Mon, 13 Sep 2010 11:07:19 -0400 From: bgai...@gmail.com To: tutor@python.org Subject: Re: [Tutor] wierd replace problem On 9/13/2010 8:19 AM, Roelof Wobben wrote: Hello, I h

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
On 9/13/2010 12:58 PM, Roelof Wobben wrote: The orginal text can be found here : http://openbookproject.net/thinkcs/python/english2e/resources/ch10/alice_in_wonderland.txt There are no \ in that text! -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] wierd replace problem

2010-09-13 Thread bob gailer
ters ... Split into words (not letters?) where word is defined as Count the frequency of each word. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/m

Re: [Tutor] FW: wierd replace problem

2010-09-13 Thread bob gailer
her it is the beginning of a word, the end of a word, within a word, or outside any word. Take the beginning of the alice file, and BY HAND decide which category the first character is in. Then the 2nd. etc. That gives you the algorithm, Then translate

Re: [Tutor] working with empty lists

2010-09-15 Thread bob gailer
happend to the 0. 1 line It works for me (after adding : at the end of the for statements, and a parenthesis at the end of the print call). >>> l = [] >>> for i in range(0,10) ...l.append(i+1) ... >>> for i in range(0,10) ...print('%s. %s' % (i, l[i])

Re: [Tutor] Remove a dictionary entry

2010-09-17 Thread bob gailer
erence /6.8 Mapping Type - dict /it tells you the answers to 1 and 5. In the Python Reference /6.6.4. Mutable Sequence Types/ it tells you the answer to 3. In the Python Reference /5.9 Comparisons/ it tells you the answer to 4. Regarding 3 there are several ways to loop through a sequence. Tuto

Re: [Tutor] Function behavior

2010-09-17 Thread bob gailer
= 0 if match == 3: amount = 3 [snip] How about: def change(amount, amts={1:0, 2:0, 3:3}): return amts[match] -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] Remove a dictionary entry

2010-09-17 Thread bob gailer
: Python v2.6.4 documentation - The Python Standard Library - 6.8 Mapping Type - dict you will see d[key] - compare that to what you wrote in version 2. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] Remove a dictionary entry

2010-09-17 Thread bob gailer
lso note the warning "Using iteritems() while adding or deleting entries in the dictionary may raise a RuntimeError or fail to iterate over all entries." You should get a list rather than an iterator of all key-value pairs then iterate over that list. -- Bob Gailer 919-636-4239 C

Re: [Tutor] Remove a dictionary entry

2010-09-18 Thread bob gailer
Yet another way is to iterate thru the dict collecting a list of keys of items to be deleted. Then iterate thru that list deleting from the dict. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] next class problem

2010-09-18 Thread bob gailer
and p2 are preferred to P1 and P2. Also why not initialize x and y thus: p1 = Point(3,3) That is what the __init__ is for. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription opt

Re: [Tutor] Opening C++ binary files

2010-09-21 Thread bob gailer
= open(filename, mode='wb') Did you mean "rb"? OP says files were written by another program. will open the file. Do you have any documentation on the file structure? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist -

Re: [Tutor] Getting/setting attributes

2010-09-21 Thread bob gailer
n self._address @address.setter #use the property.setter decorator on this method def address(self, addrvalue): self._address = addrvalue computer1 = Computer() computer1.address = "test" print computer1.address -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] list.append(x) but at a specific 'i'

2010-09-21 Thread bob gailer
On 9/21/2010 6:30 PM, Norman Khine wrote: a = ['a', 'b', 'e'] >>> b = ['c', 'd'] i want to put the items of 'b' at [-2] for example. >>> a[-2:-2]=b >>> a ['a', 'c', 'd', &#x

Re: [Tutor] inheritance problem

2010-09-30 Thread Bob Gailer
Sorry I hit the send button instead of the save button On Thu, Sep 30, 2010 at 2:58 PM, Bob Gailer wrote: > On Thu, Sep 30, 2010 at 2:38 PM, Roelof Wobben wrote: >> >> hello, >> >> Im following this page : >> http://openbookproject.net/thinkcs/python/english2e/

Re: [Tutor] Coin Toss Problems

2010-10-02 Thread bob gailer
sensitive? -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] list comprehension, efficiency?

2010-10-02 Thread bob gailer
[snip] I ran dis on a for loop and the equivalent comprehension. I was surprised to see almost identical code. I had assumed (and now wish for) that a comprehension would be a primitive written in C and thus much faster! -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] list comprehension, efficiency?

2010-10-03 Thread bob gailer
On 10/2/2010 8:02 PM, Steven D'Aprano wrote: On Sun, 3 Oct 2010 01:17:39 am bob gailer wrote: I ran dis on a for loop and the equivalent comprehension. I was surprised to see almost identical code. I had assumed (and now wish for) that a comprehension would be a primitive written in

Re: [Tutor] how to extract data only after a certain condition is met

2010-10-10 Thread bob gailer
ging operation from the contents of a document. As you can imagine, I'm pretty green in Python programming and I was hoping the learn by doing method would work. I need to get on with this project, though, and I'm kind of stuck. Any help you guys can give

Re: [Tutor] SQLite3 DB Field Alphabetizing

2010-10-12 Thread bob gailer
7;test4', 'test5', 'test6', 'test7', 'test7uyuy', 'test8', 'test9', 'testgraph', ';s;juf;sfkh', 'zzrerhshhjrs'] My question is, why is everything except [:-2] in alphabetical order? It doesn't really ma

Re: [Tutor] join question

2010-10-14 Thread bob gailer
ur homework and post useful information. Else I will disappear from your life. But maybe you will appreciate that? (It took me less than a minute to spot the problem. You too can gain that skill, but it will take work.) -- Bob Gailer 919-636-4239 Chapel Hill NC

Re: [Tutor] URL test function.

2010-10-22 Thread bob gailer
ursion. A loop is appropriate here. while True: try: urllib2.urlopen('http://'+env.host_string+'\:8080') except urllib2.URLError: time.sleep(10) else: break -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor ma

Re: [Tutor] Problem Passing VARs to Python from PHP & capturing return string

2010-10-22 Thread bob gailer
on must be in quotes (due to the space in the path). I don't know enough Perl to tell you how to do this. In Python I would: command = '"C:\Program Files\Python26\python.exe" include/weatherFeed.py -c %s -s %s' % (city, state)

Re: [Tutor] if statement

2010-11-02 Thread bob gailer
tions: http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] query result set

2010-11-09 Thread bob gailer
When starting a new subject, please start with a new email. Do not "hijack" an existing one, as that causes your query to appear as part of the hijacked thread. -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@pyt

Re: [Tutor] While Loops: Coin Flip Game :p:

2010-11-16 Thread bob gailer
Just for the heck of it: heads = sum(random.randrange(2) for i in range(100)) -- Bob Gailer 919-636-4239 Chapel Hill NC ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo

Re: [Tutor] Help regarding lists, dictionaries and tuples

2010-11-21 Thread bob gailer
es and going at it that way, but since the challenge is listed in a chapter dealing with Lists and Dictionaries (and tuples), I figure there should be some way to solve it with those tools. -- Bob Gailer 919-636-4239 Chapel Hill NC ___

Re: [Tutor] Program to report if file was modified today

2009-02-11 Thread bob gailer
s in /home/david Why do both the if and else get printed? How do I do this without all the if statments? I don't understand the if modtime > latest part, is this to loop over the files and put the oldest last? I found that part in another program and my program does not work without it.

Re: [Tutor] Program to report if file was modified today

2009-02-11 Thread bob gailer
David wrote: I get this error with the int(time.localtime()) start_of_today = int(time.localtime()) TypeError: int() argument must be a string or a number, not 'time.struct_time' Should have been start_of_today = int(time.time()) -- Bob Gailer Chapel Hill NC 91

Re: [Tutor] List weirdness

2009-02-13 Thread bob gailer
ong with that? However: >>> d[0].append(1) >>> d [[1]] I guess I can't reference [0] on an empty list. (I come from a C background.) Can you have an empty array in C? If so, it does not have any elements, so you can't refer to element 0. -- Bob Gailer Chapel Hill

Re: [Tutor] Copy file function works, but not with adding the date copied

2009-02-13 Thread bob gailer
cclpia...@comcast.net wrote: Hello, "but can't open with the application TextEdit" What are you doing to open it? What does "can't open" mean"? Error messages or what? Could this be a resource fork issue? AFAIK Python does not reproduce the resource fork. -

Re: [Tutor] Copy file function works, but not with adding the date copied

2009-02-14 Thread bob gailer
. And because of that the strangeness occurred. I haven't yet learned to work with the binaries as of yet. Thanks! Pat 4. Re: Copy file function works,but not with adding the date copied (Alan Gauld) Tutor Digest Vol 60, Issue 69 On Feb 13, 2009, at 6:16 PM, bob gailer wrote:

Re: [Tutor] *nix tail -f multiple log files with Thread

2009-02-15 Thread bob gailer
/ HTTP/1.1" 200 13718 127.0.0.1 - - [13/Feb/2009:09:18:47 -0500] "GET /theme/custom_corners/styles.php HTTP/1.1" 200 30709 I can create the label like this; def label() print "<%s\n>" % lfile But I have no idea how to get it to work when a thread is updated. thanks -david -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Reading a Text File with tkFileDialog, askopenfilename+enumerate

2009-02-16 Thread bob gailer
assigned. It's time to take a look at the Language Reference. 6.3 Assignment statements. assignment_stmt ::= (target_list "=")+ expression_list a target list is not a tuple, even though it can look like one. So I don't see it as any violation. -

Re: [Tutor] File locking: cross platform?

2009-02-20 Thread bob gailer
ervers. Some other tutor may have a different answer. I propose you open(filename, 'r') or open(filename, 'w'). -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] It's all about presentation

2009-02-21 Thread bob gailer
topic was a program to read 2 numbers, add them and print the sum. (In that era programs were run in batch mode on a HP3000. The students edited the program at their terminals, submitted them, waited a few minutes then received listings from the printer down the hall. We did eventually cover expre

Re: [Tutor] calling user defined function

2009-02-22 Thread bob gailer
if i define the function directly using the >>> prompt, after that everything is fine may you tell me where i have to save the file that defines the function is order to use it later ? is it a problem of path ? Let's say you saved the file as foo.py. Then: >>> import foo >

Re: [Tutor] new print statement + time module

2009-02-28 Thread bob gailer
George Wahid wrote: I downloaded python 3.0.1 today and started experimenting with the new print statement. print is a function, not a statement. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http

Re: [Tutor] Tutor Digest, Vol 61, Issue 3

2009-03-01 Thread bob gailer
That would depend on the interface between your program and the extensions. Do you have a design for this? You might take a look at how to create a mozilla add-on for ideas on this. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist -

Re: [Tutor] UNSUBSCRIPTABLE?

2009-03-08 Thread bob gailer
sequence No. It means that the object does not have a way to handle []. Many objects are subscriptable besides sequences. dict, set, objects with certain "special methods" e.g., __getitem__ -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Binary to Decimal conversion

2009-03-09 Thread bob gailer
really figure out what is going wrong here. I don't see anything going wrong. All I see is some Python code. Would you be kind enough to tell us why you think something is going wrong. If there is an error post the traceback If you get a result you did not expect tell us what the input

Re: [Tutor] Binary to Decimal conversion

2009-03-09 Thread bob gailer
understand binsum = binsum * int(item) * 2 + binsum + int(binum[i]) That does not agree with your verbal algorithm. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] compare csv file values against a python dictionary and create a new list from this.

2009-03-09 Thread bob gailer
7;Association of Airline Cons.'), Cls('AALA', 'Adv. Activity Licence. Auth.'), ...] That I think would be far more useful in the long run. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] help

2009-03-13 Thread bob gailer
A hollow voice says PLUGH. Be sure your lantern is lit! -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to only give the user so much time to enter response?

2009-03-15 Thread bob gailer
preciated (and hopefully yahoo won't butcher my indentation). -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] calling user defined function

2009-03-15 Thread bob gailer
roberto wrote: On Sun, Feb 22, 2009 at 11:10 PM, bob gailer wrote: roberto wrote: hello i have a question which i didn't solved yet: i can define a function using the text editor provided by IDLE 3.0; then i'd like to call this function from the python prompt but when i tr

Re: [Tutor] Opening a cmd.exe

2009-03-22 Thread bob gailer
that is not the case please tell us more about your goals and objectives. I don't understand "act as routers". -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Operational Error. --HELP

2009-03-31 Thread bob gailer
bijoy franco wrote: > > Hi, > > Python throws OperationalError while trying to do any database operations. I am using pgdb module. > > Code: > > import pgdb > > __metaclass__=type > > class addbook: > > conn=pgdb.connect(dsn='localhost:secondbooks',user='postgres',password='postgres1')

Re: [Tutor] Operational Error. --HELP

2009-03-31 Thread bob gailer
ot;/usr/lib/python2.5/site-packages/pgdb.py", line 174, in execute self.executemany(operation, (params,)) File "/usr/lib/python2.5/site-packages/pgdb.py", line 197, in executemany raise OperationalError, "internal error in '%s': %s" % (sql,err) pg.Operationa

Re: [Tutor] My Program stopped working, can anyone help

2009-04-01 Thread bob gailer
t;The coded message is:", codedMessage main() ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tut

Re: [Tutor] toggle through a list

2009-04-01 Thread bob gailer
def mode(data): numdict = defaultdict(int) for i in data: numdict[data[i]] += 1 numlist = [(count, num) for num, count in nums.items()] numlist.sort() print 'The mode is: ', numlist[-1][1] -- Bob Gailer Chapel Hill NC 91

Re: [Tutor] toggle through a list CORRECTION

2009-04-01 Thread bob gailer
bob gailer wrote: j mercedes wrote: Hi, I have problem here...I am writing a program but I am getting stucked at how to solve the mode of a series of numbers...any ideas??? The customary approach is to collect counts of each value in a dictionary. Untested code follows: from collections

Re: [Tutor] Formatting zip module arguments correctly

2009-04-05 Thread bob gailer
Benjamin Serrato wrote: > Please tell me why this code fails. I am new and I don't understand why my formatting of my zip arguments is incorrect. Since I am unsure how to communicate best so I will show the code, the error message, and what I believe is happening. > > #!c:\python30 > # Filenam

[Tutor] Please use plain text.

2009-04-06 Thread bob gailer
Please use plain text rather than formatted text. Small font size is hard for me to read. So is large! -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Checking for string in a list strangeness

2009-04-06 Thread bob gailer
fanity" has therefore come to describe a word, _expression_, gesture, or other social behavior which is socially constructed or interpreted as insulting, rude and vulgar or desecrating or showing disrespect.[1] In many cultures it is less profane for an adult to curse than it is for a ch

Re: [Tutor] Please use plain text.

2009-04-06 Thread bob gailer
M: Re: [Tutor] Formatting zip module arguments correctly metolone+gm...@gmail.com In hopes that you can see graphics, here is an extract: [snip] -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/ma

Re: [Tutor] Please use plain text.

2009-04-07 Thread bob gailer
Todd Zullinger wrote: bob gailer wrote: Please use plain text rather than formatted text. Was sending this request in an html formatted message intentional? I don't know about most folks, but I consider plain text to mean a content-type of text/plain rather than text

Re: [Tutor] Accessing a list inside a class...

2009-04-09 Thread bob gailer
_______ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] sets module equivalent with Python 2.6

2009-04-10 Thread bob gailer
in retrospect. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] python dictionary

2009-04-14 Thread bob gailer
but I do not understand the final paragraph. It might help a little if you were to use more punctuation. Are you asking a question? Could you give an example? -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org

Re: [Tutor] regular expression problem

2009-04-15 Thread bob gailer
appends the first one to the next entry...and does this till it finds everything. http://dpaste.com/33982/ Any Help? dedent the 2nd for loop. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org

Re: [Tutor] PDF to text conversion

2009-04-21 Thread bob gailer
___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Organizing my code, should I use functions?

2009-04-22 Thread bob gailer
l\Shipping Totals\Shipping Totals - 2008\Shipping Totals 2008 East.xls' thisDay = time.gmtime()[:3] prevyear = datetime.datetime.today() - datetime.timedelta(days=365) aYearAgo = prevyear.timetuple()[:3] book = xlrd.open_workbook(thisyearFile) dayexcel = xlrd.xldate.xldate_from_date_tuple(t

Re: [Tutor] Organizing my code, should I use functions?

2009-04-22 Thread bob gailer
Please use reply-all so a copy goes to the list. Eduardo Vieira wrote: On Wed, Apr 22, 2009 at 9:47 AM, bob gailer wrote: Eduardo Vieira wrote: Hello! I’m not a programmer Do you mean that you were not a programmer and are now becoming one? In a way yes, I am aspiring

Re: [Tutor] Organizing my code, should I use functions? INDENTATION CORRECTION

2009-04-22 Thread bob gailer
INDENTATION CORRECTION: shipped = todaysList[shipindex] total = sum([a for a in totals if type(a) == type(2.0)]) return shipped, total # specify the output(s) here bob gailer wrote: Please use reply-all so a copy goes to the list. Eduardo Vieira wrote: On Wed, Apr 22, 2009 at 9:47

Re: [Tutor] Tokenizing Help

2009-04-22 Thread bob gailer
han by exhaustion, I cannot anticipate what will be found What I am looking for is some help to get started, either with explaining the implementation of one of the modules with respect to my format, or with an approach that I could use from the base library. What is your ultimate goal? -- Bob Gailer

Re: [Tutor] understanding urllib.urlopen

2009-04-23 Thread bob gailer
t understand urllib.urlopen(). Could some kind soul explain what I'm doing wrong. 1) put a / after .com 2) encode it (in this case that means replace blanks with %20) x=urllib.urlopen("http://maps.google.com/?q=18%20Tadlock%20Place%20Woodland%20CA";) -- Bob Gailer Chapel Hill NC

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread bob gailer
translate to Python fairly easily! What do we do at steps 4ff if the line does not end in "yes" or "no"? If you have not written any code make a stab at it. You could start by asking "how in Python does one": open a file

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread bob gailer
ending in 'yes' line = data.read().strip() if line: if line.endswith('yes'): state = 1 else state = 6 elif state == 1: # code for state i # more states elif state == 6: data.close() break To simplify things I'd create a function to read and s

Re: [Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')

2009-05-04 Thread bob gailer
() instead of invoking this constructor directly. file is more suited to type testing (for example, writing "isinstance(f, file)"). Unfortunately no explanation as to WHY open is preferred. I have long wondered that myself. Perhaps someone with more enlightenment can t

Re: [Tutor] Pythonic way to normalize vertical whitespace

2009-05-08 Thread bob gailer
Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Sorting a list

2009-05-14 Thread bob gailer
ist.extend(numeric_list) >>> string_list ['word', 3, 4, 6, 9] In the relentless pursuit of terseness: >>> class L(list): ... def add(self, end, *item):self[-end:-end] = item >>> a=[4,6,'word',3,9] >>> result=L() >>> [result.add(

Re: [Tutor] Sorting a list

2009-05-14 Thread bob gailer
o this: [4, 6, 'word', 3, 9] should be: ['word', 3, 4, 6, 9] Why not: >>> sorted(lst, key=lambda x: (0, x) if isinstance(x, str) else (1, x)) ['word', 3, 4, 6, 9] Again in the relentless pursuit of terseness: sorted(a, key=lambda x: (isinstance(x, int)

Re: [Tutor] need help opening a file in idle

2009-05-23 Thread bob gailer
x27; is a relative path. It looks in the current directory. Obviously that file is not in the current directory. So you must provide the complete path. That is no longer a Python issue! The path to the desktop depends on OS and username! I suggest you put the file in a different

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