Re: [Image-SIG] Some issue with easy_install and PIL/Imaging

2009-10-05 Thread Fredrik Lundh
've gotten: no egg - worst seen ever, remove it from pypi or provide an egg (jensens, 2009-10-05, 0 points) On Wed, Sep 30, 2009 at 6:24 PM, Chris Withers wrote: > Fredrik Lundh wrote: >> >> On Fri, Sep 11, 2009 at 3:49 PM, Chris Withers >> wrote: >>> >&g

Re: [Image-SIG] Some issue with easy_install and PIL/Imaging

2009-09-28 Thread Fredrik Lundh
On Fri, Sep 11, 2009 at 3:49 PM, Chris Withers wrote: > Klein Stéphane wrote: >> >> Resume : >> 1. first question : why PIL package in "pypi" don't work ? > > Because Fred Lundh have his package distributions unfortunate names that > setuptools doesn't like... It used to support this, but no long

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-13 Thread Fredrik Lundh
greg wrote: If you're going to indulge in argument by authority, you need to pick authorities that can be considered, er, authoritative in the field concerned... Like Barbara Liskov, who's won tons of awards for her work on computer science and programming languages, and who was among the fir

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread Fredrik Lundh
greg wrote: It's not only misleading, it's also a seriously flawed reading of the original text - the Algol 60 report explicitly talks about assignment of *values*. Do you agree that an expression in Python has a value? > Do you agree that it makes sense to talk about assigning that value t

Re: Official definition of call-by-value (Re: Finding the instance reference...)

2008-11-12 Thread Fredrik Lundh
Aahz wrote: There you have it -- call by value is offially defined in terms of assignment. There is no mention in there of copying. So it's perfectly correct to use it in relation to Python. Except, of course, for the fact that it is generally misleading. It's not only misleading, it's also

Re: Regular expression help: unable to search ' # ' character in the file

2008-09-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: import re fd = open(file, 'r') line = fd.readline pat1 = re.compile("\#*") while(line): mat1 = pat1.search(line) if mat1: print line line = fd.readline() I strongly doubt that this is

Re: How to get the filename in the right case ?

2008-09-27 Thread Fredrik Lundh
Stef Mientki wrote: I don't think your suggestion is a good one. If a filename has uppercase characters in it, the END-USER has done that for some kind of reason. I explain how pdb works and show you how to solve the specific comparison problem you mentioned in your post, and you start rantin

Re: How to read a jpg bytearray from a Flash AS3 file

2008-09-27 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I'm trying to save an image from a Flash AS3 to my server as a jpg file. I found some PHP code to do this, but I want to do this in Python. I'm not quite sure how to convert the following code to Python. It's mainly the $GLOBALS["HTTP_RAW_POST_DATA"] part I don't know ho

Re: Using the 'with' statement with cStringIO objects

2008-09-27 Thread Fredrik Lundh
peppergrower wrote: teststring='this is a test' with cStringIO.StringIO(teststring) as testfile: pass umm. what exactly do you expect that code to do? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the filename in the right case ?

2008-09-25 Thread Fredrik Lundh
Stef Mientki wrote: > 1. I've a multitab editor. > 2. When a breakpoint is reached, > 3. I check if the file specified in pdb output, is already open in one > of the editor tabs, > 4. if not, I open a new tab with the correct file, > 5. I focus the correct editor tab and jump to the line specifie

Re: Eggs, VirtualEnv, and Apt - best practices?

2008-09-25 Thread Fredrik Lundh
Dmitry S. Makovey wrote: you have just described OS package building ;) I can't speak for everybody, but supporting multiple platforms (PHP, Perl, Python, Java) we found that the only way to stay consistent is to use OS native packaging tools (in your case apt and .deb ) and if you're missing s

Re: Tkinter 3000 WCK Install Problem

2008-09-22 Thread Fredrik Lundh
garyr wrote: I'm trying to install WCK. I downloaded and installed the Windows executable for my Python version. It appeared to run OK. I then downloaded the demo files but find that none run due to error: ImportError: No module named _tk3draw. I'm using ActivePython 2.3.5 on Windows XP Home. Wh

Re: Here's something interesting: sympy crashes in Python 2.6 (Windows)

2008-09-22 Thread Fredrik Lundh
Robert Kern wrote: No warnings show up when importing the offending module: Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from sympy.mpmath import specfun >>>

Re: Regex Help

2008-09-22 Thread Fredrik Lundh
Support Desk wrote: the code I am using is regex = r'' that's way too fragile to work with real-life HTML (what if the link has a TITLE attribute, for example? or contains whitespace after the HREF?) you might want to consider using a real HTML parser for this task. page_text = urllib.

Re: Why are "broken iterators" broken?

2008-09-22 Thread Fredrik Lundh
Cameron Simpson wrote: you probably want the consumer thread to block when it catches up with the producer, rather than exit. It sounds like he wants non-blocking behaviour in his consumer. Roy gave an example, he didn't post a requirements specification. A common example is "try to gathe

Re: Newick parser

2008-09-21 Thread Fredrik Lundh
aditya shukla wrote: Hello folks , i have a .nwk file.I want to parser the tree from that file.I found this python parser for newick trees. http://www.daimi.au.dk/~mailund/newick.html But i don't understand the usage properly.What i wanna do is if i have a file in the location c:\\files\\file

Re: Why are "broken iterators" broken?

2008-09-21 Thread Fredrik Lundh
Roy Smith wrote: There are plausible examples of collections which grow while you're iterating over them. I'm thinking specifically of a queue in a multi-threaded application. One thread pushes work onto the back of the queue while another pops from the front. The queue could certainly go

Re: Why are "broken iterators" broken?

2008-09-21 Thread Fredrik Lundh
Steven D'Aprano wrote: According to the Python docs, once an iterator raises StopIteration, it should continue to raise StopIteration forever. Iterators that fail to behave in this fashion are deemed to be "broken": http://docs.python.org/lib/typeiter.html I don't understand the reasoning be

Re: Override the '+' symbol

2008-09-21 Thread Fredrik Lundh
Mr.SpOOn wrote: how can I override the '+' symbol (and other math symbols) so that it can have a new behavior when applied to some objects? see "Emulating Numeric Types" in the language reference: http://www.python.org/doc/ref/numeric-types.html -- http://mail.python.org/mailman/listin

Re: How to kill threading.Thread instance?

2008-09-21 Thread Fredrik Lundh
Diez B. Roggisch wrote: I wonder why something like myThread.exit() or myThread.quit() or threading.kill(myThread) can't be implemented? Is something like that present in Python 3000? Not that I'm aware of it (which doesn't mean to much though). However I *am* aware of the bazillions discussi

Re: How to kill threading.Thread instance?

2008-09-21 Thread Fredrik Lundh
dmitrey wrote: BTW, it should be noticed that lots of threading module methods have no docstrings (in my Python 2.5), for example _Thread__bootstrap, _Thread__stop. things named _Class__name are explicitly marked private by the implementation (using the "__" prefix). using them just because

Re: Here's something interesting: sympy crashes in Python 2.6 (Windows)

2008-09-21 Thread Fredrik Lundh
Mensanator wrote: I'm not the one who wrote sympy, so I guess I'm not the only one who didn't notice it. If it's a well known problem, then sorry I wasted your time. Given that 2.5 explicitly warns about this specific change: >>> as = 1 :1: Warning: 'as' will become a reserved keyword in Pyt

Re: Not fully OO ?

2008-09-21 Thread Fredrik Lundh
Martin v. Löwis wrote: I don't think he meant that Python is wrong somehow, but that the OO babble of what happens for 2+2 is wrong. The babble said that, when the code is executed, an __add__ message is sent to the 2 object, with another 2 object as the parameter. That statement is incorrect:

Re: NEW GENERATED DLL ERROR FOUND WITHIN f2PY.py

2008-09-20 Thread Fredrik Lundh
Blubaugh, David A. wrote: (no need to shout when filling in the subject line, thanks) I have now been able to generate a .pyd file from a FORTRAN > file that I am trying to interface with python. I was able > to execute this with an additional insight into how f2py > operates. ImportError:

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Fredrik Lundh wrote: e.g. the python equivalent to the c++ loop for (i = 10; i >= 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in reversed(range(10)): ... (and to include the 10 in the range, add

Re: How to make a reverse for loop in python?

2008-09-20 Thread Fredrik Lundh
Alex Snast wrote: I'm new to python and i can't figure out how to write a reverse for loop in python e.g. the python equivalent to the c++ loop for (i = 10; i >= 0; --i) use range with a negative step: for i in range(10-1, -1, -1): ... or just reverse the range: for i in r

Re: Not fully OO ?

2008-09-20 Thread Fredrik Lundh
Colin J. Williams wrote: "foreach: for x in array: statements > Loops over the array given by array. On each iteration, the value of the current element is assigned to x and the internal array pointer is advanced by one. " This could be a useful addition to Python. for-in could be a usefu

Re: Not fully OO ?

2008-09-20 Thread Fredrik Lundh
Kay Schluehr wrote: Answer: if you want to define an entity it has to be defined inside a class. If you want to access an entity you have to use the dot operator. Therefore Java is OO but Python is not. you're satirising the quoted author's cargo-cultish view of object orientation, right?

Re: The Python computer language

2008-09-20 Thread Fredrik Lundh
ROSEEE wrote: http://pthoncomputerlanguage.blogspot.com report here: http://tinyurl.com/blogspot-spam -- http://mail.python.org/mailman/listinfo/python-list

Re: report a BUG of package setuptools-0.6c8.

2008-09-20 Thread Fredrik Lundh
为爱而生 wrote: File "/usr/lib/python2.5/site-packages/setuptools/command/sdist.py", line 98, in entries_finder log.warn("unrecognized .svn/entries format in %s", dirname) NameError: global name 'log' is not defined global name 'log' is not defined to the line 98!!! please report bugs here

Re: Extracting hte font name from a TrueType font file

2008-09-18 Thread Fredrik Lundh
Steve Holden wrote: Does anyone have a Python recipe for this? >>> from PIL import ImageFont >>> f = ImageFont.truetype("/windows/fonts/verdanai.ttf", 1) >>> f.font.family 'Verdana' >>> f.font.style 'Italic' -- http://mail.python.org/mailman/listinfo/python-list

Re: Twisted vs Python Sockets

2008-09-18 Thread Fredrik Lundh
James Matthews wrote: I am wondering what are the major points of twisted over regular python sockets. I am looking to write a TCP server and want to know the pros can cons of using one over the other. Twisted is a communication framework with lots of ready-made components: http://twisted

Re: PEP proposal optparse

2008-09-18 Thread Fredrik Lundh
James Mills wrote: As you can see (as long as you're reading this in fixed-width fonts) it _is_ very readable. given that it only relies on indentation from the left margin, it's no less readable in a proportional font (unless you're using an font with variable-width spaces, that is ;-).

Re: How to Determine Name of the Day in the Week

2008-09-18 Thread Fredrik Lundh
Keo Sophon wrote: I've tried calendar.month_name[0], it displays empty string, while calendar.month_name[1] is "January"? Why does calendar.month_name's index not start with index 0 as calendar.day_name? the lists are set up to match the values used by the time and datetime modules; see e.g.

Re: python-mode problem, doesnt load whole module?

2008-09-17 Thread Fredrik Lundh
cnb wrote: a = parsing.unserialize("C:/users/saftarn/desktop/twok.txt") Traceback (most recent call last): File "C:\Python25\lib\pickle.py", line 1126, in find_class klass = getattr(mod, name) when reporting a traceback, please include the error message that follows after the stack

Re: translating ascii to binary

2008-09-17 Thread Fredrik Lundh
Lie wrote: Any advice about this matter would be very appreciated. Thanks in advance. It'd be easier to make a one-char version of ascii2bin then make the string version based on the one-char version. And it'd be a lot easier to read your posts if you trimmed away at least some of the origi

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
Steven D'Aprano wrote: Assuming that you want to find runs of \u escapes, simply use non-capturing parentheses: pat = re.compile(u"(?:\\\u[0-9A-F]{4})") Doesn't work for me: pat = re.compile(u"(?:\\\u[0-9A-F]{4})") it helps if you cut and paste the right line... here's a better v

Re: python regex character group matches

2008-09-17 Thread Fredrik Lundh
christopher taylor wrote: my issue, is that the pattern i used was returning: [ '\\uAD0X', '\\u1BF3', ... ] when i expected: [ '\\uAD0X\\u1BF3', ] the code looks something like this: pat = re.compile("(\\\u[0-9A-F]{4})+", re.UNICODE|re.LOCALE) #print pat.findall(txt_line) results = pat.find

Re: recursive using the os.walk(path) from the os module

2008-09-17 Thread Fredrik Lundh
A. Joseph wrote: I want to search through a directory and re-arrange all the files into e.g All .doc files go into MS WORD folder, all .pdf files goes into PDF Folder. I`m thinking of doing something with the os.walk(path) method from os module, I need some ideal how the algorithm should look

Re: File Reading related query

2008-09-17 Thread Fredrik Lundh
Usman Ajmal wrote: Is there any function for reading a file while ignoring *\n* occuring in the file? can you be a bit more precise? are we talking about text files or binary files? how do you want to treat any newlines that actually appear in the file? -- http://mail.python.org/mailma

Re: how many objects are loaded for hello world?

2008-09-16 Thread Fredrik Lundh
belred wrote: i just read this blog about how many objects (types) are loaded for a hello world program in C#. http://blogs.msdn.com/abhinaba/archive/2008/09/15/how-many-types-are-loaded-for-hello-world.aspx how can you find out how many are loaded for a python program: print 'hello' types

Re: How do I add permanently to Pythons sys.path?

2008-09-16 Thread Fredrik Lundh
cnb wrote: no I can't... Python has supported packages since version 1.4 or so, so I'm pretty sure you can. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there any nice way to unpack a list of unknown size??

2008-09-14 Thread Fredrik Lundh
srinivasan srinivas wrote: I want to do something like below: 1. first, second, third, *rest = foo 2. for (a,b,c,*rest) in list_of_lists: update to Python 3.0 (as others have pointed out), or just do first, second, third = foo[:3] rest = foo[3:] for item in list_of_lists:

Re: Stuck connection in Python 3.0b2 http.server

2008-09-14 Thread Fredrik Lundh
rs387 wrote: I've encountered a weird issue when migrating a web server to Python 3 - the browser would wait forever without showing a page, displaying "Transferring data" in the status bar. I tracked it down to a reference cycle in my BaseHTTPRequestHandler descendant - one of the attributes st

Re: Why some blog entries at MSN Space support rss feed while others don't?

2008-09-14 Thread Fredrik Lundh
liuyuprc wrote: Not sure if this is the place this question should even be raised it isn't. -- http://mail.python.org/mailman/listinfo/python-list

Re: code style and readability [was: Re: Checking the boolean value of a collection]

2008-09-13 Thread Fredrik Lundh
Larry Bates wrote: I also have a personal dislike for early returns because I've found it makes it harder insert execution trace logging into the code. in a language that makes it trivial to wrap arbitrary callables in tracing wrappers? -- http://mail.python.org/mailman/listinfo/python-li

Re: Checking the boolean value of a collection

2008-09-13 Thread Fredrik Lundh
Marco Bizzarri wrote: class FolderInUse: > def true_for(self, archivefolder): return any([instance.forbid_to_close(archivefolder) for instance in self.core.active_outgoing_registration_instances()]) Is this any better? The true_for name does not satisfy me a lot... w

Re: How to run PyOS_InputHook from python code (i.e. yield to event loops)

2008-09-13 Thread Fredrik Lundh
ville wrote: That's tk-specific, right? I'm looking for a snippet that - Would not be tied to tk upstream, you said: "My actual use case is to keep a tkinter application responsive" -- http://mail.python.org/mailman/listinfo/python-list

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Problem is that when i start client (while the server is already running), i get an error i.e. Error 500 Internal Server Error that's a server error, not a client error. check the server logs (e.g. error.log or similar). -- http://mail.python.org/mailman/listinfo/pyth

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Where exactly should i call ServerProxy? Following is the code from my client.py ServerProxy is the preferred name. Server is an old alias for the same class. t = SecureTransport() t.set_authorization(ustring, text_ucert) server = xmlrpclib.Server('http://l

Re: book example confusion

2008-09-13 Thread Fredrik Lundh
byron wrote: Being that each function is an object, a name assignment to (tmp1,tmp2) doesn't actually evaluate or run the function itself until the name is called.. the above would be true if the code had been tmp1, tmp2 = f1, f2 but it isn't. look again. -- http://mail.python.org/mai

Re: XML RPC Problem....

2008-09-13 Thread Fredrik Lundh
Usman Ajmal wrote: Please explain the arguments of send_request. What exactly are the connection, handler and request_body? It will be really helpful if you give an example of how do i call send_request you don't call send_request. you should pass the SecureTransport instance as an argument

Re: Which version

2008-09-12 Thread Fredrik Lundh
Eric Wertman wrote: The subprocess module is one though footnote: subprocess works on older versions too, and can be trivially installed along with your application under Python 2.2 and 2.3. binary builds for Windows are available here: http://effbot.org/downloads/#subprocess -- http:

Re: Which version

2008-09-12 Thread Fredrik Lundh
Don wrote: I'm a reasonably experienced in other languages and have just decided to get my feet wet with Python. But I'm using FC6 which has v2.4.4 installed, is this good enough to start out with or am I likely to encounter bugs that have been fixed in later versions. Python 2.4 is definitely

Re: lacking follow-through

2008-09-12 Thread Fredrik Lundh
Steve Holden wrote: The defence rests. can you please stop quoting that guy, so we don't have to killfile you as well... -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
D'Arcy J.M. Cain wrote: Is there ever any advantage to having something as a builtin rather than as a regular user method? What difference does it make to the running script? I can see that adding "bar" from module "foo" to "__builtins__" means that you can use "bar()" instead of "foo.bar()".

Re: setattr in class

2008-09-12 Thread Fredrik Lundh
Bojan Mihelac wrote: Hi all - when trying to set some dynamic attributes in class, for example: class A: for lang in ['1', '2']: exec('title_%s = lang' % lang) #this work but is ugly # setattr(A, "title_%s" % lang, lang) # this wont work setattr(A, "title_1", "x") # this wo

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: I would like to make this available to the whole project. I suspect I could put it in the package __init__.py... in that way, the __builtins__ namespace should have it... am I right? the __init__ module for package "foo" defines the contents of the "foo" module; it does

Re: Matching horizontal white space

2008-09-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: multipleSpaces = re.compile(u'\\h+') importantTextString = '\n \n \n \t\t ' importantTextString = multipleSpaces.sub("M", importantTextString) what's "\\h" supposed to mean? I would have expected consecutive spaces and tabs to be replaced by M but nothing is bein

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: Can you clarify where I can find "any"? It seems to me I'm > unable to find it... it's a 2.5 addition. to use this in a "future-compatible" way in 2.3, you can add try: any except NameError: def any(iterable): for element in it

Re: Is len O(n) or O(1) ?

2008-09-11 Thread Fredrik Lundh
process wrote: ok but if len is O(1) then it doesnt matter? compared to if not lista: return [] what doesn't matter? -- http://mail.python.org/mailman/listinfo/python-list

Re: wx

2008-09-11 Thread Fredrik Lundh
Desmond Scott E wrote: I'm am a Python novice by chance not choice. (Although it appears to be a nice tool. Plus anything based on Monte Python can't be bad!) My Quest is to migrate a Python-based process from Windows2000/Python v2.4.2 (#67) to WindowsXP/Python v2.5.2 (r252:60911). I've s

Re: shelve file name extention

2008-09-11 Thread Fredrik Lundh
Monu wrote: So Can't I choose which module to use. Is there any preferance on which shelve chooses these modules? it uses the anydbm module to look for available DBM-style drivers, which looks for modules in the following order: dbhash, gdbm, dbm, dumbdbm. if you know which one you want, yo

Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-11 Thread Fredrik Lundh
Diez B. Roggisch wrote: Any reason why os.path.normpath(a).startswith(os.normpath(b)) doesn't do the trick? Except for the trivial type, you mean? That depends on whether "c:\foo" should be seen as a subpath to "c:\foobar" or not. I'd probably go for (also untested): def issubpath(a, b)

Re: How to Determine Name of the Day in the Week

2008-09-11 Thread Fredrik Lundh
Henry Chang wrote: Instead of getting integers with weekday(), Monday == 0 ... Sunday == 6; is there a way to get the actual names, such as "Monday ... Sunday"? I would like to do this without creating a data mapping. :) if you have a datetime or date object, you can use strftime with the

Re: dict slice in python (translating perl to python)

2008-09-11 Thread Fredrik Lundh
hofer wrote: The real example would be more like: name,age,country = itemgetter('name age country'.split())(x) ouch. if you do this a lot (=more than once), just wrap your dictionaries in a simple attribute proxy, and use plain attribute access. that is, given class AttributeWrapper:

Re: Python platform.

2008-09-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: I want to build a desktop application. I am searching for some kind of environment that would provide all the elements ready (Windows...). Then I would have to code the business logic only. start here: http://wiki.python.org/moin/GuiProgramming The big ones are Tki

Re: Python platform.

2008-09-11 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I wonder if there is a platform written in python. The equivalent of > the Netbeans platform http://platform.netbeans.org/ in the Python > world. Do you know such a thing? You (or maybe the Java folks) seem to have missed that platform has a rather specific meaning in

Re: function return

2008-09-11 Thread Fredrik Lundh
make that: note that you put the "return" statement inside the loop, so returning only one line is the expected behaviour. to fix this, you can append the result strings to the data_lis list inside the loop: result = "%s\t%s\t%s" %(id,gene_symbol,ptms) data_lis.append(r

Re: function return

2008-09-11 Thread Fredrik Lundh
Beema Shafreen wrote: I have a script using functions , I have a problem in returning the result. My script returns only one line , i donot know where the looping is giving problem, Can any one suggest, why this is happening and let me know how to return all the lines def get_ptm(): fh =

Re: problem with interpreter

2008-09-11 Thread Fredrik Lundh
chusky wrote: File "C:\Python25\Lib\site-packages\wx-2.8-msw-ansi\wx\_core.py", line 5, in < module> import new File "new.py", line 1 import ^ SyntaxError: invalid syntax wxPython tries to import the module "new" from Python's standard library, but picks up a broken modul

Re: Gateway to python-list is generating bounce messages.

2008-09-11 Thread Fredrik Lundh
Steven D'Aprano wrote: I wasn't aware that comp.lang.python was a news-to-mail gateway. How can one tell the difference between news groups that use a news-to-mail gateway, and news groups that don't? by reading the group's FAQ, perhaps? http://www.faqs.org/faqs/python-faq/python-newsgroup-f

Re: Adding environment variables to bash.

2008-09-11 Thread Fredrik Lundh
John Lawrence wrote: You can make a command use the current shell though if you use the '.' command e.g.: jl > cat env.sh export TEST='hello' jl > ./env.sh && env | grep TEST #Doesn't set TEST in parent shell jl > . ./env.sh && env | grep TEST #Adding '. ' before the comman

Re: Is len O(n) or O(1) ?

2008-09-11 Thread Fredrik Lundh
process wrote: Python uses arrays for lists right? len is O(1). for other operations, see http://effbot.org/zone/python-list.htm#performance > def quicksort(lista): > if lista == []: > lista better make that: def quicksort(lista): if not lista: return l

Re: Adding environment variables to bash.

2008-09-11 Thread Fredrik Lundh
aditya shukla wrote: Can i add any environment variable to bash from my python script? so that when i use env command then i can see that environment variable. not if you run the script from the shell. when a process starts, it gets a *copy* of the parent's environment. it can modify that c

Re: dynamic allocation file buffer

2008-09-11 Thread Fredrik Lundh
Steven D'Aprano wrote: I'm no longer *claiming* anything, I'm *asking* whether random access to a 4GB XML file is something that is credible or useful. It is my understanding that XML is particularly ill-suited to random access once the amount of data is too large to fit in RAM. An XML file

Re: XML RPC Problem....

2008-09-11 Thread Fredrik Lundh
Usman Ajmal wrote: And i also fount that a typical system.auth call will look like: POST /xmlrpc/clarens_server.py HTTP/1.0 Host: localhost User-Agent: xmlrpclib.py/0.9.9 (by www.pythonware.com ) Content-Type: text/xml Content-Length: 105 AUTHORIZATION: Basic MkhVTm

Re: I want to use a C++ library from Python

2008-09-10 Thread Fredrik Lundh
Anders Eriksson wrote: I have looked (very briefly) at the three framework you mention but they all need the source code of the C++? No, they need header files and an import library to be able to compile the bindings and link them to your DLL. Do you know enough about C/C++ build issues to

Re: Simple UDP server

2008-09-10 Thread Fredrik Lundh
Tzury Bar Yochay wrote: Would the one below will be capable of holding 30 concurrent connections? UDP is a connectionless datagram protocol, so that question doesn't really make much sense. -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen hangs at times?

2008-09-10 Thread Fredrik Lundh
Kenneth McDonald wrote: When making calls of the form Popen(cmd, shell=True, stdout=subprocess.PIPE), we've been getting occasional, predictable hangs. Will Popen accumulate a certain amount of stdout and then block until its read? the pipe provided by the operating system has a limited buff

Re: dict slice in python (translating perl to python)

2008-09-10 Thread Fredrik Lundh
B wrote: for a long list, you could try: result = [mydict[k] for k in mydict] or [mydict[k] for k in mydict.keys()] or [mydict[k] for k in mydict.iterkeys()] and the point of doing that instead of calling mydict.values() is what? -- http://mail.python.org/mailman/listinfo/python-

Re: md5 differences

2008-09-10 Thread Fredrik Lundh
Python wrote: I'm trying to match the results of an md5 checksum done in a tcsh shell. I keep getting different results and can't find anything on google... here's an example: [EMAIL PROTECTED]:~% echo "hello" | md5 b1946ac92492d2347c6235b4d2611184 [EMAIL PROTECTED]:~% python Python 2.5.1 (r2

Re: Web shopping carts

2008-09-10 Thread Fredrik Lundh
Luke Hamilton wrote: And unfortunately Google hasn't been much help... "You've got to be very careful if you don't know where you're going, because you might not get there." -- http://mail.python.org/mailman/listinfo/python-list

Re: Python extension, where am I going wrong

2008-09-10 Thread Fredrik Lundh
John Vines (CISD/HPCD) wrote: I am trying to create an extension module and keep getting an error, "/usr/local/lib/python2.5/site-packages/mytest.so: undefined symbol: PyInitModule" it's spelled Py_InitModule, not PyInitModule. -- http://mail.python.org/mailman/listinfo/python-list

Re: Web shopping carts

2008-09-10 Thread Fredrik Lundh
Luke Hamilton wrote: Do you happen to have anymore details? Google says "Results 1 - 10 of about 869,000 for python shopping cart." http://www.google.com/search?q=python+shopping+cart Checking the first few pages might give you something that fits your requirements (whatever they are).

Re: List of modules available for import inside Python?

2008-09-10 Thread Fredrik Lundh
Michele Simionato wrote: I have just tried the following on my Ubuntu box with the system Python: ~$ python /usr/lib/python2.5/doc/tools/listmodules.py /usr/lib/python2.5/doc/tools/listmodules.py:99: DeprecationWarning: the rgbimg module is deprecated __import__(m) ** (process:24863): WARNIN

Re: List of modules available for import inside Python?

2008-09-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: how can I list all modules that might be importable on my system, without actually importing them all ? I'm pretty sure I mentioned a way to do that back when this thread was opened. let's see, yes, here it is: ... there's a helper script in the 2.5 source c

Re: Catching subprocess stdout stream

2008-09-10 Thread Fredrik Lundh
Sean DiZazzo wrote: while aThread.isAlive() or not aQueue.empty(): l = aQueue.get().rstrip() fo.write(l) print l fo.close() A bit of fun for a sleepless night... and unless you add a call to time.sleep somewhere in that loop, you'll keep your CPU up all night as well... -- http

Re: which of these 2 quicksorts is faster?

2008-09-10 Thread Fredrik Lundh
process wrote: qsort can handle bigger lists it seems, making less recursive calls before finishing(quicksort blows the stack when sorting range(100,-1000,-1). qsort does more work though right? is there a way to speed up that? is the built-in sort not defined recursively? what makes you thin

Re: dynamic allocation file buffer

2008-09-10 Thread Fredrik Lundh
Steven D'Aprano wrote: You've created a solution to a problem which (probably) only affects a very small number of people, at least judging by your use-cases. Who has a 4GB XML file Getting 4GB XML files from, say, logging processes or databases that can render their output as XML is not tha

Re: creating an (inefficent) alternating regular expression from a list of options

2008-09-09 Thread Fredrik Lundh
Larry Bates wrote: vowel_regexp = oneOf("a aa i ii u uu".split()) # yielding r'(aa|a|uu| u|ii|i)' Is there a public module available for this purpose? Perhaps I'm missing something but your function call oneOf(...) is longer than than actually specifying the result. You can certainly writ

Re: firefox timestamp

2008-09-08 Thread Fredrik Lundh
abhilash pp wrote: I don't know if this question will fit on this section, any way my query is , i have used one script demork.py to extract details from Firefox history.dat file and now the problem is how to convert the TIMESTAMP given by that to normal date and time. example timestams are l

Re: Subprocess freezes when piping from stdout.

2008-09-07 Thread Fredrik Lundh
James McGill wrote: Is anyone aware of why this might be occurring, or of any ways around this? Does the PIPE implementation in Win32 have a maximum buffer size? pipes always have a limited buffer size, on all platforms. you're supposed to read data from them as it arrives (e.g. by explicitl

Re: lacking follow-through

2008-09-07 Thread Fredrik Lundh
Marc 'BlackJack' Rintsch wrote: Yeah, castironpi sometimes doesn't make much sense. Maybe because it's a bot!? :-) if so, they sure don't make c.l.py bots like they used to, do they? -- http://mail.python.org/mailman/listinfo/python-list

Re: Updating python dictionary

2008-09-07 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Is there a clever way to do this, or should I loop through both, essentially creating a brand new dict? since none of your dictionaries contain the keys you want in the final dictionary, creating a brand new dict sounds pretty clever to me. -- http://mail.python.o

Re: formatting a string with thousands separators

2008-09-07 Thread Fredrik Lundh
James Mills wrote: There is a much easier more consistent way: import locale locale.setlocale(locale.LC_ALL, "en_AU.UTF-8") 'en_AU.UTF-8' doesn't work on all Python platforms, though: >>> locale.setlocale(locale.LC_ALL, "en_AU.UTF-8") Traceback (most recent call last): File "", line 1, i

Re: Not fully understanding the role of Queue.task_done()

2008-09-07 Thread Fredrik Lundh
Aahz wrote: why are you using a queue for this case, btw? why not just use a plain list L = [] lock = threading.Lock() and add stuff using append in the monitor threads with lock: L.append(item) Because using a queue requires less thinking. given that the whole reason

Re: doctest not seeing any of my doc tests

2008-09-07 Thread Fredrik Lundh
Steven D'Aprano wrote: I have a function in my module: def selftest(verbose=False): import doctest doctest.testmod(verbose=verbose) what happens if you change the above to def selftest(verbose=False): import doctest, yourmodule doctest.testmod(yourmodule, verbose=verbos

Re: unexpected class behaviour

2008-09-07 Thread Fredrik Lundh
Jan Schäfer wrote: can anyone explain the behaviour of the following code sniplet: well, it *is* explained in the tutorial, the language reference, and the FAQ, so yes, it can be explained ;-) for more information, see this page: http://effbot.org/zone/default-values.htm -- http://m

Re: Directory creation

2008-09-07 Thread Fredrik Lundh
srinivasan srinivas wrote: Can someone tell me is there any module available to create directories?? I tried os, tempfile. I was facing some issues with os.mkdir(). The mode setting was not proper with this method. I created the directory 'stdin' with '0700' mode using os.mkdir() method. $>

  1   2   3   4   5   6   7   8   9   10   >