Re: .WAV processing library ?

2005-01-26 Thread Fredrik Lundh
Chris Stiles wrote: > Is there a library available for python that will enable me to process .wav > files ? > > Preferably extensible so I can write handlers for dealing with the non audio > sections. Kåre Sjölander's Snack library might be useful: http://www.speech.kth.se/snack/ -- h

Re: string.atoi and string.atol broken?

2005-01-26 Thread Fredrik Lundh
Christos TZOTZIOY Georgiou wrote: > You're messing with the time machine again, right? no, it was a subversion pilot error, this time. but now that you remind me, I have to say that this http://mail.python.org/pipermail/python-list/2005-February/030720.html is a bit scary. I wonder from w

Re: Subclassed dict as globals

2005-01-26 Thread Fredrik Lundh
Evan Simpson wrote: > In Python 2.4 the following works: > > >>> class G(dict): > ... def __getitem__(self, k): > ... return 'K' + k > ... > >>> g = G() > >>> exec 'print x, y, z' in g > Kx Ky Kz > >>> > > ...while in Python 2.3 it fails with NameError: name 'x' is not defined. Is > this an

Re: On benchmarks, heaps, priority queues

2005-01-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Hypothetical performance improvements are the root of all evil. > -- Bill Tutt (paraphrased) well, after this week, I'd say that Hypothetical performance limitations are the root of all evil. -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
"flamesrock" <[EMAIL PROTECTED]> wrote: > The statement (1 > None) is false (or any other value above 0). Why is > this? http://docs.python.org/ref/comparisons.html "The operators <, >, ==, >=, <=, and != compare the values of two objects. The objects need not have the same type. If both

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
Steven Bethard wrote: > So None being smaller than anything (except itself) is hard-coded into > Python's compare routine. > My suspicion is that even if/when objects of different types are no longer > comparable by default > (as has been suggested for Python 3.0), None will still compare as s

Re: Question about 'None'

2005-01-27 Thread Fredrik Lundh
Francis Girard wrote: > Wow ! What is it that are compared ? I think it's the references (i.e. the > adresses) that are compared. The "None" reference may map to the physical 0x0 > adress whereas 100 is internally interpreted as an object for which the > reference (i.e. address) exists and therefo

Re: unicode and data strings

2005-01-28 Thread Fredrik Lundh
Laszlo Zsolt Nagy wrote: > Now I installed Python 2.3.4 and wxPython 2.5.3 (with unicode support). I'm > getting this > exception: > > exceptions.UnicodeDecodeError:'ascii' codec can't decode byte 0x91 in > position 0: ordinal not in > range(128) >From where? Can you include a "print repr()"

Re: A proposal idea for string.split with negative maxsplit

2005-01-28 Thread Fredrik Lundh
Antoon Pardon wrote: > This behaviour would remain but additionally we would have the > following. > "st1:st2:st3:st4:st5".split(':',-2) > ["st1:st2:st3" , "st4" , "st5"] > > What do people think here? >>> "st1:st2:st3:st4:st5".rsplit(':', 2) ['st1:st2:st3', 'st4', 'st5'] -- http://ma

Re: Who should security issues be reported to?

2005-01-28 Thread Fredrik Lundh
Nick Coghlan wrote: >> I'm sorry, but this isn't really good enough. If Open Source wants to >> say that they are better than these proprietary companies, they need >> to deal with these sorts of things more professionally and establish >> decent channels of communications for dealing with it. > >

Re: Who should security issues be reported to?

2005-01-28 Thread Fredrik Lundh
Duncan Booth wrote: > I think part of the problem you are having is that Python doesn't make any > representations about security, so it is pretty hard to come up with issues > which really are security related. Products which are based on Python (e.g. > Zope) and which do aim to provide some kind

Re: Who should security issues be reported to?

2005-01-28 Thread Fredrik Lundh
Duncan Booth wrote: > I think its a bit borderline whether this really was a security bug in > Python rather than just a problem with the way some people used Python. It > was a standard library which if used in the wrong way opens a security hole > on your machine for SmartCookie, that should be

Re: python: can't open file 'timeit.py'

2005-01-28 Thread Fredrik Lundh
Aggelos I. Orfanakos wrote: > Under Gentoo Linux, I issue: > > $ python timeit.py > python: can't open file 'timeit.py' > $ ls -al /usr/lib/python2.3/timeit.py > -rw-r--r-- 1 root root 9833 Oct 19 02:17 /usr/lib/python2.3/timeit.py > > But if I specify the full path, it works: > > $ python /usr/l

Re: Pystone benchmark: Win vs. Linux (again)

2005-01-28 Thread Fredrik Lundh
Franco Fiorese wrote: > I am relatively new about Python benchmarks. > After some experiments I found that Python on my PC Windows XP has a relevant > higher performance > than on Linux. The simple test using pystone.py shows this: > > * Windows XP Pro: 16566.7 pystones/second > * Linux (kern

Re: is this sort method the same as the one in python 2.4

2005-01-29 Thread Fredrik Lundh
Raymond Hettinger wrote: >> I'm trying to emulate the sorted() method introduced in python 2.4. The >> only difference is that it takes a sequence as one of its arguments >> rather than being a method of the sequence class. Does my method do the >> same as the sorted()? > > Almost. This is closer

Re: Coding style article with interesting section on white space

2005-01-30 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > The recent "Pystone Benchmark" message says that Python is only 75% as > fast on Linux as on Windows. no, it really only says that the Pystone benchmark is 75% as fast as Linux as on Windows, on the poster's hardware, using his configuration, and using different compile

Re: Disassembling strings and turning them into function parameters

2005-01-30 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > I'm pretty new to Python, to programming overall...so how would I make > something where the user inputs multiple words in a string - like > "connect 123.123.123.123 21 user password" or similar, and then I can > split this string up to pass these arguments to a functi

Re: a Python bug in processing __del__ method ??

2005-01-30 Thread Fredrik Lundh
Baoqiu Cui wrote: > The error returned is this: > > $ python bug.py > Exception exceptions.AttributeError: "'NoneType' object has no > attribute 'population'" in <__main__.Person instance at 0xa0c9fec>> ignored > > However, if I rename variable name 'peter' to something like 'peter1' > or 'david'

Re: Regarding exception handling

2005-01-30 Thread Fredrik Lundh
"Bryan" wrote > the above is not the same. make the a = ... raise an exception and you'll see > the difference. > > s = ... # > a = 1/0 > s.close() > > as you can see, s.close() will never be called. also, in this example, i > intentionally didn't put > the extra try/except around the try/fina

Re: import doesn't work as i want

2005-01-31 Thread Fredrik Lundh
Olivier Noblanc wrote: > In the botom of this post you will see my source code. > > The problem is when i launch main.py that doesn't make anything why ? the "if __name__" statement checks the name of the module. if you run Python file as a script, by passing a filename to the python interpreter

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: > Also, the assertion that "Python has no declarations whatsoever" is no > longer obviously true. In the 2.4 decorator syntax, a decorator line is > not executable that's a nice theory, but since the decorator line is executed by the inter- preter, it's a little weak. -

Re: import doesn't work as i want

2005-01-31 Thread Fredrik Lundh
Olivier Noblanc wrote: > how to move in function ? how to put code in a function? the same way you put code in a method. change if __name__ == "__main__": app = wx.PySimpleApp(0) wx.InitAllImageHandlers() frame_1 = MyFrame(None, -1, "") app.SetTopWindow(frame_1) frame_1.Sho

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: >> that's a nice theory, but since the decorator line is executed by the >> interpreter, it's a little weak. > > Well, uh, who else would process it? the compiler. from __future__ is a declaration. @expression is an executable statement. -- http://mail.python.org/mai

Re: Relocatable binary installs....

2005-01-31 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Is there a way to make a relocateable python binary... that is... a > python installation that won't care where it is on the machine... and > won't care if it gets put somewhere else besides / ? the standard CPython interpreter is 100% "relocatable". If you think it i

Re: Relocatable binary installs....

2005-01-31 Thread Fredrik Lundh
Steve Holden wrote: >>>Is there a way to make a relocateable python binary... that is... a >>>python installation that won't care where it is on the machine... and >>>won't care if it gets put somewhere else besides / ? >> >> >> the standard CPython interpreter is 100% "relocatable". If you thin

Re: [ANN] Spike Asset Manager release 0.13

2005-01-31 Thread Fredrik Lundh
Skip Montanaro wrote: >Matt> Spike Asset Manager (SAM) is an open-source cross-platform >Matt> framework written in python for probing a system for components >Matt> and reporting them. > > That's a pretty generic description. Pardon my ignorance, but what's the > advantage over, for

Re: variable declaration

2005-01-31 Thread Fredrik Lundh
Michael Tobis wrote: > This is definitely a wart: > > ... z = 42.3 > ... > ... def f(): > ...if False: > ... global z > ...z = -666 > ... > ... f() > ... print z no, it's a declaration. from the documentation: http://docs.python.org/ref/global.html "The global statement i

Re: tkinter: Can You Underline More Than 1 Char In A Menu Title

2005-01-31 Thread Fredrik Lundh
Tim Daneliuk wrote: >>>However, I intend to actually have two separate keys invoke this menu >>>to have it behave differently in different circumstances. >> >> You can, of course, CHANGE the underlined character to match the >> circumstances. > > Yeah, I understand that ... what I want is two char

Re: Awkwardness of C API for making tuples

2005-02-02 Thread Fredrik Lundh
Dave Opstad wrote: > This would certainly be simpler, although I'm not sure I'm as clear as > to what happens if, say, in the middle of this loop a PyInt_FromLong > fails. I know that PyTuple_SetItem steals the reference; does that mean > I could just Py_DECREF the tuple and all the pieces will be

Re: Reference count question

2005-02-02 Thread Fredrik Lundh
"cedric paille" wrote: > I'm making python's modules to extend my application's functions with a built > in script editor. > At now all works very well, but i'd like to know if i'm not forgetting some > references inc/dec > > Here is a portion of my code: > > static PyObject * > Scene_GetNod

Re: Crude statistics on the standard library

2005-02-02 Thread Fredrik Lundh
F. Petitjean wrote: > sre_compile and sre_parse should be coded with a __all__ attribute they're implementation modules, and shouldn't be used by user code. -- http://mail.python.org/mailman/listinfo/python-list

Re: Reference count question

2005-02-02 Thread Fredrik Lundh
John Machin wrote: >> you should check the return value, though. PyList_SetItem may (in >> theory) fail. > > :-) > Only a bot could say that. We mere mortals have been known to do things > like (a) pass a non-list as the first argument (b) pass an out-of-range > value for the second argument. ev

Re: Awkwardness of C API for making tuples

2005-02-02 Thread Fredrik Lundh
Dave Cole wrote: > for (i = 0; i < num_values; i++) { > PyObject *obj; > > obj = PyInt_FromLong(value[i]); > if (obj == NULL > || PyTuple_SetItem(tuple, i, obj) != 0) { > Py_DECREF(tuple); > return NULL; > } > } in theory, if PyInt_FromLong succeeds, and PyTuple_SetIte

Re: test msg

2005-02-03 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > tes tmsg if you meant to send this to a test group, it didn't work. complain to your provider. -- http://mail.python.org/mailman/listinfo/python-list

Re: character sets? unicode?

2005-02-03 Thread Fredrik Lundh
Michael wrote: > I'm trying to import text from email I've received, run some regular > expressions on it, and save > the text into a database. I'm trying to figure out how to handle the issue of > character sets. I've > had some problems with my regular expressions on email that has interesti

Re: Easy Q: dealing with object type

2005-02-03 Thread Fredrik Lundh
Erik Johnson wrote: >As an aside, I notice a lot of other people's interpreters actually > print 'True' or 'False' where my system prints 0 or 1. Is that a > configuration that can easily set somewhere? $ python2.1 -c "print 1 == 1" 1 $ python2.2 -c "print 1 == 1" 1 $ python2.3 -c "print 1

Re: About standard library improvement

2005-02-03 Thread Fredrik Lundh
Frank Abel Cancio Bello wrote: > If I make some improvement to xmlrpclib module, where I should send this > improvement to form part of next standard library release? http://sourceforge.net/tracker/?group_id=5470&atid=305470 -- http://mail.python.org/mailman/listinfo/python-list

Re: Possible additions to the standard library? (WAS: About standard library improvement)

2005-02-03 Thread Fredrik Lundh
Daniel Bickett wrote: > [2] I'm currently unaware if _winreg is a c extension module or pure > python, but I'm assuming it's C, so I don't know how possible it is to > add pure python to it... from the documentation: This module exposes a very low-level interface to the Windows registry;

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-03 Thread Fredrik Lundh
Markus Wankus wrote: > Google his name - he has been banned from Netbeans and Eclipse (and > Hibernate, and others...) for > good reason. Can you imagine how much of a Troll you need to be to > *actually* get "banned" from > the newsgroups of open source projects such as those? have Pythonee

Re: Awkwardness of C API for making tuples

2005-02-03 Thread Fredrik Lundh
Steve Holden wrote: >> in theory, if PyInt_FromLong succeeds, and PyTuple_SetItem fails, you'll leak >> an object. > > And in practice this will only happen during a period when you are relying > critically on it *not* > to ... yeah, but if PyTuple_SetItem fails in this case, you better move th

Re: OT: why are LAMP sites slow?

2005-02-04 Thread Fredrik Lundh
Tim Daneliuk wrote: > THis is why, IMHO, things like SOAP a laughable - RPC is a poor > foundation for reliable, durable, and high-performance TP. It might be > fine for sending an order or invoice now and then, but sustained through- > put of the sort I think of as "high" performance is likely n

Re: regular expression match collection

2005-02-04 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > For example I have a string : "Halo by by by" > Then I want to take and know the possition of every "by" > how can I do it in python? > > I tried to use: > > p = re.compile(r"by") > m = p.search("Helo by by by") > print m.group() # result "by" > print m.span() # r

Re: string issue

2005-02-04 Thread Fredrik Lundh
"rbt" <[EMAIL PROTECTED]> wrote: >> You are modifying the list as you iterate over it. Instead, iterate over a >> copy by using: >> >> for ip in ips[:]: >> ... >> >> regards >> Steve > > Very neat. That's a trick that everyone should know about. I suppose that's why it's included in the Pytho

Re: returning True, False or None

2005-02-04 Thread Fredrik Lundh
Steven Bethard wrote: >> return max(lst) > > Very clever! Thanks! too clever. boolean > None isn't guaranteed by the language specification: http://docs.python.org/ref/comparisons.html "... objects of different types always compare unequal, and are ordered consistently but arbitr

Re: a type without a __mro__?

2005-02-05 Thread Fredrik Lundh
Alex Martelli wrote: > Can anybody suggest where to find (within the standard library) or how > to easily make (e.g. in a C extension) a type without a __mro__, except > for those (such as types.InstanceType) which are explicitly recorded in > the dispatch table copy._deepcopy_dispatch...? someth

Re: [EVALUATION] - E01: The Java Failure - May Python Helps?

2005-02-05 Thread Fredrik Lundh
Jan Dries wrote: >> have Pythoneers ever "banned" anyone from a public forum? it's not like >> we haven't seen trolls and crackpots before, you know. > > Well, we don't have to ban them because we have the PSU eliminate them > alltogether. So much more > efficient. Or do you think it's a coinci

Re: utf8 and ftplib

2005-06-20 Thread Fredrik Lundh
Richard Lewis wrote: > OK, I'm still not getting this unicode business. obviously. > > aàáâã > eèéêë > iìíîï > oòóôõ > oùúûü > > > (If testing, make sure you save this as utf-8 encoded.) why? that XML snippet doesn't include any UTF-8-encoded characters. ::: >file =

Re: global name not defined :$

2005-06-20 Thread Fredrik Lundh
"Anna M." <[EMAIL PROTECTED]> wrote: > I am trying to write a red-black tree implementation in python. I am very > new to python and appologize if my question is terribly stubid. But I ran > into some trouble. I have a class and in it there are functions but when I > try to run the code I have

Re: utf8 and ftplib

2005-06-20 Thread Fredrik Lundh
Richard Lewis wrote: > On Mon, 20 Jun 2005 14:27:17 +0200, "Fredrik Lundh" > <[EMAIL PROTECTED]> said: > > > > well, you're messing it up all by yourself. getting rid of all the > > codecs and > > unicode2charrefs nonsense will fix this:

Re: regarding cache clearing header in python cgi

2005-06-21 Thread Fredrik Lundh
"praba kar" wrote: > In Php the following headers base we can clean > the cache in the url "header('Cache-Control: > no-store, no-cache, must-revalidate'); " > I want to know Php equivalent headers in Python-cgi > If anybody know regarding this kindly mail me. did you try print 'Cache

Re: Loop until condition is true

2005-06-21 Thread Fredrik Lundh
Remi Villatel wrote: > There is always a "nice" way to do things in Python but this time I can't > find one. > > What I'm trying to achieve is a conditionnal loop of which the condition > test would be done at the end so the loop is executed at least once. It's > some way the opposite of "while".

Re: Loop until condition is true

2005-06-22 Thread Fredrik Lundh
Remi Villatel wrote: > >>while True: > >> some(code) > >> if final_condition is True: > >> break > >> # > >># > > > checking if a logical expression is true by comparing it to True is bad > > style, and comparing values using "is" is also bad style. > > Erm... You totally missed the point. I wrote

Re: Using code objects?

2005-06-22 Thread Fredrik Lundh
Chinook wrote: > When I create the code objects though, it seems a couple different ways > work and I'm wondering which is better and why (or is there a more correct > technique in this situation)? from where are you getting the source code for those code objects? from the example below, it sure

Re: utf8 and ftplib

2005-06-22 Thread Fredrik Lundh
Fredrik Lundh wrote: > character references refer to code points in the Unicode code > space, so you just convert the bytes you get after converting > to UTF-8. "so you cannot just", of course. -- http://mail.python.org/mailman/listinfo/python-list

Re: Does a function like isset() exist in Python?

2005-06-23 Thread Fredrik Lundh
George Sakkis wrote: > There are no unitialized variables in python; if you try to access an > undefined name, a NameError exception is raised: > > try: > print "foo is", foo > except NameError: > print "foo is undefined" note the order of evaluation: >>> try: ... print "foo

Re: noob question

2005-06-27 Thread Fredrik Lundh
Alan Gauld wrote: > In Python Hungarian notation is meaningless since variables > aren't typed anyway. in real-life Python code, variables tend to be 'typed' in the hungarian sense: http://msdn.microsoft.com/library/en-us/dnvs600/html/hunganotat.asp "/.../ the concept of 'type' in this cont

Re: How to compress a folder and all of its sub directories and filesinto a zip file?

2005-06-28 Thread Fredrik Lundh
Brian van den Broek wrote: > So, it would appear that compression requires a 3rd party module, not > included in Python (and not present on my Windows box). where did you get your Windows Python? afaik, the zlib module has been included in all major Python binary distributions since 1.5.2 or so.

Re: Non-blocking raw_input

2005-06-28 Thread Fredrik Lundh
Jorge Louis de Castro wrote: > I have indeed tried the msvcrt module but none of the examples given works > as described on a XP+SP2 box. what examples? how did you run the examples? (the keyboard interface functions in msvcrt only work if the program's attached to a Windows console. if you r

Re: XMLRPC and non-ascii characters

2005-06-29 Thread Fredrik Lundh
Joxean Koret wrote: > I'm having troubles to make my XMLRPC application working with non > ASCII characters. you cannot just pass in 8-bit strings in arbitrary encodings and expect the XML- RPC layer to automagically figure out what you're doing. you can either use the encoding option to the Ser

Re: Help with Regular Expressions

2005-08-10 Thread Fredrik Lundh
Harlin Seritt wrote: > I am trying to find some matches and have them put into a list when > processing is done. I'll use a simple example like email addresses. > > My input is the following: > wordList = ['myname1', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', > '[EMAIL PROTECTED]', '[EMAIL PROTECTE

Re: Why is this?

2005-08-10 Thread Fredrik Lundh
Paolino wrote: > This confuses me also, looks like empty lists share same object. nope. see Matt Hammonds reply for the full story. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unicode regular expressions -- buggy?

2005-08-11 Thread Fredrik Lundh
Christopher Subich wrote: > I don't think the python regular expression module correctly handles > combining marks; it gives inconsistent results between equivalent forms > of some regular expressions: > Is this a limitation-by-design, or a bug? limitation by design. if you want correct results

Re: what's the exactly newsgroup url of python-list?

2005-08-11 Thread Fredrik Lundh
Ben Finney wrote: > news:comp.lang.python> is a URL to a Usenet newsgroup, as > evidenced by the 'news:' schema part. If your web browser is > configured properly to invoke a newsreader (such as Thunderbird) for > 'news:' URLs, your newsrreader will then attempt to get the > comp.lang.newsgroup fr

Re: read function in python serial

2005-08-11 Thread Fredrik Lundh
"sinan ." <[EMAIL PROTECTED]> wrote: > hi i`m developing a program that reads the serial device. i like the > readline() function, but readline() depends on \n character, i want a > similar function that waits for a specific character or string that i > gave like [ETX] (hex03) how can i do this ?

Re: Gadfly use (Newby)

2005-08-16 Thread Fredrik Lundh
"niko" <[EMAIL PROTECTED]> wrote: > while using gadfly, got an error that i don't understand. > Code is as follow : > cursor = connection.cursor() > cursor.execute('select id_m from mots where nom_m = "%s"' % nom_m) > id_m = cursor.fetchall() > > Error message : > File "C:\Python24\Lib\site-pack

Re: looping list problem

2005-08-16 Thread Fredrik Lundh
Jon Bowlas wrote: > attobject = context.get_attobject() > navstring = context.get_uclattribute(attobject, 'ucl_navhide') > hiddennavelements = navstring.split(' ') > for hiddennavelement in hiddennavelements: >return hiddennavelement > > So the script 'get_attobject' basically looks for an ins

Re: base64.encode and decode not correct

2005-08-16 Thread Fredrik Lundh
Damir Hakimov wrote: > I found a strange bug in base64.encode and decode, when I try to encode > - decode a file 1728512 bytes lenth. does this work on your machine? >>> import base64 >>> x = base64.encodestring(1728512 * "*") >>> len(base64.decodestring(x)) 1728512 does it work also if you cha

Re: looping list problem

2005-08-16 Thread Fredrik Lundh
Jon Bowlas wrote: > Ok so I changed it to this: > > attobject = context.get_attobject() > navstring = context.get_uclattribute(attobject, 'ucl_navhide') > hiddennavelements = navstring.split(' ') > for hiddennavelement in hiddennavelements: >yield hiddennavelements > > But I get the following

Re: Iterparse and ElementTree confusion

2005-08-17 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > def parse_for_products(filename): > >for event, elem in iterparse(filename): >if elem.tag == "Products": >root = ElementTree(elem) >print_all(root) >else: >elem.clear() > > My problem is that if i pass the 'elem' fo

Re: GIS Related Scripting Issue

2005-08-18 Thread Fredrik Lundh
Mike Rose wrote: > I am currently using ArcGIS 9.1 and was referred to this list to ask my > question. I am using a python script to loop through a series of > features, select all polygons that are within 5 miles, run statistics on > those selected polygons, then append the values to a new datab

Re: Python for Webscripting (like PHP)

2005-08-22 Thread Fredrik Lundh
Alessandro Bottoni wrote: > (Python has even been told to be used by Yahoo! and Google, among others, > but nobody was able to demonstrate this, so far) hint: http://mail.google.com/support/bin/answer.py?answer=6554 -- http://mail.python.org/mailman/listinfo/python-list

Re: regular expressions use

2005-08-22 Thread Fredrik Lundh
"max(01)*" <[EMAIL PROTECTED]> wrote: > i would like to do some uri-decoding, which means to translate patterns > like "%2b/dhg-%3b %7E" into "+/dhg-; ~" >>> import urllib >>> urllib.unquote("%2b/dhg-%3b %7E") '+/dhg-; ~' -- http://mail.python.org/mailman/listinfo/python-list

Re: Sanitizing untrusted code for eval()

2005-08-22 Thread Fredrik Lundh
Jim Washington wrote: > 4. List comprehensions might be troublesome, though it's not clear to me > how a DoS or exploit is possible with these. see item 1. > Or is eval() simply too evil? yes. however, running a tokenizer over the source string and rejecting any string that contains unknown t

Re: How to get a unique id for bound methods?

2005-08-22 Thread Fredrik Lundh
Russell E. Owen wrote: >>>The current issue is associated with Tkinter. I'm trying to create a tk >>>callback function that calls a python "function" (any python callable >>>entity). >>> >>>To do that, I have to create a name for tk that is unique to my python >>>"function". A hash-like name would

Re: Can I send files through xmlrpc connections?

2005-08-22 Thread Fredrik Lundh
"dcrespo" wrote: > ...If the answer is Yes, can you give me an example either in the > server side and the client side? > > I googled a lot, but I can't find nothing regarding this. the XML-RPC specification http://www.xmlrpc.com/spec mentions the following data types four-byte signed i

Re: Best way to 'touch' a file?

2005-08-22 Thread Fredrik Lundh
Peter Hansen wrote: > from path import path > path('myfile').touch() import os os.utime('myfile', None) is a bit shorter, of course. >>> help(os.utime) Help on built-in function utime: utime(...) utime(path, (atime, utime)) utime(path, None) Set the access and modified time of the

Re: combining namespaces when importing two modules

2005-08-22 Thread Fredrik Lundh
Donnal Walter wrote: >I would like to be able to write something like: > > import dcw as dw > import xyz as dw > > such that the 'dw' namespace includes definitions from both dcw and xyz, > but in the script above names from dcw1 are lost. How can I combine the > two? (I'd rather not use 'import *'

Re: Python and the web

2005-08-22 Thread Fredrik Lundh
"Joe T." wrote: > 2. I know there's a Jpython but what use would I get from using Python > with > Java? If I'm already familiar with Java programming why would I want to > use > Python with Java? see, e.g. http://www.onjava.com/pub/a/onjava/2002/03/27/jython.html http://www.javaworld

Re: Best way to 'touch' a file?

2005-08-22 Thread Fredrik Lundh
Peter Hansen wrote: > And, depending on your needs, quite ineffective: > > >>> import os > >>> os.utime('missing.file', None) > Traceback (most recent call last): > File "", line 1, in ? > OSError: [Errno 2] No such file or directory: 'missing.file' > > >>> from path import path > >>> path('miss

Re: Can I send files through xmlrpc connections?

2005-08-22 Thread Fredrik Lundh
"dcrespo" wrote: > I'm sorry, I didn't the right question... Of course that I can break > the file and rewrite it on an xmlrpc protocol for transmition, or send > a byte each time through the socket lib. I meant is there a program > already developed that sends and receives files based on xmlrpc c

Re: Best way to 'touch' a file?

2005-08-22 Thread Fredrik Lundh
Peter Hansen wrote: > You've quoted selectively. He also said "Unix-style 'touch'", from > which one could quite legitimately infer nope. read his post again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Library and real path name

2005-08-23 Thread Fredrik Lundh
Michele Petrazzo wrote: > I want to redistribute the library that I create. > I create a project, its setup.py that when launched copy all files into > the "site-packages/library" directory. And here it's all ok. > When I call my library with: > > import library > library.class() > > I want that my

Re: Import Error ('mutual inclusion of modules'?)

2005-08-23 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: >I have the following code: > > A.py > > > from B import B > B.py > > > from A import R > I think python does not support this kind of 'mutual inclusion'. Am I > right? Thanks. Cesar. this page http://effbot.org/zone/import-confusion.htm might help you

Re: loop in python

2005-08-23 Thread Fredrik Lundh
Steve Holden wrote: > If you want a fast language, try Holden. I've just invented it. > Unfortunately it gets the answer to every problem wrong unless the > answer is 42, but boy it runs quickly. The code for the whole > interpreter (it's written in Python) follows: > > print 42 > > Why are you lo

Re: Convert float to string ...

2005-08-23 Thread Fredrik Lundh
Konrad Mühler wrote: > a simple question but i found no solution: > > How can i convert a float value into a string value? > > > string_value1 = string(float_value) + ' abc' str(float_value) + 'abc' repr(float_value) + "abc" '%fabc' % float_value '%gabc' % float_value (etc) the tutorial has

Re: DeprecationWarning: Non-ASCII character '\xf3'

2005-08-23 Thread Fredrik Lundh
"jau" <[EMAIL PROTECTED]> wrote: > print "hello world" > > i get this output > > hello world > sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file > C:\Workspace\J&J\src\es\jau\main.py on line 2, but no encoding declared; > see http://www.python.org/peps/pep-0263.html for details > > the

Re: Sequential XML parsing with xml.sax

2005-08-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > The API reference isn't clear on whether parseString can only handle > discrete bits of valid XML the documentation says that "parse" expects an XML document, and that "parseString" is the same thing, but parses from a buffer. it's probably easier to pass a BZ2File ins

Re: Sorta noob question - file vs. open?

2005-08-23 Thread Fredrik Lundh
Peter A.Schott wrote: > Been reading the docs saying that file should replace open in our code, > but this > doesn't seem to work: what docs? "open" is the preferred way to open a file. "file" is a type constructor. in contemporary python, they happen to map to the same callable, but that's no

Re: How to get a unique id for bound methods?

2005-08-23 Thread Fredrik Lundh
Russell E. Owen wrote: > Having looked at it again, it is familiar. I copied it when I wrote my > own code. I avoided using at the time both because the initial > underscore suggested it was a private method and because it introduces > an extra function call. > > _register has the same weakness th

Re: variable hell

2005-08-25 Thread Fredrik Lundh
"Nx" <[EMAIL PROTECTED]> wrote: > I am unpacking a list into variables, for some reason they need to be > unpacked into variable names like a0,a1,a2upto aN whatever is > in the list. why? -- http://mail.python.org/mailman/listinfo/python-list

Re: RE Despair - help required

2005-08-25 Thread Fredrik Lundh
"Yoav" wrote: >I am trying the following: > > re.search(r'\\[^"\\]+(?=("?$))', "c:\ret_files") > > and I get a return of NoneType, and I have no idea why. I know that I > missing something here, but I really can't figure out why instead of struggling with weird REs, why not use Python's standard f

Re: file access dialog

2005-08-26 Thread Fredrik Lundh
Wouter van Ooijen wrote: >I have a tool in Python to which I want to add a small GUI. The tools > currently runs everywhere PySerial is supported. I need a file-access > dialog. What is the preffered way to to this? Is there a > platform-independent file-access dialog available, or should I use th

Re: DOM text

2005-08-26 Thread Fredrik Lundh
Robert Kern wrote: > You might find that the more Pythonic XML modules are better suited to > handling mixed content. I've been using lxml and ElementTree quite > successfully. fwiw, here's an ET snippet that inserts an anchor element inside a paragraph element: # from lxml.etree import * # or #

Re: Integrate C source in a Python project

2005-08-26 Thread Fredrik Lundh
"billiejoex" wrote_ > Than you James. I'll take a look as soon as possible. > It is possible do the contrary (integrates python source in a C project)? http://docs.python.org/ext/embedding.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic image creation for the web...

2005-08-29 Thread Fredrik Lundh
"Tompa" <[EMAIL PROTECTED]> wrote: > Yes, I believe so too. Something like this, as suggested by Benjamin: > sys.stdout.write('Status: 200 OK\r\n') > sys.stdout.write('Content-type: image/gif\r\n') > sys.stdout.write('\r\n') > im.save(sys.stdout, "GIF") > > But it does not work for some reason!?

Re: python image thumbnail generator?

2005-08-29 Thread Fredrik Lundh
Paul Rubin wrote >> (1) Can this be done with python? If so, what module do I need to look >> up? > > You could do it with PIL, or run jpegtran in an external process. > jpegtran may be easier. eh? are you sure you know what jpegtran does? JPEGTRAN(1) JPEGTRAN(1) NAME jpegtran - lossl

Re: python image thumbnail generator?

2005-08-29 Thread Fredrik Lundh
Mike C. Fletcher wrote: > The core function looks something like this: > > import Image # this is PIL > > def getThumbnail( filename, size = (32,32) ): >'''Get a thumbnail image of filename''' >image = Image.open(filename) >rx, ry = image.size[0]/float(size[0]), image.size[1]/float(siz

Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Fredrik Lundh
"jog" wrote: > I want to get text out of some nodes of a huge xml file (1,5 GB). The > architecture of the xml file is something like this > I want to combine the text out of page:title and page:revision:text for > every single page element. One by one I want to index these combined > texts (so f

Re: python xml DOM? pulldom? SAX?

2005-08-29 Thread Fredrik Lundh
Alan Kennedy wrote: > SAX is perfect for the job. See code below. depends on your definition of perfect... using a 20 MB version of jog's sample, and having replaced the print statements with local variable assignments, I get the following timings: 5 lines of cElementTree code: 7.2 seconds 60+

Re: variable hell

2005-08-30 Thread Fredrik Lundh
Steve Holden wrote: > Yes. A large part of learning a language is discovering the many idioms > that have already been established for doing certain things. These are a > kind of shorthand, established by long convention, that allow one to > avoid the "learning-by-use" curve. it's not obvious tha

<    4   5   6   7   8   9   10   11   12   13   >