Re: Newbie: Explain My Problem

2005-06-29 Thread John Machin
[EMAIL PROTECTED] wrote: [snip] > while counter != 0: > if guess == num: [snip] Others have told you already what was wrong with your program. Here's a clue on how you could possibly help yourself: 1. Each time around your loop, print the values of the interesting objects, in this case coun

Re: Boss wants me to program

2005-06-29 Thread John Machin
Thomas Bartkus wrote: > "phil" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>>About teaching in the exact sciences: I think we need a more hands-on >>>applied approach, to some extent this holds for the entire school >>>system. >> >>YES! As a geometry(& trig) teacher, I am goin

Re: aligning text with space-normalized text

2005-06-29 Thread John Machin
Steven Bethard wrote: [snip] > And it appears to work: [snip] > But it seems somewhat inelegant. Can anyone see an easier/cleaner/more > Pythonic way[1] of writing this code? > > Thanks in advance, > > STeVe > > [1] Yes, I'm aware that these are subjective terms. I'm looking for > subjective

Re: Help please: How to assign an object name at runtime

2005-06-29 Thread John Machin
[EMAIL PROTECTED] wrote: > Good day: > Probably the answer to my question is staring me in the face, but the > solution escapes me. > > The following is the input line of the file: SoftDict-.csv: > ca1017,GRPHScriptSet,ADD/REM,Adobe Acrobat 4.0=2005/06/14 > > I expected an instance of Machine()

Re: aligning text with space-normalized text

2005-06-30 Thread John Machin
Steven Bethard wrote: > John Machin wrote: > >> If "work" is meant to detect *all* possibilities of 'chunks' not >> having been derived from 'text' in the described manner, then it >> doesn't work -- all information about the

Re: Store multiple dictionaries in a file

2005-06-30 Thread John Machin
bruno modulix wrote: > Philipp H. Mohr wrote: >>My code currently produces a new dictionary every iteration and >>passes it on to another peace of code. > > > May this code rest in piece Perhaps it's the piece of code that passeth all understanding? -- http://mail.python.org/mailman/listinfo

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-07-01 Thread John Machin
Simon Brunning wrote: > On 7/1/05, Peter Maas <[EMAIL PROTECTED]> wrote: > >>Simon Brunning schrieb: >> >>>Sibylle Koczian needs to sort part of a list. His first attempt made >>>the natural mistake - sorting a *copy* of part of the list: >> >>I think it was _her_ first attempt. > > > Oo

Re: Splitting string into dictionary

2005-07-01 Thread John Machin
David Pratt wrote: > I have string text with language text records that looks like this: > > 'en' | 'the brown cow' | 'fr' | 'la vache brun' Pardonnez-moi, but I thought "how now brown cow" translated into something like "comme maintenant vache brune" -- something about the adjectives agreeing

Re: Running Python interpreter in Emacs

2005-07-01 Thread John Machin
Rex Eastbourne wrote: > Yes! Thank you so much! (For some reason, by the way, I had to copy > python.exe to my c:/ directory, No, you did _not_ need to copy it there. You did _not_ need to copy it anywhere. Didn't copying an executable to your root directory [on any operating system] strike you

Re: Python, mysql, floating point values question

2005-07-01 Thread John Machin
Terry Hancock wrote: > On Friday 01 July 2005 05:40 pm, Christopher Kang wrote: > >>Anyway, I have a problem where I am pulling floating point values out >>of mysql and into python using the MYSQLdb module. >> >>However, the values seem to be altered a little when I store them in python. > > > I

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)

2005-07-02 Thread John Machin
Christos TZOTZIOY Georgiou wrote: > On Fri, 01 Jul 2005 23:45:57 +1000, rumours say that John Machin > <[EMAIL PROTECTED]> might have written: > > >>Simon Brunning wrote: >> >>>On 7/1/05, Peter Maas <[EMAIL PROTECTED]> wrote: >>> >>>

Re: What's wrong with this code?

2005-07-02 Thread John Machin
Nathan Pinno wrote: > Hi all, > > What's wrong with the following code? It says there is name error, that > random is not defined. How do I fix it? Others have already answered that question. This posting is a pre-emptive strike to head off the next half-a-dozen questions. > > # Plays th

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread John Machin
Roy Smith wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: > >>I guess as long as the NTP client is set up to ensure the time >>adjustments are smaller than some value X, it would be acceptable. > > > NTP is generally capable of keeping the various system clocks on a LAN > within a few ms of e

Re: What's wrong with this code?

2005-07-02 Thread John Machin
John Machin wrote: > Nathan Pinno wrote: >> guess = input("Guess a number: ") > > > "guess" will refer to a string e.g. "42" which will *not* compare equal > to the integer 42. Also you should use raw_input, not input. > &g

Re: Do a "Python beginners e-mail list" exist?

2005-07-07 Thread John Machin
Alessandro Brollo wrote: > Far from a professional programmer, I'm simply a > newbie Python user. Two basic questions: > > 1. I don't want to post banal questions about Python > to main Python list. Does a "banal Python questions > list" or a "Python beginners list" exist? http://mail.python.org/

Re: Create datetime instance using a tuple.

2005-07-07 Thread John Machin
Negroup wrote: >>Use: >>dt =3D datetime(*t) >> > > > Thanks for the quick reply. > I can't find any doc about '*' used in this context. Have you some url > or suggestion for which terms search in Google? http://www.python.org/doc/2.4.1/tut/tut.html Then read this section 4.7.4 Unpacking Argum

Re: print values from Py_BuildValue

2005-07-07 Thread John Machin
[EMAIL PROTECTED] wrote: > Hello, > > How do i print values returned by Py_BuildValue in Linux? 1. The same way as you would "in" any other operating system. 2. With difficulty. 3. If you must print something from C, print the C components (no difficulty). 4. If you are interested in checking wh

Re: directory traverser

2005-07-09 Thread John Machin
Florian Lindner wrote: > Hello, > IIRC there is a directory traverser for walking recursively through > subdirectories in the standard library. But I can't remember the name and > was unable to find in the docs. Where did you look? How did you look? > Anyone can point me to it? Did you try Googl

Re: Formatting data to output in web browser from web form

2005-07-09 Thread John Machin
Harlin Seritt wrote: > Hi, > > I am using CherryPy to make a very small Blog web app. > > Of course I use a textarea input on a page to get some information. > Most of the time when text is entered into it, there will be carriage > returns. > > When I take the text and then try to re-write it ou

Re: Problem with sha.new

2005-07-09 Thread John Machin
Florian Lindner wrote: > Hello, > I try to compute SHA hashes for different files: > > > for root, dirs, files in os.walk(sys.argv[1]): > for file in files: > path = os.path.join(root, file) > print path > f = open(path) print "sha is", repr(sha) ### self-help !!!

Re: Should I use "if" or "try" (as a matter of speed)?

2005-07-09 Thread John Machin
Roy Smith wrote: > Well, you've now got a failure. I used to write Fortran on punch cards, which were then fed into an OCR gadget? That's an efficient approach -- where I was, we had to write the FORTRAN [*] on coding sheets; KPOs would then produce the punched cards. [snip] > > 3) In some

Re: Codecs

2005-07-10 Thread John Machin
Ivan Van Laningham wrote: > > It seems to me that if I want to try to read an unknown file > using an exhaustive list of possible encodings ... Supposing such a list existed: What do you mean by "unknown file"? That the encoding is unknown? Possibility 1: You are going to try to decode the fil

Re: extend for loop syntax with if expr like listcomp&genexp ?

2005-07-11 Thread John Machin
Bengt Richter wrote: > E.g., so we could write > > for x in seq if x is not None: Chundrous; looks like that p**l language ... > print repr(x), "isn't None ;-)" > > instead of > > for x in (x for x in seq if x is not None): Byzantine ... > print repr(x), "isn't None ;

Re: Slicing every element of a list

2005-07-12 Thread John Machin
Alex Dempsey wrote: > Recently I tried to slice every element of a list of strings. First I tried: "slice"? Interesting terminology. Next problem you have, try posting an example of your input, and your expected output. E.g. repr(input_string): '"foo"\t"barre"\t"zot"\t"X"\n' repr(output_list): [

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > I'm parsing a text file to extract word definitions. For example the > input text file contains the following content: > > di.va.gate \'di_--v*-.ga_-t\ vb > pas.sim \'pas-*m\ adv : here and there : THROUGHOUT > > I am trying to obtain words between two literal backslash

Re: append one file to another

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > > I want to append one (huge) file to another (huge) file. The current > way I'm doing it is to do something like: > > infile = open (infilename, 'r') > filestr = infile.read() > outfile = open(outfilename, 'a') > outfile.write(filestr) > > I wonder if there is

Re: Help with inverted dictionary

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > I will transfer eventually use a database but is there any way for now > you could help me make the text files? Thank you so much. Reece > No. There is utterly no reason why you should create 5000 or 3 text files. While you are waiting to get a clue about databas

Re: all possible combinations

2005-07-13 Thread John Machin
Steven D'Aprano wrote: > On Wed, 13 Jul 2005 10:39:41 -0400, rbt wrote: [snip] > Ah, then that's easy. Sit down with pencil and paper, write out all 64 > combinations yourself, and then type them into a Python list. Then you can > access any one of those combinations with a single call. [snip] >>My

Re: all possible combinations

2005-07-13 Thread John Machin
rbt wrote: > On Wed, 2005-07-13 at 10:21 -0400, rbt wrote: > >>Say I have a list that has 3 letters in it: >> >>['a', 'b', 'c'] >> >>I want to print all the possible 4 digit combinations of those 3 >>letters: >> >>4^3 = 64 >> >> >>abaa >>aaba >>aaab >>acaa >>aaca >>aaac >>... >> >>What is the

Re: 2.4 Recent File list not working

2005-07-13 Thread John Machin
Larry Bates wrote: > I recently upgraded from 2.2 to 2.4 (ActiveState for Windows). > I was accustomed to having the most recent 10 files that I had > edited show up under File menu under Recent. "File menu" of what? Let's guess that you mean Pythonwin. The problem is now fixed. It is possible th

Re: Help - Classes and attributes

2005-07-13 Thread John Machin
rh0dium wrote: > Hi all, > > I believe I am having a fundamental problem with my class and I can't > seem to figure out what I am doing wrong. Basically I want a class > which can do several specific ldap queries. So in my code I would have > multiple searches. But I can't figure out how to do

Re: How can I import a py script by its absolute path name?

2005-07-14 Thread John Machin
Thorsten Kampe wrote: > * Edvard Majakari (2005-07-14 12:52 +0100) > >>could ildg <[EMAIL PROTECTED]> writes: >> >>>I want to import c:\xxx\yyy\zzz.py into my programme, >>>What should I do? >>>Thank you~ >> >>import sys >>sys.path.append('c:\xxx\yyy') > > > "sys.path.append('c:\\xxx\\yyy')" or

Re: all possible combinations

2005-07-14 Thread John Machin
Steven D'Aprano wrote: > On Thu, 14 Jul 2005 08:49:05 +1000, John Machin wrote: > > >>"You keep using that word. I do not think it means what you think it means." >> >>Both of you please google("define: combination") > > > Combinat

Re: all possible combinations

2005-07-14 Thread John Machin
rbt wrote: > Thanks to all who were helpful... some of you guys are too harsh and > cynical. Reality check: wander down to your nearest military establishment, ask a drill sergeant to demonstrate "harsh and cynical". > Here's what I came up with. I believe it's a proper > combination, but I'm su

Re: readlines() doesn't read entire file

2005-07-14 Thread John Machin
Jeremy wrote: > I have a most aggravating problem. I don't understand what is causing > readlines() not to read all the lines in the file. Answer all of Peter Hansen's questions, then read on ... You are on platform X; did you get the file from platform Y where Y != X? Where did you get the fi

Re: Python Programming Contest

2005-07-17 Thread John Machin
John Hazen wrote: > * Brian Quinlan <[EMAIL PROTECTED]> [2005-07-15 02:08]: > >>You can find the first problem here: >>http://www.sweetapp.com/pycontest/contest1 > > > I have one question about the problem. Is the cost we are to minimize > the cost of arriving in the target city at all, or the

Re: Documentation bug: Python console behaviour changed

2005-07-19 Thread John Machin
Kay Schluehr wrote: > > Peter Hansen schrieb: > >>Kay Schluehr wrote: >> >>>The documentation of the Python console behaviour is not correct >>>anymore for Python 2.4.1. At least for the Win2K system I'm working on >>>'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc. >>> >>>The Python int

Re: is a file open ?

2005-07-20 Thread John Machin
luis wrote: > for root, dirs, files in os.walk(path): >for file in files: > # ¿ is opened ? > ¡ rtfm ! "files" is a list of fileNAMEs -- i.e. strings. ¿ How could you possibly imagine that your sample code would open a file? What a design-nonsense that would be: instant complaints from

Re: is a file open ?

2005-07-20 Thread John Machin
Daniel Dittmar wrote: > luis wrote: > >> for root, dirs, files in os.walk(path): >>for file in files: >> # ¿ is opened ? > > > On Linux and some other Unixes, you can probably read the /proc filesystem. > > On Windows, you'll probably get the quickest result by running > handle.exe (

Re: is a file open ?

2005-07-21 Thread John Machin
luis wrote: > John Machin wrote: > >> Daniel Dittmar wrote: >> >>> luis wrote: >>> >>>> for root, dirs, files in os.walk(path): >>>>for file in files: >>>> # ¿ is opened ? >>> >>> >>>

Re: Difference between " and '

2005-07-22 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > > Can someone tell me the difference between single quote and double > quote? >>> ord("'") - ord('"') 5 or ask a meaningful question ... -- http://mail.python.org/mailman/listinfo/python-list

Re: problem with string

2005-07-22 Thread John Machin
Tzanko Tzanev wrote: > hi :) > I need some help for this script > I have > > cursor = conn.cursor() > cursor.execute("select * from playlist limit 5") > result = cursor.fetchall() > # iterate through resultset > playlist_txt = '' > for record in result: > mp3id = record[0] > mp

Re: find a specified dictionary in a list

2005-07-22 Thread John Machin
Odd-R. wrote: > I have this list: > > [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] > > All the dictionaries of this list are of the same form, and all the oids > are distinct. If I have an oid and the list, how is the simplest way of > getting the dictionary that hold

Re: find a specified dictionary in a list

2005-07-22 Thread John Machin
John Machin wrote: > Odd-R. wrote: > >> I have this list: >> >> [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] >> >> All the dictionaries

Re: find a specified dictionary in a list

2005-07-22 Thread John Machin
Odd-R. Hogstad wrote (in private e-mail, with scarcely private contents): In comp.lang.python, you wrote: Odd-R. wrote: I have this list: [{'i': 'milk', 'oid': 1}, {'i': 'butter', 'oid': 2},{'i':'cake','oid':3}] All the dictionaries of this list are of the same fo

Re: Difference between " and '

2005-07-22 Thread John Machin
Peter Hansen wrote: > Steven D'Aprano wrote: > >> It may shock some people to learn that difference in the sense of >> mathematical subtraction is not the only meaning of the word, but >> there it is. One wouldn't, I hope, misunderstand "What is the >> difference between spaghetti marinara and

Re: PEP on path module for standard library

2005-07-22 Thread John Machin
Daniel Dittmar wrote: > Duncan Booth wrote: > >> I would have expected a path object to be a sequence of path elements >> rather than a sequence of characters. > > > Maybe it's nitpicking, but I don't think that a path object should be a > 'sequence of path elements' in an iterator context.

Re: PEP on path module for standard library

2005-07-22 Thread John Machin
Michael Hoffman wrote: > John Roth wrote: > >> However, a path as a sequence of characters has even less >> meaning - I can't think of a use, while I have an application >> where traversing a path as a sequence of path elements makes >> perfect sense: I need to descend the directory structure, dir

Re: Extending python - undefined symbol error on import

2005-07-22 Thread John Machin
ch424 wrote: [snip] > However, when I open up the python command line, and type "from gpib > import *" or "import gpib" I get "ImportError: /usr/.../gpibmodule.so: > undefined symbol: ibdev" -- but I know it's defined in the ni488.h > file, especially as I can use this code from actual C programs

Re: How to modify a file 'in place' ?

2005-07-22 Thread John Machin
Elby wrote: > I'm looking for a the most simple and generic way to modify a file, with the > possibility of making backups. In fact, I would like to emulate Perl's -i > option. > > here is a bit of code, to explain it further : > > < code > > > from os import rename > > class Modif_File

Re: tuple to string?

2005-07-22 Thread John Machin
Reinhold Birkenfeld wrote: > Berthold Höllmann wrote: > >>Francois De Serres <[EMAIL PROTECTED]> writes: >> >> >>>hiho, >>> >>>what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) >>>to the string 'spam'? >> >>.>>> t = (0x73, 0x70, 0x61, 0x6D) >>.>>> ''.join('%c' % c for c in t) >>

Re: tuple to string?

2005-07-23 Thread John Machin
Steven D'Aprano wrote: > > ''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D))) > > 'spam' Why the verbal diarrhoea? What's wrong with the (already posted) ''.join(map(chr, (0x73, 0x70, 0x61, 0x6D))) ??? -- http://mail.python.org/mailman/listinfo/python-list

Re: tuple to string?

2005-07-23 Thread John Machin
Reinhold Birkenfeld wrote: > John Machin wrote: > >>Reinhold Birkenfeld wrote: >> >>>Berthold Höllmann wrote: >>> >>> >>>>Francois De Serres <[EMAIL PROTECTED]> writes: >>>> >>>> >>>> >>&g

Re: tuple to string?

2005-07-24 Thread John Machin
Steven D'Aprano wrote: > On Sat, 23 Jul 2005 23:26:19 +1000, John Machin wrote: > > >>Steven D'Aprano wrote: >> >> >>> >>>>>>''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D))) >>> >>>'spam&#

Re: tuple to string?

2005-07-24 Thread John Machin
Steven D'Aprano wrote: > On Sat, 23 Jul 2005 23:31:04 +1000, John Machin wrote: > > >>>>You don't need the sissy parentheses; '%c' * len(t) % t works just fine :-) >>> >>> >>>Ah, ok. Didn't want to lookup the precedence rul

Re: tuple to string?

2005-07-24 Thread John Machin
Francois De Serres wrote: > Francois De Serres wrote: > >> hiho, >> >> what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) >> to the string 'spam'? >> >> TIA, >> Francois >> >> > thanks to all! > > I'll pick ('%c' * len(t)) % t, for it's readability and the fact that > join()

Re: Getting a dictionary from an object

2005-07-25 Thread John Machin
Dark Cowherd wrote: >>voiceless-ly'rs > > What does this mean?? Just curious (googled that and ly'rs and didnt > find anything relevant) The voiceless part I understand to mean that Bruno is "shocked and stunned and not a little bit amazed" [1] at Steven's masterstroke which came out of the blu

Re: pyparsing 1.3.2 released

2005-07-25 Thread John Machin
Paul McGuire wrote: > "The best laid plans o' mice an' men / Gang aft a-gley" > > So said Robert Burns (who really should do something about that speech > impediment!). If "schemes" sounds like "plans", perhaps the impediment is in the region of your ears :-) -- http://mail.python.org/mailman/l

Re: Time formatting and date suffixes

2005-07-25 Thread John Machin
Jeffrey E. Forcier wrote: > This seems like a dead simple question, as it's so rudimentary I can't > believe it hasn't been addressed before. I'm using the time.strftime() > function (actually the mxDateTime implementation, but they're > compatible so it shouldn't matter) to spit out fairly b

Re: regex problem

2005-07-26 Thread John Machin
Odd-R. wrote: > Input is a string of four digit sequences, possibly > separated by a -, for instance like this > > "1234,-,4567," > > My regular expression is like this: > > rx1=re.compile(r"""\A(\b\d\d\d\d,|\b\d\d\d\d-\d\d\d\d,)*\Z""") > > When running rx1.findall("1234,-,4567,

Re: regex problem

2005-07-26 Thread John Machin
Duncan Booth wrote: > John Machin wrote: > > >>So here's the mean lean no-flab version -- you don't even need the >>parentheses (sorry, Thomas). >> >> >>>>>rx1=re.compile(r"""\b\d\d\d\d,|\b\d\d\d\d-\d\d\d\d,"&

Re: How to convert a string like '777' to an octal integer like 0777?

2005-07-30 Thread John Machin
KB wrote: > Hi, > > This may be a rudimentary question: > > How to convert a string like '777' to an octal integer like 0777, > so that it can be used in os.chmod('myfile',0777)? > > I know the leading zero is important in os.chmod. There is no law that says constant arguments to os.chmod have

Re: Enumerate registered codecs

2005-07-31 Thread John Machin
Paul Watson wrote: > I see the list of standard encodings in Python 2.4.1 documentation > section 4.9.2. > > Is there a method to enumerate the registered codecs at runtime? This has been asked before, within the last couple of months AFAIR. Use Google to search for codec(s) in this newsgroup i

Re: subclassing list

2005-07-31 Thread John Machin
spike wrote: > I've googled like crazy and can't seem to find an answer to why this > isn't working. > > I want to create a custom list class that acts as a circular list. > > ie: my_list = (0, 1, 2) Perhaps you mean [0, 1, 2] > > how I want it to behave: > > my_list[0] -> 0 > my_list[1] -> 1

Re: Determining method type given its string name presentation and itscorresponding object reference.

2005-07-31 Thread John Machin
Terry Reedy wrote: > "Apple" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Hi I am a bit new to python. I was wondering if there is a way to >>determine whether or not a given string is a member method of a given >>object: > > > Does callable(cls.attr) fit your needs? > o

Re: about coding

2005-08-06 Thread John Machin
Benjamin Niemann wrote: > cantabile wrote: > > >>Hi, being a newbie in Python, I'm a bit lost with the '-*- coding : -*-' >>directive. >> >>I'm using an accented characters language. Some of them are correctly >>displayed while one doesn't. I've written : >>-*- coding: utf-8 -*- >> >>Is this wron

Re: Syntax error after upgrading to Python 2.4

2005-08-06 Thread John Machin
Fernando wrote: >>I don't see the problem yet. I certainly do not see anything that should >>have been affected by the upgrade (was it from 2.3 on XP also?) > > > Yes. > > >>After checking for nonprinting chars, I would shuffle the param-default >>lines to try to determine which is really at f

Re: Splitting a string into groups of three characters

2005-08-07 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi, > > Is there a function that split a string into groups, containing an "x" > amount of characters? > > Ex. > TheFunction("Hello World",3) > > Returns: > > ['Hell','o W','orl','d'] > > > Any reply would be truly appreciated. > > Thank You, > Maybe, somewhere o

Re: Splitting a string into groups of three characters

2005-08-07 Thread John Machin
gene tani wrote: > Um, you shd 1st search cookbook, or Vaults Parnassu, dmoz python > section, pypackage: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/347689 which includes e.g. def each_slice_lol(listin,n): """non-overlapp'g slices, return (list of lists) """ len_listin=le

Re: How to determine that if a folder is empty?

2005-08-08 Thread John Machin
Reinhold Birkenfeld wrote: > could ildg wrote: > >>I want to check if a folder named "foldername" is empty. >>I use os.listdir(foldername)==[] to do this, >>but it will be very slow if the folder has a lot of sub-files. >>Is there any efficient ways to do this? > > > try: > os.rmdir(path) >

Re: Splitting a string into groups of three characters

2005-08-08 Thread John Machin
William Park wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > >>Hi, >> >>Is there a function that split a string into groups, containing an "x" >>amount of characters? >> >>Ex. >>TheFunction("Hello World",3) >> >>Returns: >> >>['Hell','o W','orl','d'] >> >> >>Any reply would be truly apprec

Re: Does any one recognize this binary data storage format

2005-08-09 Thread John Machin
Bengt Richter wrote: > On Tue, 09 Aug 2005 21:50:06 -, Grant Edwards <[EMAIL PROTECTED]> wrote: > > >>On 2005-08-09, Scott David Daniels <[EMAIL PROTECTED]> wrote: >> >>>Grant Edwards wrote: >>> >Ex #1) 333- >Hex On disk: 00 00 00 80 6a 6e 49 41 > >Ex #2) 666- >H

Re: regex help

2005-08-11 Thread John Machin
jeff sacksteder wrote: > Regex questions seem to be rather resistant to googling. > > My regex currently looks like - 'FOO:.*\n\n' > > The chunk of text I am attempting to locate is a line beginning with > "FOO:", followed by an unknown number of lines, terminating with a > blank line. Clearly th

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Tom Deco wrote: > Hi, > > I'm trying to use a regular expression to match a string containing a # > (basically i'm looking for #include ...) > > I don't seem to manage to write a regular expression that matches this. > > My (probably to naive) approach is: p = re.compile(r'\b#include\b) > I also

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Duncan Booth wrote: > Dan wrote: > > >>>My (probably to naive) approach is: p = re.compile(r'\b#include\b) >> >>I think your problem is the \b at the beginning. \b matches a word break >>(defined as \w\W or \W\w). There would only be a word break before the # >>if the preceding character were a \

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Jeff Schwab wrote: > John Machin wrote: > >> Search for r'^something' can never be better/faster than match for >> r'something', and with a dopey implementation of search [which >> Python's re is NOT] it could be much worse. So please

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Duncan Booth wrote: > John Machin wrote: > > >>>Alternatively for C style #includes search for r'^\s*#\s*include\b'. >> >>Search for r'^something' can never be better/faster than match for >>r'something', and with a dopey impl

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Aahz wrote: > In article <[EMAIL PROTECTED]>, > John Machin <[EMAIL PROTECTED]> wrote: > >>Search for r'^something' can never be better/faster than match for >>r'something', and with a dopey implementation of search [which Python's

Re: len(sys.argv) in (3,4)

2005-08-11 Thread John Machin
bruno modulix wrote: > Daniel Schüle wrote: > >>Hello >> >>I wrote a simple module, which is also supposed to be used as standalone >>program >>after considering how to avoid multiple if's I came up with this idea >> >>if __name__ == "__main__": >>if len(sys.argv) not in (3,4): >>prin

Re: about coding

2005-08-11 Thread John Machin
Paul Watson wrote: > cantabile wrote: > >> Hi, being a newbie in Python, I'm a bit lost with the '-*- coding : >> -*-' directive. >> >> I'm using an accented characters language. Some of them are correctly >> displayed while one doesn't. I've written : >> -*- coding: utf-8 -*- >> >> Is this wron

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Devan L wrote: > John Machin wrote: > >>Aahz wrote: >> >>>In article <[EMAIL PROTECTED]>, >>>John Machin <[EMAIL PROTECTED]> wrote: >>> >>> >>>>Search for r'^something' can never be better/faster than match f

Re: Regular expression to match a #

2005-08-11 Thread John Machin
John Machin wrote: > Devan L wrote: > >> John Machin wrote: >> >>> Aahz wrote: >>> >>>> In article <[EMAIL PROTECTED]>, >>>> John Machin <[EMAIL PROTECTED]> wrote: >>>> >>>> >>>&

Re: Regular expression to match a #

2005-08-11 Thread John Machin
Devan L wrote: > John Machin wrote: > >>Devan L wrote: >> >>>John Machin wrote: >>> >>> >>>>Aahz wrote: >>>> >>>> >>>>>In article <[EMAIL PROTECTED]>, >>>>>John Machin

Re: Bug in slice type

2005-08-11 Thread John Machin
Steven Bethard wrote: > Bryan Olson wrote: > >> >> class BuggerAll: >> >> def __init__(self, somelist): >> self.sequence = somelist[:] >> >> def __getitem__(self, key): >> if isinstance(key, slice): >> start, stop, step = key.indices(len(

Re: UCALC equivalent

2005-08-12 Thread John Machin
Scott David Daniels wrote: > max wrote: > >> Larry Bates <[EMAIL PROTECTED]> wrote in >> news:[EMAIL PROTECTED]: >> >>> Python has built in eval function and doesn't require a library. >> >> >> Are you kidding? Read the original post a little more closely. The >> o.p. is looking for a library tha

Re: socket setdefaulttimeout

2005-08-13 Thread John Machin
Dennis Lee Bieber wrote: > > I've got the opposite problem -- I'm on a dial-up (well, for a few > more weeks -- until the DSL gear arrives). For some reason DNS lookups > seem to be low priority and, if I'm downloading messages in Agent (from > three servers yet) and email (Eudora), Firefox

Re: Spaces and tabs again

2005-08-13 Thread John Machin
Dan Sommers wrote: > On Sun, 14 Aug 2005 01:04:04 GMT, > Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > > >>On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the following >>in comp.lang.python: > > >>>Are you kidding? You are going to MANDATE spaces? >>> >> >> After the backlash,

Re: Parsing a log file

2005-08-14 Thread John Machin
CG wrote: [snip] > What I basically want to do is end up with a text file that can be > easily imported into a database with a format like this (or I guess it > could be written in a SQL script form that could write directly to a > database like Mysql): > > Connect_Date Connect_Time Disconnect_dat

Re: python-Excel: Chinese Characters

2005-08-14 Thread John Machin
zxo102 wrote: > Hi there, > I am trying to put data including Chinese Characters into Excel > through python. But I got some problems. Here is my sample code: > > ## > # > import win32com.client > xlapp = win32com.client.DispatchEx("Excel.Applic

Re: Spaces and tabs again

2005-08-14 Thread John Machin
Paul Watson wrote: > Dan Sommers wrote: > >> On Sun, 14 Aug 2005 01:04:04 GMT, >> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >> >> >>> On 13 Aug 2005 13:18:21 -0700, [EMAIL PROTECTED] declaimed the following >>> in comp.lang.python: >> >> >> Are you kidding? You are going to MANDATE spaces?

Re: Spaces and tabs again

2005-08-14 Thread John Machin
Paul Watson wrote: > John Machin wrote: > >> Paul Watson wrote: >> >>> Dan Sommers wrote: >>> >>>> On Sun, 14 Aug 2005 01:04:04 GMT, >>>> Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >>>> >>>> >

Re: How can I exclude a word by using re?

2005-08-15 Thread John Machin
Bruno Desthuilliers wrote: > could ildg a écrit : > >> Thank you. >> But what should I do if there are more than one hello and I only want >> to extract what's before the first "hello". > > > Read The Fine Manual ?-) > > >> For example, the raw >> string is "hi, how are you? hello I'm fine, t

Re: How can I exclude a word by using re?

2005-08-15 Thread John Machin
could ildg wrote: > In re, the punctuation "^" can exclude a single character, but I want > to exclude a whole word now. for example I have a string "hi, how are > you. hello", I want to extract all the part before the world "hello", > I can't use ".*[^hello]" because "^" only exclude single char "

Re: How to obtain GMT offset?

2005-08-15 Thread John Machin
new pip wrote: > I'm using Windows os. If the current system date time is '28 Jun 2001 > 14:17:15 +0700', how can I obtain the value '+0700' using python? If the current system date is in 2001, obtaining "GMT offset" is the least of your concerns :-) Have you read the section on the time module

Re: List copying idiom was Re: [Python-Dev] implementation of copy standard lib

2005-08-16 Thread John Machin
Tom Anderson wrote: > > When you say [:], do you mean that you copy lists like this: > > l = someList() > m = [] > m[:] = l > > ? Why not m = L[:] instead of m = []; m[:] = L ??? > > That's what i've been doing. The other day, i realised that i could just > do: > > l = someList() > m = list

Re: zlib + Windows 32 service problem (ImportError)

2005-08-17 Thread John Machin
Laszlo Zsolt Nagy wrote: > | > >> | >> C:\Python24;C:\Python24\DLLs;c:\Python24\Lib\site-packages\win32;c:\oracle\product\10.1.0\db_1\bin;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:

Re: Making programs work together.

2005-08-17 Thread John Machin
[EMAIL PROTECTED] wrote: > Example: I'm driving a car in a game and I hit an oil slick so instead > of me having to lift off the throttle button on the keyboard, I want to > make a program to disengage the throttle as long as I'm on that oil > slick. Does that clear anything up? > Yes. -- http

Re: up to date books?

2005-08-18 Thread John Machin
Alessandro Bottoni wrote: > > > Python did not changed too much since rel. 1.5. I presume by "too much" you mean "very much" rather than "inordinately" or "excessively". IMHO the addition of [list off the top of my head] string methods, Unicode, new-style classes, generators, list comprehensi

Re: how do i add a new path into sys.path?

2005-08-18 Thread John Machin
wen wrote: > on my system(win2k server, python 2.3.5), > import sys print sys.path > > ['C:\\', 'C:\\WINNT\\system32\\python23.zip', > 'C:\\Python23\\lib\\site-packages\\Pythonwin', > 'C:\\Python23\\lib\\site-packages\\win32', > 'C:\\Python23\\lib\\site-packages\\win32\\lib', > 'C:\\Pytho

Re: Bitwise operations in Python?

2005-08-18 Thread John Machin
Carl wrote: > Dear friends, > > I am currently porting a fortran program to Python but am stuck on the > intrinsic IBITS function. > > Does anyone know about a replacement function for IBITS in Python? > > Yours, Carl > > IBITS(I, POS, LEN) > > Extracts a sequence of bits. > > I > must b

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