Re: [Tutor] Using the time module to extract a semi-random number

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 6:43 PM, Laurii wrote: > The exercise to modify a number guessing program from a fixed number "number > = 78" to using the time module and use the seconds at the time the program > is used to be the number. (i.e. if the clock on your computer says 7:35:25 > then it would t

Re: [Tutor] python queue

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 8:04 PM, Jeff Peery wrote: > > Hello, > Does anyone know if there is there a way to look at a queue's contents? Or > prevent duplicate messages from being put into a queue? The docs don't show > anything useful. The reason is that I'm collecting and drawing data. one > t

[Tutor] python queue

2009-09-16 Thread Jeff Peery
Hello, Does anyone know if there is there a way to look at a queue's contents? Or prevent duplicate messages from being put into a queue? The docs don't show anything useful. The reason is that I'm collecting and drawing data. one thread collects, and one thread draws. each time one sample is co

Re: [Tutor] Using the time module to extract a semi-random number

2009-09-16 Thread Mal Wanstall
Hi Katt, The following does the trick for me: number = int(time.strftime("%S", time.localtime())) There may be better ways to do it though. -Mal On Thu, Sep 17, 2009 at 8:43 AM, Laurii wrote: > Hello all, > > I am currently reading through the Tutorial for Non-Programers by Josh > Cogliati.  

[Tutor] Using the time module to extract a semi-random number

2009-09-16 Thread Laurii
Hello all, I am currently reading through the Tutorial for Non-Programers by Josh Cogliati. I have had great success until now. The exercise to modify a number guessing program from a fixed number "number = 78" to using the time module and use the seconds at the time the program is used to

Re: [Tutor] Convert doc to txt on Ubuntu

2009-09-16 Thread Rich Lovely
2009/9/16 Carnell, James E : > > I am needing to access the text in hundreds of Microsoft .doc files on an > Ubuntu OS. I looked at win32 , but only saw support for windows. I am going > through all of these files to create a fairly simple text delimited file for > a spreadsheet. > > A) Batch conve

Re: [Tutor] IDLE colon = syntax error

2009-09-16 Thread Dave Angel
Carnell, James E wrote: I searched through archives and wasn't able to find the solution. Using IDLE, python 3, Ubuntu (default installations). Using command line: > if 1 == 1: print "equal" > equal Using IDLE: >if 1 == 1: print "equal"

[Tutor] IDLE colon = syntax error

2009-09-16 Thread Carnell, James E
I searched through archives and wasn't able to find the solution. Using IDLE, python 3, Ubuntu (default installations). Using command line: > if 1 == 1: print "equal" > equal Using IDLE: >if 1 == 1: print "equal" >SyntaxError: in

Re: [Tutor] Convert doc to txt on Ubuntu

2009-09-16 Thread عماد نوفل
On Wed, Sep 16, 2009 at 3:03 PM, Carnell, James E < jecarn...@saintfrancis.com> wrote: > > I am needing to access the text in hundreds of Microsoft .doc files on an > Ubuntu OS. I looked at win32 , but only saw support for windows. I am going > through all of these files to create a fairly simple

[Tutor] Convert doc to txt on Ubuntu

2009-09-16 Thread Carnell, James E
I am needing to access the text in hundreds of Microsoft .doc files on an Ubuntu OS. I looked at win32 , but only saw support for windows. I am going through all of these files to create a fairly simple text delimited file for a spreadsheet. A) Batch convert to text files so I can access them B)

Re: [Tutor] Executing a command from a specific directory

2009-09-16 Thread Steve Willoughby
> Ansuman Dash wrote: > >Now I am trying to validate that the command is executed successfully. > >I have written following script to validate the log file which is created > >after running the command. Notice what's happening here: > >for line in f.readlines(): > >a=l

Re: [Tutor] Executing a command from a specific directory

2009-09-16 Thread Dave Angel
(Don't top-post; it makes reading the thread quite confusing) Ansuman Dash wrote: Hi, Thank you very much for the quick response. Code is working fine. Now I am trying to validate that the command is executed successfully. I have written following script to validate the log file which is cr

[Tutor] ImportError: cannot import name log

2009-09-16 Thread vishwajeet singh
Hi, Below is the content of __init__.py import sys from django.core.signals import got_request_exception from . import log logger = log._get_logger() def got_request_exception_callback(sender, **kwargs): """Logging all unhandled exceptions.""" type, exception, traceback = sys.exc_info()

Re: [Tutor] Fw: utf locale sorting

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 11:45 AM, Igor Mavrović - ma...@irb wrote: > Sorry Kent, I should have put it in the original message... > This is the way I call the sorted function: > >   # resultSet looks like: [[("DN", {"":["", ...], ...})], ...] > >   resultSetSortedByCn = sorted(resultSet, key=lambda

Re: [Tutor] Fw: utf locale sorting

2009-09-16 Thread Igor Mavrović - ma...@irb
Sorry Kent, I should have put it in the original message... This is the way I call the sorted function: # resultSet looks like: [[("DN", {"":["", ...], ...})], ...] resultSetSortedByCn = sorted(resultSet, key=lambda x:(x[0][1]["sn"], x[0][1]["givenName"])) resultSetSortedByOu = sorted(

Re: [Tutor] Fw: utf locale sorting

2009-09-16 Thread Rich Lovely
2009/9/16 Igor Mavrović - ma...@irb : > Hi, > > I know about the use of locale module: > import locale locale.setlocale(locale.LC_ALL, "hr_HR.UTF8") print sorted(words, key=locale.strxfrm) > > but I have specific and complicated data structure (list of lists containing > strings, tup

Re: [Tutor] Fw: utf locale sorting

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 9:51 AM, Igor Mavrović - ma...@irb wrote: > Hi, > > I know about the use of locale module: > import locale locale.setlocale(locale.LC_ALL, "hr_HR.UTF8") print sorted(words, key=locale.strxfrm) > > but I have specific and complicated data structure (list of li

Re: [Tutor] collecting certain data from a textfile

2009-09-16 Thread bob gailer
Please always reply-all so a copy goes to the Tutor list. Olli Virta wrote: Hi! Thanks for advice. I was thinking, if is there was other ways to get the wanted data out, than with that strip() method. Say what if I had to use it hundred times. Are you concerned with ease of coding or with per

Re: [Tutor] strings and replace

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 10:33 AM, Jojo Mwebaze wrote: > Hello There Again > > Might be a silly question but it has played me for the last two days! > > I have a string 'mystring' (pasted below), what i want  to do is to change > the values of  of NAXIS1 (=1024)  and NAXIS2 (=2048) to some other va

[Tutor] strings and replace

2009-09-16 Thread Jojo Mwebaze
Hello There Again Might be a silly question but it has played me for the last two days! I have a string 'mystring' (pasted below), what i want to do is to change the values of of NAXIS1 (=1024) and NAXIS2 (=2048) to some other values! say NAXIS1 = 999 and NAXIS2 = 888. These old values that i

[Tutor] Fw: utf locale sorting

2009-09-16 Thread Igor Mavrović - ma...@irb
Hi, I know about the use of locale module: import locale locale.setlocale(locale.LC_ALL, "hr_HR.UTF8") print sorted(words, key=locale.strxfrm) but I have specific and complicated data structure (list of lists containing strings, tuples and dictionaries) due to LDAP search result data. So I u

Re: [Tutor] Fwd: Executing a command from a specific directory

2009-09-16 Thread Sander Sweers
On Wed, 2009-09-16 at 18:03 +0530, Ansuman Dash wrote: > if "Request timed out.." not in a: > print("Ping is not successful.") > pLogger.info("Ping is not successful.") This will check for the string "Request timed out.." is NOT in a. Now when the ping i

Re: [Tutor] Fwd: Executing a command from a specific directory

2009-09-16 Thread Ansuman Dash
Hi, Thank you very much for the quick response. Code is working fine. Now I am trying to validate that the command is executed successfully. I have written following script to validate the log file which is created after running the command. =

Re: [Tutor] Still Trying to Understand GAE

2009-09-16 Thread Kent Johnson
On Sun, Sep 13, 2009 at 9:59 AM, ad...@gg-lab.net wrote: > Hi All, > > i've started earning python sone months ago (on Google App Engine > unfortunately). > > I have some doubts reagrding "import", and have asked a similar > question here months ago, but without finding a solution. > > So: > > wit

Re: [Tutor] : breaking out of a function that takes too long

2009-09-16 Thread Kent Johnson
On Wed, Sep 16, 2009 at 6:07 AM, C or L Smith wrote: >>> Serdar wrote: > ... >>> So again, is there a way to place a time limit on the execution of a >>> function, after which you can break out of it and then retry it or >>> move along with the rest of your program? > > At http://tinyurl.com/rbre9

Re: [Tutor] Still Trying to Understand GAE

2009-09-16 Thread Gerard Flanagan
ad...@gg-lab.net wrote: The "google" directoy has an empty __init__.py file (well, if we want to be completely correct it contains some commented -#- lines). Same for "appengine", "net" and "pyglib". As they all have an __init__.py file, they should be consiedered as modules from the python inter

Re: [Tutor] Parsing html tables and using numpy for subsequent processing

2009-09-16 Thread Gerard Flanagan
David Kim wrote: Hello all, I've finally gotten around to my 'learn how to parse html' project. For those of you looking for examples (like me!), hopefully it will show you one potentially thickheaded way to do it. [...] The code can be found at pastebin: http://financialpython.pastebin.com

Re: [Tutor] Wordscramble.py

2009-09-16 Thread Lie Ryan
David wrote: kreglet wrote: This is my first Python project. I am doing this to help me learn the language. I was wondering if someone could give me some advice as I have a lot of questions. 1. I would like to have someone look over the code and tell me how to improve it. I am sure that a

[Tutor] : breaking out of a function that takes too long

2009-09-16 Thread C or L Smith
>> Serdar wrote: ... >> So again, is there a way to place a time limit on the execution of a >> function, after which you can break out of it and then retry it or >> move along with the rest of your program? At http://tinyurl.com/rbre9n you can find a recipe that tells you how to decorate a funct

Re: [Tutor] Executing a command from a specific directory

2009-09-16 Thread Alan Gauld
"Ansuman Dash" wrote In Python scripting, how can I execute a command (which can be run from spcific directory) and then retrieve the result (after executing the command it give the command is executed successfull or not), so that I can validate it. There are sweveral ways to do this but

Re: [Tutor] Parsing html tables and using numpy for subsequentprocessing

2009-09-16 Thread Alan Gauld
"David Kim" wrote > The code can be found at pastebin: > http://financialpython.pastebin.com/f4efd8930 Nothing to do with the parsing but I noticed: def get_files(path): ''' Get a list of all files in a given directory. Returns a list of filename strings. ''' files = os

Re: [Tutor] Fwd: Executing a command from a specific directory

2009-09-16 Thread Patrick Sabin
Ansuman Dash schrieb: Hello Everybody, In Python scripting, how can I execute a command (which can be run from spcific directory) and then retrieve the result (after executing the command it give the command is executed successfull or not), so that I can validate it. Thanks, AD import