Re: find all index positions

2006-05-11 Thread Tim Chase
> say i have string like this > astring = 'abcd efgd 1234 fsdf gfds abcde 1234' > if i want to find which postion is 1234, how can i > achieve this...? i want to use index() but it only give > me the first occurence. I want to know the positions of > both "1234" Well, I'm not sure how efficient it

Re: Python memory deallocate

2006-05-11 Thread Tim Peters
[Serge Orlov] > BTW python 2.5 now returns free memory to OS, but if a program keeps > allocating more memory with each new iteration in python 2.4, it will > not help. No version of CPython ever returns memory to "the OS". All memory is obtained via the platform C's alloc() or realloc(), and any

Re: Reg Ex help

2006-05-11 Thread Tim Chase
> /main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT > from /main/parallel_branch_1/release_branch_1.0/4 > > I want to write a regex that gives me the branch the file was > checkedout on ,in this case - 'dbg_for_python' > > Also if there is a better way than using regex, please

Re: [ANN] tdir 1.69 Released And Available

2006-05-11 Thread Tim Daneliuk
Edward Elliott wrote: > Tim Daneliuk wrote: > >> 'tdir' is a reimplementation and enhancement of the old 'xdir' CP/M >> utility from Ancient Times. >> >> 'tdir' is an advanced directory display utility written in Pure Python, >> a

Re: deleting texts between patterns

2006-05-12 Thread Tim Chase
> I wish to delete lines that are in between 'abc' and > 'xyz' and print the rest of the lines. Which is the best > way to do it? While this *is* the python list, you don't specify whether this is the end goal, or whether it's part of a larger program. If it *is* the end goal (namely, you just wan

Re: NEWBIE: Tokenize command output

2006-05-12 Thread Tim Chase
>>starLines = [line for line in p.readlines() if line.startswith("*")] > > files are iterators, so no need to use readlines() (unless it's an old > Python version of course): > > starLines = [line for line in p if line.startswith("*")] Having started with some old Python, it's one of those thin

Re: NEWBIE: Tokenize command output

2006-05-12 Thread Tim Chase
> I reeducated my fingers after having troubles with huge files !-) I'll keep it in mind...the prospect of future trouble with large files is a good kick-in-the-pants to remember. >>Otherwise, just to be informed, what advantage does rstrip() have over >>[:-1] (if the two cases are considered un

Re: Broken essays on python.org

2006-05-12 Thread Tim Parkin
o follow the "Report website bug" link > at the bottom of the sidebar and post a tracker item. I was feeling > generous today ;) so I did that for you: > http://psf.pollenation.net/cgi-bin/trac.cgi/ticket/333 > > STeVe Thanks for the report.. they're fixed now.. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Sending mail with attachment...

2006-05-13 Thread Tim Williams
On 13 May 2006 03:13:33 -0700, Merrigan <[EMAIL PROTECTED]> wrote: > :: > > Code > :: > def mailSender(): > openlogmsg = open(completelog, 'rb') > mesg = MIMEText(openlogmsg.read()) > openlogmsg.close() > mesg['Subject'] = subject > mesg['From'] = fromaddy >

Re: any plans to make pprint() a builtin?

2006-05-14 Thread Tim Golden
Duncan Booth wrote: > John Salerno wrote: > > > Just wondering if this will ever happen, maybe in 3.0 when print becomes > > a function too? It would be a nice option to have it available without > > importing it every time, but maybe making it a builtin violates some > > kind of pythonic ideal? >

Re: Converting hex to char help

2006-05-14 Thread Tim Chase
> How can I convert a string "0x62" to int/hex without this problem? The call to int() takes an optional parameter for the base: >>> print int.__doc__ int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (thi

Re: comparing values in two sets

2006-05-14 Thread Tim Chase
> I'd like to compare the values in two different sets to > test if any of the positions in either set share the same > value (e.g., if the third element of each set is an 'a', > then the test fails). There's an inherant problem with this...sets by definition are unordered, much like dictionaries.

Re: Converting String to int

2006-05-14 Thread Tim Chase
> Hi all, Another problem, with the same error (error: "invalid literal for > int()") Having the actual code would be helpful... > code: > > mynums = "423.523.674.324.342.122.943.421.762.158.830" > > mynumArray = string.split(mynums,".") > > x = 0 > for nums in mynumArray: >if nums.isalnu

RE: Windows Copy Gui

2006-05-15 Thread Tim Golden
[placid] | Just wondering if anyone knows how to pop up the dialog that windows | pops up when copying/moving/deleting files from one directory to | another, in python ? http://timgolden.me.uk/python/win32_how_do_i/copy-a-file.html#shell TJG ___

RE: Formmating excel cells with PyExcelerator or COM

2006-05-15 Thread Tim Golden
[Mauricio Tellez] | Hi, I just want that a number like 1234.123 appear in excel | as 1,234.12 | In excel I just select some cells, then right click on them | and select "Cell Formatting" then select Number, and check | "Use thounsands separator" and 2 decimal places. I can't find | how to do t

Re: Why does stack.inspect take so long?

2006-05-15 Thread Tim Peters
[EMAIL PROTECTED] > Hi, I've written a top-down recursive decent parser for SPICE circuit > descriptions. For debugging purposes, I wanted each production > rule/function to know what its own name was, so at the beginning of > each rule/function, I make a call to inspect.stack()[0][3] (I think...)

Re: advice modifying re library to support more than 100 named captures.

2006-05-16 Thread Tim Peters
[Richard Meraz] > We need to capture more than 99 named groups using python regular > expressions. > ... > its clear why the language designers have decided on this limitation. For > our system, however, it is essential that we be able to capture an arbitrary > number of groups. > > Could anyone o

Re: A Unicode problem -HELP

2006-05-16 Thread Tim Roberts
cial code: "\\u0254". However, I don't see what good that would do you. The \u escape is a Python source code thing. >I'm sure this is straightforward but I can't get it to work. I think it is working exactly as you want. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

RE: Python script windows servcie

2006-05-17 Thread Tim Golden
[Mivabe] | Mivabe formulated the question : | > | > Google helped me discovering that it has something to do | something with | > 'CTRL_LOGOFF_EVENT'. I know what it means but i don't know | how to solve it. | > Is that something i have to configure in the script? | > | > I'n totally new to Py

RE: how to traverse network devices in our system?

2006-05-17 Thread Tim Golden
[EMAIL PROTECTED] | i would like to know whether python can help me querying the network | devices attached to my system (ethernet,wireless) and display their | module name and vendor name? Which OS? If it's windows, you can use WMI. I would guess Linux, tho', from your mention of module name. T

RE: Windows Registry Dump

2006-05-18 Thread Tim Golden
[Dirk Hagemann] | Does someone know how I can make a Text-Dump-File of a remote | Windows-Computer's Registry (not the whole registry - only a part of | it)? Well, your question doesn't seem to rule out this option so I thought I'd offer it: Use regedit to connect to the remote registry, then do

RE: Python Install

2006-05-18 Thread Tim Golden
[D] | Thanks, Paul - do you know where I can get the RPM? I only see the | source on the Python website. Thanks. http://www.python.org/pyvault/ (first Google hit for site:python.org RPM) TJG This e-mail has been scanned

Re: number of different lines in a file

2006-05-18 Thread Tim Chase
> I have a million-line text file with 100 characters per line, > and simply need to determine how many of the lines are distinct. A few ideas: 1) the shell way: bash$ sort file.in | uniq | wc -l This doesn't strip whitespace...a little sed magic would strip off whitespace for you: bash$ sed

RE: Windows Registry Dump

2006-05-19 Thread Tim Golden
[Dirk Hagemann] | @Diez: I'm not trying to hack into somebody's computer - it is about | collecting data from my company's anti-virus-parent-server. | And all the | information is only available in the registry (thanks Symantec...). | | @Tim, olso and Fredrik: THANKS - I will hav

RE: Windows Registry Dump

2006-05-19 Thread Tim Golden
[Dirk Hagemann] | I want to do some analysis (as always ;-) ) and for that | reason I think | it's more practical to go trough a text-file. I can produce this | text-file also by right-click on the key (the folder) in the registry | and select "Export". There one can select Text-File and the |

Re: How to append to a dictionary

2006-05-19 Thread Tim Chase
> groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'} > > I want to add another key: 'ITALIAN' : 'orange' > > How do I append this to 'groups'? groups['ITALIAN'] = 'orange' as described at http://docs.python.org/tut/node7.html#SECTION00750 -tkc -- http://mail.python.org/mail

Re: Reference Counts

2006-05-19 Thread Tim Peters
[raghu, on Heiko Wundram's test program: import sys x = {} i = 0 def test(): global x, i x[i] = "test" i += 1 del x[i-1] # Properly clean up x. for j in xrange(1): print "Before", j, ":", sys.gettotalrefcount() test() print "After", j, ":", sys.gettotalrefcount() ] > Hm

Re: number of different lines in a file

2006-05-19 Thread Tim Chase
> I actually had this problem a couple of weeks ago when I > discovered that my son's .Xsession file was 26 GB and had > filled the disk partition (!). Apparently some games he was > playing were spewing out a lot of errors, and I wanted to find > out which ones were at fault. > > Basically

Re: Segmenting a pickle stream without unpickling

2006-05-19 Thread Tim Peters
[Boris Borcic] > Assuming that the items of my_stream share no content (they are > dumps of db cursor fetches), is there a simple way to do the > equivalent of > > def pickles(my_stream) : > from cPickle import load,dumps > while 1 : > yield dumps(load(my_stream)) > > without the

Re: Decimal and Exponentiation

2006-05-19 Thread Tim Peters
[elventear] > I am the in the need to do some numerical calculations that involve > real numbers that are larger than what the native float can handle. > > I've tried to use Decimal, but I've found one main obstacle that I > don't know how to sort. I need to do exponentiation with real > exponents,

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Tim Peters
[John Salerno, on the difference between `open` and `file`] > Interesting. What is the difference between them now? In 2.5 `file` is unchanged but `open` becomes a function: >>> file >>> open -- http://mail.python.org/mailman/listinfo/python-list

Re: DO NOT USE file() (was Re: altering an object as you iterate over it?)

2006-05-19 Thread Tim Peters
[Tim Peters] >> In 2.5 `file` is unchanged but `open` becomes a function: >> >> >>> file >> >> >>> open >> [Paul Rubin] > So which one are we supposed to use? Use for what? If you're trying to check an object's type, use the

Re: misleading prefix ++

2006-05-20 Thread Tim Chase
>++i >> >>and the interpreter replies >>0 >> >>Don't you think it is misleading when you expect a variable to >>increment? >> > > Terribly. So stop expecting it to increment :) > > Seriously, --i is also valid Python. Both expressions apply two unary > operators to a name. Would you have the

Re: Generating Cutter numbers

2006-05-20 Thread Tim Chase
> I am stumped about what to do when the first letter is Q not > followed by U. It says to use numbers 2-29 for the second > letters a-t, but that is obviously not right (for one thing t > would be 21, not 29). > > Since you seem a little bit more experienced in library > science could you ex

Re: Decimal and Exponentiation

2006-05-20 Thread Tim Peters
[Raymond L. Buvel, on http://calcrpnpy.sourceforge.net/clnumManual.html ] > The clnum module handles this calculation very quickly: > > >>> from clnum import mpf > >>> mpf("1e1") ** mpf("3.01") > mpf('9.99932861e30099',26) That's probably good enough for the OP's needs

Re: Decimal and Exponentiation

2006-05-20 Thread Tim Peters
[Raymond L. Buvel, on http://calcrpnpy.sourceforge.net/clnumManual.html ] >>> The clnum module handles this calculation very quickly: >>> >>> >>> from clnum import mpf >>> >>> mpf("1e1") ** mpf("3.01") >>> m

RE: Win32: Detecting when system is locked or sleeping

2006-05-22 Thread Tim Golden
[rodmc] | I have written an application which works perfectly when the | machine is | operating under normal conditions, however when the screen becomes | locked it imediately starts to fill up several hundred MB's of memory. | | Is there a way to detect when the system is locked? This may not

Re: string.count issue (i'm stupid?)

2006-05-22 Thread Tim Chase
I agree the docstring is a bit confusing and could be clarified as to what's happening > Can someone explain me this? And in which way i can count all > the occurrence of a substring in a master string? (yes all > occurrence reusing already counter character if needed) You should be able to us

Re: Software Needs Philosophers

2006-05-22 Thread Tim Churches
osophers, facts would still be getting people tortured > and killed for discovering and sharing them. Paging Dr Mertz... (http://www.gnosis.cx) Tim C -- http://mail.python.org/mailman/listinfo/python-list

Re: Too big of a list? and other problems

2006-05-22 Thread Tim Chase
> pics = re.compile(r"images/.*\.jpeg") While I'm not sure if this is the issue, you might be having some trouble with the greediness of the "*" repeater here. HTML like will yield a result of "images/1.jpeg"> My first thought would be to install the BeautifulSoup parser, a

Re: module confict? gmpy and operator

2006-05-22 Thread Tim Peters
[EMAIL PROTECTED] > ##Holy Mother of Pearl! > ## > ##>>> for i in range(10): > ##for j in range(10): > ##print '%4d' % (gmpy.mpz(i)*gmpy.mpz(j)), > ##print > ## > ## > ## 0000000000 > ## 012

RE: COM Server crashing when returning large arrays

2006-05-23 Thread Tim Golden
[Alastair Alexander] | Hi ... I'm using pythoncom to create a python COM server | application that needs to be able to return large arrays | to COM client apps. For example, I need to be able to | return an array to Excel that is 500 by 10, with each | element of the array holding a 32 byte st

Re: Valid SQL?

2006-05-23 Thread Tim Chase
> I have this string that I am sending via a Cursor.execute() using > MySQLdb: > > insert into table Ping82_eb13__elearn__ihost__com (`dateTime`, > `values`) values( > "Fri May 12 11:39:02 2006", "1") > > Does anyone see anything wrong with this SQL syntax? While this is the *python* list, rathe

Re: how to work with tab-delimited files?

2006-05-23 Thread Tim Chase
> So in this situation, when the file is being read, is that > single space still determined to be a tab, or do you have to > press tab twice to put a full tab between the names? If there is a literal tab in the file, it will come in (to your code) as a real tab. Your editor may have settings yo

Re: graphs and charts

2006-05-23 Thread Tim Heaney
y, but I've been a Gnuplot for 15+ years, so > I'm biased. > > http://gnuplot-py.sourceforge.net/ You might also be interested in matplotlib http://matplotlib.sourceforge.net/ Here is an example of how I've used it http://cablespeed.com/~theaney/mat191/matplotlib.html Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP-xxx: Unification of for statement and list-comp syntax

2006-05-23 Thread Tim Roberts
, there's really no difference between the first two, and this would work just as well: s = """foo""" + '''bar''' The third line only works for string constants, not for string variables. IMHO, it would be the preferred method

Re: newbie: windows xp scripting

2006-05-23 Thread Tim Roberts
:\DIR2 That will create DIR2 if it does not already exist. >I could fix this with a nested if statement, but it "feels" like >windows should be creating this folder automatically if it doesn't >exist. What "feels" right is rarely a good reference for a command's

Re: Doubt with wx.CallAfter

2006-05-23 Thread Tim Roberts
eLoadMovie and the another one belongs to the handler for the >second event? No. wxCallAfter basically posts another message to the message queue, which will be handled after all the existing messages have been dispatched. Windows message handling is quite synchronous. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: No math module??

2006-05-23 Thread Tim Roberts
However, that doesn't answer the question, because even Python 1.5 should have a module called "math". -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: No math module??

2006-05-24 Thread Tim Golden
Tim Roberts wrote: > WIdgeteye <[EMAIL PROTECTED]> wrote: > > > >On Tue, 23 May 2006 12:40:49 +1000, Ben Finney wrote: > > > >Ok this is weird. I checked: > >/usr/local/lib/python2.3/lib-dynload/math.so > > > >Just as you have on your system and

Re: newbie: windows xp scripting

2006-05-24 Thread Tim Golden
Tim Roberts wrote: > "oscartheduck" <[EMAIL PROTECTED]> wrote: > > > >It wasn't, but after seeing your success I discovered what was wrong. > >My destination directory didn't exist, and for some reason windows > >wasn't automatically creati

Re: Finding Upper-case characters in regexps, unicode friendly.

2006-05-24 Thread Tim Chase
> I'm trying to make a unicode friendly regexp to grab sentences > reasonably reliably for as many unicode languages as > possible, focusing on european languages first, hence it'd be > useful to be able to refer to any uppercase unicode character > instead of just the typical [A-Z], which doesn't

Re: Finding Upper-case characters in regexps, unicode friendly. (oh, bugger)

2006-05-24 Thread Tim Chase
Sorry...I somehow missed the key *uppercase* bit of that, and somehow got it in my head that you just wanted unicode letters, not numbers. Please pardon the brain-blink. I can't find anything in Python's regexp docs that do what you want. Vim's regexp engine has a "uppercase characters" and

Re: John Bokma harassment

2006-05-25 Thread Tim X
? Of course not. This is the same. I think most would have no problem with Xah posting if he did it in a responsible manner. Note that normally I try to remove all the cross posted groups in replies to Xah's thread, but this time, I'm leaving them as I feel the nature of this thread warrants it. If you disagree, please don't hesitate to report me to my ISP as I'm more than willing to defend my decision. If I lose, there not an ISP I'd want to stay with anyway! Tim -- tcross (at) rapttech dot com dot au -- http://mail.python.org/mailman/listinfo/python-list

wincerapi

2006-05-25 Thread Tim Williams
Does anyone have a copy of the wincerapi module.It appears not to be in the win32 extensions anymore, and I've googled lots but not found it available anywhere. Thanks -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list

Re: regex in python

2006-05-25 Thread Tim Chase
> r = > re.compile(r'([^\d]*)(\d{1,3}\.\d{0,2})?(\d*)(\,\d{1,3}\.\d{0,2})?(\d*)?.*') ... > sre_constants.error: nothing to repeat The error gives something away (like any good error message should) You're attempting to repeat something that may not exist. In this case, it's the last question-m

Re: wincerapi

2006-05-25 Thread Tim Williams
On 25 May 2006 07:06:02 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I know this isn't helpful at all, but now I'm curious. What's wincer? > Its a module which provides an interface to the win32 CE Remote API :) -- http://mail.python.org/mailman/listinfo/python-list

Re: how to "normalize" indentation sources

2006-05-25 Thread Tim Peters
[John Machin, quoting reindent.py docs] >> remove empty lines at the end of files. Also ensure the last line ends >> with a newline. [John Salerno] > don't those two things conflict with one another? No. This is the repr of a file with (3) empty lines at the end: "a file\n\n \n \t\n"

Re: Speed up this code?

2006-05-25 Thread Tim Chase
> def rmlist(original, deletions): >return [i for i in original if i not in deletions] > > original will be a list of odd numbers and deletions will be numbers > that are not prime, thus this code will return all items in original > that are not in deletions. For n > 100,000 or so, the program

Re: can't figure out error: module has no attribute...

2006-05-25 Thread Tim Roberts
ndard library. Modules that are part of a single project should be in a common directory for that project. Modules that are of general interest to you for multiple projects should be in \Python24\Lib\site-packages. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can any body help me

2006-05-26 Thread Tim Chase
> 1.Given a test file containing lines of words such as (abc, abb, > abd,abb, etc), write a script that prints, in order of frequency, how > many times each word appears in the file. solution 1) search the list archives...within the last week, someone wanted to count unique lines in an input fil

RE: hide python window

2006-05-26 Thread Tim Golden
[Bell, Kevin] | When I run a script, how can I make it run in the background? I don't | want to see the command window because it runs all day. I'm on | windows... Broadly, two options (depending on what "in the background" means): 1) Complex, but complete: run it as a service. See the example

RE: hide python window, cont'd

2006-05-26 Thread Tim Golden
[John Salerno] | | Bell, Kevin wrote: | > Bell, Kevin wrote: | >> Great! And now that it's hiding w/ .pyw, how would I kill it if I | > want? | >> Just log off, or is there a better way? | >> | >> Kevin | >> | >> | > | >>> JOE WROTE: | >>> Close it in the Task Manager? | > | > | > I don't see

Re: sort a dictionary by keys in specific order

2006-05-26 Thread Tim Chase
> hi i have a normal dictionary with key and value pairs. now i wanna > sort by the keys BUT in a specific order i determine in a list !? any > ideas > > dic = {'key1':'value1', 'key2':'value2', 'key3':'value3'} > > list = [key2, key3, key1] 1) it's bad practice to shadow the list() command...f

Re: sort a dictionary by keys in specific order

2006-05-26 Thread Tim Chase
> how do i get the result back into the dictionary ? Well, if you must, if you've just got the results in my previous post, you can take them and shove them back into a dict with results = [('key1','value1'),('key2','value2)] newDict = dict(results) If you're not doing anything

Re: OLAP and pivot tables

2006-05-26 Thread Tim Churches
well. However, the core data summarisation/subsetting engine is thought to be sound (and there are some unit tests to attest to that). Probably not quite what you were after but I thought it worth a mention. Please post follow-ups, if any, to the NetEpi mailing list: http://sourceforge.net/mail/?group_id=123700 Tim C > > Cheers, > Ben -- http://mail.python.org/mailman/listinfo/python-list

Re: Thread vs. generator problem

2006-05-26 Thread Tim Peters
[Paul Rubin] > ... > When I try to do it in a separate thread: > > import time, itertools > def remote_iterate(iterator, cachesize=5): > # run iterator in a separate thread and yield its values > q = Queue.Queue(cachesize) > def f(): > print 'thread start

Re: Python DLL in Windows Folder

2007-12-26 Thread Tim Roberts
one CRT DLL and freeing in another can cause problems, but in Python, I don't think that can happen. Proper Python add-ins call Python APIs to create and destroy objects, so only the Python runtime will manage the memory. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect when a user switches between windows (in WinXP)?

2007-12-26 Thread Tim Roberts
wide. However, that requires injecting the hook DLL into every process with a Windows, and you certainly don't want to do that in Python. Write a minimal C DLL to be the hook, and have it send messages to your Python process. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to detect when a user switches between windows (in WinXP)?

2007-12-27 Thread Tim Golden
Tim Roberts wrote: > [EMAIL PROTECTED] wrote: >> I'm a beginning-to-intermediate Python programmer with some experience >> in other languages. At the moment I am trying to write a Python >> program that will run in the background and execute a series of >> co

Re: SWbemObjectEx not found

2007-12-27 Thread Tim Golden
jmgmail wrote: > I have a working VBScript and failed to convert it to Python. Can > someone help? > > ==VBScript:== > Set locator = CreateObject("WbemScripting.SWbemLocator") > Set Services = locator.ConnectServer("smsroot1","root/SMS/site_A") > Set instCollection = > Services.Get("SMS_Collection

Re: standalone python web server

2007-12-27 Thread Tim Chase
> Actually, I've considered to use django, however it required to run > command (which I don't have right to do it) > python setup.py install > > Btw, is it possible to use without running setup.py ? Yes, it's quite possible...Django is pure Python, so you just have to have its directory in

Re: getting n items at a time from a generator

2007-12-28 Thread Tim Roberts
d as well. Would this be an appropriate construct to add to itertools? -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: joining rows

2007-12-29 Thread Tim Chase
> A1 > A2 > A3 > B1 > C 2 > D 3 > D 4 > The result should be > > A1|2|3 > B1 > C2 > D3|4 > > What should I do to get my results Well, it depends on whether the resulting order matters. If not,

Re: joining rows

2007-12-29 Thread Tim Chase
> on a second read ... I see that you mean the case that should only > join consecutive lines with the same key Yes...there are actually three cases that occur to me: 1) don't care about order, but want one row for each key (1st value) 2) do care about order, and don't want disjoint runs of dupl

Re: Newbie: Why doesn't this work

2007-12-31 Thread Tim Chase
ot;x.py", line 13, in __setattr__ self.__fName, self.__lName = value ValueError: too many values to unpack (slightly munged traceback as it actually came from the test input file rather than the interactive prompt) -tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Choosing a new language

2007-12-31 Thread Tim Roberts
code reads like English prose. It's certainly possible to code "write-only" sequences by abusing comprehensions and generators, but obfuscations like that are the exception rather than the rule. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: parse text files in a directory?

2008-01-01 Thread Tim Chase
jo3c wrote: > hi everybody > im a newbie in python, i have a question > > how do u parse a bunch of text files in a directory? > > directory: /dir > files: H20080101.txt , > H20080102.txt,H20080103.txt,H20080104.txt,H20080105.txt etc.. > > i already got a python script to read and insert a s

Re: database query - logic question

2008-01-02 Thread Tim Chase
Israel Carr wrote: > Thanks for anyone who takes the time to read this. If I posted to the > wrong list, I apologize and you can disregard. > > I need help with a script to pull data from a postgres database. I'm ok > with the database connection just not sure how to parse the data to get > the

Re: Choosing a new language

2008-01-02 Thread Tim Roberts
test. Bull crap. You don't HEAR about them because of that same security clearance issue, but some of the most complicated and certainly some of the LARGEST computing systems in the world come out of the DoD. You don't create reliable large systems using a corral full of bright-eyed col

Re: Choosing a new language

2008-01-02 Thread Tim Roberts
en a very, very distant point of view with narrowly >squinted eyes. Do you really think so? It seems clear to me that the syntax of PHP was heavily influenced by Perl. PHP lacks the @array and %hash weirdnesses, but most PHP code will work just fine as Perl. -- Tim Roberts, [EMAIL PROTECTED] Pro

Re: reassign to builtin possible !?

2008-01-03 Thread Tim Chase
>> But you can't alter the values for True/False globally with this. > > Are you sure ? what about the following example ? > Is this also shadowing ? > import __builtin__ __builtin__.True = False __builtin__.True > False It doesn't seem to screw things up globally >>> import __b

Re: vim newb - indenting python comments

2008-01-04 Thread Tim Chase
> One problem I have is that the >> indent in normal mode doesn't work > when a line starts with the # character. Any idea what I'm doing > wrong? In short, ">>" *does* indent in normal mode (I presume you accurately mean "Normal" mode, rather than "Insert" mode). The question becomes why doesn'

Re: Python's great, in a word

2008-01-07 Thread Tim Chase
> The best thing about Python is ___. + readable + productive + mind-fitting -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() shorthand

2008-01-07 Thread Tim Chase
> The idea is a shorthand for reduce. Here, _next_ meant the next item > in the iterable c. You mean like one of these: def lookahead(iterator): i = iter(iterator) x = i.next() for item in i: yield x, item x = item def lookahead2(iterator, **kwarg): i = i

Re: Python setup not working on Windows XP

2008-01-07 Thread Tim Roberts
r for .py files? Did you create a PythonHandler referring to hello.py? -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Look for a string on a file and get its line number

2008-01-08 Thread Tim Chase
>> I have to search for a string on a big file. Once this string >> is found, I would need to get the number of the line in which >> the string is located on the file. Do you know how if this is >> possible to do in python ? > > This should be reasonable: > for num, line in enumerate(open

Re: stupid/style/list question

2008-01-08 Thread Tim Chase
> To flush a list it is better doing "del mylist[:]" or "mylist = []"? > Is there a preferred way? If yes, why? It depends on what you want. The former modifies the list in-place while the latter just reassigns the name "mylist" to point to a new list within the local scope as demonstrated by thi

Re: Open a List of Files

2008-01-08 Thread Tim Chase
> I decided that I was just trying to be "too smooth by 1/2" so I fell back to > > messages = open(os.path.join(host_path,'messages.txt'), 'wb') > deliveries = open(os.path.join(host_path,'deliveries.txt'), 'wb') > actions = open(os.path.join(host_path,'actions.txt'), 'wb') > parts = open(os.path.

Re: Open a List of Files

2008-01-09 Thread Tim Chase
> You don't need "for fn in open_files.keys():", you can just use "for fn in > open_files:", but simpler than that is to just use the dictionary values: > > for fn in open_files.values(): > fn.close() This can also work for standard variable names: for f in (messages, deliveries, actions,

Re: printing dots in simple program while waiting

2008-01-09 Thread Tim Chase
Martin Marcher wrote: > John wrote: > >> import time >> s = '.' >> print 'working', # Note the "," at the end of the line >> while True: >> print s, #Note the "," at the end of this line too... >> time.sleep(1) > > see my comment in the code above... see my added comment in the code abov

Re: How to get memory size/usage of python object

2008-01-09 Thread Tim Chase
Sion Arrowsmith wrote: > Santiago Romero <[EMAIL PROTECTED]> wrote: >> Is there a way to check the REAL size in memory of a python object? >> >> Something like >> >>> print sizeof(mylist) >> [ ... ] > > Would you care to precisely define "REAL size" first? Consider: > atuple = (1, 2)

Re: problem of converting a list to dict

2008-01-09 Thread Tim Chase
> mylist=['','tom=boss','mike=manager','paul=employee','meaningless'] > > I'd like to remove the first and the last item as they are irrevalent, > and convert it to the dict: > {'tom':'boss','mike':'manager','paul':'employee'} > > I tried this but it didn't work: > > mydict={} > for i in mylist[

Re: for loop without variable

2008-01-09 Thread Tim Chase
>> Hi. I'd like to be able to write a loop such as: >> for i in range(10): >> pass >> but without the i variable. The reason for this is I'm using pylint >> and it complains about the unused variable i. > > if a computer tells you to do something stupid, it's often better to > find a way to t

Re: Tracking colors

2008-01-09 Thread Tim Roberts
tly from frame to frame. You'll have to look for a range. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: What is "lambda x=x : ... " ?

2008-01-10 Thread Tim Chase
> What does "y=y" and "c=c" mean in the lambda function? the same thing it does in a function definition: def myfunct(a, b=42, y=3.141): pass > # > x = 3 > y = lambda x=x : x+10 > > print y(2) > ## > > It prints 12, so it doesn't bind the variable in th

Re: for loop without variable

2008-01-11 Thread Tim Chase
>> I recently faced a similar issue doing something like this: >> >> data_out = [] >> for i in range(len(data_in)): >> data_out.append([]) > > Another way to write this is > data_out = [[]] * len(data_in) ...if you're willing to put up with this side-effect: >>> data_in = ran

Re: FindWindowById returns None..... ?

2008-01-11 Thread Tim Roberts
t. Your description isn't specific enough; there are several ways to do it, some right, some wrong... -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Image/Video Processing in Python

2008-01-11 Thread Tim Roberts
re talking about raw number crunching. This is exactly the kind of case where you should write some C or C++ code and call it from Python. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: ISO Python example projects (like in Perl Cookbook)

2008-01-11 Thread Tim Roberts
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: > >You know you've been working at a large company for too long when you >see that subject and think "ISO-certified Python?" That's exactly what I thought, too. After reading the post I assume he a

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