I think there might be something wrong with the implementation of
modulus.
Negative float values close to 0.0 break the identity "0 <= abs(a % b)
< abs(b)".
print 0.0 % 2.0 # => 0.0
print -1e-010 % 2.0 # =>1.99
which is correct, but:
print -1e-050 % 2.0 # => 2.0
print -1
Hmmm. I understand. I'd suggest that someone just drop a link from the
Library reference manual as the divmod entry over there seems to
contradict it.
"""
divmod(a, b)
Take two (non complex) numbers as arguments and return a pair of
numbers consisting of their quotient and remainder when using lo
Anyone know what this error means?
C:/Python24/pythonw.exe -u "C:/Python24/MyProjects/HeadsUp/cls_Bot.py"
File "C:/Python24/MyProjects/HeadsUp/cls_Bot.py", line 10246
elif handname == 'straightflush':
SystemError: com_backpatch: offset too large
thanks
--
http://mail.python.org/mailman/l
thanks for the heads up. I read other posts on this error, but it's
unclear to me whether the following will be a problem as well. Suppose
I break up my very long module into smaller modules and import them
into another module 'main'. Will I get the same error running main if
the total number of
thanks for the help.
cheers.
--
http://mail.python.org/mailman/listinfo/python-list
Always nice to recommend myself:
http://farpy.holev.com
Free WYSIWYG GUI editor for wxPython (and wxRuby!).
Have fun...
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I'm using a tp_getattro function to call into a C library and get
values the the lib keeps track of. This works:
>>> o = obj.Obj()
>>> o.var
'value'
Thats great but I also want to expose some instance methods and I'm
having trouble.
But when I set tp_methods nothing shows up? If I unset t
André Malo wrote:
> tp_getattro is like defining __getattribute__, i.e. it gets called on every
> attribute read access. You can use PyObject_GenericGetAttr inside the
> function to find predefined attributes before applying your own rules.
Thanks for the reply. I see and was afraid of that, I
Ahhh... The the light clicks on in my head. I see what is happening
and both of these are great approaches.
Many thanks!
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Im trying to create a version of the game Wumpus. Mine is called
> Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
> some one help me??
> here is the file:
> http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0
>
> Wh
connyledin wrote:
> Im trying to create a version of the game Wumpus. Mine is called
> Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can
> some one help me??
> here is the file:
> http://esnips.com/webfolder/b71bfe95-d363-4dd3-bfad-3a9e36d0
>
> What i have the biggest problem
I have been using ZOPE (mostly with CMF/Plone) for a couple years now.
MY recolleciton of the initial leraning curve, was hours reading
through source code, newsgroups, web site, outdated garbage, days long
marathons of coffee, beer and very little sleep.
After about 2 weeks of this horrible mindn
Thats the best way to go about it. Python I find is fun because you
can just play with the interpreter throwing commands at it and really
just working with syntax and usually POC ideas. The most useful ideas
usually just come to you. I recieved a pretty barebones MP3 player
from my sister for my
Try matplotlib, it's pretty nice and easy to use.
--
http://mail.python.org/mailman/listinfo/python-list
sturlamolden wrote:
> But as long as the cygwin dll is there, it creates an overhead for any
> system call. The worst overhead is associated with the Unix fork()
> system call, which Cygwin must emulate as there are no Win32
> equivalent. In particular, a fork() on Unix will be optimized with
> cop
The simplest and most widely known Monty Python image I can think of is
a dead parrot.
So maybe an upside-down parrot?
Could be nice and colorful too, not to mention memorable.
It is true that many won't make the connection between some kind of
Monty Python image and the Python language, as they w
[EMAIL PROTECTED] wrote:
> the file is on that side. But apparently you have to register to
> download it.. =( But i can send it to anone who is willing to look
> trough it. just send me an email [EMAIL PROTECTED]
Ok, e-mail it to me.
But I cannot guarantee anything. I'll p
What about:
py> class A:
py. def __init__(self):
py. print self.__class__.__name__
py. print str(self)
py. def __str__(self):
py. return 'instance of %s' % self.__class__.__name__
py.
py> a = A()
A
instance of A
py>
--
http://mail.python.org/mailman/l
If you are interested in static analysis for bug hunting purposes, then
you might want to have a look at Pylint.
Cheers,
Aurélien.
--
http://mail.python.org/mailman/listinfo/python-list
have you tried replacing :
main = threading._MainThread()
with
main = threading.currentThread() ?
(not sure if that will be sufficient)
Well your way to pass exception between threads looks like I would have
done myself. But I am no expert.
Have you considered using stackless Python ? It pro
ur seems bogus to me :
[EMAIL PROTECTED]:~$ python test.py
C-c
C-c
C-d
C-d
Traceback (most recent call last):
File "test.py", line 5, in ?
raw_input()
KeyboardInterrupt
The crash happens when I type C-c another time (always *after* atleast
one C-d has been issued).
What's wrong ? My
Thanks Robert.
But I'm not trying something at all with this, only asking if it is a
bug (and it looks like one). I suspect too, that it is related to
signal handling.
Cheers,
Aurélien.
--
http://mail.python.org/mailman/listinfo/python-list
I am trying to package my application with py2exe. Unfortunately it
uses both scipy/numpy and numarray so I'm having to jump through a lot
of hoops to get it going. I'm getting problems packaging an app that
uses only scipy. See below.
Thanks!
Janto
===setup.py===
from distutils.core import setup
wrong group
--
http://mail.python.org/mailman/listinfo/python-list
I know it is racey, but the bug is not the race (iow : it is not a
matter of pressing twice C-c very quickly). It happens all the time. I
let enough time between the key strokes to let the program wait on
raw_input.
Or maybe you have something else in mind. Care to expand ?
Thanks,
Aurélien.
--
Precision : it does not happen when running interactively.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
I am having trouble figuring out how to set up an object to be
scriptable through the C API. An example of what I am attempting to
do:
>>> obj = foo.Foo()
>>> obj["key"]
Traceback (most recent call last):
File "", line 1, in ?
TypeError: unsubscriptable object
>>>
I've tried defining __ge
[EMAIL PROTECTED] wrote:
> i just mailed it to you. Thanks for looking at it.
Returning.
Comments added by me start #m.
I tried to keep all your original lines commented out and
added my fixes with #m on either side, but there were
so many errors I had to give up. I tried to preserve the
c
Posting that error message would be helpful
--
http://mail.python.org/mailman/listinfo/python-list
I see a C/python program that we're using spending a lot of time in
this function, far more than we think it should. What is it?
Thanks in advance! There seems to be nothing (but a bunch of stack
traces) when I google this.
Brett
--
http://mail.python.org/mailman/listinfo/python-list
That worked! Thank You!
I'd also like to say this group is great at fast accurate responses!
Cheers!
thanks
~jason
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik is right, ChatFactory doesn't have sendLine as a method b/c it
doesn't inherit it from ClientFactory. The code: protocol = ChatClient
does do anything within ChatFactory except set the variable. Try out
these.
from twisted.protocols.basic import LineReceiver, LineReceiver.sendLine
or chan
Tim Chase wrote:
> >
> > a = ['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]]
> >
> > As an exercise, write a loop that traverses the previous list and
> > prints the length of each element. What happens if you sen
kpp9c wrote:
> I have a several list of songs that i pick from, lets, say that there
> are 10 songs in each list and there are 2 lists.
>
> For a time i pick from my songs, but i only play a few of the songs in
> that list... now my wife, Jessica Alba, comes home, and i start playing
> from Jessic
I'm pleased to announce the 0.9.0a1 release of nose, a test runner that
brings py.test convenience to unittest, without resorting to (too much)
magic.
nose 0.9 includes a host of new features, as well as numerous
backwards-incompatible changes to interfaces and implementation. For
this reason, I'm
I'm pleased to announce the 0.9.0a1 release of nose, a test runner that
brings py.test convenience to unittest, without resorting to (too much)
magic.
nose 0.9 includes a host of new features, as well as numerous
backwards-incompatible changes to interfaces and implementation. For
this reason, I'm
First of all, the test can be optimized by adding a boolean flag which
indicates if the data has been initialized or not, and then just
testing a boolean value instead of doing an "is" comparison, at the
cost of an extra global variable. But this is still ugly (actually
uglier IMO).
I think this
Yes, my implementation was less efficient because of the extra function
call.
> class Weird(object):
> @staticmethod
> def __call__(arg):
> data = 42
> def func(arg):
> return arg+data
> Weird.__call__ = static
Personally, I would almost always pay the x2 efficiency price in order
to use a class. But then I don't know what you're writing.
Of course, if you really need it to be efficient, you can write it as a
C extension, or use Pyrex, etc. and get -much- better results.
--
http://mail.python.org/mailm
Can someone tell me of a good algorithm to partition a set of n
elements into m non-empty, disjoint subsets, where each subset has size
k?
--
http://mail.python.org/mailman/listinfo/python-list
Also, if I do not care about the number of subsets, what is a good
algorithm to partition a set of n elements into non-empty, disjoint
subsets of size k?
--
http://mail.python.org/mailman/listinfo/python-list
Hello,
Not quite what I'm looking for. I would like a list of all partitions
with each partition having k or less elements, not just one instance.
[EMAIL PROTECTED] wrote:
> Something like this, or am I missing something?
>
> def partition(List, n, m, k):
> if n!=m*k:
I am trying to find a way to poll the keyboard. In my searching, I
have found that Windows users are given the msvcrt module. Is there an
equivilant for Unix systems?
I am writing a p2p chat application, and would like to ideally approach
user input in a manner similar to the way I am using poll
Is there a way to get the length of a video clip (divix/xvid) in
seconds?
oh this is on linux. I first tryed to see if mplayer would tell me then
I could wrap the call in a popen object and be done but it does not
appear to output the length.
Now I am looking at pymedia .It would be nice if there w
You could have a look at the Mozart/Oz community. Oz is a language
supporting logic and constraint programming out of the box and people
are using these capabilities to play linguistic with graph
matching.
See http://www.lifl.fr/~duchier/papers/duchier-xdg-cslp2004.pdf for a
possibly enlightening
m the above you can see what int to long promotion is causing
Nope, it's not the promotion causing the problem.
> i dont need to say much please see for yourself. is this a bug or
> a feature.
Neither. Try changing the "+" and "-" to "+=" and "-=&
I was curious if there was any benefit to having an OS written
in Python.
The only benefit I can think of is that maybe Python is easier
to audit for security bugs than C is.
Any other benefits?
Chris
--
http://mail.python.org/mailman/listinfo/python-list
that will break horribly in windows, remenber it install all it's crap
in c:\Program Files
--
http://mail.python.org/mailman/listinfo/python-list
Is there a way that using Tkinter I can pre-render the canvas then draw
it on the screen?
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Try to use set objects:
>>> a=set(range(10))
>>> b=set(range(5))
>>> a = a - b
--
http://mail.python.org/mailman/listinfo/python-list
Some Googling yielded this recipe
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/137951/index_txt,
a little test shows promising results of the described recipe. BTW: the
Python Cookbook is always a good place to browse with questions other
people probably had as well!
--
http://mail.pyt
Hi!
Thank you for a quick and informative response!
> I'd go for 'manually decorating' anyway. Metaclasses can be really handy
> for framework-like stuff, but for the use case you describe, I think the
> explicit decorator option is much more, well, explicit - and also more
> flexible - than meta
It appears that apps distributed as Python Eggs are either a single
compressed
blob in site-packages directory or a directory under site-packages
directory.
Is this ALWAYS true? So by just erasing stuff under site-packages
I can do a COMPLETE uninstallation of an Egg?
Chris
--
http://mail.pyth
I played around with my old code before I saw your post, and I believe
I've found a solution that's a bit neater than what I had before. I
thought I could just as well post it if you're interested and have the
time. This one uses multiple inheritance, but it's legal and there's
only one metaclass.
Is there a good way to splice two lists together without resorting to a
manual loop? Say I had 2 lists:
l1 = [a,b,c]
l2 = [1,2,3]
And I want a list:
[a,1,b,2,c,3] as the result.
I've been searching around but I can't seem to find a good example.
Thanks,
Dan McLeran
--
http://mail.python.org
Michele Petrazzo wrote:
>
> I haven't tried to recompile py 2.4 myself with gcc 4.1 because it is
> already compiled with it (4.0.3), so I think (only think) that is a py
> 2.5 problem.
> I'm right? or I have to compile it with something other switches?
Sounds like a gcc problem to me. Try adding
Thanks, this worked great. Can you explain the syntax of the '*' on the
return value of izip? I've only ever seen this syntax with respect to
variable number of args.
Thanks again.
--
http://mail.python.org/mailman/listinfo/python-list
Hi
I noticed that the md5 computed with md5 module from python is
different then the md5 sum computed with md5sum utility (on slackware
and gentoo).
i.e.
$echo marius|md5sum
0f0f60ac801a9eec2163083a22307deb -
>>> test = md5.new("marius")
>>> print test.hexdigest()
242aa1a97769109065e3b4df359bcfc
>When used in a function call (as opposed to a function definition), *
>is the "unpacking" operator. Basically, it "flattens" an iterable into
>arguments. The docs mention it...
Cool, looks like I didn't read carefully enough.
Thanks again.
--
http://mail.python.org/mailman/listinfo/python-li
When I have done this, I've used the last option -- creating a "config"
module which can be imported wherever the configuration info is needed.
(This module also handles any config files and/or Windows registry
keys needed.) Using a Borg is a nice idea... but that ConfigBorg is
probably going to
I don't know what I'm doing wrong, but the result is that _import_ only
works from a python shell, but not when I call a python script.
$ cat test.py
mod = __import__("/home/me/tests/test_imp")
Called from a script it does not work:
$ python /home/me/test.py
Traceback (most recent call last):
F
It's not that, it looks like __import__looks into sys.path, so
if use an absolute path
it cannot work.
I found this thread and it seems they are right:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/6eed0025488bf130/637790b4ed62
You do *NOT* want to put double-underscores before and after a method
name. That does not indicate a private method, it indicates a "magic
method" -- something that has special meaning to Python. Thus, you
have special methods like __init__(), __len__(), __getattr__(),
__setattr__(), etc; all of
But not matter where eggs are installed they
are never spread across multiple places
on hard drive right? An egg is all under
one node of tree right?
--
http://mail.python.org/mailman/listinfo/python-list
But not matter where eggs are installed they
are never spread across multiple places
on hard drive right? An egg is all under
one node of tree right?
--
http://mail.python.org/mailman/listinfo/python-list
You are absolutely right, it's that empty entry that allows the
absolute path to work.
I'll probably add the path to sys.path, but as this is only a config
file from which I need just a few vars, I'll try to use execfile,
looking in past threads it looks like a better option for this use, I
really
L = [4,3,2,1]
L=L.sort()
L will refer to None, why L.sort() don't return the L?
I want to ask why the designer of Python do so?
--
http://mail.python.org/mailman/listinfo/python-list
Thanks a lot!
However, I wonder why L.sort() don't return the reference L, the
performance of return L and None may be the same. If L.sort() return
L, we shouldn't do the awful things such as:
keys = dict.keys()
keys.sort()
for key in keys:
...do whatever with dict[key]...
we can only write t
Sorry to follow up myself, I've finally used the execfile approach,
passing an empty dict for capturing locals and then just processing it:
new_settings = {}
execfile(self.SETTINGS_MODULE, new_settings) # returns its locals in
new_settings
# assign UPPER_CASE vars
for setting in new_settings.keys
Hi everybody,
we want extract numbers from strings and wonder if there is already a
module around for doing this. An example in our case would look like
this:
0.032 +/- 0.5 x 10(-4)
it would even be helpful to have a routine which does not recognise the
+/- , but at least the 10(-4).
Thank you
Hi!
I'm writing a server and I want to use the logging module for logging
stuff. I want to log all transactions in detail, and if everything goes
haywire I want to know which client did it. Therefore I want to affix
the client address to every single log item.
I would like to do the following:
Fo
Thank you!
I got it.
--
http://mail.python.org/mailman/listinfo/python-list
Michele Petrazzo wrote:
> [EMAIL PROTECTED] wrote:
> > Michele Petrazzo wrote:
> >> I haven't tried to recompile py 2.4 myself with gcc 4.1 because it
> >> is already compiled with it (4.0.3), so I think (only think) that
> >> is a py 2.5 problem
Hello,
There're a pylint (http://www.logilab.org/projects/pylint) and
pychecker (http://pychecker.sourceforge.net/) projects.
Eugene
--
http://mail.python.org/mailman/listinfo/python-list
This is why your best bet is probably threads.
Class Eureka(Threading.Thread):
def __init__(self):
Threading.Thread.__init__(self)
self.start()
def run(self,sleep_time):
while 1:
time.sleep(sleep_time)
print "eureka"
--
http://mail.python.o
7;__builtins__': , '__name__':
> '__main__', '__doc__': None}
> >>> blah = None
> >>> globals()
> {'__builtins__': , '__name__':
> '__main__', '__doc__': None, 'blah': None}
>
multi-line lambdas, had it been added to python a long time ago, would
had reduced a lot of complexity in the language.
for example - with multi-line lambdas - decorators are unneccesary.
just give the multi-line lambda as an argument to a function - no need
for special syntax..
the alternative dec
Thank you all for your suggestions. After a few modifications the
approach with the regexps works well!
Sebastian
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
is it possible to pass args through the api which are the same as the
args you can use on the sqlite3 command line?
What I'm talking about is the .mode or .output commands which you can
enter via the sqlite3 cli so I can dynamically change were the output
goes.
Ta
--
http://mail.python.org/ma
Ah, je comprend. Thanks for pointing that out to me - I'll just have to
spend more time at the code face to get the job done.
Many thanks,
Lol
--
http://mail.python.org/mailman/listinfo/python-list
this is how I think it should be done with multi-line lambdas:
def arg_range(inf, sup, f):
return lambda(arg):
if inf <= arg <= sup:
return f(arg)
else:
raise ValueError
and instead of
@arg_range(5, 17)
def f(arg):
return arg*2
you do:
f = arg_range(5, 17, lambda(arg)):
Can some one get me started with a working SOAP server that works over
https. (SSL)?
I have M2Crypto installed and found the following sample, but something
is wrong in ssl_context = SSL.Context()
Any help or tutorial appreciated?
from SOAPpy import SOAPServer
from M2Crypto import SSL
Hy every one. An amazing opportunity for all the people to buy and get
all the information related to the Laptops, Computer Systems,
registration for free trail and for rental basis. Effort less thing,
just make look over www.eazyrentals.com
--
http://mail.python.org/mailman/listinfo/python-lis
Replace:
mesg['To'] = recievelist
By:
mesg['To'] = ', '.join(recievelist)
--
http://mail.python.org/mailman/listinfo/python-list
Sebastjan Trepca wrote:
> Hi!
>
> just wanted to send a notice about a new portal/group for Slovenian
> Python fans here :)
>
> http://soup.zen.si (btw, it's in slovene lang)
But why is SOUP (Slovenski Ortodoksni Uporabniki Pythona)
used as an acronym?
Or is SOUP a word in Slovene also?
>
> S
robert wrote:
> From the trace of a 2.3.5 software i got:
>
> \'SystemError:
> C:sfpythondist23srcObjectscellobject.c:22: bad
> argument to internal
> function\\n\']
...
> Will there be another bug-fix release of Python 2.3 ?
No, is this still a problem in 2.4? 2.4.4 i
Yet another option:
Use web-service provided by your mobile operator
(by means of cookielib, urllib2, etc).
--
http://mail.python.org/mailman/listinfo/python-list
Yet another option:
Use Python high level API for Symbian
(http://opensource.nokia.com/projects/pythonfors60/)
to write simple server which listen to desktop client (both in Python).
Server (phone side): accept requests, send SMS using mobile phone
capability
Client (desktop): send requests, speci
Try something like this...
HTH. A.
from datetime import *
d1 = datetime( year=2006, month=5, day=15)
d2 = datetime.now()
for d in [d1,d2]:
yest = d - timedelta(days =1 )
print "%s -> %s" % (d, yest)
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
How would one go about getting sys.argv fom within the context of a C
API extention module? I want to pass it along to C library that I'm
calling from my module code.
TIA~
I'm trying to load the sys module using:
PyObject *_argv = PyImport_ImportModule("sys.argv");
but it is coming back N
John Machin wrote:
> > PyObject *_argv = PyImport_ImportModule("sys.argv");
>
> What does the name of the function tell you? You can't do that in one
> hit. Start with
> PyObject *_sys = PyImport_ImportModule("sys");
> then you need to get the module's argv attribute.
I just figured this out, doh
BTW why are python dicts implemented as hash tables and not judy arrays?
--
http://mail.python.org/mailman/listinfo/python-list
Lists are mutable, i.e. one can do this:
a = [1,2,3]
a[0] = 100
You can't do that with a tuple.
a = (1,2,3)
a[0] = 100 # error
--
http://mail.python.org/mailman/listinfo/python-list
I'm currently trying to get access to the Python source code, however
whenever I try to extract the files using the latest version of WinZip
(version 10) I get the following error "error reading however after
processing 0 entries
--
http://mail.python.org/mailman/listinfo/python-list
I'm currently trying to get access to the Python source code, however
whenever I try to extract the files using the latest version of WinZip
(version 10) I get the following error "error reading header after
processing 0 entries"
I was under the impression that I could (from reading the various pos
>You can get Python sources from python.org
I'm unable to locate a source file brings that will work with WinZip.
Can anybody please point me to the exact URL that will get me to the
source code? but it it is tar ball format or a gzip format, than that
will work for me as WinZip is not open.
--
Scott ,
I tried downloading for different archives, (different versions of
Python) I can't believe they are all garbled. But they all don't work
with WinZip.
--
http://mail.python.org/mailman/listinfo/python-list
Is there a better way to make the subclassing of built-in types stick?
The goal is to have the the fields of a class behave like strings with
extra methods attached. That is, I want the fact that the fields are
not strings to be invisible to the client programmers. But I always
want the extras to
Toon Knapen wrote:
> I'm trying to build the svn-trunk version of python on a Solaris box.
> However I do not have a python installed yet and apparantly the build of
> python requires a python to be accessible (as also annotated in the
> Makefile generated during the ./configure). How can I solve t
Dear all,
I am trying to embed python into another scripting language, to do this
I need to solve a number of problems on importing or compiling python
script. First let me state what exactly I want to do, that is, I want
the following syntax to be supported in the host language which I am
develop
3801 - 3900 of 4914 matches
Mail list logo