OT: Hierarchies [was Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.]
On Tue, 29 Oct 2013 17:22:03 +1100, Chris Angelico wrote: > On Tue, Oct 29, 2013 at 3:03 PM, wrote: >> Regarding esr's "smart-questions", although I acknowledge it has useful >> advice, I have always found it elitist and abrasive. I wish someone >> would rewrite it without the "we are gods" attitude. > > I find it actually pretty appropriate. The attitude comes from a > hierarchy in which we are not at the top - but neither is esr. Hmmm, well it's not clear to me that ESR doesn't consider himself at the top of any hacker hierarchy. I'm sure that he considers that there are those who know more than him with respect to some specific technology or other, and I'm sure he doesn't think geeks fall into organisation charts with nice neat lines between those who report to whom. But I also think he doesn't have the false modesty to put himself anywhere but in the top "elite geek hacker" category. [...] > We're in a hierarchy (or actually > several independent and unrelated ones), and being at the top means (in > the open source world) being everyone's servant; and the people at the > top simply don't have time to be _everyone's_ servant personally, so > they need some sous-servants to help them to help people. An interesting thought, but I wouldn't put it that way. It seems to me that a better description would be that geeks tend to be big believers in "giving back", or perhaps something akin to "Whiteman's Burden" that Kipling believed in, the idea that those who have have a duty to those who don't. Of course, the whole colonialism thing is out of favour these days, and truth be told the idea of bringing "civilization to the savages" was more honoured in the breach than in the observance even in Kipling's day. But the idea that those who have more than others (be that skills, knowledge or possessions) have a duty towards those who don't is not a bad philosophy to live be. If we must have hierarchies -- and alas, Homo sapiens being as it is, we do -- it is better for those at the top to have a duty to serve as well as privileges. That's what Heinlein was getting at with the (often misunderstood) "Starship Troopers". Did it glorify military service? Yes it did, but it also emphasised the *service* part. If you want the privilege of citizenship, they you have to earn it by first serving. But I think that *servant* is not the right description for the relationship you are talking about. That implies that (say) I could demand ESR's service at any time, or at least at any time within pre- defined boundaries (even servants get days off), and that he would have no right to refuse service. But that's not the case. He is a volunteer who is free to say No at any time, and the quickest way to get him to say No would be to treat him as a servant. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
Mark said : "Do I have to raise a PEP to get this stupid language changed so that it dynamically recognises what I want it to do and acts accordingly?" The printf syntax in C isn't any wonderful thing, and there is no obligation to provide some Python version of it. I have to say, there were a few things that twerked me when getting up to speed on Py, but formatting strings wasn't one of them. I'd be surprised if Guido prioritizes a fix for this part of his "stupid language". Just sayin -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On Thu, 31 Oct 2013 03:33:15 -0700, wxjmfauth wrote: > Le jeudi 31 octobre 2013 08:10:18 UTC+1, Steven D'Aprano a écrit : >> I'm glad that you know so much better than Google, Bing, Yahoo, and >> other >> search engines. When I search for "mispealled" Google gives me: [...] > As far as I know, I recognized my mistake. I had more text processing > systems in mind, than search engines. Yes, you have, I acknowledge that now. I see now that at the time I made my response to you, you had already replied recognising your error. Unfortunately I had not seen that. So in that case, I withdraw my comments and apologize. > I can even tell you, I am really stupid. I wrote pure Unicode software > to sort French or German strings. > > Pure unicode == independent from any locale. Unfortunately it is not that simple. The same code point can have different meanings in different languages, and should be treated differently when sorting. The natural Unicode sort order satisfies very few European languages, including English. A few examples: * Swedish ä is a distinct letters of the alphabet, appearing after z: "a b c z ä" is sorted according to Swedish rules. But in German ä is considered to be the letter 'a' plus an umlaut, and is collated after 'a': "a ä b c z" is sorted according to German rules. * In German ö is considered to be a variant of o, equivalent to 'oe', while in Finish ö is a distinct letter which cannot be expanded to 'oe', and which appears at the end of the alphabet. * Similarly, in modern English æ is a ligature of ae, while in Danish and Norwegian is it a distinct letter of the alphabet appearing after z: in English dictionaries, "Æsir" will be found with other "A" words, often expanded to "Aesir", while in Norwegian it will be found after "Z" words. * Most European languages convert uppercase I to lowercase i, but Turkish has distinct letters for dotted and dotless I. According to Turkish rules, lowercase(I) is ı and uppercase(i) is İ. While it is true that the Unicode character set is independent of locale, for natural processing of characters, it isn't enough to just use Unicode. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On Fri, Nov 1, 2013 at 6:11 PM, Peter Cacioppi wrote: > The printf syntax in C isn't any wonderful thing, and there is no obligation > to provide some Python version of it. Maybe, but it's supported by so many languages that it is of value. Though Python's use of the % operator does lead to edge cases (a single argument, except if it's a tuple, even though a tuple could be accepted by %r), so a printf() function might be cleaner. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: OT: Hierarchies [was Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.]
On Fri, Nov 1, 2013 at 6:00 PM, Steven D'Aprano wrote: > On Tue, 29 Oct 2013 17:22:03 +1100, Chris Angelico wrote: > >> On Tue, Oct 29, 2013 at 3:03 PM, wrote: >>> Regarding esr's "smart-questions", although I acknowledge it has useful >>> advice, I have always found it elitist and abrasive. I wish someone >>> would rewrite it without the "we are gods" attitude. >> >> I find it actually pretty appropriate. The attitude comes from a >> hierarchy in which we are not at the top - but neither is esr. > > Hmmm, well it's not clear to me that ESR doesn't consider himself at the > top of any hacker hierarchy. I'm sure that he considers that there are > those who know more than him with respect to some specific technology or > other, and I'm sure he doesn't think geeks fall into organisation charts > with nice neat lines between those who report to whom. But I also think > he doesn't have the false modesty to put himself anywhere but in the top > "elite geek hacker" category. There are multiple independent hierarchies, and in some of them, he may well be at (or close to) the top - but not all of them. Proper acceptance of a hierarchical world includes knowing that there's always someone above you. > But I think that *servant* is not the right description for the > relationship you are talking about. That implies that (say) I could > demand ESR's service at any time, or at least at any time within pre- > defined boundaries (even servants get days off), and that he would have > no right to refuse service. But that's not the case. He is a volunteer > who is free to say No at any time, and the quickest way to get him to say > No would be to treat him as a servant. It's a tricky concept to describe, and I agree that "servant" isn't an ideal term for it. I'm the head of a (tiny) community called Minstrel Hall, and what that means is that whenever anyone needs something done, it's my job to do it. That's not the classic understanding of the servant's role (the bonded man who has to do whatever he's told immediately), but is somewhat closer to a somewhat obscure term: servitor [1] or sizar [2]. I first met that word via Princess Ida, who stated that her university had no such students, though Wikipedia gives a better actual definition. The head of a community has certain duties to perform [3] and may or may not receive respect in return. Ultimately, if the head doesn't do his (or her, but the "his/her" "he/she" gets tedious) duties, he'll have no community following him, so he's responsible to his members in a very direct way. ChrisA [1] https://en.wikipedia.org/wiki/Servitor [2] https://en.wikipedia.org/wiki/Sizar [3] The quirky part of my brain is thinking now of this, sung by one of the kings in a newly-formed republican monarchy (it makes sense in context): http://math.boisestate.edu/gas/gondoliers/web_opera/gond12.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Error Testing
On 2013-11-01, William Ray Wing wrote: > Actually, FORTRAN is probably responsible for more CPU cycles being > executed even today than most other languages. If you think about > the fact that most large scientific simulation codes (weather > forecasting, combustion modeling, finite-element modeling and so on), > are still FORTRAN based, and that those are the codes that occupy > multi-hundred-thousand-core petaflop class supper computers for weeks > on end, you have to respect its longevity. IIRC, some of the scientific computing libraries I used to use daily in Python data-crunching programs are still written in FORTRAN. -- Grant -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
Le vendredi 1 novembre 2013 08:16:36 UTC+1, Steven D'Aprano a écrit : > On Thu, 31 Oct 2013 03:33:15 -0700, wxjmfauth wrote: > > > > > Le jeudi 31 octobre 2013 08:10:18 UTC+1, Steven D'Aprano a écrit : > > > > >> I'm glad that you know so much better than Google, Bing, Yahoo, and > > >> other > > >> search engines. When I search for "mispealled" Google gives me: > > [...] > > > As far as I know, I recognized my mistake. I had more text processing > > > systems in mind, than search engines. > > > > Yes, you have, I acknowledge that now. I see now that at the time I made > > my response to you, you had already replied recognising your error. > > Unfortunately I had not seen that. So in that case, I withdraw my > > comments and apologize. > > > > > > > I can even tell you, I am really stupid. I wrote pure Unicode software > > > to sort French or German strings. > > > > > > Pure unicode == independent from any locale. > > > > Unfortunately it is not that simple. The same code point can have > > different meanings in different languages, and should be treated > > differently when sorting. The natural Unicode sort order satisfies very > > few European languages, including English. A few examples: > > > > * Swedish ä is a distinct letters of the alphabet, appearing > > after z: "a b c z ä" is sorted according to Swedish rules. > > But in German ä is considered to be the letter 'a' plus an > > umlaut, and is collated after 'a': "a ä b c z" is sorted > > according to German rules. > > > > * In German ö is considered to be a variant of o, equivalent > > to 'oe', while in Finish ö is a distinct letter which > > cannot be expanded to 'oe', and which appears at the end > > of the alphabet. > > > > * Similarly, in modern English æ is a ligature of ae, while in > > Danish and Norwegian is it a distinct letter of the alphabet > > appearing after z: in English dictionaries, "Æsir" will be > > found with other "A" words, often expanded to "Aesir", while > > in Norwegian it will be found after "Z" words. > > > > * Most European languages convert uppercase I to lowercase i, > > but Turkish has distinct letters for dotted and dotless I. > > According to Turkish rules, lowercase(I) is ı and uppercase(i) > > is İ. > > > > > > While it is true that the Unicode character set is independent of locale, > > for natural processing of characters, it isn't enough to just use Unicode. > > > > > > -- > > Steven I'm aware of all the points you gave. That's why I wrote "French or German strings". The hard task is not on the side of Unicode or sorting, it is on the creation of key(s) used for sorting. Eg, cote, côte, coté, côté. French editors are not all sorting these words in the same way (diacritics). jmf PS A *real* case to test the FSR. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On 01/11/2013 07:11, Peter Cacioppi wrote: Mark said : "Do I have to raise a PEP to get this stupid language changed so that it dynamically recognises what I want it to do and acts accordingly?" The printf syntax in C isn't any wonderful thing, and there is no obligation to provide some Python version of it. I have to say, there were a few things that twerked me when getting up to speed on Py, but formatting strings wasn't one of them. I'd be surprised if Guido prioritizes a fix for this part of his "stupid language". Just sayin I'm heading into town in maybe an hour. I'll stop here http://www.toolbankexpress.com/shop/castle/ so I can get an extremely large pair of pliers with which I can extract my tongue from my cheek :) -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On Fri, Nov 1, 2013 at 8:08 PM, Mark Lawrence wrote: > I'm heading into town in maybe an hour. I'll stop here > http://www.toolbankexpress.com/shop/castle/ so I can get an extremely large > pair of pliers with which I can extract my tongue from my cheek :) I think you may have a bit of trouble. The part where you demanded the language dynamically figure out what you wanted may have gotten your tongue rather stuck there... The neat thing about this list is that even posts like that can result in real solutions :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: trying to strip out non ascii.. or rather convert non ascii
On 01/11/2013 09:00, [email protected] wrote: I'll ask again, would you please read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On 01/11/2013 09:17, Chris Angelico wrote: On Fri, Nov 1, 2013 at 8:08 PM, Mark Lawrence wrote: I'm heading into town in maybe an hour. I'll stop here http://www.toolbankexpress.com/shop/castle/ so I can get an extremely large pair of pliers with which I can extract my tongue from my cheek :) I think you may have a bit of trouble. The part where you demanded the language dynamically figure out what you wanted may have gotten your tongue rather stuck there... The neat thing about this list is that even posts like that can result in real solutions :) ChrisA Absolutely correct. This thread actually got me thinking[1]. There's a thread on Python ideas about "where did we go wrong with negative stride?". It discusses maybe fixing this for Python 4. I wondered if the idea of deprecating printf style formatting might also come up again. It was discussed in some depth here https://mail.python.org/pipermail/python-dev/2012-February/116789.html [1] yes it does happen, yes you may joke about it and yes I can take the jokes, I certainly deserve them :) -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Error Testing
On 01/11/2013 03:50, rusi wrote: On Friday, November 1, 2013 4:29:35 AM UTC+5:30, Denis McMahon wrote: My mistake, that was what Albert said, you were simply standing up for him. Please s/you/he/ in the lines of my previous post quoted above, and accept my apologies for my mistake. Heh! Chill! Yeah there is some hamming distance between the strings "Albert van der Horst" and "Rusi Mody". But you were objecting not to the state-er but to the statement... Sanity is being restored to this mailing list in that an apology is offered and accepted with such good grace. If only that grumpy old git from the south of England, whose name currently escapes me, could always behave in the same manner :) -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On Fri, Nov 1, 2013 at 8:32 PM, Mark Lawrence wrote: > I wondered if the idea of deprecating printf style formatting might also > come up again. It was discussed in some depth here > https://mail.python.org/pipermail/python-dev/2012-February/116789.html I don't see any reason for it to go. Anyone who wants to use .format() is welcome to; anyone who likes %s is welcome to use that. They have sufficiently distinct styles that they don't really come into conflict. Now, if someone wants to deprecate the "str modulo anything" operator in favour of an explicit sprintf() function (optionally with printf() that sends straight through to print()), that I might get behind - but I don't see any reason to lose the printf-style formatting codes. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: "Backward"-Iterator - Beginners question
Hi Am 31.10.2013 23:35, schrieb Terry Reedy: On 10/31/2013 5:29 PM, Ulrich Goebel wrote: I'm locking for an "iterator" type with not only the .next() method, but with a .previous(), .first() and .last() method, so that I can through it from the beginning or from the end, and in both directions, even alternately (for example two steps forward, one backward, two steps forward). You are free to write such a class, if it is appropriate for your actual use case. Ok, possibly I will try that later... If you have a concrete sequence object seq with random access, there is no reason to do so. First and last are seq[0] and seq[-1]. Given 'cursor' i, prev and next are 'i-=1;seq[i]' and 'i+=1;seq[i]'. That gives me the solution. What I have, is an iterator object comming as a SQLite database cursor object. So I could minimize the underliying SELECT and build index = list(cursor). Then with Your hints I get what I want. Thanks Ulrich -- Ulrich Goebel Paracelsusstr. 120, 53177 Bonn -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing python command line apps -- Running from within the projects w/o installing
Thanks Ben and Tim for these great contributions! Shouldn't suggestions like these be added to the argparse documentation in a recipes section? Best, Wolfgang -- https://mail.python.org/mailman/listinfo/python-list
Re: First day beginner to python, add to counter after nested loop
On Thu, 31 Oct 2013 04:07:14 -0700, rusi wrote: > > Also others (Alister?) were double-space-reply-posting as well. When > you mean to point out a behavior without getting personal, it helps to > point out all instances of that behavior. Otherwise it looks like you > are going for someone, when in fact you are going against something. oops sorry I though I had trimmed the posts i replied to to only the relevant parts. I also find the double posting annoying but don't get overly excited about it. I did however find Jonus' attitude to become unacceptable after he had this problem pointed out. -- I'm having an emotional outburst!! -- https://mail.python.org/mailman/listinfo/python-list
Re: how to extract page-URL using BeautifulSoup
On Thu, 31 Oct 2013 08:59:00 -0700, bhaktanishant wrote: > I want to extract the page-url. for example: > if i have this code > > import urllib2 from bs4 import BeautifulSoup link = > "http://www.google.com"; > page = urllib2.urlopen(link).read() > soup = BeautifulSoup(page) > > then i can extract title of page by: > > title = soup.title > > but i want to know that how to extract page-URL from "soup" that will be > "http://www.google.com"; I must be missing something here, the page url is what you use to open the page in the first place in your case link. -- May a Misguided Platypus lay its Eggs in your Jockey Shorts. -- https://mail.python.org/mailman/listinfo/python-list
Re: "Backward"-Iterator - Beginners question
On Fri, Nov 1, 2013 at 9:18 PM, Ulrich Goebel wrote: > That gives me the solution. What I have, is an iterator object comming as a > SQLite database cursor object. So I could minimize the underliying SELECT > and build index = list(cursor). Then with Your hints I get what I want. Looks good! If you need to iterate over something more than once, or go back and forth through it a bit, this is probably the best general solution anyway. With a list, heaps of things are easy, and unless you're working with gobs of data, you won't have any problems. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
Op 01-11-13 05:41, [email protected] schreef: > On 10/31/2013 02:41 AM, Steven D'Aprano wrote: > >> I don't know whether you are deliberately lying, or whether you're just >> such a careless reader that you have attributed words actually written by >> Skybuck to me, but either way I expect an apology from you for putting >> false words into my mouth. > > An apology is due when someone does some damage to things > or people (including reputation or feelings) that should > have been avoided. > > My overstating your disagreement with Skybuck was inadvertent, > does not change the points I was making (it does not matter > whether you thought he was wrong or nutty) and did no > significant damage to you or your reputation. It seems rather obvious from Steven's reaction, your overstatement hurt (damaged) his feelings. Since you ackowleged that damaged feelings are cause for an apology, it seems by your own words an apology is due. -- Antoon Pardon -- https://mail.python.org/mailman/listinfo/python-list
Help Python 3.3
Hi all, error: Setup script exited with error: Unable to find vcvarsall.bat Visual C++ Express installed. the key HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir is present and point to the vcvarsall.bat location. PC restarted(just for fun). what is wrong?? -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
I am using easy_install -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On Fri, Nov 1, 2013 at 8:20 AM, wrote: > > Hi all, > > error: Setup script exited with error: Unable to find vcvarsall.bat > > Visual C++ Express installed. Which version? Python 3.3 requires Visual C++ 2010 (10.0). > the key > HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir This looks like Visual C++ 2008 (9.0). > is present and point to the vcvarsall.bat location. > PC restarted(just for fun). > > what is wrong?? I would have to guess that you've got the wrong version of Visual C++. You can install both 2008 and 2010 in parallel, if you need 2008 for something else. Hope this helps, -- Zach PS: In the future, it is very helpful to say which OS you're using since Python is usable on so many different platforms. In this case it's pretty obvious that you're using Windows, but there are still differences between Windows versions that mean knowing the version makes support easier. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On Friday, November 1, 2013 3:33:24 PM UTC+2, Zachary Ware wrote: > On Fri, Nov 1, 2013 at 8:20 AM, wrote: > > > > > > Hi all, > > > > > > error: Setup script exited with error: Unable to find vcvarsall.bat > > > > > > Visual C++ Express installed. > > > > Which version? Python 3.3 requires Visual C++ 2010 (10.0). > > > > > the key > > HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\9.0\Setup\VC\ProductDir > > > > This looks like Visual C++ 2008 (9.0). > > > > > is present and point to the vcvarsall.bat location. > > > PC restarted(just for fun). > > > > > > what is wrong?? > > > > I would have to guess that you've got the wrong version of Visual C++. > > You can install both 2008 and 2010 in parallel, if you need 2008 for > > something else. > > > > Hope this helps, > > > > -- > > Zach > > > > PS: In the future, it is very helpful to say which OS you're using > > since Python is usable on so many different platforms. In this case > > it's pretty obvious that you're using Windows, but there are still > > differences between Windows versions that mean knowing the version > > makes support easier. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
Thanks a lot Zach. This fix the problem -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On 01/11/2013 13:49, [email protected] wrote: I'm not sure what you meant to say, but whatever it was, would you please be kind enough to read, digest and action this https://wiki.python.org/moin/GoogleGroupsPython TIA. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
Thanks Zach. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On 01/11/2013 13:59, [email protected] wrote: Thanks Zach. Would you please quote some context in your replies. Who is Zach? Which message are you replying to? What were you talking about? -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: how to extract page-URL using BeautifulSoup
This is nearly the same question you asked under another name yesterday. Its not clear what you really want to do. You are asking what the url is of the page you retrieve by providing the same url. On Fri, Nov 1, 2013 at 7:33 AM, Alister wrote: > On Thu, 31 Oct 2013 08:59:00 -0700, bhaktanishant wrote: > >> I want to extract the page-url. for example: >> if i have this code >> >> import urllib2 from bs4 import BeautifulSoup link = >> "http://www.google.com"; >> page = urllib2.urlopen(link).read() >> soup = BeautifulSoup(page) >> >> then i can extract title of page by: >> >> title = soup.title >> >> but i want to know that how to extract page-URL from "soup" that will be >> "http://www.google.com"; > > I must be missing something here, the page url is what you use to open > the page in the first place in your case link. > > > > > -- > May a Misguided Platypus lay its Eggs in your Jockey Shorts. > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com -- https://mail.python.org/mailman/listinfo/python-list
telnet problem
hello every expert,
When I use telnetlib to send a command, I meet some troubles, I have read
some documents about telnetlib and modify many times, but the script
doesn't work all the time. I want to know why.
My script is following:
#!/usr/bin/python
#
import telnetlib
t = telnetlib.Telnet()
t.open('192.168.1.1',port=23)
t.set_debuglevel(2)
t.read_until("login: ")
t.write('administrator' + '\r\n')
t.read_until("password: ")
t.write('abc123' + '\r\n')
t.read_until(">$")
t.write('dir' + '\r\n')
t.write('exit' + '\r\n')
print t.read_all()
Thanks and best regards
W
--
https://mail.python.org/mailman/listinfo/python-list
Re: telnet problem
On 2013-11-01, wrote: > hello every expert, > When I use telnetlib to send a command, I meet some troubles, I > have read some documents about telnetlib and modify many times, > but the script doesn't work all the time. What goes wrong? -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
ANN: Leo 4.11b1 released
Leo 4.11 b1 is now available at: https://sourceforge.net/projects/leo/files/Leo/4.11-b1/ Leo 4.11 contains over a year's work on Leo. Leo is a PIM, an IDE and an outliner for programmers, authors and web designers. Leo's unique features organize data in a revolutionary way. See http://leoeditor.com/tutorial.html The highlights of Leo 4.11: --- - Leo's tutorials have been rewritten and simplified. - Greatly improved abbreviations, including templates. - Clones are now valid anywhere in @file nodes. - Leo now warns if a .leo file is open elsewhere. - Leo's IPython bridge now works with IPython 1.x. - Added support for @testsetup and @testclass. - Added support for sessions. - Added colorizing themes. - A colored border highlights the pane with focus. - Added support for the clojure, markdown and TypeScript languages. - Added importers for .ipynb, .otl and vimoutliner files. - Many new and improved commands, plugins and scripts. - Dozens of bug fixes and code-level improvements. Links: -- Leo: http://leoeditor.com Docs: http://leoeditor.com/leo_toc.html Tutorials: http://leoeditor.com/tutorial.html Forum: http://groups.google.com/group/leo-editor Download: http://sourceforge.net/projects/leo/files/ Bzr: http://code.launchpad.net/leo-editor/ Quotes:http://leoeditor.com/testimonials.html Edward K. Ream November 1, 2013 -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
Στις 1/11/2013 12:24 πμ, ο/η Nick the Gr33k έγραψε: Στις 31/10/2013 9:22 μμ, ο/η [email protected] έγραψε: You set the value of 'downloads' to a list: downloads = [] if data: for torrent in data: downloads.append( torrent ) and when you use 'downloads', use have: INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., downloads) If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps you can't insert a value that is a list into it? And that may be causing your problem? If that is in fact the problem (I am only guessing), you could convert 'downloads' to a single string for insertion into your database with something like, downloads = ', '.join( downloads ) create table visitors ( counterID integer(5) not null, host varchar(50) not null, refs varchar(25) not null, city varchar(20) not null, userOS varchar(10) not null, browser varchar(10) not null, hits integer(5) not null default 1, visits datetime not null, downloads set('Καμία Ακόμη'), foreign key (counterID) references counters(ID), unique index (visits) )ENGINE = MYISAM; Decided to declare downlods as SET column type. and maintain this: downloads = [] if data: for torrent in data: downloads.append( torrent ) but error still is: [Thu Oct 31 22:24:41 2013] [error] [client 46.198.103.93] pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') Rurpy can you help me please solve this? is enum or set column types what needed here as proper columns to store 'download' list? -- https://mail.python.org/mailman/listinfo/python-list
Re: Error Testing
On 01/11/2013 14:51, Dennis Lee Bieber wrote: On Fri, 01 Nov 2013 03:25:03 +, Mark Lawrence declaimed the following: On 01/11/2013 02:27, William Ray Wing wrote: supper computers Somebody must have tough teeth, though thinking about it I recall people eating bicycles :) Was visualizing them used as plate warmers... Hum, water cooled mainframes, tell that to the kids... -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
how to load test a web app?
Hi, I am looking at three Github-like programs (Stash, Gitbucket and Trac) to see if they could be used in our company. I would like to test the reliability and stability of at least one of them (I won't do any tests if some required functionality is missing). I am curious whether the program will crash under certain circumstances (e.g. multiple users checking code at *exactly* the same moment). What approach could I follow here? Though this does not *necessarily* have to involve Python, I would prefer this. The way I see it, it would carry out certain common usage patterns many times to simulate many users. I thought about using mechanize/subprocess, the multimechanize package, or the twill package. Very curious to hear your thoughts about this and I hope this is not too vague. Thank you in advance! Regards, Albert-Jan ~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
Στις 31/10/2013 9:22 μμ, ο/η [email protected] έγραψε: On 10/31/2013 03:24 AM, Nick the Gr33k wrote: [...] # find out if visitor has downloaded torrents in the past cur.execute('''SELECT torrent FROM files WHERE host = %s''', host ) data = cur.fetchall() downloads = [] if data: for torrent in data: downloads.append( torrent ) else: downloads.append( 'None Yet' ) # add this visitor entry into database cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) [...] and On 10/31/2013 03:32 AM, Nick the Gr33k wrote: The error seen form error log is: [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] Traceback (most recent call last): [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] File "/home/nikos/public_html/cgi-bin/metrites.py", line 274, in [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] (cID, refs, host, city, useros, browser, visits, downloads) ) [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') line 274 is: # add this visitor entry into database cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) You set the value of 'downloads' to a list: downloads = [] if data: for torrent in data: downloads.append( torrent ) and when you use 'downloads', use have: INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., downloads) If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps you can't insert a value that is a list into it? And that may be causing your problem? If that is in fact the problem (I am only guessing), you could convert 'downloads' to a single string for insertion into your database with something like, downloads = ', '.join( downloads ) I would like to know if there's a way to store an entire list into a MySQL table. -- [code] # find out if visitor had downloaded torrents in the past cur.execute('''SELECT torrent FROM files WHERE host = %s''', host ) data = cur.fetchall() downloads = [] if data: for torrent in data: downloads.append( torrent ) else: downloads = 'None Yet' # add this visitor entry into database (host && downloads are unique) cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) [/code] If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps i cannot insert a value that is a list into it. From within my python script i need to to store a list variable into a mysql column. the list is suppose to store torrent filenames in a form of downloads = ["movie1", "movie2", "movie3", "movie3"] is enum or set column types what needed here as proper columns to store 'download' list? Code: create table visitors ( counterID integer(5) not null, host varchar(50) not null, refs varchar(25) not null, city varchar(20) not null, userOS varchar(10) not null, browser varchar(10) not null, hits integer(5) not null default 1, visits datetime not null, downloads set('None Yet'), foreign key (counterID) references counters(ID), unique index (visits) )ENGINE = MYISAM; Is the SET column type the way to do it? i tried it but the error i'm receiving is: pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') Please help pick the necessary column type that will be able to store a a list of values. -- https://mail.python.org/mailman/listinfo/python-list
Re: Basic Python Questions - Oct. 31, 2013
On Oct 31, 2013, at 5:31 AM, "E.D.G." wrote: > Posted by E.D.G. on October 31, 2013 > > The following are several relatively basic questions regarding Python's > capabilities. I am not presently using it myself. At the moment a number of > people including myself are comparing it with other programs such as XBasic > for possible use. > > 1. How fast can Python do math calculations compared with other languages > such as Fortran and fast versions of Basic. I would have to believe that it > is much faster than Perl for doing math calculations. > [byte] > 4. How well does Python work for interactive programming. For example, if a > Python program is running on a PC and is drawing a chart, can that chart be > modified by simply pressing a key while the Python program is running. I > have Perl and Gnuplot program combinations that can do that. Their > interactive speed is not that great. But it is adequate for my own uses. > I thought about responding to this yesterday, decided others could do so better than I, but then decided to point out a bit of demo code that was one of the first really startling pieces of Python that I stumbled into. If you look here: http://wiki.wxpython.org/MatplotlibFourierDemo You will find a fairly short, well documented demo code that interactively computes a Fast Fourier transform from the frequency domain to the time domain. As you move the two sliders below the graphs, the input aptitude and location of the frequency peaks are changed and the resulting wavelet is plotted, all in real time. Computing a Fourier transform is numerically pretty intensive, doing so in real time with no perceptible delay (at least on a reasonably modern system) should convince any skeptic of Python's ability to do BOTH number crunching AND interactive display. Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries that give Python so much power and flexibility. -Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
Στις 1/11/2013 5:04 μμ, ο/η Nick the Gr33k έγραψε: Στις 1/11/2013 12:24 πμ, ο/η Nick the Gr33k έγραψε: Στις 31/10/2013 9:22 μμ, ο/η [email protected] έγραψε: You set the value of 'downloads' to a list: downloads = [] if data: for torrent in data: downloads.append( torrent ) and when you use 'downloads', use have: INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., downloads) If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps you can't insert a value that is a list into it? And that may be causing your problem? If that is in fact the problem (I am only guessing), you could convert 'downloads' to a single string for insertion into your database with something like, downloads = ', '.join( downloads ) create table visitors ( counterID integer(5) not null, host varchar(50) not null, refs varchar(25) not null, city varchar(20) not null, userOS varchar(10) not null, browser varchar(10) not null, hits integer(5) not null default 1, visits datetime not null, downloads set('Καμία Ακόμη'), foreign key (counterID) references counters(ID), unique index (visits) )ENGINE = MYISAM; Decided to declare downlods as SET column type. and maintain this: downloads = [] if data: for torrent in data: downloads.append( torrent ) but error still is: [Thu Oct 31 22:24:41 2013] [error] [client 46.198.103.93] pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') Rurpy can you help me please solve this? is enum or set column types what needed here as proper columns to store 'download' list? I can create another table for filenames and use a many to many relationship between them because many movies can be downloaded by a visitor and many visitors can download a movie. That could work, but i wish to refrain from creating another mysql tabale just to store a couple of movies the visitor could or could not download. Just a mysql column table that will be able to store a list(movies the visitor selected) should do. -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
On Fri, Nov 1, 2013 at 11:25 AM, Nick the Gr33k wrote: > Στις 31/10/2013 9:22 μμ, ο/η [email protected] έγραψε: >> >> On 10/31/2013 03:24 AM, Nick the Gr33k wrote: >> >>> [...] >>> # find out if visitor has downloaded torrents in the past >>> cur.execute('''SELECT torrent FROM files WHERE host = %s''', host >>> ) >>> data = cur.fetchall() >>> >>> downloads = [] >>> if data: >>> for torrent in data: >>> downloads.append( torrent ) >>> else: >>> downloads.append( 'None Yet' ) >>> >>> # add this visitor entry into database >>> cur.execute('''INSERT INTO visitors (counterID, refs, host, city, >>> useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, >>> %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) >>> [...] >> >> >> and >> >> On 10/31/2013 03:32 AM, Nick the Gr33k wrote: >>> >>> The error seen form error log is: >>> >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] Traceback >>> (most recent call last): >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] File >>> "/home/nikos/public_html/cgi-bin/metrites.py", line 274, in >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] (cID, >>> refs, host, city, useros, browser, visits, downloads) ) >>> >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] >>> pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') >>> >>> line 274 is: >>> >>> # add this visitor entry into database >>> cur.execute('''INSERT INTO visitors (counterID, refs, host, city, >>> useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, >>> %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) >> >> >> >> You set the value of 'downloads' to a list: >> >>> downloads = [] >>> if data: >>> for torrent in data: >>> downloads.append( torrent ) >> >> >> and when you use 'downloads', use have: >> >>INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., >> downloads) >> >> If the 'downloads' column in table 'visitors' is a >> normal scalar value (text string or such) then perhaps >> you can't insert a value that is a list into it? And >> that may be causing your problem? >> >> If that is in fact the problem (I am only guessing), you >> could convert 'downloads' to a single string for insertion >> into your database with something like, >> >>downloads = ', '.join( downloads ) >> > > > I would like to know if there's a way to store an entire list into a MySQL > table. > -- > [code] > # find out if visitor had downloaded torrents in the past > > cur.execute('''SELECT torrent FROM files WHERE host = %s''', > host ) > data = cur.fetchall() > > downloads = [] > if data: > for torrent in data: > downloads.append( torrent ) > else: > downloads = 'None Yet' > > > # add this visitor entry into database (host && downloads > are unique) > cur.execute('''INSERT INTO visitors (counterID, refs, host, > city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, > %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) > [/code] > > > If the 'downloads' column in table 'visitors' is a > normal scalar value (text string or such) then perhaps > i cannot insert a value that is a list into it. > > From within my python script i need to to store a list variable into a mysql > column. > > the list is suppose to store torrent filenames in a form of > > downloads = ["movie1", "movie2", "movie3", "movie3"] > > > is enum or set column types what needed here as proper columns to store > 'download' list? > > Code: > > create table visitors > ( > counterID integer(5) not null, > host varchar(50) not null, > refs varchar(25) not null, > city varchar(20) not null, > userOS varchar(10) not null, > browser varchar(10) not null, > hits integer(5) not null default 1, > visits datetime not null, > downloads set('None Yet'), > > foreign key (counterID) references counters(ID), > unique index (visits) > )ENGINE = MYISAM; > > > Is the SET column type the way to do it? > i tried it but the error i'm receiving is: > > > pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') > > Please help pick the necessary column type that will be able to store a a > list of values. > -- > https://mail.python.org/mailman/listinfo/python-list If you have a list of values of the same type, but different values, you need a new table with a foreign key to the table it relates to. This is a relational database question. You can read more here: http://en.wikipedia.org/wiki/Database_normalization#Normal_forms -- Joel Goldstick h
Re: Retrieving possible list for use in a subsequent INSERT
Στις 1/11/2013 5:56 μμ, ο/η Joel Goldstick έγραψε: On Fri, Nov 1, 2013 at 11:25 AM, Nick the Gr33k wrote: Στις 31/10/2013 9:22 μμ, ο/η [email protected] έγραψε: On 10/31/2013 03:24 AM, Nick the Gr33k wrote: [...] # find out if visitor has downloaded torrents in the past cur.execute('''SELECT torrent FROM files WHERE host = %s''', host ) data = cur.fetchall() downloads = [] if data: for torrent in data: downloads.append( torrent ) else: downloads.append( 'None Yet' ) # add this visitor entry into database cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) [...] and On 10/31/2013 03:32 AM, Nick the Gr33k wrote: The error seen form error log is: [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] Traceback (most recent call last): [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] File "/home/nikos/public_html/cgi-bin/metrites.py", line 274, in [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] (cID, refs, host, city, useros, browser, visits, downloads) ) [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') line 274 is: # add this visitor entry into database cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) You set the value of 'downloads' to a list: downloads = [] if data: for torrent in data: downloads.append( torrent ) and when you use 'downloads', use have: INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., downloads) If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps you can't insert a value that is a list into it? And that may be causing your problem? If that is in fact the problem (I am only guessing), you could convert 'downloads' to a single string for insertion into your database with something like, downloads = ', '.join( downloads ) I would like to know if there's a way to store an entire list into a MySQL table. -- [code] # find out if visitor had downloaded torrents in the past cur.execute('''SELECT torrent FROM files WHERE host = %s''', host ) data = cur.fetchall() downloads = [] if data: for torrent in data: downloads.append( torrent ) else: downloads = 'None Yet' # add this visitor entry into database (host && downloads are unique) cur.execute('''INSERT INTO visitors (counterID, refs, host, city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) [/code] If the 'downloads' column in table 'visitors' is a normal scalar value (text string or such) then perhaps i cannot insert a value that is a list into it. From within my python script i need to to store a list variable into a mysql column. the list is suppose to store torrent filenames in a form of downloads = ["movie1", "movie2", "movie3", "movie3"] is enum or set column types what needed here as proper columns to store 'download' list? Code: create table visitors ( counterID integer(5) not null, host varchar(50) not null, refs varchar(25) not null, city varchar(20) not null, userOS varchar(10) not null, browser varchar(10) not null, hits integer(5) not null default 1, visits datetime not null, downloads set('None Yet'), foreign key (counterID) references counters(ID), unique index (visits) )ENGINE = MYISAM; Is the SET column type the way to do it? i tried it but the error i'm receiving is: pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') Please help pick the necessary column type that will be able to store a a list of values. -- https://mail.python.org/mailman/listinfo/python-list If you have a list of values of the same type, but different values, you need a new table with a foreign key to the table it relates to. This is a relational database question. You can read more here: http://en.wikipedia.org/wiki/Database_normalization#Normal_forms I can create another table for filenames and use a many to many relationship between them because many movies can be downloaded by a visitor and many visitors can download a movie. That could work, but i wish to refrain from creating another mysql tabale just to store a co
Re: First day beginner to python, add to counter after nested loop
On Friday, November 1, 2013 4:47:40 PM UTC+5:30, Alister wrote: > On Thu, 31 Oct 2013 04:07:14 -0700, rusi wrote: > > Also others (Alister?) were double-space-reply-posting as well. When > > you mean to point out a behavior without getting personal, it helps to > > point out all instances of that behavior. Otherwise it looks like you > > are going for someone, when in fact you are going against something. > oops sorry I though I had trimmed the posts i replied to to only the > relevant parts. > -- > I'm having an emotional outburst!! >From python the comic through python the language to python the soap [Just sayin' on this thread whats 'foaming' on the apology-thread] -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
"Joel Goldstick" wrote in message news:[email protected]... On Fri, Nov 1, 2013 at 11:25 AM, Nick the Gr33k wrote: > 31/10/2013 9:22 ??, ?/? [email protected] ??: >> >> On 10/31/2013 03:24 AM, Nick the Gr33k wrote: >> >>> [...] >>> # find out if visitor has downloaded torrents in the past >>> cur.execute('''SELECT torrent FROM files WHERE host = %s''', >>> host >>> ) >>> data = cur.fetchall() >>> >>> downloads = [] >>> if data: >>> for torrent in data: >>> downloads.append( torrent ) >>> else: >>> downloads.append( 'None Yet' ) >>> >>> # add this visitor entry into database >>> cur.execute('''INSERT INTO visitors (counterID, refs, host, city, >>> useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, >>> %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) >>> [...] >> >> >> and >> >> On 10/31/2013 03:32 AM, Nick the Gr33k wrote: >>> >>> The error seen form error log is: >>> >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] Traceback >>> (most recent call last): >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] File >>> "/home/nikos/public_html/cgi-bin/metrites.py", line 274, in >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] (cID, >>> refs, host, city, useros, browser, visits, downloads) ) >>> >>> [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] >>> pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') >>> >>> line 274 is: >>> >>> # add this visitor entry into database >>> cur.execute('''INSERT INTO visitors (counterID, refs, host, city, >>> useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s, >>> %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) >> >> >> >> You set the value of 'downloads' to a list: >> >>> downloads = [] >>> if data: >>> for torrent in data: >>> downloads.append( torrent ) >> >> >> and when you use 'downloads', use have: >> >>INSERT INTO visitors (..., downloads) VALUES (..., %s), (..., >> downloads) >> >> If the 'downloads' column in table 'visitors' is a >> normal scalar value (text string or such) then perhaps >> you can't insert a value that is a list into it? And >> that may be causing your problem? >> >> If that is in fact the problem (I am only guessing), you >> could convert 'downloads' to a single string for insertion >> into your database with something like, >> >>downloads = ', '.join( downloads ) >> > > > I would like to know if there's a way to store an entire list into a MySQL > table. > -- > [code] > # find out if visitor had downloaded torrents in the past > > cur.execute('''SELECT torrent FROM files WHERE host = > %s''', > host ) > data = cur.fetchall() > > downloads = [] > if data: > for torrent in data: > downloads.append( torrent ) > else: > downloads = 'None Yet' > > > # add this visitor entry into database (host && downloads > are unique) > cur.execute('''INSERT INTO visitors (counterID, refs, > host, > city, useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, > %s, %s)''', (cID, refs, host, city, useros, browser, visits, downloads) ) > [/code] > > > If the 'downloads' column in table 'visitors' is a > normal scalar value (text string or such) then perhaps > i cannot insert a value that is a list into it. > > From within my python script i need to to store a list variable into a > mysql > column. > > the list is suppose to store torrent filenames in a form of > > downloads = ["movie1", "movie2", "movie3", "movie3"] > > > is enum or set column types what needed here as proper columns to store > 'download' list? > > Code: > > create table visitors > ( > counterID integer(5) not null, > host varchar(50) not null, > refs varchar(25) not null, > city varchar(20) not null, > userOS varchar(10) not null, > browser varchar(10) not null, > hits integer(5) not null default 1, > visits datetime not null, > downloads set('None Yet'), > > foreign key (counterID) references counters(ID), > unique index (visits) > )ENGINE = MYISAM; > > > Is the SET column type the way to do it? > i tried it but the error i'm receiving is: > > > pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') > > Please help pick the necessary column type that will be able to store a a > list of values. > -- > https://mail.python.org/mailman/listinfo/python-list If you have a list of values of the same type, but different values, you need a new table with a foreign key to the table it relates to. This is a relational database question. You
Re: Retrieving possible list for use in a subsequent INSERT
Στις 1/11/2013 7:07 μμ, ο/η Paul Simon έγραψε: If you have a list of values of the same type, but different values, you need a new table with a foreign key to the table it relates to. This is a relational database question. You can read more here: http://en.wikipedia.org/wiki/Database_normalization#Normal_forms I already answered to that in my previous post, this answer was Joel's there was no need to retype it since i i saw it and responded to it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Basic Python Questions - Oct. 31, 2013
On 11/01/2013 08:42 AM, William Ray Wing wrote: Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries that give Python so much power and flexibility. Not to take away from your points about Python, combined with the appropriate libraries, being fast enough, but the "batteries included" refers to what comes in the stdlib -- those three libraries are not in the stdlib, so they're more along the lines of "power generators easily acquired". :) -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: getpeername() on stdin?
On Thu, Oct 31, 2013, at 21:12, Nobody wrote: > On Thu, 31 Oct 2013 12:16:23 -0400, Roy Smith wrote: > > > I want to do getpeername() on stdin. I know I can do this by wrapping a > > socket object around stdin, with > > > > s = socket.fromfd(sys.stdin.fileno(), family, type) > > > > but that requires that I know what the family and type are. What I want > > to do is discover the family and type by looking at what getpeername() > > and/or getsockname() return. Can this be done with the standard library? > > I think that you'd need to use ctypes to access the underlying > getpeername() function from libc. If it's possible to get this information with only the fd, then why does socket.fromfd require them? -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
On Thu, 31 Oct 2013 11:32:29 +0200, Nick the Gr33k wrote: > The error seen form error log is: > [Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93] > pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)') > (cID, refs, host, city, useros, browser, visits, downloads) ) I suspect the issue is that, as a list type, the pysql interface expects to map "downloads" to either multiple columns, or one column in multiple rows, ie it is expecting the list to deliver multiple data items to the database, but the database is looking for a single data item. -- Denis McMahon, [email protected] -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
"Nick the Gr33k" wrote in message news:[email protected]... > 1/11/2013 7:07 ??, ?/? Paul Simon ??: > >> If you have a list of values of the same type, but different values, >> you need a new table with a foreign key to the table it relates to. >> This is a relational database question. You can read more here: >> >> http://en.wikipedia.org/wiki/Database_normalization#Normal_forms > > I already answered to that in my previous post, this answer was Joel's > there was no need to retype it since i i saw it and responded to it. Perhaps you misunderstood my response to Joel's comment. You don't a many to many table as he said above in your quote. That's required for a normal form but isn't necessary. Denormalize the many to many form, have duplicated data in your only table if that works for you. Storage is cheap and its easier to create sql stsatements, too. Paul Simon -- https://mail.python.org/mailman/listinfo/python-list
Re: "Backward"-Iterator - Beginners question
Chris Angelico wrote: > On Fri, Nov 1, 2013 at 9:18 PM, Ulrich Goebel wrote: >> That gives me the solution. What I have, is an iterator object comming as a >> SQLite database cursor object. So I could minimize the underliying SELECT >> and build index = list(cursor). Then with Your hints I get what I want. Well, if you want to iterate over a SQL result backwards, I would seriously consider modifying the SELECT to yield the results in the right order. That would avoid keeping the list in memory and makes best use of the database. -- patrick -- https://mail.python.org/mailman/listinfo/python-list
Re: Basic Python Questions - Oct. 31, 2013
On Nov 1, 2013, at 2:08 PM, Ethan Furman wrote: > On 11/01/2013 08:42 AM, William Ray Wing wrote: >> >> Granted, this performance is based on pulling in libraries. It imports >> numpy, mathplotlib, and wx to handle the fast array calculations, the >> plotting, and the GUI respectively, but those are exactly the sorts of >> "batteries included" libraries that give Python so much power and >> flexibility. > > Not to take away from your points about Python, combined with the appropriate > libraries, being fast enough, but the "batteries included" refers to what > comes in the stdlib -- those three libraries are not in the stdlib, so > they're more along the lines of "power generators easily acquired". :) > > -- > ~Ethan~ > -- > https://mail.python.org/mailman/listinfo/python-list Strictly speaking, you are absolutely correct. But, those three libraries are SO widely available (for so many platforms), I took the liberty of being inclusive. Thanks, Bill -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On 01/11/2013 13:33, Zachary Ware wrote: On Fri, Nov 1, 2013 at 8:20 AM, wrote: error: Setup script exited with error: Unable to find vcvarsall.bat I would have to guess that you've got the wrong version of Visual C++. You can install both 2008 and 2010 in parallel, if you need 2008 for something else. As "you've got the wrong version of Visual C++" isn't easily deduced from "Unable to find vcvarsall.bat", would it be worth raising an issue on the bug tracker to get the message changed? -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
New to using re. Search for a number before a string.
I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name "ELMER FUDD" and extract the number right in front of it "608309" when such a number appears but the length of the number is variable and using ?<= in a regular expression will only search for a fixed length. Any ideas appreciated! -- https://mail.python.org/mailman/listinfo/python-list
Re: New to using re. Search for a number before a string.
On 01/11/2013 21:33, Captain Dunsel wrote: I have a text file that has lines with numbers occasionally appearing right before a person's name. For example: COLLEGE:ENROLLMENT:COMPLETED EVALUATIONS:624309FUDD, ELMER where I want to search for the name "ELMER FUDD" and extract the number right in front of it "608309" when such a number appears but the length of the number is variable and using ?<= in a regular expression will only search for a fixed length. Any ideas appreciated! How about searching with a pattern like r':(\d*)FUDD, ELMER'. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
Mark said : "so I can get an extremely large pair of pliers with which I can extract my tongue from my cheek :) " OK fair enough, and my post was in the same spirit. Chris said : "Maybe, but it's supported by so many languages that it is of value. " Sure, I suppose someone should make a module that gets you as close as possible within the as-is language definition. I can't really comment on whether Py is close enough currently, as I always thought printf was sort of crappy. I thought the C++ << business even worse. Like I said, Python seems fine to me in this area. I use the str(), round() and ljust(), rjust() functions and concatenate what I need together. The result seems more readable than the old printf crap I used to write (not exactly clearing a sky high bar). Just one man-child's opinion. -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On 11/1/2013 4:49 PM, Mark Lawrence wrote: On 01/11/2013 13:33, Zachary Ware wrote: On Fri, Nov 1, 2013 at 8:20 AM, wrote: error: Setup script exited with error: Unable to find vcvarsall.bat I would have to guess that you've got the wrong version of Visual C++. You can install both 2008 and 2010 in parallel, if you need 2008 for something else. As "you've got the wrong version of Visual C++" isn't easily deduced from "Unable to find vcvarsall.bat", would it be worth raising an issue on the bug tracker to get the message changed? Only if that message comes from something distributed with CPython, rather than from Microsoft. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Help Python 3.3
On 01/11/2013 21:50, Terry Reedy wrote: On 11/1/2013 4:49 PM, Mark Lawrence wrote: On 01/11/2013 13:33, Zachary Ware wrote: On Fri, Nov 1, 2013 at 8:20 AM, wrote: error: Setup script exited with error: Unable to find vcvarsall.bat I would have to guess that you've got the wrong version of Visual C++. You can install both 2008 and 2010 in parallel, if you need 2008 for something else. As "you've got the wrong version of Visual C++" isn't easily deduced from "Unable to find vcvarsall.bat", would it be worth raising an issue on the bug tracker to get the message changed? Only if that message comes from something distributed with CPython, rather than from Microsoft. distutils -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Front-end to GCC
In article ,
Chris Kaynor wrote:
>-=-=-=-=-=-
>Global:
>
>int arr[10];
>int main()
>{
> int i;
> for (i = 0; i < 10; i++) {
>printf("arr[%d] = %d\n", i, arr[i]);
>}
>printf("\n");
>return 0;
>}
>
>As for a reference:
>http://stackoverflow.com/questions/1831290/static-variable-initialization
> and
>http://stackoverflow.com/questions/3373108/why-are-static-variables-auto-initialized-to-zero,
>both of which then reference the C++ standard.
Or even better:
#include
int arr[] = {1,2,3,4,5,6,7,8};
int main()
{
int i;
for (i = 0; i < sizeof(arr)/sizeof(int); i++) {
printf("arr[%d] = %d\n", i, arr[i]);
}
printf("\n");
return 0;
}
Output:
"
albert@cherry:/tmp$ a.out
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 4
arr[4] = 5
arr[5] = 6
arr[6] = 7
arr[7] = 8
"
This is the output of
objdump -x a.out (after stripping)
"
a.out: file format elf64-x86-64
a.out
architecture: i386:x86-64, flags 0x0112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00400450
Lots of segments.
23 .got.plt 0030 00600900 00600900 0900 2**3
CONTENTS, ALLOC, LOAD, DATA
24 .data 0040 00600940 00600940 0940 2**5
CONTENTS, ALLOC, LOAD, DATA
25 .bss 0010 00600980 00600980 0980 2**3
ALLOC
26 .comment 001c 0980 2**0
CONTENTS, READONLY
SYMBOL TABLE:
no symbols
"
Look at .data It is CONTENTS LOAD DATA, i.e. it has content
in the executable binary and this is loaded as such into memory
at startup.
You can also ask to dump the content of the sections:
objdump -s a.out
a.out: file format elf64-x86-64
...
Contents of section .data:
600940
600950
600960 0100 0200 0300 0400
600970 0500 0600 0700 0800
Contents of section .comment:
4743433a 20284465 6269616e 20342e34 GCC: (Debian 4.4
0010 2e352d38 2920342e 342e3500 .5-8) 4.4.5.
>
>
>>
>> --
>> Steven
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>-=-=-=-=-=-
>[Alternative: text/html]
>-=-=-=-=-=-
--
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
--
https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On Sat, Nov 2, 2013 at 8:47 AM, Peter Cacioppi wrote:
> I always thought printf was sort of crappy.
>
> I thought the C++ << business even worse.
Oh, you'll get no argument from me about the std::*stream types! When
I write C++ code, I almost exclusively use C-style formatted strings,
even sometimes going to the extent of using fopen() just so I can use
fprintf() rather than fstream. Also, I often create a class something
like this:
struct format
{
char *data;
format(const char *fmt, ...);
operator char *() {return data;}
};
where the constructor calls vsprintf and there's a bit of new/delete
work to manage memory, but that's all under the covers; in code, I use
it like this:
some_function_call(format("Hello, %s!", "world"));
making it almost as if it's a function returning a string, like you
would in Python.
Most of the problems with printf come from the fragility of C's
variadic functions. Some C compilers can deal with that (gcc happily
checks printf args), but there are still fundamentally hard problems
around it. They don't apply in Python (or Pike, which has an sprintf
function[1] with even more power), as issues can be signalled with
exceptions - clean, easy, safe.
ChrisA
[1]
http://pike.lysator.liu.se/generated/manual/modref/ex/predef_3A_3A/sprintf.html
--
https://mail.python.org/mailman/listinfo/python-list
ANN: 'tsshbatch' Server Automation Tool Version 1.171 Released
'tsshbatch' Version 1.171 is now released and available for download at: http://www.tundraware.com/Software/tsshbatch The last public release was 1.137. - What Is 'tsshbatch'? 'tsshbatch' is a server automation tool to enable you to issue commands to many servers without having to log into each one separately. When writing scripts, this overcomes the 'ssh' limitation of not being able to specify the password on the command line. 'tsshbatch' also understands basic 'sudo' syntax and can be used to access a server, 'sudo' a command, and then exit. 'tsshbatch' thus allows you to write complex, hands-off scripts that-- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ issue commands to many servers without the tedium of manual login and 'sudo' promotion. System administrators, especially, will find this helpful when working in large server farms. 'tsshbatch' is written in Python and requires the 'paramiko library. It has been tested on various Linux and FreeBSD variants. WHATSNEW For 'tsshbatch' 1.171(Fri Nov 1 12:08:31 CDT 2013) -- CHANGES: - Changed default behavior to pick up $USER from the environment and not prompt for it. - When prompting for username, now shows $USER or the user presented via -n as default if present. - Cosmetic changes in reporting output - Cleaned up sudo handling and reporting NEW FEATURES: - A new option, -N, to forces prompting for username to overcome the new default behavior of using $USER or the name provided by -n without promptng. What Is 'tsshbatch'? 'tsshbatch' is a tool to enable you to issue commands to many servers without having to log into each one separately. When writing scripts, this overcomes the 'ssh' limitation of not being able to specify the password on the command line. 'tsshbatch' also understands basic 'sudo' syntax and can be used to access a server, 'sudo' a command, and then exit. 'tsshbatch' thus allows you to write complex, hands-off scripts that issue commands to many servers without the tedium of manual login and 'sudo' promotion. System administrators, especially, will find this helpful when working in large server farms. 'tsshbatch' is written in Python and requires the 'paramiko library. It has been tested on various Linux and FreeBSD variants as well as cygwin on MS-Windows. This option also overrides any previous request for key exchange authentication. - A new option, -S, forces prompting for the sudo password, with the default being any previously provided password (interactive or -p). This allows you to use one password to authenticate to the system and a different one to do sudo promotion. - Two new options, -G and -P, support file transfer GETs and PUTs respectively from the selected hosts. - A new option, -f cmdfile, allows multiple commands stored in the file to be run on each of the selected hosts. This allows for considerably more complex operations than the single command string at the end of the command line supported in previous versions. - A new option, -y, turns on 'noisy' reporting and produces context information (hostname, output stream, and command) for every line of output. This makes the output more useful when filtered through something like 'grep'. - There is a new options, -t, to turn on "test mode" which will show what would be done, but will not actually do it. This mode also displays useful diagnostic information about the command line, variable defintions, file tranfer requests, and so on. - The new -x option is used to negate a prior -t and thereby force execution of the requested file transfers and/or commands. - Both cmdfiles and hostlistfiles now support freeform whitespace and commenting via the "#" character. - Both cmdfiles and hostlistfiles now support including other files via the .include directive. Circular include detection is also implemented. - Both cmdfiles and hostlistfiles can contain variable definitions that are literally replaced in any following text. Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- Tim Daneliuk [email protected] PGP Key: http://www.tundraware.com/PGP/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
Στις 1/11/2013 9:12 μμ, ο/η Denis McMahon έγραψε:
On Thu, 31 Oct 2013 11:32:29 +0200, Nick the Gr33k wrote:
The error seen form error log is:
[Thu Oct 31 09:29:35 2013] [error] [client 46.198.103.93]
pymysql.err.InternalError: (1241, 'Operand should contain 1 column(s)')
(cID, refs, host, city, useros, browser, visits, downloads) )
I suspect the issue is that, as a list type, the pysql interface expects
to map "downloads" to either multiple columns, or one column in multiple
rows, ie it is expecting the list to deliver multiple data items to the
database, but the database is looking for a single data item.
--
I wish not to create an extra MySQL table but just have a column that
can store zero or multiple values within it.
Shall i use a specific column type like ENUM or SET ?
i tried it but this also doenst work.
# find out if visitor had downloaded torrents in the past
cur.execute('''SELECT torrent FROM files WHERE host = %s''',
host )
data = cur.fetchall()
downloads = []
if data:
for torrent in data:
downloads.append( torrent )
else:
downloads = 'None Yet'
# add this visitor entry into database (host && downloads are
unique)
cur.execute('''INSERT INTO visitors (counterID, refs, host, city,
useros, browser, visits, downloads) VALUES (%s, %s, %s, %s, %s, %s, %s,
%s)''', (cID, refs, host, city, useros, browser, visits, downloads) )
is the baove code correct?
downloads is a list(array of multiple values) or even of zero values.
HOW this 'list' is supposed to get stored into the visitors database?
What colum is able to handle this list?
--
https://mail.python.org/mailman/listinfo/python-list
Re: getpeername() on stdin?
In article , [email protected] wrote: > On Thu, Oct 31, 2013, at 21:12, Nobody wrote: > > On Thu, 31 Oct 2013 12:16:23 -0400, Roy Smith wrote: > > > > > I want to do getpeername() on stdin. I know I can do this by wrapping a > > > socket object around stdin, with > > > > > > s = socket.fromfd(sys.stdin.fileno(), family, type) > > > > > > but that requires that I know what the family and type are. What I want > > > to do is discover the family and type by looking at what getpeername() > > > and/or getsockname() return. Can this be done with the standard library? > > > > I think that you'd need to use ctypes to access the underlying > > getpeername() function from libc. > > If it's possible to get this information with only the fd, then why does > socket.fromfd require them? Because socket.fromfd() is a very simplistic alternate way to create a socket object, which meets a common use case that happens not to be my use case. -- https://mail.python.org/mailman/listinfo/python-list
XML python to database
Can anyone help me overcome a terminology and jargon barrier I am having in fully defining what tools to use to fulfil a process. I want to create a database 6 Related tables. Update information 1 or twice a week with data from an XML file that I will download, this data would update rows in 5 tables of the database. From there display, add, edit and view data in web page and produce other info based on this. My main roadblock is the XML process, I am finding it unclear to understand what tools and how to manage this process. Most examples show manually inputting data. What I know and have learnt. - can insert and update data into database using python(values I type in) - can query and view data with python from tables - can design good SQL related tables(don't know much NoSQL) - Use lxml to open view and find info from nodes of an XML file - Basic Django/Flask/Pylons haven't completed a sizable project yet but have completed their tutorials and have some previous web experience. When I look for info on this process - Info from django leads ultimately to fixtures Django Docs, initial fixtures https://docs.djangoproject.com/en/dev/howto/initial-data/ - SQLAlchemy info leads http://docs.sqlalchemy.org/en/latest/orm/examples.html#xml-persistence - Spyne RPC toolkit http://spyne.io/#s=sql&ser=Xml&show=Schema Reading these I am not sure this covers what I am actually trying to do, reliably and repeatedly update a database with XML data. Can anyone advise of the correct terminology I should be searching for to learn more. What python tools would best help me complete Sayth -- https://mail.python.org/mailman/listinfo/python-list
Re: Testing python command line apps -- Running from within the projects w/o installing
Göktuğ Kayaalp writes: > On Fri, Nov 01, 2013 at 10:42:23AM +1100, Ben Finney wrote: > > Keep the body of “if __name__ == '__main__':” to an absolute > > minimum. Put all of the set-up and process-end functionality into > > discrete functions with discrete purposes, clear return values, and > > explicit parameters. > > This is usually the way I write my modules, and I do test my command > line interfaces in a manner similar to your example. But what I was > asking is how to actually run these programs within a command shell > session and test them in a more *tangible* fashion: I think by “more tangible fashion” you're asking not about unit testing, but about full-system testing. This is called by several names – behaviour testing, integration testing, acceptance testing – each having different connotations. Testing at levels of abstraction above the unit is important, but Python's ‘unittest’ is not a good fit. You'll need a different tool. For behaviour testing, I recommend Behave, which lets you describe assertions in English and have them automatically tested https://pypi.python.org/pypi/behave/>. For integration testing, I recommend an automated build system like Jenkins http://jenkins-ci.org/> which can get your full source tree, build it using your build system, and run all your arbitrary test commands. For running arbitrary commands as tests, you might be interested in Atheist http://arco.esi.uclm.es/~david.villa/atheist/html/>. I haven't tried it. > I write a secondary script, 'app_tester', which is similar to 'app', > but before running app.main.main, it inserts ~/app to the front of > sys.path. I think that's a poor solution. It's the worst of both worlds: you have a special-case tool, but one that doesn't actually test the application properly since it's not a very accurate representation of how the application will actually be installed. Better is simply using the build system to do a real, temporary install, and running the tests in there. -- \“Odious ideas are not entitled to hide from criticism behind | `\ the human shield of their believers' feelings.” —Richard | _o__) Stallman | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
Chris said : " I almost exclusively use C-style formatted strings, even sometimes going to the extent of using fopen() just so I can use fprintf() rather than fstream. Also, I often create a class something like this: " Ditto all that, to include the special class I cooked up to handle printf issues in an object based way. In general, I liked all the C++ additions a lot. I really liked the STL. But I don't know what Bjarne was thinking with the streams. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
On Sat, Nov 2, 2013 at 12:11 PM, Peter Cacioppi wrote: > In general, I liked all the C++ additions a lot. I really liked the STL. But > I don't know what Bjarne was thinking with the streams. It does look cool on paper. You can "see" the flow of data. Everything's type-safe - unlike C's scanf family (though, again, sscanf in a high level language can get around that problem). The only problem is, it doesn't actually help much in code. It's snazzy but not all that useful. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python wart
Chris said : "It does look cool on paper. " Sure, I'll buy that Bjarne designed something intellectually pretty that just doesn't flow very well in practice. Most of his C++ worked very well both in theory and practice, so I can forgive him one nerdy overreach, if that's what it was. Python is impressive for it's lack of such constructions. Things are pretty to think about, and handy to use. What is it the French say? "Sure it works in practice, but does it work on paper?" ;) I can joke, I once had many very smart French colleagues. -- https://mail.python.org/mailman/listinfo/python-list
Re: XML python to database
On Saturday, November 2, 2013 6:01:12 AM UTC+5:30, flebber wrote: > What I know and have learnt. > - Use lxml to open view and find info from nodes of an XML file > My main roadblock is the XML process, I am finding it unclear to understand > what tools and how to manage this process. > Most examples show manually inputting data. Whats missing in lxml for this? Maybe the 'trick' for running a web search is to look for elementtree and then use the concepts in lxml [Starting http://docs.python.org/2/library/xml.etree.elementtree.html ?? ] -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On 10/31/2013 11:41 PM, Steven D'Aprano wrote:
> On Thu, 31 Oct 2013 21:41:32 -0700, rurpy wrote:
>[...]
>> Yes, on rereading you are correct, you did not say his proposition made
>> no sense, you disagreed with him that "putting this exit condition on
>> the top makes no sense" and claimed he had no business making such a
>> statement
>
> I said nothing of the sort.
Steven, please stop. Trying to treat you as as an intelligent
and intellectually honest person and consistently getting crap
like this back is getting annoying.
Here is a synopsis of the post in question (quotes are direct
quotes, not paraphrase) [*1]:
Skybuck: "To put the exit condition at the bottom is logical."
You: Ask if Skybuck has "ever done any programming at all?".
You: Give example of python While loop with test at top
You: Give example of loop with test at bottom: "inappropriate" and "ugly")
You: Example of For loop with test at bottom: "silly"
You: Example of Until loop with test at bottom: "makes sense"
Skybuck: Example of loop with test at bottom.
You: Similar While loop with test at top: "better"
You: Similar Until loop with test at bottom: "I would use a while loop"
Skybuck: "Putting this exit condition on the top makes no sense."
You: "Wait until you actually start programming before deciding
what makes sense or doesn't."
I paraphrased that dialog as "you disagreed with him that
'putting this exit condition on the top makes no sense' and
claimed he had no business making such a statement".
Instead of endlessly repeating your misrepresentation charges
along with exaggerations like "nothing of the sort", why don't
you for once actually say how my paraphrase differs materially
in meaning from what was said? How would you paraphrase it?
And, how does what you said disprove my primary point: that you
stated as fact he had no programming experience when such a
statement was your speculation, not fact, and thus likely to
raise someone's hackles?
> Good lord Rurpy, I've already called you out once for misrepresenting
> what I've said, and here you are doing it again. You didn't have the good
> graces to even say sorry, instead trying to weasel out of an apology with
> a feeble "acknowledge[ment] that I overstated your position", and here
> you are again digging yourself deeper into the hole. That's three posts
> in a row -- your original post where you characterised me as making an
> "attack" on Skybuck, the second post where you escalated by attributing
> words I never wrote to me, and now this one where yet again you continue
> to misrepresent my post despite being called out on it.
Steven, in every one of those posts I explained and justified
my statements. You don't even have the decency to address
those points -- instead you simply snip them out and repeat
your same accusations over and over as though by repeating
them enough times they will magically become true.
You may think you are being clever (or perhaps it is out of
desperation to avoid admitting that your response to Skybuck
was, as I demonstrated, an unjustified ad hominem attack) but
your twisting and squirming to avoid acknowledging my points
is painfully transparent.
> [...]
>> I am saying that your claim
>> that he has no programming experience is not supported by what he wrote
>
> I did not claim Skybuck had "no business" (your words) making such a
> statement about loop conditions. Far from it, I treated his opinion as a
> serious one worthy of discussion, discussing situations that both support
> and contradict his idea.
His idea was that loop tests should always or usually be
done at the end of the loop. You discussed *nothing* that
supported that idea. You contradicted it by showing a
number of examples where you claimed testing at the top
was better.
> I *asked him* if he had programming experience, with an explicit
> question, and even began the question with the sort of social lubricant
> that acknowledges that the question is a touchy one ("please excuse my
> question"). I suggested that *it seems* that he doesn't have such
> experience. The normal, good-faith implication of this is that I am
> stating an opinion of how it seems to me, not an absolute fact.
You seem to have a very selective memory. I quoted your
concluding sentence, which you conveniently leave out
above, previously in this message. You did not "suggest"
when you said "Wait until you start programming...". Nor
is that an expression of opinion.
If you can't even tell when you're misrespresenting your
own words, how do you expect to be able to tell when someone
else does?
Why don't you just own up to what you wrote?
> The whole
> exercise was to engage Skybuck in conversation, give him a chance to
> demonstrate (or at least assert) that I was mistaken about his lack of
> experience, and defend or amend his claim that putting the loop condition
> at the beginning of the loop makes no sense.
Then perh
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On 11/01/2013 06:50 AM, Antoon Pardon wrote: > Op 01-11-13 05:41, [email protected] schreef: >> On 10/31/2013 02:41 AM, Steven D'Aprano wrote: >> >>> I don't know whether you are deliberately lying, or whether you're just >>> such a careless reader that you have attributed words actually written by >>> Skybuck to me, but either way I expect an apology from you for putting >>> false words into my mouth. >> >> An apology is due when someone does some damage to things >> or people (including reputation or feelings) that should >> have been avoided. >> >> My overstating your disagreement with Skybuck was inadvertent, >> does not change the points I was making (it does not matter >> whether you thought he was wrong or nutty) and did no >> significant damage to you or your reputation. > > It seems rather obvious from Steven's reaction, your overstatement > hurt (damaged) his feelings. It it not obvious to me at all. > Since you ackowleged that damaged > feelings are cause for an apology, it seems by your own words > an apology is due. I explained why an apology was not appropriate previously. -- https://mail.python.org/mailman/listinfo/python-list
Re: Retrieving possible list for use in a subsequent INSERT
On Friday, November 1, 2013 9:04:08 AM UTC-6, Ferrous Cranus wrote: > Rurpy can you help me please solve this? > is enum or set column types what needed here as proper columns to store > 'download' list? I'd help if I could but I don't use MySql and don't know anything about its column types. All I could do it try to read about it (which I don't have time for right now) and you know more about it than me so you can probably figure it out more quickly. -- https://mail.python.org/mailman/listinfo/python-list
Re: XML python to database
Yes I have done the lxml search and learnt how to open view and query the file. But what is the next step in the process? To get it so that I can reliably push XML files to my database repeatedly. Looking for a basic structure or example to use to guide me for first time. Sayth -- https://mail.python.org/mailman/listinfo/python-list
multiprocessing: child process race to answer
I am using a basic multiprocessing snippet I found: #- from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': pool = Pool(processes=4) # start 4 worker processes result = pool.apply_async(f, [10])# evaluate "f(10)" asynchronously print result.get(timeout=1) print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]" #- I am using this code to have each process go off and solve the same problem, just with different inputs to the problem. I need to be able to kill all processes once 1 of n processes has come up with the solution. There will only be one answer. I have tried: sys.exit(0) #this causes the program to hang pool.close() pool.terminate These still allow further processing before the program terminates. What else can I try? I am not able to share the exact code at this time. I can provide more detail if I am unclear. Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing: child process race to answer
On 02/11/2013 02:35, smhall05 wrote: I am using a basic multiprocessing snippet I found: #- from multiprocessing import Pool def f(x): return x*x if __name__ == '__main__': pool = Pool(processes=4) # start 4 worker processes result = pool.apply_async(f, [10])# evaluate "f(10)" asynchronously print result.get(timeout=1) print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]" #- I am using this code to have each process go off and solve the same problem, just with different inputs to the problem. I need to be able to kill all processes once 1 of n processes has come up with the solution. There will only be one answer. I have tried: sys.exit(0) #this causes the program to hang pool.close() pool.terminate Did you actually mean "pool.terminate", or is that a typo for "pool.terminate()"? These still allow further processing before the program terminates. What else can I try? I am not able to share the exact code at this time. I can provide more detail if I am unclear. Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: Possibly better loop construct, also labels+goto important and on the fly compiler idea.
On Fri, 01 Nov 2013 18:50:02 -0700, rurpy wrote: > Instead of endlessly repeating your misrepresentation charges along with > exaggerations like "nothing of the sort", why don't you for once > actually say how my paraphrase differs materially in meaning from what > was said? I have directly addressed your points three times. I did not "attack" the OP by any reasonable definition of the word. My post was not an ad hominem. Skybuck's experience as a programmer is relevant to the credibility of his opinions about programming. I did not declare as a fact that he had no experience, as you claim, but posed it as a question and expressed it explicitly as a subjective observation. Each time I have responded to you, I have given direct quotes and directly addressed the substance of your posts, which is all to do with the supposed tone of my response to the OP. Each time you have continued to misrepresent me, misquote me, and interpret my words assuming bad faith rather than good, in order to justify your idea that my post was an ad hominem attack. Including this post, where you make the false statement that: [quote] His idea was that loop tests should always or usually be done at the end of the loop. You discussed *nothing* that supported that idea. Emphasis yours. But in fact I gave the concrete example of Pascal repeat...until loops, which have the test at the end of the loop. So yet again your claims are simply wrong. This is four posts in a row now that you have wrongly represented me. I can only conclude that you think that by repeating a lie often enough, you'll convince others that it must be true and "win". I will no longer play this game with you. Goodbye. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: XML python to database
On Saturday, November 2, 2013 7:31:20 AM UTC+5:30, flebber wrote: > Yes I have done the lxml search and learnt how to open view and query the > file. > But what is the next step in the process? To get it so that I can reliably > push XML files to my database repeatedly. > Looking for a basic structure or example to use to guide me for first time. I dont get where's the catch. Could be in any of 1. reliably 2. push xml 3. database 4. repeatedly 5. basic structure I'm going to assume 5. So... Forget about all the other stuff -- django, web, spyne etc Just 2 pieces of the jigsaw to start with - your database engine -- mysql, sqlite, postgres... whatever - your xml input with python as the glue inbetween. 1. So you can even whittle down the XML schema to something related to what you finally need but relatively trivial 2. Make a correspondingly (if necessary trivialized) sql schema 3. Make a bit of python glue to read the first (as a file) and write out the second 4. Debug the output 5. De-trivialize your simplifications 6. Fit into the larger framework [I wrote the above as though to a somewhat inexperienced programmer. An experienced programmer will find it condescending. If so I apologize] -- https://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing: child process race to answer
On Friday, November 1, 2013 10:52:40 PM UTC-4, MRAB wrote: > On 02/11/2013 02:35, smhall05 wrote: > > > I am using a basic multiprocessing snippet I found: > > > > > > #- > > > from multiprocessing import Pool > > > > > > def f(x): > > > return x*x > > > > > > if __name__ == '__main__': > > > pool = Pool(processes=4) # start 4 worker processes > > > result = pool.apply_async(f, [10])# evaluate "f(10)" asynchronously > > > print result.get(timeout=1) > > > print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]" > > > #- > > > > > > I am using this code to have each process go off and solve the same > > problem, just with different inputs to the problem. I need to be able to > > kill all processes once 1 of n processes has come up with the solution. > > There will only be one answer. > > > > > > I have tried: > > > > > > sys.exit(0) #this causes the program to hang > > > pool.close() > > > pool.terminate > > > > > Did you actually mean "pool.terminate", or is that a typo for > > "pool.terminate()"? > > > > > These still allow further processing before the program terminates. What > > else can I try? I am not able to share the exact code at this time. I can > > provide more detail if I am unclear. Thank you > > > I am not sure to be honest, however it turns out that I can't use pool.terminate() because pool is defined in main and not accessible under my def in which I check for the correct answer. -- https://mail.python.org/mailman/listinfo/python-list
