If you're interested in gmpy (the Python wrapper of GMP, for
unlimited-precision arithmetic, rationals, random number generation,
number-theoretical functions, etc), please DO check out
http://code.google.com/p/gmpy/ -- gmpy 1.02 is there (as far as I can
tell) in a workable state. Source on
Jeff Shannon [EMAIL PROTECTED] wrote:
Because Python uses a fundamentally different concept for variable
names than C/C++/Java (and most other static languages). In those
languages, variables can be passed by value or by reference; neither
term really applies in Python. (Or, if you
GerritM [EMAIL PROTECTED] wrote:
How can this type of fundamental knowledge be patented? I am afraid this is
again an example of a total failure of the current patent system.
As a European citizen, you have a chance to make a difference to
software patentability in Europe -- think globally,
harold fellermann [EMAIL PROTECTED] wrote:
File /sw/lib/python2.4/pickle.py, line 760, in save_global
raise PicklingError(
pickle.PicklingError: Can't pickle type 'hyper.PeriodicGrid': it's
not found as hyper.PeriodicGrid
dir(hyper)
['Dir', 'Neighbors', 'PeriodicGrid',
harold fellermann [EMAIL PROTECTED] wrote:
...
Here it goes...:
OOPS, error (exceptions.ImportError): No module named hyper
So, the __import__ in pickle fails -- indeed, __import__('foo') when
'foo' ``is imported from a subpackage'' is _supposed_ to fail, as
'hyper' is not the name you
kery [EMAIL PROTECTED] wrote:
...
Any schedule for publication of 2nd Ed? I just bought 1st Ed.
The 2nd edition Python Cookbook appears to be on-track for PyCon (late
March) for the very first ink-on-paper -- probably April in bookstores.
The 2nd edition Python in a Nutshell is more
Steven Chan [EMAIL PROTECTED] wrote:
I completely agree. I'm also waiting for an advanced Python/project
management book that helps folks out with large-scale projects.
I won't schedule that project until the Nutshell 2nd ed is substantially
done... and I'm not _promising_ I'll schedule it
[EMAIL PROTECTED] wrote:
...
Is this mean't to only cover additional entries which were added in
the 2nd edition, or is it also mean't to encompass entries which were
carried over from the 1st edition as well.
The latter: it covers all entries.
If it is both, then the editing must have
Timothy Fitz [EMAIL PROTECTED] wrote:
...
Perhaps Tim Peters is far too
concise for my feeble mind wink
It's Zen, it's beyond Mind. Let it speak to your True Self!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Craig Ringer [EMAIL PROTECTED] wrote:
...
I've just checked the OSX 10.3 machine here, and it fails to import
tkinter there too. I'd say Apple just don't build Python with Tk
support.
No idea about any 10.2, sorry, but on 10.3 that's not the problem: Tk
support is there alright, it's Tcl/Tk
Johnny Lin [EMAIL PROTECTED] wrote:
...
my understanding about locals() from the nutshell book was that i
should treat that dictionary as read-only. is it safe to use it to
delete entries?
Speaking as the Nutshell author: it's safe, it just doesn't DO
anything. I _hoped_ locals() would
TB [EMAIL PROTECTED] wrote:
Is there an elegant way to assign to a list from a list of unknown
size? For example, how could you do something like:
a, b, c = (line.split(':'))
if line could have less than three fields?
import itertools as it
a, b, c = it.islice(
it.chain(
Dave Benjamin [EMAIL PROTECTED] wrote:
Can we get a show of hands for all of those who have written or are
currently maintaining code that uses the leaky listcomp feature?
Have written: guilty -- basically to show how NOT to do things.
Currently maintaining: you _gotta_ be kidding!-)
I
Fredrik Lundh [EMAIL PROTECTED] wrote:
...
or (readable):
if len(list) n:
list.extend((n - len(list)) * [item])
I find it just as readable without the redundant if guard -- just:
alist.extend((n - len(alist)) * [item])
of course, this guard-less version depends on N*[x]
Kamilche [EMAIL PROTECTED] wrote:
I want my program to be able to reload its code dynamically. I have a
large hierarchy of objects in memory. The inheritance hierarchy of
these objects are scattered over several files.
Michael Hudson has a nice custom metaclass for that in Activestate's
Francis Girard [EMAIL PROTECTED] wrote:
...
But besides the fact that generators are either produced with the new yield
reserved word or by defining the __new__ method in a class definition, I
don't know much about them.
Having __new__ in a class definition has nothing much to do with
Nick Coghlan [EMAIL PROTECTED] wrote:
5. Several builtin functions return iterators rather than lists, specifically
xrange(), enumerate() and reversed(). Other builtins that yield sequences
(range(), sorted(), zip()) return lists.
Yes for enumerate and reversed, no for xrange:
xx=xrange(7)
André Roberge [EMAIL PROTECTED] wrote:
alex = CreateRobot()
anna = CreateRobot()
alex.move()
anna.move()
H -- while I've long since been identified as a 'bot, I can assure
you that my wife Anna isn't!
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Francis Girard [EMAIL PROTECTED] wrote:
...
A 'def' of a function whose body uses 'yield', and in 2.4 the new genexp
construct.
Ok. I guess I'll have to update to version 2.4 (from 2.3) to follow the
discussion.
It's worth upgrading even just for the extra speed;-).
Since you
Fredrik Lundh [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
or (readable):
if len(list) n:
list.extend((n - len(list)) * [item])
I find it just as readable without the redundant if guard -- just:
alist.extend((n - len(alist)) * [item])
the guard makes
Craig Ringer [EMAIL PROTECTED] wrote:
. data = ''.join(x for x in infile)
Maybe ''.join(infile) is a better way to express this functionality?
Avoids 2.4 dependency and should be faster as well as more concise.
Might it be worth providing a way to have file objects seek back to the
current
Diez B. Roggisch [EMAIL PROTECTED] wrote:
Nick Coghlan wrote:
If this only has to work for classes created for the purpose (rather than
for an arbitrary class):
Certainly a step into the direction I meant - but still missing type
declarations. And that's what at least I'd like to see
Nick Craig-Wood [EMAIL PROTECTED] wrote:
...
Or this version if you want something other than as the default
a, b, b = (line.split(':') + 3*[None])[:3]
Either you mean a, b, c -- or you're being subtler than I'm grasping.
BTW This is a feature I miss from perl...
Hmmm, I understand
Simon Brunning [EMAIL PROTECTED] wrote:
...
is there a faster way to build a circular iterator in python that by
doing this:
c=['r','g','b','c','m','y','k']
for i in range(30):
print c[i%len(c)]
I don''t know if it's faster, but:
import itertools
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
If it changed the semantics of for-loops in general, that would be quite
inconvenient to me -- once in a while I do rely on Python's semantics
(maintaining the loop control variable after a break; I don't
Paul Rubin http://[EMAIL PROTECTED] wrote:
Dave Benjamin [EMAIL PROTECTED] writes:
Can we get a show of hands for all of those who have written or are
currently maintaining code that uses the leaky listcomp feature?
It's really irrelevant whether anyone is using a feature or not. If
the
Paul Rubin http://[EMAIL PROTECTED] wrote:
...
lists. I think it would be great if the Python library exposed an
interface for parsing constant list and dict expressions, e.g.:
[1, 2, 'Joe Smith', 8237972883334L, # comment
{'Favorite fruits': ['apple', 'banana', 'pear']}, #
[EMAIL PROTECTED] wrote:
...
I think that this must have something to do with python expecting
itself to by in a TTY? Can anyone give any idea of where I should be
going with this?
http://pexpect.sourceforge.net/
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Kamilche [EMAIL PROTECTED] wrote:
Well, I look forward to seeing the new version. I have the old version
of the Python cookbook, it was very useful!
I hope the new one is even better -- many more recipes, all updated to
Python 2.3 and 2.4. The old one will remain useful for all those who
need
Mike C. Fletcher [EMAIL PROTECTED] wrote:
weakref.ref( self, self.close )
but the self.close reference in the instance is going away *before* the
object is called.
Uh -- what's holding on to this weakref.ref instance? I guess the
weakreference _itself_ is going away right after
Nick Craig-Wood [EMAIL PROTECTED] wrote:
Here is a different solution...
class Result:
def set(self, value):
self.value = value
return value
m = Result()
if m.set(re.search(r'add (\d+) (\d+)', line)):
do_add(m.value.group(1), m.value.group(2))
elif
Doug Holton [EMAIL PROTECTED] wrote:
...
oh, you mean that python compiler didn't mean the python compiler.
I wouldn't assume a novice uses terms the same way you would. It was
quite clear from his message that py2exe and the like were what he was
referring to, if you had read his first
Steven Bethard [EMAIL PROTECTED] wrote:
I get a bit uneasy from the repeated calls to m.group... If I was going
to build a class around the re, I think I might lean towards something like:
class ReWithMemory(object):
def search(self, are, aline):
self.mo = re.search(are,
Davor [EMAIL PROTECTED] wrote:
no one ever had to document structured patterns - which definitely
exist - but seem to be obvious enough that there is no need to write a
book about them...
You _gotta_ be kidding -- what do you think, e.g., Wirth's Algorithms
plus Data Structures Equals
Klaus Neuner [EMAIL PROTECTED] wrote:
what is the fastest way to determine whether list l (with
len(l)3) contains a certain element?
if thecertainelement in l:
is the fastest way unless there are properties of l which you're not
telling us about, or unless what you need is not just to
[EMAIL PROTECTED] wrote:
...
Some complexity is not needed, and I am sure even in Python
something could be dropped. But it is difficult to find what can
be removed. Remember that Saint-Exupery quote? Something
like a work of art is finished when there is nothing left to remove?
PA [EMAIL PROTECTED] wrote:
Yes. But even with the best tool and the best intents, projects
still fail. In fact, most IT projects are considered failures:
http://www.economist.com/business/PrinterFriendly.cfm?Story_ID=3423238
The main thesis of the article you quote (although it
rbt [EMAIL PROTECTED] wrote:
Grant Edwards wrote:
On 2005-01-26, rbt [EMAIL PROTECTED] wrote:
Is there an easy way to exclude binary files (I'm working on
Windows XP) from the file list returned by os.walk()?
Sure, assuming you can provide a rigorous definition of 'binary
files'.
Craig Ringer [EMAIL PROTECTED] wrote:
That's not really safe when dealing with utf-8 files though, and IIRC
with UCS2 or UCS4 as well. The Unicode BOM its self might (I'm not sure)
qualify as ASCII.
Nope, both bytes in the BOM have the high-order bit set -- they're 0xFF
and 0xFE -- so they
[EMAIL PROTECTED] wrote:
santanu [EMAIL PROTECTED] writes:
I know a little python (not the OOP part) learnt by studying the online
tutorial. Now I would like to learn it more thoroughly.
I think there's supposed to be a new version of Python in a Nutshell
Just a 2nd edition. I'm just
Steven Bethard [EMAIL PROTECTED] wrote:
...
Beware of mixing iterator methods and readline:
_mixing_, yes. But -- starting the iteration after some other kind of
reading (readline, or read(N), etc) -- is OK...
http://docs.python.org/lib/bltin-file-objects.html
next( )
flamesrock [EMAIL PROTECTED] wrote:
...
(The reason I ask is sortof unrelated. I wanted to use None as a
variable for which any integer, including negative ones have a greater
value so that I wouldn't need to implement any tests or initializations
for a loop that finds the maximum of a
Steven Bethard [EMAIL PROTECTED] wrote:
...
If I could see how to go from 'object' (or 'int', 'str', 'file', etc.)
to 'eval' or '__import__', that would help out a lot...
object.__subclasses__()
[type 'type', type 'weakref', type 'int', type 'basestring',
type 'list', type 'NoneType', type
Nick Coghlan [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
Steven Bethard [EMAIL PROTECTED] wrote:
...
If I could see how to go from 'object' (or 'int', 'str', 'file', etc.)
to 'eval' or '__import__', that would help out a lot...
object.__subclasses__()
...
Traipse through
Paul Rubin http://[EMAIL PROTECTED] wrote:
Franco Fiorese [EMAIL PROTECTED] writes:
* Windows XP Pro: 16566.7 pystones/second
* Linux (kernel 2.6.9 NPTL): 12346.2 pystones/second
I have repeated the test, on Linux, also with other distributions and
kernel but a relevant
Bill Mill [EMAIL PROTECTED] wrote:
...
class Test:
def __init__(self, method):
self.m = new.instancemethod(method, self, Test)
Beautiful! thank you very much. Looking into the new module in
python 2.4, that's equivalent to:
self.m = type(self.__init__)(method, self,
Aahz [EMAIL PROTECTED] wrote:
...
object.__subclasses__()
...
One thing my company has done is written a ``safe_eval()`` that uses a
regex to disable double-underscore access.
will the regex catch getattr(object, 'subclasses'.join(['_'*2]*2)...?-)
Alex
--
Stephen Thorne [EMAIL PROTECTED] wrote:
On Sat, 29 Jan 2005 08:53:45 -0600, Skip Montanaro [EMAIL PROTECTED] wrote:
One thing my company has done is written a ``safe_eval()`` that uses
a regex to disable double-underscore access.
Alex will the regex catch
Skip Montanaro [EMAIL PROTECTED] wrote:
Alex I dunno, maybe I'm just being pessimistic, I guess...
No, I think you are being realistic. I thought one of the basic tenets of
computer security was that which is not expressly allowed is forbidden.
Any attempt at security that attempts to
Nick Coghlan [EMAIL PROTECTED] wrote:
...
If you _can_ execute (whatever) in a separate process, then an approach
based on BSD's jail or equivalent features of other OS's may be able
to give you all you need, without needing other restrictions to be coded
in the interpreter (or whatever
[EMAIL PROTECTED] wrote:
...
1511156 As Requested 2000 adv server -2000AdvSrv.vol001+02.PAR2 (1/4) -
21/27
1511157 As Requested 2000 adv server -2000AdvSrv.vol001+02.PAR2 (2/4) -
21/27
...
would be to look for (1/ in the subject string then find the
denominator and loop
[EMAIL PROTECTED] wrote:
Michael Tobis wrote:
(unwisely taking the bait...)
If you like your language to look like this
http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html
then more power to you.
Thanks for pointing out that interesting article on Fortran 90 bugs.
How long would a
[EMAIL PROTECTED] wrote:
I had in mind the Polyhedron Fortran 90 benchmarks for Windows and
Linux on Intel x86 at
http://www.polyhedron.co.uk/compare/linux/f90bench_p4.html and
http://www.polyhedron.co.uk/compare/win32/f90bench_p4.html . The speed
differences of Absoft, Intel, and Lahey
Christos TZOTZIOY Georgiou [EMAIL PROTECTED] wrote:
...
class Test:
def __init__(self, method):
self.m = new.instancemethod(method, self, Test)
...
self.m = method.__get__(self, Test)
Almost true; not all builtin functions are descriptors though.
...
Dave Benjamin [EMAIL PROTECTED] wrote:
I ran into an odd little edge case while experimenting with functions that
create classes on the fly (don't ask me why):
Why not?. But classes have little to do with it, in my view.
def f(x):
... class C(object):
... x = x
You bind x,
Alexander Zatvornitskiy
[EMAIL PROTECTED] wrote:
Hello All!
I'am novice in python, and I find one very bad thing (from my point of
view) in language. There is no keyword or syntax to declare variable, like
'var' in
Since the lack of declarations is such a crucial design choice for
Python,
Steven Bethard [EMAIL PROTECTED] wrote:
Of if you only want to deal with the case where the attribute doesn't
exist, you can use getattr, which gets called when the attribute can't
be found anywhere else:
py class DefaultAttr(object):
... def __init__(self, default):
...
Benjamin Schmeling [EMAIL PROTECTED] wrote:
...
I don't know how to achieve implicit conversion at this point, turning an
long automatically into an bigint. The other way round, turning an bigint
into long can be realized by defining __long__.
Perhaps adding to your bigint class a
Robert Brewer [EMAIL PROTECTED] wrote:
Bah. Nothing teaches you a new language like having your job depend upon
it. People who study languages merely for personal growth learn 50% of
the syntax and 1% of the concepts, and then fritter that learning away
on inconsequential newsgroups the world
Michael Tobis [EMAIL PROTECTED] wrote:
With all due respect, I think so go away if you don't like it is
excessive, and so go away if you don't like it and you obviously don't
like it so definitely go away is more so. The writer is obviously
I disagree: I believe that, if the poster really
Michael Tobis [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
Michael Tobis [EMAIL PROTECTED] wrote:
he can perfectly
well correct his misexpression if he cares to -- not my job to try to
read his mind and perform exegesis on his words.
Well, I hate to try to tell you your job
Lowell Kirsh [EMAIL PROTECTED] wrote:
What might these exceptions be?
It's HIGHLY advisable to have your __getattr__ methods raise
AttributeError for any requested name that starts and ends with double
underscores, possibly with some specific and specifically designed
exceptions.
For
Michael Tobis [EMAIL PROTECTED] wrote:
...
I don't know that it's ever necessary to rebind, but it is, in fact,
common, and perhaps too easy. In numeric Python, avoiding rebinding
turns out to be a nontrivial skill.
Well, a for-statement is BASED on rebinding, for example. Maybe you
don't
Philippe Fremy [EMAIL PROTECTED] wrote:
Any other idea of a fun python improvement project I could join without
too much hassle ? I can't help but thinking that pychecker ought to be
able to do a better job.
Have a look at pypy -- around the key idea of reimplementing Python's
runtime in
Kartic [EMAIL PROTECTED] wrote:
...
I am not sure what book you are using but I don't think it is a very
good one.
Hmmm, considering he said it's Python in a Nutshell, I disagree with
you;-). If he had understood that he probably wanted to use lists, not
arrays, the top paragraph on p. 47
Steven Bethard [EMAIL PROTECTED] wrote:
I have lists containing values that are all either True, False or None,
e.g.:
[True, None, None, False]
[None, False, False, None ]
[False, True, True, True ]
etc.
For a given list:
* If all values are None, the
Bo Peng [EMAIL PROTECTED] wrote:
...
Thank again for everyone's help. I have learned a lot from the posts,
especially the wrapdict class.
Hmmm, you do realize that wrapdict uses a lot of indirection while my
equivalent approach, just posted, is very direct, right? To reiterate
the latter,
Nick Coghlan [EMAIL PROTECTED] wrote:
...
Michael Spencer also posted an interesting idea recently about setting up
a view of an existing dictionary, rather than as a separate object:
class attr_view(object):
def __init__(self, data):
object.__setattr__(self, _data, data)
def
Can anybody suggest where to find (within the standard library) or how
to easily make (e.g. in a C extension) a type without a __mro__, except
for those (such as types.InstanceType) which are explicitly recorded in
the dispatch table copy._deepcopy_dispatch...?
Weird request, I know, so let me
Bo Peng [EMAIL PROTECTED] wrote:
M.E.Farmer wrote:
I really don't see your need.
Maybe it is just my laziness. It is almost intolerable for me to write
lines and lines of code like
d['z'] = func(d['x']+d['y']+d['whatever']['as']+d[a][0] )
It is ugly, unreadable and error prone.
Brian van den Broek [EMAIL PROTECTED] wrote:
...
* If all values are None, the function should return None.
* If at least one value is True, the function should return True.
* Otherwise, the function should return False.
...
for val in (x for x in lst if x is not None):
return val
Alexander Zatvornitskiy
[EMAIL PROTECTED] wrote:
Hi, Alex!
31 jan 2005 at 13:46, Alex Martelli wrote:
(sorry for the delay,my mail client don't highlight me your answer)
AM Since the lack of declarations is such a crucial design choice for
AM Python, then, given that you're convinced
Fredrik Lundh [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
Can anybody suggest where to find (within the standard library) or how
to easily make (e.g. in a C extension) a type without a __mro__, except
^^
for those
Alexander Zatvornitskiy
[EMAIL PROTECTED] wrote:
...
AM The fact that in Python there are ONLY statements, NO declarations,
===
def qq():
global z
z=5
===
What is global? Statement? Ok, I fill lack of var statement:)
'global' is an ugly wart, to all intents and purposes working as if
Nick Coghlan [EMAIL PROTECTED] wrote:
Alex Martelli wrote:
'global' is an ugly wart, to all intents and purposes working as if it
was a declaration. If I had to vote about the one worst formal defect
of Python, it would surely be 'global'.
Fortunately, it's reasonably easy to avoid
Arthur [EMAIL PROTECTED] wrote:
On Sat, 5 Feb 2005 17:00:15 +0100, [EMAIL PROTECTED] (Alex Martelli)
wrote:
I consider this one of the worst ideas to have been proposed on this
newsgroup over the years, which _IS_ saying something. \
I would disagree, but only to the extent that nothing
Georg Brandl [EMAIL PROTECTED] wrote:
Slight terminology glitch -- it does return an iterator, not a
generator. Generators are functions that return iterators.
xrange returns an ITERABLE, not an ITERATOR. Videat:
a = xrange(23, 43)
a.next()
Traceback (most recent call last):
File stdin,
Nick Coghlan [EMAIL PROTECTED] wrote:
...
_temp = x.y
x.y = type(temp).__irebind__(temp, z)
...
I was thinking of something simpler:
x.y
x.y = z
That is, before the assignment attempt, x.y has to resolve to *something*, but
the interpreter isn't particularly fussy
Arthur [EMAIL PROTECTED] wrote:
Do the STUPID firms use Python as well.
Yes, they're definitely starting to do so.
Why?
The single most frequent reason is that some techie sneaked it in, for
example just for testing or to do a prototype or even without any
actual permission. Firms hardly
John Lenton [EMAIL PROTECTED] wrote:
class C(type):
def __getattribute__(self, attr):
if attr == '__mro__':
raise AttributeError, What, *me*, a __mro__? Nevah!
return super(C, self).__getattribute__(attr)
class D(object):
__metaclass__ = C
Philip Smith [EMAIL PROTECTED] wrote:
Call this a C++ programmers hang-up if you like.
I don't seem to be able to define multiple versions of __init__ in my matrix
Indeed, you can never define ``multiple versions'' of the same name in
the same scope: one scope + one name - one object.
Leif K-Brooks [EMAIL PROTECTED] wrote:
Is there a word for an iterable object which isn't also an iterator, and
therefor can be iterated over multiple times without being exhausted?
Sequence is close, but a non-iterator iterable could technically
provide an __iter__ method without
Fredrik Lundh [EMAIL PROTECTED] wrote:
Markus Wankus wrote:
Google his name - he has been banned from Netbeans and Eclipse (and
Hibernate, and others...) for good reason. Can you imagine how much of
a Troll you need to be to *actually* get banned from the newsgroups of
open source
snacktime [EMAIL PROTECTED] wrote:
...
How difficult is it to turn python bytecode into it's original source?
It's pretty easy, not really the original source (you lose comments etc)
but close enough to read and understand.
Is it that much different than java (this is what they will
Johannes Ahl-mann [EMAIL PROTECTED] wrote:
a non-recursive solution to traversing a recursive data type is bound to
get ugly, isn't it?
Not necessarily: sometimes using an explicit stack can be quite pretty,
depending. E.g.:
def all_leaves(root):
stack = [root]
while stack:
Roy Smith [EMAIL PROTECTED] wrote:
which is good news for sellers of books, tools, training, consultancy
services, and for Python programmers everywhere -- more demand always
helps. *BUT* the price is eternal vigilance...
I'm not sure what that last sentence is supposed to mean, but I
Reinhold Birkenfeld [EMAIL PROTECTED] wrote:
...
Perl also has excellent pattern matching compared to
sed, not sure about how Python measures up,
but this seems to make perl ideally suited to text processing.
Python has regular expressions much like Perl. The only difference is
that
jfj [EMAIL PROTECTED] wrote:
I don't understand.
We can take a function and attach it to an object, and then call it
as an instance method as long as it has at least one argument:
#
class A:
pass
def foo(x):
print x
A.foo = foo
a=A()
a.foo()
#
Steven Bethard [EMAIL PROTECTED] wrote:
Hmm... interesting. This isn't the main intended use of
Bunch/Struct/whatever, but it does seem like a useful thing to have...
I wonder if it would be worth having, say, a staticmethod of Bunch that
produced such a view, e.g.:
class Bunch(object):
Steven Bethard [EMAIL PROTECTED] wrote:
Seems pretty reasonable -- the only thing I worry about is that
classmethods and other attributes (e.g. properties) that are accessible
from instances can lead to subtle bugs when a user accidentally
initializes a Bunch object with the attributes of
Steven Bethard [EMAIL PROTECTED] wrote:
at the OP's original code, the line:
[(x[0], x[2]) for x in os.walk(.)]
is the equivalent of:
[dirpath, filenames for dirpath, dirnames, filenames in os.walk('.')]
Just a nit: you need parentheses in your second LC too, i.e.:
[(dirpath,
jfj [EMAIL PROTECTED] wrote:
If I say:
x=b.foo
x(1)
Then, without looking at the previous code, one can say that x is a
function which takes one argument.
One can say whatever one wishes, but saying it does not make it true.
One can say that x is a green frog, but that's false: x is a
jfj [EMAIL PROTECTED] wrote:
Isn't that inconsistent?
That Python has many callable types, not all of which are descriptors?
I don't see any inconsistency there. Sure, a more generalized currying
(argument-prebinding) capability would be more powerful, but not more
consistent
Brian van den Broek [EMAIL PROTECTED] wrote:
...
(I'm just a hobbyist, so if this suggestion clashes with some well
established use of 'Bag' in CS terminology, well, never mind.)
Yep: a Bag is a more common and neater name for a multiset -- a
set-like container which holds each item ``a
Bill Mill [EMAIL PROTECTED] wrote:
...
You are modifying the list as you iterate over it. Instead, iterate over
a copy by using:
for ip in ips[:]:
...
Once you know it, it's neat, and I use it sometimes. However, it's a
little too magical for my tastes; I'd rather be more
Steven Bethard [EMAIL PROTECTED] wrote:
...
I have a list[1] of objects from which I need to remove duplicates. I
have to maintain the list order though, so solutions like set(lst), etc.
will not work for me. What are my options? So far, I can see:
I think the recipe by that subject in
Michael Tobis [EMAIL PROTECTED] wrote:
...
.x = 1
.def foo():
. if False:
. global x
. x = 2
.foo()
.print x
prints 1
Wrong:
x = 1
def foo():
... if False:
... global x
... x = 2
...
foo()
print x
2
And indeed, that IS the problem.
Pythonistas appear to be
On 2005 Feb 07, at 22:15, jfj wrote:
Alex Martelli wrote:
jfj [EMAIL PROTECTED] wrote:
Then, without looking at the previous code, one can say that x is a
function which takes one argument.
One can say whatever one wishes, but saying it does not make it true.
One can say that x is a green frog
Diez B. Roggisch [EMAIL PROTECTED] wrote:
...
If there a good reason that the __get__ of a boundmethod does not
create a new boundmethod wrapper over the first boundmethod?
I already gave you the good reason:
Hmmm, not sure the code below is ``a good reason'' to avoid changing the
Antoon Pardon [EMAIL PROTECTED] wrote:
Op 2005-02-06, Alex Martelli schreef [EMAIL PROTECTED]:
Isn't that inconsistent?
That Python has many callable types, not all of which are descriptors?
I don't see any inconsistency there. Sure, a more generalized currying
(argument
1 - 100 of 1652 matches
Mail list logo