Re: Some posts do not show up in Google Groups
On Mon, Apr 30, 2012 at 2:20 AM, Frank Millman wrote: > > Hi all > > For a while now I have been using Google Groups to read this group, but on > the odd occasion when I want to post a message, I use Outlook Express, as I > know that some people reject all messages from Google Groups due to the high > spam ratio (which seems to have improved recently, BTW). > > >From time to time I see a thread where the original post is missing, but > the follow-ups do appear. My own posts have shown up with no problem. > > Now, in the last month, I have posted two messages using Outlook Express, > and neither of them have shown up in Google Groups. I can see replies in OE, > so they are being accepted. I send to the group gmane.comp.python.general. > > Does anyone know a reason for this, or have a solution? > > Frank Millman I believe the mail-to-news gateway has trouble with HTML messages. Try sending everything as plain text and see if that works. -- http://mail.python.org/mailman/listinfo/python-list
Re: help
On Mon, Apr 30, 2012 at 11:43 AM, viral shah wrote: > I want to print below matrix. > > can any one suggest me the method for the same > > 1 2 3 > 4 5 6 > 7 8 9 > In general, for homework questions, you should present your attempt at a solution, with specific questions where you are running into difficulty. Are you able to output anything using a python program? If not, you should take a look at one of the several excellent tutorials easily found by a web search. The official tutorial is at http://docs.python.org/py3k/tutorial/ and it might be enough for you to at least attempt a solution to your problem. Also, the python-tutor mailing list (http://mail.python.org/mailman/listinfo/tutor) is more suitable for beginning programmers. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list
Some posts do not show up in Google Groups
Hi all For a while now I have been using Google Groups to read this group, but on the odd occasion when I want to post a message, I use Outlook Express, as I know that some people reject all messages from Google Groups due to the high spam ratio (which seems to have improved recently, BTW). >From time to time I see a thread where the original post is missing, but the >follow-ups do appear. My own posts have shown up with no problem. Now, in the last month, I have posted two messages using Outlook Express, and neither of them have shown up in Google Groups. I can see replies in OE, so they are being accepted. I send to the group gmane.comp.python.general. Does anyone know a reason for this, or have a solution? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
help
I want to print below matrix. can any one suggest me the method for the same 1 2 3 4 5 6 7 8 9 Thanks -- Viral Shah IT Department, E-mail : shahviral...@gmail.com Mobile : (+91) 9722312220 -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
>On Mon, Apr 30, 2012 at 2:50 PM, Xah Lee wrote: >> jason, are you trolling me, or me you? > >Am I Turing dreaming I am a machine, or a machine dreaming I am Turing? > >Personally, I've never Turred. > >ChrisA Turing got a pretty shit deal for all the great things he did - odds are a machine would look at his life and how it should've progressed a lot better than we humans decided how it should've went. So dream away, machine. Dream of a world we humans weren't smart enough to live in. ~Temia -- When on earth, do as the earthlings do. -- http://mail.python.org/mailman/listinfo/python-list
RE: Learn Technical Writing from Unix Man in 10 Days
I did not sign up for this. ;_; -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On Mon, Apr 30, 2012 at 2:50 PM, Xah Lee wrote: > jason, are you trolling me, or me you? Am I Turing dreaming I am a machine, or a machine dreaming I am Turing? Personally, I've never Turred. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
>jason, are you trolling me, or me you? > >? > > Xah Depends on what you classify as "trolling" these days. In all honesty, the original concept of trolling seems to have become a lost art, with only a few people even knowing what the act actually was anymore, and in its absence everyone seems to draw their own definitions and conclusions of the term where it can be applied to whoever is antagonistic towards them at the time. In one definition, that being the one defined by common sense of "getting a reaction out of people", you in fact succeeded rather well by getting a reaction in general, though it was mostly mockery and heckling. In another definitions calling trolling an attempt at getting upset reactions specifically, I'd have to say there isn't so much of that unless your inquiry into who's trolling whom was because you felt as if you had been slighted by Jason's statement. So really, it's a crapshoot at this point. Who's trolling whom indeed. ~Temia -- When on earth, do as the earthlings do. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On Apr 29, 7:43 pm, Jason Earl wrote: > On Sat, Apr 28 2012, Steven D'Aprano wrote: > > On Sat, 28 Apr 2012 14:55:42 -0700, Xah Lee wrote: > > >> Learn Technical Writing from Unix Man in 10 Days > > >> Quote from man apt-get: > > >> remove > >> remove is identical to install except that packages are > >> removed > >> instead of installed. > > > Do you also expect the documentation to define "except", "instead", "is", > > "to" and "the"? > > > If you don't know what "install" and "remove" means, then you need an > > English dictionary, not a technical manual. > > It is considerably worse than that. If you look at what the > documentation for apt-get actually says, instead of just the badly > mangled version that Xah shares you would realize that the post was > basically a bald-face troll. > > The rest of Xah's links in this particular article was even worse. For > the most part he was criticizing documentation flaws that have > disappeared years ago. > > Heck, his criticism of Emacs' missing documentation has been fixed since > Emacs 21 (the Emacs developers are currently getting ready to release > Emacs 24). His criticism of git's documentation is also grossly > misleading. kernel.org still has the empty directories, but git-scm.org > has been the official home for git's documentation for years. > > I am sure that the rest of the examples are just as ridiculous. I tend > to like Xah's writing. Heck, I even sent a few bucks his way as thanks > for his Emacs Lisp tutorials. However, that particular post was simply > ridiculous. > > Jason jason, are you trolling me, or me you? ☺ Xah -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On Mon, Apr 30, 2012 at 12:43 PM, Jason Earl wrote: > It is considerably worse than that. If you look at what the > documentation for apt-get actually says, instead of just the badly > mangled version that Xah shares you would realize that the post was > basically a bald-face troll. Not only that, but a completely off-topic one... like a lot of his trolls. What has 'man apt-get' to do with Python? For all I know, the package may be written in Python, or the man page could be generated on-the-fly by a Python script, but unless you say how it's relevant to python-list/c.l.p, it's not obvious. Now, if that were 'man python' that he's criticizing, then sure. But it's not. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax for code blocks
Peter Pearson writes: > On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: > > I'd like to change the syntax of my module 'codeblocks' to make it > > more pythonic. The “chained callable” style isn't very Pythonic, IMO. Even worse is the penchant for ‘foo .bar()’, the space obscures the fact that this is attribute access. Far from Pythonic, this seems to be an attempt to write some other language in Python code. > > Current Syntax: > > > > with res << func(arg1) << 'x, y': > > print(x, y) > > > > with res << func(arg1) << block_name << 'x, y': > > print(x, y) > > > > New Syntax: > > > > with res == func(arg1) .taking_block (x, y): > > print(x, y) > > > > with res == func(arg1) .taking_block (x, y) as block_name: > > print(x, y) > [snip] > > Hey, guys, am I the only one here who can't even guess what > this code does? When did Python become so obscure? No, you're not alone; I think that code is pretty poor at communicating the intent. AFAICT the above code is a proposal. I don't know who (other than the original poster) thinks it's any good. -- \ “I cannot be angry at God, in whom I do not believe.” —Simone | `\ De Beauvoir | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax for code blocks
29.04.12 19:05, Peter Pearson написав(ла): Hey, guys, am I the only one here who can't even guess what this code does? When did Python become so obscure? This isn't Python at all. It's Ruby. -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On Sat, Apr 28 2012, Steven D'Aprano wrote: > On Sat, 28 Apr 2012 14:55:42 -0700, Xah Lee wrote: > >> Learn Technical Writing from Unix Man in 10 Days >> >> Quote from man apt-get: >> >> remove >> remove is identical to install except that packages are >> removed >> instead of installed. > > > Do you also expect the documentation to define "except", "instead", "is", > "to" and "the"? > > If you don't know what "install" and "remove" means, then you need an > English dictionary, not a technical manual. It is considerably worse than that. If you look at what the documentation for apt-get actually says, instead of just the badly mangled version that Xah shares you would realize that the post was basically a bald-face troll. The rest of Xah's links in this particular article was even worse. For the most part he was criticizing documentation flaws that have disappeared years ago. Heck, his criticism of Emacs' missing documentation has been fixed since Emacs 21 (the Emacs developers are currently getting ready to release Emacs 24). His criticism of git's documentation is also grossly misleading. kernel.org still has the empty directories, but git-scm.org has been the official home for git's documentation for years. I am sure that the rest of the examples are just as ridiculous. I tend to like Xah's writing. Heck, I even sent a few bucks his way as thanks for his Emacs Lisp tutorials. However, that particular post was simply ridiculous. Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 04/29/2012 07:17 PM, someone wrote: Ok. When do you define it to be singular, btw? There are things you can see right away about a matrix A being singular without doing any computation. By just looking at it. For example, If you see a column (or row) being a linear combination of other column(s) (or row(s)) then this is a no no. In your case you have 1 2 3 111213 212223 You can see right away that if you multiply the second row by 2, and subtract from that one times the first row, then you obtain the third row. Hence the third row is a linear combination of the first row and the second row. no good. When you get a row (or a column) being a linear combination of others rows (or columns), then this means the matrix is singular. --Nasser -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 04/29/2012 07:59 PM, someone wrote: Also, as was said, do not use INV(A) directly to solve equations. In Matlab I used x=A\b. good. I used inv(A) in python. Should I use some kind of pseudo-inverse or what do you suggest? I do not use python much myself, but a quick google showed that pyhton scipy has API for linalg, so use, which is from the documentation, the following code example X = scipy.linalg.solve(A, B) But you still need to check the cond(). If it is too large, not good. How large and all that, depends on the problem itself. But the rule of thumb, the lower the better. Less than 100 can be good in general, but I really can't give you a fixed number to use, as I am not an expert in this subjects, others who know more about it might have better recommendations. --Nasser -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 04/30/2012 02:38 AM, Nasser M. Abbasi wrote: On 04/29/2012 05:17 PM, someone wrote: I would also kindly ask about how to avoid this problem in the future, I mean, this maybe means that I have to check the condition number at all times before doing anything at all ? How to do that? I hope you'll check the condition number all the time. So how big can it (cond-number) be before I should do something else? And what to do then? Cramers rule or pseudoinverse or something else? You could be designing a building where people will live in it. If do not check the condition number, you'll end up with a building that will fall down when a small wind hits it and many people will die all because you did not bother to check the condition number when you solved the equations you used in your design. Also, as was said, do not use INV(A) directly to solve equations. In Matlab I used x=A\b. I used inv(A) in python. Should I use some kind of pseudo-inverse or what do you suggest? -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
someone writes: >> A is not just close to singular: it's singular! > Ok. When do you define it to be singular, btw? Singular means the determinant is zero, i.e. the rows or columns are not linearly independent. Let's give names to the three rows: a = [1 2 3]; b = [11 12 13]; c = [21 22 23]. Then notice that c = 2*b - a. So c is linearly dependent on a and b. Geometrically this means the three vectors are in the same plane, so the matrix doesn't have an inverse. >>> Which is the most accurate/best, even for such a bad matrix? What are you trying to do? If you are trying to calculate stuff with matrices, you really should know some basic linear algebra. -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 04/29/2012 05:17 PM, someone wrote: I would also kindly ask about how to avoid this problem in the future, I mean, this maybe means that I have to check the condition number at all times before doing anything at all ? How to do that? I hope you'll check the condition number all the time. You could be designing a building where people will live in it. If do not check the condition number, you'll end up with a building that will fall down when a small wind hits it and many people will die all because you did not bother to check the condition number when you solved the equations you used in your design. Also, as was said, do not use INV(A) directly to solve equations. --Nasser -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 04/30/2012 12:39 AM, Kiuhnm wrote: So Matlab at least warns about "Matrix is close to singular or badly scaled", which python (and I guess most other languages) does not... A is not just close to singular: it's singular! Ok. When do you define it to be singular, btw? Which is the most accurate/best, even for such a bad matrix? Is it possible to say something about that? Looks like python has a lot more digits but maybe that's just a random result... I mean Element 1,1 = 2.81e14 in Python, but something like 3e14 in Matlab and so forth - there's a small difference in the results... Both results are *wrong*: no inverse exists. What's the best solution of the two wrong ones? Best least-squares solution or whatever? With python, I would also kindly ask about how to avoid this problem in the future, I mean, this maybe means that I have to check the condition number at all times before doing anything at all ? How to do that? If cond(A) is high, you're trying to solve your problem the wrong way. So you're saying that in another language (python) I should check the condition number, before solving anything? You should try to avoid matrix inversion altogether if that's the case. For instance you shouldn't invert a matrix just to solve a linear system. What then? Cramer's rule? -- http://mail.python.org/mailman/listinfo/python-list
Re: Communication between C++ server and Python app
On 29Apr2012 21:08, Chris Angelico wrote: | On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson wrote: | > On 29Apr2012 11:42, Chris Angelico wrote: | > | Personally, I would recommend a TCP socket, because that allows the | > | flexibility of splitting across multiple computers. | > | > And the pain of ensuring security, if you're in an open network. | | You have that with all IPC. You can always bind to 127.0.0.1 or ::1 to | stop other hosts from connecting; and then it's minimal change to open | it up. I'm as concerned with other users as with other hosts. Hence the pleasures of UNIX permissions on a socket. You're right, I did say "open network", didn't I? Nonetheless, my preference stands unless a new use case arises. Cheers, -- Cameron Simpson DoD#743 http://www.cskk.ezoshosting.com/cs/ Just because Unix is a multiuser system doesn't mean I want to share it with anybody!- Paul Tomblin, in rec.aviation.military -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy (matrix solver) - python vs. matlab
On 4/30/2012 0:17, someone wrote: Hi, Notice cross-post, I hope you bear over with me for doing that (and I imagine that some of you also like python in the matlab-group like myself)... -- Python vs. Matlab: -- Python: from numpy import matrix from numpy import linalg A = matrix( [[1,2,3],[11,12,13],[21,22,23]] ) print "A=" print A print "A.I (inverse of A)=" print A.I A.I (inverse of A)= [[ 2.81466387e+14 -5.62932774e+14 2.81466387e+14] [ -5.62932774e+14 1.12586555e+15 -5.62932774e+14] [ 2.81466387e+14 -5.62932774e+14 2.81466387e+14]] Matlab: >> A=[1 2 3; 11 12 13; 21 22 23] A = 1 2 3 11 12 13 21 22 23 >> inv(A) Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.067522e-17. ans = 1.0e+15 * 0.3002 -0.6005 0.3002 -0.6005 1.2010 -0.6005 0.3002 -0.6005 0.3002 -- Python vs. Matlab: -- So Matlab at least warns about "Matrix is close to singular or badly scaled", which python (and I guess most other languages) does not... A is not just close to singular: it's singular! Which is the most accurate/best, even for such a bad matrix? Is it possible to say something about that? Looks like python has a lot more digits but maybe that's just a random result... I mean Element 1,1 = 2.81e14 in Python, but something like 3e14 in Matlab and so forth - there's a small difference in the results... Both results are *wrong*: no inverse exists. With python, I would also kindly ask about how to avoid this problem in the future, I mean, this maybe means that I have to check the condition number at all times before doing anything at all ? How to do that? If cond(A) is high, you're trying to solve your problem the wrong way. You should try to avoid matrix inversion altogether if that's the case. For instance you shouldn't invert a matrix just to solve a linear system. Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
numpy (matrix solver) - python vs. matlab
Hi, Notice cross-post, I hope you bear over with me for doing that (and I imagine that some of you also like python in the matlab-group like myself)... -- Python vs. Matlab: -- Python: from numpy import matrix from numpy import linalg A = matrix( [[1,2,3],[11,12,13],[21,22,23]] ) print "A=" print A print "A.I (inverse of A)=" print A.I A.I (inverse of A)= [[ 2.81466387e+14 -5.62932774e+14 2.81466387e+14] [ -5.62932774e+14 1.12586555e+15 -5.62932774e+14] [ 2.81466387e+14 -5.62932774e+14 2.81466387e+14]] Matlab: >> A=[1 2 3; 11 12 13; 21 22 23] A = 1 2 3 111213 212223 >> inv(A) Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.067522e-17. ans = 1.0e+15 * 0.3002 -0.60050.3002 -0.60051.2010 -0.6005 0.3002 -0.60050.3002 -- Python vs. Matlab: -- So Matlab at least warns about "Matrix is close to singular or badly scaled", which python (and I guess most other languages) does not... Which is the most accurate/best, even for such a bad matrix? Is it possible to say something about that? Looks like python has a lot more digits but maybe that's just a random result... I mean Element 1,1 = 2.81e14 in Python, but something like 3e14 in Matlab and so forth - there's a small difference in the results... With python, I would also kindly ask about how to avoid this problem in the future, I mean, this maybe means that I have to check the condition number at all times before doing anything at all ? How to do that? I hope you matlabticians like this topic, at least I myself find it interesting and many of you probably also program in some other language and then maybe you'll find this worthwhile to read about. -- http://mail.python.org/mailman/listinfo/python-list
Re: why () is () and [] is [] work in other way?
On 4/28/2012 4:47 AM, Kiuhnm wrote: On 4/27/2012 17:39, Adam Skutt wrote: On Apr 27, 8:07 am, Kiuhnm wrote: Useful... maybe, conceptually sound... no. Conceptually, NaN is the class of all elements which are not numbers, therefore NaN = NaN. NaN isn't really the class of all elements which aren't numbers. NaN is the result of a few specific IEEE 754 operations that cannot be computed, like 0/0, and for which there's no other reasonable substitute (e.g., infinity) for practical applications . In the real world, if we were doing the math with pen and paper, we'd stop as soon as we hit such an error. Equality is simply not defined for the operations that can produce NaN, because we don't know to perform those computations. So no, it doesn't conceptually follow that NaN = NaN, what conceptually follows is the operation is undefined because NaN causes a halt. Mathematics is more than arithmetics with real numbers. We can use FP too (we actually do that!). We can say that NaN = NaN but that's just an exception we're willing to make. We shouldn't say that the equivalence relation rules shouldn't be followed just because *sometimes* we break them. This is what programming languages ought to do if NaN is compared to anything other than a (floating-point) number: disallow the operation in the first place or toss an exception. If you do a signaling floating point comparison on IEEE floating point numbers, you do get an exception. On some FPUs, though, signaling operations are slower. On superscalar CPUs, exact floating point exceptions are tough to implement. They are done right on x86 machines, mostly for backwards compatibility. This requires an elaborate "retirement unit" to unwind the state of the CPU after a floating point exception. DEC Alphas didn't have that; SPARC and MIPS machines varied by model. ARM machines in their better modes do have that. Most game console FPUs do not have a full IEEE implementation. Proper language support for floating point exceptions varies with the platform. Microsoft C++ on Windows does support getting it right. (I had to deal with this once in a physics engine, where an overflow or a NaN merely indicated that a shorter time step was required.) But even there, it's an OS exception, like a signal, not a language-level exception. Other than Ada, which requires it, few languages handle such exceptions as language level exceptions. John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: Communication between C++ server and Python app
Failr point - I should do that in original question. The C++ server runs on Unix (Mac OS X as a matter of fact) and, as I'm the one who develops it, can use whthever technology is suitable. Currently it uses STL, Boost and Qt libraries. The server is responsible for providing connectivity to stock exchange and will be used mainly to monitor price of certain financial instruments and placing/cancelling orders. My idea is to keep this as simple tool that will execute whathever it's asked for. On top of this server I plan to write some trading logic in Python - scripts that will trigger certain actions depending on situation on market. I planned to exchange text commands between the C++ server and Python scripts as Python is really good in parsing text and on server side Boost/STL also do the trick. Communication between 'logic' and the server won't be high frequency - I plan to talk to teh server ~10 times a minute. Will appreciate suggestions. M. On 29 Apr 2012, at 05:00, Rodrick Brown wrote: > > Sent from my iPad > > On Apr 28, 2012, at 8:45 PM, kenk wrote: > >> Hi, >> >> I've got a server process written in C++ running on Unix machine. >> On the same box I'd like to run multiple Python scripts that will >> communicate with this server. >> >> Can you please suggest what would be best was to achieve this ? >> >> Kind regards and thanks in advance! >> M. >> -- >> http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython thread starvation
In article <7xipgj8vxh@ruckus.brouhaha.com>, Paul Rubin wrote: > Roy Smith writes: > > I agree that application-level name cacheing is "wrong", but sometimes > > doing it the wrong way just makes sense. I could whip up a simple > > cacheing wrapper around getaddrinfo() in 5 minutes. Depending on the > > environment (both technology and bureaucracy), getting a cacheing > > nameserver installed might take anywhere from 5 minutes to a few days to ... > > IMHO this really isn't one of those times. The in-app wrapper would > only be usable to just that process, and we already know that the OP has > multiple processes running the same app on the same machine. They would > benefit from being able to share the cache, so now your wrapper gets > more complicated. So, use memcache. Trivial to set up, easy Python integration, and it has the expiration mechanism built in. Not to mention it has a really cute web site (http://memcached.org/). > Also, since this is a production application, doing something in 5 > minutes is less important than making it solid and configurable. Maybe. On the other hand, the time you save with a 5 minute solution can be spent solving other, harder, problems. -- http://mail.python.org/mailman/listinfo/python-list
Re: convert integer to string
On Sun, Apr 29, 2012 at 10:18 AM, Andres Soto wrote: > I have already import string from string import * > but I can not still convert an integer to string There is no need to import the `string` module to do that. Most of the `string` module is deprecated. `str` is the *built-in* type for character strings; so no import is necessary Also, imports of the form `from X import *` are generally to be avoided. str(42) That should work. > Traceback (most recent call last): > File "", line 1, in > str(42) > TypeError: 'module' object is not callable > What is it wrong? Presumably, at some point you did: import string str = string Or similar, thus shadowing the built-in type. As I said, there's no need to `import string`, and the `str` type is built-in, so both these lines are unnecessary. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: convert integer to string
On 29/04/2012 18:18, Andres Soto wrote: I have already >> import string >> from string import * but I can not still convert an integer to string >> str(42) Traceback (most recent call last): File "", line 1, in str(42) TypeError: 'module' object is not callable >> What is it wrong? At some point you have bound "str" to a module. Normally you would be getting this: >>> str is __builtins__.str True -- http://mail.python.org/mailman/listinfo/python-list
Re: CPython thread starvation
On 4/28/2012 1:04 PM, Paul Rubin wrote: Roy Smith writes: I agree that application-level name cacheing is "wrong", but sometimes doing it the wrong way just makes sense. I could whip up a simple cacheing wrapper around getaddrinfo() in 5 minutes. Depending on the environment (both technology and bureaucracy), getting a cacheing nameserver installed might take anywhere from 5 minutes to a few days to ... IMHO this really isn't one of those times. The in-app wrapper would only be usable to just that process, and we already know that the OP has multiple processes running the same app on the same machine. They would benefit from being able to share the cache, so now your wrapper gets more complicated. If it's not a nameserver then it's something that fills in for one. And then, since the application appears to be a large scale web spider, it probably wants to run on a cluster, and the cache should be shared across all the machines. So you really probably want an industrial strength nameserver with a big persistent cache, and maybe a smaller local cache because of high locality when crawling specific sites, etc. Each process is analyzing one web site, and has its own cache. Once the site is analyzed, which usually takes about a minute, the cache disappears. Multiple threads are reading multiple pages from the web site during that time. A local cache is enough to fix the huge overhead problem of doing a DNS lookup for every link found. One site with a vast number of links took over 10 hours to analyze before this fix; now it takes about four minutes. That solved the problem. We can probably get an additional minor performance boost with a real local DNS daemon, and will probably configure one. We recently changed servers from Red Hat to CentOS, and management from CPanel to Webmin. Before the change, we had a local DNS daemon with cacheing, so we didn't have this problem. Webmin's defaults tend to be on the minimal side. The DNS information is used mostly to help decide whether two URLs actually point to the same IP address, as part of deciding whether a link is on-site or off-site. Most of those links will never be read. We're not crawling the entire site, just looking at likely pages to find the name and address of the business behind the site. (It's part of our "Know who you're dealing with" system, SiteTruth.) John Nagle -- http://mail.python.org/mailman/listinfo/python-list
Re: algorithm does python use to compare two strings
On 4/29/12 5:34 PM, Terry Reedy wrote: On 4/29/2012 6:05 AM, Terry Reedy wrote: On 4/29/2012 3:59 AM, J. Mwebaze wrote: I am just wondering which specific algorithm does python use to compare two strings. 'Python' does not use algorithms, implementations do. CPython may check id and or hash before doing a character-by-char comparison (or perhaps multiple chars at a time). Identity is checked first, but hashes aren't. I think all the sequence comparisons check for equality of len() before doing item by item comparison. == does, but != and the ordering comparisons don't, at least in the 2.x str implementation. unicode objects don't compare lengths first because the rich comparison function really just defers to an old-style -1,0,+1 compare function. In Python 3.x, bytes objects behave the same, but str objects *do* the length comparison for both == and != (but not the others, naturally). -- 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
convert integer to string
I have already >>> import string >>> from string import * but I can not still convert an integer to string >>> str(42) Traceback (most recent call last): File "", line 1, in str(42) TypeError: 'module' object is not callable >>> What is it wrong? Thank you Prof. Dr. Andrés Soto DES DACI UNACAR-- http://mail.python.org/mailman/listinfo/python-list
Re: Python interface of Stanford Parser
Dear Stefan, Because I am a very new beginner of python, even I don't know how to install the package. I just copied the whole directory to the Lib dictionary. I need steps to follow. Could you please help me? My system is Windows xp, thank you! Sincerely, Vinco -- View this message in context: http://python.6.n6.nabble.com/Python-interface-of-Stanford-Parser-tp4901977p4938837.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list
Re: algorithm does python use to compare two strings
On 4/29/2012 6:05 AM, Terry Reedy wrote: On 4/29/2012 3:59 AM, J. Mwebaze wrote: I am just wondering which specific algorithm does python use to compare two strings. 'Python' does not use algorithms, implementations do. CPython may check id and or hash before doing a character-by-char comparison (or perhaps multiple chars at a time). I think all the sequence comparisons check for equality of len() before doing item by item comparison. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax for code blocks
>> Current Syntax: >> >> with res << func(arg1) << 'x, y': >> print(x, y) >> >> with res << func(arg1) << block_name << 'x, y': >> print(x, y) >> >> New Syntax: >> >> with res == func(arg1) .taking_block (x, y): >> print(x, y) >> >> with res == func(arg1) .taking_block (x, y) as block_name: >> print(x, y) >[snip] > >Hey, guys, am I the only one here who can't even guess what >this code does? When did Python become so obscure? > >-- >To email me, substitute nowhere->spamcop, invalid->net. No, it's pretty impenetratable to me at a passing glance too. Not sure if I'd get anywhere handtracing it, though. ~Temia -- When on earth, do as the earthlings do. -- http://mail.python.org/mailman/listinfo/python-list
Re: syntax for code blocks
On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: > I'd like to change the syntax of my module 'codeblocks' to make it more > pythonic. > > Current Syntax: > > with res << func(arg1) << 'x, y': > print(x, y) > > with res << func(arg1) << block_name << 'x, y': > print(x, y) > > New Syntax: > > with res == func(arg1) .taking_block (x, y): > print(x, y) > > with res == func(arg1) .taking_block (x, y) as block_name: > print(x, y) [snip] Hey, guys, am I the only one here who can't even guess what this code does? When did Python become so obscure? -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with how to combine two csv files
On Mon, Apr 30, 2012 at 1:49 AM, Dennis Lee Bieber wrote: > What do you want done if one file has fewer records than the other? The OP did state that the files had the same number of rows. I'd say this issue is outside the scope of the question. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Help with how to combine two csv files
Hello Experts, I am new to python and I have been trying to merge two csv files, and upon several hours of unsuccessful attempts, I have decided to seek for help. the format of the file is as follows. file A has columns a, b, c and values 1,2,3 for several rows. File B also has columns d,e and values 4,5 for same number of rows as A. the files however do not have any unique column between the two. I want an output file C to have columns a,b,c,d,e with values 1,2,3,4,5 I would be very grateful for your help with some code. Thanks very much, Sammy-- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On 4/28/2012 23:55, Xah Lee wrote: Learn Technical Writing from Unix Man in 10 Days Quote from man apt-get: remove remove is identical to install except that packages are removed instead of installed. Translation: kicking kicking is identical to kissing except that receiver is kicked instead of kissed. Superficial as always. Here's the part you misquoted: ---> install install is followed by one or more packages desired for installation or upgrading. Each package is a package name, not a fully qualified filename (for instance, in a Debian GNU/Linux system, libc6 would be the argument provided, not libc6_1.9.6-2.deb). All packages required by the package(s) specified for installation will also be retrieved and installed. The /etc/apt/sources.list file is used to locate the desired packages. If a hyphen is appended to the package name (with no intervening space), the identified package will be removed if it is installed. Similarly a plus sign can be used to designate a package to install. These latter features may be used to override decisions made by apt-get's conflict resolution system. A specific version of a package can be selected for installation by following the package name with an equals and the version of the package to select. This will cause that version to be located and selected for install. Alternatively a specific distribution can be selected by following the package name with a slash and the version of the distribution or the Archive name (stable, testing, unstable). Both of the version selection mechanisms can downgrade packages and must be used with care. This is also the target to use if you want to upgrade one or more already-installed packages without upgrading every package you have on your system. Unlike the "upgrade" target, which installs the newest version of all currently installed packages, "install" will install the newest version of only the package(s) specified. Simply provide the name of the package(s) you wish to upgrade, and if a newer version is available, it (and its dependencies, as described above) will be downloaded and installed. Finally, the apt_preferences(5) mechanism allows you to create an alternative installation policy for individual packages. If no package matches the given expression and the expression contains one of '.', '?' or '*' then it is assumed to be a POSIX regular expression, and it is applied to all package names in the database. Any matches are then installed (or removed). Note that matching is done by substring so 'lo.*' matches 'how-lo' and 'lowest'. If this is undesired, anchor the regular expression with a '^' or '$' character, or create a more specific regular expression. remove remove is identical to install except that packages are removed instead of installed. Note the removing a package leaves its configuration files in system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed. <--- Kiuhnm -- http://mail.python.org/mailman/listinfo/python-list
Re: why () is () and [] is [] work in other way?
On 4/28/2012 16:18, Adam Skutt wrote: On Apr 28, 7:26 am, Kiuhnm wrote: On 4/27/2012 19:15, Adam Skutt wrote: On Apr 27, 11:01 am, Kiuhnmwrote: The abstraction is this: - There are primitives and objects. - Primitives are not objects. The converse is also true. - Primitives can become objects (boxing). - Two primitives x and y are equal iff x == y. - Two objects x and y are equal iff x.equals(y). - Two objects are the same object iff x == y. - If x is a primitive, then y = x is a deep copy. - If x is an object, then y = x is a shallow copy. - ... This is not an abstraction at all, but merely a poor explanation of how things work in Java. Your last statement is totally incorrect, as no copying of the object occurs whatsoever. The reference is merely reseated to refer to the new object. If you're going to chide me for ignoring the difference between the reference and the referent object, then you shouldn't ignore it either, especially in the one case where it actually matters! If we try to extend this to other languages, then it breaks down completely. With shallow copy I meant exactly that. I didn't think that my using the term with a more general meaning would cause such a reaction. It has a very strict, well-defined meaning in these contexts, especially in languages such as C++. In C++ it's called "memberwise copy" (see the C++ spec), which is not equivalent to Java's "shallow copy", thanks to copy constructors. So you're saying that I said that "Primitive constructs are references". Right... No, still wrong. You said: "You have the first statement backwards. References are a primitive construct, not the other way around." The other way around is "Primitive construct are references", but I never said that. What I said is correct, "References are a form of primitive construct". In C, an int is a primitive but not a reference. An int* is a pointer (reference), and is also (essentially) a primitive. I never said it isn't. While true, it's still a bad way to think about what's going on. It breaks down once we add C++ / Pascal reference types to the mix, for example. ? Assignment to a C++ reference (T&) effects the underlying object, not the reference itself. A reference can never be reseated once it is bound to an object. Comparing equality on two references directly is the same as comparing two values (it calls operator==). Comparing identity requires doing (&x ==&y), like one would do with a value. However, unlike a value, the object is not destroyed when the reference goes out of scope. Most importantly, references to base classes do not slice derived class objects, so virtual calls work correctly through references. As a result, normally the right way to think about a value is as a "temporary name" for an object and not worry about any of the details about how the language makes it work. If you add C++ references to Java, the abstraction breaks down too, so I don't see your point. Equality or equivalence is a relation which is: - reflexive - symmetric - transitive Everything else... is something else. Call it semi-equality, tricky-equality or whatever, but not equality, please. Sure, but then it's illegal to allow the usage of '==' with floating point numbers, which will never have these properties in any usable implementation[1]. ??? The operator == is called the equality operator. Floating-point numbers don't really obey those properties in any meaningful fashion. I say they do. Any counter-examples? The result is that portions of your view contradict others. Either we must give '==' a different name, meaning what you consider equality is irrelevant, or we must use method names like 'equals', which you find objectionable. If anything, you have that backwards. Look at Python: all variables in Python have pointer semantics, not value semantics. When everything is "white", the word "white" becomes redundant. So the fact that everything in Python have reference semantics means that we can't stop thinking about value and reference semantics. Nope. The behavior of variables is absolutely essential to writing correct programs. If I write a program in Python that treats variables as if they were values, it will be incorrect. You misunderstood what I said. You wouldn't treat variables as if they were values because you wouldn't even know what that means and that that's even a possibility. Well, one hopes that is true. I think we have a misunderstanding over language: you said "value and reference semantics" when you really meant "value vs. reference semantics". Ok. I've never heard an old C programmer talk about "value semantics" and "reference semantics". When everything is a value, your world is pretty simple. Except if that were true, the comp.lang.c FAQ wouldn't have this question and answer: http://c-faq.com/ptrs/passbyref.html, and several others. That's why I said "an /old/ C programmer". Much as you may not
Re: Communication between C++ server and Python app
On Sun, Apr 29, 2012 at 4:24 PM, Cameron Simpson wrote: > On 29Apr2012 11:42, Chris Angelico wrote: > | Personally, I would recommend a TCP socket, because that allows the > | flexibility of splitting across multiple computers. > > And the pain of ensuring security, if you're in an open network. You have that with all IPC. You can always bind to 127.0.0.1 or ::1 to stop other hosts from connecting; and then it's minimal change to open it up. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Communication between C++ server and Python app
Take the twisted library. I used to write myself a socket server and client. Socket is fast, but you need on the other hand to know how big the dataset might be, that will be serialized and deserialized as well. Tamer Am 29.04.2012 08:24, schrieb Cameron Simpson: > On 29Apr2012 11:42, Chris Angelico wrote: > | On Sun, Apr 29, 2012 at 10:45 AM, kenk > wrote: > | > I've got a server process written in C++ running on Unix machine. > | > On the same box I'd like to run multiple Python scripts that will > | > communicate with this server. > | > > | > Can you please suggest what would be best was to achieve this ? > | > | Personally, I would recommend a TCP socket, because that allows the > | flexibility of splitting across multiple computers. > > And the pain of ensuring security, if you're in an open network. > > | But for > | efficiency, you may want to consider a Unix socket too. > > A UNIX socket or even a named pipe has the benefit of: > - not being available remotely > - access control with normal UNIX permissions > and of course efficiency as you say. > > Generalising to a TCP socket later shouldn't be too hard if the need > arises. > > Cheers, -- http://mail.python.org/mailman/listinfo/python-list
Re: confusing doc: mutable and hashable
On 4/29/2012 3:57 AM, John O'Hagan wrote: How do function objects fit into this scheme? They have __hash__, __eq__, seem to work as dict keys and are mutable. Is it because their hash value doesn't change? I suspect functions use the default equality and hash based on id, which does not change. Under what circumstances does an object's hash value change? When someone has written a buggy .__hash__ method. Or perhaps if someone is making a non-standard, non-dict use of hash(). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: algorithm does python use to compare two strings
On 4/29/2012 3:59 AM, J. Mwebaze wrote: I am just wondering which specific algorithm does python use to compare two strings. 'Python' does not use algorithms, implementations do. CPython may check id and or hash before doing a character-by-char comparison (or perhaps multiple chars at a time). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Minor issue with sqlite3 and datetime
Hi all I could not find a mailing list for sqlite3 - hope it is ok to post here. My problem actually originates with a different problem relating to MS Sql Server. Python's datetime.datetime object uses a precision of microseconds. Sql Server's DATETIME type only uses a precision of milliseconds. When I try to insert a datetime object into a DATETIME column, the microsecond portion is rejected, but the rest succeeds, so the object is stored to the nearest second. My current workaround is, instead of inserting the datetime object directly, I use the following - dtm = dtm.isoformat(sep=' ')[:23] This converts it to a string, and strips off the last three digits of the microseconds, converting them to milliseconds. It is not elegant, but it works. I also use PostgreSQL and sqlite3. I don't want to code different routines for each one, so I use the same workaround for all three. It works with PostgreSQL, but not with sqlite3. Here is why. sqlite3/dbapi2.py contains the following - def convert_timestamp(val): [...] if len(timepart_full) == 2: microseconds = int(timepart_full[1]) else: microseconds = 0 It assumes that 'timepart_full[1]' is a string containing 6 digits. After my workaround, it only contains 3 digits, so it gives the wrong result. I think that it should right-pad the string with zeroes to bring it up to 6 digits before converting to an int, like this - microseconds = int('{:0<6}'.format(timepart_full[1])) Any chance of this being accepted? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
Hello, Xah. In comp.emacs Xah Lee wrote: > Learn Technical Writing from Unix Man in 10 Days > Quote from man apt-get: >remove >remove is identical to install except that packages are > removed >instead of installed. > Translation: >kicking >kicking is identical to kissing except that receiver is kicked >instead of kissed. Ha ha ha ha!! You don't need to go as far as apt-get to see this. Even worse is C-h f car in Emacs. Imagine it before the last paragraph got added. This only happened after a fairly long thread on emacs-devel. There are far too many man pages which are suboptimal, to say the least. > further readings: [ ] > DISAPPEARING URL IN DOC > so, i was reading man git. Quote: >Formatted and hyperlinked version of the latest git documentation > can >be viewed at http://www.kernel.org/pub/software/scm/git/docs/. > but if you go to that url, it shows a list of over one hundred fourty > empty dirs. > I guess unix/linux idiots can't be bothered to have correct > documentation. Inability to write is one thing, but they are unable to > maintain a link or update doc? Maintaining links is actually quite hard. After the struggle to document "remove", one typically has insufficient energy left over to check all the links. > does this ever happens to Apple's docs? If it did, i don't ever recall > seeing it from 18 years of using Mac. Have you ever tried to set up CUPS, the printing system? At one point, you're supposed to enter the "URI" of the printer, without any explanation of what the URI of a local printer is. At another point you're prompted to enter "Name". Name of what? If you click on the "help", you get taken to a search box, not proper docs. Typing "name" into the search box isn't useful. And so it goes on. CUPS is an Apple product. > more records of careless dead link: [ ] -- Alan Mackenzie (Nuremberg, Germany). -- http://mail.python.org/mailman/listinfo/python-list
algorithm does python use to compare two strings
I am just wondering which specific algorithm does python use to compare two strings. Could it be the Longest common subsequence is the most u Regards -- *Mob UG: +256 (0) 70 1735800 | NL +31 (0) 6 852 841 38 | Gtalk: jmwebaze | skype: mwebazej | URL: www.astro.rug.nl/~jmwebaze /* Life runs on code */* -- http://mail.python.org/mailman/listinfo/python-list
Re: confusing doc: mutable and hashable
On Sat, 28 Apr 2012 11:35:12 -0700 Chris Rebert wrote: [...] > Correct. Pedantically, you can define __hash__() on mutable objects; > it's just not very useful or sensible, so people generally don't. As > http://docs.python.org/reference/datamodel.html#object.__hash__ states > [emphasis added]: > > "If a class defines *mutable* objects and implements a __cmp__() or > __eq__() method, it *should not* implement __hash__(), since hashable > collection implementations require that a object’s hash value is > immutable (if the object’s hash value changes, it will be in the wrong > hash bucket)." [...] How do function objects fit into this scheme? They have __hash__, __eq__, seem to work as dict keys and are mutable. Is it because their hash value doesn't change? Under what circumstances does an object's hash value change? -- John -- http://mail.python.org/mailman/listinfo/python-list
Re: Learn Technical Writing from Unix Man in 10 Days
On Sat, 28 Apr 2012 14:55:42 -0700 (PDT) Xah Lee wrote: > Learn Technical Writing from Unix Man in 10 Days > > Quote from man apt-get: > > remove > remove is identical to install except that packages are > removed > instead of installed. > > Translation: > > kicking > kicking is identical to kissing except that receiver is kicked > instead of kissed. > That's funny - out of context. Maybe you're trying out material for a stand-up comedy routine, but I'm sure you're aware that the sentence you quote sensibly obviates repeating the semantics of "install", which have just been described in detail in the immediately preceding paragraph. If it did repeat them, wouldn't you mock the docs anyway, for redundancy? Regards, -- John -- http://mail.python.org/mailman/listinfo/python-list