Myghty 1.1 Released
Myghty 1.1 Released Myghty is a Python Server Page templating framework designed for large-scale, high availability websites and applications. Its conceptual design and template syntax is derived from HTML::Mason, the popular Perl-based web application platform used by Amazon.com, del.icio.us, Bricolage and others. Myghty serves as an excellent platform for developers to create custom web applications; it is the framework from which the Pylons (http://www.pylonshq.com) WSGI framework first evolved, and remains the primary template and caching engine used by Pylons. The MyghtyUtils container system, which powers Myghty's caching and session support, is used by Pylons, Turbogears, and others. Myghty is also used by itself as the web framework powering Bittorrent's website at http://www.bittorrent.com, a top- ranked and extremely high traffic website. Since its original release, Myghty has introduced many new concepts and features not found in Mason, including a rudimentary MVC framework, WSGI support, threading support and an open-ended rule-based URL resolution system. It receives favorable reviews for its ease of use, small footprint, quick and smooth operation, and great flexibility. It offers full Python scripting support within templates including a unique system of intermingling significant-whitespace-sensitive Python code with ordinary markup. Myghty also includes syntaxes that allow fine-grained control of whitespace, which makes it one of the best templating systems not just for HTML and markup but also for email generation and other whitespace-sensitive text formats. Myghty is easy to use within many popular web frameworks, including directly in any CherryPy or Turbogears application via the Buffet template adapter plugin, originally written for Myghty. Version 1.1 introduces a refactoring of Myghty's buffering and encoding internals to provide comprehensive support for Unicode and any character encoding combination - that is, full control over both the encoding of template files as well as the encoding of request output, including component- and programmatic configuration of encoding error handling. Myghty is released under the MIT License. Documentation, examples and download links can be found at: http://www.myghty.org Michael Bayer [EMAIL PROTECTED] PA HREF=http://www.myghty.org;Myghty 1.1/A - A high performance Python Server Page templating framework derived from HTML::Mason. (10-Sep-06) -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Problems with email.Generator.Generator
Hi All, The following piece of code is giving me issues: from email.Charset import Charset,QP from email.MIMEText import MIMEText charset = Charset('utf-8') charset.body_encoding = QP msg = MIMEText( u'Some text with chars that need encoding: \xa3', 'plain', ) msg.set_charset(charset) print msg.as_string() Under Python 2.4.2, this produces the following output, as I'd expect: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 Some text with chars that need encoding: =A3 However, under Python 2.4.3, I now get: Traceback (most recent call last): File test_encoding.py, line 14, in ? msg.as_string() File c:\python24\lib\email\Message.py, line 129, in as_string g.flatten(self, unixfrom=unixfrom) File c:\python24\lib\email\Generator.py, line 82, in flatten self._write(msg) File c:\python24\lib\email\Generator.py, line 113, in _write self._dispatch(msg) File c:\python24\lib\email\Generator.py, line 139, in _dispatch meth(msg) File c:\python24\lib\email\Generator.py, line 182, in _handle_text self._fp.write(payload) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 41: ordinal not in range(128) This seems to be as a result of this change: http://svn.python.org/view/python/branches/release24-maint/Lib/email/Generator.py?rev=42272r1=37910r2=42272 ...which is referred to as part of a fix for this bug: http://sourceforge.net/tracker/?func=detailaid=1409455group_id=5470atid=105470 Now, is this change to Generator.py in error or am I doing something wrong? If the latter, how can I change my code such that it works as I'd expect? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Is there a way to take a priori knowledge out of field definitions?
Hi, It is possible to build a system where the fields are self defining : - One way is to keep a dictionary of tags and descriptors, and to keep the data in a dictionary using the same tags as keys, with values - an oversimplified example: DefinitionDict = {1:'Quantity',2:'Price',3:'Value'} DataItemDict = {1:10,2:3.50,3:35.00} This is conceptually not much different to putting headers on columns in a database table or a spreadsheet, with the data item being a row, or to HT or XML. Now obviously the definitions need not be single valued strings, but could be multivalues, for use at different times, such as for gui displaying, for printing, etc, and could also hold type information, as most databases do. Up to this point, there is no a priori human knowledge mixed in with the data that has not been written down. However, when we want to make say a validation rule, such as Quantity times Price must equal Value, then we are using a priori knowledge about the data to formulate this. At this point, if a routine is written to check that DataItemDict[1] multiplied by DataItemDict[2] is indeed equal to DataItemDict[3], then we are casting the meanings into stone, and the flexibility of the structure is to a large extent lost. Now if I want to make a system where these sort of rules, as well as more complicated ones, are also definable - Is there a way to do it simply and cleanly - a way to expand the DefinitionDict so that it contains all of what we know about the structure and relationships of and between the items of data? It seems to me that if this could be done, then it could be used to dynamically generate the routines needed for validation, update, etc... But my brain strains when I try to think about how to do it... - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: PyPy with a smaller PVM for the full Python?
In [EMAIL PROTECTED], Casey Hawthorne wrote: Similarly, for JPython (which is at Python 2.2?), could one also use a lot smaller accompanying PVM with the JPython source code and JVM to use Python 2.5 in its entirety? Could you define small? I think the PVM is already quite small. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: super and __init__
Noah wrote: Am I the only one that finds the super function to be confusing? No, see for instance http://fuhm.net/super-harmful/ Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
import gtk RuntimeError: could not open display
Hi my script is working well when I am running it from the terminal window. While I am trying to start it as a Cron job, I am getting an Error described bellow: My configuration: Pentium III, Python 2.4.1, Fedora Core4 Thanks for your comments. Petr Jakes File /root/eric/analyza_dat_TPC/htmlgenerator.py, line 7, in ? from pylab import * File /usr/lib/python2.4/site-packages/pylab.py, line 1, in ? from matplotlib.pylab import * File /usr/lib/python2.4/site-packages/matplotlib/pylab.py, line 219, in ? new_figure_manager, draw_if_interactive, show = pylab_setup() File /usr/lib/python2.4/site-packages/matplotlib/backends/__init__.py, line 23, in pylab_setup globals(),locals(),[backend_name]) File /usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtkagg.py, line 10, in ? from backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File /usr/lib/python2.4/site-packages/matplotlib/backends/backend_gtk.py, line 7, in ? import gtk; gdk = gtk.gdk File /usr/lib/python2.4/__init__.py, line 37, in ? RuntimeError: could not open display -- http://mail.python.org/mailman/listinfo/python-list
Re: get the en of a program running in background
Thanks a lot. It does exactly what I expected and it's very simple oripel a écrit : Module 'subprocess' may be a better fit for you than fork+exec. Here's an example with a signal handler (1) use subprocess, don't fork and exec (2) maybe this will help: --- import signal, subprocess # define the signal handler def logsignal(signum, frame): print Caught signal # register the signal handler for SIGCHLD signal.signal(signal.SIGCHLD, logsignal) # run the subprocess in the background subprocess.Popen([sleep, 3]) # Do more stuff --- The signal handler will be called when the child process ends. Just register your own handler. You only need to register the handler once. If you need this for a single run only, or need different behavior for different subprocesses, have your signal handler re-register the old handler (see the docs for module 'signal'). A note about the example: if you run it as is, the parent process will end before the child process does. Add a call to 'os.wait()' to have it wait for the child. In your GUI you probably won't want it. Hope this helps. awalter1 wrote: Hi, I develop a graphical user interface (with pyGTK) where a click on a button shall launch a program P in background. I want to get the end of this program P but I don't want that my HMI be freezed while P is running. I try to use fork examplesI found on the web, but it seems to not run as expected. I am not familiar with these techniques in unix as well as python. But I suppose that my needs are usual, despite that I don't find anything on the web ... Is someone can give me a standard way to call a background program, wait its end, with an IHM still active ? Thank a lot for any idea. -- http://mail.python.org/mailman/listinfo/python-list
Ann: CoreBio 0.4
Announcing CoreBio 0.4 CoreBio home page: http://code.google.com/p/corebio/ Download: http://corebio.googlecode.com/svn/dist/CoreBio-0.4.1.tar.gz CoreBio is an open source python library for bioinformatics and computational biology, designed to be fast, compact, reliable and easy to use. Currently, CoreBio includes code to store and manipulate protein and DNA sequences, read and write many common biological sequence formats, read blast reports and access other computational and database resources. The CoreBio project welcomes additional suggestions, code and participants. This release includes the following modules: - data: Standard information used in computational biology. - matrix: Arrays indexed by alphabetic strings. - moremath: Various bits of useful math not in the standard python library. - resource: Access to programs, complex file formats and databases - astral: ASTRAL dataset IO. - scop: SCOP: Structural Classification of Proteins IO. - stride: STRIDE: Protein secondary structure assignment from atomic coordinates. - seq: Alphabetic sequences and associated tools and data. - seq_io: Sequence file reading and writing. - array_io: Read and write arrays of sequence data. - clustal_io: Read the CLUSTAL sequence file format. - fasta_io: Read and write FASTA format. - genbank_io: Read GenBank flat files. - intelligenetics_io: Read IntelliGenetics format. - msf_io: Read sequence information in MSF format. - nbrf_io: Sequence IO for NBRF/PIR format. - nexus_io: Read the sequence data from a nexus file. - null_io: Null sequence IO. - phylip_io: Read Sequences in interleaved Phylip format. - plain_io: Read and write raw, unformatted sequence data. - stockholm_io: Read a STOCKHOLM format. - table_io: Read tab delimited format. - ssearch_io: Parse sequence search analysis reports. - blastxml: Read BLAST XML output. - fasta: Read the output of a fasta similarity search. - transform: Transformations of Seqs (alphabetic sequences), including translation with a full suite of GeneticCode's. Gavin Crooks and John Gilman -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers ha scritto: Hi All, The following piece of code is giving me issues: from email.Charset import Charset,QP from email.MIMEText import MIMEText charset = Charset('utf-8') charset.body_encoding = QP msg = MIMEText( u'Some text with chars that need encoding: \xa3', 'plain', ) msg.set_charset(charset) print msg.as_string() Under Python 2.4.2, this produces the following output, as I'd expect: [...] However, under Python 2.4.3, I now get: Try with: msg = MIMEText( u'Some text with chars that need encoding: \xa3', _charset='utf-8', ) and you will obtain the error: Traceback (most recent call last): File pyshell#4, line 3, in -toplevel- _charset='utf-8', File C:\Python2.4\lib\email\MIMEText.py, line 28, in __init__ self.set_payload(_text, _charset) File C:\Python2.4\lib\email\Message.py, line 218, in set_payload self.set_charset(charset) File C:\Python2.4\lib\email\Message.py, line 260, in set_charset self._payload = charset.body_encode(self._payload) File C:\Python2.4\lib\email\Charset.py, line 366, in body_encode return email.base64MIME.body_encode(s) File C:\Python2.4\lib\email\base64MIME.py, line 136, in encode enc = b2a_base64(s[i:i + max_unencoded]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 41: ordinal not in range(128) Regards Manlio Perillo -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL cannot open TIFF image in Windows
Rob Williscroft wrote: I downloaded some test images from: url:http://www.remotesensing.org/libtiff/images.html I do the same and modified your code for try FreeImagePy and the results are: ok: 41 error: 20 total: 61 Better than PIL, but a lot of problems with lower-rgb-planar- 8 and flower-rgb-contig- 8 IrfanView seem that can load all the images... Rob. Bye, Michele -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Manlio Perillo wrote: Try with: msg = MIMEText( u'Some text with chars that need encoding: \xa3', _charset='utf-8', ) and you will obtain the error: Traceback (most recent call last): File pyshell#4, line 3, in -toplevel- _charset='utf-8', File C:\Python2.4\lib\email\MIMEText.py, line 28, in __init__ self.set_payload(_text, _charset) File C:\Python2.4\lib\email\Message.py, line 218, in set_payload self.set_charset(charset) File C:\Python2.4\lib\email\Message.py, line 260, in set_charset self._payload = charset.body_encode(self._payload) File C:\Python2.4\lib\email\Charset.py, line 366, in body_encode return email.base64MIME.body_encode(s) File C:\Python2.4\lib\email\base64MIME.py, line 136, in encode enc = b2a_base64(s[i:i + max_unencoded]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 41: ordinal not in range(128) OK, but I fail to see how replacing one unicode error with another is any help... :-S Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
[EMAIL PROTECTED] wrote: I think an explanation of how Sqlite3 differs from SQL and a better set of examples is still warranted. In general, Python standard library modules that are wrappers for third party libraries are very thinly documented, and they should probably remain that way, because it's really too much of a burden on the Python developers to develop this documentation and keep it up to date. The idea is to document the wrapper, not the wrapped library. If I had a choice concerning these wrapper libraries, I'd much rather see more docs on the tkinter and xml libraries. There you need to guess a lot. There is no shortage of Tcl/Tk docs, but it doesn't look the same within Python. For the Python xml libraries, I've had to experiment a lot, and I have this nagging feeling that I don't do things the way I should. (From Python 2.5, we have ElementTree, which is much better from this perspective, but we've just started using 2.4 at work, and we try to keep the amount of third party libraries to a minimum here.) It seems to me that the sqlite3 module is fairly decent in this regard, particularly since it's not even included in a completed Python release yet. Concerning the API, I'm surprised to see magic method naming such as __conform__ introduced in a library like that. It seems to me that this is a violation of PEP 8. I'm sure there are further details that could be worth mentioning in the docs, but I think it's important that we don't try to duplicate the SQLite docs in the Python docs. -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] RuPy 2007 - Python Ruby Conference
Jakub Piotr Nowak wrote: RuPy 2007 Python Ruby Conference Poznan, Poland April 7-8, 2007 Are you aware of the EuroPython Conference which will take place in Vilnius three months later? -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to take a priori knowledge out of field definitions?
Hendrik van Rooyen wrote: Hi, It is possible to build a system where the fields are self defining : - One way is to keep a dictionary of tags and descriptors, and to keep the data in a dictionary using the same tags as keys, with values - an oversimplified example: DefinitionDict = {1:'Quantity',2:'Price',3:'Value'} DataItemDict = {1:10,2:3.50,3:35.00} This is conceptually not much different to putting headers on columns in a database table or a spreadsheet, with the data item being a row, or to HT or XML. Now obviously the definitions need not be single valued strings, but could be multivalues, for use at different times, such as for gui displaying, for printing, etc, and could also hold type information, as most databases do. Up to this point, there is no a priori human knowledge mixed in with the data that has not been written down. However, when we want to make say a validation rule, such as Quantity times Price must equal Value, then we are using a priori knowledge about the data to formulate this. At this point, if a routine is written to check that DataItemDict[1] multiplied by DataItemDict[2] is indeed equal to DataItemDict[3], then we are casting the meanings into stone, and the flexibility of the structure is to a large extent lost. Now if I want to make a system where these sort of rules, as well as more complicated ones, are also definable - Is there a way to do it simply and cleanly - a way to expand the DefinitionDict so that it contains all of what we know about the structure and relationships of and between the items of data? Looks a lot like a RDBMS... It seems to me that if this could be done, then it could be used to dynamically generate the routines needed for validation, update, etc... But my brain strains when I try to think about how to do it... You may want to have a look at the descriptor protocol and packages like traits and FormEncode. -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with ctypes pointer return values
Lawrence Oluyede wrote: [EMAIL PROTECTED] wrote: Does anyone have a good idea how I should define recordList so that I can retrieve the record pointers? POINTER(POINTER(c_void)) ? Maybe I misunderstood tough... That's interesting. It had not occurred to me that you could do that. And I also read that you can index pointers with pointer[x], so I think that will do the trick. Thanks for the pointer groan. I'll give it a try ASAP. The Cog. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to take a priori knowledge out of field definitions?
Hendrik van Rooyen wrote: Hi, It is possible to build a system where the fields are self defining : - One way is to keep a dictionary of tags and descriptors, and to keep the data in a dictionary using the same tags as keys, with values - an oversimplified example: DefinitionDict = {1:'Quantity',2:'Price',3:'Value'} DataItemDict = {1:10,2:3.50,3:35.00} This is conceptually not much different to putting headers on columns in a database table or a spreadsheet, with the data item being a row, or to HT or XML. Now obviously the definitions need not be single valued strings, but could be multivalues, for use at different times, such as for gui displaying, for printing, etc, and could also hold type information, as most databases do. Up to this point, there is no a priori human knowledge mixed in with the data that has not been written down. However, when we want to make say a validation rule, such as Quantity times Price must equal Value, then we are using a priori knowledge about the data to formulate this. At this point, if a routine is written to check that DataItemDict[1] multiplied by DataItemDict[2] is indeed equal to DataItemDict[3], then we are casting the meanings into stone, and the flexibility of the structure is to a large extent lost. Now if I want to make a system where these sort of rules, as well as more complicated ones, are also definable - Is there a way to do it simply and cleanly - a way to expand the DefinitionDict so that it contains all of what we know about the structure and relationships of and between the items of data? It seems to me that if this could be done, then it could be used to dynamically generate the routines needed for validation, update, etc... But my brain strains when I try to think about how to do it... You need to look at properties. The property() function allows you to define methods that are called (and which can therefore perform access control and/or semantic checks) when attributes are accessed. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: RuPy 2007 - Python Ruby Conference
Magnus Lycka wrote: Jakub Piotr Nowak wrote: RuPy 2007 Python Ruby Conference Poznan, Poland April 7-8, 2007 Are you aware of the EuroPython Conference which will take place in Vilnius three months later? If I understand the intention right its kind of a peace pipe cross-community conference. This is somewhat uncommon these days regarding language community tribalism. So what to do if one has to polite to each other? As a joint enemy Java might be appropriate? -- http://mail.python.org/mailman/listinfo/python-list
Re: egg and modpython
Bruno Desthuilliers wrote: Wensheng a écrit : I installed pysqlite2 using easy_install. and got this when using it from modpython: -- Mod_python error: PythonHandler etc.modpython [...] I applaud you for studying the traceback in more depth than I can find the motivation for, Bruno. ;-) However, this looks like a program using some package installed by setuptools/easy_install needs to unpack that package when running. ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/var/www/.python-eggs' And this wants to happen apparently in the home directory of the Web server user, whose rights may be somewhat limited. Or perhaps one has to initialise setuptools for any particular user by running it first as that user: something that isn't a particularly common thing to do with non-interactive users on UNIX-like systems. [...] Can peak developers fix this please? Why should they fix something that's 1/ documented - http://peak.telecommunity.com/DevCenter/EggFormats#zip-file-issues The Internal Structure of Python Eggs / STOP! This is not the first document you should read! A case of Beware of the Leopard perhaps? 2/ not a an egg specific issue In my experience, most other package managers actually unpack their resources when invoked, rather than leaving the programs to attempt such things when running. Debian packages even compile the bytecode files to ensure that nothing tries (and fails) to write them to privileged locations afterwards. 3/ really just a configuration/permission problem Which should have been solved when the package manager was invoked, especially since this was most likely done as root. [...] in the mean time, I just have to use old download, unzip/untar python setup.py install way. No - you have to read the manual and fix you configuration. FWIW, the above traceback gives far enough clues (it's even written in all letters). The various ways to deal with this include running easy_install as the Web server user so that it can touch the directory and whatever else it needs, and perhaps to set up various permissions - something you wouldn't usually do; running easy_install with the --always-unzip flag when installing the package as root; using python setup.py install as usual. This situation looks either a lot like a use case whose popularity has been underestimated by the developers - intriguing given the number of people supposedly using setuptools for their Web application deployments - or a packaging mistake with the pysqlite2 .egg file. Either way, system packages rarely suffer from this kind of problem, and it's quite understandable (and justifiable) to consider this bad behaviour. Or you may read easy_install's doc to avoid installing zipped eggs: http://peak.telecommunity.com/DevCenter/EasyInstall#compressed-installation Perhaps the developers should reverse their defaults and emulate the usual behaviour of package managers, unfashionable as that may seem. Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: What algorithm does Python use to evaluate: if substring in string
Tor Erik wrote: I would be surprised if it is the naive: 2.4 and earlier uses that algorithm (but with a better implementation). And naive isn't really the right word here; on average, a brute force search is pretty good for the find/index/in use case. Most fancy algorithms ignore the setup costs and other overhead, which works well in theory, but not that well in practice. /F -- http://mail.python.org/mailman/listinfo/python-list
efficient text file search.
Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' ? BTW: does for line in f: read a block of line to te memory or is it simply calls f.readline() many times? thanks amit -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' yes, more efficient would be: grep (http://www.gnu.org/software/grep/) -- http://mail.python.org/mailman/listinfo/python-list
Re: Ann: CoreBio 0.4
On 11 Sep 2006 00:59:30 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Announcing CoreBio 0.4 CoreBio home page: http://code.google.com/p/corebio/ Download: http://corebio.googlecode.com/svn/dist/CoreBio-0.4.1.tar.gz CoreBio is an open source python library for bioinformatics and computational biology, designed to be fast, compact, reliable and easy to use. Currently, CoreBio includes code to store and manipulate protein and DNA sequences, read and write many common biological sequence formats, read blast reports and access other computational and database resources. The CoreBio project welcomes additional suggestions, code and participants. This release includes the following modules: - data: Standard information used in computational biology. - matrix: Arrays indexed by alphabetic strings. - moremath: Various bits of useful math not in the standard python library. - resource: Access to programs, complex file formats and databases - astral: ASTRAL dataset IO. - scop: SCOP: Structural Classification of Proteins IO. - stride: STRIDE: Protein secondary structure assignment from atomic coordinates. - seq: Alphabetic sequences and associated tools and data. - seq_io: Sequence file reading and writing. - array_io: Read and write arrays of sequence data. - clustal_io: Read the CLUSTAL sequence file format. - fasta_io: Read and write FASTA format. - genbank_io: Read GenBank flat files. - intelligenetics_io: Read IntelliGenetics format. - msf_io: Read sequence information in MSF format. - nbrf_io: Sequence IO for NBRF/PIR format. - nexus_io: Read the sequence data from a nexus file. - null_io: Null sequence IO. - phylip_io: Read Sequences in interleaved Phylip format. - plain_io: Read and write raw, unformatted sequence data. - stockholm_io: Read a STOCKHOLM format. - table_io: Read tab delimited format. - ssearch_io: Parse sequence search analysis reports. - blastxml: Read BLAST XML output. - fasta: Read the output of a fasta similarity search. - transform: Transformations of Seqs (alphabetic sequences), including translation with a full suite of GeneticCode's. Gavin Crooks and John Gilman -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Ann: CoreBio 0.4
Hi,why are u reinventing the wheel when Biopython[1] is already existing ? is there any specific reason u wanted to develop this CoreBio ? why dont u just extend the existing BioPython package itself ?regards,KM [1]http://biopython.org---On 9/11/06, km [EMAIL PROTECTED] wrote:On 11 Sep 2006 00:59:30 -0700, [EMAIL PROTECTED][EMAIL PROTECTED] wrote: Announcing CoreBio 0.4 CoreBio home page: http://code.google.com/p/corebio/ Download: http://corebio.googlecode.com/svn/dist/CoreBio-0.4.1.tar.gz CoreBio is an open source python library for bioinformatics and computational biology, designed to be fast, compact, reliable and easy to use. Currently, CoreBio includes code to store and manipulate protein and DNA sequences, read and write many common biological sequence formats, read blast reports and access other computational and database resources. The CoreBio project welcomes additional suggestions, code and participants. This release includes the following modules: - data: Standard information used in computational biology. - matrix: Arrays indexed by alphabetic strings. - moremath: Various bits of useful math not in the standard python library. - resource: Access to programs, complex file formats and databases - astral: ASTRAL dataset IO. - scop: SCOP: Structural Classification of Proteins IO. - stride: STRIDE: Protein secondary structure assignment from atomic coordinates. - seq: Alphabetic sequences and associated tools and data. - seq_io: Sequence file reading and writing. - array_io: Read and write arrays of sequence data. - clustal_io: Read the CLUSTAL sequence file format. - fasta_io: Read and write FASTA format. - genbank_io: Read GenBank flat files. - intelligenetics_io: Read IntelliGenetics format. - msf_io: Read sequence information in MSF format. - nbrf_io: Sequence IO for NBRF/PIR format. - nexus_io: Read the sequence data from a nexus file. - null_io: Null sequence IO. - phylip_io: Read Sequences in interleaved Phylip format. - plain_io: Read and write raw, unformatted sequence data. - stockholm_io: Read a STOCKHOLM format. - table_io: Readtab delimited format. - ssearch_io: Parse sequence search analysis reports. - blastxml: Read BLAST XML output. - fasta: Read the output of a fasta similarity search. - transform: Transformations of Seqs (alphabetic sequences), including translation with a full suite of GeneticCode's. Gavin Crooks and John Gilman -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
:) via python... Luuk wrote: noro [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' yes, more efficient would be: grep (http://www.gnu.org/software/grep/) -- http://mail.python.org/mailman/listinfo/python-list
strange DOM behaviour when using minidom
Hello, I have a really strange problem. I'm unable to figure it out on my own. I parse very simple xml documents, without any check for their form. These files look very similar and are encoded in UTF-8. Now minidom is always able to parse these files with minidom.parse(file) . Now when fetching I use this expression: xmldoc.getElementsByTagName('DocNumb')[0].firstChild.data.encode('latin1') (I know it's not beautiful but convenient. ) It always work, but sometimes it simply fails to fetch any element. Redoing it from hand in the python console with the same file always works. I have no idea what the error is. I compared working and not working files with the hex editor. I couldn't find any significant change. It's too strange. If anybody has any clue, hint or anything, please let me know. Regards, Jonatan -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
Dick Moores wrote: At 06:30 PM 9/10/2006, Kent Johnson wrote: Dick Moores wrote: Also, why do you use TextPad instead of IDLE? You're kidding, right? No. Tell me, please. Macros? Comparing files? What else? OK...please, no one interpret this as IDLE bashing or attempt to show me a better way. I'm happy with TextPad and just writing this because I was asked... In my opinion: - Most of my Python work is actually in Jython. I can run a Jython program with a tool in TP. Actually I have separate tools for each active project that set the correct working directory and invoke a batch file with the right jars. Can't do that in IDLE. - TextPad is a good general-purpose editor, not just for Python. All the following reasons really come under this heading. I have an editor I like, it works great for Python, there is really no reason to use IDLE. - Fast and powerful multi-file search (easily specify the directory and file types to search) - Syntax highlighting for XML, HTML, Velocity templates, Ruby, Java, JavaScript, R, SQL, CSS...all file types I use more or less frequently. - Word wrap - Show invisibles - Customizable with macros and external tools - Open as binary etc... Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] :) via python... Luuk wrote: noro [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' yes, more efficient would be: grep (http://www.gnu.org/software/grep/) ok, a more serious answer: some googling turned op the following. Second paragraph of chapter 14 of http://www.amk.ca/python/2.1/ a.. The speed of line-oriented file I/O has been improved because people often complain about its lack of speed, and because it's often been used as a naïve benchmark. The readline() method of file objects has therefore been rewritten to be much faster. The exact amount of the speedup will vary from platform to platform depending on how slow the C library's getc() was, but is around 66%, and potentially much faster on some particular operating systems. Tim Peters did much of the benchmarking and coding for this change, motivated by a discussion in comp.lang.python. A new module and method for file objects was also added, contributed by Jeff Epler. The new method, xreadlines(), is similar to the existing xrange() built-in. xreadlines() returns an opaque sequence object that only supports being iterated over, reading a line on every iteration but not reading the entire file into memory as the existing readlines() method does. You'd use it like this: for line in sys.stdin.xreadlines(): # ... do something for each line ... ... For a fuller discussion of the line I/O changes, see the python-dev summary for January 1-15, 2001 at http://www.amk.ca/python/dev/2001-01-1.html. -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro wrote: Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' Probably better to read the whole file at once if it isn't too big: f = file('somefile') data = f.read() if 'string' in data: print 'FOUND' -- http://mail.python.org/mailman/listinfo/python-list
Re: get the en of a program running in background
Hi, It works when a click on a button launches a program P. Now, I want that a click on another button launches another program P' In this case there is only one signal for two events : the end of P and the end of P'. How can distinct the two cases. In addition, what is the use of the frame parameter of the logsignal procedure ? It seems to be a little bit complicated to manipulate it. Thank for your help oripel a écrit : Module 'subprocess' may be a better fit for you than fork+exec. Here's an example with a signal handler (1) use subprocess, don't fork and exec (2) maybe this will help: --- import signal, subprocess # define the signal handler def logsignal(signum, frame): print Caught signal # register the signal handler for SIGCHLD signal.signal(signal.SIGCHLD, logsignal) # run the subprocess in the background subprocess.Popen([sleep, 3]) # Do more stuff --- The signal handler will be called when the child process ends. Just register your own handler. You only need to register the handler once. If you need this for a single run only, or need different behavior for different subprocesses, have your signal handler re-register the old handler (see the docs for module 'signal'). A note about the example: if you run it as is, the parent process will end before the child process does. Add a call to 'os.wait()' to have it wait for the child. In your GUI you probably won't want it. Hope this helps. awalter1 wrote: Hi, I develop a graphical user interface (with pyGTK) where a click on a button shall launch a program P in background. I want to get the end of this program P but I don't want that my HMI be freezed while P is running. I try to use fork examplesI found on the web, but it seems to not run as expected. I am not familiar with these techniques in unix as well as python. But I suppose that my needs are usual, despite that I don't find anything on the web ... Is someone can give me a standard way to call a background program, wait its end, with an IHM still active ? Thank a lot for any idea. -- http://mail.python.org/mailman/listinfo/python-list
Re: strange DOM behaviour when using minidom
Sorry, I just found the error. Simple an empty attribute. Python showed me strange row numbers. I used a multi line initialization of a dict. The error always appeared on the first line although I was on an other line. Interesting behavior. Jonatan JoReiners schrieb: Hello, I have a really strange problem. I'm unable to figure it out on my own. I parse very simple xml documents, without any check for their form. These files look very similar and are encoded in UTF-8. Now minidom is always able to parse these files with minidom.parse(file) . Now when fetching I use this expression: xmldoc.getElementsByTagName('DocNumb')[0].firstChild.data.encode('latin1') (I know it's not beautiful but convenient. ) It always work, but sometimes it simply fails to fetch any element. Redoing it from hand in the python console with the same file always works. I have no idea what the error is. I compared working and not working files with the hex editor. I couldn't find any significant change. It's too strange. If anybody has any clue, hint or anything, please let me know. Regards, Jonatan -- http://mail.python.org/mailman/listinfo/python-list
extracting substrings from a file
Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? Many thanks in advance Sofia -- http://mail.python.org/mailman/listinfo/python-list
A cross platform systray icon
Does anyone have some hints / tips / experience with making a cross platform systray icon? It should work on Windows, Gnome and KDE at minimum. I've seen the win32all code which is very similar to the C code I've written before for Windows. It would be a small irritation to have to integrate its event loop with whichever GUI framework I'm using for the rest of it though. I don't know how to make a systray under KDE/Gnome though, but I think freedesktop has made it a lot easier now. I didn't manage to find a python example - does anyone have one? Ideally I'd like someone to tell me that PyQT, tkinter or PyGTK does it all for me, but from my searching on the subject I doubt it is going to be that easy! Thanks -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
inserting into a file
I want to insert a string in a file after a particular line. I thought of using seek() function but on opening the file in append mode the seek value is undone. One crude idea i had was to read the file in a list and insert the string correspondingly. Is there any other way to do this? Please help... Sai krishna M -- I love Freedom -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)
[EMAIL PROTECTED] wrote: Bruno Desthuilliers wrote: [EMAIL PROTECTED] wrote: Probably just me. I've only been using Access and SQL Server for 12 years, so I'm sure my opinions don't count for anything. SQLite never pretended to be a full-blown RDBMS - just a lightweight simple embedded database as SQL-compliant as possible. Ah, *you* haven't read the documentation either! I use SQLite and PgSQL (and, alas, MySQL) on a daily basis. So I've *of course* read the doc (and frequently re-read it). as SQL-compliant as possible? Yes. And yes, I know about the typing issue. If you want to make sure you can migrate your data to a real RDBMS, then it's up to you to take appropriate precautions (FormEncode can be a real helper here...). This (documented enough) issue apart, we have far less troubles with SQLite than we have with MySQL, on both the dev and admin sides. And FWIW, insulting peoples won't buy you much. (snip useless rant again) -- bruno desthuilliers python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')]) -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro wrote: Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' ? BTW: does for line in f: read a block of line to te memory or is it simply calls f.readline() many times? thanks amit If your file is sorted by some key in the data, you can build a very fast binary search with mmap in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro wrote: Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' break ^^^ Add a 'break' after the print statement - that way you won't have to read the entire file unless the string isn't there. That's probably not the sort of advice you're after though :-) Can't see why reading the entire file in as the other poster suggested would help, and seeing as for line in f: is now regarded as the pythonic way of working with lines of text in a file, then I'd assume that the implementation would be at least as fast as for line in f.xreadlines(): -- http://mail.python.org/mailman/listinfo/python-list
Re: Can I make unicode in a repr() print readably?
Martin v. Löwis wrote: Terry Hancock schrieb: Or, put another way, what exactly does 'print' do when it gets a class instance to print? It seems to do the right thing if given a unicode or string object, but I cant' figure out how to make it do the same thing for a class instance. It won't. PyFile_WriteObject checks for Unicode objects, and whether the file has an encoding attribute set, and if so, encodes the Unicode object. If it is not a Unicode object, it falls through to PyObject_Print, which first checks for the tp_print slot (which can't be set in Python), then uses PyObject_Str (which requires that the __str__ result is a true byte string), or PyObject_Repr (if the RAW flag isn't set - it is when printing). PyObject_Str first checks for tp_str; if that isn't set, it falls back to PyObject_Repr. You can save some typing, of course, with a helper function: def p(o): print unicode(o) Yeah, that's what I've done as it stands. I think it's actually fewer keystrokes that way, but it is still inconsistent* with other objects, of course. I agree that this is not optimal; contributions are welcome. It would probably be easiest to drop the guarantee that PyObject_Str returns a true string, or use _PyObject_Str (which does not make this guarantee) in PyObject_Print. One would have to think what the effect on backwards compatibility is of such a change. Ah, contribute to Python itself. I'll have to think about it -- I don't do a lot of C programming these days, but it sounds like an idea. I don't know about the backwards compatibility issue. I'm not sure what would be affected. But print frequently generates encoded Unicode output if the stream supports it, so there is no guarantee whether it produces unicode or string output now. I think it's clear that str() *must* return an ordinary Python string. I think what would make sense is for the print statement to attempt to call __unicode__ on an instance before attempting to call __str__ (just as it currently falls back from __str__ to __repr__). That seems like it would be pretty consistent, right? Cheers, Terry *Okay, actually it is perfectly consistent in a technical sense, but not in the utility, this is what you do to examine the object, sense. -- Terry Hancock ([EMAIL PROTECTED]) Anansi Spaceworks http://www.AnansiSpaceworks.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for the Perfect Editor
If you have those requirements installed, it does not need anything else. mystilleef wrote: I recommend Scribes. http://scribes.sf.net Flash Demo: http://scribes.sf.net/snippets.htm GIF Demo: http://www.minds.may.ie/~dez/images/blog/scribes.html Omar wrote: I'd love the perfect editor that would be: a) free b) enable me to drag and drop code snippets from a sort of browser into the code c) can run programs right from within d) can edit - PYTHON - Javascript - HTML - actionscript (since I'm also learning flash) e) easy to learn suggestions? -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a file
Sai Krishna M wrote: One crude idea i had was to read the file in a list and insert the string correspondingly. file systems usually don't support insertion and deletion, so if you want to move things around, you have to do that yourself. reading and writing lists (using readlines/writelines) works well, as long as the files aren't too large. Is there any other way to do this? not with plain files. if you need to do lots of inserts/deletes, you should probably use a database manager instead (which uses more elaborate data structures on disk). see e.g. the dbm and bsddb modules in the standard library. /F -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: The following piece of code is giving me issues: from email.Charset import Charset,QP from email.MIMEText import MIMEText charset = Charset('utf-8') charset.body_encoding = QP msg = MIMEText( u'Some text with chars that need encoding: \xa3', 'plain', ) msg.set_charset(charset) print msg.as_string() Under Python 2.4.2, this produces the following output, as I'd expect: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 Some text with chars that need encoding: =A3 However, under Python 2.4.3, I now get: Traceback (most recent call last): File test_encoding.py, line 14, in ? msg.as_string() File c:\python24\lib\email\Message.py, line 129, in as_string g.flatten(self, unixfrom=unixfrom) File c:\python24\lib\email\Generator.py, line 82, in flatten self._write(msg) File c:\python24\lib\email\Generator.py, line 113, in _write self._dispatch(msg) File c:\python24\lib\email\Generator.py, line 139, in _dispatch meth(msg) File c:\python24\lib\email\Generator.py, line 182, in _handle_text self._fp.write(payload) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 41: ordinal not in range(128) This seems to be as a result of this change: http://svn.python.org/view/python/branches/release24-maint/Lib/email/Generator.py?rev=42272r1=37910r2=42272 ...which is referred to as part of a fix for this bug: http://sourceforge.net/tracker/?func=detailaid=1409455group_id=5470atid=105470 Now, is this change to Generator.py in error or am I doing something wrong? I'm not familiar enough with the email package to answer that. If the latter, how can I change my code such that it works as I'd expect? email.Generator and email.Message use cStringIO.StringIO internally, which can't cope with unicode. A quick fix might be to monkey-patch: from StringIO import StringIO from email import Generator, Message Generator.StringIO = Message.StringIO = StringIO # your code here Peter -- http://mail.python.org/mailman/listinfo/python-list
best small database?
I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
checkout gadfly database.regards,KMOn 9/11/06, David Isaac [EMAIL PROTECTED] wrote: I have no experience with database applications.This database will likely hold only a few hundred items,including both textfiles and binary files.I would like a pure Python solution to the extent reasonable. Suggestions?Thank you,Alan Isaac--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting substrings from a file
I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? The following seems to do it for me... outfile = file('out.txt', 'w') for line in file('in.txt'): if '/GEN' in line and '/gb:' in line: newline = [] for index, item in enumerate(line.split()): if index == 0 or item.startswith('/GEN') or item.startswith('/gb:'): newline.append(item) outfile.write('\t'.join(newline)) outfile.write('\n') outfile.close() There are some underdefined conditions...I presume that both the GEN and gb: have to appear in the line. If only one of them is required, change the and to an or. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
buzhug is a nice one: http://buzhug.sourceforge.net/ (not sure about binaries, though).greetingsAndreOn 9/11/06, km [EMAIL PROTECTED] wrote: checkout gadfly database.regards,KMOn 9/11/06, David Isaac [EMAIL PROTECTED] wrote: I have no experience with database applications.This database will likely hold only a few hundred items,including both textfiles and binary files.I would like a pure Python solution to the extent reasonable. Suggestions?Thank you,Alan Isaac--http://mail.python.org/mailman/listinfo/python-list --http://mail.python.org/mailman/listinfo/python-list -- Dr. Andre P. Meyerhttp://python.openspace.nl/meyerTNO Defence, Security and Safety http://www.tno.nl/Delft Cooperation on Intelligent Systemshttp://www.decis.nl/Ah, this is obviously some strange usage of the word 'safe' that I wasn't previously aware of. - Douglas Adams -- http://mail.python.org/mailman/listinfo/python-list
Re: win32service (wxpython) -- i cannot install service
I believe you misunderstand services. They don't have user interfaces (UIs) like other programs. They run without any UI as background processes that are in basically in an infinite loop but with a way to break out of the loop (stop service). If you wish to have a background service that has some sort of control UI, you need to write it as two parts. The service and a UI that communicates with the service either through a shared file, pipe, or socket server/ client interface. You should pick up a copy of Python Programming on Win32 which is an excellent reference book for writing Windows services. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting substrings from a file
[EMAIL PROTECTED] wrote: Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? Many thanks in advance Sofia Here's my first iteration: C:\junktype sofia.py prefixes = ['/GEN=', '/gb:'] def extract(fname): f = open(fname, 'r') chunks = [[]] for line in f: words = line.split() if words: chunks[-1].extend(words) else: chunks.append([]) for chunk in chunks: if not chunk: continue output = [chunk[0]] for word in chunk: for prefix in prefixes: if word.startswith(prefix): output.append(word) break print ' '.join(output) if __name__ == __main__: import sys extract(sys.argv[1]) C:\junksofia.py sofia.txt AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 /gb:BC009007.1 Before I fix the duplicate in the first line, you need to say whether you really want the /gb:BC009007.1 in the second line thrown away -- IOW, what's the rule? For each prefix, either (1) get the first word that starts with that prefix or (2) get all unique such words. You choose. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list
Re: Refactoring Dilemma
Kamilche wrote: Is there any reason NOT to do this that I may be unaware of? [snip] # --- Module 2.py # 'Self' module processing import sys var = 0 self = sys.modules[__name__] def MyRoutine(): self.var = 1 MyRoutine() print var Looks basically fine to me, but I'd probably write it as:: _self = __import__(__name__) Then you don't need to import sys. I'd also use a leading underscore for self so that it's clearly marked as a module-internal attribute. STeVe -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
* David Isaac (2006-09-11 14:23 +0100) I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Gadfly? -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting substrings from a file
[EMAIL PROTECTED] wrote: Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? Many thanks in advance Sofia What have your tried so far? Hint: split line on spaces, the first pieces is the first item you want, then iterate over the pieces looking for the /GEN and /gb: pieces that you are interested in keeping. I am assuming that /GEN= and /gb: data doesn't have any spaces in them. If they do, you will need to use regular expressions instead of split. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: inserting into a file
Sai Krishna M wrote: I want to insert a string in a file after a particular line. I thought of using seek() function but on opening the file in append mode the seek value is undone. One crude idea i had was to read the file in a list and insert the string correspondingly. Is there any other way to do this? Please help... Sai krishna M No magic way to insert lines. If file is small, read into memory, insert line, write to disk. If it is large, read and write lines to secondary file, insert line, read remaining lines, delete old file and rename to new file. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on handhelds
Paul Rubin http://[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Nick [EMAIL PROTECTED] writes: I have never programmed in Python a day in my life. My group is working on developing an application on the Dell Axim hand held that has a tight deadline. I have heard that Python is particularly advantageous in rapid prototyping and deployment. I would like to lean this way if I can. Does anyone know if I can run Python on the Dell Axim handheld. It runs Windows CE. If so, what all is needed to make this possible. Someone did a WinCE port a while back, but I don't think it's actively used much. The approach might be reasonable if you're an expert with some time on your hands, but for a newcomer with an onrushing deadline, you may be better off using whatever you're already using (VB or whatever), and keeping Python in mind for some future project. I agree that it is much less active than Python on other platforms, and in some areas it lags behind the PC, e.g. in GUI toolkits. However, if you want to try it go here: http://sourceforge.net/projects/pythonce See also the mailing list: http://mail.python.org/mailman/listinfo/pythonce Luke Dunstan -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
Luuk wrote: [snip] some googling turned op the following. Second paragraph of chapter 14 of http://www.amk.ca/python/2.1/ [snip] For a fuller discussion of the line I/O changes, see the python-dev summary for January 1-15, 2001 at http://www.amk.ca/python/dev/2001-01-1.html. That is *HISTORY*. That is Python 2.1. That is the year 2001. xreadlines is as dead as a dodo. -- http://mail.python.org/mailman/listinfo/python-list
Re: get the en of a program running in background
It works when a click on a button launches a program P. Now, I want that a click on another button launches another program P' In this case there is only one signal for two events : the end of P and the end of P'. How can distinct the two cases. Remember the PIDs of the forked procesess and in your signal handler use os.wait() to see which one has died. BTW os.wait() can work in non-blocking mode . -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting substrings from a file
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Here's a pyparsing solution that will address your immediate question, and also gives you some leeway for adding other / options to your search. Pyparsing's home page is at pyparsing.wikispaces.com. -- Paul data = AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 from pyparsing import * # create expression we are looking for: # name [ junk word... ] /qualifier... name = Word(alphanums,printables).setResultsName(name) junkWord = ~(Literal(/)) + Word(printables) qualifier = (/ + Word(alphas+_-.).setResultsName(key) + \ oneOf(= :) + \ Word(printables).setResultsName(value)) expr = name + ZeroOrMore(junkWord) + \ Dict(ZeroOrMore(qualifier)).setResultsName(quals) # use parse action to repackage qualifier data to support dict-like # access to qualifiers qualifier.setParseAction( lambda t: (t.key,.join(t)) ) # use this parse action instead if you just want whatever is # after the '=' or ':' delimiter in the qualifier # qualifier.setParseAction( lambda t: (t.key,t.value) ) # parse data strings, showing returned data structure # (just to show what pyparsing results structure looks like) for d in data.split(\n\n): res = expr.parseString(d) print res.dump() print print # now just do what the OP wanted in the first place for d in data.split(\n\n): res = expr.parseString(d) print res.name, res.quals[gb], res.quals[GEN] Gives these results: ['AFFX-BioB-5_at', 'E.', 'coli', [('GEN', '/GEN=bioB'), ('gb', '/gb:J04423.1')]] - name: AFFX-BioB-5_at - quals: [('GEN', '/GEN=bioB'), ('gb', '/gb:J04423.1')] - GEN: /GEN=bioB - gb: /gb:J04423.1 ['1415785_a_at', [('gb', '/gb:NM_009840.1'), ('DB_XREF', '/DB_XREF=gi:6753327'), ('GEN', '/GEN=Cct8'), ('FEA', '/FEA=FLmRNA'), ('CNT', '/CNT=482'), ('TID', '/TID=Mm.17989.1'), ('TIER', '/TIER=FL+Stack'), ('STK', '/STK=281'), ('UG', '/UG=Mm.17989'), ('LL', '/LL=12469'), ('DEF', '/DEF=Mus')]] - name: 1415785_a_at - quals: [('gb', '/gb:NM_009840.1'), ('DB_XREF', '/DB_XREF=gi:6753327'), ('GEN', '/GEN=Cct8'), ('FEA', '/FEA=FLmRNA'), ('CNT', '/CNT=482'), ('TID', '/TID=Mm.17989.1'), ('TIER', '/TIER=FL+Stack'), ('STK', '/STK=281'), ('UG', '/UG=Mm.17989'), ('LL', '/LL=12469'), ('DEF', '/DEF=Mus')] - CNT: /CNT=482 - DB_XREF: /DB_XREF=gi:6753327 - DEF: /DEF=Mus - FEA: /FEA=FLmRNA - GEN: /GEN=Cct8 - LL: /LL=12469 - STK: /STK=281 - TID: /TID=Mm.17989.1 - TIER: /TIER=FL+Stack - UG: /UG=Mm.17989 - gb: /gb:NM_009840.1 AFFX-BioB-5_at /gb:J04423.1 /GEN=bioB 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
David Isaac wrote: I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? Thank you, Alan Isaac If they are files, just use the filesyatem, you don't need a database. If you need multiple indexes into these files, then use a database, but only for the indexes that point to the files on the filesystem. The filesystem is almost always the most efficient place to store files, not as blobs in a database. The answer about which database depends on your target platform but you could consider gadfly. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: egg and modpython
I applaud you for studying the traceback in more depth than I can find the motivation for, Bruno. ;-) However, this looks like a program using some package installed by setuptools/easy_install needs to unpack that package when running. See news:[EMAIL PROTECTED] -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: A cross platform systray icon
Nick Craig-Wood wrote: Does anyone have some hints / tips / experience with making a cross platform systray icon? It should work on Windows, Gnome and KDE at minimum. I've seen the win32all code which is very similar to the C code I've written before for Windows. It would be a small irritation to have to integrate its event loop with whichever GUI framework I'm using for the rest of it though. You might do a search for TaskBarIcon in the wxPython toolkit. Duane -- http://mail.python.org/mailman/listinfo/python-list
Re: A cross platform systray icon
Nick Craig-Wood wrote: Does anyone have some hints / tips / experience with making a cross platform systray icon? It should work on Windows, Gnome and KDE at minimum. I've seen the win32all code which is very similar to the C code I've written before for Windows. It would be a small irritation to have to integrate its event loop with whichever GUI framework I'm using for the rest of it though. I don't know how to make a systray under KDE/Gnome though, but I think freedesktop has made it a lot easier now. I didn't manage to find a python example - does anyone have one? Ideally I'd like someone to tell me that PyQT, tkinter or PyGTK does it all for me, but from my searching on the subject I doubt it is going to be that easy! Thanks Google turned this up. http://radio.weblogs.com/0110159/gems/systray_py.txt Hope it helps. -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
David Isaac wrote: I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? Thank you, Alan Isaac If you want really simple, look at the anydbm module. If nothing better is available, anydbm will use dumbdbm. All of these are in the Python build, so you do not need to fetch/read/install anything additional. Doing the DB-API would be much stronger, but might be overkill in your situation. -- http://mail.python.org/mailman/listinfo/python-list
Re: extracting substrings from a file
On 11 Sep 2006 05:29:17 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I have a file with several entries in the form: AFFX-BioB-5_at E. coli /GEN=bioB /gb:J04423.1 NOTE=SIF corresponding to nucleotides 2032-2305 of /gb:J04423.1 DEF=E.coli 7,8-diamino-pelargonic acid (bioA), biotin synthetase (bioB), 7-keto-8-amino-pelargonic acid synthetase (bioF), bioC protein, and dethiobiotin synthetase (bioD), complete cds. 1415785_a_at /gb:NM_009840.1 /DB_XREF=gi:6753327 /GEN=Cct8 /FEA=FLmRNA /CNT=482 /TID=Mm.17989.1 /TIER=FL+Stack /STK=281 /UG=Mm.17989 /LL=12469 /DEF=Mus musculus chaperonin subunit 8 (theta) (Cct8), mRNA. /PROD=chaperonin subunit 8 (theta) /FL=/gb:NM_009840.1 /gb:BC009007.1 and I would like to create a file that has only the following: AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 Could anyone please tell me how can I do it? If each entry is a single line, then the following is just to give you some ideas. It is not robust enough for production though. The 2nd input line has 2 /gb fields, and your script would need to have some way of knowing which one to pick. for x in s.splitlines(): ... data = x.split() ... output = [ data[0] ] ... for z in data[1:]: ... if (z.startswith('/GEN') or z.startswith('/gb'))and z not in output: ... output.append(z) ... print ' '.join(output) ... AFFX-BioB-5_at /GEN=bioB /gb:J04423.1 1415785_a_at /gb:NM_009840.1 /GEN=Cct8 /gb:BC009007.1 HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple regex with whitespaces
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, I cannot figure out a way to find a regular expression that would match one and only one of these two strings: s1 = ' how are you' s2 = 'hello world how are you' All I could come up with was: patt = re.compile('^[ ]*([A-Za-z]+)[ ]+([A-Za-z]+)$') Which of course does not work. I cannot express the fact: sentence have 0 or 1 whitespace, separation of group have two or more whitespaces. Any suggestion ? Thanks a bunch ! Mathieu A pyparsing approach is not as terse as regexp's, but it's not terribly long either. Following John Machin's submission as a pattern: s1 = ' how are you' s2 = 'hello world how are you' from pyparsing import * wd = Word(printables) # this is necessary to suppress pyparsing's built-in whitespace skipping wd.leaveWhitespace() sentence = delimitedList(wd, delim=White(' ',exact=1)) for test in (s1,s2): print sentence.searchString(test) Pyparsing returns data as ParseResults objects, which can be accessed as lists or dicts. From this first cut, we get: [['how', 'are', 'you']] [['hello', 'world'], ['how', 'are', 'you']] These aren't really sentences any more, but we can have pyparsing put them back into sentences, by adding a parse action to sentence. sentence.setParseAction(lambda toks: .join(toks)) Now our results are: [['how are you']] [['hello world'], ['how are you']] If you really want to get fancy, and clean up some of that capitalization and lack of punctuation, you can add a more elaborate parse action instead: ispunc = lambda s: s in .!?;:, sixLoyalServingMen = ('What','Why','When','How','Where','Who') def cleanup(t): t[0] = t[0].title() if not ispunc( t[-1][-1] ): if t[0] in sixLoyalServingMen: punc = ? else: punc = . else: punc = return .join(t) + punc sentence.setParseAction(cleanup) This time we get: [['How are you?']] [['Hello world.'], ['How are you?']] The pyparsing home page is at pyparsing.wikispaces.com. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
can you add some more info, or point me to a link, i havn't found anything about binary search in mmap() in python documents. the files are very big... thanks amit Bill Scherer wrote: noro wrote: Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' ? BTW: does for line in f: read a block of line to te memory or is it simply calls f.readline() many times? thanks amit If your file is sorted by some key in the data, you can build a very fast binary search with mmap in Python. -- http://mail.python.org/mailman/listinfo/python-list
Re: Algorithm Question
On 2006-09-10, Andrew McLean [EMAIL PROTECTED] wrote: This really an algorithm question more that a Python question, but it would be implemented in Python In that case, try comp.programming. But still... I have a list of strings, A. I want to find a set of strings B such that for any a in A there exists b in B such that b is a sub-string of a. But I also want to minimise T = sum_j t_j where t_j = count of the number of elements in A which have b[j] as a sub-string My guess is that finding the smallest possible T satisfying the constraint would be hard. However, for my application just keeping it reasonably small would help. In my case the list A contains over two million addresses. I'm afraid I don't understand your description. How about an example of B for some A? A = [abb, bbc] B = [a, ab, abb, b, bb, bbc, bc, c] Is that what you're after? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
best way of testing a program exists before using it?
I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print you don't have %s installed % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). -h -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
noro wrote: Bill Scherer wrote: noro wrote: Is there a more efficient method to find a string in a text file then: f=file('somefile') for line in f: if 'string' in line: print 'FOUND' ? BTW: does for line in f: read a block of line to te memory or is it simply calls f.readline() many times? thanks amit If your file is sorted by some key in the data, you can build a very fast binary search with mmap in Python. can you add some more info, or point me to a link, i haven't found anything about binary search in mmap() in python documents. the files are very big... [please don't top-post: add your latest comments at the end so the story reads from the beginning]. I think this is probably not going to help you. A binary search is only useful if you want to locate a value in an ordered list. Since your original posting made it seem like the text you are looking for could appear in any position in any line of the file a binary search doesn't do you any good at all (in fact it complicates things and slows them down unnecessarily) because you'd still need to look at all lines. Plus, if the lines are of variable length then you'd need to start by creating an index of them, meaning you'd have to go right through the file anyway. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: efficient text file search.
John Machin [EMAIL PROTECTED] schreef in bericht news:[EMAIL PROTECTED] Luuk wrote: [snip] some googling turned op the following. Second paragraph of chapter 14 of http://www.amk.ca/python/2.1/ [snip] For a fuller discussion of the line I/O changes, see the python-dev summary for January 1-15, 2001 at http://www.amk.ca/python/dev/2001-01-1.html. That is *HISTORY*. That is Python 2.1. That is the year 2001. xreadlines is as dead as a dodo. Thats's why i started my reply with: some googling turned op the following. i did not state that further googling was unneeded ;-) -- http://mail.python.org/mailman/listinfo/python-list
ANN: ChiPy Thurs. September 14, 2006. 7pm @ Google, Chicago
Chicago Python User Group = Come join us for our best meeting ever! Topics -- * Google Code (Brian Fitzpatrick and Ben Collins-Sussman) * Trac + Subversion + doctests (Garrett Smith) * Special method names for operator overloading (Brian Ray) Location Google's Chicago office 20 West Kinzie Street, 9th Floor Chicago, IL 60610 Location description: 18 story glass and steel building on the Northwest corner of Dearborn and Kinzie. Across the street from Harry Carey's Upstairs from Keefer's restaurant * Map http://tinyurl.com/ee8my Enter via the lobby on the South side of the building, between Keefer's restaurant and Keefer's cafe. Street (meter) parking is kinda sorta available in the area. Garage and lot parking is also available Southwest and East of our building. 1. The closest L stop is Grand on the Red Line and Clark/Lake on the Blue/Green/Orange/Brown/Purple Line. (All are about an 8 minute walk from Google) 2. The closest Metra station is the Ogilvie Transportation Center (in the Citibank building) (about 20 minutes walk or take the Riverbus) 3. The closest River Bus stop is at Michigan Avenue (By the Wrigley Building at 2 North Riverside Plaza. (http://www.wendellariverbus.com/rbdock.htm) ;-) 4. The nearest helipad is at the mouth of the river, near Navy Pier. Obtain security clearance before landing. *** A Special Note from Fitz:: I'm going to need a list of all people attending to give to building security, so if you're thinking of coming, please send me your name (just to me--use my fitz at google dot com address please). About ChiPy --- ChiPy is a group of Chicago Python Programmers, l33t, and n00bs. Meetings are held monthly at various locations around Chicago. Also, ChiPy is a proud sponsor of many Open Source and Educational efforts in Chicago. Stay tuned to the mailing list for more info. ChiPy website: http://chipy.org ChiPy Mailing List: http://mail.python.org/mailman/listinfo/chicago Python website: http://python.org Forward this on. -- http://mail.python.org/mailman/listinfo/python-list
Re: egg and modpython
Paul Boddie wrote: Bruno Desthuilliers wrote: Wensheng a écrit : I installed pysqlite2 using easy_install. and got this when using it from modpython: -- Mod_python error: PythonHandler etc.modpython [...] I applaud you for studying the traceback in more depth than I can find the motivation for, Bruno. ;-) However, this looks like a program using some package installed by setuptools/easy_install needs to unpack that package when running. ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/var/www/.python-eggs' And this wants to happen apparently in the home directory of the Web server user, whose rights may be somewhat limited. Or perhaps one has to initialise setuptools for any particular user by running it first as that user: something that isn't a particularly common thing to do with non-interactive users on UNIX-like systems. [...] Can peak developers fix this please? Why should they fix something that's 1/ documented - http://peak.telecommunity.com/DevCenter/EggFormats#zip-file-issues The Internal Structure of Python Eggs / STOP! This is not the first document you should read! A case of Beware of the Leopard perhaps? 2/ not a an egg specific issue In my experience, most other package managers actually unpack their resources when invoked, rather than leaving the programs to attempt such things when running. Debian packages even compile the bytecode files to ensure that nothing tries (and fails) to write them to privileged locations afterwards. 3/ really just a configuration/permission problem Which should have been solved when the package manager was invoked, especially since this was most likely done as root. [...] in the mean time, I just have to use old download, unzip/untar python setup.py install way. No - you have to read the manual and fix you configuration. FWIW, the above traceback gives far enough clues (it's even written in all letters). The various ways to deal with this include running easy_install as the Web server user so that it can touch the directory and whatever else it needs, and perhaps to set up various permissions - something you wouldn't usually do; running easy_install with the --always-unzip flag when installing the package as root; using python setup.py install as usual. This situation looks either a lot like a use case whose popularity has been underestimated by the developers - intriguing given the number of people supposedly using setuptools for their Web application deployments - or a packaging mistake with the pysqlite2 .egg file. Either way, system packages rarely suffer from this kind of problem, and it's quite understandable (and justifiable) to consider this bad behaviour. Or you may read easy_install's doc to avoid installing zipped eggs: http://peak.telecommunity.com/DevCenter/EasyInstall#compressed-installation Perhaps the developers should reverse their defaults and emulate the usual behaviour of package managers, unfashionable as that may seem. Paul Thank you for clarification and other info/sugguestions. As I read the document, if package author set zip_safe = false in their setup.py, there would be no such problem. I also second the idea of making --always-unzip the default. It's EASY_install and EZ_setup, should be EASY so that we don't have to read the document:), right? If it's turbogears, yes, I would definitely read the document, but a package manager... -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
David Isaac a écrit : I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? May take a look at buzhug (very pythonic way to manipulate data in the base). http://buzhug.sourceforge.net/ Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print you don't have %s installed % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: PIL cannot open TIFF image in Windows
Michele Petrazzo wrote: Rob Williscroft wrote: I downloaded some test images from: url:http://www.remotesensing.org/libtiff/images.html I do the same and modified your code for try FreeImagePy and the results are: ok: 41 error: 20 total: 61 Better than PIL, but a lot of problems with lower-rgb-planar- 8 and flower-rgb-contig- 8 IrfanView seem that can load all the images... Rob. Bye, Michele I've been working with tifs a lot, and I've yet to find a perfect python solution to them. The usual images to screw things up for me are jpeg encoded pages. Best solution I've found is a try/except fall through: try: open image with PIL except: try: open image with FreeImagePy except: try: open image with wxPython except: fail Right now my program to compile multipage tiffs no longer does any of the image work itself - it processes the index file, and then generates a batch file. The batch file is a lot of calls to irfanview /append. I've yet to find a tiff irfanview can't open. Iain -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
In article [EMAIL PROTECTED], Paul Watson [EMAIL PROTECTED] wrote: David Isaac wrote: I have no experience with database applications. This database will likely hold only a few hundred items, including both textfiles and binary files. I would like a pure Python solution to the extent reasonable. Suggestions? If you want really simple, look at the anydbm module. If nothing better is available, anydbm will use dumbdbm. All of these are in the Python build, so you do not need to fetch/read/install anything additional. Doing the DB-API would be much stronger, but might be overkill in your situation. Once Python 2.5 comes out, I recommend using sqlite because it avoids the mess that dbm can cause. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ LL YR VWL R BLNG T S -- www.nancybuttons.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Peter Otten wrote: http://sourceforge.net/tracker/?func=detailaid=1409455group_id=5470atid=105470 Now, is this change to Generator.py in error or am I doing something wrong? I'm not familiar enough with the email package to answer that. I'm hoping someone around here is ;-) If the latter, how can I change my code such that it works as I'd expect? email.Generator and email.Message use cStringIO.StringIO internally, which can't cope with unicode. A quick fix might be to monkey-patch: I'm not sure that's correct, but I'm happy to stand corrected. My understanding is that the StringIO's don't mind as long as they type is consistent - ie: con't mix unicode and encoded strings, 'cos it forced python's default ascii codec to kick in and spew unicode errors. Now, I want to know what I'm supposed to do when I have unicode source and want it to end up as either a text/plain or text/html mime part. Is there a how-to for this anywhere? The email package's docs are short on examples involving charsets, unicode and the like :-( Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Steve Holden wrote: Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command "which"? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print "you don't have %s installed" % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve Yeah, this occurred to me just after I sent the mail, but I don't really want to run the program because it will go off and do some work and take time to come back. If there is a better way then that would be great. I can't think of anything other than what you have suggested with a message saying that the program wasn't found in the path which would be the most appropriate error since the path could also be wrong. Perhaps I'll just bite the bullet and get the program to do something as small as possible to test it. I guess I'll just have to continue to miss my unix commands... -h -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print you don't have %s installed % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). IMHO this is pretty portable: def is_on_path(fname): ... for p in os.environ['PATH'].split(os.pathsep): ... if os.path.isfile(os.path.join(p, fname)): ... return True ... return False HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list
Re: Algorithm Question
Andrew McLean wrote: I have a list of strings, A. I want to find a set of strings B such that for any a in A there exists b in B such that b is a sub-string of a. B=A? But I also want to minimise T = sum_j t_j where t_j = count of the number of elements in A which have b[j] as a sub-string If there not elements in A that are substrings of any other element in A, and if B=A, then t_j would be 1 for all j. Which means B=A would be optimal (since elements of B have to be substring of at least one element in A). It looks like the B={set of all elements in A that are not a substring of any other element in A} is the generally optimal solution. I suspect you mistyped or omitted something--problem is underspecified at best. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: Peter Otten wrote: http://sourceforge.net/tracker/?func=detailaid=1409455group_id=5470atid=105470 Now, is this change to Generator.py in error or am I doing something wrong? I'm not familiar enough with the email package to answer that. I'm hoping someone around here is ;-) If the latter, how can I change my code such that it works as I'd expect? email.Generator and email.Message use cStringIO.StringIO internally, which can't cope with unicode. A quick fix might be to monkey-patch: I'm not sure that's correct, but I'm happy to stand corrected. My understanding is that the StringIO's don't mind as long as they type is consistent - ie: con't mix unicode and encoded strings, 'cos it forced python's default ascii codec to kick in and spew unicode errors. Now, I want to know what I'm supposed to do when I have unicode source and want it to end up as either a text/plain or text/html mime part. Is there a how-to for this anywhere? The email package's docs are short on examples involving charsets, unicode and the like :-( Well, it would seem like the easiest approach is to monkey-patch the use of cStringIO to StringIO as recommended and see if that fixes your problem. Wouldn't it? regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Cool! A python course!
http://www.epp.jhu.edu/schedule/courseinfo.php?deptid=525coursenum=492 -- http://mail.python.org/mailman/listinfo/python-list
RE: best way of testing a program exists before using it?
[Rob Wolfe] | Hari Sekhon wrote: | I am writing a wrapper to a binary command to run it and then do | something with the xml output from it. | | What is the best way of making sure that the command is | installed on the | system before I try to execute it, like the python equivalent of the | unix command which? | | Otherwise I'd have to do something like: | | if os.system('which somecommand') != 0: | print you don't have %s installed % somecommand | sys.exit(1) | | I know that isn't portable which is why a python solution would be | better (although this will run on unix anyway, but it'd be | nice if it | ran on windows too). | | IMHO this is pretty portable: | | def is_on_path(fname): | ... for p in os.environ['PATH'].split(os.pathsep): | ... if os.path.isfile(os.path.join(p, fname)): | ... return True | ... return False | Depends on how fname is specified: on Win32, the filename itself will have one of the PATHEXT extensions, even though you conventionally don't specify it (and if you're after portability you certainly won't). On *nix, tho', you almost certainly won't have the extension. As it happens I wrote a script similar to yours this morning which takes account of the PATHEXT, but because of that, it's obviously win-specific. Maybe it could be made a bit smarter to account for the possible absence of the env var. (This is a cut-down version) code import os, sys class x_finished (Exception): pass paths = [.] + os.environ.get (PATH, ).split (;) exts = [e.lower () for e in os.environ.get (PATHEXT, .exe).split (;)] if __name__ == '__main__': if len (sys.argv) 1: search_for = sys.argv[1] else: search_for = raw_input (Search for:) base, ext = os.path.splitext (search_for) if ext: exts = [ext] try: for path in paths: for ext in exts: filepath = os.path.join (path, %s%s % (base, ext)) if os.path.isfile (filepath): print filepath raise x_finished except x_finished: pass /code TJG This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Rob Wolfe wrote: Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command "which"? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print "you don't have %s installed" % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). IMHO this is pretty portable: def is_on_path(fname): ... for p in os.environ['PATH'].split(os.pathsep): ... if os.path.isfile(os.path.join(p, fname)): ... return True ... return False HTH, Rob That works well and is portable, fits nicely. I was actually curious if somebody already came across this and perhaps put a func like this in the standard modules... Thanks. -h -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? There is the which module: http://trentm.com/projects/which/ But I'd probably just try the command and catch the exception, e.g.: import subprocess try: ... subprocess.call(['foo']) ... except OSError: ... print you don't have foo installed ... you don't have foo installed try: ... subprocess.call(['svm_learn']) ... except OSError: ... print you don't have svm_learn installed ... 1 STeVe -- http://mail.python.org/mailman/listinfo/python-list
Behaviour of classes (tired of writing too much)
How do I catch any reference to an instance of a class, i.e., I want to run some code as soon as an instance of a class is used in any way. (and I don't want to define all of __add__, __ge__ etc etc etc etc etc) The reason for the question is that I want to simplify the Message Passing Interface (MPI) calls. I find it irritating that I have to start a non-blocking send/receive and then check that the data has arrived. Why not automagically check/wait for the data when it is needed? The second part that I also need to make that idea work is the ability to change the instance to the received data, i.e., self=received data, and then launch the original reference. So I guess that the code I want to write is: class MPI_tmp: # temporary object that changes ITSELF into another object when called in any way def __on_any_call__(self): self=newobject() self.__run_the_anycall__() which probably doesn't work :-) Greatful for any ideas / Magnus -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Rob Wolfe wrote: Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print you don't have %s installed % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). IMHO this is pretty portable: def is_on_path(fname): for p in os.environ['PATH'].split(os.pathsep): if os.path.isfile(os.path.join(p, fname)): return True return False Except that the fname will then have to be a .exe on Windows and not on Unix. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Hari Sekhon wrote: Steve Holden wrote: Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command which? Otherwise I'd have to do something like: if os.system('which somecommand') != 0: print you don't have %s installed % somecommand sys.exit(1) I know that isn't portable which is why a python solution would be better (although this will run on unix anyway, but it'd be nice if it ran on windows too). The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve Yeah, this occurred to me just after I sent the mail, but I don't really want to run the program because it will go off and do some work and take time to come back. If there is a better way then that would be great. I can't think of anything other than what you have suggested with a message saying that the program wasn't found in the path which would be the most appropriate error since the path could also be wrong. Perhaps I'll just bite the bullet and get the program to do something as small as possible to test it. I guess I'll just have to continue to miss my unix commands... Erm, but don't you *have* to run the program anyway to produce the required XML output? So, if the attempt to run it fails then you know it isn't installed, and if it succeeds then you should have the required output (I'm presuming either the output will appear in a file or you'll be using the subprocess module or similar to capture its standard output). To be specific: I wasn't suggesting that you try to run the program first just to see whether it existed, I was suggesting you try to run it to produce the XML, and if it fails then you know you can't. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Steven Bethard wrote: Hari Sekhon wrote: I am writing a wrapper to a binary command to run it and then do something with the xml output from it. What is the best way of making sure that the command is installed on the system before I try to execute it, like the python equivalent of the unix command "which"? There is the which module: http://trentm.com/projects/which/ But I'd probably just try the command and catch the exception, e.g.: import subprocess try: ... subprocess.call(['foo']) ... except OSError: ... print "you don't have foo installed" ... you don't have foo installed try: ... subprocess.call(['svm_learn']) ... except OSError: ... print "you don't have svm_learn installed" ... 1 STeVe looks good, although I agree with you on the try it and see simplicity. I think if the which.py was part of the standard lib then I would use it, but as it is I will stick to the original path search that you recommended (I'm not gonna both dealing with the pathext just yet) -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with email.Generator.Generator
Chris Withers wrote: Now, I want to know what I'm supposed to do when I have unicode source and want it to end up as either a text/plain or text/html mime part. Is there a how-to for this anywhere? The email package's docs are short on examples involving charsets, unicode and the like :-( no expert in this, but have you tried the codecs module? http://docs.python.org/lib/codec-objects.html ( with 'xmlcharrefreplace' for the html )? Gerard -- http://mail.python.org/mailman/listinfo/python-list
Re: PyPy with a smaller PVM for the full Python?
Casey Hawthorne wrote: Currently PyPy is working toward compiling to C a restricted subset of Python, called RPython. Would it be possible for PyPy to compile the full subset of Python by also using a lot smaller version of the PVM (Python Virtual Machine) to go with the compiled code? So, the user would be running the C object code and also a smaller PVM! Or would this completely remove or severely reduce any speed advantage of the compiled code? Similarly, for JPython (which is at Python 2.2?), could one also use a lot smaller accompanying PVM with the JPython source code and JVM to use Python 2.5 in its entirety? -- Regards, Casey The PyPy project, as I understand it, is to have a version of Python that's entirely written in Python. The RPython modules are the ones that will be compiled into C so that they can then be compiled into a virtual machine. I doubt very much if there's anything that can be done to subset it further. Their direction on performance is toward a JIT (Just In Time compiler), not to put lots of code in C so that it runs fast. The same goes for both Java and the CLR (IronPython). I believe there are plans to subset the JVM in the 2.7 release, but I have my doubts whether that will reduce the JVM footprint as far as running Jython is concerned. The intention is to reduce the initial footprint for runing the JVM under a browser. John Roth -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
On 11/09/06, Hari Sekhon [EMAIL PROTECTED] wrote: Steve Holden wrote: Hari Sekhon wrote: The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve Yeah, this occurred to me just after I sent the mail, but I don't really want to run the program because it will go off and do some work and take time to come back. If there is a better way then that would be great. I can't think of anything other than what you have suggested with a message saying that the program wasn't found in the path which would be the most appropriate error since the path could also be wrong. If you run your wrapper and the program exists then you don't have to test for it, so the overall process is quicker and cleaner than testing-for *then* running the program If you run your wrapper and the program doesn't exist, then you have performed your if exists test without extra code and with very little processing, and the raised exception will lead you nicely into your not exists scenario. try: run_somecommand except: print you don't have %s installed % somecommand HTH :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour of classes (tired of writing too much)
[EMAIL PROTECTED] wrote: How do I catch any reference to an instance of a class, i.e., I want to run some code as soon as an instance of a class is used in any way. (and I don't want to define all of __add__, __ge__ etc etc etc etc etc) What do you mean by used in any way? Which of these are considered usage: a = Foo() # obviously b = a # ? a.__gt__(5) # apparently a.__gt__# ? Anyway, look into __getattr__ Cheers, Brian -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Erm, but don't you *have* to run the program anyway to produce the required XML output? So, if the attempt to run it fails then you know it isn't installed, and if it succeeds then you should have the required output (I'm presuming either the output will appear in a file or you'll be using the subprocess module or similar to capture its standard output). While it may not be the case for the OP, it's not entirely unreasonable there might be some intermediate process that is time-consuming...something like def do_stuff(): data = gather_data_from_user_for_x_days(7) do_something_with(data) os.system('program.exe') # to process the gathered data If it's going to bomb out in step #3, it might be nice to know before you start the 7-days worth of data-gathering/sampling in step #1. def do_stuff(): if exists_in_path('program.exe'): data = gather_data_from_user_for_x_days(7) do_something_with(data) os.system('program.exe') else: let_user_know_cant_find_program() That way, they can remedy the situtation before wasting their time with a laborious process. Granted, there's a race condition, that if the program exists and the user starts gathering data, and then deletes the program before the completion of the data-gathering, it will bomb out. However, I'd chalk that up to a stupid-user-for-shooting-themselves-in-the-foot exception. :) Sure, it's a bit contrived in this case, but I've had too many applications that do exactly this, and would have welcomed information that a piece was missing *before* I had invested time in the app. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: best small database?
Aahz [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In article [EMAIL PROTECTED], Once Python 2.5 comes out, I recommend using sqlite because it avoids the mess that dbm can cause. -- Aahz ([EMAIL PROTECTED]) * http://www.pythoncraft.com/ and if you don't want to wait for 2.5, you can install pysqlite without too much trouble - and it is *very* easy to use! For SQLite design and data browsing, check out the SQLite Browser at http://sqlitebrowser.sourceforge.net. -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Is it just me, or is Sqlite3 goofy?
Kay Schluehr wrote: [EMAIL PROTECTED] wrote: I wouldn't be at all surprised if the pysqlite author operated under that assumption. That the Python developers didn't pick up on the issue is not surprising. I'm not sure how many of them are (py)sqlite users, probably relatively few. Skip Who has reviewed sqlite/pysqlite after all? pysqlite was actually reviewed by several Python core developers before becoming a part of the Python standard library, most prominently Neil Norwitz and Anthony Baxter. Reading the passage in the sqlite FAQ I can hardly believe that passing errors silently and coercing everything to string when it fails to be coerced to INTEGER although INTEGER was an invariant declared in the create command is on par with Pythons design philosophy. [...] Unfortunately, third-party library authors don't first check with Python's design philosophy in case their software will be wrapped as a Python module ;-) I did my best to combine both SQLite's and Python's type system though, including a discussion with pysqlite 1.x users before the grand rewrite for version 2, which is the one that ended up in the Python standard library now. In other cases doctoral dissertations are written about whether a keyword or some punctuation shall be used for decorator syntax and in this case everything must be rushed into the code base of the standard library? There was no rush at all. -- Gerhard -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
Tim Williams wrote: On 11/09/06, Hari Sekhon [EMAIL PROTECTED] wrote: Steve Holden wrote: Hari Sekhon wrote: The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve Yeah, this occurred to me just after I sent the mail, but I don't really want to run the program because it will go off and do some work and take time to come back. If there is a better way then that would be great. I can't think of anything other than what you have suggested with a message saying that the program wasn't found in the path which would be the most appropriate error since the path could also be wrong. If you run your wrapper and the program exists then you don't have to test for it, so the overall process is quicker and cleaner than testing-for *then* running the program If you run your wrapper and the program doesn't exist, then you have performed your if exists test without extra code and with very little processing, and the raised exception will lead you nicely into your not exists scenario. try: run_somecommand except: print you don't have %s installed % somecommand HTH :) The down side to that is the program has to be run which consumes time and slows the script down a fair bit (as well as outputting garbage to the screen) -h -- Hari Sekhon -- http://mail.python.org/mailman/listinfo/python-list
Re: Ann: CoreBio 0.4
km wrote: Hi, why are u reinventing the wheel when Biopython[1] is already existing ? is there any specific reason u wanted to develop this CoreBio ? why dont u just extend the existing BioPython package itself ? regards, KM [1]http://biopython.org [EMAIL PROTECTED] wrote: Biopython is a fine project which I have used and contributed to in the past. Unfortunately, Biopython suffers form a lack of focus. It is a huge heap of code, some of which is well written, but of lot of which is not, and a significant portion doesn't work as advertised. There is no consistency, the code-base is idiosyncratic, the documentation is spotty, and it is very hard to actually discover and use the functionality that you need. For some common tasks there are three ways of doing things, only one of which is supported. CoreBio is intended to be a high-quality, easy to use collection of the core functionality needed for bioinformatics and computational biology. Compared to biopython, we are taking a narrow, quality first, rather than breadth first, approach with simple API's that hide as much complexity as reasonable possible. As an example of simple API's consider the common task of reading a file of protein sequences: from corebio import seq_io afile = open(human.fa) list_of_sequences = seq_io.read(afile) CoreBio will figure out the file format, so 'seq_io.read()' will parse sequence data from fasta, clustal, genbank, intelligenetics, msf, nbrf/pir, nexus or phylip formatted files. Gavin Crooks -- http://mail.python.org/mailman/listinfo/python-list
Re: Behaviour of classes (tired of writing too much)
[EMAIL PROTECTED] wrote: How do I catch any reference to an instance of a class, i.e., I want to run some code as soon as an instance of a class is used in any way. (and I don't want to define all of __add__, __ge__ etc etc etc etc etc) The reason for the question is that I want to simplify the Message Passing Interface (MPI) calls. I find it irritating that I have to start a non-blocking send/receive and then check that the data has arrived. Why not automagically check/wait for the data when it is needed? The second part that I also need to make that idea work is the ability to change the instance to the received data, i.e., self=received data, and then launch the original reference. So I guess that the code I want to write is: class MPI_tmp: # temporary object that changes ITSELF into another object when called in any way def __on_any_call__(self): self=newobject() self.__run_the_anycall__() which probably doesn't work :-) Greatful for any ideas / Magnus Maybe it could make a damned fine cup of coffee as well ;-) ? That's a pretty tall order, and mutating self isn't as simple as you think. However you *can* change an instance's __class__ attribute dynamically, which might be a way to get where you want. Not sure about the trapping all accesses bit, though. __getattr__() could give you access to undefined attributes. For new_style classes you can implement __getattribute__() to trap *any* attribute access. This would be somewhat slow, but might be acceptable if you were then changing the instance's class to something that *didn't* implement __getattribute__(). regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
assistance with python coding
I dont understand what this question is asking; can you clarify for me and maybe point me in the right direction? As an exercise, rewrite this line of code without using a sequence assignment. self.cards[i], self.cards[j] = self.cards[j], self.cards[i] V/R CW2 John Shappell 931-980-4707 FAX 775-618-2455 [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: best way of testing a program exists before using it?
On 11/09/06, Hari Sekhon [EMAIL PROTECTED] wrote: Tim Williams wrote: On 11/09/06, Hari Sekhon [EMAIL PROTECTED] wrote: Steve Holden wrote: Hari Sekhon wrote: The easiest way to test whether the command will run is to try and run it. If the program doesn't exist then you'll get an exception, which you can catch. Otherwise you'll be stuck with non-portable mechanisms for each platform anyway ... regards Steve Yeah, this occurred to me just after I sent the mail, but I don't really want to run the program because it will go off and do some work and take time to come back. If there is a better way then that would be great. I can't think of anything other than what you have suggested with a message saying that the program wasn't found in the path which would be the most appropriate error since the path could also be wrong. If you run your wrapper and the program exists then you don't have to test for it, so the overall process is quicker and cleaner than testing-for *then* running the program If you run your wrapper and the program doesn't exist, then you have performed your if exists test without extra code and with very little processing, and the raised exception will lead you nicely into your not exists scenario. try: run_somecommand except: print you don't have %s installed % somecommand HTH :) The down side to that is the program has to be run which consumes time and slows the script down a fair bit (as well as outputting garbage to the screen) Sorry, I don't follow!! If the program doesn't exist how can you run it ??? If the program does exist then running is what you wanted it to do anyway and you've saved doing a test for it first. :) -- Tim Williams -- http://mail.python.org/mailman/listinfo/python-list
Re: A cross platform systray icon
TheSeeker [EMAIL PROTECTED] wrote: Nick Craig-Wood wrote: Does anyone have some hints / tips / experience with making a cross platform systray icon? It should work on Windows, Gnome and KDE at minimum. You might do a search for TaskBarIcon in the wxPython toolkit. Yes thank you (and everyone else) who replied with that - that looks like just the thing. I was able to create a systray icon that worked under linux and windows which is great! Now to learn wxpython ;-) Thanks -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: A cross platform systray icon
Larry Bates [EMAIL PROTECTED] wrote: Google turned this up. http://radio.weblogs.com/0110159/gems/systray_py.txt I couldn't get that to work - wxwindows bitrot maybe? I did find an example which worked under windows linux http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475155 Thanks anyway -- Nick Craig-Wood [EMAIL PROTECTED] -- http://www.craig-wood.com/nick -- http://mail.python.org/mailman/listinfo/python-list
Re: get the en of a program running in background
Hi, I am using subprocess module, then I do not fork my program. How use os.wait() in a non blocking mode ? Thanks Damjan wrote: It works when a click on a button launches a program P. Now, I want that a click on another button launches another program P' In this case there is only one signal for two events : the end of P and the end of P'. How can distinct the two cases. Remember the PIDs of the forked procesess and in your signal handler use os.wait() to see which one has died. BTW os.wait() can work in non-blocking mode . -- damjan -- http://mail.python.org/mailman/listinfo/python-list