[Tutor] Bowing out

2010-03-03 Thread Kent Johnson
Hi all, After six years of tutor posts my interest and energy have waned and I'm ready to move on to something new. I'm planning to stop reading and contributing to the list. I have handed over list moderation duties to Alan Gauld and Wesley Chun. Thanks to everyone who contributes questions and

Re: [Tutor] Bowing out

2010-03-03 Thread Kent Johnson
with the Mercurial project or SunlightLabs.org. Kent On 3 March 2010 14:17, Kent Johnson ken...@tds.net wrote: After six years of tutor posts my interest and energy have waned and I'm ready to move on to something new. ___ Tutor maillist  -  tu

Re: [Tutor] returning to my quest

2010-02-25 Thread Kent Johnson
On Thu, Feb 25, 2010 at 8:59 PM, Kirk Bailey kbai...@howlermonkey.net wrote: for  WEBMAIIL portal to a pop3/smtp email service in my server; centrally hosted or in the laptop is fine, what can people recommend? Without going to IMAP, i want to leave the mail on the server. I still have no idea

Re: [Tutor] ask

2010-02-24 Thread Kent Johnson
On Tue, Feb 23, 2010 at 10:58 PM, Shurui Liu (Aaron Liu) shuru...@gmail.com wrote: This time is not my assignment, I promise. In python, when we want to list numbers, we use the command range, like, if we want to list integer from 0 to 9, we can write: range(10); if we want to list integer

[Tutor] DreamPie - The Python shell you've always dreamed about!

2010-02-24 Thread Kent Johnson
This looks promising and probably of interest to some on this list. Kent -- Forwarded message -- From: Noam Yorav-Raphael noamr...@gmail.com To: python-announce-l...@python.org Date: Sun, 21 Feb 2010 11:39:02 +0200 Subject: DreamPie - The Python shell you've always dreamed about!

Re: [Tutor] list to numpy record array

2010-02-23 Thread Kent Johnson
On Mon, Feb 22, 2010 at 11:50 PM, Vincent Davis vinc...@vincentdavis.net wrote: I must be missing something simple. I have a list of lists data = [['  0', '  0', '234.0', '24.0', ' 25'], ['  1', '  0', '22428.0', '2378.1', ' 25'],.. and what to make a record array from it but it gets

Re: [Tutor] Functions returning multiple values

2010-02-23 Thread Kent Johnson
On Tue, Feb 23, 2010 at 1:55 PM, Giorgio And, please let me ask a question: Kent told that nested_namespace(s) are default in python 2.6. And i found a line confirming this in py2.6 library. But, what about python 2.5 that as you know is the default on linux? Yes, since 2.2 nested namespaces

Re: [Tutor] Extracting comments from a file

2010-02-22 Thread Kent Johnson
On Mon, Feb 22, 2010 at 1:06 AM, Lao Mao laomao1...@googlemail.com wrote: Hi, I have an html file, with xml style comments in: !-- Some comments here Blah ... -- I'd like to extract only the comments.  My sense of smell suggests that there's probably a library (maybe an xml library)

Re: [Tutor] Functions returning multiple values

2010-02-22 Thread Kent Johnson
On Mon, Feb 22, 2010 at 9:13 AM, Giorgio anothernetfel...@gmail.com wrote: And, i have some difficulties understanding the other strange example in that howto. Just scroll down to: However, the point is that the value of x is picked up from the environment at the time when the function is

Re: [Tutor] Using and

2010-02-21 Thread Kent Johnson
On Sun, Feb 21, 2010 at 8:44 AM, jim serson fubarni...@hotmail.com wrote: Can anyone tell me if I can have my program check to see if something is true the add to count For example something like if c_1 and c_2 and c_3 true:     count + 1 This will almost work as written. Try if

Re: [Tutor] Superclass call problem

2010-02-20 Thread Kent Johnson
On Sat, Feb 20, 2010 at 12:50 PM, Alan Harris-Reid aharrisr...@googlemail.com wrote: Hi, I am having trouble understanding how superclass calls work.  Here's some code... class ParentClass():   def __init__(self):       do something here You should inherit object to use super(): class

Re: [Tutor] Replacing part of a URL

2010-02-20 Thread Kent Johnson
On Sat, Feb 20, 2010 at 5:34 PM, Lao Mao laomao1...@googlemail.com wrote: Hello, I need to be able to replace the last bit of a bunch of URLs. The urls look like this: www.somesite.com/some/path/to/something.html They may be of varying lengths, but they'll always end with

Re: [Tutor] Is it possible for a Python Program to send commands to the Python Interpreter?

2010-02-19 Thread Kent Johnson
On Fri, Feb 19, 2010 at 1:56 PM, Carnell, James E jecarn...@saintfrancis.com wrote: I am trying to teach a computer program - to program. It builds grammars and procedural memories on dictionary networks. How do I get the program to be able to input to the interpreter/command line and read the

Re: [Tutor] Reading large bz2 Files

2010-02-19 Thread Kent Johnson
On Fri, Feb 19, 2010 at 7:42 AM, Norman Rieß nor...@smash-net.org wrote: Hello, i am trying to read a large bz2 file with this code: source_file = bz2.BZ2File(file, r) for line in source_file:    print line.strip() But after 4311 lines, it stoppes without a errormessage. The bz2 file is

Re: [Tutor] Is it possible for a Python Program to send commands to the Python Interpreter?

2010-02-19 Thread Kent Johnson
On Fri, Feb 19, 2010 at 7:07 PM, Steven D'Aprano st...@pearwood.info wrote: On Sat, 20 Feb 2010 06:33:04 am Kent Johnson wrote: It sounds like you are looking for eval() (Standard warning - use eval() only on trusted data) This is the tutor list, aimed at beginners to Python, many of whom

Re: [Tutor] Python and algorithms

2010-02-18 Thread Kent Johnson
On Thu, Feb 18, 2010 at 4:59 AM, C.T. Matsumoto c.t.matsum...@gmail.com wrote: Hello Tutors, Can someone point me to any resources that can teach me about algorithms in python? I'm interested in learning how to analyze and make an algorithm. I have been reading The Algorithm Design Manual

Re: [Tutor] Python and algorithms

2010-02-18 Thread Kent Johnson
On Thu, Feb 18, 2010 at 9:43 AM, C.T. Matsumoto c.t.matsum...@gmail.com wrote: Here is the example. To keep this simple and practical, as a suggestion, consider the problem of sorting a list (a pack of cards, or a list of names or whatever you want) into order. Yes, there are many

Re: [Tutor] Find duplicates (using dictionaries)

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 11:31 AM, Karjer Jdfjdf karper12...@yahoo.comwrote: I'm relatively new at Python and I'm trying to write a function that fills a dictionary acording the following rules and (example) data: Rules: * No duplicate values in field1 * No duplicates values in field2 and

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 3:12 PM, David Perlman dperl...@wisc.edu wrote: Yeah, I got this part.  The thing that's hanging me up is that there doesn't seem to be any way to get a tzinfo instance that contains the current local time zone information.  You can do time.timezone to get the seconds

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
, it is implicit in the existing definitions that the system *knows* the current offset, even if it doesn't know the whole set of rules... On Feb 17, 2010, at 2:26 PM, Kent Johnson wrote: On Wed, Feb 17, 2010 at 3:12 PM, David Perlman dperl...@wisc.edu wrote: Yeah, I got this part.  The thing that's

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 4:37 PM, David Perlman dperl...@wisc.edu wrote: OK, here's a function that does precisely what I want: def tzDelta():  by whatever means necessary, return the current offset of the local time from utc.  s=time.time()  t,u=time.localtime(s),time.gmtime(s)  

[Tutor] PyCon anyone?

2010-02-16 Thread Kent Johnson
Hi all, I'm going to PyCon this year for the first time (yeah!) and I would love to meet other regular contributors to the tutor list. Is anyone else going to be there? Any interest in a Meet the tutors Open Space or dinner? Kent ___ Tutor maillist -

Re: [Tutor] PyCon anyone?

2010-02-16 Thread Kent Johnson
On Tue, Feb 16, 2010 at 10:09 AM, Vern Ceder vce...@canterburyschool.org wrote: Kent Johnson wrote: Hi all, I'm going to PyCon this year for the first time (yeah!) and I would love to meet other regular contributors to the tutor list. Is anyone else going to be there? Any interest in a Meet

Re: [Tutor] PyCon anyone?

2010-02-16 Thread Kent Johnson
On Tue, Feb 16, 2010 at 10:17 AM, Wayne Watson sierra_mtnv...@sbcglobal.net wrote: Hi all, I'm going to PyCon this year for the first time (yeah!) and I would love to meet other regular contributors to the tutor list. Is anyone else going to be there? Any interest in a Meet the tutors Open

Re: [Tutor] count time limit

2010-02-16 Thread Kent Johnson
On Tue, Feb 16, 2010 at 11:54 AM, Shurui Liu (Aaron Liu) shuru...@gmail.com wrote:  Modify the guess_my_number.py program to limit the number of guesses to ten (10).    Tell the user up front that they have ten guesses. After each guess, tell the user that they have ___ guesses remaining.

Re: [Tutor] Getting caller name without the help of sys._getframe(1).f_code.co_name ?

2010-02-15 Thread Kent Johnson
On Mon, Feb 15, 2010 at 6:07 AM, patrice laporte zepango...@gmail.com wrote: My own experience is that there is too much coder that forget the app they work on is aim to be used by real human, not by C/C++/Python/put what ever you want here/ guru : if your app popups to the user a message that

Re: [Tutor] Editing html using python

2010-02-15 Thread Kent Johnson
On Mon, Feb 15, 2010 at 7:28 AM, Amit Sethi amit.pureene...@gmail.com wrote: Well ya I was kind of hoping to know about more tools and recommendations on how to edit broken html . This page lists several alternatives: html5, lxml, elementtree:

Re: [Tutor] Editing html using python

2010-02-14 Thread Kent Johnson
On Sun, Feb 14, 2010 at 6:10 AM, Amit Sethi amit.pureene...@gmail.com wrote: Hi I need to edit html programmatically . Sadly the html might be broken at places . I was using BeautifulSoup but there were lots of problems and it is also not maintained can some one guide me to any tutorials on

Re: [Tutor] Not understanding this code example. Help, please.

2010-02-13 Thread Kent Johnson
On Fri, Feb 12, 2010 at 11:49 PM, Eduardo Vieira eduardo.su...@gmail.com wrote: Hello! I was reading the latest version of Mark Pilgrim's Dive into Python and am confused with these example about the pluralization rules. See http://diveintopython3.org/examples/plural3.py and

Re: [Tutor] The Order of Imports and install order of modules and other matters (XP vs W7, ...)

2010-02-13 Thread Kent Johnson
On Fri, Feb 12, 2010 at 10:55 PM, Wayne Watson sierra_mtnv...@sbcglobal.net wrote: There seems to be something of a general consensus in ordering import statements. Something like standard library imports first. When using tools like matlablib or tkinter (maybe), must one keep an order among

Re: [Tutor] json file

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 7:21 AM, Chris Patillo pythonnewb...@gmail.com wrote: I need to read in a .json file and write out a file with some of the information from this file.  I can't figure out how to read the .json file in.  I know there is a module for this, but I don't understand how it

Re: [Tutor] Getting caller name without the help of sys._getframe(1).f_code.co_name ?

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 10:56 AM, patrice laporte zepango...@gmail.com wrote: Being in an exeption of my own, I want to print the name of the caller, and I'm looking for a way to have it. I've found a lot of recipe all of them using what seems to be, according to me, a not so good trick :

Re: [Tutor] ask

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 4:08 PM, 刘书睿 shuru...@gmail.com wrote: Here are my assignment about Python, I don't know if anything is wrong. Is there anybody can help me? 1. assignment 9a and 9b hyperlink: http://cset.sp.utoledo.edu/cset1100py/cset1100_assign.html#simplepy 2. I don't know how to

Re: [Tutor] ask

2010-02-13 Thread Kent Johnson
2010/2/13 Shurui Liu (Aaron Liu) shuru...@gmail.com: Yeah, i know. I don't want somebody tell me all the answers of these assignment directly. I just want to know is there any error in the commands listed online? My teacher told us there is some, but I cannot find out. He said we can run them

Re: [Tutor] json file

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 3:00 PM, Chris Patillo pythonnewb...@gmail.com wrote: Thanks for your response.  i did some research on json.load() and I don't understand how you extract the data from it.  How do I get just the name and number from the file? The value returned from json.load() is a

Re: [Tutor] asigning class variables

2010-02-13 Thread Kent Johnson
On Sat, Feb 13, 2010 at 8:08 PM, the kids the7hans...@msn.com wrote: Hi, my name is John Paul. I was trying to define a class but I can't make it asign particular objects particular variables at their creation.  Please help. It would help to see some details of what you are trying to do. It

Re: [Tutor] html and python

2010-02-11 Thread Kent Johnson
2010/2/11 Григор grigor.ko...@gmail.com: I found this. http://karrigell.sourceforge.net/en/pythoninsidehtml.htm Many options here: http://wiki.python.org/moin/Templating Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] string to list

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 4:44 AM, Stefan Behnel stefan...@behnel.de wrote: 2) given that you have lists as items in the 'data' list, it's enough to call sort() once, as the comparison of lists is defined as the comparison of each item to the corresponding item of the other list. If you want to

Re: [Tutor] Simple Stats on Apache Logs

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 4:56 AM, Lao Mao laomao1...@googlemail.com wrote: Hi, I have 3 servers which generate about 2G of webserver logfiles in a day. These are available on my machine over NFS. I would like to draw up some stats which shows, for a given keyword, how many times it appears

Re: [Tutor] string to list

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 8:37 AM, Stefan Behnel stefan...@behnel.de wrote: Kent Johnson, 11.02.2010 14:16: On Thu, Feb 11, 2010 at 4:44 AM, Stefan Behnel wrote: 2) given that you have lists as items in the 'data' list, it's enough to call sort() once, as the comparison of lists is defined

Re: [Tutor] Algorithm for combination analysis suggestion.

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 1:59 PM, Matthew Matson gtx...@hotmail.com wrote: Hi Tutors, I am looking for the proper approach regarding the analysis of a dictionary of combinations I have. What I need to do is read from a supplied text file that has a unique ID and that unique ID's associated

Re: [Tutor] SMTP

2010-02-11 Thread Kent Johnson
On Thu, Feb 11, 2010 at 3:13 PM, Grigor Kolev grigor.ko...@gmail.com wrote: Hi. I try send a mail with smtplib Server work with postfix. I try it  import smtplib  s=smtplib.SMTP(localhost) tolist=['grigor.ko...@gmail.com'] msg = '''\  

Re: [Tutor] NameError: global name 'celsius' is not defined (actually, solved)

2010-02-10 Thread Kent Johnson
On Tue, Feb 9, 2010 at 10:00 PM, David ld...@gmx.net wrote: Hi guys, I just wrote this message, but after restarting ipython all worked fine. How is it to be explained that I first had a namespace error which, after a restart (and not merely a new run Sande_celsius-main.py), went away? I

Re: [Tutor] Error :Attempt to overwrite cell while using xlwt to create excel sheets

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 6:47 AM, nikunj badjatya nikunjbadja...@gmail.com wrote: I commented out the raise Exception statement in Row.py library module. Here's the (line no. 150 ) of Row.py which i have edited:   def insert_cell(self, col_index, cell_obj):         if col_index in

Re: [Tutor] string to list

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 6:26 AM, Owain Clarke simb...@cooptel.net wrote: Please excuse the obviousness of my question (if it is), but I have searched the documentation for how to generate a list e.g. [(1,2), (3,4)] from a string [(1,2), (3,4)]. I wonder if someone could point me in the right

Re: [Tutor] string to list

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 8:32 AM, Owain Clarke simb...@cooptel.net wrote: My son was doing a statistics project in which he had to sort some data by either one of two sets of numbers, representing armspan and height of a group of children - a boring and painstaking job.  I came across this piece

Re: [Tutor] html and python

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 2:30 PM, Grigor Kolev grigor.ko...@gmail.com wrote: Hi. I want to make a list of E-mail, photos and some additional data. But I want this list to be displayed in one site. How can I send data from a list of site page. Which module should I use I don't understand send

Re: [Tutor] html and python

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 2:54 PM, Grigor Kolev grigor.ko...@gmail.com wrote: В 14:39 -0500 на 10.02.2010 (ср), Kent Johnson написа: On Wed, Feb 10, 2010 at 2:30 PM, Grigor Kolev grigor.ko...@gmail.com wrote: Hi. I want to make a list of E-mail, photos and some additional data. But I want

Re: [Tutor] need idea

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 4:27 PM, invincible patriot invincible_patr...@hotmail.com wrote: hi i want to compare a string with a dictionary or u can say that i want to take user input A STRING, and want to compare each character of that string with the KEYS  in the dictionary, and then i wana

Re: [Tutor] running split and count + looping to check for numbers in same line

2010-02-10 Thread Kent Johnson
On Wed, Feb 10, 2010 at 6:43 PM, jim serson fubarni...@hotmail.com wrote: I am getting an error when I try and run split and count I seem to get it to work with one or the other but not together. python wants a character buffer but I am not sure how to use it. I would also like to use

Re: [Tutor] rstrip in list?

2010-02-09 Thread Kent Johnson
On Tue, Feb 9, 2010 at 11:09 AM, Ken G. beach...@insightbb.com wrote: Kent Johnson wrote: On Tue, Feb 9, 2010 at 10:28 AM, Ken G. beach...@insightbb.com wrote: I printed out some random numbers to a datafile and use 'print mylist' and they came out like this: ['102\n', '231\n', '463\n

Re: [Tutor] if item.find(extension)!= -1: -- what's the -1?

2010-02-06 Thread Kent Johnson
On Sat, Feb 6, 2010 at 11:35 AM, David ld...@gmx.net wrote: Hello again, in Knowlton's 2008 book Python: Create, Modify, Reuse the author makes frequent use of the term -1 in his code, but doesn't tell to what aim. For want of search terms Google is not helpful. Could someone please enlighten

Re: [Tutor] Variable: From input and output

2010-02-05 Thread Kent Johnson
On Thu, Feb 4, 2010 at 5:39 PM, ssiverling ssiverl...@gmail.com wrote: I uploaded a file.  I know it's not very impressive. Where did you upload it? For short programs you can just include them in your email. Also, please don't top-post, and please subscribe to the list. Kent Kent

Re: [Tutor] language aid

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 5:43 AM, Owain Clarke simb...@cooptel.net wrote: My question is, that if I proceed like this I will end up with a single list of potentially several hundred strings of the form frword:engword. In terms of performance, is this a reasonable way to do it, or will the

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: I just noticed, however, that in the comments section of the ActiveState recipe that someone is getting incorrect results for certain numbers (11 and 12, specifically). But when I use the code on my own machine it

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:09 PM, Kent Johnson ken...@tds.net wrote: On Thu, Feb 4, 2010 at 12:11 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: Here's the link to the recipe: http://code.activestate.com/recipes/576888/ Perhaps the code on activestate is not a correct copy of what you

Re: [Tutor] Help with cursors please

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 12:47 PM, Alan Harris-Reid aharrisr...@googlemail.com wrote: Hi, I have a SQLite cursor which I want to traverse more than once, eg... for row in MyCursor:   method1(row)  then later... for row in MyCursor:   method2(row)  Method2 is never run, I guess because the

Re: [Tutor] correcting an Active State Recipe for conversion to ordinal

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:21 PM, Serdar Tumgoren zstumgo...@gmail.com wrote: Perhaps the code on activestate is not a correct copy of what you are running? The conditional at line 23 extends all the way to line 35 - the end of the function - so if value % 100/10 == 1 no more code is executed

Re: [Tutor] Variable: From input and output

2010-02-04 Thread Kent Johnson
On Thu, Feb 4, 2010 at 1:19 PM, ssiverling ssiverl...@gmail.com wrote: So I have been working on this example for a little while.  I looked for the answer before posting.  I tried to use two raw inputs, then use sys.stdout.write, to add them together.  However I think I might need to use a

Re: [Tutor] help with strings

2010-02-03 Thread Kent Johnson
On Wed, Feb 3, 2010 at 8:19 AM, NISA BALAKRISHNAN snisa.balakrish...@gmail.com wrote: hi I am very new to python. I have a string for example : 123B     new Project i want to separate 123B as a single string and new  project as another string . how can i do that. i tried using partition

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine nor...@khine.net wrote: here are the changes: import re file=open('producers_google_map_code.txt', 'r') data =  repr( file.read().decode('utf-8') ) Why do you use repr() here? get_record = re.compile(ropenInfoWindowHtml\(.*?\\ticon: myIcon\\n)

Re: [Tutor] how to pass data to aother function from a class?

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 8:04 AM, Zheng Jiekai zjkh...@gmail.com wrote: I'm beginning my python learning. My python version is 3.1 I‘v never learnt OOP before. So I'm confused by the HTMLParser Here's the code: from html.parser import HTMLParser class parser(HTMLParser): def

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine nor...@khine.net wrote: On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson ken...@tds.net wrote: On Tue, Feb 2, 2010 at 4:16 AM, Norman Khine nor...@khine.net wrote: here are the changes: import re file=open('producers_google_map_code.txt', 'r') data

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 1:39 PM, Norman Khine nor...@khine.net wrote: On Tue, Feb 2, 2010 at 4:19 PM, Kent Johnson ken...@tds.net wrote: On Tue, Feb 2, 2010 at 9:33 AM, Norman Khine nor...@khine.net wrote: On Tue, Feb 2, 2010 at 1:27 PM, Kent Johnson ken...@tds.net wrote: On Tue, Feb 2, 2010

Re: [Tutor] parse text file

2010-02-02 Thread Kent Johnson
On Tue, Feb 2, 2010 at 4:56 PM, Norman Khine nor...@khine.net wrote: On Tue, Feb 2, 2010 at 10:11 PM, Kent Johnson ken...@tds.net wrote: Try this version: data = file.read() get_records = re.compile(ropenInfoWindowHtml\(.*?\ticon: myIcon\n, re.DOTALL).findall get_titles = re.compile

Re: [Tutor] parse text file

2010-02-01 Thread Kent Johnson
On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine nor...@khine.net wrote: thanks, what about the whitespace problem? \s* will match any amount of whitespace includin newlines. Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] hash value input

2010-01-30 Thread Kent Johnson
On Sat, Jan 30, 2010 at 4:56 AM, spir denis.s...@free.fr wrote: I'm surprised of this, for this should create as many indexes (in the underlying array actually holding the values) as there are integer keys. With possibly huge holes in the array. Actually, there will certainly be a

Re: [Tutor] hash value input

2010-01-29 Thread Kent Johnson
On Fri, Jan 29, 2010 at 8:03 AM, spir denis.s...@free.fr wrote: I recently discovered that Lua uses the data's address (read: id) as input to the hash func. This allows Lua tables (a kind of more versatile associative array) to use _anything_ as key, since the id is guaranteed not to change,

Re: [Tutor] hash value input

2010-01-29 Thread Kent Johnson
On Fri, Jan 29, 2010 at 1:20 PM, Rich Lovely roadier...@googlemail.com wrote: I've played with this a little.  The following class was quite handy for this: class BrokenHash(object):    def __init__(self, hashval):        self.hashval = hashval    def __hash__(self):        return

Re: [Tutor] length of a string? Advice saught

2010-01-28 Thread Kent Johnson
On Wed, Jan 27, 2010 at 6:57 PM, Alan Gauld alan.ga...@btinternet.com wrote: read() functions usually have an optional buffersize parameter set to a reasonable size. If you try to read more than that it will be truncated. This is explained in the read() documentation for files. ?? files have

Re: [Tutor] multiply and sum two lists with list comprehension?

2010-01-28 Thread Kent Johnson
On Thu, Jan 28, 2010 at 1:22 AM, Muhammad Ali ali@gmail.com wrote: Hi, I am multipliying two lists so that each of list As elements get multiplied to the corresponding list Bs. Then I am summing the product. For example, A= [1, 2, 3] and B=[2, 2, 2] so that I get [2, 4, 6] after

Re: [Tutor] The magic parentheses

2010-01-24 Thread Kent Johnson
On Sun, Jan 24, 2010 at 12:08 PM, Alan Gauld alan.ga...@btinternet.com wrote: Hugo Arts hugo.yo...@gmail.com wrote print this is {0}.format(formatted) this is formatted Caveat: this style only works in Python 3.0 upwards  (or maybe in 2.6/2.7?) It's in 2.6

Re: [Tutor] keeping track of the present line in a file

2010-01-21 Thread Kent Johnson
On Thu, Jan 21, 2010 at 1:57 AM, sudhir prasad sudheer@gmail.com wrote: hi, is there any other way to keep track of line number in a file other than fileinput.filelineno() With enumerate(): for line_number, line in enumerate(open('myfile.txt')): # etc Kent

Re: [Tutor] Still searching in html files

2010-01-21 Thread Kent Johnson
On Thu, Jan 21, 2010 at 4:03 AM, Paul Melvin p...@assured-networks.co.uk wrote: The code is at http://python.codepad.org/S1ul2bh7 and the bit I would like some advice on is how to get the sorted data and where to put it. Generally the code seems a bit disorganized, consider breaking it into

Re: [Tutor] combinatorics problem: assembling array

2010-01-21 Thread Kent Johnson
On Thu, Jan 21, 2010 at 4:06 AM, markus kossner m.koss...@tu-bs.de wrote: Dear Pythonics, I have a rather algorithmic problem that obviously made a knot in my brain: Assume we have to build up all the arrays that are possible if we have a nested array containing an array of integers that are

Re: [Tutor] combinatorics problem: assembling array

2010-01-21 Thread Kent Johnson
On Thu, Jan 21, 2010 at 8:07 AM, Kent Johnson ken...@tds.net wrote: On Thu, Jan 21, 2010 at 4:06 AM, markus kossner m.koss...@tu-bs.de wrote: Dear Pythonics, I have a rather algorithmic problem that obviously made a knot in my brain: Assume we have to build up all the arrays that are possible

Re: [Tutor] Python workspace - IDE and version control

2010-01-19 Thread Kent Johnson
On Mon, Jan 18, 2010 at 4:17 PM, Alan Gauld alan.ga...@btinternet.com wrote: I use plain old RCS for version control because its just me working on the code. Wow. You should take a look at Mercurial. It is so easy to set up a Mercurial repository for a local project - just hg init # create a

Re: [Tutor] Python workspace - IDE and version control

2010-01-19 Thread Kent Johnson
On Tue, Jan 19, 2010 at 9:12 AM, Andreas Kostyrka andr...@kostyrka.org wrote: The cool part about git that I've not yet replicated with hg is git add -p which allows you to seperate out different changes in the same file. Sounds like the record and crecord extensions come close, anyway:

Re: [Tutor] smtp project

2010-01-18 Thread Kent Johnson
. Kent Johnson wrote: On Sun, Jan 17, 2010 at 3:45 PM, Kirk Z Bailey kbai...@howlermonkey.net wrote: I am writing a script that will send an email message. This will run in a windows XP box. The box does not have a smtp server, so the script must crete not merely a smtp client to talk to a MTA

Re: [Tutor] smtp project

2010-01-17 Thread Kent Johnson
On Sun, Jan 17, 2010 at 3:45 PM, Kirk Z Bailey kbai...@howlermonkey.net wrote: I am writing a script that will send an email message. This will run in a windows XP box. The box does not have a smtp server, so the script must crete not merely a smtp client to talk to a MTA, it must BE one for

Re: [Tutor] Searching in a file

2010-01-15 Thread Kent Johnson
On Fri, Jan 15, 2010 at 4:24 AM, Paul Melvin p...@assured-networks.co.uk wrote: Hi, Thanks very much to all your suggestions, I am looking into the suggestions of Hugo and Alan. The file is not very big, only 700KB (~2 lines), which I think should be fine to be loaded into memory? I

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-15 Thread Kent Johnson
On Fri, Jan 15, 2010 at 3:43 PM, Guilherme P. de Freitas guilhe...@gpfreitas.com wrote: Ok, I checked the answers you all gave me, and the suggestions seem to be 2: a. Compute the list of members on the fly, with a list comprehension that looks up stuff on self.__dict___; b. Stay with my

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Kent Johnson
On Wed, Jan 13, 2010 at 9:24 PM, Guilherme P. de Freitas guilhe...@gpfreitas.com wrote: Hi everybody, Here is my problem. I have two classes, 'Body' and 'Member', and some attributes of 'Body' can be of type 'Member', but some may not. The precise attributes that 'Body' has depend from

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Kent Johnson
On Wed, Jan 13, 2010 at 11:15 PM, Guilherme P. de Freitas guilhe...@gpfreitas.com wrote: Ok, I got something that seems to work for me. Any comments are welcome. class Member(object):    def __init__(self):        pass class Body(object):    def __init__(self):        self.members = []

Re: [Tutor] samples on sort method of sequence object.

2010-01-13 Thread Kent Johnson
On Wed, Jan 13, 2010 at 2:21 PM, Stefan Behnel stefan...@behnel.de wrote: Hugo Arts, 13.01.2010 15:25: Here is my solution for the general case: from itertools import groupby def alphanum_key(string):    t = []    for isdigit, group in groupby(string, str.isdigit):        group =

Re: [Tutor] samples on sort method of sequence object.

2010-01-12 Thread Kent Johnson
On Tue, Jan 12, 2010 at 9:39 AM, Make Twilight ph4...@gmail.com wrote:  I can understand how to use parameters of cmp and reverse,except the key parameter...  Would anyone give me an example of using sort method with key parameter? http://personalpages.tds.net/~kent37/kk/7.html Kent

Re: [Tutor] composing one test suite from two test cases

2010-01-11 Thread Kent Johnson
On Sun, Jan 10, 2010 at 10:44 PM, Tom Roche tom_ro...@pobox.com wrote: How to create a single unittest test suite class that runs all methods from multiple TestCase classes? Why I ask: I'm trying to relearn TDD and learn Python by coding a simple app. Currently the app has 2 simple

Re: [Tutor] what is the equivalent function to strtok() in c++

2010-01-11 Thread Kent Johnson
On Mon, Jan 11, 2010 at 2:33 AM, sudhir prasad sudheer@gmail.com wrote: hi, what is the equivalent function to strtok() in c++, what i need to do is to divide a line into different strings and store them in different lists,and write them in to another file To split on a single character

Re: [Tutor] Tips

2010-01-11 Thread Kent Johnson
On Mon, Jan 11, 2010 at 12:33 AM, VacStudent v...@petradiamonds.com wrote: I would like to get a python book, how and where to get one? Amazon.com? Or lots of free resources online. Kent ___ Tutor maillist - Tutor@python.org To unsubscribe or change

Re: [Tutor] composing one test suite from two test cases

2010-01-11 Thread Kent Johnson
On Mon, Jan 11, 2010 at 8:53 AM, Tom Roche tom_ro...@pobox.com wrote: Kent Johnson Mon, 11 Jan 2010 06:42:39 -0500 However I don't recommend this style of organizing tests. I prefer using nose for test discovery, it saves the work of creating all the aggregating suites. I've heard of Nose

Re: [Tutor] Numpy unexpected result: subtraction of cell values

2010-01-11 Thread Kent Johnson
On Mon, Jan 11, 2010 at 2:02 PM, Carnell, James E jecarn...@saintfrancis.com wrote: I want to subtract the Red Value in an array cell from a neighboring Red Value cell. pictArray[39][4]    #pixel at 39 4 array([150, 140, 120], dtype=unint8) pictArray[39][5]

Re: [Tutor] question about function inside of function

2010-01-10 Thread Kent Johnson
On Sat, Jan 9, 2010 at 8:03 AM, spir denis.s...@free.fr wrote: Do you realize the inner func will be redefined before each call? Meaning in your case n calls x n outer loops x n inner loops.   def f() ... is actually a kind of masked assignment   f = function()... That's true, but it is

Re: [Tutor] Question on import foobar vs from foobar import *

2010-01-10 Thread Kent Johnson
On Sat, Jan 9, 2010 at 3:50 AM, spir denis.s...@free.fr wrote: Lie Ryan dixit: only use from module import * if the module was designed for such use In most cases, this translates to: the imported module defines __names__, which holds the list of names (of the objects) to be exported.

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Thu, Jan 7, 2010 at 1:26 PM, Lowell Tackett lowelltack...@yahoo.com wrote: I found the Python documentation (on line} and came across--'csv.Dialect.skipinitialspace' which I believe is the answer to my dilemma.  However, my effort to implement that detail, based on interpreting the

Re: [Tutor] (no subject)

2010-01-08 Thread Kent Johnson
On Thu, Jan 7, 2010 at 5:08 PM, kumar s ps_pyt...@yahoo.com wrote: I want to take coordiates x and y from each row in file a, and check if they are in range of zx and zy. If they are in range then I want to be able to write both matched rows in a tab delim single row. my code: f1 =

Re: [Tutor] Expanding a Python script to include a zcat and awk pre-process

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 2:24 AM, galaxywatc...@gmail.com wrote: So how do I uncompress zip and gzipped files in Python, zipfile and gzip and how do I force split to only evaluate the first two columns? Use the optional second argument to split(): line.split(',', 2) Better yet, can I tell

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 9:54 AM, Lowell Tackett lowelltack...@yahoo.com wrote: Now, perhaps you can you shed some light on this problem--I'm trying to do some simple arithmetic with two of the retrieved values, and get this error: coord = csv.reader(open('true_coord', 'rb'), skipinitialspace

Re: [Tutor] manipulting CSV files

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 10:56 AM, Lowell Tackett lowelltack...@yahoo.com wrote: Please keep in mind, as I'd mentioned earlier, all of this is fairly new concepts to me; from running an interpretive Python screen, to delving into the zen of computing, [even] to pasting stuff from there to

Re: [Tutor] Question on import foobar vs from foobar import *

2010-01-08 Thread Kent Johnson
On Fri, Jan 8, 2010 at 2:39 PM, Rob Cherry pythontu...@lxrb.com wrote: Extending on this advice somewhat - is it *ever* correct to import foobar. There are countless examples of import os,sys etc,etc.  Strictly speaking should we always be using from to only get what we know we need? No,

Re: [Tutor] How to open the closed file again?

2010-01-05 Thread Kent Johnson
2010/1/5 朱淳 zhuchu...@gmail.com: Hi all,     I put files in a list, just like this module: #! /usr/bin/python # -*- coding=utf-8 -*- fileList = [] def openFiles():     for i in range(0,2):     fname = file%s%i     f = open(fname,a)     fileList.append(f) def

  1   2   3   4   5   6   7   8   9   10   >