Re: Deleting lines from a file

2007-12-17 Thread Tim Chase
> I need to write a program which reads an external text file. Each time > it reads, then it needs to delete some lines, for instance from second > line to 55th line. The file is really big, so what do you think is the > fastest method to delete specific lines in a text file ? Generally, with file

Re: checking for negative values in a list

2007-12-17 Thread Tim Chase
> i am new to python guys. >i have a list of numbers > > say a = [1,-1,3,-2,4,-6] > > how should i check for negative values in the list I'm not sure if this is a homework problem, as it seems to be a fairly simple programming problem whether you know Python or not. If you're using

Re: is it possible to install 2 Python versions on windows XP ?

2007-12-17 Thread Tim Golden
Dan wrote: > On Dec 17, 11:07 am, Stef Mientki <[EMAIL PROTECTED]> > wrote: >> hello, >> >> I'm currently using Python 2.4, >> and I don't dare to switch to 2.5, >> because I depend heavily on Scipy, which is based on 2.4 >> >> To test some other Python programs I need Python version 2.5. >> I've t

Re: checking a string against multiple patterns

2007-12-18 Thread Tim Chase
> Define a small function with each test+action, and iterate over them > until a match is found: > > def check1(input): > match = re.search(pattern1, input) > if match: > return input[:match.end(1)] > > def check2(input): > match = re.search(pattern2, input) > if match: > return .

Re: why only an msi-installer for windows ?

2007-12-18 Thread Tim Couper
. not sure that they're up for putting it on other operating systems .. but you may want to email Bill G and ask him .. Tim Stef Mientki wrote: > hello, > > having a lot of trouble installing 2.5 (without affecting my stable 2.4), > I wonder why there's only a msi installer

Re: Does fileinput.input() read STDIN all at once?

2007-12-19 Thread Tim Roberts
input.py module, this will eventually call FileInput.next(), which eventually calls FileInput.readline(), which eventually calls stdin.readlines(_bufsize). The default buffer size is 8,192 bytes. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there *any* real documentation to PyWin32?

2007-12-20 Thread Tim Golden
Benoit wrote: > I understand that the Win32 has been said to be itself poorly > documented, so perhaps that the documentation that comes with the > modules is of similar quality is no coincidence. Maybe I'm still too > young in my programming to grasp the good of that documentation, but > for myse

Re: smtplib problem, Unable to relay for

2007-12-21 Thread Tim Williams
On 21/12/2007, Benedict Verheyen <[EMAIL PROTECTED]> wrote: > Hi, > > i get an "Unable to relay for" when trying to send an email from within > my network to an email address not on my domain. > I don't understand why it says "relaying" as i'm sending from an > internal domain user to an external u

Re: wxPython FileDialog, select folder

2007-12-22 Thread Tim Roberts
-rw-r--r-- 1 pofuk pofuk 105 2007-12-19 21:59 login.py Do you want to KNOW the permissions, or do you really want to get the output of "ls -l"? What you probably want is os.walk. You can call stat or os.path.isdir to get information about the files you discover. -- Tim R

Re: Damn error!

2007-12-24 Thread Tim Chase
> def print_tabela(tabela): > print "Tabela 1 | Tabela 2" > for linha in tabela: > tmp = linha.split(":") in here, insert this: print len(tmp), > print tmp[0] + " | " + tmp[1], I also think you may not want the tra

Re: Python DLL in Windows Folder

2007-12-24 Thread Tim Roberts
iew, what disqualifies python24.dll as a "system file"? The fact that it wasn't produced by Microsoft? >Installing application DLLs in the system directory is something that >should only be done for backwards compatiblity. Deployment of Python applications is much easier wh

Re: filling today's date in a form

2006-04-17 Thread Tim Chase
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, Kun <[EMAIL PROTECTED]> > wrote: > > >>... but i am >>wondering if there is a way to create a button which would automatically >>insert today's date in the date form field if the user chooses to use >>today's date. > > > If you're

Re: scanning through page and replacing all instances of 00:00:00.00

2006-04-17 Thread Tim Chase
> I have a python-cgi file that pulls data from an sql > database, i am wondering what is the easiest way to > remove all instances of '00:00:00.00' in my date column. > > how would i write a python script to scan the entire page > and delete all instances of '00:00:00.00', would i use > regular e

Re: scanning through page and replacing all instances of 00:00:00.00

2006-04-17 Thread Tim Chase
> for col in range(0, numcols): > print "", record[col], "" This is the point at which you want to intercept the column data and make your change: print "", str(record[col]).replace("00:00:00.0", ""), "%s" % foo or alternatively DATECOLUMNS = [3, 14] for col

Re: PEP 359: The "make" Statement

2006-04-17 Thread Tim Hochberg
t all that clear, I admit, but had you read the subsequent followups, it would have been clear that I wasn't arguing against the utility of the statement (nor was I arguing for it), I was arguing against complicating it for a useless use case. In particular making the namespace associated wit

Re: PEP 359: The "make" Statement

2006-04-17 Thread Tim Hochberg
Carl Banks wrote: > Tim Hochberg wrote: > >>Carl Banks wrote: >> >>>Mike Orr wrote: >>> >>> >>>>>I think this PEP is going off the rails. It's primary virtue was that it >>>> >>>>was a simpler, clea

Re: [OT] Any Python lullabies?

2006-04-18 Thread Tim Chase
> Since there have been python limmericks, are there any > Python lullabies that I can sing to my newborn son > (actually, born yesterday)? I tried to murmur some > select parts from the tutorial, but he somehow wasn't > very interested :) Well, you might start with "Twinkle, Twinkle, Little Ast

Uniquifying a list?

2006-04-18 Thread Tim Chase
Is there an obvious/pythonic way to remove duplicates from a list (resulting order doesn't matter, or can be sorted postfacto)? My first-pass hack was something of the form >>> myList = [3,1,4,1,5,9,2,6,5,3,5] >>> uniq = dict([k,None for k in myList).keys() or alternatively >>> uniq = list

Re: CGI scripts

2006-04-18 Thread Tim Roberts
cording to the Pipex web page, if you got their low-end hosting package based on Linux, you get PHP4, PHP5, or Perl. No Python. Perhaps you should have checked your requirements before you spent money on a web host. There are many good, inexpensive web hosting companies that do allow Python

Re: removing cgi fieldstorage keys

2006-04-18 Thread Tim Roberts
darned well better figure out where they're coming from! Did you add any fields? Did you add an image map? On the other hand, why do you want to remove them? -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: items in an array

2006-04-19 Thread Tim Chase
t a tuple containing just the one string (which it strangely seems like your example is doing), you can do one_string_tuple = (",".join(list_array),) (note the peculiar "trailing comma in parens creates a one-element tuple" syntax...it often catches new Python programmers off-guard) HTH, -tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Updated PEP 359: The make statement

2006-04-20 Thread Tim Roberts
=) I tried to follow the thread backwards and find out what proposed change in the "class" construct would render "make" unnecessary, but I couldn't find it. Can you summarize, Steven? -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Activating Batch Files from Python

2006-04-20 Thread Tim Roberts
sibility is to parse your .bat files by hand, and make the changes to your os.environ. Your subprocesses inherit that. .BAT files are easy to parse, especially if they're just a bunch of 'set' statements. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to append to a list twice?

2006-04-21 Thread Tim Chase
> If I want to create a list of the form [100, 99, 99, 98, 98, 97, 97...] > (where each item is repeated twice after the first one), how might I do > that most efficiently? > > Right now I have this: > > series = [100] > for x in range(10): # just for testing > series.append(series[-1] -

Re: how to append to a list twice?

2006-04-21 Thread Tim Chase
> Interesting. I tried the *2 method twice, but I kept > getting weird results, I guess because I was using append > and not extend. I thought extend added lists to lists, > but obviously that's not the case here. In the above example, it *is* "add[ing] lists to lists". Note the set of brackets:

Re: proposed Python logo

2006-04-21 Thread Tim Parkin
g is one of > the parts that disturbs me. > They're freindly snakes at a tadpole fancy dress competition having a 'cuddle'. Where do you think Python eggs come from... Tim Parkin p.s. the logo is actually based on mayan representations of snakes which very often represent only t

Re: proposed Python logo

2006-04-21 Thread Tim Parkin
version of the logo? > An alternate 'collectors' rendition of the new logo as used by Guido Van Rossum in his recent New York Google presentations and also as on t-shirts, mugs and flags handed out during EuroPython 2005! Tim Parkin p.s. was that good enough spin for you ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: what has python added to programming languages? (lets be esoteric, shall we ; )

2006-04-21 Thread Tim Chase
> Actually, I can't think off the top of my head, any > feature in the Java language (and I am making no > assertions about the implementation of specific > instances) that was truly innovative. Let's see...it has bytecode compliation. Oh...not original. Okay, howsabout cross-platform neutra

Re: problems when unpacking tuple ...

2006-04-22 Thread Tim Chase
> for a,b,c,d in line.split() : > [snip] > > The output (when given the data I want to parse) is: > ['0.0','1','0.04','0'] You'll notice that you're not passing any parameters to split(). By default, it splits on whitespace, and your input doesn't have any whitespace in it. Thus, you'

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Robert Kern] > ... > ph3 = math.atan( ac3.imag / ac3.real ) > ... Don't do that: atan2 is the correct way to compute the angle, because the signs of both inputs are needed to determine the correct quadrant. So do: ph3 = math.atan2(ac3.imag, ac3.real) instead. -- http://mail.python.o

Re: Problem calling math.cos()

2006-04-22 Thread Tim Peters
[Roy Smith] > I certainly agree about using atan2() instead of atan(), but I'm surprised > there's not an easier way to get the phase of a complex, just like abs() > gives you the modulus. I can see why you wouldn't want to pollute the > global namespace with another built-in just for this purpose

Re: Performance of Python 2.3 and 2.4

2006-04-22 Thread Tim Peters
[Michal Kwiatkowski] > I was just wondering... > > Python 2.3.5 (#2, Mar 6 2006, 10:12:24) > [GCC 4.0.3 20060304 (prerelease) (Debian 4.0.2-10)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import timeit > >>> a = timeit.Timer('2**1') > >>> b = t

Re: bug in modulus?

2006-04-23 Thread Tim Peters
[EMAIL PROTECTED] > I think there might be something wrong with the implementation of > modulus. > > Negative float values close to 0.0 break the identity "0 <= abs(a % b) < > abs(b)". While that's a mathematical identity, floating point has finite precision. Many mathematical identities can fai

Re: Probability Problem

2006-04-24 Thread Tim Peters
[Alex Martelli] >> ... >> You can compute the requested answer exactly with no random number >> generation whatsoever: compute the probability of each result from >> 0 to 1000, then sum the probabilities of entries that are exactly 390 >> apart. [Elliot Temple] > That was the plan, but how do I ge

Re: python application ideas.

2006-04-25 Thread Tim Parkin
riting it? Without an imagination you pretty much stagnate your whole > learning process. Thanks in advance. > How about writing a standalone wiki markup parser? I know a *lot* of people who would find this useful.. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Probability Problem

2006-04-25 Thread Tim Peters
[Elliot Temple] > I think I got it. I noticed my code is essentially the same as Tim > Peter's (plus the part of the problem he skipped). I read his code 20 > minutes before recreating mine from Alex's hints. Thanks! > > def main(): > ways = ways_to_roll() >

Re: Multithreading and Queue

2006-04-25 Thread Tim Peters
[Jeffrey Barish] > Several methods in Queue.Queue have warnings in their doc strings that they > are not reliable (e.g., qsize). I note that the code in all these methods > is bracketed with lock acquire/release. These locks are intended to > protect the enclosed code from collisions with other t

RE: blob problems in pysqlite

2006-04-26 Thread Tim Golden
[EMAIL PROTECTED] | I'm a long-time lurker and (I think) first time poster. | Only relatively new to python, and I'm trying to get pysqlite to work | with binary data, and having a tough time of it. | I want to set up a table with: | - a URL, | - some filenames related to that URL, | - and some si

Re: Speed of shutil.copy vs os.system("copy src dest") in win32

2006-04-27 Thread Tim Roberts
pyfileobj >implementation of hacking through the file and writing a new one is >significantly faster... any clue as to why this is? I figure I'm >missing something here. > >Does os.system launch a cmd shell every time? Yes. That's in the documentation. -- - Tim Roberts

Re: list of functions question

2006-04-27 Thread Tim Roberts
ould have worked: event_list = [f1, f2, etc] As it is, event_list is a list of strings, not a list of functions. Then, when you want to call it, remember that it has to be treated like a function: for ev in event_list: if ev(t): pass If you REALLY need the list of functions to

RE: Speed of shutil.copy vs os.system("copy src dest") in win32

2006-04-27 Thread Tim Golden
[Russell Warren] | I just did a comparison of the copying speed of shutil.copy | against the | speed of a direct windows copy using os.system. I copied a file that | was 1083 KB. | | I'm very interested to see that the shutil.copy copyfileobj | implementation of hacking through the file and wri

Re: Can one query full name (or version) of selected packages at pypi?

2006-04-27 Thread Tim Golden
[Caleb Hattingh] > My big problem, being in South Africa, is > that I have to get any distros on cover CDs or order from > distro-resellers, and they never have Testing or Unstable. Broadband > hasn't exactly hit the local market, although things might be looking > up in a few years or so. I ha

RE: Importing modules through directory shortcuts on Windows

2006-04-27 Thread Tim Golden
[Roger Upole] | You can use win32file.DeviceIoControl to link directories. | I can post some code to do so if anyone's interested. I'd certainly be interested... Thanks TJG This e-mail has been scanned for all viruses by S

RE: blob problems in pysqlite

2006-04-27 Thread Tim Golden
KnownFilesResult: (pickled_result,) = row unpickled_result = cPickle.loads (pickled_result) # do things with unpickled result | ps. Tim: Your clean take on my code made me realise that I | had stupidly included quotes in the URL argument passed to | sqlite ... It's the little things that

Re: PyEval_EvalFrame

2006-04-27 Thread Tim Peters
[EMAIL PROTECTED] > I see a C/python program that we're using spending a lot of time in > this function, far more than we think it should. What is it? PyEval_EvalFrame is the heart of the CPython interpreter: it's a very large function that _implements_ the interpreter, marching through the byte

Re: how to free the big list memory

2006-04-27 Thread Tim Peters
[kyo guan] > Python version 2.4.3 > > >>> l=range(50*1024*100) > > after this code, you can see the python nearly using about 80MB. > > then I do this > > >>> del l > > after this, the python still using more then 60MB, Why the python don't free > my > memory? It's that you've created 5 million i

RE: Importing modules through directory shortcuts on Windows

2006-04-28 Thread Tim Golden
[Roger Upole] | [... snipped ugly code ...] Thanks; I'll have to find the time to experiment with that a bit. TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more inform

RE: Get all attributes of a com object

2006-04-28 Thread Tim Golden
[bruno at modulix] | Duncan Booth wrote: | > That will show him the attributes of the Python wrapper | around the COM | > object, it won't show him the attributes of the underlying | COM object | > itself. | | I stand corrected - and shouldn't answer questions about MS technos :( In fact, i

RE: Get all attributes of a com object

2006-04-28 Thread Tim Golden
[Stefan Schukat] | You can only build a proxy module if you have the typelibrary | information which not all programs provide, since it prohibits | changes in the interface the easy way. E.g., MFC application | will normally not provide a typelibrary but support dynamic | dispatch. Oh. Thanks.

RE: os.startfile() - one or two arguments?

2006-04-28 Thread Tim Golden
[BartlebyScrivener] | Can any Windows user give a working example of adding a "command verb" | to os.startfile()? I'm afraid the core Python version of this command has only grown the command verb since 2.5a1. Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32 Type "h

Re: Popping from the middle of a deque + deque rotation speed

2006-04-28 Thread Tim Chase
> Does anyone have an easier/faster/better way of popping from the middle > of a deque than this? > > class mydeque(deque): > def popmiddle(self, pos): > self.rotate(-pos) > ret = self.popleft() > self.rotate(pos) > return ret My first thought would just be to use indexing:

Re: convert a int to a list

2006-04-28 Thread Tim Chase
> > a = ['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]] > > As an exercise, write a loop that traverses the previous list and > prints the length of each element. What happens if you send an > integer to len?

Re: Popping from the middle of a deque + deque rotation speed

2006-04-28 Thread Tim Peters
[Russell Warren] |> Does anyone have an easier/faster/better way of popping from the middle > of a deque than this? > > class mydeque(deque): > def popmiddle(self, pos): > self.rotate(-pos) > ret = self.popleft() > self.rotate(pos) > return ret As Tim

Re: Recommendations for a PostgreSQL db adapter, please?

2006-04-29 Thread Tim Churches
t is inevitable that people move on to new projects (such as pySQLite), but it would be a shame if pyPgSQL just rotted, because it has several things in its favour, such as some unit tests (which were conspicuously absent from any of the alternatives when we evaluated them in 2003 - perhaps

Re: How to get computer name

2006-04-29 Thread Tim Heaney
ng system, the environment variable you need might have a different name. For example, I think in Windows you might try >>> os.getenv('COMPUTERNAME') You can see all of the environment variables currently available with >>> os.environ I hope this helps, Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting tuple to String

2006-04-30 Thread Tim Williams
"There" being, in reality, seperate? >>> print  " ".join(xyz)Hello There HTH :) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: wxpython - new line in radiobutton's label?

2006-04-30 Thread Tim Roberts
example code also didn't >turn up anything. The native Windows radio button cannot do multiline labels. You'll have to do the first line in the radio button, and the second line as a wx.StaticText. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http

Re: list*list

2006-05-01 Thread Tim Williams
On 1 May 2006 08:28:12 -0700, BBands <[EMAIL PROTECTED]> wrote: There must be a better way to multiply the elements of one list byanother:a = [1,2,3]b = [1,2,3]c = []for i in range(len(a)):c.append(a[i]*b[i])a = cprint a[1, 4, 9] Something like: >>> [ x * y  for x,y in zip(a,b) ] [1, 4, 9

Re: list*list

2006-05-01 Thread Tim Chase
tter addressed by NumPy? a = [1,2,3] b = [1,2,3] c = [q*r for q,r in zip(a,b)] seems to do the trick for me. -tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Popping from the middle of a deque + deque rotation speed

2006-05-01 Thread Tim Peters
[Russell Warren] > ... > As to indexing into a deque being O(index)... I didn't realize that. > It is certainly something to keep in mind, though... looping through > the contents of a deque would obviously be a bad idea with this being > the case! I wonder if the generator for the deque helps red

Re: stripping

2006-05-02 Thread Tim Williams
On 1 May 2006 23:20:56 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:hii have a file test.dat egabcdefghijklmn <-newline opqrstuvwxyz  <---newlineI wish to print the contents of the file such that it appears:abcdefghijklmnopqrstuvwxyzhere is what i did:f = open("test.dat")

Re: stripping

2006-05-02 Thread Tim Williams
On 02/05/06, Tim Williams <[EMAIL PROTECTED]> wrote: On 1 May 2006 23:20:56 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED] > wrote:hii have a file test.dat eg f = open("test.dat") while 1: line = f.readline().rstrip("\n") if line: prin

Re: bug in modulus?

2006-05-02 Thread Tim Peters
[Andrew Koenig, on the counter intuitive -1e-050 % 2.0 == 2.0 example] >> I disagree. For any two floating-point numbers a and b, with b != 0, it >> is always possible to represent the exact value of a mod b as a >> floating-point number--at least on every floating-point system I have ever >> enco

Re: search file for tabs

2006-05-02 Thread Tim Chase
> The following code to search a file for tabs does not > work, at least on Windows XP. Could someone please tell > me what's wrong? Thanks. > > xfile = "file_with_tabs.txt" > for text in open(xfile,"r"): > text = text.strip() > if ("\t" in text): > print text Well, are the tabs e

Re: Strange result with math.atan2()

2006-05-02 Thread Tim Peters
[Vedran Furač] > I think that this results must be the same: > > In [3]: math.atan2(-0.0,-1) > Out[3]: -3.1415926535897931 Whether -0.0 and 0.0 are different floats internally depends on your hardware floating-point; on most machines today, they are different floats, but _compare_ equal to each ot

Re: detect video length in seconds

2006-05-02 Thread Tim Roberts
nd a timestamp, then scan backwards from the end of the file until you find a timestamp, and subtract. You can also try to extract the bitrate from an early header and use arithmetic to get a good estimate. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.pytho

Re: Sorting a list of dictionaries by dictionary key

2006-05-03 Thread Tim Chase
> assuming that DateTime returns something that compares correctly, you can > do something like: > > def sortkey(item): > return item.get("from_datetime") > > data.sort(key=sortkey) > > (assuming Python 2.4 or later) Building on Fredrik's solution, for 2.3 (or earlier?), you ca

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Tim Peters
[EMAIL PROTECTED] > Below are 2 files that isolate the problem. Note, both programs hang > (stop responding) What does "stop responding" mean? > with hyper-threading turned on (a BIOS setting), but > work as expected with hyper-threading turned off. > > Note, the Windows task manager shows 2 CPU

Re: Because of multithreading semantics, this is not reliable.

2006-05-03 Thread Tim Peters
[EMAIL PROTECTED] > Because of multithreading semantics, this is not reliable. This > sentence is found in the Python documentation for "7.8.1 Queue > Objects". > > This scares me! Why would Queue.qsize(), Queue.empty( ), and a > Queue.full() not be reliable? Because they may not be telling the

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-03 Thread Tim Peters
>> What do you mean "stop responding"? [EMAIL PROTECTED] > Both threads print their thread numbers (either 1 or 2) approximately > every 10 seconds. However, after a while (minutes to hours) both > programs (see above) hang! Where "hang" means they stop printing. > Pressing ctrl-c (after the pr

Fw: Swaying A Coder Away From Python

2006-05-04 Thread Tim Williams
- Original Message - From: DevWebProUK [EMAIL PROTECTED] To: Sent: Wednesday, May 03, 2006 10:14 PM Subject: Swaying A Coder Away From Python Swaying A Coder Away From Python By David A. Utter One programmer blogged about the powerful attraction he is feeling to C# programming, and

Re: RegEx with multiple occurrences

2006-05-04 Thread Tim Chase
> p = re.compile("(\*\)",re.IGNORECASE | re.DOTALL) > m = p.search(data) First, I presume you didn't copy & paste your expression, as it looks like you're missing a period before the second asterisk. Otherwise, all you'd get is any number of greater-than signs followed by a closing "" tag. Se

Re: Swaying A Coder Away From Python

2006-05-04 Thread Tim Williams
> (and why do you > seem to think that this matters, btw ?) I actually think it is complete twaddle, for the same reasons as you. It was forwarded to me by someone who knows I use Python, and I thought it might be of interest to a balanced list, especially as it shows an external perspectiv

Re: RegEx with multiple occurrences

2006-05-04 Thread Tim Chase
> Tim - you're a legend. Thanks. A leg-end? I always knew something was a-foot. Sorry to make myself the butt of such joking. :) My pleasure...glad it seems to be working for you. -tkc (not much of a legend at all...just a regexp wonk) -- http://mail.python.org/mailman/listinf

Re: Python function returns:

2006-05-04 Thread Tim Chase
> In Python, there does not seem to be an easy way to have > functions return multiple values except it can return a > list such as: strHostname, nPortNumber, status = > get_network_info (strIpAddress, strHostname, nPortNumber) > Am I missing something obvious? Is there a better, or > more standar

Re: Swaying A Coder Away From Python

2006-05-04 Thread Tim Williams
On 04/05/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > nope, but if we were to post to the list every time some random blogger says > something about Python, we wouldn't have room for much other stuff. > It wasn't from a random blogger, it was from an email newsletter for this site: http://www.

Re: Swaying A Coder Away From Python

2006-05-04 Thread Tim Williams
On 4 May 2006 05:24:40 -0700, BartlebyScrivener <[EMAIL PROTECTED]> wrote: > I'm picking this up via clp on Google Groups. I can't tell what Mr. > Lundh is referring to. The first line of his post is: "Tim Williams > wrote" but there's nothing that comes be

Tuple assignment and generators?

2006-05-04 Thread Tim Chase
Just as a pedantic exercise to try and understand Python a bit better, I decided to try to make a generator or class that would allow me to unpack an arbitrary number of calculatible values. In this case, just zeros (though I just to prove whatever ends up working, having a counting generator

Re: Multiple Version Install?

2006-05-04 Thread Tim Peters
[David C.Ullrich] > Would there be issues (registry settings, environment > variables, whatever) if a person tried to install > versions 1.x and 2.x simultaneously on one Windows > system? Windows 98, if it matters. > > (I can handle the file associations with no problem.) There are generally no i

Re: Tuple assignment and generators?

2006-05-04 Thread Tim Chase
> I don't think he was explicitly wanting to initialize > things to zero, but rather unpack an arbitrary sequence > into a tuple (could perhaps be the fibonnacci sequence > for example). Ant is correct here...Fibonnaci, digits of pi, the constant 42, an incrementing counter, a series of squares, w

Re: Using time.sleep() in 2 threads causes lockup when hyper-threading is enabled

2006-05-04 Thread Tim Peters
[Tim Peters] >> I didn't run it for hours ;-) [EMAIL PROTECTED] > Please try. OK, I let the first test program run for over 24 hours by now. It never hung. Overnight, the box did go into sleep mode, but the test woke itself up after sleep mode ended, and the threads reported they

Re: how to remove 50000 elements from a 100000 list?

2006-05-05 Thread Tim Chase
> but when a and b have many elements. such as: > a=range(10) b=range(5) for x in b: > > ... a.remove(x) > ... > it will very slowly. Well, your problem is rather ambiguous. In your examples, you're removing contiguous ranges. Thus, you should be able to do something

Re: combined files together

2006-05-06 Thread Tim Williams
On 06 May 2006 16:41:45 +1000, Gary Wessle <[EMAIL PROTECTED]> wrote: > is there a module to do things like concatenate all files in a given > directory into a big file, where all the files have the same data > formate? If you want to combine text files file1 and file2 into a combined file1 >>>

Re: Replace

2006-05-06 Thread Tim Williams
On 06/05/06, Eric <[EMAIL PROTECTED]> wrote: > I have a string... > > str = "tyrtrbd =ffgtyuf == =tyryr =u=p ff" > > I want to replace the characters after each '=', what I ended up doing is > somthing like this... > > buf = list(str) > newchr = '#' > > count = 0 > for i in range(len(buf)): >

Re: the print statement

2006-05-06 Thread Tim Roberts
at your VGA font happens to display them as the same glyph. >6) Would it be correct to infer that the print statement is aware of >characters beyond the 128 characters in the ascii character set? Certainly. It knows about whatever the current character set is. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: python 2.5a2, gcc 4.1 and memory problems

2006-05-06 Thread Tim Peters
[Michele Petrazzo] > I'm doing some tests on my debian testing and I see a very strange > memory problem with py 2.5a2 (just downloaded) and compiled with gcc > 4.1.0, but not with the gcc 3.3.5: > > My test are: > > #--test.py > import sys > if sys.version.startswith("2.3"): > from sets import S

Re: printing list

2006-05-07 Thread Tim Chase
compboy wrote: > How do you print elements of the list in one line? > > alist = [1, 2, 5, 10, 15] > > so it will be like this: > 1, 2, 5, 10, 15 >>> print ', '.join(alist) 1, 2, 5, 10, 15 -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: printing list

2006-05-07 Thread Tim Williams
On 7 May 2006 09:15:10 -0700, compboy <[EMAIL PROTECTED]> wrote: > How do you print elements of the list in one line? > > alist = [1, 2, 5, 10, 15] > > so it will be like this: > 1, 2, 5, 10, 15 > > because if I use this code > > for i in alist: > print i > > the result would be like this > > 1

RE: Need to send email on HIGH Disk usage

2006-05-08 Thread Tim Golden
[C Saha] | I am looking for a py script which will send me email when | ever my disk becomes more than 90% full. By the way my OS is Win XP. | | If anybody have already has written same type of script or | something very similar kind of script will also be great. You can certainly do this wi

Re: data entry tool

2006-05-08 Thread Tim Williams
On 08/05/06, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > > Make it a webapp. That will guarantee to make it runnable on the list of > OSses you gave. Use Django/TurboGears/ZOPE for the application itself- > whichever suits you best. based on the comment: > I'm not a programmer and have only don

Re: A better way to split up a list

2006-05-08 Thread Tim Chase
> The code below works fine, but it is less than nice to > look at and somewhat long winded. Is there a better way > to do the docstring task? This is the first working > version, and can proabably be "compacted" a bit (list > comprehensions etc) but I am looking for a better basic > approach. Any

Re: A better way to split up a list

2006-05-08 Thread Tim Chase
> Argh, embarassment on my part due to incomplete spec. > movelist is used to store a list of chess moves and > splitting it up in this way is so it can be printed in a > space that is 3 lines high but quite wide. Thus the way > the list grows as it is appended to in chopupmoves is > intended. Per

Re: hyperthreading locks up sleeping threads

2006-05-08 Thread Tim Peters
[EMAIL PROTECTED] > Below are 2 files. The first is a Python program that isolates the > problem within less than 1 hour (often just a few minutes). It does not on my box. I ran that program, from a DOS shell, using the released Windows Python 2.4.3. After an hour, it was still printing. I lef

Re: the print statement

2006-05-08 Thread Tim Roberts
Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: >On Sun, 07 May 2006 00:09:06 GMT, Tim Roberts <[EMAIL PROTECTED]> declaimed >the following in comp.lang.python: > >> [EMAIL PROTECTED] wrote: >> >> >6) Would it be correct to infer that the print statement

RE: Import data from Excel

2006-05-09 Thread Tim Golden
[Dale Strickland-Clark] | from win32com.client import GetObject, constants | | def GetExcelData(self, strFilePath): | """ Extract the data from the Excel sheet. | Returns tuple of tuples representing the rows and cells.""" | # The following line extracts | # all the data from she

Re: Enumerating Regular Expressions

2006-05-09 Thread Tim Chase
> Why are people getting stuck on infinite regular > languages? I've made it quite clear that I'm only really > interested in doing this for finite languages, but that > shouldn't matter anyway. The power of regular expressions is that they define a consice means to encapsulate an infinite numb

Re: Is Welfare Part of Capitalism?

2006-05-09 Thread Tim Daneliuk
[EMAIL PROTECTED] wrote: > This article is dedicated to: > But I am still confused: Is this a statement or an expression? -- http://mail.python.org/mailman/listinfo/python-list

[ANN] tdir 1.69 Released And Available

2006-05-10 Thread Tim Daneliuk
'tdir' Version 1.69 is released and available at: http://www.tundraware.com/Software/tdir/ A FreeBSD port update has also been submitted. What's New -- This version introduces the -D option which supresses "dotfile/dir" display. What Is 'tdir'? --- 'tdir' is a reimple

Re: python rounding problem.

2006-05-10 Thread Tim Roberts
"help", "copyright", "credits" or "license" for more information. >>> round(2.99543322,3) 2.9951 >>> print round(2.99543322,3) 2.995 >>> -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: NEWBIE: Tokenize command output

2006-05-11 Thread Tim Chase
Lorenzo Thurman wrote: > This is what I have so far: > > // > #!/usr/bin/python > > import os > > cmd = 'ntpq -p' > > output = os.popen(cmd).read() > // > > The output is saved in the variable 'output'. What I need to do next is > select the line from that output that starts with the '*' Wel

<    41   42   43   44   45   46   47   48   49   50   >