ded.
Also, "not that long ago" must mean different things for different people.
I think we've required logins for three years or more.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Eschewing PEP
8 is fine for other stuff, but code in the Python core (especially new
code like the logging module) should strive to adhere to PEP 8, since
many people will use the core code as a pattern for their own code.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
>> - It's a package, but contrary to any other package I've ever seen,
>> most of its functionality is implemented in __init__.py.
Trent> I'm not defending the implementation, but does this cause any
Trent> particular problems?
No, it just seems symptomatic of some potential or
ybe going
forward we should be more adamant about that when an external module becomes
a candidate for inclusion in the core.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
etime.datetime.now()
>>> t
datetime.datetime(2005, 9, 9, 12, 52, 38, 677120)
>>> strtime = t.isoformat()
>>> strtime
'2005-09-09T12:52:38.677120'
You can try stripping the microseconds first:
>>> time.strptime(strtime, "%Y-%m-%
d as an informal educational tool. As for the others (and logging as
well, for that matter), maybe it's just been too long to make changes and
they should only be changed in Py3K.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
automatic or
at least under user control. I don't want the setup.py author to control
this feature.
Thx,
Skip
--
http://mail.python.org/mailman/listinfo/python-list
>> It does, in the "in-development" version of the documentation. Sorry it
>> was not in the 2.4 releases :-(
Thomas> Maybe it can be backported to 2.4.2 - is there still time for that?
Changed now in CVS. When 2.4.2 is released it should be there.
Skip
-
meter change to basicConfig() as happening in 2.4. I didn't change any
code.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
xt --help
in the MySQLdb source dir.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
thomas> ImportError: /usr/lib/python2.3/site-packages/_mysql.so: undefined
thomas> symbol: mysql_rollback
skip> Is your libmysql.so installed in an odd place?
Oh, also, try executing
ldd /usr/lib/python2.3/site-packages/_mysql.so
If that shows libmysql as undefin
How about:
import datetime
oneday = datetime.timedelta(days=1)
oneweek = datetime.timedelta(days=7)
year = 2005
start = datetime.date(year=year, month=1, day=1)
while start.weekday() != 0:
start += oneday
days = []
while start.year == year:
da
t at Sourceforge:
http://sourceforge.net/projects/mysql-python
Andy Dustman, the author, is generally quite quick to respond.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
g behaviour:
...
> I think everyone winds up with their own wrapper around subprocess
> after they use it for more than a short period...
Thanks, that saves me much head scratching.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
>>> print x[0]
[1, 2, 3]
>>> print x[0][1]
2
>>> x[0][1] = 5
>>> print x
[[1, 5, 3], [4, 5, 6]]
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ting_value, ...]
writer = csv.writer(csvfile)
writer.writerow(newrow)
csvfile.close()
You didn't give any details on the structure of your csv file, so the
construction of newrow is purposely fuzzy.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
x27;, 'sun')
col.blue == "blue"
day.tue == 23
If they return False I would expect
col.blue == day.tue
to return False as well, not raise an exception.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
iltins behave that way? How about anything in the
>> python standard library?
Ben> No to both; I believe this may be a defining property of
Ben> enumerations. Am I wrong?
I think so. <0.5 wink>. I think you should be able to compare any two
objects. I think the co
ramming language community as a whole (or Python in particular) has any
unmet needs in the communication area.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
or may be available
in the server error log.
Apache/1.3.26 Server at www.mired.org Port 80
in the terminal just now (9:05 or so CST).
Skip
--
http://mail.python.org/mailman/listinfo/python-list
I'm just getting started with Myghty and using it under mod_python (also a
new beast for me). Do I have to worry about threading conflicts between
different mod_python interpreters or are they all independent?
Thx,
Skip
--
http://mail.python.org/mailman/listinfo/python-list
n
(check out SWIG and/or Boost and/or Python's Extending and Embedding
documentation), then write test cases. For that, look at the unittest and
doctest modules that come with Python as well as the third-party py.test
package.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
d the header files from your C++ library and it
will by dynamically linked against the library's .so (or .dll).
Skip
--
http://mail.python.org/mailman/listinfo/python-list
> Yacc has been around for a long time.
Sure, but it's capitalized there. Python innovated the use of lower-case
'y'.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
c generation?
Take a look at PEP 304 and see if that would meet your needs:
http://www.python.org/peps/pep-0304.html
If you have comments on it, best to submit a tracker item on Sourceforge in
addition to posting your ideas here to make sure they don't get lost.
Skip
--
http://mail.p
yogi> now if i got to modify one particular line from these three rows,
yogi> how can i do that.
Check out the csv module.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ber.csv", "rb").read()
'1\t2\tabc\n3\t4\tdef\n'
I get:
>>> sniffer = csv.Sniffer()
>>> d = sniffer.sniff(open("tabber.csv", "rb").read())
>>> d.delimiter
'\t'
Can you provide a concrete example (preferably in a bug report on SF)?
Skip
--
http://mail.python.org/mailman/listinfo/python-list
r.sniff(open("tabber.csv", "rb").read())
me> >>> d.delimiter
me> '\t'
BTW, this also seems to work with a Mac-style EOL:
>>> open("tabber.csv", "rb").read()
'1\t2\tabc\r3\t4\tdef\r'
&g
Laurent> If I change:
Laurent> freq = line.strip().count(char)
Laurent> by:
Laurent> freq = line.count(char)
Laurent> It works fine.
Laurent> Do you have a workaround for that?
Nope. I just checked in precisely your fix to the Python repositor
Hans> Robert Kern wrote:
>> PyPy will not bring about the Singularity.
Hans> But if it did, imagine how cool that would look on the developers
Hans> resumes... :-)
+1 QOTW
Skip
--
http://mail.python.org/mailman/listinfo/python-list
John> Guido may or may not realise it, but he seems to have been
John> managing people (in some sense of 'managing', anyway) quite
John> successfully over the past decade or so.
Sssh! Don't tell him! Hopefully the PSU won't find out and
--
http://mail.python.org/mailman/listinfo/py
st):
p = re.compile("([0-9])")
def repl(m):
return pre + m.group(1) + post
print p.sub(repl, data)
For a full explanation, google for "python nested scopes".
Skip
--
http://mail.python.org/mailman/listinfo/python-list
obviously a bit slower, you can
memoize any function without tweaking its source.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
(f.split(os.sep)[-1], c, l) for (f, c, l) in info]
return '\n'.join(['[%s|%s|%d]' % x for x in info[:size]])
def print_compact_stack(f=sys.stderr, start=0, size=100):
print >> f, compact_stack(start+1, size)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
.org/moin/Python3%2e0Suggestions
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Andreas> Does anyone know of a Python module that is able to sniff the
Andreas> encoding of text?
I have such a beast. Search here:
http://orca.mojam.com/~skip/python/
for "decode".
Skip
--
http://mail.python.org/mailman/listinfo/python-list
breaking
down and learning how to use pdb. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
my_x = x()
my_x.someMethod()
When run you will get this output:
Traceback (most recent call last):
File "slot.py", line 9, in
my_x.someMethod()
File "slot.py", line 6, in someMethod
self.sumName = "bye"
AttributeError: 'x' object has no attribute 'sumName'
Skip
--
http://mail.python.org/mailman/listinfo/python-list
uot;referer", as in the
HTTP_REFERER header in the HTTP spec:
http://en.wikipedia.org/wiki/Referer
In fact, googling for "referer" and "referrer" reports a similar number of
hits, unlike most misspellings.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
misspelled word does. Maybe I've
been using Unix systems for too long with their brief command names like mv
and grep. I prefer not to write big_honkin_long_names any more than I have
to either.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
was pining
for attribute declarations. __slots__ is the closest thing Python has to
them. I don't use them myself (since I've basically avoided new-style
classes so far).
Skip
--
http://mail.python.org/mailman/listinfo/python-list
.
Okay, so that's a few things...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
>> 1. It's generally faster than reaching for the dictionary.
Terry> But not faster than use a dict server! Why not just use (e.g.)
Terry> kdict?
Maybe because not everybody has it?
% kdict
-bash: kdict: command not found
Skip
--
http://mail.python.org
never acquired anything new, the world certainly would look
Sybren> different.
I'm not sure what in my response suggested to you that I never install new
software on my computers.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Michele> I am also +1 to run the tests in the code order.
Got any ideas how that is to be accomplished short of jiggering the names so
they sort in the order you want them to run?
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Thomas,
Ctypes doesn't work to call arbitrary C++ code, is that correct?
Skip
--
http://mail.python.org/mailman/listinfo/python-list
punches?).
I do remember the IBM Model 29 punch card machines, though as a student
nobody was there to punch my cards or verify them for me... :-(
Skip
--
http://mail.python.org/mailman/listinfo/python-list
op it
and move onto other things. The clear evidence from people who admit to
having practical experience using unit tests (or pylint or pychecker) is
that catching misspellings is an extremely shallow bug to find and fix if
you use the tools at your disposal.
Skip
--
http://mail.python.org/ma
is nowhere near
the actual message text you were responding to, making it that much
more difficult to identify your problem.
Read this essay:
http://www.catb.org/~esr/faqs/smart-questions.html
then try again.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
alled when the
main thread exits.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
David> entirely intact", as the Py_Finalize comment says.
...
David> This seems simple. Am I overlooking something?
A patch? <0.5 wink>
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ake-variable-buffer-local 'py-python-command)
and let me know if that allows your Local Variables setting to work.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
rameEx (the
main interpreter loop).
I also find pdb fairly unnecessary. A combination of unittests, inserted
prints and the occasional use of cgitb is generally sufficient for my needs.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ew> What is a pythonic equivalent?
Take a look at the ConfigParser module. It reads and writes Windows-style
INI files. Also, you can do something similar to what you do in Perl. It's
just that you import the config data from the places that need it instead of
exporting it from the plac
e lots of ways to approach web app
frameworks. They all have their pros and cons. Deciding on one to ship
with Python will likely be a significant challenge.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
r regular expression does what you want
is to provide a set of strings it must accept and another set which it must
reject. Supply those two sets and I'm sure any number of people here can
come up with a regular express that distinguishes the two sets.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
should narrow it
Paul> down some.
Even your technique narrows the list of candidates down to one, that doesn't
solve the problem. There is a certain "stamp of approval" implicit with
inclusion in the standard library. It's thus a fairly important decision to
get at l
Jim> http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
Maybe Cafe Express could be convinced to put that on a t-shirt...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
e as I
Roel> handle any other advertisement: throw it away.
Sure, but that's not what JW said. He said that *when looking at ads* the
only bits of content people read are the captions of the pictures. He said
nothing about what people read when they are reading non-advertising
content.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
e class (referenced in
the 1998 post you refer to) is available here:
http://orca.mojam.com/~skip/python/fsm.py
It's still in use, though I haven't written anything new with it in a year
or so.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Tino> Is this going to be changed? Is someone working on it? Or are
Tino> patches for SF wanted?
A patch that removes this constraint would be helpful.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
sters (Linux or
Solaris would be the software environment), I'd appreciate a reference.
Thanks,
Skip
--
http://mail.python.org/mailman/listinfo/python-list
if _iscommand(browser):
register(browser, None, Mozilla(browser))
where Mozilla == Netscape, so your proposed fix appears to be correct.
(Which reminds me, I have a patch to webbrowser.py to test...)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
] I'll
submit a bug report. A quick glance didn't locate the source of the
problem.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
... [much page traversal deleted] ...
peter> So you need to add a bug to the Python bug tracker -- at least so
peter> it seems.
If you go to the top of the doc tree:
http://docs.python.org/
and look in the left-hand sidebar you'll see "[EMAIL PROTECTED]" under the
heading "Emai
getChildren
lineno None
...
but successive calls just yielded the more electron-conserving:
dispatch Module
dispatch Stmt
dispatch Assign
dispatch AssName
dispatch Const
dispatch Assign
dispatch AssName
dispatch Const
What am I doing wrong?
Thanks,
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Hari> So in order to see that the script is working and not stuck, I'd
Hari> like to implement some kind of progress bar or something, ...
Here's mine:
http://orca.mojam.com/~skip/python/progress.py
There are both Progress and Counter classes. Same idea, differe
package formats.
And one or two people don't use Linux yet.
Uninstall support would be a good idea...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Not everyone uses Linux. Or Windows. Or Macs.
Python is a cross-platform language. Through distutils it includes a basic
cross-platform installation facility. It probably ought to also have a
corresponding basic cross-platform uninstall facility.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
The PSU warns you to keep on the lookout for posts from the anti-effbot.
It's rumored that he recently turned up in this quadrant of the galaxy. His
posts tend to be somewhat illogical, suggest a poor mastery of software
engineering in general and Python in particular, and seem unnervingly
friend
.value = True
def __call__(self, val):
if self.last is not None and self.last+1 != val:
self.value = not self.value
self.last = val
return self.value
for key, group in groupby([1,2,3, 5,6, 8, 12,13,14], Counter()):
print list(group)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Python's key concepts is "we're all adults here". You can't
really and truly hide c1 and c2, so just act responsibly and don't mess with
them from outside the function module.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
indow', 'INSERT', 'BuiltinMethodType', 'BROWSE', 'Tcl',
'BuiltinFunctionType', 'BaseWidget', 'PROJECTING', 'MethodType',
'TracebackType', 'BEVEL', 'E', 'InstanceType', 'BOTH', 'PIESLICE',
'Button', 'sys', 'Y', 'Entry', 'Message', 'PhotoImage', 'RIGHT',
'BufferType', 'Studbutton', 'INSIDE', 'Menubutton', 'WRITABLE',
'StringVar', 'ARC', 'At', 'ComplexType', 'NSEW', 'SCROLL', 'NoneType']
The chance that one of those names would rebind an already existing name in
your namespace is much higher.
The second practical difference is that if the object referenced by a name
is immutable (say, an integer), the name in the current namespace doesn't
get rebound if the module modifies the value. Consider b.py:
total_work = 0
def work():
global total_work
print "not as hard as it might be"
total_work += 1
If I execute
from b import total_work, work
names are created in my current namespace that reference the objects bound
to those names *at that moment* in the b module's namespace. If I then call
work(), it rebinds the name total_work in b's namespace (because integers
are immutable), however, I don't see the effect, because the name
"total_work" in my namespace is still bound to the object 0:
>>> from b import total_work, work
>>> total_work
0
>>> work()
not as hard as it might be
>>> total_work
0
>>> work()
not as hard as it might be
>>> total_work
0
Apparently work is really pretty easy...
If, on the other hand, I import b, I get the expected behavior:
>>> import b
>>> b.total_work
0
>>> b.work()
not as hard as it might be
>>> b.total_work
1
>>> b.work()
not as hard as it might be
>>> b.total_work
2
because each time I reference b.total_work I'm using the name in b's
namespace to find the current object to which it's bound. That's the same
name that b.work() rebinds each time it's called.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ss sessions or just command recall from the current
session? On my Mac your script works just fine for me (no import readline
as Robert Kern indicated in his reply) to do command recall from the the
current session, but more is needed if you expect to get command history
across sessions.
Skip
--
htt
reating other problems).
As the author of watch, I'm more than happy to incorporate "drivers" from
other people into the code, however, I have very little access to Linux
these days (and none on the desktop) and no Windows access.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
MCI> Look PyHook ( http://cheeseshop.python.org/pypi/pyHook/1.4 )
MCI> Ooooh!!! Sorry! It's for Windows...
That's okay (well, for me anyway). Watch runs on Windows. Perhaps someone
with Windows would like to plug pyHook into watch?
Skip
--
http://mail.python.org/
, but Python 2.5 comes with ctypes, not calldll. Might be worth
switching to remain compatible at that level.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
much killed the market for stuff like GKS. X
servers have enough features and video boards have enough performance that
for all but the most demanding graphics applications there's no desired to
write bits using something other than OpenGL and no need to expose the raw
framebuffer at
>> In csv.reader, is there any way of skip lines that start whith '#' or
>> empty lines
Nope. When we wrote the module we weren't aware of any "spec" that
specified comments or blank lines. You can easily write a file wrapper to
filter them out t
T> Do I need to close the file in this case? Why or why not?
T> for line in file('foo', 'r'):
T> print line
No. The magic of reference counting.
S
--
http://mail.python.org/mailman/listinfo/python-list
>> Hm didn't I leave ctypes in there? I added calldll because it
>> had a really nice can opener.
Oh, I have no idea (didn't download). I just sort of assumed if you had
included calldll you probably hadn't included ctypes.
Skip
--
http://mail.python.
John> This is recursive. Unlikely of course, but if the file contained a
John> large number of empty lines, might this not cause the recursion
John> limit to be exceeded?
Sure, but I was lazy. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
e manually it probably isn't too
complex (no newlines inside fields, for example).
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Nick> I still don't know why it was ever included in Python.
It was another time and place altogether than the world we live in today.
Python was a much smaller language and had a much smaller following.
Concerns about security were minimal (relative to today anyway).
Skip
Paul> Can someone PLEASE remove [EMAIL PROTECTED] from the
Paul> subscriber list???
BTDT.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ied asking on the SWIG mailing list
([EMAIL PROTECTED])? There are probably many more SWIG
experts there than here.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Frederic> In the short period of time since I introduced SE. the
Frederic> feedback has been overwhelmingly postive.
Ummm... what is it? The last SE I had was a Mac.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
crowell> However, I'd like to see the more sensible "Bela Fleck" instead
crowell> of dropping '\xe9' entirely.
Assuming the data are in latin-1 or can be converted to it, try my latscii
codec:
http://orca.mojam.com/~skip/python/latscii.py
Skip
--
ecisely what
you've asked for, but it provides some features that help integrate Python
with the shell environment.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ver, ever to try programming in csh...
Skip
--
http://mail.python.org/mailman/listinfo/python-list
()
b = C()
If I call a.printx(), self will be bound to the same object a is bound to.
If I call b.printx(), it will be bound to the object b references.
The precise use of the name "self" is indeed simply a convention. You could
call it "barney" if that makes you feel better. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
ly so I don't need to be
root and don't disturb the system-provided software. In cases where other
users need to run such tools I generally use /usr/local.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
py> What is the best way to construct an email in python and also attach
py> a html file
...
Check out the email package.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
up in
/some/where/else/lib/python2.4/site-packages
Just add that directory to PYTHONPATH and you should be good to go.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
print "hmmm...", repr(s), "doesn't look like an integer to me."
Skip
--
http://mail.python.org/mailman/listinfo/python-list
es that use braces
Stephen> or END or end; etc.
No. In that case Python makes it more readily apparent that your code is
too complex. With C, Java, C++, Perl or FORTRAN you just smush everything
over to the left and pretend it's not. ;-)
Skip
--
http://mail.python.org/mailman/listinfo/python-list
Slawomir> Well, one space is sufficient indentations for Python, right? So
even
Slawomir> on 80 column screen, you can easily fit about 40 levels of nesting
Slawomir> before it becomes a real problem :D
Oh, sure. Hence the smiley in my post...
Smileys all around. I'm happ
nts to a list of eight or twelve elements,
you'd probably be interested in knowing about that asap. eval() probably
wouldn't fail unless they completely butchered the table syntax.
With a small amount of input massaging, you could do this more cleanly with
the csv module. That's left as an exercise for the reader.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
skip> import re
skip> symbolinfo = []
skip> sympat = re.compile(
skip> r'\[',
Make that
r',?\['
Skip
--
http://mail.python.org/mailman/listinfo/python-list
es which happens at this point in time to
intersect with the definition of a Python list. You're trying to wish it
was something that it's not.
Skip
--
http://mail.python.org/mailman/listinfo/python-list
101 - 200 of 2035 matches
Mail list logo