Re: Calculate Big Number

2013-01-07 Thread Tim Chase
On 01/07/13 18:44, Nac Temha wrote: How to *quickly* calculate large numbers. For example (10**25) * (2**50) 11258999068426240L that's how...just do the math. For any other sort of answer, you'd have to clarify your question. On my laptop, that operation came back

Re: PIL or something to open EXIF Metadata with Python

2013-01-09 Thread Tim Golden
On 09/01/2013 14:45, Jose Trevino wrote: > I am trying to load the PIL module to manage exif metadata with > Python but have had no success. Try pyexiv2: http://tilloy.net/dev/pyexiv2/ TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: how to download internet files by python ?

2013-01-09 Thread Tim Roberts
iMath wrote: > >There is also a httplib2 module >https://code.google.com/p/httplib2/ > >which one is more pythonic and powerful ? Both are Pythonic, and power is irrelevant for this. Your code is going to spend 90% of its time waiting for the network. Just solve the problem.

Re: Problem with importing in Python

2013-01-11 Thread Tim Roberts
Dave Angel wrote: > >As Adnan has pointed out, Python is case insensitive. That's not really what you meant to say... -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Query windows event log with python

2013-01-12 Thread Tim Golden
On 12/01/2013 06:09, robey.lawre...@gmail.com wrote: I am looking to write a short program to query the windows event log. It needs to ask the user for input for The event type (Critical, Error, and Information), and the user needs to be able to specify a date since when they want to view result

Re: For Loop in List

2013-01-13 Thread Tim Chase
On 01/13/13 06:45, subhabangal...@gmail.com wrote: Dear Group, I have a list like, list1=[1,2,3,4,5,6,7,8,9,10,11,12] Now, if I want to take a slice of it, I can. It may be done in, list2=list1[:3] print list2 [snip] Now, I want to combine iterator with a slicing condition like for i=li

Re: For Loop in List

2013-01-13 Thread Tim Chase
On 01/13/13 07:48, Boris FELD wrote: 2013/1/13 Tim Chase : SIZE = 3 for i in range(len(list1)//SICE): ... print list1[i*SIZE:i*SIZE+SIZE] A little shorter and simpler version: x = x[1:] for i in range(0,len(x),SIZE): ... print x[i: i+SIZE] Doh, I always forget that range() takes

Re: Query windows event log with python

2013-01-14 Thread Tim Golden
On 13/01/2013 05:55, robey.lawre...@gmail.com wrote: > On Saturday, January 12, 2013 8:34:01 PM UTC+11, Tim Golden wrote: >> On 12/01/2013 06:09, email.addr...@gmail.com wrote: >> >>> I am looking to write a short program to query the windows event >> >>>

Re: Thought of the day

2013-01-14 Thread Tim Chase
On 01/13/13 22:16, Steven D'Aprano wrote: A programmer had a problem, and thought Now he has "I know, I'll solve two it with threads!" problems. A newbie programmer had a problem and thought "I'll solve it by posting on python-list@python.org and on Google Groups". And now we have the proble

Re: PyWart (Terminolgy): "Class"

2013-01-14 Thread Tim Chase
On 01/14/13 01:56, Chris Angelico wrote: On Mon, Jan 14, 2013 at 6:32 PM, Rick Johnson wrote: I really don't like using two words ("define object", or "def obj") and using one single keyword is ambiguous ("object" or "obj"). So the obvious solution is to combine the abbreviated words into one

Re: PyWart (Terminolgy): "Class"

2013-01-14 Thread Tim Chase
On 01/14/13 11:26, Steven D'Aprano wrote: Your knowledge of English has failed you. Here is the first definition from Webster's Dictionary (1913 edition): Class \Class\ (kl[.a]s), n. [F. classe, fr. L. classis class, collection, fleet; akin to Gr. klh^sis a calling, kalei^n to call, E.

Re: PyWart (Terminolgy): "Class"

2013-01-14 Thread Tim Delaney
On 15 January 2013 07:57, Chris Angelico wrote: > > Oh, and Dennis? Mal. Bad. From the Latin. :) > I was about to point out the same thing, using the same quote ;) Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Thought of the day

2013-01-15 Thread Tim Golden
On 15/01/2013 16:48, Antoine Pitrou wrote: > Steven D'Aprano pearwood.info> writes: >> >> A programmer had a problem, and thought Now he has "I know, I'll solve >> two it with threads!" problems. > > > Host: Last week the Royal Festival Hall saw the first performance of a new > logfile by one o

Re: Vote tallying...

2013-01-18 Thread Tim Chase
On 01/18/13 13:26, Kwpolska wrote: On Fri, Jan 18, 2013 at 4:19 PM, Nick Cash wrote: MySQL would certainly be fine, although I always recommend PostgreSQL over it. Bonus question, why? I write only from my personal experience, but the following might be reasons that Nick recommends PostgreS

Re: Vote tallying...

2013-01-19 Thread Tim Chase
On 01/18/13 23:19, Dennis Lee Bieber wrote: On Fri, 18 Jan 2013 18:54:32 -0400, Zero Piraeus On 18 January 2013 16:57, Tim Chase wrote: - there are just some serious what-the-heck's in MySQL's handling of some edge cases regarding NULL values and dates (Feb 31st anybody). Ther

Re: RE Help splitting CVS data

2013-01-20 Thread Tim Chase
On 01/20/13 16:16, Terry Reedy wrote: On 1/20/2013 5:04 PM, Garry wrote: I'm trying to manipulate family tree data using Python. I'm using linux and Python 2.7.3 and have data files saved as Linux formatted cvs files ... I'm stuck, comments and solutions greatly appreciated. Why are you not

Re: Windows subprocess.call problem

2013-01-21 Thread Tim Golden
On 21/01/2013 11:25, Tom Borkin wrote: > Hi; > I have this code: > > #!/Python27/python > import os, subprocess, sys > lyrics_path = "/Users/Tom/Documents/lyrics" > os.chdir(lyrics_path) > > songs = ['livin-la-vida-loca', 'whos-that-lady'] > for song in songs: > subprocess.call(['notepad.exe'

Re: Uniquely identifying each & every html template

2013-01-21 Thread Tim Roberts
tered files, then there is absolutely no way to teach a computer how to do it. It IS impossible. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Uniquely identifying each & every html template

2013-01-21 Thread Tim Roberts
e same page as page1.html? What if I subsequently delete page1.html? What if I don't? How long will you wait before deciding they are the same? -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Retrieving the full command line

2013-01-22 Thread Tim Golden
[Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, though]. I use the python -mpackage incantation to run a package which has a __main__.py module and which uses relative imports internally. I'm developing under cherrypy which includes a reloader for development. The reloader

Re: Retrieving the full command line

2013-01-22 Thread Tim Golden
On 22/01/2013 14:53, Terry Reedy wrote: > On 1/22/2013 4:24 AM, Tim Golden wrote: >> [Python 2.7/3.3 (and hg tip) running on Windows. Not Windows-specific, >> though]. >> >> I use the python -mpackage incantation to run a package which has a >> __main__.py modul

Re: Retrieving the full command line

2013-01-23 Thread Tim Golden
On 23/01/2013 03:58, Steven D'Aprano wrote: > Currently, if I have a package __main__.py that prints sys.argv, I get > results like this: > > steve@runes:~$ python3.3 /home/steve/python/testpackage/__main__.py ham > spam eggs > ['/home/steve/python/testpackage/__main__.py', 'ham', 'spam', 'eggs'

Re: Search log for string and display hourly/daily report

2013-01-23 Thread Tim Chase
On 01/23/13 13:05, spe...@gmail.com wrote: I need to search a log file for a specific string (Successfully Sent) and report the number of instances in the last hour (from when executed) and total for the day so far (midnight till the time executed). Can anyone provide any examples of such a progr

Re: Arent these snippets equivalent?

2013-01-23 Thread Tim Chase
On 01/23/13 16:47, Roy Smith wrote: while getchar() as c: putchar(c) That would give people (including me) the use case they're after most of the time (call a function, assign the return value, and test it). It's way less klunky than: while True: c = getchar() if c: # I presume yo

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 10:06, Oscar Benjamin wrote: > On 24 January 2013 04:49, Steven D'Aprano > wrote: > [SNIP] >> >> Contrariwise, I don't believe that there is currently *any* way to >> distinguish between running a script with or without -m. That should be >> fixed. > > As I said earlier in the threa

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 10:56, Tim Golden wrote: > if the package which is reconstructing the command line the package > which was the target of the original command line. Sorry: if the package which is reconstructing the command line *is not* the package which was the target of the original c

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 11:30, Oscar Benjamin wrote: > I don't really understand what your spec is. Why do you need to > inspect this information from sys.argv? Can you not just always use > 'python -m pkg' as your entry point? Sorry about the confusion. I think my original point was simply one of surprise

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 15:28, Oscar Benjamin wrote: > On 24 January 2013 13:45, Tim Golden wrote: >> On 24/01/2013 11:30, Oscar Benjamin wrote: >>> I don't really understand what your spec is. Why do you need to >>> inspect this information from sys.argv? Can you not just a

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Tim Chase
On 01/24/13 10:23, Thomas Heller wrote: Am 24.01.2013 16:54, schrieb rusi: [I personally use emacs. It would be sadistic to make that into a recommendation] It would be truly sadistic to force a long-time emacs user to any other editor. I saw the recommendation for Vim elsewhere on the threa

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 16:53, Oscar Benjamin wrote: >> Does it work if you use the -m option to run a module rather than a script? > > Sorry that was written incorrectly. I meant to say: does it work when > a module is directly on sys.path rather than as a submodule of a > package? In this case __package__

Re: The best, friendly and easy use Python Editor.

2013-01-24 Thread Tim Chase
On 01/24/13 13:34, Leonard, Arah wrote: All true (especially the holy wars bit!). OP didn't (as far as I can see) even say which OS he is using. Anyway, my suggestion is generally that people use the editor with which they are already comfortable. Sound advice. [snip] Whatever works is what wo

Re: Retrieving the full command line

2013-01-24 Thread Tim Golden
On 24/01/2013 20:01, Oscar Benjamin wrote: On 24 January 2013 17:13, Tim Golden wrote: A package-based module run via -m (python -m package.module) works as described (including the implicit __main__ module, my primary use-case). Does it work in the "python -m package.module" case

Need Pattern For Logging Into A Website

2013-01-24 Thread Tim Daneliuk
for doing this. TIA, -- ---- Tim Daneliuk tun...@tundraware.com PGP Key: http://www.tundraware.com/PGP/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Need Pattern For Logging Into A Website

2013-01-25 Thread Tim Daneliuk
On 01/25/2013 10:01 AM, Steve Petrie wrote: On Thursday, January 24, 2013 8:29:51 PM UTC-5, Tim Daneliuk wrote: I need to write a Python script to do the following: - Connect to a URL and accept any certificate - self-signed or authoritative - Provide login name/password credentials

Re: Need Pattern For Logging Into A Website

2013-01-25 Thread Tim Daneliuk
On 01/25/2013 01:18 PM, Michael Torrie wrote: On 01/25/2013 09:18 AM, Tim Daneliuk wrote: On 01/25/2013 10:01 AM, Steve Petrie wrote: On Thursday, January 24, 2013 8:29:51 PM UTC-5, Tim Daneliuk wrote: The mechanize module (http://wwwsearch.sourceforge.net/mechanize/) might be a place to start

Re: Need Pattern For Logging Into A Website

2013-01-26 Thread Tim Daneliuk
On 01/26/2013 12:53 AM, Michael Torrie wrote: On 01/25/2013 05:15 PM, Tim Daneliuk wrote: Does it handle self-signed SSL certs? No idea. you'd have to try it. OK, thanks for the pointer. -- ---- Tim Daneliuk

Re: Reading file issue

2013-01-28 Thread Tim Chase
On Mon, 28 Jan 2013 03:47:07 -0800 (PST) loial wrote: > I am parseing a file to extract data, but am seeing the file being > updated even though I never explicitly write to the file. It is > possible that another process is doing this at some later time, but > I just want to check that opening th

Re: numpy array operation

2013-01-29 Thread Tim Williams
On Tuesday, January 29, 2013 3:41:54 AM UTC-5, C. Ng wrote: > Is there a numpy operation that does the following to the array? > > > > 1 2 ==> 4 3 > > 3 4 2 1 > > > > Thanks in advance. >>> import numpy as np >>> a=np.array([[1,2],[3,4]]) >>> a array([[1, 2], [3, 4]]) >>> np.

Re: Split string data have ","

2013-01-29 Thread Tim Chase
On Tue, 29 moonhkt wrote: > >>> y = '"abc.p,zip.p",a,b' > >>> print y > "abc.p,zip.p",a,b > >>> > > >>> k= y.split(",") > >>> print k[0] > "abc.p > >>> > > Need Result, First element is > abc.p,zip.p The csv module should handle this nicely: >>> import csv >>> y = '"abc.p,zip.p",a,b' >>>

Re: surprising result all (generator) (bug??)

2012-01-31 Thread Tim Chase
On 01/31/12 06:40, Neal Becker wrote: I was just bitten by this unexpected behavior: In [24]: all ([i> 0 for i in xrange (10)]) Out[24]: False In [25]: all (i> 0 for i in xrange (10)) Out[25]: True You sure you transcribed that correctly? Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [G

Re: contextlib.contextmanager and try/finally

2012-01-31 Thread Tim Delaney
gt; ... > >>> import sys > >>> with f(): > ... sys.exit() > ... > bye > $ Note OTOH that os._exit() just terminates the process with no cleanup (this may be what you were thinking of): >>> from contextlib import contextmanager >>> @contextmanager ... def f(): ... try: ... yield ... finally: print "bye" ... >>> import os >>> with f(): ... os._exit(1) ... $ Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterate from 2nd element of a huge list

2012-01-31 Thread Tim Delaney
cated, isn't it? > If you are sure that mylist contains at least one element: >>> mylist = [1, 2, 3] >>> i = iter(mylist) >>> print next(i) 1 >>> for el in i: ... print el ... 2 3 Note: for older pythons, you may need i.next() instead of next(i)

xhtml encoding question

2012-01-31 Thread Tim Arnold
I have to follow a specification for producing xhtml files. The original files are in cp1252 encoding and I must reencode them to utf-8. Also, I have to replace certain characters with html entities. I think I've got this right, but I'd like to hear if there's something I'm doing that is dangero

Re: python zipfile v. native unzip

2012-02-01 Thread Tim Chase
On 01/31/12 07:41, Jason Friedman wrote: Does Python 2.7's zipfile module use its own algorithm or does it leverage the zip/unzip libraries that exist on the host? I ask because my host's native unzip program cannot handle files that, when unzipped, are larger than 2GB. Will using Python 2.7 ge

Re: changing sys.path

2012-02-01 Thread Tim Delaney
ctly... > > That's what really puzzles me.. What could that be then? Post the actual code, plus traceback. We cannot help you without it. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: xhtml encoding question

2012-02-01 Thread Tim Arnold
On 2/1/2012 3:26 AM, Stefan Behnel wrote: Tim Arnold, 31.01.2012 19:09: I have to follow a specification for producing xhtml files. The original files are in cp1252 encoding and I must reencode them to utf-8. Also, I have to replace certain characters with html entities

Re: changing sys.path

2012-02-02 Thread Tim Roberts
ctually adding multiple paths? One possible cause for error would be this: sys.path.extend( '/usr/local/lib' ) That succeeds, but it doesn't do what you meant. It adds "/" as a path, then "u", then "s", then "r", and so on. -- Tim Rober

Re: Problem sending an email in html with mime image

2012-02-02 Thread Tim Roberts
content of the message is irrelevant to the sending process, unless it makes your message way too big. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Tim Chase
On 02/06/12 12:48, Aaron France wrote: On 02/06/2012 09:57 AM, Matej Cepl wrote: Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj Is the above actually a good idea though? What I understand you're doing is embedding the source from th

Re: iterating over list with one mising value

2012-02-07 Thread Tim Chase
On 02/07/12 09:34, Rick Johnson wrote: On Feb 7, 8:46 am, Dave Angel wrote: On 02/07/2012 07:27 AM, Sammy Danso wrote:> Hello experts, I am having trouble accessing the content of my list. my list content has 2-pair value with the exception of one which has single value. here is an example [

Re: iterating over list with one mising value

2012-02-07 Thread Tim Chase
Thanks for your responses and help. thought I should provide more information for clarity. It sounds like you want the "grouper" function as defined here: http://docs.python.org/library/itertools.html#recipes which does what you describe. -tkc -- http://mail.python.org/mailman/listinfo/pyth

Re: Cycle around a sequence

2012-02-08 Thread Tim Golden
On 08/02/2012 08:26, Mark Lawrence wrote: On 08/02/2012 01:26, Dennis Lee Bieber wrote: On Wed, 08 Feb 2012 01:10:28 +, Mark Lawrence wrote: I'm looking at a way of cycling around a sequence i.e. starting at some given location in the middle of a sequence and running to the end before com

Re: Change os.makedirs to handle existing directory

2012-02-13 Thread Tim Delaney
> IMHO, os.makedirs should do this for you with something like > > os.makedirs(dirName, exist = False) > > and have makedirs silence the error the 'right' way whatever that is, > without turning it into an exercise for the user. Added in 3.2: http://docs.python.org/py3k/lib

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Tim Wintle
(Sorry for top-posting this bit, but I think it's required before the rest of my response) At the risk of wading into this from a UK citizen's perspective: You're imagining a public healthcare system as if it were private. Imagine you go to a doctor and say "I've got the flu, can you give me ant

Re: Python vs. C++11

2012-02-14 Thread Tim Roberts
ost line-for-line translation of my Python programs to C++ programs. (Microsoft has had a "for each" extension for a while that made this easier.) -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Wanted: Criticism of code for a Python module, plus a Mac tester

2012-02-15 Thread Tim Chase
On 02/15/12 17:33, HoneyMonster wrote: Firstly, is there anyone here who uses Python on a Mac and would be prepared to test it? I have tested it on Linux and Windows, but don't have access to a Mac. It works from my quick test of it on my Mac. The "class Player():" and the .format() calls cho

Re: XSLT to Python script conversion?

2012-02-15 Thread Tim Arnold
tool to add to your programming toolbox. Also, I used xsltproc for a while but bogged down in processing time. Now I use SAXON which is much faster for my documents. Good luck, --Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Numerical Linear Algebra in arbitrary precision

2012-02-16 Thread Tim Roberts
//docs.scipy.org/doc/numpy/reference/routines.linalg.html -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python math is off by .000000000000045

2012-02-25 Thread Tim Wintle
rect. The same can be said for ints representing the natural numbers, or positive integers. However, ints can represent 100% of integers within a specific range, where floats can't represent all real numbers for any range (except for the empty set) - because there's an infinate number of r

Re: check if directory is writable in a portable way

2012-02-28 Thread Tim Golden
On 28/02/2012 10:07, Andrea Crotti wrote: How should I check if I can create files in a directory? I tried to simply check if the directory is writeable with this function: def is_writable(name): """Return true if the file is writable from the current user """ return os.access(name, os.W_OK) b

Re: check if directory is writable in a portable way

2012-02-28 Thread Tim Chase
On 02/28/12 04:07, Andrea Crotti wrote: How should I check if I can create files in a directory? So maybe the only solution that works is something like try: open(path.join('temp', 'w')) except OsError: return False else: os.remove(path.join('temp')) return True It depe

Re: check if directory is writable in a portable way

2012-02-28 Thread Tim Chase
On 02/28/12 06:01, Andrea Crotti wrote: How should I check if I can create files in a directory? But isn't there (or should there be) a windows-related library that abstracts this horrible things? Yes, there should be. There isn't as far as I know (though that doesn't mean much given my limi

Re: check if directory is writable in a portable way

2012-02-28 Thread Tim Golden
On 28/02/2012 12:01, Andrea Crotti wrote: On 02/28/2012 11:34 AM, Tim Chase wrote: On 02/28/12 04:07, Andrea Crotti wrote: How should I check if I can create files in a directory? So maybe the only solution that works is something like try: open(path.join('temp', 'w')) ex

Re: pyusb and microchip mcp2210 interface

2012-02-29 Thread Tim Roberts
jobattle wrote: > >Has anybody out there had any experience in using the PYUSB library with >the new Microchip MCP2210 USB to SPI chip? It appears to the system as a HID device. You don't need to use PyUSB -- it already has a driver. Check libhid -- it has a Python binding. --

State of Python+OpenAL?

2012-03-05 Thread Tim Chase
Hunting around to see if there's any existing work to get 3d audio in Python, I encountered two packages (pyopenal[1] & alpy[2]), but both seem sparsely documented if at all and somewhat abandoned. Has anybody used either, or have any pointers on getting up to speed on either? Thanks, -tkc

Re: are int, float, long, double, side-effects of computer engineering?

2012-03-05 Thread Tim Roberts
n in exchange for performance. It is a performance choice that we choose to make. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Biologist new to cgi in python

2012-03-07 Thread Tim Roberts
t of type multiport/form-data. There is a module called "poster" that can do the appropriate encoding for you: http://stackoverflow.com/questions/680305/using-multipartposthandler-to-post-form-data-with-python -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- htt

Re: PyUSB available for current versions of Windows?

2012-03-09 Thread Tim Roberts
keyboard and mouse? No, that's just being overly cautious. Libusb-Win32 can act as a filter driver, inserting itself into an existing USB stack, but to do so the device stack you are filtering must be idle. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: Windows Contextmenu

2012-03-13 Thread Tim Golden
On 13/03/2012 09:41, Szabo, Patrick (LNG-VIE) wrote: I wrote the following Script which I want to run from the open with contextmenu in Windows. For that purpose I used py2exe to make an exe out of it. [... snip ...] Now the script runs fine but I don’t get all arguments from sys.argv. No

Re: Is there a ConfigParser which keeps comments

2012-03-14 Thread Tim Chase
On 03/14/12 12:06, Terry Reedy wrote: On 3/14/2012 6:07 AM, Gelonida N wrote: Now I'm looking for a library, which behaves like config parser, but with one minor difference. The write() mehtod should keep existing comments. Assuming that you have not overlooked anything, I would just subclass

Re: Python is readable

2012-03-15 Thread Tim Golden
On 15/03/2012 14:19, Kiuhnm wrote: On 3/15/2012 15:06, Mark Lawrence wrote: On 15/03/2012 11:48, Kiuhnm wrote: BTW, aren't those ':' redundant? Kiuhnm Nope. Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" fo

Re: code for computing and printing list of combinations

2012-03-20 Thread Tim Chase
On 03/20/12 09:59, Joi Mond wrote: To All, Can someone help me with the proper code to compute combinations for n=7, r=5 for the following list of numbers: 7, 8, 10, 29, 41, 48, 55. There should be 21 combination. Also once there list is made can a code be written to add (sum) each of the set of

Re: Best way to disconnect from ldap?

2012-03-21 Thread Tim Chase
On 03/21/12 15:54, Chris Kaynor wrote: As Chris Rebert pointed out, there is no guarantee as to when the __del__ method is called. CPython will generally call it immediately, however if there are reference cycles it may never call it And more maddeningly, modules/objects used/called from within

Re: Accessing the files by last modified time

2012-03-22 Thread Tim Williams
On Mar 22, 7:33 am, Sangeet wrote: > Hi > > I am new to the python programming language. > > I've been trying to write a script that would access the last modified file > in one of my directories. I'm using Win XP. > > I saw a similar topic, on the forum before, however the reply using > (os.pop

Re: Best way to disconnect from ldap?

2012-03-22 Thread Tim Chase
On 03/22/12 12:26, Steven D'Aprano wrote: On Thu, 22 Mar 2012 08:14:47 -0500, Tycho Andersen wrote: Given that you can't trust __del__, is there a legitimate use case for it? I've never found the need to write one. I've found the need to write them...then been frustrated by things falling o

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-24 Thread Tim Delaney
, etc) is IMO the most important skill for a developer to have. Pick it up quickly, become proficient with it, leave it alone for a couple of years, pick up the new version when you need/want it. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-24 Thread Tim Chase
On 03/24/12 17:08, Tim Delaney wrote: Absolutely. 10 years ago (when I was just a young lad) I'd say that I'd *forgotten* at least 20 programming languages. That number has only increased. And in the case of COBOL for me, it wasn't just forgotten, but actively repressed ;-)

Re: Documentation, assignment in expression.

2012-03-25 Thread Tim Chase
On 03/25/12 07:18, Alexander Blinne wrote: I am not sure I understand your argument. The doc section states that " [...] in Python you’re forced to write this: while True: line = f.readline() if not line: break ... # do something with line". That simply isn't true as on

Re: Documentation, assignment in expression.

2012-03-25 Thread Tim Chase
On 03/25/12 08:11, Chris Angelico wrote: On Mon, Mar 26, 2012 at 12:03 AM, Tim Chase wrote: Granted, this can be turned into an iterator with a yield, making the issue somewhat moot: No, just moving the issue to the iterator. Your iterator has exactly the same structure in it. Yeah, it

Re: Documentation, assignment in expression.

2012-03-25 Thread Tim Chase
On 03/25/12 10:16, Kiuhnm wrote: On 3/25/2012 15:48, Tim Chase wrote: The old curmudgeon in me likes the Pascal method of using "=" for equality-testing, and ":=" for assignment which feels a little closer to mathematical use of "=". Unfortunately, ":=&qu

Re: Documentation, assignment in expression.

2012-03-26 Thread Tim Chase
On 03/25/12 17:59, Dennis Lee Bieber wrote: On Sun, 25 Mar 2012 08:48:31 -0500, Tim Chase Yeah, it has the same structure internally, but I'm somewhat surprised that the DB connection object doesn't have an __iter__() that does something like this automatically under the covers.

Re: Documentation, assignment in expression.

2012-03-26 Thread Tim Chase
On 03/26/12 08:59, Thomas Rachel wrote: Am 25.03.2012 15:03 schrieb Tim Chase: while True: data = conn.fetchmany() if not data: break for row in data: process(row) Or simpler for data in iter(conn.fetchmany, []): for row in data: process(row) Nice

Re: Advise of programming one of my first programs

2012-03-27 Thread Tim Chase
On 03/27/12 10:32, Prasad, Ramit wrote: fileread = open('myfile.txt','r') tbook = eval(fileread.read()) fileread.close() The use of eval is dangerous if you are not *completely* sure what is being passed in. Try using pickle instead: http://docs.python.org/release/2.5.2/lib/pickle-example.html

Re: Advise of programming one of my first programs

2012-03-27 Thread Tim Chase
On 03/27/12 16:53, Anatoli Hristov wrote: On Tue, Mar 27, 2012 at 5:53 PM, Tim Chase wrote: On 03/27/12 10:32, Prasad, Ramit wrote: fileread = open('myfile.txt','r') tbook = eval(fileread.read()) fileread.close() The use of eval is dangerous if you are not *completely

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Tim Chase
On 03/28/12 13:05, Ross Ridge wrote: Ross Ridge wr= But a Python Unicode string might be stored in several ways; for all you know, it might actually be stored as a sequence of apples in a refrigerator, just as long as they can be referenced correctly. But it is in fact only stored in one part

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-28 Thread Tim Delaney
On 25 March 2012 11:03, Tim Chase wrote: > On 03/24/12 17:08, Tim Delaney wrote: > >> Absolutely. 10 years ago (when I was just a young lad) I'd say that I'd >> *forgotten* at least 20 programming languages. That number has only >> increased. >> > &

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-29 Thread Tim Chase
On 03/29/12 12:48, Nathan Rice wrote: Of course, this describes Lisp to some degree, so I still need to provide some answers. What is wrong with Lisp? I would say that the base syntax being horrible is probably the biggest issue. Do you mean something like: ((so (describes Lisp (to degree so

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-31 Thread Tim Rowe
l the best people I've ever known have had experience > with quite a lot of languages. I know 10 languages. But I'm not telling you what base that number is :) -- Tim Rowe -- http://mail.python.org/mailman/listinfo/python-list

Re: Will MySQL ever be supported for Python 3.x?

2012-03-31 Thread Tim Roberts
Every SQL >statement has to be rewritten, with the parameters expressed >differently. It's a good approach, but very incompatible. Those changes can be automated, given an adequate editor. "Oursql" is a far better product than the primitive MySQLdb wrapper. It is worth the

M2Crypto.SSL.Checker.NoCertificate Exception

2012-04-02 Thread Tim H.
he array of addresses. The IP is passed from the caller. Thank you in advance! -Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Tim Chase
PHP is a language that I wish would die off quickly and gracefully. I feel like the good things of PHP have already been subsumed into the ecosystems of stronger programming languages (including Python). The one killer feature PHP has to offer over other languages: ease of efficient deployment

Re: Is Programing Art or Science?

2012-04-03 Thread Tim Bradshaw
On 2012-04-03 00:52:35 +0100, Jürgen Exner said: Oh, that's why it is tought in trade schools alongside butchery, plumbing, masonry, and chimney sweeping and why you don't find any programming classes at university. So, you know, no one would do law or medicine at a university. Oh, wait. --

Re: Python Gotcha's?

2012-04-04 Thread Tim Chase
On 04/04/12 17:34, Miki Tebeka wrote: Greetings, I'm going to give a "Python Gotcha's" talk at work. If you have an interesting/common "Gotcha" (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). 1) While I believe it was fixed in m

Re: Python Gotcha's?

2012-04-05 Thread Tim Wintle
ither in javascript) I believe the choice is to make the parser as simple as possible. Agreed it's a gotcha, but json is almost always generated automatically. Tim -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Gotcha's?

2012-04-07 Thread Tim Roberts
ns to follow the same quoting rules as Python. Now, I fully understand that it is the way it is. I'm merely pointing out that his was not an unreasonable expectation. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: functions which take functions

2012-04-11 Thread Tim Chase
On 04/10/12 08:36, Kiuhnm wrote: On 4/10/2012 14:29, Ulrich Eckhardt wrote: Am 09.04.2012 20:57, schrieb Kiuhnm: That won't do. A good example is when you pass a function to re.sub, for instance. If that's a good example, then why not use it? I've used it on multiple occasions to do lookups

Re: f python?

2012-04-11 Thread Tim Roberts
to use >slashes in paths: All of them should do so. They're just string being passed to CreateFile, and CreateFile accepts forward slashes just fine. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: functions which take functions

2012-04-11 Thread Tim Roberts
7;: doAdd, 'subtract' : doSubtract, 'multiply' : doMultiply, 'divide' : doDivide } nextCommand = parseCommandLine( line ) invokeCommand( commands[NextCommand] ) -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list

Re: is this foolish?

2012-04-12 Thread Tim Golden
On 12/04/2012 10:35, Cameron Simpson wrote: > I've found myself using a Python gotcha as a feature. Have a look at Peter Inglesby's lightning talk from a recent London Python Dojo: http://inglesp.github.com/2012/03/24/mutable-default-arguments.html TJG -- http://mail.python.org/mailman/listin

Re: Python one-liner?

2012-04-14 Thread Tim Chase
On 04/13/12 22:54, Chris Angelico wrote: Yes, that would be the right method to use. I'd not bother with the function and map() though, and simply iterate: d = {} for val in l: d.setdefault(f(val), []).append(val) Or make d a defaultdict: from collections import defaultdict d = defaultd

<    1   2   3   4   5   6   7   8   9   10   >