Re: best way of testing a program exists before using it?

2006-09-11 Thread Tim Williams
On 11/09/06, Hari Sekhon <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > On 11/09/06, Hari Sekhon <[EMAIL PROTECTED]> wrote: > >> > >> Steve Holden wrote: > >> Hari Sekhon wrote: > >> > >> > >> The easiest way to

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Tim Peters
[Licheng Fang] > ... > I want to know if there is some way to make Python RE behave like grep > does, Not in general, no. The matching strategies couldn't be more different, and that's both deep and intentional. See Friedl's book for details: http://regex.info/ > or do I have to change to

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Tim Peters
[Licheng Fang[ > ... > In fact, what I'm doing is handle a lot of regular expressions. I > wanted to build VERY LONG regexps part by part and put them all into a > file for easy modification and maintenance. The idea is like this: > > (*INT) = \d+ > (*DECIMAL) = (*INT)\.(*INT) > (*FACTION) = (*DECI

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Licheng Fang] >> Oh, please do have a look at the second link I've posted. There's a >> table comparing the regexp engines. The engines you've tested probably >> all use an NFA implementation. [Bryan Olson] > Unfortunately, the stuff about NFA's is wrong. Friedl's awful > book Strongly disagree:

RE: best way of testing a program exists before using it?

2006-09-12 Thread Tim Golden
[Nick Craig-Wood] | Tim Golden <[EMAIL PROTECTED]> wrote: | > if os.path.isfile (filepath): | >print filepath | | You might get a more accurate result using | | os.access(filepath, os.X_OK) | | instead of | | os.path.isfile(filepath) | | Which checks

RE: Get CPU usage of a single process in Windows

2006-09-12 Thread Tim Golden
[Gerrit Muller] | | Tim Golden wrote: | > WMI can probably do the trick. I'm fairly sure I've got an example | somewhere, but I can't lay my hands on it at the mo. | If you have a working example of CPU usage could you post the | result? I | would be interested. I haven

RE: Get CPU usage of a single process in Windows

2006-09-12 Thread Tim Golden
[Gerrit Muller] | If you have a working example of CPU usage could you post the | result? I would be interested. OK. Here's a workingish example, cut down from the link I posted earlier. This one was designed to work with Win2K which I was using at the time. For WinXP and later, there's a new co

RE: Running python from a usb drive

2006-09-12 Thread Tim Golden
[cjl] [... snip ...] | set PATHTEXT=.py;%PATHTEXT% | I'm still having a problem with setting PATHTEXT... That would be because it's PATHEXT not PATHTEXT (it's sort of like a PATH but for EXTensions). TJG This e-mail has

RE: Help me use my Dual Core CPU!

2006-09-12 Thread Tim Golden
[Simon Wittber] | I write cross platform games in Python, and I'd really like to be able | to use this second core (on my machine, and on user's | machines) for any new games I might write. | I know threads won't help (in CPython at least) so I'm investigating | other types of concurrency which

RE: Help me use my Dual Core CPU!

2006-09-12 Thread Tim Golden
| > But I have the feeling I'm teaching my grandmother... Is that | > the kind of thing you were after? Or not? | | I'm not familiar with the expression 'teaching my grandmother'. What | exactly does it mean? Teaching my grandmother to suck eggs (and probably several variants with other relatives

RE: Running python from a usb drive

2006-09-12 Thread Tim Golden
[cjl] | Any ideas about how to set file type associations without writing to | the registry? Well, yes. Just the same as was in the article you pointed to... or have I missed something? assoc .py=python.file ftype python.file="c:\python24\python.exe" "%1" %* (or whatever version of Python). Ob

RE: Running python from a usb drive

2006-09-12 Thread Tim Golden
| [cjl] | | | Any ideas about how to set file type associations without writing to | | the registry? | [Tim Golden] | Well, yes. Just the same as was in the article you pointed | to... or have I missed something? Ah, I see. Presumably the FTYPE / ASSOC commands write things to the registry

RE: best way of testing a program exists before using it?

2006-09-12 Thread Tim Golden
| Tim Golden <[EMAIL PROTECTED]> wrote: | > [Nick Craig-Wood] | > | > | Tim Golden <[EMAIL PROTECTED]> wrote: | > | > if os.path.isfile (filepath): | > | >print filepath | > | | > | You might get a more accurate result using | &

RE: best way of testing a program exists before using it?

2006-09-12 Thread Tim Golden
[EMAIL PROTECTED] | Sent: 12 September 2006 16:04 | To: [email protected] | Subject: Re: best way of testing a program exists before using it? | | Nick> Tim Golden <[EMAIL PROTECTED]> wrote: | >> [Nick Craig-Wood] | >> | >> | Tim Golde

RE: best way of testing a program exists before using it?

2006-09-12 Thread Tim Golden
| Tim> All that said, I think the only thing would be to | add a line to the | Tim> docs saying sthg like: This will always return False | for X_OK under | Tim> Win32. I'm happy to submit the patch, but is it worth it? | | Yes, please do. If people think it works th

Re: Is it just me, or is Sqlite3 goofy?

2006-09-12 Thread Tim Chase
> dynamic typing != random typing. if your program is using the > DB-API to add data to an SQLite database, who, exactly, is > inserting the values? who's producing the data? under what > circumstances would that code produce or insert arbitrarily > typed data? Must be the code written by a Dr.

Re: Is it just me, or is Sqlite3 goofy?

2006-09-12 Thread Tim Chase
>> "But honestly, boss, I didn't write this code! It was my >> evil alter-ego that puts VARCHAR values containing Gilbert & >> Sullivan lyrics into the Amount_Due CURRENCY fields!" >> > Hence the phrase "Going for a song"? I am the very model of a modern major database, For gigabytes of informat

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Licheng Fang] >> Basically, the problem is this: >> >> >>> p = re.compile("do|dolittle") >> >>> p.match("dolittle").group() >> 'do' ... >> The Python regular expression engine doesn't exaust all the >> possibilities, but in my application I hope to get the longest possible >> match, starting fro

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Bryan Olson] >>> Unfortunately, the stuff about NFA's is wrong. Friedl's awful >>> book [Tim Peters] >> Strongly disagree: [...] [Bryan] > I know I'm disagreeing with a lot of smart people in panning > the book. That's allowed :-) >>&

Re: Validation of email

2006-09-12 Thread Tim Roberts
d to require confirmation). Mailman is written in Python. http://www.gnu.org/software/mailman/index.html -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

RE: pyLinda?

2006-09-13 Thread Tim Golden
(Caveat Lector: I've dabbled with this, but a while ago) [Gardner Pomper] | It sounds like pyLinda runs a server process and stores | tuples in it. That's about. From the "Beginner's Guide" page: http://www-users.cs.york.ac.uk/aw/pylinda/beginner.html """ First a server must be started - linda

RE: os.access(file, os.R_OK) on UNIX and WINDOWS

2006-09-13 Thread Tim Golden
[kai rosenthal] | on UNIX I changed the permission of a file "myfile" with chmod 000 | myfile. Then I got 0 from os.access(myfile, os.R_OK). This is ok. | | Then I checked the same file on WINDOWS (with samba): | I got "True" from os.access(myfile, os.R_OK). I think it is not ok?! Ummm. This is

xinclude and pathnames

2006-09-13 Thread Tim Arnold
be read via an http server. My question: is there a way to make xinclude work with relative paths or perhaps urls? Any ideas welcome--to me it looks like I'll have to restructure this part of the system since I've basically programmed myself into a corner. thanks, --Tim Arnold --

Re: Unit balancing

2006-09-13 Thread Tim Chase
> I am working with a researcher who would be very happy if he > could include units in his calculations. Then, if his > complicated expression didn't result in "kg/yr" the program > would stop and point out his error. > > Does Python (or SciPy or ..) offer this feature? Well, it's a bit of a h

Re: sending emails using python

2006-09-14 Thread Tim Williams
On 14 Sep 2006 00:11:05 -0700, sridhar <[EMAIL PROTECTED]> wrote: > > Tim Williams wrote: > > Have you verified that you are allowed to use SMTP on this server ? > > Can you send email via it using outlook express or a similar POP3/IMAP > > mail client? > > &

Re: Limitate speed of a socket-based data transferring

2006-09-14 Thread Tim Williams
On 14/09/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > billie schrieb: > > Hi all. I'm writing a TCP-based application that I will use to trasfer > > binary files through the network. This piece of code represents how do > > I get a file from a remote peer and save it on my local hard drive: >

Re: xinclude and pathnames

2006-09-14 Thread Tim Arnold
"Tim Arnold" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm using ElementTree to access some xml configuration files, and using > the module's xinclude capability. I've got lines like this in the parent > xml file (which lives in the

Re: latex openoffice converter

2006-09-14 Thread Tim Arnold
"Fabian Braennstroem" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I would like to use python to convert 'simple' latex > documents into openoffice format. Maybe, anybody has done > something similar before and can give me a starting point!? > Would be nice to hear some hi

Re: xinclude and pathnames

2006-09-14 Thread Tim Arnold
You guys saved me a bunch of hair-pulling. I'm going to check out the default_loader implementation too. --Tim Arnold -- http://mail.python.org/mailman/listinfo/python-list

Re: min() & max() vs sorted()

2006-09-14 Thread Tim Peters
[MRAB] > Some time after reading about Python 2.5 and how the built-in functions > 'min' and 'max' will be getting a new 'key' argument, I wondered how > they would treat those cases where the keys were the same, for example: > > L = ["four", "five"] > print min(L, key = len), max(L, key = len) > >

Re: Is there a way to find IP address?

2006-09-15 Thread Tim Roberts
y, but why would you want to? That IP address is not reachable from your server anyway. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Tim Peters
[Marc 'BlackJack' Rintsch] >> What about: >> >> b = array.array('f', a) [Diez B. Roggisch] > AFAIK d and f are synonym for arrays, as python doesn't distinguish > between these two on a type-level. And double it is in the end. While Python has no type of its own corresponding to the native C `flo

Re: REQ: Java/J2EE Developer 10 Months

2006-09-15 Thread Tim Chase
>> *Java, 2 year UNIX - HP / Solaris, 2 yrs OOA+D, Corba, Perl, >> XML, UML. *Java dev experience, Swing, JPS, 2 years of >> OOA+D. > > Clearly not spam, since the guy is so in touch with the > readership of this group ... sigh ... is it just me, or is > this person an idiot? Perhaps this is an a

Re: REQ: Java/J2EE Developer 10 Months

2006-09-15 Thread Tim Chase
shrikant COOLSOFT wrote: > Tim > > Stop acting like an [EMAIL PROTECTED]& > > > > > Tim Chase <[EMAIL PROTECTED]> wrote: > >> *Java, 2 year UNIX - HP / Solaris, 2 yrs OOA+D, Corba, Perl, >>> XML, UML. *Java dev experience, S

Re: something for itertools

2006-09-15 Thread Tim Williams
:5] (1, 2, 3, None, None) >>> pad_to = 5 >>> (a + pad_to*(None,))[:pad_to] (1, 2, 3, None, None) >>> (b + pad_to*(None,))[:pad_to] (10, 20, None, None, None) >>> (c + pad_to*(None,))[:pad_to] ('x', 'y', 'z', 'e', 'f') >>> -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: something for itertools

2006-09-15 Thread Tim Williams
On 15/09/06, Daniel Nogradi <[EMAIL PROTECTED]> wrote: > > or maybe a one liner :) > > > > >>> (a + 5*(None,))[:5] > > (1, 2, 3, None, None) > > > > Well, something like this is what I actually do. But for this first I > have to loop over all tuples and pick out the maximal length, so over > all

Re: min() & max() vs sorted()

2006-09-15 Thread Tim Peters
t;> >>> L = ["four", "five"] >>> print min(L, key = len), max(L, key = len) >>> >>> The result is: >>> >>> ('four', 'four') [Tim Peters] >> min() and max() both work left-to-right, and return t

Re: mp3 libs and programs

2006-09-15 Thread Tim Williams
On 15 Sep 2006 18:16:41 -0700, Jay <[EMAIL PROTECTED]> wrote: > I'm writing a python script that involves playing mp3 files. The first > approach I had was sending commands to unix command-line programs in > order to play them. I tired mpg123 and moosic, but there was a key > feature to my progra

Re: How to get the "longest possible" match with Python's RE module?

2006-09-16 Thread Tim Peters
[Tim Peters] >> [...] The most valuable general technique [Friedl] (eventually ;-) >> explained he called "unrolling", and consists of writing a regexp in >> the form: >> >>normal* (?: special normal* )* >> >> where the sets of character

Re: Is there a way to find IP address?

2006-09-16 Thread Tim Roberts
;> use it with care) >> >Hello Fredrik, >Thank you for your reply. >How can be HTTP_X_FORWARDED_FOR easily spoofed? I thought that IP >address is not possible change. No, but HTTP headers are just text. A client can put whatever it wants in them. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: How would you go about creating a heap of shortcuts to a batch file?

2006-09-17 Thread Tim Golden
googleboy wrote: > I need to create about 2000 shortcuts to a batch file. > The shortcuts need to have ... You need to use the win32com.shell module from pywin32 extensions. If you search the archives of this group and/or the python-win32 mailing list, you should find several explanations. The bes

Re: matplotlib: TypeError: a float is required

2006-09-17 Thread Tim Heaney
, width, color='r', yerr=womenStd, xerr=zeros(N)) p2 = bar(ind, womenMeans, width, color='y', bottom=menMeans, yerr=menStd, xerr=zeros(N)) I get the following bar chart http://img176.imageshack.us/my.php?image=imagenx6.png with no errors. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: matplotlib: TypeError: a float is required

2006-09-17 Thread Tim Heaney
the mailing list or sourceforge. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Limitate speed of a socket-based data transferring

2006-09-17 Thread Tim Williams
On 15/09/06, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2006-09-15, Steve Holden <[EMAIL PROTECTED]> wrote: > > > > Of course this depends crucially on the window size. Since the > > addition of the window scaling TCP option it's been possible > > to specify very large windows, which are useful

Re: mp3 file length in time

2006-09-17 Thread Tim Heaney
he length of a track in milliseconds with something like import mad print mad.MadFile("a_track.mp3").total_time() There are other modules for other libraries as well. I hope this helps, Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Hardlinks on NTFS

2006-09-17 Thread Tim Peters
[Wildemar Wildenburger] >> I'm thinking of letting my program create hardlinks (or symlinks). I >> know python allows doing this for ext, reiser and the like, but >> apparently not for ntfs systems. >> Is there any package out there that lets me create links in a platform >> independent way? [Calv

Re: How to efficiently proceed addition and subtraction in python list?

2006-09-18 Thread Tim Chase
> I have a list AAA = [1, 2, 3] and would like to subtract one from list > AAA > so AAA' = [0, 1, 2] > > What should I do? Sounds like a list comprehension to me: >>> a = [1,2,3] >>> a_prime = [x-1 for x in a] >>> a_prime [0, 1, 2] -tkc -- http://mail.python.org/mailman/listinfo/python-

Re: Curious issue with simple code

2006-09-19 Thread Tim Chase
start_dir, the behaviors of using "f" and "fp" will be the same. However, if your CWD is *not* the same, "f" is relative to the CWD, and fp is "start_dir + f" relative to the CWD. Thus, >>> start_dir = 'temp' >>&

Re: new string method in 2.5 (partition)

2006-09-19 Thread Tim Chase
>> partition(sep) condenses this pattern into a single method >> call that returns a 3-tuple containing the substring before >> the separator, the separator itself, and the substring after >> the separator. If the separator isn't found, the first >> element of the tuple is the entire string and th

Re: new string method in 2.5 (partition)

2006-09-19 Thread Tim Chase
> But you raise a good point. Notice this: > > >>> s = 'hello, world, how are you' > > >>> s.split(',') > ['hello', ' world', ' how are you'] > > >>> s.partition(',') > ('hello', ',', ' world, how are you') > > split will return all substrings. partition (and rpartition) only return > the s

Re: Installing 2.5 with 2.4?

2006-09-20 Thread Tim Peters
[Duncan Booth] >> Windows is only smart enough to avoid duplicate entries if you tell it >> to do that. e.g. >> >> PATH c:\python25;c:\python25\scripts;%PATH:c:\python25;c:\python25\scripts;=% >> >> will add the two Python 2.5 folders to the head of the path without >> duplicating them. [John Mach

RE: Using py2exe to wrap a service?

2006-09-20 Thread Tim Golden
[EMAIL PROTECTED] [... snip ...] | File "win32com\client\__init__.pyc", line 73, in GetObject | File "win32com\client\__init__.pyc", line 88, in Moniker | pywintypes.com_error: (-2147221020, 'Invalid syntax', None, None) | | The offending line is: | import active_directory as AD | ... | for

RE: Using py2exe to wrap a service?

2006-09-20 Thread Tim Golden
[Thomas Heller] | Tim Golden schrieb: | > [EMAIL PROTECTED] | > | > [... snip ...] | > | > | File "win32com\client\__init__.pyc", line 73, in GetObject | > | File "win32com\client\__init__.pyc", line 88, in Moniker | > | pywintypes.com_error: (

Re: Is it possible to change a picture resolution with Python?

2006-09-20 Thread Tim Roberts
to continue to print as 3" x 3", but to have three times as many pixels in each direction? That means you have to increase the number of pixels to 900x900. That's exactly what the code above is doing. The image file will be 9 times larger. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: naming objects from string

2006-09-20 Thread Tim Roberts
ntel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a='hello' >>> locals()[a] = 1234 >>> hello 1234 >>> -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: get process id...

2006-09-21 Thread Tim Golden
billie wrote: > [EMAIL PROTECTED] ha scritto: > > > SpreadTooThin wrote: > > > How does one get the process id? > > > Is there a method for windows and unix (mac os x etc...) > > > > under linux, do: > > import os > > os.getpid() > > Under Windows: > import ctypes > ctypes.windll.kernel32.GetCu

RE: Using py2exe to wrap a service?

2006-09-21 Thread Tim Golden
[MaR] | I do not call pythoncom.CoInitialize () as I tend to expect a module | wrapping COM stuff to do that. Hmmm. A slightly philosophical point. As the author of the said module, I think I'd have said that the other way round: I do not call CoInit... because I expect a user of the module *wh

RE: Using py2exe to wrap a service?

2006-09-21 Thread Tim Golden
[MaR] | Tim Golden wrote: | > [MaR] | > | > | I do not call pythoncom.CoInitialize () as I tend to | expect a module | > | wrapping COM stuff to do that. | > | > Hmmm. A slightly philosophical point. | [snip] | | :o) I agree! | | I have added the CoInit.. call to the __init__

Re: How to return an "not string' error in function?

2006-09-21 Thread Tim Chase
> def test(s): >if type(s) != ? : > return > #So here I want establish a situation about that if is not string > #then , but how should write the ? > #Or is there any other way to do it? >>> isinstance("hello", basestring) True >>> isinstance(u"hello", basestring) True This

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

2006-09-22 Thread Tim Williams
> > > Just as a matter of interest, are you expecting that you'll find out > about the undeliverable ones? Because in many cases nowadays you wont, > since so many domains are filtering out "undeliverable mail" messages as > an anti-spam defence. > ...and then there is the problem of validating th

Re: Replacing line in a text file

2006-09-22 Thread Tim Chase
> I am trying to read a file > This file has a line containing string 'disable = yes' > > I want to change this line to 'disable = no' Sounds like sed -i 's/disable *= *yes/disable = no/' file.txt would do what you want. It doesn't catch word boundaries, so if you have something like

Re: Replacing line in a text file

2006-09-22 Thread Tim Chase
> That is, until such time as Guido finalizes PyESP. > > import PyESP > e = ESP.mindread(CSUIDL, "r") Sounds like an extension to the __future__ module. >>> from __future__ import answers >>> answers.answer(op.question) How many other languages have a time-machine built-in, that will take th

Re: Newbie RE question

2006-09-22 Thread Tim Chase
> I would like to search for any of the strings in r'/\:*?"<>|' in a > string using RE module. Can someone tell me how? use the search() method of the regexp object. r = re.compile(r'[/\:*?"<>|]') results = r.search(a_string) or, if you're interested in the first location: r.finditer(target).n

Re: Is it possible to change a picture resolution with Python?

2006-09-22 Thread Tim Roberts
"Lad" <[EMAIL PROTECTED]> wrote: > >Tim , >Thank you for the explanation, >And I must also thank you all you others, who helped me. >Particularly, bearophile and Max. > >Now I use the following code , that provided bearophile, > >from PIL import Im

Re: Spliting a string on non alpha characters

2006-09-23 Thread Tim Chase
> I'm relatively new to python but I already noticed that many lines of > python code can be simplified to a oneliner by some clever coder. As > the topics says, I'm trying to split lines like this : > > 'foo bar- blah/hm.lala' -> [foo, bar, blah, hm, lala] > > 'foobbbar.. xyz' -> [foo, bbbar

Re: Verify an e-mail-adress - syntax and dns

2006-09-24 Thread Tim Williams
On 24/09/06, Ingo Linkweiler <[EMAIL PROTECTED]> wrote: > Has anyone a function/script to verify an e-mail-address? > > It should: > a) check the syntax > b) verify an existing mailserver or DNS/MX records > b) is problematical. A domain with MX records may not really have a mail server at all.

Re: ruby %w equivalent

2006-09-24 Thread Tim Chase
>> 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. bah, far to easy to understand...add a little line-noise, man, and it

Re: Remap Mysql tuple to dictionary

2006-09-25 Thread Tim Chase
> def remapmysql(a): > return (a[0], (a[1:])) > > def test_map(): > count = 10 # count of simulated records > l1 = range(0, count) > l2 = range(count , 2 * count ) > l3 = range(2 * count, 3 * count ) > z1 = zip(l1, l2, l3) # simulate a mysql resultset > > d1

Re: Newbie RE question

2006-09-25 Thread Tim Chase
1) Please don't top-post...it makes it hard to reply in context 2) You may want to "reply to all" so that the mailing list gets CC'd...there are lots of smart folks on the list, and by replying only to me, you limit your options to the meager extents of my knowledge. >>> I would like to search

[ANN] tperimeter 1.110 Released And Available

2006-09-25 Thread Tim Daneliuk
pdf, dvi, and Postscript formats. There is no licensing cost for individual non-commercial use. -- Tim Daneliuk [EMAIL PROTECTED] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: concat next line with previous

2006-09-26 Thread Tim Williams
On 26 Sep 2006 03:16:25 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > hi > what is the python way to concat 2 lines eg > > line 1 with some text > line 2 with some text > > i want to bring line 2 up , such that i get one whole string. > > line 1 with some text line 2 with some text > als

Re: QuoteSQL

2006-09-26 Thread Tim Chase
> "Need" is a strong word unless something like the > following doesn't work for some reason: > > cur.execute("select * from people where last_name in > (%s,%s,%s)", (name1, name2, name3) ) Which could be nicely generalized to something like >>> t = (name1, name2, name3) >>> cur.execute("s

Re: Remap Mysql tuple to dictionary

2006-09-26 Thread Tim Chase
>>NIL ILLEGITIMO CARBORUNDUM > > isn't that usually written > > Illegitimi non carborundum > > or is that just due to differences between british latin and > american latin ? Wouldn't those differences make it "carbourundum" vs. "carborundum" respectively? :*) (however, yes, dredging

Re: identifying new not inherited methods

2006-09-26 Thread Tim Chase
> I am writing a library in which I need to find the names of methods > which are implemented in a class, rather than inherited from another > class. To explain more, and to find if there is another way of doing > it, here is what I want to do: I am defining two classes, say A and B, > as: > > cla

Re: Is there a regular expression for finding email address ?

2006-09-26 Thread Tim Roberts
lt >found, you can get one. The OP should be aware, however, that a regular expression which matches the complete specification in RFC-822 and RFC-2822 is approximately 7,000 characters long. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

RE: Starting Win32 Service

2006-09-27 Thread Tim Golden
[placid] | Using Tim Golden's wmi module you can get the service names | | import wmi | c = wmi.WMI () | stopped_services = c.Win32_Service (StartMode="Auto", State="Stopped") | if stopped_services: | for s in stopped_services: | print s.Caption, "service is

RE: Problem with - WMI()

2006-09-27 Thread Tim Golden
[kath] | the following is code snippet I used to run plink command from Python. | If I run plink command directly it pops out a command prompt | window. To make the command promot window invisible I used WMI | as follows. I'm not sure WMI is necessarily the best way to do this. You might want

Re: sqlite3 error

2006-09-27 Thread Tim Chase
> import sqlite3 > > con = sqlite3.connect('labdb') > cur = con.cursor() > cur.executescript(''' > DROP TABLE IF EXISTS Researchers; > CREATE TABLE Researchers ( > researcherID varchar(9) PRIMARY KEY NOT NULL, > birthYear int(4) DEFAULT NULL, > birthMonth int(2) DEFAULT NULL, >

Re: Top and Bottom Values [PEP: 326]

2006-09-27 Thread Tim Chase
>> To begin with this already fails: >> > for i in xrange(Top): >> ... print i > > What do you expect this to do? Loop forever? Perhaps the infinite loop should take half as long as >>> for i in xrange(Bottom, Top): print i Though then the values when the loop first starts are kin

RE: Starting Win32 Service

2006-09-27 Thread Tim Golden
[placid] | > Now i was trying to use service.ChangeStartMode but each | time i pass in | > an argument i get the error; | > | > #TypeError: __call__() takes exactly 1 argument (2 given) | > | > but; | > | > >>> print service.ChangeStartMode | > (ReturnValue)> | > | > ChangeStartMode needs an argu

RE: Starting Win32 Service

2006-09-28 Thread Tim Golden
| Tim Golden wrote: | ... | > Yes, sorry about that, it's a well-known (to me) gotcha. | > Basically there's no way I can extract the params from | > the COM interface in a way which implies order, so I | > can't take them in positionally. (Corrections to this | >

Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
> In [1]: fileName = 'Perfect Setup.txt\n' > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' > character > In [3]: fileName > Out[3]: 'Perfect Setup.txt' > > Question one: > Does python provide any function that can remove the last character of > a string? > I don't know whethe

Re: remove the last character or the newline character?

2006-09-28 Thread Tim Chase
>> Does python provide any function that can remove the newline character >> from a string if it exists? > > >>> fileName = 'Perfect Setup.txt\n' > >>> fileName.strip() > 'Perfect Setup.txt' > >>> > > Or you can use lstrip() or rstrip() to remove just the left or right side. Just a caveat wit

Re: using the email module

2006-09-28 Thread Tim Williams
On 28/09/06, Erik Johnson wellkeeper dot <"com>"@bag.python.org> wrote: > #!/usr/bin/env python > > import smtplib > from email.MIMEText import MIMEText > from email.MIMEMultipart import MIMEMultipart > > > # GLOBAL DATA > #= > MAIL_SERVER = 'your_server.com' > MAIL_SUBJECT = "Python.

RE: windev vs python SOS

2006-09-29 Thread Tim Golden
[Méta-MCI - translated for non-Francophones] | Re-Bonjour ! Hello again! | J'avais écrit, dans le message précédent, que la société | PC-Soft avait eu des difficultés financières, | il y a plusieurs années. I wrote in the last message that PC-Soft had had financial difficulties a few years ag

Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread Tim Chase
> def chunkify(s, chunksize): > "Yield sequence s in chunks of size chunksize." > for i in range(0, len(s), chunksize): > yield s[i:i+chunksize] > > I wrote this because I need to take a string of a really, really long > length and process 4000 bytes at a time. > > Is there a bett

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Matthew Warren <[EMAIL PROTECTED]> wrote: > I have > found that in real usage of other programs within the company that use > lockfiles, it sometimes causes a bit of troubleshooting time when it stops > working due to a stale lockfile.. This especially happens when the program > is ki

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > > def check_lock(): > > import os, sys > > try: > > os.remove({filename}) > > except: > > if "Permission denied" in sys.exc_info()[

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Checking for a lock, and later acquiring the lock, seems non-atomic to > me. It's easier to simply create a lock directory. If it fails, the > dir already exists and someone else holds the lock. If it succeeds, > the lock is immediately yours,

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29 Sep 2006 09:47:12 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Tim Williams" <[EMAIL PROTECTED]> writes: > > My reply was in response to a post that mentioned a known problem with > > this, what happens when the previously r

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29 Sep 2006 10:04:15 -0700, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > "Tim Williams" <[EMAIL PROTECTED]> writes: > > That's the same kind of principle as my posted snippet, it doesn't > > rely on the file's presence or

Re: Making sure script only runs once instance at a time.

2006-09-29 Thread Tim Williams
On 29/09/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tim Williams wrote: > > > So that I know my mistake, which bit fails (the text from > > sys.exc_info()[1]?? ) , or is it all complete rubbish - and not > > do-able - on a *nix system ? > > opening a file

Re: Passing Arguments

2006-09-29 Thread Tim Chase
> It works fine when I 'Run Module'...but when I type in interactive mode > in the Python Shell python using_sys.py test1 test2 test3 > > I get the following error: > SyntaxError: invalid syntax By using proper syntax... :*) To pass parameters, you do it when *starting* python[*]. Thus,

Re: retry in exception

2006-09-29 Thread Tim Chase
> In ruby, the equivalent to try...except is begin...rescue. In the > rescue section you can ask it to retry the begin section. So, for > example: > > b=0 > begin > puts 1/b > rescue > b=1 > retry # <- this little guy > end Well, it's all a matter of how you look at it. I personally pref

Re: creating a small test server on my local computer

2006-09-29 Thread Tim Chase
>> Why do you need to use Python for the server? > > Well, perhaps I don't know what I'm talking about. I'm on an XP machine > and I just needed a way to test my web pages, and I thought Python could > be used to create a server to do this. But I know nothing about network > programming... Wel

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

2006-10-01 Thread Tim Peters
[charlie strauss] > Below is a simple program that will cause python to intermittently > stop executing for a few seconds. it's 100% reproducible on my machine. Any program that creates a great many long-lived container objects will behave similarly during the creation phase. Others have explain

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

2006-10-01 Thread Tim Peters
[charlie strauss] >>> Below is a simple program that will cause python to intermittently >>> stop executing for a few seconds. it's 100% reproducible on my >>> machine. [Giovanni Bajo] >> Confirmed with Python 2.4.2 on Windows. [Jorgen Grahn] > And Python 2.3.5 on Linux, amd64. In fact, it caus

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

2006-10-01 Thread Tim Peters
[Steve Holden, "pins the blame" for pauses on periodic cyclic gc] > ... > So basically what you have here is a pathological example of why it's > sometimes wise to disable garbage collection. Tim, did I miss anything? Nope! -- http://mail.python.org/mailman/listinfo/python-list

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

2006-10-01 Thread Tim Peters
[charlie strauss] > I want to clarify that, on my computer, the first instance of the gap occurs > way > before the memory if filled. (at about 20% of physical ram). Additionally the > process monitor shows no page faults. Python has no idea of how much RAM you have, or even of how much RAM it's

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

2006-10-01 Thread Tim Peters
[charlie strauss] > Steve, digging into the gc docs a bit more, I think the behaviour I am seeing > is still > not expected. Namely, the program I offered has no obvious place where > objects > are deallocated. The way GC is supposed to work is thate there are three > levels of > objects > > l

<    31   32   33   34   35   36   37   38   39   40   >