On Apr 1, 11:28 pm, Hrvoje Niksic wrote:
> Carl Banks writes:
> > This is unforgiveable, not only changing the indexing semantics of
> > Python (because a user would have NO CLUE that something underlying
> > has been changed, and thus it should never be done), but also
ve a problem. There's nothing wrong with large
classes per se, it's just a red flag. If you have all these functions
that really all operate on only one piece of data, and really all do
different things, then a large class is fine.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hat we'll start seeing all kinds of packages with
names like:
com.dusinc.sarray.ptookkit.v_1_34_beta.btree.BTree
The current lack of global package namespace effectively prevents
bureaucratic package naming, which in my mind makes it worth the
cost. However, I'd be willing to believe th
a()
session.stop()
Any methods that are callable any time, you can retain in the big
class, or put in a base class of all the sessions.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
and not
adding or removing them, Diez is correct. (Someone more familiar with
dict internals might want to verify.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
rom writing
> alltogether.
You could implement some kind of fair ordering where whoever requests
a lock first is guaranteed to get it first, but I can't think of a way
to do that without requiring all readers to acquire two locks.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
Points)
A couple general pointers:
* Don't ever use i to represent a string. Programmers expect i to be
an integer. i,j,k,l,m, and n should be integers, in fact. u,v,w,x,y,
and z should be floats. You should stick to this convention whenever
possible, but definitely never use i for anything but an integer.
* set is built into Python now; unless you're using an older version
(2.3 I think) you should use set instead of Set.
* The Python style guide (q.g.) recommends that variables use names
such as column_index rather than columnIndex. The world won't end if
you don't follow it but if you want to be Pythonic that's how.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hat, in turn, suggests he might as well not even bother sending the
discrete values to the clustering algorithm, but instead to call it
for each unique set of discretes. (However, I could imagine the
marginal cost of more dimensions is less than that of multiple runs;
I've been dealing with such a case at work.)
I'll leave it to the OP to decide.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ak a reference if passed a Unicode
object; PyArg_ParseTuple automatically creates an encoded string but
never decrefs it. (That might be necessary evil to preserve
compatibility, though. PyString_AS_STRING does it too.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
me = time[condition]
> >>> new_energy = energy[condition]
Won't work: condition is an array of ones and zeros, but you need to
index the arrays with indices. So, add a call to nonzero to get the
indices of the elements.
elements = nonzero(logical_and(min_time<=time,max_time>=time))
new_time = time[elements]
new_energy = energy[elements]
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 9, 2:58 am, Neil Crighton wrote:
> Carl Banks gmail.com> writes:
>
> > > >>> condition = (min_time <= time) & (time <= max_time)
> > > >>> new_time = time[condition]
> > > >>> new_energy = energy[condition]
&
nable, and there are some
libraries that are based strongly on callbacks (which is the term for
what you're trying to do). However, few if any libraries try to
determine the callback automatically; you have to explicity pass the
function/object to call back to.
Carl Banks
--
http://mail.python
; m-net%
>
> > > I was expecting to see
>
> > > person was here
>
> Never mind. When i add while 1:pass like in the following
>
> thread.start_new_thread(domsg, ("person",2))
> while 1 : pass
>
> the code works as expected
Whoa, there, chief, you don't want to do that. It'll cause a busy
loop and run one of your CPUs to 100%.
Instead, use the theading module and the join method:
import threading
thr = threading.Thread(target=domsg,args=("person",2))
thr.start()
# do whatever in the main thread
thr.join()
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
lp with that particular problem.
I think it will because with xrange the integers will not all have to
exist at one time, so Python doesn't have to increase the size of the
integer pool to a million.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
to two answers. The valid answer to the above
question could be "I don't have any books", neither yes nor no. The
closest thing to that you can get in Python is to raise an exception.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
lly, some people think read-only attributes are unpythonic. I
think that's ridiculous, although in general I'd advise against making
attributes read-only willy-nilly. But there's a time and place for
it.
Last thing I'll advise is don't get too hung up on terms like
"Pythonic". Treat such labels are more of a red flag and get people
who throw out the term to explain why.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
,
doing that will cause funny things to happen when pickling. If you're
doing that, consider the reload function instead (although it has it's
own problems).
I'd highly recommend against pickling an instance of a class that
isn't defined in, and loaded from, a regular module.
On Apr 17, 4:00 pm, Scott David Daniels wrote:
> Carl Banks wrote:
> > On Apr 17, 10:21 am, J Kenneth King wrote:
> >> Consider:
>
> >> code:
> >>
>
> >> clas
y); I'm just
saying there is a rationale behind it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
they can
serve as a base for Python classes. That way, if you have a class and
you want to implement a few methods in C while leaving the rest in
Python, you can factor out all the C methods into a base class written
in C.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
e.com/recipes/120687/
Also, no matter how spiffy the Python logo is, you should always give
the user an option to disable it. (A lot of people like to start an
app and do something else while it's loading, and splash screens are
highly irritating when doing this.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ay replace "import sha" with "import hashlib" and "sha.new" with
"hashlib.sha1", and any other changes that might be necessary
(unlikely). See the documentation for hashlib.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
problem is, during most of the delay wxYield can't be called
becaust the function gethostbyname is blocking.
I think Diez is correct. To avoid the freeze, one should spawn a
thread, and when it completes it should notify the GUI thread by
pushing an event or scheduling an idle call. Functions that do that
are usually thread-safe. (A permanent worker thread might be better
but it would involve a lot more synchronization.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
st be doing things the
hard way. Whatever you're trying to do with cons, car, and cdr,
chances are Python has a high-level way to do it built in that
performs a lot better.
Then again, Lispers seem to like to reimplement high-level operations
from low-level primitives every time they need i
ays to deal with that...
...and so on until eyelids can no longer stay open
Python programmer:
a == b. Next question.
Carl Banks, who might be exaggerating
...a little.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 25, 12:36 am, John Yeung wrote:
> On Apr 25, 2:06 am, Carl Banks wrote:
>
> > In answering the recent question by Mark Tarver, I think I finally hit
> > on why Lisp programmers are the way they are (in particular, why they
> > are often so hostile to the "The
ive way... Should I update the
> __eq__ method (for str class) and break almost everything?
The practical way to deal with this issue is to write your own
function when you encounter a situation where == doesn't suffice.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 25, 12:07 am, Mark Tarver wrote:
> On 25 Apr, 05:01, Carl Banks wrote:
>
>
>
> > On Apr 24, 8:19 am, Mark Tarver wrote:
>
> > > This page says that Python lists are often flexible arrays
>
> > >http://www.brpreiss.com/books/opus7/html/pa
(Given that Python's importing
framework is so complicated, though, one wonders whethter sticking to
a design ideal is worth it.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 25, 6:05 pm, Mark Wooding wrote:
> Carl Banks writes:
> > Graham, for his part, doesn't seem to appreciate that what he does is
> > beyond hope for average people, and that sometimes reality requires
> > average people to write programs.
>
> I think he
On Apr 26, 5:40 am, Vsevolod wrote:
> On Apr 25, 9:06 am, Carl Banks wrote:
> > Carl Banks, who might be exaggerating
>
> > ...a little.
>
> I think you're exaggerating. Go ask this question in c.l.l and the
> first answer you'll get is mismatch.
On Apr 26, 2:38 pm, Paul Rubin <http://phr...@nospam.invalid> wrote:
> Carl Banks writes:
> > Say you are running a thread and you want the power to be able to kill
> > it at any time. The thread is either communicating with the rest of
> > the program periodically, o
On Apr 26, 3:03 pm, Paul Rubin <http://phr...@nospam.invalid> wrote:
> Carl Banks writes:
> > Which is "communicating with the rest of the program periodically".
>
> > Presumably you have to protect objects to share them? There you go:
> > anytime you try
n in this case, and that the workaround should be pretty
easy (I doubt any numbers but one are typed out, and it should be no
problem to special-case that), it should be fixed there.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
n a boolean context.
I think a better answer to this question is: "The Zen of Python is not
called the Cold Hard Rules of Python"; in this case the language goes
against this particluar Zen as it does in many other places.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
I looked at Django hoping to write a personal little app to manage
some personal data. It turns out I didn't have to write an app at
all. Django comes with a spiffy and versatile content editor, all I
had to do was input the database schema and configure the data entry
fields.
I figure you and your bosses can do the same thing to manage your
private Wolverine image stash.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
t; return # done
>
> "self.inqueue" is a Queue object. The intent here is to drain the
> queue, then return. Is there any way this can possibly block or hang?
Yes, but it'll be waiting to acquire the semaphore which Queues
normally don't
pology like a single linked list (every node has
> 1 child, and they are chained) is a true binary tree still.
1. Singly-linked lists can and should be handled with iteration. All
recursion does it make what you're doing a lot less readable for
almost all programmers.
2. You should be u
On May 4, 4:06 pm, bearophileh...@lycos.com wrote:
> Carl Banks:
>
> >1. Singly-linked lists can and should be handled with iteration.<
>
> I was talking about a binary tree with list-like topology, of course.
"(every node has 1 child, and they are chained)"
Tha
On May 4, 8:22 pm, Steven D'Aprano
wrote:
> On Mon, 04 May 2009 15:51:15 -0700, Carl Banks wrote:
> > All
> > recursion does it make what you're doing a lot less readable for almost
> > all programmers.
>
> What nonsense.
It's not nonsense for a singly-l
On May 4, 8:26 pm, Steven D'Aprano
wrote:
> On Mon, 04 May 2009 16:33:13 -0700, Carl Banks wrote:
> > On May 4, 4:06 pm, bearophileh...@lycos.com wrote:
> >> Carl Banks:
>
> >> >1. Singly-linked lists can and should be handled with iteration.<
>
>
On May 5, 12:51 am, Steven D'Aprano
wrote:
> On Mon, 04 May 2009 23:09:25 -0700, Carl Banks wrote:
> > In Python the One Obvious Way is iteration when possible, recursion when
> > necessary.
>
> There's nothing "obvious" about solving the 8 Queens probl
o be a factory function.
> Sorry, your pseudo-code is so far from real code that I can't figure out
> what you're doing. So I guess I can't be any help till something else
> turns up to make it clearer. Maybe it's just me.
I think it's you--and probably a lot of other people who haven't ever
written games. No offense. As someone who's written games before I
will tell you that George's pseudo-code is not far from real code.
His overall approach is fairly typical of how games handle input,
although there are some problems in the details.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ayer)
player.brain.add_handlers(
keyboardHandler(player.brain,responder),
joystickHandler(player.brain,responder),
fovHandler(player.brain),
)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
have the GIL when
creating or deleting threads. In fact, I can't think of any reason
why it wouldn't work to ensure a GIL state first thing after the
thread starts and to release it right before the thread ends.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
x27;t quite tell
if that's what you're doing, then be aware that it is very tricky to
do right and most think it to be a bad idea. If you don't allow the
thread you're killing to clean up it can deadlock, and even if you do,
you have to be careful to clean up properly and you have to
ith the shell? On Windows what if I want a subprocess without a
console from a Python program in a console. Stuff like that.
I still use os.system for Q&D stuff, but now use subprocess for
everything else since I prefer thorough to short and sweet.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
of myfun and cleanup,
def mycleanfun():
try:
myfun()
finally:
cleanup()
t = threading.Thread(target=mycleanfun)
t.start()
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
futile to try to stop access entirely. There's just too many back
doors.
I would suggest that there really isn't much point in anything more
complex than your first solution, which was to validate with
properties and to store the value in a separate attribute.
Respectable programmers won't lightly bypass your validation if they
see that you've taken steps to enforce it. OTOH, once a programmer,
respectable or not, decides to override your protection, they are not
likely to be stopped by something more complex. So there is no point
in making it more complex.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
2. However, functional programming is cryptic at some level no matter
how nice you make the syntax.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 8, 1:56 pm, namekuseijin wrote:
> Carl Banks escreveu:
>
> > 2. However, functional programming is cryptic at some level no matter
> > how nice you make the syntax.
>
> When your program is nothing but function definition and function
> application, synta
nothing but calling functions".
[snip irrelevant stuff about office scripting]
Carl Banks
(**) Python does using indentation to nest, of course, but not at the
expression level.
--
http://mail.python.org/mailman/listinfo/python-list
On May 8, 7:19 pm, namekuseijin wrote:
> On May 8, 10:13 pm, Carl Banks wrote:
>
> > On May 8, 5:47 pm, namekuseijin wrote:
>
> > > My point is that when all you do is call functions, syntax is
> > > irrelevant. You call functions pretty much in the same
On May 9, 10:57 am, namekuseijin
wrote:
> Carl Banks wrote:
> > On May 8, 7:19 pm, namekuseijin wrote:
> >> On May 8, 10:13 pm, Carl Banks wrote:
> >> In Haskell, Lisp and other functional programming languages, any extra
> >> syntax gets converted into
On May 10, 12:40 pm, namekuseijin
wrote:
> Carl Banks wrote:
> > Now, maybe readability concerns don't matter to you personally, but it
> > does matter to the OP, who is trying to advocate functional
> > programming but is having difficulty because most purely fun
pend(value)
A metaclass is probably overkill to assign the wrapped blog methods.
I probably wouldn't even bother with the decorator, and just write the
loop after the class definition. Then you can use MetaBlog directly
for klass.
class MetaBlog(object):
...
for what in attr_list:
setattr(MetaBlog, what, boilerplate(what))
If it were the kind of thing I found myself doing often I'd refactor
into a decorator.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
spurrious exceptions. You could stick
proceed_with_resource() in the try clause, but then if
proceed_with_resource() throws ResourceError because it tries to
acquire a different resource and fails, then it'd be caught and
proceed_without_resource() would be called, which is a mistake.
In
method(*args)
return template
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
u want to proceed along these lines in spite of this, the way to
do it is to add some information to setup.py that lists dependencies.
There is a script, easy_install.py, that uses this information to
install dependencies automatically. However, I don't know the details
of how to do that.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
roying objects all the time. If you were to execute a line
like this in Python:
a = b + 2.0 / (0.5 * m * v * v)
It'd probably create and delete 5 intermediate number objects.
Whatever small gains you could make by eliminating a few object
allocations in your calling code would hardly be noti
daemon
processes can reattach themselves to the terminal when they're done
being a daemon. What's the use case for being able to partially clean
up before program exit?
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 16, 8:20 pm, Ben Finney wrote:
> Carl Banks writes:
> > There's already precedent for what to do in the Python library.
>
> > Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26)
> > [GCC 4.3.2] on linux2
> > Type "help", "copyright",
efcount lock.
I am not disagreeing with your assessment in general, it would be
great if Python were better able to take advantage of multiple cores,
but it's not as simple a thing as you're making it out to be.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 20, 8:59 am, Luis Zarrabeitia wrote:
> On Monday 18 May 2009 10:31:06 pm Carl Banks wrote:
>
> > Even if you decided to accept the penalty and add locking to
> > refcounts, you still have to be prepared for context switching at any
> > time when writing C code, whi
x27;t agree, there's nothing
weird or unreasonable about the argument, it's just a different
viewpoint.
> specially if it
> became the only reason for a GIL. After all, one could argue for that goal in
> almost all languages.
"B-B-B-But other languages do it that
y it's
better off for it.
The fact that other languages do something differently doesn't mean
that other way's better, in fact it really doesn't mean anything at
all.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
not careful the divisors can get
ridiculously large.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
e more sense to print enough digits
to give unambiguous representation.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
; 0:
> char = char * percentage
> sys.stdout.write(char)
> sys.stdout.flush() #Not working correctly
> sleep(2)
>
> progress(40, 50, "*")
> progress(30, 50, "*")
> progress(20, 50, "*")
> progress(10, 50, "*")
> progress(2, 50, "*")
>
> Regards
>
> jross
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 23, 2:20 am, Joel Ross wrote:
> Carl Banks wrote:
> > On May 22, 10:33 pm, Joel Ross wrote:
> >> Hi all,
>
> >> I'm using python 2.5 and trying to flush the sys.stout buffer with
> >> sys.stout.flush(), but doesn't seem to work. Each
are setting
char to a string, so on the next iteration char is the string you
printed last time. Thus char grows factorially with iterations. Not
good.
Instead, change char to some other name so you don't ever overwrite
it; char should always be just one character.
bar =
after criticizing him
for not running mine
Sorry bout that.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hough
this behemoth of an essay.
And I may be a romantic but I would think most people who post this
are really trying to be helpful and not just saying, "Out of my midst,
vile newbie, until thou hearkenst unto the sacred words".
So, it would seem that a summary (with citations) of the essa
x27;d do it.
Sometimes it's not convenient to choose a different name for the base
class method, such as when you have several subclasses, most of which
don't override the method, but a few do. In that case I'd do it same
way as you did.
One thing that does smell is your use of bo
It's
possible py2app has learned to deal with entry hooks by now, but these
days I refuse to use packages that require entry hooks so I wouldn't
know.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 29, 7:21 am, Michele Petrazzo
wrote:
> Hi all,
> I want to execute a python code inside a string and so I use the exec
> statement. The strange thing is that the try/except couple don't catch
> the exception and so it return to the main code.
> Is there a solution to convert or make this co
ecute a function received from a third-part,
The only time it's not a gaping security hole to run code supplied by
a thrid-party as-is is if the program is running on the third-party's
own computer.
If you're execing code on your computer that you didn't write or
thoroughly verify yourself--and you're obviously not doing that--then
you might as well just post your password publicly and say, "have at
it evil hackers".
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
pass
class C(A,B):
__metaclass__ = CMeta # this will work ok
> Seriously, metaclasses are making my brain hurt. How do people like
> Michele Simionato and David Mertz figure these things out? Does it all
> come to looking at the C source code for the CPython interpreter?
>
> Brain hurts, seriously.
I actually did rely on looking at the C source. There's a surprising
amount of checking involving metaclass, layout, special methods, and
so on that is involved when creating a new type.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
rstand the error. Then again, the error seems
> to reference the MRO.
>
> I hope this is one of those posts that I can look back in a few months
> from now and think "Man, was that a dumb thing to ask!" Until then, I
> would appreciate your help in trying to figure out what&
put your code in a file, let's say the file "test.py",
> and now run this file by :
> execfile ( 'test.py' )
How can you execfile test.py without knowing the path to it? Whatever
path you used to locate test.py is where the file is. If you're just
execfiling a bare filename, then it's in the current directory, so
just construct a relative pathname.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
moving other mappings (like bz2) elsewhere. Not sure where they all
went, though.
It was convenient, admittedly, but also confusing to throw all the
other codecs in with Unicode codecs.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ems like the only sane way to do it. In all other directions lies
> >> madness.
>
> > Yes but creating C stubs is also hard in presence of everything that
> > is not basic C++. How would you wrap the STL?
>
> What does the STL offer that Python doesn't already do more flexibly and
> more simply?
The opportunity to type several lines of ASCII line noise just to do
something really simple like iterate through a vector.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
a new scope
with a variable the remains at the value you want to close upon:
create_const_function(value):
def func():
return value
c = (create_const_function(i) for i in range(11, 16))
Or you can do it the slacker way and use a default argument:
c = (lambda i=i: i for i in range(11, 16))
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
oesn't match your usage.
If a value isn't used, then I think the most clear name for it is
"unused".
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 11, 11:41 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > On May 11, 6:44 pm, Ben Finney <[EMAIL PROTECTED]>
> > wrote:
> > > In such cases, the name 'dummy' is conventionally bound to the i
he reader's benefit.) So I would have to agree with
Ivan Illarionov.
Having said that, if you do think it's most important to document
whether something is used, I would suggest not using "_" (because it's
conflicts with gettext conventions) or "dummy" (because it's
misleading) for it.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 12, 7:03 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> Carl Banks <[EMAIL PROTECTED]> writes:
> > IMHO, whether a varibale is used or not has got to be one of the least
> > important things of all (in no small part because it's easily
> > discernable from
ording to literate programming expectations. Don't know of any
tools specifically for literate programming.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ope, and not from enclosed
scopes (e.g., method defintions) at all.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
rs use functional programming
so you might not want to worry about it now, though if you've been
using Ruby you might have done it before.
operator.truth was one of the few things in that module that was
useful for things other than functional programming, since there is no
truth operator in Py
On May 13, 7:46 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> On May 13, 6:09 pm, Eric Anderson <[EMAIL PROTECTED]> wrote:
>
> > I mainly work in other languages (mostly Ruby lately) but my text
> > editor (Scribes) is python. With python being everywhere for dynamic
&
think of len() as an operator. Like other operators,
it can be overloaded using the __opname__ syntax:
-x calls x.__neg__
x+2 calls x.__add__
len(x) calls x.__len__
It's not really an operator: it's a regular built-in function, has no
special syntax, and no opcodes associated with it, but in sometimes it
helps to think of it as one.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
the class it was
invoked with, rather than the class they were defined in. Try this
example:
class A(object):
@classmethod
def classname(cls):
print cls.__name__
@staticmethod
def staticname():
print "A"
class B(A):
pass
B.staticname()
B.cla
are as follows:
1. Explicity flush the buffer after any print statements that end with
a comma:
print "whatever",
sys.stdout.flush()
2. Run Python in unbuffered mode, by using the -u switch:
python -u yourscript.py
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
would outweigh the drawbacks in
complexity and reusability that a metaclass would bring. As for #2, I
don't believe "class-level functionality" is often found in bottleneck
situations, so what does it matter what speed it is?
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ty is that it is itself, and nothing
else. But, that property is true of all instances in Python;
therefore any instance may be substituted for an object instances,
therefore it satisfies LSP.
(Phew: what a tangle of nomenclature that was.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ly single threaded,
No it isn't.
It has some limitations in threading, but many programs make good use
of threads nonetheless. In fact for something like a web app Python's
threading limitations are relatively unimportant, since they tend to
be I/O-bound under heavy load.
[snip r
have been better if you had posted it separately to the two groups.
Lots of flamewars start by one person posting a cutdown not intended
for the ears of the other group.)
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
ision than we need, and we don't really need that much. For
instance, the simulations I run at work all use single precision (six
decimal digits) even though double precision is allowed.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
On May 21, 11:27 pm, Dave Parker <[EMAIL PROTECTED]>
wrote:
> On May 21, 7:01 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>
> > The crucial thing is not to slow down the calculations with useless
> > bells and whistles.
>
> Are you running your simulations on a sy
801 - 900 of 1709 matches
Mail list logo