Re: How to find any documentation for smbus?
Il Sat, 28 Oct 2023 17:08:00 +0100, Chris Green ha scritto: > I am using the python3 smbus module, but it's hard work because of the > lack of documentation. Web searches confirm that the documentation is > somewhat thin! > > If you do the obvious this is what you get:- > > >>> import smbus dir (smbus) > ['SMBus', '__doc__', '__file__', '__loader__', '__name__', > '__package__', '__spec__'] > >>> help(smbus) > > > Help on module SMBus: > > NAME > SMBus > > DESCRIPTION > This module defines an object type that allows SMBus > transactions on hosts running the Linux kernel. The host kernel > must have I2C support, I2C device interface support, and a bus > adapter driver. > All of these can be either built-in to the kernel, or loaded > from modules. > > Because the I2C device interface is opened R/W, users of this > module usually must have root permissions. > > FILE > /usr/lib/python3/dist-packages/smbus.cpython-39-arm-linux- gnueabihf.so > > > Even a list of available methods would be handy! :-) > > > Presumably python3's smbus is just a wrapper so if I could find the > underlying C/C++ > documentation it might help. https://pypi.org/project/smbus2/ smbus2 is designed to be a "drop-in replacement of smbus". SO you can look at its documentation for or use it instead of smbus. Disclaimer: I haven't any experience on this library -- https://mail.python.org/mailman/listinfo/python-list
Re: we want python software
Remember that you are wasting time of lakhs of python subscribers by asking such dumb questions being tech students. You people can Google and watch movies / songs online and you can't find how to download and install python ? That's ridiculous! On Dec 6, 2017 10:15 AM, "Abhiram R" wrote: > > > On Wed, Dec 6, 2017 at 10:08 AM, km wrote: > >> I dont know how these students are selected into b tech stream in India. >> they are so dumb. All they know is a to open a program we need to double >> click it and it runs. >> >> We were all once "dumb". We learnt it because someone Taught us. I'd > rather not entertain such or refrain from condescending replies that would > further discourage people from trying to get into the field. With all the > emphasis on the Python "community", it's important not to be so dismissive. > > > Thanks > Abhiram > > > > >> >> >> On Wed, Dec 6, 2017 at 9:19 AM, Rustom Mody >> wrote: >> >> > On Wednesday, December 6, 2017 at 3:10:24 AM UTC+5:30, Igor Korot wrote: >> > > Hi, Tony, >> > > >> > > On Tue, Dec 5, 2017 at 11:10 AM, Tony van der Hoff wrote: >> > > > On 05/12/17 16:55, Igor Korot wrote: >> > > >> Hi, >> > > >> >> > > >> On Tue, Dec 5, 2017 at 9:10 AM, Jyothiswaroop Reddy wrote: >> > > >>> Sir, >> > > >>> I am b.tech student I would like to learn python. So >> please >> > send the python software. >> > > >> Sorry, we don't send anything. You will have to go get it >> yourself. -) >> > > >> >> > > > Well, at least try to be helpful: >> > > > https://www.python.org/downloads/ >> > > >> > > This is LMGIFY. >> > > If they say they are tech students - they should know how to work with >> > Google. >> > > >> > > And I even tried to be polite. I should have probably write something >> > like: >> > > >> > > 1. Open the Web browser. >> > > 2. In the "Address Bar" type "www.pyton.org". >> > > 3. Find the link which reads "Downloads". Click on it. >> > > 4. Carefully read what version you need to install for your OS. >> > > 5. Apply the acquired knowledge and download the appropriate version. >> > > 6. Click on the installer (if on Windows). >> > > 7. Follow all the prompts. >> > > 8. Enjoy. >> > > >> > > but this is too much for the tech student. >> > >> > You are assuming that the strangeness of the request is about 'tech' >> > [engineering/tech existed centuries before computers] >> > >> > Do remember one can be a tech-{student,professional} without >> > - ever having encountered free-software >> > - internet/USENET culture >> > >> > … from which pov the request would not look so odd >> > >> > -- >> > https://mail.python.org/mailman/listinfo/python-list >> > >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > -Abhiram R > ᐧ > -- https://mail.python.org/mailman/listinfo/python-list
Re: we want python software
I dont know how these students are selected into b tech stream in India. they are so dumb. All they know is a to open a program we need to double click it and it runs.- windoze legacy. most of the time they pay huge amount to a greedy college and get into tech stream. Now that Java boom (jobs) is over in India and python is booming in AI and machine learning these people want to learn python and get easy jobs (software coolies). pls dont even entertain such posts. On Wed, Dec 6, 2017 at 9:19 AM, Rustom Mody wrote: > On Wednesday, December 6, 2017 at 3:10:24 AM UTC+5:30, Igor Korot wrote: > > Hi, Tony, > > > > On Tue, Dec 5, 2017 at 11:10 AM, Tony van der Hoff wrote: > > > On 05/12/17 16:55, Igor Korot wrote: > > >> Hi, > > >> > > >> On Tue, Dec 5, 2017 at 9:10 AM, Jyothiswaroop Reddy wrote: > > >>> Sir, > > >>> I am b.tech student I would like to learn python. So please > send the python software. > > >> Sorry, we don't send anything. You will have to go get it yourself. -) > > >> > > > Well, at least try to be helpful: > > > https://www.python.org/downloads/ > > > > This is LMGIFY. > > If they say they are tech students - they should know how to work with > Google. > > > > And I even tried to be polite. I should have probably write something > like: > > > > 1. Open the Web browser. > > 2. In the "Address Bar" type "www.pyton.org". > > 3. Find the link which reads "Downloads". Click on it. > > 4. Carefully read what version you need to install for your OS. > > 5. Apply the acquired knowledge and download the appropriate version. > > 6. Click on the installer (if on Windows). > > 7. Follow all the prompts. > > 8. Enjoy. > > > > but this is too much for the tech student. > > You are assuming that the strangeness of the request is about 'tech' > [engineering/tech existed centuries before computers] > > Do remember one can be a tech-{student,professional} without > - ever having encountered free-software > - internet/USENET culture > > … from which pov the request would not look so odd > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: learning and experimenting python.
You are wasting our time instead of learning python. On Dec 31, 2016 2:09 PM, wrote: > It is moderatable. You can delete your all messages except topics. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: HELP!! How to ask a girl out with a simple witty Python code??
show her your python and and impress her. Regards, Krishna On Thu, Mar 5, 2015 at 7:04 AM, Xrrific wrote: > Guys, please Help!!! > > I am trying to impress a girl who is learning python and want ask her out > at the same time. > > Could you please come up with something witty incorporating a simple > python line like If...then... but..etc. > > You will make me a very happy man!!! > > Thank you very much!!! > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: PyPy updated
I tried compiling pandas on pypy 2.3 but it gave error as follows numpy/core/src/multiarray/scalarapi.c:742:16: error: 'PyUnicodeObject' has no member named 'str' uni->str[length] = 0; ^ numpy/core/src/multiarray/scalarapi.c:743:16: error: 'PyUnicodeObject' has no member named 'length' uni->length = length; Cleaning up... Command /home/user/test101/bin/pypy-c -c "import setuptools, tokenize;__file__='/home/user/test101/build/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-d2Eg7e-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/user/test101/include/site/python2.7 failed with error code 1 in /home/user/test101/build/numpy Storing debug log for failure in /home/user/.pip/pip.log Regards, Krishna On Fri, May 9, 2014 at 7:18 PM, Mark Lawrence wrote: > Might interest some of you fine folk out there :- > > http://morepypy.blogspot.co.uk/2014/05/pypy-23-terrestrial-arthropod-trap. > html > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: regex multiple patterns in order
Aah! I understand now. Thank you Regards, Krishna Mohan On Mon, Jan 20, 2014 at 4:48 PM, Ben Finney wrote: > km writes: > > > I am trying to find sub sequence patterns but constrained by the order > > in which they occur > > There are also specific resources for understanding and testing regex > patterns, such as http://www.pythonregex.com/>. > > > For example > > > > >>> p = re.compile('(CAA)+?(TCT)+?(TA)+?') > > >>> p.findall('CAACAACAATCTTCTTCTTCTTATATA') > > [('CAA', 'TCT', 'TA')] > > > > But I instead find only one instance of the CAA/TCT/TA in that order. > > Yes, because the grouping operator (the parens ‘()’) in each case > contains exactly “CAA”, “TCT”, “TA”. If you want the repetitions to be > part of the group, you need the repetition operator (in your case, ‘+’) > to be part of the group. > > > How can I get 3 matches of CAA, followed by four matches of TCT followed > > by 2 matches of TA ? > > With a little experimenting I get: > > >>> p = re.compile('((?:CAA)+)?((?:TCT)+)?((?:TA)+)?') > >>> p.findall('CAACAACAATCTTCTTCTTCTTATATA') > [('CAACAACAA', 'TCTTCTTCTTCT', 'TATATA'), ('', '', '')] > > Remember that you'll get no more than one group returned for each group > you specify in the pattern. > > > Well these patterns (CAA/TCT/TA) can occur any number of times and > > atleast once so I have to use + in the regex. > > Be aware that regex is not the solution to all parsing problems; for > many parsing problems it is an attractive but inappropriate tool. You > may need to construct a more specific parser for your needs. Even if > it's possible with regex, the resulting pattern may be so complex that > it's better to write it out more explicitly. > > -- > \ “To punish me for my contempt of authority, Fate has made me an | > `\ authority myself.” —Albert Einstein, 1930-09-18 | > _o__) | > Ben Finney > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
regex multiple patterns in order
I am trying to find sub sequence patterns but constrained by the order in which they occur For example >>> p = re.compile('(CAA)+?(TCT)+?(TA)+?') >>> p.findall('CAACAACAATCTTCTTCTTCTTATATA') [('CAA', 'TCT', 'TA')] But I instead find only one instance of the CAA/TCT/TA in that order. How can I get 3 matches of CAA, followed by four matches of TCT followed by 2 matches of TA ? Well these patterns (CAA/TCT/TA) can occur any number of times and atleast once so I have to use + in the regex. Please let me know. Thanks! Regards, Krishna mohan -- https://mail.python.org/mailman/listinfo/python-list
pkg_resources ?
Hi all, I am trying to look at the source code of a python script (run.py). But it reads ###code - run.py #!/usr/bin/env python # EASY-INSTALL-SCRIPT: 'pbpy==0.1','run.py' __requires__ = 'pbpy==0.1' import pkg_resources pkg_resources.run_script('pbpy==0.1', 'run.py') ##code # What are the advantages of using pkg_resources stuff ? Thanks Regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Developers with 5 years of experience
probably it is good to post jobs in python-list itself rather than posting it on someother site. Many mailing lists do that. It gives a feel of what jobs we come across for the Python developers. KM On Thu, May 5, 2011 at 3:16 AM, Ben Finney wrote: > "Jerome jjcpl.rpo" writes: > > > One of our client in New Jersey is looking for Python Developers with > > 5 years of experience. If you have any resumes please send it across. > > Please do not solicit for jobs here. Instead, the Python Job Board > http://www.python.org/community/jobs/> is intended for that > purpose. > > -- > \“The right to search for truth implies also a duty; one must | > `\ not conceal any part of what one has recognized to be true.” | > _o__) —Albert Einstein | > Ben Finney > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Python 3.2 vs Java 1.6
Hi All, How does python 3.2 fare compared to Java 1.6 in terms of performance ? any pointers or observations ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
shared python module ?
Hi all, I have two version of python 2.6 and 2.7. Now Is there any way that I install a python module (from pypi) and import it across both the versions ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: do something every n seconds
while True: time.sleep(10) print('hello python!') HTH, KM On Thu, Nov 25, 2010 at 8:35 PM, Steve Holden wrote: > On 11/25/2010 6:38 AM, Santiago Caracol wrote >> Hello, >> >> how can I do something (e.g. check if new files are in the working >> directory) every n seconds in Python? >> > Look at the sched library, which was written to take care of > requirements like this. Use time.sleep() as your delay function and > time.time() as your time function. > > regards > Steve > -- > Steve Holden +1 571 484 6266 +1 800 494 3119 > PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ > See Python Video! http://python.mirocommunity.org/ > Holden Web LLC http://www.holdenweb.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: NoSQL Movement?
Hi, this would be a good place to start http://en.wikipedia.org/wiki/NoSQL http://nosql-database.org/ HTH, Krishna On Thu, Mar 4, 2010 at 7:41 AM, Avid Fan wrote: > Jonathan Gardner wrote: > > >> I see it as a sign of maturity with sufficiently scaled software that >> they no longer use an SQL database to manage their data. At some point >> in the project's lifetime, the data is understood well enough that the >> general nature of the SQL database is unnecessary. >> >> > I am really struggling to understand this concept. > > Is it the normalised table structure that is in question or the query > language? > > Could you give some sort of example of where SQL would not be the way to > go. The only things I can think of a simple flat file databases. > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Dictionary or Databaseè¼lease advise
Hi, Probably u should try couchdb! its a document oriented database. ( apache.couchdb.org) u can store your dictionaries as json documents and yes they are simple text files; data structures cna be directly stored into JSON documents. memory efficient too.. python module @ http://code.google.com/p/couchdb-python/ HTH Krishna ~~~ On Sat, Feb 27, 2010 at 1:39 AM, Roy Smith wrote: > In article > <891a98fa-c398-455a-981f-bf72af772...@s36g2000prh.googlegroups.com>, > Jeremy wrote: > > > I have lots of data that I currently store in dictionaries. However, > > the memory requirements are becoming a problem. I am considering > > using a database of some sorts instead, but I have never used them > > before. Would a database be more memory efficient than a dictionary? > > I also need platform independence without having to install a database > > and Python interface on all the platforms I'll be using. Is there > > something built-in to Python that will allow me to do this? > > > > Thanks, > > Jeremy > > This is a very vague question, so it'll get a vague answer :-) > > If you have so much data that you're running into memory problems, then > yes, storing the data externally in an disk-resident database seems like a > reasonable idea. > > Once you get into databases, platform independence will be an issue. There > are many databases out there to pick from. If you want something which > will work on a lot of platforms, a reasonable place to start looking is > MySQL. It's free, runs on lots of platforms, has good Python support, and > there's lots of people on the net who know it and are willing to give help > and advice. > > Databases have a bit of a learning curve. If you've never done any > database work, don't expect to download MySql (or any other database) this > afternoon and be up and running by tomorrow. > > Whatever database you pick, you're almost certainly going to end up having > to install it wherever you install your application. There's no such thing > as a universally available database that you can expect to be available > everywhere. > > Have fun! > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Manyfile Processing
use glob module Krishna On Fri, Dec 4, 2009 at 6:37 PM, Diez B. Roggisch wrote: > u...@domain.invalid schrieb: > >> Hey, >> >> sorry if i bother you with a beginners question but i have an issue >> with processing a bunch of files. They are some arithmetic lists the >> processing of one file is an easy task but how do i process many files? >> I tried reading that files in to a list and looping over the list >> elements but the function won't accept any arguments other than a string. >> >> I would appreciate if you could help me. >> > > for filename in list_of_filenames: >do_something_with_one_file(filename) > > Unless you disclose more of what your actual code looks like, there isn't > more we can do. > > Diez > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Delaunay triangulation
check CGAL (cgal.org) it has python bindings Krishna On Wed, Dec 2, 2009 at 11:28 PM, David Robinow wrote: > On Tue, Dec 1, 2009 at 8:31 PM, Vincent Davis > wrote: > > Anyone know of a python implementation of Delaunay triangulation? > > Matplotlib has one. > There's also Delny @pypi > > It's been several years since I needed this. I can't remember the > pros/cons. > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Implementation of Book Organization tool (Python2.[x])
> Though many would disagree, I consider XML as a form of database though > it is only suitable for data exchange. XML is suitable for low- to > medium-volume purpose and when compatibility with various systems is > extremely important (nearly any OS and any programming language has XML > parsers; porting a DBMS system may not be as easy as that). Thanks for the feedback. I consider XML as not very readable, so I prefer a Mark-up language like YAML. Cleaner syntax... but well, that's personal preference. > Python dictionary is stored in memory and closing the program == > deleting the database. [...] My error.. although pickling I would only "prefer" if organizing <100 books. -- http://mail.python.org/mailman/listinfo/python-list
Implementation of Book Organization tool (Python2.[x])
Hi together, I'm a python-proficient newbie and want to tackle a program with Python 2.x, which basically organizes all my digital books (*.pdf, *.chm, etc..) and to give them specific "labels", such as: "Author" -> string "Read" -> boolean "Last Opened:" -> string and so on.. Now my question is: Is it a better method to use a /database/, a /static File/, with some Markup (e.g.: YAML, XML), a Python dictionary or are there better ways I don't know of.., for organizing my books collection? I'm sure you can do it in any way above, but I'm apelling to /your/ personal experience and preference. Please give me at least one reason, why. --- I think we are in Rats' Alley where the dead men lost their bones. -- T.S. Eliot -- http://mail.python.org/mailman/listinfo/python-list
Re: Shebang line problems and python
assuming that ur on linux/unix and assuming that u have shebang line as #!/usr/bin/python in ur script set permissions like this chmod 755 myscript.py and then run the script as ./myscripy.py OR simply run the python script as "python myscript.py" at the shell prompt (note that this doesnt need shebang line in ur script file) HTH, Krishna On Thu, Sep 17, 2009 at 1:46 PM, Steven D'Aprano < ste...@remove.this.cybersource.com.au> wrote: > On Wed, 16 Sep 2009 21:35:21 -0700, Blaine wrote: > > > bla...@attila ~/tmp $ cat ./shebang-test > > #!/usr/bin/python > > import sys > > sys.stdout.write("Hello, world.\n") > > bla...@attila ~/tmp $ ./shebang-test > > ./shebang-test: line 2: import: command not found ./shebang-test: line > > 3: syntax error near unexpected token `"Hello, world.\n"' > > ./shebang-test: line 3: `sys.stdout.write("Hello, world.\n")' > > > I've seen something similar to this, which was caused by invisible ctrl-Z > characters somehow getting into my text file. If you view a hexdump of > the file, are there any unexpected characters in the file, particularly > before or between the # ! characters? > > If not, what happens if you run the file directly with Python? > > python shebang-test > > > > -- > Steven > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: bad behaviour in interactive Python prompt
On 14 Jul., 15:26, Mark Dickinson wrote: > Where did your version of Python 2.6 come from? > > If you built your copy of Python 2.6 from source, then the problem is > probably that either the readline library is missing, or (much more > likely) the include files for the readline library are missing. Look > for a package called something like libreadline5-dev or readline-devel > and install it, and then try rebuilding Python. > > Mark Yes, I built it from source and never thought that there might be such a library. Now I've re-compiled and my problem is solved! Have many thanks Mark, and Chris Rebert, too, who responded to my deleted post, which I've received per mail. Sorry for that incidence. Cheers, Kenny -- http://mail.python.org/mailman/listinfo/python-list
Re: bad behaviour in interactive Python prompt
On 14 Jul., 15:26, Mark Dickinson wrote: > Where did your version of Python 2.6 come from? > > If you built your copy of Python 2.6 from source, then the problem is > probably that either the readline library is missing, or (much more > likely) the include files for the readline library are missing. Look > for a package called something like libreadline5-dev or readline-devel > and install it, and then try rebuilding Python. > > Mark Yes, I built it from source and never thought that there might be such a library. Now I've re-compiled and my problem is solved! Have many thanks Mark, and Chris Rebert, too, who responded to my deleted post, which I've received per mail. Sorry for that incidence. Cheers, Kenny -- http://mail.python.org/mailman/listinfo/python-list
bad behaviour in interactive Python prompt
Hi, I'm experiencing a strange behaviour of the Python prompt when using the four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of getting the previous and next command respectively I get ugly characters. See it yourself: http://tinypic.com/view.php?pic=m78cgp&s=3 This is not directly Python-specific, but you feel quite handicapped if you must rewrite each command again... so my obvious question is: How can I fix this? Please, let me know if you can tell me something. Additional information: I'm running Ubuntu Linux I've tried the python prompt in several shell environments and got the same issue in csh, dash... all negative. Cheers, Kenny -- http://mail.python.org/mailman/listinfo/python-list
python-list@python.org
Hi, I'm experiencing a strange behaviour of the Python prompt when using the four arrow keys ( not the VIM' nor Emacs' ones ;-) ). Instead of getting the previous and next command respectively I get ugly characters. See it yourself: http://tinypic.com/view.php?pic=m78cgp&s=3 This is not directly Python-specific, but you feel quite handicapped if you must rewrite each command again... so my obvious question is: How can I fix this? Please, let me know if you can tell me something. Additional information: I'm running Ubuntu Linux I've tried the python prompt in several shell environments and got the same issue in csh, dash... all negative. Cheers, Kenny -- http://mail.python.org/mailman/listinfo/python-list
update python version
Hi all, Is there a way to update python 2.6.1 to 2.6.2 using easy_install ? thanks, regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Geometry package
Hi, I hope this is what u need : http://cgal-python.gforge.inria.fr/ HTH KM On Sun, Mar 29, 2009 at 1:55 AM, Justin Pearson wrote: > Hi all, > > I'm looking for a geometry package in Python; something that will let > me define line segments, and can tell me if two line segments > intersect. It would be nice if the lines could be defined in n-space > (rather than be confined to 2 or 3 dimensions), but this is not a hard > constraint. Other functionality might include support for polygons, > convex hulls, etc. > > I've searched Pypi and found a package called Shapely, but when I > followed its installation instructions, it threw a bunch of errors and > tried to re-install Python :(. > > Is there a well-known geometry package I'm missing? > > Thanks for your help, > Justin > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing python2.6.1
Dear all, I have a problem with multiprocessing module usage with python2.6.1 Here Pool object is to be instantiated with 50 processes and the method 'run' has to be called with pool object. My actual requirement is to reuse the 50 processes for further processing until 100 items. # import multiprocessing as mp def add(a,b): return a+b if __name__ == '__main__': p = mp.Pool(processes=50) y = 40 for x in range(100): p.apply_async(run, (x, y) ) ## The problem now is that it creates only 32 processes (and not more) and exits with processing first 32 numbers from range(100) . Is there a cap on the number of subprocesses one can fork ? Even then, once these 32 processes r free, I would like to reuse them with next 32 inputs (x) from range(100 ) in that order. how could i accomplish this ? thanks in advance. KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Embarrasing questio
Hi, you could do it this way also : if i in [3,5]: do something... KM ~ On Fri, Feb 13, 2009 at 1:19 AM, Michele Simionato < michele.simion...@gmail.com> wrote: > On Feb 12, 5:07 pm, TechieInsights wrote: > > On Feb 12, 9:03 am, Catherine Heathcote > > > > wrote: > > > But I just cant find it. How do I do an or, as in c/c++'s ||? Just > > > trying to do something simple, the python equivilent of: > > > > > if(i % 3 == 0 || i % 5 == 0) > > > > > Thanks. > > > > in 2.5 and above you can do > > if any(i%3 == 0, i%5 == 0) > > You are missing a few parenthesis: if any([i%3 == 0, i%5 == 0]) (but > the idiomatic solution is to use or). > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: python for *nix system admins
import os HTH KM ~~ On Sat, Sep 27, 2008 at 1:35 PM, Lars Stavholm <[EMAIL PROTECTED]> wrote: > Hi All, > > I'm new to this list and hoping that this is not off-topic. > If it is, please point me in the right direction. > > I seem to recollect a python module or library for *nix sysadmins, > but I can't for the life of me find it again. > > The module (or library) somehow added unix command capabilities > to the python language. It seemed like a lesser known, perhaps new, > python library or module. > > Any input or ideas appreciated > /Lars Stavholm > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
python 3.x third party modules
Hi all, I would like to look at third party modules which are python 3.0 ready. could some one point me to such a resource ? If its not available, it would be useful to host a page regarding this on python.org ? any comments ? KM -- http://mail.python.org/mailman/listinfo/python-list
Re: improving a huge double-for cycle
how abt this ? N = len(IN) for k in range(N): for j in range(N): if j >= k: # or k <= j doSomething() KM ~~~ On Thu, Sep 18, 2008 at 6:27 PM, Tim Chase <[EMAIL PROTECTED]>wrote: > Code: Select all >>for i in range(len(IN)): #scan all elements of the list IN >> for j in range(len(IN)): >>if i <> j: >> if IN[i].coordinates[0] == IN[j].coordinates[0]: >> if IN[i].coordinates[1] == IN[j].coordinates[1]: >> SN.append(IN[i].label) >> >> >> Unfortunately my len(IN) is about 100.000 and the running time about >> 15h :( >> >> Any idea to improve it? >> > [snip] > >> I have already tried to group the "if statements" in a single one: >> >> Code: Select all >>if i <> j and if IN[i].coordinates[0] == IN[j].coordinates[0] and >> if IN[i].coordinates[1] == IN[j].coordinates[1]: >> >> but no improvements. >> > > It's like rearranging deck-chairs on the Titanic :) Yes, it may give a > speed up, but what's 3 seconds when you're waiting 15hr :) > > Not knowing the len(IN[x].coordinates) or their structure, if it's a list > of len==2, you should be able to just do > > if i <> j and IN[i].coordinates == IN[j].coordinates > > or > > if i <> j and IN[i].coordinates[:2] == IN[j].coordinates[:2] > > However, again, this is just polish. The big problem is that you have an > O(N^2) algorithm that's killing you. > > 1) use xrange instead of range to save eating memory with a huge unneeded > array. > > 2) unless you need to append duplicate labels, you know that when I and J > are swapped, you'll reach the same condition again, so it might be worth > writing the outer loops to eliminate this scenario, and in the process, but > just starting at i+1 rather than i, you can forgo the check if "i<>j". > > Such changes might look something like > > for i in xrange(len(IN)): >for j in xrange(i+1, len(IN)): > if IN[i].coordinates == IN[j].coordinates: >SN.append(IN[i].label) > > If my college algorithms memory serves me sufficiently, this reduces your > O(N^2) to O(N log N) which will garner you some decent time savings. > > -tkc > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: Resolver One 1.2 released
Hi, sounds great - but disappointing to find it only available on window$. Is there any Linux release in near future ??? KM ~~ On Tue, Aug 19, 2008 at 6:10 PM, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: > We are proud to announce the release of Resolver One, version 1.2 - > the largest IronPython application in the world, we think, at 38,000 > lines of production code backed up by 150,000 lines of unit and > functional tests. > > Resolver One is a Rapid Application Development tool for analysing and > presenting business data, using a familiar spreadsheet interface > combined with a powerful IronPython-based scripting capability that > allows you to insert your own code directly into the recalculation > loop. > > For version 1.2, we have on big headline feature; a new function > called > RunWorkbook that allows you to "call" one spreadsheet from another, > passing in parameters and pulling out results - just like functions, > but > without having to code the function by hand. This allows you to mix > spreadsheet-based and code-based logic, using the best paradigm for > the job in hand. > > We've also added a whole bunch of usability enhancements - the full > (long!) changelist is up on our website, or you can see a screencast: > <http://www.resolversystems.com/screencasts/release-1.2> > > It's free for non-commercial use, so if you would like to take a > look, > you can download it from our website: > <http://www.resolversystems.com/get-it/> (registration no longer > required). > > > Best regards, > > Giles > -- > Giles Thomas > MD & CTO, Resolver Systems Ltd. > [EMAIL PROTECTED] > +44 (0) 20 7253 6372 > > Try out Resolver One! <http://www.resolversystems.com/get-it/> > > 17a Clerkenwell Road, London EC1M 5RD, UK > VAT No.: GB 893 5643 79 Registered in England and Wales as company > number 5467329. > Registered address: 843 Finchley Road, London NW11 8NA, UK > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: A GUI framework for running simulations
Hi, check SimPy module and then http://www.showmedo.com/videos/series?name=pythonThompsonVPythonSeries KM On Jan 23, 2008 8:10 PM, Guilherme Polo <[EMAIL PROTECTED]> wrote: > 2008/1/23, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > Hello! I am currently working on writing a simulation engine for > > special relativity physics. I'm writing it in Python, of course. I'm > > doing fine with the engine, but I want a GUI framework in which I > > could use it conveniently, and test different setups on it. I'm not so > > strong with GUI programming. I looked at Tkinter, I looked at > > WxPython, I looked at PythonCard. It all looks pretty daunting. > > > > My question is, does there exist a GUI package that is intended > > specifically for simulations? I saw a program called Golly, which is a > > simulation for Conway's Game of Life. Its GUI had most of the features > > I needed. For example, you can load a setup, there are "play" and > > "stop" buttons, you can change a setup and save it, etc. > > > > Golly uses wxWidgets, and if you are planning to use Python then you > would be using wxPython. > > > So does anyone know of a general GUI framework for running > > simulations? > > All them serves this purpose. The main part of your gui application > will be a custom widget that you will need to do yourself. > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > > > > -- > -- Guilherme H. Polo Goncalves > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Trajectory Module?
Hi have a look at these demos (includes trajectory etc) with VPython http://showmedo.com/videos/series?name=pythonThompsonVPythonSeries best wishes, KM -- On Jan 2, 2008 5:38 AM, Stef Mientki <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Greetings, > > > > I was wondering if there was a python Module/Library out there that > > handles some trajectory/physics stuff like moving an object along a > > straight path in an X,Y 2D (or 3D) plane or calculating parabolic > > arcs. I'd really settle for just the moving of an object along a > > straight line. > > > > I know it's not terribly difficult to implement this on your own, but > > I'd rather not re-invent the wheel if someone else already did a good > > job of it the first time. > > > > Thanks! > > > Depends on how detailed / graphical you've in mind. > You might be interested in this: > > > http://oase.uci.kun.nl/~mientki/data_www/pylab_works/pw_animations_screenshots.html<http://oase.uci.kun.nl/%7Emientki/data_www/pylab_works/pw_animations_screenshots.html> > > I've put a scanned version of my written notes about the trajectory > example. > No need for ODE in my very simple mind, because the functions describing > the solution are already known. > > If you want to view the demos / animations, > be sure to view the demo at the bottom first, > because it explains the philosophy behind the program. > Only 1 major feature is not described in this demo (because when I made > the demo I had no solution for it, now I think I have) > and that is : > an integrated help / instruction / assignment / fill-in forms / > judgement, specially for educational puposes. > > The program is not yet released, > because I'm now cleaning it up and debugging it (by making demos ;-) > cheers, > Stef > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: joining rows
Hi On Dec 29, 2007 3:08 PM, Beema shafreen <[EMAIL PROTECTED]> wrote: > hi every body, > > I have two columns in a file separted by tabs > > If the column1 is common in the row1 and row2 then it should be column > 2 should be displayed in the single line. > eg: > col 1 col2 > A1 > A2 > A3 > B1 > C 2 > D 3 > D 4 > The result should be > > A1|2|3 > B1 > C2 > D3|4 > > What should I do to get my results > > Looking at the answer u require , u can clearly make a dictionary if list datastructure! where dictionary keys are A,B, C ,D and corresponding values are list if items (ie., 1,2,3 ...) Once u have such a dict loaded, its kust a matter of accessing that list via a key and display it joined! HTH KM > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: comparing dictionaries to find the identical keys
Hi On Dec 28, 2007 4:55 PM, Beema shafreen <[EMAIL PROTECTED]> wrote: > hi everybody , > i need to compare two dictionary's key. I have written a script > gene_symbol = {} > probe_id = {} > result = {} > def getGene(fname): > fh = open(fname , 'r') > for line in fh: > yield line > fh.close() > for line in getGene("symbol_hu133"): > data1= line.strip().split('#') > probe_give = data1[0].strip() > gene_give = data1[1].strip() > gene_symbol[probe_give] = gene_give > #print gene_symbol.keys() > for line in getGene("gds1428.csv"): > data = line.strip().split(',') > probe_get = data[0].strip() > probe_id[probe_get] = data > if gene_symbol.keys() == probe_id.keys(): > print gene_symbol.keys(), probe_id.values() > > > can anybody show me the error I make here ,while comparing the keys of > two dictionaries so that i print the values of the dictionaries whoes Keys > are Identical > > Remember that ur looking for commonly occuring keys between the two dictionaries. And dictionary.keys() generates a 'list' of keys in that dictionary. So, u r comparing a list with another in an if construct and printing the same which is not what u want to do. Ideally u should iterate over a list of items and check out if it is present or not in the other list and then print corresponding values. Alternately this can also be done with sets module by converting the list into a set object and do a simple intersection of the two sets, by which u get the commonly occuring items. HTH KM > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
module level subclassing
Hi all, Is there a way to access the classes defined in the __init__.py into the modules files in the directory? for example say i have a module (dir) M with contents __init__.py and a.pyand b.py a.py and b.py would like to subclass/instantiate a class defined in __init__.py how's that possible ? kindly enlighten regards, KM -- http://mail.python.org/mailman/listinfo/python-list
module organization/inheritance problem
Hi all, I have a python module (M) with the following structure M (directory) | __init__.py (class Base(object) ...) | - a.py (class A(Base) ...) | - b.py (class B(Base) ...) | - c.py (class C(Base) ...) The __init_.py has a class which all the sub-modules (a,b,c) classes inherit from. * The class has an __init__ method which imports certian modules and nothing more * Each submodule (a,b,c) has a class each which are derived from the class defined in __init__.py * Each submodule's classe's __init__ method extends the base class __init__ method and imports some more modules specific to be used in that class I have thought of such subclassing to avoid repetition of importing modules across the directory hierarchy beneath. Now is the class defined in __init__.py is not acessible to the submodules. what could be done to make it work ? am i missing something ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclasses: timestamping instances
Hi, But why does it show varied difference in the time between a and b instance creations when __metaclass__ hook is used and when not used in class Y ? I dont understand that point ! KM On 9/1/07, Michele Simionato <[EMAIL PROTECTED]> wrote: > > On Sep 1, 6:07 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > > > > > Debugging with Wing IDE and examining the classes at a breakpoint shows > > this to be true (even after Y's __metaclass__ assignment is commented > out): > > > > >>> X.__metaclass__ > > > > >>> Y.__metaclass__ > > > > >>> > > For the benefit of the readers I will just point out that in order > to determine the metaclass of a class it is far better NOT to relay on > the > __metaclass__ attribute. The right thing to to is to look at the > __class__ > attribute, or to use type. Here is a (made up) example > where .__metaclass__ gives > the wrong result: > > > In [9]: class M(type): pass >...: > > In [10]: class B: __metaclass__ = M >: > > In [11]: B.__metaclass__ = None # now the hook is set to None, but the > metaclass does not change > > In [12]: B.__class__ > Out[12]: > >Michele Simionato > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
metaclasses: timestamping instances
Hi all, I have extended a prototype idea from Alex Martelli's resource on metaclasses regarding time stamping of instances. import time class Meta(type): start = time.time() def __call__(cls, *args, **kw): print 'Meta start time %e'%cls.start x = super(Meta, cls).__call__(*args, **kw) current_time = time.time() x._created = current_time - Meta.start Meta.start = time.time() return x class X(object): __metaclass__ = Meta class Y(X): __metaclass__ = Meta pass a = X() print 'a time stamp %e'%a._created b = Y() print 'b time stamp %e'%b._created print abs(a._created - b._created) I donot understand the difference between 1) setting __metaclass__ to 'Meta' in class Y 2) not setting __metaclass__ to Meta in class Y Why is the difference in behaviour of time stamping between 1 & 2 ? kindly enlighten regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner in python
Hi pls redefine ur problem. I donot understand what u wanted to accomplish . is it that u wanted to check and represent the redundant entry numbers as one entry or is it with the isoform id as a single entry and without considering other data like start and stop ? also observe that when u consider the whole line in the data file, they are all unique - there is no redundancy. KM --- On 8/2/07, Beema shafreen <[EMAIL PROTECTED]> wrote: > > Hi everybody , > I am a beginner in python, > I have to fetch the redundant entries from a file, > > code: > > import re > L = [] > fh = open('ARCHITECTURE_MAIN.txt', 'r') > for line in fh.readlines(): > data =line.strip() > # splitted = data.split('#') > L.append(data) > fh.close() > > > M=L > for x in L: > x = x.split('#') > for y in M: > y = y.split('#') > x_data = x[0],x[1],x[2],x[3] > #print x_data > y_data = y[0],y[1],y[2],y[3] > #print y_dat > if x_data[0] == y_data[0]: > print x_data > > > i get the result as a tupule, > the text file which has datas separated by hash > entry#isoform#start#stop# i have to check upto this > > 00250_1#ARCH_104#61#89#Literature#9224948#00250 > 00250_1#ARCH_104#97#126#Literature#9224948#00250 > 00250_1#ARCH_104#139#186#Literature#9224948#00250 > 00251_1#ARCH_463#7#59#SMART##00251 > 00251_1#ARCH_463#91#121#SMART##00251 > 00251_1#ARCH_463#251#414#SMART##00251 > 00251_1#ARCH_463#540#624#SMART##00251 > 00252_1#ARCH_474#1#21#Literature#8136357#00252 > 00252_1#ARCH_393#481#501#Literature#8136357#00252 > 00252_1#ARCH_463#523#553#SMART##00252 > 00253_1#ARCH_82#37#362#SMART##00253 > 00253_1#ARCH_54#365#522#SMART##00253 > 00253_1#ARCH_104#589#617#SMART##00253 > 00253_1#ARCH_104#619#647#SMART##00253 > 00253_1#ARCH_104#684#712#SMART##00253 > 00254_1#ARCH_82#27#352#SMART##00254 > 00254_1#ARCH_54#355#510#SMART##00254 > 00254_1#ARCH_104#576#604#SMART##00254 > 00254_1#ARCH_104#606#634#SMART##00254 > 00254_1#ARCH_104#671#699#SMART##00254 > 00255_1#ARCH_82#56#425#SMART##00255 > 00255_1#ARCH_54#428#582#SMART##00255 > 00255_1#ARCH_104#696#724#SMART##00255 > > > > > can you suggest me ,what are the improvement i have to make in the above > code > regards > shafreen > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: beginner in python
Hi Welcome to python ! there a a few suggestions in ur code which is a good practice to follow. In the snippet: > > for x in range(len(x_value)): > > x_co = float(x_value[x])-float(x_value[x+1]) > > y_co = float(y_value[x])-float(y_value[x+1]) > > z_co = float(z_value[x])-float(z_value[x+1]) > > data = math.sqrt(x_co)*(x_co)+(y_co)*(y_co)+(z_co)*(z_co) > > print data U suddenly change the indent from four spaces which u followed in previous for loop. pls maintain consistency in indent. Standard convention is to use four spaces for indent. Another problem is that u have not closed the filehandle in the program! HTH KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Please help on Binary file manipulation
Hi, I assume ur on a linux/unix box... pls check the manual for 'split' command in linux/unix this does ur job regards, KM --- On 6/5/07, Pieter Potgieter <[EMAIL PROTECTED]> wrote: Hi all I have a binary file of about 600kbytes - I want to break it up in file chunks of 1085 bytes - every file must have a new file name. The data is binary video frames (370 frames) - I want to play the data back into an embedded system frame/file by file. I am a complete Python newby - but have C/C++ skills. Please supply/help me with an snippet or example Thanks Pieter *** Disclaimer: The information contained in this communication is confidential and may be legally privileged. It is intended solely for the use of the individual or entity to whom it is addressed and others authorised to receive it. Any review, retransmission, dissemination, copying, disclosure or other use of, or taking of any action in reliance upon, this information by person or entities other then the intended recipient is prohibited. If you have received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and return and/or destroy the original message and all copies from any computer. Denel (Pty) Ltd exercises no editorial control over e-mail messages originating in the organisation and does not accept any responsibility for either the contents of the message or any copyright laws that may have been violated by the person sending this message. Denel (Pty) Ltd is neither liable for the proper and complete transmission of the information contained in this communication nor any delay in its receipt. This message should not be copied or used for any purpose other than intended, nor should it be disclosed to any other person. *** -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheriting from Python list object(type?)
Hi, u have the answer in ur question itself :) u dont need to redefine list methods again - just inherit from the builtin-list-type. try this with new style classes: code ### class Point(list): def __init__(self,x,y): super(Point, self).__init__() self.x = x self.y = y p = Point(2,3) print dir(p) print type(p) code regards KM -- On 23 May 2007 09:58:36 -0700, Mangabasi <[EMAIL PROTECTED]> wrote: Howdy, I would like to create a Point class that lets me use Point instances like the following example. >>> p = Point(3, 4) >>> p.x 3 >>> p.y 4 >>> p.z 1 >>> p[0] 3 >>> p[1] 4 >>> p[1] = 5 >>> p.y 5 >>> other than the x, y, z attributes, these instances should behave like regular Python lists. I have created something like : class Point: def __init__(self, x, y, z = 1): self.list = [x, y, z] def __repr__(self): return str(self.list) def __str__(self): return str(self.list) def __getattr__(self, name): if name == 'x': return self.list[0] elif name == 'y': return self.list[1] elif name == 'z': return self.list[2] else: return self.__dict__[name] def __setattr__(self, name, value): if name == 'x': self.list[0] = value elif name == 'y': self.list[1] = value elif name == 'z': self.list[2] = value else: self.__dict__[name] = value def __getitem__(self, key): return self.list[key] def __setitem__(self, key, value): self.list[key] = value def __getslice__(self, i, j): return self.list[i : j] def __setslice__(self, i, j, s): self.list[i : j] = s def __contains__(self, obj): if obj in self.list: return True else: return False There must be a way to inherit from the list type without having to redefine all the methods and attributes that regular lists have. i.e. class Point(list): ... Can someone provide an example? Thanx in advance -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: __getattr__ and __getattribute__
Oh thats lucid! thanks for the explanation. regards KM - On 5/9/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote: En Tue, 08 May 2007 08:22:03 -0300, km <[EMAIL PROTECTED]> escribió: > i find it difficult to understand the difference between the magic > methods > __getattr__ and __getattribute__ > and so donot know when to use former or later. > can someone brief me on it ? This is better understood with a bit of history. On earlier Python versions (before 2.2) the only object model available was what we now call "classic classes". Classic instances hold their attributes in a dictionary, called __dict__. Attribute lookup starts at this instance dictionary; if not found, continues in the class, and its parent class, all along the inheritance tree. If still not found, __getattr__ (if it exists) is called, and should return the attribute value or raise AttributeError. That is, __getattr__ is called *last*, and *only* when the attribute was not previously found in the usual places. Since Python 2.2, there are "new style classes" available; they inherit directly or indirectly from object. A new style instance may not even have a __dict__. An existing __getattribute__ method is tried *first*; it should return the attribute value or raise AttributeError. If no custom __getattribute__ exists, the default object.__getattribute__ is used. As a last resort, if __getattr__ is defined, it is called. OTOH, there is a single version of __setattr__, which is always invoked when setting an attribute. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
__getattr__ and __getattribute__
Hi all, i find it difficult to understand the difference between the magic methods __getattr__ and __getattribute__ and so donot know when to use former or later. can someone brief me on it ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
distance map
Hi all, Is there any module to make a network diagram given a 2-D matrix of distances ? any hints regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Best Free and Open Source Python IDE
check out SPE (StanisPpython Editor) KM On 9 Feb 2007 10:43:00 -0800, Bastos <[EMAIL PROTECTED]> wrote: On Feb 8, 10:03 am, "Srikanth" <[EMAIL PROTECTED]> wrote: > Yes, > > All I need is a good IDE, I can't find something like Eclipse (JDT). > Eclipse has a Python IDE plug-in but it's not that great. Please > recommend. > > Thanks, > Srikanth Gedit and some plugins, definitely. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: best package for a physical simulation?
Hi, checkout MMTK package http://dirac.cnrs-orleans.fr/MMTK/ regards, KM On 1/24/07, Robert Kern <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: > Hello everyone, > i would like to use python to perform some simulation involving collisions > of colloidal particles. > which is the best package/engine to do that in python? What kind of numerical methods does such simulation require? -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
setup.py ./configure arguments
Hi, how do i pass '--enable-shared' etc arguments to Python2.5 setup.py ? do i need to edit some file ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
module hierarchy snapshot
Hi, Is there any good tool get a snapshot of module hierarchy for custom python modules ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: regex problem
HI Tim, oof! thats true! thanks a lot. Is there any tool to simplify building the regex ? regards, KM On 11/23/06, Tim Chase <[EMAIL PROTECTED]> wrote: > line is am trying to match is > 1959400|Q2BYK3|Q2BYK3_9GAMM Hypothetical outer membra29.90.00011 1 > > regex i have written is > re.compile > (r'(\d+?)\|((P|O|Q)\w{5})\|\w{3,6}\_\w{3,5}\s+?.{25}\s{3}(\d+?\.\d)\s+?(\d\.\d+?)') > > I am trying to extract 0.0011 value from the above line. > why doesnt it match the group(4) item of the match ? > > any idea whats wrong with it ? Well, your ".{25}\s{3}" portion only gets you to one space short of your 29.9, so your "(\d+..." fails to match " 29.9" because there's an extra space there. My guess (from only one datum, so this could be /way/ off base) would be that you mean "\s{4}" or possibly "\s{3,4}" It seems like a very overconstrained regexp, but it might be just what you need to isolate the single line (or class of line) amongst the chaff of thousand others of similar form. -tkc -- http://mail.python.org/mailman/listinfo/python-list
regex problem
Hi all, line is am trying to match is 1959400|Q2BYK3|Q2BYK3_9GAMM Hypothetical outer membra29.90.00011 1 regex i have written is re.compile (r'(\d+?)\|((P|O|Q)\w{5})\|\w{3,6}\_\w{3,5}\s+?.{25}\s{3}(\d+?\.\d)\s+?(\d\.\d+?)') I am trying to extract 0.0011 value from the above line. why doesnt it match the group(4) item of the match ? any idea whats wrong with it ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: how to print pdf with python on a inkjet printer.
i dont see os.startfile in python2.5 installation on my system :-( KM On 11/19/06, Thomas Heller <[EMAIL PROTECTED]> wrote: Gabriel Genellina schrieb: > At Friday 17/11/2006 17:40, Tim Roberts wrote: > >> > double wow! as it is my customer wants me to print to the default >> > printer. >> > can you please help me with the command for rendering the pdf to the >> > printer with acrobat using python? >> >>You'll have to use the registry to find "acrord32", but once you find >>it, you just do: >> os.system( "\\Program Files\\Adobe\\Acrobat 7.0\\Reader\acrord32.exe >>/p xxx.pdf" ) >>The /p switch requests printing. > > Or just let Windows do the dirty work of locating Adobe Reader, > figuring out the parameters and such: > > import win32api > win32api.ShellExecute(0, "print", path/to/document.pdf, None, None, 0) > Note that in Pyhton2.5, os.startfile was extended to accept an optional second parameter; so os.startfile(path/to/document.pdf, "print") should also work. Thomas -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: What python modules are available?
Hi all, Thats ridiculous! why is that the numpy implementation documentation is put on sale and not available freely to everyone? regards, KM --- On 11/18/06, Robert Kern <[EMAIL PROTECTED]> wrote: Why Tea wrote: > All I need is something to provide me with array features. I can't > remember why I chose to use numarray a while ago... You will probably want numpy these days. numarray is being phased out. http://numpy.scipy.org/ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
java python GPL
Hi all, what does Java released under GPL mean to python ? could it hamper python development on the long run? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
biopython SProt
Hi all, Biopython's SProt module doesnt seem to work with current Uniprot KB . do anyone have a parser to read Uniprot format files ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__.py
Hi, wow ! i tried it and it works like charm! could access variables declared at root module dir in submodules. also i would like to know if i can have an abstract class declared in __init__.py with common variables ? regards, KMOn 11/14/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: "km" wrote:> I have a structure like this :> foo/__init__.py> foo/bar/__init__.py> foo/bar/firstmodule.py> foo/abc/__init__.py> foo/abc/secondmodule.py>> now i have some variables (paths to data files) common, to be used in > first module and second modules respectively.> can i set those variables in foo/__init__.py so that i can access them by> foo.mypath1 in first and second submodule class definitions?looks ok to me, as long as you remember to actually import foo into your submodules.have you tried it?--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: __init__.py
Hi, I have a structure like this : foo/__init__.py foo/bar/__init__.py foo/bar/firstmodule.py foo/abc/__init__.py foo/abc/secondmodule.py now i have some variables (paths to data files) common, to be used in first module and second modules respectively. can i set those variables in foo/__init__.py so that i can access them by foo.mypath1 in first and second submodule class definitions? if not anyother way out ? regards, KMOn 11/14/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: km wrote:> what is the use of __init__.py file in a module dir ?it tells Python that the directory is a package directory. if you have mydir/foo/__init__.py mydir/foo/module.py and mydir is on the path, you can do "import foo.module" or "from fooimport module". if you remove the __init__.py file, Python will nolonger look for submodules inside that directory. > Is it used to initialize variables that could be shared across sub> modules if set in __init__.py at root dir of module ?it's usually empty, or used to export selected portions of the packageunder more convenient names. given the example above, the contents of the __init__ module can be accessed via: import foo--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
__init__.py
Hi all, what is the use of __init__.py file in a module dir ? Is it used to initialize variables that could be shared across sub modules if set in __init__.py at root dir of module ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
cross connecting
HI all, I have a c executable in machine A which cannot execute on B. I am on machine B and i need python program to connect to A via telnet and run the program with arguments passed from program on B and at the end fetch back results to machine B. i would like to know , which set of modules are suitable for this sort of a work ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Python and CMS
Hi, check out Plone atop Zope. http://plone.org regards, KMOn 10/23/06, Sybren Stuvel <[EMAIL PROTECTED]> wrote: Kjell Magne Fauske enlightened us with:> I recommend taking a look at Django [1]. It is not a CMS right out > of the box, but writing one using the Django framework is not that> difficult.Django is my favourite as well. It's very easy to start building adynamic website.Sybren--Sybren Stüvel Stüvel IT - http://www.stuvel.eu/--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: references and buffer()
Hi all, Congratulations, you understand both Hinduism and Python better than Ido now. :) c.f.http://www.swami-krishnananda.org/brdup/brhad_III-09.html"Kati references, Yajnavalkya, iti?" the answer lies in a single line as pronounced by sri adi sankaracharya - "aham bramhasmi sivoha sivoham " , which is still not implemented in python. infact not in any other language! which is a limitatin of computers (and comp languages) - they simply arent intelligent. aham, tvam sah: cha madhye kim bhedam bhavati ? bhedam nasti ! Python uses two garbage collection schemes together. It uses referencecounting (when number of references goes to zero, remove object from memory) and mark-and-sweep (comb through process memory methodicallylooking for objects that are no longer accessible). This is whatallows it to collect cyclic structures, such as trees whose nodeslinks to their parents and vice versa. why is that python doesnt implement direct memory addressing provided a reference to an object exists ? GC intercedes at various intervals when convenient. I don't think itwould be immediate though. what is the interval and what is its effect on the performance of python interpreter ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: references and buffer()
Hi all,Say that you copy the contents of file foo into file bar and delete the original foo. Of course file bar still exists in this case. Notmuch of a difference; I haven't seen buffer objects yet (I am also newto Python), but the initialization for the buffer probably copieswhatever is in y somewhere. that means when u refer to an object with different names (variable), it referes to the same object- fine. but is it that the original object stays in memory until it is Garbage Collected ? is it that del() deletes the link of variable to the object and not the object ? and thats why u can access it from other variables ? You didn't modify the object that the variable /refers to/.Furthermore, numbers are immutable anyway. To continue with the Hindu god analogy, Vishnu did not cease to exist when any of his avatarspassed from the physical world; it is no different with objects inPython. vishnu analogy is a bit complicated as it is a manifestation of divine energy in terms of earthly object(avatar). Its clearly not a reference. each avatar is himself (vishnu). It is the same energy people around have too (coz of manifestation). ofcourse they dont realise coz of ego (id in python) and so the object class (divine energy) is the same - unlike python where we have different classes derived from object class. IOWa --> 10b -/Delete the 'a' reference and:b --> 10 got it! What is a little different is this: if there are no references left toan object (such as variables), the object the references point to will eventually be deleted. Variables are one way to have a reference to anobject. References to an object may also exist in a list, hash, orother data type. so the object exists until there are no references to it and will be Garbage Collected immediately? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: references and buffer()
Hi all, in the CPython implementation, it's the address where the object isstored. but that's an implementation detail. ok so can i point a vairiable to an address location just as done in C language ? >>> y = 'ATGCATGC' >>> x = buffer(y) >>> del(y) >>> x >>> print x ATGCATGC now even when i delete y, why is that x still exists ? thats true even in the case of vairable assignment which states it a a reference ! >>> a = 10 >>> b = a >>> del(a) >>> b 10 i always thought if u modify the referred variable/buffer object it should be reflected in the referenced variables/buffers objects . am i wrong ? does it mean that references in python are not true references ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
references and buffer()
Hi all, was looking at references in python... >>> a = 10 >>> b = a >>> id(a) 153918788 >>>id(b) 153918788 where a and b point to the same id. now is this id an address ? can one dereference a value based on address alone in python? is id similar to the address of a variable or a class ? read abt buffers as a refernce to a buffer object. actually i tried passing list and dict types to buffer function, but only with string type i could createa buffer reference, >>>y = 'GATCGTACC' >>>x = buffer(y, 0,8) >>> x >>>print x TCGTACC >>> id(y) -1085484104 >>> id(x) -1085476384 now the ids of y and x are not the same - why ? In which situatons are buffers used against the strings ? can i create a write buffer instead of readonly buffer ? what exactly are buffer object types ? and how can i instantiate them ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
psycopg: tz import error
Hi all,i have python 2.4.3 and 2.5 versions installed default python interpreter being 2.5have compiled psycopg2 with python2.4.3 setup.py.install , it installs in site-setup of 2.4.3 but when i login as a normal user and get into interctive python prompt of 2.4.3 , and " import tz " fails to import.do i need to set any env variable specially for 2.4.3 ? regards,KM -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: dmath 0.9 - Math routines for the Decimal type
and how different is MIT licence to GPL ? could u elaborate on that ? regards, KM On 9/26/06, Brian Beck <[EMAIL PROTECTED]> wrote: > Brian Beck wrote: > > What is dmath? > > == > > dmath provides the standard math routines for Python's arbitrary-precision > > Decimal type. These include acos, asin, atan, atan2, ceil, cos, cosh, > > degrees, e, exp, floor, golden_ratio, hypot, log, log10, pi, pow, radians, > > sign, sin, sinh, sqrt, tan, and tanh. > > Oh yeah, you may be wondering how this differs from decimalfuncs: > http://cheeseshop.python.org/pypi/decimalfuncs/1.4 > > The answer is that dmath has the complete set of math routines (not just a > subset), it's faster (from what I can tell), doesn't require its own > precision-setting method, and it's MIT instead of GPL licensed. > > -- > Brian Beck > Adventurer of the First Order > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
memory
Hi all,Is there any module to limit the memory usage of the python program ?regards,KM -- http://mail.python.org/mailman/listinfo/python-list
variable update
Hi all Is there any handy untility for checking if a variable is populated at runtime ? regards, KM -- 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: 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: 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
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: Building Python Based Web Application
Hi, I use Plone/Zope for and interface it with PostgreSQL . its pretty good. saves lot of time. ofcourse the learning curve is steep. Zope uses CSS heavily and since ur comfortable with it it shouldnt take muchtime building the site with much less coding in python. regards, KM On 9/9/06, Ramon Diaz-Uriarte <[EMAIL PROTECTED]> wrote: On 9/8/06, James Stroud <[EMAIL PROTECTED]> wrote:> Hello All, >> I am interested in setting up a modest invoicing system for some> consulting I am doing. I like the idea of managing this on the web and> creating invoices and printing them from a browser. However, I'm not > really sure where to start. I've played with some CMS applications, but> they seem more for blogging (mamba, wordpress, etc.). Ideally, I would> like to interface with mySQL (or whatever the favorite web-flavor > database app is these days). I would like to be able to use my python> skills.>> I confident that if I set out to write this from scatch, I will be> seriously re-inventing the wheel, perhaps several times over. >> So, my question is, does anyone know of a book and/or some kind of> framework that would make the best sense for what I am describing here?> I've heard of Zope, but I would like to make sure its appropriate for > the job before I spend 2 or 3 days getting acquainted with it. I'm adept> at HTML, python, CSS, python-CGI, and interfacing with mySQL through> DBI. I'm sure I could get something to work with these skills, but I > want to minimize wheel re-invention as much as possible.>> Basically, I want a jump start on data-base oriented web development> with a focus on applying my python skills.I think that Karrigell might do what you want, and you can read all the (excellent) documentation in a few hours. Otherwise, specially ifyou think you might get deeper into web-based stuff, with morecomplex/special/whatever needs, I'd probably try Pylons (which hasalso very nice and well organized docs). I have no direct experience with Django or TG, but I find them "overwhelming", specially comparedto Karrigell; Zope I find even more overwhelming.HTH,R.> --> James Stroud> UCLA-DOE Institute for Genomics and Proteomics > Box 951570> Los Angeles, CA 90095>> http://www.jamesstroud.com/116> --> http://mail.python.org/mailman/listinfo/python-list117>--Ramon Diaz-UriarteBioinformatics UnitSpanish National Cancer Centre (CNIO)http://ligarto.org/rdiaz --http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Where is Guido ? would be great to hear his opinion on GIL/ GC issues in future versions of Python. regards, KM On 7 Sep 2006 08:02:57 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: On 2006-09-06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:> Paul Rubin wrote:>> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> > (1) I think is here to stay, if you're going to tell programmers that>> > their destructors can't make program-visible changes (e.g. closing the>> > database connection when a dbconn is destroyed), that's a _huge_ change >> > from current practice that needs serious debate.>>>> We had that debate already (PEP 343). Yes, there is some sloppy>> current practice by CPython users that relies on the GC to close the >> db conn.>> This point is unrelated to with or ref-counting. Even the standard> library will close file objects when they are GC'd.This is not totally true. My experience is that if you use the tarfile module any tarfile that was opened for appending orwriting risks being corrupted if it isn't closed explicedly.--Antoon Pardon-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
True, since smartness is a comparison, my friends who have chosen java over python for considerations of a true threading support in a language are smarter, which makes me a dumbo ! :-) KM On 9/5/06, Richard Brodie <[EMAIL PROTECTED]> wrote: > > "km" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > I know many of my friends who did not choose python for obvious reasons > > of the nature of thread execution in the presence of GIL which means > > that one is wasting sophisticated hardware resources. > > It would probably be easier to find smarter friends than to remove the > GIL from Python. > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Hi all, > And yet, Java programmers manage to write threaded applications all > day long without getting bitten (once they're used to the issues), > despite usually being less skilled than Python programmers ;-). > These days, even semi-entry-level consumer laptop computers have dual > core CPU's, and quad Opteron boxes (8-way multiprocessing using X2 > processors) are quite affordable for midrange servers or engineering > workstations, and there's endless desire to write fancy server apps > completely in Python. There is no point paying for all that > multiprocessor hardware if your programming language won't let you use > it. So, Python must punt the GIL if it doesn't want to keep > presenting undue obstacles to writing serious apps on modern hardware. True GIL implementation must have got its own good causes as it it designed but as language evolves its very essential that one increases the scope such that it fits into many usage areas(eg. scientific applications using multiprocessors etc.). In the modern scientific age where __multiprocessor_execution_environment__ is quite common, i feel there is a need to rethink abt the introduction of true parallelization capabilities in python. I know many of my friends who didnot choose python for obvious reasons of the nature of thread execution in the presence of GIL which means that one is wasting sophisticated hardware resources. ## if __name__ == ''__multiprocessor_execution_environment__': for python_version in range(python2.4.x, python3.x, x): if python_version.GIL: print 'unusable for computation intensive multiprocessor architecture' else: print cmp(python,java) regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: threading support in python
Hi all, Are there any alternate ways of attaining true threading in python ? if GIL doesnt go then does it mean that python is useless for computation intensive scientific applications which are in need of parallelization in threading context ? regards, KM --- On 4 Sep 2006 07:58:00 -0700, bayerj <[EMAIL PROTECTED]> wrote: > Hi, > > GIL won't go. You might want to read > http://blog.ianbicking.org/gil-of-doom.html . > > Regards, > -Justin > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
threading support in python
Hi all, Is there any PEP to introduce true threading features into python's next version as in java? i mean without having GIL. when compared to other languages, python is fun to code but i feel its is lacking behind in threading regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess woes
Hi Dennis, That works great. thanks for the correction. The 'output' variable has the returned data as string obbject. how can i get it as a list object with elements as line by line? Is it that p1.communicate()[0] by default returns a single string only ? regards, KM On 8/29/06, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: On Tue, 29 Aug 2006 18:17:47 +0530, km <[EMAIL PROTECTED] >declaimed the following in comp.lang.python:> ##code start ##> import subprocess as sp> x = 'GSQIPSHYWKKNLWYYSHEIDGGCHNMW'> p0 = sp.Popen(["echo",x], stdout=sp.PIPE ) Why use this at all?> p1 = sp.Popen(["fasta34","-q","@",s],stdin=p0.stdout, stdout=sp.PIPE)> output = p1.communicate()[0] Just feed "x" to this directly... (untested): p1 = sp.Popen(["fasta34","-q","@",s],stdin=sp.PIPE, stdout=sp.PIPE)output = p1.communicate(x)[0]-- WulfraedDennis Lee Bieber KD6MOG [EMAIL PROTECTED] [EMAIL PROTECTED] HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: [EMAIL PROTECTED]) HTTP://www.bestiaria.com/-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess woes
Hi Dennis, That works great ! thanks for the correction regards, KM-- On 8/29/06, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: On Tue, 29 Aug 2006 18:17:47 +0530, km <[EMAIL PROTECTED] >declaimed the following in comp.lang.python:> ##code start ##> import subprocess as sp> x = 'GSQIPSHYWKKNLWYYSHEIDGGCHNMW'> p0 = sp.Popen(["echo",x], stdout=sp.PIPE ) Why use this at all?> p1 = sp.Popen(["fasta34","-q","@",s],stdin=p0.stdout, stdout=sp.PIPE)> output = p1.communicate()[0] Just feed "x" to this directly... (untested): p1 = sp.Popen(["fasta34","-q","@",s],stdin=sp.PIPE, stdout=sp.PIPE)output = p1.communicate(x)[0]-- WulfraedDennis Lee Bieber KD6MOG [EMAIL PROTECTED] [EMAIL PROTECTED] HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: [EMAIL PROTECTED]) HTTP://www.bestiaria.com/-- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
subprocess woes
Hi all, I have a strange question. a program on shell looks as follows: $cat test.fa |fasta34 -q @ s where test.fa contains a protein sequence (alphabets); s is the database to be searched and @ +indicates that the input is from stdin (ie., 'cat test.fa') now instead of 'cat test.fa' i take that input into a varaible and want to feed it to the +program. I have a sequence string in a variable named x, and use subprocess module to wrap this: ##code start ## import subprocess as sp x = 'GSQIPSHYWKKNLWYYSHEIDGGCHNMW' p0 = sp.Popen(["echo",x], stdout=sp.PIPE) p1 = sp.Popen(["fasta34","-q","@",s],stdin=p0.stdout, stdout=sp.PIPE) output = p1.communicate()[0] print output code end# Output for this code doesnt give me the result as the program senses the input as empty let me know where i am wrong. The idea is to pipe-input the string to the program as a variable as mentioned above. regards, KM -- http://mail.python.org/mailman/listinfo/python-list
XMLSchema Parsing
Hi all, i'd like to know if there are any good XMLSchema (.xsd files) parsing modules in python. regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
Hi all, > What you are "comparing" is either IO times (the "print loop" program), > where Perl beats C - which means that Perl's IO have been written at a > very low level instead of relying on the stdlib's IO - i'd like to know what aspects are really coded in very low level for python ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
> If you want a fast language, try Holden. I've just invented it. > Unfortunately it gets the answer to every problem wrong unless the > answer is 42, but boy it runs quickly. The code for the whole > interpreter (it's written in Python) follows: > print 42 great ! u can use it for ur own projects. but pls donot suggest it to anyone else. i think u can get an award for developing such a fast language in such a shorter time ;-) may be u can also be called 'Guido Holden Rossum' ;-) anyway improve it - its quite buggy now :-D > Speed of execution is so insignificant for the majority of programming > problems I donot agree with that. If thats the case then no one would be using C or C++ etc for instance. one important thing is that i am not comparing python with C but with similar language, Perl. well ofcourse i dont jump into conclusion, just with just a simple 'loops' snippet, that python is slower than perl. but when speed is important then ? also i hate people recommending "if u need speed code it as a C extension module". ofcourse i donot expect pure python/perl program to execute at the speed of a C program. > that this obsession reveals a certain inexperience. its neither obsession nor inexperience ... its just the requirement. i think less buggy code is not the main concern for all. if thats the case there are better languages (like Ada with better built in exception classes) and so used in mission critical applications. even perl is still popular even its difficult to maintain, but when one looks for speed (naturally), rather than the readability & maintainability of the code, does python suit perl ? i am aware one of the main principle python isn founded is better readability but is that a feature which decreases execution speed ? then what is it ? even perl is still popular even if its difficult to maintain after a certian stage of coding. there obviously will be a bias in this list towards python but i need a honest opinion of python vs perl. (especially when it comes to webscripting) > regards > Steve "The inventor of Holden" regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
Hi all, > thing. If *all* your loops are going to do is print stuff, then you're > doing the right thing with the version that "emits values". ya most of the loops print values. > know this). Since you haven't got any working code, it's not possible > that you *need* whatever negligible speed difference there might be > between Python and Perl. > > Python, don't let your first attempts at benchmarking dissuade you. > Really, trust us. ya i do. > Python's strengths lie in four things: the readability of the code, the > huge range of library modules available, the elegance of its object > oriented constructs, and the helpfulness of its community. Raw speed is > not one of its strengths, but there are tens of thousands of people > using it quite effectively and without daily concern for its speed (same > as Perl, by the way since, again, they are _not_ significantly different > in speed no matter what an empty loop test shows). I agree that python emphasizes on readability which i didnt see in many of the languages, but when the application concern is speed, does it mean that python is not yet ready? even most of the googling abt python vs perl convince me that perl is faster than python in most of the aspects. Also the first thing any newbie to python asks me is abt "raw speed in comparison with similar languages like perl" when i advocate python to perl. regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: loop in python
Hi all, ya i am sorry i tried with an empty loop first and then one which emits a value as the snippet. I have tested it on my machine and now ... 1) perl (v 5.8) does the job in 0.005 seconds 2) but python (v 2.4.1) is horribly slow its 0.61 seconds. and using range() instead of xrange() in python snippet, it not better , it takes 0.57 seconds. just test it urself and see. what more do i need to accept python is slow when it comes to loops concept ? PS : my linux box is running fedora core 2 with 256 MB RAM regards, KM --- On Tue, Aug 23, 2005 at 12:25:01PM +0530, km wrote: > Hi all, > > Why is it that the implementation of empty loop so slow in python when > compared to perl ? > > #i did this in python (v 1.5) > for x in xrange(1000): > print x > # this took 0.017 seconds > -- > #similar code in perl (v 5.6): > for $x (0..1000) > { > print $x; > } > # this took 0.005 seconds only !!! > > Is python runtime slow at all aspects when compared to perl ? > I really wonder what makes python slower than perl ? > Is there any proposal to make python faster in future versions ? > > curious to know all these ... > > regards, > KM > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
loop in python
Hi all, Why is it that the implementation of empty loop so slow in python when compared to perl ? #i did this in python (v 1.5) for x in xrange(1000): print x # this took 0.017 seconds -- #similar code in perl (v 5.6): for $x (0..1000) { print $x; } # this took 0.005 seconds only !!! Is python runtime slow at all aspects when compared to perl ? I really wonder what makes python slower than perl ? Is there any proposal to make python faster in future versions ? curious to know all these ... regards, KM -- http://mail.python.org/mailman/listinfo/python-list
global interpreter lock
Hi all, is true parallelism possible in python ? or atleast in the coming versions ? is global interpreter lock a bane in this context ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: multiple inheritance super()
Hi peter, ya got it working :-) now i understand mro better. thanks, KM - On Tue, Jul 26, 2005 at 04:09:55PM -0400, Peter Hansen wrote: > km wrote: > > Hi all, > > > > In the following code why am i not able to access class A's object > > attribute - 'a' ? I wishto extent class D with all the attributes of its > > base classes. how do i do that ? > > > > thanks in advance for enlightment ... > > > > here's the snippet > > > > #!/usr/bin/python > > > > class A(object): > > def __init__(self): > > self.a = 1 > > > > class B(object): > > def __init__(self): > > self.b = 2 > > > > class C(object): > > def __init__(self): > >self.c = 3 > > > > class D(B, A, C): > > def __init__(self): > > self.d = 4 > > super(D, self).__init__() > > Each class should do a similar super() call, with the appropriate name > substitutions. > > Calls to __init__ must be made explicitly in subclasses, including in > the case of multiple inheritance. > > Also note that often (usually) you would like the __init__ call to come > *before* other location initializations, and it's the safest thing to do > unless you have clear reasons to the contrary. > > -Peter > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
multiple inheritance super()
Hi all, In the following code why am i not able to access class A's object attribute - 'a' ? I wishto extent class D with all the attributes of its base classes. how do i do that ? thanks in advance for enlightment ... here's the snippet #!/usr/bin/python class A(object): def __init__(self): self.a = 1 class B(object): def __init__(self): self.b = 2 class C(object): def __init__(self): self.c = 3 class D(B, A, C): def __init__(self): self.d = 4 super(D, self).__init__() if __name__ == '__main__': x = D() print x.a # errs with - AttributeError -- http://mail.python.org/mailman/listinfo/python-list
without shell
hi all, can any linux command be invoked/ executed without using shell (bash) ? what abt security concerns ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
decimal numarray
Hi all, is there any support for decimal type in numarray module ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: 20050111: list basics
Hi all, > Perl's pack function will allow you to do direct memory access if you > ask it to via the "p" and "P" templates. can we do direct memory accessing in python also ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
80 bit precision ?
Hi all, does python currently support 80 bit precision Floating Point Unit ? regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: OOPS concept
Hi all, Well this doesnt explain new style classes. let me be more clear. is there any online tutorial/ recommended book which deals explicitly with object oriented programming in python? regards, KM --- > Try this online book, it may help, the url is: http://www.byteofpython.info > > > Hi all, > > > > Is there any good step by step online tutorial on OOPS concepts in python > ? > > i have checked some on the python.org.__doc__ page but couldnt make much > sense. especially i need help on newstyle classes. > > > > regards, > > KM > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
OOPS concept
Hi all, Is there any good step by step online tutorial on OOPS concepts in python ? i have checked some on the python.org.__doc__ page but couldnt make much sense. especially i need help on newstyle classes. regards, KM -- http://mail.python.org/mailman/listinfo/python-list
Re: Supercomputer and encryption and compression @ rate of 96%
Hi all, This was posted long ago. I tried to compress a mp3 file but i couldnt get the keycode+".out" file which is of size 1 bit. instead it is printed to STDOUT. i am usng python 2.4 . i understand that the keycode is embedded in the filename itself. Is it a problem with python not able to create a file with such a big filename ? any workarounds ? regards, KM On Thu, Apr 14, 2005 at 01:49:22PM +0200, Fredrik Lundh wrote: > Will McGugan wrote: > > > Please implement this as a Python module. I would like to compress my mp3 > > collection to single > > bits. > > here's the magic algorithm (somewhat simplified): > > def algorithm(data): > m = 102021 # magic constant > d = [int(c) for c in str(1*2*3*4*5*m+5+4+2+1)] > x = [ord(c) for c in hex(1+2+4+5+m*5*4*3*2*1)] > x[d[0]*d[1]*d[2]] = x[d[-1]] + sum(d) - d[d[-d[-1]-1]] + d[0] > x = __import__("".join(chr(c) for c in x[d[0]*d[1]:])).encodestring > return "".join(x(data).split("\n")).rstrip("="), sum(d)-sum(reversed(d)) > > and here's a driver for your MP3 collection: > > import glob > > def compress(filename): > data = open(filename, "rb").read() > keycode, bit = algorithm(data) > file = open(keycode + ".out", "wb") > file.write(chr(bit)) > file.close() > print "compressed", filename, > print len(data), "=>", 1, round(100.0/len(data), 3), "%" > > for file in glob.glob("*.mp3"): > compress(file) > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python - what is the fastest database ?
Hi all, Google has specially designed file system 'Goolgle File System' too. KM - On Mon, Feb 28, 2005 at 01:43:53PM -0500, Terry Reedy wrote: > > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> How is it possible that google (super big database) is super fast? > > What type database do they use / software ? > > On the hardware side, Google's secret is massively parallel cluster > computing, coupled with proprietary software for splitting tasks and > joining results. They have perhaps 200,000 CPUs. A query might be given > to hundreds of them for a fraction of a second. > > Terry J. Reedy > > > > -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Chart Director?
Hi all, Chart Director is a good module to implement graphs using in python. i have been using it since 6 months for scientific data visualisation. great module !!! regards, KM -- On Sat, Feb 19, 2005 at 08:22:19AM +0100, Vincent Wehren wrote: > [EMAIL PROTECTED] wrote: > >Does anyone here have experience with Chart Director > >(http://www.advsofteng.com/index.html)? I'm thinking about purchasing > >it and looking for any feedback from the Python community. Thanks > > > > Since ChartDirector is not exactly open source nor found its origin in a > Python setting, my uneducated guess is that it will mostly be companies > that use ChartDirector. > > However, from that vantage-point, ChartDirector is well-documented, has > lots of examples, and is great value for the money; it's pretty straight > forward, it covers all Python versions from 1.52 - 2.4, and the license > generally encompasses all other language bindings, too (all being at > version 4.0 except for the C++ version which is currently still at 3.04). > > Still, you should just try it for what you are planning to use it /for/ > and see if it meets /your/ specific needs. > > -- > Vincent Wehren > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list