Re: incompatible exit values between python 2.4 and 2.5

2006-09-18 Thread John Machin
Diez B. Roggisch wrote: > > 1) is this change of behaviour documented somewhere and did I miss > > that, or has this not been documented (yet) > > 2) Is there a build-in way to set the exit value for Python in case an > > exception is raised that is uncaught and causes python to terminate? (I > >

Re: Automatically installing libraries?

2006-09-18 Thread John Machin
Chaz Ginger wrote: > Here is a problem I am trying to solve; I am sure there must be an easy > way to do it and I just don't know how. > > I have a rather large application that I am writing. To make it easy for > the user to run I have them run a startup.py script. This script will > try to load

Re: Which date will it be 'over x days'?

2006-09-18 Thread John Machin
cyberco wrote: > I must be overlooking something since I can't find a simple way to > calculate which date it will be over, say, 9 days. I checked the > datetime, time and calendar modules, but none of them seem to have a > function to calculate the time offset. I suppose that it depends on your t

Re: Cheese Shop Registration error

2006-09-18 Thread John Machin
Richard Jones wrote: > [EMAIL PROTECTED] wrote: > > The Key ID that the kgpg shows. I tried to paste the key returned by > > the quiery on the keyserver. but it also doesn't work. I tried > > everything that has any connection with the key, but everything fails. > > > > By the way the key is: 6A61

Re: Installing 2.5 with 2.4?

2006-09-19 Thread John Machin
John Salerno wrote: > Diez B. Roggisch wrote: > > John Salerno wrote: > > > >> Hi all. Just curious, before I do it myself, about the best way to > >> install 2.5 if it's the only version I want to use. Should I uninstall > >> 2.4 first? Does 2.5 replace 2.4? I doubt the latter, but if I install >

Re: Cheese Shop Registration error

2006-09-19 Thread John Machin
Richard Jones wrote: > John Machin wrote: > > | >>> int("6A61E3AD") > > Traceback (most recent call last): > > File "", line 1, in ? > > ValueError: invalid literal for int(): 6A61E3AD > > | >>> int("6A61E3AD", 16)

Re: value exists (newbie question)

2006-09-19 Thread John Machin
eldorado wrote: > Hello, > > I am trying to parse some files so that if a postal code exists, but is > longer than five digits it will return me only the first five digits: > ... > for insDict in insureDict: > insDict['postalcode'] = insDict.get('postalcode')[:5] > ... > This works, except fo

Re: xlrd number of rows in worksheet (was: Re: Pre-defining an action to take when an expected error occurs)

2006-09-19 Thread John Machin
ng is > based on the functions' returned number of cells containing text, > excluding a space as text, against the actual, hand counted number of > cells with text. So your worksheet(s) did have rows at the end with cells with spaces in them? > Thank you John Machin for all of

Re: byte count unicode string

2006-09-19 Thread John Machin
willie wrote: > # What's the correct way to get the > # byte count of a unicode (UTF-8) string? > # I couldn't find a builtin method > # and the following is memory inefficient. > > ustr = "example\xC2\x9D".decode('UTF-8') > > num_chars = len(ustr)# 8 > > buf = ustr.encode('UTF-8') > > num_byte

Re: byte count unicode string

2006-09-20 Thread John Machin
willie wrote: > Marc 'BlackJack' Rintsch: > > >In <[EMAIL PROTECTED]>, willie wrote: > >> # What's the correct way to get the > >> # byte count of a unicode (UTF-8) string? > >> # I couldn't find a builtin method > >> # and the following is memory inefficient. > > >> ustr = "example\xC2\x9D"

Re: byte count unicode string

2006-09-20 Thread John Machin
willie wrote: > >willie wrote: > >> Marc 'BlackJack' Rintsch: > >> > >> >In <[EMAIL PROTECTED]>, willie > wrote: > >> >> # What's the correct way to get the > >> >> # byte count of a unicode (UTF-8) string? > >> >> # I couldn't find a builtin method > >> >> # and the following is memory

Re: Installing 2.5 with 2.4?

2006-09-20 Thread John Machin
Duncan Booth wrote: > "John Machin" <[EMAIL PROTECTED]> wrote: > > > 1. You need to set your path manually. A BAT file called pypath.bat > > placed somewhere on your PATH and containing: > > path c:\python%1;c:\python%1\scripts;%path% > > might

Re: byte count unicode string

2006-09-20 Thread John Machin
willie wrote: > John Machin: > > >You are confusing the hell out of yourself. You say that your web app > >deals only with UTF-8 strings. Where do you get "the unicode string" > >from??? If name is a utf-8 string, as your comment says, then len(name) >

Re: unicode mystery/problem

2006-09-20 Thread John Machin
Petr Jakes wrote: > Hi, > I am using Python 2.4.3 on Fedora Core4 and "Eric3" Python IDE > . > Below mentioned code works fine in the Eric3 environment. While trying > to start it from the command line, it returns: > > Traceback (most recent call last): > File "pokus_1.py", line 5, in ? > pr

Re: How do I define a global constant...

2006-09-20 Thread John Machin
SpreadTooThin wrote: > How do I define a constant that I can use in my script... > For example lets say I have a file called constants.py and in there I > have PI = 3.14 > > in my test script I do: > > from constants import * > > How do I access PI later on? Like this: inaccurate_estimate_of_are

Re: byte count unicode string

2006-09-20 Thread John Machin
willie wrote: > > Thanks for the thorough explanation. One last question > about terminology then I'll go away :) > What is the proper way to describe "ustr" below? > > >>> ustr = buf.decode('UTF-8') > >>> type(ustr) > > > > Is it a "unicode object that contains a UTF-8 encoded > string object?

Re: Python 2.5 WinXP AMD64

2006-09-21 Thread John Machin
Bjoern Schliessmann wrote: > Christophe wrote: > > > To be exact, you need a 64bit Windows OS on a 64bit cpu. > > Is there a reason that can be explained in a less-than-2-KB > posting? :) I mean why Python depends on the processor type that > much. > Python doesn't depend on the processor type in

Re: Printing UTF-8

2006-09-21 Thread John Machin
[EMAIL PROTECTED] wrote: > I am new to unicode so please bear with my stupidity. > > I am doing the following in a Python IDE called Wing with Python 23. > > >>> s = "äöü" >From later evidence, this string is encoded as utf-8. Looks like Wing must be using an implicit "# coding: utf-8" for interac

Re: I need some help with a regexp please

2006-09-21 Thread John Machin
codefire wrote: > Hi, > > thanks for the advice guys. > > Well took the kids swimming, watched some TV, read your hints and > within a few minutes had this: > > r = re.compile(r'[EMAIL PROTECTED]@\s]+\.\w+') > > This works for me. That is if you have an invalid email such as > tony..bATblah.com it

Re: Don't use regular expressions to "validate" email addresses

2006-09-22 Thread John Machin
Ben Finney wrote: > Steve Holden <[EMAIL PROTECTED]> writes: > > > Ben Finney wrote: > > > The best advice I've seen when people ask "How do I validate > > > whether an email address is valid?" was "Try sending mail to it". > > > > > That only applies if it's a likely-looking email address. If som

Re: I need some help with a regexp please

2006-09-22 Thread John Machin
Ant wrote: > John Machin wrote: > ... > > A little more is unfortunately not enough. The best advice you got was > > to use an existing e-mail address validator. > > We got bitten by this at the last place I worked - we were using a > regex email validator (from M

Re: Don't use regular expressions to "validate" email addresses

2006-09-22 Thread John Machin
Ben Finney wrote: > "John Machin" <[EMAIL PROTECTED]> writes: > > > What proportion of deliverable e-mail addresses have more than one @ > > in them? > > I don't know. Fortunately, I don't need to; I don't "validate" email >

Re: Re[2]: unicode mystery/problem

2006-09-22 Thread John Machin
Petr Jakeš wrote: > John, thanks for your extensive answer. > >> Hi, > >> I am using Python 2.4.3 on Fedora Core4 and "Eric3" Python IDE > >> . > >> Below mentioned code works fine in the Eric3 environment. While trying > >> to start it from the command line, it returns: > >> > >> Traceback (most

Re: "Directory this source file is in (and a sibling)"

2006-09-22 Thread John Machin
Sion Arrowsmith wrote: > I have a module which needs to know what directory it's in, and to > refer to files in a sibling directory, something like App/src/foo.py > wants to read App/data/conf.xml . But I have no idea in what context > foo.py is going to be run -- it could be being run as a script

Re: anybody using python 2.5 that raises error while importing?

2006-09-22 Thread John Machin
daniel wrote: > there's a dll extension used to be imported with no error under version > 2.4.3, but the new python complains that the name of the module can't > be found. seems not mentioned in the official documentation, any work > around to fix the issue without switching back to the old versio

Re: python-Levenshtein-0.10.1

2006-09-22 Thread John Machin
[EMAIL PROTECTED] wrote: > Hi Guys, > > I've been using this c implementation > http://trific.ath.cx/resources/python/levenshtein/ on a windows box and > it works great. > > I'd like to move my app over to linux machine and am wondering if > someone could help me understand how to 'install' this e

Re: String Pattern Matching: regex and Python regex documentation

2006-09-22 Thread John Machin
Paul McGuire wrote: > "Steve Holden" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > > Ilias Lazardis meets Xah Lee. I just *know* we're in for trouble now ... > > > > regards > > Steve > > A sign of the End Times, perhaps? > Indeed. Armageddon outa here ;-) -- http://

Re: Fatal error after RE-installing Python 2.3.4

2006-09-22 Thread John Machin
Cappy2112 wrote: > I've just started a job which has a massive python2.3.4-centric tools > installation and configuration. > > I know what you're going to say, but I can't upgrade and be the only > one with a newer version. There are close to 30 engineers using this > same tools configuration, and

Re: QuoteSQL

2006-09-23 Thread John Machin
Lawrence D'Oliveiro wrote: > Why doesn't MySQLdb provide a function like this: Because the author has read PEP 8? -- http://mail.python.org/mailman/listinfo/python-list

Re: anybody using python 2.5 that raises error while importing?

2006-09-23 Thread John Machin
daniel wrote: > John Machin wrote: > > daniel wrote: > > > there's a dll extension used to be imported with no error under version > > > 2.4.3, but the new python complains that the name of the module can't > > > be found. seems not mentioned in the

Re: Fatal error after RE-installing Python 2.3.4

2006-09-23 Thread John Machin
Cappy2112 wrote: > > > Some thoughts and questions: > > 1. Telling us what the allegedly spurious pychecker warnings were would > > be a good idea. > > pychecker isn't really a concern at this point- and has ben uninstalled > (actually deleted, since there is no installer/uninstaller for this > p

Re: Need compile python code

2006-09-23 Thread John Machin
mistral wrote: > писал(а): There seems to be a rather large communication gap. Consider asking your question in a Russian-speaking Python-related forum, for example: http://zope.net.ru/ Regards, John -- http://mail.python.org/mailman/listinfo/python-list

Re: assignment hook

2006-09-23 Thread John Machin
Roy Smith wrote: > [EMAIL PROTECTED] wrote: > > Kind people, > > Is there any way one can, within Python, intercept the act of > > assignment. > > Sure. You just need to define a __setattr__() method for your class. See > http://docs.python.org/ref/attribute-access.html for details. Is it possi

Re: HTTP GET Explodes...

2006-09-23 Thread John Machin
Pete wrote: > I was running the HTTP GET example at > http://www.python.org/doc/current/lib/httplib-examples.html and ran > into a bit of trouble... > > >>> import httplib # This works. > >>> conn = httplib.HTTPConnection("www.python.org") # This works. > >>> conn.request("GET", "/index.html")

Re: Regular expression confusion

2006-09-23 Thread John Machin
York wrote: > I have two backslash - a. and I want to replace them with one backslash, > but I failed: > > >>> import re > >>> a = '' > >>> re.sub(r'', '\\', '') > Traceback (most recent call last): >File "", line 1, in ? >File "/usr/lib/python2.3/sre.py", line 143, in sub >

Re: HTTP GET Explodes...

2006-09-23 Thread John Machin
Pete wrote: > Fade in to episode II... > > > ... > > This is compiling a *constant* regular expression, and works OK on the > > Windows distribution of Python 2.4.3 : > > H. Here's the version information stuff: > > Python 2.4.2 (#1, Feb 12 2006, 03:59:46) > [GCC 4.1.0 20060210 (Red Hat 4.1.0-

Re: HTTP GET Explodes...

2006-09-23 Thread John Machin
Pete wrote: > John Machin wrote: > > Pete wrote: > > > Fade in to episode II... > > > > > > > ... > > > > This is compiling a *constant* regular expression, and works OK on the > > > > Windows distribution of Python

Re: HTTP GET Explodes...

2006-09-24 Thread John Machin
Pete wrote: > > > Python 2.4.3 (#1, Jun 13 2006, 11:46:08) > > > [GCC 4.1.1 20060525 (Red Hat 4.1.1-1)] on linux2 > > > Type "help", "copyright", "credits" or "license" for more information. > > > >>> import httplib > > > >>> conn = httplib.HTTPConnection("www.python.org") > > > >>> conn.request("

Re: Regular expression confusion

2006-09-24 Thread John Machin
York wrote: > Oh, that's right, the second arg is escaped by re compiler too. No, that's wrong, you [should] do the escaping, the compiler unescapes :-) Cheers, John -- http://mail.python.org/mailman/listinfo/python-list

Re: ruby %w equivalent

2006-09-24 Thread John Machin
Antoine De Groote wrote: > > is there a python equivalent for the ruby %w operator? > %w{a b c} creates an array with strings "a", "b", and "c" in ruby... > | >>> "a b c".split() | ['a', 'b', 'c'] ... appears to match your single example. HTH, John -- http://mail.python.org/mailman/listinfo/p

Re: ruby %w equivalent

2006-09-24 Thread John Machin
[EMAIL PROTECTED] wrote: > > Also Google was curiously resistant to telling me where Ruby's %w is > documented. > You would need to dig into your Google toolbar config and un-tick "YAGNI filter". -- http://mail.python.org/mailman/listinfo/python-list

Re: Unexpected behaviour of csv module

2006-09-24 Thread John Machin
Andrew McLean wrote: > I have a bunch of csv files that have the following characteristics: > > - field delimiter is a comma > - all fields quoted with double quotes > - lines terminated by a *space* followed by a newline > > What surprised me was that the csv reader included the trailing space in

Re: unicode, bytes redux

2006-09-25 Thread John Machin
willie wrote: > (beating a dead horse) > > Is it too ridiculous to suggest that it'd be nice > if the unicode object were to remember the > encoding of the string it was decoded from? Where it's been is irrelevant. Where it's going to is what matters. > So that it's feasible to calculate the numb

Re: Unexpected behaviour of csv module

2006-09-25 Thread John Machin
Andrew McLean wrote: > John Machin wrote: > > A better workaround IMHO is to strip each *field* after it is received > > from the csv reader. In fact, it is very rare that leading or trailing > > space in CSV fields is of any significance at all. Multiple spaces > >

Re: unicode, bytes redux

2006-09-25 Thread John Machin
Paul Rubin wrote: > "John Machin" <[EMAIL PROTECTED]> writes: > > Actually, what Willie was concerned about was some cockamamie DBMS > > which required to be fed Unicode, which it encoded as UTF-8, > > Yeah, I remember that. > > > Tell you what, why

Re: unicode, bytes redux

2006-09-25 Thread John Machin
Paul Rubin wrote: > Leif K-Brooks <[EMAIL PROTECTED]> writes: > > It requires a fairly large change to code and API for a relatively > > uncommon problem. How often do you need to know how many bytes an > > encoded Unicode string takes up without needing the encoded string > > itself? > > Shrug. I

Re: Unexpected behaviour of csv module

2006-09-25 Thread John Machin
[EMAIL PROTECTED] wrote: > One could argue that your CSV file is broken. Hi Skip, His CSV file is mildly broken. The examples that I gave are even more broken, and are typical of real world files created by clueless developers from databases which contain quotes and commas in the data (e.g. addre

Re: unicode, bytes redux

2006-09-25 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > Actually, what Willie was concerned about was some cockamamie DBMS > > which required to be fed Unicode, which it encoded as UTF-8, but > > silently truncated if it was more than the n in varchar(n) ... or > > somethin

Re: Deprecation in String.joinfields()

2006-09-25 Thread John Machin
Anoop wrote: > Hi All, > > I am getting the following error while trying to use deprecation > > Please help > > >>> li = ["a", "b", "mpilgrim", "z", "example"] > >>> newname = string.joinfields (li[:-1], ".") > >>> newname > 'a.b.mpilgrim.z' > >>> newname = li[:-1].joinfields(".") > Traceback (mos

Re: Leave the putdowns in the Perl community, the Python world does not need them

2006-09-25 Thread John Machin
Steven Bethard wrote: > metaperl wrote: > > I was shocked to see the personal insults hurled in this thread: > > http://groups.google.com/group/comp.lang.python/browse_thread/thread/d0758cb9545cad4b > > I see that this is a Fredrik Lundh thread. I've felt the same way > before, but Fredrik has be

Re: Problems with Python 2.5 installer.

2006-09-25 Thread John Machin
paw wrote: > I have ran the MSI installer for Python 2.5 several times attempting to > install to C: > Python, however all of the files are placed in C:\ . The installer is > told to only install files for me, beyond that I have only chosen the > defaults. What do you mean by "install to C: Pyt

Re: Printing a percent sign

2006-09-25 Thread John Machin
[EMAIL PROTECTED] wrote: > Thanks -- a percent escapes itself when using %-formatting. > > Stephen > > [EMAIL PROTECTED] wrote: > > Hi all. How do I escape the "%" sign in a print statement so that it > > prints? Thanks. > > The following methods of getting answers to problems can be handy if it'

Re: where are isinstance types documented?

2006-09-26 Thread John Machin
codefire wrote: > Hi, > > I'm using the isinstance built-in function. I've found the docs for it, > but there are no docs on the supported types. It supports *all* types. > > For example isinstance(a, int) works fine but isinstance(s, string) > doesn't - because 'string is not known'. That's bec

Re: Printing a percent sign

2006-09-26 Thread John Machin
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, John > Machin wrote: > > > 1. Reasoning: How do you get a literal "'" into an SQL string constant? > > How do you get a literal "\" into a Python string constant? How do you >

Re: Printing a percent sign

2006-09-26 Thread John Machin
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, John > Machin wrote: > > > Lawrence D'Oliveiro wrote: > >> In message <[EMAIL PROTECTED]>, John > >> Machin wrote: > >> > >> > 1. Reasoning: How do you ge

Re: Printing a percent sign

2006-09-26 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > > > I'll take your word for it; it's been quite a while :-) *Something* in > > the dim dark past worked like that > > makefiles? Bingo! Actually, double bingo!! >From the docs for GNU Make: """

Re: Whither binary search?

2006-09-26 Thread John Machin
Fredrik Lundh wrote: > Neil Cerutti wrote: > > >> bisect... > > > > That doesn't tell me if an item doesn't exist in the sequence > > though, does it? Maybe I'm being dense. > > I guess you could use something like > > import bisect > > def check(list, item): > try: > return list[bisec

Re: Unexpected behaviour of csv module

2006-09-26 Thread John Machin
Andrew McLean wrote: > John Machin wrote: > > You can fix that. The beauty of open source is that you can grab it > > (Windows: c:\python2?\lib\csv.py (typically)) and hack it about till it > > suits your needs. Go fer it! > > Unfortunately the bits I should chang

Re: where are isinstance types documented?

2006-09-26 Thread John Machin
Georg Brandl wrote: > Fredrik Lundh wrote: > > Sion Arrowsmith wrote: > >> > > > >>> based on http://docs.python.org/ref/types.html, here's a list of the > >>> most commonly used core types: > >>> [ ... ] > >>> Sequences: > >>> str > >>> unicode > >>> tuple > >>> list > >> > >> And

Re: problem moving from char to integer

2006-09-26 Thread John Machin
Melih Onvural wrote: > This is the error message that I'm having a tough time interpreting: > Traceback (most recent call last): > File "pagerank.py", line 101, in ? > main() > File "pagerank.py", line 96, in main > ch = strord(url) > File "pagerank.py", line 81, in strord > resu

Re: AN Intorduction to Tkinter

2006-09-26 Thread John Machin
[EMAIL PROTECTED] wrote: > > Tis question was just asked on the py2exe mailing list. I predicted > > that if it was asked here, you would respond asking exactly which > > examples didn't work. :-p > > Right you were :-) > > Just want to learn what I already know as a great programming > interface(

Re: releasing memory to malloc

2006-09-26 Thread John Machin
[EMAIL PROTECTED] wrote: > Is there any way to get Python to release memory back to the > C allocator? I'm currently running a script that goes through > the following steps: > > 1) Creates a very large number of Python objects to produce > a relatively small data structure that sits in a C extens

Re: releasing memory to malloc

2006-09-26 Thread John Machin
[EMAIL PROTECTED] wrote: > I can, but the extension is only a thin wrapper around a general > purpose C library which is also used independently of Python. > So change the library to use xmalloc etc and add something like this to the .h file: #ifdef PYMEM #define xmalloc PyMem_Malloc etc #else #

Re: Top and Bottom Values [PEP: 326]

2006-09-27 Thread John Machin
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Antoon Pardon wrote: > > > I need this Top value in > > a context where it can be used as a start or stop value > > in a slice. > > But the only valid values allowed for indices are 0 up to the length of the > array inclusive. Larger int

Re: baffling sql string

2006-09-27 Thread John Machin
DarkBlue wrote: > Following is a code snippet from a pythoncard app > the problem is with the sql string called iq1 > If either mysubject or mytalktext contains an > apostrophe the update fails : > Example: mysubject="Let's Eat" this fails > mysubject="Lets Eat" this works fine > > What

Re: sqlite3 error

2006-09-27 Thread John Machin
John Salerno wrote: > CREATE TABLE Researchers ( > researcherID varchar(9) PRIMARY KEY NOT NULL, > birthYear int(4) DEFAULT NULL, > birthMonth int(2) DEFAULT NULL, > birthDay int(2) DEFAULT NULL, > birthCountry varchar(50) DEFAULT NULL, > birthState char(2) DEFAULT NU

Re: pythonol

2006-09-27 Thread John Machin
John Martin wrote: > 'pythonol' is a program for learning spanish. I think it's a really great > program. Unfortunately it ceased to work when I moved to SuSE 10 and 10.1 . > The author makes it clear on her website that she has devoted all the time > she's prepared to and won't maintain it. I thi

Re: Whither binary search?

2006-09-28 Thread John Machin
Sion Arrowsmith wrote: > John Machin <[EMAIL PROTECTED]> wrote: > >Fredrik Lundh wrote: > >> well, people tend to use dictionaries when they need to look things up > >> quickly... > >... like those paper dictionaries with the words in alphabetical order >

Re: best way to get data into a new instance?

2006-09-28 Thread John Machin
Diez B. Roggisch wrote: > > The programmer is responsible for the construction of new instances (or > at least the code which will do that), and a constructor should contain > parameters for at least the values you absolutely expect to be there - > for example name and age or something like that

Re: sqlite3 error

2006-09-28 Thread John Machin
John Salerno wrote: > John Machin wrote: > > John Salerno wrote: > >> CREATE TABLE Researchers ( > >> researcherID varchar(9) PRIMARY KEY NOT NULL, > >> birthYear int(4) DEFAULT NULL, > >> birthMonth int(2) DEFAULT NULL, > >>

Re: sqlite3 error

2006-09-28 Thread John Machin
Steve Holden wrote: > John Machin wrote: > > John Salerno wrote: > > > >>John Machin wrote: > >> > >>>John Salerno wrote: > >>> > >>>>CREATE TABLE Researchers ( > >>>> researcherID varchar(9) PRIMARY KEY N

Re: analyzing removable media

2006-09-28 Thread John Machin
glenn wrote: > Hi Jay > pls excuse top post - Im actually doing this project in linux, but am > wanting it to be cross platform. I definitley have to cater for win32 > also. I was hoping that burried in sys or os or that there'd be some x > platform module that did all that stuff for me > Thin

Re: There's another Timbot on the loose!

2006-09-29 Thread John Machin
Jorge Godoy wrote: > Paul Rubin writes: > > > http://web.cecs.pdx.edu/~mpj/timbot/index.html > > Should we tell them that we have the original and have a patent on him? :-) > > -- Page last updated in 2002 ... site looks like the Marie Celeste. Perhaps our timbot undert

Re: "ValueError: Empty module name" on basic import

2006-09-29 Thread John Machin
alain MONTMORY wrote: > Hello everybody, > > I am a newbie to python so I hope I am at the right place to expose my > problem. :-[ > > I am working on linux mandrake 10.1 with python : > python -V > Python 2.3.4 > I am trying o run the example which stay in the documentation in paragraph > http

Re: Problems with Python 2.5 installer.

2006-09-29 Thread John Machin
Matthew Warren wrote: > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of paw > Sent: 29 September 2006 11:01 > To: python-list@python.org > Subject: Re: Problems with Python 2.5 installer. > > > John Machin wrote: >

Re: loop over list and modify in place

2006-09-30 Thread John Machin
James Stroud wrote: > Daniel Nogradi wrote: > > Is looping over a list of objects and modifying (adding an attribute > > to) each item only possible like this? > > > > mylist = [ obj1, obj2, obj3 ] > > > > for i in xrange( len( mylist ) ): > >mylist[i].newattribute = 'new value' > > > > > > I'

Re: Python/UNO/OpenOffice?

2006-09-30 Thread John Machin
Sybren Stuvel wrote: > [EMAIL PROTECTED] enlightened us with: > > Are then any currently active and reasonably mature Python plugins/ > > apis/whatever for programming/scripting OpenOffice? The page I've > > found is http://udk.openoffice.org/python/python-bridge.html, but it > > was last updated m

Re: How to Catch 2 Exceptions at once?

2006-09-30 Thread John Machin
Gregory Piñero wrote: > How can I catch 2 exceptions at once for example: > > try: > self.gses = opener.open(req) > except (urllib2.HTTPError,urllib2.URLError): > do something.. > > Seems to work, but how do I also get information about the error? Errr .. t

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread John Machin
Giovanni Bajo wrote: > charlie strauss wrote: > > > Below is a simple program that will cause python to intermittently > > stop executing for a few seconds. it's 100% reproducible on my > > machine. > > Confirmed with Python 2.4.2 on Windows. > > gc.disable() fixes it, so it looks like you found

Re: Problem with .next() method adding junk characters.

2006-10-01 Thread John Machin
Rainy wrote: > Hi, > > I tried searching for this and did not find this issue. I only looked > at about dozen hits, I apologize if this is covered somewhere and I > missed it. Without much further ado, here's the thing (Win, Py2.5): > > >>> f = open('test', 'w') > >>> f.fileno() > 4 > >>> f.write(

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-10-02 Thread John Machin
Fredrik Lundh wrote: > > You should also benchmark this against code that uses the ordinary > append/join pattern. (you've posted conflicting benchmarks for 2.5, > but if I'm trusting the benchmarks that looks more reasonable, the > standard implementation pattern is still around 10 times faster

Re: Python/UNO/OpenOffice?

2006-10-02 Thread John Machin
Colin J. Williams wrote: > I've done some small things with Python/OpenOffice, using Windows XP. > They appear to work OK. As you might have noticed from my earlier post, I can't get off the ground. Can you please give an example (with code) of a "small thing" that works OK? TIA, John -- http

Re: Python/UNO/OpenOffice?

2006-10-02 Thread John Machin
olive wrote: > ... and you have to start your py file with: > > import uno, sys, socket > from com.sun.star.beans import PropertyValue > > ... and your start_oo_server.bat file with: > > @SET PYTHONPATH=C:\Program Files\OpenOffice.org 2.0\program;C:\Program > Files\OpenOffice.org 2.0\program\pytho

Re: Operator += works once, fails if called again

2006-10-02 Thread John Machin
Frederic Rentsch wrote: > Hi all, > >I have a class Time_Series derived from list. It lists days and > contains a dictionary of various Lists also derived from list which > contain values related to said days. (e.g. Stock quotes, volumes traded, > etc.) >I defined an operator += which work

Re: Need help with an array problem.

2006-10-02 Thread John Machin
SpreadTooThin wrote: > Basically I think the problem is in converting from a 32 bit integer to > a 16 bit integer. > > I have two arrays: > import array > > a = array.array('L', [65537]) > b = array.array('H', [0]) > > b[0] = a[0] > > Which gives an overflow message As it should. > So can't

Re: Need help with an array problem.

2006-10-02 Thread John Machin
SpreadTooThin wrote: > Robert Kern wrote: > > [EMAIL PROTECTED] wrote: > > > To your question on casting long to short. This is how: > > > a=1234L # long > > > b=int(a) # int (short) > > > > No, a Python int is a C long. A Python long is an arbitrary-precision > > number and > > does no

Re: PATCH: Speed up direct string concatenation by 20+%!

2006-10-02 Thread John Machin
Larry Hastings wrote: > > John Machin wrote: > > try benchmarking this ... well "style" may not be the appropriate word > > Running this under Python 2.5 release: > x = [] > xappend = x.append > for i in xrange(1000): > xappend

Re: PEP 358 and operations on bytes

2006-10-03 Thread John Machin
Gerrit Holl wrote: > Hi, > > In Python 3, reading from a file gives bytes rather than characters. > Some operations currently performed on strings also make sense when > performed on bytes, either if it's binary data or if it's text of > unknown or mixed encoding. Those include of course slicing a

Re: Can't get around "IndexError: list index out of range"

2006-10-03 Thread John Machin
Terry Reedy wrote bloated code: > if sys.argv[1:2] != []: if sys.argv[1:2]: :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: can't open chm files all of a sudden

2006-10-04 Thread John Machin
John Salerno wrote: > John Salerno wrote: > > Hi all. I apologize since this is only remotely Python related, but I > > hope someone might now the solution. > > > > I tried opening my Python chm docs just now, as well as the one for > > wxPython, and both are giving me an error dialog when I double

Re: Where to I find files: gtk.py _gtk.py and GDK.py

2006-10-04 Thread John Machin
[EMAIL PROTECTED] wrote: > Hello, > Can you tell me where to I find exactly this files:gtk.py, _gtk.py and > GDK.py > I was look everywhere,and download package of gtk but I can't find this > files > I would like to know what your definition of "everywhere" is. Google("python gtk") gives this as

Re: PEP 358 and operations on bytes

2006-10-04 Thread John Machin
Gerrit Holl wrote: > On 2006-10-04 05:10:32 +0200, John Machin wrote: > > > - str methods endswith, find, partition, replace, split(lines), > > > startswith, > > > - Regular expressions > > > > > > I think those can be useful on a byt

Re: How fuzzy is get_close_matches() in difflib?

2006-11-17 Thread John Machin
On Nov 17, 7:19 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: [snip] > You want to see "HIDEDCT1" match closer to "HIDESCT1" than "HIDEDST1": > > HIDEDCT1 -- John's "best match" target string > HIDEDST1 -- difflib's "best match" target string > HIDESCT1 -- source string > > John's best match ma

Re: How can I speed this function up?

2006-11-18 Thread John Machin
On Nov 18, 2:05 pm, Chris <[EMAIL PROTECTED]> wrote: > with this function I went from 8.04 s to 6.61 s. And your code became less understandable. > Now running up against > my limited knowledge of python. Any chance of getting faster? You have saved 1.4 *seconds*. What is the normal running ti

Re: How can I speed this function up?

2006-11-18 Thread John Machin
On Nov 18, 4:23 pm, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > If you can assume that all items have 6 numbers, it appears best to > unroll the inner iteration. Is this meant to be some kind of joke? If so, you should have festooned it with smilies. If not, please proceed straight to http:/

Re: How can I speed this function up?

2006-11-18 Thread John Machin
Gabriel Genellina wrote: > At Saturday 18/11/2006 05:09, John Machin wrote: > > > > If you can assume that all items have 6 numbers, it appears best to > > > unroll the inner iteration. > > > >Is this meant to be some kind of joke? > >If so, you should

Re: print with variable justification (with *)

2006-11-18 Thread John Machin
tom wrote: > Why Tea wrote: > > print format % values > > An optional minimum width of the conversion, specified using one or > > more digits or an asterisk (*), which means that the width is taken > > from the next item in values > > > > That's from one of O'reilly's books. But there is no example

Re: syntax error in sum(). Please explicate.

2006-11-18 Thread John Machin
Michael Press wrote: > I have not written python codes nor run any. I saw this > code posted and decided to try it. It fails. I read the > tutorial and the entry for the built in function sum, > but still do not see the problem. The code was cut and > paste. I doubt it -- "none" should be "None"

Re: print with variable justification (with *)

2006-11-18 Thread John Machin
tom wrote: > John Machin wrote: > > Not quite so many folks come to Python with a background in C these > > days. Is anyone aware of a tutorial that covers % formatting from a > > standing start? > If you're on a unix system you can probably do `man fprintf`, but it

Re: Reloading after from adder import * ????

2006-11-18 Thread John Machin
Seymour wrote: > I created a module with the DictAdder subclass as follows: > > class DictAdder(Adder): > def add(self, x, y): > new={} > for k in x.keys(): new[k]=x[k] > for k in y.keys(): new[k]=y[k] > return new > > At the interactive prompt I then said: from

<    5   6   7   8   9   10   11   12   13   14   >