Hi. I have been experimenting with mmap recently. I determined how to
read and write properly from it and so search and replace on large
files. The problem I am having is with replaces that are larger than
the mmap. In this instance I need to
* rewind
* resize the mmap to accomodate the
to documentation for mmap if this is an issue for
OSX. I have vmware installed so might try on CentOS to see what
happens there. Many thanks
Regards,
David
On 5-Apr-09, at 11:34 AM, Philip Semanchuk wrote:
On Apr 5, 2009, at 10:28 AM, David Pratt wrote:
Hi. I have been experimenting
, then inserting the replacement text. Not quite as smooth
as doing a resize(), moving text and inserting if this had worked.
Regards,
David
On 5-Apr-09, at 11:34 AM, Philip Semanchuk wrote:
On Apr 5, 2009, at 10:28 AM, David Pratt wrote:
Hi. I have been experimenting with mmap recently. I determined
Hi. I have a circumstance where I have to search and replace a block
of text in a very large file. I have written some psuedo code to
locate the text and print the span of text to be removed and replaced
by new block. Can someone advise what to do to remove the text span
and insert with
Hi Aaron, this worked out fine. Using an ordered dict to subclass dict.
Many thanks.
David
On Jan 18, 2009, at 11:57 AM, Aaron Brady wrote:
On Jan 18, 9:52 am, David Pratt fairwinds...@gmail.com wrote:
Hi list. I use 'type' to generate classes but have a need to order
the attributes
Hi list. I use 'type' to generate classes but have a need to order
the attributes for the generated class. Of course a dict is not going
to maintain ordering. Is there any way to dynamically generate a
class with attributes in specific order?
my_new_class = type( 'MyNewClass',
if that works out. Many thanks.
Regards,
David
On Jan 18, 2009, at 11:57 AM, Aaron Brady wrote:
On Jan 18, 9:52 am, David Pratt fairwinds...@gmail.com wrote:
Hi list. I use 'type' to generate classes but have a need to order
the attributes for the generated class. Of course a dict is not going
Can someone tell me why 'new' has been deprecated in python 2.6 and
provide direction for code that uses new for the future.
I find new is invaluable for some forms of automation. I don't see a
replacement for python 3 either. Many thanks.
--
': 'An attribute', 'fuz': 'Another one'}
Test = new.classobj(
'Test', (FirstBase, SecondBase), attr)
class MyNewClass(Test):
pass
a = MyNewClass()
print a.foo, a.buz, a.fiz, type(a)
On Nov 29, 2008, at 1:04 PM, Michael Crute wrote:
On Sat, Nov 29, 2008 at 11:52 AM, David Pratt
Yeah, can just use types.ClassType instead of new.classobj, but still
wonder what happens when we get to python 3.
Regards,
David
On Nov 29, 2008, at 1:04 PM, Michael Crute wrote:
On Sat, Nov 29, 2008 at 11:52 AM, David Pratt
[EMAIL PROTECTED] wrote:
Can someone tell me why 'new' has been
Rob. Sweet! Many thanks.
Regards,
David
On Nov 29, 2008, at 1:46 PM, Rob Williscroft wrote:
David Pratt wrote in news:mailman.4664.1227980181.3487.python-
[EMAIL PROTECTED] in comp.lang.python:
import new
class FirstBase(object):
foo = 'bar'
biz = 'baz'
class SecondBase(object
Hey Christian. Many thanks for explanation. Clears that up :-)
Regards,
David
On Nov 29, 2008, at 1:52 PM, Christian Heimes wrote:
David Pratt wrote:
Hi Mike. Many thanks for your reply and thank you for reference.
I have code that looks like the following so initially looking at
what
Hi, just want to conditionally base a class on another if it can be
imported, otherwise base it on object. Does the following look ok
for this?
try:
import foo.bar
except ImportError:
MyBase = foo.bar.Baz
else:
MyBase = object
class Something(MyBase):
--
Hi. I am in the midst of preparing a package to convert between
various schemas including orms. The issue is I don't want django,
slqalchemy, storm, rdflib etc. as hard dependencies of the package.
Each module is a schema to schema conversion. As an example, I have
imports for sqlalchemy
works
fine.
The speed of this solution is slower than os.system. Would a queue of
some kind be needed to speed this up? Has anyone implemented something
like this? Many thanks.
Regards,
David
Matt Nordhoff wrote:
David Pratt wrote:
Hi. I am trying to replace a system call with a subprocess
Hi Matt. Many thanks. Sorry I had not seen your second post. I'll give
this a try and time the completion to compare the differences and post
back later today to show os.system, buffered imput and using a file
directly for stdout.
Regards,
David
Matt Nordhoff wrote:
David Pratt wrote:
Hi
and is essentially equivalent in
execution time to original call :-). This has got me smiling. Many
thanks Matt for your help, particularly working through the second
example that provided equivalent speed.
Regards,
David
David Pratt wrote:
Hi Matt. Many thanks. Sorry I had not seen your second post
Hi. I am trying to replace a system call with a subprocess call. I have
tried subprocess.Popen and subprocess.call with but have not been
successful. The command line would be:
svnadmin dump /my/repository svndump.db
This is what I am using currently:
os.system('svnadmin dump %s %s' %
I'd like to compile cProfile for python 2.4. Where can I get it to do
this? I realize it is part of python 2.5. Many thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Hi. I am on a PPC and have been getting the same undefined symbols
traceback when linking applications after compiling. A few weeks back I
posted on a problem to pythonmac-sig@python.org after attempting to
build mod_python, today its pylucene - same problem. I initially
shrugged off the
Hi. Is anyone aware of any code to create a list of dependent modules
for a python module. Ideally am looking for something with a method to
create a unique list of imported modules that excludes imports from the
module being analyzed. Many thanks.
Regards,
David
--
Hi skip. Many thanks for this. Exactly what I need :-)
Regards,
David
[EMAIL PROTECTED] wrote:
David Hi. Is anyone aware of any code to create a list of dependent
David modules for a python module.
modulefinder: http://docs.python.org/lib/module-modulefinder.html
Added to Python
Hi John. Thank you for the tips and the link. This is helpful. Many thanks.
Regards
David
A new-style class is one which inherits ultimately from the type that is
called object.
class NewStyleClass(object):
pass
class OldStyleClass():
pass
Docs are a bit u ...
See
better flexibility.
ie.
class Factory
def __init__(self, factory):
At this point I don't have self. Would super help me?
Regards,
David
Marco Giusti wrote:
On Fri, Jun 02, 2006 at 06:15:28PM -0300, David Pratt wrote:
Hi. I want to have different handlers to do perform
My apologies. What I meant to write was this
class Factory
def __init__(self, handler):
David Pratt wrote:
Hi Marco. Thanks for your reply. I am providing the handler with the
factory instance as I have shown. This is how my code currently works.
What I am trying to figure out
Desthuilliers wrote:
David Pratt a écrit :
Hi. I want to have different handlers to do perform logic. The problem
is the Handler requires an instance of the factory since it will use its
own methods in conjunction with methods of the factory.
Once I have got a Factory instance I can give it a new
Hi. I have code that currently depends on a particular package of a
framework. I have decided I want to create my own package because I have
made many changes and it is getting too difficult to maintain each time
I retrieve an updated version of the framework from svn.
The problem is, that
Hi Peter. I'd like to fix the imports, but this would impact the
portability of portions of the code that currently work with the
existing package from the framework.
This solution does the trick and allows me to create the package I want
using a good amount of new material. I don't have to
Hi Peter. Thank you for this warning. I'll document this in the code. I
plan on importing only from dependentpackage for portability. Also, much
in the framework relies upon it. This approach is primarily for
maintenance purposes and would also allow me to package the modified
dependentpackage
Hi Ben. I hadn't realize that walk was just giving the file name so the
join did the job just great. Many thanks for helping me out with this.
Regards,
David
Ben Cartwright wrote:
David Pratt wrote:
OSError: [Errno 2] No such file or directory: '.DS_Store'
Ah. You didn't mention
Hi. I'm trying to clean files for packaging on mac using os.path.walk
and want to clean the .DS_Store files that are hidden from view but
could end up in code that I produce.
# Clean mac .DS_Store
if current_file == '.DS_Store':
print 'a DS_Store item encountered'
' % current_file
# Clean mac .DS_Store
if current_file == '.DS_Store':
print 'a DS_Store item encountered'
os.remove(f)
Ben Cartwright wrote:
David Pratt wrote:
# Clean
with the files, I though I would do remove
while walking the folders instead. I can always go back to this but I am
hoping someone can advise a way of deleting a hidden file. I am admin
on the mac so permissions is not an issue.
Regards,
David
Ben Cartwright wrote:
David Pratt wrote:
Hi Ben
Hi jojoba. I work with wxPython too but cannot answer this question.
There is an active and friendly community of wxPython users on
[EMAIL PROTECTED]
Robin Dunn, the lead person behind wxPython and others provide excellent
advice and support on this list.
Regards,
David
jojoba wrote:
Hi
I
Hi. I am wanting to create a tree list result structure from a
dictionary to categorize results. The dictionary contains elements that
identify its parent. The levels of categorization is not fixed, so there
is a need for the code to be recursive to drill down to the lowest
level. I have
Hi Kenneth. Try SQLAlchemy.
Regards,
David
Kenneth McDonald wrote:
I need to do some data manipulation, and SQLite is a nice little
product for it, except of course that I'd need to write SQL. Are
there any good libraries out there that let one write (basic) queries
in a Pythonic
Hi Allan, Max, and bearophile
Many thanks for your replies to this. The number of levels can be deeper
than two for creating child, sibling relationships. This can lead to
futher nesting as shown in my sample result list (the result I am
attempting to acheive) which is reason that I believe
Hi Bengt! I have been banging my head on this one all day! This is
brilliant (and recursive through each level which is exactly what I was
trying to work out)! Only part I needed to modify is
else: return title to else: return [title]
I tell you, you've made my day! I was getting a bit
Hi. I am working through some tutorials on unicode and am hoping that
someone can help explain this for me. I am on mac platform using python
2.4.1 at the moment. I am experimenting with unicode with the 3/4 symbol.
I want to prepare strings for db storage that come from normal Windows
Hi Martin. Many thanks for your reply. What I am reall after, the
following accomplishes.
If you are looking for at the same time, perhaps this is also
interesting:
py unicode('\xbe', 'windows-1252').encode('utf-8')
'\xc2\xbe'
Your answer really helped quite a bit to clarify this for
Hi Erik. Thank you for your reply. The advice I has helped clarify this
for me.
Regards,
David
Erik Max Francis wrote:
David Pratt wrote:
This is not working for me. Can someone explain why. Many thanks.
Because '\xbe' isn't UTF-8 for the character you want, '\xc2\xbe' is, as
you
Hi Max. Many thanks for helping to realize where I was missing the point
and making this clearer.
Regards,
David
Max Erickson wrote:
The encoding argument to unicode() is used to specify the encoding of the
string that you want to translate into unicode. The interpreter stores
unicode as
Hi. I am creating a couple of small methods to help me manage time from
UTC as standard but I am getting strange results.
If I start with a datetime of 2005-12-12 14:30:00 in timezone
'America/Halifax'
and I want to turn this into a UTC representation.
from datetime import datetime
from
This is a lot less clumsy and can easily be used in a class which is
very nice!
Many thanks bruno and Rob E for this good advice.
Regards,
David
On Monday, December 5, 2005, at 05:31 AM, bruno at modulix wrote:
David Pratt wrote:
(snip)
Can someone advise a more efficient lookup when using
Hi. I like working with lists of dictionaries since order is preserved
in a list when I want order and the dictionaries make it explicit what
I have got inside them. I find this combination very useful for storing
constants especially. Generally I find myself either needing to
retrieve the
Hi. I am splitting a string on a non whitespace character. One or more
whitespace characters can be returned as items in the list. I do not
want the items in the list that are only whitespace (can be one or more
characters of whitespace) and plan to use string.strip on those items
that are
Hi Fredrik and Peter. Many thanks for this helpful advice :-) These
are very nice solutions and much better than what I had been
contemplating. Also thanks for heads up for changes with method. I am
still using 2.3 but will move to 2.4 as soon as this is formally
approved for use in Zope.
Hi Fredrik. Good to know. Many thanks for your replies.
Regards
David
On Saturday, November 26, 2005, at 12:27 PM, Fredrik Lundh wrote:
David Pratt wrote:
Also thanks for heads up for changes with method. I am
still using 2.3 but will move to 2.4 as soon as this is formally
approved
Hi Fredrik. Many thanks for your reply and for the tuple tip. The
cursor.fetchall returns a list of lists in this instance with each list
in the main list containing the field values. With the tip, I
simplified my code to:
vlist_dict = {}
record_count = 0
for record in cursor.fetchall():
Thanks Fredrik for your help. Really short and efficient - very nice!
Regards,
David
On Monday, November 14, 2005, at 12:12 PM, Fredrik Lundh wrote:
I meant to write
d = {}
for index, record in enumerate(cursor.fetchall()):
d[index+1] = tuple(record)
which can be shorted
Hi. I am interested in having results from a db query in the following form.
{1: (value0, value1, value2,), 2: (value0, value1, value2,), 3: (value0, value1, value2,)}
so I generate a dictionary of tuples (field values) dynamically so if I queried a table with five fields I would have five
Recently I have run into an issue with sqlite where I encode strings
going into sqlite3 as utf-8. I guess by default sqlite3 is converting
this to unicode since when I try to decode I get an attribute error
like this:
AttributeError: 'unicode' object has no attribute 'decode'
The code and
to recommend the use of one type over the other. If so, can
you explain the rationale for this choice. Many thanks.
Regards,
David
On Tuesday, November 8, 2005, at 04:49 PM, Jean-Paul Calderone wrote:
On Tue, 08 Nov 2005 16:27:25 -0400, David Pratt
[EMAIL PROTECTED] wrote:
Recently I have run
I am working with a text format that advises to strip any ascii control
characters (0 - 30) as part of parsing data and also the ascii pipe
character (124) from the data. I think many of these characters are
from a different time. Since I have never seen most of these characters
in text I am
','\e','\f','\n','\r','\t','\v','|'
Regards,
David
On Monday, October 17, 2005, at 06:04 AM, Steve Holden wrote:
David Pratt wrote:
I am working with a text format that advises to strip any ascii
control
characters (0 - 30) as part of parsing data and also the ascii pipe
character (124) from
characters, and check for SQL strings
in the data to prevent any stupid things from happening if someone
wanted to be malicious.
Regards,
David
On Monday, October 17, 2005, at 12:49 PM, Steve Holden wrote:
David Pratt wrote:
[about ord(), chr() and stripping control characters]
Many thanks
perform these other processes it should be uniform and then
it will go into database as unicode. I think this should be ok.
Regards,
David
On Monday, October 17, 2005, at 01:48 PM, Tony Nelson wrote:
In article [EMAIL PROTECTED],
David Pratt [EMAIL PROTECTED] wrote:
I am working with a text
Hi. I have had good success with CSV module but recently came across
problem with reading excel from Mac Office. The trouble is with line
endings. Instead of \r\n you have just \r and the file as a whole
appears as a single line. CSV coughs and provides this exception:
_csv.Error: newline
between a weak setting for exact word matches or a
strong setting that will filter spelling variations.
Well I know this thread is a
On Sunday, October 2, 2005, at 10:45 PM, Nigel Rowe wrote:
David Pratt wrote:
Hi. Is anyone aware of any python based unacceptable language filter
code
Hi. Is anyone aware of any python based unacceptable language filter
code to scan and detect bad language in text from uploads etc.
Many thanks.
David
--
http://mail.python.org/mailman/listinfo/python-list
Hi Steven. Thank you for your detailed response. The code will be
executed on a web server with limited memory so the desire to keep file
loading in check. I like the approach you have suggested to score to
give the best guess. It leaves it fairly modular in respect to how
detailed you want
. As it stands I am filtering mime types to
the importing process to attempt to limit the possibilities.
Regards,
David
On Friday, September 23, 2005, at 02:01 AM, Mike Meyer wrote:
David Pratt [EMAIL PROTECTED] writes:
Hi. I have files that I will be importing in at least four different
Hi Skip. Thank you for your reply. This is helpful and I am glad I put
this to the list. There are some really good ideas that will help me
come up with something good to use.
Regards,
David
On Friday, September 23, 2005, at 11:14 AM, [EMAIL PROTECTED] wrote:
David I realize CSV module
Thanks Mike this is really great!
Regards,
David
On Friday, September 23, 2005, at 11:55 AM, Mike Meyer wrote:
David Pratt [EMAIL PROTECTED] writes:
Thanks Mike for your reply. I am not aware of libmagic and will look
to see what it provides.
and ...
Skip Montanaro [EMAIL PROTECTED
Hi. I have files that I will be importing in at least four different
plain text formats, one of them being tab delimited format, a couple
being token based uses pipes (but not delimited with pipes), another
being xml. There will likely be others as well but the data needs to be
extracted and
Hi. I am running a zope server. Zope runs 4 threads and I have a
document processing method that can require minutes to run so I do not
want to run out of threads. A solution to this is to run this process
asynchronously. What I am hoping to do is send a signal to a python
deamon to run a
Hi jepler! This is a nice example. I will study it so I can better
see what each part is doing. I may have a couple of questions once I
have done this because I have not yet daemonized a process and I want
to be sure I understand before I attempt to run anything I create.
Many thanks.
David
I have two versions of python running - 2.4.1 and 2.3.5. Python 2.4.1
is most current and will execute from 'python' at command line where
2.3.5 will execute from 'python2.3'. A recent problem I have is
installing rdflib. It installed and works fine on 2.4.1. rdflib uses
'python setup
I have string text with language text records that looks like this:
'en' | 'the brown cow' | 'fr' | 'la vache brun'
Two or more language records can exist in each string (example above
shows 2 - but could contain more)
The second vertical line character in the example above is the record
break
, 2005, at 02:11 AM, Robert Kern wrote:
David Pratt wrote:
I have string text with language text records that looks like this:
'en' | 'the brown cow' | 'fr' | 'la vache brun'
Two or more language records can exist in each string (example above
shows 2 - but could contain more)
The second
Pretty amazing Devan! Great regex! Thank you.
Regards,
David
On Friday, July 1, 2005, at 02:29 AM, Devan L wrote:
One line solution.
dict(re.findall(r'(.+?)' \| '(.+?)'(?:\s\||$),yourtexthere))
--
http://mail.python.org/mailman/listinfo/python-list
--
Thanks George! You guys are great! I am always learning. Python is
awesome!!
On Friday, July 1, 2005, at 02:33 AM, George Sakkis wrote:
Robert Kern wrote:
Ignore the last message.
translations = [x.strip( ') for x in line.split('|')]
d = dict(zip(translations[::2], translations[1::2]))
Hi. I am putting together a database application on Zope. I have built
a pager for my records (20 per page) but do not want the browser scroll
bars to reset to the top of the browser each time the pager is
advanced to the previous or next page. The normal behavior is fine for
everything but
Hi. I am creating methods for form validation. Each validator has its
own method and there quite a number of these. For each field, I want
to evaluate errors using one or more validators so I want to execute
the appropriate validator methods from those available. I am iterating
over each
,
David
On Sunday, June 5, 2005, at 02:03 PM, Kent Johnson wrote:
David Pratt wrote:
Hi. I am creating methods for form validation. Each validator has its
own method and there quite a number of these. For each field, I want
to
evaluate errors using one or more validators so I want
Cool! Many thanks George. Yes this is the way to go - objects. Much
better :-)
On Sunday, June 5, 2005, at 02:49 PM, George Sakkis wrote:
David Pratt wrote:
Hi. I am creating methods for form validation. Each validator has its
own method and there quite a number of these. For each field
Hi. I am creating a python application that uses PIL to generate
thumbnails and sized images. It is beginning to look the volume of
images will be large. This has got me to thinking. Is there a number
that Unix can handle in a single directory. I am using FreeBSD4.x at
the moment. I am
Hi Jason. Many thanks your reply. This is good to know about ls -
what did it do? Was it just slow or did the server or machine die? My
images will be going into the path of a web server. This is
unchartered territory for me and I don't know whether there will be
speed and access problems
Hi, I am looking for some example code or open source project that
involves pythonwx and a database. I am wanting to store images and
data on the filesystem and transmit thumbnailed images and subsets of
records to the web using xmlrpc preferably. I am wanting the
application to be able to
I have been using the following for sorting a list of dictionaries.
This works but only provides sorting on a single key. I am wanting to
extend this with a better comparison expression so that it would sort
on one key as primary, a second key as secondary sort , and maybe even
a third as
80 matches
Mail list logo