Re: Finding Full Path to Process EXE

2008-03-28 Thread Tim Golden
[EMAIL PROTECTED] wrote: > Hello, > > I would like to write a script that would enumerate all running > processes and return the full path to the EXE of each running > process. However, I can't seem to find any good info on how to do > this..any help is greatly appreciated. Thanks. I have this

Re: Python tricks

2009-01-12 Thread Tim Chase
My code has a lot of while loops of the following format: while True: ... if : break The danger with such a code is that it might go to an infinite loop - if the never occurs. Is there a way - a python trick - to have a check such that if the loop goes for more than x numbe

Re: efficient interval containment lookup

2009-01-12 Thread Tim Chase
suppose I have two lists of intervals, one significantly larger than the other. For example listA = [(10, 30), (5, 25), (100, 200), ...] might contain thousands of elements while listB (of the same form) might contain hundreds of thousands or millions of elements. I want to count how many interval

Re: win32gui

2009-01-12 Thread Tim Roberts
gt; >their is function called GetWindowText I tried to use but it doesn't >work in most of the time > >someone know a way to do this? Did you not like the reply I gave you the first time you asked this question? -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary operator and tuple unpacking -- What am I missing ?

2009-01-12 Thread Tim Roberts
>7) >>> c,d = n if n is not None else 0,0 >8) >>> print c,d >9) (22, 11) 0 >10) >>> c,d = n if n is not None else (0,0) >11) >>> print c,d >12) 22 11 As line 10 makes clear, line 7 is interpreted thus: c,d = (n if n is not None else 0) , 0

Re: efficient interval containment lookup

2009-01-13 Thread Tim Chase
Per Freem wrote: i forgot to add, my naive_find is: def naive_find(intervals, start, stop): results = [] for interval in intervals: if interval.start >= start and interval.stop <= stop: results.append(interval) return results I don't know if using a list-comprehension here is a

Re: Suggested improvements for IDLE (non-official)

2009-01-15 Thread Tim H
r wrote: On Jan 14, 4:43 pm, Terry Reedy wrote: [snip] I think the 'main' IDLE maintainer is no longer active. I think someone who would do more than fix critical bugs might be welcome. Hello Terry, That's what i was beginning to think. I am not quite ready (as far as my skills are concerned

Re: Noob question: Is all this typecasting normal?

2009-01-17 Thread Tim Rowe
nsultant, I'm quite interested about where in ATM you plan to use Python code, and how you will be meeting the applicable safety standards in the relevant administration. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: English-like Python

2009-01-17 Thread Tim Rowe
2009/1/16 has : > http://www.alice.org/ Ooh, "JavaLikeSyntax.py" indeed! Why not "PythonLikeSyntax", since that's apparently what they used! -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Tim Rowe
smatch. I was actually at the European Space Agency's Toulouse site the week after the Ariane 5 incident. I've been at jollier funerals. I can't help thinking that thinking that the team would have benefited from reading David Parnas's work on the specification of the A-7E avionics. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: issue

2009-01-19 Thread Tim Chase
I started programing with python and want to use a suitable database.But I Know nothing about them.please introduse one to me. thanks. Since you're just starting out, I'd just use the built-in (as of Python2.5) sqlite >>> import sqlite3 >>> c = sqlite3.connect('tmp/test.db') >>> cur = c.c

Re: Regular expression that skips single line comments?

2009-01-19 Thread Tim Chase
I am trying to parse a set of files that have a simple syntax using RE. I'm interested in counting '$' expansions in the files, with one minor consideration. A line becomes a comment if the first non-white space character is a semicolon. e.g. tests 1 and 2 should be ignored sInput = """ ; $1 te

Re: braces fixed '#{' and '#}'

2009-01-19 Thread Tim Roberts
27;s very dangerous to make a post like this without including the smiley. You're likely to get a mailbox full of "helpful" corrections... ;) -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: python resource management

2009-01-19 Thread Tim Arnold
problem. Then add elements back in, making > your minimalist script more and more like the real one. If the extreme > memory usage problem is isolated to one component or section, you'll find > it this way. > > HTH > Philip Also, are you creating a separate soup object for each file or reusing one object over and over? --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print lambda result ?

2009-01-20 Thread Tim Northover
Ron is sligtly confused about what he created. It was equivalent to string_ = "%d event%s" % (num, lambda x: x > 1 and "s" or "") Notice that there's no actual mention of num there, it's a function that takes one parameter. If that parameter happens to

Re: How to get first/last day of the previous month?

2009-01-20 Thread Tim Chase
I'm creating a report that is supposed to harvest the data for the previous month. So I need a way to get the first day and the last day of the previous month. Would you please tell me how to do this? >>> from datetime import date, datetime, timedelta >>> def prev_bounds(when=None): ... if n

Re: How to get first/last day of the previous month?

2009-01-20 Thread Tim Chase
You told me to think how to get the first day of the previous month, well how to know if the previous month is 28, 29, 30 or 31 days? Find the first day of the *current* month, and then subtract one day (use the timedelta object). You'll end up with the last day of the previous month as a dat

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Tim Rowe
although I've always wondered how much of that is because of language differences and how much is because Ada tends to be used on critical projects that also tend to get a lot more attention to development standards. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: date format

2009-01-21 Thread Tim Chase
Ahmed, Shakir wrote: I am grabbing few fields from a table and one of the columns is in date format. The output which I am getting is "Wed Feb 09 00:00:00 2005" but the data in that column is "02/09/2005" and I need the same format output to insert those recodes into another table. print my_serv

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-22 Thread Tim Rowe
Turing-complete. Specifically, all loops that are required to terminate require a loop variant to be defined. Typically the loop variant is a finite non-negative integer that provably decreases on every pass of the loop, which makes halting decidable. -- Tim Rowe -- http://mail.python.org/mailman/li

Re: Need script to download file from a server using python script

2009-01-23 Thread Tim Chase
The build number keeps changing. So how can i use wildchars(?) or something else to handle change in the build no.? Short answer: you can't...HTTP doesn't support wild-card requests. Longer answer: presumably there's some method to the madness of naming the file. Find the algorithm and use

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-23 Thread Tim Rowe
the maximum response time is tolerable. The loop variant can help with that, too. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Tim Rowe
2009/1/23 Kay Schluehr : > Whatever sufficiently sophisticated topic was the initially discussed > it ends all up in a request for removing reference counting and the > GIL. Well, maybe, but it seems to me that the real issue here is that we need to remove reference counting and the GIL.

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Tim Rowe
urely know about Schluehr's Law? ;-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: The First Law Of comp.lang.python Dynamics

2009-01-23 Thread Tim Rowe
2009/1/23 Martin P. Hellwig : > Or you can argue that even when an argument is repeated indefinitely it > doesn't make it suddenly right. No, but it makes for a confirmation of Schluehr's law :-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the business with the asterisk?

2009-01-24 Thread Tim Chase
From time to time I spot an asterisk (*) used in the Python code _outside_ the usual *args or **kwargs application. E.g. here: http://www.norvig.com/python-lisp.html def transpose (m): return zip(*m) >>> transpose([[1,2,3], [4,5,6]]) [(1, 4), (2, 5), (3, 6)] What does *m mean in this exam

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-24 Thread Tim Rowe
o go through a proper specification change procedure if the team (not the organisation) is more than a few people. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: *.python.org broken?

2009-01-24 Thread Tim Chase
Is anybody else having trouble accessing sites (including www, docs, wiki) in the python.org tree, or is it just me? (Or just .au?) I've had problems[1] browsing them (most irksomely, the docs) from Dillo thanks to what are apparently poor handling of IPv6 fallback rules. Dillo gets an IPv6 I

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Tim Chase
The idiomatic way would be iterating over the file-object itself - which will get you the lines: with open("foo.txt") as inf: for line in inf: print line In versions of Python before the "with" was introduced (as in the 2.4 installations I've got at both home and work), this can

Re: syntax color lang source code in blogs or website

2009-01-25 Thread Tim Greer
seems to have selected the Python and Perl groups to regularly post to, even when his posts rarely to never have any relation to said groups. Please, do not encourage his behavior. Thanks. -- Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc. Shared Hosting, Reseller Hosting, Dedicated & Semi

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Tim Chase
One other caveat here, "line" contains the newline at the end, so you might have print line.rstrip('\r\n') to remove them. I don't understand the presence of the '\r' there. Any '\x0d' that remains after reading the file in text mode and is removed by that rstrip would be a strange occurrenc

Re: Efficient multi-slicing technique?

2009-01-25 Thread Tim Chase
Is there an efficient way to multi-slice a fixed with string into individual fields that's logically equivalent to the way one would slice a delimited string using .split()? Background: I'm parsing some very large, fixed line-width text files that have weekly columns of data (52 data columns plus

Re: Newby: how to transform text into lines of text

2009-01-25 Thread Tim Chase
Scott David Daniels wrote: Here's how I'd do it: with open('deheap/deheap.py', 'rU') as source: for line in source: print line.rstrip() # Avoid trailing spaces as well. This should handle \n, \r\n, and \n\r lines. Unfortunately, a raw rstrip() eats other whitespace

Re: Efficient multi-slicing technique?

2009-01-25 Thread Tim Chase
I'm not sure if it's more efficient, but there's the struct module: http://docs.python.org/library/struct.html Thanks for your suggestion. I've been experimenting with this technique, but my initial tests don't show any performance improvements over using slice() objects to slice a string. Howev

Re: USB in python

2009-01-25 Thread Tim Roberts
sing one of the many simple and affordable USB experimenter's kits in the world. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: v = json.loads("{'test':'test'}")

2009-01-25 Thread Tim Roberts
vascript, nor is it a part of Javascript. JSON is a data exchange standard, which happens to be readable to Javascript parsers. A valid JSON expression happens to be a valid Javascript expression, but not vice versa. That's just the way it is. -- Tim Roberts, [email protected] Providenza & Boeke

Re: Newby: how to transform text into lines of text

2009-01-26 Thread Tim Rowe
2009/1/25 Tim Chase : > (again, a malformed text-file with no terminal '\n' may cause it > to be absent from the last line) Ahem. That may be "malformed" for some specific file specification, but it is only "malformed" in general if you are using an op

Re: A java hobbyist programmer learning python

2009-01-26 Thread Tim Rowe
so Hungarian /can/ be useful. At this level I don't recognise a difference between System and Applications Hungarian, by the way -- the difference is eliminated if you declare types corresponding to the "meanings", which is commonplace in, for example, Ada. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-26 Thread Tim Rowe
is part of what being a grown-up programmer is about. One size does not fit all, one language is not ideal for all applications. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Process crash with no reason

2009-01-27 Thread Tim Golden
[email protected] wrote: On Jan 26, 8:40 pm, Philip Semanchuk wrote: On Jan 26, 2009, at 1:13 PM, [email protected] wrote: Hi All, I'm running a program that is acting as a nice interface to sybase' replication server. The program is using the cherrypy web service for the GUI. The proce

Re: Recommendation for a small web framework like Perl's CGI::Application to run as CGI?

2009-01-27 Thread Tim Chase
I need to make a small, relatively low-traffic site that users can create accounts on and log into. Scripts must run as cgi (no mod_python or FastCGI is available). Can anyone recommend a small and simple web framework for Python, maybe similar to Perl's CGI::Application? Or would it just be bett

Re: errno 22 instead of errno 2

2009-01-28 Thread Tim Golden
Glenn Linderman wrote: open("c:\abc","rb") This simple one-line script, produces errno 22 on Python 2.6, but errno 2 on Python 2.5.2 Is this an unintentional regression? Or is this an intentional bug fix? The file doesn't exist (errno 2) but I guess on Windows it is also somewhat an invali

Re: need help

2009-01-28 Thread Tim Chase
need help on how to read file from other server(linux). Which service do you plan to use: FTP, HTTP and NFS are three possibilities that immediately come to mind, Or scp, or sftp, or rsync, or SMB, or AFS, or IMAP, or POP3, or instant-message, or VCS sync (svn/hg/git/bzr/cvs/darcs/whatever)

Re: need help

2009-01-28 Thread Tim Chase
Thanks for you reply. I am newbie in python. Im going to use HTTP. If all you want is to download a file, you might want to look into using "wget" or "curl" (which work for both HTTP and FTP). E.g. bash$ wget http://myothermachine/path/to/file.html However, if you need to roll it into a s

Re: Results of executing hyperlink in script

2009-01-28 Thread Tim Chase
1. This method was suggested by Cameron Laird: os.system("start %s" % URL) It works. But, if the URL contains character &, it will fail. For As an aside, the START command is a bit picky regarding quotes. You have to use this horrible contortion os.system('start "title" "%s"' % URL

Re: Function Application is not Currying

2009-01-28 Thread Tim Greer
his post in, but he bugs us in the Perl group all the time, cross posting things that have nothing to do with Perl (same with his cross posts to Python, too). :-) -- Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc. Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers and Cu

Re: is there a shorter way to write this

2009-01-29 Thread Tim Chase
I had a task in a book to pick 5 items from a list of 26 ensuring the items are not repeated import random list = ['a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z'] word = ' ' a = random.choice(list) list.remove(a) b = random.choice(

Re: is there a shorter way to write this

2009-01-29 Thread Tim Chase
Hmm, sounds like homework, but I'll bite. The underlying problem does sound like homework, but the OP posted a working solution, and was only looking for ways to improve it. So I'm a little more lenient on providing alternatives. It's true that the homework problem may have been exactly as

Re: Weird invisible arguments issues with Windows

2009-01-29 Thread Tim Golden
Uberman wrote: I've installed Python 2.6.1 (AMD64) under Windows Vista Ultimate 64-bit. First off, it didn't register the extension for .PY (although it did register .PYC). After manually associating the .PY extension with the python.exe executable, I am now getting some weirdness on the comman

Re: parsing text from a file

2009-01-29 Thread Tim Chase
if s.find('LANDesk') <0: is True for a line which doesn't contain "LANDesk"; if you want the opposite, try if s.find('LANDesk') >-1: Or more pythonically, just use if 'LANDesk' in s: -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding to the nearest 5

2009-01-29 Thread Tim Chase
How can you make python round numbers to the nearest 5: Example: 3 => 0 8 => 10 23.2 => 20 36 => 35 51.5 => 50 I'm not sure *any* rounding system will give those results. 3 should round up to 5 (not down to 0) and 23.2 should round up to 25 (not down to 20) in the same way that 8 rounds

Re: parsing text from a file

2009-01-30 Thread Tim Golden
Wes James wrote: If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" Watch out. .reg

Re: Rounding to the nearest 5

2009-01-30 Thread Tim Chase
Steven D'Aprano wrote: On Thu, 29 Jan 2009 18:26:34 -0600, Tim Chase wrote: How can you make python round numbers to the nearest 5: Example: 3 => 0 8 => 10 23.2 => 20 36 => 35 51.5 => 50 I'm not sure *any* rounding system will give those results. Round toward

Re: is python Object oriented??

2009-01-30 Thread Tim Rowe
de to conform to an object oriented design (Python doesn't). So the answer to "Is Python Object-Oriented" is either "yes" or "no", depending on what you're /really/ asking. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: search speed

2009-01-30 Thread Tim Rowe
bit of extra insurance against false positives. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Function Application is not Currying

2009-01-30 Thread Tim Greer
to just filter out his posts. -- Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc. Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers and Custom Hosting. 24/7 support, 30 day guarantee, secure servers. Industry's most experienced staff! -- Web Hosting With Muscle! -- http://ma

Re: accessing elements of a tuple

2009-01-30 Thread Tim Chase
let me re-phrase that question: i would like to access the element of individual tuples inside of a list, by using an index. so i have the list contents print list [('--datasourcename', 'DB'), ('--password', '123')] How can I access "DB" from the list directly using an index? right now I would

Re: search speed

2009-01-30 Thread Tim Chase
I have written a Python program that serach for specifik customer in files (around 1000 files) the trigger is LF01 + CUSTOMERNO While most of the solutions folks have offered involve scanning all the files each time you search, if the content of those files doesn't change much, you can build a

RE: nth root

2009-01-30 Thread Tim Roberts
Unfortunately, unless I'm doing something wrong, this appears to take 20 times as long... :-) What on earth are numpy and psyco? Do I need to watch the Lord of the Rings? Tim Tim wrote: > In PythonWin I'm running a program to find the 13th root (say) of > millions

RE: nth root

2009-01-30 Thread Tim Roberts
Dan, Thanks - you're probably right - just my intuition said to me that rather than calculating that the 13th root of 4021503534212915433093809093996098953996019232 is 3221.2904208350265 there must be a quicker way of finding out its between 3221 and 3222 but perhaps not.

Re: glob.fnmatch (was "search speed")

2009-01-31 Thread Tim Chase
[email protected] wrote: Quoth Tim Chase : PS: as an aside, how do I import just the fnmatch function? I tried both of the following and neither worked: from glob.fnmatch import fnmatch from glob import fnmatch.fnmatch I finally resorted to the contortion coded below in favor of

Re: search speed

2009-01-31 Thread Tim Rowe
2009/1/30 Scott David Daniels : > Be careful with your assertion that a regex is faster, it is certainly > not always true. I was careful *not* to assert that a regex would be faster, merely that it was *likely* to be in this case. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/

Re: Searching a file for multiple strings

2009-01-31 Thread Tim Chase
I'm fairly new with python and am trying to build a fairly simple search script. Ultimately, I'm wanting to search a directory of files for multiple user inputted keywords. I've already written a script that can search for a single string through multiple files, now I just need to adapt it to mu

Re: Searching a file for multiple strings (PS)

2009-01-31 Thread Tim Chase
I'm fairly new with python and am trying to build a fairly simple search script. Ultimately, I'm wanting to search a directory of files for multiple user inputted keywords. I've already written a script that can search for a single string through multiple files, now I just need to adapt it to mu

Re: nth root

2009-01-31 Thread Tim Roberts
"Tim Roberts" wrote: > >Thanks - you're probably right - just my intuition said to me that rather than >calculating that the 13th root of >4021503534212915433093809093996098953996019232 >is 3221.2904208350265 >there must be a quicker way of find

RE: nth root

2009-01-31 Thread Tim Roberts
*(1.0/root)) if bignum==long(nroot)**root: . which is probably very inefficient, but I can't see anything better. Tim -- http://mail.python.org/mailman/listinfo/python-list

RE: nth root

2009-01-31 Thread Tim Roberts
Paul, Yes, very good, on all counts. Many thanks. Tim From: Paul Rubin [mailto:"http://phr.cx"@NOSPAM.invalid] Sent: Sun 01-Feb-09 3:53 PM To: [email protected] Subject: Re: nth root "Tim Roberts" writes: > Actually, a

Config files editor

2009-02-01 Thread Tim Michelsen
Hello Python, does anyone know of a Python based project that has a GUI based functionality to edit config files read/written by ConfigParser? I found a command line tool here: pyinieditor - Google Code - http://code.google.com/p/pyinieditor/ But I'd rather go with a GUI tool. Thanks in adva

Re: Source code for csv module

2009-02-02 Thread Tim Chase
I just discovered the csv module here in the comp.lang.python group. It certainly makes life easier. I have found its manual, which is publicly available, but since I am still a newby, learning techniques, I was wondering if the source code for this module is available. Is it possible to have

Re: Where to put configuration/data files

2009-02-02 Thread Tim Chase
Is there a nice cross-platform way to figure out the Right (tm) place to store configuration files and other data? For what purpose? Global program config, user config, what? I've found three main categories of settings like Aahz describes (of which I've used all in a single application):

Re: is python Object oriented??

2009-02-02 Thread Tim Rowe
hilosophy what would be the point of different languages? Is it worth mentioning (again) that Python is not Java? -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: what IDE is the best to write python?

2009-02-02 Thread Tim Rowe
e how it would be any different to any other language. Admittedly I use the IDE because I like IDE's, but I don't see why it wouldn't work with a text editor and make -- the command line compiler is there. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: is python Object oriented??

2009-02-02 Thread Tim Rowe
2009/2/2 Russ P. : > On Feb 2, 2:46 pm, Tim Rowe wrote: >> No, we're supposed to believe that the designers of C++, Java, Ada, >> and Scala are all designers of languages that are not Python. If all >> languages had the same philosophy what would be the point of dif

Re: Source code for csv module

2009-02-02 Thread Tim Roberts
and are included in their full, readable source form in every Python installation? \Python25\lib in Windows, /usr/lib/python25 in Linux. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: function scope

2009-02-02 Thread Tim Roberts
been bitten by the shared default parameter noobie trap: >http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects Actually, he hasn't. His problem is more fundamental. However, this is still a good thing for you to point out now and then. -- Tim Rob

Re: Using lxml to screen scrap a site, problem with charset

2009-02-02 Thread Tim Arnold
to debug it." - Brian W. Kernighan > The way I do that is to open the file with codecs, encoding=cp1251, read it into variable and feed that to the parser. --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: x64 speed

2009-02-03 Thread Tim Daneliuk
rtualization much better, but > this seems a bit weird. Which vmware product? -- -------- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: what IDE is the best to write python?

2009-02-03 Thread Tim Rowe
2009/2/3 Jervis Whitley : > real programmers use ed. Ed? Eee, tha' were lucky. We had to make holes in Hollerith cards wi' our bare teeth... -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Use list name as string

2009-02-04 Thread Tim Chase
I know this is wrong it uses the items in the list as the filename, how do I refer to the dataname and not the items in it. Without a sample value for "dataname", it's hard to tell what you're trying to do. Do you mean dataname = ['path', 'to', 'file'] ... filename = os.sep.join(datana

Re: Use list name as string

2009-02-04 Thread Tim Chase
I know nothing but that sucks. I can think of a lot of times I would like to do something similar. There really is no way to do this, it seems like there would be some simple way kind of like str(listname) but backwards or different. Python does the only reasonable thing: doesn't give you acces

Re: Use list name as string

2009-02-04 Thread Tim Chase
can I do it the otherway, that issavedata('nameoflist') for limited cases where your variable is defined globally, you can use: >>> a = [1,2,3,4] >>> def save(s): ... print globals().get(s, "UNDEFINED") ... >>> save("a") [1, 2, 3, 4] >>> save("b") UNDEFINED >>> b = (6,5,

sys.float_info.epsilon

2009-02-04 Thread Tim Rowe
e value less than sys.float_value.epsilon other than 0.0 (which I think all representations can represent exactly). What am I missing here? -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.float_info.epsilon

2009-02-04 Thread Tim Rowe
ppily do sys.float_info.max/(2*sys.float_info.epsilon) and will give me the answer "inf") so presumably he's trying to protect against divide by zero. So my next question is whether there is any x that can be returned by float() such that x != 0 but some_number / (2 * x) raises a

Re: sys.float_info.epsilon

2009-02-04 Thread Tim Rowe
2009/2/4 Scott David Daniels : Thanks for that. It makes me feel guilty to point out that: > addition is not associative in real numbers should presumably be "addition is not associative in floating point numbers". -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Couple of noobish question

2009-02-04 Thread Tim Rowe
have to use exception handling and catch the Windows case? That's the trouble with using anything in os, of course -- it's os dependent, which is why it's there! :-) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Upgrade 2.6 to 3.0

2009-02-04 Thread Tim Rowe
when I'm trying to get to grips with the differences between versions.. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: sys.float_info.epsilon

2009-02-04 Thread Tim Rowe
2009/2/5 Scott David Daniels : > And, of course he is right (and didn't even whomp on my typo of "makes" > as "mes in the first line quoted above). A typo for "makes" didn't bother me. Non-associativity of the real numbers under addition risked making my

Re: Couple of noobish question

2009-02-04 Thread Tim Rowe
2009/2/5 : > On Feb 5, 11:14 am, Tim Rowe wrote: > > ... > >> On an MS Windows system, os.uname()[0] raises an AttributeError -- sys >> doesn't seem to contain uname. Is that a Linux thing? Would os.name >> work on Linux? Or would one have to use exception han

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Tim Rowe
r in the string -- there's your loop -- and if (there's your if) it's a "1" change the truth value of even: even = !even. If it is a number rather than a string, you want to do much the same thing but you'll need the >> and & operators. Chris has already

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-04 Thread Tim Chase
Using while loop and if statement, I'm trying to get Python to tell me whether there are even or odd number of 1's in a binary representation. For example, if I give Python a 0111, then I want it to say that the binary representation given has an odd number of 1's. If I give it 00010111, then

Re: Upgrade 2.6 to 3.0

2009-02-04 Thread Tim Rowe
on 2.6 yet, never mind 3.0). Unless all you want is in the standard library, I think it's worth the general user holding back for a while whilst the tool providers catch up. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Feet and inches

2009-02-04 Thread Tim Chase
Enter the height (in metres): and convert whatever value to feet and inches. I've done this part as you can see below, but how can I terminate the program when user inputs a height less than 1/2 inch? Dang...I got suckered into answering a homework problem for the last one. My apologies to

Re: Feet and inches

2009-02-04 Thread Tim Rowe
ht like to think about what should happen if a user enters a negative value, but the present behaviour -- when fixed -- may be what you need. -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Use list name as string

2009-02-04 Thread Tim Chase
My argument comes down to; we use M so we don't have to type [1,3,5,7], I realize that this is in part because we might not no what M will be. This is starting to sound like double talk on my part, I have only been programing in python for 2 weeks so my credibility is only that of an outside that

Re: Find the critical points

2009-02-04 Thread Tim Roberts
>M1=S.Matrix([14,-6],[-6,6]) >M2=S.Matrix([2,-6],[-6,6]) >S.Matrix.berkowitz_minors(M2) >S.Matrix.berkowitz_minors(M1) print S.Matrix.berkowitz_minors(M2) print S.Matrix.berkowitz_minors(M1) -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

time: Daylight savings confusion

2009-02-04 Thread Tim H
time was in effect (ie when the tm_isdst field is one). I can kludge it, but am I missing the "right" way to do it? Tim full code: import os, time filetypes = (".avi") skipped = [] for f in os.listdir("."): root, ext = os.path.splitext(f) if ext in fi

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-05 Thread Tim Rowe
member a programming exercise when I was an undergraduate and anyone > who *didn't* use that trick got marked down for writing inefficient code. Is adding and a modulus *really^ more efficient than flipping a bool as I suggested? I think I'd want to see measurements! -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Using while loop and if statement to tell if a binary has an odd or even number of 1's.

2009-02-05 Thread Tim Rowe
or the bit shifting because I think it's clearer. And I'd want a word with a tutor who insisted on premature optimisation ("The root of all evil", according to C A R Hoare), especially in a scripting language! -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Is c.l.py becoming less friendly?

2009-02-05 Thread Tim Rowe
2009/2/5 mk : > > (duck) > > 542 comp.lang.python rtfm > > 467 comp.lang.python shut+up > > 263 comp.lang.perl rtfm > > 45 comp.lang.perl shut+up Yes, but is there any real traffic on comp.lang.perl nowadays? Sorry, cheap shot ;-) -- Tim Rowe -- http://mail.pyth

Re: Is c.l.py becoming less friendly?

2009-02-05 Thread Tim Chase
(duck) 542 comp.lang.python rtfm 467 comp.lang.python shut+up 263 comp.lang.perl rtfm 45 comp.lang.perl shut+up Is this where we tell you to shut up? ;-) As others mentioned, the raw numbers don't mean much without a total-volume-of-posts to demonstrate the percentage. It would also be int

<    45   46   47   48   49   50   51   52   53   54   >