Giovanni Bajo wrote:
> Hello,
>
> I experimented something very strange, a few days ago. I was debugging an
> application at a customer's site, and the problem turned out to be that
> time.clock() was going "backwards", that is it was sometimes (randomically)
> returning a floating point value whi
jay graves wrote:
> Bytter wrote:
>> Hi ppl,
>> I've already posted this message through the mailing-list, but it seems
>> it never arrived here. Strange... Anyway:
>> I need to render high-quality vector graphics with Python. I was
>> thinking of something like 'cairo', though I need to run under
Hari Sekhon wrote:
> I've written an xml parser using xml.sax which works most of the time
> but often traces back when trying to read a file. The output of the
> traceback is below:
>
> Traceback (most recent call last):
> File "/usr/lib/python2.4/site-packages/cherrypy/_cphttptools.py",
> line
Gabriele *darkbard* Farina wrote:
> The first attempt to reach my goal was to override the __import__
> function to limit it working on modules that can be used and on custom
> import directories that can be accessed. Then I executed the scripts
> using exec. There is any security problem related t
Simon Forman wrote:
> Nick Craig-Wood wrote:
>> Sets are pretty fast too, and have the advantage of flexibility in
>> that you can put any numbers in you like
>>
>
> I know this is self-evident to most of the people reading this, but I
> thought it worth pointing out that this is a great way to te
[EMAIL PROTECTED] wrote:
> The two primary differences between using def and using lambda is that
> lambda is limited to a single expression and def cannot be used within
> another function.
'def' can certainly be used within another function :
def make_adder( delta ) :
def adder( x ) :
Hi everybody,
I'm having trouble using os.path.expanduser('~') on windows. It uses
$HOME or ($HOMEDRIVE+$HOMEPATH), but this doesn't work with windows
machines which are part of a domain. On such machines, the HOME envvar
may not be set at all, and the HOMEPATH envvar may be set to '\\'!!
Here's
[EMAIL PROTECTED] wrote:
> so if i change the line
> if i in range (0, 1):
> to
> if i >= 0 and i < 1:
[snip;]
> is there an alternative use of range() or something similar that can
> be as fast?
you've found that alternative yourself! just use the comparison operators...
in fact
Fuzzyman wrote:
> That was a quick response. :-)
>
> Thanks very much.
Sigh.. When I'm drowning in arcane win32 c++ crap, I tend to jump on
anything interesting on python-list. It feels like a breath of fresh air!
[sreeram;]
signature.asc
Description: OpenPGP digital signature
--
http://mail
Fuzzyman wrote:
> This code behaves differently when entered into an interactive
> interpreter session. When run as a program you will see that module and
> namespace have both become None !!
Thats because the reference count to the current '__main__' module goes
to 0, and the module object gets d
Boomshiki wrote:
> And trust me, I am not worried about 16 yr olds using it without paying, why
> would they want to? I am worried about them cracking in to where their
> grades are kept.
what you need is data security... *not* code obfuscation..
[sreeram;]
signature.asc
Description: OpenPG
Paul Rubin wrote:
> "K.S.Sreeram" <[EMAIL PROTECTED]> writes:
>> Java is not the only restricted execution environment around.
>> Javascript, as implemented by most browsers, is an excellent lightweight
>> restricted execution environment, and there
Steven D'Aprano wrote:
> Creating a restricted execution environment is *hard*. As far as I know,
> even Microsoft has never attempted it. And for all of Sun's resources and
> talent, security holes are sometimes found even in Java.
Java is not the only restricted execution environment around.
Jav
rzimerman wrote:
> I'm hoping to write a program that will read any number of urls from
> stdin (1 per line), download them, and process them. So far my script
> (below) works well for small numbers of urls. However, it does not
> scale to more than 200 urls or so, because it issues HTTP requests f
Alex Martelli wrote:
> Well then, feel free to code under such assumptions (as long as you're
> not working on any project in which I have any say:-)
Hey, I would *never* write code which depends on such intricate
implementation details! Nonetheless, its good to *know* whats going on
inside. As th
Alex Martelli wrote:
> Wrong, alas: each assignment *could* cause the dictionary's internal
> structures to be reorganized (rehashed) and impact another assignment
> (or even 'get'-access).
(been thinking about this further...)
Dictionary get/set operations *must* be atomic, because Python makes
Marc 'BlackJack' Rintsch wrote:
>>> Wrong, alas: each assignment *could* cause the dictionary's internal
>>> structures to be reorganized (rehashed) and impact another assignment
>>> (or even 'get'-access).
>> but wont the GIL be locked when the rehash occurs?
>
> If there is a GIL then maybe yes.
Alex Martelli wrote:
> Wrong, alas: each assignment *could* cause the dictionary's internal
> structures to be reorganized (rehashed) and impact another assignment
> (or even 'get'-access).
but wont the GIL be locked when the rehash occurs?
Regards
Sreeram
signature.asc
Description: OpenPGP di
Hi All
CSpace aims to be the next generation in realtime communication. It is
an opensource python application, which provides a platform for secure,
decentralized, user-to-user communication.
The platform provides a connect(user,service) primitive, similar to the
sockets API connect(ip,port). Ap
Marc 'BlackJack' Rintsch wrote:
> K.S.Sreeram wrote:
>> The very fact that you can put a loop inside __metaclass__ may be reason
>> enough for a one-off metaclass.
>
> Ah, it's not the loop but the access to the `dict`! You can write loops
> at class level
Marc 'BlackJack' Rintsch wrote:
> But why use a metaclass? If the meta class is only applied to *one*
> class, can't you do at class level whatever the metaclass is doing!?
The very fact that you can put a loop inside __metaclass__ may be reason
enough for a one-off metaclass.
Here's a contrived
Grant Edwards wrote:
> When one open()s a file (that doesn't exist) for writing , how
> does one control that file's permissions (it's "mode" in Unix
> terms).
Check out 'os.open'
It returns a file descriptor, and if you need a file object you can use
'os.fdopen' on the file descriptor
Regards
Sr
Luis M. González wrote:
> Alok wrote:
>> While posting a comment on http://www.reddit.com I got an error page
>> with the following curious statement on it.
>>
>> "reddit broke (sorry)"
>> "looks like we shouldn't have stopped using lisp..."
>
> I don't know if this is true or not, but blaming a l
Dio wrote:
> while 1:
> (rr, wr, er) = select([stdin], [], [])
> for fd in rr:
> print fd
>
> program block in the first select(), after I type something and "enter
> ", it never block in select() again,why?
select blocks until there is some data to read from stdin, but it does
no
Alex Pavluck wrote:
> String: Source for exec/eval is unavailable
I'm not able to find this message anywhere in the Python-2.4.3 sources.
What python version are you using? What input did you enter when the
prompt appeared? and copy&paste the *exact* exception you got including
the full traceback.
Maric Michaud wrote:
> Actually it's even more efficient than Lundh's
effbot's solution finds overlapping occurrences, whereas your solution
finds non-overlapping occurrences. So efficiency comparisons are not valid.
e.g:
indices( 'a', 'aa' )
your solution gives: 0,2
effbots's solution: 0,1
bruno at modulix wrote:
> if type(arg) is type([]):
Just a tiny nitpick
You can just use 'list' instead of 'type([])'
if type(arg) is list :
# blah blah
Regards
Sreeram
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
> because lots of people know how to describe XML transformations, and
> there are plenty of tools that implement such transformations efficiently ?
>
> why would XML be inefficient ?
XML Transformations (XSLT) would *certainly* be an overkill here.
They've invented a whole
Rob Cowie wrote:
> class Foo(object):
> def __init__(self):
> #call all methods here
> def test(self):
> print 'The test method'
> def hello(self):
> print 'Hello user'
class Foo(object):
def __init__(self):
for k in dir(self) :
if not k.
Marc 'BlackJack' Rintsch wrote:
>> 2) Once I assign mymodule.test with override, will modules that
>> imported my module *PRIOR* to the assignment get override, or will they
>> keep the original function test()?
>
> They see the `override()` function.
That depends on how the import was done.
If
[EMAIL PROTECTED] wrote:
> int
> set_all(PyObject *target, PyObject *item)
> {
> int i, n;
>
> n = PyObject_Length(target);
> if (n < 0)
> return -1;
> for (i = 0; i < n; i++) {
> if (PyObject_SetItem(target, i, item) < 0)
> return -1;
> }
> retu
[EMAIL PROTECTED] wrote:
> ValueError: Input strings must be a multiple of 16 in length
As James Stroud noted, a CBC mode cipher is still a block cipher, and
the input *must* be a multiple of the block size.
OpenSSL provides a standard padding mechanism so that there are no input
size limitations
Is it just me.. or are all the gmane links on daily-python dead?
All the c.l.py.announce entries point to gmane, and none of them seem to
be working. This is the error i get on gmane:
Warning: fsockopen(): unable to connect to hugh:8010 in
/home/httpd/gmane/php/lib.php on line 18
Couldn't contact
Butternut Squash wrote:
> Where is the best place to learn how to use this library???
There dont seem to any tutorials on the web for PyQt4 yet. So you'll
have to make do with reading pyqt3 tutorials, and reading the bundled
example code.
If you are comfortable with C++, then check out the Qt tut
Raymond L. Buvel wrote:
> I just tried this and it is taking an extremely long time even on a fast
> machine with 4 Gb of RAM. Killed it after a couple of minutes.
You probably tried printing the value.
a = 34564323**456356 (takes just 28 seconds)
whereas
b = str(a) takes forever!
Regards
Sreer
Raymond L. Buvel wrote:
> I just tried this and it is taking an extremely long time even on a fast
> machine with 4 Gb of RAM. Killed it after a couple of minutes.
Thats odd.
34564323**456356 completed on my laptop in 28 seconds.
[Python 2.4.3, Celeron-M 1.3GHz, WinXP], and max memory consumption
NCrypt 0.6.4 (http://tachyon.in/ncrypt/)
NCrypt is a wrapper for OpenSSL built using Pyrex. Although this is the
first public release, NCrypt has been under development for the last one
year, and is being used in production software.
The following OpenSSL features have been wrapped:
- hash algori
[EMAIL PROTECTED] wrote:
> print template % (ID, IID, Function[:10], Description[:10],
> ErrorNumber, StatusCD)
> TypeError: unsubscriptable object
It means either 'Function' or 'Description' is not a sequence.
Try inserting print statements to see what values they are.
e.g:
a = 2
a[:10]
wi
yaru22 wrote:
> In the exercise in my book, it asks me to try print "%u" % (-5)
> I'm wondering what this %u mean?
Looks like there is *no* difference between '%u' and '%d' in Python.
Python 2.4.3 source code:
from stringobject.c, formatint function
if (x < 0 && type == 'u') {
See:
http://docs.python.org/lib/typesseq-strings.html
u -> Unsigned decimal
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
dan wrote:
> I hope you won't be deterred from posting further questions to the
> group by Fredrik's somewhat terse and unfriendly reply.
>
> comp.lang.python is a forum generally noted for its pleasing admixture
> of erudition and encouragement. Fredrik is uncommonly distinguished in
> the scope
Fredrik Lundh wrote:
> by using it to split your document into reasonably-sized chunks (one
> record, one expression, one text block, one paragraph, etc), and using
> Python code to process the chunks.
I've updated cElementTree/iterparse implementation to build one full
expression at a time.
htt
Fredrik Lundh wrote:
> your celementtree example isn't exactly optimal, though... are you sure
> you understand how iterparse works?
From what i understand, the iterparse interface constructs the xml tree,
but gives you hooks into the tree construction process itself, so that
the programmer can
All the recent discussions on xml parsing performance got me curious,
and i put together a small speed test for xml processing.
The test program was designed to have as minimal state requirements as
possible so that efficient 'stream' processing can be done using sax
style events.
Here's the quic
Fredrik Lundh wrote:
> both ElementTree and cElementTree support "sax-style" event generation
> (through XMLTreeBuilder/XMLParser) and incremental parsing (through
> iterparse). the cElementTree versions of these are even faster than
> pyexpat.
>
> the iterparse interface is described here:
>
Diez B. Roggisch wrote:
> What the OP needs is a different approach to XML-documents that won't
> parse the whole file into one giant tree - but I'm pretty sure that
> (c)ElementTree will do the job as well as expat. And I don't recall the
> OP musing about performances woes, btw.
There's just NO
[EMAIL PROTECTED] wrote:
> I wrote a program that takes an XML file into memory using Minidom. I
> found out that the XML document is 10gb.
With a 10gb file, you're best bet might be to juse use Expat and C!!
Regards
Sreeram
signature.asc
Description: OpenPGP digital signature
--
http://mail
Lad wrote:
> I really would like to have ALL pictures in one file.
import Image
def merge_images( input_files, output_file ) :
img_list = [Image.open(f) for f in input_files]
out_width = max( [img.size[0] for img in img_list] )
out_height = sum( [img.size[1] for img in img_list] )
alf wrote:
> Would it be .append()? Does it reallocate te list with each apend?
No append does NOT reallocate for every call. Whenever a reallocation
happens, the newsize is proportional to the older size. So you should
essentially get amortized constant time for every append call.
If you want to
Girish Sahani wrote:
> 1) A dictionary with the numbers as keys and the letters as values.
> e.g the above would give me a dictionary like
> {1:'a', 2:'b', 3:'a', 5:'c', 6:'c' }
def get_dict( f ) :
out = {}
for line in file(f) :
n1,s1,n2,s2 = line.split(',')
out.upd
Girish Sahani wrote:
> I want to generate all substrings of size k-1 from a string of size k.
> e.g 'abcd' should give me ['abc','abd','bcd','acd']
def get_sub_set( s ) :
return [s[:i]+s[i+1:] for i in range(len(s))]
>>> print get_sub_set( 'abcd' )
['bcd', 'acd', 'abd', 'abc']
Regards
Sreeram
su wrote:
> from this command we know 'soffice.bin' process dumped core. Now can i
> do the same using python i.e. finding which process dumped core? if so
> how can i do it?
You're best bet would be to run the 'file' program using the subprocess
module and parse the output that it generates.
Re
Lad wrote:
> Hello ,
> is it possible to add( with PYTHON language) several image files into
> one?
Google for 'Python Imaging Library'...
Regards
Sreeram
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
K.S.Sreeram wrote:
> filepaths = [os.path.join(os.getcwd(),f) for f in filenames]
you can use os.path.abspath
filepaths = [os.path.abspath(f) for f in filenames]
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
su wrote:
> import os, os.path
> import re
> def core_finder(arg, dir, files):
> for file in files:
> path = os.path.join (dir, file)
> if re.search("core.*", path):
>print "found"
>print path
>
>
> os.path.walk('.', core_finder, 0)
Here's a simpler so
Yup! '_' is just used as a dummy. Its a pretty common idiom. There's
nothing special about that variable.
[EMAIL PROTECTED] wrote:
> Hello
>
>> ... _, first_n = group[0]
>
> what is the meaning of the underscore "_" ? is it a special var ? or
> should it be readed as a way of unpacking a
thanks!
so does that mean the BGRA raw mode is supported in PIL 1.1.6?
Regards
Sreeram
Fredrik Lundh wrote:
> K.S.Sreeram wrote:
>
>> I was hacking the code trying to support RGBA mode images, and
>> inadvertently i tried im.tostring("raw","BGRX") on t
My bad.
I was hacking the code trying to support RGBA mode images, and
inadvertently i tried im.tostring("raw","BGRX") on the RGBA mode image.
So BGRX does indeed work for RGB mode images.
While trying to support RGBA mode images, i realized that a BGRA raw
mode is needed for working with QImage.
Fredrik Lundh wrote:
> Fredrik Lundh wrote:
>
> I've posted a simple ImageQt interface module for PIL and PyQt4 here:
>
> http://svn.effbot.python-hosting.com/stuff/sandbox/pil/ImageQt.py
>
I'm getting an 'unknown raw mode' error on ImageQt.py:59:
data = im.tostring( "raw", "BGRX" )
Doe
Hi All,
I've started working on a new open source graphics library called
DaVinci. DaVinci aims to provide a declarative vector graphics based
framework for building GUIs.
http://tachyon.in/davinci/
It is being built on top of Anti-Grain Geometry and PyQt4.
Currently, dvpaint, a python wrapper
60 matches
Mail list logo