']
print 'z =', subject['z']
Output is
v = ee
w = ac
x = abc
y = a
z = aab
Kent
--
http://mail.python.org/mailman/listinfo/python-list
-greedy (.+?) and get this result:
('ee', 'bcac', 'a', 'bca', 'aab')
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
Kent Johnson wrote:
John Salerno wrote:
Kent Johnson wrote:
You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter
this
platform, it is again in production.
http://paperforest.blogspot.com/2006/02/digi-comp-1.html
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
Kent Johnson wrote:
One thing that is really useful about running in an editor window is
that (in TextPad, anyway) I can double-click on an error message and go
directly to the line with the error.
Interesting. The way I have it now, it shows errors the way I want
John Salerno wrote:
Kent Johnson wrote:
The working directory must be wrong. Try calling Python directly with
full paths:
C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py
Perfect! Thank you so much!
I put this line in the command line field, and I left
://docs.python.org/about.html
Submitting a proposed change or fix is easier and quicker than arguing
about it on c.l.py and it seems to get pretty quickly to the actual
document maintainers.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
://www.digitalpeers.com/pythondebugger/
Kent
--
http://mail.python.org/mailman/listinfo/python-list
of member
variables?
class AA:
def __init__(...):
self.test_flag = 0
def methos(self,...):
self.test_flag = xx
Note 'test-flag' is not a valid name.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
):
if self.aa.testflag:
2. Pass the flag to BB.method() directly:
def method(self, testflag):
if testflag:
Kent
--
http://mail.python.org/mailman/listinfo/python-list
the logging setup somewhere else, in a module that
is only loaded once? Or inspect _logger.handlers to see if it already
contains a FileHandler to your log file, and only add it if it is not
there already.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
as a command line parameter.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Jed Parsons wrote:
Thanks, Kent and Peter,
Definitely making progress here. I've got propagate = 0, and am testing
for handlers before doing any addHandler business. (The handlers test
seems to make the most difference.)
I'm down to two entries per time now! And prodding Zope
John Salerno wrote:
Kent Johnson wrote:
You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.
I've tried a lot of combinations
with SQLObject or SQLAlchemy). There are
pesky differences in data types and how to pass parameters but the
basics are the same.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
In general the idea is to move the test from 'every time I need to do
something' to 'once when some name is defined'.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
lottery numbers, performance would
have to be truly awful before you even noticed. Don't optimize until you
have identified a problem.
Python is pretty fast for most of the things you will want to do with it.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
abcd wrote:
anyone have v2.x of pysqlite that I could download? the website is
down for a hardware upgrade with no date as to when it will be back.
I need v 2.x for windows, running python v2.4
I sent pysqlite-2.0.4.win32-py2.4.exe
Kent
--
http://mail.python.org/mailman/listinfo/python
Kent Johnson wrote:
abcd wrote:
anyone have v2.x of pysqlite that I could download? the website is
down for a hardware upgrade with no date as to when it will be back.
I need v 2.x for windows, running python v2.4
I sent pysqlite-2.0.4.win32-py2.4.exe
Well tried, anyway, someone
Fuzzyman wrote:
It has finally happened, the release of `Firedrop 0.2.0
* `ConfigObj http://www.voidspace.org.uk/python/configobj.html`_ is
now used to edit all the config files.
You should add this to the dependency list in the install page, it
tripped me up.
Kent
--
http
a group to capture the text between a and /a:
In [10]: re.sub('a( [^]+)+\s?([^^]*)/a',r'\2',' asd gaa
target=_blank href=http://www.sine.com; class=wordstyle
asdgasdghae rha/a')
Out[10]: ' asd ga asdgasdghae rha'
Kent
--
http://mail.python.org/mailman/listinfo/python-list
= \
ParserElement.packratParse,ParserElement.parse
Then users would just import pyparsingpackrat instead of pyparsing.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
James Thiele wrote:
I'd like to access the name of a function from inside the function.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
I'm having some trouble finding a function that converts numbers
(whether integer, hex, whatever) to its binary representation. Is there one?
You might like this recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286
Kent
--
http://mail.python.org/mailman
(self, func):
self.func = func
def __call__(self, *args, **kwargs):
print args, kwargs
return self.func(*args, **kwargs)
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Sion Arrowsmith wrote:
Kent Johnson [EMAIL PROTECTED] wrote:
Sion Arrowsmith wrote:
(and please avoid the abuse of raw strings for Windows paths).
Why do you consider that abuse of raw strings?
I consider it abuse because it's not what they were invented for.
I consider discouraging
very easy and
convenient to copy a path from Windows Explorer and paste it directly
into a raw string, no editing required.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
collects statistics for functions, not for individual
lines of code.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
= HHHI
which is 34 bytes
Are you sure? Not for me:
In [9]: struct.calcsize('HHHI')
Out[9]: 36
Kent
--
http://mail.python.org/mailman/listinfo/python-list
, world !'
Kent
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Sure, you're right I forgot about rsplit !
I guess the negative indexes al could be done with
sep.join(xyz.split(sep)[:index])
For index=-1 use
xyz.rsplit(sep, 1)[0]
Kent
--
http://mail.python.org/mailman/listinfo/python-list
message is, when you write
a(b)
Python interprets this as, call the object a, passing the parameter b.
If a is a string - a 'str' object - Python attempts to call the string.
Strings are not callable so you get the error message you see.
Kent
--
http://mail.python.org/mailman/listinfo/python
-equiv=Pragma
content=no-cache/HEADbody?y?ú'ò?aò3??.../body/html
The page is in Chinese (I think), when you print the data it is printing
in your console encoding which is apparently not Chinese. What did you
expect to see?
Kent
--
http://mail.python.org/mailman/listinfo/python-list
into site-packages.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
happen is to submit a bug report with your
suggested change. See the link at the bottom of the above page to find
out how.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
will be dramatically faster for
large lists as it only iterates str_list once.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
I am pleased to announce a new general release (0.5.2) of xlrd, a Python
package for extracting data from Microsoft Excel spreadsheets.
How does xlrd compare with pyexcelerator? At a glance they look pretty
similar.
Thanks,
Kent
--
http://mail.python.org/mailman/listinfo
(msg, )[0]
msgSize = int(split(msg, )[1]
You have an inconsistent indent in the two lines above. All the lines in
a block must have the same indent (except sub-blocks of course).
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
On 19/03/2006 8:31 AM, Kent Johnson wrote:
How does xlrd compare with pyexcelerator? At a glance they look pretty
similar.
I have an obvious bias, so I'll just leave you with a not-very-PC
analogy to think about:
Depending on the ambient light and the quantity of mead
'stdin'.
raw_input() prompts to stdout and reads from stdin. print outputs to stdout:
In [53]: print raw_input('What is your name? ')
What is your name? Kent
Kent
or import sys and use sys.stdin and sys.stdout.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
to fix it isn't worth the trouble; just
spell out the if / else.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
raise KeyboardInterrupt
Kent
--
http://mail.python.org/mailman/listinfo/python-list
where the key is everything before the first colon, just use
line.split(':', 1) to split on just the first colon.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Jacob wrote:
How do I uninstall?
Delete the chardet folder from site-packages (Python24\Lib\site-packages
on Windows, not sure of the exact path on other OS's).
Kent
--
http://mail.python.org/mailman/listinfo/python-list
() gives the total
count.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
configuration file. %s %err
HTH
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Jacob wrote:
How do I install Universal Encoding Detector
(http://chardet.feedparser.org/)?
The usual process:
download
unpack with your favorite tool - tar or WinZip, maybe
cd chardet-1.0
python setup.py install
Kent
--
http://mail.python.org/mailman/listinfo/python-list
has no attribute 'nl_langinfo'
Kent
--
http://mail.python.org/mailman/listinfo/python-list
exceptions are subclasses of ConfigParser.Error so
if you catch that instead of ConfigParser.ParsingError your code will
catch NoSectionError as well.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Ravi Teja wrote:
I do not think that technology has gone backwards. Hyper card
alternatives still exist.
http://www.metacard.com/
At $995 per seat it's not likely to be used for a home project.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
'.
I've tried numerous variations on '.*(FOO((?!FOO).)*)+.*'
and everything I've tried either matches too much or too little.
FOO(.*?)(?=FOO|$)
I've decided it's easier for me just to search for FOO, and then
break up the string based on the locations of FOO.
Use re.split() for this.
Kent
Paul Rubin wrote:
So what's the most concise way
of turning it back into a string? ''.join(list(reversed(a_string))) ?
You don't need the list(), join() can take an iterator:
''.join(reversed(a_string))
Kent
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Hello again,
I am disappointed. You are the experts, you've got to try harder ;-)
What i want is a generalisation of this tiny function:
Why? Maybe we can find a better way...
Kent
--
http://mail.python.org/mailman/listinfo/python-list
%(created)f rather than
%(asctime)s in your format.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
provenance as well.
From xx import * is evil because it does hide the provenance of names.
It can also give unexpected results - if xx contains from zz import *,
then all of the names from zz will also be imported into the module
importing xx!
Kent
--
http://mail.python.org/mailman/listinfo/python
Paul Rubin wrote:
Tim Roberts [EMAIL PROTECTED] writes:
Yes, but the CGI module doesn't write anything, so the advice of writing a
Location: header still applies.
Aha, it's coming from CGIHTTPServer.py:CGIHTTPRequestHandler.run_cgi()
where it says
self.send_response(200, Script
execute until the yield returns.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
://hoohoo.ncsa.uiuc.edu/cgi/out.html
http://www.algonet.se/~ug/html+pycgi/redirect.html
Kent
--
http://mail.python.org/mailman/listinfo/python-list
call last):
File stdin, line 1, in ?
NameError: name 'octal' is not defined
The correct name is oct(). The docs on built-in functions are helpful here:
http://docs.python.org/lib/built-in-funcs.html
Kent
--
http://mail.python.org/mailman/listinfo/python-list
exactly the error including XPath expressions to
the node containing the error!
In Jython I use unittest, not JUnit, so instead of subclassing
XMLTestCase I call the static methods of XLMAssert from my test cases.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
that the time machine is stil working ;)
http://www.python.org/peps/pep-0352.html
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Py_TPFLAGS_BASETYPE is not set. Whether this is by
design or accident would be a question for the kinterbasdb developers.
One workaround might be to use delegation instead of subclassing...
Kent
--
http://mail.python.org/mailman/listinfo/python-list
and there is (slow) progress being made in
modernizing it. I recommend it.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
of objects which don't directly support any comparison methods
that the cmp builtin understands.
Using the index as above prevents the objects from ever being compared.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
).__init__(etc...)
Obviously I'm missing a piece of information that would help me to see
why the call gets passed back up to Base...
It's a typo in the book.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Ed Leafe wrote:
On Mar 6, 2006, at 8:08 PM, Kent Johnson wrote:
One workaround might be to use delegation instead of subclassing...
Yeah, but that would involve a lot more work at this point. The
mixin approach has been working quite well up until this problem.
Automatic delegation
implement all
the functions you use from math.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
).
Thanks,
Kent
http://xmlunit.sourceforge.net/
--
http://mail.python.org/mailman/listinfo/python-list
\\A',
snip lots more dirs]
foo.baz() here
Kent
--
http://mail.python.org/mailman/listinfo/python-list
(which does most of the setup of sys.path), one element of the
path is an empty string. This is expanded by
main() - removeduppaths() - makepath() - os.path.abspath()
to the current working dir.
This is Python 2.4.2 on Win2K.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
package to hold commonly used code. Then B
and D both use
from util import foo
In Python 2.5 you will be able to say (in D, for example)
from ..util import foo
http://www.python.org/peps/pep-0328.html
Kent
--
http://mail.python.org/mailman/listinfo/python-list
...: xxx.xxx.xxx.xxx
...: xxx.xxx.xxx.xxx:yyy'''.splitlines()
In [3]: for line in data:
...: print line.split(':')[-1]
...:
...:
yyy
yyy
yyy
xxx.xxx.xxx.xxx
xxx.xxx.xxx.xxx
yyy
Kent
--
http://mail.python.org/mailman/listinfo/python-list
on:
def make_key(f):
return (os.path.dirname(f), f.lower())
files.sort(key=make_key)
Kent
--
http://mail.python.org/mailman/listinfo/python-list
inside the loop, this replaces your
original loop:
for i, object in enumerate(lst):
print i
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Laszlo Zsolt Nagy wrote:
The values of some inputs are encoded using html entities.
How can I decode a string like Bessy#39;s cat in Bessy's cat?
http://groups.google.com/group/comp.lang.python/browse_frm/thread/819731a536a4c1a2/fce6c2f6c3d46e9c?q=htmlentitydefsrnum=2#fce6c2f6c3d46e9c
Kent
for lambda
walk_files.sort(key=str.lower)
# etc
Kent
--
http://mail.python.org/mailman/listinfo/python-list
the superclass __init__ as well:
class __metaclass__(type):
def __init__(cls, name, bases, classdict):
super(__metaclass__, cls).__init__(name, bases, classdict)
cls.sum = sum(xrange(10))
Kent
--
http://mail.python.org/mailman/listinfo/python-list
the same sort of thing
without 'apply'.
Apply has been replaced by 'extended call syntax', that is why it is
deprecated. Instead of
return apply(self._function,_args,_kargs)
write
return self._function(*_args, **_kargs)
Kent
--
http://mail.python.org/mailman/listinfo/python-list
):
Compute sqrt of x
return sqrt(x)
Kent
--
http://mail.python.org/mailman/listinfo/python-list
,
*args,
**kwargs).start()
No. threading.Thread() doesn't use *args, **kwargs, it uses explicit
named parameters.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/435883
Kent
--
http://mail.python.org/mailman/listinfo/python-list
a class.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
.iteritems())
{1: 'A', 2: 'B', 4: 'C'}
Kent
--
http://mail.python.org/mailman/listinfo/python-list
may give you some help though it may be
more complex than you need:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
Kent
--
http://mail.python.org/mailman/listinfo/python-list
() gets a bound method object from the class and calls it with no
additional argument.
str.strip(s) gets an unbound method object from the class and calls it,
passing a class instance as the first argument.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Crutcher wrote:
It is something of a navel (left over feature). xyz.strip() is (I
think) newer than string.strip()
Yes, but the question as written was about str.strip() which is an
unbound method of the str class, not string.strip() which is a
deprecated function in the string module.
Kent
UserDict.IterableUserDict which does support iteration.
I don't think there is much reason to use UserDict in modern Python as
dict can be subclassed.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
'itervalues'
What version of Python are you using? itervalues() is in Python 2.2 and
later.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
it is a just
a plain variable or like something pattern matching in Haskell.
_ is just a plain variable name in Python. It is sometimes when a
variable is needed to receive a value that won't be used. So your
example was correct and idiomatic but functionally identical to mine.
Kent
--
http
to do
what I want here?
The example above does not sort in place, if you want it to be in place use
A[:] = [a for b,a in sorted(zip(B,A))]
Kent
--
http://mail.python.org/mailman/listinfo/python-list
of Semaphores:
http://greenteapress.com/semaphores/
It requires that you know in advance how many threads need to rendezvous
so you will have to preprocess your args a little.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
the last one left off, put a global statement inside
getText() so Python knows colorIndex is global:
def getText(nodelist):
global colorIndex
for str in strings:
print colors[colorIndex % colors.length]
colorIndex += 1
Kent
try the index:
http://docs.python.org/lib/genindex.html
how do i either grab the full path or append it later ...
Use os.path.join():
base = '/some/useful/path'
for f in os.listdir(base):
full_path_to_file = os.path.join(base, f)
Kent
--
http://mail.python.org/mailman/listinfo/python-list
\\xe8 def'
s='abc \xff\xe8 def'
s.encode('string_escape')
'abc \\xff\\xe8 def'
unicode(s.encode('string_escape'))
u'abc \\xff\\xe8 def'
Kent
--
http://mail.python.org/mailman/listinfo/python-list
of the whole
program and all needed library modules. If this is expensive, you can
break up the loads by putting key imports into functions instead of at
global scope.
Note to the doubters - I have used these techniques in Jython programs,
where importing java packages can be noticably slow.
Kent
more
an attitude of try it, you'll like it!. Using Python does seem to
spoil people - I for one hate to code in Java now. Maybe bliss is a
better word for it than satori.
Kent
--
http://mail.python.org/mailman/listinfo/python-list
Gabriel B. wrote:
what does a string became when it's decoded?
I mean, it must be encoded in something, right?
Unicode, for encodings like latin-1 or utf-8. A few special cases like
str.decode('string_escape') yield byte strings again.
Kent
--
http://mail.python.org/mailman/listinfo/python
= ' ... '
Kent
--
http://mail.python.org/mailman/listinfo/python-list
for an import (and what worked from the command line).
Kent
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
Kent Johnson wrote:
John Salerno wrote:
Magnus Lycka wrote:
The other option is ASP. You have been given information about
that already. Be aware that ASP does not imply VBScript. You can
use Python in ASP as long as that's enabled. It seems to be exactly
what you
301 - 400 of 809 matches
Mail list logo