From wuwei23 at gmail.com Tue Sep 1 01:03:39 2009 From: wuwei23 at gmail.com (alex23) Date: Mon, 31 Aug 2009 22:03:39 -0700 (PDT) Subject: map References: <777de4d8-e591-4d21-bbd0-b286105895bc@i18g2000pro.googlegroups.com> Message-ID: <440835c4-fd50-4abc-a52f-d4c4085a9e74@v37g2000prg.googlegroups.com> Piet van Oostrum wrote: > [myFunc(elt, 'booHoo') for elt in myList] is also a good candidate and > in this case I think it is preferable to both the loop and the map with > a partial or lambda in terms of clarity. >From memory, a listcomp with a non-builtin function is also faster than map with the same. From rt8396 at gmail.com Tue Sep 1 01:41:29 2009 From: rt8396 at gmail.com (r) Date: Mon, 31 Aug 2009 22:41:29 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> Message-ID: Well despite all my rantings over Unicode i highly doubt Guido will remove it from Python or any other language devs will follow suit. As i pointed out the real issue is not so much a Unicode problem (which is just a monkey patch) but stems from the multi-language problem. I think a correlation can be drawn between the current state of the world now, and the state of programming *pre* OOP. A lot of duplicate natural languages are spread out every where like some noob's spaghetti code. There is no intelligent all encompassing system to reign in this unorganization. We need an intelligent object model (universal language) to reign in this madness. We must wrap up the loose ends here so we can spend more time on real problems and less time on the remedial work of duplicating code (leaning multi-lang's) and debugging code (miscommunication and misunderstandings between multi-lang users). How many countless years are wasted on humans learning multiple languages just so we can communicate? How many advancements in medicine, physics, mathematics, blah, are we pushing further down the road due to wasted time and energy? But this same problem also extends into monies, nation states, units of measure, etc. Until this multiplicity is reigned in, programmers will suffer the agony of Unicode. Travelers to foreign lands will need to exchange their monies And yes, *even* mechanic's will need to carry around a set of metric and standard wrenches in their toolboxes. What a shame :-( From wuwei23 at gmail.com Tue Sep 1 01:53:05 2009 From: wuwei23 at gmail.com (alex23) Date: Mon, 31 Aug 2009 22:53:05 -0700 (PDT) Subject: lambda functions References: <5369eaa8-bcda-44e0-90c3-8972f2b1eb91@g23g2000vbr.googlegroups.com> Message-ID: Pierre wrote: > I would like to know if it is possible to define a loop in a lambda > function.... It is if you can easily replace the for loop with a call to map(): >>> s_minus_1 = lambda s: map(lambda x: x-1, s) >>> test = range(1, 100, 10) >>> test [1, 11, 21, 31, 41, 51, 61, 71, 81, 91] >>> s_minus_1(test) [0, 10, 20, 30, 40, 50, 60, 70, 80, 90] From contact at xavierho.com Tue Sep 1 02:46:05 2009 From: contact at xavierho.com (Xavier Ho) Date: Tue, 1 Sep 2009 16:46:05 +1000 Subject: Executing python script stored as a string In-Reply-To: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: <2d56febf0908312346n6e570c39x713905568494e2b7@mail.gmail.com> I'm afraid I'm not much of a help here, but was there any reason you didn't want to wrap those "string functions" inside a function, and just call the function? Cheers, -Xav -------------- next part -------------- An HTML attachment was scrubbed... URL: From contact at xavierho.com Tue Sep 1 02:48:55 2009 From: contact at xavierho.com (Xavier Ho) Date: Tue, 1 Sep 2009 16:48:55 +1000 Subject: Executing python script stored as a string In-Reply-To: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: <2d56febf0908312348v3f35dec8wdc59749dacfa408f@mail.gmail.com> On Tue, Sep 1, 2009 at 9:29 AM, Ecir Hana wrote: > - if I understood it correctly defining a function in the string and > exec-ing it created the function in current scope. This is something I > really don't want > Oops, missed that point. May I ask what is there you don't want, and what about putting the function inside a different module and importing? What's so bad about being "in scope"? Sincerely, -Xav -------------- next part -------------- An HTML attachment was scrubbed... URL: From rt8396 at gmail.com Tue Sep 1 02:57:33 2009 From: rt8396 at gmail.com (r) Date: Mon, 31 Aug 2009 23:57:33 -0700 (PDT) Subject: IDE for python similar to visual basic References: <2a17396c-4d6d-4cb0-a314-208054a2f774@z31g2000yqd.googlegroups.com> <6cb48259-3e42-4efe-b856-7b0f1a141024@o21g2000vbl.googlegroups.com> Message-ID: <03bae1cb-33c5-4602-a6a9-e6456071508f@n2g2000vba.googlegroups.com> On Aug 30, 4:12?pm, Nobody wrote: (snip) > Creating a GUI programmatically is almost always the wrong approach. It > tends to be adopted due to a path of least resistance, rather than any > affirmative reason. so i guess it'e safe to say that you use a GUI builder? :-) From rt8396 at gmail.com Tue Sep 1 03:08:34 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 00:08:34 -0700 (PDT) Subject: IDLE file saving problem References: <70222640-1990-4fae-bbca-8451d252a1ab@13g2000prl.googlegroups.com> <9d12959olkh5l3oamr9lfhedcrqd5nt7v7@4ax.com> Message-ID: <65a1fa83-be97-4502-a24b-c35986ed518b@b18g2000vbl.googlegroups.com> On Aug 23, 4:12?am, Harald Luessen wrote: (snip) > When the cursor is somewhere in the white space at the > beginning of the lines and I use Ctrl-rightArrow ?[ctrl]-[->] > to go to the first word in the line then IDLE skips > the position with the first non-whitespace letter and places > the cursor after the first word in the line. > This is not consistent because moving backwards works. [ctrl]-[<-] > Similar things happen at the end of a line. Ah yes, this is something that erks me daily, but i seem to have forgotten about it until you brought it up (Thank you!). I must put this on the rIDLE bug list. It's these tiny annoyances that really ruin IDLE. It's noting major, but you know what a thousand paper-cuts can do... With a little spit shine IDLE could be quite wonderful. You guys will see a much improved IDLE very soon, i can promise you that! From gh at gregor-horvath.com Tue Sep 1 03:14:14 2009 From: gh at gregor-horvath.com (Gregor Horvath) Date: Tue, 1 Sep 2009 09:14:14 +0200 Subject: win32ui DLL Load Failed References: Message-ID: <20090901091414.3ee27189@brasov> Am Mon, 31 Aug 2009 12:43:04 -0700 (PDT) schrieb MikeC : > I have a python executable that's failing to load on a user's machine > running Windows XP. My developer machine is also running Windows XP. I > have determined that it is failing when it attempts to load win32ui. > > I have Python 2.6 on my developer machine and am using the pywin > support (Mark Hammonds???) for Python 2.6. Try to install: http://www.microsoft.com/downloads/details.aspx?familyid=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en 2.6 is linked against VS8 dlls, which are missing on some machines. -- Gregor From tjreedy at udel.edu Tue Sep 1 03:39:14 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 03:39:14 -0400 Subject: An assessment of the Unicode standard In-Reply-To: References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> Message-ID: r wrote: > Well despite all my rantings over Unicode i highly doubt Guido will > remove it from Python or any other language devs will follow suit. As > i pointed out the real issue is not so much a Unicode problem (which > is just a monkey patch) but stems from the multi-language problem. Unicode is a symptom, not a fundamental cause. [snip] > But this same problem also extends into monies, nation states, units > of measure, etc. There is, of course, an international system of measure. The US is the only major holdout. (I recall Burma, or somesuch, is another.) An interesting proposition would be for the US to adopt the metric system in exchange for the rest of the world adopting simplified basic English as a common language. tjr From riteshn at gmail.com Tue Sep 1 03:51:17 2009 From: riteshn at gmail.com (Ritesh Nadhani) Date: Tue, 1 Sep 2009 00:51:17 -0700 Subject: Using select.kqueue() Message-ID: <3ce825820909010051o6b960a4csb54093a05ed6bba5@mail.gmail.com> Hi I am trying to use kqueue. Since, I am on v2.5, I use the baclport: http://pypi.python.org/pypi/select26/0.1a3. Following the example at: http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which works perfectly as it tells all events), I tried to port it to Python: http://www.bpaste.net/show/25/ Not sure where I am wrong but the poller only returns *one* event ever. Adding new text, deleting the file does not return any event. What can I be doing wrong? From list at qtrac.plus.com Tue Sep 1 03:52:46 2009 From: list at qtrac.plus.com (Mark) Date: Tue, 1 Sep 2009 00:52:46 -0700 (PDT) Subject: Python Noob - gui module, book, annoying questions References: <92cc4ca1-0e0d-4355-8d9a-b4928390e619@q35g2000vbi.googlegroups.com> Message-ID: <01be7bd0-3b5d-45c1-b5b9-511a8f26b56a@o21g2000vbl.googlegroups.com> On Aug 29, 8:20?am, Pherdnut wrote: > I want to write cross-platform stuff. Any opinions on the best GUI > module for that? The "big three" cross-platform ones are PyQt4, wxPython, and PyGtk. I prefer PyQt4, but I'm biased as you'll see. > I like a good juicy, but concise book for reading on my commute > downtown. I was thinking of checking Python in a Nutshell. Good? Bad? > Better? That's a good book---but perhaps a bit out of date now? David Beazley's "Essential Python Reference" 4th Edition is similar but more up to date. But if you want a book that gives a good introduction to Python 2 _and_ GUI programming (with PyQt4), then my book "Rapid GUI Programming with Python and Qt" fits the bill. > Is 3.0+ more object based? I'm actually an FED and one of the things I > love about JS is the consistency of the language. I love Python 2.6 so > far so I'm not knocking it. But I'm not really taking advantage of the > non-core libraries as much right now anyway since I'm learning it. Python 3 is more consistent than Python 2, and I certainly prefer Python 3---but the differences aren't huge. As for OO, well for more advanced stuff I think that Python 3 is cleaner (e.g., metaclass handling), but for everyday programming both are excellent. > What do you guys like in Reg Ex books/sites? I'd like to become more > fluent in some of the less commonly used stuff. The "standard text" on regexes is "Mastering Regular Expressions" by Jeffrey Freidl, although he doesn't explicitly cover Python (but Python's regex engine is mostly a subset of Perl's, so the book is still useful). If you want something smaller and free you could download my "Programming in Python 3" book's "Regular Expressions" chapter from http://www.informit.com/store/product.aspx?isbn=0137129297 (click Sample Content, then Download the Sample pages; the regex stuff starts a few pages into the PDF). From helvinlui at gmail.com Tue Sep 1 04:25:21 2009 From: helvinlui at gmail.com (Helvin) Date: Tue, 1 Sep 2009 01:25:21 -0700 (PDT) Subject: PyQt GUI References: <7bj5ulF22b4ktU1@mid.uni-berlin.de> <60ff3276-0570-4222-9055-4e1a40538e61@r15g2000pra.googlegroups.com> <5131c895-b155-486f-aff2-7587a114e60b@o18g2000pra.googlegroups.com> <88b09175-9167-4903-9524-2725a9ab9819@j9g2000prh.googlegroups.com> <16422b45-a58b-451f-88d8-d85b70808d31@i4g2000prm.googlegroups.com> <4ee78bf1-476d-4e41-b9da-c20297aad861@13g2000prl.googlegroups.com> Message-ID: <276b5414-a2b2-401e-8e59-af248ccb7c54@f20g2000prn.googlegroups.com> Having left my problem with this embedding vtk business for a month, I came back to it yesterday, and with a bit more programming knowledge, found that my problem was simply with the python path. All I needed to do was to append, in my GUI file, the path to the python bindings, which came with the source. I have blogged in more detail here: http://learnwithhelvin.blogspot.com/2009/09/embedding-vtk-into-pyqt-gui. My VTK stuff are now displayed in my GUI! =D Welcome to ask, if my blog is not detailed enough. I just wasn't bothered to put my entire file on there. Helvin From ecir.hana at gmail.com Tue Sep 1 04:34:33 2009 From: ecir.hana at gmail.com (Ecir Hana) Date: Tue, 1 Sep 2009 01:34:33 -0700 (PDT) Subject: Executing python script stored as a string References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: On Sep 1, 5:31?am, Steven D'Aprano wrote: > > You can pass in a global and local namespaces to exec as arguments: > > >>> x = 4 > >>> ns = {'x': 4} > >>> exec "x += 1" in ns > >>> x > 4 > >>> ns['x'] > > 5 > > See the docs for details. Thanks! This is very useful! > You can copy the parts of the current scope into the namespace you pass > to exec, then later copy the revised values out again. > > But are you sure you really want to take this approach? exec is up to ten > times slower than just executing the code directly. And if the string is > coming from an untrusted source, it is a *huge* security risk. I don't know if I should use exec. I don't really mind that it's slow (btw., why is it so?). But I don't quite understand why is it security risk. How is it different to run: exec 'format(your_hdd)' than: /bin/python format.py ? > As far as I know, you can't kill threads, you can only ask them to kill > themselves. Also, I'm not sure if I follow. What does this mean? If a thread runs: while True: pass it is not possible to kill it from another thread? (Bacause it doesn't check whether some other thread asks to stop it..?) > Something like this? Well, something more like: data = [1, 2, 3] map(lambda x: x * 2, data) display_data_in_editor_viewport(data) #this renders into part of main editor window (may take some time) > If so, I think you are making this much too complicated for such a simple > use-case. Just publish an API which the script can use, and have the main > text editor application specify a "script" namespace containing only that > API. That could be a module: > > >>> import math ?# pretend this is your API shared module > >>> exec "myvalue = 42" in math.__dict__ > >>> math.myvalue > > 42 > > Then execute the text using exec, but don't bother about putting it into > a thread or subprocess. That just makes it harder to implement, and you > have to worry about concurrency issues. Ok, I could try exec, thanks for the explanation. But what about those security concerns you mentioned above? Thanks a lot, very informative! From sraji.me at gmail.com Tue Sep 1 04:34:42 2009 From: sraji.me at gmail.com (Raji Seetharaman) Date: Tue, 1 Sep 2009 14:04:42 +0530 Subject: Python and glade program - without errors but didn't display anything Message-ID: <23e3fbb60909010134x77af29ecg4827acc091f30995@mail.gmail.com> Hi all, i tried to develop a calculator using glade and python. When i run the script(python calculatorglade.py), i didn't get any errors. A calculator gui is supposed to be displayed. But no window appears. With Ctrl + C, i killed it. I got the following response from the terminal ^CTraceback (most recent call last): File "calculatorglade.py", line 106, in gtk.main() KeyboardInterrupt The Python program is available here, http://pastebin.com/m44d2c1cb The corresponding Glade xml file is available here, http://pastebin.com/m46beaac5 What should i do to display the gui window? Regards Raji. S -------------- next part -------------- An HTML attachment was scrubbed... URL: From kurt.alfred.mueller at sunrise.ch Tue Sep 1 04:47:05 2009 From: kurt.alfred.mueller at sunrise.ch (Kurt Mueller) Date: Tue, 1 Sep 2009 10:47:05 +0200 Subject: An assessment of the Unicode standard In-Reply-To: References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> Message-ID: <33B0AC00-44CA-4EA4-8322-4052E1A41871@gmail.com> Am 01.09.2009 um 09:39 schrieb Terry Reedy: >> But this same problem also extends into monies, nation states, units >> of measure, etc. > There is, of course, an international system of measure. The US is > the only major holdout. (I recall Burma, or somesuch, is another.) > An interesting proposition would be for the US to adopt the metric > system in exchange for the rest of the world adopting simplified > basic English as a common language. The SI-system is nearly universally employed. Three principal exceptions are Burma (Myanmar), Liberia, and the United States. The United Kingdom has officially adopted the International System of Units but not with the intention of replacing customary measures entirely. -------------- next part -------------- A non-text attachment was scrubbed... Name: Bild 4.png Type: image/png Size: 30358 bytes Desc: not available URL: -------------- next part -------------- When I was a student, they told us, that in a couple of years there will be the SI-system only, because most countries accepted it in their laws. So we should adopt it. That was in the early 70ties. Only this year we have to deliver results of technical processes to british and US companies. They still want them in their "crazy outdated" units. The other thing would be the US to adopt a "simplified basic English". I would not be astonished, that british people would state, that they already do :-) Gr?essli From ecir.hana at gmail.com Tue Sep 1 04:55:46 2009 From: ecir.hana at gmail.com (Ecir Hana) Date: Tue, 1 Sep 2009 01:55:46 -0700 (PDT) Subject: Executing python script stored as a string References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: <8e1026bf-9966-45b8-b9e9-646477186174@q35g2000vbi.googlegroups.com> On Sep 1, 5:31?am, Steven D'Aprano wrote: > But are you sure you really want to take this approach? exec is up to ten > times slower than just executing the code directly. Oh, you mean because of parsing and compiling? But otherwise it's as fast as regular python? That's perfectly ok. Or maybe I misunderstood you - what do you mean by "executing the code directly"? From steven at REMOVE.THIS.cybersource.com.au Tue Sep 1 05:32:29 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 01 Sep 2009 09:32:29 GMT Subject: Executing python script stored as a string References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: On Tue, 01 Sep 2009 01:34:33 -0700, Ecir Hana wrote: >> You can copy the parts of the current scope into the namespace you pass >> to exec, then later copy the revised values out again. >> >> But are you sure you really want to take this approach? exec is up to >> ten times slower than just executing the code directly. And if the >> string is coming from an untrusted source, it is a *huge* security >> risk. > > I don't know if I should use exec. I don't really mind that it's slow > (btw., why is it so?). Because it has to parse and compile the string into a code object before it can run it. > But I don't quite understand why is it security > risk. How is it different to run: > exec 'format(your_hdd)' > than: > /bin/python format.py > ? It's not different. But read what I said -- "if the string is coming from an UNTRUSTED source" -- presumably you trust yourself. If you run 'exec "format(your_hdd)"' it is because *you* want to format your hard disk. Now imagine you have a web-app which gets a string from the user and calls exec on it. Then you might have this: exec "search('%d')" % user_input and the user, who is halfway across the world, enters the following search string: places to eat'); import os; os.system('#rm -rf / Your web app will go right ahead and erase itself. That's why you need to keep untrusted strings away from exec, execfile, and eval. >> As far as I know, you can't kill threads, you can only ask them to kill >> themselves. > > Also, I'm not sure if I follow. What does this mean? If a thread runs: > > while True: > pass > > it is not possible to kill it from another thread? (Bacause it doesn't > check whether some other thread asks to stop it..?) No, I believe that the only way to halt that is to halt the entire process. Possibly there is a way to have a thread halt itself after a certain amount of time? I'm not an expert on threads, I've hardly ever used them. -- Steven From bjourne at gmail.com Tue Sep 1 05:38:30 2009 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Tue, 1 Sep 2009 11:38:30 +0200 Subject: Python word to text Message-ID: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> Hello everybody, I'm looking for a pure Python solution for converting word documents to text. App Engine doesn't allow external programs, which means that external programs like catdoc and antiword can't be used. Anyone know of any? Thanks in advance. -- mvh Bj?rn From andreengels at gmail.com Tue Sep 1 05:50:14 2009 From: andreengels at gmail.com (Andre Engels) Date: Tue, 1 Sep 2009 11:50:14 +0200 Subject: Why does this group have so much spam? In-Reply-To: <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> Message-ID: <6faf39c90909010250m13f930afjd173e0804c1f85c6@mail.gmail.com> On Sun, Aug 30, 2009 at 11:18 AM, David<71david at libero.it> wrote: > Il Sat, 29 Aug 2009 17:18:46 -0700 (PDT), casebash ha scritto: > >> So much of it could be removed even by simple keyword filtering. > > I think there is only one final solution to the spam pestilence: a tiny tax > on email and posts. > Spammers send hundreds of thousands of emails/posts a day and a tax of > 0.0001$ each does not harm normal users but discurages spammers. This tax > should be applied when a message is routed by a ISP server, this saves > mails/posts internal to a LAN. What about mailing lists? There exist well-functioning mailing lists with thousands of subscribers. Being a posting member of those will significantly increase your internet bill under your proposal. -- Andr? Engels, andreengels at gmail.com From ecir.hana at gmail.com Tue Sep 1 06:12:55 2009 From: ecir.hana at gmail.com (Ecir Hana) Date: Tue, 1 Sep 2009 03:12:55 -0700 (PDT) Subject: Executing python script stored as a string References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: <53cfc194-e2f6-4d11-b909-b1e0260856d9@33g2000vbe.googlegroups.com> On Sep 1, 11:32?am, Steven D'Aprano wrote: > > But I don't quite understand why is it security > > risk. How is it different to run: > > exec 'format(your_hdd)' > > than: > > /bin/python format.py > > ? > > It's not different. But read what I said -- "if the string is coming from > an UNTRUSTED source" -- presumably you trust yourself. If you run 'exec > "format(your_hdd)"' it is because *you* want to format your hard disk. > > Now imagine you have a web-app which gets a string from the user and > calls exec on it. Then you might have this: > > exec "search('%d')" % user_input > > and the user, who is halfway across the world, enters the following > search string: > > places to eat'); import os; os.system('#rm -rf / > > Your web app will go right ahead and erase itself. That's why you need to > keep untrusted strings away from exec, execfile, and eval. Ah, I see! Ok. > No, I believe that the only way to halt that is to halt the entire > process. > > Possibly there is a way to have a thread halt itself after a certain > amount of time? I'm not an expert on threads, I've hardly ever used them. Thank you once again! From anuhacks at gmail.com Tue Sep 1 06:13:35 2009 From: anuhacks at gmail.com (anusha k) Date: Tue, 1 Sep 2009 15:43:35 +0530 Subject: Python and glade program - without errors but didn't display anything In-Reply-To: <23e3fbb60909010134x77af29ecg4827acc091f30995@mail.gmail.com> References: <23e3fbb60909010134x77af29ecg4827acc091f30995@mail.gmail.com> Message-ID: <61f9a5fb0909010313r12f02c1ahdc5359ced979c1c8@mail.gmail.com> hi, You forgot to show the window.So in init method of py file and add self.window = self.wTree.get_widget("window_calculator") self.window.show() Njoy the share of Freedom, Anusha Kadambala On Tue, Sep 1, 2009 at 2:04 PM, Raji Seetharaman wrote: > Hi all, > i tried to develop a calculator using glade and python. > When i run the script(python calculatorglade.py), i didn't get any errors. > A calculator gui is supposed to be displayed. But no window appears. > With Ctrl + C, i killed it. I got the following response from the terminal > > ^CTraceback (most recent call last): > File "calculatorglade.py", line 106, in > gtk.main() > KeyboardInterrupt > > The Python program is available here, http://pastebin.com/m44d2c1cb > > The corresponding Glade xml file is available here, > http://pastebin.com/m46beaac5 > > What should i do to display the gui window? > > Regards > Raji. S > > -- > http://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hendrik at microcorp.co.za Tue Sep 1 07:33:53 2009 From: hendrik at microcorp.co.za (Hendrik van Rooyen) Date: Tue, 1 Sep 2009 13:33:53 +0200 Subject: Executing python script stored as a string In-Reply-To: References: <720b423c-7058-4605-96a0-b62f56aec791@s6g2000vbp.googlegroups.com> Message-ID: <200909011333.53246.hendrik@microcorp.co.za> On Tuesday 01 September 2009 11:32:29 Steven D'Aprano wrote: > Possibly there is a way to have a thread halt itself after a certain > amount of time? I'm not an expert on threads, I've hardly ever used them. Not automagically, as far as I can see. You are on your own if you want to somehow kill a thread. What I do is to wrap what I want to do in a while clause: while runbool: do_what_you_want() where runbool is a global that I set to false elsewhere when I want to stop. There is of course nothing to stop you writing a thread with something like: import time start_time = time.time() while time.time() - start_time < some_parameter: do_what_you_want() Which will have the effect of running for a while and then stop. I cannot see much use use for that as it is, as it will be bloody-minded about the time, and might chop off before the whole job is done, but one could make it more intelligent, such that it keeps track of idle time, and aborts after say a second (or a minute) of not doing anything useful. Unlike you, I am a thread and queue fanatic - use them all the time. - Hendrik From nitebirdz at sacredchaos.com Tue Sep 1 07:42:10 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Tue, 1 Sep 2009 13:42:10 +0200 Subject: Python word to text In-Reply-To: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> Message-ID: <20090901114208.GA6989@sevilla.sacredchaos.com> On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJ?rn Lindqvist wrote: > Hello everybody, > > I'm looking for a pure Python solution for converting word documents > to text. App Engine doesn't allow external programs, which means that > external programs like catdoc and antiword can't be used. Anyone know > of any? > A quick search returned this: http://code.activestate.com/recipes/279003/ Did you give it a try? From exarkun at twistedmatrix.com Tue Sep 1 08:47:55 2009 From: exarkun at twistedmatrix.com (exarkun at twistedmatrix.com) Date: Tue, 01 Sep 2009 12:47:55 -0000 Subject: Using select.kqueue() In-Reply-To: <3ce825820909010051o6b960a4csb54093a05ed6bba5@mail.gmail.com> References: <3ce825820909010051o6b960a4csb54093a05ed6bba5@mail.gmail.com> Message-ID: <20090901124755.7436.272753761.divmod.xquotient.46@localhost.localdomain> On 07:51 am, riteshn at gmail.com wrote: >Hi > >I am trying to use kqueue. Since, I am on v2.5, I use the baclport: >http://pypi.python.org/pypi/select26/0.1a3. > >Following the example at: >http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which >works perfectly as it tells all events), I tried to port it to Python: > >http://www.bpaste.net/show/25/ > >Not sure where I am wrong but the poller only returns *one* event >ever. Adding new text, deleting the file does not return any event. > >What can I be doing wrong? Perhaps you are encountering http://bugs.python.org/issue5910 Jean-Paul From sraji.me at gmail.com Tue Sep 1 08:53:16 2009 From: sraji.me at gmail.com (Raji Seetharaman) Date: Tue, 1 Sep 2009 18:23:16 +0530 Subject: Python and glade program - without errors but didn't display anything In-Reply-To: <61f9a5fb0909010313r12f02c1ahdc5359ced979c1c8@mail.gmail.com> References: <23e3fbb60909010134x77af29ecg4827acc091f30995@mail.gmail.com> <61f9a5fb0909010313r12f02c1ahdc5359ced979c1c8@mail.gmail.com> Message-ID: <23e3fbb60909010553j49eeccc8y317ad19e60cada01@mail.gmail.com> Thanks Anusha. Now my calculator gui window is displayed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mrabarnett at mrabarnett.plus.com Tue Sep 1 09:17:00 2009 From: mrabarnett at mrabarnett.plus.com (Matthew Barnett) Date: Tue, 01 Sep 2009 14:17:00 +0100 Subject: An assessment of the Unicode standard In-Reply-To: <33B0AC00-44CA-4EA4-8322-4052E1A41871@gmail.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> <33B0AC00-44CA-4EA4-8322-4052E1A41871@gmail.com> Message-ID: <4A9D1ECC.7040903@mrabarnett.plus.com> Kurt Mueller wrote: > Am 01.09.2009 um 09:39 schrieb Terry Reedy: > >>> But this same problem also extends into monies, nation states, units >>> of measure, etc. > >> There is, of course, an international system of measure. The US is the >> only major holdout. (I recall Burma, or somesuch, is another.) An >> interesting proposition would be for the US to adopt the metric system >> in exchange for the rest of the world adopting simplified basic >> English as a common language. > > The SI-system is nearly universally employed. > Three principal exceptions are Burma (Myanmar), Liberia, and the United > States. > The United Kingdom has officially adopted the International System of Units > but not with the intention of replacing customary measures entirely. > The intention in the UK was to switch to SI over a period of 10 years, starting in 1971, so from then only SI was taught in schools. Earlier this year the EU decided that it wouldn't force the UK to abandon the few remaining uses of the Imperial system; SI is preferred, but Imperial is permitted. The roads are still Imperial, and milk delivered to the door can still use the existing pint bottles, but milk sold in shops is in SI. > ------------------------------------------------------------------------ > > > > When I was a student, they told us, that in a couple of years there will be > the SI-system only, because most countries accepted it in their laws. > So we should adopt it. > That was in the early 70ties. > Only this year we have to deliver results of technical processes to british > and US companies. They still want them in their "crazy outdated" units. > > > The other thing would be the US to adopt a "simplified basic English". > I would not be astonished, that british people would state, > that they already do :-) > From tino at wildenhain.de Tue Sep 1 09:20:29 2009 From: tino at wildenhain.de (Tino Wildenhain) Date: Tue, 01 Sep 2009 15:20:29 +0200 Subject: Python word to text In-Reply-To: <20090901114208.GA6989@sevilla.sacredchaos.com> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> <20090901114208.GA6989@sevilla.sacredchaos.com> Message-ID: <4A9D1F9D.1090504@wildenhain.de> Am 01.09.2009 13:42, schrieb Nitebirdz: > On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJ?rn Lindqvist wrote: >> Hello everybody, >> >> I'm looking for a pure Python solution for converting word documents >> to text. App Engine doesn't allow external programs, which means that >> external programs like catdoc and antiword can't be used. Anyone know >> of any? >> > > A quick search returned this: > > http://code.activestate.com/recipes/279003/ > > > Did you give it a try? Thats a funny advice. Did you read that receipe? ;-) "Requires the Python for Windows extensions, and MS Word." how does this match with "App Engine doesn't allow external programs"? :-) For excel this would be easy but word - Bj?rn, did you check google api if you would be able to access google docs for this? Regards Tino -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3254 bytes Desc: S/MIME Cryptographic Signature URL: From beorn at seznam.cz Tue Sep 1 09:21:38 2009 From: beorn at seznam.cz (hoffik) Date: Tue, 1 Sep 2009 06:21:38 -0700 (PDT) Subject: Select column from a list In-Reply-To: <25185508.post@talk.nabble.com> References: <25185508.post@talk.nabble.com> Message-ID: <25240207.post@talk.nabble.com> Wow, I didn't expect so many answers and possibilities! I'll try to go through it and surely find the best solution for me :jumping: Thank you all! -- View this message in context: http://www.nabble.com/Select-column-from-a-list-tp25185508p25240207.html Sent from the Python - python-list mailing list archive at Nabble.com. From bruno.42.desthuilliers at websiteburo.invalid Tue Sep 1 09:55:22 2009 From: bruno.42.desthuilliers at websiteburo.invalid (Bruno Desthuilliers) Date: Tue, 01 Sep 2009 15:55:22 +0200 Subject: Object Reference question In-Reply-To: References: <2dcf41c3-6623-48d9-bb74-97f753088479@c34g2000yqi.googlegroups.com> <9feee13c-117e-4806-b238-e4152a68adfb@18g2000yqa.googlegroups.com> Message-ID: <4a9d279a$0$15190$426a74cc@news.free.fr> Ethan Furman a ?crit : (snip) > The best answer I can give is that you do not want to use 'name' to > reference the object itself, but only for printing/debugging purposes. Which is what the OP stated !-) > 'name' is just a label for your object, and not necessarily the only > label; that particular label may also be lost... Consider: (snip example) > As you can see, just because you have saved the original name does not > gaurantee that same name will always reference that same object, or any > object. FWIW, the __name__ attributes of functions, classes and modules works just the same... From bjourne at gmail.com Tue Sep 1 09:56:02 2009 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Tue, 1 Sep 2009 15:56:02 +0200 Subject: Python word to text In-Reply-To: <20090901114208.GA6989@sevilla.sacredchaos.com> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> <20090901114208.GA6989@sevilla.sacredchaos.com> Message-ID: <740c3aec0909010656n275ef82l45a01946c590bebd@mail.gmail.com> 2009/9/1 Nitebirdz : > On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJ?rn Lindqvist wrote: >> Hello everybody, >> >> I'm looking for a pure Python solution for converting word documents >> to text. App Engine doesn't allow external programs, which means that >> external programs like catdoc and antiword can't be used. Anyone know >> of any? >> > > A quick search returned this: > > http://code.activestate.com/recipes/279003/ It requires windows. -- mvh Bj?rn From szport at gmail.com Tue Sep 1 10:04:09 2009 From: szport at gmail.com (zaur) Date: Tue, 1 Sep 2009 07:04:09 -0700 (PDT) Subject: Is behavior of += intentional for int? References: <0025e0c6$0$2930$c3e8da3@news.astraweb.com> Message-ID: <3eed185b-ffa2-441a-a684-fe4035b2d5ab@o35g2000vbi.googlegroups.com> On 1 ???, 03:31, Steven D'Aprano wrote: > On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote: > > As a result of this debate is not whether we should conclude that there > > should be two types of integers in python: 1) immutable numbers, which > > behave as constant value; 2) mutable numbers, which behave as variable > > value? > > What can you do with mutable numbers that you can't do with immutable > ones, and why do you want to do it? > > -- > Steven Mutable numbers acts as variable quantity. So when augmented assignment is used there is no need to create a new number object in every binary operation. But when I looked now into source of python int (longobject.c) I realized that direct implementation of mutable int will not give any benefit against defining proxy int class, which supports mutability. From lallous at lgwm.org Tue Sep 1 10:04:21 2009 From: lallous at lgwm.org (lallous) Date: Tue, 1 Sep 2009 07:04:21 -0700 (PDT) Subject: copy object? Message-ID: <2a189c23-9c8e-4388-9b93-986a0a388d57@g23g2000vbr.googlegroups.com> Hello I am new to python and have some questions. How to copy objects using another method than this: class op: def __init__(self, op): for x in dir(op): if x[:2] == "__": continue setattr(self, x, getattr(op, x)) o = op(src) I tried to copy with "o = copy.copy(src)" but as soon as "src" is gone, "o"'s attributes are not correct, and I cannot use copy.deepcopy () because of this error: TypeError: object.__new__(SwigPyObject) is not safe, use SwigPyObject.__new__() Can the previous for loop be simplified and replaced with a map() and a lambda function? Thanks. From mail at timgolden.me.uk Tue Sep 1 10:05:14 2009 From: mail at timgolden.me.uk (Tim Golden) Date: Tue, 01 Sep 2009 15:05:14 +0100 Subject: Python word to text In-Reply-To: <740c3aec0909010656n275ef82l45a01946c590bebd@mail.gmail.com> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> <20090901114208.GA6989@sevilla.sacredchaos.com> <740c3aec0909010656n275ef82l45a01946c590bebd@mail.gmail.com> Message-ID: <4A9D2A1A.3000108@timgolden.me.uk> BJ?rn Lindqvist wrote: > 2009/9/1 Nitebirdz : >> On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJ?rn Lindqvist wrote: >>> Hello everybody, >>> >>> I'm looking for a pure Python solution for converting word documents >>> to text. App Engine doesn't allow external programs, which means that >>> external programs like catdoc and antiword can't be used. Anyone know >>> of any? >>> >> A quick search returned this: >> >> http://code.activestate.com/recipes/279003/ > > It requires windows. I'm moderately confident that no (published) solution exists for this without relying on an installed Word or an external program of the kind you mentioned. Obviously, there's nothing to stop someone creating a Python module which does the equivalent, possibly by wrapping the core of the catdoc/antiword code in a Python module or by recoding its functionality in Python. But I imagine you knew that :) If you were talking Excel, you'd be in luck thanks to the sterling work done by John Machin and others. But I imagine that the market for word doc interchange / conversion is considerably smaller, especially within restricted environments. Depending on the source of your docs, it would be possible to save them as, eg, XML or something for which a converter is available in Python. Even text-only, I suppose. But I suppose that you're asking because that's not a possibility? TJG From gabriel at opensuse.org Tue Sep 1 10:09:12 2009 From: gabriel at opensuse.org (Gabriel) Date: Tue, 1 Sep 2009 11:09:12 -0300 Subject: Python word to text In-Reply-To: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> Message-ID: <1adde6890909010709y461b17cckbd11aa71dbbecfd1@mail.gmail.com> 2009/9/1 BJ?rn Lindqvist : > Hello everybody, > > I'm looking for a pure Python solution for converting word documents > to text. App Engine doesn't allow external programs, which means that > external programs like catdoc and antiword can't be used. Anyone know > of any? > You could use the google docs api (http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#DownloadingDocsAndPresentations) -- Kind Regards From graemeglass at gmail.com Tue Sep 1 10:13:51 2009 From: graemeglass at gmail.com (Graeme Glass) Date: Tue, 1 Sep 2009 16:13:51 +0200 Subject: Python community buildbot page still 503 Message-ID: If I am not mistaken http://python.org/dev/buildbot/community/all/ has been down since python.org had its harddrive issues. Anyone know a time line on getting it back up and running. I have mailed the buildbot mailing list, but heard nothing for a week, so thought I would try here. Kind regards, Graeme From sverker.nilsson at sncs.se Tue Sep 1 10:47:23 2009 From: sverker.nilsson at sncs.se (Sverker Nilsson) Date: Tue, 01 Sep 2009 16:47:23 +0200 Subject: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps) Message-ID: <1251816443.14859.15.camel@sverker-laptop> A question arose on guppy-pe-list about how to iterate over objects returned one by one by a method (load) called repeatedly. I defined a generator to do this (loadall), but this seems unwieldy in general. Is there a common idiom here that can usefully be encapsulated in a general method? On Mon, 2009-08-31 at 17:57 +0100, Chris Withers wrote: > Sverker Nilsson wrote: > > It reads one Stat object at a time and wants to report something > > when there is no more to be read from the file. > > Hmm, am I right in thinking the above can more nicely be written as: > > >>> from guppy import hpy > >>> h = hpy() > >>> f = open(r'your.hpy') > >>> sets = [] > >>> for s in iter(h.load(f)): sets.append(s) > ... > The above iterates over one Stat object returned by h.load(f). I assume you want to iterate over all the objects loaded. A way to iterate over the objects (not having to define the loadall() function from previous mail) that I came up with now, is via itertools imap with h.load applied to an infinite iterator repeating the file: from guppy import hpy from itertools import imap, repeat h=hpy() f=open('your.hpy') sets = list(imap(h.load,repeat(f))) Maybe the above idiom could usefully be encapsulated in a standard function? def iapply(func, *args): '''Iterator repeatedly calling func with *args, infinitely or until it raises StopIteration''' from itertools import imap, repeat return imap(func, *[repeat(arg) for arg in args]) Usage, eg: >>> sets = list(iapply(h.load,f)) or >>> for s in iapply(h.load,f): ... What do you think, should something like iapply be added to itertools? What is the better name? :-) Sverker -- Expertise in Linux, embedded systems, image processing, C, Python... http://sncs.se From steve at lonetwin.net Tue Sep 1 10:48:08 2009 From: steve at lonetwin.net (steve) Date: Tue, 01 Sep 2009 20:18:08 +0530 Subject: An assessment of the Unicode standard In-Reply-To: <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> Message-ID: <4A9D3428.3060504@lonetwin.net> I'm a lurker on this list and am here more to learn rather than teach and although better sense tells me not to feed the troll -- I'll bite. Mainly because, r, unlike XL does seem to offer help every one in a while. So, ... On 08/31/2009 03:58 AM, r wrote: > On Aug 30, 2:05 pm, Paul Boddie wrote: (snip) >> You don't care which language it is as long as it's the one you use. That's >> what this sounds like, layered on top of what you've already written (and >> what you write below). > > I said it before and i will say it again. I DON"T CARE WHAT LANGUAGE WE USE > AS LONG AS IT IS A MODERN LANGUAGE FOUNDED ON IDEALS OF SIMPLICITY!!!! > I think you are confusing simplicity with uniformity. Uniformity is not always good. Sure standardizing on units of measure and airline codes is good, but expecting everyone to speak one language is akin to expecting everyone to wear one type of clothing or expecting everyone to drive just one type of automobile -- those kind of rules works well in a small sets where doing so fulfills a purpose (in the army, hospitals or taxi service, for instance). The problems associated with enforcing uniformity within larger sets are often _less_ _simple_ than finding _solutions_ to deal with _complexity_ (your misplaced philosophical rhetoric about how one-world-one-language-would-usher in-a-golden-age aside -- /that/ you should take up with any person of science and be ready to be laughed at). To put it another way, it is better to create data structures to deal with variable length names rather than mandating that everybody has names < 30 chars. If you fail to understand how that applies to unicode, you sadly will have trouble understanding the existence of not only unicode, but also of TCP/IP, timezones, xml and the whole concept of Interfaces. [...snip...] > Paul: civilizations rise and fall, this is beyond our control. Every great > power will utter fail at some point. Some die out like a slow burning candle, > others go quickly and painfully from defeating blows in war time. This is an > eventuality you must face friend. This whole save the whales BS is really > getting on my nerves! Stop trying to play God Paul, it is not your decision > when and where the blade shall fall. > > When a people stop evolving and no longer have anything productive to give to > evolution, evolution stamps them out. If the Indians had developed gun power > and industrialized America they might be running more than merely a casino. > Oh No! Was that out of line, you will probably think so. > > Stay in know and you shall endure... > This might come as a bit of shock for you, but evolution awards those who are capable of adapting to complexity rather then those who expect things to be uniform. You, dear friend, and those who yearn for uniformity are the ones on the path to extinction. cheers, - steve -- random non tech spiel: http://lonetwin.blogspot.com/ tech randomness: http://lonehacks.blogspot.com/ what i'm stumbling into: http://lonetwin.stumbleupon.com/ From nospam at nowhere.com Tue Sep 1 11:18:09 2009 From: nospam at nowhere.com (markspace) Date: Tue, 01 Sep 2009 08:18:09 -0700 Subject: Ban Xah Lee In-Reply-To: References: <6b854432-7cb9-4eb3-8cf5-3619df2e5ae0@a5g2000pre.googlegroups.com> Message-ID: Gernot Hassenpflug wrote: > > Crap, what the hell are *you* doing here, Arved. This is so frightening! > > LOL > Gernot (shocked to find people have other interests, hehe) Thanks for cross posting this to five different newsgroups. Your garbage is not wanted here, here being clj.programmer. Learn to use you newsreader and check where you posts are going before you send them. Followup's sent to alt.flame. From sraji.me at gmail.com Tue Sep 1 11:22:23 2009 From: sraji.me at gmail.com (Raji Seetharaman) Date: Tue, 1 Sep 2009 20:52:23 +0530 Subject: AttributeError: 'NoneType' object has no attribute 'get_text' Message-ID: <23e3fbb60909010822j32cdc88bodb88ed7c8332dc3a@mail.gmail.com> Hi all, i worked out python and glade example program to add two numbers and display its output from the following link http://www.dreamincode.net/forums/showtopic63885.htm When i run the script, i received the following error python add.py Traceback (most recent call last): File "add.py", line 34, in add thistime = adder( self.wTree.get_widget("entryNumber1").get_text(), self.wTree.get_widget("entryNumber2").get_text()) AttributeError: 'NoneType' object has no attribute 'get_text' What has to be done to overcome this error? Regards Raji. S -------------- next part -------------- An HTML attachment was scrubbed... URL: From phihag at phihag.de Tue Sep 1 11:22:31 2009 From: phihag at phihag.de (Philipp Hagemeister) Date: Tue, 01 Sep 2009 17:22:31 +0200 Subject: Python3: hex() on arbitrary classes Message-ID: <4A9D3C37.3060100@phihag.de> class X(object): def __int__(self): return 42 def __hex__(self): return '2b' #sic hex(X()) What would you expect? Python2 returns '2b', but python 3(74624) throws TypeError: 'X' object cannot be interpreted as an integer. Why doesn't python convert the object to int before constructing the hex string? Regards, Philipp Hagemeister -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 204 bytes Desc: OpenPGP digital signature URL: From upton at virginia.edu Tue Sep 1 11:22:57 2009 From: upton at virginia.edu (Dan Upton) Date: Tue, 1 Sep 2009 08:22:57 -0700 Subject: Logging contents of IRC channel In-Reply-To: <395c130e-3269-453f-b8e5-379aea2de7d8@i18g2000pro.googlegroups.com> References: <395c130e-3269-453f-b8e5-379aea2de7d8@i18g2000pro.googlegroups.com> Message-ID: <5504f9ac0909010822l37ee448fq82ac1a8860028ba9@mail.gmail.com> http://www.irchelp.org/irchelp/rfc/rfc.html describes (more or less) the protocol. It's actually pretty easy to write something which can connect and monitor one or more channels on a server--that's how I learned network programming in Java many moons ago. I'd say look at the RFC and start off logging all of your sent and received messages to the console, so if it hangs you can see what message you've gotten and look up how to respond to it. -dan On Mon, Aug 31, 2009 at 11:56 AM, Jonathan Gardner < jgardner at jonathangardner.net> wrote: > On Aug 31, 10:23 am, devaru wrote: > > I am new to Python. I want to log the activities in an IRC channel. > > Any pointers regarding this would be of great help. > > How are you going to plug into the chat server to obtain the data? > > How will you store the data? > > The in between parts are really easy. > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nitebirdz at sacredchaos.com Tue Sep 1 11:24:07 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Tue, 1 Sep 2009 17:24:07 +0200 Subject: Python word to text In-Reply-To: <4A9D1F9D.1090504@wildenhain.de> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> <20090901114208.GA6989@sevilla.sacredchaos.com> <4A9D1F9D.1090504@wildenhain.de> Message-ID: <20090901152405.GB6989@sevilla.sacredchaos.com> On Tue, Sep 01, 2009 at 03:20:29PM +0200, Tino Wildenhain wrote: >> >> A quick search returned this: >> >> http://code.activestate.com/recipes/279003/ >> >> >> Did you give it a try? > > Thats a funny advice. Did you read that receipe? ;-) > "Requires the Python for Windows extensions, and MS Word." > how does this match with "App Engine doesn't allow external programs"? :-) > Sorry, you're absolutely right. I did notice it required Windows, but didn't see any comments in the original message that this wasn't to be run on Windows. As for the issue regarding external programs, I assumed it only referred to the ones explictly mentioned or similar (catdoc, antiword, etc.). My apologies. From gherron at islandtraining.com Tue Sep 1 11:29:48 2009 From: gherron at islandtraining.com (Gary Herron) Date: Tue, 01 Sep 2009 08:29:48 -0700 Subject: [ANN] Pida 0.6beta3 In-Reply-To: <4A9C63D8.3050809@poelzi.org> References: <4A9C63D8.3050809@poelzi.org> Message-ID: <4A9D3DEC.8090706@islandtraining.com> poelzi wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > We are proud to announce the hopfully last beta of Pida 0.6. [1] > Wouldn't this be a good time to tell us what Pida does? > It was a long time since beta2 and a lot of changes happened since then: > > == Core Highlights == > ? multiprocessing language plugins > Language plugins can now use a multiprocessing infrastructure which > allows expensive operations to be done on other cpu cores. This > increases the speed of plugins like python_lint and python > dramatically and do not make the gui sluggish anymore. > ? project file caches > Projects now have a filecache which allows fast queries to filenames > and filetypes. The QuickOpen plugin provides a gui for this, > allowing the user to open files to which parts of the name, path or > filetype are known > ? very precise feature selection from LanguagePlugins > ? better filemonitor support > ? new documentation (needs some gui work tho) > ? lot of speedups > ? lot of usability enhancements > ? lots and lots of fixes > > == New Plugins == > ? RegexpToolkit - helps you develop and analyze regular expressions > ? QuickOpen - fast file opener for project files > ? WayPoint - autogenerates waypoints when you surf and edit files and > allows to jump back and forth > > > [1] http://pida.co.uk/blog/0.6beta3 > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iQIcBAEBAgAGBQJKnGPYAAoJEFYpgV2Roepc2d4P/3VSMxAd1r3UJNS6p6jpDOLm > bES6zm0RFZmsCYdFab/WEroD24vCgO4jdmgV9woQoobuO1lecTiSGYIpbq3HcXFs > qEhiAD7jo4QdR+6josXe3crUbbUPanH4J3O4+MReOfNR+w/x3w9rT+zVGxwBa7GP > oxiFYWD9BaufHJxqVaAfRN00sGCUGVXVLwdOL2OA3T10F5hNzy9zMTKvUVjWJePG > K7xzuLeDyaxxBoZ54gMT5tg9RnCKnDfStT6qeETvRH/NkxcjFG2HJSoMkD6KtLY4 > MzTJ0YbFvzp9MLxPEY/918frio5bvClRaExBdo6pOsuiIMzRrPudUlAn2fqP6Qkx > BXJRfLoXYEWmpUzzpC2zwik7ZzP2z/AwSDzJZR7ie2yKoVayGApmOeEEcePZMJUI > K2LicEcP7WdVMmzBRQcuW7A6KVlzWhhMsPig+dPiONaXDBeOncy+LXfx/9tqZ1rN > 5GsrYUc94md0I7hhmo/YdYj214FKkerq5gAtwgvQBgqSo+iNL5Pu/tlGPj2b9Ph1 > sZnaA2LfoiEzBIifiAD/rIY8pFcN5jCRTj44ntWWnvGQ+hAQwhjrNehrtdHaQGWD > wpaUy4TB5OlW1FFdp7dwEarTCdUqYRiVAvXrATw2g71WvVaSutEHwpNlnfFeT3tc > 9fLIivMy5nnsK5W/HNf0 > =Ctpz > -----END PGP SIGNATURE----- > From rami.chowdhury at gmail.com Tue Sep 1 11:35:46 2009 From: rami.chowdhury at gmail.com (Rami Chowdhury) Date: Tue, 01 Sep 2009 08:35:46 -0700 Subject: An assessment of the Unicode standard In-Reply-To: <4A9D1ECC.7040903@mrabarnett.plus.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> <33B0AC00-44CA-4EA4-8322-4052E1A41871@gmail.com> <4A9D1ECC.7040903@mrabarnett.plus.com> Message-ID: > SI is preferred, > but Imperial is permitted. IME most people in the UK under the age of 40 can speak SI without trouble. On the other hand, "let's nip down to the pub for 580ml of beer" just doesn't have the right ring to it ;-) On Tue, 01 Sep 2009 06:17:00 -0700, Matthew Barnett wrote: > Kurt Mueller wrote: >> Am 01.09.2009 um 09:39 schrieb Terry Reedy: >> >>>> But this same problem also extends into monies, nation states, units >>>> of measure, etc. >> >>> There is, of course, an international system of measure. The US is the >>> only major holdout. (I recall Burma, or somesuch, is another.) An >>> interesting proposition would be for the US to adopt the metric system >>> in exchange for the rest of the world adopting simplified basic >>> English as a common language. >> The SI-system is nearly universally employed. >> Three principal exceptions are Burma (Myanmar), Liberia, and the United >> States. >> The United Kingdom has officially adopted the International System of >> Units >> but not with the intention of replacing customary measures entirely. >> > The intention in the UK was to switch to SI over a period of 10 years, > starting in 1971, so from then only SI was taught in schools. > > Earlier this year the EU decided that it wouldn't force the UK to > abandon the few remaining uses of the Imperial system; SI is preferred, > but Imperial is permitted. The roads are still Imperial, and milk > delivered to the door can still use the existing pint bottles, but milk > sold in shops is in SI. > >> ------------------------------------------------------------------------ >> When I was a student, they told us, that in a couple of years there >> will be >> the SI-system only, because most countries accepted it in their laws. >> So we should adopt it. >> That was in the early 70ties. >> Only this year we have to deliver results of technical processes to >> british >> and US companies. They still want them in their "crazy outdated" units. >> The other thing would be the US to adopt a "simplified basic English". >> I would not be astonished, that british people would state, >> that they already do :-) >> -- Rami Chowdhury "Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) From no.email at please.post Tue Sep 1 11:58:00 2009 From: no.email at please.post (kj) Date: Tue, 1 Sep 2009 15:58:00 +0000 (UTC) Subject: Q on naming nested packages/modules Message-ID: I'm having a hard time getting the hang of Python's package/module scheme. I'd like to find out what's considered best practice when dealing with the scenario illustrated below. The quick description of the problem is: how can I have two nested modules, spam.ham and spam.ham.eggs? Suppose I have a module (I'm not even sure this is the right word) called spam.ham, so I start out with the following file structure: spam/ |-- ham.py `-- __init__.py With this arrangement, the line import spam.ham ...in client code works as expected. But now suppose that I want to factor out some code in spam/ham.py to a helper module. (The reason behind factoring out this new module is to "declutter" spam/ham.py, and improve its readibility.) My instinct (from my Perl past) is to put this factored-out code in a file spam/ham/eggs.py, i.e. to create the "nested" module spam.ham.eggs, which requires expanding the tree as follows spam/ |-- ham/ | |-- eggs.py | `-- __init__.py |-- ham.py `-- __init__.py ...and adding the following spam/ham.py to # spam/ham.py from . import eggs This doesn't work so well, because now spam/ham.py is not read. It seems that adding the spam/ham directory, or maybe adding the file spam/ham/__init__.py, causes spam/ham.py to be overlooked. Clearly, I'm not playing this game right... What is considered "best practice" for the use case sketched above? Should I, e.g. rename the directory spam/ham something like spam/ham_ and refer to the helper module as spam.ham_.eggs? Or is some other convention preferred? I consulted PEP 8, but besides recommending "short, all-lowercase names" for modules, it gives little guidance on the situation described above. TIA! kynn From dullrich at sprynet.com Tue Sep 1 12:00:11 2009 From: dullrich at sprynet.com (David C. Ullrich) Date: Tue, 01 Sep 2009 11:00:11 -0500 Subject: Permanently adding to the Python path in Ubuntu References: Message-ID: When I wanted to set PYTHONPATH I had the advantage of knowing nothing about how Linux/Ubuntu was supposed to work, so I tried everything. ~/.profile worked for me. In article , Chris Colbert wrote: > I'm having an issue with sys.path on Ubuntu. I want some of my home > built packages to overshadow the system packages. Namely, I have built > numpy 1.3.0 from source with atlas support, and I need it to > overshadow the system numpy 1.2.1 which I had to drag along as a > dependency for other stuff. I have numpy 1.3.0 installed into > /usr/local/lib/python2.6/dist-packages/. The issue is that this > directory is added to the path after the > /usr/lib/python2.6/dist-packages/ is added, so python doesnt see my > version of numpy. > > I have been combating this with a line in my .bashrc file: > > export PYTHONPATH=/usr/local/lib/python2.6/dist-packages > > So when I start python from the shell, everything works fine. > > Problems show up when python is not executed from the shell, and thus > the path variable is never exported. This can occur when I have > launcher in the gnome panel or i'm executing from within wing-ide. > > Is there a way to fix this so that the local dist-packages is added to > sys.path before the system directory ALWAYS? I can do this by editing > site.py but I think it's kind of bad form to do it this way. I feel > there has to be a way to do this without root privileges. > > Any ideas? > > Cheers, > > Chris -- David C. Ullrich From apt.shansen at gmail.com Tue Sep 1 12:19:16 2009 From: apt.shansen at gmail.com (Stephen Hansen) Date: Tue, 1 Sep 2009 09:19:16 -0700 Subject: Python3: hex() on arbitrary classes In-Reply-To: <4A9D3C37.3060100@phihag.de> References: <4A9D3C37.3060100@phihag.de> Message-ID: <7a9c25c20909010919u6b123062pc3c77da7bd6c10d9@mail.gmail.com> On Tue, Sep 1, 2009 at 8:22 AM, Philipp Hagemeister wrote: > class X(object): > def __int__(self): return 42 > def __hex__(self): return '2b' #sic > > hex(X()) > > > What would you expect? Python2 returns '2b', but python 3(74624) throws > TypeError: 'X' object cannot be interpreted as an integer. Why doesn't > python convert the object to int before constructing the hex string? > The __oct__ and __hex__ special methods were removed in 3.0; instead, it converts the value returned by __index__ in the appropriate base. >>> class X: def __index__(self): return 42 >>> hex(X()) '0x2a' The difference between __int__ and __index__ is that the former (when called by int()) can convert a wide range of objects into an integer even if they really /aren't/ -- like floats. There's some numbers you want to be able to treat as int's sometimes, and those objects should define __int__... there's other numbers which you really want to say, 'I _am_ an integer', those should define __index__. Anything which defines __index__ can be used in slicing. At least that's my understanding. It's probably only half-right / flawed, but :) The one part I'm sure of is in Python 3, there's no methods to explicitly convert to a non-decimal base-- you define __index__ to return the integer value and hex()/oct()/int(X,) convert it to the appropriate base. HTH, --S -------------- next part -------------- An HTML attachment was scrubbed... URL: From dickinsm at gmail.com Tue Sep 1 12:21:45 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Tue, 1 Sep 2009 09:21:45 -0700 (PDT) Subject: Python3: hex() on arbitrary classes References: Message-ID: On Sep 1, 4:22?pm, Philipp Hagemeister wrote: > class X(object): > ? ? def __int__(self): return 42 > ? ? def __hex__(self): return '2b' #sic > > hex(X()) > > What would you expect? Python2 returns '2b', but python 3(74624) throws > TypeError: 'X' object cannot be interpreted as an integer. Why doesn't > python convert the object to int before constructing the hex string? __hex__ is no longer a magic method in Python 3. If you want to be able to interpret instances of X as integers in the various Python contexts that expect integers (e.g., hex(), but also things like list indexing), you should implement the __index__ method: Python 3.2a0 (py3k:74624, Sep 1 2009, 16:53:00) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class X: ... def __index__(self): return 3 ... >>> hex(X()) '0x3' >>> range(10)[X()] 3 >>> 'abc' * X() 'abcabcabc' -- Mark From python at mrabarnett.plus.com Tue Sep 1 12:28:09 2009 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Sep 2009 17:28:09 +0100 Subject: AttributeError: 'NoneType' object has no attribute 'get_text' In-Reply-To: <23e3fbb60909010822j32cdc88bodb88ed7c8332dc3a@mail.gmail.com> References: <23e3fbb60909010822j32cdc88bodb88ed7c8332dc3a@mail.gmail.com> Message-ID: <4A9D4B99.6030904@mrabarnett.plus.com> Raji Seetharaman wrote: > Hi all, i worked out python and glade example program to add two numbers > and display its output from the following link > http://www.dreamincode.net/forums/showtopic63885.htm > When i run the script, i received the following error > > python add.py > Traceback (most recent call last): > File "add.py", line 34, in add > thistime = adder( self.wTree.get_widget("entryNumber1").get_text(), > self.wTree.get_widget("entryNumber2").get_text()) > AttributeError: 'NoneType' object has no attribute 'get_text' > > What has to be done to overcome this error? > I think you need to name the text entry fields "entryNumber1" and "entryNumber2". From phihag at phihag.de Tue Sep 1 12:31:41 2009 From: phihag at phihag.de (Philipp Hagemeister) Date: Tue, 01 Sep 2009 18:31:41 +0200 Subject: Python3: hex() on arbitrary classes In-Reply-To: References: Message-ID: <4A9D4C6D.4010106@phihag.de> Mark Dickinson wrote: > (...) If you want to be > able to interpret instances of X as integers in the various Python > contexts that expect integers (e.g., hex(), but also things like list > indexing), you should implement the __index__ method: Thanks. Somehow forgot this magic method and deleted it by accident. Philipp > > Python 3.2a0 (py3k:74624, Sep 1 2009, 16:53:00) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> class X: > ... def __index__(self): return 3 > ... >>>> hex(X()) > '0x3' >>>> range(10)[X()] > 3 >>>> 'abc' * X() > 'abcabcabc' > > -- > Mark -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 204 bytes Desc: OpenPGP digital signature URL: From benjamin.kaplan at case.edu Tue Sep 1 12:42:51 2009 From: benjamin.kaplan at case.edu (Benjamin Kaplan) Date: Tue, 1 Sep 2009 12:42:51 -0400 Subject: Q on naming nested packages/modules In-Reply-To: References: Message-ID: On Tue, Sep 1, 2009 at 11:58 AM, kj wrote: > > > > I'm having a hard time getting the hang of Python's package/module > scheme. ?I'd like to find out what's considered best practice when > dealing with the scenario illustrated below. > > The quick description of the problem is: how can I have two nested > modules, spam.ham and spam.ham.eggs? > > Suppose I have a module (I'm not even sure this is the right word) > called spam.ham, so I start out with the following file structure: > > ?spam/ > ?|-- ham.py > ?`-- __init__.py > > With this arrangement, the line > > import spam.ham > > ...in client code works as expected. > > But now suppose that I want to factor out some code in spam/ham.py > to a helper module. ?(The reason behind factoring out this new > module is to "declutter" spam/ham.py, and improve its readibility.) > My instinct (from my Perl past) is to put this factored-out code > in a file spam/ham/eggs.py, i.e. to create the "nested" module > spam.ham.eggs, which requires expanding the tree as follows > > ?spam/ > ?|-- ham/ > ?| ? |-- eggs.py > ?| ? `-- __init__.py > ?|-- ham.py > ?`-- __init__.py > > ...and adding the following spam/ham.py to > > # spam/ham.py > from . import eggs > > This doesn't work so well, because now spam/ham.py is not read. > It seems that adding the spam/ham directory, or maybe adding the > file spam/ham/__init__.py, causes spam/ham.py to be overlooked. > > > Clearly, I'm not playing this game right... > > What is considered "best practice" for the use case sketched above? > Should I, e.g. rename the directory spam/ham something like spam/ham_ > and refer to the helper module as spam.ham_.eggs? ?Or is some other > convention preferred? > > I consulted PEP 8, but besides recommending "short, all-lowercase > names" for modules, it gives little guidance on the situation > described above. > Take everything in ham.py and stick it in ham/__init__.py instead. This will give you the behavior you're looking for (don't import spam.ham.__init__. Everything in __init__.py is loaded into spam.ham) > TIA! > > kynn > -- > http://mail.python.org/mailman/listinfo/python-list > From no.email at please.post Tue Sep 1 12:53:08 2009 From: no.email at please.post (kj) Date: Tue, 1 Sep 2009 16:53:08 +0000 (UTC) Subject: Q on naming nested packages/modules References: Message-ID: In kj writes: >I'm having a hard time getting the hang of Python's package/module >scheme. I'd like to find out what's considered best practice when >dealing with the scenario illustrated below. >The quick description of the problem is: how can I have two nested >modules, spam.ham and spam.ham.eggs? Following up my own post... >From inspecting the directory structure of some of the standard Python modules I infer the following rules: 1. the source for "leaf" modules lives in files named after them (e.g. if x.y.z is a "leaf" module, its source code is in x/y/z.py) 2. the source for "non-leaf" modules lives in files named __init__.py (e.g. if x.y is a "non-leaf" module, its source code lives in the file x/y/__init__.py) In the examples above, the module x.y is a "non-leaf" module because there is a module x.y.z. I.e. the "leaf"-ness of a module depends solely on whether other modules deeper in the hierarchy are present. An implication of all this is that if now I wanted to create a new module x.y.z.w, this means that the previously "leaf"-module x.y.z would become "non-leaf". In other words, I'd have to: 1. create the new directory x/y/z 2. *rename* the file x/y/z.py to x/y/z/__init__.py 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w module Is the above correct? (BTW, to my Perl-pickled brain, step 2 above is the one that causes most distress... But I think I can cope.) kynn From pavlovevidence at gmail.com Tue Sep 1 13:11:34 2009 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 1 Sep 2009 10:11:34 -0700 (PDT) Subject: Q on naming nested packages/modules References: Message-ID: <1bf90898-bd48-47bc-a02b-3284e4e07923@d23g2000vbm.googlegroups.com> On Sep 1, 8:58?am, kj wrote: > I'm having a hard time getting the hang of Python's package/module > scheme. ?I'd like to find out what's considered best practice when > dealing with the scenario illustrated below. > > The quick description of the problem is: how can I have two nested > modules, spam.ham and spam.ham.eggs? > > Suppose I have a module (I'm not even sure this is the right word) > called spam.ham, so I start out with the following file structure: > > ? spam/ > ? |-- ham.py > ? `-- __init__.py > > With this arrangement, the line > > import spam.ham > > ...in client code works as expected. > > But now suppose that I want to factor out some code in spam/ham.py > to a helper module. ?(The reason behind factoring out this new > module is to "declutter" spam/ham.py, and improve its readibility.) > My instinct (from my Perl past) is to put this factored-out code > in a file spam/ham/eggs.py, i.e. to create the "nested" module > spam.ham.eggs, which requires expanding the tree as follows > > ? spam/ > ? |-- ham/ > ? | ? |-- eggs.py > ? | ? `-- __init__.py > ? |-- ham.py > ? `-- __init__.py > > ...and adding the following spam/ham.py to > > # spam/ham.py > from . import eggs > > This doesn't work so well, because now spam/ham.py is not read. > It seems that adding the spam/ham directory, or maybe adding the > file spam/ham/__init__.py, causes spam/ham.py to be overlooked. There's a hint here. You can move the contents of ham.py into ham/__init__.py, and it'll work the way you want, maybe with only a minor change or two. > Clearly, I'm not playing this game right... > > What is considered "best practice" for the use case sketched above? > Should I, e.g. rename the directory spam/ham something like spam/ham_ > and refer to the helper module as spam.ham_.eggs? ?Or is some other > convention preferred? The way you were intending is often the approach people use. I doubt there are any detailed consensus recommendations about this in the Python community. > I consulted PEP 8, but besides recommending "short, all-lowercase > names" for modules, it gives little guidance on the situation > described above. Of course it doesn't, PEP 8 is a style guide, not a project organization guide. Carl Banks From ethan at stoneleaf.us Tue Sep 1 13:14:15 2009 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 01 Sep 2009 10:14:15 -0700 Subject: Q on naming nested packages/modules In-Reply-To: References: Message-ID: <4A9D5667.6020009@stoneleaf.us> kj wrote: > In kj writes: > > >>I'm having a hard time getting the hang of Python's package/module >>scheme. I'd like to find out what's considered best practice when >>dealing with the scenario illustrated below. > > >>The quick description of the problem is: how can I have two nested >>modules, spam.ham and spam.ham.eggs? > > > Following up my own post... > >>From inspecting the directory structure of some of the standard > Python modules I infer the following rules: > > 1. the source for "leaf" modules lives in files named after them > (e.g. if x.y.z is a "leaf" module, its source code is in x/y/z.py) > > 2. the source for "non-leaf" modules lives in files named __init__.py > (e.g. if x.y is a "non-leaf" module, its source code lives in > the file x/y/__init__.py) > > In the examples above, the module x.y is a "non-leaf" module because > there is a module x.y.z. > > I.e. the "leaf"-ness of a module depends solely on whether other > modules deeper in the hierarchy are present. > > An implication of all this is that if now I wanted to create a new > module x.y.z.w, this means that the previously "leaf"-module x.y.z > would become "non-leaf". In other words, I'd have to: > > 1. create the new directory x/y/z > 2. *rename* the file x/y/z.py to x/y/z/__init__.py > 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w > module > > Is the above correct? (BTW, to my Perl-pickled brain, step 2 above > is the one that causes most distress... But I think I can cope.) > > kynn Looking at the layout of the (most excellent!-) xlrd package, the bulk of the code is in the __init__.py file, and other supporting code is the same directory, accessed in __init__ with normal imports. I also am unclear on when it's best to have supporting files in the same directory versus a subdirectory... perhaps it is that flat is better than nested? ~Ethan~ From schettino72 at gmail.com Tue Sep 1 13:23:09 2009 From: schettino72 at gmail.com (schettino72) Date: Tue, 1 Sep 2009 10:23:09 -0700 (PDT) Subject: [ANN] doit: bringing the power of build-tools to execute any kind of task Message-ID: doit 0.3 released! doit comes from the idea of bringing the power of build-tools to execute any kind of task. It will keep track of dependencies between "tasks" and execute them only when necessary. It was designed to be easy to use and "get out of your way". http://pypi.python.org/pypi/doit/0.3.0 http://python-doit.sourceforge.net/ From piet at cs.uu.nl Tue Sep 1 13:40:38 2009 From: piet at cs.uu.nl (Piet van Oostrum) Date: Tue, 01 Sep 2009 19:40:38 +0200 Subject: Is behavior of += intentional for int? References: Message-ID: >>>>> zaur (z) wrote: >z> On 29 ???, 16:45, zaur wrote: >>> Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) >>> [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin >>> Type "copyright", "credits" or "license()" for more information.>>> a=1 >>> >>> x=[a] >>> >>> id(a)==id(x[0]) >>> True >>> >>> a+=1 >>> >>> a >>> 2 >>> >>> x[0] >>> >>> 1 >>> >>> I thought that += should only change the value of the int object. But >>> += create new. >>> Is this intentional? >z> As a result of this debate is not whether we should conclude that >z> there should be two types of integers in python: 1) immutable numbers, >z> which behave as constant value; 2) mutable numbers, which behave as >z> variable value? Numbers are immutable by nature (math). The number 3.14 remains 3.14 whatever you try to do with it. What you call an immutable number is in fact a container that contains a number. You can change the contents of the container, not by modifying the number in it but by replacing it with a different number. Python has sufficient mechanisms for creating these containers: lists, dictionaries, objects. If you think they are not good enough then write a new one in C. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: piet at vanoostrum.org From bjourne at gmail.com Tue Sep 1 13:42:13 2009 From: bjourne at gmail.com (=?ISO-8859-1?Q?BJ=F6rn_Lindqvist?=) Date: Tue, 1 Sep 2009 19:42:13 +0200 Subject: Python word to text In-Reply-To: <4A9D1F9D.1090504@wildenhain.de> References: <740c3aec0909010238j124ade24i4b2830ea414b29ae@mail.gmail.com> <20090901114208.GA6989@sevilla.sacredchaos.com> <4A9D1F9D.1090504@wildenhain.de> Message-ID: <740c3aec0909011042u15afaa4ds498f34af0a147e37@mail.gmail.com> 2009/9/1 Tino Wildenhain : > Am 01.09.2009 13:42, schrieb Nitebirdz: >> >> On Tue, Sep 01, 2009 at 11:38:30AM +0200, BJ?rn Lindqvist wrote: >>> >>> Hello everybody, >>> >>> I'm looking for a pure Python solution for converting word documents >>> to text. App Engine doesn't allow external programs, which means that >>> external programs like catdoc and antiword can't be used. Anyone know >>> of any? >>> >> >> A quick search returned this: >> >> http://code.activestate.com/recipes/279003/ >> >> >> Did you give it a try? > > Thats a funny advice. Did you read that receipe? ;-) > "Requires the Python for Windows extensions, and MS Word." > how does this match with "App Engine doesn't allow external programs"? :-) > > For excel this would be easy but word - Bj?rn, did you check google api > if you would be able to access google docs for this? I did not, thanks for the tip! The system I managed to hack together uploads the .doc to a google docs account and then retrieves it again as plain text. It works but sure feels kind of silly. It's not very reliable because if google has some kind of problem with their docs application it doesn't work at all. Plus the method is dirt slow due to the latency of all the http calls. But better than nothing. -- mvh Bj?rn From montaseri at gmail.com Tue Sep 1 13:42:56 2009 From: montaseri at gmail.com (Medi) Date: Tue, 1 Sep 2009 10:42:56 -0700 (PDT) Subject: Seeking a python code browser Message-ID: <258dd816-e513-4ef5-b0d7-1f8b98fa4d4b@o9g2000prg.googlegroups.com> Is there any recommendation for a python code browser (aka xref) tool. I am a Source Navigator user, but seems like its python support is flaky. Unless you can help me with that...which is my preferred way. Thanks Medi From tim.arnold at sas.com Tue Sep 1 13:53:10 2009 From: tim.arnold at sas.com (Tim Arnold) Date: Tue, 1 Sep 2009 13:53:10 -0400 Subject: using queue Message-ID: Hi, I've been using the threading module with each thread as a key in a dictionary. I've been reading about Queues though and it looks like that's what I should be using instead. Just checking here to see if I'm on the right path. The code I have currently compiles a bunch of chapters in a book (no more than 80 jobs at a time) and just waits for them all to finish: max_running = 80 threads = dict() current = 1 chaps = [x.config['name'] for x in self.document.chapter_objects] while current <= len(chaps): running = len([x for x in threads.keys() if threads[x].isAlive()]) if running == max_running: time.sleep(10) else: chap = chaps[current - 1] c = self.compiler(self.document.config['name'], chap) threads[chap] = threading.Thread(target=c.compile) threads[chap].start() current += 1 for thread in threads.keys(): threads[thread].join(3600.0) --------------------------------- but I think Queue could do a lot of the above work for me. Here is pseudocode for what I'm thinking: q = Queue(maxsize=80) for chap in [x.config['name'] for x in self.document.chapter_objects]: c = self.compiler(self.document.config['name'], chap) t = threading.Thread(target=c.compile) t.start() q.put(t) q.join() is that the right idea? thanks, --Tim Arnold From rylesny at gmail.com Tue Sep 1 14:22:16 2009 From: rylesny at gmail.com (ryles) Date: Tue, 1 Sep 2009 11:22:16 -0700 (PDT) Subject: executable path finding References: <9d71d0bd-5109-45b6-bce7-114607386063@y10g2000prf.googlegroups.com> <7g2apoF2nipofU2@mid.uni-berlin.de> <40dd30b5-c65c-4fb2-9a3a-c9264f333018@m7g2000prd.googlegroups.com> Message-ID: <217c8605-a9ab-45a4-aeb6-dd081ca38271@y20g2000vbk.googlegroups.com> On Aug 31, 12:37?pm, koranthala wrote: > On Aug 31, 9:07?pm, "Diez B. Roggisch" wrote: > > > > > koranthala wrote: > > > Hi, > > > ? ? I am creating a python application using py2exe. I am facing a > > > problem which I am not sure how to solve. > > > ? ? The application contains many other files associated with it - > > > like icons, config files etc. The executable can be in any directory. > > > If the user creates a shortcut to the executable to run in desktop, > > > the program fails - saying that the icon image cannot be found. But I > > > can run the application properly, if I run it from application > > > directory - where all the other icons, config files etc are kept. > > > ? ? How is such issues usually solved? I do not want to hardcode the > > > paths of icons and store the icons in those paths. I guess, we can > > > change the directory to the application directory before running the > > > application. (in __init__.py ???) But how do we find the current > > > directory in that case? I am completely at sea in solving this. > > > ? ? This looks to be a very common issue. How is this usually solved? > > > You can get the location of a module via > > > ?module.__file__ > > > This can be used to find a file relative to e.g. the toplevel module/package > > of your application. > > > The pkg_resources-module of setuptools encapsulates that even into a stream > > and file-name api. > > > Diez > > Thank you Diez. It was what I was looking for. Also see: http://docs.python.org/library/pkgutil.html From martin at v.loewis.de Tue Sep 1 14:23:22 2009 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 01 Sep 2009 20:23:22 +0200 Subject: Python community buildbot page still 503 In-Reply-To: References: Message-ID: <4A9D669A.8000105@v.loewis.de> > If I am not mistaken http://python.org/dev/buildbot/community/all/ has > been down since python.org had its harddrive issues. > > Anyone know a time line on getting it back up and running. This service is, unfortunately, unmaintained. It broke when I upgraded the buildbot master to a new code base, and nobody upgraded the buildbot configuration file. So I have now removed it from the web server configuration, and put a notice on the web site. Regards, Martin From victorsubervi at gmail.com Tue Sep 1 14:45:39 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Tue, 1 Sep 2009 13:45:39 -0500 Subject: Try Except Problem Message-ID: <4dc0cfea0909011145s261c057di2f445c8473acf1ad@mail.gmail.com> Hi: I have this code: try: cursor.execute('select salesperson, office, cell, fax, home, email, assistant from general where salesperson="%s";' % (catch)) stuff = cursor.fetchone() test = raw_input('You have selected salesperson %s. Is that correct? (hit \'enter\' for affirmative, enter anything else for negative): ' % (catch)) if len(test) == 0: salesperson, office, cell, fax, home, email, assistant = new[i][0], new[i][1], new[i][2], new[i][3], new[i][4], new[i][5], new[i][6] print 'one' except: print 'two' salesperson = raw_input('Please enter the sales person\'s name: ') office = raw_input('Please enter the sales person\'s office number: ') cell = raw_input('Please enter the sales person\'s cell number: ') fax = raw_input('Please enter the sales person\'s fax number: ') home = raw_input('Please enter the sales person\'s home number: ') email = raw_input('Please enter the sales person\'s email address: ') assistant = raw_input('Please enter the name of the sales person\'s assistant: ') Now, both "one" and "two" get printed! So it's running the try AND the except!! Why??? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From 71david at libero.it Tue Sep 1 14:48:19 2009 From: 71david at libero.it (David) Date: Tue, 1 Sep 2009 20:48:19 +0200 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> Message-ID: <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> Il Tue, 1 Sep 2009 11:50:14 +0200, Andre Engels ha scritto: > What about mailing lists? There exist well-functioning mailing lists > with thousands of subscribers. Being a posting member of those will > significantly increase your internet bill under your proposal. It's an implementation issue, it doesn't touch the sense of proposal. One possibility is register the mail list to official registers and mail from a subscriber to other subscribers will be excluded from taxation or will have a lower tax rate. An excessive mailing from a single or few subscribers can be easily detected, traced, filtered and, if the case, prosecuted. D. From hyugaricdeau at gmail.com Tue Sep 1 14:52:50 2009 From: hyugaricdeau at gmail.com (Hyuga) Date: Tue, 1 Sep 2009 11:52:50 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> Message-ID: <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> On Aug 29, 8:20?pm, John Machin wrote: > On Aug 30, 8:46?am, r wrote: > > > > > Take for instance the Chinese language with it's thousands of > > characters and BS, it's more of an art than a language. ?Why do we > > need such complicated languages in this day and time. Many languages > > have been perfected, (although not perfect) far beyond that of Chinese > > language. > > The Chinese language is more widely spoken than English, is quite > capable of expression in ASCII ("r tongzhi shi sha gua") and doesn't > have those pesky it's/its problems. > > > The A-Z char set is flawless! > > ... for expressing the sounds of a very limited number of languages, > and English is *NOT* one of those. I'd say don't feel the troll, but too late for that I guess. I just wanted to add, in defense of the Chinese written language (in case this hasn't already been added--I'm probably not going to bother reading this entire thread) that I think it would make a fairly good candidate for use at least as a universal *written* language. Particularly simplified Chinese since, well, it's simpler. The advantages are that the grammar is relatively simple, and it can be used to illustrate concepts independently of the writer's spoken language. Sure it's tied somewhat to the Chinese language, but it can certainly be mapped more easily to any other language than phonetically-based written language. From tjreedy at udel.edu Tue Sep 1 15:05:35 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 15:05:35 -0400 Subject: Q on naming nested packages/modules In-Reply-To: References: Message-ID: kj wrote: > > > But now suppose that I want to factor out some code in spam/ham.py > to a helper module. (The reason behind factoring out this new > module is to "declutter" spam/ham.py, and improve its readibility.) > My instinct (from my Perl past) is to put this factored-out code > in a file spam/ham/eggs.py, i.e. to create the "nested" module > spam.ham.eggs, which requires expanding the tree as follows > > spam/ > |-- ham/ > | |-- eggs.py > | `-- __init__.py > |-- ham.py > `-- __init__.py > > ...and adding the following spam/ham.py to > > # spam/ham.py > from . import eggs > > This doesn't work so well, because now spam/ham.py is not read. > It seems that adding the spam/ham directory, or maybe adding the > file spam/ham/__init__.py, causes spam/ham.py to be overlooked. > > > Clearly, I'm not playing this game right... One way is the __init__.py answer you have already. Another is to put eggs.py (or _eggs.py to indicate that it is private) in spam and skip the ham directory. spam/ __init__.py ham.py _eggs.py tjr From info at egenix.com Tue Sep 1 15:10:45 2009 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Tue, 01 Sep 2009 21:10:45 +0200 Subject: ANN: eGenix mxODBC - Python ODBC Database Interface 3.0.3 Message-ID: <4A9D71B5.3010705@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mxODBC - Python ODBC Database Interface Version 3.0.3 mxODBC is our commercially supported Python extension providing ODBC database connectivity to Python applications on Windows and Unix platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-3.0.3-GA.html ________________________________________________________________________ INTRODUCTION mxODBC provides an easy-to-use, high-performance, reliable and robust Python interface to ODBC compatible databases such as MS SQL Server, MS Access, Oracle Database, IBM DB2 and Informix , Sybase ASE and Sybase Anywhere, MySQL, PostgreSQL, SAP MaxDB and many more. The "eGenix mxODBC - Python ODBC Database Interface" product is a commercial extension to our open-source eGenix mx Base Distribution. * About Python (http://www.python.org/): Python is an object-oriented Open Source programming language which runs on all modern platforms. By integrating ease-of-use, clarity in coding, enterprise application connectivity and rapid application design, Python establishes an ideal programming platform for today's IT challenges. * About eGenix (http://www.egenix.com/): eGenix is a software project, consulting and product company focusing on expert services and professional quality products for companies, Python users and developers. ________________________________________________________________________ NEWS mxODBC 3.0.3 is a patch-level release and includes the following updates: * Python 2.3 - 2.6 support: mxODBC 3.0 is available for Python 2.3, 2.4, 2.5 and 2.6. We ship binaries for Windows, Linux, Mac OS X, AIX, Solaris, and offer custom porting services for most other platforms. * Enhanced support for using cursors as iterators: mxODBC cursor objects can now be used as iterators to iterate over result sets. While this was already possible in previous versions using wrappers, we have now added direct iterator support to the cursor objects themselves. * Updated work-arounds for various ODBC drivers: eGenix always aims to make using mxODBC as easy and robust as possible. For this reason, we regularly add or update work-arounds for problems found in recent ODBC driver versions. This release includes new work-arounds for the MySQL ODBC driver running on 64-bit Linux, the SQL Server 200 ODBC driver and the FileMaker ODBC driver. For the full set of changes please check the mxODBC change log: http://www.egenix.com/products/python/mxODBC/changelog.html For the full set of features mxODBC has to offer, please see: http://www.egenix.com/products/python/mxODBC/#Features ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the package can be found at: http://www.egenix.com/products/python/mxODBC/ In order to use the eGenix mxODBC package you will first need to install the eGenix mx Base package: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ UPGRADING You are encouraged to upgrade to this latest mxODBC release, especially if you are using MS SQL Server or Informix as database server. Customers who have purchased mxODBC 3.0 licenses can download and install this patch-level release on top of their existing installations. The licenses will continue to work with version 3.0.2. Users of mxODBC 2.0 will have to purchase new licenses from our online shop in order to upgrade to mxODBC 3.0.2. You can request 30-day evaluation licenses by visiting our web-site at http://www.egenix.com/products/python/mxODBC/#Evaluation or writing to sales at egenix.com, stating your name (or the name of the company) and the number of eval licenses that you need. _______________________________________________________________________ SUPPORT Commercial support for this product is available from eGenix.com. Please see http://www.egenix.com/services/support/ for details about our support offerings. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Sep 01 2009) >>> Python/Zope Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ ::: Try our new mxODBC.Connect Python Database Interface for free ! :::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ From ajoys123 at gmail.com Tue Sep 1 15:13:45 2009 From: ajoys123 at gmail.com (devaru) Date: Tue, 1 Sep 2009 12:13:45 -0700 (PDT) Subject: Logging contents of IRC channel References: Message-ID: On Sep 1, 9:56?am, alex23 wrote: > On Sep 1, 3:23?am, devaru wrote: > > > I am new to Python. I want to log the activities in an IRC channel. > > Any pointers regarding this would be of great help. > > It would help us if you could explain why the answers weren't suitable > that you were given when you first[1] asked this question... > > [1]:http://groups.google.com/group/comp.lang.python/browse_frm/thread/448... _____________________________________________________________________________ @Paul Rubin: This is small experimental project and I assure you that i will not invade anyone's privacy. @alex23: My bad, I didn't check the solutions that were provided in the earlier thread (http://groups.google.com/group/comp.lang.python/ browse_frm/thread/448c0b476047f898). I'll be trying out the solutions and let this community know. Right now I'm using irclib.py. @Jonathan Gardner: I would be connecting to an IRC channel through a bot. Storing data would not be problem. I'll either store it in a file or in database. Thanks everyone for the reply :-). From rt8396 at gmail.com Tue Sep 1 15:16:03 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 12:16:03 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> Message-ID: <4d84aaa7-5b8f-4e21-962e-75df48b20af1@q35g2000vbi.googlegroups.com> On Sep 1, 2:39?am, Terry Reedy wrote: (snip) > There is, of course, an international system of measure. The US is the > only major holdout. (I recall Burma, or somesuch, is another.) An > interesting proposition would be for the US to adopt the metric system > in exchange for the rest of the world adopting simplified basic English > as a common language. Bring on the metric system Terry, i have been waiting all my life!! Now, if we can only convince those 800 million Mandarin Chinese speakers... *ahem* Do we have a Chinese translator in the house? :-) From exarkun at twistedmatrix.com Tue Sep 1 15:16:36 2009 From: exarkun at twistedmatrix.com (exarkun at twistedmatrix.com) Date: Tue, 01 Sep 2009 19:16:36 -0000 Subject: Python community buildbot page still 503 In-Reply-To: <4A9D669A.8000105@v.loewis.de> References: <4A9D669A.8000105@v.loewis.de> Message-ID: <20090901191636.7436.1088747589.divmod.xquotient.117@localhost.localdomain> On 06:23 pm, martin at v.loewis.de wrote: >>If I am not mistaken http://python.org/dev/buildbot/community/all/ has >>been down since python.org had its harddrive issues. >> >>Anyone know a time line on getting it back up and running. > >This service is, unfortunately, unmaintained. It broke when I upgraded >the buildbot master to a new code base, and nobody upgraded the >buildbot >configuration file. > >So I have now removed it from the web server configuration, and put a >notice on the web site. Um. Where should I have been watching to get some warning about this? And now that I know, can you tell me what I need to do to restore it? Jean-Paul From rami.chowdhury at gmail.com Tue Sep 1 15:21:05 2009 From: rami.chowdhury at gmail.com (Rami Chowdhury) Date: Tue, 01 Sep 2009 12:21:05 -0700 Subject: Q on naming nested packages/modules In-Reply-To: References: Message-ID: > An implication of all this is that if now I wanted to create a new > module x.y.z.w, this means that the previously "leaf"-module x.y.z > would become "non-leaf". In other words, I'd have to: > > 1. create the new directory x/y/z > 2. *rename* the file x/y/z.py to x/y/z/__init__.py > 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w > module With regard to point 2 -- would it be possible to just move z.py into x/y/z, and put 'from z import *' into x/y/z/__init__.py, for the same effect? Or is that not a good idea? On Tue, 01 Sep 2009 09:53:08 -0700, kj wrote: > In kj writes: > >> I'm having a hard time getting the hang of Python's package/module >> scheme. I'd like to find out what's considered best practice when >> dealing with the scenario illustrated below. > >> The quick description of the problem is: how can I have two nested >> modules, spam.ham and spam.ham.eggs? > > Following up my own post... > >> From inspecting the directory structure of some of the standard > Python modules I infer the following rules: > > 1. the source for "leaf" modules lives in files named after them > (e.g. if x.y.z is a "leaf" module, its source code is in x/y/z.py) > > 2. the source for "non-leaf" modules lives in files named __init__.py > (e.g. if x.y is a "non-leaf" module, its source code lives in > the file x/y/__init__.py) > > In the examples above, the module x.y is a "non-leaf" module because > there is a module x.y.z. > > I.e. the "leaf"-ness of a module depends solely on whether other > modules deeper in the hierarchy are present. > > An implication of all this is that if now I wanted to create a new > module x.y.z.w, this means that the previously "leaf"-module x.y.z > would become "non-leaf". In other words, I'd have to: > > 1. create the new directory x/y/z > 2. *rename* the file x/y/z.py to x/y/z/__init__.py > 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w > module > > Is the above correct? (BTW, to my Perl-pickled brain, step 2 above > is the one that causes most distress... But I think I can cope.) > > kynn -- Rami Chowdhury "Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) From tjreedy at udel.edu Tue Sep 1 15:21:05 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 15:21:05 -0400 Subject: copy object? In-Reply-To: <2a189c23-9c8e-4388-9b93-986a0a388d57@g23g2000vbr.googlegroups.com> References: <2a189c23-9c8e-4388-9b93-986a0a388d57@g23g2000vbr.googlegroups.com> Message-ID: lallous wrote: > Hello > > I am new to python and have some questions. > > How to copy objects using another method than this: > > class op: > def __init__(self, op): What do you expect op to be? Certainly not the class 'op'. > for x in dir(op): > if x[:2] == "__": > continue > setattr(self, x, getattr(op, x)) > > o = op(src) > > I tried to copy with "o = copy.copy(src)" but as soon as "src" is > gone, "o"'s attributes are not correct, and I cannot use copy.deepcopy > () because of this error: > TypeError: object.__new__(SwigPyObject) is not safe, use > SwigPyObject.__new__() > > Can the previous for loop be simplified and replaced with a map() and > a lambda function? If you want the instance to be a copy of another instance, the easier place to make the copy would be in the __new__ method, where you might be able to use copy.copy. tjr From rt8396 at gmail.com Tue Sep 1 15:39:43 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 12:39:43 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> Message-ID: <8f487fc8-93c0-4c32-bd95-96c849cbbaef@e18g2000vbe.googlegroups.com> On Sep 1, 9:48?am, steve wrote: (snip) > I think you are confusing simplicity with uniformity. > > Uniformity is not always good. Sure standardizing on units of measure and > airline codes is good, but expecting everyone to speak one language is akin to > expecting everyone to wear one type of clothing or expecting everyone to drive > just one type of automobile -- those kind of rules works well in a small sets > where doing so fulfills a purpose (in the army, hospitals or taxi service, for > instance). Thanks for bringing good arguments to this thread. But let me argue your talking points a bit. You seem to think that a single language somehow infringes upon the freedoms of individuals and you argue this by making parallels to personal taste's like like cars, clothing, hairstyles, etc. I am an American so i deeply believe in the right of individuals to freedom of speech, freedom of expression. Freedom of everything AS long as your freedoms don't cancel-out others freedoms. I am also not advocating the outlawing or "frowning upon" of any non- official language, quite the contrary. I AM saying that there must be *ONE* language that is taught in schools throughout the world as the very first language a child and *ONE* language that is used for official business of governments and corporations throughout the world. HOWEVER, individuals will still have the freedom to speak/write/ curse in any other language their heart desires. But with the great language unity, all peoples will be able to communicate fluently through the universal language while keeping their cultural identity. Can you not see the beauty in this system? Like i said, i believe in individual freedom, but you and i are also children of the Human race. There are some responsibilities we must keep to Human-kind as a whole. Universal communication is one of them. Universal freedom is another. An neither of these responsibilities will hold back individualism. > To put it another way, it is better to create data structures to deal with > variable length names rather than mandating that everybody has names < 30 chars. You need to understand that language is for communication and expression of ideas, and that is it. It is really not as glamorous as you make it seem. It is simple a utility and nothing more... > This might come as a bit of shock for you, but evolution awards those who are > capable of adapting to complexity rather then those who expect things to be > uniform. You, dear friend, and those who yearn for uniformity are the ones on > the path to extinction. No evolution awards those that benefit evolution. You make it seem as evolution is some loving mother hen, quite the contrary! Evolution is selfish, greedy, and sometimes evil. And it will endure all of us... remember the old cliche "Nice guys finish last"? From tjreedy at udel.edu Tue Sep 1 15:42:14 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 15:42:14 -0400 Subject: An assessment of the Unicode standard In-Reply-To: <4d84aaa7-5b8f-4e21-962e-75df48b20af1@q35g2000vbi.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> <4d84aaa7-5b8f-4e21-962e-75df48b20af1@q35g2000vbi.googlegroups.com> Message-ID: r wrote: > On Sep 1, 2:39 am, Terry Reedy wrote: > (snip) >> There is, of course, an international system of measure. The US is the >> only major holdout. (I recall Burma, or somesuch, is another.) An >> interesting proposition would be for the US to adopt the metric system >> in exchange for the rest of the world adopting simplified basic English >> as a common language. as a common *second* language. > Bring on the metric system Terry, i have been waiting all my life!! > > Now, if we can only convince those 800 million Mandarin Chinese > speakers... *ahem* Do we have a Chinese translator in the house? They already pretty much are convinced as regards to English as a second language, which is what I meant. From exarkun at twistedmatrix.com Tue Sep 1 15:44:53 2009 From: exarkun at twistedmatrix.com (exarkun at twistedmatrix.com) Date: Tue, 01 Sep 2009 19:44:53 -0000 Subject: Python community buildbot page still 503 In-Reply-To: <4A9D75AA.7080806@v.loewis.de> References: <4A9D669A.8000105@v.loewis.de> <20090901191636.7436.1088747589.divmod.xquotient.117@localhost.localdomain> <4A9D75AA.7080806@v.loewis.de> Message-ID: <20090901194453.7436.1745926192.divmod.xquotient.128@localhost.localdomain> On 07:27 pm, martin at v.loewis.de wrote: >>>>If I am not mistaken http://python.org/dev/buildbot/community/all/ >>>>has >>>>been down since python.org had its harddrive issues. >>>> >>>>Anyone know a time line on getting it back up and running. >>> >>>This service is, unfortunately, unmaintained. It broke when I >>>upgraded >>>the buildbot master to a new code base, and nobody upgraded the >>>buildbot >>>configuration file. >>> >>>So I have now removed it from the web server configuration, and put a >>>notice on the web site. >> >>Um. Where should I have been watching to get some warning about this? > >Not sure. Looking at the waterfall pages of the buildbot would have >helped. >>And now that I know, can you tell me what I need to do to restore it? > >Are you in charge of it? On reading your previous email, I assumed that someone (you, perhaps) had tried to contact Grig Gheorghiu (he was in charge of it last I heard) to let him know that some maintenance was required and that someone (you, perhaps) only made the decision to remove the community buildbots after he responded by indicating he was no longer willing to maintain it. Since you're asking if I'm in charge of it, I'm now lead to believe that no one contacted Grig. Is this the case? In case it is, I'm cc'ing him on this email. >You need to fix the config file, remove the commented-out redirects in >the Apache configuration, and revert the two commits I did to the web >pages. Jean-Paul From martin at v.loewis.de Tue Sep 1 15:52:41 2009 From: martin at v.loewis.de (=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=) Date: Tue, 01 Sep 2009 21:52:41 +0200 Subject: Python community buildbot page still 503 In-Reply-To: <20090901194453.7436.1745926192.divmod.xquotient.128@localhost.localdomain> References: <4A9D669A.8000105@v.loewis.de> <20090901191636.7436.1088747589.divmod.xquotient.117@localhost.localdomain> <4A9D75AA.7080806@v.loewis.de> <20090901194453.7436.1745926192.divmod.xquotient.128@localhost.localdomain> Message-ID: <4A9D7B89.2050502@v.loewis.de> > On reading your previous email, I assumed that someone (you, perhaps) > had tried to contact Grig Gheorghiu (he was in charge of it last I > heard) to let him know that some maintenance was required and that > someone (you, perhaps) only made the decision to remove the community > buildbots after he responded by indicating he was no longer willing to > maintain it. No, I immediately "removed" them when I learned that they were still down, even though I broke them more than a month ago. Of course, I didn't really remove them > Since you're asking if I'm in charge of it, I'm now lead to believe that > no one contacted Grig. Is this the case? In case it is, I'm cc'ing him > on this email. I sent a message to Grig right after I sent the other one, and he already responded. Regards, Martin From 71david at libero.it Tue Sep 1 16:10:24 2009 From: 71david at libero.it (David) Date: Tue, 1 Sep 2009 22:10:24 +0200 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: Il Mon, 31 Aug 2009 20:06:54 -0700 (PDT), r ha scritto: > Is the car owner not a victim too? :). i am ok with the filthy > insurance company paying as long as the owners rates don't increase. He is, unless he left keys in the cockpit, but he is 'less victim' of the people involved in the accident. Since it is impossible to protect both kind of victims the law protects the 'most victims'. I'm not sure but I think that the increases. > But why can't we force the criminal into hard labor to pay back the > lost monies? Seems like that would serve justice to all parties... I'm not saying that criminals shouldn't being prosecuted, but we are talking of something else: creating and environment that discurages criminals, because present enviroment is pretty wild and criminals have a big advantage. The mail-tax proposal aims to change this situation. >> That's a problem of the computer owner. Why should the rest of the world be >> charged of *his* problem while keeping him safe from suffering any >> consequence? > > No, why should spammers feel safe while doing their crimes? I say put > the pressure on criminals, and NOT the victims. I really doubt much is > being done to fight spam now that is why it is so prevalent. Two FBI > hackers can't keep up with billions of spams. This is a misunderstaning maybe caused by my poor english. When a person gets his computer infected and becomes zombi machine, well, *he* has a problem. At present, consequences of *his* problem are spread on me, you, people reading this discussion and the rest of internet users, while the infected computer's owner gets only a tiny fraction of those consequences. He has no reason to check his computer periodically, clean it, being cautios when surfing the net, do not install software to see free porn, etc etc because he doesn't get an evident feedback of the damage he is (even unconsciously) doing. Do you really think that things should go in this way? > Only if that tax was given to highly trained US Marines who where > given a green light to use any and all methods to brutally kill the > enemy and make an example of him with no worry of prosecution by their > own government. You did a mataphor and I've answered in the same metaphor. Let me say again that spammer and cyber criminal *must* be prosecuted with all means, but we know that present environment helps bad guys instead of good guys because most of the 'neutral guys' are just unaware (*and they want remain unaware because it's comfortable*) of being used by bad guys. > >> The mail-tax would be really small, if you send 1000 mails at month (a real >> huge traffic, for a non spammer!) the bill would be about 10 cents. >> Do you really think this is too much to get rid of most of the spam? > > I don't think that will stop most spammers since they must be making > more that a 10c a month profit or they would starve to death! I say > why not put a 1000.00 fine on any idiot that responds to a spam! What > about that? Spammers work with tenths of millions of mails/posts each month because they get revenue only from a tiny fraction of them, about 1 over several thousands. The monthly cost for such a volume of traffic would be intolerable for them. > The system is definitely flawed. I am no internet expert so i don't > really know what we could do to fix it. I do fear goverment or > corporations taking over of the internet and robbing use of our > freedom of speech under the pretense that they will *somehow* save us > from the spammers. Something must be done however. I definitely agree with you on that point, that's why I'm making this proposal: the target is to reduce the spam *without* using armies of cybercops patrolling all over the net. If we let the situation get worse, goverments will respond in the only way they know: by restricting freedom. At the opposite, if they realize that the problem is under control and even they get a little revenue, they'll be happy to let us live in peace. (I hope my english is correct enough to expose this concept...) regards David From no.email at please.post Tue Sep 1 16:11:33 2009 From: no.email at please.post (kj) Date: Tue, 1 Sep 2009 20:11:33 +0000 (UTC) Subject: Q on naming nested packages/modules References: Message-ID: In "Rami Chowdhury" writes: >> An implication of all this is that if now I wanted to create a new >> module x.y.z.w, this means that the previously "leaf"-module x.y.z >> would become "non-leaf". In other words, I'd have to: >> >> 1. create the new directory x/y/z >> 2. *rename* the file x/y/z.py to x/y/z/__init__.py >> 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w >> module >With regard to point 2 -- would it be possible to just move z.py into >x/y/z, and put 'from z import *' into x/y/z/__init__.py, for the same >effect? Or is that not a good idea? I think in this case what you would need is something like 'from ..z import *', but this does not work either; one gets the error "SyntaxError: 'import *' not allowed with 'from .'". A third solution would be to change step 2 above to this: 2. create the *symlink* x/y/z/__init__.py --> ../z.py This certainly would make things clearer-looking to me. Having all these files called the same thing, __init__.py, but having completely different meaning, makes my head hurt... In contrast, the __init__.py *symlinks* would be there just to keep python happy; the real content is where I'd expect it. I ran a simple test of this idea and it works, but there may be some subtle reasons for not doing it... Or maybe it's not a good idea simply because it is not the Python way, and I'd agree that this would be reason enough to avoid it. kynn From patx at patx.me Tue Sep 1 18:24:25 2009 From: patx at patx.me (patx at patx.me) Date: Tue, 1 Sep 2009 18:24:25 -0400 Subject: fastPATX Lion now out for your speedy web browsing needs! Message-ID: <699f51260909011524r28572553u880b916bfd6f856b@mail.gmail.com> fastPATX Lion is now out! New features include, tabbed browsing, less dependencies, and and a better download manager. The new version is by far the most stable! There was only one crash recored in the fastPATX Lion-Alpha testing! The bug that caused the crash has also been taking care of! fastPATX was also reviewed and greatly liked by many others (lmgtfy.com/?q=fastpatx). get fastpatx here -- patx, python gui and web, http://patx.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From luke.leighton at googlemail.com Tue Sep 1 18:30:25 2009 From: luke.leighton at googlemail.com (lkcl) Date: Tue, 1 Sep 2009 15:30:25 -0700 (PDT) Subject: port of GWTCanvas to python / pyjamas Message-ID: <1ddd7ba7-e0c3-450a-a92d-226b4a0eead3@f33g2000vbm.googlegroups.com> as part of the recent porting of GGhart to pyjamas, a massive performance gain can be had by using SVG Canvas. unfortunately, that meant porting GWTCanvas to pyjamas as well. this is also progressing well: http://pyjs.org/examples/gwtcanvas/ if anyone would like to help with the porting effort and with testing, that would be great: please contact pyjamas-dev at groups.google.com. the IE engine uses VML, and the GWTCanvas library takes care of providing an SVG-like interface to VML (which is rather cool). l. From luke.leighton at googlemail.com Tue Sep 1 18:32:19 2009 From: luke.leighton at googlemail.com (lkcl) Date: Tue, 1 Sep 2009 15:32:19 -0700 (PDT) Subject: port of GWT GChart to python pyjamas References: Message-ID: > been ported already, enough to show that the libray is in a mostly > useable state, even after only three days. pie-charts are proving > slightly problematic (as GChartExample24, which is a pie chart editor, > shows). fixed. demo at : http://pyjs.org/examples/gcharttestapp/output/GChartTestApp.html From rt8396 at gmail.com Tue Sep 1 18:49:57 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 15:49:57 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> Message-ID: <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> On Sep 1, 1:52?pm, Hyuga wrote: (snip) > I'd say don't feel the troll, but too late for that I guess. ? The only trolls in this thread are you and the others who breaks into MY THREAD just for the knee-jerk reaction of troll calling! Even though you *did* offer some argument to one of the subjects of this thread, it was cancelled out by your trolling! Please come back when you have some constructive thoughts on the subjects of Python as it relates to Unicode, or Universal natural languages. Whether you want to admit it or not these subjects affect programming and Python. And here is the definition of a troll for the uneducated among us, of which it seems is surprising a very large number these days... http://en.wikipedia.org/wiki/Troll_(Internet) From steve at REMOVE-THIS-cybersource.com.au Tue Sep 1 19:00:06 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 01 Sep 2009 23:00:06 GMT Subject: Is behavior of += intentional for int? References: <0025e0c6$0$2930$c3e8da3@news.astraweb.com> <3eed185b-ffa2-441a-a684-fe4035b2d5ab@o35g2000vbi.googlegroups.com> Message-ID: <00272afd$0$2930$c3e8da3@news.astraweb.com> On Tue, 01 Sep 2009 07:04:09 -0700, zaur wrote: > On 1 ???, 03:31, Steven D'Aprano > wrote: >> On Mon, 31 Aug 2009 10:21:22 -0700, zaur wrote: >> > As a result of this debate is not whether we should conclude that >> > there should be two types of integers in python: 1) immutable >> > numbers, which behave as constant value; 2) mutable numbers, which >> > behave as variable value? >> >> What can you do with mutable numbers that you can't do with immutable >> ones, and why do you want to do it? >> >> -- >> Steven > > Mutable numbers acts as variable quantity. So do immutable numbers bound to a name. > So when augmented assignment > is used there is no need to create a new number object in every binary > operation. "No need", sure, but there's no *need* to use object oriented code in the first place, or garbage collectors, or high level languages, or even functions. People got by with GOTO and assembly for years :) We use all these things because they make *programming* easier, even if it adds runtime overhead. I'm asking what *problem* you are trying to solve with mutable numbers, where immutable numbers are not satisfactory. The only answer I can imagine is that you're worried about the overhead of creating new integer objects instead of just flipping a few bits in an existing integer variable. -- Steven From rami.chowdhury at gmail.com Tue Sep 1 19:06:10 2009 From: rami.chowdhury at gmail.com (Rami Chowdhury) Date: Tue, 01 Sep 2009 16:06:10 -0700 Subject: An assessment of the Unicode standard In-Reply-To: <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> Message-ID: > The only trolls in this thread are you and the others who breaks into > MY THREAD just for the knee-jerk reaction of troll calling! How does this make one's opinion any less relevant? I think the fact that you are coming across in this thread as closed-minded, bigoted, and uninformed gives everyone plenty of right to accuse you of trolling. Being aggressive about it doesn't help. Yes, Unicode is a hack, but it's a hack necessitated by the prevalence (and naivete) of ASCII. If you're advocating something as absurd as standardizing on a universal, simple language, how about an almost equally ridiculous proposal: why don't we break backwards-compatibility with ASCII? -- Rami Chowdhury "Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) From steve at REMOVE-THIS-cybersource.com.au Tue Sep 1 19:09:59 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 01 Sep 2009 23:09:59 GMT Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> <33B0AC00-44CA-4EA4-8322-4052E1A41871@gmail.com> <4A9D1ECC.7040903@mrabarnett.plus.com> Message-ID: <00272d4d$0$2930$c3e8da3@news.astraweb.com> On Tue, 01 Sep 2009 08:35:46 -0700, Rami Chowdhury wrote: >> SI is preferred, >> but Imperial is permitted. > > IME most people in the UK under the age of 40 can speak SI without > trouble. > > On the other hand, "let's nip down to the pub for 580ml of beer" just > doesn't have the right ring to it ;-) Oh those wacky Brits and their obsession with precision -- why do they have to specify the volume of beer? What's wrong with any of these? Let's nip down to the pub for a beer. Let's nip down to the pub for a couple of drinks. Let's nip down to the pub -- good for drinkers who prefer a brandy. Let's go get hammered! -- what they're really thinking. -- Steven From rt8396 at gmail.com Tue Sep 1 19:29:54 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 16:29:54 -0700 (PDT) Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> Message-ID: <0be8384a-5048-49fc-9ede-7a0f19518c0a@p9g2000vbl.googlegroups.com> On Sep 1, 6:06?pm, "Rami Chowdhury" wrote: (snip: trolling tirade) I don't think when i started this thread i had any intentions what-so- ever of pleasing asinine-anthropologist, sociology-sickos, or neo-nazi- linguist. No, actually i am quite sure of that is the case! From tjreedy at udel.edu Tue Sep 1 19:33:47 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 19:33:47 -0400 Subject: Why does this group have so much spam? In-Reply-To: References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: David wrote: > > I'm not saying that criminals shouldn't being prosecuted, but we are talking > of something else: creating and environment that discurages criminals, > because present enviroment is pretty wild and criminals have a big > advantage. > The mail-tax proposal aims to change this situation. I have read at least one person saying he did not mind his machine being used to send out spam. I have read more that one person advocating leaving one's wi-fi base open for anyone to use as the 'neighborly' thing to do. A substantial fraction of people have turned off Window's update. Consequently, whenever Microsoft announces a vulnerablility and patch, malware writers can write an exploit of the announced vulnerability and be sure that they will find vulnerable machines. All the above are contributors to the problem and are externalizing some of the proper cost of ownership and operation of a net-connected computer. tjr From rami.chowdhury at gmail.com Tue Sep 1 19:39:59 2009 From: rami.chowdhury at gmail.com (Rami Chowdhury) Date: Tue, 01 Sep 2009 16:39:59 -0700 Subject: An assessment of the Unicode standard In-Reply-To: <0be8384a-5048-49fc-9ede-7a0f19518c0a@p9g2000vbl.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> <0be8384a-5048-49fc-9ede-7a0f19518c0a@p9g2000vbl.googlegroups.com> Message-ID: On Tue, 01 Sep 2009 16:29:54 -0700, r wrote: > [snip: variety of almost-alliterative epithets] Well, if you admit you set out to offend people, then you're trolling. -- Rami Chowdhury "Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) From pavlovevidence at gmail.com Tue Sep 1 19:43:06 2009 From: pavlovevidence at gmail.com (Carl Banks) Date: Tue, 1 Sep 2009 16:43:06 -0700 (PDT) Subject: Is behavior of += intentional for int? References: Message-ID: On Sep 1, 10:40?am, Piet van Oostrum wrote: > >>>>> zaur (z) wrote: > >z> On 29 ???, 16:45, zaur wrote: > >>> Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) > >>> [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin > >>> Type "copyright", "credits" or "license()" for more information.>>> a=1 > >>> >>> x=[a] > >>> >>> id(a)==id(x[0]) > >>> True > >>> >>> a+=1 > >>> >>> a > >>> 2 > >>> >>> x[0] > > >>> 1 > > >>> I thought that += should only change the value of the int object. But > >>> += create new. > >>> Is this intentional? > >z> As a result of this debate is not whether we should conclude that > >z> there should be two types of integers in python: 1) immutable numbers, > >z> which behave as constant value; 2) mutable numbers, which behave as > >z> variable value? > > Numbers are immutable by nature (math). The number 3.14 remains 3.14 > whatever you try to do with it. What you call an immutable number is in > fact a container that contains a number. I wouldn't agree with that terminology or logic. First of all "mutable number" is really just a short way to say "mutable number object". A number object in Python is not a number, it's just a representation of a number. Even if numbers are immutable by nature, an object representing a number need not be. And if your number object is mutable, it does not make that object a container, at least not what I would call a container. A container you have to dereference somehow to get at the object inside, whereas a mutable number object you don't dereference: it acts like number as- is. IOW, the first example below is a container, the second is not: num = [2] num[0] += 3 num = mutable_int(2) num += 3 (If you want to call the mutable number a container anyway, fine with me, I am not here to bicker.) A container is sufficient to get a layer of indirection if that's what you want the mutable number for. However, the mutable number has a performance advantage over using a container: it avoids the overhead of creating a new object. If you were using += in a loop like this, it could turn out to be significant savings. But since that's not common in Python I'd have to agree that this optimization opportunity is best done with a third-party C- extension, and not the standard library. Carl Banks From tjreedy at udel.edu Tue Sep 1 20:00:16 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Sep 2009 20:00:16 -0400 Subject: Is behavior of += intentional for int? In-Reply-To: <00272afd$0$2930$c3e8da3@news.astraweb.com> References: <0025e0c6$0$2930$c3e8da3@news.astraweb.com> <3eed185b-ffa2-441a-a684-fe4035b2d5ab@o35g2000vbi.googlegroups.com> <00272afd$0$2930$c3e8da3@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > > I'm asking what *problem* you are trying to solve with mutable numbers, > where immutable numbers are not satisfactory. The only answer I can > imagine is that you're worried about the overhead of creating new integer > objects instead of just flipping a few bits in an existing integer > variable. Of course, *because ints are immutable*, an implementation can avoid the overhead of object creation for common cases by creating an array of small integers. CPython currently does this for -10 (or -5?) to about 256 or 257. I would not be surprised if this coevers at least 80% of int.__new__ requests. tjr From "speediq\" at (none) Tue Sep 1 20:00:39 2009 From: "speediq\" at (none) (none) Date: Tue, 01 Sep 2009 20:00:39 -0400 Subject: python module for data comparison of 2 MySQL servers Message-ID: <4a9db585$0$31273$607ed4bc@cv.net> I have 2 MySQL servers in 2 different data centers. Between them, there is data replication setup. Is there a python tool so I can do data comparison for daily records? Basically, just access both servers and do a diff in memory and print out records. Thanks From steve at REMOVE-THIS-cybersource.com.au Tue Sep 1 20:17:05 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 00:17:05 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> Message-ID: <00273d07$0$2930$c3e8da3@news.astraweb.com> On Tue, 01 Sep 2009 20:48:19 +0200, David wrote: > Il Tue, 1 Sep 2009 11:50:14 +0200, Andre Engels ha scritto: > > >> What about mailing lists? There exist well-functioning mailing lists >> with thousands of subscribers. Being a posting member of those will >> significantly increase your internet bill under your proposal. > > It's an implementation issue, it doesn't touch the sense of proposal. > One possibility is register the mail list to official registers and mail > from a subscriber to other subscribers will be excluded from taxation or > will have a lower tax rate. > An excessive mailing from a single or few subscribers can be easily > detected, traced, filtered and, if the case, prosecuted. This can be done already, without the need for an email tax. ISPs could easily detect spammers, if they cared to. There are a few things that can already be done to cut the spam problem to manageable size: (1) Why aren't ISPs blocking port 25 for home users by default? My home ISP does, I can only send email through their mail server unless I ask them nicely, in which case I'd be responsible for any spam that leaves my home network. If I send spam, I'll be breaking my terms of service. (2) Why aren't ISPs cutting off detected spam bots? Owners of zombied PCs are menaces to society. ISPs are in the best position to detect PCs which are spamming, and alert the owner. If no action is taken in a week, warn the owner that they're in breach of their terms of service, and if the behaviour persists, cut the owner off until they clean up their PC. Repeat offenders should be banned. (3) ISPs who won't cut off spam bots are either incompetent or have a financial incentive to do business with spammers. Therefore, responsible ISPs should cut them off. If this means the email universe divides into two halves, the Wild West where 999 emails out of every 1000 are spam, and Civilization where only one in a thousand is spam, I'm okay with that. As for the argument that home users who send spam are the victim, that's true up to a point, but not very far. Here's an analogy: suppose that terrorists sneak into your house after picking the lock -- or in the case of Windows users with no firewall or anti-malware, stroll through the unlocked front door -- and spend the next six months camped in your spare bedroom, using your home for their base of operations while they make terrorist attacks. When the FBI kicks your doors down, don't you think you would be arrested and would have to prove that you couldn't be reasonably expected to know they were there? If millions of spam emails are coming out of your PC, that's prima facie evidence that YOU are spamming. You would need to prove that you're an innocent victim who couldn't *reasonably* be expected to know that your machine was hijacked -- you would need to prove that the spam bot was so sophisticated that it infected your PC despite the firewall, that you didn't install it yourself in order to get some stupid game, that no commonly available anti-malware program detects it. Anything less than that is *at least* negligence, and possibly willful negligence. Negligence is a crime too, especially willful negligence. Perhaps a lesser crime than deliberate bad behaviour, but if you kill somebody because you neglected to service your car, the argument "I'm the victim here, blame somebody else!" wouldn't get you very far. Not knowing how to service your car to keep it in good working order is not an excuse -- if you don't know how to change the brakes, there are people who do. If you don't know how to set up an effective firewall and anti-malware software, there are people who do. Stop hiding behind your ignorance, and pay an expert to service -- and secure -- your computer. It is 2009, and the malware problem isn't some theoretical threat that only a handful of people know about. Anyone with an infected PC who does nothing about it is, in my opinion, *equally* responsible for the spam being sent out as the criminals who hijacked the PC in the first place. Yes, I'd like to see the criminals, the malware authors and the spammers punished, but I'd be satisfied to see them put out of business. The weak link is the zombie PCs -- fix the home users' PCs, or block them, take them off the Internet, and spam becomes manageable again. -- Steven From ubershmekel at gmail.com Tue Sep 1 20:47:25 2009 From: ubershmekel at gmail.com (RunThePun) Date: Tue, 1 Sep 2009 17:47:25 -0700 (PDT) Subject: Overriding iadd for dictionary like objects References: Message-ID: <7f82416a-53be-41b3-9503-1492454cc32c@upsg2000gro.googlegroups.com> On Sep 1, 3:00?am, a... at pythoncraft.com (Aahz) wrote: > In article , > > > > > > RunThePun ? wrote: > >On Aug 30, 10:33=A0pm, a... at pythoncraft.com (Aahz) wrote: > >> In article >.com>, > >> RunThePun =A0 wrote: > > >>>I made a DictMixin where the keys are filenames and the values are the > >>>file contents. It was very simple and easy to do thanks to DictMixin. > > >>>For example this code writes "abc" in a file named "temp.txt" and > >>>prints the contents of the file named "swallow", these files are > >>>looked up/created/deleted in the directory "spam": > >>>>>> d =3D3D FilesDict('spam') > >>>>>> d['temp.txt'] =3D3D 'abc' > >>>>>> print(d['swallow']) > > >>>My problem arose when I wanted to append a string to a file which > >>>using open(..., 'ab') would have been miles more efficient because I > >>>wouldn't have to read the entire file (__getitem__) and then write the > >>>entire file back (__setitem__). The files are expected to be as big as > >>>600 KB which will be appended 30 bytes at a time about 3 times a > >>>second. Performance-wise the system would probably work without open > >>>(..., 'ab') but it would be a real thrashing so the current solution > >>>uses a method "AddTo" as Robert suggested, sacrificing the neat > >>>getitem/setitem syntax. > > >> You can do mostly what you want, I think, by having __setitem__() > >> convert string values into FileProxy() objects that have an appropriate > >> __iadd__() method. =A0That brings a whole new set of problems, of course. > > >I'm guessing you meant __getitem__, which is what Jan Kaliszewski > >suggested, but as you noted, would be a bit cumbersome in this case. > > Actually, what I meant was __setitem__. ?The idea is that you create the > proxy item when you add the data to the dict (wrapping the original > data), and the proxy has an __iadd__ method, which would allow you to do > the file append. > -- > Aahz (a... at pythoncraft.com) ? ? ? ? ? <*> ? ? ? ?http://www.pythoncraft.com/ > > "I support family values -- Addams family values" --www.nancybuttons.com But you do mean that __getitem__ would return a wrapped object as well, right? Otherwise I don't see how the iadd would be relevant because: d['a'] += 3 is equivalent to: d.__setitem__('a', d.__getitem__('a').__iadd__(3)) From barcaroller at music.net Tue Sep 1 21:01:56 2009 From: barcaroller at music.net (barcaroller) Date: Tue, 1 Sep 2009 21:01:56 -0400 Subject: PyGTK problems after Linux update... References: <7fq56dF2m6qlbU1@mid.individual.net> Message-ID: "barcaroller" wrote in message news:h7ev9g$dcu$1 at news.eternal-september.org... > Okay, I won't disagree, but how do I fix this? Never mind. The latest update today included a new pygtk which seems to have fixed the problem. All is good now. From grante at visi.com Tue Sep 1 21:14:37 2009 From: grante at visi.com (Grant Edwards) Date: Tue, 01 Sep 2009 20:14:37 -0500 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On 2009-09-01, Terry Reedy wrote: > David wrote: > >> I'm not saying that criminals shouldn't being prosecuted, but >> we are talking of something else: creating and environment >> that discurages criminals, because present enviroment is >> pretty wild and criminals have a big advantage. The mail-tax >> proposal aims to change this situation. > > I have read at least one person saying he did not mind his > machine being used to send out spam. OK, that's nuts. > I have read more that one person advocating leaving one's > wi-fi base open for anyone to use as the 'neighborly' thing to > do. That's quite a bit different that allowing one's machine to be used by spammers. -- Grant From rt8396 at gmail.com Tue Sep 1 21:29:08 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 18:29:08 -0700 (PDT) Subject: Why does this group have so much spam? References: mailman.817.1251848051.2854.python-list@python.org Message-ID: <302c7070-3542-4fb3-a579-1f2b00cdc3a5@upsg2000gro.googlegroups.com> On Sep 1, 6:33?pm, Terry Reedy wrote: (snip) > I have read at least one person saying he did not mind his machine being > used to send out spam. That's "aiding and abetting" and can be prosecuted! > I have read more that one person advocating > leaving one's wi-fi base open for anyone to use as the 'neighborly' > thing to do. Thats stupidity and *should* be painful! From rt8396 at gmail.com Tue Sep 1 21:31:17 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 18:31:17 -0700 (PDT) Subject: Why does this group have so much spam? References: mailman.817.1251848051.2854.python-list@python.org Message-ID: On Sep 1, 6:33 pm, Terry Reedy wrote: (snip) > I have read at least one person saying he did not mind his machine being > used to send out spam. That's "aiding and abetting" and can be prosecuted! > I have read more that one person advocating > leaving one's wi-fi base open for anyone to use as the 'neighborly' > thing to do. Thats stupidity and *should* be painful! From apt.shansen at gmail.com Tue Sep 1 21:44:10 2009 From: apt.shansen at gmail.com (Stephen Hansen) Date: Tue, 1 Sep 2009 18:44:10 -0700 Subject: Q on naming nested packages/modules In-Reply-To: References: Message-ID: <7a9c25c20909011844q701f0273q5860713c9fc84db5@mail.gmail.com> > >> An implication of all this is that if now I wanted to create a new > >> module x.y.z.w, this means that the previously "leaf"-module x.y.z > >> would become "non-leaf". In other words, I'd have to: > >> > >> 1. create the new directory x/y/z > >> 2. *rename* the file x/y/z.py to x/y/z/__init__.py > >> 3. create the file x/y/z/w.py to hold the source for the new x.y.z.w > >> module > > >With regard to point 2 -- would it be possible to just move z.py into > >x/y/z, and put 'from z import *' into x/y/z/__init__.py, for the same > >effect? Or is that not a good idea? > > I think in this case what you would need is something like 'from > ..z import *', but this does not work either; one gets the error > "SyntaxError: 'import *' not allowed with 'from .'". > If you have a "spam.ham" module and you want to refactor it into a package, there's basically two common things to do as you've discovered. The first is to turn ham into a package: that entails creating a directory named ham, and moving ham.py to ham/__init__.py That works fine and is used by a number of people: I personally hate doing it, though. I don't like to put significant chunks of code into __init__.py, but instead just code which largely handles... namespace-issues or bootstrapping of a package. Partly for the reason you specified: it makes life a little annoying to have multiple files with completely different content have the same filename even if they aren't ambiguous due to directories. I personally MUCH prefer turning ham into a package, and moving the original "ham.py" to spam/ham/_ham.py. In spam/ham/__init__.py, I'd then do: from spam.ham._ham import * >From a usage perspective, everything that used to be in spam.ham will still be there with all the contents you'd expect (the stuff in spam/ham/_ham.py)... and people can import spam.ham.eggs if they want or need to access those details. (I get around the above traceback you mention by just using an absolute import -- but I never use relative imports, anyways. They make my soul cry from a style and management and sanity perspective.) A third solution would be to change step 2 above to this: > > 2. create the *symlink* x/y/z/__init__.py --> ../z.py > This is IMHO a very, very, very bad idea :) Yes, it'll work. But involving symlinks will make everything from distribution to revision control a bit more complicated (even if you're never intending any Windows users to use it or use a system like svn which handles symlinks adequately). It'll just create, in essence, two separate files on your system with the same content/code. Sure they're not really two separate files, but as far as Python knows they are. It just seems like it's asking for trouble :) --S -------------- next part -------------- An HTML attachment was scrubbed... URL: From zelegolas at gmail.com Tue Sep 1 22:16:29 2009 From: zelegolas at gmail.com (zelegolas) Date: Tue, 1 Sep 2009 19:16:29 -0700 (PDT) Subject: Every thing on a database Message-ID: Hi I guess it's may be a strange idea that I will explain: I really like python but I have one thing that I don't like: Every packages are defined with folder tree. To deploy an application it's not really clean. It's why I thought about "Is that possible to put everything that I need for my python application under one file?" Base on this idea: If all packages are under one file. Like this each time an import is executing it will automatically extract packages, library or any files from this file first and if doesn't find it from the standard way. This file could a SQLite file for example. I don't know if it's possible to overwrite the import behavior. And may be what I describe is already develop by someone, if it's the case just let me know. Regards Ze. From dolgion1 at gmail.com Tue Sep 1 22:22:22 2009 From: dolgion1 at gmail.com (dolgion ch) Date: Tue, 1 Sep 2009 19:22:22 -0700 (PDT) Subject: Can't set attribute?! Message-ID: Hi there, i'm new to Python, and i don't understand why following exception occurs in this code: class NETRPCGateway(RPCGateway): """NETRPC Implementation. """ def __init__(self, host, port): self.host = host self.port = port super(NETRPCGateway, self).__init__(self.host, self.port, 'socket') def listdb(self): sock = tiny_socket.mysocket() try: sock.connect(self.host, self.port) sock.mysend(('db', 'list')) res = sock.myreceive() sock.disconnect() return res except Exception, e: return -1 def login(self, db, user, password): sock = tiny_socket.mysocket() self.db = db self.password = password self.user = user try: sock.connect(self.host, self.port) sock.mysend(('common', 'login', db, user, password)) res = sock.myreceive() sock.disconnect() except Exception, e: return -1 return res def _execute(self, obj, method, args=(), noauth=False): sock = tiny_socket.mysocket() try: sock.connect(self.host, self.port) if not noauth: print "in noauth" args = (self.db, self.uid, self.password) + args sock.mysend((obj, method) + args) res = sock.myreceive() sock.disconnect() return res except xmlrpclib.Fault, err: raise RPCException(err.faultCode, err.faultString) except tiny_socket.Myexception, err: raise RPCException(err.faultCode, err.faultString) def execute(self, obj, method, *args): return self._execute(obj, method, args) def execute_noauth(self, obj, method, *args): return self._execute(obj, method, args, noauth=True) def execute_db(self, method, *args): sock = tiny_socket.mysocket() sock.connect(host, port) sock.mysend(('db', method) + args) res = sock.myreceive() sock.disconnect() return res class RPCSession(object): """This is a wrapper class that provides Pythonic way to handle RPC (remote procedure call). It also provides a way to store session data into different kind of storage. """ __slots__ = ['host', 'port', 'protocol', 'storage', 'gateway'] def __init__(self, host, port, protocol='socket', storage={}): """Create new instance of RPCSession. @param host: the openerp-server host @params port: the openerp-server port @params protocol: the openerp-server protocol @param storage: a dict like storage that will be used to store session data """ self.host = host self.port = port self.protocol = protocol self.storage = storage print "RPCSession ", host, port,protocol if protocol == 'http': self.gateway = XMLRPCGateway(host, port, 'http') elif protocol == 'https': self.gateway = XMLRPCGateway(host, port, 'https') elif protocol == 'socket': self.gateway = NETRPCGateway(host, port) else: raise common.message(_("Connection refused!")) def __getattr__(self, name): try: return super(RPCSession, self).__getattribute__(name) except: pass return self.storage.get(name) def __setattr__(self, name, value): if name in self.__slots__: super(RPCSession, self).__setattr__(name, value) else: self.storage[name] = value def __getitem__(self, name): return self.storage.get(name) def __setitem__(self, name, value): self.storage[name] = value def __delitem__(self, name): try: del self.storage[name] except: pass def get(self, name, default=None): return self.storage.get(name, default) def get_url(self): return self.gateway.get_url() def listdb(self): return self.gateway.listdb() def login(self, db, user, password): if password is None: return -1 uid = self.gateway.login(db, user or '', password or '') if uid <= 0: return -1 self.uid = uid self.db = db self.password = password self.open = True #self.gateway.db = db #self.gateway.uid = uid #self.gateway.password = password # read the full name of the user self.user_name = self.execute('object', 'execute', 'res.users', 'read', [uid], ['name'])[0]['name'] # set the context self.context_reload() return uid def logout(self): try: self.storage.clear() except Exception, e: pass def is_logged(self): return self.uid and self.open def getmac(self): s = socket.socket(socket.AF_PACKET,socket.SOCK_RAW) s.bind(("eth0",9999)) socObj=s.getsockname() mac = socObj[-1] mac_str = ":".join(["%02x" % ord(x) for x in mac]) print "HW : %s"%mac_str return mac_str def context_reload(self): """Reload the context for the current user """ self.context = {'client': 'pos','mac':self.getmac()} self.timezone = 'utc' # self.uid context = self.execute('object', 'execute', 'res.users', 'context_get') self.context.update(context or {}) if self.context.get('tz', False): self.timezone = self.execute('common', 'timezone_get') try: import pytz except: raise common.warning(_('You select a timezone but OpenERP could not find pytz library!\nThe timezone functionality will be disable.')) # set locale in session self.locale = self.context.get('lang') def __convert(self, result): if isinstance(result, basestring): # try to convert into unicode string try: return ustr(result) except Exception, e: return result elif isinstance(result, list): return [self.__convert(val) for val in result] elif isinstance(result, tuple): return tuple([self.__convert(val) for val in result]) elif isinstance(result, dict): newres = {} for key, val in result.items(): newres[key] = self.__convert(val) return newres else: return result def execute(self, obj, method, *args): print "in execute: ", obj, method, args if not self.is_logged(): raise common.warning('Not logged...', 'Authorization Error!') try: #print "TERP-CALLING:", obj, method, args result = self.gateway.execute(obj, method, *args) #print "TERP-RESULT:", result return self.__convert(result) except socket.error, (e1, e2): raise common.message(_(u'??????? ??????????!')) except RPCException, err: if err.type in ('warning', 'UserError'): raise common.warning(err.data) else: raise common.error(u'????????? ?????!', err.backtrace) except Exception, e: raise common.error(u'????????? ?????!', str(e)) def execute_noauth(self, obj, method, *args): return self.gateway.execute_noauth(obj, method, *args) def execute_db(self, method, *args): return self.gateway.execute_db(method, *args) my script is: import session session = session.RPCSession("localhost", 8070) res = session.listdb() print "listdb: ",res uid = session.login("openerp", "admin", "admin") print uid So i instantiate a RPCSession object, i call listdb() on it without problem. The when i call the login() method, i get the AttributeError exception: RPCSession localhost 8070 socket listdb: ['openerp'] Traceback (most recent call last): File "test.py", line 6, in uid = session.login("openerp", "admin", "admin") File "/home/dolgion/workspace/erpj/current/POS/src/session.py", line 337, in login uid = self.gateway.login(db, user or '', password or '') File "/home/dolgion/workspace/erpj/current/POS/src/session.py", line 214, in login self.db = db AttributeError: can't set attribute the NETRPCGateway attribute self.db can't be set? why not? i've tried changing the RPCSession login function to set the variable like this as well: self.gateway.db = db which doesn't work either, same exception..... any suggestions? From wuwei23 at gmail.com Tue Sep 1 22:54:10 2009 From: wuwei23 at gmail.com (alex23) Date: Tue, 1 Sep 2009 19:54:10 -0700 (PDT) Subject: Can't set attribute?! References: Message-ID: <071ba111-70d8-433e-a6c2-5e6f941f3c8a@v37g2000prg.googlegroups.com> dolgion ch wrote: > the NETRPCGateway attribute self.db can't be set? why not? i've tried > changing the RPCSession login function > to set the variable like this as well: > > self.gateway.db = db > > which doesn't work either, same exception..... > > any suggestions? The problem is this line in your definition of RPCSession: __slots__ = ['host', 'port', 'protocol', 'storage', 'gateway'] Slots are a way of creating more light weight objects; you cannot have add any new attributes to an object defined with __slots__, as they don't have a dictionary for attribute storage. http://docs.python.org/reference/datamodel.html#slots As for why you can't set them on NETRPCGateway, my suspicion is that RPCGateway defines similar slots, although I don't have access to the code... is it the OSE netsvc/netrpc libs that you're using? From dolgion1 at gmail.com Tue Sep 1 23:12:46 2009 From: dolgion1 at gmail.com (dolgion ch) Date: Tue, 1 Sep 2009 20:12:46 -0700 (PDT) Subject: Can't set attribute?! References: <071ba111-70d8-433e-a6c2-5e6f941f3c8a@v37g2000prg.googlegroups.com> Message-ID: <0c8c0e30-ae46-4727-b046-fc0c1b60540a@x6g2000prc.googlegroups.com> alex23 u were right with ur suspicion about the RPCGateway, i hadn't seen that there were attributes with the names db, uid, and password already set. I resolved the issue by simply giving the attributes different names :P the problem with the slots wasn't going to occur since i was talking about setting attributes in the NETRPCGateway class, not the RPCSession class. Thanks anyhow, and good to know about this __slots__ thing, i'll keep it in mind From steven at REMOVE.THIS.cybersource.com.au Tue Sep 1 23:16:55 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 03:16:55 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On Tue, 01 Sep 2009 19:33:47 -0400, Terry Reedy wrote: > David wrote: >> >> I'm not saying that criminals shouldn't being prosecuted, but we are >> talking of something else: creating and environment that discurages >> criminals, because present enviroment is pretty wild and criminals have >> a big advantage. >> The mail-tax proposal aims to change this situation. > > I have read at least one person saying he did not mind his machine being > used to send out spam. *Lots* of people have that attitude. I know a number of kiddies whose attitude is they don't care what malware is on their PC, when performance slows down to the point they can't play World of Warcrack any more, they'll just rebuild it. > I have read more that one person advocating > leaving one's wi-fi base open for anyone to use as the 'neighborly' > thing to do. That's a different kettle of fish. You don't do anybody any harm by paying for Internet access for your neighbours (and anyone driving down the street with a laptop and wi-fi). > A substantial fraction of people have turned off Window's update. > Consequently, whenever Microsoft announces a vulnerablility and patch, > malware writers can write an exploit of the announced vulnerability and > be sure that they will find vulnerable machines. Which wouldn't matter if their system was behind a proper firewall, and if they didn't willingly install malware because it came with a cool game. Or accidentally installed it because they thought it was anti-virus. The one and only time my Windows PC was infected by malware was because my wife decided to do the right thing by installing the Windows update. Somewhere in the process -- I never worked out how -- ActiveX got turned back on in IE, and within an hour the machine had a dozen drive-by malware packages installed. I know they were drive-by, because the missus started the update process and then left the house, nobody else was there. When she returned, she came in to a hundred pop-ups on screen, and a hijacked browser. Took me two weeks of elapsed time and around 30 hours of effort to remove those suckers from the machine. Now I run Linux, behind two firewalls. -- Steven From aahz at pythoncraft.com Tue Sep 1 23:24:45 2009 From: aahz at pythoncraft.com (Aahz) Date: 1 Sep 2009 20:24:45 -0700 Subject: Overriding iadd for dictionary like objects References: <7f82416a-53be-41b3-9503-1492454cc32c@upsg2000gro.googlegroups.com> Message-ID: In article <7f82416a-53be-41b3-9503-1492454cc32c at upsg2000gro.googlegroups.com>, RunThePun wrote: >On Sep 1, 3:00=A0am, a... at pythoncraft.com (Aahz) wrote: >> In article .com>, >> RunThePun =A0 wrote: >>>On Aug 30, 10:33=3DA0pm, a... at pythoncraft.com (Aahz) wrote: >>>> In article ups=3D >>>.com>, >>>> RunThePun =3DA0 wrote: >> >>>>>I made a DictMixin where the keys are filenames and the values are the >>>>>file contents. It was very simple and easy to do thanks to DictMixin. >> >>>>>For example this code writes "abc" in a file named "temp.txt" and >>>>>prints the contents of the file named "swallow", these files are >>>>>looked up/created/deleted in the directory "spam": >>>>>>>> d =3D3D3D FilesDict('spam') >>>>>>>> d['temp.txt'] =3D3D3D 'abc' >>>>>>>> print(d['swallow']) >> >>>>>My problem arose when I wanted to append a string to a file which >>>>>using open(..., 'ab') would have been miles more efficient because I >>>>>wouldn't have to read the entire file (__getitem__) and then write the >>>>>entire file back (__setitem__). The files are expected to be as big as >>>>>600 KB which will be appended 30 bytes at a time about 3 times a >>>>>second. Performance-wise the system would probably work without open >>>>>(..., 'ab') but it would be a real thrashing so the current solution >>>>>uses a method "AddTo" as Robert suggested, sacrificing the neat >>>>>getitem/setitem syntax. >> >>>> You can do mostly what you want, I think, by having __setitem__() >>>> convert string values into FileProxy() objects that have an appropriat= >e >>>> __iadd__() method. =3DA0That brings a whole new set of problems, of co= >urse. >> >>>I'm guessing you meant __getitem__, which is what Jan Kaliszewski >>>suggested, but as you noted, would be a bit cumbersome in this case. >> >> Actually, what I meant was __setitem__. =A0The idea is that you create th= >e >> proxy item when you add the data to the dict (wrapping the original >> data), and the proxy has an __iadd__ method, which would allow you to do >> the file append. > >But you do mean that __getitem__ would return a wrapped object as >well, right? Otherwise I don't see how the iadd would be relevant >because: > d['a'] +=3D 3 >is equivalent to: > d.__setitem__('a', d.__getitem__('a').__iadd__(3)) The __getitem__ returns the proxy object created by the first __setitem__ when you did d['a'] = 'something' The __iadd__ of the proxy object returns self, so it's the same object, which means that the second __setitem__ (called by +=) can check to see that you already have a proxy object and it does not need to rewrap it. If this still doesn't make sense, I suggest you go ahead and try the experiment to prove that it does work. ;-) -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet From steven at REMOVE.THIS.cybersource.com.au Tue Sep 1 23:48:43 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 03:48:43 GMT Subject: Is behavior of += intentional for int? References: Message-ID: On Tue, 01 Sep 2009 16:43:06 -0700, Carl Banks wrote: >> Numbers are immutable by nature (math). The number 3.14 remains 3.14 >> whatever you try to do with it. What you call an immutable number is in >> fact a container that contains a number. > > I wouldn't agree with that terminology or logic. Abstract numbers aren't really "things", they're concepts, and as such I don't think mutable or immutable has any meaning. But if it does, then abstract numbers are immutable, because you can't change one into two without losing the value one, and that certainly doesn't happen. > First of all "mutable number" is really just a short way to say "mutable > number object". Yes, but "object" in the above doesn't necessarily mean object in the sense of object-oriented programming. Perhaps a better word is "mutable number thing", where "thing" could be an object in the OOP sense, or a variable in the memory-location sense, or on a stack, in a register, or chalk marks on a whiteboard. > A number object in Python is not a number, it's just a > representation of a number. Even if numbers are immutable by nature, an > object representing a number need not be. /s/number/abstract number/ Given that, then I agree, but given Python's implementation, you would need more than one change to make number's mutable, and what you would have wouldn't be Python any more. > And if your number object is mutable, it does not make that object a > container, at least not what I would call a container. A container you > have to dereference somehow to get at the object inside, whereas a > mutable number object you don't dereference: it acts like number as- is. Agreed, so long as we're talking from the programmer's perspective. From the compiler's perspective, or the Virtual Machine's perspective, variables of the type "value stored at memory location" are a kind of container: you don't dereference anything, but the compiler does. There are multiple perspectives which are valid at once, depending on where you're looking from. A *name* is kind of a container (but not in the same sense that lists and dicts are containers), in that the VM has to dereference the name to get to the object. > IOW, the first example below is a container, the second is not: Do you mean the name `num` is a container, or the *contents* of `num` is a container? I assume you mean the contents. > num = [2] > num[0] += 3 > > num = mutable_int(2) > num += 3 In the sense of container that you give, I agree. But there's nothing magic about mutable_int() in the above -- num could be bound to a regular int, and it still wouldn't be a container. Obviously. > (If you want to call the mutable number a container anyway, fine with > me, I am not here to bicker.) A container is sufficient to get a layer > of indirection if that's what you want the mutable number for. > > However, the mutable number has a performance advantage over using a > container: it avoids the overhead of creating a new object. You're assuming that the overhead of flipping bits is less than the overhead of creating a new object, and that's almost certainly valid if the VM is implemented in (say) C. But it may not be the case if the VM is implemented in (say) Python, or Javascript, in which case "create a new object" might be less expensive than "flip a bunch of bits". If you can get the CPU to flip your bits, that will be fast, but perhaps your implementation needs to convert the int to a string of ones and zeroes, then perform bit-operations on those, then convert back to a real int. (I mention this as a theoretical issue, not a serious objection to the existing CPython implementation. But perhaps the PyPy people have to deal with it?) -- Steven From m.shanmugarajan at gmail.com Tue Sep 1 23:57:02 2009 From: m.shanmugarajan at gmail.com (Shan) Date: Tue, 1 Sep 2009 20:57:02 -0700 (PDT) Subject: Daemon process Message-ID: <7644caa7-d44a-4baf-bac9-33732c3af2f9@j19g2000yqk.googlegroups.com> I have XML RPC Server listening on a port. This XML RPC Server works fine when i run it as foreground process. All the clients are able to connect with the XML RPC Server. But when i run it as daemon(not using &. I am doing it in python way only), then no clients are able to connect with the Server. I didnt got any clue where i may be wrong. Can any help me with this? I am using python 2.4 on Redhat 5.2 64 X86_64 Thanks, Shan From gagsl-py2 at yahoo.com.ar Wed Sep 2 00:20:16 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Sep 2009 01:20:16 -0300 Subject: Every thing on a database References: Message-ID: En Tue, 01 Sep 2009 23:16:29 -0300, zelegolas escribi?: > I guess it's may be a strange idea that I will explain: > > I really like python but I have one thing that I don't like: Every > packages are defined with folder tree. To deploy an application it's > not really clean. > > It's why I thought about "Is that possible to put everything that I > need for my python application under one file?" Yes. py2exe, cx_freeze, and others do that. Basically, you put everything in a zip file, and insert its filename in sys.path > Base on this idea: If all packages are under one file. Like this each > time an import is executing it will automatically extract packages, > library or any files from this file first and if doesn't find it from > the standard way. This file could a SQLite file for example. > > I don't know if it's possible to overwrite the import behavior. > And may be what I describe is already develop by someone, if it's the > case just let me know. Yes, you can customize how import works in several ways. Look for "import" in the PEP index http://www.python.org/dev/peps/ (in chronological order! import semantics is currently a mess, due to successive patches over patches; hard to understand without a historical perspective) Brett Cannon is working on a pure Python implementation for import, and I think some kind of sqlite importer is in the plans... -- Gabriel Genellina From rt8396 at gmail.com Wed Sep 2 00:22:14 2009 From: rt8396 at gmail.com (r) Date: Tue, 1 Sep 2009 21:22:14 -0700 (PDT) Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: <8a368caa-4ef4-4547-9096-1ba33ef4c433@r34g2000vba.googlegroups.com> On Sep 1, 10:16?pm, Steven D'Aprano wrote: (snip) > That's a different kettle of fish. You don't do anybody any harm by > paying for Internet access for your neighbours (and anyone driving down > the street with a laptop and wi-fi). naughty, naughty! somebody's been wardriving! ;-) > Took me two weeks of elapsed time and around 30 hours of effort to remove > those suckers from the machine. Now I run Linux, behind two firewalls. Takes me less than one hour to rebuild my system including personal files, but excluding however winders updates cause there sure are a lot of thems updates :-O From steven at REMOVE.THIS.cybersource.com.au Wed Sep 2 00:24:21 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 04:24:21 GMT Subject: Every thing on a database References: Message-ID: On Tue, 01 Sep 2009 19:16:29 -0700, zelegolas wrote: > I really like python but I have one thing that I don't like: Every > packages are defined with folder tree. To deploy an application it's not > really clean. > > It's why I thought about "Is that possible to put everything that I need > for my python application under one file?" > > Base on this idea: If all packages are under one file. Like this each > time an import is executing it will automatically extract packages, > library or any files from this file first and if doesn't find it from > the standard way. This file could a SQLite file for example. Would a zip file do? http://docs.python.org/library/zipimport.html -- Steven From gagsl-py2 at yahoo.com.ar Wed Sep 2 00:25:40 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Sep 2009 01:25:40 -0300 Subject: Daemon process References: <7644caa7-d44a-4baf-bac9-33732c3af2f9@j19g2000yqk.googlegroups.com> Message-ID: En Wed, 02 Sep 2009 00:57:02 -0300, Shan escribi?: > I have XML RPC Server listening on a port. This XML RPC Server works > fine when i run it as foreground process. All the clients are able to > connect with the XML RPC Server. But when i run it as daemon(not using > &. I am doing it in python way only), then no clients are able to > connect with the Server. I didnt got any clue where i may be wrong. > Can any help me with this? I am using python 2.4 on Redhat 5.2 64 > X86_64 In what whay "no clients are able to connect with the Server"? What error(s) do the clients report? Can you see the process running (ps)? Can you see the port open (netstat)? Can you connect to the server using telnet, from the same host? -- Gabriel Genellina From sraji.me at gmail.com Wed Sep 2 00:41:38 2009 From: sraji.me at gmail.com (Raji Seetharaman) Date: Wed, 2 Sep 2009 10:11:38 +0530 Subject: Python-list Digest, Vol 72, Issue 10 In-Reply-To: References: Message-ID: <23e3fbb60909012141k6f1d0c30r8de633031eb1bd87@mail.gmail.com> Thanks MRAB. Now it works. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjns1989 at gmail.com Wed Sep 2 01:03:52 2009 From: cjns1989 at gmail.com (Chris Jones) Date: Wed, 02 Sep 2009 01:03:52 -0400 Subject: An assessment of the Unicode standard In-Reply-To: <4d84aaa7-5b8f-4e21-962e-75df48b20af1@q35g2000vbi.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3e9ddb9b-8f61-4d8d-a25c-7e95e8a25c06@g1g2000vbr.googlegroups.com> <200908311019.58029.hendrik@microcorp.co.za> <86tyzninh2.fsf@betla.izb.knu.ac.kr> <4d84aaa7-5b8f-4e21-962e-75df48b20af1@q35g2000vbi.googlegroups.com> Message-ID: <20090902050352.GD23062@turki.gavron.org> On Tue, Sep 01, 2009 at 03:16:03PM EDT, r wrote: [..] > Bring on the metric system Terry, i have been waiting all my life!! > > Now, if we can only convince those 800 million Mandarin Chinese > speakers... *ahem* Do we have a Chinese translator in the house? > > :-) "Between the idea And the reality Between the motion And the act Falls the Shadow" And further on.. "This is the way the world ends Not with a bang but a whimper." T. S. Eliot, "The Hollow Men" The very worst about you rant is that you may be the harbinger, a sign of things to come. A loud steady voice told him that "By this as your standard, you will conquer". 'nuff said.. have a good night. CJ From fetchinson at googlemail.com Wed Sep 2 01:42:14 2009 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Tue, 1 Sep 2009 22:42:14 -0700 Subject: Seeking a python code browser In-Reply-To: <258dd816-e513-4ef5-b0d7-1f8b98fa4d4b@o9g2000prg.googlegroups.com> References: <258dd816-e513-4ef5-b0d7-1f8b98fa4d4b@o9g2000prg.googlegroups.com> Message-ID: > Is there any recommendation for a python code browser (aka xref) tool. > I am a Source Navigator user, but seems like its python support is > flaky. Unless you can help me with that...which is my preferred way. Check out code investigator: http://codeinvestigator.googlepages.com/main HTH, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From tleeuwenburg at gmail.com Wed Sep 2 02:15:14 2009 From: tleeuwenburg at gmail.com (tleeuwenburg at gmail.com) Date: Tue, 1 Sep 2009 23:15:14 -0700 (PDT) Subject: Problem with multiprocessing Message-ID: <49a8d298-60f9-4b67-a5d7-ef37510fee1b@x25g2000prf.googlegroups.com> I have a problem using multiprocessing in a simple way. I created a file, testmp.py, with the following contents: --------------------------------------------------- import multiprocessing as mp p = mp.Pool(5) def f(x): return x * x print map(f, [1,2,3,4,5]) print p.map(f, [1,2,3,4,5]) ---------------------------------------------------- I'm using 2.6 r26:66713, so not quite bleeding edge. If I run 'python2.6 testmp.py' I get errors of exactly the kind mentioned on docs.python.org for when multiprocessing is run using the interactive interpreter. However, I'm obviously *not* running the interactive interpreter. Any suggestions? From tjreedy at udel.edu Wed Sep 2 02:16:27 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Sep 2009 02:16:27 -0400 Subject: Why does this group have so much spam? In-Reply-To: References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: Steven D'Aprano wrote: >> I have read more that one person advocating >> leaving one's wi-fi base open for anyone to use as the 'neighborly' >> thing to do. > > That's a different kettle of fish. You don't do anybody any harm by > paying for Internet access for your neighbours (and anyone driving down > the street with a laptop and wi-fi). Unless the 'neighbor' is your friendly local spam or malware merchant ;-) The rationale I have seen is this: if one leaves the wi-fi router open and illegal activity is conducted thru it, and there is no residual evidence on the hard drives of on-premises machines, then one may claim that it must have been someone else. On the other hand, if the router is properly closed, then it will be hard to argue that someone hacked trough it. There are, of course, flaws in this argument, and I take it as evidence of intention to conduct illegal activity, whether properly so or not. tjr From gagsl-py2 at yahoo.com.ar Wed Sep 2 02:52:55 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Sep 2009 03:52:55 -0300 Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <36f33f74-3c95-48da-887f-83139fd15a1a@r33g2000vbp.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> Message-ID: En Tue, 01 Sep 2009 19:49:57 -0300, r escribi?: > On Sep 1, 1:52?pm, Hyuga wrote: > (snip) >> I'd say don't feel the troll, but too late for that I guess. ? > > The only trolls in this thread are you and the others who breaks into > MY THREAD just for the knee-jerk reaction of troll calling! Even > though you *did* offer some argument to one of the subjects of this > thread, it was cancelled out by your trolling! Bueno, voy a escribir en el segundo lenguaje m?s hablado en el mundo (espa?ol), despu?s del mandar?n (con m?s de 1000 millones de personas). El ingl?s est? reci?n en el tercer puesto, con menos de la mitad de hablantes (500 millones). Si no me entend?s, jodete. Fuente: http://www.wolframalpha.com/input/?i=languages+in+the+world -- Gabriel Genellina From timr at probo.com Wed Sep 2 03:07:27 2009 From: timr at probo.com (Tim Roberts) Date: Wed, 02 Sep 2009 00:07:27 -0700 Subject: Is behavior of += intentional for int? References: <0022fef9$0$2930$c3e8da3@news.astraweb.com> Message-ID: <566s951tg4pd09k8e0k5vmutchifn51fib@4ax.com> Steven D'Aprano wrote: >On Sat, 29 Aug 2009 11:11:43 -0700, zaur wrote: > >> I thought that int as object will stay the same object after += but with >> another integer value. My intuition said me that int object which >> represent integer value should behave this way. > >If it did, then you would have this behaviour: > >>>> n = 3 # bind the name n to the object 3 >>>> saved_id = id(n) # get the id of the object >>>> n += 1 # add one to the object 3 >>>> assert n == 4 # confirm that it has value four >>>> assert id(n) == saved_id # confirm that it is the same object >>>> m = 3 # bind the name m to the object 3 >>>> print m + 1 # but object 3 has been modified >5 > >This would be pretty disturbing behaviour, and anything but intuitive. Yes, indeed, and it's quite possible to write code like this in Fortran that produces exactly this result -- an integer constant gets modified. This used to get big yucks when we gathered around the keypunch, before we had the Obfuscated C Contest to amuse us. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From dickinsm at gmail.com Wed Sep 2 03:07:33 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 2 Sep 2009 00:07:33 -0700 (PDT) Subject: Python3: hex() on arbitrary classes References: Message-ID: On Sep 1, 5:31?pm, Philipp Hagemeister wrote: > Mark Dickinson wrote: > > (...) If you want to be > > able to interpret instances of X as integers in the various Python > > contexts that expect integers (e.g., hex(), but also things like list > > indexing), you should implement the __index__ method: > > Thanks. Somehow forgot this magic method and deleted it by accident. I wonder whether it would make sense for the Python 2.x hex function to fall back to __index__ when __hex__ isn't defined. With the current setup, it's not clear how to write 2.x code that will also run (post 2to3 translation) properly on 3.x. -- Mark From kerensaelise at hotmail.com Wed Sep 2 03:25:36 2009 From: kerensaelise at hotmail.com (elsa) Date: Wed, 2 Sep 2009 00:25:36 -0700 (PDT) Subject: BeautifulSoup Message-ID: <0b1f1862-5abe-4514-9567-b95d396d6314@r24g2000prf.googlegroups.com> Hi all, if I have some HTML that looks like this: Gene: yjtD
Product: predicted rRNA methyltransferase, subunit of predicted rRNA methyltransferase
Intergenic distances (bp): yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();"> is there an easy way to use BeautifulSoup to extract just the value of the href attribute? Thanks, elsa From ihatespam at hotmail.com Wed Sep 2 03:27:03 2009 From: ihatespam at hotmail.com (Just Another Victim of the Ambient Morality) Date: Wed, 2 Sep 2009 03:27:03 -0400 Subject: Adjacency lists with sqlalchemy... Message-ID: I'm desperately trying to declare an adjacency list table with declarative_base() but I can't figure it out. Strangely, all the documentation avoids declarative_base() like the plague and does everything the hard way. What the hell is this thing for if we're not supposed to use it? If anyone can show me how to declaratively create ORM adjacency list or explain to me why this can't be done, I'd be very grateful. Thank you! From steven at REMOVE.THIS.cybersource.com.au Wed Sep 2 03:35:58 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 07:35:58 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote: > Steven D'Aprano wrote: > >>> I have read more that one person advocating leaving one's wi-fi base >>> open for anyone to use as the 'neighborly' thing to do. >> >> That's a different kettle of fish. You don't do anybody any harm by >> paying for Internet access for your neighbours (and anyone driving down >> the street with a laptop and wi-fi). > > Unless the 'neighbor' is your friendly local spam or malware merchant > ;-) Since they're sending spam through your account, it's the same as you sending the spam, and you're responsible for it. > The rationale I have seen is this: if one leaves the wi-fi router open > and illegal activity is conducted thru it, and there is no residual > evidence on the hard drives of on-premises machines, then one may claim > that it must have been someone else. On the other hand, if the router is > properly closed, then it will be hard to argue that someone hacked > trough it. > > There are, of course, flaws in this argument, and I take it as evidence > of intention to conduct illegal activity, whether properly so or not. So, if somebody leaves their car unlocked, is that evidence that they were intending to rob a bank and wanted a fast getaway car? If you leave your window open on a hot summer's night, is that evidence that you're planning to fake a burglary? If you leave your knife and fork unattended in a restaurant while you go to the toilet, is that evidence that you intended to stab the waiter and blame somebody else? I assume you would answer No to each of these. So why the harsher standard when it comes to computer crime? -- Steven From Brian.Mingus at colorado.edu Wed Sep 2 03:37:14 2009 From: Brian.Mingus at colorado.edu (Brian) Date: Wed, 2 Sep 2009 01:37:14 -0600 Subject: BeautifulSoup In-Reply-To: <0b1f1862-5abe-4514-9567-b95d396d6314@r24g2000prf.googlegroups.com> References: <0b1f1862-5abe-4514-9567-b95d396d6314@r24g2000prf.googlegroups.com> Message-ID: <9839a05c0909020037i25073190q13180e0901136ec4@mail.gmail.com> >>> from BeautifulSoup import BeautifulSoup >>> soup = BeautifulSoup("""Gene: yjtD
Product: predicted rRNA methyltransferase, subunit of ... predicted rRNA methyltransferase
Intergenic distances (bp): yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();"> ... """) >>> soup.area["href"] u'http://BioCyc.org/ECOLI/NEW-IMAGE ?\ntype=GENE-IN-CHROM-BROWSER&object=EG12309' On Wed, Sep 2, 2009 at 1:25 AM, elsa wrote: > Hi all, > > if I have some HTML that looks like this: > > Gene: yjtD
>Product: predicted rRNA methyltransferase, subunit of > predicted rRNA methyltransferase
Intergenic distances (bp): b> yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();"> > > > is there an easy way to use BeautifulSoup to extract just the value of > the href attribute? > > Thanks, > > elsa > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kerensaelise at hotmail.com Wed Sep 2 03:38:20 2009 From: kerensaelise at hotmail.com (elsa) Date: Wed, 2 Sep 2009 00:38:20 -0700 (PDT) Subject: map References: <777de4d8-e591-4d21-bbd0-b286105895bc@i18g2000pro.googlegroups.com> Message-ID: On Aug 31, 11:44?pm, Hendrik van Rooyen wrote: > On Monday 31 August 2009 11:31:34 Piet van Oostrum wrote: > > > But ultimately it is also very much a matter of taste, preference and > > habit. > > This is true, but there is another reason that I posted - I have noticed that > there seems to be a tendency amongst newcomers to the group to go to great > lengths to find something that will do exactly what they want, irrespective > of the inherent complexity or lack thereof of that which they are trying to > do. > > Now I cannot understand why this is - one could say that it is caused by an > eagerness to understand all the corners of the tool that is python, but > somehow it does not feel like that to me - I see it almost as a crisis of > confidence - as if the newbie lacks the self confidence to believe that he or > she is capable of doing anything independently. ? > > So whenever I can, I try to encourage people to just do it their way, and to > see what happens, and to hack using the interactive interpreter, to build > confidence by experimenting and making mistakes, and realizing that when you > have made a mistake, it is not the end of the world, ?- you can fix it and > move on. > > Don't know if this rant makes any sense... > > - Hendrik in my own defense - firstly, I was able to implement what I wanted to do with loops, and I used this to solve the problem I needed to. However, by asking *why* map didn't work, I now understand how map works, what contexts it may indeed be useful for, and what the alternatives are. To boot, you have all given me about 10 different ways of solving the problem, some of which use prettier (and probably faster) code than the loops I wrote... From hendrik at microcorp.co.za Wed Sep 2 03:40:11 2009 From: hendrik at microcorp.co.za (Hendrik van Rooyen) Date: Wed, 2 Sep 2009 09:40:11 +0200 Subject: Daemon process In-Reply-To: <7644caa7-d44a-4baf-bac9-33732c3af2f9@j19g2000yqk.googlegroups.com> References: <7644caa7-d44a-4baf-bac9-33732c3af2f9@j19g2000yqk.googlegroups.com> Message-ID: <200909020940.11805.hendrik@microcorp.co.za> On Wednesday 02 September 2009 05:57:02 Shan wrote: > I have XML RPC Server listening on a port. This XML RPC Server works > fine when i run it as foreground process. All the clients are able to > connect with the XML RPC Server. But when i run it as daemon(not using > &. I am doing it in python way only), then no clients are able to > connect with the Server. I didnt got any clue where i may be wrong. > Can any help me with this? I am using python 2.4 on Redhat 5.2 64 > X86_64 What does: "(not using &. I am doing it in python way only)" mean? How are you doing it? - Hendrik From hendrik at microcorp.co.za Wed Sep 2 03:58:43 2009 From: hendrik at microcorp.co.za (Hendrik van Rooyen) Date: Wed, 2 Sep 2009 09:58:43 +0200 Subject: An assessment of the Unicode standard In-Reply-To: References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> Message-ID: <200909020958.43202.hendrik@microcorp.co.za> On Wednesday 02 September 2009 08:52:55 Gabriel Genellina wrote: > En Tue, 01 Sep 2009 19:49:57 -0300, r escribi?: > > On Sep 1, 1:52?pm, Hyuga wrote: > > (snip) > > > >> I'd say don't feel the troll, but too late for that I guess. ? > > > > The only trolls in this thread are you and the others who breaks into > > MY THREAD just for the knee-jerk reaction of troll calling! Even > > though you *did* offer some argument to one of the subjects of this > > thread, it was cancelled out by your trolling! > > Bueno, voy a escribir en el segundo lenguaje m?s hablado en el mundo > (espa?ol), despu?s del mandar?n (con m?s de 1000 millones de personas). El > ingl?s est? reci?n en el tercer puesto, con menos de la mitad de hablantes > (500 millones). > > Si no me entend?s, jodete. > > Fuente: http://www.wolframalpha.com/input/?i=languages+in+the+world What do you call someone who speaks three languages? - trilingual. What do you call someone who speaks two languages? - bilingual. What do you call someone who only speaks one language? - A stupid gringo! Nice one Gabriel - and with a link too! Looks like I am going to have to learn some Castilian, or something. :-) - Hendrik From __peter__ at web.de Wed Sep 2 04:39:34 2009 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Sep 2009 10:39:34 +0200 Subject: BeautifulSoup References: <0b1f1862-5abe-4514-9567-b95d396d6314@r24g2000prf.googlegroups.com> Message-ID: elsa wrote: > if I have some HTML that looks like this: > > Gene: yjtD
>Product: predicted rRNA methyltransferase, subunit of > predicted rRNA methyltransferase
Intergenic distances (bp): b> yjjY< +400 yjtD +214 >thrL');" onmouseout="return nd();"> > > > is there an easy way to use BeautifulSoup to extract just the value of > the href attribute? >>> from BeautifulSoup import BeautifulSoup as BS >>> html = ">> BS(html).find("area")["href"] u'http://BioCyc.org/ECOLI/NEW-IMAGE?\ntype=GENE-IN-CHROM- BROWSER&object=EG12309' From sraji.me at gmail.com Wed Sep 2 04:39:38 2009 From: sraji.me at gmail.com (Raji Seetharaman) Date: Wed, 2 Sep 2009 14:09:38 +0530 Subject: AttributeError: 'NoneType' object has no attribute 'get_text' Message-ID: <23e3fbb60909020139s587c50afjae69ec51e7d9f397@mail.gmail.com> On Wed, Sep 2, 2009 at 10:11 AM, Raji Seetharaman wrote: > > Thanks MRAB. Now it works. > Raji.S -------------- next part -------------- An HTML attachment was scrubbed... URL: From piet at cs.uu.nl Wed Sep 2 04:45:09 2009 From: piet at cs.uu.nl (Piet van Oostrum) Date: Wed, 02 Sep 2009 10:45:09 +0200 Subject: Is behavior of += intentional for int? References: Message-ID: >>>>> Carl Banks (CB) wrote: >CB> On Sep 1, 10:40?am, Piet van Oostrum wrote: >>> >>> Numbers are immutable by nature (math). The number 3.14 remains 3.14 >>> whatever you try to do with it. What you call an immutable number is in >>> fact a container that contains a number. >CB> I wouldn't agree with that terminology or logic. >CB> First of all "mutable number" is really just a short way to say >CB> "mutable number object". A number object in Python is not a number, >CB> it's just a representation of a number. Even if numbers are immutable >CB> by nature, an object representing a number need not be. Yes, that remark I made was more on the meta level. >CB> And if your number object is mutable, it does not make that object a >CB> container, at least not what I would call a container. A container >CB> you have to dereference somehow to get at the object inside, whereas a >CB> mutable number object you don't dereference: it acts like number as- >CB> is. If you read the OP, that was exactly what the OP (human) expected. That the list would contain some kind of reference to the number. And then of course you would have to dereference it to get the number. >CB> IOW, the first example below is a container, the second is not: >CB> num = [2] >CB> num[0] += 3 >CB> num = mutable_int(2) >CB> num += 3 >CB> (If you want to call the mutable number a container anyway, fine with >CB> me, I am not here to bicker.) A container is sufficient to get a >CB> layer of indirection if that's what you want the mutable number for. >CB> However, the mutable number has a performance advantage over using a >CB> container: it avoids the overhead of creating a new object. If you >CB> were using += in a loop like this, it could turn out to be significant >CB> savings. But since that's not common in Python I'd have to agree that >CB> this optimization opportunity is best done with a third-party C- >CB> extension, and not the standard library. That's an implementation detail. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: piet at vanoostrum.org From __peter__ at web.de Wed Sep 2 04:51:05 2009 From: __peter__ at web.de (Peter Otten) Date: Wed, 02 Sep 2009 10:51:05 +0200 Subject: Problem with multiprocessing References: <49a8d298-60f9-4b67-a5d7-ef37510fee1b@x25g2000prf.googlegroups.com> Message-ID: tleeuwenburg at gmail.com wrote: > I have a problem using multiprocessing in a simple way. I created a > file, testmp.py, with the following contents: > > --------------------------------------------------- > import multiprocessing as mp > > p = mp.Pool(5) > > def f(x): > return x * x > > print map(f, [1,2,3,4,5]) > print p.map(f, [1,2,3,4,5]) > > ---------------------------------------------------- > > I'm using 2.6 r26:66713, so not quite bleeding edge. > > If I run 'python2.6 testmp.py' I get errors of exactly the kind > mentioned on docs.python.org for when multiprocessing is run using the > interactive interpreter. However, I'm obviously *not* running the > interactive interpreter. > > Any suggestions? I'm too lazy to read the docs, so I just tinkered: import multiprocessing as mp import testmp p = mp.Pool(5) def f(x): return x * x if __name__ == "__main__": print map(f, [1,2,3,4,5]) print p.map(testmp.f, [1,2,3,4,5]) From patrol at invisibleroads.com Wed Sep 2 05:12:26 2009 From: patrol at invisibleroads.com (Roy Hyunjin Han) Date: Wed, 02 Sep 2009 05:12:26 -0400 Subject: Problem with multiprocessing In-Reply-To: References: <49a8d298-60f9-4b67-a5d7-ef37510fee1b@x25g2000prf.googlegroups.com> Message-ID: <4A9E36FA.20705@invisibleroads.com> On 09/02/2009 04:51 AM, Peter Otten wrote: > tleeuwenburg at gmail.com wrote: > >> I have a problem using multiprocessing in a simple way. I created a >> file, testmp.py, with the following contents: >> >> --------------------------------------------------- >> import multiprocessing as mp >> >> p = mp.Pool(5) >> >> def f(x): >> return x * x >> >> print map(f, [1,2,3,4,5]) >> print p.map(f, [1,2,3,4,5]) > > I'm too lazy to read the docs, so I just tinkered: > > import multiprocessing as mp > import testmp > > p = mp.Pool(5) > > def f(x): > return x * x > > if __name__ == "__main__": > print map(f, [1,2,3,4,5]) > print p.map(testmp.f, [1,2,3,4,5]) > > Yes, to use the multiprocessing module, you must make your script importable, so runtime statements should go into a __main__ conditional. This way, when multiprocessing imports the module for each of its threads, the actual runtime code only gets executed once in the parent thread, which has the lock. At least, that is what I think is happening. import multiprocessing as mp def f(x): return x * x if __name__ == '__main__': p = mp.Pool(5) print map(f, [1,2,3,4,5]) print p.map(f, [1,2,3,4,5]) http://docs.python.org/library/multiprocessing.html -- http://invisibleroads.com Connecting Python developers with local businesses From python at mrabarnett.plus.com Wed Sep 2 05:22:50 2009 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 02 Sep 2009 10:22:50 +0100 Subject: Why does this group have so much spam? In-Reply-To: <00273d07$0$2930$c3e8da3@news.astraweb.com> References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> <00273d07$0$2930$c3e8da3@news.astraweb.com> Message-ID: <4A9E396A.9030201@mrabarnett.plus.com> Steven D'Aprano wrote: > On Tue, 01 Sep 2009 20:48:19 +0200, David wrote: > >> Il Tue, 1 Sep 2009 11:50:14 +0200, Andre Engels ha scritto: >> >> >>> What about mailing lists? There exist well-functioning mailing lists >>> with thousands of subscribers. Being a posting member of those will >>> significantly increase your internet bill under your proposal. >> It's an implementation issue, it doesn't touch the sense of proposal. >> One possibility is register the mail list to official registers and mail >> from a subscriber to other subscribers will be excluded from taxation or >> will have a lower tax rate. >> An excessive mailing from a single or few subscribers can be easily >> detected, traced, filtered and, if the case, prosecuted. > > This can be done already, without the need for an email tax. ISPs could > easily detect spammers, if they cared to. > > There are a few things that can already be done to cut the spam problem > to manageable size: > > (1) Why aren't ISPs blocking port 25 for home users by default? My home > ISP does, I can only send email through their mail server unless I ask > them nicely, in which case I'd be responsible for any spam that leaves my > home network. If I send spam, I'll be breaking my terms of service. > > (2) Why aren't ISPs cutting off detected spam bots? Owners of zombied PCs > are menaces to society. ISPs are in the best position to detect PCs which > are spamming, and alert the owner. If no action is taken in a week, warn > the owner that they're in breach of their terms of service, and if the > behaviour persists, cut the owner off until they clean up their PC. > Repeat offenders should be banned. > The preferred option these days is to slow down net access of the offenders, not cut them off completely. I'm not sure how many ISPs actually do that yet. From steven at REMOVE.THIS.cybersource.com.au Wed Sep 2 05:41:07 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 09:41:07 GMT Subject: [OT] evolution [was Re: An assessment of the Unicode standard] References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> <8f487fc8-93c0-4c32-bd95-96c849cbbaef@e18g2000vbe.googlegroups.com> Message-ID: This thread has intrigued me enough to bite the bullet and look up "r"'s posts. Oh my! They say a little learning is a dangerous thing, and this is a great example -- the only think bigger than r's ignorance and naivety on these topics is his confidence that he alone understands The Truth. Oh well, we were all kiddies like that once, so absolutely sure of ourselves on the basis of the most shallow paddling around on the shore of the sea of knowledge. I will limit myself to commenting on only one thing. (A good thing too, because this is long enough as it is.) On Tue, 01 Sep 2009 12:39:43 -0700, r wrote, quoting Steve (no relation : >> This might come as a bit of shock for you, but evolution awards those >> who are capable of adapting to complexity rather then those who expect >> things to be uniform. You, dear friend, and those who yearn for >> uniformity are the ones on the path to extinction. > > No evolution awards those that benefit evolution. You make it seem as > evolution is some loving mother hen, quite the contrary! Evolution is > selfish, greedy, and sometimes evil. And it will endure all of us... > > remember the old cliche "Nice guys finish last"? This is Not Even Wrong. Evolution isn't a *thing*, it is a *process*. Nothing exists to "benefit evolution", that's like saying that horses have long legs to "benefit running" or people have lungs to "benefit breathing". Horses have long legs so *they* can run, which is beneficial to *them* (but not earthworms, oak trees, eagles or sharks) because it enables them, indirectly, to survive long enough to produce offspring which are more likely to survive than they otherwise would be. Horses aren't the mechanism for running to make more running. Running is one of the ways horses survive long enough to make more horses. "R" is utterly confused if he thinks species live or die according to because they're benefiting evolution. Species live or die according to whether or not they reproduce, not due to services rendered to a process. Suggesting that species exist for the benefit of evolution is backwards -- it is like saying that we have computers and light bulbs and televisions and DVD players so that electricity can run through wires. Or that we build cars for the benefit of combustion. (This sort of nonsense, anthropomorphizing the process of evolution, seems to be unique to those on the right-wing of politics. Go figure.) Steve (the other Steve) is right -- species which are incapable of dealing with the complexity and dynamism of the world are doomed to extinction. Biologists have a word for stasis: "dead". The most vigorous, lively ecosystems are those that are complex, like rain forests (what used to be called "jungles" when I was a lad), coral reefs and mangroves. Messy, complicated, complex ecosystems are successful because they are resilient to damage -- a plague comes along and even if it kills off every individual of one species of fruit, there are a thousand different species unharmed. The sort of monoculture which "r" sings the praises of are fragile and brittle. Look at the Cavendish banana, nearly extinct because a disease is wiping the plants out, and there's not enough genetic variability in it to survive. (Fortunately there are dozens of varieties of bananas, so when the Cavendish becomes extinct, we'll still have bananas.) Or the Irish Potato Famine: millions of Irish dead from famine because 90% of their food intake came from a *single* source, potatoes, which in turn came from not just a single variety but just a handful of closely related individuals. (Well, also because the English were brutish thugs during the famine too, but that's just politics.) As for the idea "nice guys finish last", that's a ridiculous over- simplification. Vampire bats share their food with other vampire bats who otherwise would be hungry. Remoras stick to sharks, who carry them around for years without eating them. There's those little birds which climb into the mouths of crocodiles to clean their teeth while the crocodile sits patiently with it's mouth wide open. Wolves and wild dogs and hyenas hunt cooperatively. Baboons and chimpanzees form alliances. Penguins huddle together through the freezing months of darkness, and although the winds are so cold that the penguins on the outside would freeze to death, few of them do, because they all take their share of time in the centre. Monkeys cry out warnings when they see a leopard or a hawk, even though it puts them personally at risk. Meercats post sentries, who expose themselves to danger to protect the rest of the colony. And the most successful mammal on the planet, more successful than any other large animal, is also the most cooperative, least selfish species around. It is so unselfish, so cooperative, that individuals will rush into burning buildings to save complete strangers, and that cooperation has let the species colonize the entire planet and even send a few individuals, risking life and limb, to the Moon. -- Steven From gagsl-py2 at yahoo.com.ar Wed Sep 2 06:09:09 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Sep 2009 07:09:09 -0300 Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> <200909020958.43202.hendrik@microcorp.co.za> Message-ID: En Wed, 02 Sep 2009 04:58:43 -0300, Hendrik van Rooyen escribi?: > On Wednesday 02 September 2009 08:52:55 Gabriel Genellina wrote: >> Bueno, voy a escribir en el segundo lenguaje m?s hablado en el mundo >> (espa?ol), despu?s del mandar?n (con m?s de 1000 millones de personas). > > What do you call someone who speaks three languages? - trilingual. > > What do you call someone who speaks two languages? - bilingual. > > What do you call someone who only speaks one language? > - A stupid gringo! LOL! > Nice one Gabriel - and with a link too! > Looks like I am going to have to learn some Castilian, or something. > :-) Looks like we all will have to learn mandarin! A nice language but with a high entrance barrier for western people. -- Gabriel Genellina From python at mrabarnett.plus.com Wed Sep 2 06:10:10 2009 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 02 Sep 2009 11:10:10 +0100 Subject: using queue In-Reply-To: References: Message-ID: <4A9E4482.4030608@mrabarnett.plus.com> Tim Arnold wrote: > Hi, I've been using the threading module with each thread as a key in a > dictionary. I've been reading about Queues though and it looks like that's > what I should be using instead. Just checking here to see if I'm on the > right path. > The code I have currently compiles a bunch of chapters in a book (no more > than 80 jobs at a time) and just waits for them all to finish: > > max_running = 80 > threads = dict() > current = 1 > chaps = [x.config['name'] for x in self.document.chapter_objects] > while current <= len(chaps): > running = len([x for x in threads.keys() if > threads[x].isAlive()]) > if running == max_running: > time.sleep(10) > else: > chap = chaps[current - 1] > c = self.compiler(self.document.config['name'], chap) > threads[chap] = threading.Thread(target=c.compile) > threads[chap].start() > current += 1 > > for thread in threads.keys(): > threads[thread].join(3600.0) > --------------------------------- > but I think Queue could do a lot of the above work for me. Here is > pseudocode for what I'm thinking: > > q = Queue(maxsize=80) > for chap in [x.config['name'] for x in self.document.chapter_objects]: > c = self.compiler(self.document.config['name'], chap) > t = threading.Thread(target=c.compile) > t.start() > q.put(t) > q.join() > > is that the right idea? > I don't need that many threads; just create a few to do the work and let each do multiple chapters, something like this: class CompilerTask(object): def __init__(self, chapter_queue): self.chapter_queue = chapter_queue def __call__(self): while True: chapter = self.chapter_queue.get() if chapter is None: # A None indicates that there are no more chapters. break chapter.compile() # Put back the None so that the next thread will also see it. self.chapter_queue.put(None) MAX_RUNNING = 10 # Put the chapters into a queue, ending with a None. chapter_queue = Queue() for c in self.document.chapter_objects: chapter_queue.put(self.compiler(self.document.config['name'], c.config['name'])) chapter_queue.put(None) # Start the threads to do the work. for i in range(MAX_RUNNING): t = threading.Thread(target=CompilerTask(chapter_queue)) t.start() thread_list.append(t) # The threads will finish when they see the None in the queue. for t in thread_list: t.join() From victorsubervi at gmail.com Wed Sep 2 06:43:12 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Sep 2009 06:43:12 -0400 Subject: Problem w/ mysqldump Message-ID: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> Hi: I have the following python code: import os os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql") This nicely creates the file...but the file is empty! The database exists and has lots of data, I double-checked it. If there is nothing wrong with my code, is there some way to do the same thing from within MySQL? Can I at least print everything to screen and copy it? Where would I find my database in Windoze? TIA, Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.hellwig at dcuktec.org Wed Sep 2 07:16:37 2009 From: martin.hellwig at dcuktec.org (Martin P. Hellwig) Date: Wed, 02 Sep 2009 12:16:37 +0100 Subject: [OT] evolution [was Re: An assessment of the Unicode standard] In-Reply-To: References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> <8f487fc8-93c0-4c32-bd95-96c849cbbaef@e18g2000vbe.googlegroups.com> Message-ID: <0JqdnVXRsJOLyQPXnZ2dnUVZ8nGdnZ2d@bt.com> Steven D'Aprano wrote: I'd like to add the following: It is an intriguing human trade to attribute emotions and reasons to things that have none. Intriguing because I haven't observed yet that it provides an advantage, but it happens so often that I can't exclude it either. I find that evolution makes more sense _to_me_ if I see it in the following perspective: If something can happen, it will happen, if there is a higher chance something can happen more often, then it will happen more often, though not necessaryly at the time the observer expects it -- MPH http://blog.dcuktec.com 'If consumed, best digested with added seasoning to own preference.' From tino at wildenhain.de Wed Sep 2 07:28:21 2009 From: tino at wildenhain.de (Tino Wildenhain) Date: Wed, 02 Sep 2009 13:28:21 +0200 Subject: Why does this group have so much spam? In-Reply-To: References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: <4A9E56D5.8020809@wildenhain.de> Am 01.09.2009 22:10, schrieb David: > Il Mon, 31 Aug 2009 20:06:54 -0700 (PDT), r ha scritto: > ... >> The system is definitely flawed. I am no internet expert so i don't >> really know what we could do to fix it. I do fear goverment or >> corporations taking over of the internet and robbing use of our >> freedom of speech under the pretense that they will *somehow* save us >> from the spammers. Something must be done however. > > I definitely agree with you on that point, that's why I'm making this > proposal: the target is to reduce the spam *without* using armies of > cybercops patrolling all over the net. Here is another idea: for spam senders pointing to servers under jurisdiction, size the server and check all incoming requests from users - if they try to do a deal, prosecute a few of them in the public for supporting a crime. (And of course if possible get hold of the spammers too). Sure there would be corner cases where for example a competitor might try to discredit a company, but in most cases, cui bono should be the spammer after all. T. -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3254 bytes Desc: S/MIME Cryptographic Signature URL: From bearophileHUGS at lycos.com Wed Sep 2 07:35:54 2009 From: bearophileHUGS at lycos.com (Bearophile) Date: Wed, 2 Sep 2009 04:35:54 -0700 (PDT) Subject: Can't set attribute?! References: <071ba111-70d8-433e-a6c2-5e6f941f3c8a@v37g2000prg.googlegroups.com> <0c8c0e30-ae46-4727-b046-fc0c1b60540a@x6g2000prc.googlegroups.com> Message-ID: dolgion ch: >good to know about this __slots__ thing, i'll keep it in mind< What you have to keep in mind is that it's better to not use __slots__ unless you really need to. Generally you need it not for the purposes a person coming from a static language is tempted to use it for. It's mostly useful for small classes that don't need subclassing that have to be instantiated a large number of times. As far as I know, it's meant as a memory optimization, not a way to define things in a more explicit way. Bye, bearophile From ideamonk at gmail.com Wed Sep 2 07:49:12 2009 From: ideamonk at gmail.com (Abhishek Mishra) Date: Wed, 2 Sep 2009 17:19:12 +0530 Subject: Is it a bug? In-Reply-To: References: <87b7ce88-1f2f-43ff-8096-6a95a89b6e27@e27g2000yqm.googlegroups.com> <64160c70908292110j7dada27fl9b74c9333e135a99@mail.gmail.com> Message-ID: <64160c70909020449w190a50d5iad849d13cfe6faa@mail.gmail.com> Oops, missed out that... thanks On Sun, Aug 30, 2009 at 2:25 PM, Jan Kaliszewski wrote: > 30-08-2009 o 06:10:46 Abhishek Mishra wrote: > >> The single quote \' is the culprit. >> When you say ?words = ["Hi", "Whats up", "Bye"] and try print words, >> you get this - >> ['Hi', 'Whats up', 'Bye'] >> >> All double quotes converted to single ones. Now as for your input, >> notice the single quote in What's >> Now wrapping that word with single quotes won't be correct, so python >> uses double quotes to avoid any quote completion errors. >> But there's hardly much difference "foo" and 'foo' right? While in php >> you can notice some difference. >> >> Abhishek Mishra >> http://ideamonk.blogspot.com > > Hello, > > You posted your message only to me -- and probably wanted to post it > to the list? > > Cheers, > *j > > -- > Jan Kaliszewski (zuo) > From quentin.lampin at gmail.com Wed Sep 2 07:54:51 2009 From: quentin.lampin at gmail.com (Quentin Lampin) Date: Wed, 2 Sep 2009 13:54:51 +0200 Subject: exec globals and locals Message-ID: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> Hi, Being fairly new to Python, I'm trying to figure out the best way to use the exec statement and I must admit that I am a bit lost. Consider this case: exec "print 'a'" in {},{} [exp.1] It means that I'm (kindly) asking the interpreter to execute the code string "print 'a'" with empty globals and locals. Considering that globals and locals are empty, I would expect [exp.1] to raise an exception about 'print' not being known. However, the evaluation of [exp.1] produces an output... >>> exec "print 'a'" in {},{} a So, I decided to read more attentively the documentation and here is what I've found: """ As a side effect, an implementation may insert additional keys into the dictionaries given besides those corresponding to variable names set by the executed code. For example, the current implementation may add a reference to the dictionary of the built-in module __builtin__ under the key __builtins__ (!). """ Putting aside the fact that implementation specifics are evil, I would like to know if there is one way to force builtins not to be added to the scope? I would rather add this by myself which, in my opinion, is a more explicit, thus more pythonic, way of doing. Any comment on this? Regards, Quentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From nitebirdz at sacredchaos.com Wed Sep 2 08:13:26 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Wed, 2 Sep 2009 14:13:26 +0200 Subject: Problem w/ mysqldump In-Reply-To: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> Message-ID: <20090902121325.GA8255@sevilla.sacredchaos.com> On Wed, Sep 02, 2009 at 06:43:12AM -0400, Victor Subervi wrote: > Hi: > I have the following python code: > import os > os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql") > This nicely creates the file...but the file is empty! The database exists > and has lots of data, I double-checked it. If there is nothing wrong with my > code, is there some way to do the same thing from within MySQL? Can I at > least print everything to screen and copy it? Where would I find my database > in Windoze? Are you sure the password you entered is correct? I tested the code and it worked fine for me. However, when I used an incorrect password, it returned an error and did create an empty file, just as you describe. From pavlovevidence at gmail.com Wed Sep 2 08:40:51 2009 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Sep 2009 05:40:51 -0700 (PDT) Subject: Is behavior of += intentional for int? References: <0022fef9$0$2930$c3e8da3@news.astraweb.com> <566s951tg4pd09k8e0k5vmutchifn51fib@4ax.com> Message-ID: On Sep 2, 12:07?am, Tim Roberts wrote: > Steven D'Aprano wrote: > >On Sat, 29 Aug 2009 11:11:43 -0700, zaur wrote: > > >> I thought that int as object will stay the same object after += but with > >> another integer value. My intuition said me that int object which > >> represent integer value should behave this way. > > >If it did, then you would have this behaviour: > > >>>> n = 3 ? ? ? ? ? ? ? ? ? ? # bind the name n to the object 3 > >>>> saved_id = id(n) ? ? ? ? ?# get the id of the object > >>>> n += 1 ? ? ? ? ? ? ? ? ? ?# add one to the object 3 > >>>> assert n == 4 ? ? ? ? ? ? # confirm that it has value four > >>>> assert id(n) == saved_id ?# confirm that it is the same object > >>>> m = 3 ? ? ? ? ? ? ? ? ? ? # bind the name m to the object 3 > >>>> print m + 1 ? ? ? ? ? ? ? # but object 3 has been modified > >5 > > >This would be pretty disturbing behaviour, and anything but intuitive. > > Yes, indeed, and it's quite possible to write code like this in Fortran > that produces exactly this result -- an integer constant gets modified. > > This used to get big yucks when we gathered around the keypunch, before we > had the Obfuscated C Contest to amuse us. Many Fortran compilers these days pass scalars by value by default. Recently I had to compile a cicra-1972 Fortran program where I had to disable a lot of recent Fortran innovations (like from 1977) to get it to build properly. It turned out that it did try to modify a constant somewhere, but then it segfaulted because the compiler put that constant in read-only memory. (Whoever wrote the program originally was a smart cookie, BTW, it was super versatile for its time.) Carl Banks From victorsubervi at gmail.com Wed Sep 2 08:43:22 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Sep 2009 08:43:22 -0400 Subject: Problem w/ mysqldump In-Reply-To: <20090902121325.GA8255@sevilla.sacredchaos.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> Message-ID: <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> Obviously I'm sure. It created the file. But the file was blank. How can I do a mysqldump in mysql itself? V On Wed, Sep 2, 2009 at 8:13 AM, Nitebirdz wrote: > On Wed, Sep 02, 2009 at 06:43:12AM -0400, Victor Subervi wrote: > > Hi: > > I have the following python code: > > import os > > os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql") > > This nicely creates the file...but the file is empty! The database exists > > and has lots of data, I double-checked it. If there is nothing wrong with > my > > code, is there some way to do the same thing from within MySQL? Can I at > > least print everything to screen and copy it? Where would I find my > database > > in Windoze? > > Are you sure the password you entered is correct? I tested the code and > it worked fine for me. However, when I used an incorrect password, it > returned an error and did create an empty file, just as you describe. > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leerisq at gmail.com Wed Sep 2 09:20:01 2009 From: leerisq at gmail.com (LeeRisq) Date: Wed, 2 Sep 2009 06:20:01 -0700 (PDT) Subject: Issue with writelines Message-ID: <1ae5410a-8f4c-478a-99ef-007259bf4f57@j4g2000yqa.googlegroups.com> I've written this program that has been working fine until today. Can't work out why it stopped working. The program pulls a list from an xls file, inserts each item from the list into a repeating string, that then concatenates the repeating string and writes it to a text file. It has worked fine until today, and now for some reason, it stops after 30 items in my list. I also just tried another list, and that one stopped after 70 items. Perhaps someone could take a look? Here's the file followed by the traceback: import xlrd import win32clipboard def program_uno(): ofile = open(r"C:\Query\DQLVault.txt", "w") book = xlrd.open_workbook(r"C:\DocLoader\MCL_Drawing and Legacy Docloader Sheet.xls") sh = book.sheet_by_index(0) e = sh.cell_value(1, 0) a = sh.col_values(0, start_rowx=2, end_rowx=200) b = r'%' + e c = r'%Master-V%' y = r"SELECT object_name, bp_master_date, revision, bp_revision_date, bp_unit_no, r_version_label, r_object_id, r_lock_owner, r_content_size, a_content_type, r_modify_date, r_object_type, r_link_cnt, r_assembled_from_id, r_has_frzn_assembly, a_is_hidden, i_is_replica, i_is_reference, r_is_virtual_doc, i_chronicle_id, i_folder_id FROM mcl_engineer (ALL) WHERE (((upper (object_name) like upper('%s')) and (any upper(r_version_label) like upper('%s'))" %(b, c) w = r")) ORDER BY object_name ASC, r_object_id DESC, i_position DESC" ofile.writelines(y) for x in a: d = r'%' + x z = r" or (upper(object_name) like upper('%s')) and (any upper (r_version_label) like upper('%s'))" %(d, c) f = ofile.writelines(z) ofile.writelines(w) def copy_text(): ifile = open(r"C:\Query\DQLVault.txt", "r") text = ifile.read() ifile.close() win32clipboard.OpenClipboard() win32clipboard.EmptyClipboard() win32clipboard.SetClipboardText(text) win32clipboard.CloseClipboard() program_uno() copy_text() Traceback: File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\Query\DQL Vault Revision Check.py", line 34, in program_uno() File "C:\Query\DQL Vault Revision Check.py", line 20, in program_uno f = ofile.writelines(z) TypeError: writelines() argument must be a sequence of strings From emile at fenx.com Wed Sep 2 09:20:39 2009 From: emile at fenx.com (Emile van Sebille) Date: Wed, 02 Sep 2009 06:20:39 -0700 Subject: Why does this group have so much spam? In-Reply-To: <8a368caa-4ef4-4547-9096-1ba33ef4c433@r34g2000vba.googlegroups.com> References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> <8a368caa-4ef4-4547-9096-1ba33ef4c433@r34g2000vba.googlegroups.com> Message-ID: On 9/1/2009 9:22 PM r said... > On Sep 1, 10:16 pm, Steven D'Aprano >> Took me two weeks of elapsed time and around 30 hours of effort to remove >> those suckers from the machine. Now I run Linux, behind two firewalls. > > Takes me less than one hour to rebuild my system If that's your job (as it's sometimes mine) then that sounds about right. Otherwise, you must have a lot of practice rebuilding! Emile From bborcic at gmail.com Wed Sep 2 09:33:56 2009 From: bborcic at gmail.com (Boris Borcic) Date: Wed, 02 Sep 2009 15:33:56 +0200 Subject: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps) In-Reply-To: <1251816443.14859.15.camel@sverker-laptop> References: <1251816443.14859.15.camel@sverker-laptop> Message-ID: Sverker Nilsson wrote: >> Sverker Nilsson wrote: >>> It reads one Stat object at a time and wants to report something >>> when there is no more to be read from the file. >> Hmm, am I right in thinking the above can more nicely be written as: >> >> >>> from guppy import hpy >> >>> h = hpy() >> >>> f = open(r'your.hpy') >> >>> sets = [] >> >>> for s in iter(h.load(f)): sets.append(s) >> ... >> > The above iterates over one Stat object returned by h.load(f). I assume > you want to iterate over all the objects loaded. I dont know guppy, but if h.load(f) raises StopIteration upon eof, as seems implied by your proposal, then something like the following would work. sets.extend(h.load(f) for _ in xrange(1e9)) From tkpmep at gmail.com Wed Sep 2 09:51:15 2009 From: tkpmep at gmail.com (Thomas Philips) Date: Wed, 2 Sep 2009 06:51:15 -0700 (PDT) Subject: Simple addition to random module - Student's t Message-ID: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> While the random module allows one to generate randome numbers with a variety of distributions, some useful distributions are omitted - the Student's t being among them. This distribution is easily derived from the normal distribution and the chi-squared distribution (which in turn is a special case of the gamma distribution). I edited and tested a routine to generate random variables with a Student's t distribution that I found on http://www.johndcook.com/python_student_t_rng.html, which has one bug - there is an extra factor of two in y. The corrected and tested code follows - how does one go about getting this incorporated into random so that the entire community can beneffit from it? Sincerely Thomas Philips def student_t(df): # df is the number of degrees of freedom if df < 2 or int(df) != df: raise ValueError, 'student_tvariate: df must be a integer > 1' x = random.gauss(0, 1) y = random.gammavariate(df/2.0, 2) return x / (math.sqrt(y/df)) References: 1. Student's t distribution, including relationship to normal and chi- squared distributions: http://en.wikipedia.org/wiki/Student's_t-distribution 2. Chi-squared distribution, including relationship to Gamma distribution: http://en.wikipedia.org/wiki/Chi-square_distribution 3. John Cook's original version (with the extra factor of 2): http://www.johndcook.com/python_student_t_rng.html From garyrob at me.com Wed Sep 2 10:06:45 2009 From: garyrob at me.com (Gary Robinson) Date: Wed, 02 Sep 2009 10:06:45 -0400 Subject: pickling question Message-ID: <20090902100645603977.c602c75c@me.com> When you define a class in a script, and then pickle instances of that class in the same script and store them to disk, you can't load that pickle in another script. At least not the straightforward way [pickle.load(file('somefile.pickle'))]. If you try it, you get an AttributeError during the unpickling operation. There is no problem, of course, if the class is defined in a module which is imported by the pickling script. pickle.load(file('somefile.pickle')) then works. Rather than provide specific examples here, there's a blog post from 2005 that discusses this issue in depth and presents the problem very well: http://stefaanlippens.net/pickleproblem. (I tested in Python 2.6 yesterday and the same issue persists.) Questions: 1) Does this have to be the case, or is it a design problem with pickles that should be remedied? 2) Is there an easier way around it than moving the class definition to a separate module? The blog post I point to above suggests putting "__module__ = os.path.splitext(os.path.basename(__file__))[0]" into the class definiton, but that's not working in my testing because when I do that, the pickling operation fails. Is there something else that can be done? This is obviously not a huge problem. Substantial classes should usually be defined in a separate module anyway. But sometimes it makes sense for a script to define a really simple, small class to hold some data, and needing to create a separate module just to contain such a class can be a little annoying. -- Gary Robinson CTO Emergent Music, LLC personal email: garyrob at me.com work email: grobinson at flyfi.com Company: http://www.flyfi.com Blog: http://www.garyrobinson.net From mcravitz at att.net Wed Sep 2 10:07:23 2009 From: mcravitz at att.net (MikeC) Date: Wed, 2 Sep 2009 07:07:23 -0700 (PDT) Subject: win32ui DLL Load Failed References: <20090901091414.3ee27189@brasov> Message-ID: <3a51f4f9-e6b7-4abc-9cd3-60421cfa9d5c@f18g2000prf.googlegroups.com> On Sep 1, 12:14?am, Gregor Horvath wrote: > Am Mon, 31 Aug 2009 12:43:04 -0700 (PDT) > schriebMikeC: > > > I have a python executable that's failing to load on a user's machine > > running Windows XP. My developer machine is also running Windows XP. I > > have determined that it is failing when it attempts to load win32ui. > > > I have Python 2.6 on my developer machine and am using the pywin > > support (Mark Hammonds???) for Python 2.6. > > Try to install: > > http://www.microsoft.com/downloads/details.aspx?familyid=9b2da534-3e0... > > 2.6 is linked against VS8 dlls, which are missing on some machines. > > -- > Gregor Gregor, This solved my problem. Thank you so much! Mike From invalid at invalid Wed Sep 2 10:07:54 2009 From: invalid at invalid (Grant Edwards) Date: Wed, 02 Sep 2009 09:07:54 -0500 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On 2009-09-02, Terry Reedy wrote: > Steven D'Aprano wrote: > >>> I have read more that one person advocating >>> leaving one's wi-fi base open for anyone to use as the 'neighborly' >>> thing to do. >> >> That's a different kettle of fish. You don't do anybody any >> harm by paying for Internet access for your neighbours (and >> anyone driving down the street with a laptop and wi-fi). > > Unless the 'neighbor' is your friendly local spam or malware > merchant ;-) A spam/malware merchange who can't afford/arrange other internet access? How is net access on the critical path? -- Grant Edwards grante Yow! I haven't been married at in over six years, but we visi.com had sexual counseling every day from Oral Roberts!! From invalid at invalid Wed Sep 2 10:08:42 2009 From: invalid at invalid (Grant Edwards) Date: Wed, 02 Sep 2009 09:08:42 -0500 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On 2009-09-02, Steven D'Aprano wrote: > On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote: > >> Steven D'Aprano wrote: >> >>>> I have read more that one person advocating leaving one's wi-fi base >>>> open for anyone to use as the 'neighborly' thing to do. >>> >>> That's a different kettle of fish. You don't do anybody any harm by >>> paying for Internet access for your neighbours (and anyone driving down >>> the street with a laptop and wi-fi). >> >> Unless the 'neighbor' is your friendly local spam or malware >> merchant ;-) > > Since they're sending spam through your account, it's the same > as you sending the spam, and you're responsible for it. Nobody said anything about allowing anybody to "send spam through your account". -- Grant Edwards grante Yow! ! Everybody out of at the GENETIC POOL! visi.com From mwilson at the-wire.com Wed Sep 2 10:13:11 2009 From: mwilson at the-wire.com (Mel) Date: Wed, 02 Sep 2009 10:13:11 -0400 Subject: An assessment of the Unicode standard References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <3c95e541-1d4f-4de3-b14a-0730a764c893@33g2000vbe.googlegroups.com> <200909020958.43202.hendrik@microcorp.co.za> Message-ID: Gabriel Genellina wrote: > Looks like we all will have to learn mandarin! A nice language but with a > high entrance barrier for western people. It will pay off in the long run. Problem for me: it seems most people in Toronto speak Cantonese. That's just something I'll have to deal with. Wrote a little 3-in-a-row game to get familiar with Chinese characters. Astonished at how Chinese-ready Python 2.5 already is. Collecting characters from web sites and pasting them in to literals in the program source just works. Mel. From emile at fenx.com Wed Sep 2 10:18:28 2009 From: emile at fenx.com (Emile van Sebille) Date: Wed, 02 Sep 2009 07:18:28 -0700 Subject: Problem w/ mysqldump In-Reply-To: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> Message-ID: On 9/2/2009 3:43 AM Victor Subervi said... > Hi: > I have the following python code: > import os > os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql") First, test this at the system command line -- you'll likely get an empty file there as well, so calling from within python simply does the same. Then read the mysqldump docs for the command arguments and supply the database name... Emile > This nicely creates the file...but the file is empty! The database exists > and has lots of data, I double-checked it. If there is nothing wrong with my > code, is there some way to do the same thing from within MySQL? Can I at > least print everything to screen and copy it? Where would I find my database > in Windoze? > TIA, > Victor > From dickinsm at gmail.com Wed Sep 2 11:29:52 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 2 Sep 2009 08:29:52 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> Message-ID: On Sep 2, 2:51?pm, Thomas Philips wrote: > While the random module allows one to generate randome numbers with a > variety of distributions, some useful distributions are omitted - the > Student's t being among them. This distribution is easily derived from > the normal distribution and the chi-squared distribution (which in > turn is a special case of the gamma distribution). I edited and tested > a routine to generate random variables with a Student's t distribution > that I found onhttp://www.johndcook.com/python_student_t_rng.html, > which has ?one bug - there is an extra factor of two in y. The > corrected and tested code follows - how does one go about getting this > incorporated into random so that the entire community can beneffit > from it? To get this into core Python, you'd usually submit a feature request at http://bugs.python.org. To maximize the chances of the feature being accepted, provide unit tests and documentation along with the code. There's a lot of good information about how the Python development process works at http://www.python.org/dev; see especially http://www.python.org/dev/contributing/. Alternatively, you might also consider submitting something to the Python package index, http://pypi.python.org/pypi, or posting this as a recipe at http://code.activestate.com/recipes/langs/python/ -- Mark From doulos05 at gmail.com Wed Sep 2 11:31:20 2009 From: doulos05 at gmail.com (JonathanB) Date: Wed, 2 Sep 2009 08:31:20 -0700 (PDT) Subject: Entry Level Python Jobs Message-ID: I am a self-taught Python programmer with a liberal arts degree (Cross- cultural studies). I have been programming for several years now and would like to get a job as a python programmer. Unfortunately most of the job posts I have seen are for CS Majors or people with experience. Is there a place I can look for job posts for entry level positions requiring no experience? For the hiring managers, if the job post said "CS Major" in the requirements, would you consider a liberal arts major at all? From victorsubervi at gmail.com Wed Sep 2 11:44:35 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Sep 2009 11:44:35 -0400 Subject: Problem w/ mysqldump In-Reply-To: References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> Message-ID: <4dc0cfea0909020844ld4737c4j376f1e4b4e1e888b@mail.gmail.com> Not sure how to test it at the command line as you recommend; however, I most certainly did supply the db name. I most certainly did check the docs. I also looked at code I had previously written that worked. So I'm stumped! Is there any way to print it out to screen or (better yet) print to screen in mysql itself? TIA, V On Wed, Sep 2, 2009 at 10:18 AM, Emile van Sebille wrote: > On 9/2/2009 3:43 AM Victor Subervi said... > >> Hi: >> I have the following python code: >> import os >> os.system("mysqldump -u root -pPASSWORD --opt spreadsheets > dump.sql") >> > > First, test this at the system command line -- you'll likely get an empty > file there as well, so calling from within python simply does the same. > > Then read the mysqldump docs for the command arguments and supply the > database name... > > Emile > > > This nicely creates the file...but the file is empty! The database exists >> and has lots of data, I double-checked it. If there is nothing wrong with >> my >> code, is there some way to do the same thing from within MySQL? Can I at >> least print everything to screen and copy it? Where would I find my >> database >> in Windoze? >> TIA, >> Victor >> >> > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nitebirdz at sacredchaos.com Wed Sep 2 11:48:30 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Wed, 2 Sep 2009 17:48:30 +0200 Subject: Problem w/ mysqldump In-Reply-To: <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> Message-ID: <20090902154829.GB8255@sevilla.sacredchaos.com> On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote: > > Obviously I'm sure. It created the file. But the file was blank. How can I > do a mysqldump in mysql itself? > As I said, I only got a blank file when the actual command itself failed. How do you dump the MySQL database itself without using Python? Just run the 'mysqldump' command from the prompt. Is that what you are asking? Are you running this on Windows? What OS? You do have the 'mysqldump' command available from the shell prompt and in your path, right? From rt8396 at gmail.com Wed Sep 2 11:48:54 2009 From: rt8396 at gmail.com (r) Date: Wed, 2 Sep 2009 08:48:54 -0700 (PDT) Subject: Entry Level Python Jobs References: Message-ID: <3362ce37-9fd0-408b-b408-7594233ed04b@x38g2000yqb.googlegroups.com> On Sep 2, 10:31?am, JonathanB wrote: > I am a self-taught Python programmer with a liberal arts degree (Cross- > cultural studies). I have been programming for several years now and > would like to get a job as a python programmer. Unfortunately most of > the job posts I have seen are for CS Majors or people with experience. > > Is there a place I can look for job posts for entry level positions > requiring no experience? For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? Have you thought about getting involved with the Python core development. Not a paying position, but may lead you to some good connections, and i can't think of a better place to prove yourself than that ;-) From pavlovevidence at gmail.com Wed Sep 2 11:49:45 2009 From: pavlovevidence at gmail.com (Carl Banks) Date: Wed, 2 Sep 2009 08:49:45 -0700 (PDT) Subject: pickling question References: Message-ID: On Sep 2, 7:06?am, Gary Robinson wrote: > When you define a class in a script, and then pickle > instances of that class in the same script and store > them to disk, you can't load that pickle in another > script. At least not the straightforward way > [pickle.load(file('somefile.pickle'))]. If you try it, > you get an AttributeError during the unpickling > operation. It's because when you pickle from the script it's defined in the module is called '__main__'. When import the script file as a Python module from another script, the module is called 'script' or whatever the filename is. It's just the way importing works. > There is no problem, of course, if the class is defined > in a module which is imported by the pickling script. > pickle.load(file('somefile.pickle')) then works. > > Rather than provide specific examples here, there's a > blog post from 2005 that discusses this issue in depth > and presents the problem very > well:http://stefaanlippens.net/pickleproblem. (I tested > in Python 2.6 yesterday and the same issue persists.) Actually that page kind of glosses over the real issue. But never mind that. > Questions: > > 1) Does this have to be the case, or is it a design > problem with pickles that should be remedied? It won't be remedied for the just sake of pickling. However, I'm starting to think the underlying issue should be. It's by far the most confusing aspect of Python. > 2) Is there an easier way around it than moving the > class definition to a separate module? The blog post I > point to above suggests putting "__module__ = > os.path.splitext(os.path.basename(__file__))[0]" into > the class definiton, but that's not working in my > testing because when I do that, the pickling operation > fails. Is there something else that can be done? > > This is obviously not a huge problem. Substantial > classes should usually be defined in a separate module > anyway. But sometimes it makes sense for a script to > define a really simple, small class to hold some data, > and needing to create a separate module just to contain > such a class can be a little annoying. My general recommendation is not to mix scripts a modules unless you an expert on Python importing. A file should be either a script or a module, not both. Warning: It's really hard to be expert on Python importing. I've seen confusion about how imports work even from some very smart people on this list (most notably, from people who mistakenly believe that PEP 328 is a fix for your issue). Python importing is the biggest wart in the language by far. However, if you insist, I will tell you a workaround you can use. At the very top of your script put the following lines (replacing script with the module's filename minus the .py): import sys if __name__ == '__main__': ismain = True __name__ = 'script' sys.modules['script'] = sys.modules['__main__'] else: ismain = False Then use "if ismain" instead of "if __name__ == '__main__'" to determine if you are running from a script. This has to come before any class definitions or it won't work. This effectively renames the script's __main__ module to what it would have been if it had been imported. Then proceed with pickling as usual. Carl Banks From philip at semanchuk.com Wed Sep 2 11:59:32 2009 From: philip at semanchuk.com (Philip Semanchuk) Date: Wed, 2 Sep 2009 11:59:32 -0400 Subject: Entry Level Python Jobs In-Reply-To: <3362ce37-9fd0-408b-b408-7594233ed04b@x38g2000yqb.googlegroups.com> References: <3362ce37-9fd0-408b-b408-7594233ed04b@x38g2000yqb.googlegroups.com> Message-ID: On Sep 2, 2009, at 11:48 AM, r wrote: > On Sep 2, 10:31 am, JonathanB wrote: >> I am a self-taught Python programmer with a liberal arts degree >> (Cross- >> cultural studies). I have been programming for several years now and >> would like to get a job as a python programmer. Unfortunately most of >> the job posts I have seen are for CS Majors or people with >> experience. >> >> Is there a place I can look for job posts for entry level positions >> requiring no experience? For the hiring managers, if the job post >> said >> "CS Major" in the requirements, would you consider a liberal arts >> major at all? > > Have you thought about getting involved with the Python core > development. Not a paying position, but may lead you to some good > connections, and i can't think of a better place to prove yourself > than that ;-) Or instead of diving into the Python core which might be pretty heavy stuff, create some open source code -- a game, a calculator, a music generator, an app to automatically download weather maps, etc. Whatever tickles your fancy. If you're willing to stand on your merits (and it sounds like you are), you can point people to where your code is hosted and say, "I wrote that". Anyway, it's something to do in between hitting refresh on http://www.python.org/community/jobs/ Good luck to you Philip From ethan at stoneleaf.us Wed Sep 2 12:20:25 2009 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 02 Sep 2009 09:20:25 -0700 Subject: Entry Level Python Jobs In-Reply-To: References: <3362ce37-9fd0-408b-b408-7594233ed04b@x38g2000yqb.googlegroups.com> Message-ID: <4A9E9B49.9080506@stoneleaf.us> Philip Semanchuk wrote: > > On Sep 2, 2009, at 11:48 AM, r wrote: > >> On Sep 2, 10:31 am, JonathanB wrote: >> >>> I am a self-taught Python programmer with a liberal arts degree (Cross- >>> cultural studies). I have been programming for several years now and >>> would like to get a job as a python programmer. Unfortunately most of >>> the job posts I have seen are for CS Majors or people with experience. >>> >>> Is there a place I can look for job posts for entry level positions >>> requiring no experience? For the hiring managers, if the job post said >>> "CS Major" in the requirements, would you consider a liberal arts >>> major at all? >> >> >> Have you thought about getting involved with the Python core >> development. Not a paying position, but may lead you to some good >> connections, and i can't think of a better place to prove yourself >> than that ;-) > > > Or instead of diving into the Python core which might be pretty heavy > stuff, create some open source code -- a game, a calculator, a music > generator, an app to automatically download weather maps, etc. Whatever > tickles your fancy. If you're willing to stand on your merits (and it > sounds like you are), you can point people to where your code is hosted > and say, "I wrote that". > > Anyway, it's something to do in between hitting refresh on > http://www.python.org/community/jobs/ > > Good luck to you > Philip Philip is right -- I would consider a non-CS major, but then you'd get round-filed for the no experience. Write something, or better yet, a few smallish somethings and a medium something, and then you can claim experience. ~Ethan~ From dickinsm at gmail.com Wed Sep 2 12:28:14 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 2 Sep 2009 09:28:14 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> Message-ID: <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> On Sep 2, 2:51?pm, Thomas Philips wrote: > def student_t(df): ? ? ? ? # df is the number of degrees of freedom > ? ? if df < 2 ?or int(df) != df: > ? ? ? ?raise ValueError, 'student_tvariate: df must be a integer > 1' By the way, why do you exclude the possibility df=1 here? -- Mark From http Wed Sep 2 12:28:56 2009 From: http (Paul Rubin) Date: 02 Sep 2009 09:28:56 -0700 Subject: Entry Level Python Jobs References: Message-ID: <7x63c1joon.fsf@ruckus.brouhaha.com> JonathanB writes: > I am a self-taught Python programmer with a liberal arts degree (Cross- > cultural studies).... > Is there a place I can look for job posts for entry level positions > requiring no experience? For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? I think in the current economy there are not many entry level positions requiring no experience, except for internships and that sort of thing. Also there are some jobs which really do call for a CS major or someone of equivalent background. Often though, pure technical background doesn't matter as much as inventiveness and the ability to make things happen, which is more a matter of personality than training. I don't know what cross-cultural studies is, but I could imagine assignments (e.g. internationalizing the user interface of a program or web site) where someone with that background could work out fine. Basically I think for pure software development openings, you may be difficult to place, but there's lots of other types of openings where the primary task is something other than programming and yet incidental amounts of programming are involved. For those, you'd have a much better shot. One thing that can certainly help is to have a portfolio of code you've written for personal or academic projects or whatever. Where I work we're in the process of interviewing a guy who is some kind of artist, who has used Python in some pretty cool art projects. He has a bunch of code on his web site that were very helpful in getting an impression of his capabilities. From doulos05 at gmail.com Wed Sep 2 12:52:09 2009 From: doulos05 at gmail.com (JonathanB) Date: Wed, 2 Sep 2009 09:52:09 -0700 (PDT) Subject: Entry Level Python Jobs References: <7x63c1joon.fsf@ruckus.brouhaha.com> Message-ID: <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> Ok, so what I'm hearing is "Get a code portfolio together and watch the job board on python.org." Thanks for the advice! I've been watching the python job board 3-4 times a week and I've been working my way through the Project Euler problems in my free time. I also have a trade generator that I wrote up to support a Traveller game I was running a while back, but that code is old (the first non- trivial program I ever wrote) and really fairly buggy. The user interface is basically an infinite recursion that I sys.exit() out of when I'm through, which means the code slows considerably as you do more stuff in it because each trip back to the main menu is a recursive call to the main() function. Hey, I was young and naive. I'm working on cleaning it up right now. Any other tips? From tim.arnold at sas.com Wed Sep 2 13:00:51 2009 From: tim.arnold at sas.com (Tim Arnold) Date: Wed, 2 Sep 2009 13:00:51 -0400 Subject: using queue References: Message-ID: "MRAB" wrote in message news:mailman.835.1251886213.2854.python-list at python.org... > Tim Arnold wrote: >> Hi, I've been using the threading module with each thread as a key in a >> dictionary. I've been reading about Queues though and it looks like >> that's what I should be using instead. Just checking here to see if I'm >> on the right path. >> The code I have currently compiles a bunch of chapters in a book (no more >> than 80 jobs at a time) and just waits for them all to finish: >> >> max_running = 80 >> threads = dict() >> current = 1 >> chaps = [x.config['name'] for x in self.document.chapter_objects] >> while current <= len(chaps): >> running = len([x for x in threads.keys() if >> threads[x].isAlive()]) >> if running == max_running: >> time.sleep(10) >> else: >> chap = chaps[current - 1] >> c = self.compiler(self.document.config['name'], chap) >> threads[chap] = threading.Thread(target=c.compile) >> threads[chap].start() >> current += 1 >> >> for thread in threads.keys(): >> threads[thread].join(3600.0) >> --------------------------------- >> but I think Queue could do a lot of the above work for me. Here is >> pseudocode for what I'm thinking: >> >> q = Queue(maxsize=80) >> for chap in [x.config['name'] for x in self.document.chapter_objects]: >> c = self.compiler(self.document.config['name'], chap) >> t = threading.Thread(target=c.compile) >> t.start() >> q.put(t) >> q.join() >> >> is that the right idea? >> > I don't need that many threads; just create a few to do the work and let > each do multiple chapters, something like this: > > class CompilerTask(object): > def __init__(self, chapter_queue): > self.chapter_queue = chapter_queue > def __call__(self): > while True: > chapter = self.chapter_queue.get() > if chapter is None: > # A None indicates that there are no more chapters. > break > chapter.compile() > # Put back the None so that the next thread will also see it. > self.chapter_queue.put(None) > > MAX_RUNNING = 10 > > # Put the chapters into a queue, ending with a None. > chapter_queue = Queue() > for c in self.document.chapter_objects: > chapter_queue.put(self.compiler(self.document.config['name'], > c.config['name'])) > chapter_queue.put(None) > > # Start the threads to do the work. > for i in range(MAX_RUNNING): > t = threading.Thread(target=CompilerTask(chapter_queue)) > t.start() > thread_list.append(t) > > # The threads will finish when they see the None in the queue. > for t in thread_list: > t.join() > hi, thanks for that code. It took me a bit to understand what's going on, but I think I see it now. Still, I have two questions about it: (1) what's wrong with having each chapter in a separate thread? Too much going on for a single processor? I guess that probably doesn't matter at all, but some chapters run in minutes and some in seconds. (2) The None at the end of the queue...I thought t.join() would just work. Why do we need None? thanks for thinking about this, --Tim Arnold From tkpmep at gmail.com Wed Sep 2 13:03:07 2009 From: tkpmep at gmail.com (Thomas Philips) Date: Wed, 2 Sep 2009 10:03:07 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> Message-ID: <3b93d41e-d4b2-45c7-931f-8c2c0285fe58@y20g2000vbk.googlegroups.com> On Sep 2, 12:28?pm, Mark Dickinson wrote: > On Sep 2, 2:51?pm, Thomas Philips wrote: > > > def student_t(df): ? ? ? ? # df is the number of degrees of freedom > > ? ? if df < 2 ?or int(df) != df: > > ? ? ? ?raise ValueError, 'student_tvariate: df must be a integer > 1' > > By the way, why do you exclude the possibility df=1 here? > > -- > Mark I exclude df=1 hereBecause the variance is then infinite (in fact, the distribution is then Cauchy). That said, your point is well taken; allowing df=1 makes the Cauchy distribution available to users of random, in much the same way as the Gamma makes the Chi-squared available. Here's the revised code: def student_tvariate(df): # df is the number of degrees of freedom if df < 1 or int(df) != df: raise ValueError, 'student_tvariate: df must be a positive integer' x = random.gauss(0, 1) y = random.gammavariate(df/2.0, 2) return x / (math.sqrt(y/df)) I'll follow your suggestion, add in documentation and submit it to bugs.python.com. Thanks for your guidance. Thomas Philips From aahz at pythoncraft.com Wed Sep 2 13:08:52 2009 From: aahz at pythoncraft.com (Aahz) Date: 2 Sep 2009 10:08:52 -0700 Subject: Entry Level Python Jobs References: Message-ID: In article , JonathanB wrote: > >I am a self-taught Python programmer with a liberal arts degree (Cross- >cultural studies). I have been programming for several years now and >would like to get a job as a python programmer. Unfortunately most of >the job posts I have seen are for CS Majors or people with experience. > >Is there a place I can look for job posts for entry level positions >requiring no experience? For the hiring managers, if the job post said >"CS Major" in the requirements, would you consider a liberal arts >major at all? You should also look into finding e.g. a tech support job at a company using Python. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet From rogerdpack at gmail.com Wed Sep 2 13:10:51 2009 From: rogerdpack at gmail.com (rogerdpack) Date: Wed, 2 Sep 2009 10:10:51 -0700 (PDT) Subject: website feedback to where? Message-ID: Greetings. A little new to python here, but... on this page http://docs.python.org/3.1/tutorial/introduction.html some of the "text" examples are [incorrectly] color formatted. I assume this a bug reportable to bugs.python.org? Thanks! -r From exarkun at twistedmatrix.com Wed Sep 2 13:14:32 2009 From: exarkun at twistedmatrix.com (exarkun at twistedmatrix.com) Date: Wed, 02 Sep 2009 17:14:32 -0000 Subject: pickling question In-Reply-To: <20090902100645603977.c602c75c@me.com> References: <20090902100645603977.c602c75c@me.com> Message-ID: <20090902171432.7436.1793638222.divmod.xquotient.162@localhost.localdomain> On 02:06 pm, garyrob at me.com wrote: >When you define a class in a script, and then pickle instances of that >class in the same script and store them to disk, you can't load that >pickle in another script. At least not the straightforward way >[pickle.load(file('somefile.pickle'))]. If you try it, you get an >AttributeError during the unpickling operation. > >There is no problem, of course, if the class is defined in a module >which is imported by the pickling script. >pickle.load(file('somefile.pickle')) then works. > >Rather than provide specific examples here, there's a blog post from >2005 that discusses this issue in depth and presents the problem very >well: http://stefaanlippens.net/pickleproblem. (I tested in Python 2.6 >yesterday and the same issue persists.) > >Questions: > >1) Does this have to be the case, or is it a design problem with >pickles that should be remedied? > >2) Is there an easier way around it than moving the class definition to >a separate module? The blog post I point to above suggests putting >"__module__ = os.path.splitext(os.path.basename(__file__))[0]" into the >class definiton, but that's not working in my testing because when I do >that, the pickling operation fails. Is there something else that can be >done? I described another solution here: http://jcalderone.livejournal.com/45604.html Jean-Paul From adam.crossland at gmail.com Wed Sep 2 13:15:04 2009 From: adam.crossland at gmail.com (Adam) Date: Wed, 2 Sep 2009 10:15:04 -0700 (PDT) Subject: Entry Level Python Jobs References: Message-ID: <5e5c1640-41d9-41a1-aae7-0c908c5f08d4@v36g2000yqv.googlegroups.com> On Sep 2, 11:31?am, JonathanB wrote: > For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? I got my English Writing degree in 1990, and I have been a software engineer ever since. Landing the first job was very difficult, but it gave me the foundation of experience that allowed me to circumvent the "CS-degree or equivalent" requirement on every job that I have had since. If you do choose to pursue software development as a career, you'll be shocked at how many of your fellow liberal arts degree holders are doing the same. It will be a hard road. You will have to overcome significant obstacles. You will do boring, tedious work. You will find out what it really means to pay one's dues. You will also, perchance, succeed and find happiness in a fulfilling career. I think that Python is an outstanding foundation for learning programming, but I would advise you to branch out as quickly as possible. I imagine that saying so won't endear me to anyone here, but in good conscience, I have to recommend C# and the .NET framework; it has lead me to continual and well-paying employment for many, many years now. Also, put together an on-line portfolio of code, preferably composed of complete and useful programs. Actually seeing well- written, well-documented code can go a long way towards getting you in the door for an interview. From tkpmep at gmail.com Wed Sep 2 13:15:57 2009 From: tkpmep at gmail.com (Thomas Philips) Date: Wed, 2 Sep 2009 10:15:57 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> <3b93d41e-d4b2-45c7-931f-8c2c0285fe58@y20g2000vbk.googlegroups.com> Message-ID: On Sep 2, 1:03?pm, Thomas Philips wrote: > On Sep 2, 12:28?pm, Mark Dickinson wrote: > > > On Sep 2, 2:51?pm, Thomas Philips wrote: > > > > def student_t(df): ? ? ? ? # df is the number of degrees of freedom > > > ? ? if df < 2 ?or int(df) != df: > > > ? ? ? ?raise ValueError, 'student_tvariate: df must be a integer > 1' > > > By the way, why do you exclude the possibility df=1 here? > > > -- > > Mark > > I exclude df=1 hereBecause the variance is then infinite (in fact, the > distribution is then Cauchy). That said, your point is well taken; > allowing df=1 makes the Cauchy distribution available to users of > random, in much the same way as the Gamma makes the Chi-squared > available. Here's the revised code: > > def student_tvariate(df): ? ? ? ? # df is the number of degrees of > freedom > ? ? if df < 1 ?or int(df) != df: > ? ? ? ? raise ValueError, 'student_tvariate: df must be a positive > integer' > > ? ? x = random.gauss(0, 1) > ? ? y = random.gammavariate(df/2.0, 2) > > ? ? return x / (math.sqrt(y/df)) > > I'll follow your suggestion, add in documentation and submit it to > bugs.python.com. Thanks for your guidance. > > Thomas Philips Mark, I mis-spoke - the variance is infinite when df=2 (the variance is df/ (df-2), and you get the Cauchy when df=2. So I'm going to eat humble pie and go back to def student_tvariate(df): # df is the number of degrees of freedom if df < 2 or int(df) != df: raise ValueError, 'student_tvariate: df must be a integer > 1' x = random.gauss(0, 1) y = random.gammavariate(df/2.0, 2) return x / (math.sqrt(y/df)) I made the mistake because the denominator is equivalent to the square root of the sample variance of df normal observations, which in turn has df-1 degrees of freedom...............Oh well, I think it's much easier to apologize than to rationalize my error!!!! Sincerely Tom From gustavotabares at gmail.com Wed Sep 2 13:24:10 2009 From: gustavotabares at gmail.com (Gustavo) Date: Wed, 2 Sep 2009 10:24:10 -0700 (PDT) Subject: ctypes WNetGetUniversalNameW Message-ID: <721a32fd-e1a4-40bf-87fd-00d83a2283ef@y21g2000yqn.googlegroups.com> Hello, I'm trying to call WNetGetUniversalNameW via the ctypes module but I'm only causing the interpreter to crash. Unfortunately I don't have much experience with the ctypes module and I'm still trying to figure it out. I've searched for a solution to no avail. My confusion is centered around the LPVOID buffer parameter and how this should be created/used. Any help is appreciated. # DWORD WNetGetUniversalName( # __in LPCTSTR lpLocalPath, # __in DWORD dwInfoLevel, # __out LPVOID lpBuffer, # __inout LPDWORD lpBufferSize # ); import ctypes, win32netcon LPDWORD = ctypes.POINTER(DWORD) class UniversalNameInfo(ctypes.Structure): __fields__ = [("lpUniversalName", LPCWSTR)] WNetGetUniversalNameW = ctypes.windll.mpr.WNetGetUniversalNameW path = LPCWSTR('Y:') level = DWORD(win32netcon.UNIVERSAL_NAME_INFO_LEVEL) buffer_len = LPDWORD(DWORD(1024)) uni_struct = UniversalNameInfo() ret = WNetGetUniversalNameW(path, level, uni_struct, buffer_len) From python-url at phaseit.net Wed Sep 2 13:27:55 2009 From: python-url at phaseit.net (Gabriel Genellina) Date: Wed, 2 Sep 2009 17:27:55 +0000 (UTC) Subject: Python-URL! - weekly Python news and links (Sep 2) Message-ID: QOTW: "I like how being very friendly means calling people after a guy who tried to blow up the English Parliament." - Carl Banks http://groups.google.com/group/comp.lang.python/browse_thread/thread/7a190c24d8025bb4 unichr/ord cannot handle characters outside the BMP in a narrow build: http://groups.google.com/group/comp.lang.python/t/2fe770303f1d85ea/ How to determine if a class implements a particular interface: http://groups.google.com/group/comp.lang.python/t/27ea61dd2aaa0fcb/ Igor Novikov provides a lovely small pure-Python extension to manage ARGB cursors in Tkinter. http://tkinter.unpy.net/wiki/tkXcursor Why does `some_integer += 1` create a new integer object instead of incrementing the current value? http://groups.google.com/group/comp.lang.python/t/25b921e3b00ec2ae/ Iterating and mutating a list from two or more threads: http://groups.google.com/group/comp.lang.python/t/b19381a806007f4d/ Mapping message identifiers to methods: http://groups.google.com/group/comp.lang.python/t/8f7f1771945b4add/ A class definition doesn't introduce a new lexical scope - and that's a Good Thing [long thread]: http://groups.google.com/group/comp.lang.python/t/2cd187fa256744fe/ A clean way of adding directories to the module search path: http://groups.google.com/group/comp.lang.python/t/9052cc623088bdb2/ Recipe: convert an existing module into a package or sub-package http://groups.google.com/group/comp.lang.python/t/9919cf2a60722344/ Tools for designing professional-looking applications for Windows: http://groups.google.com/group/comp.lang.python/t/d22dcd394ab08333/ The basics for doing Web applications in Python: http://groups.google.com/group/comp.lang.python/t/1176ea4e6814f466/ What CAN'T be done in Python? http://groups.google.com/group/comp.lang.python/t/a368e85aa85ab436/ Favorite debugging tools? http://groups.google.com/group/comp.lang.python/t/1efb7b97d5d94d9b/ In 3.1, print() requires the terminal to be correctly configured with respect to locale settings: http://groups.google.com/group/comp.lang.python/t/8e666bb7eae9c859/ Idea: expand the for statement to accept additional, nested 'for's and an '= if' clause: http://groups.google.com/group/comp.lang.python/t/83b1d70457345877/ ======================================================================== Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish "the efforts of Python enthusiasts": http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the "Planet" sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/group/comp.lang.python.announce/topics Python411 indexes "podcasts ... to help people learn Python ..." Updates appear more-than-weekly: http://www.awaretek.com/python/index.html The Python Package Index catalogues packages. http://www.python.org/pypi/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among the ways you can support PSF is with a donation. http://www.python.org/psf/donations/ The Summary of Python Tracker Issues is an automatically generated report summarizing new bugs, closed ones, and patch submissions. http://search.gmane.org/?author=status%40bugs.python.org&group=gmane.comp.python.devel&sort=date Although unmaintained since 2002, the Cetus collection of Python hyperlinks retains a few gems. http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The Cookbook is a collaborative effort to capture useful and interesting recipes. http://code.activestate.com/recipes/langs/python/ Many Python conferences around the world are in preparation. Watch this space for links to them. Among several Python-oriented RSS/RDF feeds available, see: http://www.python.org/channews.rdf For more, see: http://www.syndic8.com/feedlist.php?ShowMatch=python&ShowStatus=all The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://www.python.org/dev/peps/pep-0042/ del.icio.us presents an intriguing approach to reference commentary. It already aggregates quite a bit of Python intelligence. http://del.icio.us/tag/python Enjoy the *Python Magazine*. http://pymag.phparch.com/ *Py: the Journal of the Python Language* http://www.pyzine.com Dr.Dobb's Portal is another source of Python news and articles: http://www.ddj.com/TechSearch/searchResults.jhtml?queryText=python and Python articles regularly appear at IBM DeveloperWorks: http://www.ibm.com/developerworks/search/searchResults.jsp?searchSite=dW&searchScope=dW&encodedQuery=python&rankprofile=8 Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://search.gmane.org/?query=python+URL+weekly+news+links&group=gmane.comp.python.general&sort=date http://groups.google.com/groups/search?q=Python-URL!+group%3Acomp.lang.python&start=0&scoring=d& http://lwn.net/Search/DoSearch?words=python-url&ctype3=yes&cat_25=yes There is *not* an RSS for "Python-URL!"--at least not yet. Arguments for and against are occasionally entertained. Suggestions/corrections for next week's posting are always welcome. E-mail to should get through. To receive a new issue of this posting in e-mail each Monday morning (approximately), ask to subscribe. Mention "Python-URL!". Write to the same address to unsubscribe. -- The Python-URL! Team-- Phaseit, Inc. (http://phaseit.net) is pleased to participate in and sponsor the "Python-URL!" project. Watch this space for upcoming news about posting archives. From steve at REMOVE-THIS-cybersource.com.au Wed Sep 2 13:33:13 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 17:33:13 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> <8a368caa-4ef4-4547-9096-1ba33ef4c433@r34g2000vba.googlegroups.com> Message-ID: <00282fe2$0$2930$c3e8da3@news.astraweb.com> On Wed, 02 Sep 2009 06:20:39 -0700, Emile van Sebille wrote: > On 9/1/2009 9:22 PM r said... >> On Sep 1, 10:16 pm, Steven D'Aprano >>> Took me two weeks of elapsed time and around 30 hours of effort to >>> remove those suckers from the machine. Now I run Linux, behind two >>> firewalls. >> >> Takes me less than one hour to rebuild my system > > If that's your job (as it's sometimes mine) then that sounds about > right. Otherwise, you must have a lot of practice rebuilding! I could have nuked the machine and rebuilt it from scratch, but I couldn't find my WinXP original media. Besides, when I started the process, I had no idea it would take so long. I learned one thing though. System Restore sounds like a good idea, but in my experience it's only good for restoring malware when you reboot. (I won't tell you how many times I deleted the same spyware apps before I worked out what was happening. Grrr arrghhhh.) -- Steven From rt8396 at gmail.com Wed Sep 2 13:34:06 2009 From: rt8396 at gmail.com (r) Date: Wed, 2 Sep 2009 10:34:06 -0700 (PDT) Subject: evolution [was Re: An assessment of the Unicode standard] References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> <8f487fc8-93c0-4c32-bd95-96c849cbbaef@e18g2000vbe.googlegroups.com> Message-ID: <48b23a30-9e3a-4383-8af7-75700cff9001@g6g2000vbr.googlegroups.com> On Sep 2, 4:41?am, Steven D'Aprano wrote: (snip) > > No evolution awards those that benefit evolution. You make it seem as > > evolution is some loving mother hen, quite the contrary! Evolution is > > selfish, greedy, and sometimes evil. And it will endure all of us... > > > remember the old cliche "Nice guys finish last"? > > This is Not Even Wrong. Evolution isn't a *thing*, it is a *process*. > Nothing exists to "benefit evolution", that's like saying that horses > have long legs to "benefit running" or people have lungs to "benefit > breathing". Well horses do have long and well evolved legs for running and humans lungs for breathing, and they have them because it benefits them which in turn benefits evolution. the buck stops with evolution. > "R" is utterly confused if he thinks species live or die according to > because they're benefiting evolution. Species live or die according to > whether or not they reproduce, Dear God i hate the current "progress" of evolution if reproduction guaranteed survival. I think it is just a "wee" bit more complicated than that Steven. *wink* > (This sort of nonsense, anthropomorphizing the process of evolution, > seems to be unique to those on the right-wing of politics. Go figure.) Uh? let's not go there. Leave politics corrupting influence out of this. > Steve (the other Steve) is right -- species which are incapable of > dealing with the complexity and dynamism of the world are doomed to > extinction. Biologists have a word for stasis: "dead". The most vigorous, > lively ecosystems are those that are complex, like rain forests (what > used to be called "jungles" when I was a lad), coral reefs and mangroves. > Messy, complicated, complex ecosystems are successful because they are > resilient to damage -- a plague comes along and even if it kills off > every individual of one species of fruit, there are a thousand different > species unharmed. > > The sort of monoculture which "r" sings the praises of are fragile and > brittle. Look at the Cavendish banana, nearly extinct because a disease > is wiping the plants out, and there's not enough genetic variability in > it to survive. (Fortunately there are dozens of varieties of bananas, so > when the Cavendish becomes extinct, we'll still have bananas.) You cannot draw parallels between bio diversity and language diversity. Bio diversity is fundamental to all species survival, even a virus. I am quite sure that the adoption of Universal World language will not usher in the apocalypse for human kind, quite the contrary! Ok a Jew, a Catholic Priest and a Chinese man walk into a bar.... Now if the bar suddenly catches fire and only one of them notices, how should this person convey the danger to the others. Well he could jump- up-and-down-yelling-oh!-oh!-oh!-with-arms-failing-in-the-air, but i think human evolution has presented a far more elegant way to communicate than that of the chimpanzee. > Or the Irish Potato Famine: millions of Irish dead from famine because > 90% of their food intake came from a *single* source, potatoes, which in > turn came from not just a single variety but just a handful of closely > related individuals. OMG! human kind will be utterly wiped out by the universal language. Somebody please jump-up-and-down-with-flailing-arms we must warn everyone of this impending doom before it is too late! (snip: more political innuendo) > As for the idea "nice guys finish last", that's a ridiculous over- > simplification. Vampire bats share their food with other vampire bats who > otherwise would be hungry. ...could be they are fatting them up for the kill! > Remoras stick to sharks, who carry them around > for years without eating them. ...Well yes sharks share a personality trait with cab drivers but...? And i wonder if they really *know* they are back there? Sharks aren't exactly evolutions shining jewel. > There's those little birds which climb > into the mouths of crocodiles to clean their teeth while the crocodile > sits patiently with it's mouth wide open. ...Hmm, i have thought about clamping down hard while my dentist pokes around with his fingers in there. But who then would clean my teeth? And it could be that those crocs are just slightly vain? > Wolves and wild dogs and hyenas > hunt cooperatively. Baboons and chimpanzees form alliances. Penguins > huddle together through the freezing months of darkness, and although the > winds are so cold that the penguins on the outside would freeze to death, > few of them do, because they all take their share of time in the centre. ...birds of a feather flock together! > Monkeys cry out warnings when they see a leopard or a hawk, even though > it puts them personally at risk. Meercats post sentries, who expose > themselves to danger to protect the rest of the colony. ...they could be expendable to the community! > And the most successful mammal on the planet, more successful than any > other large animal, is also the most cooperative, least selfish species > around. It is so unselfish, so cooperative, that individuals will rush > into burning buildings to save complete strangers I always found it a funny (but sad irony) of human our "supposedly" advanced civilization when public warning systems must be read in multiple languages. I guess the best you can hope for is that yours will be the read first. ;-) How do say... "BREAKING NEWS!: There has been a deadly cloud of gas released from a nearby chem plant, Currently the winds are moving south-south-west at 10 miles per hour. If you are in the downwind path of this cloud, move cross wind and up wind immediately or die!"....in all the languages of the world? """Oh evolution thou art very old and wise, save us from the polluting corruption of stupidity, save us now!""" I'd like to present a bug report to evolution, obviously the garbage collector is malfunctioning. From tim.wintle at teamrubber.com Wed Sep 2 13:35:31 2009 From: tim.wintle at teamrubber.com (Tim Wintle) Date: Wed, 02 Sep 2009 18:35:31 +0100 Subject: Entry Level Python Jobs In-Reply-To: References: Message-ID: <1251912931.6106.11.camel@tim-laptop> On Wed, 2009-09-02 at 08:31 -0700, JonathanB wrote: > I am a self-taught Python programmer with a liberal arts degree > (Cross-cultural studies). I have been programming for several years > now and would like to get a job as a python programmer. Unfortunately > most of the job posts I have seen are for CS Majors or people with > experience. > > Is there a place I can look for job posts for entry level positions > requiring no experience? For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? Definately not without any experience - but "experience" doesn't have to come from paid work - coding as a hobby in your free time is what's made all the best developers I know. Some things I personally would expect (and find more important than a CS background) - in order of importance: * Experience (e.g. open source / hobby projects / work) - several years worth. * Problem solving ability * A good comprehension of C, machine code, or something where you have to care about pointers/references. * Basic maths skills. Tim From s.selvamsiva at gmail.com Wed Sep 2 13:40:46 2009 From: s.selvamsiva at gmail.com (S.Selvam) Date: Wed, 2 Sep 2009 23:10:46 +0530 Subject: Issue with writelines In-Reply-To: <1ae5410a-8f4c-478a-99ef-007259bf4f57@j4g2000yqa.googlegroups.com> References: <1ae5410a-8f4c-478a-99ef-007259bf4f57@j4g2000yqa.googlegroups.com> Message-ID: On Wed, Sep 2, 2009 at 6:50 PM, LeeRisq wrote: > I've written this program that has been working fine until today. > Can't work out why it stopped working. The program pulls a list from > an xls file, inserts each item from the list into a repeating string, > that then concatenates the repeating string and writes it to a text > file. It has worked fine until today, and now for some reason, it > stops after 30 items in my list. I also just tried another list, and > that one stopped after 70 items. Perhaps someone could take a look? > > Here's the file followed by the traceback: > > import xlrd > import win32clipboard > > > > def program_uno(): > ofile = open(r"C:\Query\DQLVault.txt", "w") > book = xlrd.open_workbook(r"C:\DocLoader\MCL_Drawing and Legacy > Docloader Sheet.xls") > sh = book.sheet_by_index(0) > e = sh.cell_value(1, 0) > a = sh.col_values(0, start_rowx=2, end_rowx=200) > b = r'%' + e > c = r'%Master-V%' > y = r"SELECT object_name, bp_master_date, revision, > bp_revision_date, bp_unit_no, r_version_label, r_object_id, > r_lock_owner, r_content_size, a_content_type, r_modify_date, > r_object_type, r_link_cnt, r_assembled_from_id, r_has_frzn_assembly, > a_is_hidden, i_is_replica, i_is_reference, r_is_virtual_doc, > i_chronicle_id, i_folder_id FROM mcl_engineer (ALL) WHERE (((upper > (object_name) like upper('%s')) and (any upper(r_version_label) like > upper('%s'))" %(b, c) > > w = r")) ORDER BY object_name ASC, r_object_id DESC, i_position > DESC" > > ofile.writelines(y) > for x in a: > d = r'%' + x > z = r" or (upper(object_name) like upper('%s')) and (any upper > (r_version_label) like upper('%s'))" %(d, c) > f = ofile.writelines(z) > ofile.writelines(w) > > > def copy_text(): > ifile = open(r"C:\Query\DQLVault.txt", "r") > text = ifile.read() > ifile.close() > > win32clipboard.OpenClipboard() > win32clipboard.EmptyClipboard() > win32clipboard.SetClipboardText(text) > win32clipboard.CloseClipboard() > > program_uno() > copy_text() > > Traceback: > > File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework > \scriptutils.py", line 310, in RunScript > exec codeObject in __main__.__dict__ > File "C:\Query\DQL Vault Revision Check.py", line 34, in > program_uno() > File "C:\Query\DQL Vault Revision Check.py", line 20, in program_uno > f = ofile.writelines(z) > TypeError: writelines() argument must be a sequence of strings > why can't you print/analyse the 'z ' value on except block. > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Yours, S.Selvam -------------- next part -------------- An HTML attachment was scrubbed... URL: From victorsubervi at gmail.com Wed Sep 2 13:50:55 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Sep 2009 13:50:55 -0400 Subject: Problem w/ mysqldump In-Reply-To: <20090902154829.GB8255@sevilla.sacredchaos.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> <20090902154829.GB8255@sevilla.sacredchaos.com> Message-ID: <4dc0cfea0909021050p325903bdj29018e35588f5843@mail.gmail.com> I am running this on Windoze. I do not use the mysql db without python. I'm just building something for a client. I tried running the mysqldump command from the python prompt. Didn't know I could do that :) It tells me "mysqldump is not defined" :( V On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz wrote: > On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote: > > > > Obviously I'm sure. It created the file. But the file was blank. How can > I > > do a mysqldump in mysql itself? > > > > As I said, I only got a blank file when the actual command itself > failed. How do you dump the MySQL database itself without using Python? > Just run the 'mysqldump' command from the prompt. Is that what you are > asking? > > Are you running this on Windows? What OS? You do have the 'mysqldump' > command available from the shell prompt and in your path, right? > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Wed Sep 2 14:05:01 2009 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 02 Sep 2009 13:05:01 -0500 Subject: Simple addition to random module - Student's t In-Reply-To: <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> Message-ID: On 2009-09-02 11:28 AM, Mark Dickinson wrote: > On Sep 2, 2:51 pm, Thomas Philips wrote: >> def student_t(df): # df is the number of degrees of freedom >> if df< 2 or int(df) != df: >> raise ValueError, 'student_tvariate: df must be a integer> 1' > > By the way, why do you exclude the possibility df=1 here? Similarly, requiring df to be an integer is extraneous. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From singletoned at gmail.com Wed Sep 2 14:10:46 2009 From: singletoned at gmail.com (Ed Singleton) Date: Wed, 2 Sep 2009 11:10:46 -0700 (PDT) Subject: Python on the Web References: <5ee192da-c56a-4adf-9572-6e5b72bafead@y4g2000prf.googlegroups.com> Message-ID: On Aug 26, 4:17?am, alex23 wrote: > Frameworks created for the sake of creating a framework, as opposed to > those written to meet a defined need, tend to be the worst examples of > masturbatory coding. Indeed, but masturbation is perfectly healthy and acceptable, and we all do it every now and then. It is however, much like the framework in question, best kept private and not made public. Ed From rami.chowdhury at gmail.com Wed Sep 2 14:10:47 2009 From: rami.chowdhury at gmail.com (Rami Chowdhury) Date: Wed, 02 Sep 2009 11:10:47 -0700 Subject: Problem w/ mysqldump In-Reply-To: <4dc0cfea0909021050p325903bdj29018e35588f5843@mail.gmail.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> <20090902154829.GB8255@sevilla.sacredchaos.com> <4dc0cfea0909021050p325903bdj29018e35588f5843@mail.gmail.com> Message-ID: > I tried running the mysqldump command > from the python prompt I think you were being asked to try running it from the command prompt (cmd.exe) -- it won't work from the Python prompt, of course. On Wed, 02 Sep 2009 10:50:55 -0700, Victor Subervi wrote: > I am running this on Windoze. I do not use the mysql db without python. > I'm > just building something for a client. I tried running the mysqldump > command > from the python prompt. Didn't know I could do that :) It tells me > "mysqldump is not defined" :( > V > > On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz > wrote: > >> On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote: >> > >> > Obviously I'm sure. It created the file. But the file was blank. How >> can >> I >> > do a mysqldump in mysql itself? >> > >> >> As I said, I only got a blank file when the actual command itself >> failed. How do you dump the MySQL database itself without using Python? >> Just run the 'mysqldump' command from the prompt. Is that what you are >> asking? >> >> Are you running this on Windows? What OS? You do have the 'mysqldump' >> command available from the shell prompt and in your path, right? >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> -- Rami Chowdhury "Never attribute to malice that which can be attributed to stupidity" -- Hanlon's Razor 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) From tjreedy at udel.edu Wed Sep 2 14:30:41 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Sep 2009 14:30:41 -0400 Subject: website feedback to where? In-Reply-To: References: Message-ID: rogerdpack wrote: > on this page > > http://docs.python.org/3.1/tutorial/introduction.html > > some of the "text" examples are [incorrectly] color formatted. I did not see any problems with my browser (FF3.5), so please be more specific. > I assume this a bug reportable to bugs.python.org? Yes, this would be a components: documentation issue. Since you are new to this, reporting and asking here first is a good idea. (The tracker already has too many invalid newbie reports.) tjr From http Wed Sep 2 14:31:52 2009 From: http (Paul Rubin) Date: 02 Sep 2009 11:31:52 -0700 Subject: Entry Level Python Jobs References: <7x63c1joon.fsf@ruckus.brouhaha.com> <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> Message-ID: <7xr5upgpuv.fsf@ruckus.brouhaha.com> JonathanB writes: > Any other tips? Learn some more languages besides Python. Python is good to know but other languages present other ways of doing things. A skillful programmer has a variety of techniques to draw from. From dickinsm at gmail.com Wed Sep 2 14:37:33 2009 From: dickinsm at gmail.com (Mark Dickinson) Date: Wed, 2 Sep 2009 11:37:33 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> <3b93d41e-d4b2-45c7-931f-8c2c0285fe58@y20g2000vbk.googlegroups.com> Message-ID: <0eae0bdb-4c07-4968-8f48-67763ab0877a@t13g2000yqn.googlegroups.com> On Sep 2, 6:15?pm, Thomas Philips wrote: > I mis-spoke - the variance is infinite when df=2 (the variance is df/ > (df-2), Yes: the variance is infinite both for df=2 and df=1, and Student's t with df=1 doesn't even have an expectation. I don't see why this would stop you from generating meaningful samples, though. > and you get the Cauchy when df=2. Are you sure about this? All my statistics books are currently hiding in my mother-in-law's attic, several hundred miles away, but wikipedia and mathworld seem to say that df=1 gives you the Cauchy distribution. > I made the mistake because the denominator is ?equivalent to the > square root of the sample variance of df normal observations, As I'm reading it, the denominator is the square root of the sample variance of *df+1* independent standard normal observations. I agree that the wikipedia description is a bit confusing. It seems that there are uses for Student's t distribution with non-integral degrees of freedom. The Boost library, and the R programming language both allow non-integral degrees of freedom. So (as Robert Kern already suggested), you could drop the test for integrality of df. In fact, you could just drop the tests on df entirely: df <= 0.0 will be picked up in the gammavariate call. -- Mark From skip at pobox.com Wed Sep 2 14:42:07 2009 From: skip at pobox.com (Skip Montanaro) Date: Wed, 2 Sep 2009 18:42:07 +0000 (UTC) Subject: pickle error - 'module' object has no attribute =?utf-8?b?J19yZWNvbnN0cnVjdCc=?= Message-ID: Saw a new-to-me error today when trying to unpickle a moderately large object (about 500k): AttributeError: 'module' object has no attribute '_reconstruct' Google turned up nothing as far as I could tell, "_reconstruct" doesn't appear in the docs and pickletools.dis() was happy to disassemble the pickle. This was with Python 2.4. Any ideas about the cause of this error? Thx, Skip Montanaro From skip at pobox.com Wed Sep 2 14:53:54 2009 From: skip at pobox.com (Skip Montanaro) Date: Wed, 2 Sep 2009 18:53:54 +0000 (UTC) Subject: pickle error - 'module' object has no =?utf-8?b?YXR0cmlidXRlCSdfcmVjb25zdHJ1Y3Qn?= References: Message-ID: Skip Montanaro pobox.com> writes: > > Saw a new-to-me error today when trying to unpickle a moderately large > object (about 500k): > > AttributeError: 'module' object has no attribute '_reconstruct' I believe I have it figured out. Most of the pickled data consists of numpy arrays. It appears I picked up an ancient version of numpy when I got the failure. S From wiggly at wiggly.org Wed Sep 2 14:54:11 2009 From: wiggly at wiggly.org (Nigel Rantor) Date: Wed, 02 Sep 2009 19:54:11 +0100 Subject: evolution [was Re: An assessment of the Unicode standard] In-Reply-To: <48b23a30-9e3a-4383-8af7-75700cff9001@g6g2000vbr.googlegroups.com> References: <2ad2272a-e016-4c07-92cf-39f7823acf05@o35g2000vbi.googlegroups.com> <1ab2c088-bead-43fa-bf4a-3e7f4d84e871@g1g2000vbr.googlegroups.com> <59cad1ba-1162-4227-9375-d132ef030a7b@d21g2000vbm.googlegroups.com> <8f487fc8-93c0-4c32-bd95-96c849cbbaef@e18g2000vbe.googlegroups.com> <48b23a30-9e3a-4383-8af7-75700cff9001@g6g2000vbr.googlegroups.com> Message-ID: <4A9EBF53.1020704@wiggly.org> r wrote: > I'd like to present a bug report to evolution, obviously the garbage > collector is malfunctioning. I think most people think that when they read the drivel that you generate. I'm done with your threads and posts. *plonk* From kiithsacmp at gmail.com Wed Sep 2 14:59:39 2009 From: kiithsacmp at gmail.com (kiithsacmp at gmail.com) Date: Wed, 2 Sep 2009 11:59:39 -0700 (PDT) Subject: IMGCrush (New Python image optimizing tool) Message-ID: <549a065b-7928-4e15-8a7b-e6d0c3d3c5d5@h13g2000yqk.googlegroups.com> Hello people, I started to work on a small Python script to simplify mass conversion of images for a website I was working on. I eventually got interested in the script more than the site istelf, and it got a lot bigger, so I released it as an opensource project It's licensed under BSD and not very polished yet, but I think I reached a point where it's at least partially usable. It should run on most Unixes but it's not compatible with Windows (using unix shell). IMGCrush (as it's called) tries to save given image (or images, it can process directories of images as well) with the smallest possible filesize, so it works similarly to pngcrush and other png optimizers, with the exception that it can also save to GIF, JPG, PNG, and user can specify image quality loss he/she can tolerate. The way it's used is that the user for instance specfies that he/she wants an image with smallest possible size with at least 99% quality or the highest quality image with 50% of size of input, etc. (there are also other ways to measure quality/size). Quality isn't measured in a very "human" way now, which will hopefully change in future. IMGCrush is also quite slow at the moment, and will probably never be fast, but it can be a lot faster than it is now. Project is hosted at Launchpad: Homepage link: https://launchpad.net/icrush Downloads: https://launchpad.net/icrush/+download Use at your own risk :-) run "imgcrush --help" for usage instructions. Criticism/ideas/whatever is welcome. -Kiith-Sa From 71david at libero.it Wed Sep 2 15:04:00 2009 From: 71david at libero.it (David) Date: Wed, 2 Sep 2009 21:04:00 +0200 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> <00273d07$0$2930$c3e8da3@news.astraweb.com> Message-ID: Il Wed, 02 Sep 2009 10:22:50 +0100, MRAB ha scritto: > The preferred option these days is to slow down net access of the > offenders, not cut them off completely. I'm not sure how many ISPs > actually do that yet. If they do, it doesn't look like it's working that much. D. From adam.crossland at gmail.com Wed Sep 2 15:04:18 2009 From: adam.crossland at gmail.com (Adam) Date: Wed, 2 Sep 2009 12:04:18 -0700 (PDT) Subject: Entry Level Python Jobs References: <7x63c1joon.fsf@ruckus.brouhaha.com> <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> Message-ID: <870cff4c-2c24-4ba9-bdf9-f571fa33b97d@y9g2000yqn.googlegroups.com> On Sep 2, 12:52?pm, JonathanB wrote: > Any other tips? I'm probably going to come off as very old school, but give yourself a good and thorough education in data structures and algorithms. You might never be called on to actually code a quick sort, merge sort, heap sort, doubly-linked list or trie, but knowing what they are and why they are important will fundamentally shape how you approach all software problem solving. There are a lot of good data structures and algorithms books that use C, so that'd be a good approach to also adding a very important language to your toolbelt. From python at rcn.com Wed Sep 2 15:15:15 2009 From: python at rcn.com (Raymond Hettinger) Date: Wed, 2 Sep 2009 12:15:15 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> Message-ID: <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> On Sep 2, 6:51?am, Thomas Philips wrote: > While the random module allows one to generate randome numbers with a > variety of distributions, some useful distributions are omitted - the > Student's t being among them. I'm curious to hear what your use cases are. My understanding is that t-distribution is an estimation tool used with small samples of a population where the variance or standard deviation is unknown. So, when do you ever need to generate random variables with this distribution? ISTM that this is akin to wanting a generator for a Kolmogorov distribution -- usually the distribution is used to test empirical data, not to generate it. I think most of the existing generators were chosen because they are useful in simulation programs. AFAICT, the Student's t- distribution doesn't fall into that category (usually, you know the population standard deviation when you're the one generating data). ISTM, there ought to be a statistics module that can calculate cumulative distribution functions for a variety of distributions. This would be far more helpful than creating more generators. Raymond From python at rcn.com Wed Sep 2 15:22:05 2009 From: python at rcn.com (Raymond Hettinger) Date: Wed, 2 Sep 2009 12:22:05 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> Message-ID: <9f1697f9-ac92-470c-b022-a754a1d7a71a@x25g2000prf.googlegroups.com> > To get this into core Python, you'd usually submit a feature request > athttp://bugs.python.org. If you do submit a patch, please assign it to me. I've been the primary maintainer for that module for several years. Raymond Hettinger From tjreedy at udel.edu Wed Sep 2 15:22:08 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Sep 2009 15:22:08 -0400 Subject: Why does this group have so much spam? In-Reply-To: References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: Steven D'Aprano wrote: > On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote: >> The rationale I have seen is this: if one leaves the wi-fi router open >> and illegal activity is conducted thru it, and there is no residual >> evidence on the hard drives of on-premises machines, then one may claim >> that it must have been someone else. On the other hand, if the router is >> properly closed, then it will be hard to argue that someone hacked >> trough it. >> >> There are, of course, flaws in this argument, and I take it as evidence >> of intention to conduct illegal activity, whether properly so or not. > > So, if somebody leaves their car unlocked, is that evidence that they > were intending to rob a bank and wanted a fast getaway car? > > If you leave your window open on a hot summer's night, is that evidence > that you're planning to fake a burglary? > > If you leave your knife and fork unattended in a restaurant while you go > to the toilet, is that evidence that you intended to stab the waiter and > blame somebody else? > > > I assume you would answer No to each of these. So why the harsher > standard when it comes to computer crime? Your cases are not at all analogous or parallel. First, I did not say 'computer crime'. I said 'illegal activity, whether properly so [illegal] or not'. The latter is much broader, sometimes including the viewing of non-sexual pictures of undraped young adults. Second, I was talking about advocacy of 'open windows' by someone who knows how to close and lock a window. So the analogy would be someone who advocates leaving your living room window open so that if the Feds come knocking on your door about 'illegal' materials being sent to or from your home, you can claim that the within-house sender or receiver must have been a stranger that came in through the window. Hmmmm. [Of course, with unlockable street-side mailboxes, a stranger would not need an open window to do such.] Terry Jan Reedy From rt8396 at gmail.com Wed Sep 2 15:25:09 2009 From: rt8396 at gmail.com (r) Date: Wed, 2 Sep 2009 12:25:09 -0700 (PDT) Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> <8a368caa-4ef4-4547-9096-1ba33ef4c433@r34g2000vba.googlegroups.com> <00282fe2$0$2930$c3e8da3@news.astraweb.com> Message-ID: On Sep 2, 12:33?pm, Steven D'Aprano wrote: (snip) > I learned one thing though. System Restore sounds like a good idea, but > in my experience it's only good for restoring malware when you reboot. System restore is a joke! and a complete waste of HD space even if you have TB's to spare! Actually i can do with almost very piece of built- in software on this stinking windows platform. Microsoft's whole system of security is a joke as evidenced by Stevens experience. Windows ships with back doors wide open just begging for an infection! --------------------- BS Packaged software --------------------- Windows Mail -> virus magnet/backdoor use gmail Internet Exploder -> virus magnet/frontdoor, use Chrome|Mozilla Windows Calendar -> only slightly useful Windows Media Player -> complete bloatware Windows Media Center -> bloatware built on bloatware Windows sync center -> what a joke! Windows Movie Maker -> yea for kids and housewife's! Windows Photo Galley -> only slightly useful. Windows Update -> well i don't like hosting viruses so...? My meeting place -> worthless junk Windows Games -> *puke* -------------------- *Dangerous and annoying services and settings from the factory* -------------------- -Remote Resitry -> completly moronic! -Remote assistance -hide known filetypes -> Donde es "destroy useless bloatware button" -UAC -> what a nagging POS! -Menus are hidden by default in explorer -Ready Boost -> *puke* -Internet Connection Sharing -NET Tcp port sharing -Secondary Logon -Terminal Services -Windows BackUp -Windows remote managment -Routing and Remote Access -All Peer * services -all Windows Media center/player network services ---------------------- Accessories crap! ---------------------- Calculator -> POS, use the python shell instead CMD -> What else ya gonna use? Notepad -> What a useless POS, only one undo! COME ON! Paint -> are you jokeing M$ -- Glorified etch-a-sketch! sidebar -> Yes i love wasting memory just to see an analog clock! sound recorder -> very slightly useful, needs more functionality WordPad -> no thanks, OO will suffice! charactor map -> only slightly useful defragmenter -> too slow disk cleanup -> obviously made for morons! Internet Explorer(no add-ons) -> polish a turd, still a turd! Windows Experience index -> useless bloat Computer Management -> horrible UI Task Manager -> The worst UI i have ever used! (Vista) Windows Help -> maybe for complete morons! ----------------------- misc bloat ----------------------- Desktop backgrounds -> crap! use a solid color (black is my fav!) Sceen savers -> crap! ohh...look at the pretty colors! Windows Transparency -> crap! vanity run muck! Themes -> crap! adolescent accessorizing! Sadly none of these built in memory robbing hard space eating annoying POS bloatwares can be uninstalled. The only advancement (if you could call it that) with Vista is the search from start menu is much better than the previous "puppy dog" search of XP. Short of that Vista is just lipstick on a pig! Thanks M$ for bending us over yet again! From kiithsacmp at gmail.com Wed Sep 2 15:27:47 2009 From: kiithsacmp at gmail.com (kiithsacmp at gmail.com) Date: Wed, 2 Sep 2009 12:27:47 -0700 (PDT) Subject: notes Message-ID: Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6 but it might run on older python as well) From rt8396 at gmail.com Wed Sep 2 15:28:11 2009 From: rt8396 at gmail.com (r) Date: Wed, 2 Sep 2009 12:28:11 -0700 (PDT) Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> <00273d07$0$2930$c3e8da3@news.astraweb.com> Message-ID: <7f6b6945-669c-45bc-b243-9013a4e2cf33@r9g2000yqa.googlegroups.com> On Sep 2, 4:22?am, MRAB wrote: > The preferred option these days is to slow down net access of the > offenders, not cut them off completely. I'm not sure how many ISPs > actually do that yet. That seems to be the case with ISP and "good" users also in the form of quotas ;-) From kiithsacmp at gmail.com Wed Sep 2 15:29:18 2009 From: kiithsacmp at gmail.com (kiithsacmp at gmail.com) Date: Wed, 2 Sep 2009 12:29:18 -0700 (PDT) Subject: notes References: Message-ID: <055bb664-b145-4c02-9d11-a0b14ab20c28@r39g2000yqm.googlegroups.com> On Sep 2, 9:27?pm, "kiithsa... at gmail.com" wrote: > Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6 > but it might run on older python as well) Sorry, got confused by Google Groups interface and posted a new topic instead of just replying From kiithsacmp at gmail.com Wed Sep 2 15:30:29 2009 From: kiithsacmp at gmail.com (kiithsacmp at gmail.com) Date: Wed, 2 Sep 2009 12:30:29 -0700 (PDT) Subject: IMGCrush (New Python image optimizing tool) References: <549a065b-7928-4e15-8a7b-e6d0c3d3c5d5@h13g2000yqk.googlegroups.com> Message-ID: On Sep 2, 8:59?pm, "kiithsa... at gmail.com" wrote: > Hello people, > > I started to work on a small Python script to simplify mass conversion > of images for a website I was working on. > I eventually got interested in the script more than the site istelf, > and it got a lot bigger, so I released it as an opensource project > > It's licensed under BSD and not very polished yet, but I think I > reached a point where it's at least partially usable. > It should run on most Unixes but it's not compatible with Windows > (using unix shell). > > IMGCrush (as it's called) tries to save given image (or images, it can > process directories of images as well) > with the smallest possible filesize, so it works similarly to pngcrush > and other png optimizers, with the exception that it can also save to > GIF, JPG, PNG, and user can specify image quality loss he/she can > tolerate. > > The way it's used is that the user for instance specfies that he/she > wants an image with smallest possible size with at least 99% quality > or the highest quality image with 50% of size of input, etc. (there > are also other ways to measure quality/size). > Quality isn't measured in a very "human" way now, which will hopefully > change in future. > IMGCrush is also quite slow at the moment, and will probably never be > fast, but it can be a lot faster than it is now. > > Project is hosted at Launchpad: > Homepage link:https://launchpad.net/icrush > Downloads: ? ? ?https://launchpad.net/icrush/+download > > Use at your own risk :-) > run "imgcrush --help" for usage instructions. > > Criticism/ideas/whatever is welcome. > > -Kiith-Sa Requires ImageMagick and Python (coded in python 2.x, I'm running 2.6 but it might run on older python as well) From tkpmep at gmail.com Wed Sep 2 15:31:10 2009 From: tkpmep at gmail.com (Thomas Philips) Date: Wed, 2 Sep 2009 12:31:10 -0700 (PDT) Subject: Simple addition to random module - Student's t References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <488df176-374a-436a-8815-44b5e6f735f5@a7g2000yqo.googlegroups.com> <3b93d41e-d4b2-45c7-931f-8c2c0285fe58@y20g2000vbk.googlegroups.com> <0eae0bdb-4c07-4968-8f48-67763ab0877a@t13g2000yqn.googlegroups.com> Message-ID: <20165263-ae7f-4d00-aecc-7219a9592d82@k26g2000vbp.googlegroups.com> On Sep 2, 2:37?pm, Mark Dickinson wrote: > On Sep 2, 6:15?pm, Thomas Philips wrote: > > > I mis-spoke - the variance is infinite when df=2 (the variance is df/ > > (df-2), > > Yes: ?the variance is infinite both for df=2 and df=1, and Student's t > with df=1 doesn't even have an expectation. ?I don't see why this > would stop you from generating meaningful samples, though. > > > and you get the Cauchy when df=2. > > Are you sure about this? ?All my statistics books are currently hiding > in my mother-in-law's attic, several hundred miles away, but wikipedia > and mathworld seem to say that df=1 gives you the Cauchy distribution. > > > I made the mistake because the denominator is ?equivalent to the > > square root of the sample variance of df normal observations, > > As I'm reading it, the denominator is the square root of the sample > variance of *df+1* independent standard normal observations. ?I agree > that the wikipedia description is a bit confusing. > > It seems that there are uses for Student's t distribution with > non-integral degrees of freedom. ?The Boost library, and the R > programming language both allow non-integral degrees of freedom. > So (as Robert Kern already suggested), you could drop the test > for integrality of df. ?In fact, you could just drop the tests > on df entirely: ?df <= 0.0 will be picked up in the gammavariate > call. > > -- > Mark To tell you the truth, I have never used it with a non-integer number of degrees of freedom, but that's not the same as saying that df should be an integer. When df is an integer, one can interpret the t- distribution as the ratio of a unit normal (i.e. N(0,1)) to the sample standard deviation of a set of df+1 unit normals divided by sqrt(df +1). However, as Robert Kern correctly observes, the distribution is defined for all positive non-integer df, though we then lose the above interpretation, and must think of it in abstract terms. The distribution has infinite variance when df=2 and an undefined mean when df<=1, but the code can still be used to generate samples. Whether or not these samples make sense is altogether another question, but it's easy enough to remmove the restrictions. From python at rcn.com Wed Sep 2 15:34:12 2009 From: python at rcn.com (Raymond Hettinger) Date: Wed, 2 Sep 2009 12:34:12 -0700 (PDT) Subject: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps) References: <1251816443.14859.15.camel@sverker-laptop> Message-ID: <435ae491-6580-4985-8885-6ed9d3e7449c@m3g2000pri.googlegroups.com> > I dont know guppy, > but if h.load(f) raises StopIteration upon eof, as seems implied by your > proposal, then something like the following would work. > > sets.extend(h.load(f) for _ in xrange(1e9)) Sounds like hpy has a weird API. Either it should be an iterator supporting __iter__() and next() and raising StopIteration when it's done, or it should simply return None to indicate an empty load. In the first case, you would write: sets.extend(h.load(f)) And in the second case: sets.extend(iter(partial(h.load, f), None)) The first way just uses the iterator protocol in a way that is consistent with the rest of the language. The second way, using the two argument form of iter(), is the standard way of creating an iterator from a function that has a sentinel return value. IOW, it is not normal to use StopIteration in a function that isn't an iterator. Raymond From emile at fenx.com Wed Sep 2 15:36:32 2009 From: emile at fenx.com (Emile van Sebille) Date: Wed, 02 Sep 2009 12:36:32 -0700 Subject: Why does this group have so much spam? In-Reply-To: References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On 9/2/2009 7:07 AM Unknown said... > A spam/malware merchange who can't afford/arrange other > internet access? How is net access on the critical path? Mailbots (a significant source of spam IMHO) thrive on net access -- for them, is there anything _more_ critical? Emile From invalid at invalid Wed Sep 2 15:47:13 2009 From: invalid at invalid (Grant Edwards) Date: Wed, 02 Sep 2009 14:47:13 -0500 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: On 2009-09-02, Emile van Sebille wrote: > On 9/2/2009 7:07 AM Unknown said... >> A spam/malware merchange who can't afford/arrange other >> internet access? How is net access on the critical path? > > Mailbots (a significant source of spam IMHO) thrive on net access -- for > them, is there anything _more_ critical? A mailbot which would otherwise not have network access is going to come park itself outside my house if I leave my AP open? There are open APs at all sorts of libraries, coffee houses, restaurants, auto dealers, book stores, etc, etc. I don't see how net access is an issue for somebody who wants to send spam. -- Grant Edwards grante Yow! Now I am depressed ... at visi.com From 71david at libero.it Wed Sep 2 15:53:15 2009 From: 71david at libero.it (David) Date: Wed, 2 Sep 2009 21:53:15 +0200 Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> <00273d07$0$2930$c3e8da3@news.astraweb.com> Message-ID: Il 02 Sep 2009 00:17:05 GMT, Steven D'Aprano ha scritto: > This can be done already, without the need for an email tax. ISPs could > easily detect spammers, if they cared to. > > There are a few things that can already be done to cut the spam problem > to manageable size: > > (1) Why aren't ISPs blocking port 25 for home users by default? My home >[...] > (2) Why aren't ISPs cutting off detected spam bots? Owners of zombied PCs [...] > (3) ISPs who won't cut off spam bots are either incompetent or have a > financial incentive to do business with spammers. Therefore, responsible > ISPs should cut them off. If this means the email universe divides into > two halves, the Wild West where 999 emails out of every 1000 are spam, > and Civilization where only one in a thousand is spam, I'm okay with that. I don't know ISP's internal dynamics so I can't imagine what kind of financial incentive they have with spammers, AFAIK ISPs must sustain costs to augment their infrastructures to face this huge amount of traffic, costs charged on the subscribers monthly bill. At first this conduct can appear convenient but higer fares lead to reduced competitivity on the market. There are opposing forces that I can not interpret, so can not give an answer for that. > > As for the argument that home users who send spam are the victim, that's > true up to a point, but not very far. Here's an analogy: suppose that > terrorists sneak into your house after picking the lock -- or in the case > of Windows users with no firewall or anti-malware, stroll through the > unlocked front door -- and spend the next six months camped in your spare > bedroom, using your home for their base of operations while they make > terrorist attacks. When the FBI kicks your doors down, don't you think > you would be arrested and would have to prove that you couldn't be > reasonably expected to know they were there? If millions of spam emails > are coming out of your PC, that's prima facie evidence that YOU are > spamming. You would need to prove that you're an innocent victim who > couldn't *reasonably* be expected to know that your machine was hijacked > -- you would need to prove that the spam bot was so sophisticated that it > infected your PC despite the firewall, that you didn't install it > yourself in order to get some stupid game, that no commonly available > anti-malware program detects it. Anything less than that is *at least* > negligence, and possibly willful negligence. Mmh, sounds like a presumption of guilt. I wouldn't go so far on this way. The metaphor of terrorists in the bedroom applies up to a point. While it's evident that you can not be unaware of people living in your home, modern malware is made to be silent to the infected computer, so it's a hidden menace and not so evident. You are depicting a situation where the owner is perfectly aware of whats happening on his machine, but this is not always the case. I agree that ignorance is not an excuse but I wouldn't use the harsh manners at first. I think that the owner of the infected computer should be warned by his ISP, who can easily monitor the amount of traffic, and being induced to take countermisures. If that warning is an amount of maney to pay proportional to mail generated, I'm confident that it would be 'inducing' enough. After that the situation can develop only in three possible ways: 1) the owner takes appropriate countermisures proving his innocence (but he must pay the mail-tax for the period of infection!) 2) the owner takes no countermisures and pays the tax: it's very likely he is a spammer and we can start the assault with tanks 3) the owner takes no countermisures and doesn't pay the tax: well, It's up to you to choose the action to take towards him. [...] > Yes, I'd like to see the criminals, the malware authors and the spammers > punished, but I'd be satisfied to see them put out of business. The weak > link is the zombie PCs -- fix the home users' PCs, or block them, take > them off the Internet, and spam becomes manageable again. you got the crux of the matter. regards David From clp2 at rebertia.com Wed Sep 2 16:00:12 2009 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 2 Sep 2009 13:00:12 -0700 Subject: exec globals and locals In-Reply-To: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> References: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> Message-ID: <50697b2c0909021300o702e31acv2408f67065acc43@mail.gmail.com> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin wrote: > Hi, > Being fairly new to Python, I'm trying to figure out the best way to use the > exec statement and I must admit that I am a bit lost. > > Consider this case: > exec "print 'a'" in {},{}?? [exp.1] > It means? that I'm (kindly) asking the interpreter to execute the code > string? "print 'a'" with empty globals and locals. > Considering that globals and locals are empty, I would expect [exp.1] to > raise an exception about 'print' not being known. In Python versions prior to 3.0, print is a statement (like for, while, if, etc), not a function (note how you don't need parentheses when using it); so it doesn't matter whether the built-in functions are available or not, print will still work. Cheers, Chris -- http://blog.rebertia.com From aahz at pythoncraft.com Wed Sep 2 16:10:17 2009 From: aahz at pythoncraft.com (Aahz) Date: 2 Sep 2009 13:10:17 -0700 Subject: website feedback to where? References: Message-ID: In article , rogerdpack wrote: > >on this page > >http://docs.python.org/3.1/tutorial/introduction.html > >some of the "text" examples are [incorrectly] color formatted. > >I assume this a bug reportable to bugs.python.org? Actually, for doc bugs you should follow the instructions in the docs, see the link "Reporting bugs" at e.g. http://docs.python.org/3.1/ -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "Look, it's your affair if you want to play with five people, but don't go calling it doubles." --John Cleese anticipates Usenet From quentin.lampin at gmail.com Wed Sep 2 16:13:30 2009 From: quentin.lampin at gmail.com (Quentin Lampin) Date: Wed, 2 Sep 2009 22:13:30 +0200 Subject: exec globals and locals In-Reply-To: <50697b2c0909021300o702e31acv2408f67065acc43@mail.gmail.com> References: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> <50697b2c0909021300o702e31acv2408f67065acc43@mail.gmail.com> Message-ID: <7d0a60b00909021313l63a974dcr97120496d2506d2c@mail.gmail.com> 2009/9/2 Chris Rebert > On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin > wrote: > > Hi, > > Being fairly new to Python, I'm trying to figure out the best way to use > the > > exec statement and I must admit that I am a bit lost. > > > > Consider this case: > > exec "print 'a'" in {},{} [exp.1] > > It means that I'm (kindly) asking the interpreter to execute the code > > string "print 'a'" with empty globals and locals. > > Considering that globals and locals are empty, I would expect [exp.1] to > > raise an exception about 'print' not being known. > > In Python versions prior to 3.0, print is a statement (like for, > while, if, etc), not a function (note how you don't need parentheses > when using it); so it doesn't matter whether the built-in functions > are available or not, print will still work. > > Cheers, > Chris > -- > http://blog.rebertia.com > Ok, thanks for the explanation.I'm really confused with print being a statement but it's seems that I won't have to put too much effort on understanding why since 3.0 states the contrary. :p By the way, could you suggest me a link that explains why 3.0 changed this. It might provide some material to understand the pros and cons of "function statements". Regards, Quentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From clp2 at rebertia.com Wed Sep 2 16:19:06 2009 From: clp2 at rebertia.com (Chris Rebert) Date: Wed, 2 Sep 2009 13:19:06 -0700 Subject: exec globals and locals In-Reply-To: <7d0a60b00909021313l63a974dcr97120496d2506d2c@mail.gmail.com> References: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> <50697b2c0909021300o702e31acv2408f67065acc43@mail.gmail.com> <7d0a60b00909021313l63a974dcr97120496d2506d2c@mail.gmail.com> Message-ID: <50697b2c0909021319s2faecdkd94ddfb33f3be4c7@mail.gmail.com> On Wed, Sep 2, 2009 at 1:13 PM, Quentin Lampin wrote: > 2009/9/2 Chris Rebert >> >> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin >> wrote: >> > Hi, >> > Being fairly new to Python, I'm trying to figure out the best way to use >> > the >> > exec statement and I must admit that I am a bit lost. >> > >> > Consider this case: >> > exec "print 'a'" in {},{}?? [exp.1] >> > It means? that I'm (kindly) asking the interpreter to execute the code >> > string? "print 'a'" with empty globals and locals. >> > Considering that globals and locals are empty, I would expect [exp.1] to >> > raise an exception about 'print' not being known. >> >> In Python versions prior to 3.0, print is a statement (like for, >> while, if, etc), not a function (note how you don't need parentheses >> when using it); so it doesn't matter whether the built-in functions >> are available or not, print will still work. >> >> Cheers, >> Chris >> -- >> http://blog.rebertia.com > > Ok, thanks for the explanation. > I'm really confused with print being a statement but it's seems that I won't > have to put too much effort on understanding why since 3.0 states the > contrary. :p > By the way, could you suggest me a link that explains why 3.0 changed this. > It might provide some material to understand the pros and cons of "function > statements". http://www.python.org/dev/peps/pep-3105/ (PEP 3105 -- Make print a function) http://mail.python.org/pipermail/python-dev/2005-September/056154.html Cheers, Chris -- http://blog.rebertia.com From quentin.lampin at gmail.com Wed Sep 2 16:20:49 2009 From: quentin.lampin at gmail.com (Quentin Lampin) Date: Wed, 2 Sep 2009 22:20:49 +0200 Subject: exec globals and locals In-Reply-To: <50697b2c0909021319s2faecdkd94ddfb33f3be4c7@mail.gmail.com> References: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> <50697b2c0909021300o702e31acv2408f67065acc43@mail.gmail.com> <7d0a60b00909021313l63a974dcr97120496d2506d2c@mail.gmail.com> <50697b2c0909021319s2faecdkd94ddfb33f3be4c7@mail.gmail.com> Message-ID: <7d0a60b00909021320q5610cebl844f84deba040b79@mail.gmail.com> 2009/9/2 Chris Rebert > On Wed, Sep 2, 2009 at 1:13 PM, Quentin Lampin > wrote: > > 2009/9/2 Chris Rebert > >> > >> On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin > > >> wrote: > >> > Hi, > >> > Being fairly new to Python, I'm trying to figure out the best way to > use > >> > the > >> > exec statement and I must admit that I am a bit lost. > >> > > >> > Consider this case: > >> > exec "print 'a'" in {},{} [exp.1] > >> > It means that I'm (kindly) asking the interpreter to execute the code > >> > string "print 'a'" with empty globals and locals. > >> > Considering that globals and locals are empty, I would expect [exp.1] > to > >> > raise an exception about 'print' not being known. > >> > >> In Python versions prior to 3.0, print is a statement (like for, > >> while, if, etc), not a function (note how you don't need parentheses > >> when using it); so it doesn't matter whether the built-in functions > >> are available or not, print will still work. > >> > >> Cheers, > >> Chris > >> -- > >> http://blog.rebertia.com > > > > Ok, thanks for the explanation. > > I'm really confused with print being a statement but it's seems that I > won't > > have to put too much effort on understanding why since 3.0 states the > > contrary. :p > > By the way, could you suggest me a link that explains why 3.0 changed > this. > > It might provide some material to understand the pros and cons of > "function > > statements". > > http://www.python.org/dev/peps/pep-3105/ (PEP 3105 -- Make print a > function) > http://mail.python.org/pipermail/python-dev/2005-September/056154.html > > Cheers, > Chris > -- > http://blog.rebertia.com > Thanks a lot Chris! Quentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From robert.kern at gmail.com Wed Sep 2 16:34:26 2009 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 02 Sep 2009 15:34:26 -0500 Subject: Simple addition to random module - Student's t In-Reply-To: <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> Message-ID: On 2009-09-02 14:15 PM, Raymond Hettinger wrote: > On Sep 2, 6:51 am, Thomas Philips wrote: >> While the random module allows one to generate randome numbers with a >> variety of distributions, some useful distributions are omitted - the >> Student's t being among them. > > I'm curious to hear what your use cases are. > > My understanding is that t-distribution is an estimation tool > used with small samples of a population where the variance or > standard deviation is unknown. > > So, when do you ever need to generate random variables with > this distribution? ISTM that this is akin to wanting > a generator for a Kolmogorov distribution -- usually the > distribution is used to test empirical data, not to generate it. In more complicated models, estimates of one parameter need to be propagated through the model, particularly if you are looking at sensitivity to parameters. Student's t describes the variation of an estimate of a mean of a sample from a Gaussian distribution. If I were modeling a processing wherein someone makes an estimate of a mean and then acts on that estimate, I would want to generate random t variates to feed that model. > I think most of the existing generators were chosen because they > are useful in simulation programs. AFAICT, the Student's t- > distribution > doesn't fall into that category (usually, you know the population > standard deviation when you're the one generating data). Student's t distribution is also used as a sort of generic fat-tailed distribution in some models and is not tied to the "estimate of a mean" description. > ISTM, there ought to be a statistics module that can calculate > cumulative distribution functions for a variety of distributions. > This would be far more helpful than creating more generators. Yes, scipy.stats. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From victorsubervi at gmail.com Wed Sep 2 16:45:02 2009 From: victorsubervi at gmail.com (Victor Subervi) Date: Wed, 2 Sep 2009 16:45:02 -0400 Subject: Problem w/ mysqldump In-Reply-To: References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> <20090902154829.GB8255@sevilla.sacredchaos.com> <4dc0cfea0909021050p325903bdj29018e35588f5843@mail.gmail.com> Message-ID: <4dc0cfea0909021345y749fe36cv5388c6a292c1fddf@mail.gmail.com> I tried running it like you said, got this error: 'mysqldump' is not a recognized internal or external command. If I could just figure out in what file the data were stored, I could copy it and try it in another computer. Any ideas? TIA, V On Wed, Sep 2, 2009 at 2:10 PM, Rami Chowdhury wrote: > I tried running the mysqldump command >> from the python prompt >> > > I think you were being asked to try running it from the command prompt > (cmd.exe) -- it won't work from the Python prompt, of course. > > > On Wed, 02 Sep 2009 10:50:55 -0700, Victor Subervi < > victorsubervi at gmail.com> wrote: > > I am running this on Windoze. I do not use the mysql db without python. I'm >> just building something for a client. I tried running the mysqldump >> command >> from the python prompt. Didn't know I could do that :) It tells me >> "mysqldump is not defined" :( >> V >> >> On Wed, Sep 2, 2009 at 11:48 AM, Nitebirdz > >wrote: >> >> On Wed, Sep 02, 2009 at 08:43:22AM -0400, Victor Subervi wrote: >>> > >>> > Obviously I'm sure. It created the file. But the file was blank. How >>> can >>> I >>> > do a mysqldump in mysql itself? >>> > >>> >>> As I said, I only got a blank file when the actual command itself >>> failed. How do you dump the MySQL database itself without using Python? >>> Just run the 'mysqldump' command from the prompt. Is that what you are >>> asking? >>> >>> Are you running this on Windows? What OS? You do have the 'mysqldump' >>> command available from the shell prompt and in your path, right? >>> >>> -- >>> http://mail.python.org/mailman/listinfo/python-list >>> >>> > > > -- > Rami Chowdhury > "Never attribute to malice that which can be attributed to stupidity" -- > Hanlon's Razor > 408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rogerpack2005 at gmail.com Wed Sep 2 16:47:04 2009 From: rogerpack2005 at gmail.com (rogerdpack) Date: Wed, 2 Sep 2009 13:47:04 -0700 (PDT) Subject: website feedback to where? References: Message-ID: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> On Sep 2, 12:30?pm, Terry Reedy wrote: > rogerdpack wrote: > > on this page > > >http://docs.python.org/3.1/tutorial/introduction.html > > > some of the "text" examples are [incorrectly] color formatted. > > I did not see any problems with my browser (FF3.5), so please be more > specific. search for "This is a rather long string containing" I suppose this is more of a documentation bug... From garyrob at me.com Wed Sep 2 16:51:29 2009 From: garyrob at me.com (Gary Robinson) Date: Wed, 02 Sep 2009 16:51:29 -0400 Subject: pickling question Message-ID: <20090902165129192897.0723c764@me.com> Many thanks for the responses I've received here to my question (below). After reading the responses, I understand what the problem is much better. In addition to the solutions mentioned in the responses, now that I understand the problem I'll offer up my own solution. The following is an executable script named pick1.py: =============== import pickle class A(object): def __init__(self, x): self.x = x def writePickle(): import pick1 a5 = pick1.A(5) f = open('pick1.pickle', 'wb') pickle.dump(a5, f) f.close() writePickle() # The dumped pickle can be read by any other script. ================ That is, we need to do the pickling in a context where the module name for the class is "pick1" rather than "__main__". The example above allows us to do that without changing __name__ or doing anything else of that nature. Thanks again! Gary > When you define a class in a script, and then pickle instances of > that class in the same script and store them to disk, you can't load > that pickle in another script. At least not the straightforward way > [pickle.load(file('somefile.pickle'))]. If you try it, you get an > AttributeError during the unpickling operation. > > There is no problem, of course, if the class is defined in a module > which is imported by the pickling script. > pickle.load(file('somefile.pickle')) then works. > > Rather than provide specific examples here, there's a blog post from > 2005 that discusses this issue in depth and presents the problem very > well: http://stefaanlippens.net/pickleproblem. (I tested in Python > 2.6 yesterday and the same issue persists.) > > Questions: > > 1) Does this have to be the case, or is it a design problem with > pickles that should be remedied? > > 2) Is there an easier way around it than moving the class definition > to a separate module? The blog post I point to above suggests putting > "__module__ = os.path.splitext(os.path.basename(__file__))[0]" into > the class definiton, but that's not working in my testing because > when I do that, the pickling operation fails. Is there something else > that can be done? > > This is obviously not a huge problem. Substantial classes should > usually be defined in a separate module anyway. But sometimes it > makes sense for a script to define a really simple, small class to > hold some data, and needing to create a separate module just to > contain such a class can be a little annoying. -- Gary Robinson CTO Emergent Music, LLC personal email: garyrob at me.com work email: grobinson at flyfi.com Company: http://www.flyfi.com Blog: http://www.garyrobinson.net From deets at nospam.web.de Wed Sep 2 16:58:52 2009 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Sep 2009 22:58:52 +0200 Subject: website feedback to where? In-Reply-To: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> References: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> Message-ID: <7g84kcF2oh8ejU1@mid.uni-berlin.de> rogerdpack schrieb: > On Sep 2, 12:30 pm, Terry Reedy wrote: >> rogerdpack wrote: >>> on this page >>> http://docs.python.org/3.1/tutorial/introduction.html >>> some of the "text" examples are [incorrectly] color formatted. >> I did not see any problems with my browser (FF3.5), so please be more >> specific. > > search for "This is a rather long string containing" > > I suppose this is more of a documentation bug... I don't see any wrong formatting. Diez From python at mrabarnett.plus.com Wed Sep 2 17:11:15 2009 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 02 Sep 2009 22:11:15 +0100 Subject: website feedback to where? In-Reply-To: <7g84kcF2oh8ejU1@mid.uni-berlin.de> References: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> <7g84kcF2oh8ejU1@mid.uni-berlin.de> Message-ID: <4A9EDF73.5020603@mrabarnett.plus.com> Diez B. Roggisch wrote: > rogerdpack schrieb: >> On Sep 2, 12:30 pm, Terry Reedy wrote: >>> rogerdpack wrote: >>>> on this page >>>> http://docs.python.org/3.1/tutorial/introduction.html >>>> some of the "text" examples are [incorrectly] color formatted. >>> I did not see any problems with my browser (FF3.5), so please be more >>> specific. >> >> search for "This is a rather long string containing" >> >> I suppose this is more of a documentation bug... > > I don't see any wrong formatting. > I see what the OP means. The blocks with a green background mostly contain code with syntax colouring, but a couple of them show what's printed when the code is run, _also_ with syntax colouring. I've copied the text below, indicating the coloured words with underscores: This _is_ a rather long string containing several lines of text just _as_ you would do _in_ C. Note that whitespace at the beginning of the line _is_ significant. From deets at nospam.web.de Wed Sep 2 17:23:09 2009 From: deets at nospam.web.de (Diez B. Roggisch) Date: Wed, 02 Sep 2009 23:23:09 +0200 Subject: website feedback to where? In-Reply-To: References: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> <7g84kcF2oh8ejU1@mid.uni-berlin.de> Message-ID: <7g861vF2o25kfU1@mid.uni-berlin.de> MRAB schrieb: > Diez B. Roggisch wrote: >> rogerdpack schrieb: >>> On Sep 2, 12:30 pm, Terry Reedy wrote: >>>> rogerdpack wrote: >>>>> on this page >>>>> http://docs.python.org/3.1/tutorial/introduction.html >>>>> some of the "text" examples are [incorrectly] color formatted. >>>> I did not see any problems with my browser (FF3.5), so please be more >>>> specific. >>> >>> search for "This is a rather long string containing" >>> >>> I suppose this is more of a documentation bug... >> >> I don't see any wrong formatting. >> > I see what the OP means. > > The blocks with a green background mostly contain code with syntax > colouring, but a couple of them show what's printed when the code is > run, _also_ with syntax colouring. > > I've copied the text below, indicating the coloured words with > underscores: > > This _is_ a rather long string containing > several lines of text just _as_ you would do _in_ C. > Note that whitespace at the beginning of the line _is_ significant. Ah. Now I see - but *barely*, which might be a question of text-rendering and browser-defaults. Diez From bob at mellowood.ca Wed Sep 2 17:55:33 2009 From: bob at mellowood.ca (bvdp) Date: Wed, 2 Sep 2009 14:55:33 -0700 (PDT) Subject: Creating slice notation from string Message-ID: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> I'm trying to NOT create a parser to do this .... and I'm sure that it's easy if I could only see the light! Is it possible to take an arbitrary string in the form "1:2", "1", ":-1", etc. and feed it to slice() and then apply the result to an existing list? For example, I have a normal python list. Let's say that x = [1,2,3,4] and I have a string, call it "s', in the format "[2:3]". All I need to do is to apply "s" to "x" just like python would do. I can, of course, convert "x" to a list with split(), convert the 2 and 3 to ints, and then do something like: x[a:b] ... but I'd like something more general. I think the answer is in slice() but I'm lost. Thanks. From robert.kern at gmail.com Wed Sep 2 18:11:02 2009 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 02 Sep 2009 17:11:02 -0500 Subject: Creating slice notation from string In-Reply-To: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> Message-ID: On 2009-09-02 16:55 PM, bvdp wrote: > I'm trying to NOT create a parser to do this .... and I'm sure that > it's easy if I could only see the light! > > Is it possible to take an arbitrary string in the form "1:2", "1", > ":-1", etc. and feed it to slice() and then apply the result to an > existing list? > > For example, I have a normal python list. Let's say that x = [1,2,3,4] > and I have a string, call it "s', in the format "[2:3]". All I need to > do is to apply "s" to "x" just like python would do. > > I can, of course, convert "x" to a list with split(), convert the 2 > and 3 to ints, and then do something like: x[a:b] ... but I'd like > something more general. I think the answer is in slice() but I'm lost. For a one-liner: x[slice(*map(int, x[1:-1].split(':')))] -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From python at mrabarnett.plus.com Wed Sep 2 18:11:17 2009 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 02 Sep 2009 23:11:17 +0100 Subject: Creating slice notation from string In-Reply-To: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> Message-ID: <4A9EED85.8050302@mrabarnett.plus.com> bvdp wrote: > I'm trying to NOT create a parser to do this .... and I'm sure that > it's easy if I could only see the light! > > Is it possible to take an arbitrary string in the form "1:2", "1", > ":-1", etc. and feed it to slice() and then apply the result to an > existing list? > > For example, I have a normal python list. Let's say that x = [1,2,3,4] > and I have a string, call it "s', in the format "[2:3]". All I need to > do is to apply "s" to "x" just like python would do. > > I can, of course, convert "x" to a list with split(), convert the 2 > and 3 to ints, and then do something like: x[a:b] ... but I'd like > something more general. I think the answer is in slice() but I'm lost. > >>> x = [1,2,3,4] >>> s = "[2:3]" >>> # Using map. >>> x[slice(*map(int, s.strip("[]").split(":")))] [3] >>> # Using a list comprehension. >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] [3] From ethan at stoneleaf.us Wed Sep 2 18:19:13 2009 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 02 Sep 2009 15:19:13 -0700 Subject: recursive decorator Message-ID: <4A9EEF61.2080104@stoneleaf.us> Greetings, List! The recent thread about a recursive function in a class definition led me back to a post about bindfunc from Arnaud, and from there I found Michele Simionato's decorator module (many thanks! :-), and from there I began to wonder... from decorator import decorator @decorator def recursive1(func, *args, **kwargs): return func(func, *args, **kwargs) @recursive1 def factorial1(recurse, n): if n < 2: return 1 return n * recurse(n-1) factorial(4) TypeError: factorial1() takes exactly 2 arguments (1 given) Now it's *entirely* possible that I am missing something easy here, but at any rate I was thinking about the above error, about how one of the design goals behind the decorator module was to enable introspection to give accurate information about usage, etc, and how if the signature was *exactly* preserved then we have this pesky and seemingly out of place variable, not mention we can't 'just use it' in the code. So I set out to create a signature-modifying decorator that would lose that first parameter from the wrapper, while keeping the rest of the signature intact. This is what I was able to come up with: def recursive(func): """ recursive is a signature modifying decorator. Specifially, it removes the first argument, so that calls to the decorated function act as if it does not exist. """ argspec = inspect.getargspec(func) first_arg = argspec[0][0] newargspec = (argspec[0][1:], ) + argspec[1:] fi = decorator.FunctionMaker(func) old_sig = inspect.formatargspec( \ formatvalue=lambda val: "", *argspec)[1:-1] new_sig = inspect.formatargspec( \ formatvalue=lambda val: "", *newargspec)[1:-1] new_def = '%s(%s)' % (fi.name, new_sig) body = 'return func(%s)' % old_sig def wrapper(*newargspec): return func(wrapper, *newargspec) evaldict = {'func':func, first_arg:wrapper} return fi.create(new_def, body, evaldict, \ doc=fi.doc, module=fi.module) I cannot remember whose sig it is at the moment (maybe Aahz'?), but it says something about debugging being twice as hard as coding, so if you code as cleverly as you can you are, by definition, not smart enough to debug it! And considering the amount of trial-and-error that went into this (along with some thought and reasoning about scopes !-), I am hoping to get some code review. And if there's an easier way to do this, I wouldn't mind knowing about that, too! Many thanks. ~Ethan~ From zuo at chopin.edu.pl Wed Sep 2 18:33:29 2009 From: zuo at chopin.edu.pl (Jan Kaliszewski) Date: Thu, 03 Sep 2009 00:33:29 +0200 Subject: Creating slice notation from string In-Reply-To: <4A9EED85.8050302@mrabarnett.plus.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: 03-09-2009 o 00:11:17 MRAB wrote: > bvdp wrote: >> I'm trying to NOT create a parser to do this .... and I'm sure that >> it's easy if I could only see the light! >> Is it possible to take an arbitrary string in the form "1:2", "1", >> ":-1", etc. and feed it to slice() and then apply the result to an >> existing list? >> For example, I have a normal python list. Let's say that x = [1,2,3,4] >> and I have a string, call it "s', in the format "[2:3]". All I need to >> do is to apply "s" to "x" just like python would do. >> I can, of course, convert "x" to a list with split(), convert the 2 >> and 3 to ints, and then do something like: x[a:b] ... but I'd like >> something more general. I think the answer is in slice() but I'm lost. >> > >>> x = [1,2,3,4] > >>> s = "[2:3]" > >>> # Using map. > >>> x[slice(*map(int, s.strip("[]").split(":")))] > [3] > >>> # Using a list comprehension. > >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] > [3] Of course, you could also do something like this: eval('x' + s) or eval(str(x) + s) -- but it's worse: less secure (e.g. if s could be user-typed) and most probably much more time-consuming (especially the latter). Cheers, *j -- Jan Kaliszewski (zuo) From zuo at chopin.edu.pl Wed Sep 2 18:42:51 2009 From: zuo at chopin.edu.pl (Jan Kaliszewski) Date: Thu, 03 Sep 2009 00:42:51 +0200 Subject: Creating slice notation from string In-Reply-To: References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: Erratum: > eval(str(x) + s) > > -- but it's worse: less secure (e.g. if s could be user-typed) and most > probably much more time-consuming (especially the latter). There should be *repr* instead of *str*. *j -- Jan Kaliszewski (zuo) From bob at mellowood.ca Wed Sep 2 18:55:10 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 15:55:10 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> Message-ID: <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> > For a one-liner: > > ? ?x[slice(*map(int, x[1:-1].split(':')))] Thanks. Almost works :) For s="[2]" and s="[1:2]" it's fine. But, if I have s = "[:2]" then I get: >>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: '' Similar problem with [2:]. Ideas? From bob at mellowood.ca Wed Sep 2 18:57:48 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 15:57:48 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: > Of course, you could also do something like this: > > ? ? ?eval('x' + s) > or > ? ? ?eval(str(x) + s) > Yes, I have user inputed 's'. So, if I can't get the generalized list version from Robert working I'll have to use this. Speed is not a big deal in this. As to malicious input, I could pretty easily check to see that all the values are integers. I tried something like this earlier but could not get it to work. Didn't think of converting my x[] to a string. Makes sense. Thanks. From rhodri at wildebst.demon.co.uk Wed Sep 2 19:16:29 2009 From: rhodri at wildebst.demon.co.uk (Rhodri James) Date: Thu, 03 Sep 2009 00:16:29 +0100 Subject: Creating slice notation from string In-Reply-To: References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: On Wed, 02 Sep 2009 23:57:48 +0100, Bob van der Poel wrote: > >> Of course, you could also do something like this: >> >> ? ? ?eval('x' + s) >> or >> ? ? ?eval(str(x) + s) >> > > Yes, I have user inputed 's'. So, if I can't get the generalized list > version from Robert working I'll have to use this. Speed is not a big > deal in this. As to malicious input, I could pretty easily check to > see that all the values are integers. If you've done that check, you've parsed the input so you might as well use the values you've derived rather than waste time and add risk by using eval(). -- Rhodri James *-* Wildebeest Herder to the Masses From ethan at stoneleaf.us Wed Sep 2 19:27:16 2009 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 02 Sep 2009 16:27:16 -0700 Subject: Creating slice notation from string In-Reply-To: <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> Message-ID: <4A9EFF54.2000302@stoneleaf.us> Bob van der Poel wrote: >>For a one-liner: >> >> x[slice(*map(int, x[1:-1].split(':')))] > > > Thanks. > > Almost works :) > > For s="[2]" and s="[1:2]" it's fine. But, if I have > > s = "[:2]" then I get: > > >>>>x[slice(*[int(i) for i in s.strip("[]").split(":")])] > > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '' > > Similar problem with [2:]. > > Ideas? try: start, end = s[1:-1].split(':') except ValueError: start = int(s[1:-1] # only one value specified end = start+1 start = int(start) if start else 0 end = int(end) if end else len(x) x[start:end] ~Ethan~ From robert.kern at gmail.com Wed Sep 2 19:35:53 2009 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 02 Sep 2009 18:35:53 -0500 Subject: Creating slice notation from string In-Reply-To: <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> Message-ID: On 2009-09-02 17:55 PM, Bob van der Poel wrote: > >> For a one-liner: >> >> x[slice(*map(int, x[1:-1].split(':')))] > > Thanks. > > Almost works :) > > For s="[2]" and s="[1:2]" it's fine. But, if I have > > s = "[:2]" then I get: > >>>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '' > > Similar problem with [2:]. > > Ideas? Expanding out to a couple of lines now: slice_args = [] for i in s.strip("[]").split(':'): if i.strip() == '': slice_args.append(None) else: slice_args.append(int(i)) y = x[slice(*slice_args)] -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco From steve at REMOVE-THIS-cybersource.com.au Wed Sep 2 19:36:01 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 02 Sep 2009 23:36:01 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> Message-ID: <002884ea$0$2930$c3e8da3@news.astraweb.com> On Wed, 02 Sep 2009 15:22:08 -0400, Terry Reedy wrote: > Steven D'Aprano wrote: >> On Wed, 02 Sep 2009 02:16:27 -0400, Terry Reedy wrote: > >>> The rationale I have seen is this: if one leaves the wi-fi router open >>> and illegal activity is conducted thru it, and there is no residual >>> evidence on the hard drives of on-premises machines, then one may >>> claim that it must have been someone else. On the other hand, if the >>> router is properly closed, then it will be hard to argue that someone >>> hacked trough it. >>> >>> There are, of course, flaws in this argument, and I take it as >>> evidence of intention to conduct illegal activity, whether properly so >>> or not. >> >> So, if somebody leaves their car unlocked, is that evidence that they >> were intending to rob a bank and wanted a fast getaway car? >> >> If you leave your window open on a hot summer's night, is that evidence >> that you're planning to fake a burglary? >> >> If you leave your knife and fork unattended in a restaurant while you >> go to the toilet, is that evidence that you intended to stab the waiter >> and blame somebody else? >> >> >> I assume you would answer No to each of these. So why the harsher >> standard when it comes to computer crime? > > Your cases are not at all analogous or parallel. I disagree, obviously, otherwise I wouldn't have posted them. > First, I did not say 'computer crime'. I said 'illegal activity, whether > properly so [illegal] or not'. The latter is much broader, sometimes > including the viewing of non-sexual pictures of undraped young adults. You're talking about *crimes* ("illegal activity") committed via *computer*. Having an open wi-fi connection isn't going to be an alibi if you're caught with a scrapbook full of such photos, or if you have a meth lab in your bathroom. > Second, I was talking about advocacy of 'open windows' by someone who > knows how to close and lock a window. If you're known to advocate "open windows" *for the express purpose of being an alibi*, then some people might (improperly, in my opinion) draw the conclusion you do. But I read your argument as being that having an open wi-fi connection was prima facie evidence of intent to commit crime regardless of whether you were a public advocate or not. Perhaps I misunderstood. The distinction you seem to be making between people who known how to lock windows (lock their wi-fi network) and those who don't is irrelevant. The question we're debating is whether or not the deliberate decision to leave your windows (your wi-fi network) open is prima facie evidence of intention to commit crime. You say it is. I say that such a conclusion would be seen as ridiculous if applied to common everyday situations, and wonder what's so special about wi-fi that it is treated more harshly than analogous situations involving non-computer crimes? The only other example I can think of is that now that mobile phones are so ubiquitous, and since they can be tracked so easily by police, leaving your mobile phone at home can be treated as prima facie evidence that you were committing a crime during the period you were untrackable. So far this outrageous conclusion has only been applied to "Mafia bosses" accused of murder (as far as I know), but how long will it be before people are arguing that if you've got nothing to hide, why would you object to being tracked by police 24/7? > So the analogy would be someone who advocates leaving your living room > window open so that if the Feds come knocking on your door about > 'illegal' materials being sent to or from your home, you can claim that > the within-house sender or receiver must have been a stranger that came > in through the window. Hmmmm. So it's the *advocacy* (for the purposes of alibi) which is evidence of wrong-doing? Not the open windows themselves? What do you make of those who advocate for open windows but don't have illegal materials in the house? Or those who have open windows, and illegal materials, but have never spoken about the use of open windows as an alibi? How would your answers change if we lived in a world where strangers did routinely drop illegal materials into people's houses (or at least to their front door), and police frequently treated the recipient as a de facto criminal? We live in such a world: http://en.wikipedia.org/wiki/Berwyn_Heights,_Maryland_mayor's_residence_drug_raid This sort of episode -- a botched, probably illegal, paramilitary raid by police against innocents -- is only unusual because the victim was white and the mayor of the town. There's an interesting parallel here. Many patent lawyers recommend that you never search the patent records for technology before attempting to market something you've invented, because if *don't* search, and infringe, you are liable to damages, but if you *do* search, fail to find anything, and then nevertheless infringe inadvertently, you are deemed to have willfully infringed and therefore are liable to triple damages. Given the difficulty of finding every possible patent you might infringe, the risk of triple damages if you search is very high. Food for thought. -- Steven From bob at mellowood.ca Wed Sep 2 19:41:34 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 16:41:34 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: On Sep 2, 4:16?pm, "Rhodri James" wrote: > On Wed, 02 Sep 2009 23:57:48 +0100, Bob van der Poel ? > wrote: > > > > >> Of course, you could also do something like this: > > >> ? ? ?eval('x' + s) > >> or > >> ? ? ?eval(str(x) + s) > > > Yes, I have user inputed 's'. So, if I can't get the generalized list > > version from Robert working I'll have to use this. Speed is not a big > > deal in this. As to malicious input, I could pretty easily check to > > see that all the values are integers. > > If you've done that check, you've parsed the input so you might as well > use the values you've derived rather than waste time and add risk by > using eval(). Not sure exactly what you mean here? Checking the values is (fairly) trivial. Probably split on ":" and check the resulting list, etc. But, translating 1, 2 or 3 ints into a valid splice isn't quit that easy? I could figure each value, and convert them to either int or None (key is the None! From my previous try '' doesn't work!) But, I still need three possible lines: if len(i) == 1: x=x[i(0)] else if len(i) == 2: x=x[i(0):i(1)] .... But, I'm wondering if just doing a split() on the index list and seeing if they are all ints or None isn't safe? From zuo at chopin.edu.pl Wed Sep 2 19:43:43 2009 From: zuo at chopin.edu.pl (Jan Kaliszewski) Date: Thu, 03 Sep 2009 01:43:43 +0200 Subject: Creating slice notation from string In-Reply-To: <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> Message-ID: 03-09-2009 o 00:55:10 Bob van der Poel wrote: >> For a one-liner: >> >> ? ?x[slice(*map(int, x[1:-1].split(':')))] > > Thanks. > > Almost works :) > > For s="[2]" and s="[1:2]" it's fine. But, if I have > > s = "[:2]" then I get: > >>>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: '' > > Similar problem with [2:]. > > Ideas? x = [1,4,3,5,4,6,5,7] s = '[3:6]' x[slice(*((int(i) if i else None) for i in s.strip("[]").split(":")))] Cheers, *j -- Jan Kaliszewski (zuo) From bob at mellowood.ca Wed Sep 2 19:56:36 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 16:56:36 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> Message-ID: On Sep 2, 4:43?pm, "Jan Kaliszewski" wrote: > 03-09-2009 o 00:55:10 Bob van der Poel wrote: > > > > >> For a one-liner: > > >> ? ?x[slice(*map(int, x[1:-1].split(':')))] > > > Thanks. > > > Almost works :) > > > For s="[2]" and s="[1:2]" it's fine. But, if I have > > > s = "[:2]" then I get: > > >>>> x[slice(*[int(i) for i in s.strip("[]").split(":")])] > > Traceback (most recent call last): > > ? File "", line 1, in > > ValueError: invalid literal for int() with base 10: '' > > > Similar problem with ?[2:]. > > > Ideas? > > ? ? ?x = [1,4,3,5,4,6,5,7] > ? ? ?s = '[3:6]' > > ? ? ?x[slice(*((int(i) if i else None) > ? ? ? ? ? ? ? ?for i in s.strip("[]").split(":")))] > Thanks. I think this will work fine. If I paste the above in a python shell it's perfect. And if I paste it into my code it errors out ... so I have to look a bit more. Always the problem with one-liners if figuring out where the error is. I think it's just a naming thing ... I'm sure I'll get it soon. I'll shout if I find more problems. Best, From steve at REMOVE-THIS-cybersource.com.au Wed Sep 2 20:06:50 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 03 Sep 2009 00:06:50 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <1lzg7j0enpype$.1gp7vleqe3zuz.dlg@40tude.net> <00273d07$0$2930$c3e8da3@news.astraweb.com> Message-ID: <00288c23$0$2930$c3e8da3@news.astraweb.com> On Wed, 02 Sep 2009 21:53:15 +0200, David wrote: >> As for the argument that home users who send spam are the victim, >> that's true up to a point, but not very far. Here's an analogy: suppose >> that terrorists sneak into your house after picking the lock -- or in >> the case of Windows users with no firewall or anti-malware, stroll >> through the unlocked front door -- and spend the next six months camped >> in your spare bedroom, using your home for their base of operations >> while they make terrorist attacks. When the FBI kicks your doors down, >> don't you think you would be arrested and would have to prove that you >> couldn't be reasonably expected to know they were there? If millions of >> spam emails are coming out of your PC, that's prima facie evidence that >> YOU are spamming. You would need to prove that you're an innocent >> victim who couldn't *reasonably* be expected to know that your machine >> was hijacked -- you would need to prove that the spam bot was so >> sophisticated that it infected your PC despite the firewall, that you >> didn't install it yourself in order to get some stupid game, that no >> commonly available anti-malware program detects it. Anything less than >> that is *at least* negligence, and possibly willful negligence. > > Mmh, sounds like a presumption of guilt. I wouldn't go so far on this > way. The metaphor of terrorists in the bedroom applies up to a point. > While it's evident that you can not be unaware of people living in your > home, modern malware is made to be silent to the infected computer, so > it's a hidden menace and not so evident. Presumption of innocence doesn't apply when it comes to breaking of terms of service. If an ISP wants to treat customers as guilty unless proven innocent, the market will decide whether that's acceptable behaviour. As for criminal charges against people sending spam, it's not presumption of guilt. The prosecutor still needs to prove you were sending spam. But if spam is coming from your machine, that's prima facie ("in the face of it") evidence that you are sending spam, or at least, that you were aware of it and did nothing to stop it. In the same way that if you are found standing over a corpse who has been stabbed to death, the murder weapon in your hand, blood to your elbows, that's prima facie evidence that you stabbed the victim. You still have the opportunity to refute the evidence, say by arguing that the blood is on your arms (but not splattered all over your face and clothes) because you tried to save the victim's life, and you had just picked up the knife. The burden of reasonable efforts to avoid sending spam isn't high. Are you using a platform which is resistant to malware (Mac or Linux, say)? If you are using a platform prone to malware, do you have at least one each of "industry practice" anti-virus and anti-spyware programs? Do you run them regularly? Are they regularly updated? Do you have a firewall enabled, blocking the usual ports? Are you blocking outgoing port 25? Do you avoid installing random software and games (including Flash-based games) from untrusted web sites? If your computer starts playing up, with unexpected slow-downs, popups, crashes and so forth, do you take steps to have it serviced? If you answer No to more than one of the above, then you should be taking extra efforts to ensure you're not sending spam, and failure to do so is negligent. If you can answer Yes to all of the above, and nevertheless have been infected, then you have done pretty much everything the random non-expert computer user should be reasonably expected to do. > You are depicting a situation where the owner is perfectly aware of > whats happening on his machine, but this is not always the case. I agree > that ignorance is not an excuse but I wouldn't use the harsh manners at > first. "At first"??? Viruses and malware have existed on computers for thirty years, if not longer! Spam has been a huge problem for a decade or more. How many more warnings do people need before they will do something about the spambots on their computers? We don't let people play load music at 3am disturbing the neighbours. Regardless of whether they were aware of what they were doing or not, we make them turn their stereo down, and if they don't, they can be charged with disturbing the peace. Why should sending out millions of spams be treated more lightly? At the moment, the only incentive people have to remove spambots from their computer is if it causes performance problems or extra ISP charges. It's time to hold computer users responsible for what their computer does. -- Steven From steve at REMOVE-THIS-cybersource.com.au Wed Sep 2 20:16:08 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 03 Sep 2009 00:16:08 GMT Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> Message-ID: <00288e52$0$2930$c3e8da3@news.astraweb.com> On Wed, 02 Sep 2009 16:41:34 -0700, Bob van der Poel wrote: > But, translating 1, 2 or 3 ints into a valid splice isn't quit that > easy? I could figure each value, and convert them to either int or None > (key is the None! From my previous try '' doesn't work!) > > But, I still need three possible lines: > > if len(i) == 1: > x=x[i(0)] > else if len(i) == 2: > x=x[i(0):i(1)] > .... items = [int(n) for n in slice_string.split(":")] slice(*items) -- Steven From bob at mellowood.ca Wed Sep 2 20:32:09 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 17:32:09 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> <00288e52$0$2930$c3e8da3@news.astraweb.com> Message-ID: On Sep 2, 5:16?pm, Steven D'Aprano wrote: > On Wed, 02 Sep 2009 16:41:34 -0700, Bob van der Poel wrote: > > > But, translating 1, 2 or 3 ints into a valid splice isn't quit that > > easy? I could figure each value, and convert them to either int or None > > (key is the None! From my previous try '' doesn't work!) > > > But, I still need three possible lines: > > > ?if len(i) == 1: > > ? ? x=x[i(0)] > > ? else if len(i) == 2: > > ? ? x=x[i(0):i(1)] > > ? ?.... > > items = [int(n) for n in slice_string.split(":")] > slice(*items) > > -- > Steven Actually, nither this or Jan's latest is working properly. I don't know if it's the slice() function or what (I'm using python 2.5). But: x = [1,2,3,4,5] slice_string="2" items = [int(n) if n else None for n in slice_string.split(":")] [slice(*items)] [1, 2] not the expected: [3] Things like -1 don't work either. I'm really not sure what's going on, but I suspect it's the way that slice() is getting filled when the slice string isn't a nice one with each ":" present? From bob at mellowood.ca Wed Sep 2 20:36:36 2009 From: bob at mellowood.ca (Bob van der Poel) Date: Wed, 2 Sep 2009 17:36:36 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> Message-ID: <18da63cc-fe86-4a4f-b123-0cfdd2810360@o9g2000prg.googlegroups.com> On Sep 2, 4:27?pm, Ethan Furman wrote: > Bob van der Poel wrote: > > > > >>For a one-liner: > > >> ? x[slice(*map(int, x[1:-1].split(':')))] > > > Thanks. > > > Almost works :) > > > For s="[2]" and s="[1:2]" it's fine. But, if I have > > > s = "[:2]" then I get: > > >>>>x[slice(*[int(i) for i in s.strip("[]").split(":")])] > > > Traceback (most recent call last): > > ? File "", line 1, in > > ValueError: invalid literal for int() with base 10: '' > > > Similar problem with ?[2:]. > > > Ideas? > > try: > ? ? ?start, end = s[1:-1].split(':') > except ValueError: > ? ? ?start = int(s[1:-1] # only one value specified > ? ? ?end = start+1 > start = int(start) if start else 0 > end = int(end) if end else len(x) > x[start:end] > > ~Ethan~ Yes ... I see. I'm thinking that eval() is looking very nice. If we do it the above way we also have to check for empties using things like [1::2] and I'm really getting confused about the possibilities :) From rt8396 at gmail.com Wed Sep 2 20:47:24 2009 From: rt8396 at gmail.com (r) Date: Wed, 2 Sep 2009 17:47:24 -0700 (PDT) Subject: Issue with writelines References: <1ae5410a-8f4c-478a-99ef-007259bf4f57@j4g2000yqa.googlegroups.com> Message-ID: <37af46a4-1786-4808-ad51-f856031e7737@e8g2000yqo.googlegroups.com> On Sep 2, 8:20?am, LeeRisq wrote: (snip: code) > Traceback: (snip) > TypeError: writelines() argument must be a sequence of strings Well you need to print out "y" and see whats in there. The error is pretty obvious. From helvinlui at gmail.com Wed Sep 2 21:33:58 2009 From: helvinlui at gmail.com (Helvin) Date: Wed, 2 Sep 2009 18:33:58 -0700 (PDT) Subject: Qstrings to Strings Message-ID: <18534b26-abb2-43f8-8832-64b47f02eced@i18g2000pro.googlegroups.com> Just wanted to say, to convert qstrings (or integers for that matter) to strings, use the str() function. http://learnwithhelvin.blogspot.com/2009/09/qstrings-and-strings.html From gagsl-py2 at yahoo.com.ar Wed Sep 2 22:46:40 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Wed, 02 Sep 2009 23:46:40 -0300 Subject: website feedback to where? References: <1b0002da-d83d-4866-aa9c-56f1d4ef46d1@u16g2000pru.googlegroups.com> Message-ID: En Wed, 02 Sep 2009 17:47:04 -0300, rogerdpack escribi?: > On Sep 2, 12:30?pm, Terry Reedy wrote: >> rogerdpack wrote: >> >http://docs.python.org/3.1/tutorial/introduction.html >> > some of the "text" examples are [incorrectly] color formatted. >> >> I did not see any problems with my browser (FF3.5), so please be more >> specific. > > search for "This is a rather long string containing" > I suppose this is more of a documentation bug... patch submitted: http://bugs.python.org/issue6828 -- Gabriel Genellina From gagsl-py2 at yahoo.com.ar Wed Sep 2 23:24:22 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Sep 2009 00:24:22 -0300 Subject: ctypes WNetGetUniversalNameW References: <721a32fd-e1a4-40bf-87fd-00d83a2283ef@y21g2000yqn.googlegroups.com> Message-ID: En Wed, 02 Sep 2009 14:24:10 -0300, Gustavo escribi?: > I'm trying to call WNetGetUniversalNameW via the ctypes module but I'm > only causing the interpreter to crash. Unfortunately I don't have much > experience with the ctypes module and I'm still trying to figure it > out. I've searched for a solution to no avail. My confusion is > centered around the LPVOID buffer parameter and how this should be > created/used. Any help is appreciated. > > # DWORD WNetGetUniversalName( > # __in LPCTSTR lpLocalPath, > # __in DWORD dwInfoLevel, > # __out LPVOID lpBuffer, > # __inout LPDWORD lpBufferSize > # ); import ctypes, win32netcon from ctypes import wintypes LPDWORD = ctypes.POINTER(wintypes.DWORD) class UniversalNameInfo(ctypes.Structure): # note the SINGLE underscores! _fields_ = [("lpUniversalName", wintypes.LPWSTR)] PUniversalNameInfo = ctypes.POINTER(UniversalNameInfo) WNetGetUniversalNameW = ctypes.windll.mpr.WNetGetUniversalNameW WNetGetUniversalNameW.argtypes = [ wintypes.LPCWSTR, wintypes.DWORD, wintypes.LPVOID, LPDWORD] path = 'Y:' level = win32netcon.UNIVERSAL_NAME_INFO_LEVEL # you must suply your own buffer: buffer = ctypes.create_unicode_buffer(1024) buffersize = wintypes.DWORD(ctypes.sizeof(buffer)) ret = WNetGetUniversalNameW(path, level, ctypes.byref(buffer), ctypes.byref(buffersize)) print ret # casting to pointer to UniversalNameInfo struct puni = ctypes.cast(buffer, PUniversalNameInfo) # dereference the pointer and access its (only) field print puni.contents.lpUniversalName -- Gabriel Genellina From ethan at stoneleaf.us Wed Sep 2 23:28:40 2009 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 02 Sep 2009 20:28:40 -0700 Subject: Creating slice notation from string In-Reply-To: <18da63cc-fe86-4a4f-b123-0cfdd2810360@o9g2000prg.googlegroups.com> References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <42742bc5-13e7-49ab-8da6-cd6bb03084f2@2g2000prl.googlegroups.com> <18da63cc-fe86-4a4f-b123-0cfdd2810360@o9g2000prg.googlegroups.com> Message-ID: On Wed, 02 Sep 2009 17:36:36 -0700, Bob van der Poel wrote: > On Sep 2, 4:27?pm, Ethan Furman wrote: >> Bob van der Poel wrote: >> >> >> >> >>For a one-liner: >> >> >> ? x[slice(*map(int, x[1:-1].split(':')))] >> >> > Thanks. >> >> > Almost works :) >> >> > For s="[2]" and s="[1:2]" it's fine. But, if I have >> >> > s = "[:2]" then I get: >> >> >>>>x[slice(*[int(i) for i in s.strip("[]").split(":")])] >> >> > Traceback (most recent call last): >> > ? File "", line 1, in >> > ValueError: invalid literal for int() with base 10: '' >> >> > Similar problem with ?[2:]. >> >> > Ideas? >> >> try: >> ? ? ?start, end = s[1:-1].split(':') >> except ValueError: >> ? ? ?start = int(s[1:-1] # only one value specified >> ? ? ?end = start+1 >> start = int(start) if start else 0 >> end = int(end) if end else len(x) >> x[start:end] >> >> ~Ethan~ > > Yes ... I see. I'm thinking that eval() is looking very nice. If we do > it the above way we also have to check for empties using things like > [1::2] and I'm really getting confused about the possibilities :) How about: [untested] s = s[1:-1] # strip the brackets if s.count(':') == 0: return x[int(s)] while s.count(':') < 2: s += ':' start, stop, step = s.split(':') start = int(start) if start else 0 end = int(stop) if stop else len(x) step = int(step) if step else 1 return x[start:stop:step) ~Ethan~ From MacRules at nome.com Wed Sep 2 23:36:56 2009 From: MacRules at nome.com (MacRules) Date: Wed, 02 Sep 2009 23:36:56 -0400 Subject: python daemon - compress data and load data into MySQL by pyodbc Message-ID: <4a9f39d9$0$22508$607ed4bc@cv.net> Hi, I installed Python daemon, pyodbc module to access the back-end DB server. My setup is like this load data job -> Python Daemon A, port 6000 -> Python Daemon B, port 7000 -> MySQL Daemon A will perform data compression, such as GZIP, and send over data to Daemon B. Daemon B will perform data uncompression, GUNZIP, and insert records to MySQL or MSSQL or Oracle. Where should I start this to code this? Can someone give me a hint, as detail as possible here? I am a python newbie. Thanks for all the help I can get, From steven at REMOVE.THIS.cybersource.com.au Wed Sep 2 23:52:53 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 03 Sep 2009 03:52:53 GMT Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> <4A9EED85.8050302@mrabarnett.plus.com> <00288e52$0$2930$c3e8da3@news.astraweb.com> Message-ID: On Wed, 02 Sep 2009 17:32:09 -0700, Bob van der Poel wrote: > Actually, nither this or Jan's latest is working properly. I don't know > if it's the slice() function or what (I'm using python 2.5). But: > > x = [1,2,3,4,5] > slice_string="2" > items = [int(n) if n else None for n in slice_string.split(":")] > [slice(*items)] > [1, 2] It's not clear what is input and what is output. I'm *guessing* that the first four lines are input and the fifth is output. By the way, nice catch for the "else None". But why are you wrapping the call to slice() in a list in the fourth line? I can't replicate your results. I get the expected results: >>> slice_string="2" >>> items = [int(n) if n else None for n in slice_string.split(":")] >>> [slice(*items)] [slice(None, 2, None)] exactly the same as: >>> slice(2) slice(None, 2, None) Testing this, I get the expected result: >>> x = [1,2,3,4,5] >>> x[slice(*items)] [1, 2] which is exactly the same if you do this: >>> x[:2:] [1, 2] > not the expected: > > [3] Why would you expect that? You can't get that result from a slice based on 2 only. Watch: >>> x[2::] [3, 4, 5] >>> x[:2:] [1, 2] >>> x[::2] [1, 3, 5] There is no slice containing *only* 2 which will give you the result you are asking for. You would need to do this: >>> x[2:3] [3] Perhaps what you are thinking of is *indexing*: >>> x[2] 3 but notice that the argument to list.__getitem__ is an int, not a slice, and the result is the item itself, not a list. To get the behaviour you want, you need something more complicated: def strToSlice(s): if ':' in s: items = [int(n) if n else None for n in s.split(':')] else: if s: n = int(s) items = [n, n+1] else: items = [None, None, None] return slice(*items) > Things like -1 don't work either. They do for me: >>> slice_string="2:-2" >>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> items = [int(n) if n else None for n in slice_string.split(":")] >>> x[ slice(*items) ] [3, 4, 5, 6, 7, 8] >>> x[2:-2] [3, 4, 5, 6, 7, 8] > I'm really not sure what's going on, but I suspect it's the way that > slice() is getting filled when the slice string isn't a nice one with > each ":" present? I think you're confused between __getitem__ with a slice argument and __getitem__ with an int argument. -- Steven From steve at lonetwin.net Thu Sep 3 00:06:27 2009 From: steve at lonetwin.net (steve) Date: Thu, 03 Sep 2009 09:36:27 +0530 Subject: Entry Level Python Jobs In-Reply-To: <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> References: <7x63c1joon.fsf@ruckus.brouhaha.com> <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> Message-ID: <4A9F40C3.5020306@lonetwin.net> Hi Jonathan, On 09/02/2009 10:22 PM, JonathanB wrote: > Ok, so what I'm hearing is "Get a code portfolio together and watch > the job board on python.org." Thanks for the advice! > > I've been watching the python job board 3-4 times a week and I've been > working my way through the Project Euler problems in my free time. I > also have a trade generator that I wrote up to support a Traveller > game I was running a while back, but that code is old (the first non- > trivial program I ever wrote) and really fairly buggy. The user > interface is basically an infinite recursion that I sys.exit() out of > when I'm through, which means the code slows considerably as you do > more stuff in it because each trip back to the main menu is a > recursive call to the main() function. Hey, I was young and naive. I'm > working on cleaning it up right now. Any other tips? - Keep an eye out for jobs which are not directly programming related -- things like system administration (which might involve scripting), that's the way I started. - Bid for some projects at places like odesk.com, rentacoder.com, getafreelancer.com etc. A lot of people here might be averse to the idea (and they'd have good reasons for it too), but doing this will pay off in the long run. You might get a feel of why people might be averse to the idea by reading these: http://www.codinghorror.com/blog/archives/001190.html http://www.examiner.com/x-1652-Gadgets-Examiner~y2008m11d14-oDesk-Guru-Elance-and-RentACoder--Are-they-worth-it Basically, these kind of jobs might end up being more trouble than their worth. However, I personally found that it is possible to build long term business relationships, which you can then take external to these sites, quite quickly if you are any good. Here is a comparison chart in case you decide to go for it http://thethriftygeek.com/2008/11/comparing-the-online-consulting-sites/ Wish you the best, regards, - steve -- random non tech spiel: http://lonetwin.blogspot.com/ tech randomness: http://lonehacks.blogspot.com/ what i'm stumbling into: http://lonetwin.stumbleupon.com/ From riteshn at gmail.com Thu Sep 3 00:08:05 2009 From: riteshn at gmail.com (Ritesh Nadhani) Date: Wed, 2 Sep 2009 21:08:05 -0700 Subject: Using select.kqueue() In-Reply-To: <20090901124755.7436.272753761.divmod.xquotient.46@localhost.localdomain> References: <3ce825820909010051o6b960a4csb54093a05ed6bba5@mail.gmail.com> <20090901124755.7436.272753761.divmod.xquotient.46@localhost.localdomain> Message-ID: <3ce825820909022108t531c6e50ie3f936254ddb84bd@mail.gmail.com> Indeed, I was facing that issue. Appplying the patch to the select26 module now works. Also, I had to change: kq.control([]...) to kq.control(ev, ...) Not sure what happens when you pass None as the first parameter. On Tue, Sep 1, 2009 at 5:47 AM, wrote: > On 07:51 am, riteshn at gmail.com wrote: >> >> Hi >> >> I am trying to use kqueue. Since, I am on v2.5, I use the baclport: >> http://pypi.python.org/pypi/select26/0.1a3. >> >> Following the example at: >> http://julipedia.blogspot.com/2004/10/example-of-kqueue.html (which >> works perfectly as it tells all events), I tried to port it to Python: >> >> http://www.bpaste.net/show/25/ >> >> Not sure where I am wrong but the poller only returns *one* event >> ever. Adding new text, deleting the file does not return any event. >> >> What can I be doing wrong? > > Perhaps you are encountering http://bugs.python.org/issue5910 > > Jean-Paul > -- Ritesh http://www.riteshn.com From nagle at animats.com Thu Sep 3 00:08:37 2009 From: nagle at animats.com (John Nagle) Date: Wed, 02 Sep 2009 21:08:37 -0700 Subject: exec globals and locals In-Reply-To: References: <7d0a60b00909020454u6c179888o25654013cccac67a@mail.gmail.com> Message-ID: <4a9f4002$0$1606$742ec2ed@news.sonic.net> Chris Rebert wrote: > On Wed, Sep 2, 2009 at 4:54 AM, Quentin Lampin wrote: >> Hi, >> Being fairly new to Python, I'm trying to figure out the best way to use the >> exec statement and I must admit that I am a bit lost. Generally, if you want to use the exec statement, you're probably lost. Unless you have a desperate need to execute some code whose content isn't determined until run time, don't use the exec statement. If the code comes from an external source, you're probably creating a security hole. John Nagle From steve at lonetwin.net Thu Sep 3 00:19:47 2009 From: steve at lonetwin.net (steve) Date: Thu, 03 Sep 2009 09:49:47 +0530 Subject: Entry Level Python Jobs In-Reply-To: <4A9F40C3.5020306@lonetwin.net> References: <7x63c1joon.fsf@ruckus.brouhaha.com> <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> <4A9F40C3.5020306@lonetwin.net> Message-ID: <4A9F43E3.7040602@lonetwin.net> On 09/03/2009 09:36 AM, steve wrote: > Hi Jonathan, > [...snip...] I feel stupid replying to my own post but just one more thing i thought about mentioning but forgot to add: - Look at your Liberal Arts major as an advantage. Every field has a 'computing gap' that needs to be filled but cannot be done because they aren't any too many good people who have the relevant cross-domain knowledge. For instance, one of the reasons I think this month's sourceforge.net project of the month is really great is because the lead dev. has a CS degree and is listed as being a medicine student: http://sourceforge.net/community/potm-200909/ So, look for these gaps in your domain which can be filled using your technical knowledge. again, .. > > Wish you the best, > regards, > - steve -- random non tech spiel: http://lonetwin.blogspot.com/ tech randomness: http://lonehacks.blogspot.com/ what i'm stumbling into: http://lonetwin.stumbleupon.com/ From riteshn at gmail.com Thu Sep 3 00:35:40 2009 From: riteshn at gmail.com (Ritesh Nadhani) Date: Wed, 2 Sep 2009 21:35:40 -0700 Subject: select.kqueue.control changelist argument Message-ID: <3ce825820909022135p252968eeh5512131aea763d3a@mail.gmail.com> Hi According to the docs at, http://docs.python.org/library/select.html Low level interface to kevent * changelist must be an iterable of kevent object or None * max_events must be 0 or a positive integer * timeout in seconds (floats possible) I am not sure I understood what happens when I pass *None* as parameter to the method. Can somebody point me to the right direction? -- From debl2NoSpam at verizon.net Thu Sep 3 00:43:48 2009 From: debl2NoSpam at verizon.net (David Lees) Date: Thu, 03 Sep 2009 04:43:48 GMT Subject: Unable to install pywin32 for Python 2.6.2 Message-ID: <8QHnm.950$tl3.384@nwrddc01.gnilink.net> I install Python 2.6.2 with no problem, but then run the installer for pywin32 from Source Forge and get this message at the end. IDLE works, but Pywin32 does not. Traceback (most recent call last): File "", line 601, in File "", line 313, in install ImportError: DLL load failed: The specified module could not be found -------------- I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not help. Any suggestions on how to install Pywin32 appreciated. TIA David Lees From half.italian at gmail.com Thu Sep 3 00:45:36 2009 From: half.italian at gmail.com (Sean DiZazzo) Date: Wed, 2 Sep 2009 21:45:36 -0700 (PDT) Subject: python daemon - compress data and load data into MySQL by pyodbc References: <4a9f39d9$0$22508$607ed4bc@cv.net> Message-ID: On Sep 2, 8:36?pm, MacRules wrote: > Hi, > > I installed Python daemon, pyodbc module to access the back-end DB server. > > My setup is like this > > load data job -> Python Daemon A, port 6000 -> Python Daemon B, port > 7000 -> MySQL > > Daemon A will perform data compression, such as GZIP, and send over data > to Daemon B. > Daemon B will perform data uncompression, GUNZIP, and insert records to > MySQL or MSSQL or Oracle. > > Where should I start this to code this? > Can someone give me a hint, as detail as possible here? > > I am a python newbie. > > Thanks for all the help I can get, Start by reading the tutorial. http://docs.python.org/tutorial/ ~Sean From ptmcg at austin.rr.com Thu Sep 3 00:46:25 2009 From: ptmcg at austin.rr.com (Paul McGuire) Date: Wed, 2 Sep 2009 21:46:25 -0700 (PDT) Subject: Creating slice notation from string References: <5dd2e798-18e5-4e7a-bbdf-63e149279a52@b25g2000prb.googlegroups.com> Message-ID: <0e388ca1-52bd-4da0-8baa-7859de3b047e@s39g2000yqj.googlegroups.com> On Sep 2, 4:55?pm, bvdp wrote: > I'm trying to NOT create a parser to do this .... and I'm sure that > it's easy if I could only see the light! > Well, this is a nice puzzler, better than a sudoku. Maybe a quick parser with pyparsing will give you some guidance on how to do this without a parser library: from pyparsing import * # relevant punctuation, suppress after parsing LBR,RBR,COLON = map(Suppress,"[]:") # expression to parse numerics and convert to int's integer = Regex("-?\d+").setParseAction(lambda t: int(t[0])) # first try, almost good enough, but wrongly parses "[2]" -> [2::] sliceExpr = ( LBR + Optional(integer,default=None) + Optional(COLON + Optional(integer,default=None), default=None) + Optional(COLON + Optional(integer,default=None), default=None) + RBR ) # better, this version special-cases "[n]" -> [n:n+1] # otherwise, just create slice from parsed int's singleInteger = integer + ~FollowedBy(COLON) singleInteger.setParseAction(lambda t : [t[0],t[0]+1]) sliceExpr = ( LBR + (singleInteger | Optional(integer,default=None) + Optional(COLON + Optional(integer,default=None), default=None) + Optional(COLON + Optional(integer,default=None), default=None) ) + RBR ) # attach parse action to convert parsed int's to a slice sliceExpr.setParseAction(lambda t: slice(*(t.asList()))) tests = """\ [2] [2:3] [2:] [2::2] [-1:-1:-1] [:-1] [::-1] [:]""".splitlines() testlist = range(10) for t in tests: parsedSlice = sliceExpr.parseString(t)[0] print t, parsedSlice, testlist[parsedSlice] Prints: [2] slice(2, 3, None) [2] [2:3] slice(2, 3, None) [2] [2:] slice(2, None, None) [2, 3, 4, 5, 6, 7, 8, 9] [2::2] slice(2, None, 2) [2, 4, 6, 8] [-1:-1:-1] slice(-1, -1, -1) [] [:-1] slice(None, -1, None) [0, 1, 2, 3, 4, 5, 6, 7, 8] [::-1] slice(None, None, -1) [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] [:] slice(None, None, None) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Yes, it is necessary to handle the special case of a "slice" that is really just a single index. If your list of parsed integers has only a single value n, then the slice constructor creates a slice (None,n,None). What you really want, if you want everything to create a slice, is to get slice(n,n+1,None). That is what the singleInteger special case does in the pyparsing parser. -- Paul From Scott.Daniels at Acm.Org Thu Sep 3 00:49:13 2009 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Wed, 02 Sep 2009 21:49:13 -0700 Subject: using queue In-Reply-To: References: Message-ID: Tim Arnold wrote: > "MRAB" wrote in message > news:mailman.835.1251886213.2854.python-list at python.org... >> I don't need that many threads; just create a few to do the work and let >> each do multiple chapters, something like this: >> a very pretty implementation with worker code: >> while True: >> chapter = self.chapter_queue.get() >> if chapter is None: >> # A None indicates that there are no more chapters. >> break >> chapter.compile() >> # Put back the None so that the next thread will also see it. >> self.chapter_queue.put(None) and loading like: >> for c in self.document.chapter_objects: >> chapter_queue.put() >> chapter_queue.put(None) >> ... >> # The threads will finish when they see the None in the queue. >> for t in thread_list: >> t.join() > > hi, thanks for that code. It took me a bit to understand what's going on, > but I think I see it now. > Still, I have two questions about it: > (1) what's wrong with having each chapter in a separate thread? Too much > going on for a single processor? Many more threads than cores and you spend a lot of your CPU switching tasks. > (2) The None at the end of the queue...I thought t.join() would just work. > Why do we need None? Because your workers aren't finished, they are running trying to get something more to do out of the queue. The t.join() would cause a deadlock w/o the None. --Scott David Daniels Scott.Daniels at Acm.Org From helvinlui at gmail.com Thu Sep 3 01:10:37 2009 From: helvinlui at gmail.com (Helvin) Date: Wed, 2 Sep 2009 22:10:37 -0700 (PDT) Subject: string find mystery Message-ID: Hi, I have come across this very strange behaviour. Check this code: if file_str.find('Geometry'): #if file_str.endswith('Data_Input_Geometry.txt'): print 'I found geometry' elif file_str.find('Material'): print 'I found material' The amazing thing is when file_str = 'C:\Qt\SimLCM\Default \Data_Input_Material.txt', the first if statement if fulfilled, that seemingly says that in this file_str, python actually finds the word 'Geometry'. I know this, because the line: 'I found geometry' is printed. However, if instead of using file_str.find(), I use file_str.endswith(), it does not exhibit this strange behaviour. Obviously, I want the elif line to be true, instead of the first if statement. Does anyone know why this is happening? Help much appreciated! Very puzzled, Helvin From debl2NoSpam at verizon.net Thu Sep 3 01:16:13 2009 From: debl2NoSpam at verizon.net (David Lees) Date: Thu, 03 Sep 2009 05:16:13 GMT Subject: Unable to install pywin32 for Python 2.6.2 In-Reply-To: <8QHnm.950$tl3.384@nwrddc01.gnilink.net> References: <8QHnm.950$tl3.384@nwrddc01.gnilink.net> Message-ID: David Lees wrote: > I install Python 2.6.2 with no problem, but then run the installer for > pywin32 from Source Forge and get this message at the end. IDLE works, > but Pywin32 does not. > > Traceback (most recent call last): > File "", line 601, in > File "", line 313, in install > ImportError: DLL load failed: The specified module could not be found > -------------- > I have uninstalled my Python 2.5.4 and Python 2.6.2 and it does not > help. Any suggestions on how to install Pywin32 appreciated. > > TIA > > David Lees Oops, Pardon my posting this. I should have Googled first and would have solved the problem. I posted this in May, and Mark Hammond solved the problem then. I forgot about it and repeated mistake. In case anyone else has this problem, my mistake was a PYTHONPATH that pointed to my Python 2.5 installation. I simply changed it to: C:\Python26\Lib\site-packages and reran the Pywin32 installer and all is fine. David Lees From apt.shansen at gmail.com Thu Sep 3 01:19:17 2009 From: apt.shansen at gmail.com (Stephen Hansen) Date: Wed, 2 Sep 2009 22:19:17 -0700 Subject: string find mystery In-Reply-To: References: Message-ID: <7a9c25c20909022219k7a903597sd0436ce1263e3b4d@mail.gmail.com> > > The amazing thing is when file_str = 'C:\Qt\SimLCM\Default > \Data_Input_Material.txt', > the first if statement if fulfilled, that seemingly says that in this > file_str, python actually finds the word 'Geometry'. > I know this, because the line: 'I found geometry' is printed. However, > if instead of using file_str.find(), I use file_str.endswith(), it > does not exhibit this strange behaviour. > > The problem is str.find returns -1 on failure; and -1 is a true value. Only 0, empty string, empty sequences, etc, are false values. So, you have to test, 'if find_str.find(pattern) != -1:' HTH, --S -------------- next part -------------- An HTML attachment was scrubbed... URL: From helvinlui at gmail.com Thu Sep 3 01:33:06 2009 From: helvinlui at gmail.com (Helvin Lui) Date: Thu, 3 Sep 2009 17:33:06 +1200 Subject: string find mystery In-Reply-To: <7a9c25c20909022219k7a903597sd0436ce1263e3b4d@mail.gmail.com> References: <7a9c25c20909022219k7a903597sd0436ce1263e3b4d@mail.gmail.com> Message-ID: Thanks! I just realised that too, but I used the condition: .find() > 0 But I think your's is better. Simple programming knowledge... > < I made a blog post: http://learnwithhelvin.blogspot.com/2009/09/1-is-true-if-loops.html On Thu, Sep 3, 2009 at 5:19 PM, Stephen Hansen wrote: > The amazing thing is when file_str = 'C:\Qt\SimLCM\Default >> \Data_Input_Material.txt', >> the first if statement if fulfilled, that seemingly says that in this >> file_str, python actually finds the word 'Geometry'. >> I know this, because the line: 'I found geometry' is printed. However, >> if instead of using file_str.find(), I use file_str.endswith(), it >> does not exhibit this strange behaviour. >> >> > The problem is str.find returns -1 on failure; and -1 is a true value. Only > 0, empty string, empty sequences, etc, are false values. > > So, you have to test, 'if find_str.find(pattern) != -1:' > > HTH, > > --S > -- Helvin "Though the world may promise me more, I'm just made to be filled with the Lord." -------------- next part -------------- An HTML attachment was scrubbed... URL: From hendrik at microcorp.co.za Thu Sep 3 01:41:46 2009 From: hendrik at microcorp.co.za (Hendrik van Rooyen) Date: Thu, 3 Sep 2009 07:41:46 +0200 Subject: map In-Reply-To: References: <777de4d8-e591-4d21-bbd0-b286105895bc@i18g2000pro.googlegroups.com> Message-ID: <200909030741.46624.hendrik@microcorp.co.za> On Wednesday 02 September 2009 09:38:20 elsa wrote: > > in my own defense - firstly, I was able to implement what I wanted to > do with loops, and I used this to solve the problem I needed to. My rant was not intended as a personal attack - far from it - if all the people on this list were to post such clear questions as you did, it would be an even greater pleasure to participate in than it is. > > However, by asking *why* map didn't work, I now understand how map > works, what contexts it may indeed be useful for, and what the > alternatives are. To boot, you have all given me about 10 different > ways of solving the problem, some of which use prettier (and probably > faster) code than the loops I wrote... Good. So you will soon be here answering questions too. When you do that, you really learn, as long as you do not feel slighted when people point out better (or merely different) solutions than yours. We all help each other here, and sometimes we even crack obscure (and not so obscure) jokes. - Hendrik From half.italian at gmail.com Thu Sep 3 01:45:20 2009 From: half.italian at gmail.com (Sean DiZazzo) Date: Wed, 2 Sep 2009 22:45:20 -0700 (PDT) Subject: string find mystery References: Message-ID: On Sep 2, 10:10?pm, Helvin wrote: > Hi, > > I have come across this very strange behaviour. Check this code: > > ? ? ? ? if file_str.find('Geometry'): > ? ? ? ? #if file_str.endswith('Data_Input_Geometry.txt'): > ? ? ? ? ? ? print 'I found geometry' > ? ? ? ? elif file_str.find('Material'): > ? ? ? ? ? ? print 'I found material' > The amazing thing is when file_str ?= 'C:\Qt\SimLCM\Default > \Data_Input_Material.txt', > the first if statement if fulfilled, that seemingly says that in this > file_str, python actually finds the word 'Geometry'. > I know this, because the line: 'I found geometry' is printed. However, > if instead of using file_str.find(), I use file_str.endswith(), it > does not exhibit this strange behaviour. > > Obviously, I want the elif line to be true, instead of the first if > statement. > > Does anyone know why this is happening? > Help much appreciated! > > Very puzzled, > Helvin string.find() returns the index at which the given word is found within the string. If the string is not found it returns -1. So, no matter what you do, string.find() will evaluate to "True" You could use it like this: if file_str.find("Geometry") != -1: but you probably want to use: if "Geometry" in file_str: ~Sean From apt.shansen at gmail.com Thu Sep 3 01:46:28 2009 From: apt.shansen at gmail.com (Stephen Hansen) Date: Wed, 2 Sep 2009 22:46:28 -0700 Subject: string find mystery In-Reply-To: References: <7a9c25c20909022219k7a903597sd0436ce1263e3b4d@mail.gmail.com> Message-ID: <7a9c25c20909022246y334405e4g35518bc999f3f488@mail.gmail.com> On Wed, Sep 2, 2009 at 10:33 PM, Helvin Lui wrote: > Thanks! I just realised that too, but I used the condition: .find() > > 0 But I think your's is better. > Simple programming knowledge... > < > Ah, but != 0 vs > 0 isn't a question of better, but correctness: because if .find() returns 0, that's a successful result. That means it successfully found the string-- at index 0, meaning the beginning of the string. This is a function of Python indexing sequences starting with 0. Some people have argued that this -1 behavior on .find is "unpythonic" from time to time, but the other solutions just aren't very good for various reasons (e.g., returning None). An alternate is .index() which raises ValueError on not-found which side-steps the oddity if the -1. On the blog: if (myString.find('bye') != -1): It's generally bad-form to surround the expression passed to the "if" statement in parens (unless necessary for implicit line wrapping purposes) :) It's considered more Pythonic and clear to just do: if myString.find('bye') != -1: Although of course, that's a style and preference issue and so it's really up to you. --S -------------- next part -------------- An HTML attachment was scrubbed... URL: From gallium.arsenide at gmail.com Thu Sep 3 01:49:46 2009 From: gallium.arsenide at gmail.com (John Yeung) Date: Wed, 2 Sep 2009 22:49:46 -0700 (PDT) Subject: string find mystery References: Message-ID: <03351ffc-2831-4130-ae51-218572172516@37g2000yqm.googlegroups.com> On Sep 3, 1:10?am, Helvin wrote: > ? ? ? ? if file_str.find('Geometry'): > ? ? ? ? #if file_str.endswith('Data_Input_Geometry.txt'): > ? ? ? ? ? ? print 'I found geometry' > The amazing thing is when file_str ?= 'C:\Qt\SimLCM\Default > \Data_Input_Material.txt', > the first if statement if fulfilled, that seemingly says that in this > file_str, python actually finds the word 'Geometry'. > > Does anyone know why this is happening? Yep. You should read the documentation on the find method. It returns -1 when the substring is not found. Also, if 'Geometry' had been found at the beginning, it would have returned 0. John From gallium.arsenide at gmail.com Thu Sep 3 01:53:19 2009 From: gallium.arsenide at gmail.com (John Yeung) Date: Wed, 2 Sep 2009 22:53:19 -0700 (PDT) Subject: string find mystery References: Message-ID: On Sep 3, 1:45?am, Sean DiZazzo wrote: > string.find() returns the index at which the given word is found > within the string. ?If the string is not found it returns -1. ?So, no > matter what you do, string.find() will evaluate to "True" It will evaluate as false if the substring is found at the beginning (position 0). > You could use it like this: ?if file_str.find("Geometry") != -1: > > but you probably want to use: if "Geometry" in file_str: This is good advice, however. John From gagsl-py2 at yahoo.com.ar Thu Sep 3 02:15:51 2009 From: gagsl-py2 at yahoo.com.ar (Gabriel Genellina) Date: Thu, 03 Sep 2009 03:15:51 -0300 Subject: Unable to install pywin32 for Python 2.6.2 References: <8QHnm.950$tl3.384@nwrddc01.gnilink.net> Message-ID: En Thu, 03 Sep 2009 02:16:13 -0300, David Lees escribi?: > In case anyone else has this problem, my mistake was a PYTHONPATH that > pointed to my Python 2.5 installation. I simply changed it to: > C:\Python26\Lib\site-packages > and reran the Pywin32 installer and all is fine. Assuming you installed Python into C:\Python26, then C:\Python26\Lib\site-packages is already on your Python search path; you don't even need to set PYTHONPATH at all. -- Gabriel Genellina From zuo at chopin.edu.pl Thu Sep 3 02:19:53 2009 From: zuo at chopin.edu.pl (Jan Kaliszewski) Date: Thu, 03 Sep 2009 08:19:53 +0200 Subject: using queue In-Reply-To: References: Message-ID: 06:49:13 Scott David Daniels wrote: > Tim Arnold wrote: >> (1) what's wrong with having each chapter in a separate thread? Too >> much going on for a single processor? > Many more threads than cores and you spend a lot of your CPU switching > tasks. In fact, python threads work relatively the best with a powerful single core; with more cores it becomes being suprisingly inefficient. The culprit is Pythn GIL and the way it [mis]cooperates with OS scheduling. See: http://www.dabeaz.com/python/GIL.pdf Yo *j -- Jan Kaliszewski (zuo) From tjreedy at udel.edu Thu Sep 3 03:34:38 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 03 Sep 2009 03:34:38 -0400 Subject: Simple addition to random module - Student's t In-Reply-To: References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> Message-ID: Robert Kern wrote: > On 2009-09-02 14:15 PM, Raymond Hettinger wrote: >> On Sep 2, 6:51 am, Thomas Philips wrote: >>> While the random module allows one to generate randome numbers with a >>> variety of distributions, some useful distributions are omitted - the >>> Student's t being among them. >> >> I'm curious to hear what your use cases are. >> >> My understanding is that t-distribution is an estimation tool >> used with small samples of a population where the variance or >> standard deviation is unknown. >> >> So, when do you ever need to generate random variables with >> this distribution? ISTM that this is akin to wanting >> a generator for a Kolmogorov distribution -- usually the >> distribution is used to test empirical data, not to generate it. > > In more complicated models, estimates of one parameter need to be > propagated through the model, particularly if you are looking at > sensitivity to parameters. Student's t describes the variation of an > estimate of a mean of a sample from a Gaussian distribution. If I were > modeling a processing wherein someone makes an estimate of a mean and > then acts on that estimate, I would want to generate random t variates > to feed that model. > >> I think most of the existing generators were chosen because they >> are useful in simulation programs. AFAICT, the Student's t- >> distribution >> doesn't fall into that category (usually, you know the population >> standard deviation when you're the one generating data). > > Student's t distribution is also used as a sort of generic fat-tailed > distribution in some models and is not tied to the "estimate of a mean" > description. Yes. One can run the simulation with various df's to see the effect of such data and possibly how and when a model breaks. >> ISTM, there ought to be a statistics module that can calculate >> cumulative distribution functions for a variety of distributions. >> This would be far more helpful than creating more generators. > > Yes, scipy.stats. Is that stable enough so that all or part could be added to stdlib? tjr From tjreedy at udel.edu Thu Sep 3 04:01:54 2009 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 03 Sep 2009 04:01:54 -0400 Subject: Why does this group have so much spam? In-Reply-To: <002884ea$0$2930$c3e8da3@news.astraweb.com> References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> <002884ea$0$2930$c3e8da3@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > On Wed, 02 Sep 2009 15:22:08 -0400, Terry Reedy wrote: > the conclusion you do. But I read your argument as being that having an > open wi-fi connection was prima facie evidence of intent to commit crime > regardless of whether you were a public advocate or not. Perhaps I > misunderstood. Yes, as you realized later. > So it's the *advocacy* (for the purposes of alibi) which is evidence of > wrong-doing? I said 'reason for me to be suspicious' rather than 'courtroom evidence'. > Not the open windows themselves? Correct. The vast majority of open WiFi is due to ignorance or insufficient motivation to jump through the hoops needed to add units to a closed network. (I believe this can and should be easier, but that is another topic.) The other advocated reason is basically to 'stick it to the corporation', under the delusion that it is possible to hurt the fictitious 'legal person' rather than the real people how are owners, workers, and other customers. ISP's price residential service based on average fixed cost and average usage. Multiple homes using one connection push those averages up. Terry Jan Reedy From chris at simplistix.co.uk Thu Sep 3 05:05:25 2009 From: chris at simplistix.co.uk (Chris Withers) Date: Thu, 03 Sep 2009 10:05:25 +0100 Subject: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps) In-Reply-To: <435ae491-6580-4985-8885-6ed9d3e7449c@m3g2000pri.googlegroups.com> References: <1251816443.14859.15.camel@sverker-laptop> <435ae491-6580-4985-8885-6ed9d3e7449c@m3g2000pri.googlegroups.com> Message-ID: <4A9F86D5.1000004@simplistix.co.uk> Raymond Hettinger wrote: > In the first case, you would write: > sets.extend(h.load(f)) yes, what I had was: for s in iter(h.load(f)): sets.append(s) ...which I mistakenly thought was working, but in in fact boils down to Raymond's code. The problem is that each item that h.load(f) returns *is* actually an iterable, so either of the above just ends up the contents of each set being extended onto `sets` rather than the sets themselved. It's all really rather confusing, apologies if there's interspersed rant in here: >>> from guppy import hpy >>> h = hpy() Minor rant, why do I have to instantiate a to do anything with heapy? Why doesn't heapy just expose load, dump, etc? (oh, and reading the code for guppy.heapy.Use and its ilk made me go temporarily blind!) ;-) >>> f = open('copy.hpy') >>> s = h.load(f) Less minor rant: this applies to most things to do with heapy... Having __repr__ return the same as __str__ and having that be a long lump of text is rather annoying. If you really must, make __str__ return the big lump of text but have __repr__ return a simple, short, item containing the class, the id, and maybe the number of contained objects... Anyway... >>> id(s) 13905272 >>> len(s) 192 >>> s.__class__ >>> i = s[0] >>> id(i) 13904112 >>> len(i) 1 >>> i.__class__ Hmmm, I'm sure there's a good reason why an item in a set has the exact same class and iterface as a whole set? It feels like some kind of filtering, where are the docs that explain all this? cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk From python.list at tim.thechases.com Thu Sep 3 05:21:16 2009 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 03 Sep 2009 04:21:16 -0500 Subject: string find mystery In-Reply-To: References: Message-ID: <4A9F8A8C.10807@tim.thechases.com> > I have come across this very strange behaviour. Check this code: > > if file_str.find('Geometry'): While the "anser" is to compare the results of .find() with -1, but the more Pythonic answer is just to use "in": if "Geometry" in file_str: which reads a lot more cleanly, IMHO. -tkc From lallous at lgwm.org Thu Sep 3 05:38:26 2009 From: lallous at lgwm.org (lallous) Date: Thu, 3 Sep 2009 02:38:26 -0700 (PDT) Subject: match braces? Message-ID: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> Hello In C/C++ you use the braces where as in Python you use the indentation levels. Most editors offer a Ctrl+[ to match the braces so that you can easily identify the scopes (more correctly "statements blocks"). I am finding it difficult to see blocks and/or jump from end to start with some IDE hotkeys, when coding in Python. Any advise? Thanks, Elias From clp2 at rebertia.com Thu Sep 3 05:43:03 2009 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 3 Sep 2009 02:43:03 -0700 Subject: match braces? In-Reply-To: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> References: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> Message-ID: <50697b2c0909030243q72da075aod1c39e8ee13be09e@mail.gmail.com> On Thu, Sep 3, 2009 at 2:38 AM, lallous wrote: > Hello > > In C/C++ you use the braces where as in Python you use the indentation > levels. > Most editors offer a Ctrl+[ to match the braces so that you can easily > identify the scopes (more correctly "statements blocks"). > > I am finding it difficult to see blocks Erm, how does the indentation itself not make it plainly and explicitly clear? Perhaps you need to set your tabstops wider? Cheers, Chris From steven at REMOVE.THIS.cybersource.com.au Thu Sep 3 05:47:47 2009 From: steven at REMOVE.THIS.cybersource.com.au (Steven D'Aprano) Date: 03 Sep 2009 09:47:47 GMT Subject: Why does this group have so much spam? References: <7294bf8b-9819-4b6d-92b2-afc1c8042a06@x6g2000prc.googlegroups.com> <7l1wem586nhf.c8spq9wpqg99.dlg@40tude.net> <171zfm8mhuokq.1e4ltdmqqfp01.dlg@40tude.net> <002884ea$0$2930$c3e8da3@news.astraweb.com> Message-ID: On Thu, 03 Sep 2009 04:01:54 -0400, Terry Reedy wrote: > ISP's price residential service based on average fixed cost and average > usage. Multiple homes using one connection push those averages up. Is that meant to be a problem? When people buy more, the unit price they are paying falls, but the total price they pay generally goes up. E.g. we've recently upgraded our business link from AUD$150 per month for 60GB to $190 for 100GB. The per GB price is less, but the total we pay is more -- and the ISP doesn't have to do much extra work for that extra money. -- Steven From python.list at tim.thechases.com Thu Sep 3 05:51:39 2009 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 03 Sep 2009 04:51:39 -0500 Subject: match braces? In-Reply-To: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> References: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> Message-ID: <4A9F91AB.5000503@tim.thechases.com> > In C/C++ you use the braces where as in Python you use the indentation > levels. > Most editors offer a Ctrl+[ to match the braces so that you can easily > identify the scopes (more correctly "statements blocks"). > > I am finding it difficult to see blocks and/or jump from end to start > with some IDE hotkeys, when coding in Python. Any advise? Any editor worth its salt will offer indentation-based folding (I know vim does, and I would be astonished if emacs didn't. With other editors, YMMV). You can just collapse the indented section to get a big-picture view. -tkc From llvirta at gmail.com Thu Sep 3 06:21:25 2009 From: llvirta at gmail.com (Olli Virta) Date: Thu, 3 Sep 2009 03:21:25 -0700 (PDT) Subject: Modifying a textfile Message-ID: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> Hi! So I got this big textfile. It's full of data from a database. About 150 or more rows or lines in a textfile. There's three first rows that belong to the same subject. And then next three rows belong to another subject and so on, to the end of the file. What I need to do, is put the three rows that goes together and belong to certain subject, on a one line in the output textfile. And the next three rows again on a one new line. And that goes with the rest of the data to the end of the new file. Can't figure out a working loop structure to handle this. Thanks! OV From clp2 at rebertia.com Thu Sep 3 06:32:38 2009 From: clp2 at rebertia.com (Chris Rebert) Date: Thu, 3 Sep 2009 03:32:38 -0700 Subject: Modifying a textfile In-Reply-To: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> References: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> Message-ID: <50697b2c0909030332j2990f27p14c5e54d3989c67e@mail.gmail.com> On Thu, Sep 3, 2009 at 3:21 AM, Olli Virta wrote: > Hi! > > So I got this big textfile. It's full of data from a database. About > 150 or > more rows or lines in a textfile. > There's three first rows that belong to the same subject. And then > next > three rows belong to another subject and so on, to the end of the > file. > > What I need to do, is put the three rows that goes together and belong > to > certain subject, on a one line in the output textfile. And the next > three > rows again on a one new line. And that goes with the rest of the data > to > the end of the new file. > > Can't figure out a working loop structure to handle this. #completely untested from itertools import izip_longest #from itertools recipes def grouper(n, iterable, fillvalue=None): "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args) output = file("output_file.whatever", 'w') f = file("input_file.whatever", 'r') for triple in grouper(3, f): triple = triple.replace('\n', '') output.write(triple) output.write('\n') Cheers, Chris -- http://blog.rebertia.com From mgedmin at gmail.com Thu Sep 3 06:53:51 2009 From: mgedmin at gmail.com (Marius Gedminas) Date: Thu, 3 Sep 2009 03:53:51 -0700 (PDT) Subject: your favorite debugging tool? References: <7xocq5vx64.fsf@ruckus.brouhaha.com> Message-ID: <4daca966-9654-4eff-8c66-2de3eecd3cd4@v36g2000yqv.googlegroups.com> On Aug 25, 2:55?pm, Esmail wrote: > Re pdb, if you have a 'pointer' (ie reference) to an object, is there > an easy way to dump out its contents, ie all of its members short of > writing a method that does that and then calling it? Usually pp vars(your_object) does what you want From daniel at stutzbachenterprises.com Thu Sep 3 07:07:54 2009 From: daniel at stutzbachenterprises.com (Daniel Stutzbach) Date: Thu, 3 Sep 2009 06:07:54 -0500 Subject: Simple addition to random module - Student's t In-Reply-To: <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> References: <060862a7-0b25-47bf-8126-a9cdd826f87a@g1g2000vbr.googlegroups.com> <14736cba-89a5-44be-88ca-d670e99e8321@13g2000prl.googlegroups.com> Message-ID: On Wed, Sep 2, 2009 at 2:15 PM, Raymond Hettinger wrote: > ISTM, there ought to be a statistics module that can calculate > cumulative distribution functions for a variety of distributions. > This would be far more helpful than creating more generators. > Many of the formulas for cumulative distribution functions require math functions not currently provided by Python (erf, gamma, etc.). (http://bugs.python.org/issue3366 includes a patch to provide them) -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC -------------- next part -------------- An HTML attachment was scrubbed... URL: From nitebirdz at sacredchaos.com Thu Sep 3 07:32:20 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Thu, 3 Sep 2009 13:32:20 +0200 Subject: Problem w/ mysqldump In-Reply-To: <4dc0cfea0909021345y749fe36cv5388c6a292c1fddf@mail.gmail.com> References: <4dc0cfea0909020343j3cb314aep5203dd3d80ebed61@mail.gmail.com> <20090902121325.GA8255@sevilla.sacredchaos.com> <4dc0cfea0909020543i138dbf2cp6d18981e5bc6a306@mail.gmail.com> <20090902154829.GB8255@sevilla.sacredchaos.com> <4dc0cfea0909021050p325903bdj29018e35588f5843@mail.gmail.com> <4dc0cfea0909021345y749fe36cv5388c6a292c1fddf@mail.gmail.com> Message-ID: <20090903113218.GA8419@sevilla.sacredchaos.com> On Wed, Sep 02, 2009 at 04:45:02PM -0400, Victor Subervi wrote: > > I tried running it like you said, got this error: > 'mysqldump' is not a recognized internal or external command. > If I could just figure out in what file the data were stored, I could copy > it and try it in another computer. Any ideas? > OK, that makes more sense now. It's not truly a Python problem at all, but rather an issue with the MySQL install/config on Windows. As somebody else pointed out, you are supposed to run the 'mysqldump' command from the command prompt, which in the case of Windows is the "cmd.exe", as far as I remember: Start --> Run --> command I'm not familiar enough with Windows though. I haven't run it in years. However, the following URL may be of some help: http://www.vbulletin.com/forum/showthread.php?t=68822 Judging by that, MySQL's binaries may not be in your path by default when you run it on Windows. If that's the case, you may have to add it (search around for info on how to add new directories to your path in Windows' terminal) or simply specify the absolute path to the command in the Python script, instead of just passing 'mysqldump'. This other exchange from a forum may also help: http://forums.mysql.com/read.php?35,144934,144960#msg-144960 From nitebirdz at sacredchaos.com Thu Sep 3 07:43:05 2009 From: nitebirdz at sacredchaos.com (Nitebirdz) Date: Thu, 3 Sep 2009 13:43:05 +0200 Subject: Entry Level Python Jobs In-Reply-To: References: Message-ID: <20090903114304.GB8419@sevilla.sacredchaos.com> On Wed, Sep 02, 2009 at 08:31:20AM -0700, JonathanB wrote: > > I am a self-taught Python programmer with a liberal arts degree (Cross- > cultural studies). I have been programming for several years now and > would like to get a job as a python programmer. Unfortunately most of > the job posts I have seen are for CS Majors or people with experience. > > Is there a place I can look for job posts for entry level positions > requiring no experience? For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? > I have a liberal arts degree and have been working in the field for years now, not as a programmer but as a high-level technical support engineer (doing core dump analysis and the like). While I opted for not working as a programmer, other co-workers without a CompSci degree have managed to do so without major problems. It seems to me that most managers are willing to hire someone based on his/her experience and proven knowledge, and not so much on the actual degree you have. Obviously, this means you will need to get some experience before moving into actual programming. So, what would I recommend? First of all, make sure you get your foot in the door. Apply for an entry-level position at a company that works in the technology field, even if it's doing technical support or writing documentation. Once you are in, work hard, show an interest in learning programming skills, talk to the developers in the company, survey people around and try to figure out where there is a need that can be met with a not-yet-written application and put it together yourself, then show it to your manager and try to convince him/her to deploy it as an official tool for your team. I've seen this work many times. Second, search around for open source projects that may look interesting to you, download the source code, study it, subscribe to their development mailing list, check out standing bugs and see if you can fix them. This is something you can definitely add to your resume. From steve at REMOVE-THIS-cybersource.com.au Thu Sep 3 07:52:44 2009 From: steve at REMOVE-THIS-cybersource.com.au (Steven D'Aprano) Date: 03 Sep 2009 11:52:44 GMT Subject: Modifying a textfile References: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> Message-ID: <00293196$0$2930$c3e8da3@news.astraweb.com> On Thu, 03 Sep 2009 03:21:25 -0700, Olli Virta wrote: > What I need to do, is put the three rows that goes together and belong > to > certain subject, on a one line in the output textfile. And the next > three > rows again on a one new line. And that goes with the rest of the data to > the end of the new file. > > Can't figure out a working loop structure to handle this. The basic algorithm is: - grab three lines from the input file - write to the output file - repeat until done There are lots of ways to do this. Here's one: # untested out = file(outfile, 'w') in_ = file(infile, 'r') while True: # Grab three lines. a = in_.readline() if a == '': # Nothing more to read, we're done. break b = in_.readline() c = in_.readline() out.write(a.rstrip() + ' ') out.write(b.rstrip() + ' ') out.write(c.rstrip() + '\n') out.close() in_.close() Here's another version: # untested out = file(outfile, 'w') accumulator = [] for line in file(infile, 'r'): if len(accumulator) == 3: out.write("%s %s %s\n" % tuple(accumulator)) accumulator = [] accumulator.append(line.rstrip()) if accumulator: out.write("%s %s %s\n" % tuple(accumulator)) out.close() Chris has posted another method, using itertools. That's probably faster for very large files, but less readable. -- Steven From hendrik at microcorp.co.za Thu Sep 3 08:17:33 2009 From: hendrik at microcorp.co.za (Hendrik van Rooyen) Date: Thu, 3 Sep 2009 14:17:33 +0200 Subject: string find mystery In-Reply-To: References: Message-ID: <200909031417.33724.hendrik@microcorp.co.za> On Thursday 03 September 2009 07:10:37 Helvin wrote: > Hi, > > I have come across this very strange behaviour. Check this code: > > if file_str.find('Geometry'): > #if file_str.endswith('Data_Input_Geometry.txt'): > print 'I found geometry' > elif file_str.find('Material'): > print 'I found material' > The amazing thing is when file_str = 'C:\Qt\SimLCM\Default > \Data_Input_Material.txt', > the first if statement if fulfilled, that seemingly says that in this > file_str, python actually finds the word 'Geometry'. > I know this, because the line: 'I found geometry' is printed. However, > if instead of using file_str.find(), I use file_str.endswith(), it > does not exhibit this strange behaviour. > > Obviously, I want the elif line to be true, instead of the first if > statement. > > Does anyone know why this is happening? > Help much appreciated! The interactive Interpreter is your friend: s = "a;kljghkahklahdfgkjahdfhadafjd;l" s.find("banana") -1 bool(_) True - Hendrik From michele.simionato at gmail.com Thu Sep 3 08:20:00 2009 From: michele.simionato at gmail.com (Michele Simionato) Date: Thu, 3 Sep 2009 05:20:00 -0700 (PDT) Subject: Entry Level Python Jobs References: Message-ID: <18b8e91d-504f-4252-aab8-a659713ac17b@e12g2000yqi.googlegroups.com> On Sep 2, 5:31?pm, JonathanB wrote: > I am a self-taught Python programmer with a liberal arts degree (Cross- > cultural studies). I have been programming for several years now and > would like to get a job as a python programmer. Unfortunately most of > the job posts I have seen are for CS Majors or people with experience. > > Is there a place I can look for job posts for entry level positions > requiring no experience? For the hiring managers, if the job post said > "CS Major" in the requirements, would you consider a liberal arts > major at all? Requiring a CS Major does not make sense. Sensible employers asks for programmers that know how to program, not for a piece of paper. For instance, at work here nobody has a CS degree, but still I would say that we have very competent programmers. You need a way to prove that you are a competent programmer. Partecipating to Open Source projects, writing articles about programming or having a technical blog are ways to show your expertise. Here when we hire people we look at their posts in public newsgroups. I find the quality of the posts a very good indicator of the quality of the perspective employees. From michele.simionato at gmail.com Thu Sep 3 08:50:07 2009 From: michele.simionato at gmail.com (Michele Simionato) Date: Thu, 3 Sep 2009 05:50:07 -0700 (PDT) Subject: recursive decorator References: Message-ID: <33a379be-bb80-4482-9a7b-5de8faefcb09@y36g2000yqh.googlegroups.com> On Sep 3, 12:19?am, Ethan Furman wrote: > Greetings, List! > > The recent thread about a recursive function in a class definition led > me back to a post about bindfunc from Arnaud, and from there I found > Michele Simionato's decorator module (many thanks! :-), and from there I > began to wonder... > > from decorator import decorator > > @decorator > def recursive1(func, *args, **kwargs): > ? ? ?return func(func, *args, **kwargs) > > @recursive1 > def factorial1(recurse, n): > ? ? ?if n < 2: > ? ? ? ? ?return 1 > ? ? ?return n * recurse(n-1) > > factorial(4) > TypeError: factorial1() takes exactly 2 arguments (1 given) What are you trying to do here? I miss why you don't use the usual definition of factorial. If you have a real life use case which is giving you trouble please share. I do not see why you want to pass a function to itself (?) M. Simionato From albert at spenarnc.xs4all.nl Thu Sep 3 09:26:43 2009 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 03 Sep 2009 13:26:43 GMT Subject: Annoying octal notation References: <6031ba08-08c8-416b-91db-ce8ff57ae8e5@w6g2000yqw.googlegroups.com> Message-ID: In article <6031ba08-08c8-416b-91db-ce8ff57ae8e5 at w6g2000yqw.googlegroups.com>, James Harris wrote: > >So you are saying that Smalltalk has r where >r is presumably for radix? That's maybe best of all. It preserves the >syntactic requirement of starting a number with a digit and seems to >have greatest flexibility. Not sure how good it looks but it's >certainly not bad. > > 0xff & 0x0e | 0b1101 > 16rff & 16r0e | 2r1101 > >Hmm. Maybe a symbol would be better than a letter. Like 0#ff 16#ff ? That is ALGOL68. It is incredible how many of it has become vindicated over time. (Yes, nineteen hundred sixty eight was the year that language was conceived.) > >James Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From koranthala at gmail.com Thu Sep 3 09:36:24 2009 From: koranthala at gmail.com (koranthala) Date: Thu, 3 Sep 2009 06:36:24 -0700 (PDT) Subject: Entry Level Python Jobs References: <7x63c1joon.fsf@ruckus.brouhaha.com> <82b4104f-7f9f-46c1-9d3c-22ae49cf187d@m38g2000yqd.googlegroups.com> <4A9F40C3.5020306@lonetwin.net> Message-ID: <41d3eda1-d41b-4af6-b6ec-21efc8187801@h13g2000yqk.googlegroups.com> On Sep 3, 9:19?am, steve wrote: > On 09/03/2009 09:36 AM, steve wrote: > > > Hi Jonathan, > > [...snip...] > > I feel stupid replying to my own post but just one more thing i thought about > mentioning but forgot to add: > - Look at your Liberal Arts major as an advantage. Every field has a 'computing > gap' that needs to be filled but cannot be done because they aren't any too many > good people who have the relevant cross-domain knowledge. For instance, one of > the reasons I think this month's sourceforge.net project of the month is really > great is because the lead dev. has a CS degree and is listed as being a medicine > student:http://sourceforge.net/community/potm-200909/ > > So, look for these gaps in your domain which can be filled using your technical > knowledge. > > again, .. > > > > > Wish you the best, > > regards, > > - steve > > -- > random non tech spiel:http://lonetwin.blogspot.com/ > tech randomness:http://lonehacks.blogspot.com/ > what i'm stumbling into:http://lonetwin.stumbleupon.com/ Also, I think topcoder.com is a good place for him. I have not used them much, but their business plan -- of asking medium to difficult questions every week, and contacting people who solves them with jobs -- is quite sound. Try that too. From hogney at gmail.com Thu Sep 3 09:43:08 2009 From: hogney at gmail.com (Lee) Date: Thu, 3 Sep 2009 06:43:08 -0700 (PDT) Subject: obscure problem using elementtree to make xhtml website Message-ID: <954b3903-d457-42e2-8aa0-0f7491b73d36@w10g2000yqf.googlegroups.com> Elementtree (python xml parser) will transform markup like into which is a reasonable thing to do for xml (called minimization, I think). But this caused an obscure problem when I used it to create the xhtml parts of my website, causing Internet Explorer to display nearly blank pages. I explain the details at http://lee-phillips.org/scripttag/ and am writing here as a heads-up to anyone who might be using a workflow similar to mine: writing documents in xml and using python and elementtree to transform those into xhtml webpages, and using the standard kludge of serving them as text/html to IE, to get around the latter's inability to handle xml. I can't be the only one (and I doubt this problem is confined to elementtree). Lee Phillips From sjmsoft at gmail.com Thu Sep 3 09:43:31 2009 From: sjmsoft at gmail.com (sjm) Date: Thu, 3 Sep 2009 06:43:31 -0700 (PDT) Subject: Annoying octal notation References: <2h2hwo918umw.1ihpdwjimzge8$.dlg@40tude.net> <6a523329-3287-4271-ba37-7be450cfc5f6@d32g2000yqh.googlegroups.com> <4a8edc29$0$1599$742ec2ed@news.sonic.net> Message-ID: On Aug 21, 2:45?pm, John Nagle wrote: > ? ? ?In 2009, Unisys finally exited the mainframe hardware business, and the > last of the 36-bit machines, the ClearPath servers, are being phased out. > That line of machines goes back to the UNIVAC 2200 series, and the UNIVAC > 1100 series, all the way back to the vacuum-tube UNIVAC 1103 from 1952. > It's the longest running series of computers in history, and code for all > those machines used octal heavily. You're right that the 36-bit machines rely heavily on octal notation. However, Unisys has not exited the hardware business. The descendants of the original 36-bit 1100-series machines are now called Dorado. Unisys announced new models as recently as May 2009 (see http://unisys.com/unisys/news/detail.jsp?id=16900004). I have the extreme pleasure of supporting a Dorado 180 and writing Python code on Windows--the best of both worlds! Cheers, Steve J. Martin From ben+python at benfinney.id.au Thu Sep 3 09:43:46 2009 From: ben+python at benfinney.id.au (Ben Finney) Date: Thu, 03 Sep 2009 23:43:46 +1000 Subject: match braces? References: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> Message-ID: <873a7487ot.fsf@benfinney.id.au> Tim Chase writes: > Any editor worth its salt will offer indentation-based folding (I know > vim does, and I would be astonished if emacs didn't. Emacs calls that ?hide/show?, and the ?hs-minor-mode? can be enabled for any buffer (and can thus of course be automatically enabled on defined conditions, e.g. whenever a Python buffer is detected). Learn more at . -- \ ?Creativity can be a social contribution, but only in so far as | `\ society is free to use the results.? ?Richard Stallman | _o__) | Ben Finney From MacRules at nome.com Thu Sep 3 09:48:36 2009 From: MacRules at nome.com (MacRules) Date: Thu, 03 Sep 2009 09:48:36 -0400 Subject: python daemon - compress data and load data into MySQL by pyodbc In-Reply-To: References: <4a9f39d9$0$22508$607ed4bc@cv.net> Message-ID: <4A9FC934.8050001@nome.com> Sean DiZazzo wrote: > On Sep 2, 8:36 pm, MacRules wrote: >> Hi, >> >> I installed Python daemon, pyodbc module to access the back-end DB server. >> >> My setup is like this >> >> load data job -> Python Daemon A, port 6000 -> Python Daemon B, port >> 7000 -> MySQL >> >> Daemon A will perform data compression, such as GZIP, and send over data >> to Daemon B. >> Daemon B will perform data uncompression, GUNZIP, and insert records to >> MySQL or MSSQL or Oracle. >> >> Where should I start this to code this? >> Can someone give me a hint, as detail as possible here? >> >> I am a python newbie. >> >> Thanks for all the help I can get, > > Start by reading the tutorial. http://docs.python.org/tutorial/ > > ~Sean Are you a Python expert? Can you show me the basic coding to get a Daemon (pass through insert data) up and insert to the backend MySQL? From albert at spenarnc.xs4all.nl Thu Sep 3 10:04:12 2009 From: albert at spenarnc.xs4all.nl (Albert van der Horst) Date: 03 Sep 2009 14:04:12 GMT Subject: Annoying octal notation References: <00216447$0$2930$c3e8da3@news.astraweb.com> Message-ID: In article , MRAB wrote: >Steven D'Aprano wrote: >> Obviously I can't speak for Ken Thompson's motivation in creating this >> feature, but I'm pretty sure it wasn't to save typing or space on >> punchcards. Even in 1969, hex was more common than octal, and yet hex >> values are written with 0x. My guess is that he wanted all numbers to >> start with a digit, to simplify parsing, and beyond that, it was just his >> programming style -- why call the copy command `copy` when you could call >> it `cp`? (Thompson was the co-inventor of Unix.) >> >Maybe it was because they were working on minicomputers, not mainframes, >so there was less processing power and storage available. Not just any minicomputers: PDP11. Octal notation is friendly with the PDP11 instruction set. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert at spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst From dns4 at cornell.edu Thu Sep 3 10:28:50 2009 From: dns4 at cornell.edu (David Smith) Date: Thu, 03 Sep 2009 10:28:50 -0400 Subject: obscure problem using elementtree to make xhtml website In-Reply-To: <954b3903-d457-42e2-8aa0-0f7491b73d36@w10g2000yqf.googlegroups.com> References: <954b3903-d457-42e2-8aa0-0f7491b73d36@w10g2000yqf.googlegroups.com> Message-ID: Lee wrote: > Elementtree (python xml parser) will transform markup like > > > > into > > > > which is a reasonable thing to do for xml (called minimization, I > think). > > But this caused an obscure problem when I used it to create the xhtml > parts of my website, > causing Internet Explorer to display nearly blank pages. I explain the > details at > > http://lee-phillips.org/scripttag/ > > and am writing here as a heads-up to anyone who might be using a > workflow similar to mine: writing documents in xml and using python > and elementtree to transform those into xhtml webpages, and using the > standard kludge of serving them as text/html to IE, to get around the > latter's inability to handle xml. I can't be the only one (and I doubt > this problem is confined to elementtree). > > > Lee Phillips It's not just Elementtree that does this .. I've seen others libraries (admittedly in other languages I won't mention here) transform empty tags to the self-terminating form. A whitespace text node or comment node in between *should* prevent that from happening. AFAIK, the only tag in IE xhtml that really doesn't like to be reduced like that is the --David From konstantin.selivanov at gmail.com Thu Sep 3 10:31:12 2009 From: konstantin.selivanov at gmail.com (konstantin) Date: Thu, 3 Sep 2009 07:31:12 -0700 (PDT) Subject: Modifying a textfile References: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> Message-ID: <5c77d9f0-8904-41c4-9d02-64584c6fa08a@l13g2000yqb.googlegroups.com> On Sep 3, 2:21?pm, Olli Virta wrote: > Hi! > > So I got this big textfile. It's full of data from a database. About > 150 or > more rows or lines in a textfile. > There's three first rows that belong to the same subject. And then > next > three rows belong to another subject and so on, to the end of the > file. > > What I need to do, is put the three rows that goes together and belong > to > certain subject, on a one line in the output textfile. And the next > three > rows again on a one new line. And that goes with the rest of the data > to > the end of the new file. > > Can't figure out a working loop structure to handle this. > > ?Thanks! OV Straightforward generator version. src = file('test_in.txt', 'r') dst = file('test_out.txt', 'w') def reader(src): count, lines = 0, '' for line in src: if count < 2: lines += line.strip() count += 1 else: yield lines + line count, lines = 0, '' if lines: yield lines + '\n' for lines in reader(src): dst.write(lines) From dns4 at cornell.edu Thu Sep 3 10:33:24 2009 From: dns4 at cornell.edu (David Smith) Date: Thu, 03 Sep 2009 10:33:24 -0400 Subject: python daemon - compress data and load data into MySQL by pyodbc In-Reply-To: <4A9FC934.8050001@nome.com> References: <4a9f39d9$0$22508$607ed4bc@cv.net> <4A9FC934.8050001@nome.com> Message-ID: MacRules wrote: > Sean DiZazzo wrote: >> On Sep 2, 8:36 pm, MacRules wrote: >>> Hi, >>> >>> I installed Python daemon, pyodbc module to access the back-end DB >>> server. >>> >>> My setup is like this >>> >>> load data job -> Python Daemon A, port 6000 -> Python Daemon B, port >>> 7000 -> MySQL >>> >>> Daemon A will perform data compression, such as GZIP, and send over data >>> to Daemon B. >>> Daemon B will perform data uncompression, GUNZIP, and insert records to >>> MySQL or MSSQL or Oracle. >>> >>> Where should I start this to code this? >>> Can someone give me a hint, as detail as possible here? >>> >>> I am a python newbie. >>> >>> Thanks for all the help I can get, >> >> Start by reading the tutorial. http://docs.python.org/tutorial/ >> >> ~Sean > Are you a Python expert? > Can you show me the basic coding to get a Daemon (pass through insert > data) up and insert to the backend MySQL? > You've asked a rather large and non-specific question. What avenues have you explored so far? Can you describe the problem this is designed to solve? --David From invalid at invalid Thu Sep 3 10:33:57 2009 From: invalid at invalid (Grant Edwards) Date: Thu, 03 Sep 2009 09:33:57 -0500 Subject: match braces? References: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> <873a7487ot.fsf@benfinney.id.au> Message-ID: On 2009-09-03, Ben Finney wrote: > Tim Chase writes: > >> Any editor worth its salt will offer indentation-based folding (I know >> vim does, and I would be astonished if emacs didn't. > > Emacs calls that ???hide/show???, and the ???hs-minor-mode??? can be enabled for > any buffer (and can thus of course be automatically enabled on defined > conditions, e.g. whenever a Python buffer is detected). > > Learn more at . There's only one problem: it doesn't work out-of-the-box. At least it never has for me. The only thing it knows how to hide is the entire body of a function definition. I never want to do that. What I want to do is hide/unhide the blocks within if/then/else or loops so that the control flow is clearer. Emacs hs-minor-mode won't do that (at least not for me). ISTR that you are supposed to be able to get it working by replacing python-mode with some after-market version and then patching the hide-show code or something like that -- but I've never been brave enough (or bored enough) to attempt it. -- Grant Edwards grante Yow! Not SENSUOUS ... only at "FROLICSOME" ... and in visi.com need of DENTAL WORK ... in PAIN!!! From hogney at gmail.com Thu Sep 3 10:34:47 2009 From: hogney at gmail.com (Lee) Date: Thu, 3 Sep 2009 07:34:47 -0700 (PDT) Subject: obscure problem using elementtree to make xhtml website References: <954b3903-d457-42e2-8aa0-0f7491b73d36@w10g2000yqf.googlegroups.com> Message-ID: I went with a space, but a comment is a better idea. I only mention the . But if the User-Agent header indicates MSIE, it returns a Content-Type of text/html, which should be parsed as HTML, where --David From konstantin.selivanov at gmail.com Thu Sep 3 10:31:12 2009 From: konstantin.selivanov at gmail.com (konstantin) Date: Thu, 3 Sep 2009 07:31:12 -0700 (PDT) Subject: Modifying a textfile References: <1d59d2b5-6a06-466f-862d-4dc953eae3e2@e8g2000yqo.googlegroups.com> Message-ID: <5c77d9f0-8904-41c4-9d02-64584c6fa08a@l13g2000yqb.googlegroups.com> On Sep 3, 2:21?pm, Olli Virta wrote: > Hi! > > So I got this big textfile. It's full of data from a database. About > 150 or > more rows or lines in a textfile. > There's three first rows that belong to the same subject. And then > next > three rows belong to another subject and so on, to the end of the > file. > > What I need to do, is put the three rows that goes together and belong > to > certain subject, on a one line in the output textfile. And the next > three > rows again on a one new line. And that goes with the rest of the data > to > the end of the new file. > > Can't figure out a working loop structure to handle this. > > ?Thanks! OV Straightforward generator version. src = file('test_in.txt', 'r') dst = file('test_out.txt', 'w') def reader(src): count, lines = 0, '' for line in src: if count < 2: lines += line.strip() count += 1 else: yield lines + line count, lines = 0, '' if lines: yield lines + '\n' for lines in reader(src): dst.write(lines) From dns4 at cornell.edu Thu Sep 3 10:33:24 2009 From: dns4 at cornell.edu (David Smith) Date: Thu, 03 Sep 2009 10:33:24 -0400 Subject: python daemon - compress data and load data into MySQL by pyodbc In-Reply-To: <4A9FC934.8050001@nome.com> References: <4a9f39d9$0$22508$607ed4bc@cv.net> <4A9FC934.8050001@nome.com> Message-ID: MacRules wrote: > Sean DiZazzo wrote: >> On Sep 2, 8:36 pm, MacRules wrote: >>> Hi, >>> >>> I installed Python daemon, pyodbc module to access the back-end DB >>> server. >>> >>> My setup is like this >>> >>> load data job -> Python Daemon A, port 6000 -> Python Daemon B, port >>> 7000 -> MySQL >>> >>> Daemon A will perform data compression, such as GZIP, and send over data >>> to Daemon B. >>> Daemon B will perform data uncompression, GUNZIP, and insert records to >>> MySQL or MSSQL or Oracle. >>> >>> Where should I start this to code this? >>> Can someone give me a hint, as detail as possible here? >>> >>> I am a python newbie. >>> >>> Thanks for all the help I can get, >> >> Start by reading the tutorial. http://docs.python.org/tutorial/ >> >> ~Sean > Are you a Python expert? > Can you show me the basic coding to get a Daemon (pass through insert > data) up and insert to the backend MySQL? > You've asked a rather large and non-specific question. What avenues have you explored so far? Can you describe the problem this is designed to solve? --David From invalid at invalid Thu Sep 3 10:33:57 2009 From: invalid at invalid (Grant Edwards) Date: Thu, 03 Sep 2009 09:33:57 -0500 Subject: match braces? References: <88421ee9-b9fa-4868-9e0f-1b3d60ad9e48@z24g2000yqb.googlegroups.com> <873a7487ot.fsf@benfinney.id.au> Message-ID: On 2009-09-03, Ben Finney wrote: > Tim Chase writes: > >> Any editor worth its salt will offer indentation-based folding (I know >> vim does, and I would be astonished if emacs didn't. > > Emacs calls that ???hide/show???, and the ???hs-minor-mode??? can be enabled for > any buffer (and can thus of course be automatically enabled on defined > conditions, e.g. whenever a Python buffer is detected). > > Learn more at . There's only one problem: it doesn't work out-of-the-box. At least it never has for me. The only thing it knows how to hide is the entire body of a function definition. I never want to do that. What I want to do is hide/unhide the blocks within if/then/else or loops so that the control flow is clearer. Emacs hs-minor-mode won't do that (at least not for me). ISTR that you are supposed to be able to get it working by replacing python-mode with some after-market version and then patching the hide-show code or something like that -- but I've never been brave enough (or bored enough) to attempt it. -- Grant Edwards grante Yow! Not SENSUOUS ... only at "FROLICSOME" ... and in visi.com need of DENTAL WORK ... in PAIN!!! From hogney at gmail.com Thu Sep 3 10:34:47 2009 From: hogney at gmail.com (Lee) Date: Thu, 3 Sep 2009 07:34:47 -0700 (PDT) Subject: obscure problem using elementtree to make xhtml website References: <954b3903-d457-42e2-8aa0-0f7491b73d36@w10g2000yqf.googlegroups.com> Message-ID: I went with a space, but a comment is a better idea. I only mention the . But if the User-Agent header indicates MSIE, it returns a Content-Type of text/html, which should be parsed as HTML, where