Re: PUT with proxy-support
On Fri, Aug 26, 2011 at 3:15 PM, Laszlo Nagy gand...@shopzeus.com wrote: Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2ZCa8v/**pycurl-7.19.0/egg-dist-tmp-**DyHFls Using curl-config (libcurl 7.12.1) src/pycurl.c:42:20: Python.h: No such file or directory src/pycurl.c:43:22: pythread.h: No such file or directory src/pycurl.c:58:4: #error Need Python version 2.2 or greater to compile pycurl. src/pycurl.c:61:4: #error Need libcurl version 7.19.0 or greater to compile pycurl. [... Error Clipped] error: Setup script exited with error: command '/usr/bin/gcc' failed with exit status 1 I'm not familiar with red hat. But looks like this is now a sysadmin problem. I could install pycurl under freebsd and ubuntu too. I have some code that might be able to PUT through a proxy for you. Please look at the attached file. You can setup a proxy this way: import MozzillaEmulator MozzillaEmulator.DEFAULT_**PROXIES = { 'http':'http://user:password@**proxy.host.com:3128http://user:passw...@proxy.host.com:3128 ', 'https':'http://user:password@**proxy.host.com:3128http://user:passw...@proxy.host.com:3128 ', } And here is how you use it: dl = MozillaEmulator.**MozillaEmulator() put_url = http://some_url_to_put_to; headers = {'Content-Type':'application/**xml;charset=UTF-8'} data = open(some_file,rb).read() response = dl.download(put_url,data,**headers,put_method=True) If you don't set the put_method flag, then it will POST instead. (But in that case, post data must be a valid post data field fields and values.) If you don't give post_data then it will GET. The PUT method was tested without a proxy, and the GET and POST methods were tested with and without proxy. Actually I have tried to do PUT through a proxy, but it didn't work. But it was a restriction on the proxy side. (As far as I can recall, the error message came from the proxy server, something about unsupported request?). So it *might* work for you, with the right proxy server that supports PUT requests. Also be aware that this version uses urllib2. Although it can use https protocol, it doesn't check the server's certificate. Mozilla Emulator works like a charm. Also managed to install pycurl and the same works too. Thanks. :) ~Shashwat -- http://mail.python.org/mailman/listinfo/python-list
PUT with proxy-support
I want to make a PUT request. I need some headers of my own ( certificates etc ) and I need to mandatorily use a proxy. Also the url is of the form http://www.xyz.com/abc and I don't have permission to put data on http://www.xyz.com while I do have permission to put data on http://www.xyz.com/abc I tried httplib, httplib2, urllib2 with no avail. I managed to do this via command line curl: $ curl http:/xyz.com/testing/shashwat/test.txt -T test.txt -H sw-version: 1.0 -H CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=1316594650;s=.AeEYJMMfElN74fnWD3GlXJ4J.1KiQFg-- --proxy proxy.xyz.com:3128 -H Content-Type:text/plain Is there a way to do it in python apart from using command line curl in python. The machine is RHEL4 and is giving hard time installing pycurl. -- http://mail.python.org/mailman/listinfo/python-list
Re: PUT with proxy-support
On Thu, Aug 25, 2011 at 4:48 PM, Thomas Jollans t...@jollybox.de wrote: On 25/08/11 13:07, Shashwat Anand wrote: I want to make a PUT request. I need some headers of my own ( certificates etc ) and I need to mandatorily use a proxy. Also the url is of the form http://www.xyz.com/abc and I don't have permission to put data on http://www.xyz.com while I do have permission to put data on http://www.xyz.com/abc I tried httplib, httplib2, urllib2 with no avail. What did you try? What problems did you run into? I'm sure there is a way in Python, and chances are you were already close to finding it -- show us what you tried, what actually happened, including any error messages in full, and what you wanted to happen. Thomas Hi Thomas, so one of my tries was: import urllib import urllib2 import httplib import httplib2 url = 'http://alatheia.zenfs.com/testing/shashwat' body_content = 'CONTENT GOES HERE' proxy = 'ca-proxy.corp.xyz.com:3128' params = { 'x-sws-version' : '1.0', 'x-sws-access' : 'public', 'User-Agent' : 'CacheSystem', 'Cache-Control' : 'public', 'Content-Type' : 'text/plain', 'App-Auth' : 'v=1;a=client.alatheia.prod;h=10.16.19.23;t=1316594650;s=AeEYJMMfElN74fnWD3GlXJ4J.1KiQFg--', } httplib2.debuglevel=4 h = httplib2.Http(proxy_info = httplib2.ProxyInfo(3, ' ca-proxy.corp.xyz.com:3128', 3128)) resp, content = h.request(url, PUT, body=body_content, headers = params) print resp print content Output: connect: (alatheia.zenfs.com, 80) Traceback (most recent call last): File test.py, line 29, in module resp, content = h.request(url, PUT, body=body_content, headers = params) File /home/y/lib/python2.6/site-packages/httplib2/__init__.py, line 1436, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File /home/y/lib/python2.6/site-packages/httplib2/__init__.py, line 1188, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File /home/y/lib/python2.6/site-packages/httplib2/__init__.py, line 1123, in _conn_request conn.connect() File /home/y/lib/python2.6/site-packages/httplib2/__init__.py, line 786, in connect self.sock.connect(sa) File /home/y/lib/python2.6/site-packages/httplib2/socks.py, line 381, in connect self.__negotiatehttp(destpair[0], destpair[1]) File /home/y/lib/python2.6/site-packages/httplib2/socks.py, line 347, in __negotiatehttp raise HTTPError((statuscode, statusline[2])) httplib2.socks.HTTPError: (403, 'Tunnel or SSL Forbidden') The reason I can trace it is because, I can use PUT on http://alatheia.zenfs.com/testing/shashwat but not on http://alatheia.zenfs.com/ however host is resolved. Again port 80 is used even when I use specific port (3128, in this case). -- http://mail.python.org/mailman/listinfo/python-list
Re: PUT with proxy-support
On Thu, Aug 25, 2011 at 4:48 PM, Max Countryman m...@me.com wrote: Check out the python Requests module: http://docs.python-requests.org/en/latest/index.html Python request module is not documented very well IMHO. I tried to figure how to make PUT calls, how to add proxy, how to add certificates in headers. Did not managed to find all of it. Am not sure is supports REST calls with proxy support. Sent from my iPhone On Aug 25, 2011, at 7:07, Shashwat Anand anand.shash...@gmail.com wrote: I want to make a PUT request. I need some headers of my own ( certificates etc ) and I need to mandatorily use a proxy. Also the url is of the form http://www.xyz.com/abchttp://www.xyz.com/abcand I don't have permission to put data on http://www.xyz.comhttp://www.xyz.com while I do have permission to put data on http://www.xyz.com/abchttp://www.xyz.com/abc I tried httplib, httplib2, urllib2 with no avail. I managed to do this via command line curl: $ curl http:/ http://xyz.com/testing/shashwat/test.txt xyz.com/testing/shashwat/test.txt -T test.txt -H sw-version: 1.0 -H CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=1316594650;s=.AeEYJMMfElN74fnWD3GlXJ4J.1KiQFg-- --proxy proxy.xyz.com:3128 -H Content-Type:text/plain Is there a way to do it in python apart from using command line curl in python. The machine is RHEL4 and is giving hard time installing pycurl. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: PUT with proxy-support
On Thu, Aug 25, 2011 at 5:22 PM, Laszlo Nagy gand...@shopzeus.com wrote: ** I tried httplib, httplib2, urllib2 with no avail. I managed to do this via command line curl: $ curl http:/xyz.com/testing/shashwat/test.txt -T test.txt -H sw-version: 1.0 -H CA-Cert-Auth:v=1;a=yxyz.prod;h=10.10.0.1;t=1316594650;s=.AeEYJMMfElN74fnWD3GlXJ4J.1KiQFg-- --proxy proxy.xyz.com:3128 -H Content-Type:text/plain If you can do it with command line curl then probably you can do it with pycurl. http://pycurl.sourceforge.net/ Yeah. I tried that. The system is RHEL 4. So it gave me this error : src/pycurl.c:42:20: Python.h: No such file or directory src/pycurl.c:43:22: pythread.h: No such file or directory src/pycurl.c:58:4: #error Need Python version 2.2 or greater to compile pycurl. src/pycurl.c:61:4: #error Need libcurl version 7.19.0 or greater to compile pycurl. Apparently we need python-devel package. Following http://fedoraproject.org/wiki/EPEL/FAQ#howtouse I added EPEL software repository. sh-3.00$ yum list | grep -i python-dev sh-3.00$ sudo yum -y install python-dev Password: Setting up Install Process Setting up repositories epel [1/1] epel 100% |=| 3.8 kB00:00 Reading repository metadata in from local files b1f7bfef07466e9561644aba7 100% |=| 841 kB00:06 epel : ## 2583/2583 Added 2583 new packages, deleted 0 old in 4.51 seconds Parsing package install arguments No Match for argument: python-dev Nothing to do Turned out that python-curl is the required package which is already installed. Still no use. sh-3.00$ yum list | grep -i python-curl python-curl.x86_64 7.12.1-1.3.el4.rf installed sh-3.00$ python Python 2.6.4 (r264:75706, Nov 9 2009, 16:32:06) [GCC 3.4.6 20060404 (Red Hat 3.4.6-10)] on linux2 Type help, copyright, credits or license for more information. import pycurl Traceback (most recent call last): File stdin, line 1, in module ImportError: No module named pycurl Tried installing via easy_install sh-3.00$ sudo easy_install pycurl Searching for pycurl Reading http://pypi.python.org/simple/pycurl/ Reading http://pycurl.sourceforge.net/ Reading http://pycurl.sourceforge.net/download/ Best match: pycurl 7.19.0 Downloading http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz Processing pycurl-7.19.0.tar.gz Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-2ZCa8v/pycurl-7.19.0/egg-dist-tmp-DyHFls Using curl-config (libcurl 7.12.1) src/pycurl.c:42:20: Python.h: No such file or directory src/pycurl.c:43:22: pythread.h: No such file or directory src/pycurl.c:58:4: #error Need Python version 2.2 or greater to compile pycurl. src/pycurl.c:61:4: #error Need libcurl version 7.19.0 or greater to compile pycurl. [... Error Clipped] error: Setup script exited with error: command '/usr/bin/gcc' failed with exit status 1 Best, Laszlo -- http://mail.python.org/mailman/listinfo/python-list
Re: Refactor/Rewrite Perl code in Python
Thanks everyone for the insight. I got the idea as to how and where to start. Guess I need to work in Perl for now, so as to start the conversion process. Regarding Tests, I had already started writing tests before posting. Writing tests for every module will be a pain as well as a nice experience. Thanks. ~Shashwat -- http://mail.python.org/mailman/listinfo/python-list
Refactor/Rewrite Perl code in Python
I am working with a huge codebase of Perl. The code have zero documentation and zero unit-tests. It seems like a huge hack. The underlying database schema is horrid. So I want to rewrite the whole of it in Python. How do I start ? The idea is to rewrite module by module. But how to make sure code doesn't break ? How can I import perl and python codes in each other ? -- http://mail.python.org/mailman/listinfo/python-list
[issue8252] add a metadata section in setup.cfg
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: -l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8252 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8253] add a resource+files section in setup.cfg
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: -l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8253 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4487] Add utf8 alias for email charsets
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: -l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4487 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Init a dictionary with a empty lists
On Sat, Feb 5, 2011 at 6:38 PM, Lisa Fritz Barry Griffin lisaochba...@gmail.com wrote: Hi there, How can I do this in a one liner: maxCountPerPhraseWordLength = {} for i in range(1,MAX_PHRASES_LENGTH+1): maxCountPerPhraseWordLength[i] = 0 maxCountPerPhraseWordLength = {} [maxCountPerPhraseWordLength.setdefault(i, 0) for i in range(1,MAX_PHRASES_LENGTH+1)] From setdefaults documentation, 'D.setdefault(k[,d]) - D.get(k,d), also set D[k]=d if k not in D' Thanks! -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
[issue8013] time.asctime segfaults when given a time in the far future
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: -l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8013 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: -l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4953 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Language Detection Library/Code
Can anyone suggest a *language detection library* in python which works on a phrase of say 2-5 words. -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Language Detection Library/Code
On Tue, Dec 28, 2010 at 6:03 AM, Katie T ka...@coderstack.co.uk wrote: On Mon, Dec 27, 2010 at 7:10 PM, Shashwat Anand anand.shash...@gmail.com wrote: Can anyone suggest a language detection library in python which works on a phrase of say 2-5 words. Generally such libraries work by bi/trigram frequency analysis, which means you're going to have a fairly high error rate with such small phrases. If you're only dealing with a handful of languages it may make more sense to combine an existing library with a simple dictionary lookup model to improve accuracy. Katie Infact I'm dealing with very few languages - German, French, Italian, Portugese and Russian. I read papers mentioning bi/tri gram frequency but was unable to find any library. 'guess-language' doesn't perform at all. The cld (Compact Language Detection) module of Google chrome performs well but it is not a standalone library ( I hope someone ports it ). Regarding dictionary lookup+n-gram approach I didn't quite understand what you wanted to say. -- http://mail.python.org/mailman/listinfo/python-list
Re: Silly newbie question - Carrot character (^)
On Fri, Nov 5, 2010 at 7:26 PM, Krister Svanlund krister.svanl...@gmail.com wrote: On Fri, Nov 5, 2010 at 2:43 PM, Matty Sarro msa...@gmail.com wrote: Hey Everyone, Just curious - I'm working on a program which includes a calculation of a circle, and I found myself trying to use pi*radius^2, and getting errors that data types float and int are unsupported for ^. Now, I realized I was making the mistake of using '^' instead of **. I've corrected this and its now working. However, what exactly does ^ do? I know its used in regular expressions but I can't seem to find anything about using it as an operator. Sadly my google foo is failing since the character gets filtered out. It's a binary operator i think... something like xor. Yes. Infact '^' is binary XOR. a = 4 bin(a) '0b100' b = 5 bin(b) '0b101' a ^ b 1 100 ^ 101 = 001 -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Problem with mechanize redirect
I was trying some sort of timed programming challenges which require getting the value from url and auto-posting. Here is what I was doing - http://securityoverride.com/challenges/programming/10/index.php Here is the content : In order to complete Programming Challenge 10, you must code a script that will search the moo directory, and all subdirectories for the three passwords below. Once complete, you must submit the folder number that goes with each password (the folder that the password was found in). Example: 1:e92nb0s4; 50:un2r9nw7; 100:48bn20b6 Then three _random_ passwords are generated. So far so good. I did wrote a code using mechanize to do this. Here is the Code : http://codepad.org/nHJtTTmL The issue is br (i.e. mechanize.Browser instance) opens the page, fetches data, crawl gets the solution, but when it comes back, sort of refresh behavior is emulated. Refresh changes the original strings. Can't I simply 'submit'. When I simply try to submit, since it is on targeturl/foo/ , it doesn't get any form as the form is on target url. Any ideas/suggestions/hints. -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: list problem...
On Thu, Sep 30, 2010 at 3:20 AM, Rog r...@pynguins.com wrote: On Wed, 29 Sep 2010 05:52:32 -0700, bruno.desthuilli...@gmail.com wrote: On 29 sep, 14:17, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote: On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote: On Tue, Sep 28, 2010 at 11:44 AM, Rog r...@pynguins.com wrote: Hi all, Have been grappling with a list problem for hours... a = [2, 3, 4, 5,.] b = [4, 8, 2, 6,.] Basicly I am trying to place a[0], b[0] in a seperate list IF a[2] and b[2] is present. I have tried sets, zip etc with no success. I am tackling Euler projects with Python 3.1, with minimal knowledge, and having to tackle the language as I progress. Enjoyable frustration :) I'm not clear on what your actual problem is, could you restate it? It sounds like you want to copy the ith element out of a and b into some other list- call it c- when the (i+2)th element meets some condition. What's the condition? Geremy Condra The condition is that the i-th element is inverted, but not equal. eg 4,2 - 2,4 , 34,5 - 5,34 etc. Hope that is clearer. Clear as mud. Perhaps you should given an example. Given input a = [2, 3, 4, 5, 6, 7] b = [4, 8, 2, 6, 10, 42] what output are you expecting, AFAICT, the OP expects [2, 4] in this case, but it's not clear what he'd expect for let's say: a = [2, 3, 21, 4, 5, 6, 7] b = [4, 8, 22, 2, 6, 10, 42] (the 'reversed' pair is at i+3, not i+2) or a = [0, 2, 3, 4, 5, 6, 7] b = [3, 4, 8, 2, 6, 10, 42] (the first pair is at pos 1, not 0) or a = [2, 3, 4, 8, 6, 7] b = [4, 8, 2, 3, 10, 42] (there's a second 'non-reversed/reversed' match at positions resp. 1 3) It is true that I would have needed any 'non-reversed/reversed' pairs, these would have been the amicable pairs I was looking for. The method to recognise them eluded me. Eyes are not good enough :) I have now joined Python-List and will follow the correct route. I have used a method suggested that has made the problem redundant, though it will bug me from now on. g = [] def divsum(n): return sum(i for i in range(1, n) if not n % i) You can optimize divsum. Remember that factors exist in pairs except when numbers are squares. Like say 12 have factors = 1, 12, 2, 6, 3, 4 so you can run the loop till sqrt(n) for n since floor(sqrt(n)) = 3 where n = 12 now factors are , (1, n/1), (2, n/2), (3, n/2). for a square number say n = 9, the factors are (1, 3, 12) If you run the loop till sqrt(n) for n since floor(sqrt(n)) = 3 where n = 9 we get the factors as (1, 9), (3, 3) One of the factor will be redundant, so you need to take care of that. for x in range(1, 2, -1): c = divsum(x) v = divsum(c) Can be done as, c, v = divsum(x), divsum(divsum(x)) if v == x and v != c: g.append(divsum(x)) No need for else part, what is the use ? else: continue print(sum(g)) You could pack this up as, sum(i for i in range(1, 0, -2) if divsum(divsum(i)) == i and divsum(i) != i) 31626 -- Rog http://www.rog.pynguins.com -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: list problem...
On Wed, Sep 29, 2010 at 12:14 AM, Rog r...@pynguins.com wrote: Hi all, Have been grappling with a list problem for hours... a = [2, 3, 4, 5,.] b = [4, 8, 2, 6,.] Basicly I am trying to place a[0], b[0] in a seperate list IF a[2] and b[2] is present. You are not exactly clear with your problem statement. Care to elaborate it more. I have tried sets, zip etc with no success. I am tackling Euler projects with Python 3.1, with minimal knowledge, and having to tackle the language as I progress. Enjoyable frustration :) -- Rog http://www.rog.pynguins.com -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: list problem...
On Wed, Sep 29, 2010 at 1:15 AM, rog r...@pynguins.com wrote: Shashwat Anand wrote: On Wed, Sep 29, 2010 at 12:14 AM, Rog r...@pynguins.com mailto: r...@pynguins.com wrote: Hi all, Have been grappling with a list problem for hours... a = [2, 3, 4, 5,.] b = [4, 8, 2, 6,.] Basicly I am trying to place a[0], b[0] in a seperate list IF a[2] and b[2] is present. You are not exactly clear with your problem statement. Care to elaborate it more. I have tried sets, zip etc with no success. I am tackling Euler projects with Python 3.1, with minimal knowledge, and having to tackle the language as I progress. Enjoyable frustration :) -- Rog http://www.rog.pynguins.com -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf Let d(/n/) be defined as the sum of proper divisors of /n/ (numbers less than /n/ which divide evenly into /n/). If d(/a/) = /b/ and d(/b/) = /a/, where /a/ ≠ /b/, then /a/ and /b/ are an amicable pair and each of /a/ and /b/ are called amicable numbers. For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220. Evaluate the sum of all the amicable numbers under 1. from Project Euler. I have all answers contained in two lists but need to extract the amicable pairs. eg a = [200, 4, 284,.] b = [284, 9, 200, ..] Hope that helps. Thanks for the link. I am not sure how and what you managed, but what I understand you need to calculate sum of divisors. A quick unoptimized solution can be, def divsum(n):return sum(i for i in range(1, n) if not n % i)... divsum(220)284 divsum(284)220 Now all is left is looping and little maths, since upper bound is not high, brute force is Ok. spoiler http://codepad.org/g6PRyoiV /spoiler # For reference Also I guess you missed 'Reply All', please take care of it next time. Rog -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Python2.7 on OSX
On Sun, Sep 26, 2010 at 12:32 AM, Jonas Galvez jo...@codeazur.com.brwrote: Just installed Python2.7 on my OSX Leopard with make altinstall. No missing dependencies, but I have one annoying problem: the delete key prints '^H' on the Python shell. Does anyone know how to fix that? Thanks in advance, Is readline module installed in yours ? try 'import readline' to check. -- Jonas -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Python autocomplete module
On Thu, Sep 16, 2010 at 5:34 PM, dusans dusan.smit...@gmail.com wrote: Is there a python module to make autocomplete suggestion easy. Try 'rlcompleter' module. Though I haven't tried it myself, just used it in .pythonrc for auto-completion in intepretor mode. http://docs.python.org/library/rlcompleter.html -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Numpy: Multiplying arrays of matrices
On Tue, Sep 14, 2010 at 7:54 PM, Gregory Ewing greg.ew...@canterbury.ac.nzwrote: Suppose I have two N+2 dimensional arrays, representing N-d arrays of 2-d matrices. I want to perform matrix multiplication between corresponding matrices in these arrays. I had thought that dot() might do this, but it appears not, because e.g. applying it to two 3-d arrays gives a 4-d array, not another 3-d array. I'd also like to be able to find the inverse of each matrix in one of these arrays, but again, inv() doesn't do what I want -- it only works on 2-d arrays. Any thoughts on how to achieve these things using numpy functions? Unrelated to numpy, but you can apply the basics of dynamic programming to optimize the stuff. -- Greg -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: compare dictionaries
On Wed, Sep 8, 2010 at 1:56 AM, Baba raoul...@gmail.com wrote: On 7 sep, 22:08, Gary Herron gher...@digipen.edu wrote: On 09/07/2010 12:46 PM, Baba wrote: word= 'even' dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2} Just go through each letter of word checking for its existence in dict2. Return False if one misses, and True if you get through the whole word: def ...(): for c in word: if c not in dict2: return False #if any character is not in dict return True # otherwise If you know of generator expressions, and remember that True and False are 1 and 0 respectively, then this works def ...(): return sum(c in dict2 for c in word) == len(word) Gary Herron -- Gary Herron, PhD. Department of Computer Science DigiPen Institute of Technology (425) 895-4418 ok but how do we address the fact that letter e needs to have the value 2 in the dictionary if it was to be True? in my example this condition is not met so the check would return False. Word is not entirely composed of letters in dict2, one of the letter is not in dict2 i.e. the 2nd e Seems You did not understood Gary's solution. It is correct. Also, you asked for 'i want to know if word is entirely composed of letters in dict2' which you are getting. Did you tried running the code ? So finding a matching key seems to be the easy part, checking if the number of ocurrences of letter in 'word' == letter.value seems to be the tricky part -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Reversing a List
On Wed, Sep 1, 2010 at 6:45 PM, Matt Saxton m...@scotweb.co.uk wrote: On Wed, 1 Sep 2010 09:00:03 -0400 Victor Subervi victorsube...@gmail.com wrote: Hi; I have this code: cursor.execute('describe products;') cols = [item[0] for item in cursor] cols = cols.reverse() cols.append('Delete') cols = cols.reverse() Unfortunately, the list doesn't reverse. If I print cols after the first reverse(), it prints None. Please advise. The reverse() method modifies the list in place, but returns None, so just use cols.reverse() rather than cols = cols.reverse() Alternatively you can do \, cols = reversed(cols) Also, is there a way to append to the front of the list directly? TIA, beno The insert() method can do this, i.e. cols.insert(0, 'Delete') -- Matt Saxton m...@scotweb.co.uk -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Dumb Stupid Question About List and String
On Wed, Sep 1, 2010 at 12:27 AM, Alban Nona python.k...@gmail.com wrote: Hi all, Im stuck on this problem: I have a function which return me a list of string (basically the result looks like: [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] In other hand, I have another list full of that kind of entries: [FN067_098_MEN_Hair_PUZ_v001.0001.exr,FN067_098_JIN_Hair_SPC_v001.0001.exr,FN067_098_MEN_Jin_MVE_v001.0001.exr,FR043_010_GEN_NRM_v001.0001.exr] I would like to do something like this: myFirstList = [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] mySecondList = [FN067_098_MEN_Hair_PUZ_v001.0001.exr,FN067_098_JIN_Hair_SPC_v001.0001.exr,FN067_098_MEN_Jin_MVE_v001.0001.exr,FR043_010_GEN_NRM_v001.0001.exr] for n in myFirstList: if n in mySecondList: mySecondList.remove(n) In fact, what I want to do it to remove entries with the secondlist which content the entries of the first one. But it seems to not work like this. Someone can help me please ? did I miss something ? You can try this if you don't care about the order. myFirstList = [FN067_098_MEN, FN067_098_JIN, FN067_098_BG] mySecondList = [FN067_098_MEN_Hair_PUZ_v001.0001.exr,FN067_098_JIN_Hair_SPC_v001.0001.exr,FN067_098_MEN_Jin_MVE_v001.0001.exr,FR043_010_GEN_NRM_v001.0001.exr] list(set(mySecondList).difference(myFirstList)) ['FN067_098_MEN_Jin_MVE_v001.0001.exr', 'FN067_098_MEN_Hair_PUZ_v001.0001.exr', 'FR043_010_GEN_NRM_v001.0001.exr', 'FN067_098_JIN_Hair_SPC_v001.0001.exr'] Another example to make this clear. a = range(10) b = range(5,15) a [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] b [5, 6, 7, 8, 9, 10, 11, 12, 13, 14] list(set(b).difference(a)) [10, 11, 12, 13, 14] -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Find closest matching string based on collection of strings in list/dict/set
On Tue, Aug 31, 2010 at 9:12 PM, pyt...@bdurham.com wrote: I'm parsing a simple, domain specific scripting language that has commands like the following: *page, *title, *text, *footer, etc. There are about 100 of these '*' commands. When we see a command that we don't recognize, I would like to find the closest match possible (from a list of all legal commands) and include this suggestion in our diagnostic output. I'm not sure what you would call the type of algorithm I'm looking for: closest matching string or auto-correct? Any suggestions on algorithms or python libraries that would help me do what I'm looking for? Here's my short-list of ideas based on my research so far: - Soundex - Lawrence Philips' Metaphone Algorithm (from aspell?) - Edit Distance Algorithm - Levenstein Word Distance Any suggestions, comments on the above techniques, or ideas on a simpler algorithm for finding close string matches based on a list, dict, or set of possible strings? You are looking possibly for autocompletion/spell correction algorithm. You can write a HMM based Pos Tagger. Thank you, Malcolm -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Find closest matching string based on collection of strings in list/dict/set
On Wed, Sep 1, 2010 at 2:31 AM, Joel Goldstick joel.goldst...@columbuswebmakers.com wrote: pyt...@bdurham.com wrote: I'm parsing a simple, domain specific scripting language that has commands like the following: *page, *title, *text, *footer, etc. There are about 100 of these '*' commands. When we see a command that we don't recognize, I would like to find the closest match possible (from a list of all legal commands) and include this suggestion in our diagnostic output. I'm not sure what you would call the type of algorithm I'm looking for: closest matching string or auto-correct? Any suggestions on algorithms or python libraries that would help me do what I'm looking for? Here's my short-list of ideas based on my research so far: - Soundex - Lawrence Philips' Metaphone Algorithm (from aspell?) - Edit Distance Algorithm - Levenstein Word Distance Any suggestions, comments on the above techniques, or ideas on a simpler algorithm for finding close string matches based on a list, dict, or set of possible strings? Thank you, Malcolm Have you looked at difflib? On a side note, you can read this awesome article by Peter Norvig. http://norvig.com/spell-correct.html -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Source code for itertools
On Tue, Aug 31, 2010 at 7:30 AM, vsoler vicente.so...@gmail.com wrote: I'm interested in studying the itertools source code, especially the permutations function. However, I cannot find the library. Where could I find it? Running Python 3.1 Thank you Either you can download it or browse it on the net. http://svn.python.org/view/python/trunk/Modules/itertoolsmodule.c?view=markup -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: freq function
On Sun, Aug 22, 2010 at 1:31 PM, Dirk Nachbar dirk...@gmail.com wrote: Here is a function which takes any list and creates a freq table, which can be printed unsorted, sorted by cases or items. It's supposed to mirror the proc freq in SAS. Dirk def freq(seq,order='unsorted',prin=True): #order can be unsorted, cases, items freq={} for s in seq: if s in freq: freq[s]+=1 else: freq[s]=1 The above code can be replaced with this: freq = {} for s in seqn: freq[s] = freq.get(s,0) + 1 if prin==True: print 'Items=',len(seq),'Cases=',len(freq) print '' if order=='unsorted': for k in freq.keys(): print k,freq[k],float(freq[k])/len(seq) elif order=='cases': #http://blog.client9.com/2007/11/sorting-python-dict-by- value.html freq2=sorted(freq.iteritems(), key=lambda (k,v): (v,k),reverse=True) for f in freq2: print f[0],f[1],float(f[1])/len(seq) elif order=='items': for k in sorted(freq.iterkeys()): print k,freq[k],float(freq[k])/len(seq) print '' return freq #test import random rand=[] for i in range(1): rand.append(str(int(100*random.random( fr=freq(rand) fr2=freq(rand,order='items') fr2=freq(rand,order='cases') -- I feel the code you wrote is bloated a bit. You shall definately give another try to improvise it. http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
[issue747320] rfc2822 formatdate functionality duplication
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue747320 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: how to change a string into dictionary
On Mon, Aug 9, 2010 at 3:03 PM, aimeixu aime...@amazon.com wrote: Hi, I am newbie for python ,Here is my question: a = {'a':'1','b':'2'} how to change a into a dictionary ,says, a = {'a':'1','b':'2'} Thanks a lot .Really need help. Parse the string and re-create the dictionary. s = {'a':'1','b':'2'} ds = {} for i in s.strip('{}').split(','): ... key, val = i.split(':') ... ds[key.strip(')] = val.strip(') ... ds {'a': '1', 'b': '2'} type(ds) class 'dict' -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: simple renaming files program
On Mon, Aug 9, 2010 at 3:14 PM, blur959 blur...@hotmail.com wrote: Hi, all, I am working on a simple program that renames files based on the directory the user gives, the names the user searched and the names the user want to replace. However, I encounter some problems. When I try running the script, when it gets to the os.rename part, there will be an error. The error is : n = os.rename(file, file.replace(s, r)) WindowsError: [Error 2] The system cannot find the file specified This is because the file does not exist. I attached my code below, hope you guys can help me, Thanks! import os directory = raw_input(input file directory) s = raw_input(search for name) r = raw_input(replace name) for file in os.listdir(directory): n = os.rename(file, file.replace(s, r)) print n Tried this on my system, works. [shutil.move(i, r) for i in os.listdir(directory) if i==s] -- http://mail.python.org/mailman/listinfo/python-list -- ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Performance ordered dictionary vs normal dictionary
It depends on the problem. A dictionary is a hash table. An ordered dictionary is a binary search tree (BST). Those are different data structures. The main things to note is that: - Access is best-case O(1) for the hash table and O(log n) for the BST. - Worst case behavior is for access is O(n) for both. The pathologic conditions are excessive collisions (hash) or an unbalanced tree (BST). In pathologic cases they both converge towards a linked list. - Searches are only meaningful for == and != for a hash table, but BST searches are also meaningful for , , =, and =. For this reason, databases are often implemented as BSTs. - A BST can be more friendly to cache than a hash table, particularly when they are large. (Remember that O(1) can be slower than O(log n). Big-O only says how run-time scales with n.) Thanks, this was really insightful :) -- http://mail.python.org/mailman/listinfo/python-list
Re: rstrip()
On Fri, Jul 16, 2010 at 10:28 PM, Jason Friedman ja...@powerpull.netwrote: $ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:43:55) [GCC 4.4.1] on linux2 Type help, copyright, credits or license for more information. x.vsd-dir.rstrip(-dir) 'x.vs' I expected 'x.vsd' as a return value. rstrip([chars]) The chars are stripped from right. Here it's ['-', 'd','i','r'] , hence these 4 characters will be stripped from right, so you are left with 'x.vs' -- http://mail.python.org/mailman/listinfo/python-list
Re: nicer way to remove prefix of a string if it exists
On Wed, Jul 14, 2010 at 5:42 AM, MRAB pyt...@mrabarnett.plus.com wrote: News123 wrote: I wondered about a potentially nicer way of removing a prefix of a string if it exists. Here what I tried so far: def rm1(prefix,txt): if txt.startswith(prefix): return txt[len(prefix):] return txt for f in [ 'file:///home/me/data.txt' , '/home/me/data.txt' ]: # method 1 inline prefix = file:// if f.startswith(prefix): rslt = f[len(prefix):] else rsl = f # method 2 as function rslt = rm1('file://',f) Is there any nicer function than above rm1()? No. Is there any nicer inline statement rhan my method 1' ? You could write: rsl = f[len(prefix):] if f.startswith(prefix) else f Or you can just do split and join, .join(f.split(prefix, 1)) will do. prefix = 'file://' f = 'file:///home/me/data.txt' .join(f.split(prefix, 1)) '/home/me/data.txt' f = 'file:///home/me/data.txtfile://' .join(f.split(prefix, 1)) '/home/me/data.txtfile://' f = '/home/me/data.txt' .join(f.split(prefix, 1)) '/home/me/data.txt' -- http://mail.python.org/mailman/listinfo/python-list
Re: python namespace question
On Wed, Jul 14, 2010 at 8:33 AM, chad cdal...@gmail.com wrote: Given the following code... #!/usr/bin/python class cgraph: def printme(self): print hello\n No need to do print hello\n, python is not C, print hello prints hello with a newline. Try it on interpretor. x = cgraph() x.printme() Does the function print() exist in the cgraph namespace or the printme() one? Where exactly is the print() function here. BTW printme() is in cgraph namespace. ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: Check if a command is valid
On Tue, Jul 13, 2010 at 6:59 AM, Kenny Meyer knny.m...@gmail.com wrote: Hello, I have to figure out if a string is callable on a Linux system. I'm actually doing this: def is_valid_command(command): retcode = 100 # initialize if command: retcode = subprocess.call(command, shell=True) if retcode is 0: print Valid command. else: print Looks not so good... is_valid_command(ls) Never mind the code, because this is not the original. The side effect of subprocess.call() is that it *actually* executes it, but I just need the return code. What are better ways of doing this? Check your $PATH. All your system commands lies there. Make a list and save it. Now just check whether your 'command' lies in the list. However better is to run the command, but some commands like 'shutdown' won't be good for this I think. ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: 500 tracker orphans; we need more reviewers
On Fri, Jul 9, 2010 at 3:28 AM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 19-6-2010 23:45, Shashwat Anand wrote: Terry: Thanks for bringing this to notice. Mark: Kudos for your effort in cleaning up bugs.python.org Like I've said elsewhere, flattery will get you everywhere. :) I think acknowledgement != flattery, but then you are free to have a different point of view :| FYI there are now 480 orphans and I've managed to get 8 issues closed. After one week I even got promoted to the triage team, although I found the pay increase rather disappointing. :) -- http://mail.python.org/mailman/listinfo/python-list
Re: Argh! Name collision!
On Wed, Jul 7, 2010 at 8:21 AM, Richard Thomas chards...@gmail.com wrote: On Jul 7, 3:11 am, Alf P. Steinbach /Usenet alf.p.steinbach +use...@gmail.com wrote: Donald Knuth once remarked (I think it was him) that what matters for a program is the name, and that he'd come up with a really good name, now all he'd had to do was figure out what it should be all about. And so considering Sturla Molden's recent posting about unavailability of MSVC 9.0 (aka Visual C++ 2008) for creating Python extensions in Windows, and my unimaginative reply proposing names like pni and pynacoin for a compiler independent Python native code interface, suddenly, as if out of thin air, or perhaps out of fish pudding, the name pyni occurred to me. pyni! Pronounced like tiny! Yay! I sat down and made my first Python extension module, following the tutorial in the docs. It worked! But, wait, perhaps some other extension is already named piny? Google. url:http://code.google.com/p/pyni/, PyNI is [a] config file reader/writer. Argh! - Alf -- blog at url:http://alfps.wordpress.com PyNI seems to perform the same function as ConfigParser. I prefer the pronunciation like tiny to Py-N-I. The latter seems clunky. On a possibly related note I was disappointed to discover that Python's QT bindings are called PyQT not QTPy. :-) Isn't this the standard. Qt - PyQt crypto - pycrypto MT - PyMT . and the list goes on and on .. :) ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
[issue9153] Run tests and demos as part of the test suite
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9153 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9161] add_option in optparse no longer accepts unicode string
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9161 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8470] Let cmd.cmd.intro be unicode friendly
Shashwat Anand anand.shash...@gmail.com added the comment: Python 2.7 is already released. This is a non-issue on py3.x. Should this issue be closed or we work on it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: why python don't support extended slice direct assignment for lists?
On Sat, Jul 3, 2010 at 4:54 AM, Robert William Hanks astroultra...@gmail.com wrote: why pure python don't support extended slice direct assignment for lists? today we have to write like this, aList=[0,1,2,3,4,5,6,7,8,9] aList [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] aList[::2]= [None]*len(aList[::2]) #or do the math by hand, what's not always possible Can you show me a case where it really is cumbersome. aList [None, 1, None, 3, None, 5, None, 7, None, 9] why not accept syntax like this for extended slice aList[::2] = None when let's say, the left side is a list and the right side is bool, int or float. the laborious [nunber]*len(aList[::2]) seens to me less readable when you want to set lost of items of a list to the same number. Also correct me if i am wrong, calling len() and building a list to this kind of operation seems a waste. aList[::2] [0, 2, 4, 6, 8] Which means you are doing [0, 2, 4, 6, 8] = None, which is plain and simple - wrong. How will you define the legitimacy of this statement. What you are basically doing here is,, [None]*len(aList[::2]) [None, None, None, None, None] aList[::2] [0, 2, 4, 6, 8] Setting [0, 2, 4, 6, 8] to [None, None, None, None, None], thereby operating on two similar data structure (here list) Just want some feedback. Just my thoughts. ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
Re: The real problem with Python 3 - no business case for conversion (was I strongly dislike Python 3)
On Sat, Jul 3, 2010 at 5:27 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 02 Jul 2010 12:07:33 -0700, John Nagle wrote: Where's the business case for moving to Python 3? It's not faster. It doesn't do anything you can't do in Python 2.6. There's no killer app for it. End of life for Python 2.x is many years away; most server Linux distros aren't even shipping with 2.6 yet. How can a business justify spending money on conversion to Python 3? The point is python2.7 is the last 2.x version. It will be supported, bugs will be fixed but no new feature will be added. Core devs will concentrate on python 3.x. You can still use 2.x, no one is stopping you. But assume that it is stagnant now. After some time only security related bugs will be fixed. So if you want to wait by then, it's all your wish. ~l0nwlf -- http://mail.python.org/mailman/listinfo/python-list
[issue9085] Version number inconsistency in email package
Shashwat Anand anand.shash...@gmail.com added the comment: In python2.5 email version is 4.0.2 In python2.6 email version is 4.0.1 In python 2.7rc2 email version is 4.0.2 I think version number is wrong with 2.5, it should have been 4.0.0 rather than 4.0.2. David: Adding you as nosy so as you can confirm upon this. -- nosy: +l0nwlf, r.david.murray versions: +Python 2.5 -Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9085 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4963] mimetypes.guess_extension result changes after mimetypes.init()
Shashwat Anand anand.shash...@gmail.com added the comment: Can't reproduce. 16:36:36 l0nwlf-MBP:~$ python2.7 Python 2.7rc2+ (trunk:82148M, Jun 22 2010, 10:32:46) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type help, copyright, credits or license for more information. import mimetypes mimetypes.guess_extension('image/jpeg') '.jpe' mimetypes.init() mimetypes.guess_extension('image/jpeg') '.jpe' Results were same in python2.5, 2.6 too. I wonder whether this is machine specific or distro specific. -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4963 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4655] during Python installation, setup.py should not use .pydistutils.cfg
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +tarek ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4655 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Help on finding word is valid as per English Dictionary through python
why do you need that ? which platform are you onto ? On OSX you can use 'DictionaryServices' API eg., import sys import DictionaryServices word = .join(sys.argv[1:]) print DictionaryServices.DCSCopyTextDefinition(None, word, (0, len(word))) Gives the meaning of the input word (works with python 2.5) You can use this script for Vi (~/.vimrc) if you want, control+a will do a spell check. Toggle Spell-Check set spell spelllang= function ToggleSpellCheck() if spelllang == en set spelllang= else set spelllang=en endif endfunction command! ToggleSpellChecking call ToggleSpellCheck() nmap c-a :ToggleSpellCheckingcr But again am not aware of your use case. On Fri, Jun 25, 2010 at 7:19 PM, Thomas Jollans tho...@jollans.com wrote: On 06/25/2010 03:30 PM, anu python wrote: Hi, I have a text file , a.txt this is a lcose button where u can observer lcose is not a valid word.It's typing mistake.Actual word is close. How can i check that each word entered in txt file having correct meaningful words as per English Dictionary. Do you have any package which can check English Dictionary In a pinch, I might use open(/usr/share/dict/words, r) as a thesaurus, and check for words in there. Read the file and create a giant frozenset or something. For something a bit more civilized, I expect that there's a python package interfacing at least one of (ispell, aspell, hunspell, myspell) (and what they're all called. There is a multitude of English dictionaries. Some don't even include neighbour, imagine that! Please help me. Thanks, Anu -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue1685453] email package should work better with unicode
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1685453 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9048] no OS X buildbots in the stable list
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9048 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Should I Learn Python or Ruby next?
Josef: Make sure you ask this question on Ruby mailing list too. Just like James I too am personally biased towards python and so will be a lot of people on this list. On Tue, Jun 22, 2010 at 2:50 PM, James Mills prolo...@shortcircuit.net.auwrote: On Tue, Jun 22, 2010 at 6:58 PM, Josef Tupag joseftu...@gmail.com wrote: Before I really dive in, though, I'm curious to hear what others think about the choice between these two languages. This is a terribly subjective opinion and I apologize to anyone that actually uses Ruby and likes it :) I find Ruby (compared to Python) to be a syntactical rip-off and a bad one at that. Some things in Ruby aren't nearly as simple or as concise as you would find in Python. When it comes to Web Frameworks IHMO, I believe Python has a lot wide variety of tools available to you, not just Django, TurbotGears, Pylons, etc. (I can't comment on Ruby). Aside from my not liking some of Ruby's syntax or semantics I found Ruby on Rails to be awful. I went through it's turotial a few months back and didn't even make the first couple of pages before I got utterly bored with reading. So there you go... Sorry I can't offer you a real objective response! cheers James -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: print line number and source filename
22:26:51 l0nwlf-MBP:~/Desktop$ cat test.py print __file__ 22:26:55 l0nwlf-MBP:~/Desktop$ python test.py test.py On Tue, Jun 22, 2010 at 10:26 PM, Shashwat Anand anand.shash...@gmail.comwrote: you can use __file__ On Tue, Jun 22, 2010 at 10:14 PM, Peng Yu pengyu...@gmail.com wrote: I want to print filename and line number for debugging purpose. So far I only find how to print the line number but not how to print filename. import inspect print inspect.currentframe().f_lineno I found inspect.getsourcefile(), but I have to supply a class name to it. I have searched online, but I don't find how to print the source filename. Would you please let me know? Also, always importing the inspect module and getting the frame and accessing the lineno from the frame is not very convenient to type. Is there a shorter way to access the line number (for example, in C++ and perl, __LINE__ can be used to access line number, which is much more convenient than the way that I found in python). -- Regards, Peng -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: print line number and source filename
you can use __file__ On Tue, Jun 22, 2010 at 10:14 PM, Peng Yu pengyu...@gmail.com wrote: I want to print filename and line number for debugging purpose. So far I only find how to print the line number but not how to print filename. import inspect print inspect.currentframe().f_lineno I found inspect.getsourcefile(), but I have to supply a class name to it. I have searched online, but I don't find how to print the source filename. Would you please let me know? Also, always importing the inspect module and getting the frame and accessing the lineno from the frame is not very convenient to type. Is there a shorter way to access the line number (for example, in C++ and perl, __LINE__ can be used to access line number, which is much more convenient than the way that I found in python). -- Regards, Peng -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: print line number and source filename
begin - import logging logging.basicConfig(level=logging.DEBUG,format=%(asctime)s %(levelname)-5.5s [%(name)s %(module)s:%(funcName)s:%(lineno)d] %(message)s) def run(): x = 5 logging.debug(X = %d % x) run() - end - You can probably use string default concatenation feature of python. Anyway, am just nitpicking. Loved your example, as I was unaware of logging module. -- http://mail.python.org/mailman/listinfo/python-list
[issue7192] webbrowser.get(firefox) does not work on Mac with installed Firefox
Shashwat Anand anand.shash...@gmail.com added the comment: 16:05:57 l0nwlf-MBP:/Applications/Firefox.app/Contents/MacOS$ ./firefox-bin 'http://www.google.com' says firefox is already running as ff is open. After we quit ff, 16:09:05 l0nwlf-MBP:/Applications/Firefox.app/Contents/MacOS$ ./firefox-bin -remote 'http://www.google.com' Nothing happens. 16:09:14 l0nwlf-MBP:/Applications/Firefox.app/Contents/MacOS$ ./firefox-bin 'http://www.google.com' Opened firefox with url(google homepage) as mentioned. Also, import webbrowser url = 'http://www.google.com' c = webbrowser.get('safari') c.open(url) True Opens two instances of safari, one with home-page and another with url mentioned. Initially safari was not running and firefox is my default browser. Incase safari is running it opens only one instance with url(google homepage) opened. -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7192 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7192] webbrowser.get(firefox) does not work on Mac with installed Firefox
Shashwat Anand anand.shash...@gmail.com added the comment: I searched for proxy+firefox on roundup and the only two issue I got was issue 8238 and issue 1160328. None of them seems related to webbrowser. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7192 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8252] add a metadata section in setup.cfg
Shashwat Anand anand.shash...@gmail.com added the comment: Is +gsoc a keyword too ? :O On Tue, Jun 22, 2010 at 7:16 PM, Ãric Araujo rep...@bugs.python.org wrote: Ãric Araujo mer...@netwok.org added the comment: Iâm starting on this now. Monitor http://bitbucket.org/Merwok/distutils2-killsetup for updates. -- keywords: +gsoc resolution: - accepted stage: - needs patch versions: -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8252 ___ -- Added file: http://bugs.python.org/file17742/unnamed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8252 ___Is quot;+gsocquot; a keyword too ? :Obrbrdiv class=gmail_quoteOn Tue, Jun 22, 2010 at 7:16 PM, Ãric Araujo span dir=ltrlt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;/span wrote:br blockquote class=gmail_quote style=margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;br Ãric Araujo lt;a href=mailto:mer...@netwok.org;mer...@netwok.org/agt; added the comment:br br Iâm starting on this now. Monitor a href=http://bitbucket.org/Merwok/distutils2-killsetup; target=_blankhttp://bitbucket.org/Merwok/distutils2-killsetup/a for updates.br br --br keywords: +gsocbr resolution: Â -gt; acceptedbr stage: Â -gt; needs patchbr versions: Â -Python 3.3br divdiv/divdiv class=h5br ___br Python tracker lt;a href=mailto:rep...@bugs.python.org;rep...@bugs.python.org/agt;br lt;a href=http://bugs.python.org/issue8252; target=_blankhttp://bugs.python.org/issue8252/agt;br ___br /div/div/blockquote/divbr ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1349106] email.Generators does not separates headers with \r\n
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1349106 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8252] add a metadata section in setup.cfg
Shashwat Anand anand.shash...@gmail.com added the comment: merwok: Pont noted. I replied it via Gmail, was unaware of the fact that it adds an unnamed file. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8252 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9033] cmd module tab misbehavior
Shashwat Anand anand.shash...@gmail.com added the comment: Tested the patch and it works for trunk and python3.2 alpha. Without adding SDK flag with configure readline module failed to build. Python build finished, but the necessary bits to build these modules were not found: _gdbm ossaudiodevreadline spwd However for cmd module, tab completion and history(up|down arrow) worked fine. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9033 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: 500 tracker orphans; we need more reviewers
Terry: Thanks for bringing this to notice. Mark: Kudos for your effort in cleaning up bugs.python.org On Sat, Jun 19, 2010 at 10:16 PM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 19/06/2010 03:37, Terry Reedy wrote: Go to the bottom of http://bugs.python.org/iss...@template=searchstatus=1 enter 1 in the Message Count box and hit Search. At the moment, this gets 510 hits. Some have had headers updated, nearly half have had a person add himself as 'nosy' (put 1 in the Nosy count box to count those that have not), but none have a written response. In the past two weeks, I have commented on some old orphans and gotten a couple of previously orphaned patches applied and the issue closed. But I am not prepared to spend my whole life on this ;=). We need more issue reviewers. Clearly. If you want to contibute, opportunity is here. With 500 orphans, and 2200 other open issues, there must be something that matches your interests and abilities. Use other search fields to narrow the choices. If you want to contibute to the tracker, this may help: http://wiki.python.org/moin/TrackerDocs/ Then read examples of comments already there. Or consider my first-response comment to http://bugs.python.org/issue8990 To write that, I * verified the reported behavior, though I forgot to explicitly say so; when doing so, include version and system (such as 3.1.2, WinXP), as that is sometimes helpful. * read the relevant doc section and pasted it in to establish a basis for discussion (the OP might have done that, but did not, so I did). Everyone reading this should at least be able to do this much for an issue like this, and this much *is* helpful. * compared behavior and doc and concluded that there is a bug. * read the posted patch as best I could, which is not much in this case, but it at least looked like a real diff file. * noticed that the diff did *not* patch the appropriate unit test file. * discussed two possible fixes and identified which the OP choose. * wrote an 'executive summary' both for the OP and future reviewers. Oh yes, I also adjusted the headers. Although new reviewers cannot do that, you *can* suggest in the message what changes to make. Special offer to readers of this thread, especially new reviewers: if you make such a suggestion, you may email me, subject: Tracker, with one clickable link like the above, cut and pasted from the browser URL box, per line of the message. Perhaps you are shy and uncomfortable saying much. Well so was I. I started about 5 years ago with *safe* comments and have s l o w l y expanded my comfort zone. The shock of discovering this week that there are 500 orphans, some 2 years old, expanded it. After no response for a year or two, even an imperfect response must be better than nothing. While there is occasional negativity on the tracker, I believe it averages less per message than python-list, which itself is pretty decent. Terry Jan Reedy Ok, but I'm going for EAFP rather than LBYL. I have written a will. :) Kindest regards. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue9033] cmd module tab misbehavior
Shashwat Anand anand.shash...@gmail.com added the comment: It seems readline module is not installed on your system. Quoting Ned Deily's comment from issue8365 which will most probably solve your issue: Issue6877 (and subsequent fixes in Issue8066) allows the Python readline module to be built and linked with the OS X editline (libedit) library rather than with the GNU readline library (which is not included with OS X). However, the libedit included in versions of OS X prior to 10.5 is considered too broken to use here. By default, if you do not specify an --with-universal-archs other than 32-bit to configure or if you do not explicitly set MACOSX_DEPLOYMENT_TARGET to another value, configure defaults to using 10.4 (or earlier) so the building of the readline module is skipped. You can check this: from distutils.sysconfig import get_config_var get_config_var('MACOSX_DEPLOYMENT_TARGET') '10.4' (Whether this is the best default is another question.) As it stands, to be able to build the readline module, either: (1) supply the GNU readline library as a local library, or (2) ensure you are building with a deployment target of at least 10.5. For example: ./configure MACOSX_DEPLOYMENT_TARGET=10.6 ; make Also note that option (2) is not available for 3.1.x since the changes to support editline/libedit were not ported to it; they are, however, in 2.6.5, 2.7 (trunk), and 3.2 (py3k) -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9033 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9033] cmd module tab misbehavior
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9033 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8820] IDLE not launching correctly
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +kbk ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8820 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8820] IDLE not launching correctly
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8820 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4654] os.path.realpath() get the wrong result
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf, loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4654 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4654] os.path.realpath() get the wrong result
Shashwat Anand anand.shash...@gmail.com added the comment: No such issue on python 2.6, 2.7, 3.2. print(os.path.realpath('/Users/l0nwlf/Desktop/tmp/../decotest.lnk')) /Users/l0nwlf/Desktop/decotest.lnk I think this issue can be closed. However, I came with a different issue while testing on 2.6, trunk and 3.2. print(os.path.realpath('~/Desktop/tmp/../decotest.lnk')) /Volumes/CoreHD/py3k/~/Desktop/decotest.lnk -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4654 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9018] os.path.normcase(None) does not raise an error on linux and should
Shashwat Anand anand.shash...@gmail.com added the comment: Following the documentation, os.path.normcase(path) Normalize the case of a pathname. On Unix and Mac OS X, this returns the path unchanged; on case-insensitive filesystems, it converts the path to lowercase. On Windows, it also converts forward slashes to backward slashes. on Mac OS X, import os os.name 'posix' Checking through, Lib/posixpath.py, # Normalize the case of a pathname. Trivial in Posix, string.lower on Mac. # On MS-DOS this may also turn slashes into backslashes; however, other # normalizations (such as optimizing '../' away) are not allowed # (another function should be defined to do that). def normcase(s): Normalize case of pathname. Has no effect under Posix # TODO: on Mac OS X, this should really return s.lower(). return s Why on Mac OS X, it should return s.lower() ? Also to raise Error for None case we can probably change normcase() in Lib/posixpath.py as, def normcase(s): Normalize case of pathname. Has no effect under Posix if s is None: raise AttributeError return s -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9018 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4654] os.path.realpath() get the wrong result
Shashwat Anand anand.shash...@gmail.com added the comment: By different issue I meant expected but non-useful output. Although it does exactly what it is supposed to do, but expanding tilde (~) to $HOME could have been the default behavior(more user-friendly I should say). Don't know if that is worth it but the scale seems more on the negative side. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4654 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9010] Infinite loop in imaplib.IMAP4_SSL when used with Gmail
Shashwat Anand anand.shash...@gmail.com added the comment: import imaplib HOST=imap.gmail.com PORT=993 USERNAME=usern...@gmail.com PASSWORD=password server = imaplib.IMAP4_SSL(host=HOST, port=PORT) server.login(USERNAME, PASSWORD) def f(): print server.select(INBOX) print server.uid(FETCH, 1:*, (UID FLAGS BODY.PEEK[HEADER.FIELDS (Subject)])) Call the f() function and then wait about about an hour. Call f() again and server.select() will not return but take all CPU. Tried to reproduce this on Python 2.7RC1. Seemed Ok to me. Took some 3 seconds to call f() not only once, but twice, thrice. -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9010 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Community (A Modest Proposal)
IDEs are seriously over-rated. Vim FTW. The only issue for beginners is they should know touch typing to fully utilize Vim and the initial curve is a bit high as compared to normal editors/IDEs. On Tue, Jun 15, 2010 at 4:16 PM, Andreas Waldenburger use...@geekmail.invalid wrote: On Tue, 15 Jun 2010 17:45:43 +1000 James Mills prolo...@shortcircuit.net.au wrote: I myself use vim (as my editor) and 2-3 Terminals on virtual workspaces (in my DE). I guess the beauty with vim is you just read the line no. type it in and hit ^G You mean just G (Shift+g), right? ^G (Ctrl+G) prints the file name and cursor position. Incidentally, :linenumberReturn does the same as linenumberG. Sorry, that's seriously OT, but think about the havoc this could wreak if some uninformed layperson read this and took it to heart. ;) /W -- INVALID? DE! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: pythonize this!
sum(i*i*(-1)**((i % 5) / 4 + (i + 4) % 5 / 4) for i in range(1,2011)) 536926141 On Tue, Jun 15, 2010 at 6:25 PM, superpollo ute...@esempio.net wrote: superpollo ha scritto: Peter Otten ha scritto: superpollo wrote: goal (from e.c.m.): evaluate 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three consecutive + must be followed by two - (^ meaning ** in this context) from itertools import cycle, izip sum(sign*i*i for sign, i in izip(cycle([1]*3+[-1]*2), range(1, 2011))) 536926141 don't understand it bit i like this a lot! ^^^ *but* -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: how to build with 2.4 having 2.6 as main python
You can try a package : python_select On Mon, Jun 14, 2010 at 2:00 PM, Alexzive zasaconsult...@gmail.com wrote: Hello there, my Mandriva has the 2.6.4 python pre-installed (in /usr/lib64/ python2.6/) I need to install numpy 1.4 for python 2.4.3 (I installed it separately from source on/usr/local/lib/python2.4/ ) but still typing python I get: Python 2.6.4 (r264:75706, Jan 8 2010, 18:59:59) [GCC 4.4.1] on linux2 Type help, copyright, credits or license for more information. what to change in order to get python calling python 2.4.3 instead of 2.6.4 (at least during python setup.py build)? I suppose I need something like changing the link to /usr/local/bin/ python.. but I fear to do something bad by myself.. please help! -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on Android Mobile?
Well, AFAIK Nokia N900 supports python fully. On Mon, Jun 14, 2010 at 4:08 AM, Anthony Papillion papill...@gmail.comwrote: Thank you gentleman for your input. I'm starting to look at Python/GTK for desktop development and was hoping there might also be something for Android. Oh well, like Simon said (pardon the pun), it is open source so... :-) Anthony -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue8989] email.utils.make_msgid: specify domain
Shashwat Anand anand.shash...@gmail.com added the comment: Adrian, Could you generate the diffs from the top level of the checkout and attach it here? -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8989 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting
Shashwat Anand anand.shash...@gmail.com added the comment: Agreed. Attaching the unit test. -- Added file: http://bugs.python.org/file17656/test_httpserver.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8572] httplib getheader() throws error instead of default
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8572 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: regarding the dimensions in gui
Do you realize you are spamming the list. You generally fire one question and wait rather than supplying us a bunch of questions. And please stop using 'sir' for heaven's sake. I realize you are from India and it is a culture there but people don't use it in mailing lists. Thanks. On Thu, Jun 10, 2010 at 11:47 AM, madhuri vio madhuri@gmail.com wrote: sir ,, i wanted to knw how to decide on the dimensions mentioned in the gui development..all i know is the top left corner is considered as the origin ... then how are we having all the dimensions positive.??? -- madhuri :) -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: How to read source code of python?
And if you are interested in source and have no particular goal, start with stdlib. On Thu, Jun 10, 2010 at 6:39 AM, rantingrick rantingr...@gmail.com wrote: On Jun 9, 7:28 pm, Leon qjing...@gmail.com wrote: I'm trying to read the source code of python. I read around, and am kind of lost, so where to start? Leon, if you are a Python newbie and cannot understand/comprehend Python's syntax read the tutorial first. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: map is useless!
map is not needed. LC is great :D On Sun, Jun 6, 2010 at 10:32 PM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: rantingrick rantingr...@gmail.com writes: Python map is just completely useless. [...] import time def test1(): l = range(1) t1 = time.time() map(lambda x:x+1, l) t2= time.time() print t2-t1 def test2(): l = range(1) t1 = time.time() for x in l: x + 1 t2 = time.time() print t2-t1 test1() 0.0029346008 test2() 0.00027520752 def test3(): Well, not building the resulting list saves some time. But even if you do r.append(x+1) map appears to be slower... Try this: def test3(): l = range(1) t1 = time.time() [ x+1 for x in l] t2 = time.time() print t2-t1 I've not used map since I learned about list comprehensions. -- Alain. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting
Changes by Shashwat Anand anand.shash...@gmail.com: Removed file: http://bugs.python.org/file17567/BaseHTTPServer.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting
Shashwat Anand anand.shash...@gmail.com added the comment: You could get a minor speedup by doing “from email.utils import formatdate”. I guess I shall do that. Applied the patch and tested it, it does not break anything IMO and should go in python2.7 -- Added file: http://bugs.python.org/file17573/BaseHTTPServer.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting
Changes by Shashwat Anand anand.shash...@gmail.com: Removed file: http://bugs.python.org/file16900/BaseHTTPServer.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting
Shashwat Anand anand.shash...@gmail.com added the comment: Seems that earlier patch was incorrect. Rectifying and submitting the correct patch. -- Added file: http://bugs.python.org/file17567/BaseHTTPServer.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7370 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8898] The email package should defer to the codecs module for all aliases
Shashwat Anand anand.shash...@gmail.com added the comment: from email.charset.ALIASES most of them failed to be recognize by codecs module. for i in email.charset.ALIASES.keys(): ... try: ... codecs.lookup(i) ... except LookupError: ... print(Not recognized by codecs : alias {} mapped to {}.format(i, email.charset.ALIASES[i])) ... ... Not recognized by codecs : alias latin-8 mapped to iso-8859-14 Not recognized by codecs : alias latin-9 mapped to iso-8859-15 Not recognized by codecs : alias latin-2 mapped to iso-8859-2 Not recognized by codecs : alias latin-3 mapped to iso-8859-3 codecs.CodecInfo object for encoding iso8859-1 at 0x10160af58 Not recognized by codecs : alias latin-6 mapped to iso-8859-10 Not recognized by codecs : alias latin-7 mapped to iso-8859-13 Not recognized by codecs : alias latin-4 mapped to iso-8859-4 Not recognized by codecs : alias latin-5 mapped to iso-8859-9 codecs.CodecInfo object for encoding euc_jp at 0x1016260b8 Not recognized by codecs : alias latin-10 mapped to iso-8859-16 codecs.CodecInfo object for encoding ascii at 0x101626120 Not recognized by codecs : alias latin_10 mapped to iso-8859-16 codecs.CodecInfo object for encoding iso8859-1 at 0x10160aae0 Not recognized by codecs : alias latin_2 mapped to iso-8859-2 Not recognized by codecs : alias latin_3 mapped to iso-8859-3 Not recognized by codecs : alias latin_4 mapped to iso-8859-4 Not recognized by codecs : alias latin_5 mapped to iso-8859-9 Not recognized by codecs : alias latin_6 mapped to iso-8859-10 Not recognized by codecs : alias latin_7 mapped to iso-8859-13 Not recognized by codecs : alias latin_8 mapped to iso-8859-14 Not recognized by codecs : alias latin_9 mapped to iso-8859-15 codecs.CodecInfo object for encoding cp949 at 0x101626390 codecs.CodecInfo object for encoding euc_kr at 0x101626530 So basically apart from latin-1 all the latin* failed to be recognized by codecs. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8898] The email package should defer to the codecs module for all aliases
Shashwat Anand anand.shash...@gmail.com added the comment: We need to add aliases for those codecs. The current aliases list only supports the format latinN for N in 1-10. latinN means latin1 to latin10 ? But latin_1 is a recognized alias. codecs.lookup('latin_1') codecs.CodecInfo object for encoding iso8859-1 at 0x10160aae0 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8898 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re:
I have not much idea but Online Judges like SPOJ/codechef have regular programming-contests and python is one of allowed languages. So yes, it's possible. If I guess right, are you making an Online Judge for python. On Thu, Jun 3, 2010 at 8:39 PM, Amit Sethi amit.pureene...@gmail.comwrote: Hi , I wish to execute some user submitted python code and have absolutely no other way out . I saw that there used to be a module called rexec which could define which modules can be imported and which cannot however exec doesn't have that kind of feature . Please if you could tell me what would the best possible ways of sandboxing python code . -- A-M-I-T S|S -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regexp, \b
\b is NOT spaces p = re.compile(r'\sword\s') m = p.match(' word ') assert m m.group(0) ' word ' On Sat, May 29, 2010 at 8:34 PM, andrew cooke and...@acooke.org wrote: This is a bit embarassing, but I seem to be misunderstanding how \b works in regexps. Please can someone explain why the following fails: from re import compile p = compile(r'\bword\b') m = p.match(' word ') assert m My understanding is that \b matches a space at the start or end of a word, and that word is a word - http://docs.python.org/library/re.html What am I missing here? I suspect I am doing something very stupid. Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regexp, \b
Also what you are probably looking for is this I guess, p = re.compile(r'\bword\b') m = p.match('word word') assert m m.group(0) 'word' On Sat, May 29, 2010 at 8:44 PM, Shashwat Anand anand.shash...@gmail.comwrote: \b is NOT spaces p = re.compile(r'\sword\s') m = p.match(' word ') assert m m.group(0) ' word ' On Sat, May 29, 2010 at 8:34 PM, andrew cooke and...@acooke.org wrote: This is a bit embarassing, but I seem to be misunderstanding how \b works in regexps. Please can someone explain why the following fails: from re import compile p = compile(r'\bword\b') m = p.match(' word ') assert m My understanding is that \b matches a space at the start or end of a word, and that word is a word - http://docs.python.org/library/re.html What am I missing here? I suspect I am doing something very stupid. Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
[issue8470] Let cmd.cmd.intro be unicode friendly
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8470 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +l0nwlf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Shashwat Anand anand.shash...@gmail.com added the comment: Tested this patch, works perfectly fine. Also it suits for the particular use case which David mentioned where there is no better alternate approach. -- Added file: http://bugs.python.org/file17484/dbapi.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Changes by Shashwat Anand anand.shash...@gmail.com: Removed file: http://bugs.python.org/file17484/dbapi.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Shashwat Anand anand.shash...@gmail.com added the comment: conn = sqlite3.connect('dbdump.sqlite') c = conn.cursor() conn.in_transaction False c.execute('CREATE TABLE foo (id integer, name text)') sqlite3.Cursor object at 0x1004a7730 conn.in_transaction False It gives True for Insert and False for Select. perfect Ok. However It should give True when we Create tables ? Adding unit-test which upon showing this behavior fails the test. -- Added file: http://bugs.python.org/file17485/dbapi.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Changes by Shashwat Anand anand.shash...@gmail.com: Removed file: http://bugs.python.org/file17485/dbapi.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8845] Expose sqlite3 connection inTransaction as read-only in_transaction attribute
Shashwat Anand anand.shash...@gmail.com added the comment: Ok then. Uploading unit-test which takes value of in_transaction as False after issuing a Create statement. It passes with the patch applied. -- Added file: http://bugs.python.org/file17486/dbapi.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8845 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8811] fixing sqlite3 docs for py3k
Changes by Shashwat Anand anand.shash...@gmail.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8811 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: launching vi/vim from console
or in a reverse way you can open vim and use ':shell' followed by python. I prefer it that way generally On Mon, May 24, 2010 at 6:01 PM, adm avinash.ma...@gmail.com wrote: On May 24, 4:59 pm, Jean-Michel Pichavant jeanmic...@sequans.com wrote: adm wrote: I am newbie to python. Is there a way to launch vi/vim or any other editor from python console? I find editing in console very limiting. I can either have a console which launches vi and remembers it's content and then executes or invoke python interpreter from vim. Since I could not find anything I wrote this: http://python.pastebin.com/MFTHxuLe Please suggest if there is any better alternative for this. I tried googling for this but could not find anything interesting. Thanks, Adm import os os.system.('vi') or you can start an ipython shell and start vi using !vi Thanks. I wanted something like ipython. I will give it a try. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Chatroom
seems like an academic project which is worth grades On Tue, May 25, 2010 at 7:01 AM, alex23 wuwe...@gmail.com wrote: Martin P. Hellwig martin.hell...@dcuktec.org wrote: What have you tried so far? Alternatively, how much is it worth to you? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list