-1212' )
output = string.Template( 'My name is $NAME and my phone is $Phone.'
).safe_substitute( values )
Brilliant!! Using a custom dictionary solves my problem and gives me
some ideas on similar challenges.
Thank you!
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Take a look at "Text Processing In Python" by David Mertz. This book
doesn't cover all your requirements, but its a well-written book that is
more comprehensive than its title might indicate.
There's also a free version of this book online.
Malcolm
--
http://mail.python.
Dave,
Not the OP, but really enjoyed your analysis and solution. Excellent
job!!
Thank you!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
# ignore multiple blank lines
if not line and not lastLine:
pass
else:
output.append( line )
lastLine = line
return '\n'.join( output )
Regards,
Malcolm
--
http:/
Tim,
Sounds like an interesting project.
Have you considered using SnagIt to produce your screenshots?
www.TechSmith.com/SnagIt
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Stef,
Looks great!!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
>
> from itertools import izip, count
>
> def enumerate(iterable, start=0):
> return izip(count(start), iterable)
>
> >>> list(enumerate('spam', 1))
> [(1, 's'), (2, 'p'), (3, 'a'), (4, 'm')]
Brilliant!!
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Stef,
Take a look at what the dabo team has put together.
http://dabodev.com
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
> I'm trying to compress a string.
> E.g:
>
> "BBBC" -> "ABC"
Doesn't preserve order, but insures uniqueness:
line = "BBBC"
print ''.join( set( line ) )
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Shakir,
> I have thousands of records in MS Access database table, which records I
> am fetching using python script. One of the columns having string like
> '8 58-2155-58'
>
> Desired output: '858215558'
>
> I want to remove any spaces between string and
Mensanator,
>>> import os.path
>>> dl = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
>>> drives = ['%s:' % d for d in dl if os.path.exists('%s:' % d)]
>>> drives
Very clever!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
> appreciate somebody to join and put new views on this project
Send us a link to one of the sites with your code, eg.
http://python.pastebin.com
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
d
Pycover
http://www.geocities.com/drew_csillag/pycover.html
Thanks,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Ryan,
If you don't mind being Windows-only, there's another approach that I've
been working on. I use a WTL application to host the web browser, then
pass
the browser instance to a COM server written in Python, along with a COM
wrapper of the application window. This gives me the
could use a database in place of dictionaries, but I'm
looking for maximum performance.
The following page lists two 64 bit versions of Python for Windows:
http://www.python.org/download/releases/2.5.2/
For Win64-Itanium users: python-2.5.2.ia64.msi
For Win64-AMD64 users: python-2.5.2.amd64.
Dear List,
Thanks for everyone's feedback - excellent detail - all my questions
have been answered.
BTW: Roel was correct that I got confused over the AMD and Intel naming
conventions regarding the 64 bit versions of Python for Windows. (I
missed that nuance that the Intel build refered t
are too big for my workstation's 2G of RAM.
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
I'm looking for a version of Python for Blackberry mobile phones
- has anyone heard of such a thing? I've been googling this topic
without success.
Thanks,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
I understand that many portions of the string module are redundant with
the native methods of strings and will removed in Python 3.0. Makes
sense to me.
But what will happen to the portions of the string module that are not
covered by native string methods - like the following:
- string
Does Python 2.5.2's embedded SQLite support full text searching?
Any recommendations on a source where one can find out which SQLite
features are enabled/disabled in each release of Python? I'm trying to
figure out what's available in 2.5.2 as well as what to expect in 2.6
and
Is there an official list of all Python's ?
I'm learning Python and trying to get an idea of what
are available and specifically, what
are used by each native Python data type?
Thanks!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Hrvoje,
>> Is there an official list of all Python's ?
> http://docs.python.org/ref/specialnames.html
Wonderful!! Thank you very much.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
While reading feedback to my post "Does Python 2.5.2's embedded SQLite
support full text searching?" I noticed that there appears to be some
confusion regarding whether Python 2.5 includes the SQLite engine.
My Windows 2.5.2 binary download includes SQLite.
But other posters clai
d be an iterator(?) type
object that tracked file names and line numbers as it returns individual
lines.
Is there a Python parsing library to handle this type of task or am I
better off writing my own?
The effort to write one from scratch doesn't seem too difficult (minus
recursive file and c
name] = value
else:
yield define_regexp.sub(define_repl, line)
It would be easy to modify it to keep track of line numbers and file
names.
--
http://mail.python.org/mailman/listinfo/python-list
lue
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
ace all my functions in dictionary and lookup the function to be
called
Any suggestions on the "best" way to do this?
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
(vs. a for-loop) that manually calls my file/stream
iterator/generator's .next() method while manually handling the
StopIteration exception. Doesn't sound too elegant.
Is there a Pythonic design pattern/best practice that I can apply here?
Thank you,
Malcolm
--
http://mail.python.org/mai
George,
> Is there an elegant way to unget a line when reading from a file/stream
> iterator/generator?
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502304
That's exactly what I was looking for!
For those following this thread, the above recipe creates a generic
object
Bruno,
Thank you for your detailed analysis. I learned a lot about Python
reading everyone's responses.
For development I'm using #5: "globals().get("func")" because its
seamless to add additional functionality.
But when I release into production I'm
Duncan,
> If speed is an issue then it may be better to avoid the test altogether ...
>
Thanks for your suggestion.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Hi Max,
Thank you for pointing out the pattern of my request.
Using your google query
(http://www.google.dk/search?hl=en&q=python+factory+pattern) I found the
following description of what I'm doing.
Command Dispatch Pattern
http://www.suttoncourtenay.org.uk/duncan/accu/pythonpatterns.
func
return func
@register
def foo(): print "Foo!"
@register
def bar(): print "Bar!"
>>> functions
{'foo': , 'bar': }
>>> functions['bar']()
Bar!
--
http://mail.python.org/mailman/listinfo/python-list
Erik,
> Perhaps I missed something earlier in the thread, but I really don't see the
> need for that registry dict or the register decorator. Python already
maintains a dictionary for each scope:
The advantage of the decorator technique is that you explicitly declare
which fu
o you plan on posting your next update?
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Bad file names, i.e. filenames the OS considers illegal, will cause
functions in the os.path module to raise an error.
Example:
import os.path
print os.path.getsize( 'c:/pytest/*.py' )
On Windows XP using Python 2.5.2 I get the following traceback:
Traceback (most recent call las
omfortable with a browser based interface as well.
I'm looking for feedback from anyone that has pondered the same question
as well as any pros/cons or tips from anyone that has chosen the
browser/lcoal web server route.
Thanks,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
d. I'm looking forward to hearing what others say on
this topic.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
d. I'm looking forward to hearing what others say on
this topic.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Matimus and John,
Thank you both for your feedback.
Matimus: I agree with your analysis. I blame lack of caffeine for my
original post :)
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
James,
Check out the optparse module as well. The optparse module supercedes(?)
the cmd module and offers a lot more functionality.
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
on.org/mailman/listinfo/python-list
rsing rules for each
level's label type, separators, and error checking. If there's an
existing, road tested class (with unit tests) that does this, I would
rather avoid re-inventing/re-testing the wheel.
Thanks,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Pistacchio,
Templite
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496702
A light-weight (~40 lines), fully functional, general purpose templating
engine, allowing you to embed python code directly into your text. This
engine is suitable for any templating (not only HTML/XML), and is
very elegant approaches.
Its interesting to compare your two very different approaches. I will to
spend some more time studying your techniques before I choose a final
approach.
Thank you both again. I'm learning a lot of Python by studying your
examples! :)
Malcolm
--
http://mail.python.o
y the above lines ... ... are you
referencing formatter.py?
http://www.koders.com/python/fid4B7C6E1C20384FC7521414F46DF9DAA33DF2CA11.aspx
Thanks for your help on this - I'm learning a lot!
Malcolm
PS: "throw( up )" ... very funny! :)
--
http://mail.python.org/mailman/listinfo/python-list
Dennis,
> I was a touch bored in the last hour at work today so...
Thank you!!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
functions = {}
def register(func):
functions[func.__name__] = func
return func
@register
def foo(): print "Foo!"
@register
def bar(): print "Bar!"
>>> functions
{'foo': , 'bar': }
>>> functions['bar']()
Bar!
Thanks for your feedback,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Anyone have any benchmarks on the difference in performance between 32
and 64 bit versions of Python for specific categories of operation, eg.
math, file, string, etc. operations?
My question is OS neutral so feel free to share your experience with
either Windows or Linux OS's.
Than
uot; in a shell...
thanks in advance,
Arno
--
http://mail.python.org/mailman/listinfo/python-list
On 7 sep 2008, at 00:25, John Machin wrote:
On Sep 7, 8:03 am, Python <[EMAIL PROTECTED]> wrote:
Hi there,
I moved a few modules into the modules folder (on OSX: /opt/local/
lib/
python2.5/site-packages/).
They don't show up though when I start IDLE...
Is there a way to reload
On 7 sep 2008, at 13:50, Gabriel Genellina wrote:
En Sat, 06 Sep 2008 20:26:24 -0300, Python <[EMAIL PROTECTED]> escribió:
now one question came up, how do I make those path permanent?
i mean, sys.path.append( adds it for the current session,
yet when i logout of IDLE and start it agai
Hi there!
I'm trying to match the results of an md5 checksum done in a tcsh shell.
I keep getting different results and can't find anything on google...
here's an example:
[EMAIL PROTECTED]:~% echo "hello" | md5
b1946ac92492d2347c6235b4d2611184
[EMAIL PROTECTED]:~%
On 10 sep 2008, at 18:34, Fredrik Lundh wrote:
Python wrote:
I'm trying to match the results of an md5 checksum done in a tcsh
shell.
I keep getting different results and can't find anything on google...
here's an example:
[EMAIL PROTECTED]:~% ech
On 10 sep 2008, at 18:30, Richard Brodie wrote:
"Python" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
here's an example:
[EMAIL PROTECTED]:~% echo "hello" | md5
b1946ac92492d2347c6235b4d2611184
How do I get the same results?
Checksum the
On 10 sep 2008, at 19:39, Grant Edwards wrote:
On 2008-09-10, Wojtek Walczak <[EMAIL PROTECTED]> wrote:
On Wed, 10 Sep 2008 19:12:28 +0200, Python wrote:
[EMAIL PROTECTED]:~% echo "test" > test.txt
[EMAIL PROTECTED]:~% md5 test.txt
MD5 (test.txt) = d8e8fca2dc0f896fd7cb4cb
inal window into his
posting."
I did! I did!
my bad... i cut some crap from the path to make it a bit easier to read
but that was before the time i knew it was checksumming the
actual path in stead of the contents of the file.
So I figured it didn't matter...
;)
--
http://mail.python.org/mailman/listinfo/python-list
#x27;, 'C:\\Python25\\lib\\site-packages\\Numeric', 'C:\\Python25\
\lib\\site-packages\\PIL']
Now I have my personal programs in C:/Python25/Progs/
How do I add so that I can just do "import somefile" from anywhere in
that directory in the interpreter and it can l
script,
but some reason, that is a mystery to me, when you scale the window up.
the item2(sub) is getting blocked by a white box. Im not sure where
this box is coming from and not really sure how to get rid of it.
Im fairly new to python and even newer to wxPython, if Im going around
my head to
something with me hiding the second panel. Please help me out here
thanks
Attached is my two python scripts that im using
use the test.py to test
the PaintPanel script..import wx
class PaintPanel(wx.Panel):
def __init__(self, parent, id, sub = 0, *args, **kwds):
wx.Panel.__init__(self
I'm looking for a small, simple, fast, Python based web server
for a simple, client side application we're building. We don't
want to distrubute and support a "real" web server like Apache or
Tomcat or depend on the presence of local web server such as IIS.
The application
sure what caused the slowness you've experienced (... with running
> local versions of Python web servers)
Thanks to a past post by "Christoph Zwerschke" , I was
able to identify the problem.
Windows (XP, Vista, Windows 7) tries to do a IPV6 connection which times
out after
'm going to
re-examine this assumption and take another look at cherrypy.
Thanks for your help!
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Anyone know if CherryPy works with the 64-bit version of Python
2.6?
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Is there an os independent way to check if a python app is
running?
Goal: I have a server program based on cherrypy that I only want
to have running once. If a system administrator accidentally
attempts to run this program more than once, I would like the 2nd
instance of the program to detect
Simon,
> if True:
>print "I'm running."
>
> ;-)
LOL! Yes, I should of worded my original post better (meant to say "...
if a python app is already running".
Enjoyed your post anyway - I'm still laughing :)
Cheers,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
We're preparing to release a commercial software product based on
Python. When a customer reports problems with our software, we
would like to capture as much information about their environment
as possible while being respectful of privacy concerns. The info
we capture will be displayed t
Diez,
Thank you for your sample code. That was just what we were looking for.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Alex,
> one way is you can create a lock file, then when the program
start you check to see if this lock file exists.
Makes sense - thanks!
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
ate - won't work in our
specific case.
MRAB and Diez posted some excellent, cross platform approaches to
locking a resource.
Thanks for your feedback.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Does anyone have any recommendations on which version of the
MSVC?90.DLL's need to be distributed with a Python 2.6.4 PY2EXE (0.6.9)
based executable? (I assume I need just a matching pair of MSVCR90.DLL
and MSVCP90.DLL?)
My understanding is that I need to match the version of the DLL'
g/mailman/listinfo/python-list
> This is a new wsgi web server implemented in a single file.
> http://code.google.com/p/web2py/source/browse/gluon/sneaky.py
Thank you Massimo.
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
hat succeeds, then a server program is
> already running at that port, so he should exit.
Thank you for your tip - spot on!
Best regards,
Malcolm (OP for this thread)
--
http://mail.python.org/mailman/listinfo/python-list
th start at the same time, and each tries to
> connect, then both will fail, but you don't want both to start, either.
Thank you for pointing out that nuance.
Best regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
n' %
(retcode,))
This seems to work. My py2exe program will now run out of the box on a
bare-bones Windows XP install. (note: running 'vcredist_x86.exe /qu'
will uninstall the DLLs again)
I'm surprised that this technique works because the Python interpreter
itself needs to fin
Waldemar,
Thank your for sharing your technique - works great with 32-bit Python
2.6.4.
Has anyone tried this with a 64-bit version of Python?
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
I'm looking for the best practice way for a multi-threaded python web
server application to read/write to a shared file or a SQLite database.
What do I need to do (if anything) to make sure my writes to a regular
file on disk or to a SQLite database are atomic in nature when multiple
clients
David,
Try disabling your firewall software momentarily to see if that
makes a difference. IDLE uses a local port for inter-process
communication - you may need to configure your firewall to allow
IDLE's port usage.
To test whether Python itself has been properly installed, open
up a cmd p
tp://mail.python.org/mailman/listinfo/python-list
MRAB,
"MRAB" wrote:
> >>> import re
> >>> re.split(r'(\s+)', "Hello world!")
> ['Hello', ' ', 'world!']
That was exactly (EXACTLY!) the solution I was looking for.
Thank you!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
Looking for any recommendations on a Python module/package that
would allow me to submit small HTML Unicode documents to Google
and retrieve the translated results. Or is this the type of task
that one should use a urllib-like module and do manually?
Note: By small HTML Unicode documents I mean
We're currently writing a web application based on a threaded
python web server framework (cherrypy) and would like to
simultaneously support users from multiple locales.
The locale module doesn't appear to be thread safe. Are there 3rd
party libraries or modules that provide locale p
Does Python provide a way to format a string according to a
'picture' format?
For example, if I have a string '123456789' and want it formatted
like '(123)-45-(678)[9]', is there a module or function that will
allow me to do this or do I need to code this type of
tra
''.join( output )
# test cases
print picture("123456789", "(@@@)-@@-(@@@)[...@]")
print picture("123456789ABC", "(@@@)-@@-(@@@)[...@]")
print picture("1234", "(@@@)-@@-(@@@)[...@]")
print picture("123456789", "(@@@)-@@-(@@@)")
print picture("123456789", "(@@@)-@@-(@@@)[...@][@]")
Regards,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
56789ABC", "(@@@)-@@-(@@@)[...@]", pad_left=False)
print picture("1234", "(@@@)-@@-(@@@)[...@]", pad_left=False)
print picture("123456789", "(@@@)-@@-(@@@)", pad_left=False)
print picture("123456789", "(@@@)-@@-(@@@)[...@][@]",
pad_left=False)
That way you can specify your placeholder, your padding
character, and whether you want it to pad to the left or right.
--
http://mail.python.org/mailman/listinfo/python-list
needed to learn :)
Thanks again!
Malcolm
- Original message -
From: "Arnaud Delobelle"
To: python-list@python.org
Date: Wed, 10 Feb 2010 18:21:35 +
Subject: Re: Creating formatted output using picture strings
pyt...@bdurham.com writes:
> Original poster here.
>
&g
Is there any way to time out a regular expression in Python
2.6.4?
Motiviation: Our application allows users to enter regular
expressions as validation criteria. If a user enters a
pathological regular expression, we would like to timeout the
evaluation of this expression after a short period of
We're building a py2exe executable that may need to do some
dynamic module imports.
I'm looking for suggestions on how we can mechanically generate a
list of standard library modules/packages to make sure our build
has the full set of Python 2.6.4 libraries.
We're planning on cr
I'm looking for recommendations on a cloud based file storage
service with a Python API.
Would appreciate hearing feedback from anyone using Python to
interface to Amazon S3, RackSpace Cloud Files, Microsoft Azure,
Rsync.net, or other hosted file storage service. What services do
you recomme
about
regarding use of this function on Windows (XP or higher) or
Linux?
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
created these files.
2. As soon as my process terminates (voluntarily or involuntarily), the
temp file gets deleted.
But I want to make sure.
Thanks,
Mal
--
http://mail.python.org/mailman/listinfo/python-list
I just happened to look at a compiled Python 2.6.4 .PYC file in
an editor and noticed that the full path and file name of the
compiled module showed up in my .PYC file at least 10 different
times. Is there a reason for full vs. relative path names and why
does the module name need to be duplicated
d your list of OS specific behaviors were EXACTLY the
type of information I was looking for.
Thanks again!
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
I've read the documentation on compileall and tried using this
module directly.
Nowhere can I find how to specify to compileall that it should
create .pyo vs. .pyc files.
Goal: I would like to use the compileall.compile_dir() method to
generate -OO type .pyo files as part of a larger P
hon.org/mailman/listinfo/python-list
http://holdenweb.eventbrite.com/
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Is there technique to determine if threads are active in a Python
application?
The only technique I can think of is to check sys.modules for
thread and threading. But this will only show whether these
modules were imported - not whether there are actually background
threads running.
Motivation
alled - my
google-fu fails me. This was approx 1976 when Popular Science's ELF-1
with 256 bytes was quite a sensation.
Cheers,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
e explain this mystery to me?
Thank you,
Malcolm
--
http://mail.python.org/mailman/listinfo/python-list
301 - 400 of 4760 matches
Mail list logo