itools 0.60.3 released

2009-07-17 Thread J. David Ibáñez
itools is a Python library, it groups a number of packages into a single meta-package for easier development and deployment: itools.abnf itools.i18n itools.stl itools.core itools.ical itools.tmx itools.csv itools.odf

ikaaro 0.60.3 released

2009-07-17 Thread J. David Ibáñez
This is a Content Management System built on Python itools, among other features ikaaro provides: - content and document management (indexsearch, metadata, etc.) - multilingual user interfaces and content - high level modules: wiki, forum, tracker, etc. The new script icms-forget.py reduces

ANN: Leo 4.6 final released

2009-07-17 Thread Edward K Ream
Leo 4.6 final is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458package_id=29106 Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.6: -- - Cached

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Gabriel Rossetti
Maxim Khitrov wrote: On Thu, Jul 16, 2009 at 5:00 PM, Carl Bankspavlovevide...@gmail.com wrote: On Jul 16, 8:12 am, Gabriel Rossetti gabriel.rosse...@arimaz.com wrote: Hello everyone, I am using threading.Condition.wait(timeout) and was surprised to see that there is no return value

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread koranthala
That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing. This is an extremely common type of error. Actually, I felt that 0 not being considered False would be a better option. I had lot of

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti gabriel.rosse...@arimaz.com (GR) wrote: GR Hello everyone, GR I am using threading.Condition.wait(timeout) and was surprised to see that GR there is no return value nor an exception when wait() is used w/ a timeout. GR How am I supposed

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Chris Rebert
On Thu, Jul 16, 2009 at 11:13 PM, koranthalakoranth...@gmail.com wrote: That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing.  This is an extremely common type of error. Actually, I felt

Re: turtle dump

2009-07-17 Thread Peter Otten
Terry Reedy wrote: Terry Reedy wrote: $ file tmp.ps tmp.ps: PostScript document text conforming DSC level 3.0, type EPS Try changing the file extension from .ps to .eps. I will. Thank you. I tried it. Unfortunately, OOo does not open it correctly. It just displays the first three

Re: Override a method but inherit the docstring

2009-07-17 Thread Peter Otten
Ben Finney wrote: Howdy all, The following is a common idiom:: class FooGonk(object): def frobnicate(self): Frobnicate this gonk. basic_implementation(self.wobble) class BarGonk(FooGonk): def frobnicate(self):

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-17 Thread Nobody
On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote: Well, you were write: unintentionally I removed strip(). But the problem does not ends here: I get this error now: File ./temp.py, line 488, in module main() File ./temp.py, line 475, in main for line in sys.stdin: File

Re: urllib with x509 certs

2009-07-17 Thread Lacrima
Hello! I've solved this problem, using pyCurl. Here is sample code. import pycurl import StringIO b = StringIO.StringIO() c = pycurl.Curl() url = 'https://example.com/' c.setopt(pycurl.URL, url) c.setopt(pycurl.WRITEFUNCTION, b.write) c.setopt(pycurl.CAINFO, 'cert.crt') c.setopt(pycurl.SSLKEY,

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Steven D'Aprano
On Thu, 16 Jul 2009 23:13:51 -0700, koranthala wrote: That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing. This is an extremely common type of error. Actually, I felt that 0 not being

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Paul Rubin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: It is very useful to be able to write e.g.: if header or body or footer: print assemble_page(header, body, footer) and have empty strings to be equivalent to False. Why doesn't assemble_page properly handle the case where

Re: invoke method on many instances

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 05:19:50 +, Alan G Isaac wrote: As a recurrent situation, I need to invoke the same method on many instances. Speed matters, but the solution should be pure Python. Is the following convenience function a reasonable approach? def apply2(itr, methodname, *args,

Re: Override a method but inherit the docstring

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 12:58:48 +1000, Ben Finney wrote: Using a decorator in this manner requires repeating the super class name. Perhaps there is a way to get the bases of BarGonk, but I don't think so, because at the time that the decorator is called, BarGonk is not yet fully defined.

Re: TypeError: unbound method

2009-07-17 Thread Steven D'Aprano
On Thu, 16 Jul 2009 18:08:45 -0700, Chris Rebert wrote: You're trying to call an instance method on the class itself, which doesn't make sense. Oh I don't know, people do it all the time -- just not the way the OP did :) You need to first create an instance of the class to invoke the method

Re: How to check if any item from a list of strings is in a big string?

2009-07-17 Thread Steven D'Aprano
On Thu, 16 Jul 2009 11:02:57 -0500, Pablo Torres N. wrote: On Thu, Jul 9, 2009 at 22:07, Steven D'Apranoste...@remove.this.cybersource.com.au wrote: On Thu, 09 Jul 2009 18:36:05 -0700, inkhorn wrote: def list_items_in_string(list_items, string):     for item in list_items:         if item

ann: servicestation - run your linux/mac services on windows without needing pywin...

2009-07-17 Thread Oisin Mulvihill
Hi There, I gave a lightning talk about my ServiceStation project at Europython 2009. While it isn't written in Python (C++/Windows), I did write it with python in mind. Its released under the CDDL license. I'm hoping it will be of use to other Python users who will need to run their

Re: question of style

2009-07-17 Thread Piet van Oostrum
koranthala koranth...@gmail.com (k) wrote: That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing. This is an extremely common type of error. k Actually, I felt that 0 not being considered

Re: Persistent variable in subprocess using multiprocessing?

2009-07-17 Thread Piet van Oostrum
There is stil something not clear in your description. m I'm using multiprocessing to spawn several subprocesses, each of which m uses a very large data structure (making it impractical to pass it via m pipes / pickling). I need to allocate this structure once when the m process is created and

Re: ann: servicestation - run your linux/mac services on windows without needing pywin...

2009-07-17 Thread Tim Golden
Oisin Mulvihill wrote: Hi There, I gave a lightning talk about my ServiceStation project at Europython 2009. While it isn't written in Python (C++/Windows), I did write it with python in mind. Its released under the CDDL license. I'm hoping it will be of use to other Python users who will

Re: ctype performance benchmark

2009-07-17 Thread Stefan Behnel
auror...@gmail.com wrote: My overall observation is that ctypes function has an overhead that is 2 to 3 times to a similar C extension function. This may become a limiting factor if the function calls are fine grained. Using ctypes for performance enhancement is a lot more productive if the

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Piet van Oostrum
Gabriel Rossetti gabriel.rosse...@arimaz.com (GR) wrote: GR I have a 1-1 relation, I have a thread reading msgs from a network socket GR and a method waiting for an answer to arrive (see my thread GR Threading.Condition problem). I would like to be able to have a timeout GR as to not block

ANN: psyco V2

2009-07-17 Thread Christian Tismer
Announcing Psyco V2 source release -- This is the long awaited announcement of Psyco V2. Psyco V2 is a continuation of the well-known psyco project, which was called finished and was dis-continued by its author Armin Rigo in 2005, in favor of the PyPy project.

Re: Why not enforce four space indentations in version 3.x?

2009-07-17 Thread Nobody
On Thu, 16 Jul 2009 09:18:47 -0500, Tim Chase wrote: Yes, the dictatorial a tab always equals 8 spaces Saying always is incorrect; it is more accurate to say that tab stops are every 8 columns unless proven otherwise, with the burden of proof falling on whoever wants to use something different.

Re: Clarity vs. code reuse/generality

2009-07-17 Thread Albert van der Horst
In article mailman.2814.1247032175.8015.python-l...@python.org, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: On 07 Jul 2009 05:05:12 GMT, Steven D'Aprano st...@remove-this-cybersource.com.au declaimed the following in gmane.comp.python.general: Paraphrasing the Collins Dictionary of

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-17 Thread Piet van Oostrum
akhil1988 akhilan...@gmail.com (a) wrote: a Well, you were write: unintentionally I removed strip(). But the problem does a not ends here: a I get this error now: a File ./temp.py, line 488, in module a main() a File ./temp.py, line 475, in main a for line in sys.stdin: a File

Re: ann: servicestation - run your linux/mac services on windows without needing pywin...

2009-07-17 Thread Oisin Mulvihill
On Jul 17, 9:34 am, Tim Golden m...@timgolden.me.uk wrote: Oisin Mulvihill wrote: Hi There, I gave a lightning talk about my ServiceStation project at Europython 2009. While it isn't written in Python (C++/Windows), I did write it with python in mind. Its released under the CDDL

Re: error when compiling source on linux

2009-07-17 Thread Peter Fodrek
On Friday 17 July 2009 06:44:26 aj wrote: when I try to compile Python 2.6 from source code on ubuntu, I get the message /usr/bin/ld: cannot open output file python: Is a directory This says that there is directory in the sources with same name as will be named output It can only occur when

Re: ann: servicestation - run your linux/mac services on windows without needing pywin...

2009-07-17 Thread Tim Golden
Oisin Mulvihill wrote: I have to admit I didn't come across srvany before. It's been part of the Windows Resource Kit since way back, but like many such things is probably known more by word-of-mouth than by Internet Searchability * Properly tracking all child processes launched by the

Re: Passing python list from C to python

2009-07-17 Thread hartley
On Jul 16, 9:26 pm, a...@pythoncraft.com (Aahz) wrote: In article 0afc5c4d-1af5-4d0e-9442-26b51b12e...@m11g2000yqh.googlegroups.com, hartley  hartle...@gmail.com wrote: If you had loosened up on the sarcasm I would probably have read what you wrote more thoroughly instead of just skimming

Re: Override a method but inherit the docstring

2009-07-17 Thread Ben Finney
Peter Otten __pete...@web.de writes: Just thinking aloud: Write a patch for pydoc that looks up the base-class documentation. That doesn't scale; I want the docstring to be discovered by the normal interface (the ‘__doc__’ attribute) by *every* tool that gathers docstrings from methods. Also,

Re: Why aren't OrderedDicts comparable with etc?

2009-07-17 Thread Sion Arrowsmith
Jack Diederich jackd...@gmail.com wrote: It isn't an OrderedDict thing, it is a comparison thing. Two regular dicts also raise an error if you try to LT them. Since when? Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type help, copyright, credits or license for more

Re: missing 'xor' Boolean operator

2009-07-17 Thread Jean-Michel Pichavant
Luis Alberto Zarrabeitia Gomez wrote: Quoting Jean-Michel Pichavant jeanmic...@sequans.com: Emile van Sebille wrote: On 7/16/2009 7:04 AM Unknown said... On 2009-07-16, Emile van Sebille em...@fenx.com wrote: daysInAdvance = int(inputVar) or 25 I don't

Re: ANN: psyco V2

2009-07-17 Thread Bearophile
Very good, thank you. I'll try it when I can. Is Psyco3 going to borrow/steal some ideas/code from Unladen Swallow? The problem I have with Psyco1.6 is that you can't use the normal profilers to know how much seconds of running time is taken by each function/method of your code. Psyco1.6 has a

Re: Try... except....Try again?

2009-07-17 Thread Andre Engels
On Fri, Jul 17, 2009 at 7:31 AM, Xavier Hocont...@xavierho.com wrote: I have a simple class that generates prime numbers, using memorisation and iteration to generate the next prime number. In the class, I have defined a function that gives, say, the 5th prime number. Or the 1000th, it's

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
On Fri, Jul 17, 2009 at 7:33 PM, Andre Engels andreeng...@gmail.com wrote: Where do you get these Don't do it!s? As far as I know, while true loops are a very acceptable idiom for programming in Python (and several other languages). Hey Andre, Friends, internet, common sense. Also... while

Re: Override a method but inherit the docstring

2009-07-17 Thread David Stanek
On Fri, Jul 17, 2009 at 2:58 AM, Peter Otten__pete...@web.de wrote: Ben Finney wrote: Howdy all, The following is a common idiom::     class FooGonk(object):         def frobnicate(self):             Frobnicate this gonk.             basic_implementation(self.wobble)     class

setup.py not found

2009-07-17 Thread larry.mart...@gmail.com
I'm trying to install a package (cx_Oracle) on a mac running 10.5.7. I've done this on other platforms, but never on a mac. I followed the instructions given, but when I try and run setup I get: Apollo:instantclient_10_2 user$ python setup.py build

guessing file type

2009-07-17 Thread Seldon
Hello, I need to determine programmatically a file type from its content/extension (much like the file UNIX command line utility) I searched for a suitable Python library module, with little luck. Do you know something useful ? Thanks in advance. -- Seldon --

Re: Override a method but inherit the docstring

2009-07-17 Thread David Stanek
On Fri, Jul 17, 2009 at 3:52 AM, Steven D'Apranost...@remove-this-cybersource.com.au wrote: On Fri, 17 Jul 2009 12:58:48 +1000, Ben Finney wrote: Using a decorator in this manner requires repeating the super class name.  Perhaps there is a way to get the bases of BarGonk, but I don't think

Re: guessing file type

2009-07-17 Thread Ben Finney
Seldon sel...@katamail.it writes: Hello, I need to determine programmatically a file type from its content/extension (much like the file UNIX command line utility) The Unix ‘file(1)’ program does its magic with a library called “magic” and a corresponding database. I searched for a suitable

Re: guessing file type

2009-07-17 Thread Tim Chase
Hello, I need to determine programmatically a file type from its content/extension (much like the file UNIX command line utility) I searched for a suitable Python library module, with little luck. Do you know something useful ? Are you looking for something comprehensive? Or are you just

Re: guessing file type

2009-07-17 Thread VanL
Seldon wrote: Hello, I need to determine programmatically a file type from its content/extension (much like the file UNIX command line utility) I searched for a suitable Python library module, with little luck. Do you know something useful ? Python-magic

Re: Try... except....Try again?

2009-07-17 Thread MRAB
Xavier Ho wrote: I have a simple class that generates prime numbers, using memorisation and iteration to generate the next prime number. In the class, I have defined a function that gives, say, the 5th prime number. Or the 1000th, it's still very fast. But the code isn't what I really like.

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 00:34:00 -0700, Paul Rubin wrote: Steven D'Aprano st...@remove-this-cybersource.com.au writes: It is very useful to be able to write e.g.: if header or body or footer: print assemble_page(header, body, footer) and have empty strings to be equivalent to False.

ANN: Leo 4.6 final released

2009-07-17 Thread Edward K Ream
Leo 4.6 final is now available at: http://sourceforge.net/project/showfiles.php?group_id=3458package_id=29106 Leo is a text editor, data organizer, project manager and much more. See: http://webpages.charter.net/edreamleo/intro.html The highlights of Leo 4.6: -- - Cached

Re: missing 'xor' Boolean operator

2009-07-17 Thread Steven D'Aprano
On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Python has extended the algebra definition of or and and top any type, but it is so unintuitive (I'm no LISP programmer). I disagree. The Something/Nothing dichotomy is so intuitive to me that I would hate to go back to a

Re: guessing file type

2009-07-17 Thread Justin Ezequiel
On Jul 17, 8:39 pm, VanL van.lindb...@gmail.com wrote: Seldon wrote: Hello,  I need to determine programmatically a file type from its content/extension (much like the file UNIX command line utility) I searched for a suitable Python library module, with little luck. Do you know something

Re: Try... except....Try again?

2009-07-17 Thread Steven D'Aprano
Apologies for breaking threading, but the original post hasn't showed up on my ISP's news server. Xavier Ho wrote: I have a simple class that generates prime numbers, using memorisation and iteration to generate the next prime number. [...] The next() function generates the next prime, and

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Paul Rubin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: def assemble_page(header, body, footer): if header or body or footer: do_lots_of_expensive_processing() else: do_nothing_gracefully() Why should the processing be expensive if all three fields are empty?

Re: missing 'xor' Boolean operator

2009-07-17 Thread Luis Zarrabeitia
On Friday 17 July 2009 07:06:26 am Jean-Michel Pichavant wrote: I was saying that using boolean operators with object instead of boolean values is error prone, cause no language behaves he same way, I don't know of many languages that actively promote the duck typing concept, are as highly

Re: missing 'xor' Boolean operator

2009-07-17 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means no error and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1 or result_2 or result_3 The equivalent: failed =

Try... except....Try again?

2009-07-17 Thread Xavier Ho
oops, wrong address. When will reply-to tag appear on the Python mailing list? =/ Good idea, Steven and MRAB. I changed my code to the following: def nPrime(self, n): Returns nth prime number, the first one being 2, where n = 0. When n = 1, it returns 3. for x in

Re: missing 'xor' Boolean operator

2009-07-17 Thread Ethan Furman
Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means no error and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1 or result_2 or

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 07:12:51 -0700, Paul Rubin wrote: Steven D'Aprano st...@remove-this-cybersource.com.au writes: def assemble_page(header, body, footer): if header or body or footer: do_lots_of_expensive_processing() else: do_nothing_gracefully() Why should the

Re: Try... except....Try again?

2009-07-17 Thread Jack Diederich
On Fri, Jul 17, 2009 at 10:35 AM, Xavier Hocont...@xavierho.com wrote: I changed my code to the following:     def nPrime(self, n):     Returns nth prime number, the first one being 2, where n = 0. When n = 1, it returns 3.     for x in range(n+2):     try:    

Re: Einstein summation notation

2009-07-17 Thread MRAB
koranthala wrote: That test was designed to treat None as a boolean False, without noticing that numeric 0 is also treated as False and could make the test do the wrong thing. This is an extremely common type of error. Actually, I felt that 0 not being considered False would be a better

Re: no return value for threading.Condition.wait(timeout)?

2009-07-17 Thread Gabriel Rossetti
Piet van Oostrum wrote: Gabriel Rossetti gabriel.rosse...@arimaz.com (GR) wrote: GR I have a 1-1 relation, I have a thread reading msgs from a network socket GR and a method waiting for an answer to arrive (see my thread GR Threading.Condition problem). I would like to be able

Re: Einstein summation notation

2009-07-17 Thread Jerry Hill
On Fri, Jul 17, 2009 at 11:09 AM, MRABpyt...@mrabarnett.plus.com wrote: Python did always have True and False. Only if always means since python 2.2.1. See: http://www.python.org/doc/2.3/whatsnew/section-bool.html and http://www.python.org/dev/peps/pep-0285/ for details. -- Jerry --

Re: missing 'xor' Boolean operator

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 16:34:57 +0200, Jean-Michel Pichavant wrote: Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means no error and an arbitrary non- zero integer means some error, it is simple and easy to write:

Re: Einstein summation notation

2009-07-17 Thread Steven D'Aprano
On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote: Python did always have True and False. $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam True, False Traceback (innermost last):

'del' function for Dictionary

2009-07-17 Thread mayank gupta
Hi all, I wanted to know whether there is a more efficient way to delete an entry from a dictionary (instead of using the 'del' function), because after analyzing the time taken by the code, it seems to me that the 'del' function takes most of the time. I might be incorrect as well. Kindly help

Re: Try... except....Try again?

2009-07-17 Thread Xavier Ho
On Fri, Jul 17, 2009 at 11:02 PM, Jack Diederich jackd...@gmail.com wrote: If you use an off-the-shelf prime number generator fucntion[1] that returns consecutive primes the method collapses into a simple function. def nPrime(n, primes=[], next_prime=eratosthenes().next): while

Re: 'del' function for Dictionary

2009-07-17 Thread Michiel Overtoom
mayank gupta wrote: after analyzing the time taken by the code, What code? -- http://mail.python.org/mailman/listinfo/python-list

Find first matching substring

2009-07-17 Thread Eloff
Almost every time I've had to do parsing of text over the last 5 years I've needed this function: def find_first(s, subs, start=None, end=None): results = [s.find(sub, start, end) for sub in subs] results = [r for r in results if r != -1] if results: return min(results)

Re: Einstein summation notation

2009-07-17 Thread Ethan Furman
Paul Rubin wrote: Steven D'Aprano st...@remove-this-cybersource.com.au writes: def assemble_page(header, body, footer): if header or body or footer: do_lots_of_expensive_processing() else: do_nothing_gracefully() Why should the processing be expensive if all three fields

Re: Einstein summation notation (was: question of style)

2009-07-17 Thread Paul Rubin
Steven D'Aprano st...@remove-this-cybersource.com.au writes: Since I haven't specified an implementation for assemble_page, it could be doing *anything*. Perhaps it has to talk to a remote database over a slow link, perhaps it generates 300 lines of really inefficient HTML code with no

Question regarding style/design..

2009-07-17 Thread Wells Oliver
Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the if __name__ == '__main__': convention. Is there a preference? Is there an... application scope such that the

A multi-threaded file searcher for processing large text files

2009-07-17 Thread Mahmoud Abdelkader
I'm building a threaded file searcher that uses some of Fredrik Lundh's ( http://effbot.org/zone/wide-finder.htm) suggestions for parsing text very quickly in pure python, as I have about a 10GB log file to parse every day. A naiive approach would be to just parse the 1MB chunks, add the results

Re: missing 'xor' Boolean operator

2009-07-17 Thread Emile van Sebille
On 7/17/2009 7:34 AM Jean-Michel Pichavant said... Steven D'Aprano wrote: On Thu, 16 Jul 2009 15:53:45 +0200, Jean-Michel Pichavant wrote: Given three result codes, where 0 means no error and an arbitrary non- zero integer means some error, it is simple and easy to write: failed = result_1

Regular exprssion for IRC messages

2009-07-17 Thread nohics nohics
Hello, When an IRC client receive a messages, this message in in a special format defined here: Message format in pseudo BNFhttp://www.irchelp.org/irchelp/rfc/chapter2.html#c2_3_1( http://www.irchelp.org/irchelp/rfc/chapter2.html#c2_3_1 ). For example we can have:

Re: Question regarding style/design..

2009-07-17 Thread Tim Chase
Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the if __name__ == '__main__': convention. Is there a preference? Is there an... application scope such that the

Re: ctype performance benchmark

2009-07-17 Thread Wai Yip
I started with ctypes because it is the battery included with the Python standard library. My code is very fluid and I'm looking for easy opportunity to optimize it. One example is to find the longest common prefix among two strings. Right now I am comparing it character by character with pure

Installing python-gnutls on Windows

2009-07-17 Thread IronyOfLife
Hi, I'm new to python and would like to request your help installing python-gnutls on windows. Are there binaries available which can be installed ? Looks like the setup.py file which came with the package is for Debian. I tried modifying it for windows but am still getting errors.

getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where)

Propagate import for all modules in a package.

2009-07-17 Thread Phil
I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire package. Here is an example... package __init__.py

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-17 Thread Scott David Daniels
akhil1988 wrote: mis-ordered reply, bits shown below Nobody-38 wrote: On Thu, 16 Jul 2009 15:43:37 -0700, akhil1988 wrote: ... In Python 3 you can't decode strings because they are Unicode strings and it doesn't make sense to decode a Unicode string. You can only decode encoded things which

Re: Einstein summation notation

2009-07-17 Thread Matthew Barnett
Steven D'Aprano wrote: On Fri, 17 Jul 2009 16:09:03 +0100, MRAB wrote: Python did always have True and False. Oops! I meant didn't, of course. $ python1.5 Python 1.5.2 (#1, Apr 1 2009, 22:55:54) [GCC 4.1.2 20070925 (Red Hat 4.1.2-27)] on linux2 Copyright 1991-1995 Stichting

Re: Question regarding style/design..

2009-07-17 Thread Robert Kern
On 2009-07-17 12:11, Tim Chase wrote: Sometimes I see relatively small application, generally task scripts, written as essentially a list of statements. Other times, I see them neatly divided into functions and then the if __name__ == '__main__': convention. Is there a preference? Is there an...

Re: Propagate import for all modules in a package.

2009-07-17 Thread Diez B. Roggisch
Phil schrieb: I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire package. Here is an example... package

Re: Find first matching substring

2009-07-17 Thread MRAB
Eloff wrote: Almost every time I've had to do parsing of text over the last 5 years I've needed this function: def find_first(s, subs, start=None, end=None): results = [s.find(sub, start, end) for sub in subs] results = [r for r in results if r != -1] if results:

Generator Expressions and CSV

2009-07-17 Thread Zaki
Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any suggestions? Outline: 1. Read tab delim files from a directory, files are of 3 types:

Re: Propagate import for all modules in a package.

2009-07-17 Thread Albert Hopkins
On Fri, 2009-07-17 at 10:28 -0700, Phil wrote: I'm really new to Python and I am absolutely stumped trying to figure this out. I have searched plenty, but I am either searching for the wrong keywords or this isn't possible. What I want to do is have one import be global for the entire

Re: Question regarding style/design..

2009-07-17 Thread Tim Chase
Robert Kern wrote: [sage advice snipped] Don't waste half a day trying to figure out why your script mysteriously doesn't work. Learn from my mistakes. :-) I find that's the best type of mistake to learn from: other people's ;-) -tkc -- http://mail.python.org/mailman/listinfo/python-list

Writing a single list of numbers to a .m (matlab) file

2009-07-17 Thread Hanna Michelsen
Hi, I was wondering if I could get some suggestions on how to write a single list of numbers to a .m file (for matlab) so that I can create a matlab vector out of the list of numbers from my python program. I have been using a csv writer to create .m files from lists of lists, but I'm not sure

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread MRAB
LoD MoD wrote: I am having trouble extending my option parsing. Any help is appreciated: import sys import getopt import time def tail(file): while 1: where = file.tell() line = file.readline() if not line: time.sleep(1) file.seek(where)

Re: Generator Expressions and CSV

2009-07-17 Thread Emile van Sebille
On 7/17/2009 10:58 AM Zaki said... snip Now, I've tried running this and it takes much longer than I'd like. I was wondering if there might be a better way to do things Suppose, for the sake of argument, that you've written highly efficient code. Then the processing time would already be

Re: getopt code NameError exception on logTail.py

2009-07-17 Thread LoD MoD
In this instance the trackback was somewhat unhelpful.There problem was here: file = open(filename, 'r') should be file = open(a, 'r') args should be passed within the getopt riff On Fri, Jul 17, 2009 at 11:08 AM, MRAB pyt...@mrabarnett.plus.com wrote: LoD MoD wrote:

Re: ctype performance benchmark

2009-07-17 Thread Nick Craig-Wood
Wai Yip auror...@gmail.com wrote: I started with ctypes because it is the battery included with the Python standard library. My code is very fluid and I'm looking for easy opportunity to optimize it. One example is to find the longest common prefix among two strings. Right now I am

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just treat the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: Propagate import for all modules in a package.

2009-07-17 Thread Phil
Thanks to both of you for the fast and detailed responses. I will just use the package for what it is, a namespace. -- http://mail.python.org/mailman/listinfo/python-list

Re: Generator Expressions and CSV

2009-07-17 Thread MRAB
Zaki wrote: Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any suggestions? Outline: 1. Read tab delim files from a directory, files

Mechanize not recognized by py2exe

2009-07-17 Thread Stephen M. Olds
I have a Python script getData.py that uses Mechanize, and runs fine under the interpreter. It was installed using easy_install - and the install seemed to indicate it was completed. The problem is, when I try to compile it using py2exe while in the folder of the script, and using the run

Re: ctype performance benchmark

2009-07-17 Thread Duncan Booth
Wai Yip auror...@gmail.com wrote: I started with ctypes because it is the battery included with the Python standard library. My code is very fluid and I'm looking for easy opportunity to optimize it. One example is to find the longest common prefix among two strings. Right now I am comparing

Re: A Bug By Any Other Name ...

2009-07-17 Thread Albert van der Horst
In article mailman.2664.1246857607.8015.python-l...@python.org, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Mon, 06 Jul 2009 00:28:43 -0300, Steven D'Aprano st...@remove-this-cybersource.com.au escribi?: On Mon, 06 Jul 2009 14:32:46 +1200, Lawrence D'Oliveiro wrote: I wonder how many

proposal: add setresuid() system call to python

2009-07-17 Thread travis+ml-python
Hello, Historically, I have used scripting languages like python for typical uses, but they tend to not fare very well at system programming; for close interfacing with the operating system, I'm often forced to use a language like C. This is undesirable to me. I do not think this has to be the

Re: A Bug By Any Other Name ...

2009-07-17 Thread J. Cliff Dyer
On Fri, 2009-07-17 at 20:53 +, Albert van der Horst wrote: Because unlike in algol 68 in python whitespace is relevant, we could get by with requiring whitespace: x= -q # okay ab and -ac and -b -d# okay 8 ** -2 # okay

Re: Generator Expressions and CSV

2009-07-17 Thread Zaki
On Jul 17, 2:49 pm, MRAB pyt...@mrabarnett.plus.com wrote: Zaki wrote: Hey all, I'm really new to Python and this may seem like a really dumb question, but basically, I wrote a script to do the following, however the processing time/memory usage is not what I'd like it to be. Any

  1   2   3   >