Re: [Python-Dev] repeated keyword arguments

2008-06-28 Thread tomer filiba
On Jun 28, 12:56 am, "Guido van Rossum" <[EMAIL PROTECTED]> wrote: > No, it could just be a harmless typo in a long argument list. to elaborate on this point a little, i came across this error when i ported my code to 2.4. i used the optparse class which takes 10's of kwargs, and it turned out i'd

[Python-Dev] repeated keyword arguments

2008-06-27 Thread tomer filiba
the following code works on python 2.5: >>> def f(**kwargs): ... print kwargs ... >>> f(a=5,b=7,a=8) {'a': 8, 'b': 7} >>> but fails on python2.4, saying that "a" is given twice. is this a bug or a feature? -tomer ___ Python-Dev mailing list Python

[Python-Dev] forceful exit

2008-06-22 Thread tomer filiba
hi i'm having trouble when forking child processes to serve sockets. the skeleton is something like the following: def work(): try: while True: s = listener.accept()[0] log("hello %s", s) if os.fork() == 0: try: s

Re: [Python-Dev] misbehaving __contains__

2008-01-23 Thread tomer filiba
On Jan 23, 2008 3:19 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > [Steven Bethard] > > >We've already lost this if anyone really wants to break it:: > > > >>>> class C(object): > >... def __iter__(self): > >... return iter(xrange(3)) > >... def __contains__(sel

[Python-Dev] misbehaving __contains__

2008-01-22 Thread tomer filiba
i'm using python to create expression objects, for more intuitive usage as predicates, for instance: x = (Arg(0) > 17) & (Arg(1).foo == "bar") instead of x = And(Gt(Arg(0), 17), Eq(GetAttr(Arg(1), "foo"), "bar")) so now i can use x.eval(18, "spam") and get the result of the expression. i'

Re: [Python-Dev] functional continuations

2007-12-16 Thread tomer filiba
... which would explain the NULL deref exceptions i was getting :) -tomer On Dec 16, 2007 12:54 AM, Greg Ewing <[EMAIL PROTECTED]> wrote: > tomer filiba wrote: > > the idea i came up with is, using exceptions for functional > > continuations: after all, the exception's

Re: [Python-Dev] functional continuations

2007-12-15 Thread tomer filiba
[2]. [1] while (STACK_LEVEL() > b->b_level) { v = POP(); Py_XDECREF(v); } [2] hrrrmpff -tomer On Dec 15, 2007 6:57 PM, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > At 01:04 AM 12/15/2007 -0800, tomer filiba wrote: > >* do you suppose it will work? are there any drawb

[Python-Dev] functional continuations

2007-12-15 Thread tomer filiba
i'm working on some minimalistic asynchronous framework for python, somewhat like twisted or stackless, but for different purposes. i came to the conclusion i want to be able to "freeze" functions, and resume them later, when some condition is matched. the idea i came up with is, using exceptions

Re: [Python-Dev] import file extensions

2007-09-14 Thread tomer filiba
On 9/14/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > The best way would be to not use import, but provide a separate > function (e.g. calling it "require"). > yepp, that's probably the cleanest and quickest solution. i needed to see all the alternatives to realize this though. sorry. --

[Python-Dev] import file extensions

2007-09-14 Thread tomer filiba
a quick question: i'm working on a pythonic build system, where the build scripts are plain python files. but i want to differentiate them from normal python files (.py) by a different suffix (say .pyy), but then i can't import them. so i'm wondering, is there a quick way to just add another exten

[Python-Dev] generators and with

2007-05-13 Thread tomer filiba
why not add __enter__ and __exit__ to generator objects? it's really a trivial addition: __enter__ returns self, __exit__ calls close(). it would be used to ensure close() is called when the generator is disposed, instead of doing that manually. typical usage would be: with mygenerator() as g:

Re: [Python-Dev] classes and cell variables question

2006-12-29 Thread tomer filiba
On 12/29/06, Jeremy Hylton <[EMAIL PROTECTED]> wrote: > def spam(): > x = 5 > class eggs(object): > x = 6 > def spam(self): > return x > return eggs > > spam()().spam() should return 5. > the question that arises is -- is this what we wanted? if i had to read such code, where i

Re: [Python-Dev] Non-blocking (asynchronous) timer without thread?

2006-12-23 Thread tomer filiba
> The main goal is to prevent threads overhead and problems with race > conditions and deadlocks. check out stackless python -- http://www.stackless.com/ -tomer ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/p

Re: [Python-Dev] classes and cell variables question

2006-12-19 Thread tomer filiba
> If you don't follow this reasoning, please write a counter-proposal > so that people have something to shoot down. ? i just wanted to be sure it was done on purpose, and what were the reasons for that. -tomer On 12/20/06, "Martin v. Löwis" <[EMAIL PROTECTED]> wr

[Python-Dev] classes and cell variables question

2006-12-19 Thread tomer filiba
to my understanding of the object model, the code of snippet 1 and snippet 2 should be equivalent. a class is just a "special function" that returns its locals automatically and passes them to the metaclass constructor: --- snippet 1 --- class foo(object): x = 5 def f(self): print

Re: [Python-Dev] infinities

2006-11-26 Thread tomer filiba
> Um, you do realize that you're not going to be able to fit sys.maxint > strings into a list, right? i can multiply by four, thank you. of course i don't expect anyone to read a string *that* long. besides, this *particular example* isn't important, it was just meant to show why someone might wan

Re: [Python-Dev] infinities

2006-11-26 Thread tomer filiba
e, not a separate module. here's what i want: >>> f = 5.0 >>> f.is_infinity() False >>> float.PosInf 1.#INF -tomer On 11/26/06, Bob Ippolito <[EMAIL PROTECTED]> wrote: > On 11/26/06, tomer filiba <[EMAIL PROTECTED]> wrote: > > i found several pl

[Python-Dev] infinities

2006-11-26 Thread tomer filiba
i found several places in my code where i use positive infinity (posinf) for various things, i.e., def readline(self, limit = -1): if limit < 0: limit = 1e1 # posinf chars = [] while limit > 0: ch = self.read(1) chars.append(ch)

Re: [Python-Dev] __dir__, part 2

2006-11-07 Thread tomer filiba
> as well as updating the documentation in various > places (the dir and PyObject_Dir documentation, obviously, but also the list > of magic methods in the language reference). oops, i meant everything except that -tomer On 11/7/06, tomer filiba <[EMAIL PROTECTED]> wrote: >

Re: [Python-Dev] __dir__, part 2

2006-11-07 Thread tomer filiba
okay, everything's fixed. i updated the patch and added a small test to: Lib/test/test_builtins.py::test_dir -tomer On 11/7/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > tomer filiba wrote: > > cool. first time i build the entire interpreter, 'twas fun :) > > cur

Re: [Python-Dev] __dir__, part 2

2006-11-06 Thread tomer filiba
x27;, '__module__', '__new__', '__reduce__', '__reduce_ ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'bow', 'wow'] -tomer On 11/6/06, Guido van Rossum <[EMAIL PROTECTED]> wrot

[Python-Dev] __dir__, part 2

2006-11-06 Thread tomer filiba
so, if you remember, i suggested adding __dir__ to objects, so as to make dir() customizable, remove the deprecated __methods__ and __members__, and make it symmetrical to other built-in functions. you can see the original post here: http://mail.python.org/pipermail/python-dev/2006-July/067095.htm

Re: [Python-Dev] weakref enhancements

2006-09-29 Thread tomer filiba
this may still be premature, but i see people misunderstood the purpose. weakattrs are not likely to be used "externally", out of the scope of the object. they are just meant to provide an easy to use means for not holding cyclic references between parents and children. many graph-like structures

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread tomer filiba
> I'm sceptical that these would find use in practice.> [..]> Also, I question the utility of maintaining a weakref to a method or> attribute instead of holding one for the object or class.  As long as > the enclosing object or class lives, so too will their methods and> attributes.  So what is the

[Python-Dev] weakref enhancements

2006-09-28 Thread tomer filiba
i'd like to suggest adding weak attributes and weak methods to the std weakrefmodule. weakattrs are weakly-referenced attributes. when the value they reference is no longer strongly-referenced by something else, the weakattrs "nullify" themselves. weakmethod is a method decorator, like classmethod

[Python-Dev] dict containment annoyance

2006-08-12 Thread tomer filiba
[Aahz] > -1 > > This is seriously no different from an attempt to do > > >>> a = {} > >>> a[ [] ] = 1 how so? i'm not trying to modify/store anything in a dict. i'm only testing if a certain object is contained in the dict. that's totally different. imagine this: >>> x = 6 >>> x < 2 am i trying to

[Python-Dev] dict containment annoyance

2006-08-12 Thread tomer filiba
>>> a={1:2, 3:4}>>> [] in aTraceback (most recent call last):  File "", line 1, in ?TypeError: list objects are unhashable>>>imo, the _expression_ should just evaluate to False instead of raising an  exception. it's a question of semantics -- i asked whether the object (a list, in this case)is cont

Re: [Python-Dev] PyThreadState_SetAsyncExc bug?

2006-08-11 Thread tomer filiba
so it should be fixed, or at least checked for conformness by the code.-tomerOn 8/11/06, Tim Peters < [EMAIL PROTECTED]> wrote:[tomer filiba]> while working on a library for raising exceptions in the context > of another thread, i've come across a bug in PyThreadState_SetAsyncEx

Re: [Python-Dev] PyThreadState_SetAsyncExc bug?

2006-08-11 Thread tomer filiba
opened a new bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1538556&group_id=5470&atid=105470 On 8/11/06, tomer filiba <[EMAIL PROTECTED]> wrote: > while working on a library for raising exceptions in the context > of another thread, i

[Python-Dev] PyThreadState_SetAsyncExc bug?

2006-08-11 Thread tomer filiba
while working on a library for raising exceptions in the context of another thread, i've come across a bug in PyThreadState_SetAsyncExc. if i raise an instance, sys.exc_info() confuses the exception value for the exception type, and the exception value is set None. if i raise the type itself, the i

Re: [Python-Dev] patching pydoc?

2006-07-28 Thread tomer filiba
tching pydoc? > Newsgroups: gmane.comp.python.devel > Date: 2006-07-28 18:29:50 GMT (5 hours and 27 minutes ago) > > "tomer filiba" gmail.com> wrote in message > news:1d85506f0607280635q3a693682l230c7821dc6f408f mail.gmail.com... > ... > > therefore, i would lik

[Python-Dev] Fwd: patching pydoc?

2006-07-28 Thread tomer filiba
submitted patch: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1530482&group_id=5470 -tomer -- Forwarded message -- From: tomer filiba <[EMAIL PROTECTED]> Date: Jul 28, 2006 3:35 PM Subject: patching pydoc? To: python-dev@python.org i have a pro

[Python-Dev] patching pydoc?

2006-07-28 Thread tomer filiba
i have a problem with pydoc in rpyc. i wanted help(obj), where obj is a NetProxy object, to work as if it were local. i followed the code starting from site.help to pydoc.doc, which is the ultimate function that generates and prints the text. i expected there would be some function in the middle t

[Python-Dev] exception too expensive?

2006-07-08 Thread tomer filiba
i thought avoiding a second dict lookup should be faster, but it turned out to be completely wrong. it's only marginally faster, but if an exception occurs,it's x10 slower.## the code#>>> import time >>> b = dict((i, 7) for i in range(1000)) >>> def try_lookup(k):... try:... return b[k]

[Python-Dev] introducing __dir__?

2006-07-06 Thread tomer filiba
i'd guess this has been brought up before, but i'm not aware of it. anyway -- by what i've gathered, today's dir() "collects" the attributes of the object from __dict__, __methods__, __members__, and ultimately __class__. also, if i understood correctly, __methods__ and __members__ are deprecated.

Re: [Python-Dev] weakattr

2006-07-03 Thread tomer filiba
#x27;s not much to test :) ) > Toss it out in python-list, I think some people over there would be able > to offer more feedback. will do... although i doubt they will offer any -tomer On 7/2/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "tomer filiba" <[EMAIL

[Python-Dev] weakattr

2006-07-01 Thread tomer filiba
weakattr (weak attributes) are attributes that are weakly referencedby their containing object. they are very useful for cyclic references --an object that holds a reference to itself. when a cyclic reference is found by the GC, the memory may be freed, but __del__ is not called, because it's impo

Re: [Python-Dev] suggestion: except in list comprehension

2006-04-26 Thread tomer filiba
  x.append(...)    except:    ...and it's such a big syntactic change.don't worry, i'm not going to argue it past this.-tomer On 4/26/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: "tomer filiba" <[EMAIL PROTECTED]> wrote:> "[" for in [if ] [ex

[Python-Dev] suggestion: except in list comprehension

2006-04-26 Thread tomer filiba
a friend of mine suggested this, and i thought i should share it with the mailing list.many times when you would want to use list/generator comprehensions, you have tofall back to the old for/append way, because of exceptions. so it may be a good idea to allow an exception handling mechanism in the

[Python-Dev] bin codec + EOF

2006-04-21 Thread tomer filiba
yeah, i came to realize nothing helpful will ever come out from this list, so i might as well stop trying. but i have one last thing to try.i'm really missing a binary codec, just like the hex codec, for doing things like >>> "abc".encode("bin")"01110110001001100011">>> "0111011000100110001

Re: [Python-Dev] proposal: evaluated string

2006-04-20 Thread tomer filiba
x27;t support quantom superposition?-tomer On 4/20/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: Tomer, please stop. We've seen your proposal. We've said "-1". Pleasetake it instead of wasting your time trying to argue for it.On 4/20/06, tomer filiba <[EMAIL PROTECTE

Re: [Python-Dev] proposal: evaluated string

2006-04-20 Thread tomer filiba
We already have a slew of templating utilities (see Cheetah for example).first of all -- i know there's a bunch of templating engines, but i think it should be a built-in feature of the language. like boo does. and estr is stronger than simple $name substitution, like Template does. Be sure to stay

Re: [Python-Dev] proposal: evaluated string

2006-04-20 Thread tomer filiba
you'll need it as a builtin-tomerOn 4/20/06, Josiah Carlson < [EMAIL PROTECTED]> wrote:"tomer filiba" < [EMAIL PROTECTED]> wrote:> the evaluated string will be evaluated based on the current scope (locals> and globals), just like> normal expressions. the differen

[Python-Dev] proposal: evaluated string

2006-04-20 Thread tomer filiba
many times, templating a string is a tidious task. using the % operator, either with tuples or dicts,is difficult to maintain, when the number of templated arguments is large. and string.Template,although more easy to read, is less intutive and cumbersome: import stringt = string.Template("hello $n

[Python-Dev] bug with __dict__?

2006-04-19 Thread tomer filiba
overriding __getattr__ and __setattr__ has several negative side effects, for example:* inside__getattr__/__setattr__ you have to use self.__dict__["attr"] instead of self.attr* it's easy to get stack overflow exceptions when you do something wrong * you must remember to call the super's [get/set]

Re: [Python-Dev] adding Construct to the standard library?

2006-04-19 Thread tomer filiba
n already included in the stdlib, i still think it has a room there. existing projects can be ported without too much effort, and new ones could benefit from it as well.-tomerOn 4/19/06, Giovanni Bajo <[EMAIL PROTECTED]> wrote: tomer filiba <[EMAIL PROTECTED]> wrote: > the point is -

[Python-Dev] a flattening operator?

2006-04-18 Thread tomer filiba
i'm not going to defend and fight for this idea too much. i only bringit up because it bothers me. i'm sure some people here would kill me for even suggesting this, and i really don't want to be killed right now,so i bring it up as something you should think about. nothing more.PEP-225 has some wei

Re: [Python-Dev] adding Construct to the standard library?

2006-04-18 Thread tomer filiba
elpful library as a builtin, and so is Construct. the two don't competeon a spot in the stdlib.-tomer On 4/18/06, Paul Moore <[EMAIL PROTECTED] > wrote: On 4/17/06, tomer filiba <[EMAIL PROTECTED]> wrote:> after several people (several > 10) contacted me and said "IMHO 

Re: [Python-Dev] adding Construct to the standard library?

2006-04-18 Thread tomer filiba
Indeed, I wish I had known about this a year ago; it would have saved me a lot of work.  Of course it probably didn't exist a year ago...  :( well, yeah. many people need "parsing-abilities", but they resort to ad-hoc parsers using struct/some ad-hoc implementation of their own. there clearly is a

[Python-Dev] adding Construct to the standard library?

2006-04-17 Thread tomer filiba
hello folksafter several people (several > 10) contacted me and said "IMHO 'construct' is a good candidate for stdlib",i thought i should give it a try. of course i'm not saying it should be included right now, but in 6 months time, or such a timeframe (aiming at python 2.6? some 2.5.x release?)a