Re: Accessing __slots__ from C

2008-09-11 Thread Carl Banks
he slot in the object structure by querying the member descriptor of the type object. descr = GetAttrString(cls,"varname"); offset = descr->d_member->offset; slotvar = (PyObject*)(((char*)obj)+offset) There might be some macros to simplify this. Use at your own risk. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Accessing __slots__ from C

2008-09-12 Thread Carl Banks
> Unfortunately, I am inexperienced at this kind of thing, so I wasn't > > able to get something working. Maybe someone could tell me what's > > wrong with the code below (it gives the error "'struct _object' has no > > member named 'd_member'

Re: n00b question: Better Syntax for Coroutines?

2008-09-12 Thread Carl Banks
you're stuck with using threads in a standard Python release. Generators can't serve as coroutines when you're yielding from a nested call (they only go one level deep). You can get coroutines with Stackless Python, a non-standard version of Python. But even with Stackless I got the impression that you'd be building coroutines atop something that was fairly thread-like. There is no coroutine syntax. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: lacking follow-through

2008-09-12 Thread Carl Banks
On Sep 12, 12:35 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > The defence rests. > > can you please stop quoting that guy, so we don't have to killfile you > as well... Guy? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: lacking follow-through

2008-09-12 Thread Carl Banks
to an A.I.'s. > > Your various outpourings appear so rambling and ill-conceived that > silence is often the only polite response. > > If you are flattered to be compared to an AI you must come from the same > race as Mr. Spock in Star Trek. I'm surprised there is anyone who still gives castironpi credit for being fully human. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: question about python

2008-09-13 Thread Carl Banks
7;) > cfile.write('and the web browser converts it. ') > cfile.write(' http://python.about.com/ > index.html">Click me! ') > cfile.write('The wording of your request was: "%s"' %(line)) > cfile.write('') > > cfile.close() > csock.close() Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: question about python

2008-09-13 Thread Carl Banks
On Sep 13, 1:00 am, fishfin <[EMAIL PROTECTED]> wrote: > @ Carl: Yes, I think your right now that I look at it (or at least all > except for the last two lines need to be indented). I'm still not sure > how to send the stuff to the web browser though. Thanks for pointing >

Re: Function getting a reference to its own module

2008-09-17 Thread Carl Banks
.modules[__name__] or write a separate function to return the appropriate nested module of __name__. Neither method is foolproof I don't think. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: report a BUG of package setuptools-0.6c8.

2008-09-20 Thread Carl Banks
n't list an obvious way to report bugs so I wonder if they're using bugs.python.org? Hope not) If not, the OP should ask on the setuptools mailing list. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Not fully OO ?

2008-09-20 Thread Carl Banks
e or less) define what Python is, not trendy computer science catch words. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: A bit weird dictionary behavior

2008-09-22 Thread Carl Banks
ruth value of an expression... And some would argue that it was wrong to have such a wide definition for the truth value of an expression in the first place... Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no tailcall-optimization?

2008-09-23 Thread Carl Banks
ld be better for that, since it would be a pretty complex thing that would benefit only a tiny fraction of users.) Carl Banks (**) Actually the compiler can do some compile-time constant expression folding, but that's about it. Otherwise it's object agnostic. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Carl Banks
might not want to do that. For that matter, a library should never print error or status messages. Messages should either be sent to the caller somehow, or handled using the logging facility. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: matrix algebra

2008-09-24 Thread Carl Banks
never I write Blender plugins I usually do all the dirty work with numpy. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple processes, private working directories

2008-09-24 Thread Carl Banks
acts like threading module but uses processes. I think you can still run it as a third- party module in 2.5. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP Proposal

2008-09-25 Thread Carl Banks
ide-effects can and are supposed to happen in the process of trying. Anyway, this proposal can easily be implemented more or less as proposed without any syntax changes, using the same ideas as the multimethod implementations, but guaranteeing trial-and-error dispatching. Carl Banks (**)

Re: Large Data Sets: Use base variables or classes? And some binding questions

2008-09-26 Thread Carl Banks
to the indices.) This might be a perfect fit for your needs. You have to upgrade to 2.6, though, which won't be released for a few days. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Large Data Sets: Use base variables or classes? And some binding questions

2008-09-26 Thread Carl Banks
On Sep 26, 7:43 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 26 Sep 2008 14:54:36 -0700, Carl Banks wrote: > > However, it seems from the rest of your comments that speed is your main > > concern.  Last time someone reported __slots__ didn&#

Re: Large Data Sets: Use base variables or classes? And some binding questions

2008-09-26 Thread Carl Banks
On Sep 26, 8:53 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > It might still end up being slower (creating slot descriptors might > take more time for all I know) but it's more than just an effect of > less memory. Actually scratch that. Descriptors are only created when the ty

Re: Borg vs Singleton vs OddClass

2008-09-28 Thread Carl Banks
ss,"_instance",None) if obj is None: obj = _NotOddClass._instance = NotOddClass() return obj If you're real kinky you can use a metaclass. There are reasons to prefer any of these. I'd recommend the factory function unless you think the users could significantly

Re: What is not objects in Python?

2008-09-28 Thread Carl Banks
ou to understanda a language for what it is, not for whatever computer science buzzword labels it has. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is not objects in Python?

2008-09-28 Thread Carl Banks
n syntax. There's no clear cut distinction there, it's just a design decision. Likewise, making len() into a function is just a design decision, that len is a common enough operation that it need elevated status. It's really nothing more. Python wouldn't suffer much regardless if len is a method, a built-in function, or an operator with its own syntax. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: del and sets proposal

2008-10-03 Thread Carl Banks
uldn't want that addition to `set`\s but at least it can be > implemented without introducing inconsistencies. If set behaved that way then "del a[1]" wouldn't behave like del anymore. Normally, "del whatever" means that you can no longer use "whatever"; in this proposal you can. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: del and sets proposal

2008-10-03 Thread Carl Banks
the first dictionary entry but rather delete the entry in > the object with a value of 1, which IMHO would be perfectly logical for a set > (which is why I started this discussion). It's not logical at all. In all current uses of del, the thing that follows del is a valid expressio

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Carl Banks
ng. I suppose many LISPers do as well. I guess which is less effort depends on whether you find it more difficult to identify patterns whole line, or read an extra word. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: advice on this little script

2006-03-09 Thread Carl Banks
name modules that avoids confusion with other symbols is to use "act of" words, i.e., words that end in ing, ion, age, or ment. I would have named the glob module "globbing", the time module "timing", and so on; then I wouldn't have to cringe.) Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Help Create Good Data Model

2006-03-11 Thread Carl Banks
s, in which case it won't exactly hurt to put the acquisition inside the try block. It might be true of mutexes for all I know. But even in those rare cases, I recommend always sticking to the idiom for consistency.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Help Create Good Data Model

2006-03-12 Thread Carl Banks
that it's in the standard libarary. But interally it's fairly similar to how you're doing it. (It has a few extra locks to handle empty and full conditions, IIRC.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Counting nested loop iterations

2006-03-16 Thread Carl Banks
oo for color in animal) for i,(animal,zoo) in enumerate(aciter): pass But even the clear version isn't as nearly clear and straightforward as the nested fors with the counter. I wouldn't forsake that clarity just so it isn't "kludgy". Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Function params with **? what do these mean?

2006-03-20 Thread Carl Banks
pretty good description), but I can't think of any particular reason to search for all occurrences of them. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: New-style Python icons

2006-03-20 Thread Carl Banks
> you like, you can grab them from: > > http://www.doxdesk.com/img/software/py/icons.png I like 'em. Almost makes me wish I was using Windows. (No it doesn't.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: TaskQueue

2006-03-21 Thread Carl Banks
implemented some workaround that I don't remember, and forgot about the issue until your post. But yeah, something like an InterruptableQueue might be a nice thing to have. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: TaskQueue

2006-03-21 Thread Carl Banks
x27;s not applicable to your example, sometimes None is an object you want to pass through. (I think Alex Martelli came up with that one.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: TaskQueue

2006-03-21 Thread Carl Banks
Carl Banks wrote: > But yeah, something like an InterruptableQueue might be a nice thing to > have. Ok, I see now that InterruptableQueue wouldn't help the OP, though it would have helped me in my situation, so it'd still be a good idea. Carl Banks -- http://mail.python.org/

Re: TaskQueue

2006-03-21 Thread Carl Banks
Rene Pijlman wrote: > Carl Banks: > >Rene Pijlman: > >> for i in range(self.numberOfThreads): > >> self.workQueue.put(None) > > > >Or, you could just put one sentinel in the Queue, and subclass the > >Queue's _get method not

Re: Dynamically growing numarray array.

2006-03-22 Thread Carl Banks
ent_array() array([ [ 0., 1., 2.]]) >>> x.add_point([0,0,0]) >>> x.add_point([1,1,1]) >>> x.get_current_array() array([[ 0., 1., 2.], [ 0., 0., 0.], [ 1., 1., 1.]]) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: import random module

2006-03-22 Thread Carl Banks
the current directory, because current directory is in sys.path. Unless there's a change sys.path planned, the shadowing should still happen. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-29 Thread Carl Banks
t for the test to pass when the list is empty. The behavior of all() is correct. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Seems like I want a pre-processor, but...

2006-03-29 Thread Carl Banks
change the type of the queue again in 2.5, it would still work without any changes. Don't redo the work the base class does if you don't have to. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-30 Thread Carl Banks
; > The question that needs to be answered is, what if > there are no elements at all? Then every element in seq is true. (And false. :) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-30 Thread Carl Banks
"all" carries an assumption of existence. (Or maybe it doesn't for you guys in Australia; it does in the USA.) In Python, yes and no are the only possible answers. Probably the only analogous thing you could do in Python would be for all() to raise ValueError when passed an empty sequence. Carl Banks ** - and note that, if you are being snarky, you would say "yes". -- http://mail.python.org/mailman/listinfo/python-list

Re: any() and all() on empty list?

2006-03-31 Thread Carl Banks
Ron Adam wrote: > Carl Banks wrote: > > > In Python, yes and no are the only possible answers. Probably the only > > analogous thing you could do in Python would be for all() to raise > > ValueError when passed an empty sequence. > > There is also 'None

Re: efficiency of range() and xrange() in for loops

2006-04-05 Thread Carl Banks
r(range(n)). Nope, out of the question for Python 2.x. Note that the the builtin range could be rebound, or a global range could appear in the module, at run time. There might even be a good reason to do so Point is, optimizing the call to range can break compatibility even in the for loop. Car

Re: pre-PEP: The create statement

2006-04-05 Thread Carl Banks
ume if it passes then "class" would become a regular symbol and a synonym of "type". Overall, it seems like an idea worth considering. In fact, I'd be in favor of phasing out "class" in favor of "create type" in the interests of there being only one obv

Re: updated pre-PEP: The create statement

2006-04-06 Thread Carl Banks
tml > > In this post, I'm especially soliciting review of Carl Banks's point > (now discussed under Open Issues) which asks if it would be better to > have the create statement translated into: > > = ("", *, **) > > instead of the current: > >

Re: Decorators, Identity functions and execution...

2006-04-09 Thread Carl Banks
end up doing a lot of work optimizing that will ultimately have very little benefit. Having said that, this decorator will not affect calling overhead at all. The decorator is applied when the module is loaded, not when the decorated function is called. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators, Identity functions and execution...

2006-04-09 Thread Carl Banks
Felipe Almeida Lessa wrote: > Em Dom, 2006-04-09 às 08:52 -0700, Carl Banks escreveu: > > You've made the unfortunate mistake of indenting it with tabs, which > > do > > not show up on some newsreaders. I see the tabs in Google; people > > using Microsoft Outlook

Re: Decorators, Identity functions and execution...

2006-04-09 Thread Carl Banks
Steven D'Aprano wrote: > On Sun, 09 Apr 2006 08:52:18 -0700, Carl Banks wrote: > > > it's more important > > to respect community standards than to stick to some silly preference > > you have. > > What happens when the community standard is a silly prefer

Re: Python editing with emacs/wordstar key bindings.

2006-04-12 Thread Carl Banks
ode nil) > Is there a better python-mode script I should be using other than the > default that came with emacs? I doubt there's one that solves your problem. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: quiet conversion functions

2006-04-12 Thread Carl Banks
ot;,"b","c","d"})'; echo 135601192 $ perl -e 'print int("hello, world")'; echo 0 Somebody (I'm guessing Larry Wall himself) thought it was "sensible" for int() to return the internal pointer of the hash. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python editing with emacs/wordstar key bindings.

2006-04-13 Thread Carl Banks
g without setting the major mode (if not, there ought to be), but this should do the trick for you. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

PyWeek done

2006-04-16 Thread Carl Banks
ell, I was aiming pretty high for an individual entry. I [EMAIL PROTECTED] hate collision detection. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: slightly OT: Python BootCamp

2009-11-29 Thread Carl Banks
e vacancy in this: > > http://www.otg-nc.com/python-bootcamp > > It's a week long Python Bootcamp. I'm surprised they're able to fill out 5 days with intensive training on Python. :) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-11-29 Thread Carl Banks
you can write foo.$bar=1 to create a new attribute, you'd expect to be able to write $bar=1 to create a new local variable, but you can't. These issues are significant, and given that a proposal for just computed attributes that didn't have these issues was already rejected, I woul

Re: Feature request: String-inferred names

2009-11-29 Thread Carl Banks
. > > All of this can be determined through common sense. Another thing that can be determined through common sense is that if you have object that you are calling getattr and setattr on so much that you think you need special syntax, you should have been using a dict. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Not Callable, float?

2009-11-29 Thread Carl Banks
ved. I'll use asum. That "float" isn't reserved isn't the problem here since the conflict occurred with the word sum, which is a function. Most languages I know don't reserve the names of functions. For instance you can't do this in C: int printf = 1; printf("%d\n", printf); Python doesn't reserve the names of types either, which is a little uncommon (but not unheard of), so that can be a gotcha. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature request: String-inferred names

2009-12-01 Thread Carl Banks
gic and > method binding.  Dictionaries don't provide equivalent > support. The right approach to having "inheritance-like behavior" AND "typically don't know the name of the thing being accessed at compile time" in the same object--and I doubt that would be widely useful--is to add an option to dictionaries to support inheritance. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: How to set object parameters nicely?

2009-12-02 Thread Carl Banks
s no reason ten or twenty parameters isn't perfectly reasonable. Whenever I have ten parameters in an __init__, I ususally just write out the assignments, although more often than not the object's attributes don't correspond to the parameters one-to-one, so I'd have to write them out anyway. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: python bijection

2009-12-04 Thread Carl Banks
on, because a scalar number is a quarternion. Carl Banks (Would be +1 on a good graph implementation... just not because of ElementTree.) -- http://mail.python.org/mailman/listinfo/python-list

Re: python bijection

2009-12-04 Thread Carl Banks
On Dec 4, 4:42 pm, Lie Ryan wrote: > On 12/5/2009 9:41 AM, Carl Banks wrote: > > > > > > > On Dec 4, 12:46 pm, geremy condra  wrote: > > more common than full-blown graph package). > >> Sure, its a tree, which is also a graph. In this case it looks to >

Re: subprocess kill

2009-12-04 Thread Carl Banks
can't answer it. There a lot of reasons a process might not die when you try to kill it: it could be trapping and ignoring signals (which is rude but it happens), it could be stuck in a critical section, the program might be threaded and not handling signals well, the program might have forked itself and the original process id has disappeared, etc. We can't read your mind or divine what's running on your computer, so we can't answer your question. We can only suggest things that might be wrong. It's up to you to investigate and/or dig deeper. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

ctypes pointer from offset into array?

2009-12-05 Thread Carl Banks
Is there a way to get the pointer to an array offset in ctypes. Example, say I define an array like so: xfer = (c_char*bufsize)() How would I get a pointer to then nth byte (equivalient of &xfer[n])? I guess I would have expected xfer+n to work, but it doesn't. Carl Banks

Re: Float precision and float equality

2009-12-06 Thread Carl Banks
al numbers were on the scale of 10**11, and the difference was around 10**1, so it really didn't matter.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is the significance of after() in this code?

2009-12-06 Thread Carl Banks
". It's return value is then bound to the attribute "after_id" of the object "self". Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Float precision and float equality

2009-12-07 Thread Carl Banks
t machine epsilon? I think everyone else here is talking about a number that is small relative to the expected smallest scale of the calculation. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Graph library for Python

2009-12-08 Thread Carl Banks
en-mindedness with not being a pushover quite well; given this, and that they took initiative, I am satisfied that they will do a good job designing it for the general case. Also, "Now is better than never." (And before anyone gives the obvious retort, please consider if you really t

Re: switch

2009-12-09 Thread Carl Banks
w do you dispatch using polymorphism in that case? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: switch

2009-12-09 Thread Carl Banks
On Dec 9, 5:02 pm, Asun Friere wrote: > On Dec 9, 7:08 pm, Carl Banks wrote: > > > What if the object is a string you just read from a file? > > > How do you dispatch using polymorphism in that case? > > This would be a pertinent question, were I advocating that _all_

Re: switch

2009-12-10 Thread Carl Banks
On Dec 10, 3:34 am, Asun Friere wrote: > On Dec 10, 2:00 pm, Carl Banks wrote: [snip most of questionable, verly verbose reply] > > You argued that a decent language OO should never > > have a switch statement because polymorphic dispatch is the right way > > to hand

Re: Float precision and float equality

2009-12-10 Thread Carl Banks
On Dec 10, 10:46 am, dbd wrote: > On Dec 7, 12:58 pm, Carl Banks wrote: > > > On Dec 7, 10:53 am, dbd wrote: > > > ... > > > You're talking about machine epsilon?  I think everyone else here is > > talking about a number that is small relative

Re: datetime 'NoneType' sporadic error

2009-12-11 Thread Carl Banks
t was sent to > me by one of the users. It only happens occasionally. My guess is somewhere in your code the symbol datetime is being used as a variable. That is, you're doing something like datetime = x. This shadows the module. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: power of explicit self?

2009-12-14 Thread Carl Banks
elf behavior for Python methods is mostly found in the file classobject.c. Basically whenever a method is accessed through an object, the object creates an instancemethod for it. The instancemethod type is defined in classobject.c. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Seek support for new slice syntax PEP.

2009-12-14 Thread Carl Banks
eeded): class SliceCreator(object): def __getitem__(self,loc): if not isinstance(loc,slice): raise TypeError return loc slc = SliceCreator() slash = slc[n-1: n*(n-1)+1: n-1] It might have been a reasonable idea for slice (and, perhaps, range) to use slice notatio

Re: Dangerous behavior of list(generator)

2009-12-14 Thread Carl Banks
y issues? But to answer your question, I think "simple is better than complex" rules the day. Right now StopIteration stops an iteration, simple as that. Any fix would add complexity. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Dangerous behavior of list(generator)

2009-12-14 Thread Carl Banks
though building a list by hand to test it is a lot more work than reading an exception traceback--but it'a stark violation of a Zen and common sense, so it is more serious than other sorts of errors. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: treaps in python

2009-12-14 Thread Carl Banks
as something other than GPL, but you should note that we just had a thread discussing a proposal to include a data structure I consider more generally useful (graph), and that ended up pretty much dead. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: iterators and views of lists

2009-12-16 Thread Carl Banks
operations needed, and avoids copying. Python expresses container operations succinctly and clearly, and doesn't value performance as much. Copying and replacing is good enough most of the time, so there's less demand for things like mutator views. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: iterators and views of lists

2009-12-18 Thread Carl Banks
to mutate the underlying structure--if there is actual underlying data structure-- but it doesn't mean they are weak or limited. Python and C++ iterators are similar in their most basic usage, but grow more powerful in different directions. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: shouldn't list comprehension be faster than for loops?

2009-12-18 Thread Carl Banks
Some features were added to Python to make writing easier, not to make it run faster. This time your intuition was correct. Next time, who knows? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: iterators and views of lists

2009-12-18 Thread Carl Banks
On Dec 18, 11:08 am, "Alf P. Steinbach" wrote: > * Carl Banks: > > > > > On Dec 17, 10:00 pm, Brendan Miller wrote: > >> On Thu, Dec 17, 2009 at 6:44 PM, Steven D'Aprano > > >> wrote: > >>> On Thu, 17 Dec 2009 12:07:59 -0800, Br

Re: iterators and views of lists

2009-12-19 Thread Carl Banks
not having this power, but I still doubt that C++ iterators are used like this much. In most code I've seen people use STL or similar data structures, and then use the iterators for the particular data type, and/or pointers. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with Dynamically unloading a module

2009-12-23 Thread Carl Banks
module's namespace, not to the module itself. So if any references to functions defined in the module remain, the module dict will stick around, but the module itself may be collected. > > But believe me, you don't want to mess up with the python import > > mechanism. > > Unless you understand how it works. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Carl Banks
a string containing either an integer > representation, or something alphabetic, into an integer, or a zero, > in like 1 method call? No, as he said, it only describes the most important functions. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: please help shrink this each_with_index() implementation

2010-01-06 Thread Carl Banks
ld not make the decision for me. Oh well, your language does. Deal with it, or pick another language. Carl Banks P.S. Actually, Python has ways to request no expection when it's actually useful, e.g. the get method of dicts, but not when it's ridiculous and stupid like int()

Re: lightweight encryption of text file

2010-01-10 Thread Carl Banks
ile back to the original text > file without the password would be equivalent to guessing the > password. gpg -c simpletextfile.txt -o simpletextfile.gpg But I guess you can't depend on users to have gpg installed so you have to roll out some unvetted Python tool. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What is built-in method sub

2010-01-11 Thread Carl Banks
s wrong, you'll have to be more specific about what your sctipt does, and maybe share the profile printout or something. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
#x27;öğe' in test_dict.keys() > > __main__:1: UnicodeWarning: Unicode equal comparison failed to convert > both arguments to Unicode - interpreting them as being unequal > False The OP changed his default encoding. I was able to confirm the behavior after setting the default encoding to latin-1. This is most definitely a bug in Python. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
n comparing a byte string and a Unicode string, the byte string will be decoded according to the default encoding.) > FYI, ‘foo in bar.keys()’ is easier to spell as ‘foo in bar’. I believe the OP's point was to show that dicts behave differently than lists here ("in" works for lists, doesn't work for dicts). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 5:38 pm, Carl Banks wrote: > On Jan 16, 3:58 pm, Steven D'Aprano cybersource.com.au> wrote: > > On Sat, 16 Jan 2010 15:35:05 -0800, gizli wrote: > > > Hi all, > > > > I am using Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41). I ran > >

Re: Unicode and dictionaries

2010-01-16 Thread Carl Banks
On Jan 16, 7:06 pm, Ben Finney wrote: > Carl Banks writes: > > On Jan 16, 3:56 pm, Ben Finney wrote: > > > gizli writes: > > > > >>> test_dict = {u'öğe':1} > > > > >>> u'öğe' in test_dict.keys() > > >

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
n call overhead (which is already high enough as it is). And with the performance hit, extra scoping complexity, the inability to be used outside the function context, and no real benefit except to save typing, I don't see it ever being approved. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: > * Carl Banks: > > > On Jan 20, 11:43 pm, Martin Drautzburg > [snip] > > >> What I am really looking for is a way > > >>         - to be able to call move(up) > >>         - having the "

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
On Jan 21, 10:46 am, "Alf P. Steinbach" wrote: > * Carl Banks: > > > > > > > On Jan 21, 2:38 am, "Alf P. Steinbach" wrote: > >> * Carl Banks: > > >>> On Jan 20, 11:43 pm, Martin Drautzburg > >> [snip] > > >

Re: Symbols as parameters?

2010-01-21 Thread Carl Banks
quot;. > > In any case, getting the context right seems to be the biggest problem. > If I don't want to pollute my namespace, those symbols need to be > defined in some context but undefined in others. AFAIK there are not > really "blocks" in python and lexical scoping is present primarily in > functions. That's pretty much the issue. BTW, I'm sorry that the thread got a little flamey there. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Symbols as parameters?

2010-01-22 Thread Carl Banks
ike this: "move(direction.up)" which can then be execed. It wouldn't be a whole new language, just an altered syntax. However, you are right in that, if you don't want to go creating your own syntax, PyParsing will be of no help. You'll have to shoehorn your DSL in a lang

Re: PyArg_ParseTupleAndKeywords

2010-01-22 Thread Carl Banks
code only works if *EVERY* argument is specified in > exactly the same position it appears in keyword-null-terminated array. That it would have to be in a certain order is strange. Are you sure it's just not merely that they all have to be present? > Could you please help me? Tricky, but I think it'd help if you provided more information. My gut feeling is that there exception is being raised somewhere other than you think it is (i.e., not by PyArg_ParseTuple), so I'd recommend adding some debugging statements to track down the exact point wher the error occurs. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Sikuli: the coolest Python project I have yet seen...

2010-01-25 Thread Carl Banks
to see the alternate implementations in use. And it couldn't come at a better time for me as I am trying to figure out how to automate some GUI-only program I am forced to use at work. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: TypeError not caught by except statement

2010-01-25 Thread Carl Banks
ss because logging is considered something that shouldn't bring your program down on error. You can apparently define a logging handler that overrides "handleError" to propogate the exception if you want. Can't tell you why it's hanging, but the logging error you're getting is probably because your string formatter is trying to perform the following operation: "refer" % (ret,) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: myths about python 3

2010-01-27 Thread Carl Banks
7;t gain market share. So rail if it makes you feel better but you've already lost. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: myths about python 3

2010-01-27 Thread Carl Banks
urther along at this point than anticipated, since they > >originally thought they might have to go up to 2.9. > > This assumes that the decision to stop making new 2.x releases is based > on Python 3 adoption, rather than on something else. I should have said, "If anything...".

<    8   9   10   11   12   13   14   15   16   17   >