Re: C#3.0 and lambdas

2005-09-22 Thread Christophe
Steven Bethard a écrit : > Steven D'Aprano wrote: > >> I would love to see your test code and profiling results that demonstrate >> that explicit tuple unpacking in the body of a function is faster than >> tuple unpacking (implicit or explicit) in the header of a function. > > > Should be pretty

Re: Looking for system/network monitoring tool written in Python

2005-09-22 Thread David Wilson
See http://pynms.sourceforge.net/ Also see Google. :) David. -- http://mail.python.org/mailman/listinfo/python-list

need to divide a date

2005-09-22 Thread nephish
Hey there, i am doing a plotting application. i am using mxRelativeDateTimeDiff to get how much time is between date x and date y now what i need to do is divide that time by 20 to get 20 even time slots for plotting on a graph. For example, if the difference between them is 20 hours, i need 20 p

Re: Calling python scripts from C# programs

2005-09-22 Thread David Wilson
You should also be aware of IronPython, although it is not suitable for production use due to its reliance on a beta version of the .NET runtime. In some future time, IronPython will probably be the cleanest and simplest way to integrate Python with existing .NET code. http://www.ironpython.com/

time challenge

2005-09-22 Thread nephish
Hey there, i am doing a plotting application. i am using mxRelativeDateTimeDiff to get how much time is between date x and date y now what i need to do is divide that time by 20 to get 20 even time slots for plotting on a graph. For example, if the difference between them is 20 hours, i need 20

Re: unusual exponential formatting puzzle

2005-09-22 Thread Neal Becker
Paul Rubin wrote: > Neal Becker <[EMAIL PROTECTED]> writes: >> Like a puzzle? I need to interface python output to some strange old >> program. It wants to see numbers formatted as: >> >> e.g.: 0.23456789E01 > > Yeah, that was normal with FORTRAN. > >> My solution is to print to a string with

How to tell if an exception has been caught ( from inside the exception )?

2005-09-22 Thread Paul Dale
Hi everyone, I'm writing an exception that will open a trouble ticket for certain events. Things like network failure. I thought I would like to have it only open a ticket if the exception is not caught. Is there a way to do this inside the Exception? As far as I can see there are only two eve

Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Tom Brown
On Thursday 22 September 2005 05:52, Nico Grubert wrote: > Does f = open('/tmp/myfile', 'w') overwrite the existing file or > does f.writelines('456') replace the first line in the existing file? Here's an excerpt from open.__doc__ The mode can be 'r', 'w' or 'a' for reading (default), w

Re: How to tell if an exception has been caught ( from inside the exception )?

2005-09-22 Thread Dan
If the exception isn't caught, it is printed to standard error. This means that either __str__ or __repr__ is called (to convert it to a displayable string). If the exception is caught, those methods *probably* won't be called. -- Where you are is not as important as where you are going.

Re: Perl's documentation come of age

2005-09-22 Thread Mabden
"Måns Rullgård" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This guy deserves two ascii trolls: > > ___ > /| /| | | > ||__|| | Please do | >

Re: How to use writelines to append new lines to an existing file

2005-09-22 Thread Max Erickson
Nico Grubert <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Hi there, > > I would like to open an existing file that contains some lines of > text in order to append a new line at the end of the content. > > My first try was: > > >>> f = open('/tmp/myfile', 'w') #create new file for wr

Convert from unicode to int

2005-09-22 Thread Tor Erik S�nvisen
Hi Is there any simpler way to convert a unicode numeric to an int than: int(u'1024'.encode('ascii')) ?? regards tores -- http://mail.python.org/mailman/listinfo/python-list

re.split() problem

2005-09-22 Thread Masayuki Takemura
Hi all. re.split() doesn't work as I intend. My Python Version is 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32. For example, >>> r = re.compile('^$', re.MULTILINE) >>> r.split('foo\nbar\n\nbaz') ['foo\nbar\n\nbaz'] but I expected ['foo\nbar\n', 'baz']. This proble

Re: How to tell if an exception has been caught ( from inside theexception )?

2005-09-22 Thread Fredrik Lundh
Paul Dale wrote: > I'm writing an exception that will open a trouble ticket for certain > events. Things like network failure. I thought I would like to have it > only open a ticket if the exception is not caught. Is there a way to do > this inside the Exception? As far as I can see there are only

Open PDF

2005-09-22 Thread Jorge Ramirez
Hello,   I would like to know how to open a PDF document from a python script, any suggestions are appreciated.   Thanks,   JR -- http://mail.python.org/mailman/listinfo/python-list

Re: Threading, real or simulated?

2005-09-22 Thread Antoon Pardon
Op 2005-09-22, Sam schreef <[EMAIL PROTECTED]>: > Jp Calderone writes: > >> On Wed, 21 Sep 2005 18:23:33 -0500, Sam <[EMAIL PROTECTED]> wrote: >>>I'm using Python 2.3.5 with pygtk 2.4.1, and I'm using the second threading >>>approach from pygtk's FAQ 20.6 - invoking "gtk.gdk.threads_init()", and

Re: Convert from unicode to int

2005-09-22 Thread Max M
Tor Erik Sønvisen wrote: > Hi > > Is there any simpler way to convert a unicode numeric to an int than: > > int(u'1024'.encode('ascii')) why doesn't: int(u'104') work for you? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/lis

Re: Convert from unicode to int

2005-09-22 Thread Grant Edwards
On 2005-09-22, Tor Erik Sønvisen <[EMAIL PROTECTED]> wrote: > Hi > > Is there any simpler way to convert a unicode numeric to an int than: > > int(u'1024'.encode('ascii')) >>> int(u'1024') 1024 Didn't that work for you when you tried it? -- Grant Edwards grante Yow

Stampare su stampante aghi

2005-09-22 Thread lux
Salve a tutti, sono alle prese con delle stampe su stampanti ad aghi... Per stampare puro testo la soluzione più gettonata sembra essere f = open("LPT1:") f.write("bla bla") f.close() devo dire che funziona benissimo, ma mi piacerebbe essere slegato falla parallela (sempre meno frequente) e invi

Re: plateform info.

2005-09-22 Thread Mike Meyer
Maurice LING <[EMAIL PROTECTED]> writes: > Is there a way of getting the path to the site-packages directory? >>> import sys >>> import os >>> for dir in sys.path: ... if os.path.split(dir)[-1] == 'site-packages': ... print dir ... /usr/opt/lib/python2.4/site-packages >>> But there's sel

NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
This code doesn't seem to do what I think it should do: # python 2.3.2 # not sure of my win32 extensions version import logging from logging.handlers import NTEventLogHandler logger = logging.getLogger("testlogger") handler = NTEventLogHandler("testlogger") logger.addHandler(handler) logger.info(

Re: Open PDF

2005-09-22 Thread Dan
> I would like to know how to open a PDF document from a python script You mean open it and display it to the user? Under Windows you may be able to get away with just "executing" the file (as though it were an executable): import os os.system("c:/path/to/file.pdf") Under Linux you can proba

Re: How to tell if an exception has been caught ( from inside the exception )?

2005-09-22 Thread Rocco Moretti
Paul Dale wrote: > > Hi everyone, > > I'm writing an exception that will open a trouble ticket for certain > events. Things like network failure. I thought I would like to have it > only open a ticket if the exception is not caught. Is there a way to do > this inside the Exception? As far as I

Re: need to divide a date

2005-09-22 Thread Steve Holden
[EMAIL PROTECTED] wrote: > Hey there, > i am doing a plotting application. > i am using mxRelativeDateTimeDiff to get how much time is between > date x and date y > > now what i need to do is divide that time by 20 to get 20 even time > slots > for plotting on a graph. > > For example, if the dif

Re: Finding where to store application data portably

2005-09-22 Thread Mike Meyer
rbt <[EMAIL PROTECTED]> writes: > On Tue, 2005-09-20 at 23:03 +0100, Tony Houghton wrote: >> I'm using pygame to write a game called Bombz which needs to save some >> data in a directory associated with it. In Unix/Linux I'd probably use >> "~/.bombz", in Windows something like >> "C:\Documents An

Re: idle

2005-09-22 Thread Franz Steinhaeusler
On Thu, 22 Sep 2005 14:31:22 +0200, TK <[EMAIL PROTECTED]> wrote: >Hi, > >is there no IDLE in Python2.4? > >o-o > >Thomas Sure, on Windows: C:\Python24\Lib\idlelib\idle.pyw You should have a shortcuts in your StartMenu und Python 2.4 -- Franz Steinhaeusler -- http://mail.python.org/mailman/l

Need help:Unable to make runnable Python on AIX 4.3.3

2005-09-22 Thread mkent
I have a vexing problem and seek some input on how to fix it. Starting with Python 2.4.0, I have been unable to compile a working Python on our AIX 4.3.3 development system. I can compile a working Python 2.3.x with no problem. The failure symptom is that Python 2.4.x fails its unit tests on tes

Re: Looking for system/network monitoring tool written in Python

2005-09-22 Thread Mike Meyer
"David Wilson" <[EMAIL PROTECTED]> writes: > See http://pynms.sourceforge.net/ Thanks for the pointer. And to Simon Brunning for the pointer to Eddie. > Also see Google. :) While everything may be in Google, it's not always obvious how to get it out. I've managed to extract a score of systems fr

Re: re.split() problem

2005-09-22 Thread Fredrik Lundh
Masayuki Takemura wrot: > re.split() doesn't work as I intend. it works as it's supposed to work. empty matches are not considered to be valid split points, partially because it doesn't really make sense to split on nothing in most cases, but mostly because doing so will, most likely, result in

Simultaneous Adobe Reader

2005-09-22 Thread Jorge Ramirez
Hello,   From windows, using a python script how can I open Adobe Reader without displaying a PDF document?  Furthermore, using a script is it possible to run two Adobe Reader sessions simulatneously.  Thanks in advance.   Kind Regards, JR -- http://mail.python.org/mailman/listinfo/python-

Re: Looking for system/network monitoring tool written in Python

2005-09-22 Thread Eddie Corns
Simon Brunning <[EMAIL PROTECTED]> writes: >On 9/22/05, Mike Meyer <[EMAIL PROTECTED]> wrote: >> I've found a fair number of systems/network monitoring tools (things >> like Big Brother, Big Sister, cricket, etc.) written in Perl. I'm >> curious if there are any written in Python. >There's EDDIE

Re: Finding where to store application data portably

2005-09-22 Thread en.karpachov
On Thu, 22 Sep 2005 00:23:56 +1000 Steven D'Aprano wrote: > I wish the Linux Standard Base folks would specify that settings files > should all go into a subdirectory like ~/settings rather than filling up > the home directory with cruft. That was acceptable in the days when people > only looked a

Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Vinay Sajip
Jaime Wyant wrote: > This code doesn't seem to do what I think it should do: > > # python 2.3.2 > # not sure of my win32 extensions version > > import logging > from logging.handlers import NTEventLogHandler > logger = logging.getLogger("testlogger") > handler = NTEventLogHandler("testlogger") > lo

Re: Perl's documentation come of age

2005-09-22 Thread Mike
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jim Hugunin's keynote speech at this year's PyCon was accompanied by a > projection if his interactive interpreter session, and I know I wasn't > alone in finding this a convincing example of Microsoft's (well, Jim's,

Re: Open PDF

2005-09-22 Thread Mike Meyer
Dan <[EMAIL PROTECTED]> writes: > Under Linux you can probably use xpdf or gpdf: > > os.system("xpdf /path/to/file.pdf") > > Note that you should check the return code of "system" to see if the > execution was successful. For example, the user might not have xpdf > installed. This is the problem

Python installation root directory problem

2005-09-22 Thread Matt Leslie
Hi, I am trying to install python 2.4.1 on a windows XP machine. Whether I choose to install 'for me' or 'for all users, and no matter where I select as the root directory, the installer always puts the python root in C:\, which is obviously a bit messy. I am running this instalaltion as a sli

Re: Calling python scripts from C# programs

2005-09-22 Thread Paul
Another option is to implement the needed python code in COM server and call that from C#. A simple example of python COM server can be seen about halfway down the page here http://www.oreilly.com/catalog/pythonwin32/chapter/ch12.html -- http://mail.python.org/mailman/listinfo/python-list

Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
I must be missing something. This is what I read from the documentation: When a logger is created, the level is set to NOTSET (which causes all messages to be processed in the root logger, or delegation to the parent in non-root loggers). :/ Thanks! jw On 22 Sep 2005 08:21:48 -0700, Vinay Sajip

Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Jaime Wyant
BTW - you're suggestion worked. Thanks again! jw On 9/22/05, Jaime Wyant <[EMAIL PROTECTED]> wrote: > I must be missing something. This is what I read from the documentation: > > When a logger is created, the level is set to NOTSET (which causes all > messages to be processed in the root logger,

Re: Calling python scripts from C# programs

2005-09-22 Thread Brett Hoerner
David Wilson wrote: > http://www.ironpython.com/ It should be noted that they (?) don't seem to update that site anymore, you can find 0.9.1 here: http://workspaces.gotdotnet.com/ironpython There is also Boo, which is Python-like (with some differences) but is a .NET Language itself. I never und

Indexed variables

2005-09-22 Thread python-novice
Hello, being an almost complete Python AND programming neophyte I would like to ask the following - very elementary, as I might suspect - question: How do I do the following flawed things right: a1=a2=0 def f(x): if x == a1: a1 = a1 + 1 elif x == a2: a2 = a2 + 1 Now

Re: wxPython Notebook crash when pressing alt key

2005-09-22 Thread Graham Fawcett
Kreedz wrote: > Could Windows version have anything to do with this?? Else I've got > some really weird issue... > > I'm on Windows 2000 Professional Yes, that definitely counts as a wierd issue. I couldn't reproduce the bug either. C:\temp>python ActivePython 2.4.1 Build 247 (ActiveState Corp

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
>a1=a2=0 > >def f(x): >if x == a1: >a1 = a1 + 1 >elif x == a2: >a2 = a2 + 1 > > >Now if I call f with f(a2) only a1, of course, is incremented because the >if-clause does only check for the value of the input and the values of a1 >and a2 are identical. > >So how do I define

Re: Indexed variables

2005-09-22 Thread Rocco Moretti
[EMAIL PROTECTED] wrote: > So how do I define the function such as to discrimate wheter I call it by > f(a1) or f(a2) ? I don't want to sound rude, but I think you'll be better served by telling us why you would want to do such a thing - ten to one someone can suggest a better way to acomplish

Re: Indexed variables

2005-09-22 Thread Tom Anderson
On Thu, 22 Sep 2005 [EMAIL PROTECTED] wrote: > How do I do the following flawed things right: Well, that depends on what you mean by 'right'. I'm going to give you two solutions; one that answers your apparent question, and one that addresses what i suspect is your true question. > a1=a2=0 > >

Re: Indexed variables

2005-09-22 Thread Laszlo Zsolt Nagy
>If you really want to change an actual parameter inside an object, then > > inside a function, I mean -- http://mail.python.org/mailman/listinfo/python-list

Re: Question About Logic In Python

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: >> >> 2. Expressions that will be used in a calculation or another >> expression. >> > By which you appear to mean "expressions in which Boolean values are > used as numbers". Or compared to other types, which is common. >> This matters because if you

Re: Writing a parser the right way?

2005-09-22 Thread beza1e1
Thanks for the hints. I just found NLTK and MontyLingua. And yes, it is just adventure game language. This means every tense except present tense is discarded as "not changing world". Furthermore the parser will make a lot of assumptions, which are perhaps 90% right, not perfect: if word[-2:] ==

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Steve Holden wrote: > Ron Adam wrote: > >> Tony Houghton wrote: >> >>> I'm using pygame to write a game called Bombz which needs to save some >>> data in a directory associated with it. In Unix/Linux I'd probably use >>> "~/.bombz", in Windows something like >>> "C:\Documents And Settings\\Applic

Re: Python installation root directory problem

2005-09-22 Thread Matt Leslie
Further diggingappears to show this is an instance of the problem documented here: http://tinyurl.com/82dt2 Running msiexec with logging revealed the following lines: MSI (s) (48:F8) [18:15:47:990]: Ignoring disallowed property X MSI (s) (48:F8) [18:15:47:990]: Ignoring disallowed property TARG

Linux/Python -> SQL*Server Connexion chain

2005-09-22 Thread Gilles Lenfant
Hi, Have you guys any good experience on connecting a Python (Zope) app running on Linux to a Windoze SQL*Server ? Many thanks by advance to report your success, failure, pitfalls (...) and used products. Even reports using commercial solutions are welcome. -- Gilles -- http://mail.python.o

Re: time challenge

2005-09-22 Thread Scott David Daniels
nephish wrote: > i am doing a plotting application> If its 40 minutes, > i need 20 plots that are 2 minutes apart. > what would be a way i could pull this off? > > thanks Sounds like homework related to another assignment discussed above. Write your code, try to get it to work, and _then_ i

Re: Threading, real or simulated?

2005-09-22 Thread Peter Hansen
Antoon Pardon wrote: > Op 2005-09-22, Sam schreef <[EMAIL PROTECTED]>: >>What's the GIL?. > > The general interpretor lock. In general changing python internals That should be "global" (and, more pedantically, "interpreter"). -- http://mail.python.org/mailman/listinfo/python-list

How to show percentage

2005-09-22 Thread Sen-Lung Chen
Dear All: I have a question of show percentage. For example ,I want to show the percentage of 1/3 = 33.33% I use the 1*100/3 = 33 it is 33 not 33.33 , how to show the 33.33 % Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing a parser the right way?

2005-09-22 Thread Steven Bethard
beza1e1 wrote: > Verbs are the tricky part i think. There is no way to recognice them. > So i will have to get a database ... work to do. ;) Try the Brill tagger[1] or MXPOST[2]. STeVe [1] http://www.cs.jhu.edu/~brill/code.html [2] ftp://ftp.cis.upenn.edu/pub/adwait/jmx/jmx.tar.gz -- http://mai

Re: Perl's documentation come of age

2005-09-22 Thread Fredrik Lundh
Mike wrote: > > Jim Hugunin's keynote speech at this year's PyCon was accompanied by a > > projection if his interactive interpreter session, and I know I wasn't > > alone in finding this a convincing example of Microsoft's (well, Jim's, > > really) full integration of Python into the .net framewo

Re: Linux/Python -> SQL*Server Connexion chain

2005-09-22 Thread Benji York
Gilles Lenfant wrote: > Have you guys any good experience on connecting a Python (Zope) app > running on Linux to a Windoze SQL*Server ? Yep. I wrote bindings to ODBTP (http://odbtp.sourceforge.net/) using ctypes. It worked really well, good performance and quite reliable. You can see an alph

Re: Finding where to store application data portably

2005-09-22 Thread Ron Adam
Tony Houghton wrote: > > This works on Win XP. Not sure if it will work on Linux. > > > > import os > > > > parent = os.path.split(os.path.abspath(os.sys.argv[0]))[0] > > file = parent + os.sep + '.bombz' > > Ooh, no, I don't want saved data to go in the installation directory. In > genera

Re: Question About Logic In Python

2005-09-22 Thread Terry Reedy
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Which is yet another reason why it makes absolutely no sense to apply > arithmetic operations to Boolean values. Except for counting the number of true values. This and other legitimate uses of False/True as 0/1 (inde

Re: How to show percentage

2005-09-22 Thread [EMAIL PROTECTED]
Traditionally, one part of the expression has to be a float for the result to be a float (this is a holdover from C). So 100/3.0 will give you the result you want. Alternatively, you can put "from __future__ import division" at the top of your script, and then 100/3 will return a float. http://www

Re: How to show percentage

2005-09-22 Thread Bill Mill
You need to convert 1 or 3 to a float. How about: >>> def pct(num, den): return (float(num)/den) * 100 ... >>> pct(1, 3) 33.329 Peace Bill Mill bill.mill at gmail.com On 22 Sep 2005 10:51:43 -0700, Sen-Lung Chen <[EMAIL PROTECTED]> wrote: > Dear All: > I have a question of show perc

Re: How to show percentage

2005-09-22 Thread Mike Meyer
"Sen-Lung Chen" <[EMAIL PROTECTED]> writes: > Dear All: > I have a question of show percentage. > For example ,I want to show the percentage of 1/3 = 33.33% > > I use the 1*100/3 = 33 > it is 33 not 33.33 , how to show the 33.33 % Python interprets '/' in an integer environment to return ints,

Re: NTEventLogHandler not logging `info'?

2005-09-22 Thread Vinay Sajip
Jaime Wyant wrote: > I must be missing something. This is what I read from the documentation: > > When a logger is created, the level is set to NOTSET (which causes all > messages to be processed in the root logger, or delegation to the > parent in non-root loggers). > The documentation could be c

<    1   2