Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 11:31 pm, norseman wrote: > Steve Howell wrote: > > On May 11, 10:16 pm, norseman wrote: > >> Tim Arnold wrote: > >>> Hi, I have some html files that I want to validate by using an external > >>> script 'validate'. The html files need a doctype header attached before > >>> validation.

Re: install pyPgSQL on Windows for python 2.5

2009-05-11 Thread ralf321
On 24 Mrz., 18:25, someon wrote: > On Mar 24, 4:57 pm, Dietmar Schwertberger > wrote: > > > someone wrote: > > > Hi, > > > > does anyone know how to install pyPgSQL on Windows? There is no > > > package for Python 2.5 on Homepage: > > > I've installed newest Visual C++ Studio 2008 from Microsoft,

Re: How do I test the integrity of a Python installation in Debian and Ubuntu

2009-05-11 Thread Geoff Gardiner
Lawrence D'Oliveiro wrote: > .. I expect an apology. > Otherwise, it becomes grounds for an abuse complaint to your ISP. > Yes, I do apologize profusely and publicly, and would have done so regardless of threat. I had trouble with posts making it through to the list and so was also posting in

Re: piping input to an external script

2009-05-11 Thread norseman
Steve Howell wrote: On May 11, 10:16 pm, norseman wrote: Tim Arnold wrote: Hi, I have some html files that I want to validate by using an external script 'validate'. The html files need a doctype header attached before validation. The files are in utf8 encoding. My code: --- import

Re: Fwd: Re: Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread Mark Hammond
Probably some import statement is finding a .pyd module built against Python 2.5 instead of Python 2.6; it might be that PYTHONPATH points somewhere wrong, or the registry for Python 2.6 is setup wrong, or something else entirely... Cheers, Mark On 12/05/2009 3:13 PM, David Lyon wrote: Hi,

Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 10:16 pm, norseman wrote: > Tim Arnold wrote: > > Hi, I have some html files that I want to validate by using an external > > script 'validate'. The html files need a doctype header attached before > > validation. The files are in utf8 encoding. My code: > > --- > > import o

Re: Wrapping comments

2009-05-11 Thread Arnaud Delobelle
Tobias Weber writes: > In article , > David Robinow wrote: > >> (define-key key-translation-map [?\M-3] "#") >> >> >> or, if you prefer, just be sick. > > Thanks, but I don't believe using releases from people who think I jump > should through hoops just to make my keyboard work is a good pl

Re: piping input to an external script

2009-05-11 Thread norseman
Tim Arnold wrote: Hi, I have some html files that I want to validate by using an external script 'validate'. The html files need a doctype header attached before validation. The files are in utf8 encoding. My code: --- import os,sys import codecs,subprocess HEADER = '' filename =

Fwd: Re: Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread David Lyon
Hi, hmmm... that's annoying.. Whilst I don't have an exact answer I have a few hunches... Perphaps what has happened is that the windows installer between the versions of pywin32 has installed newer versions of the same dlls over the top of older ones. Or, possibly, the installer hasn't wanted

Re: Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread David Lyon
Hi, hmmm... that's annoying.. Whilst I don't have an exact answer I have a few hunches... Perphaps what has happened is that the windows installer between the versions of pywin32 has installed newer versions of the same dlls over the top of older ones. Or, possibly, the installer hasn't wanted

Re: Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread David Lyon
On Tue, 12 May 2009 02:22:56 GMT, David Lees wrote: > I have no problem installing Python 2.6.2 for windows under XP SP3 and > IDLE and the command line versions work fine. When I run the pywin32 > installer downloaded from sourceforge (pywin32-212.win32-py2.6.exe) I > get the following error

Re: Nimrod programming language

2009-05-11 Thread kay
On 12 Mai, 02:10, Tomasz Rola wrote: > On Mon, 11 May 2009, rump...@web.de wrote: > > > One question I ask myself upon seeing a new language is if it is possible > > > to program amb (amb=ambiguous) operator in it. This page gives a very > > > nice, "code first" explanation of amb and how it is su

Re: piping input to an external script

2009-05-11 Thread Steve Howell
On May 11, 11:04 am, "Tim Arnold" wrote: > Hi, I have some html files that I want to validate by using an external > script 'validate'. The html files need a doctype header attached before > validation. The files are in utf8 encoding. My code: > --- > import os,sys > import codecs,subp

Re: web access through vpn client

2009-05-11 Thread Gabriel Genellina
En Fri, 01 May 2009 21:41:03 -0300, Stephen Hansen escribió: urllib2 and BeautifulSoup work pretty well to do what I want, and the first little routine actually gets the data from the web page... except if my VPN client is turned on. Usually when something like that happens with a VPN its b

Re: dict would be very slow for big data

2009-05-11 Thread Steve Howell
On May 11, 8:28 pm, forrest yang wrote: > hi > i am trying to insert a lot of data into a dict, which may be > 10,000,000 level. > after inserting 10 unit, the insert rate become very slow, 50,000/ > s, and the entire time used for this task would be very long,also. > would anyone know some so

piping input to an external script

2009-05-11 Thread Tim Arnold
Hi, I have some html files that I want to validate by using an external script 'validate'. The html files need a doctype header attached before validation. The files are in utf8 encoding. My code: --- import os,sys import codecs,subprocess HEADER = '' filename = 'mytest.html' fd = c

Re: putting date strings in order

2009-05-11 Thread Paul Rubin
noydb writes: > Anyone have any good ideas? I was curious to see what people came up > with. Is this a homework assignment? Some hints: 1) figure out how to compare two month names for chronological order, leaving out the issue of the starting month not being january. 2) figure out how to a

dict would be very slow for big data

2009-05-11 Thread forrest yang
hi i am trying to insert a lot of data into a dict, which may be 10,000,000 level. after inserting 10 unit, the insert rate become very slow, 50,000/ s, and the entire time used for this task would be very long,also. would anyone know some solution for this case? thanks -- http://mail.python.

Re: Can I get a value's name

2009-05-11 Thread Alan Brogan
Thank you Ken for your help answer On Mon, May 11, 2009 at 8:11 PM, Ken Seehart wrote: > jalanb3 wrote: >> >> def replace_line(pattern,replacement): >>    values = '\n' in pattern and [ pattern ] or [] >>    values += '\n' in replacement and [ replacement ] or [] >> >> Can I later get the name "

Re: OOP & Abstract Classes

2009-05-11 Thread alex23
On May 12, 1:22 am, Mike Driscoll wrote: > I've never used (or heard of) the Abstract type...and the guy who > wrote the FAQ was being a jerk. It looks like he was just throwing in > an undefined variable name just to make his Python program break while > taking a pot shot at people who use that s

putting date strings in order

2009-05-11 Thread noydb
All, How best to go about this? >> I have a list containing strings referring to months, like ["x_apr", "x_jul", "x_jan", "x_aug", "x_may", etc] -- always using the 3-chars for month. The list will contain all 12 months, however the starting month may not necessarily be jan. I want to order th

Re: sqlite single transaction without foreign key or triggers

2009-05-11 Thread Aahz
In article , Rob Williscroft wrote: > >db.execute( ''' > update "sessions" set "uid" = ? > where "uid" = ? > and exists( > select * from "users" where "uid" = ? > ) >''', >(v['uid'],s.SID, v['uid']) > ) This will be more efficient if you do "sel

Re: OS X: How to play .wav file w/Python?

2009-05-11 Thread alex23
On May 12, 11:55 am, kj wrote: > import pygame.mixer > > pygame.mixer.init() > pygame.mixer.Sound("bell.wav").play > print "done" > > What am I doing wrong? Your first mistake is not pasting here the traceback you received. That always makes it easier to assist with problems like this. However,

Unable to install Pywin32 for Python 2.6.2

2009-05-11 Thread David Lees
I have no problem installing Python 2.6.2 for windows under XP SP3 and IDLE and the command line versions work fine. When I run the pywin32 installer downloaded from sourceforge (pywin32-212.win32-py2.6.exe) I get the following error message: Traceback (most recent call last): File "", line

Re: creating classes with mix-ins

2009-05-11 Thread Carl Banks
On May 11, 11:16 am, samwyse wrote: > I'm writing a class that derives it's functionality from mix-ins. > Here's the code: > >     def boilerplate(what):   # This used to be a decorator, but all of > the >         ##what = f.__name__  # function bodies turned out to be > 'pass'. >         'Validat

OS X: How to play .wav file w/Python?

2009-05-11 Thread kj
Hi. I'm trying to learn how to play a .wav file in OS X with Python. I tried the following, which ran without errors, but produced nothing audible (even though the file bell.wav plays perfectly well otherwise, e.g. view the Finder's Preview): import pygame.mixer pygame.mixer.init() pygame.mixer.

Re: OOP & Abstract Classes

2009-05-11 Thread Terry Reedy
Adam Gaskins wrote: Wow, thanks Nick! This is just what I was looking for! I agree that Nick's semi-abstract class is what you need. After doing some subclasses, you may discover that there is more common code that you can factor out and push to the base class. You may also find it convenien

Re: How do I test the integrity of a Python installation in Debian and Ubuntu

2009-05-11 Thread Lawrence D'Oliveiro
In message , Geoff Gardiner wrote: > @Lawrence D'Oliveiro: > ... I see that you published my unobfuscated e-mail address on USENET for all to see. I obfuscated it for a reason, to keep the spammers away. I'm assuming this was a momentary lapse of judgement, for which I expect an apology. Othe

Re: Nimrod programming language

2009-05-11 Thread Lawrence D'Oliveiro
In message <57f4c81a-3537-49fa-a5f6- a0cc0d43d...@o14g2000vbo.googlegroups.com>, rump...@web.de wrote: > I am dissatisfied with Python's (or Java's) Unicode handling: > 1) IO overhead to convert UTF-8 (defacto standard on UNIX) into > UTF-16. Are you sure they're using UTF-16? I would use UCS-2 o

Re: Re: Complete frustration

2009-05-11 Thread Dave Angel
norseman wrote: hellcats wrote: I have Python2.5 installed on Windows XP. Whenever I double click on a something.pyw file, IDLE launches and opens something.pyw in the editor. I would prefer to actually *RUN* the program, not edit it. If I want to edit it then I'll choose the "Edit with IDLE"

Re: how to consume .NET webservice

2009-05-11 Thread namekuseijin
Diez B. Roggisch wrote: namekuseijin schrieb: bav escreveu: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Unless Microsoft extended the standard in any way, then it should be just as you c

Re: Nimrod programming language

2009-05-11 Thread Tomasz Rola
On Mon, 11 May 2009, rump...@web.de wrote: > > One question I ask myself upon seeing a new language is if it is possible > > to program amb (amb=ambiguous) operator in it. This page gives a very > > nice, "code first" explanation of amb and how it is supposed to work: > > > > http://www.randomhack

Re: Nimrod programming language

2009-05-11 Thread Paul Rubin
rump...@web.de writes: > I am dissatisfied with Python's (or Java's) Unicode handling: > 1) IO overhead to convert UTF-8 (defacto standard on UNIX) into > UTF-16. So use UTF-8 internally. You can still iterate through strings efficiently. Random access would take a performance hit. When that's

Re: Your Favorite Python Book

2009-05-11 Thread Shawn Milochik
On Mon, May 11, 2009 at 5:52 PM, wrote: > Sam, > > In no specific order (I brought them all): > > Wesley Chun's "Core Python Programming" > David Mertz's "Text Processing in Python" (older, but excellent) > Mark Lutz's "Learning Python" > > All highly recommended. > > Best of luck on your Python

Re: sqlite single transaction without foreign key or triggers

2009-05-11 Thread gert
On 11 mei, 23:07, Rob Williscroft wrote: > gert wrote in news:d7591495-4661-4243-ad7e-f142d8244e88 > @e24g2000vbe.googlegroups.com in comp.lang.python: > > > I am trying to do this in a single transaction, the 3 separate > > statements work fine, but i am screwed if they are not executed > > toget

Re: MacPython 3.0.1 installation problem, no /usr/local/bin/python*

2009-05-11 Thread Raoul Gough
Ned Deily writes: > In article > , > Benjamin Kaplan wrote: >> On Sat, May 9, 2009 at 4:30 AM, Raoul Gough >> wrote: [snip] >> > So did something go wrong with the installer, or is it all >> > supposed to work somehow differently? >> >> Because Python 3 breaks compatibility with Python 2, th

Re: Wrapping comments

2009-05-11 Thread Rhodri James
On Mon, 11 May 2009 08:39:48 +0100, Tobias Weber wrote: In article , "Rhodri James" wrote: What on earth are you talking about? '#' has its own key on a UK layout Not on Apple keyboards, and the emacs release in question is Mac only. My commiserations. That was a bad design decision o

Re: issue with twisted and reactor. Can't stop reactor

2009-05-11 Thread Gabriel
Jean-Paul Calderone escribió: > None of the reactors in Twisted are restartable. You can run and stop them > once. After you've stopped a reactor, you cannot run it again. This is > the > cause of your problem. > > Jean-Paul I see. Is it possible to do what I want using twisted? or I should f

Re: There may be a much better way to manage artillery.

2009-05-11 Thread Rhodri James
On Mon, 11 May 2009 22:59:43 +0100, Tobiah wrote: On Mon, 11 May 2009 00:48:25 +0100, Rhodri James wrote: On Mon, 11 May 2009 00:06:34 +0100, Tobiah wrote: [Snippety snip] I wanted the bullets to be responsible for destroying themselves, but a little Googling brought me to points about da

Re: Nimrod programming language

2009-05-11 Thread Mensanator
On May 11, 4:55 pm, rump...@web.de wrote: > On 10 Mai, 10:40, Paul Rubin wrote:> Andreas > Rumpf writes: > > > I invented a new programming language called "Nimrod" that combines > > > Python's readability with C's performance. Please check it out: > > >http://force

Re: how to consume .NET webservice

2009-05-11 Thread Diez B. Roggisch
namekuseijin schrieb: bav escreveu: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Unless Microsoft extended the standard in any way, then it should be just as you consume any web service, I

Re: Nimrod programming language

2009-05-11 Thread rumpf_a
> One question I ask myself upon seeing a new language is if it is possible > to program amb (amb=ambiguous) operator in it. This page gives a very > nice, "code first" explanation of amb and how it is supposed to work: > > http://www.randomhacks.net/articles/2005/10/11/amb-operator > Hm. I am not

Re: issue with twisted and reactor. Can't stop reactor

2009-05-11 Thread Jean-Paul Calderone
On Mon, 11 May 2009 17:40:57 -0300, Gabriel wrote: Hello all!, I'm trying to implement a simple one way communication using twisted. [snip] When I call send the first time it works fine, when I call send a second time the sender hangs. [snip] None of the reactors in Twisted are restartable.

Re: Your Favorite Python Book

2009-05-11 Thread python
Sam, In no specific order (I brought them all): Wesley Chun's "Core Python Programming" David Mertz's "Text Processing in Python" (older, but excellent) Mark Lutz's "Learning Python" All highly recommended. Best of luck on your Python journey! Regards, Malcolm -- http://mail.python.org/mailma

Re: There may be a much better way to manage artillery.

2009-05-11 Thread Tobiah
On Mon, 11 May 2009 00:48:25 +0100, Rhodri James wrote: > On Mon, 11 May 2009 00:06:34 +0100, Tobiah wrote: > > [Snippety snip] > >> I wanted the bullets to be responsible for destroying themselves, but a >> little Googling brought me to points about dangling references and how >> an object is

Re: Nimrod programming language

2009-05-11 Thread rumpf_a
On 10 Mai, 10:40, Paul Rubin wrote: > Andreas Rumpf writes: > > I invented a new programming language called "Nimrod" that combines > > Python's readability with C's performance. Please check it out: > >http://force7.de/nimrod/Any feedback is appreciated. > > Looks n

Re: How to replace constructor with factory method

2009-05-11 Thread Luis Zarrabeitia
On Monday 11 May 2009 04:39:41 pm roge...@gmail.com wrote: > so o = A() instead being equivalent to: > > s = object() > A.__init__(s) > o = s Actually, it would be more like this: s = A.__new__(A) if isinstance(s,A): A.__init__(s) o = s > o = my_factory_function( A ) You could tweak: *) A'

Re: Your Favorite Python Book

2009-05-11 Thread Chris Rebert
On Mon, May 11, 2009 at 1:44 PM, Sam Tregar wrote: > Greetings.  I'm working on learning Python and I'm looking for good books to > read.  I'm almost done with Dive into Python and I liked it a lot. I found > Programming Python a little dry the last time I looked at it, but I'm more > motivated no

Re: creating classes with mix-ins

2009-05-11 Thread samwyse
On May 11, 1:16 pm, samwyse wrote: > I'm writing a class that derives it's functionality from mix-ins. While waiting, I gave a try at using class decorators. Here's what I came up with: def add_methods(*m_list, **kwds): def wrapper(klass): for m_name in m_list: def templ

Re: Nimrod programming language

2009-05-11 Thread rumpf_a
On 10 Mai, 07:36, k...@fiber-space.de wrote: > On 8 Mai, 17:48, Andreas Rumpf wrote: > > > Dear Python-users, > > > I invented a new programming language called "Nimrod" that combines > > Python's readability with C's performance. Please check it > > out:http://force7.de/nimrod/ > > Any feedback

Re: How do I test the integrity of a Python installation in Debian and Ubuntu

2009-05-11 Thread Geoff Gardiner
Aahz wrote: > ... That seems to demonstrate that regrtest.py is indeed a good mechanism for > finding out whether it's a b0rked install! > I agree that regrtest.py looks a good mechanism. It just appears that `apt-get install python` on Debian and Ubuntu brings no tests with it. @Lawrence D'Ol

[silly] Re: issue with twisted and reactor. Can't stop reactor

2009-05-11 Thread Tim Harig
On 2009-05-11, Gabriel wrote: > Subject: issue with twisted and reactor. Can't stop reactor Not having written anything using twisted I cannot help you much with your code; but, I cannot resist commenting about your subject line: I suspect that if are having an issue with your reactor after bein

Re: sqlite single transaction without foreign key or triggers

2009-05-11 Thread Rob Williscroft
gert wrote in news:d7591495-4661-4243-ad7e-f142d8244e88 @e24g2000vbe.googlegroups.com in comp.lang.python: > I am trying to do this in a single transaction, the 3 separate > statements work fine, but i am screwed if they are not executed > together. Well you're in luck, Python DBAPI 2 connections

Re: How to replace constructor with factory method

2009-05-11 Thread Chris Rebert
On Mon, May 11, 2009 at 1:39 PM, wrote: > Hi, > > Just wonder if it's possible in Python. > > what I want is to tweak an existing Python class A with no > constructor, so that A() results in fuctory method call? > > so o = A() instead being equivalent to: > > s = object() > A.__init__(s) > o = s

Re: Fill Javascript form

2009-05-11 Thread Shawn Milochik
How is the form "written in JavaScript"? Is it dynamically generated? In any case, can you just send a POST request if you know the values required? -- http://mail.python.org/mailman/listinfo/python-list

Re: Your Favorite Python Book

2009-05-11 Thread Shawn Milochik
It depends on what you want to do. If you still want to beef up on general knowledge, maybe skim through "The Python Cookbook" or something reference-like. If you feel ready to start doing something with Python, look into one of the recent titles that applies Python for a specific purpose. Example

Your Favorite Python Book

2009-05-11 Thread Sam Tregar
Greetings. I'm working on learning Python and I'm looking for good books to read. I'm almost done with Dive into Python and I liked it a lot. I found Programming Python a little dry the last time I looked at it, but I'm more motivated now so I might return to it. What's your favorite? Why? -sa

issue with twisted and reactor. Can't stop reactor

2009-05-11 Thread Gabriel
Hello all!, I'm trying to implement a simple one way communication using twisted. Sender: > send message > close connection Receiver: > receive > do something > wait for other message I'm testing with this simple examples: Sender: [code] class SenderClient(protocol.Protocol): def __init__(

How to replace constructor with factory method

2009-05-11 Thread rogeeff
Hi, Just wonder if it's possible in Python. what I want is to tweak an existing Python class A with no constructor, so that A() results in fuctory method call? so o = A() instead being equivalent to: s = object() A.__init__(s) o = s becomes: o = my_factory_function( A ) Thanks, Gennadiy --

Fill Javascript form

2009-05-11 Thread Matteo
Hi everybody, I have to fill a web form to authenticate and connect to the internet. I thought it would have been easy to make a script to do that automatically on startup. Unfortunately, it turned out that the form is written in JavaScript, and urllib2 therefore fails to even fetch the form. The

Re: OOP & Abstract Classes

2009-05-11 Thread Adam Gaskins
Wow, thanks Nick! This is just what I was looking for! Thanks to Peter as well. And as for your suggestion that I probably shouldn't mess with things I don't understand and learn the basics first... well, that is probably sound advice, but I figured out years ago that I learn things best by a)

Re: how to consume .NET webservice

2009-05-11 Thread Mike Driscoll
On May 11, 3:09 pm, "bav" wrote: > question from a python newbie; > >   how can i consume in python language, a .NET web service, passing >   a string array as parameter in some easy steps? > > best regards You're being pretty vague here. Try using Google first...I got plenty of hits with "python

Re: how to consume .NET webservice

2009-05-11 Thread namekuseijin
bav escreveu: question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? Unless Microsoft extended the standard in any way, then it should be just as you consume any web service, I guess. ;) -- a game

how to consume .NET webservice

2009-05-11 Thread bav
question from a python newbie; how can i consume in python language, a .NET web service, passing a string array as parameter in some easy steps? best regards -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Pygame with Python

2009-05-11 Thread Mike Driscoll
On May 11, 2:54 pm, cripplem...@gmail.com wrote: > Hi. I would just like to know which of the versions of python and > pygame would be best to download for use together. I am a windows xp > user. Look at the pygame website to see what the newest version of Python it supports and go with that unles

Re: Writing text to a Word Document

2009-05-11 Thread Mike Driscoll
On May 11, 11:27 am, gazath...@gmail.com wrote: > Hi everyone, > > I am trying to write several attributes from a database table and > using the code below I can write the values however it is only > overwriting on the first line. > > I am new to the win32com bit and I would like to know what is th

Using Pygame with Python

2009-05-11 Thread cripplemeal
Hi. I would just like to know which of the versions of python and pygame would be best to download for use together. I am a windows xp user. -- http://mail.python.org/mailman/listinfo/python-list

Re: Wrapping comments

2009-05-11 Thread Simon Brunning
2009/5/10 Tobias Weber : > (still not gonna use software that doesn't let me type # because it's > alt+3 on a UK layout; having to re-learn or configure that is just sick) To use Aquamacs with a UK keyboard, you want to select Options, Option Key, Meta & British. Things just work then. -- Cheers

Re: OOP & Abstract Classes

2009-05-11 Thread Peter Otten
Adam Gaskins wrote: > So I was beginning to learn OOP for PHP, and it seemed to me that abstract > classes were just right for my application. In my application I must > communicate with several peices of test equipment that communicate via > RS-232. Most use SCPI instructions, some do not and req

Re: Wrapping comments

2009-05-11 Thread MRAB
norseman wrote: Tobias Weber wrote: Hi, the guideline (PEP 8) is hard wrap to 7x characters. The reason given is that soft wrap makes code illegible. So what if you hard wrap code but let comments and docstrings soft-wrap? Otherwise it's hugely annoying to edit them. Say you remove the first

Re: OOP & Abstract Classes

2009-05-11 Thread Nick Craig-Wood
Adam Gaskins wrote: > I am a fairly seasoned PHP developer (don't shoot, I'm changing teams!:) who > is admittedly behind the curve with OOP. Like most who learned PHP, I > started doing web app backend stuff, but I have moved to full blown windows > apps in the last 6 months using Winbinde

Re: Can I get a value's name

2009-05-11 Thread John O'Hagan
On Mon, 11 May 2009, jalanb3 wrote: [...] > > def replace_line(pattern,replacement): > errors = '\n' in pattern and [ 'pattern' ] or [] > errors += '\n' in replacement and [ 'replacement' ] or [] > values = [ locals()[e] for e in errors ] > # etc, etc, and eventually: > print

creating classes with mix-ins

2009-05-11 Thread samwyse
I'm writing a class that derives it's functionality from mix-ins. Here's the code: def boilerplate(what): # This used to be a decorator, but all of the ##what = f.__name__ # function bodies turned out to be 'pass'. 'Validate the user, then call the appropriate plug-in.'

sqlite single transaction without foreign key or triggers

2009-05-11 Thread gert
I am trying to do this in a single transaction, the 3 separate statements work fine, but i am screwed if they are not executed together. ### db.execute('BEGIN') # db.execute('UPDATE users SET uid=? WHERE uid=?',(v['uid'],s.UID)) db.execute('UPDATE sessions SET uid=? WHERE si

Re: Can I get a value's name

2009-05-11 Thread Scott David Daniels
jalanb3 wrote: ... Given a variable name I can use locals() to get the value Is there a way to do it the other way round Given the value, can I get the variable name ? (1) Yes you can in some cases. (2) You should not, things do not inherently have a name. With that prelude: de

Re: OOP & Abstract Classes

2009-05-11 Thread Adam Gaskins
Any idea why I didn't see this reply on my ng? I only see the reply from Marco. Can't help but wonder if there is more that is not getting through here. Would someone mind forwarding me any other replies? FWIW I'm using news.east.cox.net. Thanks, -Adam > Mike Driscoll wrote: > >> I've never u

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Peter Otten
Mikael Olofsson wrote: > Duncan Booth wrote: > >> The __get__ method should be returning a new object, NOT modifying the >> state of the decorator. As written it will break badly and unexpectedly >> in a variety of situations: >> >> [snip good examples of things going bad] > > Ouch! So, does th

Re: list comprehension question

2009-05-11 Thread J Kenneth King
Steven D'Aprano writes: > On Thu, 07 May 2009 13:28:10 -0400, J Kenneth King wrote: > >> Steven D'Aprano writes: >> >>> On Wed, 06 May 2009 09:48:51 -0400, J Kenneth King wrote: >>> Emile van Sebille writes: > On 5/5/2009 9:15 AM J Kenneth King said... > >> List comprehe

Writing text to a Word Document

2009-05-11 Thread gazathome
Hi everyone, I am trying to write several attributes from a database table and using the code below I can write the values however it is only overwriting on the first line. I am new to the win32com bit and I would like to know what is the recommended reference to loop down the page and add multip

Re: How to debug this import problem?

2009-05-11 Thread Iwan
Mmm, we solved half of the cause of this one. Test runs are kicked off via setuptools's test command. But this happens programmatically, and successively in one process. But setuptools's test command clears all modules imported during a test run from sys.modules - hence it is intended that module

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Mikael Olofsson
Duncan Booth wrote: The __get__ method should be returning a new object, NOT modifying the state of the decorator. As written it will break badly and unexpectedly in a variety of situations: [snip good examples of things going bad] Ouch! So, does that mean that George's solution based on a

Re: OOP & Abstract Classes

2009-05-11 Thread Marco Mariani
Mike Driscoll wrote: I've never used (or heard of) the Abstract type...and the guy who wrote the FAQ was being a jerk. Who, Peter Norvig? (from wikipedia) Peter Norvig is an American computer scientist. He is currently the Director of Research (formerly Director of Search Quality) at Google

Re: mod_python and xml.dom.minidom

2009-05-11 Thread dpapathanasiou
For the record, and in case anyone else runs into this particular problem, here's how resolved it. My original xml_utils.py was written this way: from xml.dom import minidom def parse_item_attribute (item, attribute_name): item_doc = minidom.parseString(item) ... That version worked und

Re: OOP & Abstract Classes

2009-05-11 Thread Ulrich Eckhardt
Adam Gaskins wrote: > Long story short, I'm tired of doing things in such a hackish manner > and want to write applications that are cross platform (I'd like to > get our production dept on linux eventually) and truely object > oriented. Adam, there is one notion here that I seriously dislike: yo

Re: OOP & Abstract Classes

2009-05-11 Thread Mike Driscoll
On May 11, 9:53 am, "Adam Gaskins" wrote: > Hi all, > > -- Non critical info-- > I am a fairly seasoned PHP developer (don't shoot, I'm changing teams!:) who > is admittedly behind the curve with OOP. Like most who learned PHP, I > started doing web app backend stuff, but I have moved to full blow

Re: How do I test the integrity of a Python installation in Debian and Ubuntu

2009-05-11 Thread Aahz
In article , Geoff Gardiner wrote: >Aahz wrote: >> >> What directory are you running this from? What happens if you switch to >> running "python Lib/test/regrtest.py"? Taking a closer look, this looks >> more like a plain import error. > >I couldn't do quite that because there's no Lib, but in

Re: What's the use of the else in try/except/else?

2009-05-11 Thread kj
In Scott David Daniels writes: >kj wrote: >> ... I can't come with an example in which the same couldn't be >> accomplished with >> >> try: >> # do something >> # do something else >> except ...: >> # handle exception >> >> The only significant difference I can come up with is th

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Duncan Booth
Mikael Olofsson wrote: > George Sakkis decorator function solution seems to work equally well for > functions and methods. However, I prefer the cleaner encapsulation given > by a class. Based on those observations, I think I will use the > following approach: > > >>> class test_decorator(o

Re: stand alone exec

2009-05-11 Thread Pascal Chambon
Hello It sounds indeed like a runtime library problem... You should run a dependancy finder (like dependency walker - http://www.dependencywalker.com/) on your executable, and thus see what might be lacking on other systems. I know that on *nix systems there are tools to see more precisely wha

Re: unicode bit me

2009-05-11 Thread norseman
Steven D'Aprano wrote: On Fri, 08 May 2009 14:22:32 -0400, Terry Reedy wrote: Scott David Daniels wrote: It would be a bit easier if people would bother to mention their Python version, as we regularly get questions from people running 2.3, 2.4, 2.5, 2.6, 2.7a, 3.0, and 3.1b. They run comput

Re: Wrapping comments

2009-05-11 Thread norseman
Tobias Weber wrote: Hi, the guideline (PEP 8) is hard wrap to 7x characters. The reason given is that soft wrap makes code illegible. So what if you hard wrap code but let comments and docstrings soft-wrap? Otherwise it's hugely annoying to edit them. Say you remove the first three words of

Re: Complete frustration

2009-05-11 Thread norseman
hellcats wrote: I have Python2.5 installed on Windows XP. Whenever I double click on a something.pyw file, IDLE launches and opens something.pyw in the editor. I would prefer to actually *RUN* the program, not edit it. If I want to edit it then I'll choose the "Edit with IDLE" context menu. So I

Re: [Python-Dev] .pth files are evil

2009-05-11 Thread P.J. Eby
At 04:42 PM 5/9/2009 +0200, Martin v. Löwis wrote: >> If you always use --single-version-externally-managed with easy_install, >> it will stop editing .pth files on installation. > > It's --multi-version (-m) that does that. > --single-version-externally-managed is a "setup.py install" option. >

Can I get a value's name

2009-05-11 Thread jalanb3
Context for this question arises from some recent code. In particular the "replace_line" method, which takes in a regexp to look for, and a replacement for when it matches. It is supposed to work for single lines only (we add ^ and $ to the regexp), so arguments which have '\n' in them are not

Re: mod_python and xml.dom.minidom

2009-05-11 Thread dpapathanasiou
> His problem is therefore likely to be something completely different. You are correct. As per the earlier advice, I switched from mod_python to mod_wsgi but I still see the same error: [Mon May 11 10:30:21 2009] [notice] Apache/2.2.11 (Unix) mod_wsgi/2.4 Python/2.5.2 configured -- resuming no

Re: win32 How to make sure a file is completely written?

2009-05-11 Thread justind
On May 11, 10:03 am, Tim Golden wrote: > justind wrote: > > Hello, > > > I'm usinghttp://code.activestate.com/recipes/156178/to watch a > > folder in windows. > > Wow, that takes me back. There's a bit more info (and a different > technique) here if you're interested: > >  http://timgolden.me.uk/p

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Mikael Olofsson
George Sakkis wrote: Yes, just return an actual function from the decorator instead of a callable object: def test_decorator2(func): def wrapper(*args): print 'Decorator2:', args func(*args) return wrapper class cls(object): @test_decorator def meth(self,*args):

Re: Decorating methods - where do my arguments go?

2009-05-11 Thread Mikael Olofsson
Peter Otten wrote: You have to turn your decorator into a descriptor by providing a __get__() method. A primitive example: class test_decorator(object): def __init__(self,func): self._func = func def __call__(self, *args): print 'Decorator:', args self._func(self

Re: win32 How to make sure a file is completely written?

2009-05-11 Thread Tim Golden
justind wrote: Hello, I'm using http://code.activestate.com/recipes/156178/ to watch a folder in windows. Wow, that takes me back. There's a bit more info (and a different technique) here if you're interested: http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html Bu

Re: win32 How to make sure a file is completely written?

2009-05-11 Thread ma
You have to wait until IO is ready. In Unix, we accomplish this with fcntl and the default signal SIGIO, I am not sure how you would do this in Windows. On Mon, May 11, 2009 at 9:51 AM, justind wrote: > Hello, > > I'm using http://code.activestate.com/recipes/156178/ to watch a > folder in windo

  1   2   >