r 2.3 and 2.4 (and
perhaps 2.5 by the time I'll be done, as progress is being quite slow --
as uber technical lead at Google, I'm pretty busy these days!-), but I
do agree that the current edition is still quite useful.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Alex <[EMAIL PROTECTED]> wrote:
...
> I have a series of new classes with child-parent relationship and each
> has unique __slots__. They don't have __dict__ . I need to be able to
> pickle and unpickle them. As far as I could understand, I need to
> provide __getsta
t (some
future Firefox version might perhaps integrate a Python engine, just
like it integrates a Javascript engine today, but I wouldn't hold my
breath waiting;-).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
with early binding), I'd code:
def logit(fn):
method = getattr(log, fn.func_name)
def callit(**kwargs): return method(kwargs)
return callit
If you need to do late binding instead, you can move the getattr to
inside the body of callit.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
, since block always
keeps the last overlap bytes; it needs to be changed into something like
(warning -- untested code!-)
if overlap>0:
while True:
next = f.read(blocksize-overlap)
if not next: break
block = block[-overlap:] + next
yield block
else:
while True:
next = f.r
Python, yes. In other equally
valid implementations of the language, such as Jython, IronPython, or,
for all we know, some future implementation of Classic, that may well
not be the case. Many, quite reasonably, dislike relying on a specific
implementation's peculiarities, and prefer to
ing, untested code...]]
infile = open('infile.txt')
oufile = open('oufile.txt', 'w')
for line in infile:
if line.strip().isdigit(): oufile.write(line)
oufile.close()
infile.close()
Alex
--
http://mail.python.org/mailman/listinfo/python-list
would mean no keywords would need to be added).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
you can use a lambda factory in the same role
as the much clearer and more readable factory function you had (which I
keep thinking is the _sensible_ solution)...:
funcs = [ (lambda x,y: lambda n: x*y/n)(x,y) for x,y in a ]
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Max Rybinsky <[EMAIL PROTECTED]> wrote:
> Thank you for explanation, Alex.
> It appears that almost every beginner to Python gets in trouble with
> this ...feature. :)
Almost every beginner to Python gets in trouble by expecting "do what
I'm thinking of RIGHT NOW&qu
Paul Watson <[EMAIL PROTECTED]> wrote:
> "Alex Martelli" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> > In today's implementations of Classic Python, yes. In other equally
> > valid implementations of the language, such as J
, emit messages that can erroneously end up in
the redirected stdout of your program... VERY, VERY bad things.
Don't ever catch and ``handle'' exceptions in such ways. In particular,
each time you're thinking of writing a bare 'except:' clause, think
again, and you'll most likely find a much better approach.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
<[EMAIL PROTECTED]> wrote:
...
> For the other Alex observations (about Mac OsX and my examples of
> automation centered on web automation) I have a PC, and the fact that
> Python is very good at dealing with the web, doesn't help too much
> in this case...
All of your
arg1, arg2=arg2)
I don't understand what added value all of those extra, contorted lines
are supposed to bring to the party.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
memory chip just
melted, the CPU's on strike, locusts...! Not stuff any program can do
much about in the short term, except by switching to a different
machine.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
equent use case, so this further level of refinement
was apparently not warranted ("use only as much power as you need" is a
programming principle that tends to promote simplicity, and therefore,
in many cases, is well worth adhering to).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
>
> > I find this style of coding repulsive when compared to:
> >
> > def foo(arg1=None, arg2=None):
> > print dict(arg1=arg1, arg2=arg2)
> >
> > I don't understand
pt spinning even the child process was ended.
It would be astonishing if it were otherwise! The loop in function spin
is deliberately coded to NEVER terminate, so of course it never does.
> Any idea ? Thanks!
Have the spin function accept the pid argument and exit the loop if said
pid has termi
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
>
> > Have the spin function accept the pid argument and exit the loop if said
> > pid has terminated; to check the latter, e.g., os.kill(pid, 0) -- this
> > will raise an OSError if no process with t
John J. Lee <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> [...]
> > If you're trying to test your code to ensure it explicitly closes all
> > files, you could (from within your tests) rebind built-ins 'file' and
> >
t to re-raise the "accidentally caught" exception if needed.
But if something goes wrong that you had NOT anticipated, just log as
much info as you can for the postmortem, give nice diagnostics to the
user if you wish, and do NOT keep processing -- and for these
diagnostic-only purposes, use sys.excepthook, not a slew of try/except
all over your application making it crufty and unmaintainable.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
he right tool for the
job: print for simple output, often diagnostic in nature, where you
don't mind the spaces and/or newlines that implies; sys.stdout.write
when you do want to really control every aspect of the output.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Alex <[EMAIL PROTECTED]> wrote:
> I have a serious problem and I hope there is some solution. It is
> easier to illustrate with a simple code:
>
> >>> class Parent(object):
> __slots__=['A', 'B']
> def __init__(self, a, b):
>
is the while loop part. Could it be better?
What about replacing this whole block with, say...:
return ':'.join(mac[c:c+2] for c in range(0, 12, 2)).upper()
(as you did already check that len(mac) is 12...)
Alex
--
http://mail.python.org/mailman/listinfo/python-list
I've seen a few discussion about the use of 'super' in Python, including
the opinion that 'super' should only be used to solve inheritance
diamond problem. (And that a constructor that wants to call the
superclass methods should just call them by name and forget about super.)
What is people's op
on
what exactly you're coding, the size of the project etc., but what I'm
trying to find out about is the python communities' recognised good
practices.
thanks,
alex
--
http://mail.python.org/mailman/listinfo/python-list
I know that I can catch access to unknown attributes with code something
like the following:
class example:
def __getattr__(self, name):
if name == 'age':
return __age
else:
raise AttributeError
but is there an existing mixin helper class in
bruno at modulix wrote:
> Alex Hunsley wrote:
>
>>There's no really specific questions in this post, but I'm looking for
>>people's thought on the issues within...
>>
>>
>>The two main versions I've encountered for data pseudo-hiding
&
Jorge Godoy wrote:
> Alex Hunsley <[EMAIL PROTECTED]> writes:
>
>
>>Sorry, I wasn't being clear. What I should have said is that I don't like the
>>idea of a typo in an assignment causing the assigning of the wrong thing.
>>e.g. imagine a si
Jorge Godoy wrote:
> Alex Hunsley <[EMAIL PROTECTED]> writes:
>
>
>>Sorry, I wasn't being clear. What I should have said is that I don't like the
>>idea of a typo in an assignment causing the assigning of the wrong thing.
>>e.g. imagine a si
Steven D'Aprano wrote:
> On Mon, 31 Oct 2005 10:39:40 +0000, Alex Hunsley wrote:
>
>
>>I know that I can catch access to unknown attributes with code something
>>like the following:
>>
>>class example:
>> def __getattr__(self, name):
>>
Jorge Godoy wrote:
> Alex Hunsley <[EMAIL PROTECTED]> writes:
>
>
>>Btw, can you recall the subject line of the thread? I'd like to google groups
>>for it and have a read of that thread...
>>ta!
>
>
> Search for: "alex martelli pychecker&
[EMAIL PROTECTED] wrote:
> Need python Pro at [EMAIL PROTECTED] , if u wanna help,
1) Why would anyone want to help you when you're not even willing to
spend the (small) time and effort to spell simple words like "you"
correctly or make sure your post actually makes sense? Start by helping
you
Steven D'Aprano wrote:
> On Mon, 31 Oct 2005 10:35:19 +0000, Alex Hunsley wrote:
>
>
>>There's no really specific questions in this post, but I'm looking for
>>people's thought on the issues within...
>>
>>
>>The two main versions I&
restriction easily -- such
restrictions are always intended against *accidental* cases, not against
deliberate attacks).
Differently from __slots__, Rats gives no problems with pickling,
inheritance, etc, etc.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Alex Hunsley <[EMAIL PROTECTED]> wrote:
> There's no really specific questions in this post, but I'm looking for
> people's thought on the issues within...
>
>
> The two main versions I've encountered for data pseudo-hiding
> (encapsulation) in p
Alex Hunsley <[EMAIL PROTECTED]> wrote:
> I've seen a few discussion about the use of 'super' in Python, including
> the opinion that 'super' should only be used to solve inheritance
> diamond problem. (And that a constructor that wants to call the
>
language specs neither mandate nor forbid such behavior. How, exactly,
does the OP believe the language specs should "allow" (presumably,
REQUIRE) ``the runtime'' to communicate the sum total of all that it's
doing or not doing (beyond whatever the language specs themselves may
require or forbid it to do) on any particular occasion...?!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Aahz <[EMAIL PROTECTED]> wrote:
> In article <[EMAIL PROTECTED]>,
> Alex Martelli <[EMAIL PROTECTED]> wrote:
> >
> >the canonical idiom when you need such distinction is:
> >
> >_not_there = object()
> >def foo(bar=_not_there, baz=_n
Gerhard Häring wrote:
> Alex Hunsley wrote:
>
>> [EMAIL PROTECTED] wrote:
>>
>>> Need python Pro at [EMAIL PROTECTED] , if u wanna help,
>>
>> [...]
>> 2) Why should someone willing to help you enter into a private email
>> discussion? [...]
Fredrik Lundh wrote:
> Alex Hunsley wrote:
>
>
>>2) Why should someone willing to help you enter into a private email
>>discussion? Newsgroups like this exist to help people
>
>
> looks like "Fan" wants to run his own group:
>
> ht
Alex Hunsley wrote:
> Fredrik Lundh wrote:
>
>> Alex Hunsley wrote:
>>
>>
>>> 2) Why should someone willing to help you enter into a private email
>>> discussion? Newsgroups like this exist to help people
>>
>>
>>
>> looks like &q
te
"there is NOTHING here". I love it.
For pickling, object() as a unique "nothing here, NOT EVEN a None"
marker (AKA sentinel) works fine.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
READY called func1
at the time the execfunc dict was being built.
Suggestion: parenthesise differently to make tuples:
execfunc = { 'key1' : (func1, ()),
'key2' : (func2, args) }
now, something like:
f, a = execfunc[k]
f(**a)
will work for either key.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Leif K-Brooks <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
> > execfunc = { 'key1' : (func1, ()),
> > 'key2' : (func2, args) }
> >
> > now, something like:
> >
> > f, a = execfunc[k]
> > f(*
Paul Rubin <http://[EMAIL PROTECTED]> wrote:
...
> You can use re.search on array.array byte vectors. I don't know how
> the speed compares with string.find.
Pretty well, though of course one should measure on representative cases
for one's specific application needs:
A beginner might be best advised to stick with CPython (and, if DotNet
is needed, perhaps the Python-like language Boo) while IronPython
stabilizes and fleshes out, but I'm rather more optimistic than you
about the speed with which that will happen.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
tpatterns with re or string.find; if
the bits were packed 8 to a byte, such searches would be very hard.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
even a committee,
would no doubt produce even more bloat.
If you want bloat, go use a bloated language (there are so incredibly
many of them, that you'll have your pick!), and please leave alone one
of the few languages that have managed to at least control the amount of
cruft they have accumulated over the years (we keep hoping for a REMOVAL
of many legacy features come Python 3.0 time, in fact).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
ea but not your formula. If the most junior team
member was 1 month out of school, would it really be OK for the
supervisor to be somebody who graduated 3 months ago?-)
Alex
--
http://mail.python.org/mailman/listinfo/python-list
functions*, i.e., ones written in *C*. Just wrap any builtin
function you need to register as observer into a tiny Python-coded
wrapper and live happily ever after.
...
> Not all objects can be weakly referenced; those objects which can
> include class instances, functions written in Python (but
you observe is the only possible one.
If you want copies instead, ASK for copies...:
gridSystemId = [ [None]*columns for x in xrange(rows) ]
Alex
--
http://mail.python.org/mailman/listinfo/python-list
On 3 Nov 2005, at 05:03, Alex Martelli wrote:
> Brandon K <[EMAIL PROTECTED]> wrote [inverting his topposting!]:
>
>
>>> Six megabytes is pretty much nothing on a modern computer.
>>>
>
>
>> BTW, it'd be 6 megabits or 750kb ;)
>>
>
&g
Alex Stapleton <[EMAIL PROTECTED]> wrote:
...
> >>> Six megabytes is pretty much nothing on a modern computer.
> >
> >> BTW, it'd be 6 megabits or 750kb ;)
> >
> > ...but Mike was proposing using one digit per bit, hence, 6 megabytes.
> >
red, that apparently doesn't
matter) and based on type inference, with several similarities to Python
(I have no experience of Boo since Mono's installations on MacOSX
haven't worked well for me, but on paper it looks nice).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
some low levels, and BoostPython as "glue"); other
Python success stories show it used in payroll applications (the hugely
successful PayThyme), productivity ones (OSAF's Chandler), etc, etc.
Look around the web for "Python success stories" and you may find man
mentations, pyrex, BoostPython, and a zillion other tools, it's
just about impossible to give examples of libraries which Python cannot
use pretty easily and successfully. Library availability (through any
or all of these tools) is one of the strong practical argument FOR
Python!-)
Alex
--
http://mail.python.org/mailman/listinfo/python-list
's a recipe for that in the Python Cookbook (2nd edition).
(I believe py2app doesn't need to package the standard library, either,
since it comes with MacOSX 10.3 and later, but I haven't checked).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
for me.
>
> I really enjoy python. So many good things have been added to the
> language without taking the fun away :-)
Glad to hear this!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
ou didn't
top-post, though (i.e., if you didn't put your comments BEFORE what
you're commenting on -- that puts the "conversation" in a weirdly
distorted order, unless one give up on quoting what you're commenting
on, or invests a lot of time and energy in editing...;-).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Rocco Moretti <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
> > The Eternal Squire <[EMAIL PROTECTED]> wrote:
> >...
> >
> >>2) Consider what he really wants for a supervisor of software
> >>engineers. Ideally such a person should b
thons
standard library) and you'll do even better!-)
Alex
--
http://mail.python.org/mailman/listinfo/python-list
book -- but it does
not address the specific problem you desire. Raedler's recipe does.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
le(23)
In this case, the 'self' inside each method refers to the same object to
which the name 'x' refers ``on the outside''.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
ers, on average -- admittedly, out of these, only sawzall and
pyrex are ones I've used "for real", the other ones I've studied but
never found real-life occasions to use, but that, too (using IRL about
25% of the languages one learns), is roughly par for the course (I would
g
at's all of
the difference that's biting you...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
cription's fee. In those 2 weeks you
get to read for free a few books in the online library -- I'd suggest
sampling the Nutshell, the Cookbook and possibly a couple more...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
n about the several small differences between the new-style
object model and the old-style, legacy one.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> I m not a python Expert or anythin
> i need help, i m losin my motivation to continue with python
> can anyone inspire me again.???
Not without knowing more about your motivations for starting Python in
the first place...
Alex
--
http://mail.python.or
On 4 Nov 2005, at 10:26, Ben Sizer wrote:
> Tom Anderson wrote:
>
>> On Wed, 2 Nov 2005, Dan Bishop wrote:
>>
>>
>>> Tor Erik Sønvisen wrote:
>>>
>>>
I need a time and space efficient way of storing up to 6 million
bits.
>>>
>>> The most space-efficient way of storing bits is to
Magnus Lycka <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
> > Yes, but I haven't found knowing (and using) Python dampens my
> > enthusiasms for learning new languages.
>
> But you're more enthusiatic than most of us Alex. I wish
> I could say th
nderstand
why that is the case), and the best way to reach me these days is
through "gmail.com" .
Alex
--
http://mail.python.org/mailman/listinfo/python-list
ting A will not. I think the right correction to the Nutshell
is therefore:
x = C.__new__(C, 23)
if isinstance(x, C): type(x).__init__(x, 23)
and this is how I plan to have it in the 2nd edition.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> > I can't imagine NOT getting enthusiastic and stimulated by reading Van
> > Roy and Hariri's book -- it IS quite as good and readable as SICP.
>
> It's been o
a great time to
send me any bug reports or (minor;-) feature requests, since I hope to
release a "1.01 release candidate" of gmpy ASAP. I'm currently unable
to build any Windows version -- any volunteer for THAT task is doubly
welcome;-).
Thanks,
Alex
--
http://mail.python.org/mailman/listinfo/python-list
mpy.mpz(4)
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: unsupported operand type(s) for //: 'mpz' and 'mpz'
while, on my machine:
Helen:~/gmpy/test alex$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer,
Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> > gmpy users able to download and build from sourceforge's cvs are
> > encouraged to test the current CVS version.
>
> Oh cool, I wondered whether any gmpy maintenance was
hink VC per se will suffice -- somebody
needs to build or find a suitable version of GMP for Windows, too.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
ot;raw"
> device files, where the current offset and transfer size must be a
> multiple of some block size?
Very likely. It is also likely that the same applies to the destination (ie
memory) address.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
nybody to
_worry_ about "the future of ... Python"?!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
I've looked at getitem, getslice, and iter. What is it if not one of these?
Obviously James hadn't looked at __iter__ in the RIGHT way!
> > And, how about the "**something" operator?
> >
> > James
>
> A dictionary would be pretty much the same except
except Hasan's talk (but, you'll miss a chance to sample
Google's famous food...;-). Emailing Neal would still be nice, just so
we know you're expected to show up... but, not absolutely _required_!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
loadable from sourceforge).
> Thanks for the updates to gmpy!
You're welcome, and thank YOU for the feedback &c.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
On 8 Nov 2005, at 12:21, [EMAIL PROTECTED] wrote:
> which feature of python do you like most?
>
I think this question might be a bit like asking whether you love
your mum or your dad most to a lot of people ;)
People like Python as a whole usually. It's not like C++ or PHP or
anything where
some small amount of
memory -- any object that's unique and you never need to pass can play
the same role as a sentinel, obviously.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
h rice existed in the world to satisfy the request...;-).
Well, repeated halving is just like repeated doubling "backwards", so it
squeezes vast ranges of possibilities down to tiny ones just as fast as
repeated doubling produces oceans of rice from a small chessboard;-).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
e clients
thin. The only issue is, your apps will require network connectivity to
execute... but these days, with airlines and train lines busy adding
wi-fi, and towns busily blanketing themselves with free wi-fi, etc, etc,
that's less and less likely to be a big problem...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
eedup wrt Python, and
some speedup wrt gmpy 1.0 (all GMP's merit -- I didn't address
performance aspects at all in this delta). Just out of curiosity: what
performance do you get on the Athlon with a pentium3-compiled GMP?
> I did very that the tp_compare errors are fixed.
the itertools module is and remains a PRECIOUS resource. If
you want an iterator rather than a list, itertools.ifilter is quite
appropriate here.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
iltin namespace shouldn't get too crowded. But what I
think matters little -- what __GvR__ thinks is more important...!-)
Alex
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Alex Martelli wrote:
> > This becomes a valid list comprehension by writing 'if' instead of
> > 'when'.
> valid, yes. efficient, I am not sure.
>
> [ x for x in xrange(1000) if p(x) ]
>
&
ators, lists, files,
dicts, etc, etc -- I'm not so sure. Right now, if I mistakenly try to
add a list to a dict, I get an exception which immediately alerts me to
my mistake. I definitely wouldn't want to lose that...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
frequent use cases for such an addition, I doubt it's
worth even trying to make a patch in order to time it against
itertools.takewhile...
Alex
--
http://mail.python.org/mailman/listinfo/python-list
intermediate
object. For example, instead of:
for x in takefile(foo, takewhile(bar, zlupp)): ...
you may choose to code, e.g.,
zlupps_bars = takewhile(bar, zlupp)
zb_foos = takewhile(foo, zlupps_bars)
for x in zb_foos: ...
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
th versions
> (not suprising really since both are using the same libgmp.so on the
> system).
Yep, as I said any speed differences should be due to the underlying
GMP, since gmpy.c itself has not undergone any speed-related change.
> Thanks and look forward to the release
Thank YOU for th
uot; (whatever that means), but in
assembly code, C, C++... so your last paragraph is easily shown to be an
irrelevant aside -- it's not an issue of what language the code is in.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
t; (and equally unprintable in
polite company). If I could choose to eradicate only one of these two
from the world, I'd opt for the spelling -- the widespread and totally
unfounded belief in the worth of obfuscation is also damaging, but less
so, since it only steals some time and energy from
;' would? I don't see how "it breaks out of the
whole thing expression" -- it terminates ONE for-clause (and what else
would your cherished ``when'' do?).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
<[EMAIL PROTECTED]> wrote:
> I've created Windows binaries for Python 2.3 and 2.4. It should be
> compatible with PentiumPro or later processors.
Thanks! I hope to package up a release early next week, and to include
these.
Alex
--
http://mail.python.org/mailman/listinfo/python-list
or with -Qnew on Python's commandline or 'from __future__ import
division' at the top of your module -- to help you get used to it).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
301 - 400 of 2602 matches
Mail list logo