Param decorator - can you suggest improvements

2013-01-17 Thread Mark Carter
I thought it would be interesting to try to implement Scheme SRFI 39 (Parameter objects) in Python. The idea is that you define a function that returns a default value. If you call that function with no arguments, it returns the current default. If you call it with an argument, it resets the de

Re: Google spreadsheets - getting started

2012-11-03 Thread Mark Carter
OK, the story so far: import gdata import gdata.auth import gdata.gauth import gdata.docs.service import OpenSSL.crypto tokenfile = "privatekey.p12" #f = open(tokenfile, 'r') #blob = f.read() #f.close() #if blob: p12 = OpenSSL.crypto.load_pkcs12(file(tokenfile, 'rb').read(), 'notasecret') print

Re: Google spreadsheets - getting started

2012-11-03 Thread Mark Carter
OK, maybe the p12 file is useful after all (?) I've got the following code: import gdata tokenfile = "my-privatekey.p12" f = open(tokenfile, 'r') blob = f.read() f.close() token = gdata.gauth.token_from_blob(blob) When I run that I get: Traceback (most recent call last): File "/home/mcarter/wa

Google spreadsheets - getting started

2012-11-03 Thread Mark Carter
I want to mess around with my online Google spreadsheets from my Linux box programmatically. I am TOTALLY confused. I've got gdata installed, and it appears that the best way to access the spreadsheets is to authenticate with Oauth2. Here's the main thing: how do I get an Oauth2 key to use with

Re: Guarding arithmetic

2012-08-23 Thread Mark Carter
On Thursday, 23 August 2012 10:23:20 UTC+1, Laszlo Nagy wrote: > On 2012-08-23 11:05, Mark Carter wrote: > You are very vague. "There is an error" - but what kind of error? Assume that it doesn't matter. > In some special cases, this can be a good idea to do. Thos

Re: Guarding arithmetic

2012-08-23 Thread Mark Carter
On Thursday, 23 August 2012 10:16:08 UTC+1, Chris Angelico wrote: > On Thu, Aug 23, 2012 at 7:05 PM, Mark Carter <> wrote: > > Suppose I want to define a function "safe", which returns the argument > > passed if there is no error, and 42 if there is one. >

Guarding arithmetic

2012-08-23 Thread Mark Carter
Suppose I want to define a function "safe", which returns the argument passed if there is no error, and 42 if there is one. So the setup is something like: def safe(x): # WHAT WOULD DEFINE HERE? print safe(666) # prints 666 print safe(1/0) # prints 42 I don't see how such a function could be

Re: Looking for a urllib(2) cookie handler

2011-04-19 Thread Mark Carter
On Apr 19, 12:44 pm, Mark Carter wrote: > url and say "just use the cookie that I have in Firefox"? "mechanize" looks kinda like what I want, but i still can't get it to work properly. So far I have: import cookielib import mechanize cookiefile = "C:\\User

Looking for a urllib(2) cookie handler

2011-04-19 Thread Mark Carter
I'm in python 2.6.5, and have Firefox 3.6.13. I would like to download some html from a site and scrape it programatically. The site requires a cookie, which I have in Firefox. Is there a simple python recipe I can use to read the contents of a url and say "just use the cookie that I have in Firef

Re: wx.Frame hidden, and customising the close button

2011-02-11 Thread Mark Carter
On Feb 11, 1:39 pm, Vlastimil Brom wrote: > (wxPython-specific questions may be rather discussed  on that > maillist:http://groups.google.com/group/wxpython-users/topics?pli=1 Just the ticket! Many thanks! -- http://mail.python.org/mailman/listinfo/python-list

wx.Frame hidden, and customising the close button

2011-02-11 Thread Mark Carter
Is there a way of testing whether a frame (suppose I have it as a variable my_frame) is hidden in wxPython? Also, is there a way that I can over-ride the close button so that the frame becomes hidden rather than destroyed, and perform supplementary tests? -- http://mail.python.org/mailman/listinf

Printing RTF file under win32

2011-01-21 Thread Mark Carter
I'm using Python 2.6.5 on win32. I would like to print a batch of RTF files on a printer. I don't want to use the win32api.ShellExecute command because that invokes Word, and Word has been configured in a strange way by one of our admins, making it inconvenient to use. What should I do? -- http:/

wx Just Print!

2011-01-14 Thread Mark Carter
I'm using Python 2.6.5. I would like to be able to print an RTF file, with no prompts for printers or anything like that. Here's the code so far: import wx.richtext rtp = wx.richtext.RichTextPrinting() rtp.PrintFile('C:\\path\\to\\file.rtf') When I run it, it says: ... assert "(wxThePrintPaperDat

Python scripts from DOS

2010-07-09 Thread Mark Carter
On my machine, I can go to a DOS shell, and type myscript.py This will cause the script to be run as a python script. So that bit works. On another machine, on which python was set up without admin privileges, if I type myscript.py it will open the "Open With" dialog box. It wont let me exec

win32com sql update problem

2010-05-11 Thread Mark Carter
Consider the following snippet of code: import win32com.client DSN = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=M:\\Finance\\camel\ \camel.mdb;' conn.Open(DSN) cursor = conn.Execute("UPDATE tblInvoice SET InvComments='Python' WHERE InvBillingPeriod = 'April 2010' AND InvJobCode = '2169'") rows

Re: Install 2.6.4 as non-admin on Windows

2010-03-18 Thread Mark Carter
On 18 Mar, 15:23, "egl...@gmail.com" wrote: > The only file written to a system folder is python2x.dll (I think it's > not true for python2.6 any longer), so your approach is perfectly > valid if you can put this dll into a folder where it can be found by > the system. Thanks. That sounds easy en

Install 2.6.4 as non-admin on Windows

2010-03-18 Thread Mark Carter
How do I install python 2.6.4 on Windows without admin privileges? Can I install it on a machine I control, zip up the contents, copy it across to an admin-restricted machine, and set up a couple of environemtn variables? Does python install files to system directories, making this impossible? --

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
[EMAIL PROTECTED] wrote: > if you are not satisfied with the native version, why not install the > official version directly from python site > http://www.python.org/download/ (macpython) instead of using that of > macports. It moreover is provided with many utilities > > There is a macpython list

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
Arnaud Delobelle wrote: > Is there a particular reason you want python from MacPorts? OSX > Leopard comes with python 2.5, that's what I use on my mac. I heard from somewhere that Apple's version was a bit wonky, and that I would be better off with a "proper" build. -- http://mail.python.org/ma

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
has wrote: > On 15 Mar, 18:05, Mark Carter <[EMAIL PROTECTED]> wrote: >> The sorts of things I want to do are: >> * copy the directory of Finder to the clipboard >> * add a new file to Finder's directory. >> * find out the size of a directory >> * open a

Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
One thing I really liked about Ubuntu was that Nautilus allowed you to add scripts to a directory which could be accessed via the RMB. It was a very simple thing to do. I've recently switched to Leopard, and I'm trying to do the same thing. I'm fairly experienced with Python, but new to OS X. I

Re: sqlite3 bug??

2007-06-17 Thread mark carter
Carsten Haese wrote: > On Sun, 2007-06-17 at 07:43 -0700, 7stud wrote: >> Please report the whole docs as a bug. > > I imagine the author appreciates constructive criticism. This is not > constructive criticism. > > In other words: Pointing out specific shortcomings and ways to correct > them, su

Re: sqlite3 bug??

2007-06-17 Thread mark carter
7stud wrote: > On Jun 17, 7:16 am, mark carter <[EMAIL PROTECTED]> wrote: >> David Wahler wrote: >>> On 6/17/07, mark carter <[EMAIL PROTECTED]> wrote: >>>> Anyone else getting these problems? >>> Seehttp://www.python.org/dev/peps/pep-0249/(em

Re: sqlite3 bug??

2007-06-17 Thread mark carter
David Wahler wrote: > On 6/17/07, mark carter <[EMAIL PROTECTED]> wrote: >> Anyone else getting these problems? > > See http://www.python.org/dev/peps/pep-0249/ (emphasis mine): > >.commit() OK, I tried that, and I appear to be cooking. The funny thing is, I co

sqlite3 bug??

2007-06-17 Thread mark carter
I hesitate to ask, but ... I'm using Ubuntu Feisty: * Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 * SQLite version 3.3.13 Suppose I run the following program: import sqlite3 conn = sqlite3.connect('example') c = conn.cursor() # Create

Re: Working with fixed format text db's

2007-06-08 Thread Mark Carter
Neil Cerutti wrote: > The underlying problem, of course, is the archaic flat-file > format with fixed-width data fields. Even the Department of > Education has moved on to XML for most of it's data files, :( I'm writing a small app, and was wondering the best way to store data. Currently the fi

Re: Who uses Python?

2007-06-04 Thread Mark Carter
Thomas Jollans wrote: > Broadly speaking, everyone who uses python programs in it and may thus be > considered a "programmer". A woman from a job agency 'phoned me up the other day, and asked me if I was any good with "algortihms". I told her that all programs are algorithms, so the question

Re: Who uses Python?

2007-06-04 Thread Mark Carter
walterbyrd wrote: > Anything else? Finance? Web-analytics? SEO? Digital art? I played with NodeBox a little while ago: http://nodebox.net/code/index.php/Home "NodeBox is a Mac OS X application that lets you create 2D visuals (static, animated or interactive) using Python programming code and ex

Re: Python rocks

2007-06-03 Thread Mark Carter
Alex Martelli wrote: > Josiah Carlson <[EMAIL PROTECTED]> wrote: > >>> pitfall of Python is knowing whether an operation is destructive or not. >> If it returns None, it probably changes the content of an object. > > A reasonable heuristic, but with lots of exceptions, alas: > somedict.get(so

Re: Python rocks

2007-06-03 Thread Mark Carter
Alex Martelli wrote: > Mark Carter <[EMAIL PROTECTED]> wrote: > Yes, GMP is a pain to compile (especially on Mac OS X), but I believe > Just mentioning this in case you want to give Scheme another chance Thanks. I'll take a look at it. I think I've decided to finish of

Re: Python rocks

2007-06-02 Thread Mark Carter
Josiah Carlson wrote: > Mark Carter wrote: >> Not that I'm particularly knowledgeable about language design issues, >> but maybe closures and slightly different scoping rules would be nice. > > Python has had closures for years. I just looked up http://ww

Re: Python rocks

2007-06-02 Thread Mark Carter
Steve Howell wrote: > --- Mark Carter <[EMAIL PROTECTED]> wrote: > >> Well, I know I'm preaching to the converted - but >> Python rocks. >> [...] > > A few questions from the choir: > > As a recent newcomer to the language, did you > encount

Python rocks

2007-06-02 Thread Mark Carter
Well, I know I'm preaching to the converted - but Python rocks. I've been enchanted by the siren calls of Scheme, Lisp and Forth, but in the end, I find Python much easier. I even tried a little bit of Tcl. To give a bit of context ... I have recently switched from Windows to OS X and Linux. I

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-22 Thread Mark Carter
Mark Carter wrote: > At the risk of being labelled a troll One thing I just discovered, and by which I mean *really* discovered ... is that Lisp is an interactive environment. I am working on trying to verify the contents of disks. I noticed that the input formats are slightly wrong,

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Carter
Mark Tarver wrote: > Interesting. At the risk of being labelled a troll, one thought that is occuring to me is that in Lisp it seems that sometimes it is difficult to achieve a simple thing in a simple way. To clarify ... recently, I had been trying to obtain md5 hashes of the files we had on

Re: Programming challenge: wildcard exclusion in cartesian products

2006-03-20 Thread Mark Carter
I'd like to propose a coding challenge of my own. The challenge is to reproduce the TEA (Tiny Encryption Algorith): http://www.simonshepherd.supanet.com/tea.htm in your language of choice. Here's the code, just two simple functions: void encipher(unsigned long *const v,unsigned long *const w,

Re: Windows and python execution

2005-12-26 Thread Mark Carter
rzed wrote: > I should have asked which Windows version you had. XP Pro My bad. On Win2k > or XP, adding .py (for instance) to the PATHEXT variable means that > you can execute "myNeatProgram.py" with this command-line: > prompt>myNeatProgram Oh, now I see! It's beginning to make sense to me

Re: Windows and python execution

2005-12-26 Thread Mark Carter
Bengt Richter wrote: >>>And there is a PATHEXT environment variable, >> >>Aha. You'bve provided a significant clue. >> >>What you need to do is include the following line in autoexec.bat: >>set .py=c:\python24\python.exe >> >>This will achieve the desired result. I'm suprised more people don't us

Re: Windows and python execution

2005-12-26 Thread Mark Carter
BartlebyScrivener wrote: > The installer can put python.exe in his PATH but if he's storing his > scripts in some oddball place then he has to tell Windows where to find > them. I think you're misunderstanding what I was after. python.exe is already in my PATH. What I was trying to do was execute

Re: Windows and python execution

2005-12-26 Thread Mark Carter
rzed wrote: > Mark Carter <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > >>What I would like to do it type something like >> >>>myscript.py >> >>instead of >> >>>python myscript.py > As another poster points o

Windows and python execution

2005-12-26 Thread Mark Carter
What I would like to do it type something like > myscript.py instead of > python myscript.py on a Windows console. I know its possible because Ruby scripts manage to do this - I just don't know the registry settings that need to be tweaked to enable it. Any ideas (I'd prefer to know the registr

Passwords in cron scripts

2005-12-24 Thread Mark Carter
I have some python scripts that run as cron jobs. They connect to external resources (like a newsserver) - for which passwords are required. I currently have them stored in the scripts themselves (ouch!) - and was wondering if there was a more secure solution. -- http://mail.python.org/mailman/

Re: Xah's Edu Corner: Responsible Software Licensing

2005-12-17 Thread Mark Carter
robic0 wrote: > Xah, please admit to me that your under the influence of > physocopic drugs! He could be schizophrenic. Seekers of all things wierd on the internet can do no better than Gene Ray's Timecube: http://www.timecube.com/ His outpourings are so well known that he even gets a menti

Re: Web functions idea

2005-11-29 Thread Mark Carter
bruno at modulix wrote: > Mark Carter wrote: > Congratulations, you've just rediscovered REST !-) Huzzah! > Turbogears is probably what you're looking for (if not quite what you > describe). Thanks. It looks quite interesting. -- http://mail.python.org/mailman/listinfo/python-list

Web functions idea

2005-11-29 Thread Mark Carter
I was musing recently about how one could, for example, set up a really simple mailing subscription list. It occurred to me that a really simple way to implement it would be to use xmlrpc. So there could be a function subscribe(emailAddress), which would send an email for confirmation, and anothe

Re: Port blocking

2005-01-11 Thread Mark Carter
Ed Leafe wrote: On Jan 10, 2005, at 8:00 PM, Steve Holden wrote: There isn't, IMHO, anything with the polish of (say) Microsoft Access, or even Microsoft SQL Server's less brilliant interfaces. Some things Microsoft *can* do well, it's a shame they didn't just stick to the knitting. Though

Re: Port blocking

2005-01-10 Thread Mark Carter
Mark Carter wrote: Paul Rubin wrote: Usually you wouldn't run a public corba or pyro service over the internet. You'd use something like XMLRPC over HTTP port 80 partly for the precise purpose of not getting blocked by firewalls. I'm not sure if we're talking at cross-pu

Re: Port blocking

2005-01-10 Thread Mark Carter
Paul Rubin wrote: Mark Carter <[EMAIL PROTECTED]> writes: Supposing I decide to write a server-side application using something like corba or pyro. Usually you wouldn't run a public corba or pyro service over the internet. You'd use something like XMLRPC over HTTP port 80 partly

Port blocking

2005-01-10 Thread Mark Carter
Supposing I decide to write a server-side application using something like corba or pyro. What's the chance that in big corporations, the client's ports (in both senses of the word: fee-paying, and application) will be blocked, thereby immediately scuppering whatever I have written? Has this p

Re: How can engineers not understand source-code control?

2005-01-04 Thread Mark Carter
Mark Carter wrote: I'm thinking that the I-Ching is a vast untapped resource for programming wisdom, plus it makes it funny. Well, carrying on in the same frivilous and some might say off-topic mood, I did a bit of a Google, and found that you can generate your very own I-Ching reading:

Re: How can engineers not understand source-code control?

2005-01-04 Thread Mark Carter
;; This buffer is for notes you don't want to save, and for Lisp evaluation. ;; If you want to create a file, first visit that file with C-x C-f, ;; then enter the text in that file's own buffer. Cameron Laird wrote: > Well *that* certainly made my morning unpleasant. Then let's see if I can spoil

Re: How can engineers not understand source-code control?

2005-01-04 Thread Mark Carter
> Cameron Laird wrote: > >> I've seen the infatuation for Excel (and so on) for years, True story: when I began working for my current employer, there was a guy there doing some work with a spreadsheet. He was given two weeks to perform the task. It was a loss-leader to get some real work from th

Re: The Industry choice

2005-01-02 Thread Mark Carter
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Mark Carter <[EMAIL PROTECTED]> wrote: >. >[tale of *very* >typical experience >with non-software >engineers] >. >

Re: The Industry choice

2005-01-02 Thread Mark Carter
> It might be nice if it was widely understood (in IT) that Python was a language any competent > programmer could pick up in an afternoon I am a programmer who works for a firm of engineers, where they program in VBA, badly. I've often mentioned Python, whereupon I'm usually dismissed as a cra

Re: Which blog tool

2005-01-01 Thread Mark Carter
Premshree Pillai wrote: You can use the Blogger API to post to your Blogger account. There's a Python interface to the API -- PyBlogger -- available here: http://beetle.cbtlsl.com/archives/category/pyblogger Hey, it Just Works! I got the whole basic thing working in a few minutes. It was exactly w

Which blog tool

2005-01-01 Thread Mark Carter
I currently use python to automatically summarise a certain newsgroup daily, and post the findings that it makes. Someone has suggested that they would like a to see a blog of the posts. I wondered if there was a python tool/library that could automate the blog postings. Any ideas? Some details