Re: For_loops hurt my brain.

2008-07-16 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: This script uses a simple for loop to zip some files. However I am repeating code that cries out for a nested loop. Cries out for a *function*, I'd say. My two lists of files_to_be_zipped (spare and seekfacts) are of > uneven length so I can't seem to decipher the "

Re: Is there any component-oriented (non-MVC) web framework available for Python?

2008-07-16 Thread Sebastian "lunar" Wiesner
Alis <[EMAIL PROTECTED]>: > Is there any component-oriented (non-MVC) web framework available for > Python? > > That is something like Apache Wicket, Tapestry or JSF, but I need it > to be in Python. Zope [1] might be worth trying. [1] http://www.zope.org -- Freedom is always the freedom of d

Re: how to match whole word

2008-07-16 Thread John S
On Jul 16, 9:38 am, Peng Yu <[EMAIL PROTECTED]> wrote: > On Jul 15, 10:29 pm, Gary Herron <[EMAIL PROTECTED]> wrote: > > > > > Peng Yu wrote: > > > Hi, > > > > The following code snippet is from /usr/bin/rpl. I would like the it > > > to match a word, for example, "abc" in ":abc:". But the current

Re: how to match whole word

2008-07-16 Thread Fredrik Lundh
John S wrote: > Not sure why you picked \A and \Z -- they are only useful if you are > using the re.M flag. Well, they're aliases for ^ and $ in "normal" mode, at least for strings that don't end with a newline. re.I is the same as re.IGNORECASE. More than one option may be OR'ed together. T

Re: py2exe issues with pictures and icons

2008-07-16 Thread Mike Driscoll
On Jul 16, 3:22 pm, Alexnb <[EMAIL PROTECTED]> wrote: > Alexnb wrote: > > > Mike Driscoll wrote: > > >> On Jul 16, 1:37 pm, Alexnb <[EMAIL PROTECTED]> wrote: > >>> Hello > > >>> I am sure most of you are familiar with py2exe. I am having a bit of a > >>> problem. See the program has a few pictures

Having trouble with some lists in BeautifulSoup

2008-07-16 Thread Alexnb
Okay, what I want to do with this code is to got to thesaurus.reference.com and then search for a word and get the syns for it. Now, I can get the syns, but they are still in html form and some are hyperlinks. But I can't get the contents out. I am not that familiar with BeautifulSoup. So if anyon

Re: Setting Message Importance using SMTP Mail

2008-07-16 Thread MRAB
On Jul 16, 4:42 pm, Whyatt <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm trying to create a message using SMTP Mail through Python with a > message Importance of either 0 (Low) or 2 (High). > > If I do outer.Add_header('Importance', '0') it is ignored. > > If I do uter.Replace_header('Importance', '

Re: One step up from str.split()

2008-07-16 Thread Matimus
On Jul 15, 4:28 pm, "Joel Koltner" <[EMAIL PROTECTED]> wrote: > "Sion Arrowsmith" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > What's wrong with sys.argv ? > > Mainly that it doesn't exist.  :-)  The example was slightly contrived -- I'm > really dealing with commands inter

singletons

2008-07-16 Thread Craig Allen
Hey, forgive me for just diving in, but I have a question I was thinking of asking on another list but it really is a general question so let me ask it here. It's about how to approach making singletons. Background: I've been programming in python seriously for about a year now, maybe a little lon

Re: python's YENC.DECODE -> weird output

2008-07-16 Thread John Machin
On Jul 16, 11:33 pm, John Savage <[EMAIL PROTECTED]> wrote: > I save posts from a midi music newsgroup, some are encoded with > yenc encoding. This gave me an opportunity to try out the decoders > in Python. The UU decoder works okay, but my YENC effort gives > results unexpected: > > import ye

Re: For_loops hurt my brain.

2008-07-16 Thread mizhi
Other possibility, combining Dan and Fredrik's posts: import zipfile import os zips = { 'c:/spare.zip': ['c:/spare/huge.fm3', 'c:/spare/huge.wk3'], 'c:/seekfacts.zip': ['c:/seekfacts/bookmark.html', 'c:/seekfacts/ index.htm', 'c:/seekfacts/seek.css', 'c:/seekfacts/seek.js'] }; def z

Re: Framework recommendations for web service?

2008-07-16 Thread Massimo Di Pierro
web2py (not to be confused with web.py although both of them are excellent) comes with XMLRPC, XML, JSON and RSS API. You can find an XMLRPC example here: http://mdp.cti.depaul.edu/examples/default/examples#xmlrpc_examples The web2py source (including the optional web based interface) fits

python doc in command line

2008-07-16 Thread Peng Yu
Hi, Perl has a command line help perldoc. I'm wondering if python has a similar help command. Thanks, Peng -- http://mail.python.org/mailman/listinfo/python-list

Re: python doc in command line

2008-07-16 Thread Fredrik Lundh
Peng Yu wrote: Perl has a command line help perldoc. I'm wondering if python has a similar help command. it's built into the interpreter, and Python tells you how to use it when you start Python in interactive mode. $ python Python 2.5.1 Type "help", "copyright", "credits" or "license" for

Re: python doc in command line

2008-07-16 Thread Ben Finney
Peng Yu <[EMAIL PROTECTED]> writes: > Perl has a command line help perldoc. I'm wondering if python has a > similar help command. The interactive interpreter has a "help" command, and a corresponding "help" function which can be passed an object to display its docstrings recursively and nicely-fo

Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
I've done a lot of web searching, a fair bit of C-source reading, and quite a lot of miscellaneous head scratching, and I find that I am not necessarily closer to an ideal solution. I have a Python/C interface layer that essentially does the following: Py_XDECREF (some_callback); closeService (so

Re: Manually prompting garbage collection

2008-07-16 Thread Fredrik Lundh
Kyle Lanclos wrote: I want to modify the above sequence to manually prompt Python's garbage collection routine(s) to take over (performance is not an issue here), similar to the following: Py_XDECREF (some_callback); PyCollect_Garbage (); closeService (some_service); return; Is that possible?

Re: isPrime works but UnBoundLocalError when mapping on list

2008-07-16 Thread Terry Reedy
Andreas Tawn wrote: Terry Reedy wrote: For loop variables continue after the loop exits. This is intentional. I never knew that and I can't find reference to it in the docs. Can you help me with the reasons for it? 1. Python's reluctance to multiply scopes without necessity (as other re

Re: python's YENC.DECODE -> weird output

2008-07-16 Thread Terry Reedy
John Savage wrote: I save posts from a midi music newsgroup, some are encoded with yenc encoding. This gave me an opportunity to try out the decoders in Python. The UU decoder works okay, but my YENC effort gives results unexpected: import yenc, sys fd1=open(sys.argv[1],'r') #y

Re: Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
Fredrik Lundh wrote: > what magic do you expect the "manual garbage collection" to do here that > the DECREF doesn't already do? The DECREF decrements the reference count, but does not immediately prompt garbage collection when the reference count drops to zero; that garbage collection does not a

Re: Custom 'Float' class. Am I right here?

2008-07-16 Thread Terry Reedy
Prashant Saxena wrote: import sys class Float(float): """ Custom float datatype with addtional attributes. """ def __new__(self, value=0.0, #default value name='', # string & nbsp; range=(0.0, 1.0) # tuple

Re: singletons

2008-07-16 Thread castironpi
On Jul 16, 5:20 pm, Craig Allen <[EMAIL PROTECTED]> wrote: > Hey, forgive me for just diving in, but I have a question I was > thinking of asking on another list but it really is a general question > so let me ask it here.  It's about how to approach making singletons. > Background: I've been progr

Re: Manually prompting garbage collection

2008-07-16 Thread Fredrik Lundh
Kyle Lanclos wrote: The DECREF decrements the reference count, but does not immediately prompt garbage collection when the reference count drops to zero; that garbage collection does not appear to occur until I return from the particular C function I am in the middle of executing. Yeah, but wh

Re: Manually prompting garbage collection

2008-07-16 Thread Fredrik Lundh
Fredrik Lundh wrote: > Do these objects have direct references to a resource that you're > explicitly destroying from your C code? and yes, if this is the problem, the correct solution is to create an separate object type that's designed to manages the resource and act as a proxy against it, a

Re: About wmi

2008-07-16 Thread patrol
On 7月17日, 上午3时20分, Tim Golden <[EMAIL PROTECTED]> wrote: > patrol wrote: > > On 7月17日, 上午12时16分, Tim Golden <[EMAIL PROTECTED]> wrote: > >> Assuming that the error comes back in the sys.stdout encoding, the > >> following version *should* work ok. I still haven't got a non-English set > >> up to

Re: About wmi

2008-07-16 Thread patrol
I will try to modify the wmi.py ,however I'm a novice.It will take a long time. You can give it up temporarily. If you don't mind ,can you tell me where needs modifying and how? Just unicode? Or Other? -- http://mail.python.org/mailman/listinfo/python-list

Re: singletons

2008-07-16 Thread Craig Allen
I don't intend to do much subclassing of this, but of course, I'd rather not second guess the future and it's not hard to imagine we will come to some point that we need to do just that. Thanks for the ideas about repairing option one, which I'd given up, though the ideal is still that tl = TehLi

Re: Manually prompting garbage collection

2008-07-16 Thread Kyle Lanclos
Fredrik Lundh wrote: > Yeah, but what do you expect that garbage collection pass to result in? Basically, I want to toss the objects before I close the service that they depend on. > PyGC_Collect() does exactly that, so if that doesn't solve your problem, > the only way to fix is this is to go b

how to debug python's extend module written in c/c++ on windows

2008-07-16 Thread tcfg
dear all: I have searched the debug informations of many python's IDE, but I cannot find the method about debuging the extend module written in Visual studio 2008 on windows. The wingIDE tell me that we can debug the extend module on linux, but cannot on windows. and using wingdbstub.py we can emb

wxpython: visual effects missing after py2exe

2008-07-16 Thread Leo Lee
Please take close look at the details of the two snapshots. I need explanation and correcting this problem. begin 666 after.png MB5!.1PT*&@[EMAIL PROTECTED];0```#-" ,```#GL'7)`7-21T(`KLX< MZ01G04U!``"[EMAIL PROTECTED]>B8``("[EMAIL PROTECTED]@``'4P M``#J8 [EMAIL PROTECTED]/ ```P!03%1%

Re: wxPython: How can I get window's HANDLE in wxPython.

2008-07-16 Thread Leo Lee
Thank you , Mike. "Mike Driscoll" <[EMAIL PROTECTED]> ??:[EMAIL PROTECTED] On Jul 2, 8:40 pm, "Leo Lee" <[EMAIL PROTECTED]> wrote: > I need a window's handle to be passed to external c++. > Thanks in advance Are you talking about a wxPython wx.Window object or an external window handle? If th

Re: Best Python packages?

2008-07-16 Thread Larry Bates
Ben Sizer wrote: Although the standard library in Python is great, there are undoubtedly some great packages available from 3rd parties, and I've encountered a few almost by accident. However, I don't know how a user would become aware of many of these. http://pypi.python.org/pypi/ presumably lis

Re: Framework recommendations for web service?

2008-07-16 Thread Larry Bates
Phillip B Oldham wrote: We're looking at the next phase of development for our webapp, and the main focus will be to move the core from the app to a web service so other systems can use the data we've gathered (we're thinking along the lines of the XML API of Highrise from 37Signals). Its possib

Re: py2exe issues with pictures and icons

2008-07-16 Thread Larry Bates
Alexnb wrote: Hello I am sure most of you are familiar with py2exe. I am having a bit of a problem. See the program has a few pictures involved and the .ico it uses for the windows. However, the pictures are stored in the same directory as the source, something like: C:\Docs and settings\me\My d

Re: wxpython: visual effects missing after py2exe

2008-07-16 Thread Leo Lee
Hi, I think I have already solved this problem while I am digging into the installation sources. I found this: C:\Python25\Lib\site-packages\py2exe\samples\singlefile\gui\setup.py # Requires wxPython. This sample demonstrates: # # - single file exe using wxPython as GUI. from distutils.core im

Re: singletons

2008-07-16 Thread Asun Friere
On Jul 17, 8:20 am, Craig Allen <[EMAIL PROTECTED]> wrote: > Is it pythonic? You probably can't get anymore pythonic than something written by the BDFL. In describing the use of __new__ in Unifying types and classes in Python 2.2 he gives this recipe for a Singleton. class Singleton(object):

Re: Amazon: "Practical Django Projects" by James Bennett (June 2008)

2008-07-16 Thread Stefan Scholl
Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Stefan Scholl wrote: > >> Django isn't ready. > > That's a remarkably ignorant statement. The 1.0 release will be in September. -- Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/ -- http://mail.python.org/mailman/listinfo/python-

Re: Amazon: "Practical Django Projects" by James Bennett (June 2008)

2008-07-16 Thread Marc 'BlackJack' Rintsch
On Thu, 17 Jul 2008 05:41:11 +0200, Stefan Scholl wrote: > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> Stefan Scholl wrote: >> >>> Django isn't ready. >> >> That's a remarkably ignorant statement. > > The 1.0 release will be in September. So what? It's not the version number that matters but

subtype and super method. How to?

2008-07-16 Thread Prashant Saxena
import sys class Attribute(object):     """     Common attributes and methods for custom types     """     __slots__ = []          def __init__(self, name=None, type=None, range=(0,1)):     self.__name = name     self.__type = type     self.__range = range          #Read only attribute

Re: singletons

2008-07-16 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Craig Allen wrote: > ... the ideal is still that > > tl = TehLibrary() would always return the same object. >> class TehLibrary(object) : ... @classmethod ... def __new__(self, cls) : ... return self >>> s = TehLibrary() >>> s == TehLibrary() True

Re: Converting from local -> UTC

2008-07-16 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Keith Hughitt wrote: > I have a UTC date (e.g. 2008-07-11 00:00:00). I would like to create a > UTC date ... >>> import calendar >>> calendar.timegm((2008, 7, 11, 0, 0, 0, 0, 0, -1)) 1215734400 [EMAIL PROTECTED]> TZ=NZ date -d "00:00:00 01-Jan-1970Z +1215734400 s

Re: Best Python packages?

2008-07-16 Thread Russ P.
On Jul 16, 7:16 am, Ben Sizer <[EMAIL PROTECTED]> wrote: > Although the standard library in Python is great, there are > undoubtedly some great packages available from 3rd parties, and I've > encountered a few almost by accident. However, I don't know how a user > would become aware of many of thes

Re: Problem with MySQLdb and mod_python

2008-07-16 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Cyril Bazin wrote: > But it seems, after many tests, that the script stops at the > instruction : "c.execute(requete)" What's the error message? This should be in Apache's error_log file. -- http://mail.python.org/mailman/listinfo/python-list

Re: fork after creating temporary file using NamedTemporaryFile

2008-07-16 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Sebastian "lunar" Wiesner wrote: > Relying on the destructor is *always* a bad idea, you should always > close files explicitly! There shouldn't be any problem with files opened read-only. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to debug python's extend module written in c/c++ on windows

2008-07-16 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb: dear all: I have searched the debug informations of many python's IDE, but I cannot find the method about debuging the extend module written in Visual studio 2008 on windows. The wingIDE tell me that we can debug the extend module on linux, but cannot on windows. and u

Need help getting BeautifulSoup contents

2008-07-16 Thread Alexnb
The trick to this one is that the html looks something like this: american, /browse/blue blue , /browse/brick brick , brie, cheddar, cheshire, /browse/churn churn , /browse/cottage cottage , /browse/cream cream , dunlop, and it goes on My question is I want everything inside, the conten

Re: Is there any component-oriented (non-MVC) web framework available for Python?

2008-07-16 Thread Diez B. Roggisch
Alis schrieb: Hi Is there any component-oriented (non-MVC) web framework available for Python? That is something like Apache Wicket, Tapestry or JSF, but I need it to be in Python. ToscaWidgets, can be used with any WSGI-compliant framework. Diez -- http://mail.python.org/mailman/listinfo/py

Re: how to debug python's extend module written in c/c++ on windows

2008-07-16 Thread tcfg
dear Diez: I need step into c function in extending module(DLL) when debugging the script. and I want Single-step debugging the extend module itself, but python script Launched The whole process. best regards fang -- http://mail.python.org/mailman/listinfo/python-list

Re: singletons

2008-07-16 Thread Carl Banks
On Jul 16, 6:20 pm, Craig Allen <[EMAIL PROTECTED]> wrote: > Anyone have any comments?  Is there anything wrong, evil, or ugly > about using a module this way, or am I correct to think that actually, > this is a common approach in python. > > Is it pythonic? The one drawback to this is that it co

Rotating a cube

2008-07-16 Thread J-Burns
Hello. Need some help here. I have a 4*4 cube. So the equation of the cube becoming: x + 4*y + 16*z Now i want to rotate this cube 90 degrees anticlockwise( a right rotation). How can i do that? The rotation must take place with the axis of rotation b

<    1   2