As far as I've been able to determine, Python does not remember
(immutably, that is) the working directory at the program's start-up,
or, if it does, it does not officially expose this information.
Does anyone know why this is? Is there a PEP stating the rationale
for it?
Thanks!
--
In roy-ca6d77.17031119082...@news.panix.com Roy Smith r...@panix.com writes:
In article k0rj38$2gc$1...@reader1.panix.com, kj no.em...@please.post
wrote:
As far as I've been able to determine, Python does not remember
(immutably, that is) the working directory at the program's start-up
What's the most reliable way for module code to determine the
absolute path of the working directory at the start of execution?
(By module code I mean code that lives in a file that is not
meant to be run as a script, but rather it is meant to be loaded
as the result of some import statement.
of the rationale behind PEP 3130
Thank you!
kj
--
http://mail.python.org/mailman/listinfo/python-list
Is there an *explicitly stated* reason (e.g. in a PEP, or in some
python dev list message) for why the inspect module (at least for
Python 2.7) does not include anything like a currentcallable()
function that would *stably*[1] return the currently executing
callable object?
(It seems unlikely
it's an all-out disgrace.
when is python going to get a decent module distribution system???
and don't tell me to do it myself: it's clear that the sorry
situation we have now is precisely that too many programmers without
the requisite expertise or policy-making authority have decided to
pitch
arguments in Java would be appreciated.
TIA!
kj
--
http://mail.python.org/mailman/listinfo/python-list
for Gnome+Python?
TIA!
~kj
[1] Needless to say, when I write apps I mean full-blown GUI
apps: windows, menus, events, threads, clickable icon, the whole
ball of wax. As opposed to cli apps, panel widgets, etc.
--
http://mail.python.org/mailman/listinfo/python-list
In 4d181afb$0$30001$c3e8da3$54964...@news.astraweb.com Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info writes:
We know it because it explains the observable facts.
So does Monday-night quarterbacking...
--
http://mail.python.org/mailman/listinfo/python-list
that I'm not going insane when inevitably I'm told
that there's no bug in dict or list).
Interestingly enough, if I replace list with UserList, I see no
change in behavior. So maybe I am going insane after all.
~kj
P.S. If you uncomment the commented-out line, and comment out the
last line
back, all is forgotten!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In xns9e59a27def178duncanbo...@127.0.0.1 Duncan Booth
duncan.bo...@invalid.invalid writes:
kj no.em...@please.post wrote:
Watch this:
class neodict(dict): pass
...
d = neodict()
type(d)
class '__main__.neodict'
type(d.copy())
type 'dict'
Bug? Feature? Genius beyond the grasp
In mailman.302.1293387041.6505.python-l...@python.org Ian Kelly
ian.g.ke...@gmail.com writes:
On 12/26/2010 10:53 AM, kj wrote:
P.S. If you uncomment the commented-out line, and comment out the
last line of the __init__ method (which installs self._delitem as
self.__delitem__) then *all
raises the exception
than I have for seeing the traceback of Python's underlying C code
when I get an error like the one shown above.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.301.1293383804.6505.python-l...@python.org Ethan Furman
et...@stoneleaf.us writes:
You failed to mention that cleverness is not a prime requisite of the
python programmer -- in fact, it's usually frowned upon.
That's the party line, anyway. I no longer believe it. I've been
as
basic as the *class* that the method belongs to, whenever applicable.
I imagine there's a good reason for this coyness, but I can't figure
it out.)
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.272.1293215190.6505.python-l...@python.org Daniel Urban
urban.d...@gmail.com writes:
On Fri, Dec 24, 2010 at 17:24, kj no.em...@please.post wrote:
(BTW, I don't understand why inspect doesn't provide something as
basic as the *class* that the method belongs to, whenever applicable
Watch this:
class neodict(dict): pass
...
d = neodict()
type(d)
class '__main__.neodict'
type(d.copy())
type 'dict'
Bug? Feature? Genius beyond the grasp of schlubs like me?
~kj
--
http://mail.python.org/mailman/listinfo/python-list
one go about deciding the ordering of base classes?
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
.
Thanks!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
', '.', 'org', '/', 'dev', '/',
'library', '/', 'stdtypes', '.', 'html', '\
?', 'highlight', '=', 'partition', '#', 'str', '.', 'partition']
~kj
--
http://mail.python.org/mailman/listinfo/python-list
choice but to
study the source code, since there's no other more readable
description of this implementation.
Maybe there are fewer abstraction leaks in 3.0...
~kj
--
http://mail.python.org/mailman/listinfo/python-list
audience for the errors generated by my
argument-checking functions should see no further than the point
where they called a function incorrectly.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In 1f47c36d-a509-4d05-ba79-62b4a534b...@j19g2000prh.googlegroups.com Carl
Banks pavlovevide...@gmail.com writes:
On Dec 22, 8:52=A0am, kj no.em...@please.post wrote:
In mailman.65.1292517591.6505.python-l...@python.org Robert Kern rober=
t.k...@gmail.com writes:
Obfuscating the location
that, one would have little assurance that
one's experimentation has truly uncovered all the necessary details;
IME, programming-by-guesswork leads to numerous and often nasty bugs.
Is there any other way?
TIA!
~kj
[1] The minimal bit in the question statement is just another way of
specifying
In 4d127d5e$0$29997$c3e8da3$54964...@news.astraweb.com Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info writes:
On Wed, 22 Dec 2010 14:20:51 +, kj wrote:
Here's another example, fresh from today's crop of wonders:
(v. 2.7.0)
from collections import Mapping
issubclass(dict, Mapping
-raising the exception. (Or some
clueful/non-oxymoronic version of this.) How feasible is this?
And, if it is quite unfeasible, is there some other way to achieve
the same overall design goals described above?
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
the
source I'm seeking, but subsequent readings of incorrect stuff may
have overwritten the correct information in my brain.)
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
value
of epsilon for this purpose?
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.278.1288129342.2218.python-l...@python.org Steve Holden
st...@holdenweb.com writes:
On 10/26/2010 2:44 PM, kj wrote:
In mailman.258.1288104186.2218.python-l...@python.org Steve Holden
st...@holdenweb.com writes:
The answer is probably the same as you will see if you try
from
In mailman.241.1288036400.2218.python-l...@python.org Terry Reedy
tjre...@udel.edu writes:
On 10/25/2010 3:11 PM, kj wrote:
Well, it's pretty *enshrined*, wouldn't you say?
No.
After all, it is part of the standard distribution,
So is 'import antigravity'
Are you playing with my
In mailman.258.1288104186.2218.python-l...@python.org Steve Holden
st...@holdenweb.com writes:
The answer is probably the same as you will see if you try
from __future__ import braces
That feature *is* available in Python 2.6 ;-)
Now, that's hilarious.
kj
--
http://mail.python.org/mailman
In The Zen of Python, one of the maxims is flat is better than
nested? Why? Can anyone give me a concrete example that illustrates
this point?
TIA!
~kj
PS: My question should not be construed as a defense for nested.
I have no particular preference for either flat or nested; it all
depends
In f8b6c925-ca3b-4be4-8851-6b18c6465...@j18g2000yqd.googlegroups.com
rantingrick rantingr...@gmail.com writes:
On Oct 25, 5:07=A0am, kj no.em...@please.post wrote:
In The Zen of Python, one of the maxims is flat is better than
nested? =A0Why? =A0Can anyone give me a concrete example
In mailman.232.1288020268.2218.python-l...@python.org Steve Holden
st...@holdenweb.com writes:
On 10/25/2010 10:47 AM, rantingrick wrote:
On Oct 25, 5:07 am, kj no.em...@please.post wrote:
In The Zen of Python, one of the maxims is flat is better than
nested? Why? Can anyone give me
on objects that should be gc'd?
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
-like in Python would be
appreciated.
TIA!
kj
--
http://mail.python.org/mailman/listinfo/python-list
In i9o8jc$9p...@lust.ihug.co.nz Lawrence D'Oliveiro
l...@geek-central.gen.new_zealand writes:
In message i9n4ph$d7...@reader1.panix.com, kj wrote:
I tried to fix the problem by applying the equivalent of stty
-echo within a python interactive session, but discovered that
this setting
In mailman.29.1287515736.2218.python-l...@python.org Jed Smith
j...@jedsmith.org writes:
On Tue, Oct 19, 2010 at 2:35 PM, kj no.em...@please.post wrote:
In mailman.24.1287510296.2218.python-l...@python.org Jed Smith j...@jed=
smith.org writes:
On Tue, Oct 19, 2010 at 1:37 PM, kj no.em
under the Emacs shell; I don't observe
it under, e.g., Terminal or xterm.)
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
(e.g. emacs shell),
so YMMV.)
Does anyone know how can I suppress this annoying feature?
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.24.1287510296.2218.python-l...@python.org Jed Smith
j...@jedsmith.org writes:
On Tue, Oct 19, 2010 at 1:37 PM, kj no.em...@please.post wrote:
% stty -echo
That doesn't do what you think it does.
Gee, thanks. That really helped. I'll go talk to my guru now,
and meditate over
are still fluid. I'm trying to minimize
the effort required to keep the docstrings current, while still
retaining the freedom to adjust the values of the globals. Also,
FWIW, most of these globals are merely default values that can be
overridden at runtime.)
TIA!
~kj
--
http://mail.python.org
MRAB, Peter: thanks for the decorator idea!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In i9clfa$mk...@reader1.panix.com kj no.em...@please.post writes:
MRAB, Peter: thanks for the decorator idea!
As an afterthought, is there any way to extend this general idea
to other docstrings beyond function docstrings?
I imagine that the decorator idea works well for method docstrings
too
subpaths leading to this file
are fine.
(For all I know, it is possible that, even though the libeng.dylib
file matches _engClose, this is only a fragment of a longer symbol
name.)
Can anyone suggest a way to fix this error?
Thanks!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.1782.1287266502.29448.python-l...@python.org Emile van Sebille
em...@fenx.com writes:
On 10/16/2010 2:15 PM kj said...
The following interaction (in OS X) summarizes the situation:
% echo $DYLD_LIBRARY_PATH
/Applications/MATLAB_R2010a.app/bin/maci64
% grep -r _engClose
In 8hujfsfb9...@mid.individual.net Gregory Ewing
greg.ew...@canterbury.ac.nz writes:
kj wrote:
The hardest case is module docstrings.
Actually, that one's quite easy, just assign to __doc__.
__doc__ = This is a %s docstring % made-up
D'oh! Thanks.
--
http://mail.python.org/mailman
this exchange.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
a
*lot* of time, so by now I've developed what can only be described
as a phobia to it. I probably need professional help at this point.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
it. Similarly
for other more complicated variations on this theme.
Anyway, thanks for the code. It's very useful.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In 4cae667c$0$29993$c3e8da3$54964...@news.astraweb.com Steven D'Aprano
st...@remove-this-cybersource.com.au writes:
On Fri, 08 Oct 2010 00:23:30 +, kj wrote:
Because it's always better to use a well-written, fast, efficient,
correct, well-tested wheel than to invent your own slow
me with despair. As much as I dislike it, sooner or
later I'll have to go on faith.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In i8loa2$3o...@reader1.panix.com kj no.em...@please.post writes:
At any rate, using your [i.e. Arnaud's] suggestions in this and
your other post, the current implementation of frozendict stands
at:
class frozendict(dict):
for method in ('__delitem__ __setitem__ clear pop popitem setdefault
In mailman.1461.1286539843.29448.python-l...@python.org Jonas H.
jo...@lophus.org writes:
On 10/08/2010 02:23 AM, kj wrote:
Here's my implementation suggestion:
class frozendict(dict):
def _immutable_error(self, *args, **kwargs):
raise TypeError(%r object is immutable % self
that would imply a consistent iteration
order.)
Thanks again!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
the damn things).
If you had something else in mind, please let me know.
~kj
--
http://mail.python.org/mailman/listinfo/python-list
In m2fwwjazs2@web.de de...@web.de (Diez B. Roggisch) writes:
kj no.em...@please.post writes:
The short version of this question is: where can I find the algorithm
used by the tuple class's __hash__ method?
Surprisingly, in the source:
http://google.com/codesearch/p?hl=de#-2BKs-LW4I0
,
~kj
--
http://mail.python.org/mailman/listinfo/python-list
for mutability. Is there one?
Thanks!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
ugly, I sure how there's another way
that is a lot more beautiful than this one.
TIA!
~kj
--
http://mail.python.org/mailman/listinfo/python-list
setdefault '
'update').split():
exec
def %s(self, *a, **k):
cn = self.__class__.__name__
raise TypeError('%%s' object is not mutable %% cn)
% method
def __hash__(self):
return hash(frozenset(self.items()))
...which is a lot nicer!
Thanks!
~kj
--
http
key for
something like this? (Basically I'm looking for a good way to
combine hashkeys.)
Thanks!
kj
--
http://mail.python.org/mailman/listinfo/python-list
a rather un-Pythonic hack, but seeing there
in the venerable collections module suggested to me that maybe this
is actually the best way to achieve this effect in Python. Is this
so? If not, please let me know of a better way.
TIA!
kj
--
http://mail.python.org/mailman/listinfo/python-list
in a SyntaxError:
invalid syntax.
Is there any way to use a loop to set a whole bunch of local
variables (and later refer to these variables by their individual
names)?
TIA!
kj
--
http://mail.python.org/mailman/listinfo/python-list
reply; rather,
I'm interested in reading people's take on the question and their
way of dealing with those functions they consider worthy of the
standard library.)
kj
--
http://mail.python.org/mailman/listinfo/python-list
The following attempt to get a list of partial sums fails:
s = 0
[((s += t) and s) for t in range(1, 10)]
File stdin, line 1
[((s += t) and s) for t in range(1, 10)]
^
SyntaxError: invalid syntax
What's the best way to get a list of partial sums?
TIA!
kj
--
http
Does anyone know of a Python module for *moderate* time-stretching[1]
an MP3 (or AIFF) file?
FWIW, the audio I want to time-stretch is human speech.
TIA!
~K
[1] By moderate time stretching I mean, for example, taking an
audio that would normally play in 5 seconds, and stretch it so that
it
In mailman.123.1282955703.29448.python-l...@python.org Benjamin Kaplan
benjamin.kap...@case.edu writes:
On Fri, Aug 27, 2010 at 8:01 PM, kj no.em...@please.post wrote:
Hi! =A0Does anyone know of an easy way to convert a Unicode string into a=
n image file (either jpg or png)?
Do you mean
Hi! Does anyone know of an easy way to convert a Unicode string into an image
file (either jpg or png)?
TIA!
~k
--
http://mail.python.org/mailman/listinfo/python-list
In mailman.2125.1281849995.1673.python-l...@python.org Chris Rebert
c...@rebertia.com writes:
On Sat, Aug 14, 2010 at 5:13 PM, kj no.em...@please.post wrote:
In af7fdb85-8c87-434e-94f3-18d8729bf...@l25g2000prn.googlegroups.com Ra=
ymond Hettinger pyt...@rcn.com writes:
On Aug 12, 1:37=3DA0pm
In i486al$b...@online.de Martin v. Loewis mar...@v.loewis.de writes:
Does anyone know of such a module?
ZODB supports persistent lists.
Thanks; I'll check it out.
~K
--
http://mail.python.org/mailman/listinfo/python-list
In af7fdb85-8c87-434e-94f3-18d8729bf...@l25g2000prn.googlegroups.com Raymond
Hettinger pyt...@rcn.com writes:
On Aug 12, 1:37=A0pm, Thomas Jollans tho...@jollybox.de wrote:
On Tuesday 10 August 2010, it occurred to kj to exclaim:
I'm looking for a module that implements persistent lists
Here's the problem: I have about 25,000 mp3 files, each lasting,
*on average*, only a few seconds, though the variance is wide (the
longest one lasts around 20 seconds). (These files correspond to
sample sentences for foreign language training.)
The problem is that there is basically no
I'm looking for a module that implements persistent lists: objects
that behave like lists except that all their elements are stored
on disk. IOW, the equivalent of shelves, but for lists rather
than a dictionaries.
Does anyone know of such a module?
(I suppose that I could slap together a
I'm always happy to be nominated for QOTW, in this case I didn't
say it, and the nomination should go to KJ.
(The ol' insert Monty Python reference move: it never fails...)
--
http://mail.python.org/mailman/listinfo/python-list
In pan.2010.07.23.21.46.03.547...@nowhere.com Nobody nob...@nowhere.com
writes:
On Fri, 23 Jul 2010 10:42:26 +, Steven D'Aprano wrote:
Don't write bare excepts, always catch the error you want and nothing
else.
That advice would make more sense if it was possible to know which
I want to write code that parses a file that is far bigger than
the amount of memory I can count on. Therefore, I want to stay as
far away as possible from anything that produces a memory-resident
DOM tree.
The top-level structure of this xml is very simple: it's just a
very long list of
In i3c7lc$e6v$0...@news.t-online.com Peter Otten __pete...@web.de writes:
How about
http://effbot.org/zone/element-iterparse.htm#incremental-parsing
Exactly!
Thanks!
~K
--
http://mail.python.org/mailman/listinfo/python-list
Is there a simple way to get Python to pretty-print a dict whose
values contain Unicode? (Of course, the goal here is that these
printed values are human-readable.)
If I run the following simple script:
from pprint import pprint
x = u'\u6c17\u304c\u9055\u3046'
print '{%s: %s}' % (u'x', x)
In mailman.778.1279213534.1673.python-l...@python.org Thomas Jollans
tho...@jollans.com writes:
On 07/15/2010 06:41 PM, kj wrote:
In mailman.733.1279124991.1673.python-l...@python.org Thomas Jollans
tho...@jollans.com writes:
http://docs.python.org/library/ctypes.html#fundamental-data
In mailman.733.1279124991.1673.python-l...@python.org Thomas Jollans
tho...@jollans.com writes:
http://docs.python.org/library/ctypes.html#fundamental-data-types
c_longdouble maps to float
Thanks for pointing this out!
~K
(Does it make *any difference at all* to use c_longdouble instead
of
This is a question _for Emacs users_ (the rest of you, go away :) ).
How do you do Python code-folding in Emacs?
Thanks!
~K
--
http://mail.python.org/mailman/listinfo/python-list
I have a C library function hg that returns a long double, so when
I import it using C types I specify this return type like this:
MYLIB.hg.restype = ctypes.c_longdouble
But certain non-zero values returned by hg appear as zero Python-side.
If I modify hg so that it prints out its value right
I define
ninv = 1.0/n
...where n is some integer, and I want to write some function f such
that f(m * ninv) returns the smallest integer that is = m * ninv,
where m is some other integer. And, in particular, if m is p*n
for some integer p, then f((p*n) * ninv) should return the integer
p.
Please disregard my ineptly posed question.
~K
In i0l9f3$7d...@reader1.panix.com kj no.em...@please.post writes:
I define
ninv = 1.0/n
...where n is some integer, and I want to write some function f such
that f(m * ninv) returns the smallest integer that is = m * ninv,
where m is some
Task: given a list, produce a tally of all the distinct items in
the list (for some suitable notion of distinct).
Example: if the list is ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b',
'c', 'a'], then the desired tally would look something like this:
[('a', 4), ('b', 3), ('c', 3)]
I find myself
Thank you all!
~K
--
http://mail.python.org/mailman/listinfo/python-list
I want to implement clean-up functions for scripts to be run on a
Linux cluster (through LSF). The goal is to make sure that a
minimal wrap-up sequence (print diagnostic info, flush buffers,
etc.) gets executed if the job is terminated for some reason. (The
most common reason for premature
In mailman.86.1273631889.32709.python-l...@python.org Tim Chase writes:
05/11/2010 09:07 PM, Terry Reedy wrote:
If os.walk were rewritten, it should be as an iterator (generator).
Directory entry and exit functions could still be added as params.
It *is* an iterator/generator. However, I
In mailman.82.1273630064.32709.python-l...@python.org Terry Reedy
tjre...@udel.edu writes:
On 5/11/2010 3:49 PM, kj wrote:
PS: I never understood why os.walk does not support hooks for key
events during such a tree traversal.
Either 1) it is intentionally simple, with the expectation
I want implement a function that walks through a directory tree
and performs an analsysis of all the subdirectories found. The
task has two essential requirements that, AFAICT, make it impossible
to use os.walk for this:
1. I need to be able to prune certain directories from being visited.
In mailman.75.1273614838.32709.python-l...@python.org Tim Chase
python.l...@tim.thechases.com writes:
That said, the core source for os.walk() is a whole 23
lines of code, it's easy enough to just clone it and add what you
need...
Thanks, that was a good idea.
~K
--
I want to define a class attribute that is computed from other
class attributes. Furthermore, this attribute should be inheritable,
and its value in the subclasses should reflect the subclasses values
of the attributes used to compute the computed attribute. I tried
the following:
class
In 4bdb4e4...@dnews.tpgi.com.au Lie Ryan lie.1...@gmail.com writes:
class MetaSpam(type):
@property
def Y(cls):
return cls.X * 3
class Spam(object):
__metaclass__ = MetaSpam
and there we go:
class Ham(Spam):
... X = 7
...
class Eggs(Spam):
... X = '.'
...
Ham.Y;
I'm looking for a Python-based, small, self-contained package to
hand out API keys, in the same spirit as Google API keys.
The basic specs are simple: 1) enforce the one key per customer
rule; 2) be robot-proof; 3) be reasonably difficult to circumvent
even for humans.
(This is for a web
In 4bb802f7$0$8827$c3e8...@news.astraweb.com Steven D'Aprano
st...@remove-this-cybersource.com.au writes:
On Sat, 03 Apr 2010 22:58:43 +, kj wrote:
Suppose I have a function with the following signature:
def spam(x, y, z):
# etc.
Is there a way to refer, within the function
Suppose I have a function with the following signature:
def spam(x, y, z):
# etc.
Is there a way to refer, within the function, to all its arguments
as a single list? (I.e. I'm looking for Python's equivalent of
Perl's @_ variable.)
I'm aware of locals(), but I want to preserve the
In hp8h73$k1...@reader1.panix.com kj no.em...@please.post writes:
Suppose I have a function with the following signature:
def spam(x, y, z):
# etc.
Is there a way to refer, within the function, to all its arguments
as a single list? (I.e. I'm looking for Python's equivalent of
Perl's
In hp8kc9$dg...@reader1.panix.com kj no.em...@please.post writes:
In hp8h73$k1...@reader1.panix.com kj no.em...@please.post writes:
Suppose I have a function with the following signature:
def spam(x, y, z):
# etc.
Is there a way to refer, within the function, to all its arguments
1 - 100 of 371 matches
Mail list logo