Re: Sending an email with a binary attachment
On Tue, Mar 1, 2016 at 6:58 PM, Anthony Papillion wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA512 > > On 02/29/2016 11:13 AM, Chris Angelico wrote: >> On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson >> wrote: >>> try: smtp.sendmail(message['From'], message['To'], >>> message.as_string()) except: print "Message sending has failed" >>> sys.exit(1) print "Message sending was successful" sys.exit(0) >>> >> >> This is the problem, right here. Replace this code with: >> >> smtp.sendmail(message['From'], message['To'], message.as_string()) > > Hmm, I'm a bit confused. Are you saying that the problem is that I'm > enclosing the code in a Try/Except block? Besides that, I don't see > anything different. If it's the Try/Except block, how do I catch the > exception it might generate if I'm not using the exception block? > That's exactly the difference. Why do you need to catch the exception? All you're doing is destroying all the information, rendering it down to a blunt "has failed". We've had several threads touching on this, recently. I'm going to say this in what might be taken as a rude way, but the emphasis is necessary: ** Folks, *stop catching exceptions* just to print failure messages and exit. You are shooting yourselves in the foot. ** You should catch exceptions if you can actually handle them, but if all you're doing is printing out a fixed message and aborting, delete that code. Less code AND a better result. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM, wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list The program creates search for uniform networks, that is x nodes each with y links. Only a subset of permutations possible "easiest found out with pen and paper". So to the left is the node and to the right the nodes it links to. When you run new network, sometimes it is full every node have x links, you create a uniform network. But often ir reports fail the links was exhausted and you stuck into a loop, that i fortunatily have the conditions to break. But it *sometimes* break to early when there is still one or two pairs that would had worked. Not it is easy to make a fix for those, but it certainly would be more beautiful setting the correct condition. function createLinks() { var i = 0; var j = 0; while(i < nodes) { // This see so that links already generated accounted for if one link than j j = arr[i].nodelinks.length; stupid = nodes - 1; temparr = new Array(); while(j < links) { dublett = false; // Onlygenerate random values bigger than "i" else all links exhausted if(i == 0) { aLink = Math.floor(Math.random() * (nodes - 1)); aLink ++ ; } else { aLink = Math.floor(Math.random() * (stupid - i)) + i + 1; } if (aLink == nodes)aLink -- ; if (temparr[0] == null) { temparr[0] = aLink; } for(k = 0; k < arr[i].nodelinks.length; k ++ ) { if(aLink == arr[i].nodelinks[k]) { dublett = true; } } inmylist = false; var t = 0; for(var m = 0; m < temparr.length; m ++ ) { if(temparr[m] == aLink) { inmylist = true; } } if (inmylist == false) { temparr[temparr.length] = aLink; } else { inmylist = false } scope = (nodes - 1) - i; if (temparr.length >= scope) { myboolean = false; return myboolean; } if(dublett == false && arr[aLink].nroflinks < links) { arr[i].nodelinks[arr[i].nodelinks.length] = aLink; arr[aLink].nodelinks[arr[aLink].nodelinks.length] = i; arr[i].nroflinks ++ ; arr[aLink].nroflinks ++ ; j ++ ; } } i ++ ; } myboolean = true; return myboolean; } -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Wildman via Python-list wrote: > I want to take an image file, convert it to XBM format and > display it. Thanks to Mr. Otten I can open and display the > XBM image without any problems. The script first calls an > external program for the image conversion then I can open > and display it. Of course, I am left with the XBM file that > needs to be deleted. It seemed to me to be a better approach > to use stdout and pipe thereby eliminating the XBM file > altogether. Here is code I have so far but I'm not sure > what to do next... > > convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" > p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) > xbmFile, err = p.communicate() Why would you need a shell? > The variable fileName contains the image file path and name. > The variable convert contains the complete command. The last > argument in the command tells the convert utility to covert > to an XBM and to direct the output to stdout. After the above > code runs xbmFile contains the actual image, which is plain > text. (X BitMap (XBM) is a plain text binary image format.) > > My question is how do I take the xbmFile variable and convert > it to an image object that can be displayed? The technique > for displaying an image from a file does not work or at least > I have not been able to get it to work. I think Image.open() accepts a file-like object, so import io ... command = [ "convert", fileName, "-resize", "48x48!", "-threshold", "55%", "xbm:-"] p = subprocess.Popen(command, stdout=subprocess.PIPE) xbmFile, err = p.communicate() openImage = Image.open(io.BytesIO(xbmFile)) should work. -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM, wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list Here is example output and as you can see there is no reason to not create the last pair, the link is not a copy it should be created but condition somehow wrong *sometimes*. Hurray failed generate network ***not quite if single pair two nodes missing 0'st NODE Links-> 7,3,5 1'st NODE Links-> 4,6,3 2'st NODE Links-> 5,9,3 3'st NODE Links-> 0,1,2 4'st NODE Links-> 1,8,5 5'st NODE Links-> 0,2,4 6'st NODE Links-> 1,7,9 7'st NODE Links-> 0,6,8 8'st NODE Links-> 4,7 9'st NODE Links-> 2,6 -- https://mail.python.org/mailman/listinfo/python-list
Re: Condition fullfilled to early but only "sometimes"
Den tisdag 1 mars 2016 kl. 08:49:57 UTC+1 skrev Ian: > It's not at all clear what the problem is from your description. What > is it that you expect the code to do? What is it doing instead that > violates your expectation? Why are you asking for Javascript help on a > Python mailing list? > > On Mon, Feb 29, 2016 at 10:40 PM, wrote: > > I've been looking at the code for two days so i am a bit crosseyed. > > If anyone could help me set the condition so the loop catch the last > > pair/pairs, it is kind of weird that it succeed sometimes and break to > > early and report fail others. > > > > I would be very greatful if anyone can see why it break to early and return > > fail. Although it is clearly a succes looking at the last remaining pair > > none connected pair.It should report fail for the network permutations that > > stall due to link exhausting, but not stall creating last pair. > > > > It just a minor bug due to some condition that i just not get. > > Have a go 5 munutes maybe someone catch the faulthy condition. > > > > http://jt.node365.se/mydebug1.html > > -- > > https://mail.python.org/mailman/listinfo/python-list Here is a script to draw networks, drag and drop nodes. So the function will go here, right now only node deep one work. http://jt.node365.se/nodes11.html -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Mon, 29 Feb 2016 06:01 pm, Chris Angelico wrote: > I've never used reload() in any production code, ever. Ever. reload() isn't intended for production code. It is a convenience for interactive use. I cannot imagine why you would want to reload() in production code. That would imply that your production code is modifying already-imported modules, then wanting to import them again. Why would anyone in their right mind do that? Possibly because they lost a bet? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano wrote: > I cannot imagine why you would want to reload() in production code. That > would imply that your production code is modifying already-imported > modules, then wanting to import them again. Why would anyone in their right > mind do that? Possibly because they lost a bet? BartC and I have both done this exact thing, though neither of us used Python for it. It's not so insane as you might think; sometimes you want to update code, but you don't want to restart a process. Just because you've never had a process that hits a year of uptime doesn't mean nobody else does. :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: General computer language, syntax question.
On Tue, 1 Mar 2016 12:56 am, jonas.thornv...@gmail.com wrote: > I mean for for example Javascript Jonas, this is a Python forum. If we thought Javascript was a beautiful and well-designed language, we're be on a Javascript forum, complaining about Python. > if (typeof array[index] !== 'undefined' && array[index] !== null) { > or this one > if (array[index] != null) { > > I mean how do they come up with such convoluted syntax, do they pull it > out of ass? Probably. I don't know Javascript very well. It is possible that your statements about Javascript are as misinformed as your statements about Python. In Python, you certainly can do membership testing of a list: py> alist = ["ab", "cd", "ef", "gh"] py> "ef" in alist True py> "xy" in alist False and you can also test for empty lists just as easily: py> if alist: ... print("not empty") ... else: ... print("empty") ... not empty py> blist = [] py> if blist: ... print("not empty") ... else: ... print("empty") ... empty -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: common mistakes in this simple program
On Tue, 1 Mar 2016 03:29 am, Ian Kelly wrote: > On Mon, Feb 29, 2016 at 8:18 AM, Ganesh Pal wrote: >> Iam on python 2.6 > > Python 2.6 has been unsupported since October 2013. Among other > things, that means it is no longer receiving security updates like > more recent versions. Unless you have an extremely strong reason for > wanting to stay to Python 2.6, you should update your Python version. Python 2.6 is still fully supported by Red Hat. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: usage of try except for review.
On Tue, 1 Mar 2016 04:38 am, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 4:34 AM, Ganesh Pal wrote: >> On Mon, Feb 29, 2016 at 10:10 PM, Dennis Lee Bieber >> wrote: >> >>> Ask yourself: Will my program still work if I remove all the >>> assert >>> statements. If the answer is "No", then you should not be using an >>> assert. >> >> You meant if the answer is "NO" then I should be using asset ? > > No, Dennis was correct. You should assume that "assert" can > potentially be replaced with "pass" and your program will continue to > work. http://import-that.dreamwidth.org/676.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: [Off-topic] Requests author discusses MentalHealthError exception
On Tue, 1 Mar 2016 09:38 am, Larry Martell wrote: > But what is reality? Reality is that which, when you stop believing in it, doesn't go away. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: convert Dbase (.dbf) files to SQLite databases
Il giorno mercoledì 15 luglio 2009 18:30:29 UTC+2, John Machin ha scritto: > On Jul 15, 8:39 pm, David Lyon wrote: > > On Wed, 15 Jul 2009 11:53:28 +0200, Helmut Jarausch > > > > wrote: > > > Hi, > > > > > I have a lot of old Dbase files (.dbf) and I'll like to convert these > > > to SQLite databases as automatically as possible. > > > Does anybody know a tool/Python script to do so? > > > > > I know, I could use dbfpy and create the SQLite table and import all > > > data. But is there something easier? > > > > yes... > > > > Use OpenOffice-Scalc or MS-Office-Excel to open the table... > > Max 64K rows for Scalc and Excel 2003; 2007 can take 2**20 rows. > Only old dBase (not dBase 7). Memo fields not handled. Visual FoxPro > DBFs not supported by Excel even tho' VFP is an MS product. > > > > Export to csv > > Yuk. > > > > > Use SQLite Manager (https://addons.mozilla.org/en-US/firefox/addon/5817) > > > > and use the import wizard to import your data > > > > It shouldn't take too long... > > ... before you get sick of the error-prone manual tasks. > > I'd write a script that took a DBF file, analysed the field > descriptions, made a CREATE TABLE statement, executed it, and then > started doing inserts. Fairly easy to write. Scripts have the great > benefit that you can fix them and re-run a whole lot easier than > redoing manual steps. > > If dbfpy can't handle any new-fangled stuff you may have in your > files, drop me a line ... I have a soon-to-be released DBF module that > should be able to read the "new" stuff up to dBase7 and VFP9, > including memo files, conversion from whatever to Unicode if > needed, ... > > Cheers, > John -- https://mail.python.org/mailman/listinfo/python-list
[no subject]
I can't work with Python -- https://mail.python.org/mailman/listinfo/python-list
The debug process never connected back to Wing IDE
Hi python stopped working on this error: The debug process never connected back to Wing IDE: Aborting debug session. See Trouble-shooting Failure to Debug in the product manual. can you please show me how to fix this issue, thanks. -- https://mail.python.org/mailman/listinfo/python-list
RE:
I am sorry, though I have to say that I would find it hard working with a large snake every day as well. Luckily, there is a programing language (called Python) that could help in developing a snake removing application pretty easily. If, however you are actually talking about the programming language, then if you are asking for help in understanding it, or better being able to work with it, a little more information would probably help others help you. If you are simply making a statement that you are unable to work with it and have no interest in trying, then I am sorry that you feel that way, and encourage you to try a different language. (I would even try to recommend one, if we knew more about WHY you can't work with python.) If you are just trying to vent, I get that... though I would think that constructive venting would work better; ("I can't work with that damn python because it just won't install for me, I keep getting this stupid error 'blah'"). If you are trying to start an argument, or trolling, I suggest trying something more controversial... "Python is the worst language in the world because you have to indent everything exactly, that is a really stupid design!", that, I suspect would get a really good argument going! In any case, responding to your *actual* statement, good luck with finding co-workers that you can work with, I know how frustrating it can be not liking your co-workers. Dan > -Original Message- > From: Python-list [mailto:python-list-bounces+d.strohl=f5@python.org] On > Behalf Of Shamanov > Sent: Monday, February 29, 2016 11:20 AM > To: python-list@python.org > Subject: > > I can't work with Python > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: convert Dbase (.dbf) files to SQLite databases
Il giorno mercoledì 15 luglio 2009 18:30:29 UTC+2, John Machin ha scritto: If dbfpy can't handle any new-fangled stuff you may have in your files, drop me a line ... I have a soon-to-be released DBF module that should be able to read the "new" stuff up to dBase7 and VFP9, including memo files, conversion from whatever to Unicode if needed, ... Or you can use my dbf module [1] which has been in the wild for several years now and is fairly robust instead of waiting for John's module which has been in the "soon to be released" category for nearly as long. -- ~Ethan~ [1] https://pypi.python.org/pypi/dbf -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Sun, 28 Feb 2016 11:38 pm, BartC wrote: > On 28/02/2016 06:34, Steven D'Aprano wrote: > >> GUI elements are by definition graphical in nature, and like other >> graphical elements, manipulation by hand is superior to command-based >> manipulation. Graphical interfaces for manipulating graphics have won the >> UI war so effectively that some people have forgotten there ever was a >> war. Can you imagine using Photoshop without drag and drop? >> >> And yet programming those graphical interfaces is an exception. There, >> with very few exceptions, we still *require* a command interface. Not >> just a command interface, but an *off-line* command interface, where you >> batch up all your commands then run them at once, as if we were >> Neanderthals living in a cave. > > You've got that back to front. > > It's the GUI users who are the Neanderthals, having to effectively point > at things with sticks. Or have to physically move that rock themselves > (ie. drag a file to a wastebasket). I haven't physically moved an icon to the wastebasket for years. I point at the icon, right-click, and tell it "move yourself to the trash". > More advanced uses have the power of language, with all its > sophistications (ie. commands lines and scripting). Language is pretty important. But when you need to drive a nail into a piece of wood, would you rather hit the nail with a hammer, or explain to the hammer the precise direction and magnitude of force you would like it to apply when it impacts the nails? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: convert Dbase (.dbf) files to SQLite databases
Il giorno mercoledì 15 luglio 2009 18:30:29 UTC+2, John Machin ha scritto: Hmm, looks like that email was sent back in 2009. Sorry for the noise. I'm still not able to find a dbf module from John, though. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Mon, 29 Feb 2016 07:33 pm, Chris Angelico wrote: > On Mon, Feb 29, 2016 at 7:25 PM, Marko Rauhamaa wrote: >> As for why you should avoid JS/CSS, Web pages open very slowly, jump >> around wildly during rendering and have unexpected artifacts (not to >> mention the numerous data collection abuses) when they are encumbered >> with truckloads of state-of-the-art web dev gimmicks. > > And when I pick up a paintbrush, canvas, and oil paints, the result is > appallingly hard on the eyes. Clearly oil paints should not be used, > and we should just place the brush tastefully on the canvas, because > that is guaranteed to look good. > > Don't blame the tool for its poor users. A better analogy is: When I add cocaine to my stew, the result is a appallingly bad for those who eat it. Do you have any idea how rough cocaine is on the human body and brain? My wife likes the analogy, being on cocaine is like pressing the accelerator of your car all the way to the floor, ALL THE TIME, regardless of whether you are moving forward or stopped at the lights. And yet, for some reason, people seem to like the cocaine-riddled stew, and often ask me to add more cocaine. People cannot get enough of Javascript, no matter what it does to the security and stability of their browser, no matter how many pop-ups it launches or how much spyware and malware it installs, or how many times it kills their browser. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: [Off-topic] Requests author discusses MentalHealthError exception
On 01.03.2016 13:13, Steven D'Aprano wrote: On Tue, 1 Mar 2016 09:38 am, Larry Martell wrote: But what is reality? Reality is that which, when you stop believing in it, doesn't go away. Just like that. -- https://mail.python.org/mailman/listinfo/python-list
Re: usage of try except for review.
On Mon, 29 Feb 2016 07:13 pm, Ganesh Pal wrote: > def run_cmd_and_verify(cmd, timeout=1000): > try: > out, err, ret = run(cmd, timeout=timeout) > assert ret ==0,"ERROR (ret %d): " \ > " \nout: %s\nerr: %s\n" % (ret, out, err) Do not use assert for error checking. http://import-that.dreamwidth.org/676.html Instead, you should write this: out, err, ret = run(cmd, timeout=timeout) if ret != 0: raise RuntimeError( "ERROR (ret %d): \nout: %s\nerr: %s\n" % (ret, out, err)) > except Exception as e: > logging.error("Failed to run %s got %s" % (cmd, e)) > return False > return True > > > def run_test(): > """ > Mount > """ > pdb.set_trace() Do not use the debugger as part of production code. The debugger is for debugging. When you have debugged the section of code, remove the debugger calls. > for cmd in ["mount /nfs_mount1", "mount /cifs_mount1"]: > try: > if not run_cmd_and_verify(cmd, timeout=3600): > return False > except: >logging.error("Failure while running command %") > logging.info("Setup and Creation Done !!!") Do not use bare except clauses like this unless you know what you are doing. https://realpython.com/blog/python/the-most-diabolical-python-antipattern/ > cmd = "run_scan" > out, err, ret = run(cmd) > for cmd in ["create_data.py -nfs ", > "validate.py -30 "]: > try: > if not run_cmd_and_verify(cmd, timeout=3600): >return False > except: > logging.error("") > return False > logging.info("Mount IS START.Done !!!") > > def main(): > if not run_test(): > sys.exit("Exiting Main") > > > if __name__ == '__main__': > main() I would re-write this script as something like this: # Untested def run_cmd(cmd, timeout=1000): out, err, ret = run(cmd, timeout=timeout) if ret != 0: raise RuntimeError( "ERROR (ret %d): \nout: %s\nerr: %s\n" % (ret, out, err)) def run_test(): for cmd in ["mount /nfs_mount1", "mount /cifs_mount1"]: run_cmd(cmd, timeout=3600) logging.info("Setup and Creation Done !!!") cmd = "run_scan" out, err, ret = run(cmd) # Do you care about the result of the scan? Then you should log it. for cmd in ["create_data.py -nfs ", "validate.py -30 "]: run_cmd(cmd, timeout=3600) logging.info("Mount IS START.Done !!!") if __name__ == '__main__': try: run_test() except Exception as err: logging.error("run_test failed", exc_info=True) sys.exit(1) > Question 1: > > > > 1. Have I used try and expect block correctly ? , In my case I have > the except block that's is not needed it just gives an message I > have still included for the sake of try block If the except block is not needed, then you should not use try. > 2. If a failure’s are encountered the error by assert condition the > errors are now displayed on the screen , how do I redirect it to log > file using logging error Don't use assert like that. > 3. my function def has 1000 but Iam using 3600 in the calling fnx etc > , Time out value are overwritten ? I don't understand the question. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Tue, 1 Mar 2016 12:25 am, alien2u...@gmail.com wrote: >> As for need of import in Idle session, I use it to >> - import sys >> - sys.append.path('D:\\Where\\Ever\\My\\Modules\\Lie') > > Kindly read above as > sys.path.append() > >> - import mymodule There are better ways to manage your Python path than to manually insert paths into sys.path like that. What version of Python are you using? -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: [Off-topic] Requests author discusses MentalHealthError exception
On Tue, 1 Mar 2016 04:08 am, Rustom Mody wrote: > And who is the last arbiter on that 'reality'? I'll give you the benefit of the doubt that this is a genuine question, and not just an attempt to ask a rhetorical question to demonstrate your profundity. You should not assume that there is any such thing as "the last arbiter" of reality. There is no arbiter at all, let alone a final one. But what we have are various ways of managing and uncertainty and error. One of which is consensus. For instance, there are seven billion people on earth who think they are people, and one who thinks he may be a butterfly. Which is more likely to be correct? https://en.wikiquote.org/wiki/Zhuangzi To quote Terry Pratchett: ‘The poet Hoha once dreamed he was a butterfly, and then he awoke and said, “Am I a man who dreamed he was a butterfly or am I a butterfly dreaming he is a man?”‘ said Lobsang, trying to join in. ‘Really?’ said Susan briskly. ‘And which was he?’ ‘What? Well…who knows?’ ‘How did he write his poems?’ said Susan. ‘With a brush, of course.’ ‘He didn’t flap around making information-rich patterns in the air or laying eggs on cabbage leaves?’ ‘No one ever mentioned it.’ ‘Then he was probably a man,’ said Susan. Because there are limitations on how we observe reality, there are limits to how objective we can be. We have an imperfect ability to observe the world around us (including our own mental states) and are prone to errors. But, over a wide range of conditions (although not *all* conditions) we can eliminate many classes of error by comparing notes with our fellows, so to speak. If I think I am a butterfly, and my wife thinks I'm a man, and my co-workers think I'm a man, and my neighbours think I'm a man, chances are good that it is me who is mistaken, not them. Consequently reality is a shared construct -- or rather, our understanding of reality is at least partly a shared construct. In principle, at least, *everything* is subject to disproof. But in practice some things are more certain than others. I wouldn't bet $100 on quarks still being considered the fundamental building block of matter in 200 years, but I would bet a million dollars on the sun still seeming to rise in the east every 24 hours. As Isaac Asimov put it: When people thought the earth was flat, they were wrong. When people thought the earth was spherical, they were wrong. But if you think that thinking the earth is spherical is just as wrong as thinking the earth is flat, then your view is wronger than both of them put together. https://en.wikipedia.org/wiki/Wronger_than_wrong http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm It's not that reality itself is subject to change (except in the trivial sense that we can take actions that modify the state of the world: I can pick this cup up and move it over there, you can eat that apple) but that our understanding of reality is subject to change. Sometimes our understanding is full of uncertainty and doubt, sometimes it is subject to re-interpretation, and sometimes our understanding is almost certainly correct: it is difficult to imagine any credible or believable reinterpretation that would change the facts as we know them. A thousand years from now, the sun will still appear to be rising in the east. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Tue, 1 Mar 2016 10:39 pm, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano > wrote: >> I cannot imagine why you would want to reload() in production code. That >> would imply that your production code is modifying already-imported >> modules, then wanting to import them again. Why would anyone in their >> right mind do that? Possibly because they lost a bet? > > BartC and I have both done this exact thing, though neither of us used > Python for it. It's not so insane as you might think; sometimes you > want to update code, but you don't want to restart a process. Just > because you've never had a process that hits a year of uptime doesn't > mean nobody else does. :) I've had an uptime of over 400 days on my laptop, without logging out, so yes I have had processes with over a year of uptime. But that doesn't mean I expect to modify the code of a running process and reload it. Modify data, sure, but not code. I'll grudgingly accept that, just maybe, if you have some sort of plugin system, you may want to unload and reload plugins, replacing the old plugin with a new one of the same name. Maybe you could get that to work in Python using the import system. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
What arguments are passed to the __new__ method ?
Hello It's not clear to me what arguments are passed to the __new__ method. Here is a piece of code: class Premiere: def __new__(cls, price): return object.__new__(cls) def __init__(self, price): pass p = Premiere(1000) No errors, so it seems that 2 arguments are passed to __new__, cls and price. But if i do: class Premiere: def __new__(cls, price): return object.__new__(cls, price) def __init__(self, price): pass p = Premiere(1000) it fails. It is strange because according to me it is equivalent to: class Premiere: def __init__(self, price): pass p = Premiere(1000) which is OK. -- https://mail.python.org/mailman/listinfo/python-list
Re:
On Mar 1, 2016 9:11 AM, "Shamanov" wrote: > > I can't work with Python I'm sorry to hear that. If you want some help you will have to give us more information. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 09:56:56 +0100, Peter Otten wrote: > Wildman via Python-list wrote: > >> I want to take an image file, convert it to XBM format and >> display it. Thanks to Mr. Otten I can open and display the >> XBM image without any problems. The script first calls an >> external program for the image conversion then I can open >> and display it. Of course, I am left with the XBM file that >> needs to be deleted. It seemed to me to be a better approach >> to use stdout and pipe thereby eliminating the XBM file >> altogether. Here is code I have so far but I'm not sure >> what to do next... >> >> convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" >> p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) >> xbmFile, err = p.communicate() > > Why would you need a shell? I guess it is a Linux thing. If I don't use it, I get the below error. A shell window does not actually open. I presume it runs in the background while executing the subprocess command. Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__ return self.func(*args) File "./test.py", line 59, in open_image p = subprocess.Popen(command, stdout=subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory >> The variable fileName contains the image file path and name. >> The variable convert contains the complete command. The last >> argument in the command tells the convert utility to covert >> to an XBM and to direct the output to stdout. After the above >> code runs xbmFile contains the actual image, which is plain >> text. (X BitMap (XBM) is a plain text binary image format.) >> >> My question is how do I take the xbmFile variable and convert >> it to an image object that can be displayed? The technique >> for displaying an image from a file does not work or at least >> I have not been able to get it to work. > > I think Image.open() accepts a file-like object, so > > import io > ... > command = [ > "convert", fileName, > "-resize", "48x48!", > "-threshold", "55%", > "xbm:-"] > p = subprocess.Popen(command, stdout=subprocess.PIPE) > xbmFile, err = p.communicate() > openImage = Image.open(io.BytesIO(xbmFile)) > > should work. I does work, perfectly. During my research I didn't run across anything about using io. The learning process continues... I am in your debt again. Thank you. -- GNU/Linux user #557453 "Be at war with your vices, at peace with your neighbors, and let every new year find you a better man." -Benjamin Franklin -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Wed, Mar 2, 2016 at 4:11 AM, Steven D'Aprano wrote: > On Tue, 1 Mar 2016 10:39 pm, Chris Angelico wrote: > >> On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano >> wrote: >>> I cannot imagine why you would want to reload() in production code. That >>> would imply that your production code is modifying already-imported >>> modules, then wanting to import them again. Why would anyone in their >>> right mind do that? Possibly because they lost a bet? >> >> BartC and I have both done this exact thing, though neither of us used >> Python for it. It's not so insane as you might think; sometimes you >> want to update code, but you don't want to restart a process. Just >> because you've never had a process that hits a year of uptime doesn't >> mean nobody else does. :) > > I've had an uptime of over 400 days on my laptop, without logging out, so > yes I have had processes with over a year of uptime. But that doesn't mean > I expect to modify the code of a running process and reload it. Modify > data, sure, but not code. > > I'll grudgingly accept that, just maybe, if you have some sort of plugin > system, you may want to unload and reload plugins, replacing the old plugin > with a new one of the same name. Maybe you could get that to work in Python > using the import system. And then you expand the plugin system so it includes everything other than a kernel that manages plugins, and you now have the kind of system I'm talking about. My MUD server and client are both structured like this: 1) Startup file, which does basic setup, initializes all other files, then (in the server) binds to a port and starts listening. It then drops to a back-end loop, either threaded or async I/O. 2) Globally-available utilities toolbox. Can be reloaded to add or edit any of the functions/classes in it. 3) (Client only) GUI handling file. Creates the window, handles user interaction. Can be reloaded, although since it doesn't destroy and recreate the window, some changes won't take effect until full restart. 4) All other plugins, which can do pretty much anything. The system is quite happy to add, remove, and update these at any time. Everything except the startup file can be edited after startup. That's basically _every_ piece of code in the whole project. Major features can be implemented and debugged without resetting anything, and once I'm satisfied with the code, I commit and push, and end users can pull that change without restarting. If I were to implement this in Python, I would probably do it by reimplementing module-like behaviour, rather than actually using import. But it could be made to work, and it definitely has its benefits. On the server, it's crucial - I can't kick my users off every time I make changes; even on the client, having to restart and reconnect for every change would be tedious, although that's more for my own debugging than for other people's usage (it's not as big a deal to update the program once a week and then have to restart). ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Wed, Mar 2, 2016 at 3:44 AM, Steven D'Aprano wrote: > On Mon, 29 Feb 2016 07:33 pm, Chris Angelico wrote: > >> On Mon, Feb 29, 2016 at 7:25 PM, Marko Rauhamaa wrote: >>> As for why you should avoid JS/CSS, Web pages open very slowly, jump >>> around wildly during rendering and have unexpected artifacts (not to >>> mention the numerous data collection abuses) when they are encumbered >>> with truckloads of state-of-the-art web dev gimmicks. >> >> And when I pick up a paintbrush, canvas, and oil paints, the result is >> appallingly hard on the eyes. Clearly oil paints should not be used, >> and we should just place the brush tastefully on the canvas, because >> that is guaranteed to look good. >> >> Don't blame the tool for its poor users. > > A better analogy is: > > When I add cocaine to my stew, the result is a appallingly bad for those who > eat it. Do you have any idea how rough cocaine is on the human body and > brain? My wife likes the analogy, being on cocaine is like pressing the > accelerator of your car all the way to the floor, ALL THE TIME, regardless > of whether you are moving forward or stopped at the lights. And yet, for > some reason, people seem to like the cocaine-riddled stew, and often ask me > to add more cocaine. > > People cannot get enough of Javascript, no matter what it does to the > security and stability of their browser, no matter how many pop-ups it > launches or how much spyware and malware it installs, or how many times it > kills their browser. s/cocaine/sriracha/ and I would agree with you, because there are places where JS can majorly enhance a web site, and it isn't going to kill you if you use it correctly. But while we might disagree on the precise boundary between "good JS" and "bad JS", it seems we're pretty vehemently in agreement that there are a lot of sites out there that serve up a stew that burns the paint off buildings in the next county. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
Steven D'Aprano : > On Sun, 28 Feb 2016 11:38 pm, BartC wrote: >> It's the GUI users who are the Neanderthals, having to effectively >> point at things with sticks. Or have to physically move that rock >> themselves (ie. drag a file to a wastebasket). > > I haven't physically moved an icon to the wastebasket for years. I > point at the icon, right-click, and tell it "move yourself to the > trash". Do you find that interface convenient? Do you often find yourself clickety-clicking around to perform bulk file operations? > Language is pretty important. But when you need to drive a nail into a > piece of wood, would you rather hit the nail with a hammer, or explain > to the hammer the precise direction and magnitude of force you would > like it to apply when it impacts the nails? I don't know. My everyday file manipulation needs are so diverse that I couldn't imagine how a GUI would make my life easier. What I'm thinking is, could Python turn into a serious competitor to bash? The standard shell suffers greatly from sloppy quoting, and many of the age-old list-processing idioms are more awkward than cute. A python shell would need a well-thought-out default import plus a way to string together external commands. Maybe JSON or similar could be the standard I/O framing format (instead of SPC-separated fields and LF-separated records). Someone must have tried that before. (Tclsh did that years back but suffered from analogous problems as bash.) Marko -- https://mail.python.org/mailman/listinfo/python-list
Re:
On Wed, Mar 2, 2016 at 2:53 AM, Dan Strohl wrote: > If you are trying to start an argument, or trolling, I suggest trying > something more controversial... "Python is the worst language in the world > because you have to indent everything exactly, that is a really stupid > design!", that, I suspect would get a really good argument going! > Python is the worst language in the world because it forces you to use Unicode instead of allowing Shift-JIS or DBCS! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Wildman via Python-list wrote: > On Tue, 01 Mar 2016 09:56:56 +0100, Peter Otten wrote: >> Wildman via Python-list wrote: >>> convert = "convert " + fileName + " -resize 48x48! -threshold 55% xbm:-" >>> p = subprocess.Popen([convert], stdout=subprocess.PIPE, shell=True) >>> xbmFile, err = p.communicate() >> Why would you need a shell? Just in case the example in my previous post has not made it clear: that was a rhetorical question. You do not need the shell, and in fact shouldn't use it. > I guess it is a Linux thing. If I don't use it, I get > the below error. A shell window does not actually open. > I presume it runs in the background while executing the > subprocess command. > Exception in Tkinter callback > Traceback (most recent call last): > File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1535, in __call__ > return self.func(*args) > File "./test.py", line 59, in open_image > p = subprocess.Popen(command, stdout=subprocess.PIPE) > File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ > errread, errwrite) > File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child > raise child_exception > OSError: [Errno 2] No such file or directory An exception is raised because you pass the command as a single argument like in [Python 2.7] >>> subprocess.Popen("ls /usr/share/dict/words") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory This looks for an executable called "ls /usr/share/dict/words" (the whole shebang!) where you actually want to run "ls" with the argument "/usr/share/dict/words". Once you split the parts >>> subprocess.Popen(["ls", "/usr/share/dict/words"]) >>> /usr/share/dict/words everything works as expected. The error message in Python 3.4 would have given you a clue, by the way: [Python 3.4] >>> subprocess.Popen("ls /usr/share/dict/words") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.4/subprocess.py", line 859, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'ls /usr/share/dict/words' -- https://mail.python.org/mailman/listinfo/python-list
Re: The debug process never connected back to Wing IDE
On 2/29/2016 6:42 PM, quoc tuong via Python-list wrote: Hi python stopped working on this error: The debug process never connected back to Wing IDE: Aborting debug session. See Trouble-shooting Failure to Debug in the product manual. Dit you do that -- check the manual? If the 'product manual' is inadequate, tell the product producer. Or inquire on a WingIDE list. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 19:26:55 +0100, Peter Otten wrote: > An exception is raised because you pass the command as a single argument I did not realize that how the command was passed would make such a difference. I guess I am stuck in my old VB habits for creating variables. You don't have to say it, this ain't VB! :-) After making the changes to "command = ", it works fine without the shell. At the risk of sounding redundant, thank you. -- GNU/Linux user #557453 "The Constitution only gives people the right to pursue happiness. You have to catch it yourself." -Benjamin Franklin -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
Am 29.02.16 um 22:51 schrieb Wildman: I want to take an image file, convert it to XBM format and display it. Thanks to Mr. Otten I can open and display the XBM image without any problems. The script first calls an external program for the image conversion then I can open and display it. Of course, I am left with the XBM file that needs to be deleted. I think you are solving the wrong problem. If your aim is to just display an image using Tkinter, you can use PIL to read the image and transfer the bits into a Tkinter photoimage object. For an example, look here: http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/ (this might need some updating if you are using Python 3) Christian -- https://mail.python.org/mailman/listinfo/python-list
Re: What arguments are passed to the __new__ method ?
On Tue, Mar 1, 2016 at 11:24 AM, ast wrote: > > class Premiere: > >def __new__(cls, price): >return object.__new__(cls, price) > >def __init__(self, price): >pass > > p = Premiere(1000) > > it fails. It is strange because according to me it is equivalent to: > > class Premiere: > >def __init__(self, price): > pass > > p = Premiere(1000) The implementation knowns whether a type overrides the __new__ or __init__ methods. You're expected to consume additional arguments in this case. However, excess arguments are ignored in object.__new__ if a type overrides __init__ without overriding __new__ (i.e. your second example). Excess arguments are also ignored in object.__init__ if a type overrides __new__ without overriding __init__. In CPython, this behavior is implemented for object.__new__ by the following statement in Objects/typeobject.c, object_new: if (excess_args(args, kwds) && (type->tp_init == object_init || type->tp_new != object_new)) { PyErr_SetString(PyExc_TypeError, "object() takes no parameters"); return NULL; } An exception is always raised if a type overrides __new__ and passes extra arguments to object.__new__. No exception is raised for excess arguments in object.__new__ if a type overrides __init__ but not __new__. The __init__ method must consume the extra arguments; it must not pass them to object.__init__. The behavior for object.__init__ is implemented by the following statement in Objects/typeobject.c, object_init: if (excess_args(args, kwds) && (type->tp_new == object_new || type->tp_init != object_init)) { PyErr_SetString(PyExc_TypeError, "object.__init__() takes no parameters"); err = -1; } An exception is always raised if a type overrides __init__ and passes extra arguments to object.__init__. No exception is raised for excess arguments in object.__init__ if a type overrides __new__ but not __init__. The __new__ method must consume the extra arguments; it must not pass them to object.__new__. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 20:30:59 +0100, Christian Gollwitzer wrote: > Am 29.02.16 um 22:51 schrieb Wildman: >> I want to take an image file, convert it to XBM format and >> display it. Thanks to Mr. Otten I can open and display the >> XBM image without any problems. The script first calls an >> external program for the image conversion then I can open >> and display it. Of course, I am left with the XBM file that >> needs to be deleted. > > I think you are solving the wrong problem. If your aim is to just > display an image using Tkinter, you can use PIL to read the image and > transfer the bits into a Tkinter photoimage object. For an example, look > here: > > http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/ > > (this might need some updating if you are using Python 3) > > Christian Thanks. I have read that page, among many others, during my research. It deals with an actual image file. I am dealing with an image that is not a file. It was redirected to stdout from another process and was never saved to the hard drive. Anyway, with Mr. Otten's help the problem is resolved. -- GNU/Linux user #557453 "Real patriotism is a willingness to challenge the government when it's wrong." -Ron Paul -- https://mail.python.org/mailman/listinfo/python-list
Re: What arguments are passed to the __new__ method ?
On 3/1/2016 12:24 PM, ast wrote: Hello It's not clear to me what arguments are passed to the __new__ method. The objects passed to any function are the objects that are passed. The type and number of objects that *should be* passed depends on the signature of the function. If class C defines __new__, then C.__new__ will receive as args C and all args passed in a C(...) call. So the C(...) call should have args that match those expected by __new__. If C also defines __init__, it will get the same args other than self replacing cls and thus it should have the same signature. The case is covered by in the entry for __new__ in https://docs.python.org/3/reference/datamodel.html#basic-customization "If __new__() returns an instance of cls, then the new instance’s __init__() method will be invoked like __init__(self[, ...]), where self is the new instance and the remaining arguments are the same as were passed to __new__()." class Premiere: def __new__(cls, price): return object.__new__(cls) This matches "Typical implementations create a new instance of the class by invoking the superclass’s __new__() method using super(currentclass, cls).__new__(cls[, ...]) with appropriate arguments and then modifying the newly-created instance as necessary before returning it." object.__new__ only takes the cls parameter. def __init__(self, price): pass p = Premiere(1000) No errors, so it seems that 2 arguments are passed to __new__, cls and price, and 2 arguments are passed to __init__, self and price -- as documented. But if i do: class Premiere: def __new__(cls, price): return object.__new__(cls, price) You get an error in current python because you sent an extra arg to object.__new__. If __new__ calls a superclass __new__, then it should only pass the args expected. At one time, object.__new__ would have accepted the price arg and ignored it. This is no longer true def __init__(self, price): pass p = Premiere(1000) it fails. It is strange because according to me it is equivalent to: Well, 'you' is wrong ;-), because in the following case, Premiere.__new__ is object.__new__, which has a different signature than __new__ above. class Premiere: def __init__(self, price): pass p = Premiere(1000) which is OK. Premiere is callable because it inherits object.__call__. That function, or the implementation of the CALL FUNCTION bytecode, must notice that Premiere.__new__ is object.__new__, by inheritance, and only pass Premiere and not 1000. The doc entry for __init__ says "The arguments are those passed to the class constructor expression." (The latter is the expression in the code that results in the class call.) This is always true. But since the signature of object.__new__ was restricted, the claim that the same args are sent to __new__ and __init__ seems not to be true. I may open a new doc issue. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: What arguments are passed to the __new__ method ?
On Tue, Mar 1, 2016 at 2:27 PM, Terry Reedy wrote: > On 3/1/2016 12:24 PM, ast wrote: > >> class Premiere: >> def __init__(self, price): >> pass >> p = Premiere(1000) >> >> which is OK. > > Premiere is callable because it inherits object.__call__. That function, or > the implementation of the CALL FUNCTION bytecode, must notice that > Premiere.__new__ is object.__new__, by inheritance, and only pass Premiere > and not 1000. It's not handled in bytecode or __call__. In CPython the type_call function passes its args and kwds to the type's tp_new and tp_init functions without modification. object.__new__ ignores the excess arguments in this case, as described in my previous message. While I think the cases where object.__new__ and object.__init__ ignore excess arguments are practical and sensible, they should still be documented. AFAICT, the language reference has nothing to say on this matter. -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote: > > On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano wrote: > > I cannot imagine why you would want to reload() in production code. That > > would imply that your production code is modifying already-imported > > modules, then wanting to import them again. Why would anyone in their right > > mind do that? Possibly because they lost a bet? > > BartC and I have both done this exact thing, though neither of us used > Python for it. It's not so insane as you might think; sometimes you > want to update code, but you don't want to restart a process. Just > because you've never had a process that hits a year of uptime doesn't > mean nobody else does. :) I have a hard time understanding the appeal of super-long uptimes. I'm not even comfortable running a single kernel version that long. What's so awful about 5 minutes of announced downtime in the middle of the night once a month while the system restarts? -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote: > On Mar 1, 2016 4:41 AM, "Chris Angelico" wrote: >> >> On Tue, Mar 1, 2016 at 10:18 PM, Steven D'Aprano > wrote: >> > I cannot imagine why you would want to reload() in production code. That >> > would imply that your production code is modifying already-imported >> > modules, then wanting to import them again. Why would anyone in their > right >> > mind do that? Possibly because they lost a bet? >> >> BartC and I have both done this exact thing, though neither of us used >> Python for it. It's not so insane as you might think; sometimes you >> want to update code, but you don't want to restart a process. Just >> because you've never had a process that hits a year of uptime doesn't >> mean nobody else does. :) > > I have a hard time understanding the appeal of super-long uptimes. I'm not > even comfortable running a single kernel version that long. What's so awful > about 5 minutes of announced downtime in the middle of the night once a > month while the system restarts? It kicks connections off, which may not matter to web sites, but it matters to servers that are designed for long-running connections. But more importantly, five minutes once a month isn't enough to do all your updates - so a live-update system would be required even with a regular monthly reset. I tend to have announced outages for kernel updates and such (eg a couple weeks ago), but in between, I want to be able to keep everything going, even though I'm making changes. Maybe I don't get to a year all that often (from memory, I think I've just twice achieved >1y uptime), but I certainly have multi-day uptimes, despite making changes multiple times a day. And I want to be able to deploy changes in the middle of a game, not leave off until the next scheduled downtime. So, yes, I need to be able to modify an already-imported module. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Tue, Mar 1, 2016 at 3:02 PM, Chris Angelico wrote: > On Wed, Mar 2, 2016 at 8:53 AM, Ian Kelly wrote: >> I have a hard time understanding the appeal of super-long uptimes. I'm not >> even comfortable running a single kernel version that long. What's so awful >> about 5 minutes of announced downtime in the middle of the night once a >> month while the system restarts? > > It kicks connections off, which may not matter to web sites, but it > matters to servers that are designed for long-running connections. But > more importantly, five minutes once a month isn't enough to do all > your updates - so a live-update system would be required even with a > regular monthly reset. I tend to have announced outages for kernel > updates and such (eg a couple weeks ago), but in between, I want to be > able to keep everything going, even though I'm making changes. > > Maybe I don't get to a year all that often (from memory, I think I've > just twice achieved >1y uptime), but I certainly have multi-day > uptimes, despite making changes multiple times a day. And I want to be > able to deploy changes in the middle of a game, not leave off until > the next scheduled downtime. So, yes, I need to be able to modify an > already-imported module. I certainly understand the value of being able to work on a mudlib without having to restart the mud. There's a big difference between that and clocking a year of uptime just because you can, though. The MUD that I used to play had scheduled restarts every 2-4 weeks, not to perform updates, but just to restart the process and clear out memory leaks. This never caused any real problem. You knew that it was coming because it was announced, and you took a break for a couple of minutes. If you were AFK, then your auto-login script reconnected you within shortly after the MUD came back up. -- https://mail.python.org/mailman/listinfo/python-list
Re: Request More Help With XBM Image
On Tue, 01 Mar 2016 12:56:03 -0600, Wildman wrote: > On Tue, 01 Mar 2016 19:26:55 +0100, Peter Otten wrote: > >> An exception is raised because you pass the command as a single argument > > > > I did not realize that how the command was passed would > make such a difference. I guess I am stuck in my old > VB habits for creating variables. You don't have to > say it, this ain't VB! :-) > > After making the changes to "command = ", it works fine > without the shell. At the risk of sounding redundant, > thank you. Ok, after some thought I think I understand what happened. Since I had the command as a single element, bash was required to parse the command therefore my code would not run without shell=true. That makes sense. I may not be the fastest oar in the water but I will eventually reach the shore. Thanks again for all your help. -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Wed, Mar 2, 2016 at 9:29 AM, Ian Kelly wrote: > I certainly understand the value of being able to work on a mudlib > without having to restart the mud. There's a big difference between > that and clocking a year of uptime just because you can, though. Oh, sure. I mentioned the year because I have done that once or twice, but it's the week, rather than the year, that's truly important. If something came up that meant I absolutely had to reset everything on a six-monthly basis, no big deal (although I'd rather not have a reset every month). > The MUD that I used to play had scheduled restarts every 2-4 weeks, > not to perform updates, but just to restart the process and clear out > memory leaks. This never caused any real problem. You knew that it was > coming because it was announced, and you took a break for a couple of > minutes. If you were AFK, then your auto-login script reconnected you > within shortly after the MUD came back up. Yeah, and I play one that has semi-scheduled restarts about every 6-10 weeks, for similar reasons (and also for game balance reasons; they deliberately don't save gear across restarts, so people have to gather new gear). I haven't had issues with memory leaks on my server, but it's relatively low traffic. Again, though, if it turned out (under heavier load) that periodic restarts were important, I could design around that requirement, but there's no way I could design around a model of "weekly downtime as the only way to change anything", the way games like Magic: The Gathering Online do. I've once seen them have to do an emergency out-of-band patch - and it took them an hour or something of outage to do it. Unacceptable in my book. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > There's a big difference between > that and clocking a year of uptime just because you can, though. What other reason is there for having a year of uptime? It's not like it is difficult. My laptop doesn't actually go anywhere: for historical reasons, it's a laptop but it is (mostly) used as a desktop. It sits on my desk. If there's a power outage, the handy built-in UPS (battery) keeps it alive for an hour or two. I come in, I nudge the mouse to wake xscreensaver and authenticate; I do my work; then I run xscreensaver to lock the screen and leave. If I need access to something from home, I can SSH into the office network, and from there into the laptop. The OS is as stable as the surface of the moon, and simply doesn't crash or go down ever. (If only Firefox was as good, alas, but when it does crash it is nearly always because I've allowed Javascript to run on some popular, multimedia-rich, information-free website.) I don't reboot because I don't need to reboot. Why would you reboot just for the sake of rebooting? When I unlock the screen, my system is usable *instantly*. I don't have to open a dozen applications, wait for them to load, authenticate into half a dozen different systems. They're already open. About once a year, or every 18 months or so, I need to reboot to go into Windows. If not for that, and the occasional kernel update, I'd probably never reboot. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
rdflib subclass problem
Hello, I'm just getting to grips with RDF and rdflib, and I've hit something I can't figure out. I have a graph with information on two people. (I haven't shown the imports below because they're scattered around my interactive session and I might reconstruct them incorrectly. Anyone familiar with rdflib will probably know what they are.) >>> G = Graph() >>> mark = BNode() >>> nat = BNode() >>> G.add((mark, RDF.type, FOAF.Person)) >>> G.add((mark, FOAF.firstName, Literal('mark'))) >>> G.add((nat, RDF.type, URIRef('Professor'))) >>> G.add((nat, FOAF.firstName, Literal('natalie'))) >>> G.add((URIRef('Professor'), RDFS.subClassOf, FOAF.Person)) >>> So I have specified that mark is a Person, natalie is a Professor, and that Professor is a subclass of Person. (I know that Professor is really a FOAF.title, but I'm just tinkering ATM.) >>> qres = G.query( """SELECT DISTINCT ?aname WHERE { ?a rdf:type foaf:Person . ?a foaf:firstName ?aname . }""", initNs = {"rdf": RDF,"foaf": FOAF}) >>> for row in qres: print "%s is a person" % row mark is a person >>> qres = G.query( """SELECT DISTINCT ?aname WHERE { ?a rdf:type ?prof . ?a foaf:firstName ?aname . }""", initNs = {"rdf": RDF,"foaf": FOAF, "prof": URIRef('Professor')}) >>> for row in qres: print "%s is a Prof" % row natalie is a Prof mark is a Prof >>> But according to the above queries only mark is a Person, and each is a Professor. I would have thought that both would be Persons and only natalie would be a Professor. Can anyone spot where I'm going wrong here? Thanks. Duncan -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Wed, 2 Mar 2016 05:06 am, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 28 Feb 2016 11:38 pm, BartC wrote: >>> It's the GUI users who are the Neanderthals, having to effectively >>> point at things with sticks. Or have to physically move that rock >>> themselves (ie. drag a file to a wastebasket). >> >> I haven't physically moved an icon to the wastebasket for years. I >> point at the icon, right-click, and tell it "move yourself to the >> trash". > > Do you find that interface convenient? Do you often find yourself > clickety-clicking around to perform bulk file operations? Sometimes. Especially with media files which display a thumbnail, it is far more convenient to be able to look at the icon and recognise the file than to try to guess from the filename "x73nfh.jpg". And having recognised the file visually, its often easier to drag it into the folder of your choice than to type "mv x7 dir" in a separate window. But not always. It's much easier to do "mv foo* dir". Horses for courses. >> Language is pretty important. But when you need to drive a nail into a >> piece of wood, would you rather hit the nail with a hammer, or explain >> to the hammer the precise direction and magnitude of force you would >> like it to apply when it impacts the nails? > > I don't know. My everyday file manipulation needs are so diverse that I > couldn't imagine how a GUI would make my life easier. *shrug* Then perhaps they're not as diverse as you think. > What I'm thinking is, could Python turn into a serious competitor to > bash? The standard shell suffers greatly from sloppy quoting, and many > of the age-old list-processing idioms are more awkward than cute. No. Python's syntax is too wordy to make a good shell. You need brackets and quote marks for everything: # bash ls foo/bar # Python ls("foo/bar") iPython is usable, by adding non-standard syntax to its REPL. I don't think it's a serious contender as replacement for bash, but you could give it a try. But the standard Python REPL? No. > A python shell would need a well-thought-out default import plus a way > to string together external commands. Maybe JSON or similar could be the > standard I/O framing format (instead of SPC-separated fields and > LF-separated records). You really want to be typing JSON by hand instead of space-separated fields/arguments? # Python using JSON ls('["-l", "foo/bar", "spam/ham"]') # bash ls -l foo/bar spam/ham Bugger that for a game of soldiers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Wed, Mar 2, 2016 at 12:51 PM, Steven D'Aprano wrote: > On Wed, 2 Mar 2016 05:06 am, Marko Rauhamaa wrote: > >> Steven D'Aprano : >> >>> On Sun, 28 Feb 2016 11:38 pm, BartC wrote: It's the GUI users who are the Neanderthals, having to effectively point at things with sticks. Or have to physically move that rock themselves (ie. drag a file to a wastebasket). >>> >>> I haven't physically moved an icon to the wastebasket for years. I >>> point at the icon, right-click, and tell it "move yourself to the >>> trash". >> >> Do you find that interface convenient? Do you often find yourself >> clickety-clicking around to perform bulk file operations? > > Sometimes. Especially with media files which display a thumbnail, it is far > more convenient to be able to look at the icon and recognise the file than > to try to guess from the filename "x73nfh.jpg". And having recognised the > file visually, its often easier to drag it into the folder of your choice > than to type "mv x7 dir" in a separate window. > > But not always. It's much easier to do "mv foo* dir". Horses for > courses. Absolutely. Tab completion *ROCKS* when you know the file name - point-and-click is *SUPERB* when you want to identify things by some form of metadata that the GUI can pull out and display (image/video file thumbnails being one example; executable files can include their own icons, esp on Windows; etcetera). The downside of the GUI, here, is that it sometimes is quite costly to generate those thumbnails; tab completion is done by reading the directory, but thumbnailing a bunch of JPGs requires reading the file contents (even if you were actually planning on clicking on one of the text files in the same directory). Like you say, horses for courses; but in many cases, I'd recommend starting with the cheap option - the command line - and moving to the costlier one only in the situations where you know it's of value. >> What I'm thinking is, could Python turn into a serious competitor to >> bash? The standard shell suffers greatly from sloppy quoting, and many >> of the age-old list-processing idioms are more awkward than cute. > > No. Python's syntax is too wordy to make a good shell. You need brackets and > quote marks for everything: > > # bash > ls foo/bar > > # Python > ls("foo/bar") > > iPython is usable, by adding non-standard syntax to its REPL. I don't think > it's a serious contender as replacement for bash, but you could give it a > try. But the standard Python REPL? No. >> A python shell would need a well-thought-out default import plus a way >> to string together external commands. Maybe JSON or similar could be the >> standard I/O framing format (instead of SPC-separated fields and >> LF-separated records). I think the non-standard syntax plan is the way to do it. But the thing is, you either have a code-like structure where you delimit everything, or you have the messy rules involving quoting and interpolation. The well-established basic shell syntax of space-delimited parameters with optional quoting is a great balance between verbosity and complexity. Not sure what "LF-separated records" has to do with "SPC-separated fields", though. The latter is all about how you type a command, and the former is all about the way different commands interact via stdin and stdout. > You really want to be typing JSON by hand instead of space-separated > fields/arguments? > > # Python using JSON > ls('["-l", "foo/bar", "spam/ham"]') > > # bash > ls -l foo/bar spam/ham > > Bugger that for a game of soldiers. No kidding, but at least it's consistent. Maybe there's a middle-ground, where it's still perfectly consistent, while not being quite as verbose? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Reason for not allowing import twice but allowing reload()
On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote: > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote: > >> There's a big difference between >> that and clocking a year of uptime just because you can, though. > > What other reason is there for having a year of uptime? > > It's not like it is difficult. My laptop doesn't actually go anywhere: for > historical reasons, it's a laptop but it is (mostly) used as a desktop. It > sits on my desk. If there's a power outage, the handy built-in UPS > (battery) keeps it alive for an hour or two. I come in, I nudge the mouse > to wake xscreensaver and authenticate; I do my work; then I run > xscreensaver to lock the screen and leave. > > If I need access to something from home, I can SSH into the office network, > and from there into the laptop. > > The OS is as stable as the surface of the moon, and simply doesn't crash or > go down ever. (If only Firefox was as good, alas, but when it does crash it > is nearly always because I've allowed Javascript to run on some popular, > multimedia-rich, information-free website.) I don't reboot because I don't > need to reboot. Why would you reboot just for the sake of rebooting? Software updates? The nice thing about *nix systems is that *most* updates don't require a reboot. I'm still going to reboot any time there's a kernel update though, and those are fairly frequent. I could read the patch notes to determine whether this new kernel version is actually important, but it takes less of my time just to go ahead and reboot. With my company-owned Macbook Air, the security policy will eventually schedule a *forced* reboot when there are "critical" updates to be installed. Thankfully the scheduler is pretty good about making sure it's not catching the user at an inopportune moment. -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Wed, 2 Mar 2016 05:07 am, Chris Angelico wrote: > On Wed, Mar 2, 2016 at 3:44 AM, Steven D'Aprano > wrote: >> A better analogy is: >> >> When I add cocaine to my stew, the result is a appallingly bad for those >> who eat it. Do you have any idea how rough cocaine is on the human body >> and brain? My wife likes the analogy, being on cocaine is like pressing >> the accelerator of your car all the way to the floor, ALL THE TIME, >> regardless of whether you are moving forward or stopped at the lights. >> And yet, for some reason, people seem to like the cocaine-riddled stew, >> and often ask me to add more cocaine. >> >> People cannot get enough of Javascript, no matter what it does to the >> security and stability of their browser, no matter how many pop-ups it >> launches or how much spyware and malware it installs, or how many times >> it kills their browser. > > s/cocaine/sriracha/ and I would agree with you, because there are > places where JS can majorly enhance a web site, and it isn't going to > kill you if you use it correctly. If by "kill" you mean "compromise your system", then JS absolutely can kill. Running somebody else's code on your machine could have *any* consequence, such as installing spyware, a spam-bot, ransomware, a keylogger that results in your bank account being emptied, or (if the spyware is being run by people who consider you an enemy of the state) literal death via a midnight visit from the secret police or a Hellfire missile fired through your window. https://community.rapid7.com/community/metasploit/blog/2014/01/23/firefox-privileged-payloads http://er.educause.edu/blogs/2016/2/fast-forward-javascript-api-exploits http://arstechnica.com/security/2013/08/attackers-wield-firefox-exploit-to-uncloak-anonymous-tor-users/ https://www.vidder.com/resources/attacks/javascript-device-exploit.html https://www.usenix.org/legacy/event/woot08/tech/full_papers/daniel/daniel_html/ http://www.mcafee.com/threat-intelligence/malware/default.aspx?id=1487635#vtab-characteristics (The last one typos the malware as "Java" code, but if you read on you'll see they actually mean Javascript.) As a web developer, if you host ads, your viewers at the mercy of malware: https://en.wikipedia.org/wiki/Malvertising Most malicious advertising is still written in Flash/ActionScript (a variant of Javascript), but some use Javascript: http://www.pcworld.com/article/3039816/security/malvertising-campaigns-are-becoming-harder-to-detect.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list
How to know if an object is still be referenced?
Recently I was puzzled by a tkinter problem. The codes below (from a book) can display the picture correctly. gifdir = "../gifs/" from tkinter import * win = Tk() photo = PhotoImage(file=gifdir + "ora-pp.gif") Button(win, image=photo).pack() win.mainloop() And the codes below (from another book) will also work. class DrumMachine: def create_play_bar(self): photo = PhotoImage(file='images/signature.gif') label = Label(playbar_frame, image=photo) label.image = photo label.grid(row=start_row, column=50, padx=1, sticky='w') In the second example, I noticed that the "photo" was referenced two times and I think it might be a redundancy so I remove the line "label.image = photo". But it fails then. How can it be? one works and the other not. I search for answers on the web and here are some links talking about it: http://stackoverflow.com/questions/20812579/why-it-shows-blank-instead-of-picture-in-my-tkinter-program http://effbot.org/tkinterbook/photoimage.htm They all said that you have to keep a reference to the "photo" or else it will be garbage collected. Now, as I had learn Python so far, I know that a keyword argument passed in an object instantiation will bind this object to its attribute name, i.e. create a reference to this object. (and it should or the whole language will be in disaster) Can anyone help me out? -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Saturday, February 27, 2016 at 6:19:21 AM UTC-5, wrong.a...@gmail.com wrote: > I have some VB forms with more than a hundred objects. If I cannot drag and > drop text boxes, list boxes, labels, etc., it will be too much work to create > that with several lines of code for each object. > > Isn't there any good GUI IDE like Visual Basic? I hope there are some less > well known GUI IDEs which I did not come across. Thanks. I'd recommend PyQt/PySide and Eric as an IDE: http://eric-ide.python-projects.org/index.html Eric has good integration with QtDesigner - you can create forms in designer like in VB and it will automatically generate python code for it or you can load *.ui files dynamically. The project management and VCS integration is also very convenient. Regards, Mikhail -- https://mail.python.org/mailman/listinfo/python-list
Re: Sending an email with a binary attachment
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 03/01/2016 02:03 AM, Chris Angelico wrote: > On Tue, Mar 1, 2016 at 6:58 PM, Anthony Papillion > wrote: >> -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 >> >> On 02/29/2016 11:13 AM, Chris Angelico wrote: >>> On Tue, Mar 1, 2016 at 4:08 AM, Peter Pearson >>> wrote: try: smtp.sendmail(message['From'], message['To'], message.as_string()) except: print "Message sending has failed" sys.exit(1) print "Message sending was successful" sys.exit(0) >>> >>> This is the problem, right here. Replace this code with: >>> >>> smtp.sendmail(message['From'], message['To'], >>> message.as_string()) >> >> Hmm, I'm a bit confused. Are you saying that the problem is that >> I'm enclosing the code in a Try/Except block? Besides that, I >> don't see anything different. If it's the Try/Except block, how >> do I catch the exception it might generate if I'm not using the >> exception block? >> > > That's exactly the difference. Why do you need to catch the > exception? All you're doing is destroying all the information, > rendering it down to a blunt "has failed". Mostly, I catch exceptions for two reasons: 1) because it's a habit that I've developed over the years and 2) I think unhandled exceptions make things look ugly. Mostly, I catch them from habit though. > > You should catch exceptions if you can actually handle them, but > if all you're doing is printing out a fixed message and aborting, > delete that code. Less code AND a better result. You make some very good points. It's going to take me some time to not catch exceptions by knee-jerk but I can see how doing so can cripple code and make debugging much harder. Thanks for the pointers. Anthony -BEGIN PGP SIGNATURE- iQIcBAEBCgAGBQJW1mwTAAoJEAKK33RTsEsV0L4P/jvRCX7w+8iqzlFub0CS35C6 KtuFXLEh+evKGhBecgToCA9eutuvCltknCxJz/Yyd56+QFsze1HHdDWGakuOP/1x gOwzZKr1vsjD4eMkoRRokIVkg437yOju0OReUOATKpYGgwnB6xW9RbOLwHRftXfa pmxg5k2KCBZ1omVLQ1BQcvM48Vi5J4k6IlFAVyM/L3Dzsyj9E1CtJ/VarTwkmAOf RbrBV7EH/k1ELM6yWsm0P00zhQkwZTdKt+Y3OGj7WaYoZXk7D3Q8wJqOJrHgInCr /JjbjX8yHtcVVaIRPKGVGt5PGNDdGvkmI5mJPXL+Io0k8faA4QLqjdCTFniyJ2t3 6HprovGQOJs64WN9RshcCwncJcWLC1wcLWZhZOj9nNZawTM6pWEDFpn1zmg6/lqu DmqhEeudjUtCjRJZr9xey47JJRRkjUrh/g1+VRW+aUfeuIc7xA6Nw7qvf3PqT6tH 8CtVwK9O2sHQ4y8lzAK3vCYY3Lw34qdO2zBC0ycxhMPbk1BqcL5U4WOTDZD/9H3h sh0E19pLYsAtoJpF2tnB2PcJaIWA9Zofz5/K6+5fs5B1wVW34Nu8wz6LMhUR1qSW yJH9Wv8Oznk99qiYUiOiduqGKwLM4+Fg0xYAX1muGNRvLfcYuGDFkyYhdZn9f7dM QdmK/dIaGT9l45hjDQTu =RlhP -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-list
Re: convert Dbase (.dbf) files to SQLite databases
On 03/01/2016 06:08 PM, Dennis Lee Bieber wrote: On Tue, 01 Mar 2016 08:49:08 -0800, Ethan Furman declaimed the following: Hmm, looks like that email was sent back in 2009. Sorry for the noise. I'm still not able to find a dbf module from John, though. Is it one of: https://www.google.com/#q=dbf.py I only checked the first three pages: - 12 refer to mine - 4 refer to pydbf - various others The third page drifts off into non-English languages and non-Python links. A search for his name and dbf also did not reveal anything. Ah well (aka *sigh*). -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
Steven D'Aprano : > On Wed, 2 Mar 2016 05:06 am, Marko Rauhamaa wrote: >> A python shell would need a well-thought-out default import plus a >> way to string together external commands. Maybe JSON or similar could >> be the standard I/O framing format (instead of SPC-separated fields >> and LF-separated records). > > You really want to be typing JSON by hand instead of space-separated > fields/arguments? > > # Python using JSON > ls('["-l", "foo/bar", "spam/ham"]') > > # bash > ls -l foo/bar spam/ham > > Bugger that for a game of soldiers. I was talking about JSON for the standard I/O, not the command-line arguments, as in: ps -ef | awk '/httpd/ { print $2 }' where "ps -ef" emits SPC-separated fields and LF-separated records, and awk parses and processes them. Marko -- https://mail.python.org/mailman/listinfo/python-list
Is it possiable to find the fastest ones of dns servers from a huge number of them fastly with python?
Hi all, I've a huge number of dns servers, around +5000, and I want to find the top 50 fastest ones out of them for my location. Is it possible for this type of thing using python under my Debian Jessie box? Regards -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- https://mail.python.org/mailman/listinfo/python-list
Re: Everything good about Python except GUI IDE?
On Wed, Mar 2, 2016 at 4:41 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Wed, 2 Mar 2016 05:06 am, Marko Rauhamaa wrote: >>> A python shell would need a well-thought-out default import plus a >>> way to string together external commands. Maybe JSON or similar could >>> be the standard I/O framing format (instead of SPC-separated fields >>> and LF-separated records). >> >> You really want to be typing JSON by hand instead of space-separated >> fields/arguments? >> >> # Python using JSON >> ls('["-l", "foo/bar", "spam/ham"]') >> >> # bash >> ls -l foo/bar spam/ham >> >> Bugger that for a game of soldiers. > > I was talking about JSON for the standard I/O, not the command-line > arguments, as in: > >ps -ef | awk '/httpd/ { print $2 }' > > where "ps -ef" emits SPC-separated fields and LF-separated records, and > awk parses and processes them. If you want to change that, you have to change the entire ecosystem, not just the shell. You would have to teach every single program to use a different structure. A lot of programs already do support NUL-separation - usually with a -z parameter or something. But you won't be able to magically get them all to use JSON. And I doubt it would be advantageous anyway. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is it possiable to find the fastest ones of dns servers from a huge number of them fastly with python?
On Wed, Mar 2, 2016 at 4:48 PM, Hongyi Zhao wrote: > I've a huge number of dns servers, around +5000, and I want to find > the top 50 fastest ones out of them for my location. > > Is it possible for this type of thing using python under my Debian Jessie > box? > Yep! Google "how to get busted for denial of service attacks". Why would you want to test that many DNS servers? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Is it possiable to find the fastest ones of dns servers from a huge number of them fastly with python?
On Wed, 02 Mar 2016 16:59:24 +1100, Chris Angelico wrote: > Yep! Google "how to get busted for denial of service attacks". > > Why would you want to test that many DNS servers? I'm from China, and the GFW has blocked many DNS servers. So I must pick out some good for using. > > ChrisA -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to know if an object is still be referenced?
On 3/1/2016 9:35 PM, jf...@ms4.hinet.net wrote: Recently I was puzzled by a tkinter problem. The codes below (from a book) can display the picture correctly. gifdir = "../gifs/" from tkinter import * win = Tk() photo = PhotoImage(file=gifdir + "ora-pp.gif") Button(win, image=photo).pack() win.mainloop() Since photo is a global name, the binding remain until you explicitly delete it or exit the app. And the codes below (from another book) will also work. class DrumMachine: def create_play_bar(self): photo = PhotoImage(file='images/signature.gif') label = Label(playbar_frame, image=photo) label.image = photo label.grid(row=start_row, column=50, padx=1, sticky='w') Here photo is a local name and the binding disappears when the function exits. I would rewrite it to follow pattern 1. self.photo = PhotoImage(file='images/signature.gif') label = Label(playbar_frame, image=self.photo) To me, saving an attribute reference is not worth the extra line. In the second example, I noticed that the "photo" was referenced two times and I think it might be a redundancy so I remove the line "label.image = photo". But it fails then. On another question, I made the same suggestion. Oops. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list