Re: Python is slow

2008-05-22 Thread Carl Banks
ave Parker here any minute to tell us how Flaming Thunder isn't slow. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorator metaclass

2008-05-23 Thread Carl Banks
I believe it's happening because you mixed old-style and new-style classes. But it's not the right solution anyway. > Any help on this? Probably the best piece of advice is "Don't try to use Decorator pattern". :) Seriously, you might want to see what other people have done in similar cases. This stuff is tricky to get right, so maybe you should shamelessly ride the coattails of someone who already ran into all the issues. One example I can think of is the ZODB Persistent class (it's a proxy class, so some of the same issues are involved). Perhaps searching Python cookbook for some proxy or decorator class recipes will give you ideas. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-05-23 Thread Carl Banks
anguages and not-so-fast non-machine-coded languages. And like it or not, the world rarely cares to make the distinction between language and implementation, and frankly, it's usually not necessary to. What Brad said is perfectly acceptable, and good advice IMHO, under the common usage of the terms. I

Re: Decorator metaclass

2008-05-23 Thread Carl Banks
fault_hello(self): print "hello, children" A.say_hello = new_default_hello Notice that you need to use self when assigning it to the class object, and not to use self when assigning it to an instance of the class. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Assignment and comparison in one statement

2008-05-23 Thread Carl Banks
print p (I recommend doing it this way in C, too.) For the case where you want to do this in an elif-clause, look for the recent thread "C-like assignment expression?" which list some workarounds. Or just Google this newsgroup for "assignment expression". It's one of few minor irritating things in Python syntax. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-05-24 Thread Carl Banks
On May 24, 1:56 am, cm_gui <[EMAIL PROTECTED]> wrote: > i'm not trying to 'troll' here. Maybe you're not trying, but you're succeeding. If you want to criticize be constructive about it, otherwise get out. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Assignment and comparison in one statement

2008-05-24 Thread Carl Banks
On May 24, 7:12 am, Johannes Bauer <[EMAIL PROTECTED]> wrote: > Carl Banks schrieb: > > > p = myfunction() > > if p: > > print p > > > (I recommend doing it this way in C, too.) > > This is okay for if-clauses, but sucks for whil

Re: FW: php vs python

2008-05-28 Thread Carl Banks
r purpose and when combined with Jackson structured > > programming could be used straight away by rooky programmers in business > > systems programming. I am sure it has progressed since ANSI 68. > > > The Inuit have 13 terms for snow. Microsoft advocate DSLs. Why have DSLs > > if language does not matter? > > > My 2c worth. > > http://www.fukung.net/v/7729/php_vs_python.png > :) Ha ha. Took me a second. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Optimization: Picking random keys from a dictionary and mutating values

2008-05-29 Thread Carl Banks
n evolutionary search, so mutate in this sense relates to a > genetic algorithm, perhaps a gradient decent? A gradient descent method is not an evolutionary search and involves no randomness (unless noise is added to the objective, which is a possible way to attack a function with unimportant small scale features, and in that case normalvariate would be the thing used). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: should I put old or new style classes in my book?

2008-05-30 Thread Carl Banks
worry about, and most of the time you can and should add (object) and the code will still work." And leave it at that--let the interested newbie seek out more information on their own. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python's setuptools (eggs) vs ruby's gems survey/discussion

2008-06-01 Thread Carl Banks
consistent and reasonable usage. For open source, mom-and-pop operations, and other smaller projects, I think it adds a whole lot of complexity over what otherwise is a simple thing. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
ct, I'd say this is even worse than useless. Creating accessor functions is a sort of blessing for external use. Knowing that there are accessor functions is likely to cause a user to show even less restraint. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 6:40 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2008-06-02, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 2, 5:38 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> If you really need it, you can do data hiding in

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 8:14 am, Carl Banks <[EMAIL PROTECTED]> wrote: > Fair enough, but I don't see anything in your example that suggests a > way to discriminate between access from within the class and access > from outside the class, which is the crucial aspect of data hiding. And, if

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 9:07 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2008-06-02, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 2, 6:40 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> On 2008-06-02, Carl Banks <[EMAIL PROTECTED]> wrote

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 4:50 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jun 2, 6:41 am, Carl Banks <[EMAIL PROTECTED]> wrote: > > > You are not realizing that only useful(**) thing about data hiding is > > that some code has access to the data, other code does n

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 6:39 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jun 2, 3:04 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 2, 4:50 pm, "Russ P." <[EMAIL PROTECTED]> wrote: > > > > On Jun 2, 6:41 am, Carl Banks <[EM

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
s. Thus, the client would have > access, but he would know very well that he is using something that > the original designer did not intend for him to use. Reasonable enough. I've always thought C++ should have a private_cast. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-02 Thread Carl Banks
On Jun 2, 10:14 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > On 2008-06-02, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 2, 9:07 am, Antoon Pardon <[EMAIL PROTECTED]> wrote: > >> On 2008-06-02, Carl Banks <[EMAIL PROTECTED]> wrote

Re: Best way to modify code without breaking stuff.

2008-06-04 Thread Carl Banks
d use an environment variable to choose which one: if os.environ.get("USENEWMODULE") == "yes": from newwhatever import * else: from oldwhatever import * Or, you could set a flag in some sort of configuration module and check that: import config if config.use_new_module

Re: Best way to modify code without breaking stuff.

2008-06-04 Thread Carl Banks
n between different branches depending on whether you're using the tools or changing the model. (Subversion can do this, but I'm not sure if it's for individual files or only directories.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: readline() & seek() ???

2008-06-05 Thread Carl Banks
T", > move to the 35th character of the line and read 5 characters from > there. > Capture these 5 characters and write them to a new text file, each 5 > characters separated by a comma. Your professor possibly reads comp.lang.python, and if so, is likely to know how to track yo

Re: Q re documentation Python style

2008-06-08 Thread Carl Banks
oc And then you could do this: @doc("This is the docstring.") def some_function(): do_whatever() I think most tools that use docstrings actually execute the module, which means by the time the tool sees it the docstring will have been assigned, though I'm not

Re: Question by someone coming from C...

2008-06-09 Thread Carl Banks
onfig.debug_options: print_debugging_info() But again, the logging modules handles all this for you so no point for this particular task. P.S. I'd do it more or less this way in C, too. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Producer-consumer threading problem

2008-06-10 Thread Carl Banks
ds like a sentinel would work for this. The producer puts a specific object (say, None) in the queue and the consumer checks for this object and stops consuming when it sees it. But that seems so obvious I suspect there's something else up. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Producer-consumer threading problem

2008-06-11 Thread Carl Banks
he += is atomic. Otherwise you have to use a lock. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

At long last...

2008-06-19 Thread Carl Banks
Tuples will have an index method in Python 2.6. I promise I won't indiscriminately use tuples for homogenous data. Honest. Scout's honor. Cross my heart. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: At long last...

2008-06-19 Thread Carl Banks
On Jun 19, 10:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > Tuples will have an index method in Python 2.6. > > > I promise I won't indiscriminately use tuples for homogenous data. > > Honest. Scout's honor. Cross my heart. >

Re: At long last...

2008-06-20 Thread Carl Banks
On Jun 19, 11:26 pm, Dan Bishop <[EMAIL PROTECTED]> wrote: > On Jun 19, 9:24 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 19, 10:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > Carl Banks wrote: > > > > Tuples will hav

Re: sublassing as a verb

2008-06-20 Thread Carl Banks
ener is a subclass of URLopener? Yes. Anthimeria is very common in English. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: regexp: match only if previous matched?

2008-06-23 Thread Carl Banks
before the number: $112 and $45 In which case your regexp should be somehting like this: \$[0-9]+ Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Looping-related Memory Leak

2008-06-26 Thread Carl Banks
If so, change it to use a different instance each time. (If you just use the module- level load function you are already using a different instance each time.) Unpicklers hold a reference to everything they've seen, which prevents objects it unpickles from being garbage collected until it i

Re: Help me optimize my feed script.

2008-06-26 Thread Carl Banks
; > f = open('c:/scripts/myFeeds.htm', 'w') > f.write(s) > f.close > > print > print 'myFeeds.htm written' Using the += operator on strings is a common bottleneck in programs. First thing you should try is to get rid of that. (Recent versions o

Re: Cyclic imports

2008-06-27 Thread Carl Banks
such guarantee, so you have to arrange your modules so that code that depends on another module is run after the dependent module. (One common time where this happens is when subclassing a class from another module: the module with the base class needs to run first.) If you have circular imports in

Re: Pygame, how to show window without loop? no loop=popupand close...

2008-06-27 Thread Carl Banks
to occur, without using CPU cycles. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Pygame, how to show window without loop? no loop=popupand close...

2008-06-28 Thread Carl Banks
On Jun 28, 6:49 pm, defn noob <[EMAIL PROTECTED]> wrote: > On 28 Juni, 08:32, Carl Banks <[EMAIL PROTECTED]> wrote: > > > On Jun 27, 10:58 pm, defn noob <[EMAIL PROTECTED]> wrote: > > > > right. im an idiot anyway. i can just draw the lines befo

Re: Looping-related Memory Leak

2008-06-30 Thread Carl Banks
On Jun 30, 1:55 pm, Tom Davis <[EMAIL PROTECTED]> wrote: > On Jun 26, 5:38 am, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > > On Jun 26, 5:19 am, Tom Davis <[EMAIL PROTECTED]> wrote: > > > > I am having a problem where a long-running function will c

Re: re.search much slower then grep on some regular expressions

2008-07-04 Thread Carl Banks
nce of the regexp that I'm aware of. > but why would you say this particular > regex isn't common enough in real code? When re.search regexps start with things like [^...]* or .*, typically the excluded characters are a typically found frequently in the input. For example, the pattern .*hello.* could be used to find a line with hello in it, with the expectation that there are lots of newlines. But if there aren't any newlines the regexp wouldn't be very useful. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-05 Thread Carl Banks
r algorithm that is used in grep. Python RE's have > > more capabilities than grep RE's which need a slower, more complex > > algorithm. > > FWIW, grep itself can confirm this statement. The following command roughly > takes as long as Python's re.search: > > # grep -P '[^ "=]*/' input > > -P tells grep to use real perl-compatible regular expressions. This confirms that a particular engine might not be optimized for it, but it's not necessarily a reflection that the engine is more complex. I'm not sure of the specifics and maybe that is the case, but it could also be a case of a different codebase which is optimized differently. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-05 Thread Carl Banks
On Jul 5, 6:44 am, "Sebastian \"lunar\" Wiesner" <[EMAIL PROTECTED]> wrote: > Carl Banks <[EMAIL PROTECTED]>: > > > > > On Jul 5, 4:12 am, "Sebastian \"lunar\" Wiesner" > > <[EMAIL PROTECTED]> wrote: > >> P

Re: Dynamically Changing the Base Class

2008-07-07 Thread Carl Banks
is so if you look at the MRO: Foo, _Foo, Base, object Which is the same MRO that would occur if _Foo derived from Base directly. The drawback (which is also a drawback to the hypothetical base reassignment) is that Foo's __init__ method won't call Base's. The only way you can make SWIG __init__ call it's superclass's __init__ is apparently a patch. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: why is "self" used in OO-Python?

2008-07-12 Thread Carl Banks
m manipulate it? > Makes more sense to draw the line to not access any attributes at all > no? Much of what you're arguing is only true if you accept it as a given that data hiding is important. The designers of Python don't really think it is, and that's why they don't have it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Mutually referencing imports -- impossible?

2008-07-13 Thread Carl Banks
motorcycle.py: from carsim import car def create_car(): global a a = car.Car() This last limitation is due to a wart in the import logic. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Suggestion: Python global scope

2008-07-15 Thread Carl Banks
would reference > the global X, rather than previous X. Do you have a specific use case in mind? Where would this sort of thing be useful? (The be sure, I can think of a use case for something like this, namely optimizing away hash lookups for frequently used globals. But such an optimi

Re: singletons

2008-07-16 Thread Carl Banks
odule in as the first argument. I have reasons for doing it but it doesn't do anything the above method does. It would be used like this: @modmethod def something(self): self.var = 1 self.max = 10 ] Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python embedding question (2).

2008-07-17 Thread Carl Banks
find that out myself (I'm pretty excited about the thing > already ^^), but I'd be happy to hear of people who have used it already. Pyglet runs on top of OpenGL, which might have performance problems on an embedded device, if OpenGL or Mesa is even supported. If it's suppo

Re: Python Written in C?

2008-07-20 Thread Carl Banks
a loss if you decide to learn some other language. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: 2d graphics - what module to use?

2008-07-25 Thread Carl Banks
www.mathworks.com If you're only interested in sine waves you most certainly should not give Matlab a try; even with student pricing it's going to be way expensive for something that simple. For just popping up a window and drawing on it I recommend PyGame. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Attack a sacred Python Cow

2008-07-26 Thread Carl Banks
instead of "if x==0", or "if s" instead of "if len(s)==0". Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Attack a sacred Python Cow

2008-07-26 Thread Carl Banks
- no in Python. Or how about this: a = 1 # a is an integer a += "hello" # oops, now it's a string Let me suggest that such things are a Very Bad Idea and so that line is better left in place. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Attack a sacred Python Cow

2008-07-26 Thread Carl Banks
etty weak. The use case of simply passing something to a function that accepts any boolean doesn't count. For instance, I could write: def nand(a,b): return not (a and b) And then I could use it like this, even if x is an interger and y a string: if nand(x,y): But that doesn't b

Re: Attack a sacred Python Cow

2008-07-27 Thread Carl Banks
On Jul 27, 5:14 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 26 Jul 2008 15:58:16 -0700, Carl Banks wrote: > > On Jul 26, 5:07 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > >> Whether or not one should write 'if x' or

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-28 Thread Carl Banks
On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > Cutting to the crux of the discussion... > > On Sun, 27 Jul 2008 23:45:26 -0700, Carl Banks wrote: > > I want something where "if x" will do but a simple explicit test won

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote: > > On Jul 28, 10:00 am, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> Cutting to the c

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 5:27 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 29 Jul 2008 01:37:45 -0700, Carl Banks wrote: > > I am looking for one that can't. > > If you are writing code that needs to do the right thing with arbitrary > types, then your so-called &q

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
es how "if x" improves polymorphism relative to simple explicit tests? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 11:12 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 28, 8:15 pm, Steven D'Aprano <[EMAIL PROTECTED] > > cybersource.com.au> wrote: > >> On Mon, 28 Jul 2008 13:22:37 -0700, Carl Banks wrote: > >>> O

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 1:30 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > > > I can't dig up a simple example from code I wrote quickly, but because of > > the > > fact that explicit comparisons always hamp

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 5:27 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 29 Jul 2008 01:37:45 -0700, Carl Banks wrote: > > I would accept as "evidence" something that satisfies my criteria, which > > your example did not: it could have easily (and more robu

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 4:08 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 29, 1:30 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > >> On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > > >>> I can't dig up a

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 3:43 pm, "Heiko Wundram" <[EMAIL PROTECTED]> wrote: > Am 29.07.2008, 18:30 Uhr, schrieb Carl Banks <[EMAIL PROTECTED]>: > > > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > >> I can't dig up a simple example from c

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 10:23 pm, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > Bzzt. "if len(x)!=0" is a simple explicit that would work for this > > class and all built-in containers. (Or should--Steven D'Aprano's > > objections notwit

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 7:30 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Tue, 29 Jul 2008 10:30:43 -0700, Carl Banks wrote: > > On Jul 29, 5:15 am, Heiko Wundram <[EMAIL PROTECTED]> wrote: > >> I can't dig up a simple example from code I wro

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 30, 12:22 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > That's not what I was asking for. I was asking for a use case for "if > > x" that can't be replaced by a simple explicit test. Your example > > didn't sa

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 11:17 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > >> As I wrote in the second reply email I sent, check out my integer set > >> recipe on ASPN (and to save you the search: > >> http://code.activestate.com/recipes/466286/

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > Much like in Steven D'Aprano's example, still the only actual code > > snippet I've seen, it seems that this can easily be done with a simple > > explicit test by

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
it can backfire to use "if x" to check whether an iterable is empty since you can get a false positive if it's an iterator. Other than that it's maybe slighly less type safe to use explicit test. > Having said that, it would sure be nice to be able to write > > if

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
n just how much polymophism "if x" supports relative to explicit tests, which is to say, not much. BTW, I haven't changed my criteria since I asked for the challenge. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-29 Thread Carl Banks
On Jul 30, 1:58 am, "Russ P." <[EMAIL PROTECTED]> wrote: > On Jul 29, 10:33 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > > On Jul 30, 1:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: > > > Having said that, it would sure be nice to be able

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Carl Banks
On Jul 30, 11:07 am, Terry Reedy <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > That's not what I was asking for. I was asking for a use case for "if > > x" that can't be replaced by a simple explicit test. Your example > > didn't satis

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Carl Banks
On Jul 30, 3:56 am, Erik Max Francis <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > I mean in general. I wouldn't spell it like that. I would prefer if > > empty(x), with an __empty__ method. (And support __nonzero__ aka > > __bool__ dropped completely.) >

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-30 Thread Carl Banks
On Jul 30, 4:49 am, Ethan Furman <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 29, 6:42 pm, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: > >> I don't have any postable code (it's in a half way state and I haven't > >> touched it

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
out ever considering how rarely this more extensive polymorphism comes up in practice. I was calling them out to say "prove to me that it actually happens". I believe it's very rare not to know enough about the expected type that explicit tests won't work. We'

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 31, 12:13 am, Ethan Furman <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > So I stand by the point I was trying to make: for your average day-to- > > day programming, the main benefit of "if x" is to save keystrokes. It > > doesn't help your c

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
le who took it literally, those who are not an ass would have accepted his explanation that he was paraphrasing it and moved on, rather than rubbing it in. If you recall, I agreed with his statement. Would you like to claim that I don't understand the fundamentals of Python? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-07-31 Thread Carl Banks
On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [snip excellent explanation of why it's hard to for "if x" to be extensively polymorphic] By the way, one thing I forgot to mention is Matt Fitzgibbons' filter example. As I said, it's hard to write code

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Carl Banks
On Aug 1, 8:49 am, Matthew Fitzgibbons <[EMAIL PROTECTED]> wrote: > Carl Banks wrote: > > On Jul 31, 11:44 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > [snip excellent explanation of why it's hard to for "if x" to be > > extensively polymorphic] &g

Re: Strong/weak typing

2008-08-01 Thread Carl Banks
t even if you do that, most of the variables in a program are going to spend their whole time being bound to a single time. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Carl Banks
is. Nonzeroness is useful. Emptiness is useful. Singularity a kind of useful. Nothing and something are vague, ill-defined, ad hoc concepts that mean nothing to a computer. Have you ever seen an algorithm that says "if x is something"? Something and nothing do seem to come

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Carl Banks
On Aug 1, 4:45 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Aug 1, 3:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > > > > > Nevertheless, I think this is probably the best example of the > > > enhanced polymorphism of "if x" yet. I'm

Re: Boolean tests [was Re: Attack a sacred Python Cow]

2008-08-01 Thread Carl Banks
On Aug 1, 4:45 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Aug 1, 3:36 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > In general, asking code to apply across numeric, container, and other > > classes is asking too much. Python code can be generic only within > &

Re: Locking around

2008-08-06 Thread Carl Banks
in locked_keys: global_lock.wait() locked_keys.add(s3key) global_lock.release() def unlock_s3key(s3key): global_lock.acquire() locked_keys.remove(s3key) global_lock.notifyAll() global_lock.release() Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Locking around

2008-08-06 Thread Carl Banks
ll(); notify alone won't cut it. Consider what happens if you have two threads waiting for keys A and B respectively. When the thread that has B is done, it releases B and calls notify, but notify happens to wake up the thread waiting on A. Thus the thread waiting on B is starved. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: .cpp to .pyd

2008-08-07 Thread Carl Banks
7;C:\\boost-whatever-version\\include'] Notice the doubling of backslashes. Remember to add the directory where the boost header files lie on your system; don't add this line exactly. You should end up with a setup call that looks like this: setup(name="blah", ext_modules

Re: how to find out if an object is a class?

2008-08-07 Thread Carl Banks
;s tp_flags field for Py_TPFLAGS_HEAPTYPE bit, but I don't know of any simple way to check for it from Python. It's still possible for it to fail since someone could create heap types in C though I'd expect that's very rare. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: .cpp to .pyd

2008-08-09 Thread Carl Banks
On Aug 9, 7:46 am, [EMAIL PROTECTED] wrote: > On 9 kol, 13:34, [EMAIL PROTECTED] wrote: > > > > > On 9 kol, 01:27, Carl Banks <[EMAIL PROTECTED]> wrote: > > > > On Aug 8, 1:11 pm, [EMAIL PROTECTED] wrote: > > > > > Thanks for quick reply.Maybe I

Re: Missing exceptions in PEP 3107

2008-08-10 Thread Carl Banks
like this, but that usually only happens after the community has had time to explore the problem domain for awhile (cf. WSGI). Carl Banks (**) - Actually there is a minor policy recommendation: that the pydoc and inspect module learn to understand and display the annotations. -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: Chandler 1.0

2008-08-10 Thread Carl Banks
d for Windows, Mac, and > Linux at: > > http://chandlerproject.org/download > > Additional information is available from the Chandler Project homepage. > > Thanks for your interest in Chandler Desktop! Cool. Maybe we'll Duke Nukem Forever soon, too. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance crossover packages

2008-08-11 Thread Carl Banks
import mastergen BTW, the error message is misleading, and it seems like it'd be a common error. Maybe it deserves a special case error message. (I.e. if the call to metaclass.__init__ raises TypeError, check to see if it's a module and raise a better error message.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Carl Banks
ines[self.index] self.index += 1 return line function_that_calls_readline(FileMimicker()) (Why would I want to clutter up my module's namespace for that silly thing?) So I see no good reason for the compiler to disallow nested class statements; it's occasionally useful and not a common pitfall. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why prefer != over <> for Python 3.0?

2008-03-29 Thread Carl Banks
are so much about that you will avoid using a langauge because of it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why prefer != over <> for Python 3.0?

2008-03-29 Thread Carl Banks
On Mar 29, 9:23 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 29 Mar 2008 12:49:05 -0700, Carl Banks wrote: > >> Please set it straight in 3.0, and if not, convince me with a good > >> reason of doing so, so that I can live with it

Re: troll poll

2008-03-31 Thread Carl Banks
it been established that castironpi is a person at all? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question - Overloading ==

2008-03-31 Thread Carl Banks
return self.comparison_signature() == other.comparison_signature() This I suspect would handle your problem gracefully, assuming that objects of different types should be considered not equal and have a different set of attributes in the signature. For extra credit, you can factor the __eq__ method into a parent class and inherit the comparison in A and B. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for indent advice howto in emacs python-mode

2008-03-31 Thread Carl Banks
lowing the comment "elset they're about to enter the first item" sets the indent for the other case. You might want to use that code in all cases. (Warning: this may cause problems elsewhere, such as nesting function call.) And once again, all bets are off if you're using python.el in Emacs 21. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Prototype OO

2008-04-02 Thread Carl Banks
name mangling attributes is to minimize accidental conflicts, not to enforce data hiding. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested try...except

2008-04-02 Thread Carl Banks
dency to line up the init and finalize statements. In other words, it looks wrong for open and close to be in different columns: open() try: do_stuff() finally: close() It's almost always wrong for initiazation to be inside of the try block. Perhaps the advent of with blocks wil

Re: sine in python

2008-04-06 Thread Carl Banks
) * 180/math.pi Careful there, bud. 5/6 might not give you the value you're expecting it to, depending on the version of Python you're using. If you're on Python 2.x, you'll want to use "from __future__ import division", or to specify 5 and 6 as floats, i.e., 5.0/6.

Dependency Queue

2008-04-07 Thread Carl Banks
rdware). I'm pretty sure I could hack out this structure on my own, but I'd like to see any prior information if there is any, in case anyone's figured out things like, Is there an easy way to detect cycles on insertion? and so on. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Dependency Queue

2008-04-07 Thread Carl Banks
On Apr 7, 1:13 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Carl Banks" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | I'm looking for any information about a certain kind of dynamic data > | structure. Not knowing

<    5   6   7   8   9   10   11   12   13   14   >