Re: autoexecution in Windows

2005-03-07 Thread rbt
Earl Eiland wrote: In Linux, if I make the first line #!/path/to/Python, all I have to do to execute the program is type ./FileName (assuming my pwd is the same as FileName). what's the Windows equivalent? Earl On Mon, 2005-03-07 at 13:36, F. Petitjean wrote: Le Mon, 07 Mar 2005 13:25:35 -0700, Ea

Re: autoexecution in Windows

2005-03-07 Thread "Martin v. Löwis"
Earl Eiland wrote: How does one make a Python program auto-execute in Windows? Use any of the mechanisms to make an arbitrary program auto-execute (do you want on boot, on login, or what?), and use c:\pythonXY\python.exe as the executable name; use the script name as the first argument. Regards, Ma

Re: autoexecution in Windows

2005-03-07 Thread Earl Eiland
O.K. I stand corrected. "auto-execute is the wrong term. Earl On Mon, 2005-03-07 at 14:03, rbt wrote: > Earl Eiland wrote: > > How does one make a Python program auto-execute in Windows? > > > > Earl > > > > No program (python or other) can just arbitrarily execute. A user has to > click it

Re: hidden attribute on Windows files

2005-03-07 Thread John Machin
rbt wrote: > How do I enable the hidden attribute when creating files on Windows > computers? I'd *really* prefer to do from the standard Python installer > (no win32 extensions). Any tips? > > Thanks Breaking your problem down a bit: 1. How is that done from the command line in Windows? 2. How t

Re: i18n: looking for expertise

2005-03-07 Thread klappnase
"Serge Orlov" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > I've never used tkinter, but I heard good things about it. Are you > sure it's not you who made it to return byte string sometimes? Yes, I used a Tkinter.StringVar to keep track of the contents of an Entry widget; a

Re: global variables

2005-03-07 Thread David S.
M.N.A.Smadi grads.ece.mcmaster.ca> writes: > I need to have a varaible that will contain a value that will be > modified in one file, and when coming back to the same file it > should retain the same value. You must import the module in which the variable lives and qualify it appropriately.

Re: win32com and Python2.4: Interpreter crashing!

2005-03-07 Thread Roger Upole
There's a bug in the tokenizer that's triggered by the long lines generated by makepy. See http://sourceforge.net/tracker/index.php?func=detail&aid=1085454&group_id=78018&atid=551954 and www.python.org/sf/1089395 Roger "Tim N. van der Leeuw" <[EMAIL PROTECTED]> wrote in message news:

Re: python -i (interactive environment)

2005-03-07 Thread Just
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: > Michael Hoffman wrote: > > Joe wrote: > > > >> I want the script to decide whether to fall back to the interactive > >> prompt. You solution makes it ALWAYS fall back to the interactive prompt. > > > > > > Actually, usi

Re: zipimport IOError reading Modules.zip in Mac standalone app

2005-03-07 Thread Just
In article <[EMAIL PROTECTED]>, "Bob Swerdlow" <[EMAIL PROTECTED]> wrote: > We have some users of our application getting error messages like: > IOError: zipimport: can not open file > /Volumes/MyApp/MyApp.app/Contents/Resources/Modules.zip > This only happens on our Mac version - the Window

Re: Python 2.4 removes None data type?

2005-03-07 Thread John Machin
[EMAIL PROTECTED] wrote: > Sheesh... I didn't actually pull the type(None) comparison out of my > code. Sheesh yourself. Newsgroup readers can't do inspect.hasaclue('J. Random Poster'); they rely on duck-typing or goose-typing. > I was simply throwing together a possible situation. Had I > thou

Re: GOTO (was Re: Appeal for python developers)

2005-03-07 Thread Anthra Norell
> Heiko wrote:   > SETUP = object()> ELSE = object()> BREAK = object() > > machine = {"WAITING FOR ACTION":>   {customer_drops_coin:"COIN HAS BEEN DROPPED",>    customer_selects_beverage:"ORDER RECEIVED",>    customer_cancels_order:"ACCOUNT CLOSURE IS

Re: autoexecution in Windows

2005-03-07 Thread Bill
Earl Eiland wrote: > How does one make a Python program auto-execute in Windows? > > Earl You need to have files with .py or .pyo or .py registered to open with the python interpreter. In Windows Explorer, choose the menu item Tools->Folder Options and select the File Types tab to see how registe

Re: shuffle the lines of a large file

2005-03-07 Thread Raymond Hettinger
[Joerg Schuster] > I am looking for a method to "shuffle" the lines of a large file. > > I have a corpus of sorted and "uniqed" English sentences that has been > produced with (1): > > (1) sort corpus | uniq > corpus.uniq > > corpus.uniq is 80G large. Since the corpus is huge, the python portion s

Re: programmatically calling a function

2005-03-07 Thread Larry Bates
I see lots of others have made suggestions, but here is a method that I use frequently: define a dictionary that contains references to your functions: def foo(): . . whatever it does . def bar(): . . whatever it does . xfer={'foo', foo, 'bar', bar} Then you can write for fname in fnames:

Re: pyconfig.h

2005-03-07 Thread Jeff Epler
The pyconfig.h file (/usr/include/python2.3/pyconfig.h) should begin something like this /* pyconfig.h. Generated by configure. */ /* pyconfig.h.in. Generated from configure.in by autoheader. */ and shouldn't cause problems. If it starts in a wildly different way than that, then it's p

py2exe error: 2.4.2.4: No such file or directory

2005-03-07 Thread Larry Bates
I had occasion to look back at a project I did over a year ago and needed to make one small change. I use py2exe to package it for distribution via Inno Setup. After making my change I tried to run my setup script that worked fine before and get the following message: F:\SYSCON\WTS\HTMLmenu>pyth

Re: mxDateTime on Mac: Fatal Python Error

2005-03-07 Thread M.-A. Lemburg
[EMAIL PROTECTED] wrote: I'm trying to get mxDateTime working on a Mac so that I can use pyscopg and cx_Oracle. The Egenix base package builds and installs quite happily, but then when I try to import it I get import mx.DateTime Fatal Python error: Interpreter not initialized (version mismatch?) A

Re: Unicode BOM marks

2005-03-07 Thread Francis Girard
Le lundi 7 Mars 2005 21:54, "Martin v. LÃwis" a ÃcritÂ: Hi, Thank you for your very informative answer. Some interspersed remarks follow. > > I personally would write my applications so that they put the signature > into files that cannot be concatenated meaningfully (since the > signature simp

pymem.h In function '__declspec'

2005-03-07 Thread pythonnewbie
I have installed Python-2.3.3 in the SUSE Linux 9.1 system and am trying to rebuild an application rpm that was implemented in Python, I am getting the following error, /usr/Python-2.3.3/Include/pymem.h In function '__declspec' /usr/Python-2.3.3/Include/pymem.h:51: error: parse error before '__dec

Re: Possible to import a module whose name is contained in avariable?

2005-03-07 Thread Scott David Daniels
Steven Reddie wrote: Hi, Thanks, that seems to be what I was missing. I'm having some further related trouble though. I want to do something like this: MODULES = [ 'module1', 'module2' ] def libinfo(): for m in MODULES: __import__('libinfo.'

Re: mxDateTime on Mac: Fatal Python Error

2005-03-07 Thread Dave Reed
On Monday 07 March 2005 17:51, M.-A. Lemburg wrote: > [EMAIL PROTECTED] wrote: > > I'm trying to get mxDateTime working on a Mac so that I can use pyscopg > > and cx_Oracle. The Egenix base package builds and installs quite > > happily, but then when I try to import it I get > > > > > >>>import

Re: Unicode BOM marks

2005-03-07 Thread Jeff Epler
On Mon, Mar 07, 2005 at 11:56:57PM +0100, Francis Girard wrote: > BTW, the python "unicode" built-in function documentation says it returns a > "unicode" string which scarcely means something. What is the python > "internal" unicode encoding ? The language reference says farily little about unic

Re: mxDateTime on Mac: Fatal Python Error

2005-03-07 Thread Michael Maibaum
On Mon, Mar 07, 2005 at 11:51:20PM +0100, M.-A. Lemburg wrote: [EMAIL PROTECTED] wrote: I'm trying to get mxDateTime working on a Mac so that I can use pyscopg and cx_Oracle. The Egenix base package builds and installs quite happily, but then when I try to import it I get import mx.DateTime Fatal

Re: global variables

2005-03-07 Thread Harlin Seritt
You most likely need to construct your script using OOP. Can give you give an example of code you're using when you get this error? This helps a lot. Regards, Harlin -- http://mail.python.org/mailman/listinfo/python-list

Re: mod_python & "please recompile it with -DEAPI" apache warning

2005-03-07 Thread grahamd
[EMAIL PROTECTED] wrote: > 2) added to MakeFile after config: > EXTRA_CFLAGS=-DEAPI You can do this, but it should be to "src/Makefile" and added to "CFLAGS" and not "EXTRA_CFLAGS" as the latter doesn't exist. -- http://mail.python.org/mailman/listinfo/python-list

pymen.h

2005-03-07 Thread pythonnewbie
I have installed Python-2.3.3 in the SUSE Linux 9.1 system and am trying to rebuild an application rpm that was implemented in Python, I got the following error when compiling the application extension module, /usr/Python-2.3.3/Include/pymem.h: In function '__declspec' /usr/Python-2.3.3/Include/py

Re: pymem.h In function '__declspec'

2005-03-07 Thread Jeff Epler
What does this command print? gcc -c -I/usr/Python-2.3.3/Include -x c -o /dev/null \ /usr/Python-2.3.3/Include/pymem.h If it prints an error like the one you included in this message, then the set of header files in /usr/Python-2.3.3/Include is damaged, incomplete, or wrong for your com

quick question

2005-03-07 Thread Leeds, Mark
I have a string variable say “8023 “ and I want to get rid of the beginning And ending quotes.   I’ve tried different things But haven’t had any success.   I’m definitely a python hacker and Not an expert. Thanks.        Mark -- http://mail.

Re: IndexedCatalog and ZEO

2005-03-07 Thread Almad
Leif K-Brooks wrote: > from IndexedCatalog.Shelf import Shelf > shelf = Shelf(('localhost', 1234), [Class1, Class2]) Is it also possible to connect via socket instead of port? I've tried to pass '/tmp/zeosocket' instead of ('localhost', 1234), but it isn't successfull. Is is any way to do that?

Exception handling code (try/except/finally)

2005-03-07 Thread djw
c.l.p- I am having trouble understanding how one is supposed to correctly utilize try:...except:...finally: in real code. If I have a block of code like: def foo(): try: ... some code that can raise an exception ... finally: ... do some cleanup ...

Re: Exception handling code (try/except/finally)

2005-03-07 Thread Michael Hoffman
djw wrote: c.l.p- I am having trouble understanding how one is supposed to correctly utilize try:...except:...finally: in real code. If I have a block of code like: def foo(): try: ... some code that can raise an exception ... finally: ... do some cleanup ... retu

Safe string escaping?

2005-03-07 Thread Grant Olson
I have a data file that has lines like "foo\n\0" where the \n\0 is acutally backslash+n+backslash+0. I.E. a repr of the string from python would be "foo\\n\\0". I'm trying to convert this string into one that contains actual newlines and whatnot. I feel like there has to be a better and safer wa

Re: Safe string escaping?

2005-03-07 Thread Michael Hoffman
Grant Olson wrote: I have a data file that has lines like "foo\n\0" where the \n\0 is acutally backslash+n+backslash+0. I.E. a repr of the string from python would be "foo\\n\\0". I'm trying to convert this string into one that contains actual newlines and whatnot. r"foo\n\0".decode("string_escap

Re: Unicode BOM marks

2005-03-07 Thread "Martin v. LÃwis"
Francis Girard wrote: Well, no text files can't be concatenated ! Sooner or later, someone will use "cat" on the text files your application did generate. That will be a lot of fun for the new unicode aware "super-cat". Well, no. For example, Python source code is not typically concatenated, nor

Re: Safe string escaping?

2005-03-07 Thread Daniel Bickett
There is very likely a more reasonable solution than this, but it was the first one that came to mind: IDLE 1.0.3 >>> string = "foo\\n\\0" >>> string = string.replace( "\\n" , "\n" ) >>> string = string.replace( "\\0" , "\0" ) >>> string 'foo\n\x00' >>> print string foo Hope this helps. -

Re: quick question

2005-03-07 Thread Daniel Bickett
If you simply wanted to get rid of quotes entirely, you could use: "\"Hello!\"".replace( "\"" , "" ) However, since you only want the beginning and ending quotes removed: >>> string = "\"If thou wert my fool, nuncle...\"" >>> print string "If thou wert my fool, nuncle..." >>> if string.startswi

Re: quick question

2005-03-07 Thread Steve Holden
Leeds, Mark wrote: I have a string variable say “8023 “ and I want to get rid of the beginning And ending quotes. I’ve tried different things But haven’t had any success. I’m definitely a python hacker and Not an expert. Thanks. >>> x = '"This is a quoted string"' >>> print x "This is a

select random entry from dictionary

2005-03-07 Thread Tor Erik Sønvisen
Hi How can I select a random entry from a dictionary, regardless of its key-values? regards tores -- http://mail.python.org/mailman/listinfo/python-list

RE: select random entry from dictionary

2005-03-07 Thread Tony Meyer
> How can I select a random entry from a dictionary, regardless of its > key-values? >>> import random >>> d = {1:'a', 2:'b', 3:'c'} >>> a = random.choice(d.keys()) >>> a, d[a] (2, 'b') (etc) =Tony.Meyer -- http://mail.python.org/mailman/listinfo/python-list

Re: select random entry from dictionary

2005-03-07 Thread [EMAIL PROTECTED]
>From the Python 2.4 quickreference: d.popitem() Removes and returns an arbitrary (key, value) pair from d If this isn't random enough, then you can generate a random number in range(len(d)) -- http://mail.python.org/mailman/listinfo/python-list

Re: select random entry from dictionary

2005-03-07 Thread chengdu
import random print d[d.keys()[int(random.random()*len(d.keys()))]] HTH -c -- http://mail.python.org/mailman/listinfo/python-list

Re: py2exe error: 2.4.2.4: No such file or directory

2005-03-07 Thread Stephen Thorne
On Mon, 07 Mar 2005 16:20:30 -0600, Larry Bates <[EMAIL PROTECTED]> wrote: > I had occasion to look back at a project I did over a year ago > and needed to make one small change. I use py2exe to package > it for distribution via Inno Setup. After making my change > I tried to run my setup script

Re: python -i (interactive environment)

2005-03-07 Thread Paulo Eduardo Neves
When I'm using pyunit and want to stop in a point during the test (skipping all the framework initialization), I just start the debugger: import pdb pdb.set_trace() You'll get the debugger prompt. -- http://mail.python.org/mailman/listinfo/python-list

Re: select random entry from dictionary

2005-03-07 Thread Scott David Daniels
Tony Meyer wrote: How can I select a random entry from a dictionary, regardless of its key-values? a = random.choice(d.keys()) a, d[a] Or even: key, value = random.choice(d.items()) or: value = random.choice(d.values()) --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailm

Re: Safe string escaping?

2005-03-07 Thread Bengt Richter
On Mon, 07 Mar 2005 19:24:43 -0500, "Grant Olson" <[EMAIL PROTECTED]> wrote: >I have a data file that has lines like "foo\n\0" where the \n\0 is acutally >backslash+n+backslash+0. I.E. a repr of the string from python would be >"foo\\n\\0". I'm trying to convert this string into one that contain

python-dev Summary for 2005-02-15 through 2005-02-28

2005-03-07 Thread Brett C.
[The HTML version of this Summary is available at http://www.python.org/dev/summary/2005-02-15_2005-02-28.html] = Summary Announcements = Status of the candidates It looks like all three candidates for taking

Re: Python 2.4 / WinXP / distutils error (cookbook example)

2005-03-07 Thread magoldfish
Martin v. Löwis wrote: > There are several solutions, but one is to install Visual Studio .NET > 2003 (which is different from Visual Studio .NET, also referred to > as VS.NET 2002). Microsoft managed to rename the C library (CRT) between > 2002 (msvcr7.dll) and 2003 (msvcr71.dll), and you need to

Queued stdout, flush() doesn't seems to help...

2005-03-07 Thread Dave Lajoie
Hello Everyone,   I have been using this piece of code to start an exec and "process" its stdout/stderror   import sysimport popen2 executable = r'execfile -arg1 -arg2'r, w, e = popen2.popen3(executable)r.flush()w.flush()e.flush() x=0 # just print the 1000 first lineswhile x<1000:    sys.std

Dictionaries of Lists

2005-03-07 Thread gf gf
I'd like to associate certain lists with keywords, and retrieve them. But this is not possible as lists are not hashable. What is the best workaround? I don't mind making my lists immutable. Is there a way to tupelize them? I tried mydict[mykey]=([a for a in list]) but it didn't seem to work.

Re: Dictionaries of Lists

2005-03-07 Thread Erik Max Francis
gf gf wrote: I'd like to associate certain lists with keywords, and retrieve them. But this is not possible as lists are not hashable. You can convert them to tuples with the `tuple' function: aDictionary[tuple(aList)] = aKeyword > What is the best workaround? I don't mind making my > lis

Re: Dictionaries of Lists

2005-03-07 Thread Robert Kern
gf gf wrote: I'd like to associate certain lists with keywords, and retrieve them. But this is not possible as lists are not hashable. Do you want mydict[mylist] = mykey or mydict[mykey] = mylist ? The former is not possible with lists for the reason you noted. The latter, however, works just

RE: Dictionaries of Lists

2005-03-07 Thread Tony Meyer
> I'd like to associate certain lists with keywords, and > retrieve them. But this is not possible as lists are > not hashable. A dictionary's values don't have to be hashable, so if the keywords are the keys in the dictionary, this would work. >>> d = {} >>> d['key1'] = [1,2,3] >>> d['key2'] =

Re: Dictionaries of Lists

2005-03-07 Thread Terry Hancock
On Monday 07 March 2005 11:09 pm, gf gf wrote: > I'd like to associate certain lists with keywords, and > retrieve them. But this is not possible as lists are > not hashable. > > What is the best workaround? I don't mind making my > lists immutable. Is there a way to tupelize them? > I tried my

parameter name conflict. How to solve?

2005-03-07 Thread Bo Peng
Dear list, If you ask: why do you choose these names? The answer is: they need to be conformable with other functions, parameter names. I have a function that pretty much like: def output(output=''): print output and now in another function, I need to call output function, with again keyword p

Mysterious "Attribute Errors" when GUI Programming

2005-03-07 Thread Coral Snake
I am having problems with programming even simple "Hello World" programs from books and tutorials that use Python GUI libraries. Such Programs cause python to throw "Attribute Errors" even when the "attributes" being asked for by the errors exist in the source code. This has happened to me in both

Re: Dictionaries of Lists

2005-03-07 Thread Steven Bethard
Tony Meyer wrote: [a for a in list] (or a[:]) makes a copy of a list. or list(a) STeVe -- http://mail.python.org/mailman/listinfo/python-list

Re: Mysterious "Attribute Errors" when GUI Programming

2005-03-07 Thread Robert Kern
Coral Snake wrote: I am having problems with programming even simple "Hello World" programs from books and tutorials that use Python GUI libraries. Such Programs cause python to throw "Attribute Errors" even when the "attributes" being asked for by the errors exist in the source code. This has happ

Re: parameter name conflict. How to solve?

2005-03-07 Thread Steven Bethard
Bo Peng wrote: Dear list, If you ask: why do you choose these names? The answer is: they need to be conformable with other functions, parameter names. I have a function that pretty much like: def output(output=''): print output and now in another function, I need to call output function, with a

unicode surrogates in py2.2/win

2005-03-07 Thread Mike Brown
In mid-October 2004, Jeff Epler helped me here with this string iterator: def chars(s): """ This generator function helps iterate over the characters in a string. When the string is unicode and a surrogate pair is encountered, the pair is returned together, regardless of whether

Default function arguments, KURL::cleanPath() -- a bindings bug?

2005-03-07 Thread Frans Englich
Hello, I've stumbled over a behavior related to default function arguments which appears to be a bug, from what I can tell. See this snippet: >>> from kdecore import KURL >>> u = KURL( "http://www.example.org/test/../"; ) >>> u.cleanPath() Traceback (most recent call last): File "", line 1,

RE: parameter name conflict. How to solve?

2005-03-07 Thread Delaney, Timothy C (Timothy)
Steven Bethard wrote: >> If you ask: why do you choose these names? The answer is: they need >> to be conformable with other functions, parameter names. Is this a style guide thing? >> I have a function that pretty much like: >> >> def output(output=''): >> print output >> >> and now in anot

RE: Default function arguments, KURL::cleanPath() -- a bindings bug?

2005-03-07 Thread Delaney, Timothy C (Timothy)
Frans Englich wrote: > Apparently, cleanPath /requires/ a boolean argument, but the C++ > function definition says: > > void cleanPath(bool cleanDirSeparator = true); Most likely that cleanPath's default parameter hasn't been declared to *Python*. If so, I expect this is a KURL bug. Raise a bu

Re: Speeding up CGIHTTPServer

2005-03-07 Thread Tim Roberts
"Johan Kohler" <[EMAIL PROTECTED]> wrote: > >I'm using CGIHTTPServer (via its test() method) to test some CGI on my >Windoze 98 box. I find that the execution is very slow. Is there >anything I can do to make sure I'm getting the best performance out of >CGIHTTPServer? Compared to what, and on w

Re: py2exe error: 2.4.2.4: No such file or directory

2005-03-07 Thread Thomas Heller
Larry Bates <[EMAIL PROTECTED]> writes: > I had occasion to look back at a project I did over a year ago > and needed to make one small change. I use py2exe to package > it for distribution via Inno Setup. After making my change > I tried to run my setup script that worked fine before and > get

<    1   2