Re: 2to3 chokes on bad character

2011-02-24 Thread John Machin
On Feb 23, 7:47 pm, "Frank Millman" wrote: > Hi all > > I don't know if this counts as a bug in 2to3.py, but when I ran it on my > program directory it crashed, with a traceback but without any indication of > which file caused the problem. > [traceback snipped] > UnicodeDecodeError: 'utf8' codec

Re: 2to3 chokes on bad character

2011-02-24 Thread John Machin
On Feb 25, 12:00 am, Peter Otten <__pete...@web.de> wrote: > John Machin wrote: > > Your Python 2.x code should be TESTED before you poke 2to3 at it. In > > this case just trying to run or import the offending code file would > > have given an informative syntax error

Re: py3k: converting int to bytes

2011-02-24 Thread John Machin
On Feb 25, 4:39 am, Terry Reedy wrote: > Note: an as yet undocumented feature of bytes (at least in Py3) is that > bytes(count) == bytes()*count == b'\x00'*count. Python 3.1.3 docs for bytes() say same constructor args as for bytearray(); this says about the source parameter: """If it is an integ

Re: getting text out of an xml string

2011-03-04 Thread John Machin
On Mar 5, 6:53 am, JT wrote: > Yo, > >  So I have almost convinced a small program to do what I want it to > do.  One thing remains (at least, one thing I know of at the moment): > I am converting xml to some other format, and there are strings in the > xml like this. > > The python: > > elif v ==

Re: getting text out of an xml string

2011-03-05 Thread John Machin
On Mar 5, 8:57 am, JT wrote: > On Mar 4, 9:30 pm, John Machin wrote: > > > Your data has been FUABARred (the first A being for Almost) -- the > > "\u3c00" and "\u3e00" were once "<" and ">" respectively. You will > > Hi John

Re: Snowball to Python compiler

2011-04-21 Thread John Machin
On Friday, April 22, 2011 8:05:37 AM UTC+10, Matt Chaput wrote: > I'm looking for some code that will take a Snowball program and compile > it into a Python script. Or, less ideally, a Snowball interpreter > written in Python. > > (http://snowball.tartarus.org/) If anyone has done such things

Re: codec for UTF-8 with BOM

2011-05-02 Thread John Machin
On Monday, 2 May 2011 19:47:45 UTC+10, Chris Rebert wrote: > On Mon, May 2, 2011 at 1:34 AM, Ulrich Eckhardt > wrote: > The correct name, as you found below and as is corroborated by the > webpage, seems to be "utf_8_sig": > >>> u"FOøbar".encode('utf_8_sig') > '\xef\xbb\xbfFO\xc3\xb8bar' To com

codecs.open() doesn't handle platform-specific line terminator

2011-05-09 Thread John Machin
According to the 3.2 docs (http://docs.python.org/py3k/library/codecs.html#codecs.open), """Files are always opened in binary mode, even if no binary mode was specified. This is done to avoid data loss due to encodings using 8-bit values. This means that no automatic conversion of b'\n' is done on

Re: unicode by default

2011-05-11 Thread John Machin
On Thu, May 12, 2011 8:51 am, harrismh777 wrote: > Is it true that if I am > working without using bytes sequences that I will not need to care about > the encoding anyway, unless of course I need to specify a unicode code > point? Quite the contrary. (1) You cannot work without using bytes seque

Re: urllib2 request with binary file as payload

2011-05-11 Thread John Machin
On Thu, May 12, 2011 10:20 am, Michiel Sikma wrote: > Hi there, > I made a small script implementing a part of Youtube's API that allows > you to upload videos. It's pretty straightforward and uses urllib2. > The script was written for Python 2.6, but the server I'm going to use > it on only has 2.

Re: unicode by default

2011-05-11 Thread John Machin
On Thu, May 12, 2011 11:22 am, harrismh777 wrote: > John Machin wrote: >> (1) You cannot work without using bytes sequences. Files are byte >> sequences. Web communication is in bytes. You need to (know / assume / >> be >> able to extract / guess) the input encodi

Re: unicode by default

2011-05-11 Thread John Machin
On Thu, May 12, 2011 1:44 pm, harrismh777 wrote: > By > default it looks like Python3 is writing output with UTF-8 as default... > and I thought that by default Python3 was using either UTF-16 or UTF-32. > So, I'm confused here... also, I used the character sequence \u00A3 > which I thought was UT

Re: unicode by default

2011-05-11 Thread John Machin
On Thu, May 12, 2011 2:14 pm, Benjamin Kaplan wrote: > > If the file you're writing to doesn't specify an encoding, Python will > default to locale.getdefaultencoding(), No such attribute. Perhaps you mean locale.getpreferredencoding() -- http://mail.python.org/mailman/listinfo/python-list

Re: unicode by default

2011-05-12 Thread John Machin
On Thu, May 12, 2011 4:31 pm, harrismh777 wrote: > > So, the UTF-16 UTF-32 is INTERNAL only, for Python NO. See one of my previous messages. UTF-16 and UTF-32, like UTF-8 are encodings for the EXTERNAL representation of Unicode characters in byte streams. > I also was not aware that UTF-8 chars

Re: Parsing a search string

2004-12-31 Thread John Machin
Andrew Dalke wrote: > "It's me" wrote: > > Here's a NDFA for your text: > > > >b 0 1-9 a-Z , . + - ' " \n > > S0: S0 E E S1 E E E S3 E S2 E > > S1: T1 E E S1 E E E E E E T1 > > S2: S2 E E S2 E E E E E T2 E > > S3: T3 E E S3 E E E E E E T3 > > Now if I only h

Re: Calling Function Without Parentheses!

2005-01-02 Thread John Machin
Kamilche wrote: > What a debug nightmare! I just spent HOURS running my script through > the debugger, sprinkling in log statements, and the like, tracking down > my problem. > > I called a function without the ending parentheses. I sure do WISH > Python would trap it when I try to do the following

Re: Calling Function Without Parentheses!

2005-01-02 Thread John Machin
Dan Bishop wrote: > Kamilche wrote: > > What a debug nightmare! I just spent HOURS running my script through > > the debugger, sprinkling in log statements, and the like, tracking > down > > my problem. > > > > I called a function without the ending parentheses. I sure do WISH > > Python would tra

Re: Py2exe and extension issues

2005-01-03 Thread John Machin
[EMAIL PROTECTED] wrote: > Is anyone aware of issues with Py2exe and extensions compiled with > cygwin/mingw for Python 2.3? I have an extension that wraps access to > some C DLLs. The generated executable always segfaults at startup, > although things work fine when running through the normal

Re: Speed ain't bad

2005-01-03 Thread John Machin
Anders J. Munch wrote: > Another way is the strategy of "it's easier to ask forgiveness than to > ask permission". > If you replace: > if(not os.path.isdir(zfdir)): > os.makedirs(zfdir) > with: > try: > os.makedirs(zfdir) > except EnvironmentError: > pass > > the

Re: emulating an and operator in regular expressions

2005-01-03 Thread John Machin
Terry Reedy wrote: > "Craig Ringer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Mon, 2005-01-03 at 08:52, Ross La Haye wrote: > >> How can an and operator be emulated in regular expressions in Python? > > Regular expressions are designed to define and detect repetition and

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-04 Thread John Machin
Steven Bethard wrote: > Sorry if this is a repost -- it didn't appear for me the first time. > > > So I was looking at the Language Reference's discussion about emulating > container types[1], and nowhere in it does it mention that .keys() is > part of the container protocol. I don't see any refe

Re: Reaching the real world

2005-01-04 Thread John Machin
Fuzzyman wrote: > I have a friend who would like to move and program lights and other > electric/electro-mechanical devices by computer. I would like to help - > and needless to say Python would be an ideal language for the > 'programmers interface'. Try Googling for "Python X10" -- http://mail

Re: why does UserDict.DictMixin use keys instead of __iter__?

2005-01-04 Thread John Machin
Steven Bethard wrote: > John Machin wrote: > > Steven Bethard wrote: > > > >>So I was looking at the Language Reference's discussion about > >>emulating container types[1], and nowhere in it does it mention that > >> .keys() is part of the container

Re: Pythonic search of list of dictionaries

2005-01-04 Thread John Machin
Bulba! wrote: [big snip] Forget the csv-induced dicts for the moment, they're just an artifact of your first solution attempt. Whether english = csv_row[1], or english = csv_row_dict["english"], doesn't matter yet. Let's take a few steps back, and look at what you are trying to do through a telesc

Re: Speed revisited

2005-01-08 Thread John Machin
Bulba! wrote: > On 4 Jan 2005 14:33:34 -0800, "John Machin" <[EMAIL PROTECTED]> > wrote: > > >(b) Fast forwarding 30+ years, let's look at the dictionary method, > >assuming you have enough memory to hold all your data at once: > > > >Step 1:

Re: Speed revisited

2005-01-09 Thread John Machin
Bulba! wrote: > On 8 Jan 2005 18:25:56 -0800, "John Machin" <[EMAIL PROTECTED]> > wrote: > > >Secondly, you are calling cmp() up to THREE times when once is enough. > >Didn't it occur to you that your last elif needed an else to finish it > >off, and

Re: Python3: on removing map, reduce, filter

2005-01-09 Thread John Machin
Steven Bethard wrote: > Note that list comprehensions are also C-implemented, AFAIK. Rather strange meaning attached to "C-implemented". The implementation generates the code that would have been generated had you written out the loop yourself, with a speed boost (compared with the fastest DIY ap

Re: Speed revisited

2005-01-09 Thread John Machin
Andrea Griffini wrote: > On 9 Jan 2005 12:39:32 -0800, "John Machin" <[EMAIL PROTECTED]> > wrote: > > >Tip 1: Once you have data in memory, don't move it, move a pointer or > >index over the parts you are inspecting. > > > >Tip 2: Develop an

Re: unicode mystery

2005-01-11 Thread John Machin
Sean McIlroy wrote: > I recently found out that unicode("\347", "iso-8859-1") is the > lowercase c-with-cedilla, so I set out to round up the unicode numbers > of the extra characters you need for French, and I found them all just > fine EXCEPT for the o-e ligature (oeuvre, etc). I examined the un

Octal notation: severe deprecation

2005-01-11 Thread John Machin
Some poster wrote (in connexion with another topic): > ... unicode("\347", "iso-8859-1") ... Well, I haven't had a good rant for quite a while, so here goes: I'm a bit of a retro specimen, being able (inter alia) to recall octal opcodes from the ICT 1900 series (070=call, 072=exit, 074=branch, .

Re: Importing Problem on Windows

2005-01-11 Thread John Machin
brolewis wrote: > I have a directory that has two files in it: > > parse.py > parser.py > > parse.py imports a function from parser.py and uses it to parse out the > needed information. On Linux, the following code works without a > problem: > > parse.py, line 1: > from parser import regexsearch >

Re: Importing Problem on Windows

2005-01-11 Thread John Machin
brolewis wrote: > I have a directory that has two files in it: > > parse.py > parser.py > > parse.py imports a function from parser.py and uses it to parse out the > needed information. On Linux, the following code works without a > problem: > > parse.py, line 1: > from parser import regexsearch >

Re: Help Optimizing Word Search

2005-01-11 Thread John Machin
Case Nelson wrote: > Hi there I've just been playing around with some python code and I've > got a fun little optimization problem I could use some help with. > > Basically, the program needs to take in a random list of no more than > 10 letters, and find all possible mutations that match a word

Re: SciTe

2005-01-11 Thread John Machin
Lucas Raab wrote: > I didn't want to go through the rigamole of adding myself to the SciTe > mailing list, so I'm asking my question here. How do I choose a > different C/C++ compiler to compile in?? I don't use the g++ compiler; I > use the VC 7 compiler. > > TIA, > Lucas How the @#$% should we

Re: Help Optimizing Word Search

2005-01-11 Thread John Machin
Paul Rubin wrote: > "Case Nelson" <[EMAIL PROTECTED]> writes: > > Basically, the program needs to take in a random list of no more than > > 10 letters, and find all possible mutations that match a word in my > > dictionary (80k words). However a wildcard letter '?' is also an > > acceptable char

Re: What strategy for random accession of records in massive FASTA file?

2005-01-12 Thread John Machin
Chris Lasher wrote: > Hello, > I have a rather large (100+ MB) FASTA file from which I need to > access records in a random order. The FASTA format is a standard format > for storing molecular biological sequences. Each record contains a > header line for describing the sequence that begins with a

Re: Pickled text file causing ValueError (dos/unix issue)

2005-01-14 Thread John Machin
On Fri, 14 Jan 2005 09:12:49 -0500, Tim Peters <[EMAIL PROTECTED]> wrote: >[Aki Niimura] >> I started to use pickle to store the latest user settings for the tool >> I wrote. It writes out a pickled text file when it terminates and it >> restores the settings when it starts. >... >> I guess DOS te

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Fredrik Lundh wrote: > > lst = [i for i in lst if i != 2] > > (if you have 2.4, try replacing [] with () and see what happens) The result is a generator with a name ("lst") that's rather misleading in the context. Achieving the same result as the list comprehension, by doing lst = list(i for

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Nick Coghlan wrote: > > I think this is about the best you can do for an in-place version: >for i, x in enumerate(reversed(lst)): > if x == 2: >del lst[-i] Don't think, implement and measure. You may be surprised. Compare these two for example: !def method_del_bkwds(lst, x): !

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Michael Hoffman wrote: > skull wrote: > > but I still have an other thing to worry about coming with this way: does > > performance sucks when the list is big enough? > > It makes a copy operation! > > > > here is a faster and 'ugly' solution: > > > > lst = [1, 2, 3] > > i = 0 > > while i < len(ls

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Nick Coghlan wrote: > I think this is about the best you can do for an in-place version: >for i, x in enumerate(reversed(lst)): > if x == 2: >del lst[-i] I think del lst[-i-1] might be functionally better. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to del item of a list in loop?

2005-01-15 Thread John Machin
Michael Hoffman wrote: > John Machin wrote: > > > Three significant figures is plenty. Showing just the minimum of the > > results might be better. > > It might be, but how much time do you want to spend on getting your > results for a benchmark that will be run

generator expressions: performance anomaly?

2005-01-16 Thread John Machin
Please consider the timings below, where a generator expression starts out slower than the equivalent list comprehension, and gets worse: >python -m timeit -s "orig=range(10)" "lst=orig[:];lst[:]=(x for x in orig)" 10 loops, best of 3: 6.84e+004 usec per loop >python -m timeit -s "orig=range(

Re: How to del item of a list in loop?

2005-01-16 Thread John Machin
Bengt Richter wrote: > No one seems to have suggested this in-place way yet, > so I'll trot it out once again ;-) > > >>> lst = [1, 2, 3] > >>> i = 0 > >>> for item in lst: > ...if item !=2: > ...lst[i] = item > ...i += 1 > ... > >>> del lst[i:] > >>> lst > [1, 3] Wo

Re: generator expressions: performance anomaly?

2005-01-16 Thread John Machin
On Sun, 16 Jan 2005 12:18:23 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >"John Machin" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> Please consider the timings below, where a generator expression starts >> out slowe

Re: How to del item of a list in loop?

2005-01-16 Thread John Machin
skull wrote: > According to Nick's article, I added three 'reversed' methods to your provided > test prog. and the result turned out method_reversed is faster than others except the 'three' case. > Following is my modified version: [snip] > def method_reversed_idx(lst): > idx = 0 > for i

Re: Fuzzy matching of postal addresses

2005-01-17 Thread John Machin
Ermmm ... only remove "the" when you are sure it is a whole word. Even then it's a dodgy idea. In the first 1000 lines of the nearest address file I had to hand, I found these: Catherine, Matthew, Rotherwood, Weatherall, and "The Avenue". Ermmm... don't rip out commas (or other punctuation); repla

Re: Fuzzy matching of postal addresses

2005-01-17 Thread John Machin
You can't even get anywhere near 100% accuracy when comparing "authoritative sources" e.g. postal authority and the body charged with maintaining a database of which streets are in which electoral district -- no, not AUS, but close :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Fuzzy matching of postal addresses

2005-01-18 Thread John Machin
John Machin wrote: > Ermmm ... only remove "the" when you are sure it is a whole word. Even > then it's a dodgy idea. In the first 1000 lines of the nearest address > file I had to hand, I found these: Catherine, Matthew, Rotherwood, > Weatherall, and "The Avenue&

Re: file copy portability

2005-01-18 Thread John Machin
Bob Smith wrote: > Is shutil.copyfile(src,dst) the *most* portable way to copy files with > Python? I'm dealing with plain text files on Windows, Linux and Mac OSX. > > Thanks! Portable what? Way of copying?? Do you want your files transferred (a) so that they look like native text files on the

Re: list item's position

2005-01-19 Thread John Machin
On Wed, 19 Jan 2005 22:02:51 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: > >See Mark's post, if you "need to know the index of something" this is >the perfect case for enumerate (assuming you have at least Python 2.3): But the OP (despite what he says) _doesn't_ need to know the index of th

Re: why no time() + timedelta() ?

2005-01-20 Thread John Machin
Tim Peters wrote: > [josh] > > Why can't timedelta arithmetic be done on time objects? > > Obviously, because it's not implemented . > > > (e.g. datetime.time(5)-datetime.timedelta(microseconds=3) > > > > Nonzero "days" of the timedelta could either be ignored, or > > trigger an exception. > > And

Re: Unbinding multiple variables

2005-01-20 Thread John Machin
Johnny Lin wrote: > Hi! > > Is there a way to automate the unbinding of multiple variables? Say I > have a list of the names of all variables in the current scope via > dir(). Is there a command using del or something like that that will > iterate the list and unbind each of the variables? Yes.

Re: Simple (newbie) regular expression question

2005-01-21 Thread John Machin
André Roberge wrote: > Sorry for the simple question, but I find regular > expressions rather intimidating. And I've never > needed them before ... > > How would I go about to 'define' a regular expression that > would identify strings like > __alphanumerical__ as in __init__ > (Just to spell th

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: > I have a short multi-threaded script that checks web images to make > sure they are still there. I get a segmentation fault everytime I run > it and I can't figure out why. Writing threaded scripts is new to me so > I may be doing something wrong that should be obvious :( >

Re: why am I getting a segmentation fault?

2005-01-21 Thread John Machin
Jay donnell wrote: > >### Have you looked in your database to see if the >script has > actually > >updated item.goodImage? Do you have a test plan? > > Thank you for the help. Sorry for the messy code. I was under time > constraints. I had class, and I was rushing to get this working before > cla

Re: getting file size

2005-01-21 Thread John Machin
Bob Smith wrote: > Are these the same: > > 1. f_size = os.path.getsize(file_name) > > 2. fp1 = file(file_name, 'r') > data = fp1.readlines() > last_byte = fp1.tell() > > I always get the same value when doing 1. or 2. Is there a reason I > should do both? When reading to the end of a file,

Re: getting file size

2005-01-23 Thread John Machin
Tim Roberts wrote: > Bob Smith <[EMAIL PROTECTED]> wrote: > > >Are these the same: > > > >1. f_size = os.path.getsize(file_name) > > > >2. fp1 = file(file_name, 'r') > >data = fp1.readlines() > >last_byte = fp1.tell() > > > >I always get the same value when doing 1. or 2. Is there a reason

Re: getting file size

2005-01-23 Thread John Machin
Tim Roberts wrote: > Bob Smith <[EMAIL PROTECTED]> wrote: > > >Are these the same: > > > >1. f_size = os.path.getsize(file_name) > > > >2. fp1 = file(file_name, 'r') > >data = fp1.readlines() > >last_byte = fp1.tell() > > > >I always get the same value when doing 1. or 2. Is there a reason

Re: Fuzzy matching of postal addresses [1/1]

2005-01-23 Thread John Machin
Andrew McLean wrote: > In case anyone is interested, here is the latest. > def insCost(tokenList, indx, pos): > """The cost of inserting a specific token at a specific normalised position along the sequence.""" > if containsNumber(tokenList[indx]): > return INSERT_TOKEN_WITH_NUMBER

Re: Set parity of a string

2005-01-23 Thread John Machin
Peter Hansen wrote: > snacktime wrote: > > Is there a module that sets the parity of a string? I have an > > application that needs to communicate with a host using even parity > > So what I need is before sending the message, convert it from space to > > even parity. And when I get the respons

Re: "bad argument type for built-in operation"

2005-01-24 Thread John Machin
Gilles Arnaud wrote: > Hello, > > I've got a nasty bug and no idea to deal with : > > here is the method : Big snip. The Python code is unlikely to be your problem. > and the trace > > in None [(-2.0, 2.0), (-2.0, 2.0)] [0.1385039192456847, > 0.87787941093093491] 2 2 > [0.1385039192456847, 0.8

Re: Looking for Form Feeds

2005-01-24 Thread John Machin
Greg Lindstrom wrote: > Hello- > I have a file generated by an HP-9000 running Unix containing form feeds > signified by ^M^L. I am trying to scan for the linefeed to signal > certain processing to be performed but can not get the regex to "see" > it. Suppose I read my input line into a variable

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Paul Kooistra wrote: > I need a tool to browse text files with a size of 10-20 Mb. These > files have a fixed record length of 800 bytes (CR/LF), and containt > records used to create printed pages by an external company. > > Each line (record) contains an 2-character identifier, like 'A0' or > 'C

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Paul Kooistra wrote: > I need a tool to browse text files with a size of 10-20 Mb. These > files have a fixed record length of 800 bytes (CR/LF), and containt > records used to create printed pages by an external company. > > Each line (record) contains an 2-character identifier, like 'A0' or > 'C

Re: How to input one char at a time from stdin?

2005-01-25 Thread John Machin
On Wed, 26 Jan 2005 01:15:10 +0530, Swaroop C H <[EMAIL PROTECTED]> wrote: >On Tue, 25 Jan 2005 12:38:13 -0700, Brent W. Hughes ><[EMAIL PROTECTED]> wrote: >> I'd like to get a character from stdin, perform some action, get another >> character, etc. If I just use stdin.read(1), it waits until I

Re: Browsing text ; Python the right tool?

2005-01-25 Thread John Machin
Jeff Shannon wrote: > Paul Kooistra wrote: > > > 1. Does anybody now of a generic tool (not necessarily Python based) > > that does the job I've outlined? > > 2. If not, is there some framework or widget in Python I can adapt to > > do what I want? > > Not that I know of, but... > > > 3. If not, s

Re: Browsing text ; Python the right tool?

2005-01-26 Thread John Machin
Jeff Shannon wrote: > John Machin wrote: > > > Jeff Shannon wrote: > > > >> [...] If each record is CRLF terminated, then > >>you can get one record at a time simply by iterating over the file > >>("for line in open('myfile.dat'

Re: Responding to trollish postings.

2005-01-26 Thread John Machin
Terry Reedy wrote: > > No offense taken. My personal strategy is to read only as much of trollish > threads as I find interesting or somehow instructive, almost never respond, > and then ignore the rest. I also mostly ignore discussions about such > threads. > Indeed. Let's just nominate XL to

Re: Why do look-ahead and look-behind have to be fixed-width patterns?

2005-01-27 Thread John Machin
inhahe wrote: > Hi i'm a newbie at this and probably always will be, so don't be surprised > if I don't know what i'm talking about. > > but I don't understand why regex look-behinds (and look-aheads) have to be > fixed-width patterns. > > i'm getting the impression that it's supposed to make sear

Re: py.dll for version 2.2.1 (Windows)

2005-01-28 Thread John Machin
mike wrote: > Just recently, my virus checker detected what it called a Trojan Horse > in the py.dll file in the python22 folder. Sorry to come on like the Inquisition, but this _might_ be something of significance to the whole Windows Python community: When was "just recently"? Which virus chec

Re: Awkwardness of C API for making tuples

2005-02-01 Thread John Machin
Dave Opstad wrote: > One of the functions in a C extension I'm writing needs to return a > tuple of integers, where the length of the tuple is only known at > runtime. I'm currently doing a loop calling PyInt_FromLong to make the > integers, What is the purpose of this first loop? In what variabl

Re: Awkwardness of C API for making tuples

2005-02-01 Thread John Machin
Dave Opstad wrote: > In article <[EMAIL PROTECTED]>, > "John Machin" <[EMAIL PROTECTED]> wrote: > > > What is the purpose of this first loop? > > Error handling. If I can't successfully create all the PyInts then I can > dispose the on

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-02 Thread John Machin
Leeuw van der, Tim TOP-POSTED: > Hi all, > > I can use this version of gtk and PyGtk to run simple programs. There seems to be no problem with the code-completion in PythonWin. > I can do: dir(gtk) without problems after importing the gtk module of PyGtk, when I use idle or console. (Python versio

Re: Reference count question

2005-02-02 Thread John Machin
Fredrik Lundh wrote: > > >PyList_SetItem(List,i,Str); > > you should check the return value, though. PyList_SetItem may (in > theory) fail. > :-) Only a bot could say that. We mere mortals have been known to do things like (a) pass a non-list as the first argument (b) pass an out-of-range va

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: > >> > Do you have a file called drwtsn32.log anywhere on your computer? > > No, unfortunately I cannot find such file anywhere on my computer > > What do I do to get such file? Or anything equally useful? > On my Windows 2000 box, just crash something :-) Perhaps t

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: > > > > > > -Original Message- > > From: [EMAIL PROTECTED] on behalf of John Machin > > Sent: Thu 2/3/2005 12:00 PM > > To: python-list@python.org > > Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4,

Re: Crashing Python interpreter! (windows XP, python2.3.4, 2.3.5rc1, 2.4.0)

2005-02-03 Thread John Machin
Leeuw van der, Tim wrote: > > > > > > -Original Message- > > From: [EMAIL PROTECTED] on behalf of John Machin > > Sent: Thu 2/3/2005 12:00 PM > > To: python-list@python.org > > Subject: Re: Crashing Python interpreter! (windows XP, python2.3.4,

Re: how to generate SQL SELECT pivot table string

2005-02-03 Thread John Machin
McBooCzech wrote: > Hallo all, > > I am trying to generate SQL SELECT command which will return pivot > table. The number of column in the pivot table depends on the data > stored in the database. It means I do not know in advance how many > columns the pivot table will have. > > For example I will

Re: Converting a string to a function pointer

2005-02-04 Thread John Machin
On Fri, 04 Feb 2005 12:01:35 +0100, Håkan Persson <[EMAIL PROTECTED]> wrote: >Hi. > >I am trying to "convert" a string into a function pointer. >Suppose I have the following: > >from a import a >from b import b >from c import c > >funcString = GetFunctionAsString() > >and funcString is a string th

Re: newbie: Syntax error

2005-02-04 Thread John Machin
Chad Everett wrote: > Hi Everyone, > > I am new to Python and programming in general. I bought the book "Python > Programming for the Absolute Beginner" by michael Dawson. > > I have been working through it but am having trouble. > I am trying to make a coin flip program and keep geting a Synax Er

Re: Error!

2005-02-04 Thread John Machin
administrata wrote: > I'm programming Car Salesman Program. > It's been "3 days" learning python... >From whom or what book or what tutorial? > But, i got problem You got problemS. What Jeff & Brian wrote, plus: You have "change" instead of "charge". You forgot to add in the base price -- "ac

Re: extreme newbie

2005-06-18 Thread John Machin
Dennis Lee Bieber wrote: > On 18 Jun 2005 07:48:13 -0700, "cpunerd4" <[EMAIL PROTECTED]> declaimed > the following in comp.lang.python: > > >>even so, >>crackers have a harder time getting into compiled programs rather than >>intepreted languages. I know hiding the code won't stop all crackers >

Re: oddness in super()

2005-06-18 Thread John Machin
Michael P. Soulier wrote: > Ok, this works in Python on Windows, but here on Linux, with Python 2.4.1, I'm > getting an error. > > The docs say: > > A typical use for calling a cooperative superclass method is: > > class C(B): > def meth(self, arg): > super(C, self).meth(arg) > > H

Re: struct.(un)pack and ASCIIZ strrings

2005-06-18 Thread John Machin
Terry Reedy wrote: > "Sergey Dorofeev" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>I can use string.unpack if string in struct uses fixed amount of bytes. > > > I presume you mean struct.unpack(format, string). The string len must be > known when you call, but need not b

Re: Regex for repeated character?

2005-06-18 Thread John Machin
Terry Hancock wrote: > On Saturday 18 June 2005 02:05 am, John Machin wrote: > >>Doug Schwarz wrote: >> >>>In article <[EMAIL PROTECTED]>, >>> Leif K-Brooks <[EMAIL PROTECTED]> wrote: >>> >>>>How do I make a regular expressi

Re: catch argc-argv

2005-06-20 Thread John Machin
mg wrote: > Hello, > > I am writting bindings for a FEM application. In one of my function > 'initModulename', called when the module is imported, I would like to > get the argc and argv arguments used in the main function of Python. This is an "interesting" way of writing bindings. Most peopl

Re: catch argc-argv

2005-06-20 Thread John Machin
Duncan Booth wrote: > John Machin wrote: > > >>>So, my question is: does the Python API containe fonctions like >>>'get_argc()' and 'get_argv()' ? >>> >> >>If you can't see them in the documentation, they aren't the

Re: Python and encodings drives me crazy

2005-06-20 Thread John Machin
Oliver Andrich wrote: > 2005/6/21, Konstantin Veretennicov <[EMAIL PROTECTED]>: > >>It does, as long as headline and caption *can* actually be encoded as >>macroman. After you decode headline from utf-8 it will be unicode and >>not all unicode characters can be mapped to macroman: >> >> >u'\u0

Re: reading a list from a file

2005-06-20 Thread John Machin
Rune Strand wrote: > But iif it are many lists in the file and they're organised like this: > > ['a','b','c','d','e'] > ['a','b','c','d','e'] > ['A','B','C','D','E'] ['X','F','R','E','Q'] > > I think this'll do it > > data = open('the_file', 'r').read().split(']') > > lists = [] > for el in dat

Re: utf8 silly question

2005-06-21 Thread John Machin
Jeff Epler wrote: > If you want to work with unicode, then write > us = u"\N{COPYRIGHT SIGN} some text" You can avoid almost all the wear and tear on your shift keys: >>> u"\N{copyright sign}" u'\xa9' ... you are stuck with \N for reasons that should be obvious :-) Cheers, John -- htt

Re: *Python* Power Tools

2005-06-21 Thread John Machin
Micah wrote: > Anyone know if there is any organized effort underway to implement the > Python equivalent of "Perl Power Tools" ? > > If not, would starting this be a waste of effort since: +1 WOFTAM-of-the-year > > - it's already being done in Perl? > - cygwin thrives? F

Re: oddness in shelve module

2005-06-21 Thread John Machin
Michael P. Soulier wrote: > I'm trying to add objects to a shelve db object via hash assignment, but > I'm getting an odd exception. > > Traceback (most recent call last): > File "RemGui.py", line 117, in onMonitorButton > self.startMonitoring() > File "RemGui.py", line 163, in startMonit

Re: oddness in shelve module

2005-06-22 Thread John Machin
Michael P. Soulier wrote: >On 22/06/05 John Machin said: > > > >>AFAICT, wrong "it". The "item assignment" which is alleged not to be >>supported is of this form: an_object[some_key] = a_value >> >>I.e. "self.db" is the sus

Re: trouble subclassing str

2005-06-23 Thread John Machin
Brent wrote: > I'd like to subclass the built-in str type. For example: You'd like to build this weird-looking semi-mutable object as a perceived solution to what problem? Perhaps an alternative is a class of objects which have a "key" (your current string value) and some data attributes? Mayb

Re: Sorting part of a list

2005-06-24 Thread John Machin
Sibylle Koczian wrote: > Hello, > > I thought I understood list slices, but I don't. I want to sort only the > last part of a list, preferably in place. If I do > > >>> ll = [3, 1, 4, 2] > >>> ll[2:].sort() It may help in unravelling any bogglement to point out that this is equivalent to te

Re: howto load and unload a module

2005-06-24 Thread John Machin
Peter Hansen wrote: > Guy Robinson wrote: > >> I have a directory of python scripts that all (should) contain a >> number of attributes and methods of the same name. >> >> I need to import each module, test for these items and unload the >> module. I have 2 questions. [snip] >> 2.. how do I test

Re: autoconfigure vss python question

2005-06-24 Thread John Machin
lode leroy wrote: > Hi folks, > > I'm trying to build a python module using MINGW on MSYS > the "configure" script is determining where python is installed as follows: > > python.exe -c 'import sys; print sys.prefix' > c:\Python24 > > which is good on native windows (i.e. when invoked from CMD.E

Re: Favorite non-python language trick?

2005-06-24 Thread John Machin
James wrote: > Interesting thread ... > > 1.) Language support for ranges as in Ada/Pascal/Ruby > 1..10 rather than range(1, 10) Did you mean 1..9 or 1...10 or both or neither? Can this construct be used like this: (i+1)..n ? If not, what would you use? What is the frequency of range literals i

Re: Favorite non-python language trick?

2005-06-24 Thread John Machin
James Stroud wrote: > On Friday 24 June 2005 05:58 am, Steven D'Aprano wrote: > >>with colour do begin >>red := 0; blue := 255; green := 0; >>end; >> >>instead of: >> >>colour.red := 0; colour.blue := 255; colour.green := 0; >> >>Okay, so maybe it is more of a feature than a trick, but I miss it a

  1   2   3   4   5   6   7   8   9   10   >