hi
i'm trying to figure out if a pipe on win32 has data for me to read.
this is the code i've come up with:
def poll(self, timeout, interval = 0.2):
"""a poor man's version of select() on win32"""
from win32pipe import PeekNamedPipe
from msvcrt import g
i've had this strange idea of using the exception's traceback (which
holds the stack frame) to enable functional continuations, meaning,
raise some special exception which will be caught by a reactor/
scheduler/framework, which could later revive it by restoring the
frame.
i'm thinking of using th
how i manage to optimize my code
from here.
-tomer
On Jan 25, 4:51 pm, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Thu, 25 Jan 2007 04:29:35 -0800, Paul Rubin wrote:
> > "gangesmaster" <[EMAIL PROTECTED]> writes:
> >> what i see as a bug is thi
print "my name is", name
... return foo
...
>>> def make_foos(names):
... return [make_foo(n) for n in names]
...
>>> foos = make_foos(["hello", "world", "spam", "bacon"])
>>> foos[0]()
my name is hello
>>> f
ugliness :)
so this is why [lambda: i for i in range(10)] will always return 9.
imho that's a bug, not a feature.
thanks.
-tomer
Duncan Booth wrote:
> "gangesmaster" <[EMAIL PROTECTED]> wrote:
>
> > what problem does the cell object solve?
>
> The c
why does CPython require to wrap the free variables if
closure functions by a cell objects?
why can't it just pass the object itself?
>>> def f(x):
... def g():
... return x+2
... return g
...
>>> g5 = f(5)
>>> dis(g5)
3 0 LOAD_DEREF 0 (x)
just something i thought looked nice and wanted to share with the rest
of you:
>>> class x(object):
... def __metaclass__(name, bases, dict):
... print "hello"
... return type(name, bases, dict)
...
hello
>>>
instead of defining a separate metaclass function/class, you
three-liner:
reposted from python-dev for more feedback. it suggests to add
the weakattr class to the standard weakref.py module.
comments are welcome.
[ http://article.gmane.org/gmane.comp.python.devel/81875 ]
From: tomer filiba gmail.com>
Subject: weakattr
Newsgroups: gmane.comp.python.devel
D
what uses do you have to socket.dup? on *nixes it makes,
to dup() the socket before forking, but how can that be useful
on windows?
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
the following (random) code crashes my interpreter
(python 2.4.3/winxp):
from types import CodeType as code
exec code(0, 5, 8, 0, "hello moshe", (), (), (), "", "", 0, "")
i would expect the interpreter to do some verifying, at least for
sanity (valid opcodes, correct stack size, etc.) before exe
None is not currently a keyword
--
http://mail.python.org/mailman/listinfo/python-list
typing "help(type)" gives the following documentation:
>>> help(type)
Help on class type in module __builtin__:
class type(object)
| type(object) -> the object's type
| type(name, bases, dict) -> a new type
"type" behaves both as a function, that reports the type of an obje
> Today you can archive the same effect (but not necessarily with the same
> performance) with:
>
> for node in (x for x in tree if x.haschildren()):
>
true, but it has different semantic meanings
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
i wanted to suggest this myself. +1
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
sock2 is an attempt to improve python's socket module, by a more
pythonic version (options are properties, protocols are classes,
etc.etc)
you can get it here (including a small demo)
http://iostack.wikispaces.com/download
i would like to receive comments/bug reports, to improve it.
just reply to
anyone has a good bit-stream reader and writer?
(before i go to write my own)
i.e.
f = open(..)
b = BitStream(f)
b.write("10010010")
b.read(5) # 10010
or something like that?
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
see http://interpython.sourceforge.net
--
http://mail.python.org/mailman/listinfo/python-list
Remote Python Call (RPyC) has been released. this release introduces
delivering objects, reducing memory consumption with __slots__, and
several other new/improved helper functions. see the release notes and
changelog (on the site) for more info.
home:
http://rpyc.wikispaces.com
-tomer
--
htt
Remote Python Call (RPyC) - transparent and symmetrical python RPC and
distributed computing library
download and info: http://rpyc.wikispaces.com
full changelog: http://rpyc.wikispaces.com/changelog
release notes: http://rpyc.wikispaces.com/release+notes
major changes:
* added isinstance and iss
Remote Python Call 2.50 release-candidate
http://rpyc.wikispaces.com
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
Construct, the "parsing made fun" library, has moved from it's
sourceforge home to wikispaces:
http://pyconstruct.wikispaces.com
(the sf page redirects there)
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
that's not a question of design. i just want a child-thread to kill the
process. in a platform agnostic way.
--
http://mail.python.org/mailman/listinfo/python-list
i can't make the main thread daemonic. the situation is this:
* the main thread starts a thread
* the new thread does sys.exit()
* the new thread dies, but the process remains
i can do os.kill(os.getpid()), or TerminateProcess(-1) but that's not
what i want
-tomer
--
http://mail.python.org/mail
(i forgot to say it didn't work)
--
http://mail.python.org/mailman/listinfo/python-list
>>> import threading
>>> t=threading.Thread(target=sys.exit)
>>> t.setDaemon(True)
>>> t.start()
>>>
?
--
http://mail.python.org/mailman/listinfo/python-list
calling sys.exit() from a thread does nothing... the thread dies, but
the interpreter remains. i guess the interpreter just catches and
ignore the SystemExit exception...
does anybody know of a way to overcome this limitation?
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
[for people who missed my previous posts]
"""RPyC is a transparent, symmetrical python library for
distributed-computing. Pronounced "are-pie-see", it began as an RPC
library (hence the name), but grew into something much more
comprehensive with many use cases. It basically works by giving you
ful
the RPyC's project page has moved to
http://rpyc.wikispaces.com
the old site (http://rpyc.sourceforge.net) redirects there now. because
it's the official site, i chose to limit changes to members only.
it's so much easier to maintain the wiki that the crappy htmls at
sourceforge :)
anyway, the ne
class person(object):
def _get_age(self):
return self.__age
age = property(_get_age) # a read-only property
def _get_name(self):
return self.__name
def _set_name(self, value):
self.__name = value
name = property(_get_name, _set_name)
--
http://mail.pyt
okay, i got the name wrong. i wasn't trying to provide production-level
code, just a snippet. the function you want is
PyRun_SimpleString( const char *command)
#include
char secret_code[] = "print 'moshe'";
int main()
{
return PyRun_SimpleString(secret_code);
}
and you need to link with py
as we all know, * (asterisk) can be used to "inline" or "flatten" a
tuple into an argument list, i.e.:
def f(a, b, c):
...
x = (1,2,3)
f(*x)
so... mainly for symmetry's sake, why not make a "flattening" operator
that also works outside the context of function calls? for example:
a = (1,2,3)
well, you can do something silly: create a c file into which you embed
your code, ie.,
#include
char code[] = "print 'hello moshe'";
void main(...)
{
Py_ExecString(code);
}
then you can compile the C file into an object file, and use regular
obfuscators/anti-debuggers. of course people who
?
i really liked it
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
"make type" is uber leet
--
http://mail.python.org/mailman/listinfo/python-list
finally, i opened a wiki for Construct, the "parsing made fun" library.
the project's page: http://pyconstruct.sourceforge.net/
the project's wiki: http://pyconstruct.wikispaces.com/ (anyone can
edit)
so now we have one place where people can share inventory constructs,
questions-and-answers, pat
i dont think it's possible, to create proxy classes, but even if i did,
calling remote methods with a `self` that is not an instance of the
remote class would blow up.
-tomer
--
http://mail.python.org/mailman/listinfo/python-list
i was taking about python...
--
http://mail.python.org/mailman/listinfo/python-list
let's start with a question:
==
>>> class z(object):
... def __init__(self):
... self.blah=5
...
>>> class x(object):
... def __init__(self):
... z.__init__(self)
...
>>> y=x()
Traceback (most recent call last):
File "", line 1, in ?
File "", line 3, in
>> Why is the first uglier than the second?
YES THATS THE POINT. PYTHON CAN BE USED JUST LIKE A CONFIG FILE.
and if your users did
timeout = "300"
instead of
timeout = 300
then either your config parser must be uber-smart and all-knowing, and
check the types of key-value pairs, or your server wou
> Huh? You think a competent sys admin can't learn enough Python to hack
> your pickled file?
>
> Binary configs only keep out legitimate users who don't have the time or
> ability to learn how to hack the binary format. Black hats and power users
> will break your binary format and hack them anywa
40 matches
Mail list logo