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
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
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:
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__(self, item):
...
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'm doing
... 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 traceback holds the entire
context
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
(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 drawbacks i didn't
anticipate?
Yes
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.
--
An NCO
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 can't
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
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
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] wrote:
tomer filiba schrieb:
my
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)
. 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 places in my code where i use positive infinity
(posinf) for various things, i.e.,
def
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 want
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 :)
currently i retained support
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:
okay, everything's fixed
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:
are just there to make things fast; in
this case I don't see a need for dir() to be fast.
--Guido
On 11/6/06, tomer filiba [EMAIL PROTECTED] wrote:
so, if you remember, i suggested adding __dir__ to objects, so as to make
dir() customizable, remove the deprecated __methods__ and __members__
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,
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
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 point
a={1:2, 3:4} [] in aTraceback (most recent call last): File stdin, line 1, in ?TypeError: list objects are unhashableimo, 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 contained
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
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_SetAsyncExc. if i raise
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
submitted patch:
https://sourceforge.net/tracker/?func=detailatid=305470aid=1530482group_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 problem with pydoc in rpyc
minutes ago)
tomer filiba tomerfiliba at gmail.com wrote in message
news:1d85506f0607280635q3a693682l230c7821dc6f408f at mail.gmail.com...
...
therefore, i would like to split this behavior into two parts:
* render_doc - a function that returns the document text
* doc - a function that calls
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]... except
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 PROTECTED] wrote:
weakattr (weak attributes) are attributes that are weakly
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
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
this.-tomer
On 4/26/06, Josiah Carlson [EMAIL PROTECTED] wrote:
tomer filiba [EMAIL PROTECTED] wrote: [ expr for expr in expr [if cond] [except exception-class-or-tuple: action] ]
Note that of the continue cases you offer, all of them are merely simpleif condition (though the file example could use
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
just like r does the escaping for you.but estr types must be implemented so the evaluate with the current scope (locals and globals),not the score they were defined it, so unless you want to do nasty tricks with sys._getframe,
which doesn't work on all implementations of python, you'll need it as
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
could
benefit from it as well.-tomerOn 4/19/06, Giovanni Bajo [EMAIL PROTECTED] wrote:
tomer filiba [EMAIL PROTECTED] wrote:
the point is -- ctypes can define C types. not the TCP/IP stack. Construct can do both. it's a superset of ctype's typing mechanism. but of course both have the right
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
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
, and provides the mechanisms needed for that.
Construst is about data structures of all sorts and kinds. ctypes is a very helpful 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
DISCLAIMERi'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
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
43 matches
Mail list logo