From torriem at gmail.com Tue Jul 1 00:17:39 2014 From: torriem at gmail.com (Michael Torrie) Date: Mon, 30 Jun 2014 22:17:39 -0600 Subject: [OT] What can Nuitka do? In-Reply-To: References: <4bfec709-263b-4c82-93ed-054432fd9d7e@googlegroups.com> <53ae31d6$0$29985$c3e8da3$5496439d@news.astraweb.com> <2f8d99b4-7a0b-47bf-8980-41f51cf7a9e7@googlegroups.com> <53AE411A.2080808@gmail.com> <2C380108368A4531B8E4C7287A344E6C@dev.null> <53B161DC.20708@gmail.com> Message-ID: <53B23663.1040201@gmail.com> On 06/30/2014 07:36 AM, Chris Angelico wrote: > Hmm. I'm not sure that it's necessarily that bad; I've done 3G-based > X11 forwarding fairly successfully on occasion. Yes, it's potentially > quite slow, but it certainly works - I've used SciTE, for instance, > and I've used some GTK2 apps without problems. What do you mean by > "modern toolkit"? Modern toolkit is defined as anything that uses client-side rendering. In the good old days of Motif and Xaw widgets, if a program wanted to draw, the toolkit would instruct the server to draw primitives. Rectangles, lines, etc. Each widget would be created in its own window, and events would be all handled on the server. Unfortunately we quickly hit some limits with that idea, as good and fast as it was. First of all, anti-aliased fonts were difficult to accomplish. There were hacks to do this early on, but it quickly became apparent that the actual application could do a better job of it if it would just do the rendering itself and have the X server draw it. Not only anti-aliased fonts, but also when you start talking about wanting to do layered effects like alpha-blending. All of this the app could do better and more efficiently than the X server could, since the X server would have had to round-trip to the app anyway to get the information since the X server is in a different process (or different computer) and cannot access the memory the app is using to store things. Kieth Packard wrote some X extensions to allow client-side rendering to be efficient and to let the X server to handle RGBA images, and to composite them together. Also, events in modern toolkits are done very differently than the original X toolkits. Instead of using multiple windows, clients now just establish one window and then handle events and figure out what widgets should receive the events client-side instead of server-side. This allows handling of things like scrollable canvases. Anyway, all of this improved the behavior and appearance of applications. When used locally, shared memory facilities make X pretty fast, although latency is still quite high. There's no way to synchronize frame redraws, so apps tear and stutter when you drag and resize. But over a network now, the nature of the X protocol means a lot of round-trips to the server to do things. This is very apparent when you run on a very slow connection. You might see widgets get drawn, then erase, then drawn again. Using a complex app like firefox, which has another layer of abstraction over GTK that makes it even worse, is very difficult on anything less than a LAN. Or try a Java Swing app! I've done it on occasion. I'd rather run Xvnc on the remote host and vnc in than forward X. FreeNX makes things very usable. http://en.wikipedia.org/wiki/NX_technology describes how NX works. I love that X11 apps work over a forward connection. And I love that I can run a remote window manager on a local X server if I wanted to. But I recognize X has it's problems and I can see how Wayland will eventually be so much better while still letting me remote apps, which is essential to me. From torriem at gmail.com Tue Jul 1 00:26:08 2014 From: torriem at gmail.com (Michael Torrie) Date: Mon, 30 Jun 2014 22:26:08 -0600 Subject: [OT] What can Nuitka do? In-Reply-To: <53B23663.1040201@gmail.com> References: <4bfec709-263b-4c82-93ed-054432fd9d7e@googlegroups.com> <53ae31d6$0$29985$c3e8da3$5496439d@news.astraweb.com> <2f8d99b4-7a0b-47bf-8980-41f51cf7a9e7@googlegroups.com> <53AE411A.2080808@gmail.com> <2C380108368A4531B8E4C7287A344E6C@dev.null> <53B161DC.20708@gmail.com> <53B23663.1040201@gmail.com> Message-ID: <53B23860.6070608@gmail.com> I highly recommend the talk by Daniel Stone who used to be a core X.org developer. He explains it quite well how X is used currently, and why it has problems and why they are considered so hard to fix that Wayland (and Mir) was created. https://www.youtube.com/watch?v=RIctzAQOe44 One interesting point he made was the X server is no longer network transparent like it used to be. It is network capable now but when used in that way (ssh forwarding), it's essentially done in the same way as VNC, but more poorly because of the way X11 is architected. From 114piyush at gmail.com Tue Jul 1 04:58:57 2014 From: 114piyush at gmail.com (Piyush Verma) Date: Tue, 1 Jul 2014 14:28:57 +0530 Subject: thread.interrupt_main() behaviour Message-ID: Hi, What is the behavior when we call thread.interrupt_main() method. Using this method I have implemented a new method for checking timeout. 359 def TimeoutFunc(self):360 '''Function invoked by timer thread in case of timeout '''361 self.log.debug("Timeout thread invoked now for test %s" % self.name)362 self.isTimeout = True363 #Interrupt test process364 thread.interrupt_main() Above method is invoked correctly, but I am not able to understand the behaviour. Please have a look into below diagram to explain which I am using. [image: Inline image 1] Since two threads are running same method, I wanted to know which main thread will be interrupted in both case. Regards, ~Piyush Facebook Twitter -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 23888 bytes Desc: not available URL: From skip at pobox.com Tue Jul 1 05:45:02 2014 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jul 2014 04:45:02 -0500 Subject: thread.interrupt_main() behaviour In-Reply-To: References: Message-ID: On Tue, Jul 1, 2014 at 3:58 AM, Piyush Verma <114piyush at gmail.com> wrote: > > Since two threads are running same method, I wanted to know which main thread will be interrupted in both case. I'm no threading expert, but a process can only have one main thread, the one you labeled "P". Threads T2 and Tt2 will both interrupt that thread. Skip From mhysnm1964 at gmail.com Tue Jul 1 05:56:29 2014 From: mhysnm1964 at gmail.com (Sean Murphy) Date: Tue, 1 Jul 2014 19:56:29 +1000 Subject: Python and wireshark. Message-ID: <944B8C1B-0214-4ABF-82A5-EC8B8D34285D@gmail.com> All. Is there any way to use python with Wireshark/Tshark? I am not able to use the GUI due to my vision impairment. So I am thinking of using Wireshark libraries and Python to provide a text console environment. Tshark does give you command line capability. I am more seeking for the ability of changing things on the fly, rather then creating complex command line parameters. Thoughts? Sean From sadzak at gmail.com Tue Jul 1 06:01:24 2014 From: sadzak at gmail.com (Adnan Sadzak) Date: Tue, 1 Jul 2014 12:01:24 +0200 Subject: Python and wireshark. In-Reply-To: <944B8C1B-0214-4ABF-82A5-EC8B8D34285D@gmail.com> References: <944B8C1B-0214-4ABF-82A5-EC8B8D34285D@gmail.com> Message-ID: You can try scapy (http://www.secdev.org/projects/scapy/) Cheers, Adnan On Tue, Jul 1, 2014 at 11:56 AM, Sean Murphy wrote: > All. > > Is there any way to use python with Wireshark/Tshark? I am not able to use > the GUI due to my vision impairment. So I am thinking of using Wireshark > libraries and Python to provide a text console environment. Tshark does > give you command line capability. I am more seeking for the ability of > changing things on the fly, rather then creating complex command line > parameters. > > > Thoughts? > > > Sean > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From onlydebian at gmail.com Tue Jul 1 06:27:59 2014 From: onlydebian at gmail.com (=?GB2312?B?sru7tbCit+U=?=) Date: Tue, 1 Jul 2014 03:27:59 -0700 (PDT) Subject: How to add ftp put function in PyQT network ftp demo Message-ID: <7492d8ec-8e64-4f0d-b927-b3981b75eea2@googlegroups.com> I want to modify the pyqt network ftp demo to include an upload function, but I am failing. Could someone can show me how to do this? I have tried to add this code, but it does not work. [Orignal demo]https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py at First, i add these code into demo. not work at all ############## buttonBox.addButton(self.uploadButton, QtGui.QDialogButtonBox.ActionRole) self.uploadButton = QtGui.QPushButton("upload") self.uploadButton.clicked.connect(self.selectFile) def selectFile(self): self.filename =QtGui.QFileDialog.getOpenFileName() up_fname = re.sub(r".*/","",self.filename) upload_file = QtCore.QFile(self.filename) self.ftp.put(upload_file, up_fname) ############## Second, i modify like this, i can upload small file successfully, but fail on big size file, the app will crash. ##################### def selectFile(self): self.filename =QtGui.QFileDialog.getOpenFileName() print self.filename up_fname = re.sub(r".*/","",self.filename) print up_fname upload_file = QtCore.QFile(self.filename) #print upload_file upload_file.open(QtCore.QIODevice.ReadOnly) ba = QtCore.QByteArray() ba.append(upload_file.readAll()) #buffer = QtCore.QBuffer() #### do not how to use Buffer #buffer.open(QtCore.QIODevice.ReadWrite) #buffer.setData(ba) self.ftp.put(ba, up_fname) self.progressDialog.setLabelText("Uploading %s..." % up_fname) self.uploadButton.setEnabled(False) self.progressDialog.exec_() self.uploadButton.setEnabled(True) self.ftp.list() #################### From rmorgan466 at gmail.com Tue Jul 1 06:38:35 2014 From: rmorgan466 at gmail.com (Rita) Date: Tue, 1 Jul 2014 06:38:35 -0400 Subject: general module auditing Message-ID: i work in a group of developers (15 or so) who are located globally. I would like to know what modules everyone is uses if I ever have to upgrade my python. Is there mechanism which will let me see who is using what? ie, tom,matplotlib bob, pylab nancy, numpy nancy, matplotlib etc... -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From patil.jay2009 at gmail.com Tue Jul 1 06:51:31 2014 From: patil.jay2009 at gmail.com (Jaydeep Patil) Date: Tue, 1 Jul 2014 03:51:31 -0700 (PDT) Subject: Convert Excel Range into python List Message-ID: <6a3feb11-f03d-48bf-a674-a8567db1f8f6@googlegroups.com> How to convert excel range into python list or tuple? show me example Regards Jaydeep Patil From denismfmcmahon at gmail.com Tue Jul 1 07:11:49 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Tue, 1 Jul 2014 11:11:49 +0000 (UTC) Subject: Convert Excel Range into python List References: <6a3feb11-f03d-48bf-a674-a8567db1f8f6@googlegroups.com> Message-ID: On Tue, 01 Jul 2014 03:51:31 -0700, Jaydeep Patil wrote: > How to convert excel range into python list or tuple? > show me example http://lmgtfy.com/?q=convert+excel+range+into+python+list+or+tuple This is an example of how to google a programming question. Learn from it! -- Denis McMahon, denismfmcmahon at gmail.com From a24061 at ducksburg.com Tue Jul 1 07:26:53 2014 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 01 Jul 2014 12:26:53 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database Message-ID: I have some code that reads files in a leafnode2 news spool & needs to check for new files periodically. The full paths are all like '/var/spool/news/message.id/345/<123456 at example.com>' with a 3-digit subdirectory & a Message-ID for the filename itself. I'm using Python 3 & sqlite3 in the standard library. I have a table of filenames created with the following command: cursor.execute('CREATE TABLE files (filename TEXT PRIMARY KEY, used INTEGER)') To check for new files in one of the subdirectories, I run A then either B or C below (I've tried both). A. listing1 = os.listdir(directory) listing [os.path.join(directory, x) for x in listing1] B. cursor = db_conn.cursor() for filename in listing: cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) row = cursor.fetchone() if not row: cursor.execute('INSERT INTO files VALUES (?, ?)', (filename, 0) ) files_new += 1 db_conn.commit() C. cursor = db_conn.cursor() subdir_like = directory + '/%' cursor.execute('SELECT filename FROM files WHERE filename LIKE ?', (subdir_like,)) rows = cursor.fetchall() known_files = [row[0] for row in rows] for filename in listing: if filename not in known_files: cursor.execute('INSERT INTO files VALUES (?, ?)', (filename, 0) ) files_new += 1 db_conn.commit() A+B was the first method I came up with, because it looks like the "keep it simple & let the database do its job" approach, but it was very time-consuming, so I tested A+C out. A is quick (a second); B can drag on for over an hour to check 2000 filenames (for example) in a subdirectory; C always takes less than a minute. So C is much better than B, but it looks (to me) like one of those attempts to bypass & ignore the database's built-in optimizations. Comments? -- No sport is less organized than Calvinball! From patil.jay2009 at gmail.com Tue Jul 1 08:04:51 2014 From: patil.jay2009 at gmail.com (Jaydeep Patil) Date: Tue, 1 Jul 2014 05:04:51 -0700 (PDT) Subject: Python While loop Takes too much time. In-Reply-To: References: Message-ID: On Monday, 30 June 2014 18:16:21 UTC+5:30, Peter Otten wrote: > Jaydeep Patil wrote: > > > > > I have did excel automation using python. > > > In my code I am creating python dictionaries for different three columns > > > data at a time.There are are many rows above 4000. Lets have look in below > > > function. Why it is taking too much time? > > > > > > Code: > > > > > > def transientTestDict(self,ws,startrow,startcol): > > > > > > self.hwaDict = OrderedDict() > > > self.yawRateDict = OrderedDict() > > > > > > rng = ws.Cells(startrow,startcol) > > > > > > while not rng.Value is None: > > > r = rng.Row > > > c = rng.Column > > > > > > time = rng.Value > > > > > > rng1 = rng.GetOffset(0,1) > > > hwa = rng1.Value > > > > > > rng2 = rng.GetOffset(0,2) > > > yawrate = rng2.Value > > > > > > self.hwaDict[time] = hwa,rng.Row,rng.Column > > > self.yawRateDict[time] = yawrate,rng.Row,rng.Column > > > > > > rng = ws.Cells(r+1,c) > > > > > > > > > > > > Please have look in above code & suggest me to improve speed of my code. > > > > Assuming that what slows down things is neither Python nor Excel, but the > > communication between these I'd try to do as much as possible in Python. For > > example (untested): > > > > def transientTestDict(self, ws, startrow, startcol): > > self.hwaDict = OrderedDict() > > self.yawRateDict = OrderedDict() > > > > time_col, hwa_col, yawrate_col = range(startcol, startcol+3) > > > > for row in xrange(startrow, sys.maxint): > > time = ws.Cells(row, time_col).Value > > if time is None: > > break > > hwa = ws.Cells(row, hwa_col).Value > > yawrate = ws.Cells(row, yawrate_col).Value > > > > self.hwaDict[time] = hwa, row, time_col > > self.yawRateDict[time] = yawrate, row, time_col > > > > While this avoids cell arithmetic in Excel it still fetches every value > > separately, so I have no idea if there is a significant effect. > > > > Does Excel provide a means to get multiple cell values at once? That would > > likely help. Dear Peter, I have tested code written by you. But still it is taking same time. Regards Jay From rosuav at gmail.com Tue Jul 1 08:06:02 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 1 Jul 2014 22:06:02 +1000 Subject: Searching for lots of similar strings (filenames) in sqlite3 database In-Reply-To: References: Message-ID: On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: > cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) Shouldn't this be an equality check rather than IS, which normally I'd expect to be "IS NULL" or "IS NOT NULL"? As to your actual question: Your two database lookups are doing distinctly different things, so there's no surprise that they perform very differently. B asks the database "Do you have this? Do you have this?" for every file you have, and C asks the database "What do you have?", and then comparing that against the list of files. By the way - the A+C technique could be done quite tidily as a set difference: # assume you have listing1 and cursor set up # as per your above code listing = {os.path.join(directory, x) for x in listing1} cursor.execute(...) # as per above known_files = {row[0] for row in cursor} # cursors are iterable needed_files = listing - known_files cursor.executemany('INSERT INTO files VALUES (?, ?)', ((filename, 0) for filename in needed_files)) Anyway. The significant thing is the performance of the database on two different workloads: either "give me everything that matches this pattern" (where the pattern ends with a percent sign), or "do you have this? do you have this? do you have this?". Generally, database indexing is fairly efficient at handling prefix searches, so the first query will basically amount to an index search, which is a lot faster than the repeated separate searching; it takes advantage of the fact that all the strings you're looking at will have the same prefix. There is one critical consideration, though. What happens if the directory name contains an underscore or percent sign? Or can you absolutely guarantee that they won't? You may need to escape them, and I'm not sure how SQLite handles that. (Possibly \_ will match literal _, and \\ will match literal \, or something like that.) This is not bypassing the database's optimization; in fact, it's working tidily within it. If you want to express your logic in a way that lets the database truly be in command of optimization, it would look something like this: INSERT INTO files SELECT filename,0 FROM (VALUES('foo'),('bar'),('quux'),('spam')) AS needed(filename) EXCEPT SELECT filename,0 FROM files And you'd need to check the SQLite docs for how to define a table that consists of literal values. (The above syntax works in PostgreSQL; I'm pretty sure it's not all standard SQL.) But doing the set difference in Python is just as good a way of doing the job. ChrisA From python at mrabarnett.plus.com Tue Jul 1 08:13:56 2014 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Jul 2014 13:13:56 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database In-Reply-To: References: Message-ID: <53B2A604.3040208@mrabarnett.plus.com> On 2014-07-01 12:26, Adam Funk wrote: > I have some code that reads files in a leafnode2 news spool & needs to > check for new files periodically. The full paths are all like > '/var/spool/news/message.id/345/<123456 at example.com>' with a 3-digit > subdirectory & a Message-ID for the filename itself. I'm using Python > 3 & sqlite3 in the standard library. > > I have a table of filenames created with the following command: > > cursor.execute('CREATE TABLE files (filename TEXT PRIMARY KEY, used INTEGER)') > > To check for new files in one of the subdirectories, I run A then > either B or C below (I've tried both). > > A. > listing1 = os.listdir(directory) > listing [os.path.join(directory, x) for x in listing1] > > B. > cursor = db_conn.cursor() > for filename in listing: > cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) > row = cursor.fetchone() > if not row: > cursor.execute('INSERT INTO files VALUES (?, ?)', (filename, 0) ) > files_new += 1 > db_conn.commit() > > C. > cursor = db_conn.cursor() > subdir_like = directory + '/%' > cursor.execute('SELECT filename FROM files WHERE filename LIKE ?', (subdir_like,)) > rows = cursor.fetchall() > known_files = [row[0] for row in rows] > for filename in listing: > if filename not in known_files: > cursor.execute('INSERT INTO files VALUES (?, ?)', (filename, 0) ) > files_new += 1 > db_conn.commit() > > A+B was the first method I came up with, because it looks like the > "keep it simple & let the database do its job" approach, but it was > very time-consuming, so I tested A+C out. A is quick (a second); B > can drag on for over an hour to check 2000 filenames (for example) in > a subdirectory; C always takes less than a minute. So C is much > better than B, but it looks (to me) like one of those attempts to > bypass & ignore the database's built-in optimizations. > > Comments? > In C, 'known_files' is a list, so it performs a linear search for each of the filenames. If you make 'known_files' a set, it'll probably be even faster! Anyway, I'm sure there's something in SQL for "insert or update" or "on duplicate", but that's an SQL question, not a Python question. From kwa at kuwata-lab.com Tue Jul 1 08:14:02 2014 From: kwa at kuwata-lab.com (Makoto Kuwata) Date: Tue, 1 Jul 2014 21:14:02 +0900 Subject: [ANN] Oktest.py 0.15.0 released; a new-style testing library Message-ID: Hi all, I released Oktest.py 0.15.0. * PyPI: https://pypi.python.org/pypi/Oktest/ * Document: http://www.kuwata-lab.com/oktest/oktest-py_users-guide.html What is Oktest.py? ------------------ Oktest.py is a new-style testing library for Python. Example:: from oktest import test, ok, NG class FooTest(unittest.TestCase): @test("1 + 1 should be 2") def _(self): ok (1+1) == 2 # same as assertEqual(2, 1+1) @test("other examples") def _(self): ok (s) == 'foo' # same as assertEqual(s, 'foo') ok (s) != 'foo' # same as assertNotEqual(s, 'foo') ok (n) > 0 # same as assertTrue(n > 0) ok (fn).raises(Error) # same as assertRaises(Error, fn) ok ([]).is_a(list) # same as assertTrue(isinstance([], list)) NG ([]).is_a(tuple) # same as assertTrue(not isinstance([], tuple)) ok ('A.txt').is_file() # same as assertTrue(os.path.isfile('A.txt')) NG ('A.txt').is_dir() # same as assertTrue(not os.path.isdir('A.txt')) See http://www.kuwata-lab.com/oktest/oktest-py_users-guide.html for details. Changes in this release ----------------------- * [enhance] oktest.web.WSGITest class supports multipart form data. * [enhance] oktest.web.WSGITest class supports 'Cookie' and 'Set-Cookie'. * [enhance] New assertion methods. ok (xs).all(lambda x: x is None) # ok when all items in xs are None ok (xs).any(lambda x: x is None) # ok when there is None in xs ok (x).between(minval, maxval) # ok when minval <= x <= maxval ok (xs).length([minlen, maxlen]) # ok when minlen <= len(xs) <= maxlen ok (dictionary).has_key('key') # ok when dictinary has key ok (dictionary).has_item('key','val') # ok when dictionary has key an val * [enhance] New utility function 'options_of()' to get user-defined options. * [bugfix] oktest.web.WSGITest now works on Python 3.4. * [bugfix] fix oktest.web.WSGITest class to encode urlpath when multibyte. See http://www.kuwata-lab.com/oktest/oktest-py_CHANGES.txt for details. -- regards, makoto kuwata -------------- next part -------------- An HTML attachment was scrubbed... URL: From __peter__ at web.de Tue Jul 1 08:40:18 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Jul 2014 14:40:18 +0200 Subject: Python While loop Takes too much time. References: Message-ID: Jaydeep Patil wrote: > Dear Peter, > I have tested code written by you. But still it is taking same time. Too bad ;( If you run the equivalent loop written in Basic from within Excel -- is that faster? If you run the loop in Python with some made-up data instead of that fetched from Excel -- is that faster? What I'm trying to tell you: you need to put in some work to identify the culprit... From __peter__ at web.de Tue Jul 1 08:43:48 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Jul 2014 14:43:48 +0200 Subject: unorderable error: less ok, equal ok, less-or-equal gives unorderable error! References: <53B1C013.3070901@stoneleaf.us> Message-ID: Ethan Furman wrote: > On 06/30/2014 12:34 PM, Peter Otten wrote: >> RainyDay wrote: >>> >>> def __eq__(self, other): >>> return self._loc == getattr(other, "_loc", None) >> >> Note that None is not a good default when _loc is expected to be a tuple: > > In this case None is not being returned, but will be comparid with > self._loc, so RainyDay is good there. RainyDay wrote: > I'm only using None in equality comparison, it's never a default value of > _loc itself, so this should be ok because it'll compare to all other > object types and correctly say they're unequal. Yes, sorry. I read what I expected rather than what was there. From rosuav at gmail.com Tue Jul 1 10:02:51 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Jul 2014 00:02:51 +1000 Subject: Searching for lots of similar strings (filenames) in sqlite3 database In-Reply-To: <53B2A604.3040208@mrabarnett.plus.com> References: <53B2A604.3040208@mrabarnett.plus.com> Message-ID: On Tue, Jul 1, 2014 at 10:13 PM, MRAB wrote: > Anyway, I'm sure there's something in SQL for "insert or update" or "on > duplicate", but that's an SQL question, not a Python question. Not in standard SQL, no; there might be in SQLite, as a non-standard extension, but it's a fundamentally hard problem and it has issues. Frankly, though, I doubt the time cost of set operations is anything significant compared to the various queries against the database. ChrisA From flebber.crue at gmail.com Tue Jul 1 10:04:33 2014 From: flebber.crue at gmail.com (flebber) Date: Tue, 1 Jul 2014 07:04:33 -0700 (PDT) Subject: fixing an horrific formatted csv file. Message-ID: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> What I am trying to do is to reformat a csv file into something more usable. currently the file has no headers, multiple lines with varying columns that are not related. This is a sample Meeting,05/07/14,RHIL,Rosehill Gardens,Weights,TAB,+3m Entire Circuit, , Race,1,CIVIC STAKES,CIVIC,CIVIC,1350,~ ,3U ,~ ,QLT ,54,0,0,5/07/2014,, , , , ,No class restriction, Quality, For Three-Years-Old and Upwards, No sex restriction, (Listed),Of $100000. First $60000, second $20000, third $10000, fourth $5000, fifth $2000, sixth $1000, seventh $1000, eighth $1000 Horse,1,Bennetta,0,"Grahame Begg",Randwick,,0,0,16-3-1-3 $390450.00,,0,0,0,,98.00,M, Horse,2,Breakfast in Bed,0,"David Vandyke",Warwick Farm,,0,0,20-6-1-5 $201250.00,,0,0,0,,81.00,M, Horse,3,Capital Commander,0,"Gerald Ryan",Rosehill,,0,0,43-9-9-3 $438625.00,,0,0,0,,85.00,M, Horse,4,Coup Ay Tee (NZ),0,"Chris Waller",Rosehill,,0,0,35-9-6-5 $519811.00,,0,0,0,,101.00,G, Horse,5,Generalife,0,"John O'Shea",Warwick Farm,,0,0,19-6-1-3 $235045.00,,0,0,0,,87.00,G, Horse,6,He's Your Man (FR),0,"Chris Waller",Rosehill,,0,0,13-2-3-1 $108110.00,,0,0,0,,93.00,G, Horse,7,Hidden Kisses,0,"Chris Waller",Rosehill,,0,0,40-8-8-5 $565750.00,,0,0,0,,96.00,M, Horse,8,Oakfield Commands,0,"Gerald Ryan",Rosehill,,0,0,22-7-4-6 $269530.00,,0,0,0,,94.00,G, Horse,9,Taxmeifyoucan,0,"Gregory Hickman",Warwick Farm,,0,0,18-2-4-4 $539730.00,,0,0,0,,91.00,G, Horse,10,The Peak,0,"Bart & James Cummings",Randwick,,0,0,15-6-1-0 $426732.00,,0,0,0,,95.00,G, Horse,11,Tougher Than Ever (NZ),0,"Chris Waller",Rosehill,,0,0,17-3-2-3 $321613.00,,0,0,0,,97.00,H, Horse,12,TROMSO,0,"Chris Waller",Rosehill,,0,0,47-8-11-2 $622300.00,,0,0,0,,103.00,G, Race,2,FLYING WELTER - BENCHMARK 95 HCP,BM95,BM95,1100,BM95 ,3U ,~ ,HCP ,54,0,0,5/07/2014,, , , , ,BenchMark 95, Handicap, For Three-Years-Old and Upwards, No sex restriction,Of $85000. First $48750, second $16750, third $8350, fourth $4150, fifth $2000, sixth $1000, seventh $1000, eighth $1000, ninth $1000, tenth $1000 Horse,1,Big Bonanza,0,"Don Robb",Wyong,,0,57.5,31-9-4-3 $366860.00,,0,0,0,,92.00,G, Horse,2,Casual Choice,0,"Joseph Pride",Warwick Farm,,0,54,8-2-3-0 $105930.00,,0,0,0, So what I am trying to so is end up with an output like this. Meeting, Date, Race, Number, Name, Trainer, Location Rosehill, 05/07/14, 1, 1,Bennetta,"Grahame Begg",Randwick, Rosehill, 05/07/14, 1, 2,Breakfast in Bed,"David Vandyke",Warwick Farm, So as a start i thought i would try inserting the Meeting and Race number however I am just not getting it right. import csv outfile = open("/home/sayth/Scripts/cleancsv.csv", "w") with open('/home/sayth/Scripts/test.csv') as f: f_csv = csv.reader(f) headers = next(f_csv) for row in f_csv: meeting = row[3] in row[0] == 'Meeting' new = row.insert(0, meeting) while row[1] in row[0] == 'Race' < 9: # pref less than next found row[0] # grab row[1] as id number id = row[1] # from row[0] and insert it in first position new_lines = new.insert(1, id) outfile.write(new_lines) outfile.close() How should I go about this? Thanks Sayth From breamoreboy at yahoo.co.uk Tue Jul 1 10:14:26 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 01 Jul 2014 15:14:26 +0100 Subject: Convert Excel Range into python List In-Reply-To: <6a3feb11-f03d-48bf-a674-a8567db1f8f6@googlegroups.com> References: <6a3feb11-f03d-48bf-a674-a8567db1f8f6@googlegroups.com> Message-ID: On 01/07/2014 11:51, Jaydeep Patil wrote: > How to convert excel range into python list or tuple? > show me example > > Regards > Jaydeep Patil > Sorry but if you can't show that you've put some effort into this then you're not likely to get answers. Further would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing and single line paragraphs that show in your other posts, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From python at mrabarnett.plus.com Tue Jul 1 10:32:23 2014 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Jul 2014 15:32:23 +0100 Subject: fixing an horrific formatted csv file. In-Reply-To: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> Message-ID: <53B2C677.5050108@mrabarnett.plus.com> On 2014-07-01 15:04, flebber wrote: > What I am trying to do is to reformat a csv file into something more usable. > currently the file has no headers, multiple lines with varying columns that are not related. > > This is a sample > > Meeting,05/07/14,RHIL,Rosehill Gardens,Weights,TAB,+3m Entire Circuit, , > Race,1,CIVIC STAKES,CIVIC,CIVIC,1350,~ ,3U ,~ ,QLT ,54,0,0,5/07/2014,, , , , ,No class restriction, Quality, For Three-Years-Old and Upwards, No sex restriction, (Listed),Of $100000. First $60000, second $20000, third $10000, fourth $5000, fifth $2000, sixth $1000, seventh $1000, eighth $1000 > Horse,1,Bennetta,0,"Grahame Begg",Randwick,,0,0,16-3-1-3 $390450.00,,0,0,0,,98.00,M, > Horse,2,Breakfast in Bed,0,"David Vandyke",Warwick Farm,,0,0,20-6-1-5 $201250.00,,0,0,0,,81.00,M, > Horse,3,Capital Commander,0,"Gerald Ryan",Rosehill,,0,0,43-9-9-3 $438625.00,,0,0,0,,85.00,M, > Horse,4,Coup Ay Tee (NZ),0,"Chris Waller",Rosehill,,0,0,35-9-6-5 $519811.00,,0,0,0,,101.00,G, > Horse,5,Generalife,0,"John O'Shea",Warwick Farm,,0,0,19-6-1-3 $235045.00,,0,0,0,,87.00,G, > Horse,6,He's Your Man (FR),0,"Chris Waller",Rosehill,,0,0,13-2-3-1 $108110.00,,0,0,0,,93.00,G, > Horse,7,Hidden Kisses,0,"Chris Waller",Rosehill,,0,0,40-8-8-5 $565750.00,,0,0,0,,96.00,M, > Horse,8,Oakfield Commands,0,"Gerald Ryan",Rosehill,,0,0,22-7-4-6 $269530.00,,0,0,0,,94.00,G, > Horse,9,Taxmeifyoucan,0,"Gregory Hickman",Warwick Farm,,0,0,18-2-4-4 $539730.00,,0,0,0,,91.00,G, > Horse,10,The Peak,0,"Bart & James Cummings",Randwick,,0,0,15-6-1-0 $426732.00,,0,0,0,,95.00,G, > Horse,11,Tougher Than Ever (NZ),0,"Chris Waller",Rosehill,,0,0,17-3-2-3 $321613.00,,0,0,0,,97.00,H, > Horse,12,TROMSO,0,"Chris Waller",Rosehill,,0,0,47-8-11-2 $622300.00,,0,0,0,,103.00,G, > Race,2,FLYING WELTER - BENCHMARK 95 HCP,BM95,BM95,1100,BM95 ,3U ,~ ,HCP ,54,0,0,5/07/2014,, , , , ,BenchMark 95, Handicap, For Three-Years-Old and Upwards, No sex restriction,Of $85000. First $48750, second $16750, third $8350, fourth $4150, fifth $2000, sixth $1000, seventh $1000, eighth $1000, ninth $1000, tenth $1000 > Horse,1,Big Bonanza,0,"Don Robb",Wyong,,0,57.5,31-9-4-3 $366860.00,,0,0,0,,92.00,G, > Horse,2,Casual Choice,0,"Joseph Pride",Warwick Farm,,0,54,8-2-3-0 $105930.00,,0,0,0, > > So what I am trying to so is end up with an output like this. > > Meeting, Date, Race, Number, Name, Trainer, Location > Rosehill, 05/07/14, 1, 1,Bennetta,"Grahame Begg",Randwick, > Rosehill, 05/07/14, 1, 2,Breakfast in Bed,"David Vandyke",Warwick Farm, > > So as a start i thought i would try inserting the Meeting and Race number however I am just not getting it right. > > import csv > > outfile = open("/home/sayth/Scripts/cleancsv.csv", "w") > with open('/home/sayth/Scripts/test.csv') as f: > f_csv = csv.reader(f) > headers = next(f_csv) > for row in f_csv: > meeting = row[3] in row[0] == 'Meeting' > new = row.insert(0, meeting) > while row[1] in row[0] == 'Race' < 9: # pref less than next found row[0] > > # grab row[1] as id number > id = row[1] > # from row[0] and insert it in first position > new_lines = new.insert(1, id) > outfile.write(new_lines) > outfile.close() > > How should I go about this? > There's no point in reading the first row as the headers because it clearly doesn't contain just the headings. First write a row for the header. Then, for each row: If the first field is 'Meeting', then remember the meeting, etc. If the first field is 'Race', then remember the race, etc. If the first field is 'Horse', then write the row with the additional fields for race, etc. And so on. BTW, the indentation for the 'outfile.close()' line is wrong. It would, of course, be better to use the 'with' statement for that file too. From mailinglists at xgm.de Tue Jul 1 11:12:34 2014 From: mailinglists at xgm.de (Florian Lindner) Date: Tue, 01 Jul 2014 17:12:34 +0200 Subject: Get named groups from a regular expression Message-ID: Hello, Is there a way I can extract the named groups from a regular expression? e.g. given "(?P\d)" I want to get something like ["testgrp"]. OR Can I make the match object to return default values for named groups, even if no match was produced? Thanks, Florian From a24061 at ducksburg.com Tue Jul 1 11:15:47 2014 From: a24061 at ducksburg.com (Adam Funk) Date: Tue, 01 Jul 2014 16:15:47 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database References: Message-ID: <3uva8bx3dn.ln2@news.ducksburg.com> On 2014-07-01, Chris Angelico wrote: > On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >> cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) > > Shouldn't this be an equality check rather than IS, which normally I'd > expect to be "IS NULL" or "IS NOT NULL"? Oh, it probably should be in "heavy" SQL. In SQLite, '==', '=', & 'IS' are interchangeable. http://www.tutorialspoint.com/sqlite/sqlite_operators.htm Looking at that page again, I see that 'GLOB' is a case-sensitive version of 'LIKE'. I can't help but wonder if that makes it faster. ;-) > As to your actual question: Your two database lookups are doing > distinctly different things, so there's no surprise that they perform > very differently. B asks the database "Do you have this? Do you have > this?" for every file you have, and C asks the database "What do you > have?", and then comparing that against the list of files. By the way > - the A+C technique could be done quite tidily as a set difference: > > # assume you have listing1 and cursor set up > # as per your above code > listing = {os.path.join(directory, x) for x in listing1} > cursor.execute(...) # as per above > known_files = {row[0] for row in cursor} # cursors are iterable > needed_files = listing - known_files > cursor.executemany('INSERT INTO files VALUES (?, ?)', ((filename, > 0) for filename in needed_files)) Oh, even better: add_files = listing - known_files delete_files = known_files - listing and then I can remove files that have disappeared off the spool from the table. Thanks very much! > Anyway. The significant thing is the performance of the database on > two different workloads: either "give me everything that matches this > pattern" (where the pattern ends with a percent sign), or "do you have > this? do you have this? do you have this?". Generally, database > indexing is fairly efficient at handling prefix searches, so the first > query will basically amount to an index search, which is a lot faster > than the repeated separate searching; it takes advantage of the fact > that all the strings you're looking at will have the same prefix. > > There is one critical consideration, though. What happens if the > directory name contains an underscore or percent sign? Or can you > absolutely guarantee that they won't? You may need to escape them, and > I'm not sure how SQLite handles that. (Possibly \_ will match literal > _, and \\ will match literal \, or something like that.) I can guarantee that the directory names are all '/var/spool/news/message.id/' then 3 digits. (The filenames are pretty wild, since they are MIDs.) AIUI, using the '?' substitution in the sqlite3 library is supposed to be safe. > This is not bypassing the database's optimization; in fact, it's > working tidily within it. That's reassuring! ... > But doing the set difference in Python is just as good a way of doing the job. I like it. Thanks very much. -- Specifications are for the weak & timid! --- Klingon Programmer's Guide From __peter__ at web.de Tue Jul 1 11:29:17 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Jul 2014 17:29:17 +0200 Subject: Get named groups from a regular expression References: Message-ID: Florian Lindner wrote: > Is there a way I can extract the named groups from a regular expression? > e.g. given "(?P\d)" I want to get something like ["testgrp"]. Easy, just write a regular expression to parse regular expressions ;) (Sorry, I can't contribute something constructive, my first idea, re.DEBUG doesn't help) > OR > > Can I make the match object to return default values for named groups, > even if no match was produced? From rosuav at gmail.com Tue Jul 1 11:57:21 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Jul 2014 01:57:21 +1000 Subject: Searching for lots of similar strings (filenames) in sqlite3 database In-Reply-To: <3uva8bx3dn.ln2@news.ducksburg.com> References: <3uva8bx3dn.ln2@news.ducksburg.com> Message-ID: On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: > On 2014-07-01, Chris Angelico wrote: > >> On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >>> cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) >> >> Shouldn't this be an equality check rather than IS, which normally I'd >> expect to be "IS NULL" or "IS NOT NULL"? > > Oh, it probably should be in "heavy" SQL. In SQLite, '==', '=', & > 'IS' are interchangeable. > > http://www.tutorialspoint.com/sqlite/sqlite_operators.htm Ah, okay. In that case, I'd advise going with either == for consistency with the rest of Python, or (preferably) = for consistency with other SQL engines. You wouldn't use "is" to test if two Python strings are equal, so there's no particular reason to use it here :) > Oh, even better: > > add_files = listing - known_files > delete_files = known_files - listing > > and then I can remove files that have disappeared off the spool from > the table. Thanks very much! Ah! Didn't know that was a valuable feature for you, but getting that "for free" is an extra little bonus, so that's awesome! >> There is one critical consideration, though. What happens if the >> directory name contains an underscore or percent sign? Or can you >> absolutely guarantee that they won't? You may need to escape them, and >> I'm not sure how SQLite handles that. (Possibly \_ will match literal >> _, and \\ will match literal \, or something like that.) > > I can guarantee that the directory names are all > '/var/spool/news/message.id/' then 3 digits. (The filenames are > pretty wild, since they are MIDs.) AIUI, using the '?' substitution > in the sqlite3 library is supposed to be safe. This is nothing to do with question-mark substitution. There are two separate levels of character significance here - it's like a quoted string with a regex. Suppose you want to make a regex that searches for an apostrophe. If you try to define that in a single-quoted string, you need to escape it: regex = '^\'$' However, if you ask the user to enter a regex, that wouldn't be necessary: regex = input("Enter a pattern: ") # raw_input in Python 2 Enter a pattern: ^'$ This is what the question mark substitution is like - it avoids the need to carefully manage string delimiters and so on. However, if you want to make a regex that searches for a backslash, then you need to escape it, because the backslash is important to the regex itself. In the same way, the underscore and percent sign are significant to the LIKE operator. If it were possible to have a directory name with a percent sign in it, it would match far too much - because you'd construct a LIKE pattern something like (ahem) "/var/spool/news/message%20id/142/%" - and as you can see, the percent sign at the end is no different from the percent sign in the middle. But you're safe because you know your data, unrelated to your substitution method. Possibly merits a comment... but possibly not worth it. ChrisA From rosuav at gmail.com Tue Jul 1 11:58:39 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Jul 2014 01:58:39 +1000 Subject: Get named groups from a regular expression In-Reply-To: References: Message-ID: On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__peter__ at web.de> wrote: > Easy, just write a regular expression to parse regular expressions ;) Hmm, is that even possible? AIUI you can't make a regex that correctly parses nested tokens, and named groups can definitely be nested. ChrisA From python at mrabarnett.plus.com Tue Jul 1 12:53:03 2014 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 01 Jul 2014 17:53:03 +0100 Subject: Get named groups from a regular expression In-Reply-To: References: Message-ID: <53B2E76F.8030700@mrabarnett.plus.com> On 2014-07-01 16:12, Florian Lindner wrote: > Hello, > > Is there a way I can extract the named groups from a regular expression? > e.g. given "(?P\d)" I want to get something like ["testgrp"]. > > OR > > Can I make the match object to return default values for named groups, even > if no match was produced? > >>> import re >>> r = re.compile(r"(?P\d)") >>> r.groupindex {'testgrp': 1} i.e. there's a named group called 'testgrp' whose group number is 1. From skip at python.org Tue Jul 1 13:30:44 2014 From: skip at python.org (Skip Montanaro) Date: Tue, 1 Jul 2014 12:30:44 -0500 Subject: What's the "right" way to abandon an open source package? Message-ID: This is only Python-related because the package in question (lockfile at PyPI) is written in Python and hosted (at least in part) on PyPI. I have not had any interest in maintaining this package for a few years. I wrote it mostly as an exercise, and while I do happen to use it ever-so-slightly in my work, its state as of a few years ago is perfect for my modest needs. Working on it no longer scratches any itches for me. I'd much rather be out riding my bike. I'm at the point in my professional career that I no longer want to program at home after spending all day programming at work. I've tried to find people to take it over, but so far unsuccessfully. I continue to get bug reports, some from OS package maintainers or maintainers of applications which use lockfile. Lots of these people seem demanding of my time (which makes me even less interested in lockfile maintenance). Is there a "correct" way to abandon the damn thing? Thx, Skip From ian.g.kelly at gmail.com Tue Jul 1 13:47:09 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Jul 2014 11:47:09 -0600 Subject: thread.interrupt_main() behaviour In-Reply-To: References: Message-ID: On Tue, Jul 1, 2014 at 3:45 AM, Skip Montanaro wrote: > On Tue, Jul 1, 2014 at 3:58 AM, Piyush Verma <114piyush at gmail.com> wrote: >> >> Since two threads are running same method, I wanted to know which main thread will be interrupted in both case. > > I'm no threading expert, but a process can only have one main thread, > the one you labeled "P". Threads T2 and Tt2 will both interrupt that > thread. Also, the threading model has no hierarchy as suggested by the diagram. All threads are equals (except the main thread, which is slightly more equal than others). From pmiscml at gmail.com Tue Jul 1 13:59:48 2014 From: pmiscml at gmail.com (Paul Sokolovsky) Date: Tue, 1 Jul 2014 20:59:48 +0300 Subject: What's the "right" way to abandon an open source package? In-Reply-To: References: Message-ID: <20140701205948.62bf413f@x34f> Hello, On Tue, 1 Jul 2014 12:30:44 -0500 Skip Montanaro wrote: > This is only Python-related because the package in question (lockfile > at PyPI) is written in Python and hosted (at least in part) on PyPI. I > have not had any interest in maintaining this package for a few years. > I wrote it mostly as an exercise, and while I do happen to use it > ever-so-slightly in my work, its state as of a few years ago is > perfect for my modest needs. Working on it no longer scratches any > itches for me. I'd much rather be out riding my bike. I'm at the point > in my professional career that I no longer want to program at home > after spending all day programming at work. I've tried to find people > to take it over, but so far unsuccessfully. I continue to get bug > reports, some from OS package maintainers or maintainers of > applications which use lockfile. Lots of these people seem demanding > of my time (which makes me even less interested in lockfile > maintenance). Is there a "correct" way to abandon the damn thing? Put it on github and reply to any request with "patches welcome!". That's assuming it's ok for you once a month to go thru pull request queue and press "Merge" or "Close" buttons. If that's too hard, then well, don't press those buttons - someone else will pick those pulls into one's own fork and will maintain it. > > Thx, > > Skip > -- > https://mail.python.org/mailman/listinfo/python-list -- Best regards, Paul mailto:pmiscml at gmail.com From ethan at stoneleaf.us Tue Jul 1 13:43:54 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 01 Jul 2014 10:43:54 -0700 Subject: What's the "right" way to abandon an open source package? In-Reply-To: References: Message-ID: <53B2F35A.9000409@stoneleaf.us> On 07/01/2014 10:30 AM, Skip Montanaro wrote: > This is only Python-related because the package in question (lockfile > at PyPI) is written in Python and hosted (at least in part) on PyPI. I > have not had any interest in maintaining this package for a few years. > I wrote it mostly as an exercise, and while I do happen to use it > ever-so-slightly in my work, its state as of a few years ago is > perfect for my modest needs. Working on it no longer scratches any > itches for me. I'd much rather be out riding my bike. I'm at the point > in my professional career that I no longer want to program at home > after spending all day programming at work. I've tried to find people > to take it over, but so far unsuccessfully. I continue to get bug > reports, some from OS package maintainers or maintainers of > applications which use lockfile. Lots of these people seem demanding > of my time (which makes me even less interested in lockfile > maintenance). Is there a "correct" way to abandon the damn thing? I'm willing to take it on. -- ~Ethan~ From irmen.NOSPAM at xs4all.nl Tue Jul 1 14:16:04 2014 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Tue, 01 Jul 2014 20:16:04 +0200 Subject: general module auditing In-Reply-To: References: Message-ID: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> On 1-7-2014 12:38, Rita wrote: > i work in a group of developers (15 or so) who are located globally. I > would like to know what modules everyone is uses if I ever have to upgrade > my python. Is there mechanism which will let me see who is using what? > > ie, > > tom,matplotlib > bob, pylab > nancy, numpy > nancy, matplotlib > > etc... > > Well, if your group is all using Pip (and perhaps even virtualenv), you could use pip list. In my case: $ pip list appdirs (1.3.0) colorama (0.3.1) cytoolz (0.6.1) docutils (0.11) Jinja2 (2.7.3) MarkupSafe (0.23) pip (1.5.6) py (1.4.20) pyflakes (0.8.1) Pygments (1.6) serpent (1.5, d:\projects\serpent) setuptools (4.0.1) smartypants (1.8.3) Sphinx (1.2.2) Sphinx-PyPI-upload (0.2.1) tox (1.7.1) virtualenv (1.11.6) wheel (0.23.0) You can even use pip freeze and use the resulting output as a requirements.txt file to easily install everything using pip install -r. Hope this is an idea to get you started? Irmen From steve+comp.lang.python at pearwood.info Tue Jul 1 14:40:23 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 01 Jul 2014 18:40:23 GMT Subject: What's the "right" way to abandon an open source package? References: Message-ID: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> On Tue, 01 Jul 2014 20:59:48 +0300, Paul Sokolovsky wrote: > Put it on github http://nedbatchelder.com/blog/201405/github_monoculture.html Besides, do you really want to give your support to a crowd who built a replica of the Oval Office in their corporate offices? While git is a decent DVCS, almost as good as hg, there's something about git culture which attracts geek wankery. -- Steven From denismfmcmahon at gmail.com Tue Jul 1 14:45:17 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Tue, 1 Jul 2014 18:45:17 +0000 (UTC) Subject: Python While loop Takes too much time. References: Message-ID: On Tue, 01 Jul 2014 14:40:18 +0200, Peter Otten wrote: > What I'm trying to tell you: you need to put in some work to identify > the culprit... His next question was "how do I read a range from excel, please give me an example" I gave him an example of using google to search for solutions to his problem. If he can't be bothered to try and solve it himslef, I'm nopt going to write his code for him. -- Denis McMahon, denismfmcmahon at gmail.com From skip at pobox.com Tue Jul 1 14:51:34 2014 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jul 2014 13:51:34 -0500 Subject: What's the "right" way to abandon an open source package? In-Reply-To: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: It's on github (by request from another person who didn't take it over). It's also on Google Code. I'm actually pretty naive and agnostic about these various hosting sites and their favorite revision control tools, but I don't have enough time to master all of them. I think I have a couple volunteers. Cross your fingers. Thanks, Skip On Tue, Jul 1, 2014 at 1:40 PM, Steven D'Aprano wrote: > On Tue, 01 Jul 2014 20:59:48 +0300, Paul Sokolovsky wrote: > >> Put it on github > > > http://nedbatchelder.com/blog/201405/github_monoculture.html > > Besides, do you really want to give your support to a crowd who built a > replica of the Oval Office in their corporate offices? While git is a > decent DVCS, almost as good as hg, there's something about git culture > which attracts geek wankery. > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list From __peter__ at web.de Tue Jul 1 15:00:53 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 01 Jul 2014 21:00:53 +0200 Subject: Get named groups from a regular expression References: Message-ID: Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__peter__ at web.de> wrote: >> Easy, just write a regular expression to parse regular expressions ;) > > Hmm, is that even possible? AIUI you can't make a regex that correctly > parses nested tokens, and named groups can definitely be nested. Hmm, it was a joke. For a limited number of nestings you should be able to cook something up; I think Python allows up to 100 groups, so there is an upper limit of nesting levels. You might need a regex implementation that allows more than 100 groups to parse your regex-parsing regex though... From pmiscml at gmail.com Tue Jul 1 15:05:45 2014 From: pmiscml at gmail.com (Paul Sokolovsky) Date: Tue, 1 Jul 2014 22:05:45 +0300 Subject: What's the "right" way to abandon an open source package? In-Reply-To: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20140701220545.19bf95c9@x34f> Hello, On 01 Jul 2014 18:40:23 GMT Steven D'Aprano wrote: > On Tue, 01 Jul 2014 20:59:48 +0300, Paul Sokolovsky wrote: > > > Put it on github > > > http://nedbatchelder.com/blog/201405/github_monoculture.html Everyone who (re)posts stuff like that should have mandatory N.B. of "I just bought a server farm to offer an alternative". And come on, the guy asked the *easiest* way to lose an open-source package (apparently, in not an anti-social way). > > Besides, do you really want to give your support to a crowd who built > a replica of the Oval Office in their corporate offices? While git is > a decent DVCS, almost as good as hg, there's something about git > culture which attracts geek wankery. You mix up git and some other things. First is "github, inc.". I'm sure all that publicity is their secret plan to overthrow google and facebook. Bwahaha. Second thing is (young pythonistas, close your eyes and ears!) is Roooooby. That's where that slight smell of decay which bothers you comes from. Indeed, using software written in Ruby is disgusting. But if you look around, all software written for advanced git project hosting is written in Ruby - gitorious, gitlab. Steven, I hope you have plan how to resolve that situation with Python enlightment too. Until then people will use that ruby stuff, in particular github. (Ah, and if your solution is "hg", sorry, that won't work - for many reasons, including CPython big startup delay :-F. Don't speak about git monoculture though - *BSD folks are still using CVS, so world is safe). > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list -- Best regards, Paul mailto:pmiscml at gmail.com From jkn_gg at nicorp.f9.co.uk Tue Jul 1 16:49:43 2014 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Tue, 1 Jul 2014 13:49:43 -0700 (PDT) Subject: Get named groups from a regular expression In-Reply-To: References: Message-ID: On Tuesday, 1 July 2014 16:12:34 UTC+1, Florian Lindner wrote: > Hello, > > > > Is there a way I can extract the named groups from a regular expression? > > e.g. given "(?P\d)" I want to get something like ["testgrp"]. > > > > OR > > > > Can I make the match object to return default values for named groups, even > > if no match was produced? > > > > Thanks, > > Florian If you can, my approach would to have a class which you use both to create the regex (using group names), and return the names of the groups in the regex you have created. As I say, this might not be possible in your case though. Jon N From anthra.norell at bluewin.ch Tue Jul 1 16:49:14 2014 From: anthra.norell at bluewin.ch (F.R.) Date: Tue, 01 Jul 2014 22:49:14 +0200 Subject: fixing an horrific formatted csv file. In-Reply-To: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> Message-ID: <53B31ECA.9030909@bluewin.ch> On 07/01/2014 04:04 PM, flebber wrote: > What I am trying to do is to reformat a csv file into something more usable. > currently the file has no headers, multiple lines with varying columns that are not related. > > This is a sample > > Meeting,05/07/14,RHIL,Rosehill Gardens,Weights,TAB,+3m Entire Circuit, , > Race,1,CIVIC STAKES,CIVIC,CIVIC,1350,~ ,3U ,~ ,QLT ,54,0,0,5/07/2014,, , , , ,No class restriction, Quality, For Three-Years-Old and Upwards, No sex restriction, (Listed),Of $100000. First $60000, second $20000, third $10000, fourth $5000, fifth $2000, sixth $1000, seventh $1000, eighth $1000 > Horse,1,Bennetta,0,"Grahame Begg",Randwick,,0,0,16-3-1-3 $390450.00,,0,0,0,,98.00,M, > Horse,2,Breakfast in Bed,0,"David Vandyke",Warwick Farm,,0,0,20-6-1-5 $201250.00,,0,0,0,,81.00,M, > Horse,3,Capital Commander,0,"Gerald Ryan",Rosehill,,0,0,43-9-9-3 $438625.00,,0,0,0,,85.00,M, > Horse,4,Coup Ay Tee (NZ),0,"Chris Waller",Rosehill,,0,0,35-9-6-5 $519811.00,,0,0,0,,101.00,G, > Horse,5,Generalife,0,"John O'Shea",Warwick Farm,,0,0,19-6-1-3 $235045.00,,0,0,0,,87.00,G, > Horse,6,He's Your Man (FR),0,"Chris Waller",Rosehill,,0,0,13-2-3-1 $108110.00,,0,0,0,,93.00,G, > Horse,7,Hidden Kisses,0,"Chris Waller",Rosehill,,0,0,40-8-8-5 $565750.00,,0,0,0,,96.00,M, > Horse,8,Oakfield Commands,0,"Gerald Ryan",Rosehill,,0,0,22-7-4-6 $269530.00,,0,0,0,,94.00,G, > Horse,9,Taxmeifyoucan,0,"Gregory Hickman",Warwick Farm,,0,0,18-2-4-4 $539730.00,,0,0,0,,91.00,G, > Horse,10,The Peak,0,"Bart & James Cummings",Randwick,,0,0,15-6-1-0 $426732.00,,0,0,0,,95.00,G, > Horse,11,Tougher Than Ever (NZ),0,"Chris Waller",Rosehill,,0,0,17-3-2-3 $321613.00,,0,0,0,,97.00,H, > Horse,12,TROMSO,0,"Chris Waller",Rosehill,,0,0,47-8-11-2 $622300.00,,0,0,0,,103.00,G, > Race,2,FLYING WELTER - BENCHMARK 95 HCP,BM95,BM95,1100,BM95 ,3U ,~ ,HCP ,54,0,0,5/07/2014,, , , , ,BenchMark 95, Handicap, For Three-Years-Old and Upwards, No sex restriction,Of $85000. First $48750, second $16750, third $8350, fourth $4150, fifth $2000, sixth $1000, seventh $1000, eighth $1000, ninth $1000, tenth $1000 > Horse,1,Big Bonanza,0,"Don Robb",Wyong,,0,57.5,31-9-4-3 $366860.00,,0,0,0,,92.00,G, > Horse,2,Casual Choice,0,"Joseph Pride",Warwick Farm,,0,54,8-2-3-0 $105930.00,,0,0,0, > > So what I am trying to so is end up with an output like this. > > Meeting, Date, Race, Number, Name, Trainer, Location > Rosehill, 05/07/14, 1, 1,Bennetta,"Grahame Begg",Randwick, > Rosehill, 05/07/14, 1, 2,Breakfast in Bed,"David Vandyke",Warwick Farm, > > So as a start i thought i would try inserting the Meeting and Race number however I am just not getting it right. > > import csv > > outfile = open("/home/sayth/Scripts/cleancsv.csv", "w") > with open('/home/sayth/Scripts/test.csv') as f: > f_csv = csv.reader(f) > headers = next(f_csv) > for row in f_csv: > meeting = row[3] in row[0] == 'Meeting' > new = row.insert(0, meeting) > while row[1] in row[0] == 'Race' < 9: # pref less than next found row[0] > > # grab row[1] as id number > id = row[1] > # from row[0] and insert it in first position > new_lines = new.insert(1, id) > outfile.write(new_lines) > outfile.close() > > How should I go about this? > > Thanks > > Sayth Reformatting is what I do most and over time I have acquired some practice. Complete solutions are not often proposed, possibly sneered on for their officiousness. In that case I apologize. I couldn't resist. It is such a nice example. Having solved it, I figure why not share it . . . Frederic ------------------------------------------------------------------------------------------------------------ def race_table (csv_text): input_table = [[item.strip(' "') for item in record.split (',')] for record in csv_text.splitlines ()] # At this point look at input_table to find the record indices output_table = [] for record in input_table: if record [0] == 'Meeting': meeting = record [3] elif record [0] == 'Race': date = record [13] race = record [1] elif record [0] == 'Horse': number = record [1] name = record [2] trainer = record [4] location = record [5] output_table.append ((meeting, date, race, number, name, trainer, location)) return output_table >>> for record in race_table (your_csv_text): print record ('Rosehill Gardens', '5/07/2014', '1', '1', 'Bennetta', 'Grahame Begg', 'Randwick') ('Rosehill Gardens', '5/07/2014', '1', '2', 'Breakfast in Bed', 'David Vandyke', 'Warwick Farm') ('Rosehill Gardens', '5/07/2014', '1', '3', 'Capital Commander', 'Gerald Ryan', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '4', 'Coup Ay Tee (NZ)', 'Chris Waller', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '5', 'Generalife', "John O'Shea", 'Warwick Farm') ('Rosehill Gardens', '5/07/2014', '1', '6', "He's Your Man (FR)", 'Chris Waller', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '7', 'Hidden Kisses', 'Chris Waller', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '8', 'Oakfield Commands', 'Gerald Ryan', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '9', 'Taxmeifyoucan', 'Gregory Hickman', 'Warwick Farm') ('Rosehill Gardens', '5/07/2014', '1', '10', 'The Peak', 'Bart & James Cummings', 'Randwick') ('Rosehill Gardens', '5/07/2014', '1', '11', 'Tougher Than Ever (NZ)', 'Chris Waller', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '1', '12', 'TROMSO', 'Chris Waller', 'Rosehill') ('Rosehill Gardens', '5/07/2014', '2', '1', 'Big Bonanza', 'Don Robb', 'Wyong') ('Rosehill Gardens', '5/07/2014', '2', '2', 'Casual Choice', 'Joseph Pride', 'Warwick Farm') >>> TM = TX.Table_Maker (headings = ('Meeting','Date','Race','Number','Name','Trainer','Location')) >>> TM (race_table (your_csv_text)).write () Meeting | Date | Race | Number | Name | Trainer | Location | Rosehill Gardens | 5/07/2014 | 1 | 1 | Bennetta | Grahame Begg | Randwick | Rosehill Gardens | 5/07/2014 | 1 | 2 | Breakfast in Bed | David Vandyke | Warwick Farm | Rosehill Gardens | 5/07/2014 | 1 | 3 | Capital Commander | Gerald Ryan | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 4 | Coup Ay Tee (NZ) | Chris Waller | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 5 | Generalife | John O'Shea | Warwick Farm | Rosehill Gardens | 5/07/2014 | 1 | 6 | He's Your Man (FR) | Chris Waller | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 7 | Hidden Kisses | Chris Waller | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 8 | Oakfield Commands | Gerald Ryan | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 9 | Taxmeifyoucan | Gregory Hickman | Warwick Farm | Rosehill Gardens | 5/07/2014 | 1 | 10 | The Peak | Bart & James Cummings | Randwick | Rosehill Gardens | 5/07/2014 | 1 | 11 | Tougher Than Ever (NZ) | Chris Waller | Rosehill | Rosehill Gardens | 5/07/2014 | 1 | 12 | TROMSO | Chris Waller | Rosehill | Rosehill Gardens | 5/07/2014 | 2 | 1 | Big Bonanza | Don Robb | Wyong | Rosehill Gardens | 5/07/2014 | 2 | 2 | Casual Choice | Joseph Pride | Warwick Farm | From tjreedy at udel.edu Tue Jul 1 17:05:58 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 01 Jul 2014 17:05:58 -0400 Subject: Success with subprocess communicate on Windows? Message-ID: I am mentoring a GSOC student, Saimadhav Heblikar, who is working on adding the following feature to Idle: submit the editor text to an external program, such as pyflakes, and display the result in an OutputWindow. If it reports line numbers with problems, as pyflakes does, users will be able to jump to the line in the file (this exists already for multiple-file grep output). The 'obvious' implementation is to use subprocess.Open.communicate to run the process and capture the output. The prototype code at http://bugs.python.org/issue21880 works on linux. The key part of the new code at http://bugs.python.org/file35819/3rdpartychecker-v2.diff is +from subprocess import Popen, PIPE ... + proc = Popen(args, stdout=PIPE, stderr=PIPE) + proc.wait() + output, error = map(lambda b:b.decode('utf-8'), proc.communicate()) It does not work on Windows. As I reported on http://bugs.python.org/issue8631, msg222053, >>> subprocess.check_output("pyflakes -h") works in the interpreter and Idle shell, while >>> s.check_output("pyflakes c:\programs\python34\lib\turtle.py") gives bizarre output in the interpreter and hangs in the idle shell, as does the code above. My question is whether anyone reading that has had success getting subprocess output capture to work consistently on Windows? -- Terry Jan Reedy From flebber.crue at gmail.com Tue Jul 1 17:41:18 2014 From: flebber.crue at gmail.com (flebber) Date: Tue, 1 Jul 2014 14:41:18 -0700 (PDT) Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> Message-ID: <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> That's a really cool solution. I understand why providing full solutions is frowned upon, because it doesn't assist in learning. Which is true, it's incredibly helpful in this case. The python cookbook is really good and what I was using as a start for dealing with csv. But it doesn't even go anywhere near this. Lots of examples with simple inputs. Anyway Thanks again Sayth From ian.g.kelly at gmail.com Tue Jul 1 18:34:39 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 1 Jul 2014 16:34:39 -0600 Subject: What's the "right" way to abandon an open source package? In-Reply-To: <20140701220545.19bf95c9@x34f> References: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> <20140701220545.19bf95c9@x34f> Message-ID: On Tue, Jul 1, 2014 at 1:05 PM, Paul Sokolovsky wrote: > On 01 Jul 2014 18:40:23 GMT > Steven D'Aprano wrote: >> http://nedbatchelder.com/blog/201405/github_monoculture.html > > Everyone who (re)posts stuff like that should have mandatory N.B. of "I > just bought a server farm to offer an alternative". There already are alternatives. > Second thing is (young pythonistas, close your eyes and ears!) is > Roooooby. That's where that slight smell of decay which bothers you > comes from. Indeed, using software written in Ruby is disgusting. But > if you look around, all software written for advanced git project > hosting is written in Ruby - gitorious, gitlab. Steven, I hope you have > plan how to resolve that situation with Python enlightment too. Until > then people will use that ruby stuff, in particular github. Ruby has nothing to do with it. (And no, I don't think that using software written in Ruby is "disgusting".) We're talking about web sites; from the user perspective, they're just neat bundles of networking protocols and the implementation language is irrelevant, as long as their needs are met. > (Ah, and if > your solution is "hg", sorry, that won't work - for many reasons, > including CPython big startup delay :-F. The warm startup delay for CPython on my box is about 17 ms. hg starts, prints its list of commands, and exits in about 44 ms. That's practically invisible to the user, unless you're using a script that involves executing hg from the shell hundreds of times, in which case you might want to consider having your script use the command server instead. Or if it's the start-up delay on the web server that you're concerned about, then set up the server to use persistent processes. From izecksohn at yahoo.com Tue Jul 1 17:17:14 2014 From: izecksohn at yahoo.com (Pedro Izecksohn) Date: Tue, 1 Jul 2014 14:17:14 -0700 Subject: 1-0.95 Message-ID: <1404249434.13291.YahooMailNeo@web140104.mail.bf1.yahoo.com> pedro at microboard:~$ /usr/bin/python3 Python 3.3.2+ (default, Feb 28 2014, 00:52:16) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1-0.95 0.050000000000000044 >>>? ? How to get 0.05 as result? ? bc has scale=2 . Has Python some similar feature? From rxjwg98 at gmail.com Tue Jul 1 18:56:49 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Tue, 1 Jul 2014 15:56:49 -0700 (PDT) Subject: What use with Python Message-ID: Hi, I am new to Python. Weeks ago, I was asked about Python questions on an interview. Now I want to learn Python, but I do not know what I can do with it on a PC. Especially I would like to do something interesting instead of some text search etc. Python may can do more than I realize now. Could you tell me something on a PC? Thanks, From breamoreboy at yahoo.co.uk Tue Jul 1 19:00:01 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 02 Jul 2014 00:00:01 +0100 Subject: 1-0.95 In-Reply-To: <1404249434.13291.YahooMailNeo@web140104.mail.bf1.yahoo.com> References: <1404249434.13291.YahooMailNeo@web140104.mail.bf1.yahoo.com> Message-ID: On 01/07/2014 22:17, Pedro Izecksohn wrote: > pedro at microboard:~$ /usr/bin/python3 > Python 3.3.2+ (default, Feb 28 2014, 00:52:16) > [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> 1-0.95 > 0.050000000000000044 >>>> > > How to get 0.05 as result? > > bc has scale=2 . Has Python some similar feature? > Asked and answered roughly one trillion times. Try searching for python floating point, not that this is specific to python. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From pecore at pascolo.net Tue Jul 1 19:13:14 2014 From: pecore at pascolo.net (pecore at pascolo.net) Date: Wed, 02 Jul 2014 01:13:14 +0200 Subject: 1-0.95 References: Message-ID: <87zjgsy8ol.fsf@pascolo.net> Pedro Izecksohn writes: > pedro at microboard:~$ /usr/bin/python3 > Python 3.3.2+ (default, Feb 28 2014, 00:52:16) > [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> 1-0.95 > 0.050000000000000044 >>>>? > > ? How to get 0.05 as result? print("%4.2f"%(1-0.95)) i.e., you can change how a result is displayed, not its internal representation From ben at benfinney.id.au Tue Jul 1 19:18:59 2014 From: ben at benfinney.id.au (Ben Finney) Date: Wed, 02 Jul 2014 09:18:59 +1000 Subject: What's the "right" way to abandon an open source package? References: Message-ID: <85simkwtuk.fsf@benfinney.id.au> Skip Montanaro writes: > I've tried to find people to take it over, but so far unsuccessfully. The principle (laid out by ESR in ?The Cathedral and the Bazaar?) is: When you lose interest in a program, your last duty to it is to hand it off to a competent successor. Whether successful or not, I can testify that Skip has been conscientious in following this principle: he has been asking parties who have demonstrated interest and/or competence for some time now to take over maintenance of the ?lockfile? library. > I continue to get bug reports, some from OS package maintainers or > maintainers of applications which use lockfile. Lots of these people > seem demanding of my time (which makes me even less interested in > lockfile maintenance). I don't know of any good way to make those decrease, without some other contact point for the project becoming more prominent than yours. > Is there a "correct" way to abandon the damn thing? You have, IMO, already put in sufficient public effort to give opportunity to potential maintainers. I would say that, in the case of the ?lockfile? library, you have already discharged your responsibilities under the above principle; and can politely let each person know they are on their own for maintenance. -- \ ?I've always wanted to be somebody, but I see now that I should | `\ have been more specific.? ?Jane Wagner, via Lily Tomlin | _o__) | Ben Finney From ben at benfinney.id.au Tue Jul 1 19:34:48 2014 From: ben at benfinney.id.au (Ben Finney) Date: Wed, 02 Jul 2014 09:34:48 +1000 Subject: Discussion problems of monoculture (was: What's the "right" way to abandon an open source package?) References: <53b30097$0$29985$c3e8da3$5496439d@news.astraweb.com> <20140701220545.19bf95c9@x34f> Message-ID: <85oax8wt47.fsf_-_@benfinney.id.au> Ian Kelly writes: > On Tue, Jul 1, 2014 at 1:05 PM, Paul Sokolovsky wrote: > > On 01 Jul 2014 18:40:23 GMT > > Steven D'Aprano wrote: > >> http://nedbatchelder.com/blog/201405/github_monoculture.html > > > > Everyone who (re)posts stuff like that should have mandatory N.B. of "I > > just bought a server farm to offer an alternative". > > There already are alternatives. Even if there weren't, I cannot at all agree with Paul's sentiment. Someone raising awareness of a problem is *not* under any obligation to stay silent in the absence of a complete ready solution. Frequently, a solution can only realistically come when *many* people talk about the problem first; all the more so when the problem described is one of large scale. -- \ ?Sane people have an appropriate perspective on the relative | `\ importance of foodstuffs and human beings. Crazy people can't | _o__) tell the difference.? ?Paul Z. Myers, 2010-04-18 | Ben Finney From rosuav at gmail.com Tue Jul 1 21:20:53 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Jul 2014 11:20:53 +1000 Subject: fixing an horrific formatted csv file. In-Reply-To: <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> Message-ID: On Wed, Jul 2, 2014 at 7:41 AM, flebber wrote: > I understand why providing full solutions is frowned upon, because it doesn't assist in learning. Which is true, it's incredibly helpful in this case. In this case, my main reason for not providing a full solution is that the work tends to be iterative. When I have a huge and messy file, what I usually do is grab the first half-dozen lines and work out how I'd go about fixing them manually, then write a script that does that. Then run the script on the whole file, and see where it either chokes or produces wrong data. Pick up the first few lines of wrong data, figure out how to tweak the program to handle those. Rinse and repeat. Often, what that results in is a file that gets progressively tidier. When the scope of the mess is infinite (like with human-entered data - believe you me, you haven't seen messy until you've seen what a committee can do to a simple job), this means you stop working on the script at exactly the point where it stops being worth the effort - which is something that only you can decide. ChrisA From rmorgan466 at gmail.com Tue Jul 1 22:04:43 2014 From: rmorgan466 at gmail.com (Rita) Date: Tue, 1 Jul 2014 22:04:43 -0400 Subject: general module auditing In-Reply-To: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> Message-ID: yes, this helps. But I want to know who uses the module, serpent. So, when I upgrade it or remove it they won't be affected adversely. On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong wrote: > On 1-7-2014 12:38, Rita wrote: > > i work in a group of developers (15 or so) who are located globally. I > > would like to know what modules everyone is uses if I ever have to > upgrade > > my python. Is there mechanism which will let me see who is using what? > > > > ie, > > > > tom,matplotlib > > bob, pylab > > nancy, numpy > > nancy, matplotlib > > > > etc... > > > > > > Well, if your group is all using Pip (and perhaps even virtualenv), you > could use pip > list. In my case: > > $ pip list > appdirs (1.3.0) > colorama (0.3.1) > cytoolz (0.6.1) > docutils (0.11) > Jinja2 (2.7.3) > MarkupSafe (0.23) > pip (1.5.6) > py (1.4.20) > pyflakes (0.8.1) > Pygments (1.6) > serpent (1.5, d:\projects\serpent) > setuptools (4.0.1) > smartypants (1.8.3) > Sphinx (1.2.2) > Sphinx-PyPI-upload (0.2.1) > tox (1.7.1) > virtualenv (1.11.6) > wheel (0.23.0) > > You can even use pip freeze and use the resulting output as a > requirements.txt file to > easily install everything using pip install -r. > > Hope this is an idea to get you started? > > Irmen > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Tue Jul 1 21:09:13 2014 From: wrw at mac.com (William Ray Wing) Date: Tue, 01 Jul 2014 21:09:13 -0400 Subject: What use with Python In-Reply-To: References: Message-ID: On Jul 1, 2014, at 6:56 PM, rxjwg98 at gmail.com wrote: > Hi, > > I am new to Python. Weeks ago, I was asked about Python questions on an interview. > Now I want to learn Python, but I do not know what I can do with it on a PC. > Especially I would like to do something interesting instead of some text search etc. > Python may can do more than I realize now. Could you tell me something on a PC? > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list Python is a completely general purpose programming language. It has extensive libraries that adapt it to tackle almost any programming problem (with the possible exception of device drivers). Those libraries include several graphics packages and GUI frameworks, libraries for doing network programming, for performing heavy-duty numerical analysis (number crunching) and scientific data analysis, as well as web applications, semantic analysis, statistical analysis, and which will interface it to any of several databases. Examples of well-known Python programs running ?in the wild? include YouTube and Bit Torrent. Well written Python programs (that is, those that use Python?s abstracted OS services) run equally well on a PC, a Mac, UNIX, and Linux. -Bill From david.garvey at gmail.com Tue Jul 1 23:24:15 2014 From: david.garvey at gmail.com (david.garvey at gmail.com) Date: Tue, 1 Jul 2014 20:24:15 -0700 Subject: What use with Python In-Reply-To: References: Message-ID: How about Web python? https://wiki.python.org/moin/WebFrameworks PC can run linux. Perhaps a vagrant linux virtual host would be in order? http://www.vagrantup.com/ Or windoz https://www.python.org/download/windows David On Tue, Jul 1, 2014 at 3:56 PM, wrote: > Hi, > > I am new to Python. Weeks ago, I was asked about Python questions on an > interview. > Now I want to learn Python, but I do not know what I can do with it on a > PC. > Especially I would like to do something interesting instead of some text > search etc. > Python may can do more than I realize now. Could you tell me something on > a PC? > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list > -- David Garvey -------------- next part -------------- An HTML attachment was scrubbed... URL: From timr at probo.com Wed Jul 2 00:33:29 2014 From: timr at probo.com (Tim Roberts) Date: Tue, 01 Jul 2014 21:33:29 -0700 Subject: Success with subprocess communicate on Windows? References: Message-ID: Terry Reedy wrote: > >It does not work on Windows. As I reported on >http://bugs.python.org/issue8631, msg222053, > >>> subprocess.check_output("pyflakes -h") >works in the interpreter and Idle shell, while > >>> s.check_output("pyflakes c:\programs\python34\lib\turtle.py") >gives bizarre output in the interpreter and hangs in the idle shell, as >does the code above. Right. What do you think \t is in a string? (Hint: it's only one byte.) You need to use s.check_output("pyflakes c:\\programs\\python34\\lib\\turtle.py") or s.check_output(r"pyflakes c:\programs\python34\lib\turtle.py") -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From breamoreboy at yahoo.co.uk Wed Jul 2 00:57:17 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 02 Jul 2014 05:57:17 +0100 Subject: What's the "right" way to abandon an open source package? In-Reply-To: <85simkwtuk.fsf@benfinney.id.au> References: <85simkwtuk.fsf@benfinney.id.au> Message-ID: On 02/07/2014 00:18, Ben Finney wrote: > Skip Montanaro writes: > >> I've tried to find people to take it over, but so far unsuccessfully. > > The principle (laid out by ESR in ?The Cathedral and the Bazaar?) is: > > When you lose interest in a program, your last duty to it is to hand > it off to a competent successor. > > > > Whether successful or not, I can testify that Skip has been > conscientious in following this principle: he has been asking parties > who have demonstrated interest and/or competence for some time now to > take over maintenance of the ?lockfile? library. > >> I continue to get bug reports, some from OS package maintainers or >> maintainers of applications which use lockfile. Lots of these people >> seem demanding of my time (which makes me even less interested in >> lockfile maintenance). > > I don't know of any good way to make those decrease, without some other > contact point for the project becoming more prominent than yours. > >> Is there a "correct" way to abandon the damn thing? > > You have, IMO, already put in sufficient public effort to give > opportunity to potential maintainers. > > I would say that, in the case of the ?lockfile? library, you have > already discharged your responsibilities under the above principle; and > can politely let each person know they are on their own for maintenance. > Very well put. Kudos to Skip and yourself :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From benjamin at python.org Wed Jul 2 01:55:14 2014 From: benjamin at python.org (Benjamin Peterson) Date: Tue, 01 Jul 2014 22:55:14 -0700 Subject: [RELEASE] Python 2.7.8 Message-ID: <1404280514.30741.136823729.74EB0C0B@webmail.messagingengine.com> Greetings, I have the distinct privilege of informing you that the latest release of the Python 2.7 series, 2.7.8, has been released and is available for download. 2.7.8 contains several important regression fixes and security changes: - The openssl version bundled in the Windows installer has been updated. - A regression in the mimetypes module on Windows has been fixed. [1] - A possible overflow in the buffer type has been fixed. [2] - A bug in the CGIHTTPServer module which allows arbitrary execution of code in the server root has been patched. [3] - A regression in the handling of UNC paths in os.path.join has been fixed. [4] Downloads of 2.7.8 are at https://www.python.org/download/releases/2.7.8/ The full changelog is located at http://hg.python.org/cpython/raw-file/v2.7.8/Misc/NEWS This is a production release. As always, please report bugs to http://bugs.python.org/ Till next time, Benjamin Peterson 2.7 Release Manager (on behalf of all of Python's contributors) [1] http://bugs.python.org/issue21652 [2] http://bugs.python.org/issue21831 [3] http://bugs.python.org/issue21766 [4] http://bugs.python.org/issue21672 From onlydebian at gmail.com Wed Jul 2 04:05:38 2014 From: onlydebian at gmail.com (=?GB2312?B?sru7tbCit+U=?=) Date: Wed, 2 Jul 2014 01:05:38 -0700 (PDT) Subject: How to add ftp put function in PyQT network ftp demo In-Reply-To: <7492d8ec-8e64-4f0d-b927-b3981b75eea2@googlegroups.com> References: <7492d8ec-8e64-4f0d-b927-b3981b75eea2@googlegroups.com> Message-ID: ? 2014?7?1????UTC+7??5?27?59????????? > I want to modify the pyqt network ftp demo to include an upload function, but I am failing. Could someone can show me how to do this? I have tried to add this code, but it does not work. > > [Orignal demo]https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py > > > > at First, i add these code into demo. not work at all > > ############## > > buttonBox.addButton(self.uploadButton, > > QtGui.QDialogButtonBox.ActionRole) > > self.uploadButton = QtGui.QPushButton("upload") > > self.uploadButton.clicked.connect(self.selectFile) > > > > def selectFile(self): > > self.filename =QtGui.QFileDialog.getOpenFileName() > > up_fname = re.sub(r".*/","",self.filename) > > upload_file = QtCore.QFile(self.filename) > > self.ftp.put(upload_file, up_fname) > > > > ############## > > > > Second, i modify like this, i can upload small file successfully, but fail on big size file, the app will crash. > > > > ##################### > > def selectFile(self): > > self.filename =QtGui.QFileDialog.getOpenFileName() > > print self.filename > > up_fname = re.sub(r".*/","",self.filename) > > print up_fname > > > > > > upload_file = QtCore.QFile(self.filename) > > #print upload_file > > upload_file.open(QtCore.QIODevice.ReadOnly) > > ba = QtCore.QByteArray() > > ba.append(upload_file.readAll()) > > > > #buffer = QtCore.QBuffer() #### do not how to use Buffer > > #buffer.open(QtCore.QIODevice.ReadWrite) > > #buffer.setData(ba) > > > > self.ftp.put(ba, up_fname) > > self.progressDialog.setLabelText("Uploading %s..." % up_fname) > > self.uploadButton.setEnabled(False) > > self.progressDialog.exec_() > > self.uploadButton.setEnabled(True) > > self.ftp.list() > > > > #################### any one can give some suggestion? From jeanpierreda at gmail.com Wed Jul 2 04:11:57 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 2 Jul 2014 01:11:57 -0700 Subject: Get named groups from a regular expression In-Reply-To: References: Message-ID: On Tue, Jul 1, 2014 at 8:58 AM, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:29 AM, Peter Otten <__peter__ at web.de> wrote: >> Easy, just write a regular expression to parse regular expressions ;) > > Hmm, is that even possible? AIUI you can't make a regex that correctly > parses nested tokens, and named groups can definitely be nested. Nesting isn't inherently a problem. Since nesting doesn't change the way they parse, you can ignore nesting for the purposes of pulling out named groups. Find each unescaped "(?P<...>". (Making sure they are unescaped is annoying, though.) -- Devin From musicdenotation at gmail.com Wed Jul 2 04:26:07 2014 From: musicdenotation at gmail.com (musicdenotation at gmail.com) Date: Wed, 2 Jul 2014 15:26:07 +0700 Subject: Statically type-checked variant of Python Message-ID: PHP has Hack, JavaScript has TypeScript, Python has what? From tjreedy at udel.edu Wed Jul 2 05:05:51 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Jul 2014 05:05:51 -0400 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: On 7/2/2014 12:33 AM, Tim Roberts wrote: > Terry Reedy wrote: >> >> It does not work on Windows. As I reported on >> http://bugs.python.org/issue8631, msg222053, >>>>> subprocess.check_output("pyflakes -h") >> works in the interpreter and Idle shell, while >>>>> s.check_output("pyflakes c:\programs\python34\lib\turtle.py") >> gives bizarre output in the interpreter and hangs in the idle shell, as >> does the code above. > > Right. What do you think \t is in a string? (Hint: it's only one byte.) Yes, how could I forget that. But my use of a string literal here does not explain the problems when used string variables, as generated by os. I should try printing out the list of args passed to subprocess. While remembering what \t is explains the command interpreter output (recursing through /lib), it does not explain the difference when invoked from Idle. There seems to be some bad interaction when calling subprocesses in the user subprocess. > You need to use > s.check_output("pyflakes c:\\programs\\python34\\lib\\turtle.py") > or > s.check_output(r"pyflakes c:\programs\python34\lib\turtle.py") Now I get "Command 'pyflakes c:\programs\python34\lib\turtle.py' returns non-zero exit status 1" on both. On Idle, as least, a command-prompt window is flashed/displayed. It makes no sense to me that in the command interpreter, 'pyflakes c:\\programs\\python34\\lib' works and 'pyflakes c:\\programs\\python34\\lib\\turtle.py' returns status 1. whereas both (with quotes elided and undoubled \) work at the command prompt. -- Terry Jan Reedy From flebber.crue at gmail.com Wed Jul 2 05:13:45 2014 From: flebber.crue at gmail.com (flebber) Date: Wed, 2 Jul 2014 02:13:45 -0700 (PDT) Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> Message-ID: > >>> TM = TX.Table_Maker (headings = > ('Meeting','Date','Race','Number','Name','Trainer','Location')) > >>> TM (race_table (your_csv_text)).write () Where do I find TX? Found this mention in the list, was it available in pip by any name? https://mail.python.org/pipermail/python-list/2014-February/667464.html Sayth From a24061 at ducksburg.com Wed Jul 2 05:30:01 2014 From: a24061 at ducksburg.com (Adam Funk) Date: Wed, 02 Jul 2014 10:30:01 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database References: <3uva8bx3dn.ln2@news.ducksburg.com> Message-ID: On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >> >>> On Tue, Jul 1, 2014 at 9:26 PM, Adam Funk wrote: >>>> cursor.execute('SELECT filename FROM files WHERE filename IS ?', (filename,)) >>> >>> Shouldn't this be an equality check rather than IS, which normally I'd >>> expect to be "IS NULL" or "IS NOT NULL"? >> >> Oh, it probably should be in "heavy" SQL. In SQLite, '==', '=', & >> 'IS' are interchangeable. >> >> http://www.tutorialspoint.com/sqlite/sqlite_operators.htm > > Ah, okay. In that case, I'd advise going with either == for > consistency with the rest of Python, or (preferably) = for consistency > with other SQL engines. You wouldn't use "is" to test if two Python > strings are equal, so there's no particular reason to use it here :) I agree. >> Oh, even better: >> >> add_files = listing - known_files >> delete_files = known_files - listing >> >> and then I can remove files that have disappeared off the spool from >> the table. Thanks very much! > > Ah! Didn't know that was a valuable feature for you, but getting that > "for free" is an extra little bonus, so that's awesome! I didn't know it was a valuable feature until I saw that easy way to do it! This will keep the database from growing indefinitely, though. -- '...and Tom [Snyder] turns to him and says, "so Alice [Cooper], is it true you kill chickens on stage?" That was the opening question, and Alice looks at him real serious and goes, "Oh no, no no. That's Colonel Sanders. Colonel Sanders kills chickens."' From fk26541598fk at gmail.com Wed Jul 2 05:43:28 2014 From: fk26541598fk at gmail.com (fk26541598fk at gmail.com) Date: Wed, 2 Jul 2014 02:43:28 -0700 (PDT) Subject: How can I catch values from other def by flask??? Message-ID: <79aa79d7-bd71-4635-af9d-aae489cc06e4@googlegroups.com> this is my code def aa(): if request.method=='POST': get_test(value1) return value1 else: get_test(value2) return value2 return 'it does not work' def post_test(value1): value1='POST it works' return value1 def get_test(value2): value2='GET it works' how can i catch post_test value1 to aa() return??? From a24061 at ducksburg.com Wed Jul 2 05:32:55 2014 From: a24061 at ducksburg.com (Adam Funk) Date: Wed, 02 Jul 2014 10:32:55 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database References: <3uva8bx3dn.ln2@news.ducksburg.com> Message-ID: <770d8bxunj.ln2@news.ducksburg.com> On 2014-07-01, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 1:15 AM, Adam Funk wrote: >> On 2014-07-01, Chris Angelico wrote: >>> There is one critical consideration, though. What happens if the >>> directory name contains an underscore or percent sign? Or can you >>> absolutely guarantee that they won't? You may need to escape them, and >>> I'm not sure how SQLite handles that. (Possibly \_ will match literal >>> _, and \\ will match literal \, or something like that.) >> >> I can guarantee that the directory names are all >> '/var/spool/news/message.id/' then 3 digits. (The filenames are >> pretty wild, since they are MIDs.) AIUI, using the '?' substitution >> in the sqlite3 library is supposed to be safe. > > This is nothing to do with question-mark substitution. There are two > separate levels of character significance here - it's like a quoted > string with a regex. Suppose you want to make a regex that searches > for an apostrophe. If you try to define that in a single-quoted > string, you need to escape it: > > regex = '^\'$' > > However, if you ask the user to enter a regex, that wouldn't be necessary: > > regex = input("Enter a pattern: ") # raw_input in Python 2 > Enter a pattern: ^'$ > > This is what the question mark substitution is like - it avoids the > need to carefully manage string delimiters and so on. However, if you > want to make a regex that searches for a backslash, then you need to > escape it, because the backslash is important to the regex itself. In > the same way, the underscore and percent sign are significant to the > LIKE operator. If it were possible to have a directory name with a > percent sign in it, it would match far too much - because you'd > construct a LIKE pattern something like (ahem) > "/var/spool/news/message%20id/142/%" - and as you can see, the percent > sign at the end is no different from the percent sign in the middle. > > But you're safe because you know your data, unrelated to your > substitution method. Possibly merits a comment... but possibly not > worth it. Well, I've changed it to the following anyway. subdir_glob = subdir + '/*' cursor.execute('SELECT filename FROM files WHERE filename GLOB ?', (subdir_glob,)) rows = cursor.fetchall() known_files = {row[0] for row in rows} I see what you mean about paths containing '%', but I don't see why you were concerned about underscores, though. -- You know, there are many people in the country today who, through no fault of their own, are sane. Some of them were born sane. Some of them became sane later in their lives. --? Graham Chapman From rosuav at gmail.com Wed Jul 2 06:03:12 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 2 Jul 2014 20:03:12 +1000 Subject: Searching for lots of similar strings (filenames) in sqlite3 database In-Reply-To: <770d8bxunj.ln2@news.ducksburg.com> References: <3uva8bx3dn.ln2@news.ducksburg.com> <770d8bxunj.ln2@news.ducksburg.com> Message-ID: On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk wrote: > Well, I've changed it to the following anyway. > > subdir_glob = subdir + '/*' > cursor.execute('SELECT filename FROM files WHERE filename GLOB ?', > (subdir_glob,)) > rows = cursor.fetchall() > known_files = {row[0] for row in rows} > > I see what you mean about paths containing '%', but I don't see why > you were concerned about underscores, though. With GLOB, presumably ? matches a single character and * matches any number of characters. With LIKE, _ matches a single character and % matches any number. So, for instance, WHERE filename LIKE '/foo/bar/spam_spam/%' will match '/foo/bar/spam2spam/1234', which may be a little surprising. It's not going to be a serious problem in most cases, as it'll also match '/foo/bar/spam_spam/1234', but the false positives will make one of those "Huhhhhh????" moments if you don't keep an eye on your magic characters. In your specific case, you happen to be safe, but as I look over the code, my paranoia kicks in and tells me to check :) It's just one of those things that flags itself to the mind - anything that might help catch bugs early is a good feature of the mind, in my opinion! ChrisA From steve+comp.lang.python at pearwood.info Wed Jul 2 08:15:34 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jul 2014 12:15:34 GMT Subject: Statically type-checked variant of Python References: Message-ID: <53b3f7e6$0$29985$c3e8da3$5496439d@news.astraweb.com> On Wed, 02 Jul 2014 15:26:07 +0700, musicdenotation wrote: > PHP has Hack, JavaScript has TypeScript, Python has what? I don't know if this counts, but there's Cobra: http://cobra-language.com/ http://cobra-language.com/docs/python/ Cobra has a lot more than just (optional) static typing. Some of the features strike me as good ideas, such as contracts and unit tests, some as dubious (there's a lot of changes to the syntax which, in my opinion, hurt readability). But overall, it strikes me as a very exciting language. -- Steven From steve+comp.lang.python at pearwood.info Wed Jul 2 08:20:09 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jul 2014 12:20:09 GMT Subject: How can I catch values from other def by flask??? References: <79aa79d7-bd71-4635-af9d-aae489cc06e4@googlegroups.com> Message-ID: <53b3f8f9$0$29985$c3e8da3$5496439d@news.astraweb.com> On Wed, 02 Jul 2014 02:43:28 -0700, fk26541598fk wrote: > this is my code Change the code as shown below: > def aa(): > if request.method=='POST': > get_test(value1) > return value1 def aa(): if request.method=='POST': value1 = post_test() return value1 > else: > get_test(value2) > return value2 else: value2 = get_test() return value2 > return 'it does not work' > > def post_test(value1): > value1='POST it works' > return value1 def post_test(): return 'POST it works' > def get_test(value2): > value2='GET it works' def get_test(): return 'GET it works' -- Steven From a24061 at ducksburg.com Wed Jul 2 08:30:08 2014 From: a24061 at ducksburg.com (Adam Funk) Date: Wed, 02 Jul 2014 13:30:08 +0100 Subject: Searching for lots of similar strings (filenames) in sqlite3 database References: <3uva8bx3dn.ln2@news.ducksburg.com> <770d8bxunj.ln2@news.ducksburg.com> Message-ID: On 2014-07-02, Chris Angelico wrote: > On Wed, Jul 2, 2014 at 7:32 PM, Adam Funk wrote: >> Well, I've changed it to the following anyway. >> >> subdir_glob = subdir + '/*' >> cursor.execute('SELECT filename FROM files WHERE filename GLOB ?', >> (subdir_glob,)) >> rows = cursor.fetchall() >> known_files = {row[0] for row in rows} >> >> I see what you mean about paths containing '%', but I don't see why >> you were concerned about underscores, though. > > With GLOB, presumably ? matches a single character and * matches any > number of characters. With LIKE, _ matches a single character and % > matches any number. So, for instance, WHERE filename LIKE > '/foo/bar/spam_spam/%' will match '/foo/bar/spam2spam/1234', which may > be a little surprising. It's not going to be a serious problem in most > cases, as it'll also match '/foo/bar/spam_spam/1234', but the false > positives will make one of those "Huhhhhh????" moments if you don't > keep an eye on your magic characters. > > In your specific case, you happen to be safe, but as I look over the > code, my paranoia kicks in and tells me to check :) It's just one of > those things that flags itself to the mind - anything that might help > catch bugs early is a good feature of the mind, in my opinion! Oh, I'd just missed the '_' in the LIKE documentation. Doh! -- Indentation is for enemy skulls, not code! --- Klingon Programmer's Guide From suman.sstech at gmail.com Wed Jul 2 09:44:59 2014 From: suman.sstech at gmail.com (Suman Bharathi Balasubramanian) Date: Wed, 2 Jul 2014 06:44:59 -0700 (PDT) Subject: NEW JOB req: Python developer with Analytical risk Message-ID: <67ec4e3f-c847-4379-ab49-8e8484a47c4d@googlegroups.com> Python Developers with Analytical Risk Exp- NYC, Long Island, Wilmington, Columbus, Dallas 6 months plus * Implement statistical, economic, econometric or other mathematical models/code for Client's bank models in Python * Ability to translate existing Excel / SAS Model implementations into requirements and high-performance Python implementation * Work with Enterprise Data Warehouse (ICDW/Teradata) staff members to map variables from their source systems to tables and data sets used by the modeling team and to create necessary meta data to document sources and field definitions * Responsible for all aspects of data management for the modeling team, data sourcing into containers (Numpy/Pandas), Documentation(Sphynx), Acceleration, (Numba/Cython) and graphics (Matplotlib/Ggplot/Bokeh) * Assist modeling team members with questions surrounding sources of data files and definitions of data fields * Develop and maintain report-writing programs used by modeling team members. ---- * Application Developer (Ad Hoc/Statistical Programmer) with 7+ experience years in Python * Experience with Python programming using Data Containers (Numpy/Pandas), Documentation (Sphynx), Acceleration, (Numba/Cython) and graphics (Matplotlib/Ggplot/Bokeh) * Translate Excel / SAS Model Implementations into Python * Ability to produce queries/tables on request - Sourced from Oracle / Teradata Databases * Preference will be provided to those with demonstrated modeling experience in consumer and retail business banking * Excellent communication skills, as the incumbent will frequently be called upon to make presentations to senior management and to write documents that describe work products in a clear manner. regards, suman.b at sstech.us From steve+comp.lang.python at pearwood.info Wed Jul 2 11:27:20 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jul 2014 15:27:20 GMT Subject: 1-0.95 References: Message-ID: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> On Tue, 01 Jul 2014 14:17:14 -0700, Pedro Izecksohn wrote: > pedro at microboard:~$ /usr/bin/python3 > Python 3.3.2+ (default, Feb 28 2014, 00:52:16) [GCC 4.8.1] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> 1-0.95 > 0.050000000000000044 >>>>? >>>>? > ? How to get 0.05 as result? Oh, this is a fantastic example of the trouble with floating point! Thank you for finding it! py> 0.05 0.05 py> 1 - 0.95 0.050000000000000044 py> 1 - 0.9 - 0.05 0.049999999999999975 py> 1 - 0.5 - 0.45 0.04999999999999999 *This is not a Python problem* This is a problem with the underlying C double floating point format. Actually, it is not even a problem with the C format, since this problem applies to ANY floating point format, consequently this sort of thing plagues *every* programming language (unless they use arbitrary-precision rationals, but they have their own problems). In this *specific* case, you can get better (but slower) results by using the Decimal format: py> from decimal import Decimal py> 1 - Decimal("0.95") Decimal('0.05') This works because the Decimal type stores numbers in base 10, like you learned about in school, and so numbers that are exact in base 10 are (usually) exact in Decimal. However, the built-in float stores numbers in base 2, for speed and accuracy. Unfortunately many numbers which are exact in base 10 are not exact in base 2. Let's look at a simple number like 0.1 (in decimal), and try to calculate it in base 2: 0.1 in binary (0.1b) equals 1/2, which is too big. 0.01b equals 1/4, which is too big. 0.001b equals 1/8, which is too big. 0.0001b equals 1/16, which is too small, so the answer lies somewhere between 0.0001b and 0.001b. 0.00011b equals 1/16 + 1/32 = 3/32, which is too small. 0.000111b equals 1/16 + 1/32 + 1/64 = 7/64, which is too big, so the answer lies somewhere between 0.000111b and 0.00011b. If you keep going, you will eventually get that the decimal 0.1 written in base 2 is .000110011001100110011001100110011... where the "0011" repeats forever. (Just like in decimal, where 1/3 = 0.33333... repeating forever.) Since floats don't use an infinite amount of memory, this infinite sequence has to be rounded off somewhere. And so it is that 0.1 stored as a float is a *tiny* bit larger than the true decimal value 0.1: py> Decimal.from_float(0.1) Decimal('0.1000000000000000055511151231257827021181583404541015625') All the troubles with floating point numbers start with this harsh reality, numbers have to be rounded off somewhere lest they use infinite memory, and that rounding introduces errors into the calculation. Sometimes those errors cancel, and sometimes they reinforce. To understand what is going on in more detail, you can start with these links: https://docs.python.org/2/faq/design.html#why-am-i-getting-strange-results-with-simple-arithmetic-operations http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm http://blog.codinghorror.com/why-do-computers-suck-at-math/ https://randomascii.wordpress.com/category/floating-point/ https://www.gnu.org/software/gawk/manual/html_node/Floating-Point-Issues.html Good luck! -- Steven From anthra.norell at bluewin.ch Wed Jul 2 11:51:05 2014 From: anthra.norell at bluewin.ch (F.R.) Date: Wed, 02 Jul 2014 17:51:05 +0200 Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> Message-ID: <53B42A69.2000107@bluewin.ch> On 07/02/2014 11:13 AM, flebber wrote: >>>>> TM = TX.Table_Maker (headings = >> ('Meeting','Date','Race','Number','Name','Trainer','Location')) >>>>> TM (race_table (your_csv_text)).write () > Where do I find TX? Found this mention in the list, was it available in pip by any name? > https://mail.python.org/pipermail/python-list/2014-February/667464.html > > Sayth I'd have to make it available. I proposed it some time ago and received a couple of suggestions in return. It is a modular transformation framework written entirely in python (2.7). It consists essentially of a base class "Transformer" that handles input and output in such a way that Transformer objects can be chained. It saved me from drowning an a horrible and growing tangle of hacks. Finding something usable I had previously done took time. Understanding how it worked took more time and adapting it took still more time, so that writing yet another hack from scratch was faster. A number of hacks I could quickly wrap into a Transformer object and so could start building a library of standard Transformers. The Table_Maker is one of them. The table making code is quite bad. It suffers from feature overload. I would clean it up for distribution. I'd be happy to distribute the base class and a few standard Translators, such as I use every day. (File Reader, File Writer, DB Run Command, DB Write, Table Maker, PDF To Text, Text To Lines, Lines To Text, Sort, Sort And Unique, etc.) Writing one's own Transformers is a breeze. Testing too, because a Transformer keeps its input and output and, in line with the system's design philosophy, does only its own single thing. A Chain is a list of Transformers that run in sequence. It is itself derived from Transformer and is a functional equivalent. So Chains nest. Fixing a Chain that nothing comes out of is a straightforward matter too. It will still have run up to the failing element. Chain.show () reveals the culprit as the first one to have no output. I am not up to date on distributing and would depend on qualified help on that. Frederic -------------------------------------------------------------------------------- A brief overview The TX solution to your race table would be (TX is the name of the module): class Race_Table (TX.Transformer): ''' In: CSV text Out: Tabular data (2-dimensional list) ''' name = 'Race_Table' @TX.setup # Checks timestamps to prevent needless reruns in the absence of new input def transform (self): for line in self.Input.data: # See my post self.Output.take (output_table) Example file to file: >>> Race_Schedule_F2F = TX.Chain (TX.File_Reader (), Race_Table (), TX.List_To_CSV (delimiter = ';'), TX.File_Writer (terminal = out_file_name) >>> Race_Schedule_F2F (input_file_name) # Does it all! Example web to database: >>> Race_Schedule_WWW2DB = TX.Chain (TX.WWW_Reader (), Race_Schedule_HTML_Reader (), Race_Table (), TX.DB_Writer (table_name = 'horses')) >>> Race_Schedule_WWW2DB (url) # Does is all! You'd have to write the Race_Schedule_HTML_Reader Verify your table: >>> Table_Viewer = TX.Chain (TX.Table_Maker (), TX.Table_Writer ()) >>> Race_Schedule_WWW2DB.show_tree () # See which one should display Chain Chain[0] - WWW Reader Chain[1] - Race_Schedule_HTML_Reader Chain[2] - Race_Table Chain[3] - DB Writer >>> print Table_Viewer (Race_Schedule_WWW2DB[2]()) # All Transformers keep their data (Display of table) Verify database: >>> print Table_Viewer (TX.DB_Reader (table_name = 'horses')()) (Display of database table) From marko at pacujo.net Wed Jul 2 12:59:25 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 02 Jul 2014 19:59:25 +0300 Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8761jflms2.fsf@elektro.pacujo.net> Steven D'Aprano : > This is a problem with the underlying C double floating point format. > Actually, it is not even a problem with the C format, since this > problem applies to ANY floating point format, consequently this sort > of thing plagues *every* programming language (unless they use > arbitrary-precision rationals, but they have their own problems). Actually, it is not a problem at all. Floating-point numbers are a wonderful thing. > This works because the Decimal type stores numbers in base 10, like you > learned about in school, and so numbers that are exact in base 10 are > (usually) exact in Decimal. Exactly, the problem is in our base 10 mind. Note, however: >>> Decimal(1) / Decimal(3) * Decimal(3) Decimal('0.9999999999999999999999999999') Even "arbitrary-precision" rationals would suffer from the same problem: >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) False Yes, I'm making it up, but it's still true. Marko From wolfgang.maier at biologie.uni-freiburg.de Wed Jul 2 13:31:44 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Wed, 02 Jul 2014 19:31:44 +0200 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: On 02.07.2014 11:05, Terry Reedy wrote: > On 7/2/2014 12:33 AM, Tim Roberts wrote: >> Terry Reedy wrote: >> >> You need to use >> s.check_output("pyflakes c:\\programs\\python34\\lib\\turtle.py") >> or >> s.check_output(r"pyflakes c:\programs\python34\lib\turtle.py") > > Now I get "Command 'pyflakes c:\programs\python34\lib\turtle.py' returns > non-zero exit status 1" on both. On Idle, as least, a command-prompt > window is flashed/displayed. It makes no sense to me that in the command > interpreter, > 'pyflakes c:\\programs\\python34\\lib' works and > 'pyflakes c:\\programs\\python34\\lib\\turtle.py' returns status 1. > whereas both (with quotes elided and undoubled \) work at the command > prompt. > I am not 100% sure whether that is the problem, but from what I gather from the subprocess module docs the args string is passed to the Windows CreateProcess function as a single string. To me this seems to imply that it is passed as the lpCommandLine parameter (with Null for the lpApplicationName parameter). This is what Microsoft says about this case (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx): If lpApplicationName is NULL, the first white space?delimited token of the command line specifies the module name. If you are using a long file name that contains a space, use quoted strings to indicate where the file name ends and the arguments begin (see the explanation for the lpApplicationName parameter). If the file name does not contain an extension, .exe is appended. Therefore, if the file name extension is .com, this parameter must include the .com extension. If the file name ends in a period (.) with no extension, or if the file name contains a path, .exe is not appended. If the file name does not contain a directory path, the system searches for the executable file in the following sequence. So in your case the default behavior would be to add an .exe extension to pyflakes, which is probably not what you intended ? Best, Wolfgang From skip at pobox.com Wed Jul 2 13:34:56 2014 From: skip at pobox.com (Skip Montanaro) Date: Wed, 2 Jul 2014 12:34:56 -0500 Subject: 1-0.95 In-Reply-To: <8761jflms2.fsf@elektro.pacujo.net> References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 2, 2014 at 11:59 AM, Marko Rauhamaa wrote: > Yes, I'm making it up, but it's still true. I don't think there's any reason to be hypothetical: In [149]: d Out[149]: Decimal('2') In [150]: d.sqrt() * d.sqrt() == d Out[150]: False :-) Skip From wolfgang.maier at biologie.uni-freiburg.de Wed Jul 2 13:37:03 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Wed, 02 Jul 2014 19:37:03 +0200 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: On 02.07.2014 19:31, Wolfgang Maier wrote: > > I am not 100% sure whether that is the problem, but from what I gather > from the subprocess module docs the args string is passed to the Windows > CreateProcess function as a single string. > To me this seems to imply that it is passed as the lpCommandLine > parameter (with Null for the lpApplicationName parameter). > This is what Microsoft says about this case > (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx): > > > > If lpApplicationName is NULL, the first white space?delimited token of > the command line specifies the module name. If you are using a long file > name that contains a space, use quoted strings to indicate where the > file name ends and the arguments begin (see the explanation for the > lpApplicationName parameter). If the file name does not contain an > extension, .exe is appended. Therefore, if the file name extension is > .com, this parameter must include the .com extension. If the file name > ends in a period (.) with no extension, or if the file name contains a > path, .exe is not appended. If the file name does not contain a > directory path, the system searches for the executable file in the > following sequence. > > > So in your case the default behavior would be to add an .exe extension > to pyflakes, which is probably not what you intended ? > > Best, > Wolfgang > Ah, I forgot about your pyflakes -h example, which works, so my explanation must be wrong. Sorry. From breamoreboy at yahoo.co.uk Wed Jul 2 13:42:16 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 02 Jul 2014 18:42:16 +0100 Subject: NEW JOB req: Python developer with Analytical risk In-Reply-To: <67ec4e3f-c847-4379-ab49-8e8484a47c4d@googlegroups.com> References: <67ec4e3f-c847-4379-ab49-8e8484a47c4d@googlegroups.com> Message-ID: On 02/07/2014 14:44, Suman Bharathi Balasubramanian wrote: Please post your jobs here https://www.python.org/community/jobs/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From steve+comp.lang.python at pearwood.info Wed Jul 2 14:34:03 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 02 Jul 2014 18:34:03 GMT Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> Message-ID: <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> On Wed, 02 Jul 2014 19:59:25 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> This is a problem with the underlying C double floating point format. >> Actually, it is not even a problem with the C format, since this >> problem applies to ANY floating point format, consequently this sort of >> thing plagues *every* programming language (unless they use >> arbitrary-precision rationals, but they have their own problems). > > Actually, it is not a problem at all. Floating-point numbers are a > wonderful thing. No, *numbers* in the abstract mathematical sense are a wonderful thing. Concrete floating point numbers are a *useful approximation* to mathematical numbers. But they're messy, inexact, and fail to have the properties we expect real numbers to have, e.g. any of these can fail with IEEE-754 floating point numbers: 1/(1/x) == x x*(y+z) == x*y + x*z x + y - z == x - z + y x + y == x implies y == 0 You think maths is hard? That's *nothing* compared to reasoning about floating point numbers, where you cannot even expect x+1 to be different from x. In the Bad Old Days before IEEE-754, things were even worse! I've heard of CPUs where it was impossible to guard against DivideByZero errors: if x != 0: # succeeds print 1/x # divide by zero because the test for inequality tested more digits than the divider used. Ouch. >> This works because the Decimal type stores numbers in base 10, like you >> learned about in school, and so numbers that are exact in base 10 are >> (usually) exact in Decimal. > > Exactly, the problem is in our base 10 mind. No no no no! The problem is that *no matter what base you pick* some exact rational numbers cannot be represented in a finite number of digits. (Not to mention the irrationals.) > Note, however: > > >>> Decimal(1) / Decimal(3) * Decimal(3) > Decimal('0.9999999999999999999999999999') Yes! Because Decimal has a finite (albeit configurable) precision, while 1/3 requires infinite number of decimal places. Consequently, 1/Decimal(3) is a little bit smaller than 1/3, and multiplying by 3 gives you something a little bit smaller than 1. Ironically, in base 2, the errors in that calculation cancel out: py> 1/3*3 == 1 True and of course in base 3 the calculation would be exact. > Even "arbitrary-precision" rationals would suffer from the same problem: Not so. py> from fractions import Fraction py> Fraction(1, 3)*3 == 1 True "Arbitrary precision" rationals like Fraction are capable of representing *every rational number* exactly (provided you have enough memory). > >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) > False Square root of 2 is not a rational number. -- Steven From irmen.NOSPAM at xs4all.nl Wed Jul 2 14:46:50 2014 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Wed, 02 Jul 2014 20:46:50 +0200 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> Message-ID: <53b4539b$0$2901$e4fe514c@news.xs4all.nl> On 2-7-2014 4:04, Rita wrote: > yes, this helps. But I want to know who uses the module, serpent. So, when > I upgrade it or remove it they won't be affected adversely. (Please don't top-post, it makes the discussion harder to follow.) > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong > wrote: > >> On 1-7-2014 12:38, Rita wrote: >>> i work in a group of developers (15 or so) who are located globally. I >>> would like to know what modules everyone is uses if I ever have to >> upgrade >>> my python. Is there mechanism which will let me see who is using what? >>> >>> ie, >>> >>> tom,matplotlib >>> bob, pylab >>> nancy, numpy >>> nancy, matplotlib >>> >>> etc... >>> >>> >> >> Well, if your group is all using Pip (and perhaps even virtualenv), you >> could use pip >> list. In my case: >> >> $ pip list [...] Why would the fact that you upgrade or remove a package, affect another developer in your group? Are you all using the same machine to develop on, with one Python installation? I think you'll have to tell us some more details about the way you work together before we can give a meaningful answer to your question. Irmen From kjakupak at gmail.com Wed Jul 2 15:20:10 2014 From: kjakupak at gmail.com (kjakupak at gmail.com) Date: Wed, 2 Jul 2014 12:20:10 -0700 (PDT) Subject: OOP with MyTime Message-ID: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help. What I've gotten so far: class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs def between(t1, t2): if float(t1 <= t3) and float(t3 < t2): return True else: return False I just don't understand how to make a function that uses MyTime objects into the boolean function? Any help would be great. From 4kir4.1i at gmail.com Wed Jul 2 15:45:28 2014 From: 4kir4.1i at gmail.com (Akira Li) Date: Wed, 02 Jul 2014 23:45:28 +0400 Subject: OOP with MyTime References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: <87zjgrlf3b.fsf@gmail.com> kjakupak at gmail.com writes: > I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. > > This is a question from the How to Think Like a Computer Scientist book, and I need help. > > What I've gotten so far: > > class MyTime: > def __init__(self, hrs=0, mins=0, secs=0): > self.hours = hrs > self.minutes = mins > self.seconds = secs > def between(t1, t2): > if float(t1 <= t3) and float(t3 < t2): > return True > else: > return False > > I just don't understand how to make a function that uses MyTime objects into the boolean function? Any help would be great. A method accepts the object itself as the first parameter: import functools @functools.total_ordering class MyTime: ... def inbetween(self, t1, t2): """Return whether `self` is in [t1, t2) right-open range.""" return t1 <= self < t2 # `self` is the object itself def _astuple(self): return (self.hours, self.minutes, self.seconds) def __lt__(self, other): """Return whether `self < other`.""" return self._astuple() < other._astuple() def __eq__(self, other): """Return whether `self == other`.""" return self._astuple() == other._astuple() See https://docs.python.org/3/library/functools.html#functools.total_ordering Example: >>> MyTime(1).inbetween(MyTime(0), MyTime(2)) True It is equivalent to: >>> MyTime(0) <= MyTime(1) < MyTime(2) True -- Akira From python at mrabarnett.plus.com Wed Jul 2 16:02:00 2014 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 02 Jul 2014 21:02:00 +0100 Subject: OOP with MyTime In-Reply-To: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: <53B46538.7000809@mrabarnett.plus.com> On 2014-07-02 20:20, kjakupak at gmail.com wrote: > I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. > > This is a question from the How to Think Like a Computer Scientist book, and I need help. > > What I've gotten so far: > > class MyTime: > def __init__(self, hrs=0, mins=0, secs=0): > self.hours = hrs > self.minutes = mins > self.seconds = secs > def between(t1, t2): > if float(t1 <= t3) and float(t3 < t2): > return True > else: > return False > > I just don't understand how to make a function that uses MyTime objects into the boolean function? Any help would be great. > If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments 't1' and 't2'. You can then compare the hours, minutes and seconds of self against those of t1 and t2: def between(self, t1, t2): return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= (t2.hours, t2.minutes, t2.seconds) That could be shortened further using chained comparisons. Note that the code assumes that the times t1 and t2 are ordered, i.e. that time t1 is not later/greater than time t2. From marko at pacujo.net Wed Jul 2 16:00:15 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 02 Jul 2014 23:00:15 +0300 Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <878uobpm40.fsf@elektro.pacujo.net> Steven D'Aprano : >> >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) >> False > > Square root of 2 is not a rational number. Nobody said it was. It's just that even "arbitrary-precision" rational numbers wouldn't free you from the issues of floating-point numbers. The Decimal number class won't do it, either, of course. On the other hand, floating-point numbers are perfect whenever you deal with science and measurement. And when you deal with business (= money), integers are the obvious choice. I would venture to say that the real applications for Decimal are very rare. In practice, I'm afraid, people with rather a weak understanding of numbers and computation might gravitate toward Decimal unnecessarily. Marko From mosheavraham2002 at gmail.com Wed Jul 2 18:01:45 2014 From: mosheavraham2002 at gmail.com (Moshe Avraham) Date: Wed, 2 Jul 2014 18:01:45 -0400 Subject: FW: install software via Python script Message-ID: <002201cf9641$37639ef0$a62adcd0$@gmail.com> HI Guys, I need to install variety of software (Oracle, SqlServer, upgrade JAVA version, WAS, WMB, Tomcat, etc.) on both WINDOWS and UNIX/LINUX. These are usual daily operation of large IT departments. So instead of developing both shell & DOS scripts, I like to develop a single Python script (for each of these software) to run on all operation systems. Can someone suggest an easy simple way of developing a script for Oracle (as an example). Thanks, Moshe -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Wed Jul 2 18:07:30 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 2 Jul 2014 22:07:30 +0000 (UTC) Subject: FW: install software via Python script References: Message-ID: On 2014-07-02, Moshe Avraham wrote: > I need to install variety of software (Oracle, SqlServer, upgrade > JAVA version, WAS, WMB, Tomcat, etc.) on both WINDOWS and UNIX/LINUX. > > These are usual daily operation of large IT departments. > > So instead of developing both shell & DOS scripts, I like to develop > a single Python script (for each of these software) to run on all > operation systems. > > Can someone suggest an easy simple way of developing a script for > Oracle (as an example). 1. Write down a precise description of each of the steps required to accomplish the task. 2. Convert each step to Python. -- Grant Edwards grant.b.edwards Yow! I am NOT a nut.... at gmail.com From pmiscml at gmail.com Wed Jul 2 18:46:37 2014 From: pmiscml at gmail.com (Paul Sokolovsky) Date: Thu, 3 Jul 2014 01:46:37 +0300 Subject: install software via Python script In-Reply-To: <002201cf9641$37639ef0$a62adcd0$@gmail.com> References: <002201cf9641$37639ef0$a62adcd0$@gmail.com> Message-ID: <20140703014637.48c799f1@x34f> Hello, On Wed, 2 Jul 2014 18:01:45 -0400 "Moshe Avraham" wrote: > HI Guys, > > I need to install variety of software (Oracle, SqlServer, upgrade JAVA > version, WAS, WMB, Tomcat, etc.) on both WINDOWS and UNIX/LINUX. > > These are usual daily operation of large IT departments. > > So instead of developing both shell & DOS scripts, I like to develop a > single Python script (for each of these software) to run on all > operation systems. > > Can someone suggest an easy simple way of developing a script for > Oracle (as an example). You should look into Ansible http://www.ansible.com , https://github.com/ansible/ansible > > Thanks, > > Moshe > -- Best regards, Paul mailto:pmiscml at gmail.com From 1248283536 at qq.com Wed Jul 2 18:40:50 2014 From: 1248283536 at qq.com (=?utf-8?B?5rC06Z2Z5rWB5rex?=) Date: Thu, 3 Jul 2014 06:40:50 +0800 Subject: how can i get the source code of goagent.exe? Message-ID: There is a open source project-goagent,when you download it and extract it, code.google.com/p/goagent/downloads? in the local diretory, a file named goagent.exe in it. how can i get the source code of goagent.exe ,not the binary form ,the text form. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Wed Jul 2 19:14:13 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Jul 2014 19:14:13 -0400 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: On 7/2/2014 1:37 PM, Wolfgang Maier wrote: > On 02.07.2014 19:31, Wolfgang Maier wrote: >> >> I am not 100% sure whether that is the problem, but from what I gather >> from the subprocess module docs the args string is passed to the Windows >> CreateProcess function as a single string. >> To me this seems to imply that it is passed as the lpCommandLine >> parameter (with Null for the lpApplicationName parameter). >> This is what Microsoft says about this case >> (http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx): >> >> >> >> >> If lpApplicationName is NULL, the first white space?delimited token of >> the command line specifies the module name. If you are using a long file >> name that contains a space, use quoted strings to indicate where the >> file name ends and the arguments begin (see the explanation for the >> lpApplicationName parameter). If the file name does not contain an >> extension, .exe is appended. Therefore, if the file name extension is >> .com, this parameter must include the .com extension. If the file name >> ends in a period (.) with no extension, or if the file name contains a >> path, .exe is not appended. If the file name does not contain a >> directory path, the system searches for the executable file in the >> following sequence. >> >> >> So in your case the default behavior would be to add an .exe extension >> to pyflakes, which is probably not what you intended ? >> >> Best, >> Wolfgang >> > > Ah, I forgot about your pyflakes -h example, which works, so my > explanation must be wrong. I appreciate the attempt. I hope there is someone who has been successful who can answer ;-). -- Terry Jan Reedy From tjreedy at udel.edu Wed Jul 2 19:17:24 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Jul 2014 19:17:24 -0400 Subject: how can i get the source code of goagent.exe? In-Reply-To: References: Message-ID: On 7/2/2014 6:40 PM, ???? wrote: > There is a open source project-goagent,when you download it and extract it, > code.google.com/p/*goagent*/downloads? > > in the local diretory, a file named goagent.exe in it. > > how can i get the source code of goagent.exe ,not the binary form ,the > text form. This appears to be off-topic for this list because I suspect 'goagent' meant 'go agent', where 'go' is googles language, not Python. However, go to https://code.google.com/p/goagent/source/checkout. Use g. search to fint out about git. -- Terry Jan Reedy From wolfgang.maier at biologie.uni-freiburg.de Wed Jul 2 19:22:50 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Wed, 2 Jul 2014 23:22:50 +0000 (UTC) Subject: Success with subprocess communicate on Windows? References: Message-ID: Terry Reedy udel.edu> writes: > > On 7/2/2014 12:33 AM, Tim Roberts wrote: > > Terry Reedy udel.edu> wrote: > >> > > You need to use > > s.check_output("pyflakes c:\\programs\\python34\\lib\\turtle.py") > > or > > s.check_output(r"pyflakes c:\programs\python34\lib\turtle.py") > > Now I get "Command 'pyflakes c:\programs\python34\lib\turtle.py' returns > non-zero exit status 1" on both. On Idle, as least, a command-prompt > window is flashed/displayed. It makes no sense to me that in the command > interpreter, > 'pyflakes c:\\programs\\python34\\lib' works and > 'pyflakes c:\\programs\\python34\\lib\\turtle.py' returns status 1. > whereas both (with quotes elided and undoubled \) work at the command > prompt. > Finally found out what the problem is: When I'm running your command using the cmd console, I get this output: c:\python34\lib\turtle.py:571: local variable 'rgb' is assigned to but never used c:\python34\lib\turtle.py:2936: local variable 'a21' is assigned to but never used c:\python34\lib\turtle.py:3590: local variable 'dummy' is assigned to but never used c:\python34\lib\turtle.py:3786: undefined name 'mainloop' c:\python34\lib\turtle.py:3969: undefined name 'mainloop' c:\python34\lib\turtle.py:3973: undefined name 'isdown' c:\python34\lib\turtle.py:3974: undefined name 'pu' c:\python34\lib\turtle.py:3976: undefined name 'pd' .. now look at the exit code: echo %errorlevel% 1 ah, pyflakes does exit with a non-zero exit code when it finds errors in your file!! Now, using subprocess.check_output in IDLE: >>> msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') Traceback (most recent call last): File "", line 1, in msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') File "C:\Python34\lib\subprocess.py", line 618, in check_output raise CalledProcessError(retcode, process.args, output=output) subprocess.CalledProcessError: Command 'pyflakes c:\python34\lib\turtle.py' returned non-zero exit status 1 as you said, but logical since (taken from the docs): "subprocess.check_output(args, *, input=None, stdin=None, stderr=None, shell=False, universal_newlines=False, timeout=None) Run command with arguments and return its output. If the return code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and any output in the output attribute." and in fact: >>> try: msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') except subprocess.CalledProcessError as e: print (e.output[:81]) b"c:\\python34\\lib\\turtle.py:571: local variable 'rgb' is assigned to but never used" So, everything's just fine except that it may be more convenient to use Popen().communicate() to avoid raising the error in the first place :) Hope it helps this time, Wolfgang From mosheavraham2002 at gmail.com Wed Jul 2 19:56:10 2014 From: mosheavraham2002 at gmail.com (Moshe Avraham) Date: Wed, 2 Jul 2014 19:56:10 -0400 Subject: install software via Python script In-Reply-To: <002201cf9641$37639ef0$a62adcd0$@gmail.com> References: <002201cf9641$37639ef0$a62adcd0$@gmail.com> Message-ID: <006501cf9651$32f35940$98da0bc0$@gmail.com> HI Guys, I need to install variety of software (Oracle, SqlServer, upgrade JAVA version, WAS, WMB, Tomcat, etc.) on both WINDOWS and UNIX/LINUX. These are usual daily operation of large IT departments. So instead of developing both shell & DOS scripts, I like to develop a single Python script (for each of these software) to run on all operation systems. Can someone suggest an easy simple way of developing a script for Oracle (as an example). Thanks, Moshe -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Wed Jul 2 20:16:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jul 2014 10:16:09 +1000 Subject: 1-0.95 In-Reply-To: <878uobpm40.fsf@elektro.pacujo.net> References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 3, 2014 at 6:00 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >>> >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) >>> False >> >> Square root of 2 is not a rational number. > > Nobody said it was. It's just that even "arbitrary-precision" rational > numbers wouldn't free you from the issues of floating-point numbers. The > Decimal number class won't do it, either, of course. They do free you from the issues of floating point. In exchange, they give you the problems of rationals. (Most notably, addition becomes very slow. Remember grade school and learning to add/subtract vulgar fractions?) > On the other hand, floating-point numbers are perfect whenever you deal > with science and measurement. And when you deal with business (= money), > integers are the obvious choice. Why are floats perfect for science, but not for other situations? Integers are great if you can guarantee you can fit within them - which, when you're talking about money, presumably means you're working in a fixed-point system (eg with the popular something-and-cents notation (including the GBP with pounds and pence), you store currency in cents, which is fixed-point two places after the decimal). What about when you have to work with fractions of a cent? Ah! I know! Let's have two integers - one for the number of dollars/euro/pounds/etc, and then another one that says how much out of 2**32 of another one we have! book = (29, 2147483648) # $29.50 airfare = (2468, 2920577761) # $2468.68 interest = (1, 616212701) # $1.1434732 See, integers are the obvious choice for money! > I would venture to say that the real applications for Decimal are very > rare. In practice, I'm afraid, people with rather a weak understanding > of numbers and computation might gravitate toward Decimal unnecessarily. Your second part? Possibly. There was some discussion about an import hook that would turn all unmarked non-integer literals into Decimals rather than floats, and it was decided that it wouldn't be worth it. But there definitely are real uses for Decimal, and quite a lot of them - just as there were very solid reasons for REXX's numeric implementation having been fairly similar. (Although - unsurprisingly given that Python has had another couple of decades of development - not as sophisticated. For instance, REXX doesn't have numeric contexts, so all changes to precision etc are global.) Numbers can't be represented in a computer in any way that doesn't potentially demand infinite storage. There are two basic techniques for storing numbers: ratios, possibly where the denominator is selected from a very restricted set (IEEE floating point is (usually) this - the denominator must be a power of two), and algebraic symbols, where you represent sqrt(2) as "\u221a2" and evaluate to an actual number only at the very end, if ever (which gets around the problems of intermediate rounding, and allows perfect cancelling out - pow("\u221a2",8) == "16"). No matter what system you use, you're eventually going to get down to a choice: retain all the precision you possibly can, and maybe use infinite or near-infinite storage; or throw away the bits that aren't going to affect the calculation significantly, and keep the object size down to something reasonable. I do seem to recall, back in maths class, being allowed to use either 22/7 or 3.14 for ?, because the difference between either of those and the true value was not significant :) It's the same in computing, except that it's common to go as far as 3.141592653589793 (a number I memorized out of the GW-BASIC manual, back when I first started programming with floating point). Short of actually running on a Turing machine, your program is always going to be bound by these restrictions. ChrisA From ethan at stoneleaf.us Wed Jul 2 19:54:30 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 02 Jul 2014 16:54:30 -0700 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: <53B49BB6.4030904@stoneleaf.us> On 07/02/2014 04:22 PM, Wolfgang Maier wrote: > > So, everything's just fine except that it may be more convenient to use > Popen().communicate() to avoid raising the error in the first place :) Nice sleuthing! :) -- ~Ethan~ From conradwt at gmail.com Wed Jul 2 21:12:22 2014 From: conradwt at gmail.com (Conrad Taylor) Date: Wed, 2 Jul 2014 18:12:22 -0700 (PDT) Subject: Is pip being automatically installed for Python 3.4.0? Message-ID: Hi, shouldn't pip be automatically installed for Python 3.4.0 release? I have read through the release and the PEP 453. Thus, can someone confirm whether or not this is the case? BTW, I have installed Python 3.4.0 using MacPorts. -- Think different and code well, -Conrad From rmorgan466 at gmail.com Wed Jul 2 21:17:23 2014 From: rmorgan466 at gmail.com (Rita) Date: Wed, 2 Jul 2014 21:17:23 -0400 Subject: general module auditing In-Reply-To: <53b4539b$0$2901$e4fe514c@news.xs4all.nl> References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong wrote: > On 2-7-2014 4:04, Rita wrote: > > yes, this helps. But I want to know who uses the module, serpent. So, > when > > I upgrade it or remove it they won't be affected adversely. > > > (Please don't top-post, it makes the discussion harder to follow.) > > > > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong > > wrote: > > > >> On 1-7-2014 12:38, Rita wrote: > >>> i work in a group of developers (15 or so) who are located globally. I > >>> would like to know what modules everyone is uses if I ever have to > >> upgrade > >>> my python. Is there mechanism which will let me see who is using what? > >>> > >>> ie, > >>> > >>> tom,matplotlib > >>> bob, pylab > >>> nancy, numpy > >>> nancy, matplotlib > >>> > >>> etc... > >>> > >>> > >> > >> Well, if your group is all using Pip (and perhaps even virtualenv), you > >> could use pip > >> list. In my case: > >> > >> $ pip list > > [...] > > > Why would the fact that you upgrade or remove a package, affect another > developer in > your group? Are you all using the same machine to develop on, with one > Python installation? > > I think you'll have to tell us some more details about the way you work > together before > we can give a meaningful answer to your question. > > > Irmen > > -- > https://mail.python.org/mailman/listinfo/python-list > we have a shared mount point which has our python install. we have 3 servers on one part of the campus and 2 in another part. I want to find out what packages our user base is using thats the final goal. I can figure out who is using python by writing a wrapper but not what module. -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From fk26541598fk at gmail.com Wed Jul 2 21:27:29 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 2 Jul 2014 18:27:29 -0700 (PDT) Subject: How can I catch values from other def by flask??? In-Reply-To: <53b3f8f9$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <79aa79d7-bd71-4635-af9d-aae489cc06e4@googlegroups.com> <53b3f8f9$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven Thank you!!! it's work i'm so appreciate that hava a nice day^^ From fk26541598fk at gmail.com Wed Jul 2 21:29:53 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 2 Jul 2014 18:29:53 -0700 (PDT) Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: References: Message-ID: <60ea2800-2715-4cf7-91d8-973953b479bd@googlegroups.com> it's truth pip will be automatically install Python3.4.0 if you want to use another version you should use wget From steve+comp.lang.python at pearwood.info Wed Jul 2 22:19:30 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 03 Jul 2014 02:19:30 GMT Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> Message-ID: <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >>> >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) >>> False >> >> Square root of 2 is not a rational number. > > Nobody said it was. Your comment can be read as implying it. You stated: [quote] Even "arbitrary-precision" RATIONALS [emphasis added] would suffer from the same problem [end quote] and then showed an invented example where you squared a NON-RATIONAL. By the way, there's no need to use an invented example. Here is an actual example: py> import math py> from fractions import Fraction py> math.sqrt(Fraction(2))**2 2.0000000000000004 > It's just that even "arbitrary-precision" rational > numbers wouldn't free you from the issues of floating-point numbers. Hmmm, well, I wouldn't put it that way. I would put it that a rational number class has problems of its own. A correct, non-buggy rational number class does not suffer from most of the problems of floating point numbers. For example, apart from x = 0, the following: 1/(1/x) == x is always true in mathematics, and always true with a rational class, but not always true with floating point: py> x = 49.0 py> 1/(1/x) == x False py> x = Fraction(49) py> 1/(1/x) == x True The specific problem you show, with sqrt, comes about because it takes you outside of the rationals and into the floating point numbers. > The Decimal number class won't do it, either, of course. Decimals are floating point number, so they suffer from the same kind of failures as other floating point numbers. > On the other hand, floating-point numbers are perfect whenever you deal > with science and measurement. /head-desk I'm sorry Marko, have you not being paying attention? Have you ever done any numeric programming? Floating-point is *hard*, not "perfect". Even *trivially simple* arithmetic problems can burn you, badly. Have you not heard of catastrophic cancellation, or the Table Maker's Dilemma, or ill- conditioned equations? If scientists don't have to worry about these things (and they actually do), it's because the people writing the scientific libraries have worried about them. Almost every thing that most non-experts believe is true about doing calculations on a computer is false -- including, I daresay, me. I'm sure I've probably got some wrong ideas too. Or at least incomplete ones. This page gives some examples: http://introcs.cs.princeton.edu/java/91float/ including a calculation of the harmonic sum 1/1 + 1/2 + 1/3 + 1/4 + ... Mathematically that sum diverges to infinity; numerically, it converges to a fixed, finite value. > And when you deal with business (= money), > integers are the obvious choice. Unfortunately there is nothing obvious about using integers. If you want to represent $1.01, what could be more obvious than using 1.01? But that's the *wrong solution*. Unfortunately using integers for money is trickier than you may think. If all you're doing is multiplying, adding and subtracting, then using 101 for $1.01 is fine. But as soon as you start doing division, percentages, sales tax calculations, interest calculations, currency conversions, etc., you've got a problem. How do you divide 107 cents by 3? If you just truncate: py> (107//3)*3 105 you've just lost two cents. If you round to the nearest whole number: py> (round(107/3))*3 108 you've just invented a cent from thin air. Both answers are wrong. Depending on your application, you may pick one or the other, but either way, you have to care about rounding, and that's neither obvious nor easy. > I would venture to say that the real applications for Decimal are very > rare. In practice, I'm afraid, people with rather a weak understanding > of numbers and computation might gravitate toward Decimal unnecessarily. Financial applications are one of the real applications for Decimal. You can think of Decimal numbers as an easy way to fake the use of integers, without having to worry about moving the decimal point around or come up with your own rounding modes. py> from decimal import * py> setcontext(Context(prec=3)) py> (Decimal("1.07")/3)*3 Decimal('1.07') -- Steven From liuerfire at gmail.com Wed Jul 2 22:20:21 2014 From: liuerfire at gmail.com (liuerfire Wang) Date: Thu, 3 Jul 2014 10:20:21 +0800 Subject: how can i get the source code of goagent.exe? In-Reply-To: References: Message-ID: Hi ???? the source code is on https://github.com/goagent/goagent Hi Terry, GoAgent, a tool to help cross the GFW, is written by Python not Go. So this may be not off-topic. :P On Thu, Jul 3, 2014 at 6:40 AM, ???? <1248283536 at qq.com> wrote: > There is a open source project-goagent,when you download it and extract it, > code.google.com/p/*goagent*/downloads? > > in the local diretory, a file named goagent.exe in it. > > how can i get the source code of goagent.exe ,not the binary form ,the > text form. > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -- Best regards. /********************************** google+: +liuerfire twitter: @liuerfire ??????????????~^_^~ ***********************************/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From c.candide at laposte.net Wed Jul 2 22:39:47 2014 From: c.candide at laposte.net (candide) Date: Wed, 2 Jul 2014 19:39:47 -0700 (PDT) Subject: TypeError expected in an augmented assignment Message-ID: An hybrid list-tuple concatenation is not allowed >>> []+(1, 2) Traceback (most recent call last): File "", line 1, in TypeError: can only concatenate list (not "tuple") to list >>> hence I was expecting (*) that the following code raises a TypeError : >>> x = [] >>> x += (1, 2) >>> x [1, 2] >>> Any explanation ? (*) as the docs states, the augmented assignment is supposed to perform the concatenation : An augmented assignment (...) performs the binary operation specific to the type of assignment on the two operands (...) From conradwt at gmail.com Wed Jul 2 22:52:01 2014 From: conradwt at gmail.com (Conrad Taylor) Date: Wed, 2 Jul 2014 19:52:01 -0700 (PDT) Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: <60ea2800-2715-4cf7-91d8-973953b479bd@googlegroups.com> References: <60ea2800-2715-4cf7-91d8-973953b479bd@googlegroups.com> Message-ID: <62195113-ed2f-42c9-beb3-80cd1f3546f5@googlegroups.com> On Wednesday, July 2, 2014 6:29:53 PM UTC-7, Frank Liou wrote: > it's truth > > > > pip will be automatically install Python3.4.0 > > > > if you want to use another version > > > > you should use wget This doesn't appear to be the case when installing via MacPorts. From tjreedy at udel.edu Wed Jul 2 22:57:49 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Jul 2014 22:57:49 -0400 Subject: TypeError expected in an augmented assignment In-Reply-To: References: Message-ID: On 7/2/2014 10:39 PM, candide wrote: > An hybrid list-tuple concatenation is not allowed > >>>> []+(1, 2) > Traceback (most recent call last): > File "", line 1, in > TypeError: can only concatenate list (not "tuple") to list >>>> > > > > hence I was expecting (*) that the following code raises a TypeError : > >>>> x = [] >>>> x += (1, 2) >>>> x > [1, 2] >>>> > > > Any explanation ? >>> seq = [1,2] >>> seq.extend((3,4)) >>> seq+= {5, 6} # the order of extending is not determined >>> seq [1, 2, 3, 4, 5, 6] >>> -- Terry Jan Reedy From tjreedy at udel.edu Wed Jul 2 22:59:04 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 02 Jul 2014 22:59:04 -0400 Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: References: Message-ID: On 7/2/2014 9:12 PM, Conrad Taylor wrote: > Hi, shouldn't pip be automatically installed for Python 3.4.0 release? I have read through the release and the PEP 453. Thus, can someone confirm whether or not this is the case? BTW, I have installed Python 3.4.0 using MacPorts. by windows installer -- Terry Jan Reedy From zachary.ware+pylist at gmail.com Wed Jul 2 23:23:58 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 2 Jul 2014 22:23:58 -0500 Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: <62195113-ed2f-42c9-beb3-80cd1f3546f5@googlegroups.com> References: <60ea2800-2715-4cf7-91d8-973953b479bd@googlegroups.com> <62195113-ed2f-42c9-beb3-80cd1f3546f5@googlegroups.com> Message-ID: On Wed, Jul 2, 2014 at 9:52 PM, Conrad Taylor wrote: > This doesn't appear to be the case when installing via MacPorts. You may need to run `python3.4 -m ensurepip`. Add '--help' to learn about the available options. -- Zach From tjreedy at udel.edu Thu Jul 3 00:09:14 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 03 Jul 2014 00:09:14 -0400 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: On 7/2/2014 7:22 PM, Wolfgang Maier wrote: > Finally found out what the problem is: > When I'm running your command using the cmd console, I get this output: > > c:\python34\lib\turtle.py:571: local variable 'rgb' is assigned to but never > used > c:\python34\lib\turtle.py:2936: local variable 'a21' is assigned to but > never used > c:\python34\lib\turtle.py:3590: local variable 'dummy' is assigned to but > never used > c:\python34\lib\turtle.py:3786: undefined name 'mainloop' > c:\python34\lib\turtle.py:3969: undefined name 'mainloop' > c:\python34\lib\turtle.py:3973: undefined name 'isdown' > c:\python34\lib\turtle.py:3974: undefined name 'pu' > c:\python34\lib\turtle.py:3976: undefined name 'pd' > .. > > now look at the exit code: > echo %errorlevel% > 1 I did not know about this. > ah, pyflakes does exit with a non-zero exit code when it finds errors in > your file!! I guessed that and confirmed it in pyflakes.api.main(). The same is true with >pyflakes c:/programs/python34/lib (path for my machine), except that then there is 20 or more times as much output. > Now, using subprocess.check_output in IDLE: > >>>> msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') > Traceback (most recent call last): > File "", line 1, in > msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') > File "C:\Python34\lib\subprocess.py", line 618, in check_output > raise CalledProcessError(retcode, process.args, output=output) > subprocess.CalledProcessError: Command 'pyflakes c:\python34\lib\turtle.py' > returned non-zero exit status 1 Yes, but what puzzled me is that running subprocess.check_output(r'pyflakes c:\programs\python34\lib') in the regular interpreter *does* produce output instead of the error message. My guess is that it fills up the pipe, so that check_output starts reading the pipe long before pyflakes exits with status 1. Hmm. I tried it again, and I see some but not all of the output I got at the command line *and* I see the exit status message. So the subprocess must get some of the output but then stop when it sees the exit status. Thanks. > as you said, but logical since (taken from the docs): > > "subprocess.check_output(args, *, input=None, stdin=None, stderr=None, > shell=False, universal_newlines=False, timeout=None) > Run command with arguments and return its output. > > If the return code was non-zero it raises a CalledProcessError. The > CalledProcessError object will have the return code in the returncode > attribute and any output in the output attribute." > > and in fact: >>>> try: > msg=subprocess.check_output(r'pyflakes c:\python34\lib\turtle.py') > except subprocess.CalledProcessError as e: > print (e.output[:81]) > > > b"c:\\python34\\lib\\turtle.py:571: local variable 'rgb' is assigned to but > never used" > > So, everything's just fine except that it may be more convenient to use > Popen().communicate() to avoid raising the error in the first place :) As I believe I said in my first post, that is where we started -- but in Idle. I did not realize then that at least some of the problem is specific to Idle on Windows and not Python on Windows. It may have something to do with running in pythonw.exe > Hope it helps this time, Yes, it did, to focus my attention. I will see if I can get all of the output with communicate in the normal interpreter. Having it work in Idle is a different matter, as before it hung indefinitely without showing anything with subprocess.check_output(r'pyflakes c:\programs\python34\lib') or with the original Popen.communicate. But I should start experiments in Idle with something that works right in the normal interpreter. --- Doing that, this works on 2.7.7, 3.4.1+, and 3.5.0a (and would work in posix also). import subprocess as s p = s.Popen([r'pyflakes', r'c:\programs\python34\lib\turtle.py'], stdout=s.PIPE, stderr=s.PIPE) o,e = p.communicate() for line in o.decode().splitlines(): print(line) Next I will reapply the patch that did not work, add a debug print, and see how what did not work Windows (but worked on linux) is different from the above. -- Terry Jan Reedy From rustompmody at gmail.com Thu Jul 3 00:06:52 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 2 Jul 2014 21:06:52 -0700 (PDT) Subject: 1-0.95 In-Reply-To: <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote: > > On the other hand, floating-point numbers are perfect whenever you deal > > with science and measurement. > /head-desk Just as there are even some esteemed members of this list who think that c - a is a meaningful operation where c is speed of light a is speed of an automobile From peter.romfeld.hk at gmail.com Wed Jul 2 23:54:41 2014 From: peter.romfeld.hk at gmail.com (Peter Romfeld) Date: Thu, 03 Jul 2014 11:54:41 +0800 Subject: Image Upload with FalconFramework Message-ID: <53B4D401.8080303@gmail.com> Hi, I am stuck at a simple image upload function, in django i just used: for feature phones: file = request.body iOS with Form: class ImageForm(forms.Form): image = forms.FileField() form = ImageForm(request.POST, request.FILES) file = request.FILES['image'].read() with falcon i tried but not working; req.stream.read() Cheers, Peter From nad at acm.org Thu Jul 3 00:59:46 2014 From: nad at acm.org (Ned Deily) Date: Wed, 02 Jul 2014 21:59:46 -0700 Subject: Is pip being automatically installed for Python 3.4.0? References: Message-ID: In article , Conrad Taylor wrote: > Hi, shouldn't pip be automatically installed for Python 3.4.0 release? I > have read through the release and the PEP 453. Thus, can someone confirm > whether or not this is the case? BTW, I have installed Python 3.4.0 using > MacPorts. Like many other third-party package managers, MacPorts has chosen to continue to distribute pip as a separate item. To install it and the MacPorts Python 3.4: sudo port install py34-pip -- Ned Deily, nad at acm.org From greg.ewing at canterbury.ac.nz Thu Jul 3 00:55:17 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 03 Jul 2014 16:55:17 +1200 Subject: 1-0.95 In-Reply-To: <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> Message-ID: Rustom Mody wrote: > Just as there are even some esteemed members of this list who think > that c - a is a meaningful operation > where > c is speed of light > a is speed of an automobile Indeed, it should be (c - a) / (1 - (c*a)/c**2). Although loss of precision might give you the right answer anyway. :-) -- Greg From rustompmody at gmail.com Thu Jul 3 01:21:07 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 2 Jul 2014 22:21:07 -0700 (PDT) Subject: 1-0.95 In-Reply-To: References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> Message-ID: On Thursday, July 3, 2014 10:25:17 AM UTC+5:30, Gregory Ewing wrote: > Rustom Mody wrote: > > Just as there are even some esteemed members of this list who think > > that c - a is a meaningful operation > > where > > c is speed of light > > a is speed of an automobile > Indeed, it should be (c - a) / (1 - (c*a)/c**2). > Although loss of precision might give you the > right answer anyway. :-) :-) Surprising how unfamiliar familiar equations like the Lorentz transformation look when converted from its usual mathematicerese and put into programmerese I like to think unicode would help. But I find it does not help much: (c-a)/(1 - ca/c?) [And I would have sworn there should be a ? somewhere? Dont remember any of this?] From ian.g.kelly at gmail.com Thu Jul 3 01:50:21 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 2 Jul 2014 23:50:21 -0600 Subject: 1-0.95 In-Reply-To: References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> Message-ID: On Wed, Jul 2, 2014 at 10:55 PM, Gregory Ewing wrote: > Although loss of precision might give you the > right answer anyway. :-) There aren't that many digits in the speed of light. Unless we're talking about a very, very slow-moving automobile. From wxjmfauth at gmail.com Thu Jul 3 01:55:47 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Wed, 2 Jul 2014 22:55:47 -0700 (PDT) Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: References: Message-ID: <407c5120-d163-4465-bea9-6b9cff066578@googlegroups.com> %%%%%%%%% pip and co. Never succeeded to put this to work. If this is the future... From i at introo.me Thu Jul 3 02:17:17 2014 From: i at introo.me (Shiyao Ma) Date: Thu, 3 Jul 2014 14:17:17 +0800 Subject: how can i get the source code of goagent.exe? In-Reply-To: References: Message-ID: Ask on the goagent googlecode? exe is fow win, dig out more on the linux version. I bet it should be delivered with py source in that version. Regards. 2014-07-03 10:20 GMT+08:00 liuerfire Wang : > Hi ???? > the source code is on https://github.com/goagent/goagent > > Hi Terry, > GoAgent, a tool to help cross the GFW, is written by Python not Go. So this > may be not off-topic. :P > > > On Thu, Jul 3, 2014 at 6:40 AM, ???? <1248283536 at qq.com> wrote: >> >> There is a open source project-goagent,when you download it and extract >> it, >> code.google.com/p/goagent/downloads? >> >> in the local diretory, a file named goagent.exe in it. >> >> how can i get the source code of goagent.exe ,not the binary form ,the >> text form. >> >> >> >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Best regards. > /********************************** > google+: +liuerfire twitter: @liuerfire > ??????????????~^_^~ > ***********************************/ > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- ????????????????http://introo.me? From marko at pacujo.net Thu Jul 3 02:51:35 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 03 Jul 2014 09:51:35 +0300 Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87zjgrdjew.fsf@elektro.pacujo.net> Steven D'Aprano : > On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote: >> Steven D'Aprano : >>>> >>> Rational(2).sqrt() * Rational(2).sqrt() == Rational(2) >>>> False >>> Square root of 2 is not a rational number. >> Nobody said it was. > > Your comment can be read as implying it. You stated: > > [quote] > Even "arbitrary-precision" RATIONALS [emphasis added] would > suffer from the same problem > [end quote] > > and then showed an invented example where you squared a NON-RATIONAL. While ?2 is irrational, the hypothetical Rational(2).sqrt() probably would be another "arbitrary-precision" Rational number and thus, necessarily an approximation. That's completely analogous to Decimal(1) / Decimal(3) being an approximation. And the point: when dealing with real numbers on a computer, there's no way to avoid approximations. If an aspiring programmer is dismayed at the imprecision of 0.1, that probably wouldn't be the right moment to talk about Decimal(). > By the way, there's no need to use an invented example. Here is an > actual example: > > py> import math > py> from fractions import Fraction > py> math.sqrt(Fraction(2))**2 > 2.0000000000000004 Sure, although you were invoking "arbitrary-precision" rational numbers, which Fraction() is not. > I'm sorry Marko, have you not being paying attention? Have you ever > done any numeric programming? Your style is consistent and impeccable. > Floating-point is *hard*, not "perfect". It can be both. The point is, regular floating point numbers will likely the optimal choice for your numeric calculation needs. They are compact, fast and readily supported by hardware and numeric software. Switching to Decimal might give you a false sense of security. Marko From breamoreboy at yahoo.co.uk Thu Jul 3 02:54:52 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 03 Jul 2014 07:54:52 +0100 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On 03/07/2014 02:17, Rita wrote: > > On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong > wrote: > > On 2-7-2014 4:04, Rita wrote: > > yes, this helps. But I want to know who uses the module, serpent. > So, when > > I upgrade it or remove it they won't be affected adversely. > > (Please don't top-post, it makes the discussion harder to follow.) > > > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong > > > > wrote: > > > >> On 1-7-2014 12:38, Rita wrote: > >>> i work in a group of developers (15 or so) who are located > globally. I > >>> would like to know what modules everyone is uses if I ever have to > >> upgrade > >>> my python. Is there mechanism which will let me see who is > using what? > >>> > >>> ie, > >>> > >>> tom,matplotlib > >>> bob, pylab > >>> nancy, numpy > >>> nancy, matplotlib > >>> > >>> etc... > >>> > >>> > >> > >> Well, if your group is all using Pip (and perhaps even > virtualenv), you > >> could use pip > >> list. In my case: > >> > >> $ pip list > > [...] > > > Why would the fact that you upgrade or remove a package, affect > another developer in > your group? Are you all using the same machine to develop on, with > one Python installation? > > I think you'll have to tell us some more details about the way you > work together before > we can give a meaningful answer to your question. > > Irmen > > -- > https://mail.python.org/mailman/listinfo/python-list > > we have a shared mount point which has our python install. we have 3 > servers on one part of the campus and 2 in another part. > > I want to find out what packages our user base is using thats the final > goal. I can figure out who is using python by writing a wrapper but not > what module. > > -- > --- Get your facts first, then you can distort them as you please.-- > You can check every users's program for import statements but do you really need to, why not check what's in the site-packages folder for your python install? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Thu Jul 3 03:06:13 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 03 Jul 2014 08:06:13 +0100 Subject: Image Upload with FalconFramework In-Reply-To: <53B4D401.8080303@gmail.com> References: <53B4D401.8080303@gmail.com> Message-ID: On 03/07/2014 04:54, Peter Romfeld wrote: > Hi, > > I am stuck at a simple image upload function, in django i just used: > > for feature phones: > file = request.body > > iOS with Form: > class ImageForm(forms.Form): > image = forms.FileField() What is forms? image is defined at the class level, not the instance level, did you actually mean that? > form = ImageForm(request.POST, request.FILES) > file = request.FILES['image'].read() file has been overwritten. > > with falcon i tried but not working; > req.stream.read() req is undefined here. > > Cheers, > Peter > So please give us your OS and Python versions, the exact code that you've tried to run, how you've tried to run it, what you expected to happen and what actually happened including the complete traceback if any. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From c.candide at laposte.net Thu Jul 3 03:51:39 2014 From: c.candide at laposte.net (candide) Date: Thu, 3 Jul 2014 00:51:39 -0700 (PDT) Subject: TypeError expected in an augmented assignment In-Reply-To: References: Message-ID: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> > >>> seq = [1,2] > > >>> seq.extend((3,4)) OK, this feature is referenced in the Python Library reference here : https://docs.python.org/3.2/library/stdtypes.html#typesseq-mutable not thoroughly referenced but, anyway, referenced. > > >>> seq+= {5, 6} # the order of extending is not determined > > >>> seq > > [1, 2, 3, 4, 5, 6] > > >>> Good and interesting observation. But I can't find out where this feature is referenced in the Language/Library Reference. Because, as my first post explains, augmented assignment performs the binary operation associated to the augmented assignment, cf. https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError. From wolfgang.maier at biologie.uni-freiburg.de Thu Jul 3 04:03:07 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Thu, 03 Jul 2014 10:03:07 +0200 Subject: Success with subprocess communicate on Windows? In-Reply-To: References: Message-ID: <53B50E3B.1040006@biologie.uni-freiburg.de> On 07/03/2014 06:09 AM, Terry Reedy wrote: > > Yes, but what puzzled me is that running > subprocess.check_output(r'pyflakes c:\programs\python34\lib') > in the regular interpreter *does* produce output instead of the error > message. My guess is that it fills up the pipe, so that check_output > starts reading the pipe long before pyflakes exits with status 1. > > Hmm. I tried it again, and I see some but not all of the output I got at > the command line *and* I see the exit status message. So the subprocess > must get some of the output but then stop when it sees the exit status. > Thanks. > For a partial explanation try this: from the command line (again my path is slightly different): pyflakes C:\Python34\lib > stdout.txt this will still give you a few lines of output and these should be the same ones you're seeing from the python interpreter when you're doing: subprocess.check_output(r'pyflakes C:\Python34\lib') ==> pyflakes sends these lines to stderr instead of stdout !! confirmation: subprocess.check_output(r'pyflakes C:\Python34\lib', stderr=subprocess.PIPE) and the output is gone. So the remaining questions are: - why on earth is pyflakes sending these lines (and only these) to stderr ? - what is happening to the stderr output when run in IDLE ? I guess it is caught and suppressed somewhere, but to add to your observations the check_output call doesn't hang on IDLE, but finishes eventually with no output other than the traceback. Best wishes, Wolfgang From rosuav at gmail.com Thu Jul 3 04:36:49 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jul 2014 18:36:49 +1000 Subject: TypeError expected in an augmented assignment In-Reply-To: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> References: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> Message-ID: On Thu, Jul 3, 2014 at 5:51 PM, candide wrote: > Good and interesting observation. But I can't find out where this feature is referenced in the Language/Library Reference. Because, as my first post explains, augmented assignment performs the binary operation associated to the augmented assignment, cf. > > https://docs.python.org/3.2/reference/simple_stmts.html#augmented-assignment-statements > > so seq+= {5, 6} performs seq + {5, 6}, the later raising a TypeError. >From that link: """ An augmented assignment expression like x += 1 can be rewritten as x = x + 1 to achieve a similar, but not exactly equal effect. In the augmented version, x is only evaluated once. Also, when possible, the actual operation is performed in-place, meaning that rather than creating a new object and assigning that to the target, the old object is modified instead. """ The significance here is that the augmented assignment may not necessarily be at all comparable to the non-augmented version, but ought to have *approximately* the same *intention*. There are plenty of situations where the two will differ, eg when there are multiple references to the same object: >>> a = b = [1,2] >>> a += [3] >>> a,b ([1, 2, 3], [1, 2, 3]) >>> a = a + [4] >>> a,b ([1, 2, 3, 4], [1, 2, 3]) In its simplest form, x += 1 <-> x = x + 1, but there are plenty of ways to distinguish them. ChrisA From steve at pearwood.info Thu Jul 3 05:15:59 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 03 Jul 2014 09:15:59 GMT Subject: OT: speeds (physical, not computing) [was Re: 1-0.95] References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <46d1a4dd-8298-4a73-a383-e65cd485fa83@googlegroups.com> Message-ID: <53b51f4e$0$11121$c3e8da3@news.astraweb.com> On Wed, 02 Jul 2014 21:06:52 -0700, Rustom Mody wrote: > On Thursday, July 3, 2014 7:49:30 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 02 Jul 2014 23:00:15 +0300, Marko Rauhamaa wrote: > >> > On the other hand, floating-point numbers are perfect whenever you >> > deal with science and measurement. > >> /head-desk > > > > Just as there are even some esteemed members of this list who think that > c - a is a meaningful operation > where > c is speed of light > a is speed of an automobile > > > You seem to be having some sort of nervous tic. Subtracting two numbers a and c *is* a meaningful operation, even if they are speeds, and even in special relativity. Consider an observer O in an inertial frame of reference. A car x is driving towards the observer at v metres per second, while a photon p travels away from the observer at c m/s: x --> v O p ----------> c According to the observer, the difference in speeds between x and p is just (c - v), the same as in classic mechanics. The technical term for it is "closing speed" (or "opening speed" as the case may be) as seen by O. Note that this is *not* the difference in speeds as observed by x, but I never said it was. You don't have to believe me. You can believe the Physics FAQs, maintained by John Baez: http://math.ucr.edu/home/baez/physics/Relativity/SR/velocity.html The important part is the paragraph titled "How can that be right?" and ending "In this sense velocities add according to ordinary vector addition." As I wanted to confirm my understanding of the situation: https://groups.google.com/forum/#!topic/sci.physics/BqT0p_7tHYg -- Steven From wolfgang.maier at biologie.uni-freiburg.de Thu Jul 3 05:22:44 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Thu, 03 Jul 2014 11:22:44 +0200 Subject: Success with subprocess communicate on Windows? In-Reply-To: <53B50E3B.1040006@biologie.uni-freiburg.de> References: <53B50E3B.1040006@biologie.uni-freiburg.de> Message-ID: <53B520E4.3010809@biologie.uni-freiburg.de> On 07/03/2014 10:03 AM, Wolfgang Maier wrote: > On 07/03/2014 06:09 AM, Terry Reedy wrote: > > - what is happening to the stderr output when run in IDLE ? I guess it > is caught and suppressed somewhere, but to add to your observations the > check_output call doesn't hang on IDLE, but finishes eventually with no > output other than the traceback. stderr output not being displayed in IDLE is mentioned in http://bugs.python.org/issue13582 . From rmorgan466 at gmail.com Thu Jul 3 05:27:23 2014 From: rmorgan466 at gmail.com (Rita) Date: Thu, 3 Jul 2014 05:27:23 -0400 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence wrote: > On 03/07/2014 02:17, Rita wrote: > >> >> On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong > > wrote: >> >> On 2-7-2014 4:04, Rita wrote: >> > yes, this helps. But I want to know who uses the module, serpent. >> So, when >> > I upgrade it or remove it they won't be affected adversely. >> >> (Please don't top-post, it makes the discussion harder to follow.) >> >> > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong >> > >> >> > wrote: >> > >> >> On 1-7-2014 12:38, Rita wrote: >> >>> i work in a group of developers (15 or so) who are located >> globally. I >> >>> would like to know what modules everyone is uses if I ever have >> to >> >> upgrade >> >>> my python. Is there mechanism which will let me see who is >> using what? >> >>> >> >>> ie, >> >>> >> >>> tom,matplotlib >> >>> bob, pylab >> >>> nancy, numpy >> >>> nancy, matplotlib >> >>> >> >>> etc... >> >>> >> >>> >> >> >> >> Well, if your group is all using Pip (and perhaps even >> virtualenv), you >> >> could use pip >> >> list. In my case: >> >> >> >> $ pip list >> >> [...] >> >> >> Why would the fact that you upgrade or remove a package, affect >> another developer in >> your group? Are you all using the same machine to develop on, with >> one Python installation? >> >> I think you'll have to tell us some more details about the way you >> work together before >> we can give a meaningful answer to your question. >> >> Irmen >> >> -- >> https://mail.python.org/mailman/listinfo/python-list >> >> we have a shared mount point which has our python install. we have 3 >> servers on one part of the campus and 2 in another part. >> >> I want to find out what packages our user base is using thats the final >> goal. I can figure out who is using python by writing a wrapper but not >> what module. >> >> -- >> --- Get your facts first, then you can distort them as you please.-- >> >> > You can check every users's program for import statements but do you > really need to, why not check what's in the site-packages folder for your > python install? > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > how can i get frequency of the module usage? thats the end goal. -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From c.candide at laposte.net Thu Jul 3 05:35:01 2014 From: c.candide at laposte.net (candide) Date: Thu, 3 Jul 2014 02:35:01 -0700 (PDT) Subject: TypeError expected in an augmented assignment In-Reply-To: References: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> Message-ID: <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> > >From that link: > > > > """ > > An augmented assignment expression like x += 1 can be rewritten as x = > > x + 1 to achieve a similar, but not exactly equal effect. In the > > augmented version, x is only evaluated once. Also, when possible, the > > actual operation is performed in-place, meaning that rather than > > creating a new object and assigning that to the target, the old object > > is modified instead. > > """ > > > > The significance here is that the augmented assignment may not > > necessarily be at all comparable to the non-augmented version, but > > ought to have *approximately* the same *intention*. This is not my reading. > > of situations where the two will differ, eg when there are multiple > > references to the same object: > > > > >>> a = b = [1,2] > > >>> a += [3] > > >>> a,b > > ([1, 2, 3], [1, 2, 3]) > > >>> a = a + [4] > > >>> a,b > > ([1, 2, 3, 4], [1, 2, 3]) > > OK but this behavior is in conformance with the Reference Manual (cf. your quote above : "when possible, the actual operation is performed in-place"). This is not my point because the doc explictly claims that "an augmented assignment [...] performs the binary operation specific to the type of assignment on the two operands". From steve at pearwood.info Thu Jul 3 05:36:47 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 03 Jul 2014 09:36:47 GMT Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <87zjgrdjew.fsf@elektro.pacujo.net> Message-ID: <53b5242e$0$11121$c3e8da3@news.astraweb.com> On Thu, 03 Jul 2014 09:51:35 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : [...] >> By the way, there's no need to use an invented example. Here is an >> actual example: >> >> py> import math >> py> from fractions import Fraction >> py> math.sqrt(Fraction(2))**2 >> 2.0000000000000004 > > Sure, although you were invoking "arbitrary-precision" rational numbers, > which Fraction() is not. In what way is Fraction not an arbitrary precision rational number? It's a rational number, and it can store numbers to any arbitrary precision you like (up to the limit of RAM) in any base you like. How about the smallest non-zero number representable in base 17 to 13004 significant figures? I can represent that as a Fraction with no difficulty at all: py> x = 1/(Fraction(17)**13004) py> str(x)[:20] + "..." + str(x)[-5:] '1/572497511269282241...23521' And it is calculated *exactly*. Now, I admit that I have misgivings about using the term "precision" when it comes to discussing rational numbers, since the idea of significant figures doesn't really work very well with fraction notation. It's not clear to me how many "significant figures" x above should be described as having. The number of digits in its decimal expansion perhaps? But you started using the term, not me, so I'm just following your lead. If you don't think Fraction counts as "arbitrary precision rational number", what do you think does? [...] >> Floating-point is *hard*, not "perfect". > > It can be both. "Perfect" requires that it be flawless. It certainly is not flawless. As I have repeatedly stated, there are mathematical properties which floating point numbers do not obey. Given that they are supposed to model real numbers, the fact that they do not obey the mathematical laws applicable to real numbers is a pretty big flaw. > The point is, regular floating point numbers will likely > the optimal choice for your numeric calculation needs. They are compact, > fast and readily supported by hardware and numeric software. Switching > to Decimal might give you a false sense of security. Ah, now this is a much more reasonable thing to say. Why didn't you say so in the first place? :-) -- Steven From sangeeth.saravanaraj at gmail.com Thu Jul 3 06:15:38 2014 From: sangeeth.saravanaraj at gmail.com (Sangeeth Saravanaraj) Date: Thu, 3 Jul 2014 15:45:38 +0530 Subject: threading.Condition.wait() is not catching SIGTERM Message-ID: <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B@gmail.com> Hi All, I have the following code which when executed waits to be interrupted by SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a threading.Condition() and acquires() it! The program then registers the signal handlers where notify() and release() is called when the above mentioned signals are received. After registering the signal handlers, it calls wait() on the condition variable and block. When I tried to stop the program with Ctrl-C, its did not respond. IOW, the _signal_handler() method did not get called. # start from signal import signal, SIGINT, SIGTERM, SIGQUIT from threading import Condition class A: def __init__(self): self._termination_signal = Condition() self._termination_signal.acquire(blocking=0) def _signal_handler(self, signum, frame): print "Received terminate request - signal = {0}".format(signum) del frame self._termination_signal.notify() self._termination_signal.release() return def register_and_wait(self): signal(SIGINT, self._signal_handler) signal(SIGTERM, self._signal_handler) signal(SIGQUIT, self._signal_handler) print "Waiting to be interrupted!" self._termination_signal.wait() # control blocks here! print "Notified!!" def main(): a = A() a.register_and_wait() if __name__ == "__main__": main() # end What am I doing wrong?! Thank you, Sangeeth -------------- next part -------------- An HTML attachment was scrubbed... URL: From roy at panix.com Thu Jul 3 06:19:00 2014 From: roy at panix.com (Roy Smith) Date: Thu, 03 Jul 2014 06:19:00 -0400 Subject: threading.Condition.wait() is not catching SIGTERM References: Message-ID: In article , Sangeeth Saravanaraj wrote: > Hi All, > > I have the following code which when executed waits to be interrupted by > SIGINT, SIGTERM or SIGQUIT. We need more information. What version of Python are you using? And, what operating system is this running on? From sangeeth.saravanaraj at gmail.com Thu Jul 3 06:27:45 2014 From: sangeeth.saravanaraj at gmail.com (Sangeeth Saravanaraj) Date: Thu, 3 Jul 2014 15:57:45 +0530 Subject: threading.Condition.wait() is not catching SIGTERM In-Reply-To: References: Message-ID: <00F58FB9-3C75-4DE5-8B9F-4ADB7B29EFE4@gmail.com> On 03-Jul-2014, at 3:49 pm, Roy Smith wrote: > In article , > Sangeeth Saravanaraj wrote: > >> Hi All, >> >> I have the following code which when executed waits to be interrupted by >> SIGINT, SIGTERM or SIGQUIT. > > We need more information. What version of Python are you using? And, > what operating system is this running on? I am using Python 2.7.7 and running this code on MacOS Darwin Kernel 13.2.0 But does the behavior of threading.Condition.wait() depends on operating system?! > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Thu Jul 3 06:33:48 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jul 2014 20:33:48 +1000 Subject: threading.Condition.wait() is not catching SIGTERM In-Reply-To: <00F58FB9-3C75-4DE5-8B9F-4ADB7B29EFE4@gmail.com> References: <00F58FB9-3C75-4DE5-8B9F-4ADB7B29EFE4@gmail.com> Message-ID: On Thu, Jul 3, 2014 at 8:27 PM, Sangeeth Saravanaraj wrote: > But does the behavior of threading.Condition.wait() depends on operating system?! The behaviour of signals certainly does - there's a huge difference between Windows and POSIX, and there are lesser differences between Linux and Mac OS, and so on. It's just safest to say exactly what platform, in case it matters. ChrisA From marko at pacujo.net Thu Jul 3 07:17:34 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 03 Jul 2014 14:17:34 +0300 Subject: 1-0.95 References: <53b424d7$0$29985$c3e8da3$5496439d@news.astraweb.com> <8761jflms2.fsf@elektro.pacujo.net> <53b4509a$0$29985$c3e8da3$5496439d@news.astraweb.com> <878uobpm40.fsf@elektro.pacujo.net> <53b4bdb2$0$29985$c3e8da3$5496439d@news.astraweb.com> <87zjgrdjew.fsf@elektro.pacujo.net> <53b5242e$0$11121$c3e8da3@news.astraweb.com> Message-ID: <87d2dmitdd.fsf@elektro.pacujo.net> Steven D'Aprano : > If you don't think Fraction counts as "arbitrary precision rational > number", what do you think does? I was assuming you were referring to an idealized datatype. Fraction() doesn't have a square root method. Let's make one: def newton(x, n): guess = Fraction(1) for i in range(n): guess = (guess + x / guess) / 2 return guess >>> newton(Fraction(2), 3) Fraction(577, 408) >>> newton(Fraction(2), 8) Fraction(489266466344238819545868088398566945584921822586685371455477\ 00898547222910968507268117381704646657, 345963636159190997653185453890148615173898600719883426481871047662465\ 65694525469768325292176831232) >>> newton(Fraction(2), 18) ... keeps going and going and going ... Point being, if you have trouble with floats, you will likely have it with Decimal(), Fraction(), super-duper Rational(), Algebraic(), Expressible(), you name it. You'll just have to develop an understanding of numeric computation. BTW, the same thing applies to integers, also. While Python has abstracted out many of the 2's-complement arithmetic details, the bits shine through. >> The point is, regular floating point numbers will likely the optimal >> choice for your numeric calculation needs. They are compact, fast and >> readily supported by hardware and numeric software. Switching to >> Decimal might give you a false sense of security. > > Ah, now this is a much more reasonable thing to say. Why didn't you > say so in the first place? :-) That's all I've been saying all along. Marko From breamoreboy at yahoo.co.uk Thu Jul 3 08:36:59 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 03 Jul 2014 13:36:59 +0100 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On 03/07/2014 10:27, Rita wrote: > > > > On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence > wrote: > > On 03/07/2014 02:17, Rita wrote: > > > On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong > > __>> wrote: > > On 2-7-2014 4:04, Rita wrote: > > yes, this helps. But I want to know who uses the module, > serpent. > So, when > > I upgrade it or remove it they won't be affected adversely. > > (Please don't top-post, it makes the discussion harder to > follow.) > > > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong > > __>> > > > wrote: > > > >> On 1-7-2014 12:38, Rita wrote: > >>> i work in a group of developers (15 or so) who are > located > globally. I > >>> would like to know what modules everyone is uses if I > ever have to > >> upgrade > >>> my python. Is there mechanism which will let me see who is > using what? > >>> > >>> ie, > >>> > >>> tom,matplotlib > >>> bob, pylab > >>> nancy, numpy > >>> nancy, matplotlib > >>> > >>> etc... > >>> > >>> > >> > >> Well, if your group is all using Pip (and perhaps even > virtualenv), you > >> could use pip > >> list. In my case: > >> > >> $ pip list > > [...] > > > Why would the fact that you upgrade or remove a package, affect > another developer in > your group? Are you all using the same machine to develop > on, with > one Python installation? > > I think you'll have to tell us some more details about the > way you > work together before > we can give a meaningful answer to your question. > > Irmen > > -- > https://mail.python.org/__mailman/listinfo/python-list > > > we have a shared mount point which has our python install. we have 3 > servers on one part of the campus and 2 in another part. > > I want to find out what packages our user base is using thats > the final > goal. I can figure out who is using python by writing a wrapper > but not > what module. > > -- > --- Get your facts first, then you can distort them as you please.-- > > > You can check every users's program for import statements but do you > really need to, why not check what's in the site-packages folder for > your python install? > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > how can i get frequency of the module usage? thats the end goal. > > -- > --- Get your facts first, then you can distort them as you please.-- > > Count the number of imports or count the times a given program gets run for the number of imports depending on what you mean. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Thu Jul 3 08:43:23 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 03 Jul 2014 13:43:23 +0100 Subject: TypeError expected in an augmented assignment In-Reply-To: <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> References: <55f74a23-95ea-4be1-950d-e57e645dab1a@googlegroups.com> <6ed679b1-c6e1-408e-8167-476b169fa2eb@googlegroups.com> Message-ID: On 03/07/2014 10:35, candide wrote: > > >> >From that link: >> >> >> >> """ >> >> An augmented assignment expression like x += 1 can be rewritten as x = >> >> x + 1 to achieve a similar, but not exactly equal effect. In the >> >> augmented version, x is only evaluated once. Also, when possible, the >> >> actual operation is performed in-place, meaning that rather than >> >> creating a new object and assigning that to the target, the old object >> >> is modified instead. >> >> """ >> >> >> >> The significance here is that the augmented assignment may not >> >> necessarily be at all comparable to the non-augmented version, but >> >> ought to have *approximately* the same *intention*. > > > This is not my reading. > > > > >> >> of situations where the two will differ, eg when there are multiple >> >> references to the same object: >> >> >> >>>>> a = b = [1,2] >> >>>>> a += [3] >> >>>>> a,b >> >> ([1, 2, 3], [1, 2, 3]) >> >>>>> a = a + [4] >> >>>>> a,b >> >> ([1, 2, 3, 4], [1, 2, 3]) >> >> > > OK but this behavior is in conformance with the Reference Manual (cf. your quote above : "when possible, the actual operation is performed in-place"). This is not my point because the doc explictly claims that "an augmented assignment [...] performs the binary operation specific to the type of assignment on the two operands". > To get the wording changed to satisfy yourself, either raise an issue on the bug tracker at bugs.python.org and attach a patch file, or send an email with suggested wording to docs at python.org. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From kjakupak at gmail.com Thu Jul 3 08:51:45 2014 From: kjakupak at gmail.com (kjakupak at gmail.com) Date: Thu, 3 Jul 2014 05:51:45 -0700 (PDT) Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > > > If you want 'between' to be an instance method of the MyTime class, it > > needs 'self' as well as the 2 arguments 't1' and 't2'. > > > > You can then compare the hours, minutes and seconds of self against > > those of t1 and t2: > > > > def between(self, t1, t2): > > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, > > self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) > > <= (t2.hours, t2.minutes, t2.seconds) > > > > That could be shortened further using chained comparisons. > > > > Note that the code assumes that the times t1 and t2 are ordered, i.e. > > that time t1 is not later/greater than time t2. So I've now gotten this: class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs if self.seconds >= 60: self.minutes += self.seconds // 60 self.seconds = self.seconds % 60 if self.minutes >= 60: self.hours += self.minutes // 60 self.minutes = self.minutes % 60 if self.hours >= 24: self.hours = self.hours % 24 def get_sec(self): return (self.hours * 60 + self.minutes) * 60 + self.seconds def __str__(self): return "{:02d}:{:02d}:{:02d}".\ format(self.hours, self.minutes, self.seconds) def between(self, t1, t2): return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= (t2.hours, t2.minutes, t2.seconds) t1 = MyTime(9, 59, 59) print("t1 =", t1) t2 = MyTime(10, 0, 1) print("t2 =", t2) t3 = MyTime(10, 0, 0) print("t3 =", t3) print("between(t2, t3, t1) =", between(t2, t3, t1)) print("between(t1, t3, t2) =", between(t1, t3, t2)) print("between(t3, t1, t2) =", between(t3, t1, t2)) print("between(t1, t2, t3) =", between(t1, t2, t3)) Am I on the right track or? Not sure where to go from here From rosuav at gmail.com Thu Jul 3 09:01:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jul 2014 23:01:09 +1000 Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: On Thu, Jul 3, 2014 at 10:51 PM, wrote: > So I've now gotten this: > class MyTime: > def between(self, t1, t2): > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= (t2.hours, t2.minutes, t2.seconds) > print("between(t2, t3, t1) =", between(t2, t3, t1)) And what happens when you run this code? A NameError, I would expect. Do you understand how to define and call methods? ChrisA From kjakupak at gmail.com Thu Jul 3 09:08:39 2014 From: kjakupak at gmail.com (kjakupak at gmail.com) Date: Thu, 3 Jul 2014 06:08:39 -0700 (PDT) Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: <51a84c60-f1c0-4a30-94de-e047f1b553bc@googlegroups.com> On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote: > > > > And what happens when you run this code? A NameError, I would expect. > > Do you understand how to define and call methods? > > > > ChrisA Altered the code. But yes a nameerror came up class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs if self.seconds >= 60: self.minutes += self.seconds // 60 self.seconds = self.seconds % 60 if self.minutes >= 60: self.hours += self.minutes // 60 self.minutes = self.minutes % 60 if self.hours >= 24: self.hours = self.hours % 24 def get_sec(self): return (self.hours * 60 + self.minutes) * 60 + self.seconds def __str__(self): return "{:02d}:{:02d}:{:02d}".\ format(self.hours, self.minutes, self.seconds) def between(self, t1, t2): return (t1.get_sec() <= (self.get_sec()) and (self.get_sec()) <= (t2.get_sec()) s = MyTime() t1 = s(9, 59, 59) print("t1 =", t1) t2 = s(10, 0, 1) print("t2 =", t2) t3 = s(10, 0, 0) print("t3 =", t3) print("between(t2, t3, t1) =", s.between(t2, t3, t1)) print("between(t1, t3, t2) =", s.between(t1, t3, t2)) print("between(t3, t1, t2) =", s.between(t3, t1, t2)) From python at mrabarnett.plus.com Thu Jul 3 09:11:49 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 03 Jul 2014 14:11:49 +0100 Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: <53B55695.7050500@mrabarnett.plus.com> On 2014-07-03 13:51, kjakupak at gmail.com wrote: > On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: >> > >> >> If you want 'between' to be an instance method of the MyTime class, it >> >> needs 'self' as well as the 2 arguments 't1' and 't2'. >> >> >> >> You can then compare the hours, minutes and seconds of self against >> >> those of t1 and t2: >> >> >> >> def between(self, t1, t2): >> >> return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, >> >> self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) >> >> <= (t2.hours, t2.minutes, t2.seconds) >> >> >> >> That could be shortened further using chained comparisons. >> >> >> >> Note that the code assumes that the times t1 and t2 are ordered, i.e. >> >> that time t1 is not later/greater than time t2. > > So I've now gotten this: > class MyTime: > > def __init__(self, hrs=0, mins=0, secs=0): > self.hours = hrs > self.minutes = mins > self.seconds = secs > > if self.seconds >= 60: > self.minutes += self.seconds // 60 > self.seconds = self.seconds % 60 > > if self.minutes >= 60: > self.hours += self.minutes // 60 > self.minutes = self.minutes % 60 > > if self.hours >= 24: > self.hours = self.hours % 24 > > def get_sec(self): > return (self.hours * 60 + self.minutes) * 60 + self.seconds > > def __str__(self): > return "{:02d}:{:02d}:{:02d}".\ > format(self.hours, self.minutes, self.seconds) > > def between(self, t1, t2): > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= (t2.hours, t2.minutes, t2.seconds) > > > t1 = MyTime(9, 59, 59) > print("t1 =", t1) > > t2 = MyTime(10, 0, 1) > print("t2 =", t2) > > t3 = MyTime(10, 0, 0) > print("t3 =", t3) > > print("between(t2, t3, t1) =", between(t2, t3, t1)) > print("between(t1, t3, t2) =", between(t1, t3, t2)) > print("between(t3, t1, t2) =", between(t3, t1, t2)) > print("between(t1, t2, t3) =", between(t1, t2, t3)) > > Am I on the right track or? Not sure where to go from here > You need to decide whether you want 'between' to be a method of the MyTime class or a separate function. In the above code it's defined as a method, so you can say: t2.between(t3, t1) which means "is t2 between t3 and t1?". That would return False because t3 is greater than t1, but: t2.between(t1, t3) would return True. (I _did_ say that it assumes that the times are ordered.) BTW, gmail is messing up your messages. This will tell you how to fix it: https://wiki.python.org/moin/GoogleGroupsPython From rosuav at gmail.com Thu Jul 3 09:17:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 3 Jul 2014 23:17:44 +1000 Subject: OOP with MyTime In-Reply-To: <51a84c60-f1c0-4a30-94de-e047f1b553bc@googlegroups.com> References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> <51a84c60-f1c0-4a30-94de-e047f1b553bc@googlegroups.com> Message-ID: On Thu, Jul 3, 2014 at 11:08 PM, wrote: > Altered the code. But yes a nameerror came up When that sort of thing happens, you have three basic approaches to solving the problem. 1) Read the traceback, look at the line of code it points to, and see if you can figure out what it means. 2) Post here with the full traceback so we have a chance of being able to help you 3) Play 20 questions with us, while making the gathering of information as hard as pulling teeth. Suggestion: The third option is the least effective. :) ChrisA From kjakupak at gmail.com Thu Jul 3 11:21:29 2014 From: kjakupak at gmail.com (kjakupak at gmail.com) Date: Thu, 3 Jul 2014 08:21:29 -0700 (PDT) Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: > On 2014-07-03 13:51, kjakupak at gmail.com wrote: > > > On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: > > >> > > > >> > > >> If you want 'between' to be an instance method of the MyTime class, it > > >> > > >> needs 'self' as well as the 2 arguments 't1' and 't2'. > > >> > > >> > > >> > > >> You can then compare the hours, minutes and seconds of self against > > >> > > >> those of t1 and t2: > > >> > > >> > > >> > > >> def between(self, t1, t2): > > >> > > >> return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, > > >> > > >> self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) > > >> > > >> <= (t2.hours, t2.minutes, t2.seconds) > > >> > > >> > > >> > > >> That could be shortened further using chained comparisons. > > >> > > >> > > >> > > >> Note that the code assumes that the times t1 and t2 are ordered, i.e. > > >> > > >> that time t1 is not later/greater than time t2. > > > > > > So I've now gotten this: > > > class MyTime: > > > > > > def __init__(self, hrs=0, mins=0, secs=0): > > > self.hours = hrs > > > self.minutes = mins > > > self.seconds = secs > > > > > > if self.seconds >= 60: > > > self.minutes += self.seconds // 60 > > > self.seconds = self.seconds % 60 > > > > > > if self.minutes >= 60: > > > self.hours += self.minutes // 60 > > > self.minutes = self.minutes % 60 > > > > > > if self.hours >= 24: > > > self.hours = self.hours % 24 > > > > > > def get_sec(self): > > > return (self.hours * 60 + self.minutes) * 60 + self.seconds > > > > > > def __str__(self): > > > return "{:02d}:{:02d}:{:02d}".\ > > > format(self.hours, self.minutes, self.seconds) > > > > > > def between(self, t1, t2): > > > return (t1.hours, t1.minutes, t1.seconds) <= (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) <= (t2.hours, t2.minutes, t2.seconds) > > > > > > > > > t1 = MyTime(9, 59, 59) > > > print("t1 =", t1) > > > > > > t2 = MyTime(10, 0, 1) > > > print("t2 =", t2) > > > > > > t3 = MyTime(10, 0, 0) > > > print("t3 =", t3) > > > > > > print("between(t2, t3, t1) =", between(t2, t3, t1)) > > > print("between(t1, t3, t2) =", between(t1, t3, t2)) > > > print("between(t3, t1, t2) =", between(t3, t1, t2)) > > > print("between(t1, t2, t3) =", between(t1, t2, t3)) > > > > > > Am I on the right track or? Not sure where to go from here > > > > > You need to decide whether you want 'between' to be a method of the > > MyTime class or a separate function. > > > > In the above code it's defined as a method, so you can say: > > > > t2.between(t3, t1) > > > > which means "is t2 between t3 and t1?". > > > > That would return False because t3 is greater than t1, but: > > > > t2.between(t1, t3) > > > > would return True. > > > > (I _did_ say that it assumes that the times are ordered.) > > > > BTW, gmail is messing up your messages. This will tell you how to fix > > it: > > > > https://wiki.python.org/moin/GoogleGroupsPython I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why? t1 = (9, 59, 59) print("t1 =", t1) t2 = (10, 0, 1) print("t2 =", t2) t3 = (10, 0, 0) print("t3 =", t3) print("between(t2, t3, t1) =", t2.between(t3, t1)) From rosuav at gmail.com Thu Jul 3 11:35:07 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jul 2014 01:35:07 +1000 Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: On Fri, Jul 4, 2014 at 1:21 AM, wrote: > I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why? > > t1 = (9, 59, 59) Two points. Firstly, as I said before, posting the entire exception helps us enormously. Secondly, with most computerized parsers, the file is processed top-down, left-to-right, so it's possible for a syntax error to be discovered a bit after where it actually happens - but not before. So when you get parsing errors, check the immediately preceding line; sometimes it's there. Since you haven't shown us that line, we have no idea what's happening. Showing us the code below the highlighted error line is of no value; showing us the code before that line is helpful. Also: Please don't use Google Groups, or if you must, please clean up its messes. ChrisA From breamoreboy at yahoo.co.uk Thu Jul 3 12:23:47 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 03 Jul 2014 17:23:47 +0100 Subject: OOP with MyTime In-Reply-To: References: <7020a5d8-96a9-4fa4-8e69-4c7593dedee3@googlegroups.com> Message-ID: On 03/07/2014 16:21, kjakupak at gmail.com wrote: > On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: I'm pleased to see that you have answers. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From tshepard at rcsreg.com Thu Jul 3 13:31:04 2014 From: tshepard at rcsreg.com (Tobiah) Date: Thu, 03 Jul 2014 10:31:04 -0700 Subject: PEP8 and 4 spaces Message-ID: <53B59358.2040404@tobiah.org> Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer tabs. Boss want's us to unify. The sole thing you get with spaces as far as I can tell, is that someone loading the code into Notepad will still see a 4 character indent. That may be true, but that same person is going to have a difficult time editing the code. Anyway, I gave up the 80 char line length long ago, having little feeling for some dolt on a Weiss terminal that for some reason needs to edit my code. I feel rather the same about the spaces and tabs, given that most people seem to be using editors these days that are configurable to show tabs a four characters. Any evidence out there that this part of PEP8 is becoming more optional or even obsolete, as I've heard others say about the 80 char line length? Just need ammo for when the hammer of code unification comes down. Thanks, Tobiah From rosuav at gmail.com Thu Jul 3 13:38:27 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jul 2014 03:38:27 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. Boss want's us to > unify. 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules. 2) Tabs let different people display the indents at different widths. You want it to look like four spaces? No problem. You think it looks better at eight? Fine, set your display to eight. Easy. 3) Perhaps most importantly: You don't have to unify. Let your source control system do the work for you. In git, that's the smudge/clean filters and gitattributes; I don't know the mechanics in hg, but I'm sure it'll exist; in other systems, you might have to rig something up, or dig through the docs. But you should be able to settle on one thing in source control and let everyone check out files in whatever way they like. Personally, I like, use, and recommend, tabs - but the next best thing to tabs is a consistent number of spaces (preferably four). But if you can't make your tools handle the difference, you're going to be putting unnecessary strains on the humans. Let the humans work with whatever they prefer. ChrisA From roy at panix.com Thu Jul 3 13:46:55 2014 From: roy at panix.com (Roy Smith) Date: Thu, 03 Jul 2014 13:46:55 -0400 Subject: PEP8 and 4 spaces References: Message-ID: In article , Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. > [...] > Just need ammo for when the hammer of code > unification comes down. There are so many battles to fight that are worth fighting. This isn't one of them. Just go with pep-8 and move on to solving real problems. From __peter__ at web.de Thu Jul 3 13:57:37 2014 From: __peter__ at web.de (Peter Otten) Date: Thu, 03 Jul 2014 19:57:37 +0200 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. Boss want's us to > unify. The sole thing you get with spaces as > far as I can tell, is that someone loading the > code into Notepad will still see a 4 character > indent. That may be true, but that same person > is going to have a difficult time editing the > code. > > Anyway, I gave up the 80 char line length long > ago, having little feeling for some dolt on > a Weiss terminal that for some reason needs to > edit my code. I feel rather the same about the > spaces and tabs, given that most people seem to > be using editors these days that are configurable > to show tabs a four characters. > > Any evidence out there that this part of PEP8 is becoming > more optional or even obsolete, as I've heard others > say about the 80 char line length? > > Just need ammo for when the hammer of code > unification comes down. Indentation: more important than what convention is chosen is that a convention is chosen. Relax and follow your collegue's example. As to the line length: how do you manage to exceed the 80-char limit? Deep nesting, long variable names, complex expressions? All of these often make it worthwhile refactoring the code even with a lot of horizonal space left blank on the monitor. Also: you can probably come up with five aspects that affect the quality of your company's code more than the above superficial points and that are hard to fix. So pick your fights and attack the most relevant issue. From tshepard at rcsreg.com Thu Jul 3 14:02:04 2014 From: tshepard at rcsreg.com (Toby Shepard) Date: Thu, 03 Jul 2014 11:02:04 -0700 Subject: PEP8 and 4 spaces In-Reply-To: <20140703124646.7acb8123@bigbox.christie.dr> References: <53B59358.2040404@tobiah.org> <20140703124646.7acb8123@bigbox.christie.dr> Message-ID: <53B59A9C.7080006@rcsreg.com> On 07/03/2014 10:46 AM, Tim Chase wrote: >> Any evidence out there that this part of PEP8 is becoming >> more optional or even obsolete, as I've heard others >> say about the 80 char line length? >> >> Just need ammo for when the hammer of code >> unification comes down. > > I'm not sure you'll get a whole lot of "PEP8 is optional or > obsolete", though some may protest the 80-char suggestion. > > While I prefer tabs for similar reasons you present (I can set them > to display at whatever width is comfortable), I have Vim configured > to expand tabs into spaces so that my code conforms to standards. > > If you're really picky about it, just create hooks in your VCS (you > ARE using revision control, right?) that turn > $STANDARD_NUMBER_OF_SPACES into a tabs at checkout, and then revert > tabs back to that number of spaces pre-commit. For git, this SO > post covers it: > > http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs > Very interesting. Yes, we're using Git. Thanks for the suggestion. Tobiah From pmiscml at gmail.com Thu Jul 3 14:07:28 2014 From: pmiscml at gmail.com (Paul Sokolovsky) Date: Thu, 3 Jul 2014 21:07:28 +0300 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> Message-ID: <20140703210728.28d69d91@x34f> Hello, On Fri, 4 Jul 2014 03:38:27 +1000 Chris Angelico wrote: > On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: > > Coworker takes PEP8 as gospel and uses 4 spaces > > to indent. I prefer tabs. Boss want's us to > > unify. > > 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast > rules. > 2) Tabs let different people display the indents at different > widths. That's exactly the problem with tabs - whatever you think your code looks like with tabs, other people will see quite different picture. Also, most people are not interested in doing mumbo-jumbo with tabs settings, and have them set to standard 8-char tabs. So, any python code which uses only tabs for indentation automatically violates 4-space convention (and mixing tabs and spaces is nowadays prohibited in Python). Summing up: if you care about other human beings, use spaces. If you don't care about other human beings, you may use tabs, but other human beings surely will take how you treat them into account ;-). -- Best regards, Paul mailto:pmiscml at gmail.com From invalid at invalid.invalid Thu Jul 3 15:02:48 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Thu, 3 Jul 2014 19:02:48 +0000 (UTC) Subject: PEP8 and 4 spaces References: Message-ID: On 2014-07-03, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer > tabs. Boss want's us to unify. The sole thing you get with spaces > as far as I can tell, is that someone loading the code into Notepad > will still see a 4 character indent. Or any editor at all. > That may be true, but that same person is going to have a difficult > time editing the code. That's true with Notepad, but with dozens of other programming editors, code indented with spaces will read and edit prefectly. Not so for tab-indented code. > Anyway, I gave up the 80 char line length long ago, having little > feeling for some dolt Same to you. > on a Weiss terminal that for some reason needs to edit my code. I > feel rather the same about the spaces and tabs, given that most > people seem to be using editors these days that are configurable to > show tabs a four characters. > > Any evidence out there that this part of PEP8 is becoming more > optional or even obsolete, as I've heard others say about the 80 char > line length? > > Just need ammo for when the hammer of code unification comes down. Just do the right thing and configure your editor to indent with spaces. -- Grant Edwards grant.b.edwards Yow! Am I SHOPLIFTING? at gmail.com From python.list at tim.thechases.com Thu Jul 3 13:46:46 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 3 Jul 2014 12:46:46 -0500 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: <20140703124646.7acb8123@bigbox.christie.dr> > Any evidence out there that this part of PEP8 is becoming > more optional or even obsolete, as I've heard others > say about the 80 char line length? > > Just need ammo for when the hammer of code > unification comes down. I'm not sure you'll get a whole lot of "PEP8 is optional or obsolete", though some may protest the 80-char suggestion. While I prefer tabs for similar reasons you present (I can set them to display at whatever width is comfortable), I have Vim configured to expand tabs into spaces so that my code conforms to standards. If you're really picky about it, just create hooks in your VCS (you ARE using revision control, right?) that turn $STANDARD_NUMBER_OF_SPACES into a tabs at checkout, and then revert tabs back to that number of spaces pre-commit. For git, this SO post covers it: http://stackoverflow.com/questions/2316677/can-git-automatically-switch-between-spaces-and-tabs -tkc From wxjmfauth at gmail.com Thu Jul 3 15:22:29 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Thu, 3 Jul 2014 12:22:29 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> Message-ID: <1e8adb15-5cb3-44be-8668-453feb9915c8@googlegroups.com> Le jeudi 3 juillet 2014 20:07:28 UTC+2, Paul Sokolovsky a ?crit?: > Hello, > > > > On Fri, 4 Jul 2014 03:38:27 +1000 > > Chris Angelico wrote: > > > > > On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: > > > > Coworker takes PEP8 as gospel and uses 4 spaces > > > > to indent. I prefer tabs. Boss want's us to > > > > unify. > > > > > > 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast > > > rules. > > > 2) Tabs let different people display the indents at different > > > widths. > > > > That's exactly the problem with tabs - whatever you think your code > > looks like with tabs, other people will see quite different picture. > > > > Also, most people are not interested in doing mumbo-jumbo with tabs > > settings, and have them set to standard 8-char tabs. So, any python > > code which uses only tabs for indentation automatically violates > > 4-space convention (and mixing tabs and spaces is nowadays prohibited > > in Python). > > > > Summing up: if you care about other human beings, use spaces. If you > > don't care about other human beings, you may use tabs, but other human > > beings surely will take how you treat them into account ;-). > > > > > > -- > > Best regards, > > Paul mailto:pmiscml at gmail.com "Tabulation", the key, the code point, the tab stop have been created for humans beeings. Today, at Unicode time, there are only naive ascii people, who think a code point/space can be replaced by a set of characters. jmf From python.list at tim.thechases.com Thu Jul 3 15:40:19 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 3 Jul 2014 14:40:19 -0500 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: <20140703144019.586bf46c@bigbox.christie.dr> On 2014-07-03 19:02, Grant Edwards wrote: > > That may be true, but that same person is going to have a > > difficult time editing the code. > > That's true with Notepad, but with dozens of other programming > editors, code indented with spaces will read and edit prefectly. > Not so for tab-indented code. A broken editor isn't the world's best argument. If I used an editor that changed my line-endings, randomly altered arbitrary characters, or tried to compress multiple spaces into one, I'd complain that the editor was broken. If a file has tab characters and my editor doesn't let me properly deal with characters, then THE EDITOR IS BROKEN. That said, even though I'm "-0" on "use 4 spaces rather than tabs", I conform to the standard to reduce interop headache even if I'd rather use tabs. -tkc From nad at acm.org Thu Jul 3 16:13:57 2014 From: nad at acm.org (Ned Deily) Date: Thu, 03 Jul 2014 13:13:57 -0700 Subject: threading.Condition.wait() is not catching SIGTERM References: <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B@gmail.com> Message-ID: In article <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B at gmail.com>, > I have the following code which when executed waits to be interrupted by > SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a > threading.Condition() and acquires() it! The program then registers the > signal handlers where notify() and release() is called when the above > mentioned signals are received. After registering the signal handlers, it > calls wait() on the condition variable and block. > > When I tried to stop the program with Ctrl-C, its did not respond. IOW, the > _signal_handler() method did not get called. I'm not sure what you are trying to do but your test case seems flawed. threading.Condition is designed to be used with multiple threads but your test doesn't actually use threads. If you run your test with a reasonably current Python 3 (after changing print to print()), you can see that it fails (and why it fails) when interrupting with Ctrl-C: Waiting to be interrupted! ^CReceived terminate request - signal = 2 Traceback (most recent call last): File "b.py", line 30, in main() File "b.py", line 27, in main a.register_and_wait() File "b.py", line 22, in register_and_wait self._termination_signal.wait() # control blocks here! File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin g.py", line 289, in wait waiter.acquire() File "b.py", line 13, in _signal_handler self._termination_signal.notify() File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin g.py", line 339, in notify raise RuntimeError("cannot notify on un-acquired lock") RuntimeError: cannot notify on un-acquired lock After a quick glance, I'm not sure why Python 2.7 is behaving differently, e.g. not raising an error, since both versions of Condition.notify have the same test so the difference is elsewhere. Feel free to open an issue for not catching the error in 2.7 but you should rethink what you are trying to do here. -- Ned Deily, nad at acm.org From tshepard at rcsreg.com Thu Jul 3 16:21:51 2014 From: tshepard at rcsreg.com (Toby Shepard) Date: Thu, 03 Jul 2014 13:21:51 -0700 Subject: PEP8 and 4 spaces In-Reply-To: <8871383c-4961-4004-83f1-949cabf16ff9@email.android.com> References: <53B59358.2040404@tobiah.org> <8871383c-4961-4004-83f1-949cabf16ff9@email.android.com> Message-ID: <53B5BB5F.8010502@rcsreg.com> On 07/03/2014 12:44 PM, Simon Ward wrote: > > > On 3 July 2014 18:31:04 BST, Tobiah wrote: >> Coworker takes PEP8 as gospel and uses 4 spaces to indent. I >> prefer tabs. Boss want's us to unify. > > This isn't worth arguing about. How point of view changes things. > >> Anyway, I gave up the 80 char line length long ago, having little >> feeling for some dolt on a Weiss terminal that for some reason >> needs to edit my code. > > Putting the code factoring considerations aside, because others have > already mentioned them and I'm sure others will, there are some other > practical reasons for limiting line width: All that is fine, and makes great sense. I generally write short lines. I know the tricks for splitting otherwise long lines into multiple readable lines. I'm not advocating that we use semicolons and always go past 80 characters. I'm just saying that once in a while it makes sense to me to do it, and I don't lose sleep when it happens. >> I feel rather the same about the spaces and tabs, given that most >> people seem to be using editors these days that are configurable to >> show tabs a four characters. > > Conversely, those same editors can probably automatically indent and > unindent a configurable amount of spaces. If you don't use such an > editor, and you really can't tolerate the different style, you can > use another tool to reindent your code. It works both ways. I'm using Vim, and it will handle the spaces and give a tab-like experience - not quite as good, but good enough to live with. Either of us could give in. The boss likes tabs, as I do. The coworker really only has PEP8 to point to. There is really nothing good about the space way, other than as I said, Notepad users will see four space indents. Most other users can configure the tabstop as they like *if* tabs are being used. The Notepad users will get by just fine. It could fall either way. I was just trying to nudge it toward mine. Tobiah From roy at panix.com Thu Jul 3 16:43:13 2014 From: roy at panix.com (Roy Smith) Date: Thu, 03 Jul 2014 16:43:13 -0400 Subject: threading.Condition.wait() is not catching SIGTERM References: <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B@gmail.com> Message-ID: In article , Ned Deily wrote: > In article <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B at gmail.com>, > > I have the following code which when executed waits to be interrupted by > > SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a > > threading.Condition() and acquires() it! The program then registers the > > signal handlers where notify() and release() is called when the above > > mentioned signals are received. After registering the signal handlers, it > > calls wait() on the condition variable and block. > > > > When I tried to stop the program with Ctrl-C, its did not respond. IOW, the > > _signal_handler() method did not get called. > > I'm not sure what you are trying to do but your test case seems flawed. > threading.Condition is designed to be used with multiple threads but > your test doesn't actually use threads. If you run your test with a > reasonably current Python 3 (after changing print to print()), you can > see that it fails (and why it fails) when interrupting with Ctrl-C: > > Waiting to be interrupted! > ^CReceived terminate request - signal = 2 > Traceback (most recent call last): > File "b.py", line 30, in > main() > File "b.py", line 27, in main > a.register_and_wait() > File "b.py", line 22, in register_and_wait > self._termination_signal.wait() # control blocks here! > File > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin > g.py", line 289, in wait > waiter.acquire() > File "b.py", line 13, in _signal_handler > self._termination_signal.notify() > File > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin > g.py", line 339, in notify > raise RuntimeError("cannot notify on un-acquired lock") > RuntimeError: cannot notify on un-acquired lock > > After a quick glance, I'm not sure why Python 2.7 is behaving > differently, e.g. not raising an error, since both versions of > Condition.notify have the same test so the difference is elsewhere. > Feel free to open an issue for not catching the error in 2.7 but you > should rethink what you are trying to do here. That's not the whole story. I was playing around with his example this morning (Python 2.7.1, OSX, Darwin Kernel Version 11.4.2). My original thought was that maybe the wait() call is holding the GIL and breaking it up into two threads would solve that somehow. So, I tried this: --------------------------------- from signal import signal, SIGINT, SIGTERM, SIGQUIT from threading import Condition, Thread, current_thread import time class A: def __init__(self): self._termination_signal = Condition() def _signal_handler(self, signum, frame): print "Received terminate request - signal = {0}".format(signum,) del frame return def register_and_wait(self): t = Thread(target=A.run, args=[self._termination_signal]) t.start() signal(SIGINT, self._signal_handler) signal(SIGTERM, self._signal_handler) signal(SIGQUIT, self._signal_handler) @staticmethod def run(ts): ts.acquire(blocking=0) print "Waiting to be interrupted!" ts.wait() # control blocks here! print "Notified!!" def main(): a = A() a.register_and_wait() if __name__ == "__main__": main() --------------------------------------- I got the same result: _signal_handler() never gets called. You may be right that at the point where notify() gets called, you don't have a lock, but that's moot because you never even get to that point. That's the fundamental problem here, and it sure smells like a deadlock. And since it happens even in the non-threaded version, my nose says it's somehow GIL related. I just noticed that the acquire call is documented as taking specifically True or False, not generically something truthy or falsey. I tried it again with accept(blocking=False) and got the same result. Hmmm, I just also noticed what I think is a bug in the docs (https://docs.python.org/2/library/threading.html). It says, "If a call with blocking set to True would block, return False immediately". Isn't that backwards? Doesn't that describe the blocking=False behavior? From simon+python at bleah.co.uk Thu Jul 3 15:44:38 2014 From: simon+python at bleah.co.uk (Simon Ward) Date: Thu, 03 Jul 2014 20:44:38 +0100 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: <8871383c-4961-4004-83f1-949cabf16ff9@email.android.com> On 3 July 2014 18:31:04 BST, Tobiah wrote: >Coworker takes PEP8 as gospel and uses 4 spaces >to indent. I prefer tabs. Boss want's us to >unify. This isn't worth arguing about. Pick a convention, it's probably going to be a compromise, get used to it. PEP8 is as good a base as any, and is (mostly) directly supported by various syntax checking tools such as flake8 and pylama (which I think both use the pep8 tool underneath), and the modes of various editors. Any good editor will make indentation painless, whichever method you settle on. >Anyway, I gave up the 80 char line length long >ago, having little feeling for some dolt on >a Weiss terminal that for some reason needs to >edit my code. Putting the code factoring considerations aside, because others have already mentioned them and I'm sure others will, there are some other practical reasons for limiting line width: I often use multiple editors side-by-side or in split window mode. If I'm limited to one screen I'll probably also have documentation open on that screen. Having to side scroll, or have a single editor take up most of the width of the display forcing switching between windows, seems to me to be more harmful than good for productivity. There is plenty of research on the readability of prose, less so on code, but some of the considerations apply to code too. I'll pick out three of them. The first probably applies less to code (because code is generally line-based and the line widths vary; it's not just a big wall of text): people tend to find it harder to track from one line to the next with longer lines of text. The second has to do with focus: as the reader continues along a line of text their focus dwindles, it seems that starting a new line renews focus. Thirdly, it may seem unintuitive given that we appear to have more capacity for horizontal movement of the eyes, but excessively long lines can cause more work for them potentially inducing eyestrain. We focus near the centre. Our peripheral vision either side is less discerning of details and more on movement (such as an attacker). We must move our eyes to continue reading long lines, and possibly even move our heads. This is a problem for vertical movement too, and happens if lines are too short. (I have no idea how this affects readers of vertical scripts.) > I feel rather the same about the >spaces and tabs, given that most people seem to >be using editors these days that are configurable >to show tabs a four characters. Conversely, those same editors can probably automatically indent and unindent a configurable amount of spaces. If you don't use such an editor, and you really can't tolerate the different style, you can use another tool to reindent your code. Simon From toby at tobiah.org Thu Jul 3 17:23:03 2014 From: toby at tobiah.org (Tobiah) Date: Thu, 03 Jul 2014 14:23:03 -0700 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: On 07/03/2014 12:40 PM, Tim Chase wrote: > On 2014-07-03 19:02, Grant Edwards wrote: >>> That may be true, but that same person is going to have a >>> difficult time editing the code. >> >> That's true with Notepad, but with dozens of other programming >> editors, code indented with spaces will read and edit prefectly. >> Not so for tab-indented code. > > A broken editor isn't the world's best argument. If I used an editor > that changed my line-endings, randomly altered arbitrary characters, > or tried to compress multiple spaces into one, I'd complain that the > editor was broken. If a file has tab characters and my editor > doesn't let me properly deal with characters, then THE EDITOR IS > BROKEN. > > That said, even though I'm "-0" on "use 4 spaces rather than tabs", I > conform to the standard to reduce interop headache even if I'd rather > use tabs. > > -tkc > I think your suggestion of having GIT handle the transformations is the way we'll go. nothing to quibble or worry about. Well put spaces in the repository since it still seems to be the community's preference and I'll convert to tabs with GIT on the fly. Problem solved. Thanks, Tobiah From toby at tobiah.org Thu Jul 3 17:28:15 2014 From: toby at tobiah.org (Tobiah) Date: Thu, 03 Jul 2014 14:28:15 -0700 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: >> Anyway, I gave up the 80 char line length long ago, having little >> feeling for some dolt > > Same to you. Haha, the language was too strong. The code I'm talking about is only going to be seen by a small group of programmers. The current trio has all been here for over 20 years. I'd be more concerned if the code were ever to be made public. >> on a Weiss terminal that for some reason needs to edit my code. I >> feel rather the same about the spaces and tabs, given that most >> people seem to be using editors these days that are configurable to >> show tabs a four characters. >> >> Any evidence out there that this part of PEP8 is becoming more >> optional or even obsolete, as I've heard others say about the 80 char >> line length? >> >> Just need ammo for when the hammer of code unification comes down. > > Just do the right thing and configure your editor to indent with > spaces. > From rmorgan466 at gmail.com Thu Jul 3 19:09:15 2014 From: rmorgan466 at gmail.com (Rita) Date: Thu, 3 Jul 2014 19:09:15 -0400 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On Thu, Jul 3, 2014 at 8:36 AM, Mark Lawrence wrote: > On 03/07/2014 10:27, Rita wrote: > >> >> >> >> On Thu, Jul 3, 2014 at 2:54 AM, Mark Lawrence > > wrote: >> >> On 03/07/2014 02:17, Rita wrote: >> >> >> On Wed, Jul 2, 2014 at 2:46 PM, Irmen de Jong >> >> > >> __>> wrote: >> >> On 2-7-2014 4:04, Rita wrote: >> > yes, this helps. But I want to know who uses the module, >> serpent. >> So, when >> > I upgrade it or remove it they won't be affected >> adversely. >> >> (Please don't top-post, it makes the discussion harder to >> follow.) >> >> > On Tue, Jul 1, 2014 at 2:16 PM, Irmen de Jong >> >> > >__>> >> >> >> > wrote: >> > >> >> On 1-7-2014 12:38, Rita wrote: >> >>> i work in a group of developers (15 or so) who are >> located >> globally. I >> >>> would like to know what modules everyone is uses if I >> ever have to >> >> upgrade >> >>> my python. Is there mechanism which will let me see who >> is >> using what? >> >>> >> >>> ie, >> >>> >> >>> tom,matplotlib >> >>> bob, pylab >> >>> nancy, numpy >> >>> nancy, matplotlib >> >>> >> >>> etc... >> >>> >> >>> >> >> >> >> Well, if your group is all using Pip (and perhaps even >> virtualenv), you >> >> could use pip >> >> list. In my case: >> >> >> >> $ pip list >> >> [...] >> >> >> Why would the fact that you upgrade or remove a package, >> affect >> another developer in >> your group? Are you all using the same machine to develop >> on, with >> one Python installation? >> >> I think you'll have to tell us some more details about the >> way you >> work together before >> we can give a meaningful answer to your question. >> >> Irmen >> >> -- >> https://mail.python.org/__mailman/listinfo/python-list >> >> >> >> we have a shared mount point which has our python install. we >> have 3 >> servers on one part of the campus and 2 in another part. >> >> I want to find out what packages our user base is using thats >> the final >> goal. I can figure out who is using python by writing a wrapper >> but not >> what module. >> >> -- >> --- Get your facts first, then you can distort them as you >> please.-- >> >> >> You can check every users's program for import statements but do you >> really need to, why not check what's in the site-packages folder for >> your python install? >> >> -- >> My fellow Pythonistas, ask not what our language can do for you, ask >> what you can do for our language. >> >> Mark Lawrence >> >> how can i get frequency of the module usage? thats the end goal. >> >> -- >> --- Get your facts first, then you can distort them as you please.-- >> >> >> > Count the number of imports or count the times a given program gets run > for the number of imports depending on what you mean. > > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > here is what I am doing now, egrep 'from|import' *.py | wc -l which is giving me that. But this does not give me the number of times the particular module gets called. I was thinking of adding a logging feature to all of my modules so every time they get called it will be written to a log file with corresponding host and username. Is there an easy way to do that? -- --- Get your facts first, then you can distort them as you please.-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Thu Jul 3 19:15:20 2014 From: emile at fenx.com (Emile van Sebille) Date: Thu, 03 Jul 2014 16:15:20 -0700 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: On 7/3/2014 2:23 PM, Tobiah wrote: > I think your suggestion of having GIT handle the transformations > is the way we'll go. nothing to quibble or worry about. Well put > spaces in the repository since it still seems to be the community's > preference and I'll convert to tabs with GIT on the fly. Problem > solved. Just watch out for mixed tabs and spaces in the same file -- a tab counts as eight spaces and can be used interchangeably in python2. Emile From breamoreboy at yahoo.co.uk Thu Jul 3 19:19:34 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 00:19:34 +0100 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: On 04/07/2014 00:09, Rita wrote: > > here is what I am doing now, > > egrep 'from|import' *.py | wc -l which is giving me that. But this does > not give me the number of times the particular module gets called. I was > thinking of adding a logging feature to all of my modules so every time > they get called it will be written to a log file with corresponding host > and username. Is there an easy way to do that? > Start here https://docs.python.org/3/library/logging.html#module-logging -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From jnufcvyvuc at tznvy.pbz Thu Jul 3 19:30:24 2014 From: jnufcvyvuc at tznvy.pbz (Philip Shaw) Date: 03 Jul 2014 23:30:24 GMT Subject: Get named groups from a regular expression References: Message-ID: <53b5e78f$0$2911$c3e8da3$76491128@news.astraweb.com> On 2014-07-01, Florian Lindner wrote: > > Is there a way I can extract the named groups from a regular > expression? e.g. given "(?P\d)" I want to get something > like ["testgrp"]. The match object has an attribute called "groupdict", so you can get the found named groups using match.groupdict.keys. I can't remember what happens to unnamed groups (I prefer to name every group I want), but ISTR that there is a list of capture groups in which the indexes are the capture groups number (i.e. what you'd use to backreference them). > Can I make the match object to return default values for named > groups, even if no match was produced? A lazy solution I've used was to write a default dict, then update it with the groupdict. I doubt that's all that efficient, but the defaults were constant strings and the program was network-bound anyway. From cs at zip.com.au Thu Jul 3 19:28:26 2014 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 4 Jul 2014 09:28:26 +1000 Subject: threading.Condition.wait() is not catching SIGTERM In-Reply-To: References: Message-ID: <20140703232826.GA64540@cskk.homeip.net> On 03Jul2014 16:43, Roy Smith wrote: [...] >Hmmm, I just also noticed what I think is a bug in the docs >(https://docs.python.org/2/library/threading.html). It says, "If a call >with blocking set to True would block, return False immediately". Isn't >that backwards? Doesn't that describe the blocking=False behavior? If you mean this text under Lock.acquire: When invoked with the blocking argument set to False, do not block. If a call with blocking set to True would block, return False immediately; otherwise, set the lock to locked and return True. that pretty clearly (to me) describes blocking=False, by contrasting it with a behaviour that would obtain if blocking=True. It is in the clause describing "the blocking argument set to False", after all. Cheers, Cameron Simpson From sangeeth.saravanaraj at gmail.com Thu Jul 3 20:48:00 2014 From: sangeeth.saravanaraj at gmail.com (Sangeeth Saravanaraj) Date: Fri, 4 Jul 2014 06:18:00 +0530 Subject: threading.Condition.wait() is not catching SIGTERM In-Reply-To: References: <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B@gmail.com> Message-ID: <8418D56C-E3D7-4B13-80E9-004E2CC5611F@gmail.com> On 04-Jul-2014, at 1:43 am, Ned Deily wrote: > In article <17F05A1B-44C8-4F25-AFE9-5DBCFFB9982B at gmail.com>, >> I have the following code which when executed waits to be interrupted by >> SIGINT, SIGTERM or SIGQUIT. When an object is initialized, it creates a >> threading.Condition() and acquires() it! The program then registers the >> signal handlers where notify() and release() is called when the above >> mentioned signals are received. After registering the signal handlers, it >> calls wait() on the condition variable and block. >> >> When I tried to stop the program with Ctrl-C, its did not respond. IOW, the >> _signal_handler() method did not get called. > > I'm not sure what you are trying to do but your test case seems flawed. > threading.Condition is designed to be used with multiple threads but > your test doesn't actually use threads. If you run your test with a > reasonably current Python 3 (after changing print to print()), you can > see that it fails (and why it fails) when interrupting with Ctrl-C: > > Waiting to be interrupted! > ^CReceived terminate request - signal = 2 > Traceback (most recent call last): > File "b.py", line 30, in > main() > File "b.py", line 27, in main > a.register_and_wait() > File "b.py", line 22, in register_and_wait > self._termination_signal.wait() # control blocks here! > File > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin > g.py", line 289, in wait > waiter.acquire() > File "b.py", line 13, in _signal_handler > self._termination_signal.notify() > File > "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threadin > g.py", line 339, in notify > raise RuntimeError("cannot notify on un-acquired lock") > RuntimeError: cannot notify on un-acquired lock > > After a quick glance, I'm not sure why Python 2.7 is behaving > differently, e.g. not raising an error, since both versions of > Condition.notify have the same test so the difference is elsewhere. > Feel free to open an issue for not catching the error in 2.7 but you Ned, thanks for the explanation. I have filed http://bugs.python.org/issue21913 to explore further on this issue. Thank you, Sangeeth > should rethink what you are trying to do here. > > -- > Ned Deily, > nad at acm.org > > -- > https://mail.python.org/mailman/listinfo/python-list From steve+comp.lang.python at pearwood.info Thu Jul 3 21:02:40 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jul 2014 01:02:40 GMT Subject: PEP8 and 4 spaces References: Message-ID: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> On Thu, 03 Jul 2014 10:31:04 -0700, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer > tabs. Boss want's us to unify. Point out to your boss, and your co-worker, that PEP 8 *explicitly* states that it is not compulsory except for the standard library, and that for third-party and private code, local conventions over-rule PEP 8. In other words, if your co-worker is the only one who uses spaces when everyone else uses tabs, **he is violating PEP 8**. > The sole thing you get with spaces as > far as I can tell, is that someone loading the code into Notepad will > still see a 4 character indent. That may be true, but that same person > is going to have a difficult time editing the code. Advantages of spaces: - It's a convention that many people follow. Disadvantages of tabs: - Many standard Unix/Linux/POSIX tools have a hard time dealing with tabs. I call such tools *broken*, and there is a vicious circle going on: programmers use the fact that these tools don't support tabs to justify the use of spaces, and the majority consensus that you should use spaces as justification for not fixing the tools. As I understand it, Unix coders tend to prefer spaces, and Windows users tend to be more comfortable with tabs. This isn't a hard-and-fast rule, you'll find plenty of exceptions, but it seems to me that Unix tools are unforgiving of tabs while Windows IDEs tend to default to tabs. I'm not a Windows person myself, any Windows guys like to comment? > Anyway, I gave up the 80 char line length long ago, having little > feeling for some dolt on a Weiss terminal that for some reason needs to > edit my code. How do you feel about some dolt who aligns two or three editor windows side-by-side so they can compare code? :-) Being able to set code side-by-side, say in a horizontal diff, or two editors next to each other, is a much more important reason to support a 79+1 maximum line width than Weiss terminals. -- Steven From rosuav at gmail.com Thu Jul 3 21:19:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jul 2014 11:19:44 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 4, 2014 at 11:02 AM, Steven D'Aprano wrote: > As I understand it, Unix coders tend to prefer spaces, and Windows users > tend to be more comfortable with tabs. This isn't a hard-and-fast rule, > you'll find plenty of exceptions, but it seems to me that Unix tools are > unforgiving of tabs while Windows IDEs tend to default to tabs. I'm not a > Windows person myself, any Windows guys like to comment? I've worked both platforms extensively, and it's not really as clear-cut as that. Most Unix tools are perfectly happy with tabs, *as long as you let them mean eight spaces*; a lot, but not all, have an option to configure tab width, but you have to specify it to every program separately. On the flip side, tab configurability can be a huge feature. There've been times when I've looked at something with the tab width set to something insane like 7 or 9 (no, folks, I did not say "7 of 9") to highlight a display bug or other oddity. Not often, but it has its uses - and you can't do that if there are actual spaces involved. Anyone who's using a broken editor should fix it or switch editors. That's easy. And if you really love your editor, sometimes you can fix the issue outside it - maybe in a source control hook. ChrisA From steve+comp.lang.python at pearwood.info Thu Jul 3 21:21:36 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jul 2014 01:21:36 GMT Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> On Thu, 03 Jul 2014 21:07:28 +0300, Paul Sokolovsky wrote: > Hello, > > On Fri, 4 Jul 2014 03:38:27 +1000 > Chris Angelico wrote: > >> On Fri, Jul 4, 2014 at 3:31 AM, Tobiah wrote: >> > Coworker takes PEP8 as gospel and uses 4 spaces to indent. I prefer >> > tabs. Boss want's us to unify. >> >> 1) PEP 8 is meant to be guidelines, *not* a set of hard-and-fast rules. >> 2) Tabs let different people display the indents at different widths. > > That's exactly the problem with tabs - whatever you think your code > looks like with tabs, other people will see quite different picture. Why do you consider this a problem? The only rational reason I can think of is that you are concerned about line widths. If I write code with tabs set to two spaces, indent five times, and then write 50 characters of code, I'll see a total line width of 60 columns. Somebody who views tabs as four spaces will see a width of 70, and someone else who views them as eight spaces will see a width of 90 columns. So I can see that's somewhat of a problem, but not a huge one. > Also, most people are not interested in doing mumbo-jumbo with tabs > settings, and have them set to standard 8-char tabs. So, any python code > which uses only tabs for indentation automatically violates 4-space > convention "Mumbo-jumbo"? In any decent editor, it's a single setting. In kwrite I go Settings > Configure Editor, click the Editing icon, and there's a "Tab width" field right there. Hardly mumbo-jumbo. In any case, the 4-space convention is just a convention. If you're willing to go against PEP 8 and use tabs, going against PEP 8 and using 8- column tab settings shouldn't worry you. > (and mixing tabs and spaces is nowadays prohibited in Python). Yes, that's because the algorithm used by the parser to determine the indentation level may not give the same answer as a human reader, in the presence of mixed tabs and spaces. In any case, in the entire history of the space/tab argument, I'm not aware of a single person who recommended mixed space/tabs for indents. There are two standard solutions for the problem of indenting code, not three: use spaces, or use tabs, but not "arbitrarily pick one or the other each time you indent". > Summing up: if you care about other human beings, use spaces. If you > don't care about other human beings, you may use tabs, but other human > beings surely will take how you treat them into account ;-). Ha ha, that's funny, I would have said the opposite: if you care about keeping tools that expect spaces happy, use spaces, if you care about allowing people to configure the look of your code, or poor unfortunates who aren't using a programmer's editor, use tabs. -- Steven From rosuav at gmail.com Thu Jul 3 21:30:12 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jul 2014 11:30:12 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano wrote: >> Summing up: if you care about other human beings, use spaces. If you >> don't care about other human beings, you may use tabs, but other human >> beings surely will take how you treat them into account ;-). > > Ha ha, that's funny, I would have said the opposite: if you care about > keeping tools that expect spaces happy, use spaces, if you care about > allowing people to configure the look of your code, or poor unfortunates > who aren't using a programmer's editor, use tabs. Right. And hey. If you're a sufficiently competent programmer, you CAN get away with not caring about other human beings: either because you're so utterly valuable that people accept you despite your rough edges... or because you just script away the differences :) Now, if your *boss* doesn't understand about these things, it's possible to lose your job over stupid stuff like style guides. Although to be fair, I'd been planning to quit for a long time, and the style guide was the last in a long line of problems, so when I kicked back and said basically "No, your style guide is a bad idea", it ended up with us parting ways. But that's a separate point. ChrisA From roy at panix.com Thu Jul 3 21:37:07 2014 From: roy at panix.com (Roy Smith) Date: Thu, 03 Jul 2014 21:37:07 -0400 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Fri, Jul 4, 2014 at 11:21 AM, Steven D'Aprano > wrote: > >> Summing up: if you care about other human beings, use spaces. If you > >> don't care about other human beings, you may use tabs, but other human > >> beings surely will take how you treat them into account ;-). > > > > Ha ha, that's funny, I would have said the opposite: if you care about > > keeping tools that expect spaces happy, use spaces, if you care about > > allowing people to configure the look of your code, or poor unfortunates > > who aren't using a programmer's editor, use tabs. > > Right. And hey. If you're a sufficiently competent programmer, you CAN > get away with not caring about other human beings: either because > you're so utterly valuable that people accept you despite your rough > edges... or because you just script away the differences :) > > Now, if your *boss* doesn't understand about these things, it's > possible to lose your job over stupid stuff like style guides. > Although to be fair, I'd been planning to quit for a long time, and > the style guide was the last in a long line of problems, so when I > kicked back and said basically "No, your style guide is a bad idea", > it ended up with us parting ways. But that's a separate point. > > ChrisA The way I figure it, there are two things which have sucked up more time, effort, and productivity than anything else. Buffer overrun bugs, and arguments about whitespace (and placement of braces in those sorts of languages). I'm not sure which order they go in. Solving buffer overruns is easy; you use bounds-checked containers, or languages which don't expose raw memory. Killing whitespace arguments seems to be a far more intractable problem. From demianbrecht at gmail.com Thu Jul 3 23:23:42 2014 From: demianbrecht at gmail.com (Demian Brecht) Date: Thu, 3 Jul 2014 20:23:42 -0700 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: On Jul 3, 2014 10:31 AM, "Tobiah" wrote: > Just need ammo for when the hammer of code unification comes down. One issue that I've encountered in the past (one of the reasons outside of pep8) that I switched to spaces is when working with libraries other than your own. If you want to stick print statements, breakpoints or make any other modifications to the code you're working with, chances are if you're using tabs in your editor, you're going to run into issues when making those changes. Most (of not all) libraries I've worked with use spaces. Pep8 suggests the use of spaces. New hires who have spent any amount of time in python are /likely/ most used to using spaces. For those reasons I much prefer spaces over tabs. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flebber.crue at gmail.com Fri Jul 4 00:12:15 2014 From: flebber.crue at gmail.com (flebber) Date: Thu, 3 Jul 2014 21:12:15 -0700 (PDT) Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> Message-ID: <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> I have taken the code and gone a little further, but I need to be able to protect myself against commas and single quotes in names. How is it the best to do this? so in my file I had on line 44 this trainer name. "Michael, Wayne & John Hawkes" and in line 95 this horse name. Inz'n'out this throws of my capturing correct item 9. How do I protect against this? Here is current code. import re from sys import argv SCRIPT, FILENAME = argv def out_file_name(file_name): """take an input file and keep the name with appended _clean""" file_parts = file_name.split(".",) output_file = file_parts[0] + '_clean.' + file_parts[1] return output_file def race_table(text_file): """utility to reorganise poorly made csv entry""" input_table = [[item.strip(' "') for item in record.split(',')] for record in text_file.splitlines()] # At this point look at input_table to find the record indices output_table = [] for record in input_table: if record[0] == 'Meeting': meeting = record[3] elif record[0] == 'Race': date = record[13] race = record[1] elif record[0] == 'Horse': number = record[1] name = record[2] results = record[9] res_split = re.split('[- ]', results) starts = res_split[0] wins = res_split[1] seconds = res_split[2] thirds = res_split[3] prizemoney = res_split[4] trainer = record[4] location = record[5] print(name, wins, seconds) output_table.append((meeting, date, race, number, name, starts, wins, seconds, thirds, prizemoney, trainer, location)) return output_table MY_FILE = out_file_name(FILENAME) # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: # for line in race_table(f_in.readline()): # new_row = line with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: CONTENT = f_in.read() # print(content) FILE_CONTENTS = race_table(CONTENT) # print new_name f_out.write(str(FILE_CONTENTS)) if __name__ == '__main__': pass From greg.ewing at canterbury.ac.nz Fri Jul 4 02:19:09 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 04 Jul 2014 18:19:09 +1200 Subject: fixing an horrific formatted csv file. In-Reply-To: <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> Message-ID: flebber wrote: > so in my file I had on line 44 this trainer name. > > "Michael, Wayne & John Hawkes" > > and in line 95 this horse name. Inz'n'out > > this throws of my capturing correct item 9. How do I protect against this? Use python's csv module to read the file. Don't try to do it yourself; the rules for handling embedded commas and quotes in csv are quite complicated. As long as the file is a well-formed csv file, the csv module should parse fields like that correctly. -- Greg From greg.ewing at canterbury.ac.nz Fri Jul 4 02:35:04 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 04 Jul 2014 18:35:04 +1200 Subject: PEP8 and 4 spaces In-Reply-To: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > Disadvantages of tabs: > - Many standard Unix/Linux/POSIX tools have a hard time dealing with tabs. > > I call such tools *broken*, They're not broken, they're just using a different set of conventions. Unix traditionally uses tab characters as a form of space compression. The meaning of a tab is fixed, and configurable indentation is done by inserting a suitable combination of tabs and spaces. As long as *all* your tools follow that convention, everything is fine. The problems arise when you mix in tools that use different conventions. The truly broken tools IMO are things like mail handlers that shrink away in terror when they see a tab and remove it altogether. There's no excuse for that, as far as I can see. -- Greg From greg.ewing at canterbury.ac.nz Fri Jul 4 02:55:37 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Fri, 04 Jul 2014 18:55:37 +1200 Subject: PEP8 and 4 spaces In-Reply-To: <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: >>That's exactly the problem with tabs - whatever you think your code >>looks like with tabs, other people will see quite different picture. > > Why do you consider this a problem? It's a problem if you try to use tabs for lining things up in a tabular fashion in your source code. The solution is not to use tabs for that -- only use tabs for indentation, and use spaces for everything else. Or, as PEP 8 suggests, don't try to line things up in the first place. I know it's ironic that tabs are no good for tabulation. But it's unavoidable in a plain text format that doesn't carry any metadata about how to interpret the tabs. -- Greg From info at egenix.com Fri Jul 4 04:43:03 2014 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Fri, 04 Jul 2014 10:43:03 +0200 Subject: eGenix at the EuroPython Conference 2014 Message-ID: <53B66917.7010404@egenix.com> ________________________________________________________________________ eGenix.com at the EuroPython Conference 2014 July 21-27 2014 Berlin, Germany ________________________________________________________________________ The EuroPython Conference (https://ep2014.europython.eu/) is the one of the premier conferences for Python users and developers in Europe. It is the second largest gathering of Python enthusiast around the world. This year it is being held from July 21-27 in Berlin, Germany. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/EuroPython-Conference-2014.html ________________________________________________________________________ MEET UP WITH EGENIX AT EUROPYTHON eGenix was one of the founding members of the EuroPython conference team and played a major role in organizing the first EuroPython conference in the year 2002. Since then we have attended every EuroPython conference to meet up face-to-face with the many people we know from the Python community and the many people that we don't yet know from the community -- if you are interested in meeting with us, please drop us a note so that we can arrange a meeting at info at egenix.com. ________________________________________________________________________ EGENIX TALKS AT EUROPYTHON At this year's EuroPython, Marc-Andr? Lemburg, CEO of eGenix, will be giving a talk providing some insights into our experience with large-scale database applications written in Python. Advanced Database Programming with Python ----------------------------------------- Getting the best out of your database. The Python DB-API 2.0 (http://www.python.org/dev/peps/pep-0249/) provides a direct interface to many popular database backends. It makes interaction with relational database very straight forward and allows tapping into the full set of features these databases provide. The talk will cover advanced database topics which are relevant in production environments such as locks, distributed transactions and transaction isolation. Friday, 11:30 CEST, Room C01 https://ep2014.europython.eu/en/schedule/sessions/104/ Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 04 2014) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2014-07-21: EuroPython 2014, Berlin, Germany ... 17 days to go ::::: Try our 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 wxjmfauth at gmail.com Fri Jul 4 04:47:11 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Fri, 4 Jul 2014 01:47:11 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Le vendredi 4 juillet 2014 08:35:04 UTC+2, Gregory Ewing a ?crit?: > > The truly broken tools IMO are things like mail handlers that > > shrink away in terror when they see a tab and remove it > > altogether. There's no excuse for that, as far as I can see. > > Yes, and you can extend this to the editors, which deliberately missusing the tabulation rules by inserting something else, eg. spaces (U+0020, 'SPACE'). From marko at pacujo.net Fri Jul 4 05:21:48 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 04 Jul 2014 12:21:48 +0300 Subject: PEP8 and 4 spaces References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <877g3tiimr.fsf@elektro.pacujo.net> wxjmfauth at gmail.com: > Le vendredi 4 juillet 2014 08:35:04 UTC+2, Gregory Ewing a ?crit?: >> The truly broken tools IMO are things like mail handlers that shrink >> away in terror when they see a tab and remove it altogether. There's >> no excuse for that, as far as I can see. > > Yes, and you can extend this to the editors, which deliberately > missusing the tabulation rules by inserting something else, eg. spaces > (U+0020, 'SPACE'). A worthy flame war with top-class trolling mixed in. How could I stay out? My esteemed editor never "misuses the tabulation rules" as I have instructed it to never insert TAB characters in files: (custom-set-variables '(indent-tabs-mode nil)) Marko From wxjmfauth at gmail.com Fri Jul 4 05:24:07 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Fri, 4 Jul 2014 02:24:07 -0700 (PDT) Subject: eGenix at the EuroPython Conference 2014 In-Reply-To: References: Message-ID: <4b6f777c-d92b-4d99-872e-8a8cbf11b2ec@googlegroups.com> ============== >>> sys.getsizeof('a') 26 >>> sys.getsizeof('EURO') 40 >>> import timeit >>> timeit.timeit("('abc'*1000 + 'z').find('z')") 2.4989620382882043 >>> timeit.timeit("('abc'*1000 + 'EURO').find('EURO')") 5.09689729988173 >>> >>> >>> # ditto, for a dozen European languages >>> # languages using a latin alphabet with >>> # some small exceptions (eg German (Germany)) >>> >>> # Py3.2 does better! >>> jmf From wxjmfauth at gmail.com Fri Jul 4 06:10:32 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Fri, 4 Jul 2014 03:10:32 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: <877g3tiimr.fsf@elektro.pacujo.net> References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> <877g3tiimr.fsf@elektro.pacujo.net> Message-ID: <0519d709-df75-4662-a653-a80a7643e3a0@googlegroups.com> Le vendredi 4 juillet 2014 11:21:48 UTC+2, Marko Rauhamaa a ?crit?: > wxjmfauth at gmail.com: > > > > > Le vendredi 4 juillet 2014 08:35:04 UTC+2, Gregory Ewing a ?crit?: > > >> The truly broken tools IMO are things like mail handlers that shrink > > >> away in terror when they see a tab and remove it altogether. There's > > >> no excuse for that, as far as I can see. > > > > > > Yes, and you can extend this to the editors, which deliberately > > > missusing the tabulation rules by inserting something else, eg. spaces > > > (U+0020, 'SPACE'). > > > > A worthy flame war with top-class trolling mixed in. How could I stay > > out? > > > > My esteemed editor never "misuses the tabulation rules" as I have > > instructed it to never insert TAB characters in files: > > > > (custom-set-variables > > '(indent-tabs-mode nil)) > > > > > > > > Marko -------- Yes. And what? If I give you a correctly formated doc with tabulations and you do not wish to use it, that you your problem. From fk26541598fk at gmail.com Fri Jul 4 06:15:57 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Fri, 4 Jul 2014 03:15:57 -0700 (PDT) Subject: flask sql cann't insert Variable in VALUES Message-ID: I try to insert username in to my table it show Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. it maybe mean no request i try to change username to '123123' then it works.... what's problem with this? @app.route('/user/',methods=['GET','POST']) def hello(username): if request.method=='POST': save_friends(username) return username def save_friends(username): conn = engine.connect() conn.execute("INSERT INTO friends(name) VALUES(username)") From rosuav at gmail.com Fri Jul 4 06:24:26 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 4 Jul 2014 20:24:26 +1000 Subject: flask sql cann't insert Variable in VALUES In-Reply-To: References: Message-ID: On Fri, Jul 4, 2014 at 8:15 PM, Frank Liou wrote: > I try to insert username in to my table > > it show > > Internal Server Error > The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application. > > ... > def save_friends(username): > conn = engine.connect() > conn.execute("INSERT INTO friends(name) VALUES(username)") There are two things that you need to understand here, and rather than give you the answers, I'm going to point you toward what you should know. The first one is that your result page simply tells you that there was an error; you need to look in the server logs to find the actual text of the error. Get to know those logs; they'll collect all sorts of errors for you. And the second is about the nature of SQL and Python. Have a look at the basic documentation on parameterized queries, and *be sure you understand it*. There is a lot more at stake here than you might realize, so I'm not simply going to explain what's wrong here; you absolutely must comprehend parameterized queries. ChrisA From flebber.crue at gmail.com Fri Jul 4 06:28:04 2014 From: flebber.crue at gmail.com (flebber) Date: Fri, 4 Jul 2014 03:28:04 -0700 (PDT) Subject: fixing an horrific formatted csv file. In-Reply-To: <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> Message-ID: On Friday, 4 July 2014 14:12:15 UTC+10, flebber wrote: > I have taken the code and gone a little further, but I need to be able to protect myself against commas and single quotes in names. > > > > How is it the best to do this? > > > > so in my file I had on line 44 this trainer name. > > > > "Michael, Wayne & John Hawkes" > > > > and in line 95 this horse name. > > Inz'n'out > > > > this throws of my capturing correct item 9. How do I protect against this? > > > > Here is current code. > > > > import re > > from sys import argv > > SCRIPT, FILENAME = argv > > > > > > def out_file_name(file_name): > > """take an input file and keep the name with appended _clean""" > > file_parts = file_name.split(".",) > > output_file = file_parts[0] + '_clean.' + file_parts[1] > > return output_file > > > > > > def race_table(text_file): > > """utility to reorganise poorly made csv entry""" > > input_table = [[item.strip(' "') for item in record.split(',')] > > for record in text_file.splitlines()] > > # At this point look at input_table to find the record indices > > output_table = [] > > for record in input_table: > > if record[0] == 'Meeting': > > meeting = record[3] > > elif record[0] == 'Race': > > date = record[13] > > race = record[1] > > elif record[0] == 'Horse': > > number = record[1] > > name = record[2] > > results = record[9] > > res_split = re.split('[- ]', results) > > starts = res_split[0] > > wins = res_split[1] > > seconds = res_split[2] > > thirds = res_split[3] > > prizemoney = res_split[4] > > trainer = record[4] > > location = record[5] > > print(name, wins, seconds) > > output_table.append((meeting, date, race, number, name, > > starts, wins, seconds, thirds, prizemoney, > > trainer, location)) > > return output_table > > > > MY_FILE = out_file_name(FILENAME) > > > > # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: > > # for line in race_table(f_in.readline()): > > # new_row = line > > with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: > > CONTENT = f_in.read() > > # print(content) > > FILE_CONTENTS = race_table(CONTENT) > > # print new_name > > f_out.write(str(FILE_CONTENTS)) > > > > > > if __name__ == '__main__': > > pass So I found this on stack overflow In [2]: import string In [3]: identity = string.maketrans("", "") In [4]: x = ['+5556', '-1539', '-99', '+1500'] In [5]: x = [s.translate(identity, "+-") for s in x] In [6]: x Out[6]: ['5556', '1539', '99', '1500'] but it fails in my file, due to I believe mine being a list of list. Is there an easy way to iterate the sublists without flattening? Current code. input_table = [[item.strip(' "') for item in record.split(',')] for record in text_file.splitlines()] # At this point look at input_table to find the record indices identity = string.maketrans("", "") print(input_table) input_table = [s.translate(identity, ",'") for s in input_table] Sayth From kwpolska at gmail.com Fri Jul 4 06:44:39 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Fri, 4 Jul 2014 12:44:39 +0200 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: On Thu, Jul 3, 2014 at 7:31 PM, Tobiah wrote: > Anyway, I gave up the 80 char line length long > ago, having little feeling for some dolt on > a Weiss terminal that for some reason needs to > edit my code. And yet, you did not give up an even more insane line length limit, in e-mail. The longest line in your original message is a measly 57 characters long. The median line length is 46 characters. Which is pretty insane, and ultra-hard to read. You can do more in e-mail. > Each line of characters MUST be no more than 998 characters, and > SHOULD be no more than 78 characters, excluding the CRLF. That's the standard, [RFC 5322][]; the exact same quote appeared back in [RFC 2822][]. However, many places actually want you to use a bit less; common values include 70 or 72. But still, it is MUCH more roomy and readable than the value you use. Here are the line lengths in the original message: [47, 45, 45, 46, 46, 47, 45, 5, 46, 43, 46, 47, 47, 49, 31, 57, 52, 34, 42, 23] [RFC 5322]: http://tools.ietf.org/html/rfc5322#section-2.1.1 [RFC 2822]: http://tools.ietf.org/html/rfc2822#section-2.1.1 -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From flebber.crue at gmail.com Fri Jul 4 06:48:10 2014 From: flebber.crue at gmail.com (flebber) Date: Fri, 4 Jul 2014 03:48:10 -0700 (PDT) Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> Message-ID: On Friday, 4 July 2014 16:19:09 UTC+10, Gregory Ewing wrote: > flebber wrote: > > > so in my file I had on line 44 this trainer name. > > > > > > "Michael, Wayne & John Hawkes" > > > > > > and in line 95 this horse name. Inz'n'out > > > > > > this throws of my capturing correct item 9. How do I protect against this? > > > > Use python's csv module to read the file. Don't try to > > do it yourself; the rules for handling embedded commas > > and quotes in csv are quite complicated. As long as > > the file is a well-formed csv file, the csv module > > should parse fields like that correctly. > > > > -- > > Greg True Greg worked easier def race_table(text_file): """utility to reorganise poorly made csv entry""" # input_table = [[item.strip(' "') for item in record.split(',')] # for record in text_file.splitlines()] # At this point look at input_table to find the record indices # identity = string.maketrans("", "") # print(input_table) # input_table = [s.translate(identity, ",'") for s # in input_table] output_table = [] for record in text_file: if record[0] == 'Meeting': meeting = record[3] elif record[0] == 'Race': date = record[13] race = record[1] elif record[0] == 'Horse': number = record[1] name = record[2] results = record[9] res_split = re.split('[- ]', results) starts = res_split[0] wins = res_split[1] seconds = res_split[2] thirds = res_split[3] try: prizemoney = res_split[4] finally: prizemoney = 0 trainer = record[4] location = record[5] print(name, wins, seconds) output_table.append((meeting, date, race, number, name, starts, wins, seconds, thirds, prizemoney, trainer, location)) return output_table MY_FILE = out_file_name(FILENAME) # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: # for line in race_table(f_in.readline()): # new_row = line with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: CONTENT = csv.reader(f_in) # print(content) FILE_CONTENTS = race_table(CONTENT) # print new_name f_out.write(str(FILE_CONTENTS)) if __name__ == '__main__': pass Sayth From conradwt at gmail.com Fri Jul 4 07:16:21 2014 From: conradwt at gmail.com (Conrad Taylor) Date: Fri, 4 Jul 2014 04:16:21 -0700 (PDT) Subject: Is pip being automatically installed for Python 3.4.0? In-Reply-To: References: Message-ID: <85a29f88-ca3b-40da-ae19-518310af0506@googlegroups.com> On Wednesday, July 2, 2014 9:59:46 PM UTC-7, Ned Deily wrote: > In article , > > Conrad Taylor wrote: > > > Hi, shouldn't pip be automatically installed for Python 3.4.0 release? I > > > have read through the release and the PEP 453. Thus, can someone confirm > > > whether or not this is the case? BTW, I have installed Python 3.4.0 using > > > MacPorts. > > > > Like many other third-party package managers, MacPorts has chosen to > > continue to distribute pip as a separate item. To install it and the > > MacPorts Python 3.4: > > > > sudo port install py34-pip > Yes, I have come to the same solution prior to the original post but I wanted to try the functionality in PEP 453 being that I would like to prepare instructions for others. > > > -- > > Ned Deily, > > nad at acm.org From selvaperumal.p at gmail.com Fri Jul 4 08:15:23 2014 From: selvaperumal.p at gmail.com (selvaperumal.p at gmail.com) Date: Fri, 4 Jul 2014 05:15:23 -0700 (PDT) Subject: TextBlob on Windows In-Reply-To: References: Message-ID: <13ca4895-6e99-432b-9f59-94b47def60a0@googlegroups.com> On Saturday, 24 May 2014 04:45:14 UTC+5:30, subhaba... at gmail.com wrote: > Dear Group, > > > > It seems there is a nice language processing library named TextBlob, like NLTK. > > But I am being unable to install it on my Windows(MS-Windows 7 machine. I am using Python 2.7 > > > > If anyone of the esteemed members may kindly suggest me the solution. > > > > I tried the note in following URL > > http://stackoverflow.com/questions/20562768/trouble-installing-textblob-for-python > > > > but did not help much. > > > > Thanking in Advance, > > Regards, > > Subhabrata Banerjee. hi mam i too having the same problem. If you got any solution for the problem please let me know I am in dire need of the package to be used in python. please! From mailinglists at xgm.de Fri Jul 4 08:27:12 2014 From: mailinglists at xgm.de (Florian Lindner) Date: Fri, 04 Jul 2014 14:27:12 +0200 Subject: Why is regexp not working? Message-ID: Hello, I have that piece of code: def _split_block(self, block): cre = [re.compile(r, flags = re.MULTILINE) for r in self.regexps] block = "".join(block) print(block) print("-------------------") for regexp in cre: match = regexp.match(block) for grp in regexp.groupindex: data = match.group(grp) if match else None self.data[grp].append(data) block is a list of strings, terminated by \n. self.regexps: self.regexps = [r"it (?P\d+) .* dt complete yes | write-iteration-checkpoint |", r"it (?P\d+) read ahead" If I run my program it looks like that: it 1 ahadf dt complete yes | write-iteration-checkpoint | Timestep completed ------------------- it 1 read ahead it 2 ahgsaf dt complete yes | write-iteration-checkpoint | Timestep completed ------------------- it 4 read ahead it 3 dfdsag dt complete yes | write-iteration-checkpoint | Timestep completed ------------------- it 9 read ahead it 4 dsfdd dt complete yes | write-iteration-checkpoint | Timestep completed ------------------- it 16 read ahead ------------------- {'it_read_ahead': [None, '1', '4', '9', '16'], 'coupling_iterations': ['1', None, None, None, None]} it_read_ahead is always matched when it should (all blocks but the first). But why is the regexp containing coupling_iterations only matched in the first block? I tried different combinations using re.match vs. re.search and with or without re.MULTILINE. Thanks! Florian From anthra.norell at bluewin.ch Fri Jul 4 09:24:31 2014 From: anthra.norell at bluewin.ch (F.R.) Date: Fri, 04 Jul 2014 15:24:31 +0200 Subject: fixing an horrific formatted csv file. In-Reply-To: References: <47e2e29d-b5c3-4aa6-abf9-3b1e46eb0dec@googlegroups.com> <0d3871c6-81d4-4168-9408-ad85299b0955@googlegroups.com> <11ecf009-6f81-4fa5-bee9-b52b9407f0af@googlegroups.com> Message-ID: <53B6AB0F.4060203@bluewin.ch> On 07/04/2014 12:28 PM, flebber wrote: > On Friday, 4 July 2014 14:12:15 UTC+10, flebber wrote: >> I have taken the code and gone a little further, but I need to be able to protect myself against commas and single quotes in names. >> >> >> >> How is it the best to do this? >> >> >> >> so in my file I had on line 44 this trainer name. >> >> >> >> "Michael, Wayne & John Hawkes" >> >> >> >> and in line 95 this horse name. >> >> Inz'n'out >> >> >> >> this throws of my capturing correct item 9. How do I protect against this? >> >> >> >> Here is current code. >> >> >> >> import re >> >> from sys import argv >> >> SCRIPT, FILENAME = argv >> >> >> >> >> >> def out_file_name(file_name): >> >> """take an input file and keep the name with appended _clean""" >> >> file_parts = file_name.split(".",) >> >> output_file = file_parts[0] + '_clean.' + file_parts[1] >> >> return output_file >> >> >> >> >> >> def race_table(text_file): >> >> """utility to reorganise poorly made csv entry""" >> >> input_table = [[item.strip(' "') for item in record.split(',')] >> >> for record in text_file.splitlines()] >> >> # At this point look at input_table to find the record indices >> >> output_table = [] >> >> for record in input_table: >> >> if record[0] == 'Meeting': >> >> meeting = record[3] >> >> elif record[0] == 'Race': >> >> date = record[13] >> >> race = record[1] >> >> elif record[0] == 'Horse': >> >> number = record[1] >> >> name = record[2] >> >> results = record[9] >> >> res_split = re.split('[- ]', results) >> >> starts = res_split[0] >> >> wins = res_split[1] >> >> seconds = res_split[2] >> >> thirds = res_split[3] >> >> prizemoney = res_split[4] >> >> trainer = record[4] >> >> location = record[5] >> >> print(name, wins, seconds) >> >> output_table.append((meeting, date, race, number, name, >> >> starts, wins, seconds, thirds, prizemoney, >> >> trainer, location)) >> >> return output_table >> >> >> >> MY_FILE = out_file_name(FILENAME) >> >> >> >> # with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: >> >> # for line in race_table(f_in.readline()): >> >> # new_row = line >> >> with open(FILENAME, 'r') as f_in, open(MY_FILE, 'w') as f_out: >> >> CONTENT = f_in.read() >> >> # print(content) >> >> FILE_CONTENTS = race_table(CONTENT) >> >> # print new_name >> >> f_out.write(str(FILE_CONTENTS)) >> >> >> >> >> >> if __name__ == '__main__': >> >> pass > So I found this on stack overflow > > In [2]: import string > > In [3]: identity = string.maketrans("", "") > > In [4]: x = ['+5556', '-1539', '-99', '+1500'] > > In [5]: x = [s.translate(identity, "+-") for s in x] > > In [6]: x > Out[6]: ['5556', '1539', '99', '1500'] > > but it fails in my file, due to I believe mine being a list of list. Is there an easy way to iterate the sublists without flattening? > > Current code. > > input_table = [[item.strip(' "') for item in record.split(',')] > for record in text_file.splitlines()] > # At this point look at input_table to find the record indices > identity = string.maketrans("", "") > print(input_table) > input_table = [s.translate(identity, ",'") for s > in input_table] > > Sayth Take Gregory's advice and use the csv module. Don't reinvent a csv parser. My "csv" splitter was the simplest approach possible, which I tend to use with undocumented formats, tweaking for unexpected features as they come along. Frederic From jldunn2000 at gmail.com Fri Jul 4 09:38:10 2014 From: jldunn2000 at gmail.com (loial) Date: Fri, 4 Jul 2014 06:38:10 -0700 (PDT) Subject: capturing SNMP trap events Message-ID: I want to monitor printers for events such as the completion of printing. If the printer initiates an SNMP trap event when the job has finished printing, how can I capture this? Presumably I need some sort of deamon to listen for these trap messages. I have looked at pySNMP but am not sure if this can be used to capture SNMP trap events from the printer. From roy at panix.com Fri Jul 4 09:47:31 2014 From: roy at panix.com (Roy Smith) Date: Fri, 04 Jul 2014 09:47:31 -0400 Subject: PEP8 and 4 spaces References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Gregory Ewing wrote: > As long as *all* your tools follow that convention, everything > is fine. The problems arise when you mix in tools that use > different conventions. The problem is, tools always get mixed. I use emacs. The next guy uses vi. Somebody else uses Sublime. The list goes on and on. You will never control what tools other people use. From mihamina.rakotomandimby at rktmb.org Fri Jul 4 09:59:01 2014 From: mihamina.rakotomandimby at rktmb.org (Mihamina Rakotomandimby) Date: Fri, 04 Jul 2014 16:59:01 +0300 Subject: PEP8 and 4 spaces In-Reply-To: References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53B6B325.7040504@rktmb.org> On 07/04/2014 04:47 PM, Roy Smith wrote: >> As long as*all* your tools follow that convention, everything >> >is fine. The problems arise when you mix in tools that use >> >different conventions. > The problem is, tools always get mixed. I use emacs. The next guy uses > vi. Somebody else uses Sublime. The list goes on and on. You will > never control what tools other people use. This may be the subject of a PEP: "What tool will you use" :-) From invalid at invalid.invalid Fri Jul 4 10:28:52 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 4 Jul 2014 14:28:52 +0000 (UTC) Subject: PEP8 and 4 spaces References: Message-ID: On 2014-07-03, Emile van Sebille wrote: > On 7/3/2014 2:23 PM, Tobiah wrote: >> I think your suggestion of having GIT handle the transformations >> is the way we'll go. nothing to quibble or worry about. Well put >> spaces in the repository since it still seems to be the community's >> preference and I'll convert to tabs with GIT on the fly. Problem >> solved. > > Just watch out for mixed tabs and spaces in the same file -- a tab > counts as eight spaces and can be used interchangeably in python2. Definitely. Indenting with tabs vs. spaces is mostly personal preference (though spaces are better!). But, mixing the two is right out, and should be stomped on hard. -- Grant From marko at pacujo.net Fri Jul 4 10:54:50 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 04 Jul 2014 17:54:50 +0300 Subject: PEP8 and 4 spaces References: Message-ID: <877g3tdvid.fsf@elektro.pacujo.net> Grant Edwards : > Definitely. Indenting with tabs vs. spaces is mostly personal > preference (though spaces are better!). But, mixing the two is right > out, and should be stomped on hard. Often one person writes the code and another person fixes bugs in it or adds features to it. So if one uses tabs and the other refrains from using them, you'll get the mixed style you abhor. Even if we accepted that to be bad style, there's nothing on the screen that would warn against such usage: the lines seemingly align perfectly, and the code runs as expected. Marko From breamoreboy at yahoo.co.uk Fri Jul 4 10:57:15 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 15:57:15 +0100 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: On 04/07/2014 15:28, Grant Edwards wrote: > On 2014-07-03, Emile van Sebille wrote: >> On 7/3/2014 2:23 PM, Tobiah wrote: >>> I think your suggestion of having GIT handle the transformations >>> is the way we'll go. nothing to quibble or worry about. Well put >>> spaces in the repository since it still seems to be the community's >>> preference and I'll convert to tabs with GIT on the fly. Problem >>> solved. >> >> Just watch out for mixed tabs and spaces in the same file -- a tab >> counts as eight spaces and can be used interchangeably in python2. > > Definitely. Indenting with tabs vs. spaces is mostly personal > preference (though spaces are better!). But, mixing the two is right > out, and should be stomped on hard. > Yet another reason to switch to Python 3. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Fri Jul 4 10:58:30 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Jul 2014 00:58:30 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <877g3tdvid.fsf@elektro.pacujo.net> References: <877g3tdvid.fsf@elektro.pacujo.net> Message-ID: On Sat, Jul 5, 2014 at 12:54 AM, Marko Rauhamaa wrote: > Grant Edwards : > >> Definitely. Indenting with tabs vs. spaces is mostly personal >> preference (though spaces are better!). But, mixing the two is right >> out, and should be stomped on hard. > > Often one person writes the code and another person fixes bugs in it or > adds features to it. So if one uses tabs and the other refrains from > using them, you'll get the mixed style you abhor. > > Even if we accepted that to be bad style, there's nothing on the screen > that would warn against such usage: the lines seemingly align perfectly, > and the code runs as expected. That depends on your editor. SciTE, for instance, will give a warning any time indentation changes wrongly; if you mix tabs and spaces, there'll be error markers at the beginning of each change (so if there's one line with eight spaces amid a sea of tabs, that line and the one below it will be marked). ChrisA From breamoreboy at yahoo.co.uk Fri Jul 4 11:00:18 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 16:00:18 +0100 Subject: PEP8 and 4 spaces In-Reply-To: <877g3tdvid.fsf@elektro.pacujo.net> References: <877g3tdvid.fsf@elektro.pacujo.net> Message-ID: On 04/07/2014 15:54, Marko Rauhamaa wrote: > Grant Edwards : > >> Definitely. Indenting with tabs vs. spaces is mostly personal >> preference (though spaces are better!). But, mixing the two is right >> out, and should be stomped on hard. > > Often one person writes the code and another person fixes bugs in it or > adds features to it. So if one uses tabs and the other refrains from > using them, you'll get the mixed style you abhor. > > Even if we accepted that to be bad style, there's nothing on the screen > that would warn against such usage: the lines seemingly align perfectly, > and the code runs as expected. > > Marko > Only for the very old fashioned Python 2, the modern Python 3 has booted mixed tabs and spaces into touch. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Fri Jul 4 11:12:28 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 16:12:28 +0100 Subject: PEP8 and 4 spaces In-Reply-To: <53B6B325.7040504@rktmb.org> References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> <53B6B325.7040504@rktmb.org> Message-ID: On 04/07/2014 14:59, Mihamina Rakotomandimby wrote: > On 07/04/2014 04:47 PM, Roy Smith wrote: >>> As long as*all* your tools follow that convention, everything >>> >is fine. The problems arise when you mix in tools that use >>> >different conventions. >> The problem is, tools always get mixed. I use emacs. The next guy uses >> vi. Somebody else uses Sublime. The list goes on and on. You will >> never control what tools other people use. > > This may be the subject of a PEP: "What tool will you use" :-) I'll nominate our resident unicode expert to write the PEP as he's also an expert on tools. Consider his superb use of the greatly loved google groups for example. Sadly I understand that he has yet to master the intricacies of pip, but I'm sure that'll come with practice, or has he given up? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From marko at pacujo.net Fri Jul 4 11:12:10 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 04 Jul 2014 18:12:10 +0300 Subject: PEP8 and 4 spaces References: <877g3tdvid.fsf@elektro.pacujo.net> Message-ID: <8738ehduph.fsf@elektro.pacujo.net> Mark Lawrence : > Only for the very old fashioned Python 2, the modern Python 3 has > booted mixed tabs and spaces into touch. Since Python 3 (alas!) got into the business of booting, it should have booted tabs altogether. Marko From georger.silva at gmail.com Fri Jul 4 11:14:23 2014 From: georger.silva at gmail.com (George Silva) Date: Fri, 4 Jul 2014 12:14:23 -0300 Subject: PEP8 and 4 spaces In-Reply-To: References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> <53B6B325.7040504@rktmb.org> Message-ID: Isn't this an old discussion? Just configure your editor properly. In my team we all use spaces, but I'll be damned if I need to type 12 spaces in a row. I'll just configured Sublime to insert spaces instead of tabs. Problem solved. On Fri, Jul 4, 2014 at 12:12 PM, Mark Lawrence wrote: > On 04/07/2014 14:59, Mihamina Rakotomandimby wrote: > >> On 07/04/2014 04:47 PM, Roy Smith wrote: >> >>> As long as*all* your tools follow that convention, everything >>>> >is fine. The problems arise when you mix in tools that use >>>> >different conventions. >>>> >>> The problem is, tools always get mixed. I use emacs. The next guy uses >>> vi. Somebody else uses Sublime. The list goes on and on. You will >>> never control what tools other people use. >>> >> >> This may be the subject of a PEP: "What tool will you use" :-) >> > > I'll nominate our resident unicode expert to write the PEP as he's also an > expert on tools. Consider his superb use of the greatly loved google > groups for example. Sadly I understand that he has yet to master the > intricacies of pip, but I'm sure that'll come with practice, or has he > given up? > > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- George R. C. Silva SIGMA Consultoria ---------------------------- http://www.consultoriasigma.com.br/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From emile at fenx.com Fri Jul 4 11:57:09 2014 From: emile at fenx.com (Emile van Sebille) Date: Fri, 04 Jul 2014 08:57:09 -0700 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: On 7/4/2014 7:57 AM, Mark Lawrence wrote: > On 04/07/2014 15:28, Grant Edwards wrote: >> On 2014-07-03, Emile van Sebille wrote: >>> Just watch out for mixed tabs and spaces in the same file -- a tab >>> counts as eight spaces and can be used interchangeably in python2. >> >> Definitely. Indenting with tabs vs. spaces is mostly personal >> preference (though spaces are better!). But, mixing the two is right >> out, and should be stomped on hard. >> > > Yet another reason to switch to Python 3. For new projects, sure. But since the v1.5 days I've deployed the current python version a dozen times a year on various one-offs so that I'm sure I've got every python version deployed somewhere, and they just run, so why fix something that works. Or upgrade it when a three line fix addresses the issue. Emile From python at mrabarnett.plus.com Fri Jul 4 11:57:19 2014 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 04 Jul 2014 16:57:19 +0100 Subject: Why is regexp not working? In-Reply-To: References: Message-ID: <53B6CEDF.1060905@mrabarnett.plus.com> On 2014-07-04 13:27, Florian Lindner wrote: > Hello, > > I have that piece of code: > > def _split_block(self, block): > cre = [re.compile(r, flags = re.MULTILINE) for r in self.regexps] > block = "".join(block) > print(block) > print("-------------------") > for regexp in cre: > match = regexp.match(block) > for grp in regexp.groupindex: > data = match.group(grp) if match else None > self.data[grp].append(data) > > > block is a list of strings, terminated by \n. self.regexps: > > > self.regexps = [r"it (?P\d+) .* dt complete yes | > write-iteration-checkpoint |", > r"it (?P\d+) read ahead" > > > If I run my program it looks like that: > > > it 1 ahadf dt complete yes | write-iteration-checkpoint | > Timestep completed > > ------------------- > it 1 read ahead > it 2 ahgsaf dt complete yes | write-iteration-checkpoint | > Timestep completed > > ------------------- > it 4 read ahead > it 3 dfdsag dt complete yes | write-iteration-checkpoint | > Timestep completed > > ------------------- > it 9 read ahead > it 4 dsfdd dt complete yes | write-iteration-checkpoint | > Timestep completed > > ------------------- > it 16 read ahead > ------------------- > {'it_read_ahead': [None, '1', '4', '9', '16'], 'coupling_iterations': ['1', > None, None, None, None]} > > it_read_ahead is always matched when it should (all blocks but the first). > But why is the regexp containing coupling_iterations only matched in the > first block? > > I tried different combinations using re.match vs. re.search and with or > without re.MULTILINE. > The character '|' is a metacharacter that separates alternatives. For example, the regex 'a|b' will match 'a' or b'. Your regexes end with '|', which means that they will match an empty string at the start of the target string. From breamoreboy at yahoo.co.uk Fri Jul 4 12:06:02 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 17:06:02 +0100 Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: On 04/07/2014 16:57, Emile van Sebille wrote: > On 7/4/2014 7:57 AM, Mark Lawrence wrote: >> On 04/07/2014 15:28, Grant Edwards wrote: >>> On 2014-07-03, Emile van Sebille wrote: > >>>> Just watch out for mixed tabs and spaces in the same file -- a tab >>>> counts as eight spaces and can be used interchangeably in python2. >>> >>> Definitely. Indenting with tabs vs. spaces is mostly personal >>> preference (though spaces are better!). But, mixing the two is right >>> out, and should be stomped on hard. >>> >> >> Yet another reason to switch to Python 3. > > For new projects, sure. But since the v1.5 days I've deployed the > current python version a dozen times a year on various one-offs so that > I'm sure I've got every python version deployed somewhere, and they just > run, so why fix something that works. Or upgrade it when a three line > fix addresses the issue. > > Emile > Surely the issue of mixing tabs and spaces is much more important than working systems? :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From fiedzia at gmail.com Fri Jul 4 12:19:24 2014 From: fiedzia at gmail.com (Maciej Dziardziel) Date: Fri, 4 Jul 2014 09:19:24 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: <86b5df79-fef3-438a-bc88-10e39ea96bce@googlegroups.com> > Surely the issue of mixing tabs and spaces is much more important than > > working systems? :) Python 3 considers tabs as an error and refuses to work. From roy at panix.com Fri Jul 4 12:31:24 2014 From: roy at panix.com (Roy Smith) Date: Fri, 04 Jul 2014 12:31:24 -0400 Subject: PEP8 and 4 spaces References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> <53B6B325.7040504@rktmb.org> Message-ID: In article , George Silva wrote: > Isn't this an old discussion? Just configure your editor properly. In my > team we all use spaces, but I'll be damned if I need to type 12 spaces in a > row. I'll just configured Sublime to insert spaces instead of tabs. Problem > solved. On emacs, I used auto-indent mode. I hit tab, and it automatically inserts the correct number of spaces (where "correct" is language-specific; for Python, it uses the pep-8 rules). It also does syntax highlighting, parenthesis and quote matching, keyword recognition, etc. I assume any sane editor has similar functionality. I see my coworkers using vim, sublime, eclipse, and X-code. They all appear to do these things, and I would thus classify any of them as sane editors. I'm sure there are others. If the tool you're (in the generic sense of "you") using doesn't have this type of basic language support, you should reconsider your choice of tool. From steve+comp.lang.python at pearwood.info Fri Jul 4 12:56:16 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jul 2014 16:56:16 GMT Subject: PEP8 and 4 spaces References: <86b5df79-fef3-438a-bc88-10e39ea96bce@googlegroups.com> Message-ID: <53b6dcb0$0$29985$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Jul 2014 09:19:24 -0700, Maciej Dziardziel wrote: >> Surely the issue of mixing tabs and spaces is much more important than >> working systems? :) > > > Python 3 considers tabs as an error and refuses to work. Incorrect. [steve at ando ~]$ python3 Python 3.3.0rc3 (default, Sep 27 2012, 18:44:58) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux Type "help", "copyright", "credits" or "license" for more information. === startup script executed === py> code = """ ... def func(): ... \treturn 23 ... ... print( func() + 1000 ) ... """ py> py> exec(code) 1023 -- Steven From georger.silva at gmail.com Fri Jul 4 12:37:19 2014 From: georger.silva at gmail.com (George Silva) Date: Fri, 4 Jul 2014 13:37:19 -0300 Subject: PEP8 and 4 spaces In-Reply-To: References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> <53B6B325.7040504@rktmb.org> Message-ID: > I assume any sane editor has similar functionality. I see my coworkers > using vim, sublime, eclipse, and X-code. They all appear to do these > things, and I would thus classify any of them as sane editors. I'm sure > there are others. If the tool you're (in the generic sense of "you") > using doesn't have this type of basic language support, you should > reconsider your choice of tool Could not agree more :D -------------- next part -------------- An HTML attachment was scrubbed... URL: From irmen.NOSPAM at xs4all.nl Fri Jul 4 13:05:14 2014 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 04 Jul 2014 19:05:14 +0200 Subject: general module auditing In-Reply-To: References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> Message-ID: <53b6deca$0$2907$e4fe514c@news.xs4all.nl> On 4-7-2014 1:09, Rita wrote: > > here is what I am doing now, > > egrep 'from|import' *.py | wc -l which is giving me that. But this does not > give me the number of times the particular module gets called. I was > thinking of adding a logging feature to all of my modules so every time > they get called it will be written to a log file with corresponding host > and username. Is there an easy way to do that? Okay I've read up a bit on Python import hooks and came up with the following code. It hooks into Python's import mechanim by putting a custom loader into sys.meta_path that logs the time, the user, the machine and the name of the module being imported. Theoretically you could load this as a startup module (sitecustomize.py?) and make it log to a central location or something like that. The code at the end of this message outputs the following on my machine: $ python audit.py Hello I'm about to import a module. 2014-07-04 19:01:12,321 [irmen at Neptune] importing /cgi 2014-07-04 19:01:12,323 [irmen at Neptune] importing /urlparse 2014-07-04 19:01:12,328 [irmen at Neptune] importing /mimetools [... and some more modules...] Bye. Code follows: import sys import logging import socket import os import getpass def setup_import_logging(): class ContextFilter(logging.Filter): def filter(self, record): record.hostname = socket.gethostname() if sys.version_info < (3, 0): record.username = getpass.getuser() else: record.username = os.getlogin() return True # configure the logger, adapt as desired: logging.basicConfig(level=logging.DEBUG, format="%(asctime)s [%(username)s@%(hostname)s] %(message)s") class AuditingImporter(object): log = logging.getLogger("auditingimporter") log.setLevel(logging.DEBUG) log.addFilter(ContextFilter()) def find_module(self, fullname, path): return self.find_spec(fullname, path) def find_spec(self, fullname, path, target=None): self.log.debug("importing {path}/{fullname}".format(path=path or "", fullname=fullname)) return None sys.meta_path.insert(0, AuditingImporter()) setup_import_logging() print("Hello I'm about to import a module.") import cgi # will generate a load of logging entries print("Bye.") From irmen.NOSPAM at xs4all.nl Fri Jul 4 13:10:30 2014 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Fri, 04 Jul 2014 19:10:30 +0200 Subject: general module auditing In-Reply-To: <53b6deca$0$2907$e4fe514c@news.xs4all.nl> References: <53b2fae4$0$2878$e4fe514c@news.xs4all.nl> <53b4539b$0$2901$e4fe514c@news.xs4all.nl> <53b6deca$0$2907$e4fe514c@news.xs4all.nl> Message-ID: <53b6e005$0$2967$e4fe514c@news.xs4all.nl> On 4-7-2014 19:05, Irmen de Jong wrote: > The code at the end of this message outputs the following on my machine: [...] hmm the formatting got screwed up a bit it seems. Here's the same code: https://gist.github.com/irmen/c3d07118a8e1a00367f5 Irmen From lie.1296 at gmail.com Fri Jul 4 14:29:35 2014 From: lie.1296 at gmail.com (Lie Ryan) Date: Fri, 04 Jul 2014 19:29:35 +0100 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 04/07/14 07:55, Gregory Ewing wrote: > Steven D'Aprano wrote: > >>> That's exactly the problem with tabs - whatever you think your code >>> looks like with tabs, other people will see quite different picture. >> >> Why do you consider this a problem? > > It's a problem if you try to use tabs for lining things > up in a tabular fashion in your source code. > > The solution is not to use tabs for that -- only use > tabs for indentation, and use spaces for everything > else. Or, as PEP 8 suggests, don't try to line things > up in the first place. PEP8 suggests using this style of method invocation: obj.method(foo, bar, baz) which is an effect impossible to do correctly with tabs alone. If you want to follow this style strictly, you end up having to either mix tabs and spaces, or just use spaces, or as I prefer it, avoid the issue altogether: obj.method( foo, bar, baz, ) From simon+python at bleah.co.uk Fri Jul 4 14:52:03 2014 From: simon+python at bleah.co.uk (Simon Ward) Date: Fri, 04 Jul 2014 19:52:03 +0100 Subject: PEP8 and 4 spaces In-Reply-To: <877g3tdvid.fsf@elektro.pacujo.net> References: <877g3tdvid.fsf@elektro.pacujo.net> Message-ID: On 4 July 2014 15:54:50 BST, Marko Rauhamaa wrote: >Even if we accepted that to be bad style, there's nothing on the screen >that would warn against such usage: the lines seemingly align >perfectly, >and the code runs as expected. If using vim, set list and listchars, you get to highlight tabs and trailing spaces. Simon From roy at panix.com Fri Jul 4 15:04:05 2014 From: roy at panix.com (Roy Smith) Date: Fri, 04 Jul 2014 15:04:05 -0400 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Lie Ryan wrote: > PEP8 suggests using this style of method invocation: > > obj.method(foo, > bar, > baz) > > which is an effect impossible to do correctly with tabs alone. If course you can do it with tabs. Just make sure all your method names are 7 letters long :-) From breamoreboy at yahoo.co.uk Fri Jul 4 15:50:01 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 04 Jul 2014 20:50:01 +0100 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 04/07/2014 20:04, Roy Smith wrote: > In article , > Lie Ryan wrote: > >> PEP8 suggests using this style of method invocation: >> >> obj.method(foo, >> bar, >> baz) >> >> which is an effect impossible to do correctly with tabs alone. > > If course you can do it with tabs. Just make sure all your method names > are 7 letters long :-) > When the homework gets handed in I guess the lecturer will know who's read this thread :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rxjwg98 at gmail.com Fri Jul 4 17:50:02 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Fri, 4 Jul 2014 14:50:02 -0700 (PDT) Subject: This Python script cannot open by a editor? Message-ID: <62a534ec-c22f-451e-80f7-c6f49a8cbcc1@googlegroups.com> Hi, I am learning a Python Tool from web: http://www.ohwr.org/projects/hdl-make/wiki/Quick-start-new I download the program to Ubuntu 12.04. I find that in the folder it is shown as hdlmake-v1.0, 37.8 KB Python Script. I remember that script file can be loaded to an editor to read its content. But, when I open it by double click, it is shown as like binary file in GEDIT. What is the reason of this? A general Python file has .py extension, and can be edited. Is it right? Thanks From jkn_gg at nicorp.f9.co.uk Fri Jul 4 18:06:47 2014 From: jkn_gg at nicorp.f9.co.uk (jkn) Date: Fri, 4 Jul 2014 15:06:47 -0700 (PDT) Subject: This Python script cannot open by a editor? In-Reply-To: <62a534ec-c22f-451e-80f7-c6f49a8cbcc1@googlegroups.com> References: <62a534ec-c22f-451e-80f7-c6f49a8cbcc1@googlegroups.com> Message-ID: Hi there the script is 'actually' a python script compressed, with a short header (see the '#!/usr/bin/python' right at the front? I'm guessing that if you make it executable, and run it, then it will either create a .py file that you can edit, or just run the hdlmake function that you want. This is not very well explained on the wiki page that you link to... you might also try downloading the alternative distributions on the download page. HTH jon N From greg.ewing at canterbury.ac.nz Fri Jul 4 19:14:46 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sat, 05 Jul 2014 11:14:46 +1200 Subject: PEP8 and 4 spaces In-Reply-To: References: <53b5fd2f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Roy Smith wrote: > The problem is, tools always get mixed. I use emacs. The next guy uses > vi. Somebody else uses Sublime. The list goes on and on. You will > never control what tools other people use. Yes, but my point is that none of the tools are "broken", they're just incompatible. -- Greg From greg.ewing at canterbury.ac.nz Fri Jul 4 19:17:13 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sat, 05 Jul 2014 11:17:13 +1200 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Lie Ryan wrote: > PEP8 suggests using this style of method invocation: > > obj.method(foo, > bar, > baz) > > which is an effect impossible to do correctly with tabs alone. Yes, PEP 8 is self-contradictory in that regard. I also happen to think that recommendation is insane for other reasons as well, and cheerfully ignore it. -- Greg From python.list at tim.thechases.com Fri Jul 4 19:35:34 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Fri, 4 Jul 2014 18:35:34 -0500 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20140704183534.72e3714b@bigbox.christie.dr> On 2014-07-05 11:17, Gregory Ewing wrote: > > PEP8 suggests using this style of method invocation: > > > > obj.method(foo, > > bar, > > baz) > > > > which is an effect impossible to do correctly with tabs alone. > > Yes, PEP 8 is self-contradictory in that regard. > I also happen to think that recommendation is insane > for other reasons as well, and cheerfully ignore it. To be fair, in the same section[1] that example is given, it also suggests # More indentation included to distinguish this from the rest. def long_function_name( var_one, var_two, var_three, var_four): print(var_one) # Hanging indents should add a level. foo = long_function_name( var_one, var_two, var_three, var_four) both of which can be done with arbitrary indentation without the need to mix tabs+spaces or use a non-integer multiple of indentation-spaces. I just use these two in all instances and (as you, Greg, advise), "cheerfully ignore [the first form]" The only time I intentionally violate the "don't do these" section """ # Arguments on first line forbidden when not using vertical alignment. foo = long_function_name(var_one, var_two, var_three, var_four) """ is when defining options in optparse: parser.add_option("-v", "--verbose", help="be prolix", action="store_true", dest="verbose", default=False, ) as I find that a little easier to read when I'm scanning large blocks of parser.add_option(...) calls, having the option stick out to the right. -tkc [1] http://legacy.python.org/dev/peps/pep-0008/#indentation From steve+comp.lang.python at pearwood.info Fri Jul 4 19:37:30 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 04 Jul 2014 23:37:30 GMT Subject: This Python script cannot open by a editor? References: <62a534ec-c22f-451e-80f7-c6f49a8cbcc1@googlegroups.com> Message-ID: <53b73ab9$0$29985$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Jul 2014 14:50:02 -0700, rxjwg98 wrote: > Hi, > > I am learning a Python Tool from web: > http://www.ohwr.org/projects/hdl-make/wiki/Quick-start-new Did you read that web page? It says: To get the code you have two choices: you might clone the repository, which contains the most recent changes (more features, more bugs too...) or download a frozen version in a form of a "binary" file. > I download the program to Ubuntu 12.04. I find that in the folder it is > shown as hdlmake-v1.0, 37.8 KB Python Script. At the bash shell from inside that folder, run: file hdlmake-v1.0 What does it say? > I remember that script > file can be loaded to an editor to read its content. But, when I open it > by double click, it is shown as like binary file in GEDIT. > > What is the reason of this? Because it is a binary file. > A general Python file has .py extension, and can be edited. Is it right? Python *source code* normally has a .py extension, although it could have no extension at all. Python *byte code* is a binary file, usually with a .pyc or .pyo extension. On Windows, sometimes you also get .pyw. You can also get Python code inside a zip file, which may have a .zip extension. On Windows, you can get Python code frozen in a .exe file, and I believe on Mac you can get it frozen in a .app file. -- Steven From rantingrickjohnson at gmail.com Fri Jul 4 22:00:51 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 4 Jul 2014 19:00:51 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: Message-ID: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> On Thursday, July 3, 2014 12:31:04 PM UTC-5, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces I'm saddened that every one of these little "tabs versus spaces" arguments revolve more around selfishness and less around an understanding of what a "tabs" and "spaces" actually *are*, because, how can you solve a problem when you're unable to understand the fundamental dicotomoy of this relationship between "tabs" and "spaces"? I believe the whole issue can be boiled down into: "Use the correct tool for the job". And there in lies the rub, before we can make the *choice*, we must comprehend the *differences*. ============================================================ What is a "space" ============================================================ Duh! ============================================================ What is a "tab" ============================================================ We all know "tabs" are used to present text in tabular form (aka: tables), however, tabs are much more than merely a "concatenation-of-N-spaces". Not only do tabs allow a user to control alignments via the mechanical process of pressing the "tab key", tabs also allow a more powerful and precise "hook" into the underlying mechinism of vertical alignments via "rules" defined by the user. AND THIS LAST POINT IS THE TRUE POWER OF "TABS"! Yes, "tabs" are an extrapolation of "spaces", but they are also more powerful than a "space" could ever be. If we imagine "spaces" and "backspaces" to be like *addtion* and *subtraction*, we can extrapolate that "tabs" and um, well, "backtabs" to be like *multiplication* and *division* -- not in a quantitve sense of course, but in an "exponentially more powerful" sense. ============================================================ Tabs or spaces? ============================================================ And now we must answer the burning question. Not that my habits really matter but I myself use only spaces and NEVER tabs, and i only use four spaces, never more, never less,,, and i don't use spaces because i prefer spaces over tabs, no, i use spaces because spaces are going to render the same in all editors. Strangly, I rather fancy the idea of using tabs in code,,, which allow each viewer to view the code in his or her level of indention,,, however, i cannot justify using a tab as a replacement for a space. Tabs should be used for "tabular" data (aka: speadsheets), and since code is NOT tabular data, we would be wise to use the space char for indention. from brain import logic From rantingrickjohnson at gmail.com Fri Jul 4 22:47:45 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 4 Jul 2014 19:47:45 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> [A continuation of my last reply...] Here is a recent situation that occurred to me that showcases the tendency of humans to carelessly bind illogical terms to common objects, thereby creating a inverse esoteric of ubiquitous illogic, in this case, the term: "flash-light". ============================================================ Illuminating the illogical: ============================================================ A friend and myself where working outside and as the light began to fade he realized we needed a light source, so he called out: "SOMEBODY GET ME A FLASH-LIGHT!" As i was heading in to grab a "flashlight" i realized the bombastic insanity of such a term. Why is a handheld light called a flashlight? It does not flash, in fact, its main purpose is to provide a consistent light source that is easy to carry, whereas flashing would be quite annoying! *And just then that mischievous little inner voice started whispering in my ear, giving me "ideas", Muahahah!* So i returned to my friend who was already quite annoyed with his repair project, and started "flashing" the light on and off. He quickly turned around and demanded: "What the hell are you doing?", to which i replied, "You asked for a flash-light, yes?" Of course everyone knows that a flash light does not "flash", so why do we continue to propagate such foolish terms? Well, for the same reason language designers keep giving us illogical terms like "function" and "class", but i digress. The point is we go around the world falsely believing we have a strong grasp of the simple things, when in fact, a whole world of illogic infects our understanding of even the most basic aspects of our lives. Of course, I'm anxiously await my friend to ask for a "drop light" -- oh boy, that will be fun! >:^) From sqlite-users-bounces at sqlite.org Sat Jul 5 01:00:22 2014 From: sqlite-users-bounces at sqlite.org (sqlite-users-bounces at sqlite.org) Date: Sat, 05 Jul 2014 01:00:22 -0400 Subject: Your message to sqlite-users awaits moderator approval Message-ID: Your mail to 'sqlite-users' with the subject hi Is being held until the list moderator can review it for approval. The reason it is being held: Post by non-member to a members-only list Either the message will get posted to the list, or you will receive notification of the moderator's decision. If you would like to cancel this posting, please visit the following URL: http://sqlite.org:8080/cgi-bin/mailman/confirm/sqlite-users/2d7d8debd5e7f2d664ffa70c079cc75008d59b73 From hayesstw at telkomsa.net Sat Jul 5 02:19:15 2014 From: hayesstw at telkomsa.net (Steve Hayes) Date: Sat, 05 Jul 2014 08:19:15 +0200 Subject: Your message to sqlite-users awaits moderator approval References: Message-ID: <626fr91acpkkurmaqglrs183ejl7vf1udh@4ax.com> On Sat, 05 Jul 2014 01:00:22 -0400, sqlite-users-bounces at sqlite.org wrote: >Your mail to 'sqlite-users' with the subject > > hi > >Is being held until the list moderator can review it for approval. > >The reason it is being held: > > Post by non-member to a members-only list So has someone tried to gate the comp.lang.python newsgroup to an Sqlite mailing list without the list owner's permission? -- Steve Hayes from Tshwane, South Africa Web: http://www.khanya.org.za/stevesig.htm Blog: http://khanya.wordpress.com E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk From rosuav at gmail.com Sat Jul 5 02:35:50 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Jul 2014 16:35:50 +1000 Subject: Your message to sqlite-users awaits moderator approval In-Reply-To: <626fr91acpkkurmaqglrs183ejl7vf1udh@4ax.com> References: <626fr91acpkkurmaqglrs183ejl7vf1udh@4ax.com> Message-ID: On Sat, Jul 5, 2014 at 4:19 PM, Steve Hayes wrote: > On Sat, 05 Jul 2014 01:00:22 -0400, sqlite-users-bounces at sqlite.org wrote: > >>Your mail to 'sqlite-users' with the subject >> >> hi >> >>Is being held until the list moderator can review it for approval. >> >>The reason it is being held: >> >> Post by non-member to a members-only list > > So has someone tried to gate the comp.lang.python newsgroup to an Sqlite > mailing list without the list owner's permission? More likely someone just posted a piece of spam with a forged From address. If some piece of malware got access to somebody's address book and started sending spam "from" one address to another address, picked at random, it's entirely possible that it'd pick two list addresses. At that point, the target list will get an email from an address it doesn't recognize, and what you see above happens - non-members aren't allowed to post to most lists (without a mod's approval; I run a list for a local society's committee, and it's normal for people to send something to the committee who aren't members of it, so those posts go to the moderation queue), and the post gets bounced. When it first came in, I clicked on the link to cancel the post, but someone beat me to it. :) ChrisA From travisgriggs at gmail.com Sat Jul 5 03:51:32 2014 From: travisgriggs at gmail.com (Travis Griggs) Date: Sat, 5 Jul 2014 00:51:32 -0700 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53b6019f$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <934AB143-020F-44BD-991A-6A7F3FD59009@gmail.com> > On Jul 4, 2014, at 11:29, Lie Ryan wrote: > >> On 04/07/14 07:55, Gregory Ewing wrote: >> Steven D'Aprano wrote: >> >>>> That's exactly the problem with tabs - whatever you think your code >>>> looks like with tabs, other people will see quite different picture. >>> >>> Why do you consider this a problem? >> >> It's a problem if you try to use tabs for lining things >> up in a tabular fashion in your source code. >> >> The solution is not to use tabs for that -- only use >> tabs for indentation, and use spaces for everything >> else. Or, as PEP 8 suggests, don't try to line things >> up in the first place. > > PEP8 suggests using this style of method invocation: > > obj.method(foo, > bar, > baz) > > which is an effect impossible to do correctly with tabs alone. If you want to follow this style strictly, you end up having to either mix tabs and spaces, or just use spaces, or as I prefer it, avoid the issue altogether: > > obj.method( > foo, > bar, > baz, > ) Ok, here's irony. I'm looking at that thinking "what the heck is he talking about?!?". And then my brain catches up. My mail reader is of course "modern" and does not use a mono space font. So the value of the along ed indent is lost anyway. But wasn't that what spaces were supposed to give us over tabs, some separation from the trading betwixt different editors? Chuckle. Travis Griggs From rosuav at gmail.com Fri Jul 4 23:03:05 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 5 Jul 2014 13:03:05 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> Message-ID: On Sat, Jul 5, 2014 at 12:47 PM, Rick Johnson wrote: > Of course, I'm anxiously await my friend to ask for a "drop > light" -- oh boy, that will be fun! >:^) Just wait till you get into theatre, and people start asking for parcans, domes, bubbles, gobos, gels, and workers. If you can't learn a little technical terminology for the field you're in, you're in the wrong universe. ChrisA From greg.ewing at canterbury.ac.nz Sat Jul 5 04:57:14 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sat, 05 Jul 2014 20:57:14 +1200 Subject: PEP8 and 4 spaces In-Reply-To: <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> Message-ID: Rick Johnson wrote: > Why is a handheld light > called a flashlight? It does not flash, According to Wikipedia, originally it did: "Early flashlights ran on zinc?carbon batteries, which could not provide a steady electric current and required periodic 'rest' to continue functioning. Because these early flashlights also used energy-inefficient carbon-filament bulbs, "resting" occurred at short intervals. Consequently, they could be used only in brief flashes, hence the common American name flashlight." Of course, in sane parts of the world, we call them torches. :-) -- Greg From alister.nospam.ware at ntlworld.com Sat Jul 5 05:48:55 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Sat, 05 Jul 2014 09:48:55 GMT Subject: PEP8 and 4 spaces References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> Message-ID: On Sat, 05 Jul 2014 20:57:14 +1200, Gregory Ewing wrote: > Rick Johnson wrote: >> Why is a handheld light called a flashlight? It does not flash, > > According to Wikipedia, originally it did: > > "Early flashlights ran on zinc?carbon batteries, which could not provide > a steady electric current and required periodic 'rest' to continue > functioning. Because these early flashlights also used > energy-inefficient carbon-filament bulbs, "resting" occurred at short > intervals. Consequently, they could be used only in brief flashes, hence > the common American name flashlight." > > Of course, in sane parts of the world, we call them torches. :-) +1 don't just use the correct tool fro the job use the correct name for the tool ;-) -- If your bread is stale, make toast. From steve+comp.lang.python at pearwood.info Sat Jul 5 06:15:32 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 05 Jul 2014 10:15:32 GMT Subject: OT: Flashlights [was Re: PEP8 and 4 spaces] References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> Message-ID: <53b7d044$0$29985$c3e8da3$5496439d@news.astraweb.com> On Fri, 04 Jul 2014 19:47:45 -0700, Rick Johnson wrote: > [A continuation of my last reply...] > > Here is a recent situation that occurred to me that showcases the > tendency of humans to carelessly bind illogical terms to common objects, I think you mean the tendency of certain people to go off half-cocked and mistake their own ignorance for knowledge. "Since I personally don't know why flashlights are called that name, it clearly MUST BE that there is no reason for that name!!!" (By the way, outside of the USA, flashlights in the rest of the English- speaking world are usually called "torches", so called because, like the old-fashioned burning torch, they provide light.) > thereby creating a inverse esoteric of ubiquitous illogic, in this case, > the term: "flash-light". A few minutes googling would have given you the answer: flashlights are called flashlights because originally you could only flash them on and off. Due to the high power requirements and the low battery capacities at the time, leaving the torch switched on would burn out the filament, exhaust the battery, or both. The Oxford Dictionary also points out that "flashlight" is a term used for signalling and warning lights, such as in lighthouses. It doesn't say whether the signalling use inspired, or was inspired by, the hand-held flashlight. I expect that, since electric lighthouses are more than two decades older than flashlights, that usage came first. Both the flashlight and the flash bulb were first patented in 1899, and it is possible that the name of one was influenced by the name of the other. Flash bulbs used an electrically-ignited filament of magnesium to provide a single, extremely bright, flash of light. They replaced the older system of a small trough of flash powder (a mixture of magnesium and potassium chlorate) ignited in the air. So far from being an illogical term, the name "flashlight" actually gives you a glimpse into the historical background of the invention. > Of course everyone knows that a flash light does not "flash", "Everybody" is wrong. I have torches (flashlights) with a "flash" function, where they flash on and off. I've also owned torches where they had a switch to turn them on and give a steady, hands-free light, and a second button that only generated light while it was held down. > so why do we continue to propagate such foolish terms? Not a foolish term, merely a sign that technology marches on. > Well, for the same reason > language designers keep giving us illogical terms like "function" and > "class", but i digress. Oh my, I can hardly wait to hear this. It ought to be good. > The point is we go around the world falsely believing we have a strong > grasp of the simple things Speak for yourself. Oh, I see you are! -- Steven From ian.g.kelly at gmail.com Sat Jul 5 14:57:11 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 5 Jul 2014 12:57:11 -0600 Subject: PEP8 and 4 spaces In-Reply-To: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: On Fri, Jul 4, 2014 at 8:00 PM, Rick Johnson wrote: > Strangly, I rather fancy the idea of using tabs in code,,, > which allow each viewer to view the code in his or her level > of indention,,, however, i cannot justify using a tab as a > replacement for a space. Tabs should be used for "tabular" > data (aka: speadsheets), and since code is NOT tabular data, > we would be wise to use the space char for indention. I find it a little curious that nobody ever seems to advocate the use of vertical tabs instead of repeated newlines. It should offer the same benefit as horizontal tabs, namely that one could then independently configure one's editor to separate adjacent code elements with the desired number of blank lines. But I suppose that nobody finds that useful enough to bother with in the vertical case. From roy at panix.com Sat Jul 5 15:07:17 2014 From: roy at panix.com (Roy Smith) Date: Sat, 05 Jul 2014 15:07:17 -0400 Subject: PEP8 and 4 spaces References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: In article , Ian Kelly wrote: > On Fri, Jul 4, 2014 at 8:00 PM, Rick Johnson > wrote: > > Strangly, I rather fancy the idea of using tabs in code,,, > > which allow each viewer to view the code in his or her level > > of indention,,, however, i cannot justify using a tab as a > > replacement for a space. Tabs should be used for "tabular" > > data (aka: speadsheets), and since code is NOT tabular data, > > we would be wise to use the space char for indention. > > I find it a little curious that nobody ever seems to advocate the use > of vertical tabs instead of repeated newlines. It should offer the > same benefit as horizontal tabs, namely that one could then > independently configure one's editor to separate adjacent code > elements with the desired number of blank lines. But I suppose that > nobody finds that useful enough to bother with in the vertical case. Personally, I'm holding out for U+00A0 being a valid character in an identifier. Intercourse this underscore stuff. From robert.kern at gmail.com Sat Jul 5 16:07:26 2014 From: robert.kern at gmail.com (Robert Kern) Date: Sat, 05 Jul 2014 21:07:26 +0100 Subject: PEP8 and 4 spaces In-Reply-To: References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: On 2014-07-05 19:57, Ian Kelly wrote: > On Fri, Jul 4, 2014 at 8:00 PM, Rick Johnson > wrote: >> Strangly, I rather fancy the idea of using tabs in code,,, >> which allow each viewer to view the code in his or her level >> of indention,,, however, i cannot justify using a tab as a >> replacement for a space. Tabs should be used for "tabular" >> data (aka: speadsheets), and since code is NOT tabular data, >> we would be wise to use the space char for indention. > > I find it a little curious that nobody ever seems to advocate the use > of vertical tabs instead of repeated newlines. It should offer the > same benefit as horizontal tabs, namely that one could then > independently configure one's editor to separate adjacent code > elements with the desired number of blank lines. But I suppose that > nobody finds that useful enough to bother with in the vertical case. I do see the occasional person using form feeds to separate sections of code. -- 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 torriem at gmail.com Sat Jul 5 18:03:16 2014 From: torriem at gmail.com (Michael Torrie) Date: Sat, 05 Jul 2014 16:03:16 -0600 Subject: PEP8 and 4 spaces In-Reply-To: <877g3tdvid.fsf@elektro.pacujo.net> References: <877g3tdvid.fsf@elektro.pacujo.net> Message-ID: <53B87624.7060806@gmail.com> On 07/04/2014 08:54 AM, Marko Rauhamaa wrote: > Grant Edwards : > >> Definitely. Indenting with tabs vs. spaces is mostly personal >> preference (though spaces are better!). But, mixing the two is right >> out, and should be stomped on hard. > > Often one person writes the code and another person fixes bugs in it or > adds features to it. So if one uses tabs and the other refrains from > using them, you'll get the mixed style you abhor. > > Even if we accepted that to be bad style, there's nothing on the screen > that would warn against such usage: the lines seemingly align perfectly, > and the code runs as expected. Or more likely the lines seemingly align perfectly and the code does not compile and run, or worse it does run but does not do the right thing. From breamoreboy at yahoo.co.uk Sat Jul 5 18:50:14 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 05 Jul 2014 23:50:14 +0100 Subject: PEP8 and 4 spaces In-Reply-To: <53B87624.7060806@gmail.com> References: <877g3tdvid.fsf@elektro.pacujo.net> <53B87624.7060806@gmail.com> Message-ID: On 05/07/2014 23:03, Michael Torrie wrote: > On 07/04/2014 08:54 AM, Marko Rauhamaa wrote: >> Grant Edwards : >> >>> Definitely. Indenting with tabs vs. spaces is mostly personal >>> preference (though spaces are better!). But, mixing the two is right >>> out, and should be stomped on hard. >> >> Often one person writes the code and another person fixes bugs in it or >> adds features to it. So if one uses tabs and the other refrains from >> using them, you'll get the mixed style you abhor. >> >> Even if we accepted that to be bad style, there's nothing on the screen >> that would warn against such usage: the lines seemingly align perfectly, >> and the code runs as expected. > > Or more likely the lines seemingly align perfectly and the code does not > compile and run, or worse it does run but does not do the right thing. > Some commentators lead me to believe that the latter is perfectly acceptable so long as the code runs quickly. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Sat Jul 5 19:27:59 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 6 Jul 2014 09:27:59 +1000 Subject: PEP8 and 4 spaces In-Reply-To: References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: On Sun, Jul 6, 2014 at 4:57 AM, Ian Kelly wrote: > I find it a little curious that nobody ever seems to advocate the use > of vertical tabs instead of repeated newlines. It should offer the > same benefit as horizontal tabs, namely that one could then > independently configure one's editor to separate adjacent code > elements with the desired number of blank lines. But I suppose that > nobody finds that useful enough to bother with in the vertical case. How often do you ever have multiple consecutive blank lines? My newlines are either single (line end) or in pairs (one blank line), and I don't remember having anything else (at least, not intentionally). Greater separation than a blank line is provided by comments, not more whitespace. ChrisA From dan at tombstonezero.net Sat Jul 5 21:18:36 2014 From: dan at tombstonezero.net (Dan Sommers) Date: Sun, 6 Jul 2014 01:18:36 +0000 (UTC) Subject: PEP8 and 4 spaces References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: On Sun, 06 Jul 2014 09:27:59 +1000, Chris Angelico wrote: > How often do you ever have multiple consecutive blank lines? My > newlines are either single (line end) or in pairs (one blank line), > and I don't remember having anything else (at least, not > intentionally). Greater separation than a blank line is provided by > comments, not more whitespace. > > ChrisA http://legacy.python.org/dev/peps/pep-0008/#id15 says: "Separate top-level function and class definitions with two blank lines." With docstrings occurring inside function definitions, this happens quite a bit. Dan From rosuav at gmail.com Sat Jul 5 21:28:21 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 6 Jul 2014 11:28:21 +1000 Subject: PEP8 and 4 spaces In-Reply-To: References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> Message-ID: On Sun, Jul 6, 2014 at 11:18 AM, Dan Sommers wrote: > On Sun, 06 Jul 2014 09:27:59 +1000, Chris Angelico wrote: > >> How often do you ever have multiple consecutive blank lines? My >> newlines are either single (line end) or in pairs (one blank line), >> and I don't remember having anything else (at least, not >> intentionally). Greater separation than a blank line is provided by >> comments, not more whitespace. >> >> ChrisA > > http://legacy.python.org/dev/peps/pep-0008/#id15 says: "Separate top-level > function and class definitions with two blank lines." > > With docstrings occurring inside function definitions, this happens quite a > bit. Ah, okay. Still, it's not something that scales up much, the way horizontal whitespace does. You go to 2 blanks, and extras (sparingly) between groups, but it's not like indentation, where nesting naturally requires progressively more space. If you're nesting groups of functions like that, you probably should be using something other than whitespace (maybe separate files?). ChrisA From denismfmcmahon at gmail.com Sat Jul 5 22:58:02 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Sun, 6 Jul 2014 02:58:02 +0000 (UTC) Subject: Why is regexp not working? References: Message-ID: On Fri, 04 Jul 2014 14:27:12 +0200, Florian Lindner wrote: > self.regexps = [r"it (?P\d+) .* dt complete yes | > write-iteration-checkpoint |", > r"it (?P\d+) read ahead" My first thought is what is the effect of '|' as the last character in the regex? -- Denis McMahon, denismfmcmahon at gmail.com From g.statkute at gmail.com Sun Jul 6 04:45:44 2014 From: g.statkute at gmail.com (gintare) Date: Sun, 6 Jul 2014 01:45:44 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, Message-ID: I run python33 scrupt SVtxt.py from Windows command line I want to print out the file contents to stdout. File contents: "Vi kan inte l?ngre underordna den vinster..." Python script sentences i have tries to use: f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r') linef=f.readlines() f.close() print(linef)#gives error print(linef).decode("utf-8","ignore")#gives error ERROR: c:\Python33\Scripts\lang\langu>python SVtxt.py Traceback (most recent call last): File "SVtxt.py", line 8, in print(linef).decode("utf-8","ignore") File "C:\Python33\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 91-92: From g.statkute at gmail.com Sun Jul 6 05:05:10 2014 From: g.statkute at gmail.com (gintare) Date: Sun, 6 Jul 2014 02:05:10 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: References: Message-ID: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> The answer is on page:https://docs.python.org/3.3/howto/unicode.html#reading-and-writing-unicode-data The correct code: f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') linef=f.readlines() print(repr(linef)) From rxjwg98 at gmail.com Sun Jul 6 07:51:03 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 04:51:03 -0700 (PDT) Subject: Question about metacharacter '*' Message-ID: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> Hi, I just begin to learn Python. I do not see the usefulness of '*' in its description below: The first metacharacter for repeating things that we'll look at is *. * doesn't match the literal character *; instead, it specifies that the previous character can be matched zero or more times, instead of exactly once. For example, ca*t will match ct (0 a characters), cat (1 a), caaat (3 a characters), and so forth. It has to be used with other search constraints? Thanks, From jeanpierreda at gmail.com Sun Jul 6 08:09:57 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 6 Jul 2014 05:09:57 -0700 Subject: Question about metacharacter '*' In-Reply-To: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> Message-ID: On Sun, Jul 6, 2014 at 4:51 AM, wrote: > Hi, > > I just begin to learn Python. I do not see the usefulness of '*' in its > description below: > > > > > The first metacharacter for repeating things that we'll look at is *. * doesn't > match the literal character *; instead, it specifies that the previous character > can be matched zero or more times, instead of exactly once. > > For example, ca*t will match ct (0 a characters), cat (1 a), caaat (3 a > characters), and so forth. > > > > It has to be used with other search constraints? (BTW, this is a regexp question, not really a Python question per se.) That's usually when it's useful, yeah. For example, [0-9] matches any of the characters 0 through 9. So to match a natural number written in decimal form, we might use the regexp [0-9][0-9]*, which matches the strings "1", "12", and "007", but not "" or "Jeffrey". Another useful one is `.*` -- `.` matches exactly one character, no matter what that character is. So, `.*` matches any string at all. The power of regexps stems from the ability to mix and match all of the regexp pieces in pretty much any way you want. -- Devin From rxjwg98 at gmail.com Sun Jul 6 08:13:55 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 05:13:55 -0700 (PDT) Subject: Why is it different from the example on the tutorial? Message-ID: Hi, I type the following sample codes on Python, but it echoes differently. Regular expressions are compiled into pattern objects, which have methods for various operations such as searching for pattern matches or performing string substitutions. >>> >>> import re >>> p = re.compile('ab*') >>> p <_sre.SRE_Pattern object at 0x...> What I get on Python console: $ python Python 2.7.5 (default, Oct 2 2013, 22:34:09) [GCC 4.8.1] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> p = re.compile('ab*') File "", line 1 p = re.compile('ab*') ^ SyntaxError: invalid syntax >>> Thanks, From python.list at tim.thechases.com Sun Jul 6 08:54:42 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 6 Jul 2014 07:54:42 -0500 Subject: Why is it different from the example on the tutorial? In-Reply-To: References: Message-ID: <20140706075442.5ec16d84@bigbox.christie.dr> On 2014-07-06 05:13, rxjwg98 at gmail.com wrote: > What I get on Python console: > > $ python > Python 2.7.5 (default, Oct 2 2013, 22:34:09) > [GCC 4.8.1] on cygwin > Type "help", "copyright", "credits" or "license" for more > information. > >>> import re > >>> p = re.compile('ab*') > File "", line 1 > p = re.compile('ab*') > ^ > SyntaxError: invalid syntax > >>> Are you sure that you copied/pasted that directly from the console instead of transcribing it with some mistake? I just did the same thing at the console and it worked perfectly fine $ python Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> p = re.compile('ab*') >>> -tkc From davea at davea.name Sun Jul 6 08:57:58 2014 From: davea at davea.name (Dave Angel) Date: Sun, 6 Jul 2014 08:57:58 -0400 (EDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> Message-ID: gintare Wrote in message: > The answer is on page:https://docs.python.org/3.3/howto/unicode.html#reading-and-writing-unicode-data > > The correct code: > f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') > linef=f.readlines() > print(repr(linef)) > But naturally the path should be fixed as well. Either use forward slashes, escape the backslashes, or use a raw string. f=open( r'C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') -- DaveA From rafi.michaeli at whitesourcesoftware.com Sun Jul 6 09:12:18 2014 From: rafi.michaeli at whitesourcesoftware.com (rafi.michaeli at whitesourcesoftware.com) Date: Sun, 6 Jul 2014 06:12:18 -0700 (PDT) Subject: Webinar on How to Manage Your Python Open Source Message-ID: <37a11e04-ed80-4ce6-9cf5-8255ee639837@googlegroups.com> Hey everyone, We are conducting a webinar this Wednesday about How to Manage Your Python Open Source. the session will be mainly about challenge of managing open-source components that are embedded in your Python projects. If you are interested please register in this form: https://attendee.gotowebinar.com/register/7034105107342895362 we hope to see you there :) Rafi, WhiteSource software. From Richard at Damon-Family.org Sun Jul 6 09:21:45 2014 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 06 Jul 2014 09:21:45 -0400 Subject: cx_freeze and temporary files - security related question In-Reply-To: References: Message-ID: <53cuv.255700$eG6.225581@fx29.iad> On 5/21/14, 12:42 PM, Nagy L?szl? Zsolt wrote: > I need to create an application for Windows 7 that runs from a flash > drive. This program would be used to create remote backups of the > pendrive. The pendrive contains sensitive data, so when I plug in the > pendrive and run the program to make a backup, it should not leave any > trace of operation on the windows system. The information is so > sensitive that I was forbidden to use cloud storage. I was also > forbidden to make backups to a local drive, or leave any trace on the > host windows system. > > The question is this: if I create this program with Python 3.4 and > cx_Freeze, then what should I expect. When the user starts the > cx_freeze-d program from the flash drive, will it create temporary files > on the system drive? Will it leave log files or store any permanent or > temporary data on the system drive (maybe in the user's tmp folder) that > can later be used to tell what drive was mounted, with what parameters > the program was started etc. > > Thanks > I am not sure about what temp files python might leave around, but if you are being ultimately paranoid about this, one risk that will be present is the possibility of leaving traces of data in the swap file. If the program doesn't specifically prohibit it, anything that is brought into memory (and the act of reading the pendrive will do this) might end up in the swap file. I can't imagine python having a run time option to force it to disable the swap file. If the data is as sensitive as they seem to want to treat it, perhaps you should follow the procedures of classified computing, which says that any storage medium "exposed" to classified computing becomes classified. This would say that you would use a dedicated machine to do these backups, and after doing them, you remove the hard disk from the machine and lock it up, only to be taken out for later backups. This level of paranoia says you don't need to be as concerned about figuring out what traces might be left, you assume they are and lock them up. From rxjwg98 at gmail.com Sun Jul 6 09:38:41 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 06:38:41 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: References: Message-ID: On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote: > On 2014-07-06 05:13, rxjwg98 at gmail.com wrote: > > > What I get on Python console: > > > > > > $ python > > > Python 2.7.5 (default, Oct 2 2013, 22:34:09) > > > [GCC 4.8.1] on cygwin > > > Type "help", "copyright", "credits" or "license" for more > > > information. > > > >>> import re > > > >>> p = re.compile('ab*') > > > File "", line 1 > > > p = re.compile('ab*') > > > ^ > > > SyntaxError: invalid syntax > > > >>> > > > > Are you sure that you copied/pasted that directly from the console > > instead of transcribing it with some mistake? > > > > I just did the same thing at the console and it worked perfectly > > fine > > > > $ python > > Python 2.7.3 (default, Mar 13 2014, 11:03:55) > > [GCC 4.7.2] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> import re > > >>> p = re.compile('ab*') > > >>> > > > > > > -tkc Thanks. It did be caused by unclear copy&paste. I shall be careful in future. When I enter: >>>counter=100 >>>counter 100 When I get match result: >>>pattern='abcd' >>>prog = re.compile(pattern) >>>string='abcd' >>>result = prog.match(string) >>>result <_sre.SRE_Match object at 0x6ffffeda5e0> >>>result.group(0) 'abcd' It looks like 'result' is different from a simple 'counter' variable. I do not yet find the definition of 'result' object. What do you call 'result' object? Where can I find it (what topic would be in a tutorial)? Thanks, From rantingrickjohnson at gmail.com Sun Jul 6 10:18:53 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 07:18:53 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: References: Message-ID: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj... at gmail.com wrote: > When I get match result: > py>pattern='abcd' > py>prog = re.compile(pattern) > py>string='abcd' > py>result = prog.match(string) > py>result > <_sre.SRE_Match object at 0x6ffffeda5e0> > py>result.group(0) > 'abcd' > > It looks like 'result' is different from a simple > 'counter' variable. I do not yet find the definition of > 'result' object. What do you call 'result' object? Where > can I find it (what topic would be in a tutorial)? Thanks, One of the most powerful features of Python,,, for the noob,,, be documentation strings. With Python you need not buy expensive books, or venture into seedy and dangerous alley ways of the inter-webs, no, all you need to do is do that which any young and inexperienced lad would do when he finds himself in a troubling situation: YELL FOR HELP! The built-in function "help" will answer all your questions,,, considering you ask the correct questions of course!,,, but always remember the advice of a wise man and don't become the "boy who cried wolf" one too many times! From breamoreboy at yahoo.co.uk Sun Jul 6 10:25:13 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 06 Jul 2014 15:25:13 +0100 Subject: Why is it different from the example on the tutorial? In-Reply-To: References: Message-ID: On 06/07/2014 14:38, rxjwg98 at gmail.com wrote: > On Sunday, July 6, 2014 8:54:42 AM UTC-4, Tim Chase wrote: >> On 2014-07-06 05:13, rxjwg98 at gmail.com wrote: >> >>> What I get on Python console: >> >>> >> >>> $ python >> >>> Python 2.7.5 (default, Oct 2 2013, 22:34:09) >> >>> [GCC 4.8.1] on cygwin >> >>> Type "help", "copyright", "credits" or "license" for more >> >>> information. >> >>>>>> import re >> >>>>>> p = re.compile('ab*') >> >>> File "", line 1 >> >>> p = re.compile('ab*') >> >>> ^ >> >>> SyntaxError: invalid syntax >> >>>>>> >> >> >> >> Are you sure that you copied/pasted that directly from the console >> >> instead of transcribing it with some mistake? >> >> >> >> I just did the same thing at the console and it worked perfectly >> >> fine >> >> >> >> $ python >> >> Python 2.7.3 (default, Mar 13 2014, 11:03:55) >> >> [GCC 4.7.2] on linux2 >> >> Type "help", "copyright", "credits" or "license" for more information. >> >>>>> import re >> >>>>> p = re.compile('ab*') >> >>>>> >> >> >> >> >> >> -tkc > Thanks. It did be caused by unclear copy&paste. I shall be careful in future. > > When I enter: >>>> counter=100 >>>> counter > 100 > > When I get match result: > >>>> pattern='abcd' >>>> prog = re.compile(pattern) >>>> string='abcd' >>>> result = prog.match(string) >>>> result > <_sre.SRE_Match object at 0x6ffffeda5e0> > >>>> result.group(0) > 'abcd' > > It looks like 'result' is different from a simple 'counter' variable. I do not > yet find the definition of 'result' object. What do you call 'result' object? > Where can I find it (what topic would be in a tutorial)? > > Thanks, > > >>> help(result) Help on SRE_Match object: class SRE_Match(builtins.object) | The result of re.match() and re.search(). etc https://docs.python.org/3/library/re.html#module-re https://docs.python.org/3/library/re.html#match-objects https://docs.python.org/3/library/re.html#re.match https://docs.python.org/3/library/re.html#re.search https://docs.python.org/3/library/re.html#regular-expression-examples A slight aside, would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From roy at panix.com Sun Jul 6 10:34:44 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 10:34:44 -0400 Subject: Why is it different from the example on the tutorial? References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> Message-ID: In article <21e704ee-648b-423d-8682-11cb310a31a8 at googlegroups.com>, Rick Johnson wrote: > On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj... at gmail.com wrote: > > When I get match result: > > py>pattern='abcd' > > py>prog = re.compile(pattern) > > py>string='abcd' > > py>result = prog.match(string) > > py>result > > <_sre.SRE_Match object at 0x6ffffeda5e0> > > py>result.group(0) > > 'abcd' > > > > It looks like 'result' is different from a simple > > 'counter' variable. I do not yet find the definition of > > 'result' object. What do you call 'result' object? Where > > can I find it (what topic would be in a tutorial)? Thanks, > > One of the most powerful features of Python,,, for the > noob,,, be documentation strings. I guess I must still be a noob, because I still find them pretty useful! More generically, Python supports "introspection", which means you can ask an object to tell you things about itself. Let's say you've got an object, foo. Here's some useful things you can do to learn more about it: * As Rick points out, you can do help(foo). This is probably the place to start. * You can print dict(foo), which just prints out the attributes the object has. This is really handy when you vaguely remember that a class has some operation, but can't remember the exact name. For example, I use two different database packages, and can never remember which has sort() and which has order_by(). * You can print foo itself, to find out its value, but this can get tricky, since sometimes objects print themselves in confusing ways. Printing repr(foo) will usually get you more detail. * You can print type(foo), to find out exactly what it is (useful when even printing repr() doesn't explain what's going on). From rosuav at gmail.com Sun Jul 6 10:45:04 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 00:45:04 +1000 Subject: Why is it different from the example on the tutorial? In-Reply-To: References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> Message-ID: On Mon, Jul 7, 2014 at 12:34 AM, Roy Smith wrote: > * You can print type(foo), to find out exactly what it is (useful when > even printing repr() doesn't explain what's going on). And very VERY occasionally, print(id(type(foo))) comes in handy, because two types might look the same, but an isinstance check looks (modulo subclassing) at type identity. :) But yes, the info Roy listed is normally what you'll be wanting. ChrisA From breamoreboy at yahoo.co.uk Sun Jul 6 10:47:25 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 06 Jul 2014 15:47:25 +0100 Subject: Why is it different from the example on the tutorial? In-Reply-To: References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> Message-ID: On 06/07/2014 15:34, Roy Smith wrote: > > * You can print foo itself, to find out its value, but this can get > tricky, since sometimes objects print themselves in confusing ways. > Printing repr(foo) will usually get you more detail. > For the OP the pretty print module is usually better than plain old print https://docs.python.org/3/library/pprint.html#module-pprint. I use it like this from pprint import pprint as pp The iPython shell (and presumably others as well) also does a better job of displaying objects than print. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rantingrickjohnson at gmail.com Sun Jul 6 10:52:02 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 07:52:02 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> Message-ID: <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> On Sunday, July 6, 2014 4:05:10 AM UTC-5, gintare wrote: > The correct code: > f=open(,'r', encoding='utf-8') > linef=f.readlines() > print(repr(linef)) Yes but do you understand why? And even if you DO understand why, you should explain the details because the neophytes are always watching! >_> <_< o_O? ...what, me worry? Now don't misunderstand me, i am happy that you took the time to report to us that you found the answer! Yes, nothing is more aggravating than writing a long, thoughtful, and elegant answer, and then have the OP come back and say: "Oh i found the answer, but thanks anyway" But really, kudos to you for at least making the effort to report. Because the only thing worse than a report without context is no report at all! Indeed, then we end up with unresolved threads and our community mojo suffers.... but i digress! Now, we must explain WHY this new code works, and WHY the old code failed. SIMPLE! "file.readlines()" returns a list, with each value of the list representing a line of the file. Nothing wrong with using "readlines()" of course, UNTIL you try to pass the value of "readlines" into the "print()" function, ah-aH-AH! So the direct reason for failure is due to the fact that the "print()" function ONLY handles strings, not list objects. So in light of this problem there are a few solutions: 1. Cast the list into a string, which you did using the "repr()" function, although you can also use the "str()" function, or use "string formatting" if formatting makes sense (in this case formatting does not make sense). 2. Use a different method of the file object which returns a string instead of a "list-of-lines". Your code seems to make no use of "line-ified-data-structures", so why burn cycles creating one? PS: We could use a few more members of the female persuasion in this community, so thanks for dropping by and hope to see you posting in the future! We desperately need something "fair" to offset the reeking of smelly socks, stinky armpits, and the stomach churning *stench* of illogical naming conventions! From rxjwg98 at gmail.com Sun Jul 6 11:03:48 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 08:03:48 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> Message-ID: <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> On Sunday, July 6, 2014 10:18:53 AM UTC-4, Rick Johnson wrote: > On Sunday, July 6, 2014 8:38:41 AM UTC-5, rxj... at gmail.com wrote: > > > When I get match result: > > > py>pattern='abcd' > > > py>prog = re.compile(pattern) > > > py>string='abcd' > > > py>result = prog.match(string) > > > py>result > > > <_sre.SRE_Match object at 0x6ffffeda5e0> > > > py>result.group(0) > > > 'abcd' > > > > > > It looks like 'result' is different from a simple > > > 'counter' variable. I do not yet find the definition of > > > 'result' object. What do you call 'result' object? Where > > > can I find it (what topic would be in a tutorial)? Thanks, > > > > One of the most powerful features of Python,,, for the > > noob,,, be documentation strings. With Python you need not > > buy expensive books, or venture into seedy and dangerous > > alley ways of the inter-webs, no, all you need to do is do > > that which any young and inexperienced lad would do when he > > finds himself in a troubling situation: > > > > YELL FOR HELP! > > > > The built-in function "help" will answer all your > > questions,,, considering you ask the correct questions of > > course!,,, but always remember the advice of a wise man and > > don't become the "boy who cried wolf" one too many times! Thanks. I do not want to waste everyone's time. For a jump start, there are small errors making me frustrating. Your help does help me, confirm the usage etc. After a basic familiarity, I do not want to post more. I use cygwin Python, I type help of an object 'result'. It does show up the help content, but it never quits the help afterwards. It is annoying, and time wasting. (Sorry again, that problem may be about Cygwin, not Python. Excuse me to mention that here. Of course, your help post consumes your time. Thanks again. From python at mrabarnett.plus.com Sun Jul 6 11:32:26 2014 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 06 Jul 2014 16:32:26 +0100 Subject: Question about metacharacter '*' In-Reply-To: References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> Message-ID: <53B96C0A.3030302@mrabarnett.plus.com> On 2014-07-06 13:09, Devin Jeanpierre wrote: > On Sun, Jul 6, 2014 at 4:51 AM, wrote: >> Hi, >> >> I just begin to learn Python. I do not see the usefulness of '*' in its >> description below: >> >> >> >> >> The first metacharacter for repeating things that we'll look at is *. * doesn't >> match the literal character *; instead, it specifies that the previous character >> can be matched zero or more times, instead of exactly once. >> >> For example, ca*t will match ct (0 a characters), cat (1 a), caaat (3 a >> characters), and so forth. >> >> >> >> It has to be used with other search constraints? > > (BTW, this is a regexp question, not really a Python question per se.) > > That's usually when it's useful, yeah. For example, [0-9] matches any > of the characters 0 through 9. So to match a natural number written in > decimal form, we might use the regexp [0-9][0-9]*, which matches the > strings "1", "12", and "007", but not "" or "Jeffrey". > > Another useful one is `.*` -- `.` matches exactly one character, no > matter what that character is. So, `.*` matches any string at all. > Not quite. It won't match a '\n' unless the DOTALL flag is turned on. > The power of regexps stems from the ability to mix and match all of > the regexp pieces in pretty much any way you want. > From rantingrickjohnson at gmail.com Sun Jul 6 11:41:29 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 08:41:29 -0700 (PDT) Subject: OT: Flashlights [was Re: PEP8 and 4 spaces] In-Reply-To: <53b7d044$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> <53b7d044$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Saturday, July 5, 2014 5:15:32 AM UTC-5, Steven D'Aprano wrote: > (By the way, outside of the USA, flashlights in the rest > of the English- speaking world are usually called > "torches", so called because, like the old-fashioned > burning torch, they provide light.) Well Steven all i can hope is that one day you and i will be working on a project together, and you will ask me for a "touch", and when i return with a petrol soaked rag burning on the end of twig and proceed to light your hair on fire, hopefully at that moment, you will THEN gain a healthy respect for logical naming conventions! You see, just as a "proper" programming language utilize the punishments of Exceptions for illogical behaviors, life utilizes the power of pain for even greater effect. Ah, what's that old adage about doing the same things over and over but expecting different results? Oh well, maybe someone can chime in... SHALL WE "RINSE AND REPEAT" MR.D'APRANO? > A few minutes googling would have given you the answer: > flashlights are called flashlights because originally you > could only flash them on and off. Due to the high power > requirements and the low battery capacities at the time, > leaving the torch switched on would burn out the filament, > exhaust the battery, or both. So what you're telling me is that in the early days of the "portable light" the function of the device was so terrible that the best all one could hope for was limited intermittent functionality with a great chance of destroying the device simply in the course of its normal use? Wow, and people actually paid money for these devices? Sounds like window 95 all over again! *yawn* > So far from being an illogical term, the name "flashlight" > actually gives you a glimpse into the historical > background of the invention. Yes, because when my power goes out, and i need to get to the electrical panel during a torrential rainstorm, at 2am in the morning, after a long day working in the company of idiots, and then coming home to a nagging "significant other", and then my dog dies... whist i tromp through the mud and the muck, at least my mind will be at peace knowing the historical significance of an illogical naming convention coined for a device that was so impractical as to render itself completely useless... THANKS "FLASHLIGHT" @_@! From __peter__ at web.de Sun Jul 6 11:46:50 2014 From: __peter__ at web.de (Peter Otten) Date: Sun, 06 Jul 2014 17:46:50 +0200 Subject: Why is it different from the example on the tutorial? References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> Message-ID: rxjwg98 at gmail.com wrote: > I use cygwin Python, > I type help of an object 'result'. It does show up the help content, but > it never quits the help afterwards. It is annoying, and time wasting. To quit help try hitting the 'q' key. From rantingrickjohnson at gmail.com Sun Jul 6 11:53:41 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 08:53:41 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> Message-ID: <6fd77d6a-3487-474b-bb96-8da6ab8008f5@googlegroups.com> On Sunday, July 6, 2014 9:34:44 AM UTC-5, Roy Smith wrote: > * You can print dict(foo), which just prints out the attributes the > object has. Looks like a typo there. I think you probably meant to say "dir(foo)" ============================================================ INTERACTIVE SESSION: Python 2.x ============================================================ py> l = range(5) py> l [0, 1, 2, 3, 4] py> dict(l) Traceback (most recent call last): File "", line 1, in dict(l) TypeError: cannot convert dictionary update sequence element #0 to a sequence py> dir(l) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] From jeanpierreda at gmail.com Sun Jul 6 11:50:13 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 6 Jul 2014 08:50:13 -0700 Subject: Question about metacharacter '*' In-Reply-To: <53B96C0A.3030302@mrabarnett.plus.com> References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> Message-ID: In related news, the regexp I gave for numbers will match "1a". -- Devin On Sun, Jul 6, 2014 at 8:32 AM, MRAB wrote: > On 2014-07-06 13:09, Devin Jeanpierre wrote: >> >> On Sun, Jul 6, 2014 at 4:51 AM, wrote: >>> >>> Hi, >>> >>> I just begin to learn Python. I do not see the usefulness of '*' in its >>> description below: >>> >>> >>> >>> >>> The first metacharacter for repeating things that we'll look at is *. * >>> doesn't >>> match the literal character *; instead, it specifies that the previous >>> character >>> can be matched zero or more times, instead of exactly once. >>> >>> For example, ca*t will match ct (0 a characters), cat (1 a), caaat (3 a >>> characters), and so forth. >>> >>> >>> >>> It has to be used with other search constraints? >> >> >> (BTW, this is a regexp question, not really a Python question per se.) >> >> That's usually when it's useful, yeah. For example, [0-9] matches any >> of the characters 0 through 9. So to match a natural number written in >> decimal form, we might use the regexp [0-9][0-9]*, which matches the >> strings "1", "12", and "007", but not "" or "Jeffrey". >> >> Another useful one is `.*` -- `.` matches exactly one character, no >> matter what that character is. So, `.*` matches any string at all. >> > Not quite. It won't match a '\n' unless the DOTALL flag is turned on. > > >> The power of regexps stems from the ability to mix and match all of >> the regexp pieces in pretty much any way you want. >> > > -- > https://mail.python.org/mailman/listinfo/python-list From roy at panix.com Sun Jul 6 12:01:08 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 12:01:08 -0400 Subject: Why is it different from the example on the tutorial? References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6fd77d6a-3487-474b-bb96-8da6ab8008f5@googlegroups.com> Message-ID: In article <6fd77d6a-3487-474b-bb96-8da6ab8008f5 at googlegroups.com>, Rick Johnson wrote: > On Sunday, July 6, 2014 9:34:44 AM UTC-5, Roy Smith wrote: > > > * You can print dict(foo), which just prints out the attributes the > > object has. > > Looks like a typo there. > > I think you probably meant to say "dir(foo)" This is true. Good catch. From rustompmody at gmail.com Sun Jul 6 12:01:39 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Sun, 6 Jul 2014 09:01:39 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: References: Message-ID: <34cc50af-9a3f-4739-bab4-55e4e321cf9a@googlegroups.com> On Sunday, July 6, 2014 5:43:55 PM UTC+5:30, rxj... at gmail.com wrote: > Hi, > I type the following sample codes on Python, but it echoes differently. > Regular expressions are compiled into pattern objects, which have methods for > various operations such as searching for pattern matches or performing string > substitutions. > >>> import re > >>> p = re.compile('ab*') > >>> p > What I get on Python console: > $ python > Python 2.7.5 (default, Oct 2 2013, 22:34:09) > [GCC 4.8.1] on cygwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import re > >>> p = re.compile('ab*') > File "", line 1 > p = re.compile('ab*') > ^ > SyntaxError: invalid syntax 1. For *using* regular exps match is fine For *hacking in the interpreter* I find findall more convenient. match and findall take the same arguments 2. I wouldn't bother with compile at least at the start 3. Use raw strings for patterns even if it does not seem necessary (below) $ python Python 2.7.7 (default, Jun 3 2014, 16:16:56) [GCC 4.8.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from re import findall >>> findall(r'ab*', 'abcd') ['ab'] >>> findall(r'ab*', 'abcdab') ['ab', 'ab'] >>> findall(r'ab*', 'abcdabbb') ['ab', 'abbb'] From rantingrickjohnson at gmail.com Sun Jul 6 12:02:22 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 09:02:22 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> Message-ID: On Sunday, July 6, 2014 10:03:48 AM UTC-5, rxj... at gmail.com wrote: > Thanks. I do not want to waste everyone's time. Oh NOW you tell us! I could be ranting about flashlights, but here i am wasting time with you again! > For a jump start, there are small errors making me > frustrating. Your help does help me, confirm the usage > etc. How about YOU confirm your OWN usage. I am confident the help function works just fine, can you prove otherwise? We're here to help not to write code for you like slaves. Remember GIGO! > After a basic familiarity, I do not want to post more. I > use cygwin Python, I type help of an object 'result'. It > does show up the help content, but it never quits the help > afterwards. It is annoying, and time wasting. Surely you have a simple Python command line available? Last i heard GvR was giving them away for free! Can you open one and try some interactive musings? If the only tool in your toolbox is a hammer, well, you know the rest... From tjreedy at udel.edu Sun Jul 6 12:14:26 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 06 Jul 2014 12:14:26 -0400 Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> Message-ID: On 7/6/2014 10:52 AM, Rick Johnson wrote: > So the direct reason for failure is due to the fact that the > "print()" function ONLY handles strings, not list objects. >>> print(object()) >>> print(['abc', 'cdf']) ['abc', 'cdf'] Since the original poster did not copy the traceback from the print error, it is unclear what the error was. -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sun Jul 6 12:24:18 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 09:24:18 -0700 (PDT) Subject: Question about metacharacter '*' In-Reply-To: References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> Message-ID: On Sunday, July 6, 2014 10:50:13 AM UTC-5, Devin Jeanpierre wrote: > In related news, the regexp I gave for numbers will match "1a". Well of course it matched, because your pattern defines "one or more consecutive digits". So it will match the "1" of "1a" and the "11" of "11a" likewise. As an aside i prefer to only utilize a "character set" when nothing else will suffice. And in this case r"[0-9][0-9]*" can be expressed just as correctly (and less noisy IMHO) as r"\d\d*". ============================================================ INTERACTIVE SESSION: Python 2.x ============================================================ # Note: Grouping used for explicitness. # # Using character sets: >>> import re >>> re.search(r'([0-9][0-9]*)', '1a').groups() ('1',) >>> re.search(r'([0-9][0-9]*)', '11a').groups() ('11',) >>> re.search(r'([0-9][0-9]*)', '111aaa222').groups() ('111',) # # Same result without charactor sets: >>> re.search(r'(\d\d*)', '1a').groups() ('1',) >>> re.search(r'(\d\d*)', '11a').groups() ('11',) >>> re.search(r'(\d\d*)', '111aaa222').groups() ('111',) From rantingrickjohnson at gmail.com Sun Jul 6 12:32:11 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 09:32:11 -0700 (PDT) Subject: Question about metacharacter '*' In-Reply-To: References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> Message-ID: [CONTINUED FROM LAST REPLY...] Likewise if your intent is to filter out any match strings which contain non-digits, then define the start and stop points of the pattern: # Match only if all are digits >>> re.match(r'\d\d*$', '111aaa222') # fails # Match only if all are digits and, # allow leading white-space >>> re.match(r'\s*\d\d*$', ' 111') <_sre.SRE_Match object at 0x026D8410> # But not trailing space! >>> re.match(r'\s*\d\d*$', ' 111 ') # fails From i at introo.me Sun Jul 6 12:36:23 2014 From: i at introo.me (Shiyao Ma) Date: Mon, 7 Jul 2014 00:36:23 +0800 Subject: How do you use `help` when write your code Message-ID: Hi Pythonistas I often heard people mention use help(ob) as a way of documentation look up. Personally I seldom/never do that. My normal workflow is use ipython, obj? or obj?? for quick look up or use docs.python.org for a detailed read. Do you use `help`? How does it integrate into your workflow? Or instead, what similar tools do you use? Regards. shiyao -- ????????????????http://introo.me? From roy at panix.com Sun Jul 6 12:47:38 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 12:47:38 -0400 Subject: Question about metacharacter '*' References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> Message-ID: In article , Rick Johnson wrote: > As an aside i prefer to only utilize a "character set" when > nothing else will suffice. And in this case r"[0-9][0-9]*" > can be expressed just as correctly (and less noisy IMHO) as > r"\d\d*". Even better, r"\d+" >>> re.search(r'(\d\d*)', '111aaa222').groups() ('111',) >>> re.search(r'(\d+)', '111aaa222').groups() ('111',) Oddly enough, I prefer character sets to the backslash notation, but I suppose that's largely because when I first learned regexes, that new-fangled backslash stuff hadn't been invented yet. :-) I know I've said this before, but people should put more effort into learning regex. There are lots of good tools in Python (startswith, endswith, split, in, etc) which handle many of the most common regex use cases. Regex is also not as easy to use in Python as it is in a language like Perl where it's baked into the syntax. As a result, pythonistas tend to shy away from regex, and either never learn the full power, or let their skills grow rusty. Which is a shame, because for many tasks, there's no better tool. From rantingrickjohnson at gmail.com Sun Jul 6 12:53:34 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 09:53:34 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> Message-ID: <4ebc3166-f17e-482b-ad6c-f109db4cad2d@googlegroups.com> On Sunday, July 6, 2014 11:14:26 AM UTC-5, Terry Reedy wrote: > On 7/6/2014 10:52 AM, Rick Johnson wrote: > > So the direct reason for failure is due to the fact that the > > "print()" function ONLY handles strings, not list objects. > >>> print(object()) > > >>> print(['abc', 'cdf']) > ['abc', 'cdf'] Hmm, you are correct Terry, i must have been confusing file#write() and print() when i wrote all that nonsense. Thanks for pointing out the error. > Since the original poster did not copy the traceback from > the print error, it is unclear what the error was. I'm wondering what she is expecting this line to do: "print(linef).decode("utf-8","ignore") My understanding is that print is a one way destination to a stream, and the only return value would be the default None. Urm, last time i got myself into trouble by not testing, not letting that happen again! O:-) ============================================================ INTERACTIVE SESSION: Python 2.x ============================================================ py> from __future__ import print_function py> print([1,2,3]) [1, 2, 3] py> print(print([1,2,3])) [1, 2, 3] None py> returnvalue = print([1,2,3]) [1, 2, 3] py> repr(returnvalue) 'None' Seems like she'd better do the decoding before printing, or am i wrong again? From rantingrickjohnson at gmail.com Sun Jul 6 13:38:23 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 10:38:23 -0700 (PDT) Subject: Question about metacharacter '*' In-Reply-To: References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> Message-ID: <2f63eeac-77c3-48fc-b4dd-020ad74cd0b1@googlegroups.com> On Sunday, July 6, 2014 11:47:38 AM UTC-5, Roy Smith wrote: > Even better, r"\d+" > >>> re.search(r'(\d\d*)', '111aaa222').groups() > ('111',) > >>> re.search(r'(\d+)', '111aaa222').groups() > ('111',) Yes, good catch! I had failed to reduce your original pattern down to it's most fundamental aspects for the sake of completeness, and instead, opted to modify it in a manner that mirrored your example. > Oddly enough, I prefer character sets to the backslash > notation, but I suppose that's largely because when I > first learned regexes, that new-fangled backslash stuff > hadn't been invented yet. :-) Ha, point taken! :-) Character sets really shine when you need a fixed range of letters or numbers which are NOT defined by one of the "special characters" of \d \D \W \w, etc... Say you want to match any letters between "c" and "m" or the digits between "3" and "6". Defining that pattern using OR'd "char literals" would be a massive undertaking! Another great use of character sets is skipping chars that don't match a "target". For instance, a python comment will start with one hash char and proceedeth to the end of the line,,, which when accounting for leading white-space,,, could be defined by the pattern: r'\s*#[^\n]' > Regex is also not as easy to use in Python as it is in a > language like Perl where it's baked into the syntax. As a > result, pythonistas tend to shy away from regex, and > either never learn the full power, or let their skills > grow rusty. Which is a shame, because for many tasks, > there's no better tool. Agreed, but unfortunately like many other languages, Python has decided to import all the illogical of regex syntax from other languages instead of creating a "new" regex syntax that is consistent and logical. They did the same thing with Tkinter, and what a nightmare! And don't misunderstand my statements, i don't intend that we should create a syntax of verbosity, NO, we *CAN* keep the syntax succinct whist eliminating the illogical and inconsistent aspects that plague our patterns. Will regex ever be easy to learn, probably not, but they can be easier to use if only we put on our "big boy" pants and decide to do something about it! From steve+comp.lang.python at pearwood.info Sun Jul 6 13:52:50 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 06 Jul 2014 17:52:50 GMT Subject: How do you use `help` when write your code References: Message-ID: <53b98cf2$0$29985$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 00:36:23 +0800, Shiyao Ma wrote: > Hi Pythonistas > > I often heard people mention use help(ob) as a way of documentation look > up. Personally I seldom/never do that. My normal workflow is use > ipython, obj? or obj?? for quick look up or use docs.python.org for a > detailed read. > > Do you use `help`? How does it integrate into your workflow? I frequently use the help() function. (By the way, a little trivia for you: although the help function is in the built-in namespace, it is not actually a built-in! When you start Python interactively, the site.py script runs automatically, creates the help() function, and monkey-patches it into the builtins namespace.) I rarely use ipython, I use the regular Python interactive interpreter, so obj? and obj?? aren't an option. My usual workflow is to have at least one Python interpreter open at all times. If I don't remember the parameters for a method or function, I'll call help(class.method) or help(function). If I'm not sure what the method is called, I'll usually call help(class) or help(module). If there are too many things in the class or module, I'll use dir() to inspect it first. I have a monkey-patched version of dir() which takes a second argument, a glob, to filter the list of names returned: py> len(dir(os)) # Too much! 312 py> dir(os, 'env') ['_putenv', '_unsetenv', 'environ', 'environb', 'getenv', 'getenvb', 'putenv', 'supports_bytes_environ', 'unsetenv'] py> dir(os, 'env*') ['environ', 'environb'] -- Steven From rantingrickjohnson at gmail.com Sun Jul 6 13:58:28 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 10:58:28 -0700 (PDT) Subject: Question about metacharacter '*' In-Reply-To: <2f63eeac-77c3-48fc-b4dd-020ad74cd0b1@googlegroups.com> References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <53B96C0A.3030302@mrabarnett.plus.com> <2f63eeac-77c3-48fc-b4dd-020ad74cd0b1@googlegroups.com> Message-ID: On Sunday, July 6, 2014 12:38:23 PM UTC-5, Rick Johnson wrote: > r'\s*#[^\n]' Well, there i go not testing again! r'\s*#[^\n]*' From wxjmfauth at gmail.com Sun Jul 6 14:14:38 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Sun, 6 Jul 2014 11:14:38 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: <4ebc3166-f17e-482b-ad6c-f109db4cad2d@googlegroups.com> References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> <4ebc3166-f17e-482b-ad6c-f109db4cad2d@googlegroups.com> Message-ID: <53aba448-ac52-46c7-99c0-906e8bbc0e0d@googlegroups.com> Le dimanche 6 juillet 2014 18:53:34 UTC+2, Rick Johnson a ?crit?: [...] > > > Seems like she'd better do the decoding before printing No > [...], or > > am i wrong again? Yes >>> s = 'abc???' >>> sys.stdout.encoding '' >>> print(s) abc??? >>> sys.stdout.encoding = 'cp437' >>> sys.stdout.encoding 'cp437' >>> print(s) Traceback (most recent call last): File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write s = s.encode(self.pencoding).decode('cp1252') File "C:\Python32\lib\encodings\cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> sys.stdout.encoding = 'cp850' >>> sys.stdout.encoding 'cp850' >>> print(s) Traceback (most recent call last): File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write s = s.encode(self.pencoding).decode('cp1252') File "C:\Python32\lib\encodings\cp850.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> # and so on >>> sys.stdout.encoding = 'cp1252') File "", line 1 sys.stdout.encoding = 'cp1252') ^ SyntaxError: invalid syntax >>> # oops >>> sys.stdout.encoding = 'cp1252' >>> print(s) abc??? >>> sys.stdout.encoding = 'mac-roman' >>> print(s) abc??? >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> sys.stdout.encoding = 'utf-8' >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> sys.stdout.encoding = 'utf-16-le' >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> >>> sys.stdout.encoding = 'utf-32-be' >>> print(s.encode(sys.stdout.encoding, 'replace')) 'abc???' >>> jmf From python.list at tim.thechases.com Sun Jul 6 14:22:30 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 6 Jul 2014 13:22:30 -0500 Subject: How do you use `help` when write your code In-Reply-To: <53b98cf2$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53b98cf2$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20140706132230.6f394bfc@bigbox.christie.dr> On 2014-07-06 17:52, Steven D'Aprano wrote: > I have a monkey-patched version of dir() which takes a second > argument, a glob, to filter the list of names returned: > > py> len(dir(os)) # Too much! > 312 > py> dir(os, 'env') > ['_putenv', '_unsetenv', 'environ', 'environb', 'getenv', > 'getenvb', 'putenv', 'supports_bytes_environ', 'unsetenv'] > py> dir(os, 'env*') > ['environ', 'environb'] And for those of us that don't have Steven's monkey-patched dir() call, I tend to do it with a list comprehension: >>> [s for s in dir(obj) if 'env' in s] {output here} This works nicely for even more complex tests: >>> [s for s in dir(obj) if not s.startswith('_')] {list of public properties/methods} >>> [s for s in dir(obj) if callable(getattr(obj, s))] {list of callable attributes} >>> [s for s in dir(obj) if isinstance(getattr(obj, s), basestring)] {list of string attributes} -tkc From breamoreboy at yahoo.co.uk Sun Jul 6 14:29:03 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 06 Jul 2014 19:29:03 +0100 Subject: Why is it different from the example on the tutorial? In-Reply-To: <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> Message-ID: On 06/07/2014 16:03, rxjwg98 at gmail.com wrote: > > Thanks. I do not want to waste everyone's time. For a jump start, there are > small errors making me frustrating. Your help does help me, confirm the usage > etc. After a basic familiarity, I do not want to post more. I use cygwin Python, > I type help of an object 'result'. It does show up the help content, but it > never quits the help afterwards. It is annoying, and time wasting. (Sorry again, > that problem may be about Cygwin, not Python. Excuse me to mention that here. > Of course, your help post consumes your time. Thanks again. > Don't bother about wasting our time as that's what we're here for :) There is a tutor mailing list that you might feel more comfortable on. See https://mail.python.org/mailman/listinfo/tutor or gmane.comp.python.tutor -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rxjwg98 at gmail.com Sun Jul 6 14:26:14 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 11:26:14 -0700 (PDT) Subject: What is the difference between matchObj.group() and matchObj.group(0) Message-ID: <809dbbdf-b452-4f25-a1ff-f00a2202939d@googlegroups.com> Hi, I cannot get the difference between matchObj.group() and matchObj.group(0), Although there definitions are obvious different. And group() mentions 'tuple'. tuple means all the elements in line object? Match Object Methods Description group(num=0) This method returns entire match (or specific subgroup num) groups() This method returns all matching subgroups in a tuple (empty if there weren't any) I run the following code. Even I add more words to line object, Both have the same output. Could you clarify this question? Thanks again. #!/usr/bin/python import re line = "Cats are smarter than dogs" matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I) if matchObj: print "matchObj.group() : ", matchObj.group() print "matchObj.group(1) : ", matchObj.group(1) print "matchObj.group(2) : ", matchObj.group(2) else: print "No match!!" From rantingrickjohnson at gmail.com Sun Jul 6 14:48:11 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 11:48:11 -0700 (PDT) Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: On Sunday, July 6, 2014 11:36:23 AM UTC-5, Shiyao Ma wrote: > I often heard people mention use help(ob) as a way of > documentation look up. Personally I seldom/never do that. > My normal workflow is use ipython, obj? or obj?? for quick > look up or use docs.python.org for a detailed read. Do you > use `help`? How does it integrate into your workflow? Or > instead, what similar tools do you use? For me i use a very simple graphical IDE for writing code, and i have a Python interactive console for testing snippets here or there when needed. I just abhor bloatware like Eclise! I also have no use for debuggers or line breaks or any of that childish nonsense. *Real* programmers possess keen detective that can root out bugs with nothing more than a few well placed print statements and some good old fashioned "eyeball analysis". Besides, writing rock solid interfaces is prerequisite for programmer happiness. That means type checking inputs to function and classes so you don't propagate errors ten miles from the source of the problem before they get raised by Python (Tkinter i'm looking at angrily you now!), then you spend two day analyzing miles of implicit trace-back messages only to find out a parameter was illegal and could have been caught at input! ARE YOU KIDDING ME! And, as Mr.D'Aprano has stated, many of the built-in functions like "dir" are in need of refining. But i go a step further than mere monkey patching, and have decided long ago that too much of the introspection of Python is broken in ways that can only be repaired via an "introspection mini-language", which i have incorporated directly into my custom shell. Besides, who really enjoys typing help(obj) or dir(obj) Both of those function require more effort to type than the information for which they provide, much of which is too verbose anyhow. I mean really, what is GvR's excuse for not adding some filtering to "dir"? He could do it in a backwards compatible manner, but no, he refuses, and instead, decides to fracture a community over a print function! BUT I DIGRESS! And i've never used ipyhon, but if that question mark does what i think it does then i'm yet again reminded that "great minds do, in fact, think alike"! What i'm saying is that the built-in functions of "help", "dir", "type", "id", "repr", "str", etc... are "enough" for the neophyte however they are woefully inadequate for a pythonista like myself. In fact, the more i use this language the more i realize how much i need to change to make it useful for me, which reminds me that i need to get cracking on that fork again. Although i don't know why i bother to mention that fork anyway since it will most likely be my little private toy anyway. I have yet to be convinced that this community deserves any of my contributions, and instead, they will suffer my grievances. From roy at panix.com Sun Jul 6 14:48:26 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 14:48:26 -0400 Subject: How do you use `help` when write your code References: <53b98cf2$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <53b98cf2$0$29985$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > I have a monkey-patched version of dir() which takes a second > argument, a glob, to filter the list of names returned: Neat idea, but globs are for wimps. All the cool kids are using regexes. See that other thread over there ==> From rxjwg98 at gmail.com Sun Jul 6 14:57:50 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 11:57:50 -0700 (PDT) Subject: How to write this repeat matching? Message-ID: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> Hi, On Python website, it says that the following match can reach 'abcb' in 6 steps: ............. A step-by-step example will make this more obvious. Let's consider the expression a[bcd]*b. This matches the letter 'a', zero or more letters from the class [bcd], and finally ends with a 'b'. Now imagine matching this RE against the string abcbd. The end of the RE has now been reached, and it has matched abcb. This demonstrates how the matching engine goes as far as it can at first, and if no match is found it will then progressively back up and retry the rest of the RE again and again. It will back up until it has tried zero matches for [bcd]*, and if that subsequently fails, the engine will conclude that the string doesn't match the RE at all. ............. I write the following code: ....... import re line = "abcdb" matchObj = re.match( 'a[bcd]*b', line) if matchObj: print "matchObj.group() : ", matchObj.group() print "matchObj.group(0) : ", matchObj.group() print "matchObj.group(1) : ", matchObj.group(1) print "matchObj.group(2) : ", matchObj.group(2) else: print "No match!!" ......... In which I have used its match pattern, but the result is not 'abcb' Only matchObj.group(0): abcdb displays. All other group(s) have no content. How to write this greedy search? Thanks, From breamoreboy at yahoo.co.uk Sun Jul 6 14:58:31 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 06 Jul 2014 19:58:31 +0100 Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: On 06/07/2014 19:48, Rick Johnson wrote: > > *Real* programmers possess keen detective that can root out > bugs with nothing more than a few well placed print > statements and some good old fashioned "eyeball analysis". > In the 21st century real programmers are using the logging module so they don't have to mess around. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From wrw at mac.com Sun Jul 6 15:04:12 2014 From: wrw at mac.com (William Ray Wing) Date: Sun, 06 Jul 2014 15:04:12 -0400 Subject: cx_freeze and temporary files - security related question In-Reply-To: <53cuv.255700$eG6.225581@fx29.iad> References: <53cuv.255700$eG6.225581@fx29.iad> Message-ID: <9BC2DC15-68A3-4F41-9D74-BC77E03C27CE@mac.com> On Jul 6, 2014, at 9:21 AM, Richard Damon wrote: > On 5/21/14, 12:42 PM, Nagy L?szl? Zsolt wrote: >> I need to create an application for Windows 7 that runs from a flash >> drive. This program would be used to create remote backups of the >> pendrive. The pendrive contains sensitive data, so when I plug in the >> pendrive and run the program to make a backup, it should not leave any >> trace of operation on the windows system. The information is so >> sensitive that I was forbidden to use cloud storage. I was also >> forbidden to make backups to a local drive, or leave any trace on the >> host windows system. >> >> The question is this: if I create this program with Python 3.4 and >> cx_Freeze, then what should I expect. When the user starts the >> cx_freeze-d program from the flash drive, will it create temporary files >> on the system drive? Will it leave log files or store any permanent or >> temporary data on the system drive (maybe in the user's tmp folder) that >> can later be used to tell what drive was mounted, with what parameters >> the program was started etc. >> >> Thanks >> > > I am not sure about what temp files python might leave around, but if you are being ultimately paranoid about this, one risk that will be present is the possibility of leaving traces of data in the swap file. If the program doesn't specifically prohibit it, anything that is brought into memory (and the act of reading the pendrive will do this) might end up in the swap file. > > I can't imagine python having a run time option to force it to disable the swap file. > > If the data is as sensitive as they seem to want to treat it, perhaps you should follow the procedures of classified computing, which says that any storage medium "exposed" to classified computing becomes classified. This would say that you would use a dedicated machine to do these backups, and after doing them, you remove the hard disk from the machine and lock it up, only to be taken out for later backups. This level of paranoia says you don't need to be as concerned about figuring out what traces might be left, you assume they are and lock them up. > ? Furthermore, I don?t know about Windows, but on many UNIX-like OSs, the file system preserves the time the file was last accessed. If the goal is truly to leave no traces of the fact that the a group of files was backed up, this pretty well would be a red flag that they had been. -Bill From python at mrabarnett.plus.com Sun Jul 6 15:13:46 2014 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 06 Jul 2014 20:13:46 +0100 Subject: What is the difference between matchObj.group() and matchObj.group(0) In-Reply-To: <809dbbdf-b452-4f25-a1ff-f00a2202939d@googlegroups.com> References: <809dbbdf-b452-4f25-a1ff-f00a2202939d@googlegroups.com> Message-ID: <53B99FEA.4070000@mrabarnett.plus.com> On 2014-07-06 19:26, rxjwg98 at gmail.com wrote: > Hi, > > I cannot get the difference between matchObj.group() and matchObj.group(0), > Although there definitions are obvious different. And group() mentions 'tuple'. > tuple means all the elements in line object? > > > > Match Object Methods > > Description > > group(num=0) This method returns entire match (or specific subgroup num) > groups() This method returns all matching subgroups in a tuple > (empty if there weren't any) > > > > I run the following code. Even I add more words to line object, Both have the > same output. > > Could you clarify this question? > matchObj.group(g) returns what was captured by group g. If you don't specify the group, it'll assume that you want group 0, which is the entire part of the string that matched. From python at mrabarnett.plus.com Sun Jul 6 15:19:43 2014 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 06 Jul 2014 20:19:43 +0100 Subject: How to write this repeat matching? In-Reply-To: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> References: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> Message-ID: <53B9A14F.9030705@mrabarnett.plus.com> On 2014-07-06 19:57, rxjwg98 at gmail.com wrote: > Hi, > On Python website, it says that the following match can reach 'abcb' in 6 steps: > > ............. > A step-by-step example will make this more obvious. Let's consider the expression > a[bcd]*b. This matches the letter 'a', zero or more letters from the class [bcd], > and finally ends with a 'b'. Now imagine matching this RE against the string > abcbd. > > The end of the RE has now been reached, and it has matched abcb. This > demonstrates how the matching engine goes as far as it can at first, and if no > match is found it will then progressively back up and retry the rest of the RE > again and again. It will back up until it has tried zero matches for [bcd]*, and > if that subsequently fails, the engine will conclude that the string doesn't > match the RE at all. > ............. > > I write the following code: > > ....... > import re > > line = "abcdb" > > matchObj = re.match( 'a[bcd]*b', line) > > if matchObj: > print "matchObj.group() : ", matchObj.group() > print "matchObj.group(0) : ", matchObj.group() > print "matchObj.group(1) : ", matchObj.group(1) > print "matchObj.group(2) : ", matchObj.group(2) > else: > print "No match!!" > ......... > > In which I have used its match pattern, but the result is not 'abcb' > That's because the example has 'abcb', but you have: line = "abcdb" (You've put a 'd' in it.) > Only matchObj.group(0): abcdb > > displays. All other group(s) have no content. > There are no capture groups in your regex, only group 0 (the entire matched part). > How to write this greedy search? > From roy at panix.com Sun Jul 6 15:15:10 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 15:15:10 -0400 Subject: How do you use `help` when write your code References: Message-ID: In article , Mark Lawrence wrote: > On 06/07/2014 19:48, Rick Johnson wrote: > > > > *Real* programmers possess keen detective that can root out > > bugs with nothing more than a few well placed print > > statements and some good old fashioned "eyeball analysis". > > > > In the 21st century real programmers are using the logging module so > they don't have to mess around. The problem with the logging module is you can configure it to do pretty much anything, which is another way of saying if it's not configured right (perhaps because you're running your application in an environment it wasn't designed for), your output disappears into the ether. I can't tell you how many times I've given up fighting with logging and just done "open("/tmp/x").write("my debugging message\n") when all else failed. From drsalists at gmail.com Sun Jul 6 15:25:17 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 6 Jul 2014 12:25:17 -0700 Subject: PEP8 and 4 spaces In-Reply-To: <53B59358.2040404@tobiah.org> References: <53B59358.2040404@tobiah.org> Message-ID: On Thu, Jul 3, 2014 at 10:31 AM, Tobiah wrote: > Coworker takes PEP8 as gospel and uses 4 spaces > to indent. I prefer tabs. I recently converted from tabs to spaces. I probably still have some code that uses tabs, but most of my personal stuff has been converted. I like tabs. Tabs work better for me than spaces, because I know how to use them. Also, some "make" tools insist on tabs. Also, where many people like 4 spaces or 8 spaces, I prefer tabs expanded to 3 columns. But I finally acknowledged that some very smart people don't understand tabs, or don't want to learn how to use them. Also, I figured out how to get python files to use spaces and Makefile's to use tabs, using some slight vim configuration. So I'm using 4 spaces now. It's nice not having to ignore the relevant pep8 and pylint warnings anymore. And I don't miss tabs nearly as much as I thought I would. In fact, I'm not sure I miss them at all. From ian.g.kelly at gmail.com Sun Jul 6 15:29:26 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 6 Jul 2014 13:29:26 -0600 Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> Message-ID: On Sun, Jul 6, 2014 at 1:25 PM, Dan Stromberg wrote: > I like tabs. Tabs work better for me than spaces, because I know how > to use them. Also, some "make" tools insist on tabs. Those tools are just as broken as the ones that only work with spaces. Fortunately, I can't even remember the last time I had to edit a Makefile. From roy at panix.com Sun Jul 6 15:34:42 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 15:34:42 -0400 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: In article , Dan Stromberg wrote: > On Thu, Jul 3, 2014 at 10:31 AM, Tobiah wrote: > > Coworker takes PEP8 as gospel and uses 4 spaces > > to indent. I prefer tabs. > > I recently converted from tabs to spaces. I probably still have some > code that uses tabs, but most of my personal stuff has been converted. > > I like tabs. Tabs work better for me than spaces, because I know how > to use them. Also, some "make" tools insist on tabs. Why should the fact that Make requires tabs affect how you edit Python code? From ian.g.kelly at gmail.com Sun Jul 6 15:26:44 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sun, 6 Jul 2014 13:26:44 -0600 Subject: How to write this repeat matching? In-Reply-To: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> References: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> Message-ID: On Sun, Jul 6, 2014 at 12:57 PM, wrote: > I write the following code: > > ....... > import re > > line = "abcdb" > > matchObj = re.match( 'a[bcd]*b', line) > > if matchObj: > print "matchObj.group() : ", matchObj.group() > print "matchObj.group(0) : ", matchObj.group() > print "matchObj.group(1) : ", matchObj.group(1) > print "matchObj.group(2) : ", matchObj.group(2) > else: > print "No match!!" > ......... > > In which I have used its match pattern, but the result is not 'abcb' You're never going to get a match of 'abcb' on that string, because 'abcb' is not found anywhere in that string. There are two possible matches for the given pattern over that string: 'abcdb' and 'ab'. The first one matches the [bcd]* three times, and the second one matches it zero times. Because the matching is greedy, you get the result that matches three times. It cannot match one, two or four times because then there would be no 'b' following the [bcd]* portion as required by the pattern. > > Only matchObj.group(0): abcdb > > displays. All other group(s) have no content. Calling match.group(0) is equivalent to calling match.group without arguments. In that case it returns the matched string of the entire regular expression. match.group(1) and match.group(2) will return the value of the first and second matching group respectively, but the pattern does not have any matching groups. If you want a matching group, then enclose the part that you want it to match in parentheses. For example, if you change the pattern to: matchObj = re.match('a([bcd]*)b', line) then the value of matchObj.group(1) will be 'bcd' From rantingrickjohnson at gmail.com Sun Jul 6 15:37:36 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 6 Jul 2014 12:37:36 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: <53aba448-ac52-46c7-99c0-906e8bbc0e0d@googlegroups.com> References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> <4ebc3166-f17e-482b-ad6c-f109db4cad2d@googlegroups.com> <53aba448-ac52-46c7-99c0-906e8bbc0e0d@googlegroups.com> Message-ID: <9ae0cf67-e6d0-45c4-95a2-deb76159ffe8@googlegroups.com> On Sunday, July 6, 2014 1:14:38 PM UTC-5, wxjm... at gmail.com wrote: > Le dimanche 6 juillet 2014 18:53:34 UTC+2, Rick Johnson a ?crit : > [...] > > > Seems like she'd better do the decoding before printing > No > > > or am i wrong again? > Yes > > >>> s = 'abc???' > >>> sys.stdout.encoding > '' > >>> print(s) > abc??? > >>> sys.stdout.encoding = 'cp437' > >>> sys.stdout.encoding > 'cp437' > >>> print(s) > Traceback (most recent call last): > File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write > s = s.encode(self.pencoding).decode('cp1252') > File "C:\Python32\lib\encodings\cp437.py", line 12, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: > character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > >>> sys.stdout.encoding = 'cp850' > >>> sys.stdout.encoding > 'cp850' > >>> print(s) > Traceback (most recent call last): > File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write > s = s.encode(self.pencoding).decode('cp1252') > File "C:\Python32\lib\encodings\cp850.py", line 12, in encode > return codecs.charmap_encode(input,errors,encoding_map) > UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: > character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > >>> # and so on > >>> sys.stdout.encoding = 'cp1252') > File "", line 1 > sys.stdout.encoding = 'cp1252') > ^ > SyntaxError: invalid syntax > >>> # oops > >>> sys.stdout.encoding = 'cp1252' > >>> print(s) > abc??? > >>> sys.stdout.encoding = 'mac-roman' > >>> print(s) > abc??? > >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > >>> sys.stdout.encoding = 'utf-8' > >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > >>> sys.stdout.encoding = 'utf-16-le' > >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > >>> sys.stdout.encoding = 'utf-32-be' > >>> print(s.encode(sys.stdout.encoding, 'replace')) > 'abc???' > jmf Oh my, all that code just so you can handle glyphs with squiggly little accent marks? Are you so afraid you'll forget how to pronounce the words without them? I wonder how those simpleton Americans are able to pronounce words without a tutorial? Boggles the mind really, BOGGLES THE MIND! For the remainder of your bloated Unicode char set that defines symbols, and cute little miniature fractions, and snowmen, and all sorts of ridiculous scrawl... what a waste of time! You know, instead of bending over backwards to "include" every selfish char man in his complete and utter stupidity can muster, when are we going to realize that keyboards can only contain a very *finite* number of keys before they become unusable. If you want to draw shapes and scrawl to a screen, USE THE CORRECT DAMN TOOL! In this day and age of "globalism", when are we going to unite under a single form of written communication. And if not for the sake of programmers, i can think of an even more important reason,,, for the sake of miscommunications and animosity. How many fights and wars have been started simply on the grounds of a miscommunication? "THE MINDS OF LITTLE MEN ARE CONSUMED WITH EMOTIONAL IDENTITIES AND THE PURSUIT OF CREATING SYMBOLS THAT DEFINE THOSE IDENTITIES" The true free man does not belong to any "imaginary" group, he does not pay allegiance to any one country, or any one religion, or any one sports team (if at all), no, he is free and belongs to group defined by a single word, a group from which he does NOT choose, but a group from which he is *BOUND*: THAT GROUP BE HUMANITY! My keyboard has every char i could ever need to express myself sufficiently across a medium that requires redundant "pecking" of keys on a keyboard. This is the form of communication we have achieved thus far, so until we can evolve past this "pecking olymics", we would be wise to keep our pecking to a minimum and employ a ubiquitous written language that is elegant and simplistic, and optimized for typing. I'm sorry but i guess i'm just too practical for all this nonsense. To me Unicode is just like automobiles. Everyone has their own color and brand, and this one has a butt warmer and that one has a vanity mirror, when in fact all automobiles serve the same purpose of transportation. Although, unlike automobiles where i can choose to drive ONLY my car, with Unicode i'm forced to interface with your selfish idea of what a car should be. I just want to get from point A to point B without being pulled over and arrested because you were "partying" with three prostitutes who forgot their crack pipe under the seat! But don't bother listening to me anyway, and go on with your selfish pursuits, continue dividing people instead of uniting them, continue creating a world that is superfluously complex by your own hand -- but don't be surprised when this monstrosity comes crashing down on top of you! THERE IS PRIDE BEFORE THE FALL From Richard at Damon-Family.org Sun Jul 6 15:52:17 2014 From: Richard at Damon-Family.org (Richard Damon) Date: Sun, 06 Jul 2014 15:52:17 -0400 Subject: cx_freeze and temporary files - security related question In-Reply-To: <9BC2DC15-68A3-4F41-9D74-BC77E03C27CE@mac.com> References: <53cuv.255700$eG6.225581@fx29.iad> <9BC2DC15-68A3-4F41-9D74-BC77E03C27CE@mac.com> Message-ID: <53B9A8F1.1090701@Damon-Family.org> On 7/6/14, 3:04 PM, William Ray Wing wrote: > Furthermore, I don?t know about Windows, but on many UNIX-like OSs, > the file system preserves the time the file was last accessed. If the > goal is truly to leave no traces of the fact that the a group of files > was backed up, this pretty well would be a red flag that they had > been. -Bill I don't think the OP was concerned about leaving hints on the pen drive that it was backed up, but on the machine used to back it up. This is why my suggestion is, if you are concerned about leaving traces, lock up the drive with all the traces, just like you probably do all the backups. Then you can know that there aren't any traces left behind that you didn't think of. -- Richard Damon From orgnut at yahoo.com Sun Jul 6 16:32:14 2014 From: orgnut at yahoo.com (Larry Hudson) Date: Sun, 06 Jul 2014 13:32:14 -0700 Subject: Why is it different from the example on the tutorial? In-Reply-To: <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> Message-ID: On 07/06/2014 08:03 AM, rxjwg98 at gmail.com wrote: > Thanks. I do not want to waste everyone's time. For a jump start, there are > small errors making me frustrating. Your help does help me, confirm the usage > etc. After a basic familiarity, I do not want to post more. I use cygwin Python, > I type help of an object 'result'. It does show up the help content, but it > never quits the help afterwards. It is annoying, and time wasting. (Sorry again, > that problem may be about Cygwin, not Python. Excuse me to mention that here. > Of course, your help post consumes your time. Thanks again. > I'm curious as to why you're using Cygwin Python. Cygwin is great for using Unix/Linux programs that are not available in Windows, but there are Windows-native versions of Python available. I would suggest that you would be better off installing Python directly into Windows instead of going round-about with Cygwin. If you do this, I would also suggest that you install Python 3 instead of Python 2, but you may have to find a different tutorial. Although I suspect that part of your problems are that the tutorial you're using IS for Python 3 rather than the 2.7 you are using. Really, there aren't a lot of differences between 2 and 3, but the differences ARE very significant. And 3 is definitely the better, as well as the future. (Aside: I do have Cygwin installed on my Windows system, but I have pretty much given up on using Windows. I find Linux far superior and more comfortable to use, and it gets away from Big-Brotherish Microsoft. I do use it occasionally, but I think the last time I ran it was at least two months ago.) -=- Larry -=- From rxjwg98 at gmail.com Sun Jul 6 16:42:12 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Sun, 6 Jul 2014 13:42:12 -0700 (PDT) Subject: Why is it different from the example on the tutorial? In-Reply-To: References: <21e704ee-648b-423d-8682-11cb310a31a8@googlegroups.com> <6928b0db-4f08-4279-aa2e-98f5b70fbc22@googlegroups.com> Message-ID: On Sunday, July 6, 2014 4:32:14 PM UTC-4, Larry Hudson wrote: > On 07/06/2014 08:03 AM, rxjwg98 at gmail.com wrote: > > > > > Thanks. I do not want to waste everyone's time. For a jump start, there are > > > small errors making me frustrating. Your help does help me, confirm the usage > > > etc. After a basic familiarity, I do not want to post more. I use cygwin Python, > > > I type help of an object 'result'. It does show up the help content, but it > > > never quits the help afterwards. It is annoying, and time wasting. (Sorry again, > > > that problem may be about Cygwin, not Python. Excuse me to mention that here. > > > Of course, your help post consumes your time. Thanks again. > > > > > I'm curious as to why you're using Cygwin Python. Cygwin is great for using Unix/Linux programs > > that are not available in Windows, but there are Windows-native versions of Python available. I > > would suggest that you would be better off installing Python directly into Windows instead of > > going round-about with Cygwin. > > > > If you do this, I would also suggest that you install Python 3 instead of Python 2, but you may > > have to find a different tutorial. Although I suspect that part of your problems are that the > > tutorial you're using IS for Python 3 rather than the 2.7 you are using. Really, there aren't a > > lot of differences between 2 and 3, but the differences ARE very significant. And 3 is > > definitely the better, as well as the future. > > > > (Aside: I do have Cygwin installed on my Windows system, but I have pretty much given up on > > using Windows. I find Linux far superior and more comfortable to use, and it gets away from > > Big-Brotherish Microsoft. I do use it occasionally, but I think the last time I ran it was at > > least two months ago.) > > > > -=- Larry -=- Thanks. In fact, I have both Cygwin and Windows version Python, but I incorrectly thought that Cygwin version Python would be closer to Linux than Windows Python. Another thing, I find that Windows Python have a GUI interface. It is good, but it does not have command history as Cygwin has. From fomcl at yahoo.com Sun Jul 6 13:41:14 2014 From: fomcl at yahoo.com (Albert-Jan Roskam) Date: Sun, 6 Jul 2014 10:41:14 -0700 Subject: Question about metacharacter '*' Message-ID: <1404668474.56075.BPMail_high_noncarrier@web163802.mail.gq1.yahoo.com> >In article , > Rick Johnson wrote: > >> As an aside i prefer to only utilize a "character set" when >> nothing else will suffice. And in this case r"[0-9][0-9]*" >> can be expressed just as correctly (and less noisy IMHO) as >> r"\d\d*". > >Even better, r"\d+" I tend tot do that too, even though technically the two are not perfectly equivalent. With the re.LOCALE flag LC_ctype is also affected, which affects what is captured by \d but not by [0-9] From rosuav at gmail.com Sun Jul 6 18:25:59 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 08:25:59 +1000 Subject: OT: Flashlights [was Re: PEP8 and 4 spaces] In-Reply-To: References: <22220d8c-af69-434b-9361-520e396e615e@googlegroups.com> <8c3844c1-9008-474f-9db5-49d6fad7c0bb@googlegroups.com> <53b7d044$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 1:41 AM, Rick Johnson wrote: > Well Steven all i can hope is that one day you and i will be > working on a project together, and you will ask me for a > "touch", and when i return with a petrol soaked rag burning > on the end of twig and proceed to light your hair on fire, > hopefully at that moment, you will THEN gain a healthy respect > for logical naming conventions! Let's reverse that. Suppose you're the one who is asking for something to illuminate your task - what item will you request? Remember, the person who provides it will be exactly what you're suggesting of yourself - a literal-minded genie. http://tvtropes.org/pmwiki/pmwiki.php/Main/LiteralGenie http://tvtropes.org/pmwiki/pmwiki.php/Main/JackassGenie ChrisA From python at mrabarnett.plus.com Sun Jul 6 18:49:23 2014 From: python at mrabarnett.plus.com (MRAB) Date: Sun, 06 Jul 2014 23:49:23 +0100 Subject: Question about metacharacter '*' In-Reply-To: <1404668474.56075.BPMail_high_noncarrier@web163802.mail.gq1.yahoo.com> References: <1404668474.56075.BPMail_high_noncarrier@web163802.mail.gq1.yahoo.com> Message-ID: <53B9D273.1060706@mrabarnett.plus.com> On 2014-07-06 18:41, Albert-Jan Roskam wrote: > > > >>In article , >> Rick Johnson wrote: >> >>> As an aside i prefer to only utilize a "character set" when >>> nothing else will suffice. And in this case r"[0-9][0-9]*" >>> can be expressed just as correctly (and less noisy IMHO) as >>> r"\d\d*". >> >>Even better, r"\d+" > > I tend tot do that too, even though technically the two are not perfectly equivalent. With the re.LOCALE flag LC_ctype is also affected, which affects what is captured by \d but not by [0-9] > \d also matches more than just [0-9] in Unicode. From rosuav at gmail.com Sun Jul 6 18:54:43 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 08:54:43 +1000 Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: On Mon, Jul 7, 2014 at 5:15 AM, Roy Smith wrote: > In article , > Mark Lawrence wrote: > >> On 06/07/2014 19:48, Rick Johnson wrote: >> > >> > *Real* programmers possess keen detective that can root out >> > bugs with nothing more than a few well placed print >> > statements and some good old fashioned "eyeball analysis". >> > >> >> In the 21st century real programmers are using the logging module so >> they don't have to mess around. > > The problem with the logging module is you can configure it to do pretty > much anything, which is another way of saying if it's not configured > right (perhaps because you're running your application in an environment > it wasn't designed for), your output disappears into the ether. > > I can't tell you how many times I've given up fighting with logging and > just done "open("/tmp/x").write("my debugging message\n") when all else > failed. But the important thing is that you log. There's a VAST difference between logging and interactive debugging: logging can debug something that happened once and didn't recur, interactive debugging requires that you create the problem on command. Have you ever had a bug where someone else finds it and then doesn't give you full repro steps? Or where you find it yourself and declare it intermittent? Proper logging (and hey, Python's pretty helpful with exceptions) can mean that you find that just by browsing backward. There are times when you have to go for the "Real Programmer" debugging style. Pretend the program is a black box, no source code available, nothing. (Maybe that's because it really is like that, or maybe it's just easier to strace a process and watch for the failures than it is to hunt down the source code for the exact version you're running.) Or pretend the code has no direct correlation to what happens, owing to an interpreter bug. (Again, it really can be; imagine a refcount bug in a Python C API function.) Debugging those problems gives you an appreciation for the ease of "double-click the line in the traceback, or hit F4, and go straight to the cause of the error". Python gives us an insane amount of help (I say "insane" because sometimes there have been performance questions surrounding tracebacks), although at the end of the day, debugging is something people. not tools, do. No matter how good Python's traceback handling is, it becomes useless if you wrap everything in "try: ... except: print('Something went wrong')". As Alice's father told her, a tool's "intended function is almost beside the point. Ultimately it's only as good as the person who wields it". http://alice.wikia.com/wiki/Memory ChrisA From jeanpierreda at gmail.com Sun Jul 6 20:39:57 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Sun, 6 Jul 2014 17:39:57 -0700 Subject: Question about metacharacter '*' In-Reply-To: <53B9D273.1060706@mrabarnett.plus.com> References: <1404668474.56075.BPMail_high_noncarrier@web163802.mail.gq1.yahoo.com> <53B9D273.1060706@mrabarnett.plus.com> Message-ID: The reason I did not use \d\d* or \d+ or ^\d+$ or any number of more-correct things was because the OP was new to regexps. -- Devin On Sun, Jul 6, 2014 at 3:49 PM, MRAB wrote: > On 2014-07-06 18:41, Albert-Jan Roskam wrote: >> >> >> >> >>> In article , >>> Rick Johnson wrote: >>> >>>> As an aside i prefer to only utilize a "character set" when >>>> nothing else will suffice. And in this case r"[0-9][0-9]*" >>>> can be expressed just as correctly (and less noisy IMHO) as >>>> r"\d\d*". >>> >>> >>> Even better, r"\d+" >> >> >> I tend tot do that too, even though technically the two are not perfectly >> equivalent. With the re.LOCALE flag LC_ctype is also affected, which affects >> what is captured by \d but not by [0-9] >> > \d also matches more than just [0-9] in Unicode. > > -- > https://mail.python.org/mailman/listinfo/python-list From ben at benfinney.id.au Sun Jul 6 20:53:00 2014 From: ben at benfinney.id.au (Ben Finney) Date: Mon, 07 Jul 2014 10:53:00 +1000 Subject: How do you use `help` when write your code References: Message-ID: <85a98mvvkj.fsf@benfinney.id.au> Shiyao Ma writes: > My normal workflow is use ipython, obj? or obj?? for quick look up or > use docs.python.org for a detailed read. I don't use IPython. I'm glad it exists for those who want it. I frequently use Python on hosts not entirely under my control, where I don't have authority to install new packages, and which only have stock Python installed. So I have to be familiar with IDLE and the standard Python interactive shell. I also find IPython of questionable value when teaching Python to newcomers: its interactive features diverge quite markedly from what is available when writing Python code in a file, so it turns out to be too distracting for someone learning the language. Using the standard Python interactive shell, at least, means what a newcomer learns t the shell is almost entirely transferable to what they need to do to get code into a module's source code. As for the powerful features available in IPython, I find that I get most of them from a Python-aware programmer's editor like Emacs, which also gives me a powerful interactive environment that does more than only Python code. So it would be, IMO, a mistake for me to become too reliant on IPython-specific functionality. It's a high, specific investment that doesn't pay off well on other machines (which commonly don't have it immediately available) or other languages which I need to use. > Do you use `help`? How does it integrate into your workflow? I very often use ?help(foo)? at the Python interactive prompt, to get a quick reference to what an object's attributes and features are. There are two common cases where ?help(foo)? is unable to help: * If ?foo? is a function written without using keyword-only args, but needing to have a bunch of keyword arguments, the signature will often be the uninformative ?foo(*args, **kwargs)?. A docstring is crucial here, but it's too often wrong or absent. I look forward to more and more functions migrating to use keyword-only arguments for these cases, so the function signature can become much more informative in ?help?. * If ?foo? is a function implemented in an extension (non-Python) module, the signature ?foo(...)? is utterly useless. Here, again, the docstring is crucial; and it is frequently just a terse one-liner with no good explanation. Even the standard library is rife with unhelpful function docstrings of this kind. Other than those caveats, I find browsing ?help(foo)? output is very helpful in an interactive session, not least for getting information quickly about an unknown object I've generated from some third-party function call. It is a very good feature that ?help(foo)? for a class instance shows the help of the class: it can be used indiscriminately, and is thus easier to recommend as a mental habit. > Or instead, what similar tools do you use? I have the ?python-doc? and ?python3-doc? packages installed locally, and this gives instant access to the whole Python documentation in my browser without any lag or network dependency. The ?logging? module is a standard feature and makes it much easier to emit informative debugging statements that (unlike ad-hoc ?print? calls) *don't* need to be removed later. Logging can also reveal a lot about the objects while the program is running, as a valuable complement to the ?help? feature and online documentation. -- \ ?Puritanism: The haunting fear that someone, somewhere, may be | `\ happy.? ?Henry L. Mencken | _o__) | Ben Finney From roy at panix.com Sun Jul 6 20:52:33 2014 From: roy at panix.com (Roy Smith) Date: Sun, 06 Jul 2014 20:52:33 -0400 Subject: How do you use `help` when write your code References: Message-ID: In article , Chris Angelico wrote: > But the important thing is that you log. I 'spose. Let's see. Yesterday we generated 133 GB of log files. And Sunday is a slow day :-) > Have you ever had a bug where someone else finds it and then doesn't > give you full repro steps? Are there people like that where you are? Weird. > There are times when you have to go for the "Real Programmer" > debugging style. Pretend the program is a black box, no source code > available, nothing. Yup; strace and tcpdump are two of my best friends. The source code only tells you what the program is *supposed* to do. Strace tells you what it did. And tcpdump tells you what it said. From ben at benfinney.id.au Sun Jul 6 21:00:59 2014 From: ben at benfinney.id.au (Ben Finney) Date: Mon, 07 Jul 2014 11:00:59 +1000 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: <8561javv78.fsf@benfinney.id.au> Dan Stromberg writes: > But I finally acknowledged that some very smart people don't > understand tabs, or don't want to learn how to use them. One day, you may reach the further realisation that those same very smart people *do* understand tabs, and *do* know how to use them ? and nevertheless choose not to put them in source code, for good reasons. > Also, I figured out how to get python files to use spaces and > Makefile's to use tabs, using some slight vim configuration. The makefile syntax is one of the excellent examples of why it's a terrible idea to use tab characters in source code. It's also an excellent example of how a poor design decision (a line beginning with U+0020 SPACE is semantically different from a line beginning with U+0009 CHARACTER TABULATION) can be irrevocable ? the syntax can't be changed now, without breaking compatibility for countless makefiles out there already ? and cause endless confusion and wasted effort dealing with it. Using a mature, well-customised, language-agnostic programmer's editor does make it much better: Vim and Emacs can both seamlessly handle ?tabs are forbidden by default? as a configuration choice, along with ?tabs are necessary in make files, using spaces in the wrong place is an error? at the same time. > So I'm using 4 spaces now. > > It's nice not having to ignore the relevant pep8 and pylint warnings > anymore. And I don't miss tabs nearly as much as I thought I would. > In fact, I'm not sure I miss them at all. Hooray! Welcome to the light :-) -- \ ?The best ad-libs are rehearsed.? ?Graham Kennedy | `\ | _o__) | Ben Finney From fk26541598fk at gmail.com Sun Jul 6 22:18:34 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Sun, 6 Jul 2014 19:18:34 -0700 (PDT) Subject: flask sql cann't insert Variable in VALUES In-Reply-To: References: Message-ID: <2243f87c-78d2-4503-97fa-e30f61c842e5@googlegroups.com> Thank you CA learn so much from your words From cs at zip.com.au Sun Jul 6 21:51:45 2014 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 7 Jul 2014 11:51:45 +1000 Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: <20140707015145.GA80444@cskk.homeip.net> On 06Jul2014 15:15, Roy Smith wrote: >In article , > Mark Lawrence wrote: >> In the 21st century real programmers are using the logging module so >> they don't have to mess around. > >The problem with the logging module is you can configure it to do pretty >much anything, which is another way of saying if it's not configured >right (perhaps because you're running your application in an environment >it wasn't designed for), your output disappears into the ether. > >I can't tell you how many times I've given up fighting with logging and >just done "open("/tmp/x").write("my debugging message\n") when all else >failed. Indeed. I have a cs.logutils module, which is almost entirely support for the logging module (standard setups, funky use cases), but it also defines two functions, X and D, thus: def X(fmt, *args): msg = str(fmt) if args: msg = msg % args sys.stderr.write(msg) sys.stderr.write("\n") sys.stderr.flush() def D(fmt, *args): ''' Print formatted debug string straight to sys.stderr if D_mode is true, bypassing the logging modules entirely. A quick'n'dirty debug tool. ''' global D_mode if D_mode: X(fmt, *args) I use X() for ad hoc right now debugging and D() for turn on at need debugging. Surprisingly handy. Many many of my modules have "from cs.logutils import X, D" at the top. Cheers, Cameron Simpson "How do you know I'm Mad?" asked Alice. "You must be," said the Cat, "or you wouldn't have come here." From steve+comp.lang.python at pearwood.info Sun Jul 6 22:28:38 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 02:28:38 GMT Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: <53ba05d6$0$29985$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > The makefile syntax is one of the excellent examples of why it's a > terrible idea to use tab characters in source code. Hmmm... I'm not sure that conclusion follows. I think that makefile syntax is an example of why it is a terrible idea to give spaces and tabs different semantics, not that tabs themselves are harmful. > It's also an > excellent example of how a poor design decision (a line beginning with > U+0020 SPACE is semantically different from a line beginning with U+0009 > CHARACTER TABULATION) can be irrevocable Yes. Design your public APIs cleanly and clearly from the start. The story of makefiles is a warning of the dark side to "release early, release often", and the dangers of using alpha software in production: [quote] Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried either, so I figured this would be a good excuse to learn. After getting myself snarled up with my first stab at Lex, I just did something simple with the pattern newline-tab. It worked, it stayed. And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn't want to screw up my embedded base. The rest, sadly, is history. -- Stuart Feldman [end quote] -- Steven From rosuav at gmail.com Sun Jul 6 22:58:07 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 12:58:07 +1000 Subject: How do you use `help` when write your code In-Reply-To: <85a98mvvkj.fsf@benfinney.id.au> References: <85a98mvvkj.fsf@benfinney.id.au> Message-ID: On Mon, Jul 7, 2014 at 10:53 AM, Ben Finney wrote: > There are two common cases where ?help(foo)? is unable to help: > > * If ?foo? is a function written without using keyword-only args, but > needing to have a bunch of keyword arguments, the signature will often > be the uninformative ?foo(*args, **kwargs)?. A docstring is crucial > here, but it's too often wrong or absent. > > I look forward to more and more functions migrating to use > keyword-only arguments for these cases, so the function signature can > become much more informative in ?help?. Most common cause of this problem is when a function ought to have functools.wraps but didn't. if DEBUG: debug = print else: @functools.wraps(print) def debug(*a, **kw): pass Without wraps(), the non-debug-mode version of debug() is completely unhelpful. There's another issue with help(), and that's when it's used on a large class - it's not that it's unhelpful, it's more that the useful information gets lost in the spam of a pile of dunder functions. Check out help(1) for instance. ChrisA From rosuav at gmail.com Sun Jul 6 23:06:07 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 13:06:07 +1000 Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: On Mon, Jul 7, 2014 at 10:52 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> But the important thing is that you log. > > I 'spose. Let's see. Yesterday we generated 133 GB of log files. And > Sunday is a slow day :-) Heh, that's a bit bigger in scale than most of what I work with... but yes. I have a log file of the from and to addresses of every email that goes through my spam filter, and whether it was marked spam or ham; the expectation is that any mail that doesn't bounce (the server will reject prior to this log based on certain rules) will be in the log, so if anyone asks about something, I can grep the log for an address. It's a fairly compact log, and this is a fairly small site, so the growth is a lot slower than 133GB/day! But the principle's the same: log today so you can find a problem tomorrow. >> Have you ever had a bug where someone else finds it and then doesn't >> give you full repro steps? > > Are there people like that where you are? Weird. Yes, sadly, there are people just about everywhere. (Despite my post being in response to one of yours, Roy, I still partly felt that I was addressing Rick. Hence the slightly odd wording of something that, for most of us, is a "duh" matter.) >> There are times when you have to go for the "Real Programmer" >> debugging style. Pretend the program is a black box, no source code >> available, nothing. > > Yup; strace and tcpdump are two of my best friends. The source code > only tells you what the program is *supposed* to do. Strace tells you > what it did. And tcpdump tells you what it said. That's about it, yeah. I tend to find both strace and tcpdump rather too spammy for most usage, so any time I reach for those tools, it's usually with some tight filtering - and even that's not always helpful. The last thing I straced was a (closed-source) game that was having some problems (cross-platform, I'm one of a very small number of Linux testers), and it was running at well over 100 FPS... and each frame involved quite a few system calls. Yeah, that was spammy. ChrisA From rosuav at gmail.com Sun Jul 6 22:50:18 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 12:50:18 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <53ba05d6$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53B59358.2040404@tobiah.org> <53ba05d6$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 12:28 PM, Steven D'Aprano wrote: > The story of makefiles is a warning of the dark side to "release early, > release often", and the dangers of using alpha software in production: > > [quote] > Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried > either, so I figured this would be a good excuse to learn. After getting > myself snarled up with my first stab at Lex, I just did something simple > with the pattern newline-tab. It worked, it stayed. And then a few weeks > later I had a user population of about a dozen, most of them friends, and > I didn't want to screw up my embedded base. The rest, sadly, is history. > -- Stuart Feldman > [end quote] Perhaps. Or perhaps it's a warning about the importance of version 0 of a piece of software: you "release early, release often", but you start with version 0.1, where the standard backward compat guarantees don't hold. You get some feedback, and then when you finally release version 1.0, you start promising not to mess people's stuff up; but before that, anything might change. ChrisA From steve+comp.lang.python at pearwood.info Sun Jul 6 23:20:28 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 03:20:28 GMT Subject: open() and EOFError Message-ID: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> Are there any circumstances where merely *opening* a file (before reading it) can raise EOFError? -- Steven From mrwhackadoo1 at gmail.com Sun Jul 6 19:03:07 2014 From: mrwhackadoo1 at gmail.com (mrwhackadoo1 at gmail.com) Date: Sun, 6 Jul 2014 23:03:07 +0000 Subject: =?utf-8?Q?Saving?= Message-ID: <53b9d5c1.037a320a.5521.ffffa6bb@mx.google.com> Hi, I?ve been looking forever for this and I cant get it. I need to know how to save my code and save as programs because I write code and I run it but then I cant save it for later. Please help and thank you for your time. -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg.ewing at canterbury.ac.nz Mon Jul 7 01:04:12 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Mon, 07 Jul 2014 17:04:12 +1200 Subject: open() and EOFError In-Reply-To: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > Are there any circumstances where merely *opening* a file (before reading > it) can raise EOFError? I don't think so. As far as I know, the only built-in thing that raises EOFError is input() (and raw_input() in Py2). -- Greg From ben at benfinney.id.au Mon Jul 7 01:29:05 2014 From: ben at benfinney.id.au (Ben Finney) Date: Mon, 07 Jul 2014 15:29:05 +1000 Subject: Programmer's text editor (was: Saving) References: <53b9d5c1.037a320a.5521.ffffa6bb@mx.google.com> Message-ID: <85zjglvise.fsf@benfinney.id.au> writes: > I need to know how to save my code and save as programs because I > write code and I run it but then I cant save it for later. You can write Python code using any text editor. You will do well to use a text editor which is deliberately designed for programming and other related editing tasks. I would also recommend that a programmer's text editor should: * Be licensed as free software ? the tool should be able to be improved and maintained and distributed to you by any party sufficiently motivated, not locked up by any single party. * Work the same on all major platforms ? you should not need to abandon a tool you like merely because you switch to a different machine for a while. * Be mature with a strong track record ? a text editor which has been around for some decades, and still has a large following, has demonstrated it can survive many different trends in programming tools. * Well-supported with its own vibrant community ? you don't necessarily need to join such a community, but you will greatly benefit from the fact that a tool has robust community support. That the tool is free software is a significant contributor to this. * Be indefinitely customisable to meet new needs ? this ensures that anyone sufficiently motivated can allow you to use the tool you already know for new tasks that come along. Having a strong community of support will mean that most tasks are already supported in the tool by people who came before you. * Properly support many programming languages and related formats ? this is an outcome of the tool being community-supported, mature, and highly customisable. The tool should, in its standard installation, already support major programming languages and formats, and have a simple way to add supporting plug-ins as you need them. I know of two obvious text editors that meet these criteria: * Vim * Emacs If you're using a *nix style operating system such as GNU+Linux, you will have both of these available for installation from the operating system. > Please help and thank you for your time. I hope that helps. Familiarising yourself with a strong, free-software, cross-platform text editor is an essential investment in programming. Good hunting! -- \ ?We have clumsy, sputtering, inefficient brains?. It is a | `\ *struggle* to be rational and objective, and failures are not | _o__) evidence for an alternative reality.? ?Paul Z. Myers, 2010-10-14 | Ben Finney From dan at tombstonezero.net Mon Jul 7 01:35:41 2014 From: dan at tombstonezero.net (Dan Sommers) Date: Mon, 7 Jul 2014 05:35:41 +0000 (UTC) Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > The makefile syntax is one of the excellent examples of why it's a > terrible idea to use tab characters in source code. It's also an > excellent example of how a poor design decision (a line beginning with > U+0020 SPACE is semantically different from a line beginning with > U+0009 CHARACTER TABULATION) can be irrevocable ? the syntax can't be > changed now, without breaking compatibility for countless makefiles > out there already ? and cause endless confusion and wasted effort > dealing with it. When makefile syntax came into being, there were ASCII TAB characters, with a value of 9, and ASCII SPC characters, with a value of 32 (and there may not even have been those). The former is a "control" character, which has specific semantics associated with it; the latter is a "printable" character, which is usually printed and interpreted as itself (although in this particular case, the printed representation is hard to see on most output devices). This mailing list doesn't seem to mind that lines beginning with ASCII SPC characters are semantically different from lines beginning with ASCII LF characters, although many detractors of Python seem unduly fixated on it. From cs at zip.com.au Mon Jul 7 01:14:32 2014 From: cs at zip.com.au (Cameron Simpson) Date: Mon, 7 Jul 2014 15:14:32 +1000 Subject: Saving In-Reply-To: <53b9d5c1.037a320a.5521.ffffa6bb@mx.google.com> References: <53b9d5c1.037a320a.5521.ffffa6bb@mx.google.com> Message-ID: <20140707051432.GA99012@cskk.homeip.net> On 06Jul2014 23:03, mrwhackadoo1 at gmail.com wrote: >I need to know how to save my code and save as programs because I write code >Please help and thank you for your time. Please tell a bit more about your work environment (editors, IDEs, computer OS, etc). The basic answer to your question is to edit the code in a file of its own, and to run it is a separate action, from that file. As an example, my coding environment contains an editor window and a shell (command line) window. (Plus doco in a web browser, etc, as needed.) So open a file with a useful name (start with "program1.py", but pick something more apt depending on the task) and open an editor on that file. When ready to test, save the file (probably a single key command in most editors, or the ever popular "File->Save" menu option). Then in another window, run it: python program1.py So you don't write code, test and _then_ save. You write code and save. Then test from the saved file. Cheers, Cameron Simpson I'm Bubba of Borg. Y'all fixin' to be assimilated. From wxjmfauth at gmail.com Mon Jul 7 02:58:05 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Sun, 6 Jul 2014 23:58:05 -0700 (PDT) Subject: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout, In-Reply-To: <9ae0cf67-e6d0-45c4-95a2-deb76159ffe8@googlegroups.com> References: <57444726-c79e-499c-aff6-5d268448035f@googlegroups.com> <6a41f25e-2025-4f1a-ad9d-4458fc804b63@googlegroups.com> <4ebc3166-f17e-482b-ad6c-f109db4cad2d@googlegroups.com> <53aba448-ac52-46c7-99c0-906e8bbc0e0d@googlegroups.com> <9ae0cf67-e6d0-45c4-95a2-deb76159ffe8@googlegroups.com> Message-ID: Le dimanche 6 juillet 2014 21:37:36 UTC+2, Rick Johnson a ?crit?: > On Sunday, July 6, 2014 1:14:38 PM UTC-5, wxjm... at gmail.com wrote: > > > Le dimanche 6 juillet 2014 18:53:34 UTC+2, Rick Johnson a ?crit : > > > [...] > > > > > > > Seems like she'd better do the decoding before printing > > > No > > > > > > > or am i wrong again? > > > Yes > > > > > > >>> s = 'abc???' > > > >>> sys.stdout.encoding > > > '' > > > >>> print(s) > > > abc??? > > > >>> sys.stdout.encoding = 'cp437' > > > >>> sys.stdout.encoding > > > 'cp437' > > > >>> print(s) > > > Traceback (most recent call last): > > > File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write > > > s = s.encode(self.pencoding).decode('cp1252') > > > File "C:\Python32\lib\encodings\cp437.py", line 12, in encode > > > return codecs.charmap_encode(input,errors,encoding_map) > > > UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: > > > character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > >>> sys.stdout.encoding = 'cp850' > > > >>> sys.stdout.encoding > > > 'cp850' > > > >>> print(s) > > > Traceback (most recent call last): > > > File "", line 1, in File "D:\jm\jmpy\eta\eta40beta2\etastdio.py", line 158, in write > > > s = s.encode(self.pencoding).decode('cp1252') > > > File "C:\Python32\lib\encodings\cp850.py", line 12, in encode > > > return codecs.charmap_encode(input,errors,encoding_map) > > > UnicodeEncodeError: 'charmap' codec can't encode characters in position 4-5: > > > character maps to >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > >>> # and so on > > > >>> sys.stdout.encoding = 'cp1252') > > > File "", line 1 > > > sys.stdout.encoding = 'cp1252') > > > ^ > > > SyntaxError: invalid syntax > > > >>> # oops > > > >>> sys.stdout.encoding = 'cp1252' > > > >>> print(s) > > > abc??? > > > >>> sys.stdout.encoding = 'mac-roman' > > > >>> print(s) > > > abc??? > > > >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > >>> sys.stdout.encoding = 'utf-8' > > > >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > >>> sys.stdout.encoding = 'utf-16-le' > > > >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > >>> sys.stdout.encoding = 'utf-32-be' > > > >>> print(s.encode(sys.stdout.encoding, 'replace')) > > > 'abc???' > > > jmf > > > > Oh my, all that code just so you can handle glyphs with > > squiggly little accent marks? Are you so afraid you'll > > forget how to pronounce the words without them? I wonder how > > those simpleton Americans are able to pronounce words without > > a tutorial? Boggles the mind really, BOGGLES THE MIND! > > > > For the remainder of your bloated Unicode char set that > > defines symbols, and cute little miniature fractions, and > > snowmen, and all sorts of ridiculous scrawl... what a waste > > of time! > > > > You know, instead of bending over backwards to "include" > > every selfish char man in his complete and utter stupidity > > can muster, when are we going to realize that keyboards can > > only contain a very *finite* number of keys before they > > become unusable. If you want to draw shapes and scrawl to a > > screen, USE THE CORRECT DAMN TOOL! > > > > In this day and age of "globalism", when are we going to > > unite under a single form of written communication. And if > > not for the sake of programmers, i can think of an even more > > important reason,,, for the sake of miscommunications and > > animosity. How many fights and wars have been started simply > > on the grounds of a miscommunication? > > > > "THE MINDS OF LITTLE MEN ARE CONSUMED WITH > > EMOTIONAL IDENTITIES AND THE PURSUIT OF CREATING > > SYMBOLS THAT DEFINE THOSE IDENTITIES" > > > > The true free man does not belong to any "imaginary" group, > > he does not pay allegiance to any one country, or any one > > religion, or any one sports team (if at all), no, he is free > > and belongs to group defined by a single word, a group from > > which he does NOT choose, but a group from which he is > > *BOUND*: > > > > THAT GROUP BE HUMANITY! > > > > My keyboard has every char i could ever need to express > > myself sufficiently across a medium that requires redundant > > "pecking" of keys on a keyboard. This is the form of > > communication we have achieved thus far, so until we can > > evolve past this "pecking olymics", we would be wise to keep > > our pecking to a minimum and employ a ubiquitous written > > language that is elegant and simplistic, and optimized for > > typing. > > > > I'm sorry but i guess i'm just too practical for all this > > nonsense. To me Unicode is just like automobiles. Everyone > > has their own color and brand, and this one has a butt > > warmer and that one has a vanity mirror, when in fact all > > automobiles serve the same purpose of transportation. > > > > Although, unlike automobiles where i can choose to drive > > ONLY my car, with Unicode i'm forced to interface with your > > selfish idea of what a car should be. I just want to get > > from point A to point B without being pulled over and > > arrested because you were "partying" with three prostitutes > > who forgot their crack pipe under the seat! > > > > But don't bother listening to me anyway, and go on with your > > selfish pursuits, continue dividing people instead of > > uniting them, continue creating a world that is superfluously > > complex by your own hand -- but don't be surprised when this > > monstrosity comes crashing down on top of you! > > > > THERE IS PRIDE BEFORE THE FALL -------- I forgot to mention, the example I gave came from one of my interactive Python interpreter (a gui app). You have certainly noticed, it has the faculty to modify on the fly the coding of the "device" that will host a unicode. It mimics, in fact, any device which may receive a unicode (terminal, file, db, gui text widget, ...) and that a unicode has to be encoded. The characters I'm using are just characters very representative of unicode and I deliberatly choose them with care. Glyphs have here nothing to do. But, if you wish examples with others chars/fonts like junicode (medieval scripts), stix (math symbols), polytonic Greek or why not Urdu script (nastaliq, naskh [*]), ... https://medium.com/@eteraz/the-death-of-the-urdu-script-9ce935435d90 [*] not yet tested. jmf From g.statkute at gmail.com Mon Jul 7 03:19:05 2014 From: g.statkute at gmail.com (gintare) Date: Mon, 7 Jul 2014 00:19:05 -0700 (PDT) Subject: finditer Message-ID: If smbd has time, maybe you could advice how to accomplish this task in faster way. I have a text = """ word{vb} wordtransl {vb} sent1. sent1trans. sent2 sent2trans... """ I need to match once wordtransl, and than many times repeating patterns consisting of sent and senttrans. The way i achieved this goal is for sure not most efficient one: sw=word # i know the word stry='\s*'+sw+'\s*.*\{vb\}\n+' stry=stry+'(?P.*)\{vb\}\n+' stryc=re.compile(stry, re.UNICODE) LtryM=re.search(stryc, linef) #here i find wordtrans part=re.split(stryc,linef) #here i split search text to obtain part with repeating sent and senttrans stry2='(?:' stry2=stry2+'\s*'+sw+'\s*.*\{vb\}\n+' stry2=stry2+'(?P.*)\{vb\}\n+' stry2=stry2+')*' stry2=stry2+'(' stry2=stry2+'(?P.*)\n+' stry2=stry2+'(?P.*)\n+' stry2=stry2+')' stryc2=re.compile(stry2, re.UNICODE) LtryM=re.finditer(stryc2, part[2]) #here i find text pieces consisting sent and sentrans for item in LtryM: stry3='' stry3=stry3+'(?P.*)\n+' stry3=stry3+'(?P.*)\n+' stryc3=re.compile(stry3, re.UNICODE) LtryM3=re.search(stryc3, item.group()) #here i find sent and senttrans print(LtryM3.groupdict()) From steve at pearwood.info Mon Jul 7 03:57:21 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 07:57:21 GMT Subject: Module name does not match file name Message-ID: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> Cut a long story short... I'm trying to debug a Tkinter app written in Python. The author of this app designed it as a maze of twisty dependencies, all alike, and his idea of source control was to make multiple copies of every file and drop them in random places on the hard drive. He also has a whole lot of non- standard, semi-standard, and just plain weird locations added to the PYTHONPATH, some of which are added at run time for extra enjoyment, so I'm having lots of fun trying to work out which files are being imported and where they are being imported from. I ran the modulefinder tool to get a list of imported modules: $ python2.6 -m modulefinder /long/path/script.py but to my surprise, it claims that "import pg" is *not* reading the pg.py file I located, but instead loading a module with a completely different name: $ python2.6 -m modulefinder /long/path/script.py Name File ---- ---- [...] m pg /usr/local/lib/python2.6/dist-packages/pgmodule.so Can anyone explain how "import pg" can end up coming from pgmodule.so? Sure enough: >>> import pg >>> pg.__file__ '/usr/local/lib/python2.6/dist-packages/pgmodule.so' What sorcery is this??? -- Steven From rosuav at gmail.com Mon Jul 7 04:04:36 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 18:04:36 +1000 Subject: Module name does not match file name In-Reply-To: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano wrote: > Can anyone explain how "import pg" can end up coming from pgmodule.so? First guess: There's a "pg.py" somewhere that imports the so, then replaces itself in sys.modules. # importme.py import sys sys.modules["importme"]=sys >>> import importme >>> importme Unfortunately, that doesn't help much with actually finding the source code that's doing this. ChrisA From steve at pearwood.info Mon Jul 7 04:00:14 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 08:00:14 GMT Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Are there any circumstances where merely *opening* a file (before >> reading it) can raise EOFError? > > I don't think so. As far as I know, the only built-in thing that raises > EOFError is input() (and raw_input() in Py2). Thanks. That's what I thought. How do people feel about code like this? try: name = input("Enter file name, or Ctrl-D to exit") # On Windows, use Ctrl-Z [enter] instead. fp = open(name) except EOFError: sys.exit() except IOError: handle_bad_file(name) else: handle_good_file(fp) -- Steven From rosuav at gmail.com Mon Jul 7 04:09:28 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 18:09:28 +1000 Subject: open() and EOFError In-Reply-To: <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > handle_bad_file(name) > else: > handle_good_file(fp) It seems trivial in this example to break it into two try blocks: try: name = input("Enter file name, or Ctrl-D to exit") # On Windows, use Ctrl-Z [enter] instead. except EOFError: sys.exit() try: fp = open(name) except IOError: handle_bad_file(name) else: handle_good_file(fp) But if the code's more complicated and it's not so easy to split, then sure, doesn't seem a problem. It's like spam[foo//bar] and then catching either IndexError or ZeroDivisionError - there's no big confusion from having two distinct sources of two distinct errors handled by two distinct except blocks. ChrisA From steve at pearwood.info Mon Jul 7 04:57:00 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 08:57:00 GMT Subject: Module name does not match file name References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Ah, I think I have a partial answer... but not a complete answer. On Mon, 07 Jul 2014 07:57:21 +0000, Steven D'Aprano wrote: > Can anyone explain how "import pg" can end up coming from pgmodule.so? > > > Sure enough: > >>>> import pg >>>> pg.__file__ > '/usr/local/lib/python2.6/dist-packages/pgmodule.so' I've looked inside the pgmodule.c source code, and it includes this snippet: extern void initpg(void) { char *p; int i; Py_InitModule("pg", pg_methods); which suggests that the pgmodule.so file creates a module called "pg". What I don't understand is how "import pg" gets turned into "run pgmodule.so"? -- Steven From rosuav at gmail.com Mon Jul 7 05:03:33 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 19:03:33 +1000 Subject: Module name does not match file name In-Reply-To: <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano wrote: > which suggests that the pgmodule.so file creates a module called "pg". > What I don't understand is how "import pg" gets turned into "run > pgmodule.so"? What happens if you *don't* import pg? Is there a sys.modules["pg"] already? If so, I'd go looking at what gets imported on startup - in fact, either way, "python -v" output might be of value here. ChrisA From steve at pearwood.info Mon Jul 7 05:03:17 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 09:03:17 GMT Subject: Module name does not match file name References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53ba6254$0$2926$c3e8da3$76491128@news.astraweb.com> On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano > wrote: >> Can anyone explain how "import pg" can end up coming from pgmodule.so? > > First guess: There's a "pg.py" somewhere that imports the so, then > replaces itself in sys.modules. Oh, there's a pg.py somewhere alright, but it imports _py and there is no _py module anywhere on the system. I don't believe that the pg.py file is actually used, even though it is in the site-packages next to pgmodule.py. I did mention the maze of twisty dependencies, didn't I? -- Steven From rosuav at gmail.com Mon Jul 7 05:11:52 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 19:11:52 +1000 Subject: Module name does not match file name In-Reply-To: <53ba6254$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba6254$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 7:03 PM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 18:04:36 +1000, Chris Angelico wrote: > >> On Mon, Jul 7, 2014 at 5:57 PM, Steven D'Aprano >> wrote: >>> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> First guess: There's a "pg.py" somewhere that imports the so, then >> replaces itself in sys.modules. > > > Oh, there's a pg.py somewhere alright, but it imports _py and there is no > _py module anywhere on the system. I don't believe that the pg.py file is > actually used, even though it is in the site-packages next to pgmodule.py. Huh. Definitely curious as to what 'python -v' says, then. > I did mention the maze of twisty dependencies, didn't I? And I winced at your opening paragraph. ChrisA From steve at pearwood.info Mon Jul 7 05:28:43 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 09:28:43 GMT Subject: Module name does not match file name References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53ba684b$0$2926$c3e8da3$76491128@news.astraweb.com> On Mon, 07 Jul 2014 19:03:33 +1000, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:57 PM, Steven D'Aprano > wrote: >> which suggests that the pgmodule.so file creates a module called "pg". >> What I don't understand is how "import pg" gets turned into "run >> pgmodule.so"? > > What happens if you *don't* import pg? Is there a sys.modules["pg"] > already? No. py> "pg" in sys.modules.keys() False But then there's this: py> import pgmodule Traceback (most recent call last): File "", line 1, in ImportError: dynamic module does not define init function (initpgmodule) py> import pg py> import pgmodule py> pg.__file__ == pgmodule.__file__ True o_O -- Steven From denismfmcmahon at gmail.com Mon Jul 7 05:31:34 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Mon, 7 Jul 2014 09:31:34 +0000 (UTC) Subject: Saving References: Message-ID: On Sun, 06 Jul 2014 23:03:07 +0000, mrwhackadoo1 wrote: > Hi, I?ve been looking forever for this and I cant get it. > > I need to know how to save my code and save as programs because I write > code and I run it but then I cant save it for later. > > Please help and thank you for your time. Write your code in a file and run them from your command line, instead of entering your programs directly into the interpreter. -- Denis McMahon, denismfmcmahon at gmail.com From marko at pacujo.net Mon Jul 7 05:42:28 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 12:42:28 +0300 Subject: Emperor's New Coroutines? Message-ID: <87lhs5h5dn.fsf@elektro.pacujo.net> The asyncio module comes with coroutine support. Investigating the topic on the net reveals that FSM's are for old people and the brave new world uses coroutines. Unfortunately, all examples I could find seem to be overly simplistic, and I'm left thinking coroutines have few practical uses in network programming. PEP-380 refers to the classic Dining Philosophers: (reproduced below). Suppose I want to fix the protocol by supplying an "attendant" object that periodically tells the philosophers to drop whatever they are doing and start thinking. So I would add: schedule(attendant(..., [ plato, socrates, euclid ])) but how would I modify the philosopher code to support such master resets? Marko ======================================================================== from scheduler import * class Utensil: def __init__(self, id): self.id = id self.available = True self.queue = [] def acquire(self): #print "--- acquire", self.id, "avail", self.available if not self.available: block(self.queue) yield #print "--- acquired", self.id self.available = False def release(self): #print "--- release", self.id self.available = True unblock(self.queue) def philosopher(name, lifetime, think_time, eat_time, left_fork, right_fork): for i in range(lifetime): for j in range(think_time): print(name, "thinking") yield print(name, "waiting for fork", left_fork.id) yield from left_fork.acquire() print(name, "acquired fork", left_fork.id) print(name, "waiting for fork", right_fork.id) yield from right_fork.acquire() print(name, "acquired fork", right_fork.id) for j in range(eat_time): # They're Python philosophers, so they eat spam rather than spaghetti print(name, "eating spam") yield print(name, "releasing forks", left_fork.id, "and", right_fork.id) left_fork.release() right_fork.release() print(name, "leaving the table") forks = [Utensil(i) for i in range(3)] schedule(philosopher("Plato", 7, 2, 3, forks[0], forks[1]), "Plato") schedule(philosopher("Socrates", 8, 3, 1, forks[1], forks[2]), "Socrates") schedule(philosopher("Euclid", 5, 1, 4, forks[2], forks[0]), "Euclid") run() From __peter__ at web.de Mon Jul 7 06:41:15 2014 From: __peter__ at web.de (Peter Otten) Date: Mon, 07 Jul 2014 12:41:15 +0200 Subject: Module name does not match file name References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > Ah, I think I have a partial answer... but not a complete answer. > > > On Mon, 07 Jul 2014 07:57:21 +0000, Steven D'Aprano wrote: > >> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> >> Sure enough: >> >>>>> import pg >>>>> pg.__file__ >> '/usr/local/lib/python2.6/dist-packages/pgmodule.so' > > > > I've looked inside the pgmodule.c source code, and it includes this > snippet: > > > extern void > initpg(void) > { > char *p; > int i; > > Py_InitModule("pg", pg_methods); > > > which suggests that the pgmodule.so file creates a module called "pg". > What I don't understand is how "import pg" gets turned into "run > pgmodule.so"? It seems the suffix "module.so" is tried automagically by the import machinery: $ touch alphamodule.so $ python Python 2.7.5+ (default, Feb 27 2014, 19:37:08) [GCC 4.8.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import alpha Traceback (most recent call last): File "", line 1, in ImportError: ./alphamodule.so: file too short From robert.kern at gmail.com Mon Jul 7 07:15:51 2014 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 07 Jul 2014 12:15:51 +0100 Subject: Module name does not match file name In-Reply-To: <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 2014-07-07 09:57, Steven D'Aprano wrote: > Ah, I think I have a partial answer... but not a complete answer. > > > On Mon, 07 Jul 2014 07:57:21 +0000, Steven D'Aprano wrote: > >> Can anyone explain how "import pg" can end up coming from pgmodule.so? >> >> >> Sure enough: >> >>>>> import pg >>>>> pg.__file__ >> '/usr/local/lib/python2.6/dist-packages/pgmodule.so' > > > > I've looked inside the pgmodule.c source code, and it includes this > snippet: > > > extern void > initpg(void) > { > char *p; > int i; > > Py_InitModule("pg", pg_methods); > > > which suggests that the pgmodule.so file creates a module called "pg". > What I don't understand is how "import pg" gets turned into "run > pgmodule.so"? This has been standard Python behavior for extension modules since forever. It's a very old practice and not recommended for new code, though. [~] |1> import imp [~] |2> imp.get_suffixes() [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', 'rb', 2)] -- 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 roy at panix.com Mon Jul 7 07:22:15 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 07:22:15 -0400 Subject: How do you use `help` when write your code References: Message-ID: In article , Chris Angelico wrote: > That's about it, yeah. I tend to find both strace and tcpdump rather > too spammy for most usage, so any time I reach for those tools, it's > usually with some tight filtering - and even that's not always > helpful. Usually, when I fire up strace, it's because I'm looking for something specific. A common use case is, "I just edited this config file, but it doesn't seem to be having any effect". I'll do something like "strace -e file" and grep out all the open() calls. From there, it's trivial to verify that it is indeed reading my config file (or not). Or that there's other config files (/usr/share/whatever) that it's reading that I didn't even know existed, which might be overriding my own. Likewise for which libraries it's linking against, which executables it's running, etc. From rosuav at gmail.com Mon Jul 7 07:36:15 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 21:36:15 +1000 Subject: How do you use `help` when write your code In-Reply-To: References: Message-ID: On Mon, Jul 7, 2014 at 9:22 PM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> That's about it, yeah. I tend to find both strace and tcpdump rather >> too spammy for most usage, so any time I reach for those tools, it's >> usually with some tight filtering - and even that's not always >> helpful. > > Usually, when I fire up strace, it's because I'm looking for something > specific. A common use case is, "I just edited this config file, but it > doesn't seem to be having any effect". I'll do something like "strace > -e file" and grep out all the open() calls. From there, it's trivial to > verify that it is indeed reading my config file (or not). Or that > there's other config files (/usr/share/whatever) that it's reading that > I didn't even know existed, which might be overriding my own. Likewise > for which libraries it's linking against, which executables it's > running, etc. Yep. Sometimes it's fairly easy. I was trying to figure out where rdesktop was looking for its keymaps, and rather than hunt down the source, I just straced it and watched for errors, and found that it was looking for ~/.rdesktop/keymaps, so I made that as a symlink to what I wanted. (I'm sure I could have found this somewhere in the docs, but after a small amount of searching, I didn't have any indication of where; and for this job, I needed it to be local, rather than in a root-owned directory.) That one was pretty straight-forward. The time I was trying to trace that game, though, I was trying to figure out why it was unable to save screenshots; and since the most likely cause was an incorrect path name, I couldn't search for the path. Had to negate the search - run the trace, then filter out everything that looks like the one most common line, rinse and repeat until it's silent. Then hit the screenshot key. Whoops, filtered out too much, didn't see a thing.... weaken the filters, start again. Would have liked source code for THAT one! A simple line of "write my parameters to stderr" would have done the job. At the end of the day, it's just another tool in the box. You learn to use it because there are times when it's the right one for the job. ChrisA From steve+comp.lang.python at pearwood.info Mon Jul 7 07:56:31 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 11:56:31 GMT Subject: Module name does not match file name References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53ba8aef$0$29995$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: > On 2014-07-07 09:57, Steven D'Aprano wrote: >> What I don't understand is how "import pg" gets turned into "run >> pgmodule.so"? > > This has been standard Python behavior for extension modules since > forever. It's a very old practice and not recommended for new code, > though. Hmmm. Well, that is very special. Is this documented anywhere? I know very little about extension modules. If I just rename the source file from pgmodule.c to pg.c, recompile to pg.so, and use that in place of pgmodule.so, is anything likely to break? > |1> import imp > > [~] > |2> imp.get_suffixes() > [('.so', 'rb', 3), ('module.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', > 'rb', 2)] That seems to be gone in Python 3.3: py> imp.get_suffixes() [('.cpython-33m.so', 'rb', 3), ('.abi3.so', 'rb', 3), ('.so', 'rb', 3), ('.py', 'U', 1), ('.pyc', 'rb', 2)] -- Steven From rosuav at gmail.com Mon Jul 7 08:04:51 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 22:04:51 +1000 Subject: Module name does not match file name In-Reply-To: <53ba8aef$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba8aef$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 9:56 PM, Steven D'Aprano wrote: > Hmmm. Well, that is very special. Is this documented anywhere? "Special", in the sense of Shepherd Book addressing Mal. "Isn't that... special." ChrisA From davea at davea.name Mon Jul 7 08:14:31 2014 From: davea at davea.name (Dave Angel) Date: Mon, 7 Jul 2014 08:14:31 -0400 (EDT) Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: Steven D'Aprano Wrote in message: > On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > >> Steven D'Aprano wrote: >>> Are there any circumstances where merely *opening* a file (before >>> reading it) can raise EOFError? >> >> I don't think so. As far as I know, the only built-in thing that raises >> EOFError is input() (and raw_input() in Py2). > > Thanks. That's what I thought. > > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > handle_bad_file(name) > else: > handle_good_file(fp) > Depends on who is going to be maintaining your code next year.Be sure and leave him some comments. Even if it's going to be you. For example, it's not obvious at a glance that name is visible in the second exception block and not the first. -- DaveA From rosuav at gmail.com Mon Jul 7 08:19:20 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 22:19:20 +1000 Subject: open() and EOFError In-Reply-To: <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > handle_bad_file(name) > else: > handle_good_file(fp) Just thought of something. It's possible for input() to raise IOError, if I'm not mistaken; consider redirection, for instance. In that case, you would definitely want to split the try blocks, so you don't try to "handle_bad_file" when no name was entered. (As Dave says, name hasn't been assigned at that point, although I'd be less concerned about a possible cascaded NameError than about a possible handle_bad_file() with the previous name, if this is in a loop.) ChrisA From roy at panix.com Mon Jul 7 08:39:04 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 08:39:04 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: In article <53ba538d$0$2926$c3e8da3$76491128 at news.astraweb.com>, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 17:04:12 +1200, Gregory Ewing wrote: > > > Steven D'Aprano wrote: > >> Are there any circumstances where merely *opening* a file (before > >> reading it) can raise EOFError? > > > > I don't think so. As far as I know, the only built-in thing that raises > > EOFError is input() (and raw_input() in Py2). > > Thanks. That's what I thought. > > How do people feel about code like this? > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > fp = open(name) > except EOFError: > sys.exit() > except IOError: > handle_bad_file(name) > else: > handle_good_file(fp) I really dislike putting more than one statement inside a try block. Breaking this up into two try statements, one catching the EOF, the other catching the IOError, is better. More verbose, to be sure, but the flow of control is a lot more obvious. On a different topic, I've always disliked embedding instructions to "type Ctrl-D". The problem is, how to generate an EOF (or interrupt, or whatever) is configurable in the tty driver (see below). In theory, the user could have remapped EOF to be something else. Maybe they're a die-hard Windows fan, and insist on being able to type Ctrl-Z for EOF. Not to mention that things like readline are probably running the terminal in raw mode and remapping everything all over again. On the other hand, telling the user to "generate EOF", while technically more correct, is not very useful for most people. I suppose you could interrogate the tty driver to find out what the current EOF character is, and stick that in your prompt. I don't even know if that's possible with the standard Python library, and I doubt it would be very portable. I'm not sure what the best solution is here. ------------------------------------------------------ $ stty -e speed 9600 baud; 24 rows; 80 columns; lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo -extproc iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8 -ignbrk brkint -inpck -ignpar -parmrk oflags: opost onlcr -oxtabs -onocr -onlret cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow -dtrflow -mdmbuf discard dsusp eof eol eol2 erase intr kill lnext ^O ^Y ^D ^? ^C ^U ^V min quit reprint start status stop susp time werase 1 ^\ ^R ^Q ^T ^S ^Z 0 ^W ------------------------------------------------------ From roy at panix.com Mon Jul 7 08:46:33 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 08:46:33 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: > > How do people feel about code like this? > > > > try: > > name = input("Enter file name, or Ctrl-D to exit") > > # On Windows, use Ctrl-Z [enter] instead. > > fp = open(name) > > except EOFError: > > sys.exit() > > except IOError: > > handle_bad_file(name) > > else: > > handle_good_file(fp) > > Just thought of something. It's possible for input() to raise IOError, > if I'm not mistaken; consider redirection, for instance. In that case, > you would definitely want to split the try blocks, so you don't try to > "handle_bad_file" when no name was entered. (As Dave says, name hasn't > been assigned at that point, although I'd be less concerned about a > possible cascaded NameError than about a possible handle_bad_file() > with the previous name, if this is in a loop.) > > ChrisA My latest and greatest IOError horror story.... A guy here at work was running a Python job that was taking many days to complete. He was running it on one of our production machines where we continually push out new releases, and clean up old ones after a few days. Well, his job took longer than a few days and the directory containing the virtualenv he was running out of was deleted. This didn't bother anything until several days later, when something deep inside some library function needed to open a (now missing) data file. Which of course, generated an IOError, which was caught in some unexpected place, causing all sorts of confusion trying to figure out WTF happened. We've since modified our cleanup script to run lsof and skip purging any releases which are still in use :-) From rosuav at gmail.com Mon Jul 7 08:55:20 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 22:55:20 +1000 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 10:39 PM, Roy Smith wrote: > $ stty -e > speed 9600 baud; 24 rows; 80 columns; > lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl > -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo > -extproc > iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8 > -ignbrk brkint -inpck -ignpar -parmrk > oflags: opost onlcr -oxtabs -onocr -onlret > cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow > -dtrflow -mdmbuf > discard dsusp eof eol eol2 erase intr kill lnext > ^O ^Y ^D ^? ^C ^U ^V > min quit reprint start status stop susp time werase > 1 ^\ ^R ^Q ^T ^S ^Z 0 ^W Not sure what you're running, but 'stty -e' throws an error for me (Debian Wheezy). I get fairly similar output from 'stty -a', though; and it's marginally more parseable: rosuav at sikorsky:~$ stty -a rosuav at sikorsky:~$ stty -a speed 38400 baud; rows 55; columns 190; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts -ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke (That's off a maximized window. If I restore the window, I get a more classic 24x80.) The same info can be queried in Python via termios.tcgetattr()[6][termios.VEOF] but you then have to parse that to interpret it for a human (it comes out as b'\4', which you have to figure out means ^D). I'm not sure if there's a utility function anywhere for "give me the human readable form of this". ChrisA From rosuav at gmail.com Mon Jul 7 08:58:14 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 22:58:14 +1000 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 10:46 PM, Roy Smith wrote: > We've since modified our cleanup script to run lsof and skip purging any > releases which are still in use :-) LOL! I have a computer on which I periodically build and install new versions of a few pieces of software. Most of them don't keep running indefinitely, but I once checked lsof and found that I had about a dozen different versions of /usr/local/bin/pike, all executing happily from memory. If one of them happened to go looking for some file (eg an importable module), it'd end up picking up the latest version... hopefully that's never a problem (chances are the different versions aren't all *that* different - it'll just be that I pulled upstream's edits and rebuilt). I love how Unix will happily let you unlink a file and keep using it. Sure, it's a pitfall for people who are trying to figure out where on earth their disk space has gone ("I deleted that huge file, but my disk's still full!!"), but it's soooooo much easier to work with than "File in use, cannot delete". ChrisA From breamoreboy at yahoo.co.uk Mon Jul 7 09:06:33 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 07 Jul 2014 14:06:33 +0100 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 07/07/2014 09:09, Chris Angelico wrote: > On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano wrote: >> How do people feel about code like this? >> >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> fp = open(name) >> except EOFError: >> sys.exit() >> except IOError: >> handle_bad_file(name) >> else: >> handle_good_file(fp) > > It seems trivial in this example to break it into two try blocks: > > try: > name = input("Enter file name, or Ctrl-D to exit") > # On Windows, use Ctrl-Z [enter] instead. > except EOFError: > sys.exit() > try: > fp = open(name) > except IOError: > handle_bad_file(name) > else: > handle_good_file(fp) > All those extra lines to type, not on your life. Surely it would be better written as a one liner? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Mon Jul 7 09:27:19 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 23:27:19 +1000 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 11:06 PM, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> >> It seems trivial in this example to break it into two try blocks: >> >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> except EOFError: >> sys.exit() >> try: >> fp = open(name) >> except IOError: >> handle_bad_file(name) >> else: >> handle_good_file(fp) >> > > All those extra lines to type, not on your life. Surely it would be better > written as a one liner? Challenge accepted! I shall wield the power of PEP 463, even though it never got accepted, and pretend that it's a standard feature! name = (input("Enter file name, or Ctrl-D to exit") except EOFError: sys.exit()) (handle_good_file(open(name)) except IOError: handle_bad_file(name)) Readers with a degree in higher mathematics will note that this is not one, but two lines. It can be turned into one line, however the forking out of the name requires some cheating. But since the last part is now an expression, we have the option of lambda shenanigans... (lambda n:(handle_good_file(open(n))except IOError:handle_bad_file(n)))(input("Enter file name, or Ctrl-D to exit")except EOFError:sys.exit()) Et voila! A single line, albeit 142 characters long, and that with superfluous (ha!) internal spaces removed. As a side-effect of expressionization (if that's a word), the code now catches IOError from inside handle_good_file() by going to handle_bad_file, which is almost certainly a bad idea (most likely, handle_good_file is going to read from that file). But it's much more important that this be a one-liner! Alternatively, the nesting could be inverted. As long as handle_bad_file() returns something which is not a file pointer (eg None), and handle_good_file is carefully written to quietly do nothing if given that, the original semantics could be retained: (lambda n:(handle_good_file(open(n)except IOError:handle_bad_file(n))))(input("Enter file name, or Ctrl-D to exit")except EOFError:sys.exit()) Take your pick. And enjoy! :) ChrisA From rosuav at gmail.com Mon Jul 7 09:29:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 7 Jul 2014 23:29:09 +1000 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 11:06 PM, Mark Lawrence wrote: >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> except EOFError: >> sys.exit() >> try: >> fp = open(name) >> except IOError: >> handle_bad_file(name) >> else: >> handle_good_file(fp) >> > > All those extra lines to type, not on your life. Surely it would be better > written as a one liner? In all seriousness, though, if you're worried about the number of lines, it's not that big a deal to squish up the small try blocks. try: name = input("Enter file name, or Ctrl-D to exit") except EOFError: sys.exit() try: fp = open(name) except IOError: handle_bad_file(name) else: handle_good_file(fp) Might violate some style guides, but IMO it's not a problem. ChrisA From rxjwg98 at gmail.com Mon Jul 7 09:30:47 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 06:30:47 -0700 (PDT) Subject: How to write this repeat matching? In-Reply-To: References: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> Message-ID: <3840e655-b202-4a8d-b432-77c2d3cd58a4@googlegroups.com> On Sunday, July 6, 2014 3:26:44 PM UTC-4, Ian wrote: > On Sun, Jul 6, 2014 at 12:57 PM, wrote: > > > I write the following code: > > > > > > ....... > > > import re > > > > > > line = "abcdb" > > > > > > matchObj = re.match( 'a[bcd]*b', line) > > > > > > if matchObj: > > > print "matchObj.group() : ", matchObj.group() > > > print "matchObj.group(0) : ", matchObj.group() > > > print "matchObj.group(1) : ", matchObj.group(1) > > > print "matchObj.group(2) : ", matchObj.group(2) > > > else: > > > print "No match!!" > > > ......... > > > > > > In which I have used its match pattern, but the result is not 'abcb' > > > > You're never going to get a match of 'abcb' on that string, because > > 'abcb' is not found anywhere in that string. > > > > There are two possible matches for the given pattern over that string: > > 'abcdb' and 'ab'. The first one matches the [bcd]* three times, and > > the second one matches it zero times. Because the matching is greedy, > > you get the result that matches three times. It cannot match one, two > > or four times because then there would be no 'b' following the [bcd]* > > portion as required by the pattern. > > > > > > > > Only matchObj.group(0): abcdb > > > > > > displays. All other group(s) have no content. > > > > Calling match.group(0) is equivalent to calling match.group without > > arguments. In that case it returns the matched string of the entire > > regular expression. match.group(1) and match.group(2) will return the > > value of the first and second matching group respectively, but the > > pattern does not have any matching groups. If you want a matching > > group, then enclose the part that you want it to match in parentheses. > > For example, if you change the pattern to: > > > > matchObj = re.match('a([bcd]*)b', line) > > > > then the value of matchObj.group(1) will be 'bcd' Because I am new to Python, I may not describe the question clearly. Could you read the original problem on web: https://docs.python.org/2/howto/regex.html It says that it gets 'abcb'. Could you explain it to me? Thanks again A step-by-step example will make this more obvious. Let's consider the expression a[bcd]*b. This matches the letter 'a', zero or more letters from the class [bcd], and finally ends with a 'b'. Now imagine matching this RE against the string abcbd. Step Matched Explanation 1 a The a in the RE matches. 2 abcbd The engine matches [bcd]*, going as far as it can, which is to the end of the string. 3 Failure The engine tries to match b, but the current position is at the end of the string, so it fails. 4 abcb Back up, so that [bcd]* matches one less character. 5 Failure Try b again, but the current position is at the last character, which is a 'd'. 6 abc Back up again, so that [bcd]* is only matching bc. 6 abcb Try b again. This time the character at the current position is 'b', so it succeeds. From rxjwg98 at gmail.com Mon Jul 7 10:08:53 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 07:08:53 -0700 (PDT) Subject: What is 're.M'? Message-ID: Hi, I learn this short Python code from: http://www.tutorialspoint.com/python/python_reg_expressions.htm but I still do not decipher the meaning in its line, even after read its command explanation. It says that: re.M: Makes $ match the end of a line (not just the end of the string) and makes ^ match the start of any line (not just the start of the string). More specific, what does 're.M' means? I have tried several other modification to the searchObj line, without clue yet. Could you explain re.M and the following two searchObj mechanisms? Thanks, import re line = "Cats are smarter than dogs"; searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) # searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) if searchObj: print "searchObj.group() : ", searchObj.group() print "searchObj.group(1) : ", searchObj.group(1) print "searchObj.group(2) : ", searchObj.group(2) else: print "Nothing found!!" From skip at pobox.com Mon Jul 7 10:15:33 2014 From: skip at pobox.com (Skip Montanaro) Date: Mon, 7 Jul 2014 09:15:33 -0500 Subject: What is 're.M'? In-Reply-To: References: Message-ID: Scroll down to the "Module Contents" section of this page: https://docs.python.org/2/library/re.html It explains re.M and other "constants". Skip From breamoreboy at yahoo.co.uk Mon Jul 7 10:25:29 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 07 Jul 2014 15:25:29 +0100 Subject: What is 're.M'? In-Reply-To: References: Message-ID: On 07/07/2014 15:08, rxjwg98 at gmail.com wrote: > Hi, > > I learn this short Python code from: > > http://www.tutorialspoint.com/python/python_reg_expressions.htm > > but I still do not decipher the meaning in its line, even after read its command > explanation. > > It says that: > re.M: > > Makes $ match the end of a line (not just the end of the string) and makes ^ > match the start of any line (not just the start of the string). > > More specific, what does 're.M' means? > > I have tried several other modification to the searchObj line, without clue yet. > > Could you explain re.M and the following two searchObj mechanisms? > > Thanks, > > import re > > line = "Cats are smarter than dogs"; > > searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) > # searchObj = re.search( r'(.*) (.*?) .*', line, re.M|re.I) > > if searchObj: > print "searchObj.group() : ", searchObj.group() > print "searchObj.group(1) : ", searchObj.group(1) > print "searchObj.group(2) : ", searchObj.group(2) > else: > print "Nothing found!!" > The answer is on the first link that I sent you yesterday afternoon, that's 06/07/2014 15:25 BST. Was the email not delivered or did you not bother to read it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From robert.kern at gmail.com Mon Jul 7 10:25:36 2014 From: robert.kern at gmail.com (Robert Kern) Date: Mon, 07 Jul 2014 15:25:36 +0100 Subject: Module name does not match file name In-Reply-To: <53ba8aef$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53ba52e1$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba60dc$0$2926$c3e8da3$76491128@news.astraweb.com> <53ba8aef$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2014-07-07 12:56, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 12:15:51 +0100, Robert Kern wrote: > >> On 2014-07-07 09:57, Steven D'Aprano wrote: >>> What I don't understand is how "import pg" gets turned into "run >>> pgmodule.so"? >> >> This has been standard Python behavior for extension modules since >> forever. It's a very old practice and not recommended for new code, >> though. > > Hmmm. Well, that is very special. Is this documented anywhere? Not that I can find. Maybe the PEP that removed it for Python 3 might document it implicitly. > I know very little about extension modules. If I just rename the source > file from pgmodule.c to pg.c, recompile to pg.so, and use that in place > of pgmodule.so, is anything likely to break? I don't think so, but why would you bother (assuming you aren't the maintainer of pgmodule.so)? -- 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+comp.lang.python at pearwood.info Mon Jul 7 10:46:19 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 14:46:19 GMT Subject: What is 're.M'? References: Message-ID: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > More specific, what does 're.M' means? Feel free to look at it interactively. re.M is a flag to control the meaning of the regular expression. It is short for re.MULTILINE, just as re.I is short for re.IGNORECASE: py> import re py> re.M == re.MULTILINE True py> re.I == re.IGNORECASE True They are just numeric flags: py> re.I 2 py> re.M 8 so you can combine then: py> re.I | re.M 10 re.M turns on "multi-line matching". This changes the meaning of the special characters ^ and $. Standard mode: ^ matches the start of the string $ matches the end of the string Multi-line mode: ^ matches the start of each line $ matches the end of each line Here is an example. Copy and paste this into the interpreter: import re text = """First line. Second line. Third line.""" pattern = "^.*$" # Match anything from the start to end. By default, . does not match newlines, so by default the regex matches nothing: py> re.search(pattern, text) is None # Nothing matches! True If you use MULTILINE mode, $ matches the end of the first line: py> re.search(pattern, text, re.M).group() 'First line.' If you add MULTILINE mode and DOTALL mode, it matches everything: py> re.search(pattern, text, re.M|re.S).group() 'First line.\nSecond line.\nThird line.' See the reference manual for more details: https://docs.python.org/3/library/re.html#module-contents (Python 3) https://docs.python.org/2/library/re.html#module-contents (Python 2) -- Steven From rxjwg98 at gmail.com Mon Jul 7 10:59:58 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 07:59:58 -0700 (PDT) Subject: What is 're.M'? In-Reply-To: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <0dcfeb67-7be3-48b9-a7d4-85e8202ea211@googlegroups.com> On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. It is short for re.MULTILINE, just as > > re.I is short for re.IGNORECASE: > > > > py> import re > > py> re.M == re.MULTILINE > > True > > py> re.I == re.IGNORECASE > > True > > > > > > They are just numeric flags: > > > > py> re.I > > 2 > > py> re.M > > 8 > > > > so you can combine then: > > > > > > py> re.I | re.M > > 10 > > > > > > re.M turns on "multi-line matching". This changes the meaning of the > > special characters ^ and $. > > > > Standard mode: > > ^ matches the start of the string > > $ matches the end of the string > > > > Multi-line mode: > > ^ matches the start of each line > > $ matches the end of each line > > > > > > Here is an example. Copy and paste this into the interpreter: > > > > > > import re > > text = """First line. > > Second line. > > Third line.""" > > pattern = "^.*$" # Match anything from the start to end. > > > > > > By default, . does not match newlines, so by default the regex matches > > nothing: > > > > > > py> re.search(pattern, text) is None # Nothing matches! > > True > > > > > > If you use MULTILINE mode, $ matches the end of the first line: > > > > > > py> re.search(pattern, text, re.M).group() > > 'First line.' > > > > > > If you add MULTILINE mode and DOTALL mode, it matches everything: > > > > py> re.search(pattern, text, re.M|re.S).group() > > 'First line.\nSecond line.\nThird line.' > > > > > > See the reference manual for more details: > > > > https://docs.python.org/3/library/re.html#module-contents > > (Python 3) > > > > https://docs.python.org/2/library/re.html#module-contents > > (Python 2) > > > > > > > > -- > > Steven Thanks all of you. The email address associates with this group is not my everyday email. Excuse me for not reply yet. I did read for several times the part you point out. I admit, that I have difficulties on reading now. In that explanation, it says about '$' and '^'. But I do not see any '$' and '^' in "r'(.*) are (.*?) .*'" '$' and '^' are pattern characters? It should be inside matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I) How to connect '$' or '^' to: matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I) Thanks for your help and please correct me now. From rxjwg98 at gmail.com Mon Jul 7 11:16:13 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 08:16:13 -0700 (PDT) Subject: What is 're.M'? In-Reply-To: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <5925191d-5219-4740-8039-b11ed3b00ccd@googlegroups.com> On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. It is short for re.MULTILINE, just as > > re.I is short for re.IGNORECASE: > > > > py> import re > > py> re.M == re.MULTILINE > > True > > py> re.I == re.IGNORECASE > > True > > > > > > They are just numeric flags: > > > > py> re.I > > 2 > > py> re.M > > 8 > > > > so you can combine then: > > > > > > py> re.I | re.M > > 10 > > > > > > re.M turns on "multi-line matching". This changes the meaning of the > > special characters ^ and $. > > > > Standard mode: > > ^ matches the start of the string > > $ matches the end of the string > > > > Multi-line mode: > > ^ matches the start of each line > > $ matches the end of each line > > > > > > Here is an example. Copy and paste this into the interpreter: > > > > > > import re > > text = """First line. > > Second line. > > Third line.""" > > pattern = "^.*$" # Match anything from the start to end. > > > > > > By default, . does not match newlines, so by default the regex matches > > nothing: > > > > > > py> re.search(pattern, text) is None # Nothing matches! > > True > > > > > > If you use MULTILINE mode, $ matches the end of the first line: > > > > > > py> re.search(pattern, text, re.M).group() > > 'First line.' > > > > > > If you add MULTILINE mode and DOTALL mode, it matches everything: > > > > py> re.search(pattern, text, re.M|re.S).group() > > 'First line.\nSecond line.\nThird line.' > > > > > > See the reference manual for more details: > > > > https://docs.python.org/3/library/re.html#module-contents > > (Python 3) > > > > https://docs.python.org/2/library/re.html#module-contents > > (Python 2) > > > > > > > > -- > > Steven Thanks, your post makes me much clearer. But for my original example, it has only one line: matchObj = re.match( r'(.*) are (.*?) .*', line, re.M|re.I) re.M does not make any difference, is it right? From rxjwg98 at gmail.com Mon Jul 7 11:20:42 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 08:20:42 -0700 (PDT) Subject: What is 're.M'? In-Reply-To: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Monday, July 7, 2014 10:46:19 AM UTC-4, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 07:08:53 -0700, rxjwg98 wrote: > > > > > More specific, what does 're.M' means? > > > > > > Feel free to look at it interactively. re.M is a flag to control the > > meaning of the regular expression. It is short for re.MULTILINE, just as > > re.I is short for re.IGNORECASE: > > > > py> import re > > py> re.M == re.MULTILINE > > True > > py> re.I == re.IGNORECASE > > True > > > > > > They are just numeric flags: > > > > py> re.I > > 2 > > py> re.M > > 8 > > > > so you can combine then: > > > > > > py> re.I | re.M > > 10 > > > > > > re.M turns on "multi-line matching". This changes the meaning of the > > special characters ^ and $. > > > > Standard mode: > > ^ matches the start of the string > > $ matches the end of the string > > > > Multi-line mode: > > ^ matches the start of each line > > $ matches the end of each line > > > > > > Here is an example. Copy and paste this into the interpreter: > > > > > > import re > > text = """First line. > > Second line. > > Third line.""" > > pattern = "^.*$" # Match anything from the start to end. > > > > > > By default, . does not match newlines, so by default the regex matches > > nothing: > > > > > > py> re.search(pattern, text) is None # Nothing matches! > > True > > > > > > If you use MULTILINE mode, $ matches the end of the first line: > > > > > > py> re.search(pattern, text, re.M).group() > > 'First line.' > > > > > > If you add MULTILINE mode and DOTALL mode, it matches everything: > > > > py> re.search(pattern, text, re.M|re.S).group() > > 'First line.\nSecond line.\nThird line.' > > > > > > See the reference manual for more details: > > > > https://docs.python.org/3/library/re.html#module-contents > > (Python 3) > > > > https://docs.python.org/2/library/re.html#module-contents > > (Python 2) > > > > > > > > -- > > Steven Your patter is: pattern = "^.*$" while my example has pattern: '(.*) are (.*?) .*' which does not have either '^' or '$' Why re.M has effects on my example? Thanks, From renatooliveira.cin at gmail.com Mon Jul 7 10:16:16 2014 From: renatooliveira.cin at gmail.com (Renato Oliveira) Date: Mon, 7 Jul 2014 11:16:16 -0300 Subject: [Python Brasil 10] Registrations are now open! Message-ID: Hey everyone! Registrations for Python Brasil are now open! http://2014.pythonbrasil.org.br/register Sadly the payment form is in portuguese, so if you have any trouble please let me know (in private message). The call for papers will open on Jul 10th as you can see here http://2014.pythonbrasil.org.br/about For now the announced keynotes are: Alex Gaynor http://2014.pythonbrasil.org.br/news/keynotes-alex-gaynor Fernando Perez http://2014.pythonbrasil.org.br/news/keynotes-fernando-perez Lynn Root http://2014.pythonbrasil.org.br/news/keynotes-lynn-root And this beach is waiting for you: http://2014.pythonbrasil.org.br/venue Please, help us by spreading the word :) Thanks Renato Oliveira @_renatooliveira Labcodes - www.labcodes.com.br -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Mon Jul 7 11:45:27 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 15:45:27 GMT Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > It's possible for input() to raise IOError, if I'm not mistaken; > consider redirection, for instance. What indirection? Do you mean, if built-in input() has been monkey- patched? Well, sure, but in that case it could do anything. I'm only concerned with the builtins. Otherwise, I have no idea what you mean by that. https://docs.python.org/3/library/functions.html#input -- Steven From as at sci.fi Mon Jul 7 11:48:58 2014 From: as at sci.fi (Anssi Saari) Date: Mon, 07 Jul 2014 18:48:58 +0300 Subject: How to write this repeat matching? References: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> <3840e655-b202-4a8d-b432-77c2d3cd58a4@googlegroups.com> Message-ID: rxjwg98 at gmail.com writes: > Because I am new to Python, I may not describe the question clearly. Could you > read the original problem on web: > > https://docs.python.org/2/howto/regex.html > > It says that it gets 'abcb'. Could you explain it to me? Thanks again Actually, it tries to explain how * works in the regular expression engine. Do you feel that's a crucial thing for a beginner to understand about Python? Hopefully your answer is no and you can move on. From rosuav at gmail.com Mon Jul 7 11:53:19 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 01:53:19 +1000 Subject: open() and EOFError In-Reply-To: <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jul 8, 2014 at 1:45 AM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > >> It's possible for input() to raise IOError, if I'm not mistaken; >> consider redirection, for instance. > > What indirection? Do you mean, if built-in input() has been monkey- > patched? Well, sure, but in that case it could do anything. I'm only > concerned with the builtins. Otherwise, I have no idea what you mean by > that. > > https://docs.python.org/3/library/functions.html#input I said redirection, not indirection, and I was thinking of OS-level changes. If input() is actually reading from some file/device, then any error that that could raise could come up from reading from stdin. Imagine if your script is running with input redirected from a file on a dodgy remote mount, and the far end goes down - at some point, you'll attempt to read and fail. I'm not sure that you'll see EOF then; by rights, you ought to see some other error. ChrisA From drsalists at gmail.com Mon Jul 7 12:07:43 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Mon, 7 Jul 2014 09:07:43 -0700 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 7/7/14, Mark Lawrence wrote: > On 07/07/2014 09:09, Chris Angelico wrote: >> On Mon, Jul 7, 2014 at 6:00 PM, Steven D'Aprano >> wrote: >>> How do people feel about code like this? >>> >>> try: >>> name = input("Enter file name, or Ctrl-D to exit") >>> # On Windows, use Ctrl-Z [enter] instead. >>> fp = open(name) >>> except EOFError: >>> sys.exit() >>> except IOError: >>> handle_bad_file(name) >>> else: >>> handle_good_file(fp) >> >> It seems trivial in this example to break it into two try blocks: >> >> try: >> name = input("Enter file name, or Ctrl-D to exit") >> # On Windows, use Ctrl-Z [enter] instead. >> except EOFError: >> sys.exit() >> try: >> fp = open(name) >> except IOError: >> handle_bad_file(name) >> else: >> handle_good_file(fp) >> > > All those extra lines to type, not on your life. Surely it would be > better written as a one liner? Don't be afraid of a few extra keystrokes. Clarity is king. From marko at pacujo.net Mon Jul 7 12:08:46 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 19:08:46 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87a98lb181.fsf@elektro.pacujo.net> Steven D'Aprano : > On Mon, 07 Jul 2014 22:19:20 +1000, Chris Angelico wrote: > >> It's possible for input() to raise IOError, if I'm not mistaken; >> consider redirection, for instance. > > What indirection? Do you mean, if built-in input() has been monkey- > patched? Well, sure, but in that case it could do anything. I'm only > concerned with the builtins. Otherwise, I have no idea what you mean > by that. input() quite naturally can raise an IOError. For example: import os, socket s = socket.socket(socket.AF_UNIX) s.bind("xyz") os.dup2(s.fileno(), 0); print(input()) results in an IOError (EINVAL, to be exact). strace reveals that input() simply delegates to: read(0, 0xb73aa000, 4096) = -1 EINVAL (Invalid argument) Marko From marko at pacujo.net Mon Jul 7 12:12:04 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 19:12:04 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bac097$0$29995$c3e8da3$5496439d@news.astraweb.com> <87a98lb181.fsf@elektro.pacujo.net> Message-ID: <8761j9b12j.fsf@elektro.pacujo.net> Marko Rauhamaa : > input() quite naturally can raise an IOError. For example: > > import os, socket > s = socket.socket(socket.AF_UNIX) > s.bind("xyz") > os.dup2(s.fileno(), 0); print(input()) > > results in an IOError (EINVAL, to be exact). Even simpler: >>> import os >>> os.close(0); input() Traceback (most recent call last): File "", line 1, in IOError: [Errno 9] Bad file descriptor Marko From ian.g.kelly at gmail.com Mon Jul 7 12:18:34 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 7 Jul 2014 10:18:34 -0600 Subject: How to write this repeat matching? In-Reply-To: <3840e655-b202-4a8d-b432-77c2d3cd58a4@googlegroups.com> References: <93a40570-00ed-4507-aa16-221d7e500468@googlegroups.com> <3840e655-b202-4a8d-b432-77c2d3cd58a4@googlegroups.com> Message-ID: On Mon, Jul 7, 2014 at 7:30 AM, wrote: > Because I am new to Python, I may not describe the question clearly. Could you > read the original problem on web: > > https://docs.python.org/2/howto/regex.html > > It says that it gets 'abcb'. Could you explain it to me? Thanks again The string being matched in the explanation at that link is 'abcbd', not 'abcdb'. The 'a' in the pattern matches the 'a' in the string, the '[bcd]*' in the pattern matches the 'bc' in the string (with a repeat count of 2), and finally the 'b' in the pattern matches the 'b' following that in the string. From ian.g.kelly at gmail.com Mon Jul 7 12:30:54 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 7 Jul 2014 10:30:54 -0600 Subject: thread.interrupt_main() behaviour In-Reply-To: References: Message-ID: On Mon, Jul 7, 2014 at 8:41 AM, Piyush Verma <114piyush at gmail.com> wrote: > Thanks Ian for information. There is slightly more I want to do. Consider if > I want to kill some threads not all, is there a way to do that? You can't safely interrupt threads. What you can do is *request* the thread to terminate by setting a flag on it (perhaps using a threading.Event object, but an ordinary bool attribute can also be used), and then having the thread periodically check the state of the flag and exit gracefully when requested. For more detail, see: http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python From breamoreboy at yahoo.co.uk Mon Jul 7 12:39:54 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 07 Jul 2014 17:39:54 +0100 Subject: What is 're.M'? In-Reply-To: References: <53bab2bb$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 07/07/2014 16:20, rxjwg98 at gmail.com wrote: For the second time, would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ian.g.kelly at gmail.com Mon Jul 7 13:05:44 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 7 Jul 2014 11:05:44 -0600 Subject: Question about metacharacter '*' In-Reply-To: <53B9D273.1060706@mrabarnett.plus.com> References: <1404668474.56075.BPMail_high_noncarrier@web163802.mail.gq1.yahoo.com> <53B9D273.1060706@mrabarnett.plus.com> Message-ID: On Sun, Jul 6, 2014 at 4:49 PM, MRAB wrote: > \d also matches more than just [0-9] in Unicode. I think that anything matched by \d will also be accepted by int(). >>> decimals = [c for c in (chr(i) for i in range(17 * 2**16)) if unicodedata.category(c) == 'Nd'] >>> len(decimals) 460 >>> re.match(r'\d*', ''.join(decimals)).span() (0, 460) >>> int(''.join(decimals)) 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 >>> nondecimals = [c for c in (chr(i) for i in range(17 * 2**16)) if unicodedata.category(c) in 'NoNl'] >>> len(nondecimals) 688 >>> re.findall(r'\d', ''.join(nondecimals)) [] From ian.g.kelly at gmail.com Mon Jul 7 13:25:36 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 7 Jul 2014 11:25:36 -0600 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico wrote: > But if the code's more complicated and it's not so easy to split, then > sure, doesn't seem a problem. It's like spam[foo//bar] and then > catching either IndexError or ZeroDivisionError - there's no big > confusion from having two distinct sources of two distinct errors > handled by two distinct except blocks. It's good practice to keep your try blocks as narrow as possible in any case. One wouldn't normally expect them, but a custom __getitem__ *could* cause a ZeroDivisionError, and a custom __floordiv__ *could* cause an IndexError. From rosuav at gmail.com Mon Jul 7 13:29:24 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 03:29:24 +1000 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Tue, Jul 8, 2014 at 3:25 AM, Ian Kelly wrote: > On Mon, Jul 7, 2014 at 2:09 AM, Chris Angelico wrote: >> But if the code's more complicated and it's not so easy to split, then >> sure, doesn't seem a problem. It's like spam[foo//bar] and then >> catching either IndexError or ZeroDivisionError - there's no big >> confusion from having two distinct sources of two distinct errors >> handled by two distinct except blocks. > > It's good practice to keep your try blocks as narrow as possible in > any case. One wouldn't normally expect them, but a custom __getitem__ > *could* cause a ZeroDivisionError, and a custom __floordiv__ *could* > cause an IndexError. Yeah, in theory. But it's not normal, and if you always break everything out to keep exception-catching scope as narrow as possible, you begin to lose readability in other ways. So I wouldn't object to seeing those two combined. ChrisA From marko at pacujo.net Mon Jul 7 13:31:53 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 20:31:53 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <87wqbp9it2.fsf@elektro.pacujo.net> Ian Kelly : > It's good practice to keep your try blocks as narrow as possible in > any case. True. Unfortunately, that leads to trouble with the handy "with" construct: with open(path) as f: ... If the open() call is guarded against exceptions (as it usually should), one must revert to the classic syntax: try: f = open(path) except IOError: ... try: ... finally: f.close() Marko From marko at pacujo.net Mon Jul 7 13:40:00 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 20:40:00 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <87simd9ifj.fsf@elektro.pacujo.net> Chris Angelico : > if you always break everything out to keep exception-catching scope as > narrow as possible, you begin to lose readability in other ways. I've begun to wonder if there might exist a new, easier-to-read try-except syntax. Marko From steve+comp.lang.python at pearwood.info Mon Jul 7 14:07:24 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 07 Jul 2014 18:07:24 GMT Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> Message-ID: <53bae1db$0$29995$c3e8da3$5496439d@news.astraweb.com> On Mon, 07 Jul 2014 20:31:53 +0300, Marko Rauhamaa wrote: > If the open() call is guarded against exceptions (as it usually should), > one must revert to the classic syntax: > > try: > f = open(path) > except IOError: > ... > try: > ... > finally: > f.close() try: f = open(path) except Whatever: handle_error() else: with f: do_stuff() While I agree with the general idea that try blocks should be as narrow *as reasonable*, they shouldn't be as narrow *as possible* since one can start guarding against unreasonable things. try: open except NameError: ... else: try: f = open(filename) except ZeroDivisionError: # Just in case open has been monkey-patched. ... except NameError: # Oops! Forgot to bind a value to filename! # Or maybe another thread deleted open??? Woe, woe!!! ... The thing is, even if you catch these bizarre things, what are you going to do with them? If you can't do anything about it, there's no point catching the exception -- never catch anything you can't recover from, or otherwise handle. Just treat it as a fatal error and let it cause a traceback. As a general rule of thumb, if you have two things which (under reasonable circumstances) might fail in *different* ways, then it's okay to put them in the same try block, and then catch the two exceptions separately: try: do_this(with_that()) except ThatError: ... except ThisError: ... If you handle the exceptions the same way, then you can still put them in the same try block: try: do_this(with_that()) except (ThatError, ThisError): ... The worst case is when they might fail with the same exception, but you need to handle the failures differently: try: a = with_that() except ThatError: ... else: try: do_this(a) except ThatError: ... That gets old really quickly! But then, handling errors is always the ugliest part of coding. Hiding the messy details inside a function is often a good idea. -- Steven From marko at pacujo.net Mon Jul 7 14:42:25 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 07 Jul 2014 21:42:25 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> <53bae1db$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87oax19fji.fsf@elektro.pacujo.net> Steven D'Aprano : > try: > f = open(path) > except Whatever: > handle_error() > else: > with f: > do_stuff() That's cool. Never really used try-else. > That gets old really quickly! But then, handling errors is always the > ugliest part of coding. Hiding the messy details inside a function is > often a good idea. There's no way around it; life is messy. Marko From tjreedy at udel.edu Mon Jul 7 14:49:56 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 07 Jul 2014 14:49:56 -0400 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 7/7/2014 8:39 AM, Roy Smith wrote: > On a different topic, I've always disliked embedding instructions to > "type Ctrl-D". The problem is, how to generate an EOF (or interrupt, or > whatever) is configurable in the tty driver (see below). In theory, the > user could have remapped EOF to be something else. Maybe they're a > die-hard Windows fan, and insist on being able to type Ctrl-Z for EOF. > Not to mention that things like readline are probably running the > terminal in raw mode and remapping everything all over again. > > On the other hand, telling the user to "generate EOF", while technically > more correct, is not very useful for most people. I suppose you could > interrogate the tty driver to find out what the current EOF character > is, and stick that in your prompt. I don't even know if that's possible > with the standard Python library, and I doubt it would be very portable. > I'm not sure what the best solution is here. Avoid EOFError. Much better, I think, is the somewhat customary s = input("Enter something, or hit to exit") if not s: sys.exit() else: -- Terry Jan Reedy From rxjwg98 at gmail.com Mon Jul 7 14:51:02 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Mon, 7 Jul 2014 11:51:02 -0700 (PDT) Subject: Question about metacharacter '*' In-Reply-To: References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> Message-ID: <86b50887-96b0-4a21-8b0a-26c5a435c76d@googlegroups.com> On Sunday, July 6, 2014 8:09:57 AM UTC-4, Devin Jeanpierre wrote: > On Sun, Jul 6, 2014 at 4:51 AM, wrote: > > > Hi, > > > > > > I just begin to learn Python. I do not see the usefulness of '*' in its > > > description below: > > > > > > > > > > > > > > > The first metacharacter for repeating things that we'll look at is *. * doesn't > > > match the literal character *; instead, it specifies that the previous character > > > can be matched zero or more times, instead of exactly once. > > > > > > For example, ca*t will match ct (0 a characters), cat (1 a), caaat (3 a > > > characters), and so forth. > > > > > > > > > > > > It has to be used with other search constraints? > > > > (BTW, this is a regexp question, not really a Python question per se.) > > > > That's usually when it's useful, yeah. For example, [0-9] matches any > > of the characters 0 through 9. So to match a natural number written in > > decimal form, we might use the regexp [0-9][0-9]*, which matches the > > strings "1", "12", and "007", but not "" or "Jeffrey". > > > > Another useful one is `.*` -- `.` matches exactly one character, no > > matter what that character is. So, `.*` matches any string at all. > > > > The power of regexps stems from the ability to mix and match all of > > the regexp pieces in pretty much any way you want. > > > > -- Devin Would you give me an example using your pattern: `.*` -- `.`? I try it, but it cannot pass. (of course, I use it incorrectly) From jeanpierreda at gmail.com Mon Jul 7 16:27:59 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Mon, 7 Jul 2014 13:27:59 -0700 Subject: Question about metacharacter '*' In-Reply-To: <86b50887-96b0-4a21-8b0a-26c5a435c76d@googlegroups.com> References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <86b50887-96b0-4a21-8b0a-26c5a435c76d@googlegroups.com> Message-ID: On Mon, Jul 7, 2014 at 11:51 AM, wrote: > Would you give me an example using your pattern: `.*` -- `.`? > I try it, but it cannot pass. (of course, I use it incorrectly) Those are two patterns. Python 3.4.1 (default, Jul 7 2014, 13:22:02) [GCC 4.6.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> re.fullmatch(r'.', 'a') <_sre.SRE_Match object; span=(0, 1), match='a'> >>> re.fullmatch(r'.', 'ab') >>> re.fullmatch(r'.', '') >>> >>> re.fullmatch(r'.*', 'a') <_sre.SRE_Match object; span=(0, 1), match='a'> >>> re.fullmatch(r'.*', 'ab') <_sre.SRE_Match object; span=(0, 2), match='ab'> >>> re.fullmatch(r'.*', '') <_sre.SRE_Match object; span=(0, 0), match=''> -- Devin From breamoreboy at yahoo.co.uk Mon Jul 7 17:50:19 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 07 Jul 2014 22:50:19 +0100 Subject: Question about metacharacter '*' In-Reply-To: <86b50887-96b0-4a21-8b0a-26c5a435c76d@googlegroups.com> References: <3f7ecf04-b881-4e79-aa59-893580090468@googlegroups.com> <86b50887-96b0-4a21-8b0a-26c5a435c76d@googlegroups.com> Message-ID: On 07/07/2014 19:51, rxjwg98 at gmail.com wrote: Will you please do something about the double spaced google crap that you keep sending, I've already asked you twice. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From greg.ewing at canterbury.ac.nz Mon Jul 7 17:50:07 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 08 Jul 2014 09:50:07 +1200 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: Roy Smith wrote: > We've since modified our cleanup script to run lsof and skip purging any > releases which are still in use :-) Or, if you're on Unix, make sure you open all the files you're likely to need at the beginning and hold onto them. :-) -- Greg From greg.ewing at canterbury.ac.nz Mon Jul 7 18:04:19 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 08 Jul 2014 10:04:19 +1200 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: Terry Reedy wrote: > Avoid EOFError. Much better, I think, is the somewhat customary > > s = input("Enter something, or hit to exit") > if not s: sys.exit() > else: I beg to differ -- on Unix, Ctrl-D *is* the customary way to exit from something that's reading from stdin. In any case, you need to be able to handle EOF gracefully if the user uses it. -- Greg From greg.ewing at canterbury.ac.nz Mon Jul 7 18:09:07 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Tue, 08 Jul 2014 10:09:07 +1200 Subject: open() and EOFError In-Reply-To: <87wqbp9it2.fsf@elektro.pacujo.net> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> Message-ID: Marko Rauhamaa wrote: > with open(path) as f: > ... > > If the open() call is guarded against exceptions (as it usually should), > one must revert to the classic syntax: Hmmm, maybe we could do with a with-except statement: with open(path) as f: ... except IOError: # Catches exceptions in the with-expression only ... Although that would be a bit confusing. -- Greg From breamoreboy at yahoo.co.uk Mon Jul 7 19:10:45 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 08 Jul 2014 00:10:45 +0100 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> Message-ID: On 07/07/2014 23:09, Gregory Ewing wrote: > Marko Rauhamaa wrote: >> with open(path) as f: >> ... >> >> If the open() call is guarded against exceptions (as it usually should), >> one must revert to the classic syntax: > > Hmmm, maybe we could do with a with-except statement: > > with open(path) as f: > ... > except IOError: > # Catches exceptions in the with-expression only > ... > > Although that would be a bit confusing. > I wrap the with inside a try/except, the other file handling parts within another try/except and use the finer grained exceptions from PEP 3151 to write (at least to my eye) cleaner looking code. Somehow I think we'll get agreement on the best way to do this when the cows come home. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From roy at panix.com Mon Jul 7 20:22:26 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 20:22:26 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> <53bae1db$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <53bae1db$0$29995$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > While I agree with the general idea that try blocks should be as narrow > *as reasonable*, they shouldn't be as narrow *as possible* since one can > start guarding against unreasonable things. I'm more willing to accept multi-statement try blocks with multiple except clauses when the things you're catching are very specific: try: foo.quack() bar.roar() except Foo.QuackError: print "OMG, can't quack" except Bar.RoarError: print "Yowza" If you're catching generic things like IOError or ValueError, it's more likely for there to be some code path you didn't expect. > The thing is, even if you catch these bizarre things, what are you going > to do with them? If you can't do anything about it, there's no point > catching the exception -- never catch anything you can't recover from, or > otherwise handle. Just treat it as a fatal error and let it cause a > traceback. That I agree with. Of course, sometimes you do want to catch *everything*. For example, in something like a web server, you want to have something like try: do_request() except Exception: handle_exception() except: # WTF? This should never happen, but deal with it anyway handle_exception() way up at the top. Our handle_exception() logs a stack trace and returns a 500-something HTTP response. The alternative is to have the web server exit, which would be a Bad Thing. Well, actually, if that happened, the gunicorn master process would catch that a worker exited and restart it, but that would be slow. And if gunicorn exited, then upstart would catch that, and restart gunicorn :-) From roy at panix.com Mon Jul 7 20:26:01 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 20:26:01 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > I love how Unix will happily let you unlink a file and keep using it. > Sure, it's a pitfall for people who are trying to figure out where on > earth their disk space has gone ("I deleted that huge file, but my > disk's still full!!"), but it's soooooo much easier to work with than > "File in use, cannot delete". It's a common way to deal with temp file cleanup. From roy at panix.com Mon Jul 7 20:28:38 2014 From: roy at panix.com (Roy Smith) Date: Mon, 07 Jul 2014 20:28:38 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Mon, Jul 7, 2014 at 10:39 PM, Roy Smith wrote: > > $ stty -e [...] > Not sure what you're running, but 'stty -e' throws an error for me > (Debian Wheezy). That was on OSX. From rosuav at gmail.com Mon Jul 7 20:55:13 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 10:55:13 +1000 Subject: open() and EOFError In-Reply-To: <87simd9ifj.fsf@elektro.pacujo.net> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87simd9ifj.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 8, 2014 at 3:40 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> if you always break everything out to keep exception-catching scope as >> narrow as possible, you begin to lose readability in other ways. > > I've begun to wonder if there might exist a new, easier-to-read > try-except syntax. http://www.python.org/dev/peps/pep-0463/ anyone? :) ChrisA From ben at benfinney.id.au Mon Jul 7 21:22:25 2014 From: ben at benfinney.id.au (Ben Finney) Date: Tue, 08 Jul 2014 11:22:25 +1000 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: <85simcve3y.fsf@benfinney.id.au> Dan Sommers writes: > On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > > > [?] a poor design decision (a line beginning with U+0020 SPACE is > > semantically different from a line beginning with U+0009 CHARACTER > > TABULATION) can be irrevocable ? the syntax can't be changed now, > > without breaking compatibility for countless makefiles out there > > already ? and cause endless confusion and wasted effort dealing with > > it. > > When makefile syntax came into being, there were ASCII TAB characters, > with a value of 9, and ASCII SPC characters, with a value of 32 (and > there may not even have been those). A group of (a particular amount of) U+0020 characters is visually indistinguishable from a U+0009 character, when the default semantics are applied to each. > The former is a "control" character, which has specific semantics > associated with it; the latter is a "printable" character, which is > usually printed and interpreted as itself (although in this particular > case, the printed representation is hard to see on most output > devices). And those specific semantics make the display of those characters easily confused. That is why it's generally a bad idea to use U+0009 in text edited by humans. > This mailing list doesn't seem to mind that lines beginning with ASCII > SPC characters are semantically different from lines beginning with > ASCII LF characters, although many detractors of Python seem unduly > fixated on it. The salient difference being that U+000A LINE FEED is easily visually distinguished from a short sequence of U+0020 SPACE characters. This avoids the confusion, and makes use of both together unproblematic. -- \ ?Come on Milhouse, there?s no such thing as a soul! It?s just | `\ something they made up to scare kids, like the Boogie Man or | _o__) Michael Jackson.? ?Bart, _The Simpsons_ | Ben Finney From jsf80238 at gmail.com Mon Jul 7 23:38:27 2014 From: jsf80238 at gmail.com (Jason Friedman) Date: Mon, 7 Jul 2014 21:38:27 -0600 Subject: finditer In-Reply-To: References: Message-ID: On Mon, Jul 7, 2014 at 1:19 AM, gintare wrote: > If smbd has time, maybe you could advice how to accomplish this task in faster way. > > I have a text = """ word{vb} > wordtransl {vb} > > sent1. > > sent1trans. > > sent2 > > sent2trans... """ > > I need to match once wordtransl, and than many times repeating patterns consisting of sent and senttrans. You might try itertools.groupby (https://docs.python.org/3/library/itertools.html#module-itertools). text = """ word{vb} wordtransl {vb} sent1 sent1trans sent2 sent2trans """ import itertools import re result_list = list() lines = text.split("\n") for line in lines[:]: if line.startswith("sent"): break lines.pop(0) def is_start(x): pattern = re.compile(r"sent\d+$") if re.search(pattern, x): return True for key, mygroup in itertools.groupby(lines, is_start): result_list.append(list(mygroup)) print(result_list) From alexjeffburke at gmail.com Mon Jul 7 19:49:58 2014 From: alexjeffburke at gmail.com (Alex Burke) Date: Tue, 8 Jul 2014 01:49:58 +0200 Subject: error handling when opening files Message-ID: Hi there, While reading up on a previous thread 'open() and EOFError' I saw the following (with minor changes to help make my question clearer) block suggested as a canonical way to open files and do something: try: f = open(path) except IOError: handle_error() else: with f: do_stuff() This somewhat surprised me because I'd always written such a block something more as follows: try: with open(path) as f: do_stuff() except IOError: handle_error('file never opened') except ApplicationError: handle_error('doing something with the content went wrong') Aside from the pythonic but less widely known else clause of the try/except in the first form, what else is different? What nuances am I missing? The reason I preferred the second was in addition to catching the IOError when attempting the open() if the file does not exist I thought I was accounting for the possibility en error occurs while reading data out of the file. That and to handle if do_stuff() was actually calling readline() or such on the file which I thought was possible source of issues. I am wondering if this is also related to some misunderstanding around the file context manager - on exit of the with() block a close is arranged, but if that close() is called in an error situation I was under the impression that the error would be raised again outside it. Otherwise the only way I can see of getting errors is have a variable set to None and if the with block succeeds set it to some other value thus being able to do an if not None check afterward. That's probably enough conflated questioning for now.. who'd have thought opening a file could be such a poser! Yep, it's always the error handling :) Thanks in advance, Alex J Burke. From rosuav at gmail.com Tue Jul 8 01:25:26 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 15:25:26 +1000 Subject: error handling when opening files In-Reply-To: References: Message-ID: On Tue, Jul 8, 2014 at 9:49 AM, Alex Burke wrote: > The reason I preferred the second was in addition to catching the > IOError when attempting the open() if the file does not exist I > thought I was accounting for the possibility en error occurs while > reading data out of the file. If that's what you're expecting, then your message is wrong, because you say "file never opened" - but you possibly DID open it, and maybe read something from it. The choice between the two forms should be based on whether you want to distinguish between errors on opening and errors on reading, or conflate them as "file unreadable". There are times and places for each style. ChrisA From wxjmfauth at gmail.com Tue Jul 8 03:03:58 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Tue, 8 Jul 2014 00:03:58 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> Message-ID: <27b1269a-a1aa-4510-b50f-8a4646e88c99@googlegroups.com> Le mardi 8 juillet 2014 03:22:25 UTC+2, Ben Finney a ?crit?: > > > A group of (a particular amount of) U+0020 characters is visually > > indistinguishable from a U+0009 character, when the default semantics > > are applied to each. > > Tabs and tabulations are the only way to align text properly. There is no other way. Can be "Python", txt, word, ..., everything. For the promoters of "just configure your editor": make these invsible chars visible. From marko at pacujo.net Tue Jul 8 04:30:50 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 11:30:50 +0300 Subject: error handling when opening files References: Message-ID: <87fvicgslh.fsf@elektro.pacujo.net> Alex Burke : > While reading up on a previous thread 'open() and EOFError' I saw the > following (with minor changes to help make my question clearer) block > suggested as a canonical way to open files and do something: > > try: > f = open(path) > except IOError: > handle_error() > else: > with f: > do_stuff() > > This somewhat surprised me because I'd always written such a block > something more as follows: > > try: > with open(path) as f: > do_stuff() > except IOError: > handle_error('file never opened') > except ApplicationError: > handle_error('doing something with the content went wrong') > > Aside from the pythonic but less widely known else clause of the > try/except in the first form, what else is different? What nuances am > I missing? Your version catches IOError for do_stuff() as well as open(). You usually want to guard each statement with try-except so you can log and pinpoint the error better. Marko From breamoreboy at yahoo.co.uk Tue Jul 8 04:48:08 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 08 Jul 2014 09:48:08 +0100 Subject: PyPy-STM: first "interesting" release Message-ID: A GIL-less Python? See http://morepypy.blogspot.co.uk/2014/07/pypy-stm-first-interesting-release.html -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From steve at pearwood.info Tue Jul 8 04:48:08 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 08:48:08 GMT Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> Message-ID: <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> On Tue, 08 Jul 2014 11:22:25 +1000, Ben Finney wrote: > A group of (a particular amount of) U+0020 characters is visually > indistinguishable from a U+0009 character, when the default semantics > are applied to each. Hmmm. I'm not sure there actually *is* such a thing as "default semantics" for tabs. If you look at a tab character in a font, it probably looks like a single space, but that depends on the font designer. But if you look at it in a text editor, it will probably look like eight spaces, unless it looks like four, or some other number, and if you look at it in a word processor, it will probably look like a "jump to the next tab stop" command. In a spreadsheet application, it will be a cell separator and consequently doesn't look like anything at all. I don't think any of those things count as "default semantics". The point being, tabs are *control characters*, like newlines and carriage returns and form feeds, not regular characters like spaces and "A" or "?". Since "indent" is an *instruction* rather than a character, it is best handled with a control character. In any case, if we limit ourselves to text editors, only a specific number of spaces will be visually indistinguishable from a tab, where the number depends on which column you start with: x x # Tab x x # Seven spaces x x # Six spaces x x # Eight spaces Even in a proportional font, the last two should be distinguishable from the first two. Admittedly, that does leave the case where N spaces (for some 1 <= N <= 8) looks like a tab. That's a probably, but it's not the only one: * End of line is a problem. I know of *at least* the following seven conventions for end-of-line: - ASCII line feed, \n (Unix etc.) - ASCII carriage return, \r (Acorn, ZX Spectrum, Apple, etc.) - ASCII \r\n (CP/M, DOS, Windows, Symbian, Palm, etc.) - ASCII \n\r (RISC OS) - ASCII Record Separator, \x1E (QNX) - EBCDIC New Line, \N{NEXT LINE} in Unicode (IBM mainframes) - ATASCII \x9B (Atari) * Form feeds are a problem, since they are invisible, but still get used (by Vim or Emacs, I forget which) to mark sections of text. * Issues to do with word-wrapping and hyphenation, or lack thereof, are a problem. * Encoding issues are a problem. * There are other invisible characters than spaces (non-breaking space, em-space, en-space, thin space). The solution is to use a smarter editor. For example, an editor might draw a horizontal rule to show a form feed on a line of its own, or highlight unexpected carriage return characters with ^M, or display tabs in a different colour from spaces, or overlay it with a \x09 glyph. Or an editor might be smart enough to automatically do what the current paragraph or block does: if the block is already indented with tabs, pressing tab inserts a tab, but if it is indented with spaces, pressing tab inserts spaces. Isn't this why you recommend people use a programmer's editor rather than Notepad? A good editor should handle these things for you automatically, or at least with a minimum amount of manual effort. >> The former is a "control" character, which has specific semantics >> associated with it; the latter is a "printable" character, which is >> usually printed and interpreted as itself (although in this particular >> case, the printed representation is hard to see on most output >> devices). > > And those specific semantics make the display of those characters easily > confused. That is why it's generally a bad idea to use U+0009 in text > edited by humans. I disagree. Using tabs is no more a bad idea than using a formfeed, or having support for multiple encodings. >> This mailing list doesn't seem to mind that lines beginning with ASCII >> SPC characters are semantically different from lines beginning with >> ASCII LF characters, although many detractors of Python seem unduly >> fixated on it. > > The salient difference being that U+000A LINE FEED is easily visually > distinguished from a short sequence of U+0020 SPACE characters. This > avoids the confusion, and makes use of both together unproblematic. True, but that's *only* because your editor chooses to follow the convention "display a LINE FEED by starting a new line" rather than by the convention "display the (invisible or zero-width) glyph of the LINE FEED". If editors were to standardise on the convention "display a HORIZONTAL TAB character as visibly distinct from a sequence of spaces" (e.g. by shading the background a different colour, or overlying it with an arrow) then we would not be having this discussion. In other words, it is the choice of editors to be *insufficiently smart* about tabs that causes the problem. There is a vicious circle here: * editors don't handle tabs correctly * which leads to (some) people believing that "tabs are bad" and should be avoided * which leads to editors failing to handle tabs correctly, because "tabs are bad" and should be avoided. A pity really. -- Steven From steve at pearwood.info Tue Jul 8 05:00:46 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 09:00:46 GMT Subject: error handling when opening files References: Message-ID: <53bbb33b$0$2926$c3e8da3$76491128@news.astraweb.com> On Tue, 08 Jul 2014 01:49:58 +0200, Alex Burke wrote: > Hi there, > > While reading up on a previous thread 'open() and EOFError' I saw the > following (with minor changes to help make my question clearer) block > suggested as a canonical way to open files and do something: Emphasis on "a" canonical way, out of many canonical ways ;-) > try: > f = open(path) > except IOError: > handle_error() > else: > with f: > do_stuff() I wrote it that way to show that there is no need to fall back on the old- fashioned "try...except...finally" idiom that was used before the with statement and context managers. In practice, I would usually do what you do: > This somewhat surprised me because I'd always written such a block > something more as follows: > > try: > with open(path) as f: > do_stuff() > except IOError: > handle_error('file never opened') > except ApplicationError: > handle_error('doing something with the content went wrong') assuming that open() and do_stuff() don't raise the same exceptions. If they do raise the same exceptions, and it is important to distinguish IOError raised by open() from IOError raised by do_stuff, then you cannot use this idiom. > Aside from the pythonic but less widely known else clause of the > try/except in the first form, what else is different? What nuances am I > missing? > > The reason I preferred the second was in addition to catching the > IOError when attempting the open() if the file does not exist I thought > I was accounting for the possibility en error occurs while reading data > out of the file. That and to handle if do_stuff() was actually calling > readline() or such on the file which I thought was possible source of > issues. Correct. But now imagine you're happily reading through the file, processing line after line, and halfway through the file read() fails because it's on a network share and somebody just tripped over the cable. Your script now *lies to you* and says the file was never opened. If you care about accurate error messages, you should be more careful about conflating two different errors (that is, catching too much in a single try...except block). > I am wondering if this is also related to some misunderstanding around > the file context manager - on exit of the with() block a close is > arranged, but if that close() is called in an error situation I was > under the impression that the error would be raised again outside it. In general, context managers may choose whether or not to re-raise exceptions. Some exceptions are not errors and may be swallowed silently. However, file objects will re-raise the error. Interestingly, did you know that even *closing* a file can fail? -- Steven From steve at pearwood.info Tue Jul 8 05:03:02 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 09:03:02 GMT Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53bbb3c6$0$2926$c3e8da3$76491128@news.astraweb.com> On Mon, 07 Jul 2014 14:49:56 -0400, Terry Reedy wrote: > Avoid EOFError. Much better, I think, is the somewhat customary > > s = input("Enter something, or hit to exit") if not s: > sys.exit() > else: Under many circumstances, I would do exactly that. But sometimes an empty string is valid data, not a signal for special processing (whether exiting the application, or something else). -- Steven From steve at pearwood.info Tue Jul 8 05:04:27 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 09:04:27 GMT Subject: PyPy-STM: first "interesting" release References: Message-ID: <53bbb41b$0$2926$c3e8da3$76491128@news.astraweb.com> On Tue, 08 Jul 2014 09:48:08 +0100, Mark Lawrence wrote: > A GIL-less Python? See > http://morepypy.blogspot.co.uk/2014/07/pypy-stm-first-interesting- release.html Both Jython and IronPython are GIL-less, and have been forever. -- Steven From rosuav at gmail.com Tue Jul 8 05:05:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 19:05:09 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Tue, Jul 8, 2014 at 6:48 PM, Steven D'Aprano wrote: > If editors were to standardise on the convention "display a > HORIZONTAL TAB character as visibly distinct from a sequence of > spaces" (e.g. by shading the background a different colour, or overlying > it with an arrow) DeScribe Word Processor has (had? it hasn't been developed in about a decade... but it still runs just fine) a whole lot of visual guides for metacharacters, which can be turned on or off. Normally, we prefer not to have a little dot to mark every 0x20 space, but you can have 'em if you want 'em; tabs get shown as diamonds; paragraph markers as pilcrows; line breaks as a small circle; and so on. (The difference between a paragraph and a line break isn't a normal one in most text editors, so I'd be looking at representing U+000A newlines with a pilcrow, probably.) Obviously you need a means of distinguishing the end-of-line marker from an actual character, since PILCROW SIGN is a perfectly acceptable character; but if the metacharacters are shown in, say, a pale blue, rather than the usual black text, it'd be easy enough. ChrisA From marko at pacujo.net Tue Jul 8 05:09:45 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 12:09:45 +0300 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <87a98kgqsm.fsf@elektro.pacujo.net> Steven D'Aprano : > * editors don't handle tabs correctly But you said yourself: > I'm not sure there actually *is* such a thing as "default semantics" > for tabs. What is "correct" handling of ASCII TAB characters in a text file? The unix tradition is to let the TTY interpret the TABs. Utilities such as "ed", "cat", "diff" or "gcc" don't interpret or process TABs in any way but simply output them together with the rest of the text. And the TTY tradition is to have TAB stops at every 8 columns (by default). So this question has little to do with text editors except in that your editor should display your program roughly the same way as "lpr" prints it out. Marko From wxjmfauth at gmail.com Tue Jul 8 05:38:42 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Tue, 8 Jul 2014 02:38:42 -0700 (PDT) Subject: error handling when opening files In-Reply-To: References: Message-ID: <97efde28-a8c8-44cd-817a-97fab21876cb@googlegroups.com> Alex is right (at least not wrong) and I'm also working in a similar way. - If there is a problem in opening, the file is never opened and only an IOError can happen. - If do_stuff succeeds: the file is open and will be closed because of the with statement. - If do_stuff does not succeed (errors), the file will be closed (with statement) and only later the error is raised. Tricky, but it works like this. In short: simple and elegant solution. >>> def z(): ... try: ... with open('eta.cfg', 'r') as f: ... a = 1 / 0 ... except IOError: ... print('error in opening file') ... except ZeroDivisionError: ... print('ZeroDivisionError', f.closed) ... >>> z() ZeroDivisionError True >>> def z2(): ... try: ... with open('xxx.cfg', 'r') as f: ... a = 1 / 0 ... except IOError: ... print('error in opening file') ... except ZeroDivisionError: ... print('ZeroDivisionError', f.closed) ... >>> z2() error in opening file >>> def z3(): ... try: ... with open('xxx.cfg', 'r') as f: ... a = 1 / 0 ... except IOError: ... print('error in opening file') ... print(f.closed) ... except ZeroDivisionError: ... print('ZeroDivisionError', f.closed) ... >>> z3() error in opening file Traceback (most recent call last): File "", line 1, in File "", line 7, in z3 UnboundLocalError: local variable 'f' referenced before assignment ---- One could consider a case where do_stuff is opening a file... ---- Quote: "Interestingly, did you know that even *closing* " a file can fail? Answer: Does "with" fail? I never explicitely closed the file. From rosuav at gmail.com Tue Jul 8 06:28:21 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 20:28:21 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <87a98kgqsm.fsf@elektro.pacujo.net> References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> <87a98kgqsm.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 8, 2014 at 7:09 PM, Marko Rauhamaa wrote: > The unix tradition is to let the TTY interpret the TABs. Utilities such > as "ed", "cat", "diff" or "gcc" don't interpret or process TABs in any > way but simply output them together with the rest of the text. Not quite; tools like diff that put a character at the beginning of the line are likely to be tab-aware, and gcc is certainly going to comprehend them (at least to the extent of treating them as whitespace). And I think less takes notice of them, too, so it's only the very simplest tools like cat that actually ignore them or treat them as single characters (or even bytes). ChrisA From rosuav at gmail.com Tue Jul 8 06:29:20 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 20:29:20 +1000 Subject: open() and EOFError In-Reply-To: <53bbb3c6$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <53bbb3c6$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Tue, Jul 8, 2014 at 7:03 PM, Steven D'Aprano wrote: > On Mon, 07 Jul 2014 14:49:56 -0400, Terry Reedy wrote: > >> Avoid EOFError. Much better, I think, is the somewhat customary >> >> s = input("Enter something, or hit to exit") if not s: >> sys.exit() >> else: > > Under many circumstances, I would do exactly that. But sometimes an empty > string is valid data, not a signal for special processing (whether > exiting the application, or something else). Or you want to have two different signals: empty string means "use the default", and something else means "exit the application now please". Very common. ChrisA From rosuav at gmail.com Tue Jul 8 06:35:53 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 20:35:53 +1000 Subject: error handling when opening files In-Reply-To: <53bbb33b$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53bbb33b$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On Tue, Jul 8, 2014 at 7:00 PM, Steven D'Aprano wrote: > Interestingly, did you know that even *closing* a file can fail? I know that can happen with SSL sockets (which can require writing and reading). Can't think of any situations on normal file systems where that's true, unless the actual failure is in the flushing of buffers; technically, that's not a failure of closing, but it could be a failure that's detected on close(). Is that what you're thinking of? ChrisA From robin at reportlab.com Tue Jul 8 06:39:26 2014 From: robin at reportlab.com (Robin Becker) Date: Tue, 08 Jul 2014 11:39:26 +0100 Subject: generic _ssl error Message-ID: <53BBCA5E.8030709@chamonix.reportlab.co.uk> I have the following from some production machines when trying to clone / pull etc etc using mercurial on ubuntu 10.04 hg clone https://myhost/myrepos abort: error: _ssl.c:480: error:0D0C50A1:asn1 encoding routines:ASN1_item_verify:unknown message digest algorithm I believe that _ssl.c must be the _ssl.so module which presumably is being used by the hg command. The system python which mercurial uses is Python 2.7.2 (default, Sep 20 2011, 16:38:53) Could this error be the result of upgrading the openssl to fix heartbleed and not upgrading the system python? On other servers I am able to clone etc etc without issue, but those are almost all 12.04 machines and were fully updated at the time of heartbleed. -- Robin Becker From marko at pacujo.net Tue Jul 8 07:13:09 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 14:13:09 +0300 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> <87a98kgqsm.fsf@elektro.pacujo.net> Message-ID: <874mysgl2y.fsf@elektro.pacujo.net> Chris Angelico : > Not quite; tools like diff that put a character at the beginning of > the line are likely to be tab-aware, No, just tried it again: diff outputs tabs as tabs. $ diff abc def 1,2c1,2 < abc < abc --- > def > def where line 1 begins with a tab and line 2 begins with 8 spaces in each file. > and gcc is certainly going to comprehend them $ gcc -c test.c test.c:1:2: error: expected identifier or ?(? at end of input where test.c contains ( IOW, gcc reports that the open parenthesis is in column 2. > (at least to the extent of treating them as whitespace). Sure, but that doesn't concern the tab stops in any way. > And I think less takes notice of them, too, How? > so it's only the very simplest tools like cat that actually ignore > them or treat them as single characters (or even bytes). They all seem to be "simple." At least Python is: $ python3 -c 'print (' File "", line 1 print ( ^ SyntaxError: unexpected EOF while parsing where the caret is pointing at the wrong visual column. Marko From rosuav at gmail.com Tue Jul 8 07:37:40 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 8 Jul 2014 21:37:40 +1000 Subject: PEP8 and 4 spaces In-Reply-To: <874mysgl2y.fsf@elektro.pacujo.net> References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> <87a98kgqsm.fsf@elektro.pacujo.net> <874mysgl2y.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 8, 2014 at 9:13 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Not quite; tools like diff that put a character at the beginning of >> the line are likely to be tab-aware, > > No, just tried it again: diff outputs tabs as tabs. > > $ diff abc def > 1,2c1,2 > < abc > < abc > --- > > def > > def > > where line 1 begins with a tab and line 2 begins with 8 spaces in each > file. Check out its -t and -T options; diff is definitely tab-aware. >> and gcc is certainly going to comprehend them > > $ gcc -c test.c > test.c:1:2: error: expected identifier or ?(? at end of input > > where test.c contains > > ( > > IOW, gcc reports that the open parenthesis is in column 2. It's easier to number the positions that way, in the same way that you would number lines - by how many times you have to hit down or right arrow to get there. In my MUD client, I measure text positions in characters (within a line; a particular position is identified by (line, char), because lines are generally far more important than overall positions), even when tabs are involved; a tab simply counts as one character, even though it displays as up to eight times the width. Actually, I'm currently contemplating a reworking of how that's all mapped out, which would mean that *any* character is allowed to take up *any* width, including zero, in which case the only significance is that a tab takes up a variable width depending on where it is in the line (which is already coped with). >> And I think less takes notice of them, too, > > How? Shrink your terminal down to some weird width like 45, create a file with long lines including tabs, 'less' the file, and use the right arrow key to scroll horizontally. It takes note of tabs and renders them properly. >> so it's only the very simplest tools like cat that actually ignore >> them or treat them as single characters (or even bytes). > > They all seem to be "simple." At least Python is: > > $ python3 -c 'print (' > File "", line 1 > print ( > ^ > SyntaxError: unexpected EOF while parsing > > where the caret is pointing at the wrong visual column. If someone cares enough to write a patch, I'm sure the traceback renderer could be improved. But how many people actually use tabs inside code like that? ChrisA From invalid at invalid.invalid Tue Jul 8 10:19:34 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 8 Jul 2014 14:19:34 +0000 (UTC) Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 2014-07-07, Gregory Ewing wrote: > Terry Reedy wrote: >> Avoid EOFError. Much better, I think, is the somewhat customary >> >> s = input("Enter something, or hit to exit") >> if not s: sys.exit() >> else: > > I beg to differ -- on Unix, Ctrl-D *is* the customary > way to exit from something that's reading from stdin. Indeed. Ctrl-D is _the_ canonical way to tell a program that's reading stdin that your're done. I've never run across "hit to exit". > In any case, you need to be able to handle EOF gracefully if the user > uses it. -- Grant Edwards grant.b.edwards Yow! Nipples, dimples, at knuckles, NICKLES, gmail.com wrinkles, pimples!! From neilc at norwich.edu Tue Jul 8 10:29:18 2014 From: neilc at norwich.edu (Neil D. Cerutti) Date: Tue, 08 Jul 2014 10:29:18 -0400 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <87wqbp9it2.fsf@elektro.pacujo.net> Message-ID: On 7/7/2014 7:10 PM, Mark Lawrence wrote: > On 07/07/2014 23:09, Gregory Ewing wrote: >> Marko Rauhamaa wrote: >>> with open(path) as f: >>> ... >>> >>> If the open() call is guarded against exceptions (as it usually should), >>> one must revert to the classic syntax: >> >> Hmmm, maybe we could do with a with-except statement: >> >> with open(path) as f: >> ... >> except IOError: >> # Catches exceptions in the with-expression only >> ... >> >> Although that would be a bit confusing. > > I wrap the with inside a try/except, the other file handling parts > within another try/except and use the finer grained exceptions from PEP > 3151 to write (at least to my eye) cleaner looking code. Somehow I > think we'll get agreement on the best way to do this when the cows come > home. On Windows it's my experience that EOF from interactive sessions is ignored. Programs keep going as best they can, providing some other means of exit, e.g., an 'exit' command. But maybe that's just the shell. -- Neil Cerutti From 2014 at jmunch.dk Tue Jul 8 10:53:47 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 16:53:47 +0200 Subject: NaN comparisons - Call For Anecdotes Message-ID: <53BC05FB.4050707@jmunch.dk> Most people don't need to deal with NaN's in Python at all, fortunately. They just don't appear in normal computation, because the interpreter raises an exception instead. It happens in my work I come across them quite a lot. I'm writing software that talks to embedded applications that can contain NaN values for a variety of reasons - never-initialised storage, initialise-to-NaN, hardware failures etc. So when my software reads these values in binary, unpack them using the struct module, and goes to work. And NaN's are no different from any other value, it's something to store, compare, display etc. And that worked fine in my Python 2.4 apps. Then I upgraded to 2.7 and it broke. Because 2.7 goes out of it's way to ensure that NaN's don't compare equal to themselves. I discovered it when a sanity check told me that two functions, to_binary and from_binary, weren't each other's inverse, as they were intended to be. Apparently, bitPattern==to_binary(from_binary(bitPattern)) wasn't true for this particular value of bitPattern. Of course, the bit pattern in question was the binary representation for a floating-point NaN. Panic time! If I can't trust == to return True for (mathematically) equal objects, that means that every single algorithm I had ever written that explicitly or implicitly does .__eq__ or .__ne__ comparison was suspect! That meant I had 30000 lines of code to review. Every time there's a comparison, if there was any chance that either value could be a float NaN, I would have to change e.g. if x==y: to if x==y or (isinstance(x, float) and isinstance(y, float) and math.isnan(x) and math.isnan(y)): To make it bearable, I could wrap the pattern up in a function and write if my_equal(x,y): but I would still lose, because the standard library does == and != all over the place without calling my_equal. In the end I came up with this hack: Every time I struct.unpack'd a float, I check if it's a NaN, and if it is, then I replace it with a reference to a single, shared, "canonical" NaN. That means that container objects that skip __equal__ when comparing an object to itself will work -- e.g. hash keys. It's half a solution, of course: Any further computation with a NaN value will change it to a different NaN object, so I still needed to do explicit NaN-checks in various places. I'm sure there are still NaN-related bugs in my code, but right now it's "good enough" - I haven't seen NaN-related bugs in a good while. Now, all this bothers me. Not that I had to do some work to get stuff to work in an imperfect world. No, what bothers me is that this behaviour was explicitly and deliberately put in for no good reason. The only reason is "standard says so". Not that there's any legal requirement for Python to follow the IEEE-754 standard. Or for that matter, for Python's spelling of IEEE-754 comparisons to be "==". So I make this claim: float.__eq__ implementing IEEE-754 NaN comparison rules creates real problems for developers. And it has never, ever, helped anyone do anything. "Never" is a strong claim, and easily disproven if false: Simply provide a counterexample. So that is my challenge: If you have a program (a pre-existing and useful one, not something artificial created for this challenge) that benefits from NaN!=NaN and that would fail if x==x for all float objects x, then please come forward and show it, and I'll buy you a beer the next time I'm at PyCon. regards, Anders From python at bdurham.com Tue Jul 8 10:59:18 2014 From: python at bdurham.com (python at bdurham.com) Date: Tue, 08 Jul 2014 10:59:18 -0400 Subject: Naming conventions for functions and methods Message-ID: <1404831558.6942.139345801.530E4959@webmail.messagingengine.com> Looking for your opinions on how you name your functions and methods. Example: I have a function that hashes a file. I could name this function hash_file() or file_hash(). The 1st naming convention sounds more natural, the 2nd naming convention allows one to group related functions together by the object being acted on. PEP-8 doesn't appear to offer guidance in this area. Thoughts? Malcolm -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Tue Jul 8 11:08:44 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 08 Jul 2014 11:08:44 -0400 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: On 7/8/2014 10:19 AM, Grant Edwards wrote: > On 2014-07-07, Gregory Ewing wrote: >> Terry Reedy wrote: >>> Avoid EOFError. Much better, I think, is the somewhat customary >>> >>> s = input("Enter something, or hit to exit") >>> if not s: sys.exit() >>> else: >> >> I beg to differ -- on Unix, Ctrl-D *is* the customary >> way to exit from something that's reading from stdin. > > Indeed. Ctrl-D is _the_ canonical way to tell a program that's > reading stdin that your're done. Not on Windows. > I've never run across "hit to exit". > >> In any case, you need to be able to handle EOF gracefully if the user >> uses it. > -- Terry Jan Reedy From rosuav at gmail.com Tue Jul 8 11:19:57 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 01:19:57 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC05FB.4050707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> Message-ID: On Wed, Jul 9, 2014 at 12:53 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > In the end I came up with this hack: Every time I struct.unpack'd a > float, I check if it's a NaN, and if it is, then I replace it with a > reference to a single, shared, "canonical" NaN. That means that > container objects that skip __equal__ when comparing an object to > itself will work -- e.g. hash keys. Let's take a step back. No, let's take a step forward. And let's take a step back again. (And we're building a military-grade laser!) Why *should* all NaNs be equal to each other? You said on the other list that NaN==NaN was equivalent to (2+2)==(1+3), but that assumes that NaN is a single "thing". It's really describing the whole huge area of "stuff that just ain't numbers". Imagine if (x + y) wasn't 4, but was "table". And (a + b) turned out to be "cyan". Does table equal cyan, just because neither of them is a number? Certainly not. Neither should (inf - inf) be equal to (inf / inf). Both of those expressions evaluate to something that can't possibly be a number - it can't be anywhere on the number line, it can't be anywhere on the complex plane, it simply isn't a number. And they're not the same non-numeric "thing". For hash keys, float object identity will successfully look them up: >>> d={} >>> d[float("nan")]=1 >>> d[float("nan")]=2 >>> x=float("nan") >>> d[x]=3 >>> d[x] 3 >>> d {nan: 1, nan: 2, nan: 3} So I'm not sure where the problems come from. You can iterate over a dict's keys and look things up with them: >>> for k,v in d.items(): print(k,v,d[k]) nan 1 1 nan 2 2 nan 3 3 You can do a simple 'is' check as well as your equality check: if x is y or x == y: print("They're the same") But any time you compare floats for equality, you *already* have to understand what you're doing (because of rounding and such), so I don't see why the special case on NaN is significant, unless as mentioned above, you want all NaNs to be equal, which doesn't make sense. ChrisA From python.list at tim.thechases.com Tue Jul 8 11:20:33 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 8 Jul 2014 10:20:33 -0500 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <20140708102033.13efb3a4@bigbox.christie.dr> On 2014-07-08 11:08, Terry Reedy wrote: > > Indeed. Ctrl-D is _the_ canonical way to tell a program that's > > reading stdin that your're done. > > Not on Windows. Okay, EOF is the canonical way to tell a program reading stdin that you're done. It just happens that EOF ^D on *nix-likes and ^Z on Win32. :-) -tkc From ian.g.kelly at gmail.com Tue Jul 8 11:23:47 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 09:23:47 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC05FB.4050707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 8:53 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > And that worked fine in my Python 2.4 apps. Then I upgraded to 2.7 > and it broke. Because 2.7 goes out of it's way to ensure that NaN's > don't compare equal to themselves. As far as I know nothing changed between 2.4 and 2.7 in this regard. Python has always had NaN compare unequal to everything, per the standard. > I discovered it when a sanity check told me that two functions, > to_binary and from_binary, weren't each other's inverse, as they were > intended to be. Apparently, > bitPattern==to_binary(from_binary(bitPattern)) wasn't true for this > particular value of bitPattern. Of course, the bit pattern in > question was the binary representation for a floating-point NaN. Okay, here's your problem: there isn't just one binary representation for NaN. The standard defines any value with all 1's in the exponent and a non-zero significand as NaN (a zero significand would instead be an infinity). Your bit comparison is going to have to be prepared to compare NaNs that don't have the same binary representation. By the way, there are also multiple binary representations for 0. If you compare them as floats, then they'll compare equal to one another, but if you're just comparing binary representations then you'll have issues there as well. > Now, all this bothers me. Not that I had to do some work to get stuff > to work in an imperfect world. No, what bothers me is that this > behaviour was explicitly and deliberately put in for no good reason. > The only reason is "standard says so". Not that there's any legal > requirement for Python to follow the IEEE-754 standard. Or for that > matter, for Python's spelling of IEEE-754 comparisons to be "==". Following the standard isn't a good reason itself? It seems to me that one should be expected to provide a strong justification for *deviating* from the standard, not for following it. From rosuav at gmail.com Tue Jul 8 11:24:43 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 01:24:43 +1000 Subject: open() and EOFError In-Reply-To: <20140708102033.13efb3a4@bigbox.christie.dr> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> Message-ID: On Wed, Jul 9, 2014 at 1:20 AM, Tim Chase wrote: > On 2014-07-08 11:08, Terry Reedy wrote: >> > Indeed. Ctrl-D is _the_ canonical way to tell a program that's >> > reading stdin that your're done. >> >> Not on Windows. > > Okay, EOF is the canonical way to tell a program reading stdin that > you're done. It just happens that EOF ^D on *nix-likes and ^Z on > Win32. :-) > > -tkc I can't think of any Windows-native programs that ask for EOF. Only those which came from POSIX platforms do it. That said, though, Windows doesn't tend to encourage interactive command-line programs at all, so you may as well just follow the Unix convention. ChrisA From skip at pobox.com Tue Jul 8 11:24:50 2014 From: skip at pobox.com (Skip Montanaro) Date: Tue, 8 Jul 2014 10:24:50 -0500 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 10:19 AM, Chris Angelico wrote: > For hash keys, float object identity will successfully look them up: >>>> d={} >>>> d[float("nan")]=1 >>>> d[float("nan")]=2 >>>> x=float("nan") >>>> d[x]=3 >>>> d[x] > 3 >>>> d > {nan: 1, nan: 2, nan: 3} Neat! S From rosuav at gmail.com Tue Jul 8 11:31:41 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 01:31:41 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> Message-ID: On Wed, Jul 9, 2014 at 1:24 AM, Skip Montanaro wrote: > On Tue, Jul 8, 2014 at 10:19 AM, Chris Angelico wrote: >> For hash keys, float object identity will successfully look them up: >>>>> d={} >>>>> d[float("nan")]=1 >>>>> d[float("nan")]=2 >>>>> x=float("nan") >>>>> d[x]=3 >>>>> d[x] >> 3 >>>>> d >> {nan: 1, nan: 2, nan: 3} > > Neat! Yeah. It's one of those arguable points; is it a mere optimization that dict lookup does an identity check before an equality check, or is it crucial to other invariants (like the iteration one - if you iterate over items(), it should give exactly the same results as iterating over keys() and then looking things up)? Obviously it's better for the dict to use equality checks rather than identity checks (otherwise, at the very least, you'd have to explicitly intern all strings used as dict keys - that'd just be ridiculous), but with objects that don't compare equal to themselves, what should be done? I think Python's picked a quite reasonable approach. ChrisA From python.list at tim.thechases.com Tue Jul 8 11:46:35 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 8 Jul 2014 10:46:35 -0500 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> Message-ID: <20140708104635.350592d0@bigbox.christie.dr> On 2014-07-09 01:24, Chris Angelico wrote: > On Wed, Jul 9, 2014 at 1:20 AM, Tim Chase > > Okay, EOF is the canonical way to tell a program reading stdin > > that you're done. It just happens that EOF ^D on *nix-likes and > > ^Z on Win32. :-) > > > > -tkc > > I can't think of any Windows-native programs that ask for EOF. Only > those which came from POSIX platforms do it. That said, though, > Windows doesn't tend to encourage interactive command-line programs > at all, so you may as well just follow the Unix convention. There was a time in life where I used "copy con output.txt" on a disturbingly frequent basis. Control+Z ended my file for me. -tkc From rosuav at gmail.com Tue Jul 8 11:49:38 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 01:49:38 +1000 Subject: open() and EOFError In-Reply-To: <20140708104635.350592d0@bigbox.christie.dr> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> <20140708104635.350592d0@bigbox.christie.dr> Message-ID: On Wed, Jul 9, 2014 at 1:46 AM, Tim Chase wrote: > On 2014-07-09 01:24, Chris Angelico wrote: >> On Wed, Jul 9, 2014 at 1:20 AM, Tim Chase >> > Okay, EOF is the canonical way to tell a program reading stdin >> > that you're done. It just happens that EOF ^D on *nix-likes and >> > ^Z on Win32. :-) >> > >> > -tkc >> >> I can't think of any Windows-native programs that ask for EOF. Only >> those which came from POSIX platforms do it. That said, though, >> Windows doesn't tend to encourage interactive command-line programs >> at all, so you may as well just follow the Unix convention. > > There was a time in life where I used "copy con output.txt" on a > disturbingly frequent basis. Control+Z ended my file for me. > Yes, and I've done that with a few programs (sort comes to mind; also Regina Rexx, because it lacked a true interactive interpreter), but not interactive ones. Those programs are filters, so obviously EOF is the way to signal, well, end of file. (Have you ever used COPY CON to create a binary file?) ChrisA From python.list at tim.thechases.com Tue Jul 8 11:57:26 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 8 Jul 2014 10:57:26 -0500 Subject: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> <20140708104635.350592d0@bigbox.christie.dr> Message-ID: <20140708105726.3477e1bb@bigbox.christie.dr> On 2014-07-09 01:49, Chris Angelico wrote: > Have you ever used COPY CON to create a binary file? No, for that I used DEBUG.EXE (or DEBUG.COM on older versions of DOS) -tkc From marko at pacujo.net Tue Jul 8 12:16:53 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 19:16:53 +0300 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> Message-ID: <878uo3akqy.fsf@elektro.pacujo.net> Chris Angelico : > Why *should* all NaNs be equal to each other? I appreciate why you can't say NaN is equal to NaN. However, shouldn't the very comparison attempt trigger an arithmetic exception? After all, so does a division by zero. Marko From rosuav at gmail.com Tue Jul 8 12:20:05 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 02:20:05 +1000 Subject: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) In-Reply-To: <20140708105726.3477e1bb@bigbox.christie.dr> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> <20140708104635.350592d0@bigbox.christie.dr> <20140708105726.3477e1bb@bigbox.christie.dr> Message-ID: On Wed, Jul 9, 2014 at 1:57 AM, Tim Chase wrote: > On 2014-07-09 01:49, Chris Angelico wrote: >> Have you ever used COPY CON to create a binary file? > > No, for that I used DEBUG.EXE (or DEBUG.COM on older versions of DOS) I never used a DOS version so old it had DEBUG.COM, but I used DEBUG.EXE extensively. It was, for years, the only means I had of building assembly language programs - no C compiler, no proper assembler, nothing. One of my greatest triumphs, at the time, was the development of an absolutely insane (even at the time I knew it was insane) system that let me build an assembly program with line labels in it; it would pipe commands into DEBUG and pipe the output back out, and drive DEBUG's mini-assembler. When it came to a label, it would look at what the prompt said would be the next address, and save it. When the label was used, it would patch in the actual address. And forward references were handled, too - it'd put in a placeholder, and then go and assemble over it afterward. (I'm not sure what happened if the placeholder resulted in the wrong size of jump command being assembled. It was a definite consideration, as conditional jumps had to be relative, but unconditional jumps could be relative (two-byte command) or absolute (three-byte command). Maybe it just always put in a distant target, and patched in a NOP if it didn't need the third byte, or something. I don't remember.) Sadly, there was a period when all my programming was either in BASIC or assembly, and even more sadly, I would write low-level code using DEBUG, save it into the format needed by BLOAD, and then CALL ABSOLUTE the routine from BASIC... in order to, for instance, access the mouse. Life got ever so much better when I moved to OS/2, and started using REXX for most of my work. (And then eventually got a C compiler, albeit a Windows one. Was years and years before I actually got a decent build system for OS/2.) There was a time when, just for the fun of it, I started memorizing a whole lot of 8086 opcodes in hex, just so I could COPY CON PROGRAM.COM and make something actually work. I don't think there was ever any purpose in it at all, but it was fun. I guess that's a purpose... some people play Tetris, some people have girlfriends/boyfriends, and some people learn to write machine code at COPY CON... ChrisA From rosuav at gmail.com Tue Jul 8 12:27:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 02:27:09 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <878uo3akqy.fsf@elektro.pacujo.net> References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 9, 2014 at 2:16 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> Why *should* all NaNs be equal to each other? > > I appreciate why you can't say NaN is equal to NaN. However, shouldn't > the very comparison attempt trigger an arithmetic exception? After all, > so does a division by zero. I'd say it would surprise people rather a lot if operations like dict insertion/lookup could trigger arithmetic exceptions. :) ChrisA From balglaas at xs4all.nl Tue Jul 8 12:38:58 2014 From: balglaas at xs4all.nl (Jan van den Broek) Date: 08 Jul 2014 16:38:58 GMT Subject: ^D vs ^Z as EOF and DOS dinosaurs talking (was: open() and EOFError) References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> <20140708104635.350592d0@bigbox.christie.dr> Message-ID: On 2014-07-08, Tim Chase wrote: > On 2014-07-09 01:49, Chris Angelico wrote: >> Have you ever used COPY CON to create a binary file? > > No, for that I used DEBUG.EXE (or DEBUG.COM on older versions of DOS) Both. -- Jan v/d Broek balglaas at xs4all.nl "Geef je over, wy zyn Bassie en Adriaan, weerstand is nutteloos" From python.list at tim.thechases.com Tue Jul 8 12:40:03 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Tue, 8 Jul 2014 11:40:03 -0500 Subject: open() and EOFError In-Reply-To: References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> Message-ID: <20140708114003.1ca872fb@bigbox.christie.dr> On 2014-07-09 01:24, Chris Angelico wrote: > I can't think of any Windows-native programs that ask for EOF. Only > those which came from POSIX platforms do it. That said, though, > Windows doesn't tend to encourage interactive command-line programs > at all, so you may as well just follow the Unix convention. And within the last 10 minutes doing some work on a Win32 box, I noticed that both the "wmic" console (standard since at least XP I believe) and Python use EOF to quit (both provide alternate methods of quitting, but EOF is fast & easy). -tkc From rosuav at gmail.com Tue Jul 8 12:50:31 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 02:50:31 +1000 Subject: open() and EOFError In-Reply-To: <20140708114003.1ca872fb@bigbox.christie.dr> References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> <20140708114003.1ca872fb@bigbox.christie.dr> Message-ID: On Wed, Jul 9, 2014 at 2:40 AM, Tim Chase wrote: > On 2014-07-09 01:24, Chris Angelico wrote: >> I can't think of any Windows-native programs that ask for EOF. Only >> those which came from POSIX platforms do it. That said, though, >> Windows doesn't tend to encourage interactive command-line programs >> at all, so you may as well just follow the Unix convention. > > And within the last 10 minutes doing some work on a Win32 box, I > noticed that both the "wmic" console (standard since at least XP I > believe) and Python use EOF to quit (both provide alternate methods of > quitting, but EOF is fast & easy). > Python doesn't count, as it's cross-platform; lots of programs work the same way on all their platforms, and it doesn't say anything about the expectations of native Windows apps. But wmic, that's a better example. Counter-example: Command-line FTP on Windows doesn't react to Ctrl-Z, which annoys me somewhat when I move from one to another. (Not as much as it annoys me by not supporting passive mode, though. I generally have to turn to a web browser to do basic FTP downloads across a VM boundary, and for uploads, I either have to go fetch a better FTP client (like FileZilla), or - as I've often done - whip up a few lines of basic TCP socket file transfer, because I can do that at an interactive interpreter faster than most people can move files any other way.) hrisA From steve+comp.lang.python at pearwood.info Tue Jul 8 13:13:46 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 17:13:46 GMT Subject: NaN comparisons - Call For Anecdotes References: Message-ID: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 16:53:47 +0200, Anders J. Munch wrote: > Most people don't need to deal with NaN's in Python at all, fortunately. > They just don't appear in normal computation, because the interpreter > raises an exception instead. > > It happens in my work I come across them quite a lot. I'm writing > software that talks to embedded applications that can contain NaN values > for a variety of reasons - never-initialised storage, initialise-to-NaN, > hardware failures etc. > > So when my software reads these values in binary, unpack them using the > struct module, and goes to work. And NaN's are no different from any > other value, it's something to store, compare, display etc. > > And that worked fine in my Python 2.4 apps. I think you're smoking something funny :-) [steve at ando ~]$ python2.4 Python 2.4.3 (#1, Jan 9 2013, 06:49:54) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2 Type "help", "copyright", "credits" or "license" for more information. py> NAN = float('NAN') py> NAN == NAN False NANs compared unequal in Python 2.4. [...] > Now, all this bothers me. Not that I had to do some work to get stuff > to work in an imperfect world. No, what bothers me is that this > behaviour was explicitly and deliberately put in for no good reason. Oh, you've read the IEEE-754 standard, and that's what it says? "We're going to specify this behaviour for NANs just to annoy people" perhaps? -- Steven From rosuav at gmail.com Tue Jul 8 13:21:21 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 03:21:21 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 3:13 AM, Steven D'Aprano wrote: >> Now, all this bothers me. Not that I had to do some work to get stuff >> to work in an imperfect world. No, what bothers me is that this >> behaviour was explicitly and deliberately put in for no good reason. > > Oh, you've read the IEEE-754 standard, and that's what it says? "We're > going to specify this behaviour for NANs just to annoy people" perhaps? You're confusing IEEE with Adobe. IEEE is pronounced "Aiiiiieeeeeeeeeeeeeeee!", but it's Adobe that makes people scream that. http://www.theregister.co.uk/2009/04/30/xee_photoshop_psd_code_rant/ ChrisA From skip at pobox.com Tue Jul 8 13:23:57 2014 From: skip at pobox.com (Skip Montanaro) Date: Tue, 8 Jul 2014 12:23:57 -0500 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC05FB.4050707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 9:53 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > Most people don't need to deal with NaN's in Python at all, > fortunately. They just don't appear in normal computation, because the > interpreter raises an exception instead. In addition to what others have written, I will add one thing. There are certainly situations where raising an exception is bad. Consider all the people in the scientific computing community doing fancy linear algebra sorts of things, often with missing data. They generally want NaN propagated and not have some long running calculation crash in the middle. Skip From marko at pacujo.net Tue Jul 8 13:31:25 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 20:31:25 +0300 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> Message-ID: <871ttvahaq.fsf@elektro.pacujo.net> Chris Angelico : > I'd say it would surprise people rather a lot if operations like dict > insertion/lookup could trigger arithmetic exceptions. :) That wouldn't trigger exceptions. Dict operations do an "is" test before an "==" test. In fact, you couldn't even use NaN as a dict key otherwise. Thus, dict operations never test NaN == NaN. Marko From marko at pacujo.net Tue Jul 8 13:36:40 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 08 Jul 2014 20:36:40 +0300 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> Message-ID: <87wqbn92hj.fsf@elektro.pacujo.net> Skip Montanaro : > In addition to what others have written, I will add one thing. There > are certainly situations where raising an exception is bad. Consider > all the people in the scientific computing community doing fancy > linear algebra sorts of things, often with missing data. They > generally want NaN propagated and not have some long running > calculation crash in the middle. Do the scientific computers mind: >>> 1 / 0 Traceback (most recent call last): File "", line 1, in ZeroDivisionError: division by zero or would they prefer their fancy linear-algebraic computation to just forge on? Marko From skip at pobox.com Tue Jul 8 13:49:08 2014 From: skip at pobox.com (Skip Montanaro) Date: Tue, 8 Jul 2014 12:49:08 -0500 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <87wqbn92hj.fsf@elektro.pacujo.net> References: <53BC05FB.4050707@jmunch.dk> <87wqbn92hj.fsf@elektro.pacujo.net> Message-ID: >>> import numpy >>> a1 = numpy.ones(5) >>> a1 array([ 1., 1., 1., 1., 1.]) >>> a0 = numpy.zeros(5) >>> a0 array([ 0., 0., 0., 0., 0.]) >>> a1 / a0 __main__:1: RuntimeWarning: divide by zero encountered in true_divide array([ inf, inf, inf, inf, inf]) >>> nans = numpy.array([float("nan")] * 5) >>> nans array([ nan, nan, nan, nan, nan]) >>> a1 / nans array([ nan, nan, nan, nan, nan]) >>> a1 / a0 * nans array([ nan, nan, nan, nan, nan]) You get a runtime warning (this is in Python 2.7), but the division returns the appropriate value, in this case, infinity. So, yes, they forge on, and NaN taints things just about the way you'd expect. Skip On Tue, Jul 8, 2014 at 12:36 PM, Marko Rauhamaa wrote: > Skip Montanaro : > >> In addition to what others have written, I will add one thing. There >> are certainly situations where raising an exception is bad. Consider >> all the people in the scientific computing community doing fancy >> linear algebra sorts of things, often with missing data. They >> generally want NaN propagated and not have some long running >> calculation crash in the middle. > > Do the scientific computers mind: > > >>> 1 / 0 > Traceback (most recent call last): > File "", line 1, in > ZeroDivisionError: division by zero > > or would they prefer their fancy linear-algebraic computation to just > forge on? > > > Marko > -- > https://mail.python.org/mailman/listinfo/python-list From rosuav at gmail.com Tue Jul 8 13:54:52 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 03:54:52 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <871ttvahaq.fsf@elektro.pacujo.net> References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> <871ttvahaq.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 9, 2014 at 3:31 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> I'd say it would surprise people rather a lot if operations like dict >> insertion/lookup could trigger arithmetic exceptions. :) > > That wouldn't trigger exceptions. > > Dict operations do an "is" test before an "==" test. In fact, you > couldn't even use NaN as a dict key otherwise. Thus, dict operations > never test NaN == NaN. Check out the example I posted early in this thread of a dict with three keys, all of them NaN. And note that hash(float("nan"))==0. Now try looking up d[0]. Before it raises KeyError, it has to compare that 0 for equality with each of the nans, because it can't shortcut it based on the hash. In fact, I can prove it thus: >>> class X: def __eq__(self, other): if self is other: print("Comparing against self - I am me!") return True print("Comparing against",other,"-",id(other)) return False def __hash__(self): return 0 >>> d[X()] Comparing against nan - 18777952 Comparing against nan - 19624864 Comparing against nan - 18776272 Traceback (most recent call last): File "", line 1, in d[X()] KeyError: <__main__.X object at 0x016B40D0> Any lookup of anything with a hash of 0 will do this. 0 itself (as any type of number), another NaN, or anything at all. For the dict to work sanely, these comparisons have to work and be False. ChrisA From rosuav at gmail.com Tue Jul 8 13:57:25 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 03:57:25 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> <871ttvahaq.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 9, 2014 at 3:54 AM, Chris Angelico wrote: >>>> class X: > def __eq__(self, other): > if self is other: > print("Comparing against self - I am me!") > return True > print("Comparing against",other,"-",id(other)) > return False > def __hash__(self): > return 0 > >>>> d[X()] > Comparing against nan - 18777952 > Comparing against nan - 19624864 > Comparing against nan - 18776272 > Traceback (most recent call last): > File "", line 1, in > d[X()] > KeyError: <__main__.X object at 0x016B40D0> Better example: Subclass float, then it can actually *be* a nan. >>> class NoisyFloat(float): def __eq__(self, other): print("Comparing",id(self),"against",id(other)) return super().__eq__(other) def __hash__(self): return super().__hash__() >>> d[NoisyFloat("nan")] Comparing 23777152 against 18777952 Comparing 23777152 against 19624864 Comparing 23777152 against 18776272 Traceback (most recent call last): File "", line 1, in d[NoisyFloat("nan")] KeyError: nan That's comparing nan==nan three types with four different nans. ChrisA From ethan at stoneleaf.us Tue Jul 8 13:34:24 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 08 Jul 2014 10:34:24 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC05FB.4050707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> Message-ID: <53BC2BA0.3050500@stoneleaf.us> On 07/08/2014 07:53 AM, Anders J. Munch wrote: > > Most people don't need to deal with NaN's in Python at all, > fortunately. They just don't appear in normal computation, because the > interpreter raises an exception instead. What exception? Apparently your claims about NaN in Python are all wrong -- have you been using a custom interpreter? Python 2.7.4 (default, Sep 26 2013, 03:20:26) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> float('inf') - float('inf') nan -- ~Ethan~ From steve+comp.lang.python at pearwood.info Tue Jul 8 14:10:27 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 18:10:27 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> Message-ID: <53bc3412$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 19:16:53 +0300, Marko Rauhamaa wrote: > Chris Angelico : > >> Why *should* all NaNs be equal to each other? > > I appreciate why you can't say NaN is equal to NaN. However, shouldn't > the very comparison attempt trigger an arithmetic exception? No. Why should it? It's not an error to check whether two things are equal. > After all, so does a division by zero. Um, yes, and multiplying by zero isn't an error. In what way is x == y related to x/0 ? But having said that, sometimes it is useful to stop processing as soon as you reach a NAN. For that, IEEE-754 defines two kinds of NANs, Quiet NANs and Signalling NANs. Quiet NANs don't trigger a signal when you perform operations on them. (By default -- I believe you can enable signals if you wish.) Signalling NANs always trigger a signal, including when you check them for equality: py> from decimal import Decimal as D py> a = D('nan') py> b = D('snan') py> 1 == a False py> 1 == b Traceback (most recent call last): File "", line 1, in decimal.InvalidOperation: [] But by default, NANs are quiet. The C99 standard doesn't support signalling NANs, and Java actually prohibits them. Aside: The influence of C and Java has crippled IEEE-754 support across almost all languages and hardware. It's a crying shame the pernicious influence those two languages have had. http://grouper.ieee.org/groups/1788/email/pdfmPSi1DgZZf.pdf Floating point is *hard*, and people who don't understand it insist on telling those who do that "you don't need that feature" :-( -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 8 14:12:38 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 08 Jul 2014 18:12:38 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <878uo3akqy.fsf@elektro.pacujo.net> <871ttvahaq.fsf@elektro.pacujo.net> Message-ID: <53bc3496$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 20:31:25 +0300, Marko Rauhamaa wrote: > Thus, dict operations never test NaN == NaN You're assuming that there is only one NAN instance. That is not correct: py> a = float('nan') py> b = float('nan') py> a is b False py> a in {b: None} False -- Steven From 2014 at jmunch.dk Tue Jul 8 14:29:52 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 20:29:52 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> Message-ID: <53BC38A0.7030100@jmunch.dk> Chris Angelico wrote: > > Why *should* all NaNs be equal to each other? You said on the other > list that NaN==NaN was equivalent to (2+2)==(1+3), but that assumes > that NaN is a single "thing". I don't actually care if all NaN bitpatterns are in the same equivalence group or if each bitpattern is its own equivalence group. I just want the == equivalence relation to be sound. > For hash keys, float object identity will successfully look them up: Except you can't expect to rely on object identity in most interesting cases. >>> x = float('nan') >>> import struct >>> y = struct.unpack('>> d[x] = "found" >>> d[y] Traceback (most recent call last): File "", line 1, in KeyError: nan and also: >>> def f(): return float('inf')/float('inf') >>> f() == f() False >>> f() is f() False > But any time you compare floats for equality, you *already* have to > understand what you're doing (because of rounding and such), so I > don't see why the special case on NaN is significant, unless as > mentioned above, you want all NaNs to be equal, which doesn't make > sense. Let me conjure up a simple example: | class Monitor(Thread): | def run(self): | old = self.get_current_value() | while not self.Terminated: | new = self.get_current_value() | if new != old: | print(time.asctime(), "changed to", new) | old = new | time.sleep(1) This is a completely generic change detection algorithm, and not a "floating-point algorithm" in any way: It will work on strings, lists, sets, anything that get_current_value returns, including non-NaN floats. You don't need to know anything about floating-point representation to write or use such an algorithm, why should you? It works on tuples, sets, lists, serial port handles, module objects, pretty much anything you can imagine -- except NaN floats. regards, Anders From arnodel at gmail.com Tue Jul 8 14:31:26 2014 From: arnodel at gmail.com (Arnaud Delobelle) Date: Tue, 8 Jul 2014 19:31:26 +0100 Subject: Naming conventions for functions and methods In-Reply-To: <1404831558.6942.139345801.530E4959@webmail.messagingengine.com> References: <1404831558.6942.139345801.530E4959@webmail.messagingengine.com> Message-ID: On 8 July 2014 15:59, wrote: > > Looking for your opinions on how you name your functions and methods. Example: I have a function that hashes a file. I could name this function hash_file() or file_hash(). The 1st naming convention sounds more natural, the 2nd naming convention allows one to group related functions together by the object being acted on. PEP-8 doesn't appear to offer guidance in this area. Thoughts? Malcolm If you want to group related functions together, I would suggest putting them in a module, e.g. 'fileutils'. I'd still go for hashfile for the function name though. -- Arnaud From rosuav at gmail.com Tue Jul 8 14:42:18 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 04:42:18 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC38A0.7030100@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BC38A0.7030100@jmunch.dk> Message-ID: On Wed, Jul 9, 2014 at 4:29 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > Chris Angelico wrote: >> For hash keys, float object identity will successfully look them up: > > > Except you can't expect to rely on object identity in most interesting > cases. > >>>> x = float('nan') >>>> import struct >>>> y = struct.unpack('>>> d[x] = "found" >>>> d[y] > > Traceback (most recent call last): > File "", line 1, in > KeyError: nan > > and also: > >>>> def f(): return float('inf')/float('inf') >>>> f() == f() > False >>>> f() is f() > False Neither of those examples is anything to do with object identity. In the first case, you pack the value and recreate an equivalent of the same type with the same value. In the second, you independently construct two floats with the same value. Both times, you have equivalence (both are NaN), but not identical objects. > Let me conjure up a simple example: > > | class Monitor(Thread): > | def run(self): > | old = self.get_current_value() > | while not self.Terminated: > | new = self.get_current_value() > | if new != old: > | print(time.asctime(), "changed to", new) > | old = new > | time.sleep(1) > > This is a completely generic change detection algorithm, and not a > "floating-point algorithm" in any way: It will work on strings, lists, sets, > anything that get_current_value returns, including non-NaN floats. You don't > need to know anything about floating-point representation to write or use > such an algorithm, why should you? It works on tuples, sets, lists, serial > port handles, module objects, pretty much anything you can imagine -- except > NaN floats. You also have to cope with objects that define __eq__ or __ne__. If you know that you have a monitor like that, then you make sure that the value is something comparable; there are plenty of reasons to have to be careful there. (Consider, for instance, what happens if get_current_value() returns a list. Mutating that list can change whether or not it's equal to something else.) ChrisA From 2014 at jmunch.dk Tue Jul 8 14:54:06 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 20:54:06 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> Message-ID: <53BC3E4E.3020707@jmunch.dk> Ian Kelly wrote: > As far as I know nothing changed between 2.4 and 2.7 in this regard. > Python has always had NaN compare unequal to everything, per the > standard. It might have been platform-specific in 2.4. > Okay, here's your problem: there isn't just one binary representation > for NaN. I'm fully aware of that. Whether NaN's are one equivalence class or several is not the issue. What matters is the integrity of the equivalence relation. > Following the standard isn't a good reason itself? If a standard tells you to jump of a cliff... regards, Anders From 2014 at jmunch.dk Tue Jul 8 15:02:09 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 21:02:09 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53BC4031.20408@jmunch.dk> Steven D'Aprano wrote: > Oh, you've read the IEEE-754 standard, and that's what it says? "We're going > to specify this behaviour for NANs just to annoy people" perhaps? I was referring to the deliberate choice to enforce IEEE-754 rules in Python. There is no force of law that requires Python to do so. regards, Anders From 2014 at jmunch.dk Tue Jul 8 15:04:15 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 21:04:15 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC2BA0.3050500@stoneleaf.us> References: <53BC05FB.4050707@jmunch.dk> <53BC2BA0.3050500@stoneleaf.us> Message-ID: <53BC40AF.50407@jmunch.dk> Ethan Furman skrev: > What exception? Apparently your claims about NaN in Python are all wrong -- > have you been using a custom interpreter? > >>> float('inf') - float('inf') > nan If you deliberately try to manufacture NaN's, you can. I never said otherwise. regards, Anders From 2014 at jmunch.dk Tue Jul 8 15:06:06 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 21:06:06 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> Message-ID: <53BC411E.6000102@jmunch.dk> Den 14-07-08 19:23, Skip Montanaro skrev: > > In addition to what others have written, I will add one thing. There > are certainly situations where raising an exception is bad. Consider > all the people in the scientific computing community doing fancy > linear algebra sorts of things, often with missing data. They > generally want NaN propagated and not have some long running > calculation crash in the middle. NaN!=NaN doesn't cause NaN's to propagate any more or any less. It simply causes a different branch of code to run, quite often the wrong one. regards, Anders From c.candide at laposte.net Tue Jul 8 15:19:26 2014 From: c.candide at laposte.net (candide) Date: Tue, 8 Jul 2014 12:19:26 -0700 (PDT) Subject: Python top learning language Message-ID: <3409ed3b-2b4f-4199-b802-1f5f16faf681@googlegroups.com> http://www.infoworld.com/d/application-development/python-bumps-java-top-learning-language-245774 From roland at rptd.ch Tue Jul 8 15:18:21 2014 From: roland at rptd.ch (=?UTF-8?B?Um9sYW5kIFBsw7xzcw==?=) Date: Tue, 08 Jul 2014 21:18:21 +0200 Subject: Loading modules from files through C++ In-Reply-To: References: <5376ACE7.8030706@rptd.ch> <53775D68.2010009@rptd.ch> <537768FB.7060303@rptd.ch> <53778005.8030105@rptd.ch> <53778E22.3040701@rptd.ch> <53790CCF.1070905@rptd.ch> <537B8E31.7000607@rptd.ch> Message-ID: <53BC43FD.3060409@rptd.ch> > On Wed, May 21, 2014 at 3:17 AM, Roland Pl?ss wrote: >> The important part are the last two lines. An important module is >> lacking the __builtins__ dictionary member so I had to add it. >> >> Hopefully this works also in Py3 should I switch some time later. But I >> guess it should seeing how simple the import now became. > An interesting omission, I'm a little surprised at that. But if your > switch to Py3 is a serious (or even half-serious) possibility, I > recommend tossing a quick comment against that line of code. Check to > see if you actually need it, and if you still do, see if there's a > change there. The module has been renamed (from __builtin__ to > builtins, although the global reference to it is still __builtins__), > so you may need to adjust something there, too. But mainly, see if you > can drop that line of code in Py3. > >> Furthermore I had to call the string runner with moduleDict both as >> global and local dictionary. With that change the virtual script is >> properly loaded and working as it should. > This part does make sense, though. Normally, module-level code runs > with the same locals and globals: > >>>> locals() is globals() > True > > And that doesn't change in Py3, so I would expect that your C++ code > also won't change. > > ChrisA I changed now a couple of things and it looks like the segfault happens somewhere inside PyErr_Print(). So I've programatically loaded a script into a new module using load_module and a module created by hand. If now in this script I've loaded an error is located the crash happens. The situation thus looks like this. Let's say Script.py is my script. The call chain would be something like this for example: someNativeClass.cpp : someFunction() Script.py : def run() main.cpp The error is due to a if( ! PyArg_ParseTuple( args, "iiii", &x1, &y1, &x2, &y2 ) ){ return NULL; } Thus the PyErr_Print() would have to print in the stack trace two C++ class, one in the someNativeClass and one generated for the loaded Script.py . It looks like Python 3 expects something from the C++ classes not written in the documentation. What could a C++ class require to be working being included in a stack trace like this? -- Yours sincerely Pl?ss Roland Leader and Head Programmer - Game: Epsylon ( http://www.indiedb.com/games/epsylon ) - Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine , http://dragengine.rptd.ch/wiki ) - Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php ) - As well as various Blender export scripts und game tools -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 246 bytes Desc: OpenPGP digital signature URL: From 2014 at jmunch.dk Tue Jul 8 15:25:44 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 21:25:44 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC4031.20408@jmunch.dk> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53BC4031.20408@jmunch.dk> Message-ID: <53BC45B8.9060007@jmunch.dk> I wrote: > Steven D'Aprano wrote: >> Oh, you've read the IEEE-754 standard, and that's what it says? "We're going >> to specify this behaviour for NANs just to annoy people" perhaps? > I was referring to the deliberate choice to enforce IEEE-754 rules in Python. > There is no force of law that requires Python to do so. > And just to be clear, I didn't mean python-dev did this to annoy people either. I just meant that the choice made is not supported by any use case, so there's no upside to outweigh the problems it creates. At least I've yet to hear any use case. So far I'm 0 beers in debt. regards, Anders From ethan at stoneleaf.us Tue Jul 8 15:16:47 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 08 Jul 2014 12:16:47 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC40AF.50407@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BC2BA0.3050500@stoneleaf.us> <53BC40AF.50407@jmunch.dk> Message-ID: <53BC439F.7020502@stoneleaf.us> On 07/08/2014 12:04 PM, Anders J. Munch wrote: > Ethan Furman skrev: > >> What exception? Apparently your claims about NaN in Python are all wrong -- have you been using a custom interpreter? >> >>> float('inf') - float('inf') >> nan > > If you deliberately try to manufacture NaN's, you can. I never said otherwise. What you said is: "They just don't appear in normal computation, because the interpreter raises an exception instead." I just ran a calculation that created a NaN, the same as 4 - 3 creates a 1, and no exception was raised. Do you have an example where one is? -- ~Ethan~ From ian.g.kelly at gmail.com Tue Jul 8 15:50:06 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 13:50:06 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC439F.7020502@stoneleaf.us> References: <53BC05FB.4050707@jmunch.dk> <53BC2BA0.3050500@stoneleaf.us> <53BC40AF.50407@jmunch.dk> <53BC439F.7020502@stoneleaf.us> Message-ID: On Tue, Jul 8, 2014 at 1:16 PM, Ethan Furman wrote: > What you said is: "They just don't appear in normal computation, because the > > interpreter raises an exception instead." > > I just ran a calculation that created a NaN, the same as 4 - 3 creates a 1, > and no exception was raised. > > Do you have an example where one is? The math module functions raise exceptions instead of returning NaN. From ian.g.kelly at gmail.com Tue Jul 8 15:57:30 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 13:57:30 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC3E4E.3020707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 12:54 PM, Anders J. Munch <2014 at jmunch.dk> wrote: > > Ian Kelly wrote: >> >> As far as I know nothing changed between 2.4 and 2.7 in this regard. >> Python has always had NaN compare unequal to everything, per the >> standard. > > It might have been platform-specific in 2.4. I doubt it, but okay, which platform? >> Okay, here's your problem: there isn't just one binary representation >> for NaN. > > I'm fully aware of that. Whether NaN's are one equivalence class or several > is not the issue. What matters is the integrity of the equivalence relation. I have some bad news for you. This is on Python 2.7.6: >>> from decimal import Decimal >>> from fractions import Fraction >>> Decimal(2) == 2 True >>> 2 == Fraction(2) True >>> Decimal(2) == Fraction(2) False I'm not sure exactly when this bug was fixed, but it works as expected in 3.4.0. >> Following the standard isn't a good reason itself? > > If a standard tells you to jump of a cliff... So I don't know of a good use case for nan != nan in Python (but really I'm not the one to ask), but I do know of use cases in other scenarios. On platforms that don't provide an isnan() function, the only convenient and efficient way to test for nan is by testing reflexivity: x != x. Following the standard means that any algorithm that uses this trick can (in theory) be implemented in Python without changes. From ethan at stoneleaf.us Tue Jul 8 16:03:08 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 08 Jul 2014 13:03:08 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BC2BA0.3050500@stoneleaf.us> <53BC40AF.50407@jmunch.dk> <53BC439F.7020502@stoneleaf.us> Message-ID: <53BC4E7C.7050107@stoneleaf.us> On 07/08/2014 12:50 PM, Ian Kelly wrote: > On Tue, Jul 8, 2014 at 1:16 PM, Ethan Furman wrote: >> What you said is: "They just don't appear in normal computation, because the >> >> interpreter raises an exception instead." >> >> I just ran a calculation that created a NaN, the same as 4 - 3 creates a 1, >> and no exception was raised. >> >> Do you have an example where one is? > > The math module functions raise exceptions instead of returning NaN. Ah, so if actual numbers go in, either actual numbers come out or an exception is raised -- good to know, and thanks for clarifying. -- ~Ethan~ From 2014 at jmunch.dk Tue Jul 8 16:10:59 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 08 Jul 2014 22:10:59 +0200 Subject: [Python-Dev] == on object tests identity in 3.x In-Reply-To: <20140708165745.GJ13014@ando> References: <53BB2AC7.2060009@gmx.de> <53BB2F25.3020205@gmx.de> <53BB5082.500@btinternet.com> <20140708031202.GF13014@ando> <53BB6D5F.1010800@btinternet.com> <87a98ktjv7.fsf@uwakimon.sk.tsukuba.ac.jp> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> Message-ID: <53BC5053.1010904@jmunch.dk> Steven D'Aprano wrote: > - Dropping reflexivity preserves the useful property that NANs compare > unequal to everything. Please present an example from real life where that turned out useful, and earn yourself a beer! I've only experienced examples to the contrary. > - Keeping reflexivity for NANs would have implied some pretty nasty > things, e.g. if log(-3) == log(-5), then -3 == -5. >>> log(-3) Traceback (most recent call last): File "", line 1, in ValueError: math domain error You were perhaps referring to the log functions in C and Fortran, not math.log? The tradeoffs are different in those languages, so choices the IEEE-754 committee made with C and Fortran in mind may be less relevant for Python. regards, Anders From ian.g.kelly at gmail.com Tue Jul 8 17:53:04 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 15:53:04 -0600 Subject: [Python-Dev] == on object tests identity in 3.x In-Reply-To: <53BC5053.1010904@jmunch.dk> References: <53BB2AC7.2060009@gmx.de> <53BB2F25.3020205@gmx.de> <53BB5082.500@btinternet.com> <20140708031202.GF13014@ando> <53BB6D5F.1010800@btinternet.com> <87a98ktjv7.fsf@uwakimon.sk.tsukuba.ac.jp> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> <53BC5053.1010904@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2014 at jmunch.dk> wrote: > Steven D'Aprano wrote: >> - Keeping reflexivity for NANs would have implied some pretty nasty >> things, e.g. if log(-3) == log(-5), then -3 == -5. > > >>>> log(-3) > Traceback (most recent call last): > File "", line 1, in > ValueError: math domain error > > You were perhaps referring to the log functions in C and Fortran, not > math.log? > The tradeoffs are different in those languages, so choices the IEEE-754 > committee made with C and Fortran in mind may be less relevant for Python. >>> import ctypes >>> libm = ctypes.cdll.LoadLibrary("libm.so.6") >>> log = libm.log >>> log.argtypes = [ctypes.c_double] >>> log.restype = ctypes.c_double >>> log(-3) nan >>> log(-5) nan >>> log(-3) == log(-5) False From ethan at stoneleaf.us Tue Jul 8 18:03:26 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 08 Jul 2014 15:03:26 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC3E4E.3020707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> Message-ID: <53BC6AAE.9020306@stoneleaf.us> On 07/08/2014 11:54 AM, Anders J. Munch wrote: > > If a standard tells you to jump of a cliff... because a bunch of tanks are chasing you down, there's water at the bottom, and not a helicopter in sight... well, jumping off the cliff could easily be your best chance. ;) -- ~Ethan~ From ian.g.kelly at gmail.com Tue Jul 8 18:05:45 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 16:05:45 -0600 Subject: [Python-Dev] == on object tests identity in 3.x In-Reply-To: References: <53BB2AC7.2060009@gmx.de> <53BB2F25.3020205@gmx.de> <53BB5082.500@btinternet.com> <20140708031202.GF13014@ando> <53BB6D5F.1010800@btinternet.com> <87a98ktjv7.fsf@uwakimon.sk.tsukuba.ac.jp> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> <53BC5053.1010904@jmunch.dk> Message-ID: On Tue, Jul 8, 2014 at 3:53 PM, Ian Kelly wrote: > On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2014 at jmunch.dk> wrote: >> Steven D'Aprano wrote: >>> - Keeping reflexivity for NANs would have implied some pretty nasty >>> things, e.g. if log(-3) == log(-5), then -3 == -5. >> >> >>>>> log(-3) >> Traceback (most recent call last): >> File "", line 1, in >> ValueError: math domain error >> >> You were perhaps referring to the log functions in C and Fortran, not >> math.log? >> The tradeoffs are different in those languages, so choices the IEEE-754 >> committee made with C and Fortran in mind may be less relevant for Python. > >>>> import ctypes >>>> libm = ctypes.cdll.LoadLibrary("libm.so.6") >>>> log = libm.log >>>> log.argtypes = [ctypes.c_double] >>>> log.restype = ctypes.c_double >>>> log(-3) > nan >>>> log(-5) > nan >>>> log(-3) == log(-5) > False Also, numpy provides more control over floating-point error handling than straight Python does, and I think (but can't presently test) that numpy.log(-3) will return nan by default. From ian.g.kelly at gmail.com Tue Jul 8 18:07:07 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 8 Jul 2014 16:07:07 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC6AAE.9020306@stoneleaf.us> References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> <53BC6AAE.9020306@stoneleaf.us> Message-ID: On Tue, Jul 8, 2014 at 4:03 PM, Ethan Furman wrote: > On 07/08/2014 11:54 AM, Anders J. Munch wrote: >> >> >> If a standard tells you to jump of a cliff... > > > because a bunch of tanks are chasing you down, there's water at the bottom, > and not a helicopter in sight... > > well, jumping off the cliff could easily be your best chance. ;) Especially if you have a friend with a TARDIS. From breamoreboy at yahoo.co.uk Tue Jul 8 19:21:22 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 09 Jul 2014 00:21:22 +0100 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> <53BC6AAE.9020306@stoneleaf.us> Message-ID: On 08/07/2014 23:07, Ian Kelly wrote: > On Tue, Jul 8, 2014 at 4:03 PM, Ethan Furman wrote: >> On 07/08/2014 11:54 AM, Anders J. Munch wrote: >>> >>> >>> If a standard tells you to jump of a cliff... >> >> >> because a bunch of tanks are chasing you down, there's water at the bottom, >> and not a helicopter in sight... >> >> well, jumping off the cliff could easily be your best chance. ;) > > Especially if you have a friend with a TARDIS. > This can lead to unforeseen circumstances though http://en.wikipedia.org/wiki/The_Flipside_of_Dominick_Hide -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ethan at stoneleaf.us Tue Jul 8 18:45:02 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Tue, 08 Jul 2014 15:45:02 -0700 Subject: PyPy-STM: first "interesting" release In-Reply-To: <53bbb41b$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53bbb41b$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <53BC746E.4090406@stoneleaf.us> On 07/08/2014 02:04 AM, Steven D'Aprano wrote: > On Tue, 08 Jul 2014 09:48:08 +0100, Mark Lawrence wrote: > >> A GIL-less Python? See >> http://morepypy.blogspot.co.uk/2014/07/pypy-stm-first-interesting- > release.html > > > Both Jython and IronPython are GIL-less, and have been forever. Yeah, but one requires Java, and the other .NET. :/ -- ~Ethan~ From ben at benfinney.id.au Tue Jul 8 19:59:22 2014 From: ben at benfinney.id.au (Ben Finney) Date: Wed, 09 Jul 2014 09:59:22 +1000 Subject: Naming conventions for functions and methods References: <1404831558.6942.139345801.530E4959@webmail.messagingengine.com> Message-ID: <85k37nv1ut.fsf@benfinney.id.au> python at bdurham.com writes: > Looking for your opinions on how you name your functions and > methods. Example: I have a function that hashes a file. I could > name this function hash_file() or file_hash(). I'd prefer just ?hash?. The function name can be considered an action verb, with its arguments as the objects acted upon. -- \ ?Nothing worth saying is inoffensive to everyone. Nothing worth | `\ saying will fail to make you enemies. And nothing worth saying | _o__) will not produce a confrontation.? ?Johann Hari, 2011 | Ben Finney From steve+comp.lang.python at pearwood.info Tue Jul 8 20:10:09 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 00:10:09 GMT Subject: NaN comparisons - Call For Anecdotes References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 21:02:09 +0200, Anders J. Munch wrote: > Steven D'Aprano wrote: >> Oh, you've read the IEEE-754 standard, and that's what it says? "We're >> going to specify this behaviour for NANs just to annoy people" perhaps? > I was referring to the deliberate choice to enforce IEEE-754 rules in > Python. There is no force of law that requires Python to do so. There's no force of law that requires Python to enforce reflexivity on values where reflexivity does not apply, any more than Python should enforce total order on values which aren't ordered (such as complex numbers, or sets). I'm sorry that you happened to (apparently) have a use-case where you simultaneously have to deal with NANs but not in a numeric context. But from the description of your problem, it seems to me that the obvious solution is not to deal with floats until as late as possible. That is, your current work-flow (if I have understood it correctly) is: * gather unpacked floats from some device, as ints * pack them into floats * process them in some way which requires reflexivity * (maybe) much later perform numeric calculations on them It seems to me that the trivial work-around is: * gather packed floats from some device, as ints * process them *as ints* in some way which requires reflexivity * unpack back into floats * (maybe) much later perform numeric calculations on them Although perhaps I don't understand your use-case. -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 8 21:00:08 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 01:00:08 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BC2BA0.3050500@stoneleaf.us> <53BC40AF.50407@jmunch.dk> <53BC439F.7020502@stoneleaf.us> Message-ID: <53bc9418$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 13:50:06 -0600, Ian Kelly wrote: > The math module functions raise exceptions instead of returning NaN. That's not the only way that NANs can be constructed. In particular, the OP is collecting NANs from some other device. I don't know how it ends up with NANs, but it does, so he has to deal with them. -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 8 21:04:12 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 01:04:12 GMT Subject: [Python-Dev] == on object tests identity in 3.x References: <53BB2AC7.2060009@gmx.de> <53BB2F25.3020205@gmx.de> <53BB5082.500@btinternet.com> <20140708031202.GF13014@ando> <53BB6D5F.1010800@btinternet.com> <87a98ktjv7.fsf@uwakimon.sk.tsukuba.ac.jp> <8761j8thf5.fsf@uwakimon.sk.tsukuba.ac.jp> <20140708165745.GJ13014@ando> <53BC5053.1010904@jmunch.dk> Message-ID: <53bc950c$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 16:05:45 -0600, Ian Kelly wrote: > On Tue, Jul 8, 2014 at 3:53 PM, Ian Kelly wrote: >> On Tue, Jul 8, 2014 at 2:10 PM, Anders J. Munch <2014 at jmunch.dk> wrote: >>> Steven D'Aprano wrote: >>>> - Keeping reflexivity for NANs would have implied some pretty nasty >>>> things, e.g. if log(-3) == log(-5), then -3 == -5. >>> >>> >>>>>> log(-3) >>> Traceback (most recent call last): >>> File "", line 1, in >>> ValueError: math domain error >>> >>> You were perhaps referring to the log functions in C and Fortran, not >>> math.log? >>> The tradeoffs are different in those languages, so choices the >>> IEEE-754 committee made with C and Fortran in mind may be less >>> relevant for Python. >> >>>>> import ctypes >>>>> libm = ctypes.cdll.LoadLibrary("libm.so.6") log = libm.log >>>>> log.argtypes = [ctypes.c_double] >>>>> log.restype = ctypes.c_double >>>>> log(-3) >> nan >>>>> log(-5) >> nan >>>>> log(-3) == log(-5) >> False > > Also, numpy provides more control over floating-point error handling > than straight Python does, and I think (but can't presently test) that > numpy.log(-3) will return nan by default. Correct: py> numpy.log(-3) nan py> if numpy.log(-3) == numpy.log(-5): ... print "-3 == -5" ... py> -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 8 21:04:56 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 01:04:56 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> Message-ID: <53bc9537$0$29995$c3e8da3$5496439d@news.astraweb.com> On Tue, 08 Jul 2014 13:57:30 -0600, Ian Kelly wrote: >>>> Decimal(2) == Fraction(2) > False > > I'm not sure exactly when this bug was fixed, but it works as expected > in 3.4.0. It isn't a bug, it's a missing feature. The problem is that in Python 2.7, neither Decimal nor Fraction are aware of the other: py> Decimal(2).__eq__(Fraction(2)) NotImplemented py> Fraction(2).__eq__(Decimal(2)) NotImplemented The obvious, but wrong, solution is to coerce both into floats: py> a = Decimal("2.000000000000000000000000000001") py> b = Fraction(2) - Fraction(1, 2)**100 py> a > 2 > b # a and b are certainly not equal True py> float(a) == float(b) True Some time by Python 3.3, Decimal appears to have become aware of how to compare exactly with Fraction. -- Steven From roy at panix.com Tue Jul 8 21:05:12 2014 From: roy at panix.com (Roy Smith) Date: Tue, 08 Jul 2014 21:05:12 -0400 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> Message-ID: In article , Tim Chase wrote: > On 2014-07-09 01:24, Chris Angelico wrote: > > On Wed, Jul 9, 2014 at 1:20 AM, Tim Chase > > > Okay, EOF is the canonical way to tell a program reading stdin > > > that you're done. It just happens that EOF ^D on *nix-likes and > > > ^Z on Win32. :-) > > > > > > -tkc > > > > I can't think of any Windows-native programs that ask for EOF. Only > > those which came from POSIX platforms do it. That said, though, > > Windows doesn't tend to encourage interactive command-line programs > > at all, so you may as well just follow the Unix convention. > > There was a time in life where I used "copy con output.txt" on a > disturbingly frequent basis. Control+Z ended my file for me. > > -tkc I once knew a guy who linked /dev/tty.c to /dev/tty, then he could do "cc /dev/tty.c" and type a C program in to the compiler from the terminal. From drsalists at gmail.com Tue Jul 8 21:48:22 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Tue, 8 Jul 2014 18:48:22 -0700 Subject: Python top learning language In-Reply-To: <3409ed3b-2b4f-4199-b802-1f5f16faf681@googlegroups.com> References: <3409ed3b-2b4f-4199-b802-1f5f16faf681@googlegroups.com> Message-ID: On Tue, Jul 8, 2014 at 12:19 PM, candide wrote: > http://www.infoworld.com/d/application-development/python-bumps-java-top-learning-language-245774 As a sort of nano-celebration, here's a blast from Python's past (May, 1997): https://web.archive.org/web/19970501011626/http://www.python.org/ From ben at benfinney.id.au Tue Jul 8 22:41:07 2014 From: ben at benfinney.id.au (Ben Finney) Date: Wed, 09 Jul 2014 12:41:07 +1000 Subject: PEP8 and 4 spaces References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <8561j7uud8.fsf@benfinney.id.au> Steven D'Aprano writes: > On Tue, 08 Jul 2014 11:22:25 +1000, Ben Finney wrote: > > > A group of (a particular amount of) U+0020 characters is visually > > indistinguishable from a U+0009 character, when the default semantics > > are applied to each. > > Hmmm. I'm not sure there actually *is* such a thing as "default > semantics" for tabs. It was likely never standardised, but yes, default semantics are long established for the HT (Horizontal Tab) control code in a text stream . The default semantics are that an HT (Horizontal Tabulation) control code is an instruction to introduce enough horizontal space such that the following character appears at the next multiple-of-8 column. These semantics assume a fixed character width, which is itself a default semantic of the display of computer text; variable-width is a deviation from the default. > If you look at a tab character in a font I'm not talking about glyphs (for a control code, there isn't much sense talking about a default glyph), I'm talking about the default semantics of how they affect display. > But if you look at it in a text editor, it will probably look like > eight spaces, unless it looks like four, or some other number, and if > you look at it in a word processor, it will probably look like a "jump > to the next tab stop" command. Right. Programs that conform to the established default semantics for an HT (U+0009) code point will shift to the next tab stop to display the following character. Tab stops themselves are, in fixed-width character layout (which is itself the historical default), spaced apart by multiples of 8 character columns. > I don't think any of those things count as "default semantics". I hope my position is clearer. > The point being, tabs are *control characters*, like newlines and > carriage returns and form feeds, not regular characters like spaces > and "A" or "?". Since "indent" is an *instruction* rather than a > character, it is best handled with a control character. Right. And those control codes affect display of the text, and there are default semantics for those codes: what those control codes specifically mean. The HT code has the default display semantic of ?display the following character at the next horizontal tab stop?. > The solution is to use a smarter editor. The recipient's choice of editor program is not within the control of the author. Furthermore, it's expecting that the recipient will deviate from the default display semantics of the text as received. The author should write the text such that the default semantics are useful, and/or avoid text where the default semantics are undesirable or unreliably implemented. In this case: If the programmer doesn't like U+0009 resulting in text aligned at multiple-of-8 tab stops, or doesn't like the fact that recipients may have tab stops set differently, then I don't care what editor the author uses; they should avoid putting U+0009 into text. That said, a smarter text editor program *can* be a solution for ?I don't like the default semantics *as displayed on my computer*?. If a programmer wants to deviate from the defaults, and can convince others on a rational and non-coercive basis to go along with their non-default preferences, they all have my blessing. If they want their preferences to override the default more broadly, they need a better argument than ?it just looks better to me?. > Isn't this why you recommend people use a programmer's editor rather > than Notepad? I don't see how recommending a better editor for the *author* addresses how the *recipient*'s device renders the text. so no, that's not a reason why I recommend the author use a programmer's editor. > True, but that's *only* because your editor chooses to follow the > convention "display a LINE FEED by starting a new line" rather than by > the convention "display the (invisible or zero-width) glyph of the > LINE FEED". If editors were to standardise on the convention "display > a HORIZONTAL TAB character as visibly distinct from a sequence of > spaces" (e.g. by shading the background a different colour, or > overlying it with an arrow) then we would not be having this > discussion. If things were different, they'd be different. I'm talking about default display semantics of the U+0009 code as they are. -- \ ?I used to be an airline pilot. I got fired because I kept | `\ locking the keys in the plane. They caught me on an 80 foot | _o__) stepladder with a coathanger.? ?Steven Wright | Ben Finney From steve at pearwood.info Wed Jul 9 00:01:20 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 04:01:20 GMT Subject: [OT] Grandma, is that you? [was Re: NaN comparisons - Call For Anecdotes] References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> <53BC6AAE.9020306@stoneleaf.us> Message-ID: <53bcbe90$0$2746$c3e8da3$76491128@news.astraweb.com> On Wed, 09 Jul 2014 00:21:22 +0100, Mark Lawrence wrote: > This can lead to unforeseen circumstances though > http://en.wikipedia.org/wiki/The_Flipside_of_Dominick_Hide I prefer this one: http://en.wikipedia.org/wiki/Roswell_That_Ends_Well From tjreedy at udel.edu Wed Jul 9 00:57:03 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 09 Jul 2014 00:57:03 -0400 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/8/2014 8:10 PM, Steven D'Aprano wrote: > There's no force of law that requires Python to enforce reflexivity on > values where reflexivity does not apply, There are laws of logic that make the lack of reflexivity obnoxious when putting objects in collections. Python evaded the problem, at least for some builtins, by contradicting itself and treating nans as equal to themselves in the context of collections. In 2.x, 'in' was defined in terms of ==, but >>> nan=float('nan') >>> nl = [nan] >>> nan in nl True even though nan != the only member of nl. In 3.x, 'in' was redefined to include 'is' as well as '=='. -- Terry Jan Reedy From greg.ewing at canterbury.ac.nz Wed Jul 9 01:27:11 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 09 Jul 2014 17:27:11 +1200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BC3E4E.3020707@jmunch.dk> <53BC6AAE.9020306@stoneleaf.us> Message-ID: Ian Kelly wrote: >>well, jumping off the cliff could easily be your best chance. ;) > > Especially if you have a friend with a TARDIS. Or you're James Bond, in which case you ski off the cliff and then open your parachute. -- Greg From dieter at handshake.de Wed Jul 9 01:41:05 2014 From: dieter at handshake.de (dieter) Date: Wed, 09 Jul 2014 07:41:05 +0200 Subject: generic _ssl error References: <53BBCA5E.8030709@chamonix.reportlab.co.uk> Message-ID: <87ha2rxf66.fsf@handshake.de> Robin Becker writes: > I have the following from some production machines when trying to > clone / pull etc etc using mercurial on ubuntu 10.04 > > hg clone https://myhost/myrepos > abort: error: _ssl.c:480: error:0D0C50A1:asn1 encoding > routines:ASN1_item_verify:unknown message digest algorithm > > I believe that _ssl.c must be the _ssl.so module which presumably is > being used by the hg command. > > The system python which mercurial uses is > > Python 2.7.2 (default, Sep 20 2011, 16:38:53) > > Could this error be the result of upgrading the openssl to fix > heartbleed and not upgrading the system python? The error message tells you that a message digest algorithm is being used (liklely by the remote site) which is not supported locally. There is a big chance that this means that locally something (related with ssl/message digests - i.e. likely "OpenSSL") is too old. I would try to upgrade the "OpenSSL" installation -- and then see whether the problem goes away. From steve at pearwood.info Wed Jul 9 02:43:15 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 06:43:15 GMT Subject: NaN comparisons - Call For Anecdotes References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53bce483$0$2746$c3e8da3$76491128@news.astraweb.com> On Wed, 09 Jul 2014 00:57:03 -0400, Terry Reedy wrote: > On 7/8/2014 8:10 PM, Steven D'Aprano wrote: > >> There's no force of law that requires Python to enforce reflexivity on >> values where reflexivity does not apply, > > There are laws of logic that make the lack of reflexivity obnoxious when > putting objects in collections. Floating point numbers are not real numbers and do not obey the laws of real arithmetic. Once you allow floats, or comparisons between arbitrary types, no matter what you do, something is going to break and somebody is going to be upset. > Python evaded the problem, at least for > some builtins, by contradicting itself and treating nans as equal to > themselves in the context of collections. It's not just NANs. It's any non-reflexive type: py> class AlwaysUnequal: ... def __eq__(self, other): return False ... py> x = AlwaysUnequal() py> x in [1, 2, x] True py> any(x == a for a in [1, 2, x]) False > In 2.x, 'in' was defined in terms of ==, but > >>> nan=float('nan') > >>> nl = [nan] > >>> nan in nl > True > even though nan != the only member of nl. > > In 3.x, 'in' was redefined to include 'is' as well as '=='. I don't understand this. You've just shown an example from Python 2 where 'in' uses 'is'. How is that a Python 3 change? -- Steve From rosuav at gmail.com Wed Jul 9 02:52:32 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 16:52:32 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bce483$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bce483$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 4:43 PM, Steven D'Aprano wrote: > I don't understand this. You've just shown an example from Python 2 where > 'in' uses 'is'. How is that a Python 3 change? A docs change. https://docs.python.org/2/reference/expressions.html#not-in """ For the list and tuple types, x in y is true if and only if there exists an index i such that x == y[i] is true. """ https://docs.python.org/3/reference/expressions.html#not-in """ For container types such as list, tuple, set, frozenset, dict, or collections.deque, the expression x in y is equivalent to any(x is e or x == e for e in y). """ So the definition of the operator (as stated in the docs) has changed to match its behaviour. That's definitely a change; the Py2 behaviour is buggy according to its docs. Should the Py2 docs be updated to match the Py3 docs, or should it be left as a minor technical distinction that almost never is important? ChrisA From steve at pearwood.info Wed Jul 9 03:00:52 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 07:00:52 GMT Subject: Proposal: === and !=== operators Message-ID: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> At the moment, Python has two (in)equality operators, == and != which call __eq__ and __ne__ methods. Some problems with those: * Many people expect == to always be reflexive (that is, x == x for every x) but classes which customise __eq__ may not be. * The == operator requires __eq__ to return True or False (or NotImplemented) and raises TypeError if it doesn't, which makes it impossible to use == with (say) three-valued or fuzzy logic. I propose: * The == operator be redefined to *always* assume reflexivity, that is, it first compares the two arguments using `is` before calling the __eq__ methods. * That's a backwards-incompatible change, so you need to enable it using "from __future__ import equals" in Python 3.5, and then to become the default behaviour in 3.6. * To support non-reflexive types, allow === and !=== operators, which are like == and != except they don't call `is` first. * The new === and !== operators call __eeq__ and __ene__ (extended equal and extended not equal) methods; if they don't exist, they fall back on __eq__ and __ne__. * To support multi-valued logics, === and !== are not required to return True or False, they can return anything you like and it is up to the caller to ensure that they are sensible. * Returning NotImplemented from __eeq__ and __ene__ has the same meaning as for __eq__ and __ne__. * For the avoidance of doubt, `if...elif...else` are not expected to be aware of multi-valued logics. No other changes to the language are expected. Thoughts? Comments? -- Steven From fk26541598fk at gmail.com Wed Jul 9 03:14:56 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 9 Jul 2014 00:14:56 -0700 (PDT) Subject: same code same tables but not the same result(use flask and postgres) Message-ID: i use flask connect to postgres def post_insert(username): conn = engine.connect() encoded = base64.b64encode(username.encode('utf-8')) puresql = sqla.text("INSERT INTO friends(name) VALUES(:encoded)") conn.execute(puresql,encoded = encoded) i insert username encode with base64 to my database but one i got MTIzNDU2Nzg= <==it's right anoter i got \x4d54497a4e4455324e7a673d i change database to another database but tables is use same code to create what 's wrong?? From rosuav at gmail.com Wed Jul 9 03:21:20 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 17:21:20 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 5:00 PM, Steven D'Aprano wrote: > Thoughts? Comments? First thought: It will just add confusion. Currently, there are small pockets of confusion surrounding the few cases where something's non-reflexive, and there are occasional threads on the subject, like we have now. Adding another pair of equality operators will mean that everyone has to think "Do I want == or ===?", and we just need to look at PHP and ECMAScript to see what happens - people pick the wrong operator and have no end of subtle problems. There will be blog posts around saying "always use === in Python", or "never use === in Python", and everyone will get confused about how Python's === is similar to and/or different from ECMAScript's and/or PHP's, and ultimately, the only people who win out will be those who get paid to write blog posts. I think this is a big fat YAGNI. The two operators will differ in so few situations that you may as well just define a few cases as "x is y or x == y" instead of creating thew new operator; because really, that's all that's happening here. (And the Py3 docs now use that kind of notation to describe 'in'.) If you want fuzzy logic or three-valued truth or anything, you probably know the types of the things you're comparing, so it should be safe to use a method. ChrisA From rosuav at gmail.com Wed Jul 9 03:22:58 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 17:22:58 +1000 Subject: same code same tables but not the same result(use flask and postgres) In-Reply-To: References: Message-ID: On Wed, Jul 9, 2014 at 5:14 PM, Frank Liou wrote: > one i got > > MTIzNDU2Nzg= <==it's right > > anoter i got > > \x4d54497a4e4455324e7a673d Encode that string as ASCII and represent the bytes in hexadecimal, and you get the second one. My guess is that maybe you have one of them running Python 2 and one running Python 3. ChrisA From mmanns at gmx.net Tue Jul 8 20:53:41 2014 From: mmanns at gmx.net (Martin Manns) Date: Wed, 9 Jul 2014 02:53:41 +0200 Subject: [ANN] pyspread 0.3.0 Message-ID: ============== pyspread 0.3.0 ============== Pyspread 0.3.0 is released. This update is the first release that runs with wxPython 3.x. About pyspread ============== Pyspread is a non-traditional spreadsheet application that is based on and written in the programming language Python. The goal of pyspread is to be the most pythonic spreadsheet application. Pyspread is free software. It is released under the GPL v3. Project website: http://manns.github.com/pyspread/ Download page: https://pypi.python.org/pypi/pyspread What is new in 0.3.0 ==================== + wxPython 3.x support + Entryline code completion (use ) + EntryLine tooltip now displays docstrings for methods and builtins (use ) + nn function added to remove None from result array + Uncompressed pysu save file format + Writing xls files (still experimental) + Cell locking + Cell sorting + Frozen cells can now be updated periodically (>=100 ms/update) + Reference to a selection can now be copied the the clipboard with + + R now moves the active cell to the first column of + the actual row + now selects the current row + + now selects the current column + Fingerprint in gpg key choice dialog + Tooltips for toolbar icons Known issues ============ + Selection mode is disabled in Windows. + Sometimes, pressing redo when there is nothing left to redo has undesired effects such as redoing an operation again. + On some (not all) Windows system lockup prevention does not work Martin From fk26541598fk at gmail.com Wed Jul 9 03:25:37 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 9 Jul 2014 00:25:37 -0700 (PDT) Subject: same code same tables but not the same result(use flask and postgres) In-Reply-To: References: Message-ID: Hi ChrisA i use same workspace all the same python 3.3 From info at egenix.com Wed Jul 9 03:40:56 2014 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Wed, 09 Jul 2014 09:40:56 +0200 Subject: ANN: eGenix mxODBC 3.3.1 - Python ODBC Database Interface Message-ID: <53BCF208.3050808@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mxODBC Python ODBC Database Interface Version 3.3.1 mxODBC is our commercially supported Python extension providing ODBC database connectivity to Python applications on Windows, Mac OS X, Unix and BSD platforms This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mxODBC-3.3.1-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: http://www.egenix.com/products/python/mxODBC/ The "eGenix mxODBC - Python ODBC Database Interface" product is a commercial extension to our open-source eGenix mx Base Distribution: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ NEWS The 3.3.1 release of our mxODBC is a patch level release of our popular Python ODBC Interface for Windows, Linux, Mac OS X and FreeBSD. It includes these enhancements and fixes: Installation Enhancements ------------------------- * Added web installer package to the Python Package Index (PyPI) which simplifies installation. In addition to the usual ways of installing mxODBC, we have uploaded a web installer to PyPI, so that it is now also possible to use one of these installation methods on all supported platforms (Windows, Linux, FreeBSD, Mac OS X): - easy_install egenix-mxodbc via PyPI - pip install egenix-mxodbc via PyPI - egg reference in zc.buildout via PyPI - running "python setup.py install" in the unzipped web installer archive directory The web installer will automatically detect the platform and choose the right binary download package for you. All downloads are verified before installation. Driver Compatibility -------------------- SQL Server * Fixed a problem with custom errorhandlers set at connection time, which could result in warnings not being ignored during connect. SQL Server raises such warnings during connect, so this fix will restore mxODBC 3.2 behavior for SQL Server. * Documented a solution for a problem with the SQL Server 2012 parser complaining about not being able to deduce types of some operations using more than one bound variable, e.g. "col1 >= ? + ?". Teradata * Improved the Teradata ODBC driver setup instructions to address some common gotchas when setting up mxODBC to work with these drivers. * Fixed a problem with Teradata and the test suite which resulted in an error "[Teradata][ODBC Teradata Driver] Beyond SQL_ACTIVE_STATEMENTS limit". The driver needs an explicit call to cursor.flush() to close any open result sets before running commits or rollbacks. Misc ---- * Fixed a problem in cursor.getcolattributes() that caused errors to be ignored. * Added better protection against ODBC driver bugs in getenvattr(). * Fixed an attribute error when using the NamespaceRowFactory function. * Fixed a deprecation warning when using the NamespaceRowFactory function. * Prepared mxODBC for two digit Python patch level numbers, ie. 2.7.10. * Fixed prebuilt archives to also work correctly with easy_install. * Added dependency on egenix-mx-base, so that easy_install and pip automatically install the mx Base package as well. For the full set of changes please check the mxODBC change log: http://www.egenix.com/products/python/mxODBC/changelog.html ________________________________________________________________________ FEATURES mxODBC 3.3 was released on 2014-04-08. Please see the full announcement for highlights of the 3.3 release: http://www.egenix.com/company/news/eGenix-mxODBC-3.3.0-GA.html For the full set of features mxODBC has to offer, please see: http://www.egenix.com/products/python/mxODBC/#Features ________________________________________________________________________ EDITIONS mxODBC is available in these two editions: * The Professional Edition, which gives full access to all mxODBC features. * The Product Development Edition, which allows including mxODBC in applications you develop. For a complete overview of the available editions, please see the product page: http://www.egenix.com/products/python/mxODBC/#mxODBCEditions ________________________________________________________________________ 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 Users are encouraged to upgrade to this latest mxODBC release to benefit from the new features and updated ODBC driver support. We have taken special care not to introduce backwards incompatible changes, making the upgrade experience as smooth as possible. Customers who have purchased mxODBC 3.3 licenses can continue to use their licenses with this patch level release. For upgrade purchases, we will give out 20% discount coupons going from mxODBC 2.x to 3.3 and 50% coupons for upgrades from mxODBC 3.x to 3.3. Please contact the eGenix.com Sales Team with your existing license serials for details for an upgrade discount coupon. If you want to try the new release before purchase, you can request 30-day evaluation licenses by visiting our web-site 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. _______________________________________________________________________ INFORMATION 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. PS: If you want to meet with eGenix at EuroPython 2014, please send an email and we can arrange a meeting. Enjoy, -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 09 2014) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2014-07-21: EuroPython 2014, Berlin, Germany ... 12 days to go ::::: Try our 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 fk26541598fk at gmail.com Wed Jul 9 03:46:34 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 9 Jul 2014 00:46:34 -0700 (PDT) Subject: same code same tables but not the same result(use flask and postgres) In-Reply-To: References: Message-ID: <71a5e1d9-578f-47f6-a618-93ec50d36888@googlegroups.com> oh by the way one of database version is postgres 80420 another is 90304 80420 is fine but 90304 is so strange From cs at zip.com.au Wed Jul 9 04:17:23 2014 From: cs at zip.com.au (Cameron Simpson) Date: Wed, 9 Jul 2014 18:17:23 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <20140709081723.GA90432@cskk.homeip.net> On 09Jul2014 07:00, Steven D'Aprano wrote: >At the moment, Python has two (in)equality operators, == and != which >call __eq__ and __ne__ methods. Some problems with those: > >* Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__ may not be. I'm presuming this proposal is fallout from the Nan anecdotes, since NaN != Nan? The language spec is at least up front about it, I thought. It could be plainer, but at least it says: Furthermore, some types (for example, function objects) support only a degenerate notion of comparison where any two objects of that type are unequal. which implies nonreflexivity. Returning to Nan, I had thought it was an explicit design choice in IEEE floating point that NaN != NaN so that in (hypothetically) common cases results won't accidentally issue truthiness in the vein of propagating evaluation errors. Personally I'd go for Nan == Nan raising a ValueError myself, but that is a bikeshed I lack the expertise to paint. Anyway, I thought it is a design feature that a class can arrange for nonreflexivity in ==. Surprising, maybe, but wouldn't use of such a special class be known to the user? Have we got some examples of people using nonreflexive == classes and being burnt? Aside from Nan, which I'd argue is a well known special case, or should be. >* The == operator requires __eq__ to return True or False > (or NotImplemented) and raises TypeError if it doesn't, which > makes it impossible to use == with (say) three-valued or fuzzy > logic. In the Python 3.4.0 docs the __eq__ etc methods have this paragraph: A rich comparison method may return the singleton NotImplemented if it does not implement the operation for a given pair of arguments. By convention, False and True are returned for a successful comparison. However, these methods can return any value, so if the comparison operator is used in a Boolean context (e.g., in the condition of an if statement), Python will call bool() on the value to determine if the result is true or false. and some tests with 2.7.8 and 3.4.1: % python Python 2.7.8 (default, Jul 3 2014, 06:13:58) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class O(object): ... def __eq__(self, other): return 9 ... >>> o=O() >>> o == o 9 % python3.4 Python 3.4.1 (default, May 21 2014, 01:39:38) [GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> class O(object): ... def __eq__(self, other): return 9 ... >>> o=O() >>> o == o 9 I don't see this type constraint you describe. >I propose: > >* The == operator be redefined to *always* assume reflexivity, that > is, it first compares the two arguments using `is` before calling > the __eq__ methods. Won't this slow down every == test? >* That's a backwards-incompatible change, so you need to enable it > using "from __future__ import equals" in Python 3.5, and then to > become the default behaviour in 3.6. > >* To support non-reflexive types, allow === and !=== operators, which > are like == and != except they don't call `is` first. [...] I don't like the spelling. They seem very easy to misuse as typos of conventional == and !=, and not visually very different. Cheers, Cameron Simpson 55 mph is fast enough to get you killed, but slow enough to make you think you're safe. - The Gumball Rally From wxjmfauth at gmail.com Wed Jul 9 04:19:00 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Wed, 9 Jul 2014 01:19:00 -0700 (PDT) Subject: PEP8 and 4 spaces In-Reply-To: References: <53B59358.2040404@tobiah.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: <22ad932d-ad24-4284-afb9-9d43b8e84df6@googlegroups.com> I'm neutral, I do not wish to convince anybody, I'm reacting like a normal user and on top of this I wrote interactive intepreters (gui). My conclusion: "tabs" everywhere: simple, practical, perfect look and it is always working (I never meet a case, where tab may be a problem). Ditto with all the editors I'm using. From steve at pearwood.info Wed Jul 9 05:02:55 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 09:02:55 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53bd053e$0$2746$c3e8da3$76491128@news.astraweb.com> On Wed, 09 Jul 2014 18:17:23 +1000, Cameron Simpson wrote: > On 09Jul2014 07:00, Steven D'Aprano wrote: >>At the moment, Python has two (in)equality operators, == and != which >>call __eq__ and __ne__ methods. Some problems with those: >> >>* Many people expect == to always be reflexive (that is, x == x for >> every x) but classes which customise __eq__ may not be. > > I'm presuming this proposal is fallout from the Nan anecdotes, since NaN > != Nan? There is *yet another* bloody argument going on about NANs on Python-Dev, from people who (for the most part) don't do numeric programming but feel sure that they know better than William Kahan and the IEEE-754 committee that designed it :-( > The language spec is at least up front about it, I thought. It could be > plainer, but at least it says: > > Furthermore, some types (for example, function objects) support only > a degenerate notion of comparison where any two objects of that type > are unequal. > > which implies nonreflexivity. Functions inherit the default behaviour of __eq__ from object, which falls back on identity: py> def f(): return 1 ... py> f == f True > Returning to Nan, I had thought it was an explicit design choice in IEEE > floating point that NaN != NaN so that in (hypothetically) common cases > results won't accidentally issue truthiness in the vein of propagating > evaluation errors. There are various reasons for why the NANs always compare unordered (including unequal), but yes it is a deliberate decision. Unfortunately people who aren't doing numeric work (and a few who are) don't like it, and don't like that it breaks certain "common sense" > > Personally I'd go for Nan == Nan raising a ValueError myself, but that > is a bikeshed I lack the expertise to paint. If we can do other nonsensical comparisons and get False, why treat NANs differently? py> "Hello World" == {2.5: None} False For what it's worth, the IEEE-754 standard supports the "exception on comparison" model with signalling NANs, unfortunately C99 does not support signalling NANs and Java explicitly forbids them. > Anyway, I thought it is a design feature that a class can arrange for > nonreflexivity in ==. Surprising, maybe, but wouldn't use of such a > special class be known to the user? Well yes, but then you have folks like Anders ("NaN comparisons - Call For Anecdotes" thread) who didn't know that floats are not reflexive (as well as not transitive, associative, or commutative). He's hardly the only one -- Stackoverflow appears to get a question asking about NANs about three times a week. More broadly, if you're writing a generic library which will be used with arbitrary objects, there are very few assumptions you can make about them -- nevertheless people do. > Have we got some examples of people using nonreflexive == classes and > being burnt? Aside from Nan, which I'd argue is a well known special > case, or should be. Yes it should be, and no I don't, but people are *extremely* vehement that x == x ought to return True for any x. In my opinion, reflexivity is not that important outside of pure mathematics and logic, and people only get upset about the lack of it because it goes against their intuition about what it means for two things to be equal. But other clever people disagree, and even though they're wrong *wink* I'd rather seek a compromise that gives everybody what they want. >>* The == operator requires __eq__ to return True or False >> (or NotImplemented) and raises TypeError if it doesn't, which makes it >> impossible to use == with (say) three-valued or fuzzy logic. Hmmm... I could have sworn that == raised an exception if __eq__ returned something other than True/False/NotImplemented, but apparently I was wrong. Maybe I dreamt it. > I don't see this type constraint you describe. Neither do I. >>I propose: >> >>* The == operator be redefined to *always* assume reflexivity, that >> is, it first compares the two arguments using `is` before calling the >> __eq__ methods. > > Won't this slow down every == test? Only by a pointer comparison, which is very fast. Compared to the cost of looking up __eq__ and calling it, the extra cost will be insignificant, and since many objects (small ints, certain strings, etc.) are cached, the over-all result will probably be to speed up the average == test. >>* That's a backwards-incompatible change, so you need to enable it >> using "from __future__ import equals" in Python 3.5, and then to >> become the default behaviour in 3.6. >> >>* To support non-reflexive types, allow === and !=== operators, which >> are like == and != except they don't call `is` first. > [...] > > I don't like the spelling. They seem very easy to misuse as typos of > conventional == and !=, and not visually very different. If you can tell the difference between x=y and x==y you should be able to also distinguish x===y. But I accept that it's a little sub-optimal. -- Steven From steve at pearwood.info Wed Jul 9 05:17:40 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 09:17:40 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> On Wed, 09 Jul 2014 17:21:20 +1000, Chris Angelico wrote: > On Wed, Jul 9, 2014 at 5:00 PM, Steven D'Aprano > wrote: >> Thoughts? Comments? > > First thought: It will just add confusion. Currently, there are small > pockets of confusion surrounding the few cases where something's > non-reflexive, and there are occasional threads on the subject, like we > have now. It's a reoccurring issue that keeps coming up over and over again. Most people have no need of NANs, and want them to behave like "normal" objects. I'm sympathetic to this idea. Whenever this comes up, no-one has suggested any non-reflexive values other than NANs, SQL NUL, and "Always Compares Unequal", which I suspect is more of a toy than an actual useful example. So there are *very, very* few people who actually need NANs. (But those who do ought to be able to easily get it.) > Adding another pair of equality operators will mean that > everyone has to think "Do I want == or ===?", I don't think so. Nearly everyone will just use ==, those who want === will know they need it. > and we just need to look > at PHP and ECMAScript to see what happens - people pick the wrong > operator and have no end of subtle problems. People are already having problems, just listen to Anders. He's (apparently) not doing NAN-aware computations on his data, he just wants to be able to do something like this_list_of_floats == that_list_of_floats without NANs screwing it up. But by the same token, if I want to use NANs the way they're supposed to be used, I should still be able to use an equals operator (rather than a function or method). > There will be blog posts > around saying "always use === in Python", or "never use === in Python", I doubt that this would even come into the radar of most bloggers. > and everyone will get confused about how Python's === is similar to > and/or different from ECMAScript's and/or PHP's, Like we get confused over how == is different from Javascript's and PHP's? :-) > and ultimately, the > only people who win out will be those who get paid to write blog posts. > > I think this is a big fat YAGNI. The two operators will differ in so few > situations that you may as well just define a few cases as "x is y or x > == y" instead of creating thew new operator; But the problem is, most people will need to us "x is y or x == y" nearly everywhere! And that doesn't help with containers: py> alist = [1.0, 2, float('NAN'), 4] py> blist = [1, 2.0, float('nan'), 4] py> alist is blist or alist == blist False There ought to be a simple way for people to get alist == blist, while still allowing IEEE-754 aware code to work. > because really, that's all > that's happening here. (And the Py3 docs now use that kind of notation > to describe 'in'.) If you want fuzzy logic or three-valued truth or > anything, you probably know the types of the things you're comparing, so > it should be safe to use a method. Ah, forget the fuzzy logic, I was dreaming. -- Steven From rosuav at gmail.com Wed Jul 9 05:23:48 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 9 Jul 2014 19:23:48 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53bd053e$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd053e$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 7:02 PM, Steven D'Aprano wrote: > If you can tell the difference between x=y and x==y you should be able to > also distinguish x===y. But I accept that it's a little sub-optimal. I'm not bothered so much by the "which one is this" confusion as the "which should this be" confusion. With = and ==, it's easy: = for assignment, == for comparison. But == and === would both be comparison operators, and almost never would return different values. People would use the wrong one frequently, and not know why. ChrisA From varun292006 at gmail.com Wed Jul 9 04:38:59 2014 From: varun292006 at gmail.com (varun bhatnagar) Date: Wed, 9 Jul 2014 10:38:59 +0200 Subject: Does python support ATL Modelling Language? Message-ID: Hi, I am trying to shift my application from JAVA to Python and in JAVA I am using ATL Transformations (modelling techniques). Is it possible to do that with Python, does python support ATL Transformations. If not is there any API/library/module which supports this? Any kind of help will be appreciated! :) Thanks, BR, Varun -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.nandagoban at traxens.com Wed Jul 9 06:36:16 2014 From: a.nandagoban at traxens.com (Arulnambi Nandagoban) Date: Wed, 9 Jul 2014 12:36:16 +0200 Subject: Entreprise level python tcp server Message-ID: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> Hello all, Can anyone tell me the reliability level of python server in enterprise application ? I already developed a tcp server in python as a prototype. Our requirement for tcp server to handle more than 10000 connection simultaneously . Since, I am the only python fanatic in my company, it is difficult to make them convince. If you could provide me with source for benchmark for tcp server with different language, it will be great. I like to convert the python script to windows application. For the moment, I use Pyinstaller to do this task. Is there any other tool available to do this task. BR, Arulnambi R&D engineer Traxens SAS France -------------- next part -------------- An HTML attachment was scrubbed... URL: From songofacandy at gmail.com Wed Jul 9 07:05:05 2014 From: songofacandy at gmail.com (INADA Naoki) Date: Wed, 9 Jul 2014 20:05:05 +0900 Subject: Entreprise level python tcp server In-Reply-To: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> References: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> Message-ID: I +1 on Tornado. Here is echo server in some languages and frameworks. https://github.com/methane/echoserver # Benchmark is very outdated. Go is now very faster than before. On Wed, Jul 9, 2014 at 7:36 PM, Arulnambi Nandagoban wrote: > Hello all, > > > > Can anyone tell me the reliability level of python server in enterprise > application ? I already developed a tcp server in python as a prototype. > > Our requirement for tcp server to handle more than 10000 connection > simultaneously . Since, I am the only python fanatic in my company, it is > difficult > > to make them convince. If you could provide me with source for benchmark for > tcp server with different language, it will be great. > > I like to convert the python script to windows application. For the moment, > I use Pyinstaller to do this task. Is there any other tool available to do > this task. > > > > BR, > > Arulnambi > > > > R&D engineer > > Traxens SAS > > France > > > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- INADA Naoki From jeanpierreda at gmail.com Wed Jul 9 08:01:41 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Wed, 9 Jul 2014 05:01:41 -0700 Subject: Proposal: === and !=== operators In-Reply-To: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 12:00 AM, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__ may not be. > > * The == operator requires __eq__ to return True or False > (or NotImplemented) and raises TypeError if it doesn't, which > makes it impossible to use == with (say) three-valued or fuzzy > logic. Counter-proposal: The second use case doesn't matter that much, and can be added to == without breaking backwards compatibility meaningfully. The first case is covered by all sorts of things, but I'd suggest that the most meaningful way in which nan "is the same as" nan is that they both behave the same, as objects. The Python "is" operator returns True when two objects are identical. Is it a great leap to guarantee, in Python, that equivalent immutable objects are always identical? Then float('nan') is float('nan') should always return True. We already implicitly allow that a Python implementation may choose to do this (e.g. small integers are cached), but it isn't so hard to guarantee it. (You don't even have to cache anything. PyPy makes things is-identical even when they are behind the scenes different objects in memory, IIRC.) See also http://wiki.ecmascript.org/doku.php?id=harmony:egal , which is a similar proposal for ES6. -- Devin From roy at panix.com Wed Jul 9 08:27:28 2014 From: roy at panix.com (Roy Smith) Date: Wed, 09 Jul 2014 08:27:28 -0400 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: In article <53bce8a3$0$2746$c3e8da3$76491128 at news.astraweb.com>, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__ may not be. > > * The == operator requires __eq__ to return True or False > (or NotImplemented) and raises TypeError if it doesn't, which > makes it impossible to use == with (say) three-valued or fuzzy > logic. > > > I propose: > > * The == operator be redefined to *always* assume reflexivity, that > is, it first compares the two arguments using `is` before calling > the __eq__ methods. > > * That's a backwards-incompatible change, so you need to enable it > using "from __future__ import equals" in Python 3.5, and then to > become the default behaviour in 3.6. > > * To support non-reflexive types, allow === and !=== operators, which > are like == and != except they don't call `is` first. > > * The new === and !== operators call __eeq__ and __ene__ (extended > equal and extended not equal) methods; if they don't exist, they > fall back on __eq__ and __ne__. > > * To support multi-valued logics, === and !== are not required to > return True or False, they can return anything you like and it is > up to the caller to ensure that they are sensible. > > * Returning NotImplemented from __eeq__ and __ene__ has the same > meaning as for __eq__ and __ne__. > > * For the avoidance of doubt, `if...elif...else` are not expected to > be aware of multi-valued logics. No other changes to the language > are expected. > > > Thoughts? Comments? -1. This seems like it will just add additional complexity and confusion, for very little gain. We would have *three* ways to compare for equality (==, ===, and is). From steve+comp.lang.python at pearwood.info Wed Jul 9 08:48:29 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 12:48:29 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote: > We would have *three* ways to compare for equality (==, ===, and is). `is` does not, never has, and never will, be a test for equality. py> x = [] py> y = [] py> x is y False -- Steven From ethan at stoneleaf.us Wed Jul 9 08:43:25 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 09 Jul 2014 05:43:25 -0700 Subject: Proposal: === and !=== operators In-Reply-To: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53BD38ED.2060604@stoneleaf.us> On 07/09/2014 12:00 AM, Steven D'Aprano wrote: > > I propose: [adding new operators] -1 Too much added confusion, too little gain. -- ~Ethan~ From varun292006 at gmail.com Wed Jul 9 09:40:01 2014 From: varun292006 at gmail.com (varun bhatnagar) Date: Wed, 9 Jul 2014 15:40:01 +0200 Subject: Does python support ATL Modelling Language? In-Reply-To: <9DBC3AC7-F200-4B4D-A39C-EF244EB396FC@mac.com> References: <9DBC3AC7-F200-4B4D-A39C-EF244EB396FC@mac.com> Message-ID: Thanks a lot William for the reply! Before writing the previous mail I did a search but I was not able to find anything which can fulfill my need. I want something where in I can define certain rules for my xml and based on those rules my xmls should get merged into another xml (probably XSLT, still need to investigate). All these things I was doing using ATL. Anyways, I can still go through this and see if this works for me. /Varun On Wed, Jul 9, 2014 at 3:20 PM, William Ray Wing wrote: > On Jul 9, 2014, at 4:38 AM, varun bhatnagar wrote: > > > Hi, > > > > I am trying to shift my application from JAVA to Python and in JAVA I am > using ATL Transformations (modelling techniques). Is it possible to do that > with Python, does python support ATL Transformations. If not is there any > API/library/module which supports this? > > > > Any kind of help will be appreciated! :) > > > > Thanks, > > BR, > > Varun > > -- > > https://mail.python.org/mailman/listinfo/python-list > > I know next to nothing about model transformation languages. However, a > few seconds in Wikipedia and Google turned up: > > http://www.lfd.uci.edu/~gohlke/code/transformations.py.html > > If you Google for ?python model transformation? you will get a fair list > of other possibilities. > > -Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrw at mac.com Wed Jul 9 09:20:49 2014 From: wrw at mac.com (William Ray Wing) Date: Wed, 09 Jul 2014 09:20:49 -0400 Subject: Does python support ATL Modelling Language? In-Reply-To: References: Message-ID: <9DBC3AC7-F200-4B4D-A39C-EF244EB396FC@mac.com> On Jul 9, 2014, at 4:38 AM, varun bhatnagar wrote: > Hi, > > I am trying to shift my application from JAVA to Python and in JAVA I am using ATL Transformations (modelling techniques). Is it possible to do that with Python, does python support ATL Transformations. If not is there any API/library/module which supports this? > > Any kind of help will be appreciated! :) > > Thanks, > BR, > Varun > -- > https://mail.python.org/mailman/listinfo/python-list I know next to nothing about model transformation languages. However, a few seconds in Wikipedia and Google turned up: http://www.lfd.uci.edu/~gohlke/code/transformations.py.html If you Google for ?python model transformation? you will get a fair list of other possibilities. -Bill From sssdevelop at gmail.com Wed Jul 9 10:27:46 2014 From: sssdevelop at gmail.com (sssdevelop) Date: Wed, 9 Jul 2014 07:27:46 -0700 (PDT) Subject: Help me write better Code Message-ID: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Hello, I have working code - but looking for better/improved code. Better coding practices, better algorithm :) Problem: Given sequence of increasing integers, print blocks of consecutive integers. Example: Input: [10, 11, 12, 15] Output: [10, 11, 12] Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] Outout: [67, 68], [91, 92, 93, 94] My code looks as below: ----------------------------- #!/usr/bin/python a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] #a = [] #a = [10] #a = [10, 11, 12, 15] print "Input: " print a prev = 0 blocks = [] tmp = [] last = 0 for element in a: if prev == 0: prev = element next if element == prev + 1: if tmp: pass else: tmp.append(prev) tmp.append(element) else: if tmp: blocks.append(tmp) tmp = [] prev = element if tmp: blocks.append(tmp) if blocks: #print "I have repeated elements and those are:" for b in blocks: print b ----------------------- thank you in advance! From subhabangalore at gmail.com Wed Jul 9 10:36:49 2014 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Wed, 9 Jul 2014 07:36:49 -0700 (PDT) Subject: Writing Python File at Specific Interval Message-ID: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Dear Group, I am trying to write a file, which would create a new file name as the code runs. The code (a basic crawler) would run every morning or evening, on a predefined time. [This part is fine]. In the next part, I am trying to store the daily results to a new file. As I researched I found some tips around time module, logging module, pythoncom etc. But not getting any important lead. If any one of the esteemed members may kindly suggest. Regards, Subhabrata Banerjee. From 2014 at jmunch.dk Wed Jul 9 11:05:32 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Wed, 09 Jul 2014 17:05:32 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC38A0.7030100@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BC38A0.7030100@jmunch.dk> Message-ID: <53BD5A3C.30305@jmunch.dk> I wrote: > | class Monitor(Thread): > | def run(self): > | old = self.get_current_value() > | while not self.Terminated: > | new = self.get_current_value() > | if new != old: > | print(time.asctime(), "changed to", new) > | old = new > | time.sleep(1) > Huh, I don't know what happened to the identation here, I'l try again: class Monitor(Thread): ....def run(self): ........old = self.get_current_value() ........while not self.Terminated: ............new = self.get_current_value() ............if new != old: ................print(time.asctime(), "changed to", new) ............old = new ............time.sleep(1) regards, Anders From 2014 at jmunch.dk Wed Jul 9 11:08:15 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Wed, 09 Jul 2014 17:08:15 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53BD5ADF.2050409@jmunch.dk> Steven D'Aprano wrote: > It seems to me that the trivial work-around is: > > * gather packed floats from some device, as ints > * process them *as ints* in some way which requires reflexivity > * unpack back into floats > * (maybe) much later perform numeric calculations on them > > > Although perhaps I don't understand your use-case. Clearly you do not. floats are not ints. I have no idea how you imagine processing IEEE-754 floating-point values in int form. My use case is: Working with IEEE-754 floating-point values. That means storing and retrieving them, serialising and transferring them, accepting them as user input, printing them, all the usual things you do with values. And doing so in a way that does not require special handling in algorithms that are otherwise generic. When the same algorithm is capable of dealing with ints, bytestrings, text string, tuples, list, dictionaries, time stamps, NoneType's, bools, floating-point floats and a thousand other things, then NaNs stand out as the values that have special algorithm-breaking magic. I gave an example of such an algorithm in an earlier reply to Chris. regards, Anders From rosuav at gmail.com Wed Jul 9 11:13:26 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Jul 2014 01:13:26 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BD5ADF.2050409@jmunch.dk> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53BD5ADF.2050409@jmunch.dk> Message-ID: On Thu, Jul 10, 2014 at 1:08 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > Steven D'Aprano wrote: >> >> It seems to me that the trivial work-around is: >> >> * gather packed floats from some device, as ints >> * process them *as ints* in some way which requires reflexivity >> * unpack back into floats >> * (maybe) much later perform numeric calculations on them >> >> >> Although perhaps I don't understand your use-case. > > > Clearly you do not. floats are not ints. I have no idea how you imagine > processing IEEE-754 floating-point values in int form. > > My use case is: Working with IEEE-754 floating-point values. That means > storing and retrieving them, serialising and transferring them, accepting > them as user input, printing them, all the usual things you do with values. > > And doing so in a way that does not require special handling in algorithms > that are otherwise generic. > When the same algorithm is capable of dealing with ints, bytestrings, text > string, tuples, list, dictionaries, time stamps, NoneType's, bools, > floating-point floats and a thousand other things, then NaNs stand out as > the values that have special algorithm-breaking magic. > > I gave an example of such an algorithm in an earlier reply to Chris. If you need to do bitwise comparisons, then the easiest way is to use the bitpattern, converted to an integer. A 64-bit float becomes a 64-bit integer. It's then very simple to compare them, and reflexivity is maintained. At what point do you actually need them to be floats? What are you really doing with them? ChrisA From robert.kern at gmail.com Wed Jul 9 11:27:42 2014 From: robert.kern at gmail.com (Robert Kern) Date: Wed, 09 Jul 2014 16:27:42 +0100 Subject: Proposal: === and !=== operators In-Reply-To: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On 2014-07-09 08:00, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__ may not be. > > * The == operator requires __eq__ to return True or False > (or NotImplemented) and raises TypeError if it doesn't, which > makes it impossible to use == with (say) three-valued or fuzzy > logic. No, it doesn't. It can return anything. [~] |1> x = np.arange(5) [~] |2> x == 3 array([False, False, False, True, False], dtype=bool) You can blame Numeric/numpy for that feature getting in. :-) Now certainly, many uses of __eq__, like containment comparisons, do assume that the result is a bool(able). -- 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 breamoreboy at yahoo.co.uk Wed Jul 9 11:44:01 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 09 Jul 2014 16:44:01 +0100 Subject: Help me write better Code In-Reply-To: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: On 09/07/2014 15:27, sssdevelop wrote: > Hello, > > I have working code - but looking for better/improved code. Better coding practices, better algorithm :) > > Problem: Given sequence of increasing integers, print blocks of consecutive integers. > > Example: > > Input: [10, 11, 12, 15] > Output: [10, 11, 12] > > Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > Outout: [67, 68], [91, 92, 93, 94] > > My code looks as below: > ----------------------------- > #!/usr/bin/python > a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > #a = [] > #a = [10] > #a = [10, 11, 12, 15] > print "Input: " > print a > > prev = 0 > blocks = [] > tmp = [] > last = 0 > for element in a: > if prev == 0: > prev = element > next > if element == prev + 1: > if tmp: > pass > else: > tmp.append(prev) > tmp.append(element) > else: > if tmp: > blocks.append(tmp) > tmp = [] > > prev = element > > if tmp: > blocks.append(tmp) > > if blocks: > #print "I have repeated elements and those are:" > for b in blocks: > print b > > ----------------------- > > thank you in advance! > Adopted from here https://docs.python.org/3.0/library/itertools.html data = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]): group = list(map(operator.itemgetter(1), g)) if len(group) > 1: print(group) >>> [67, 68] [91, 92, 93, 94] >>> -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From 2014 at jmunch.dk Wed Jul 9 12:24:46 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Wed, 09 Jul 2014 18:24:46 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53BD5ADF.2050409@jmunch.dk> Message-ID: <53BD6CCE.30403@jmunch.dk> Chris Angelico: > If you need to do bitwise comparisons, then the easiest way is to use > the bitpattern, converted to an integer. A 64-bit float becomes a > 64-bit integer. It's then very simple to compare them, and reflexivity > is maintained. At what point do you actually need them to be floats? > What are you really doing with them? What does one do with floats? Add, subtract, multipy, divide, display, input, store and retrieve to and from various formats. All the usual stuff. Why would my use be different from anyone elses? What you and Steven seem to be saying is that I should employ strategies to avoid NaNs ever being compared. I'll take that one step further and say that as long as NaN!=NaN, everyone should seek to avoid NaNs ever being compared. regards, Anders From rustompmody at gmail.com Wed Jul 9 12:20:06 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 9 Jul 2014 09:20:06 -0700 (PDT) Subject: Proposal: === and !=== operators In-Reply-To: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wednesday, July 9, 2014 2:47:40 PM UTC+5:30, Steven D'Aprano wrote: > On Wed, 09 Jul 2014 17:21:20 +1000, Chris Angelico wrote: > > wrote: > >> Thoughts? Comments? > > First thought: It will just add confusion. Currently, there are small > > pockets of confusion surrounding the few cases where something's > > non-reflexive, and there are occasional threads on the subject, like we > > have now. > It's a reoccurring issue that keeps coming up over and over again. Most > people have no need of NANs, and want them to behave like "normal" > objects. I'm sympathetic to this idea. -nan from me And since you count nans as normal, I am sure you can work out how much that amounts to From ethan at stoneleaf.us Wed Jul 9 12:42:28 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 09 Jul 2014 09:42:28 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BC05FB.4050707@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> Message-ID: <53BD70F4.4000504@stoneleaf.us> On 07/08/2014 07:53 AM, Anders J. Munch wrote: > > So I make this claim: float.__eq__ implementing IEEE-754 NaN > comparison rules creates real problems for developers. And it has > never, ever, helped anyone do anything. > > "Never" is a strong claim, and easily disproven if false: Simply > provide a counterexample. So that is my challenge: If you have a > program (a pre-existing and useful one, not something artificial > created for this challenge) that benefits from NaN!=NaN and that would > fail if x==x for all float objects x, then please come forward and > show it, and I'll buy you a beer the next time I'm at PyCon. I would suggest you ask for this on the numerical mailing lists instead of here -- and you may not want to offer a beer to everyone that has an anecdote for NaN behavior being useful. -- ~Ethan~ From steve+comp.lang.python at pearwood.info Wed Jul 9 12:53:47 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 09 Jul 2014 16:53:47 GMT Subject: NaN comparisons - Call For Anecdotes References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53bd739b$0$29995$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Jul 2014 17:08:15 +0200, Anders J. Munch wrote: > Steven D'Aprano wrote: >> It seems to me that the trivial work-around is: >> >> * gather packed floats from some device, as ints * process them *as >> ints* in some way which requires reflexivity * unpack back into floats >> * (maybe) much later perform numeric calculations on them >> >> >> Although perhaps I don't understand your use-case. > > Clearly you do not. floats are not ints. Of course not. But there is a one-to-one correspondence between a 64-bit float and a 64-bit int, and the conversion is lossless in both directions. When you talked about: "So when my software reads these values in binary, unpack them using the struct module, and goes to work." I assumed that you realised that the 64-bit(?) values you were receiving in binary could be interpreted as ints. After all, you have to unpack them from some bytes. Since that's not what you're doing, I have no idea what it is. > I have no idea how you imagine > processing IEEE-754 floating-point values in int form. Cast your 64-bit float into a 64-bit int. Or, if it's a C single rather than a double, cast the 32-bit float into a 32-bit int. Now you can compare them for equality without carrying about NANs, and without losing data. Later, when you're ready to start doing some numeric work on them, you cast back to floats. That's the idea I had in mind. Perhaps it doesn't match your use-case. > My use case is: Working with IEEE-754 floating-point values. That means > storing and retrieving them, serialising and transferring them, > accepting them as user input, printing them, all the usual things you do > with values. But apparently not arithmetic? > And doing so in a way that does not require special handling in > algorithms that are otherwise generic. Ah, well there's your problem. NANs are special, as a signed zeroes and INFs. Does it distress you that x + x = x when x is an INF? > When the same algorithm is capable of dealing with ints, bytestrings, > text string, tuples, list, dictionaries, time stamps, NoneType's, bools, > floating-point floats and a thousand other things, ^^^^^^^^^^^^^^^^^^^^^ Obviously not, or you wouldn't be complaining about the inability to handle floats. The hardware devices generating your float data... do they also generate ints, bytestrings, text strings, tuples, lists, dicts, time stamps, None, bools, and a thousand other things? If not, I wonder why you are insisting that you have to handle a *specialised* data type using a *generic* algorithm. > then NaNs stand out > as the values that have special algorithm-breaking magic. Well yes. Floats have all sorts of problems. They're horrible really, the worst possible way to model real numbers, except for all the other ways. I'm not unsympathetic to your problem, which is why I proposed two new operators, === and !==, and a change to == and !=, in another thread. Would == always doing an identity test before calling __eq__ solve your problem? If not, what would it take to solve your problem? -- Steven From emile at fenx.com Wed Jul 9 13:12:52 2014 From: emile at fenx.com (Emile van Sebille) Date: Wed, 09 Jul 2014 10:12:52 -0700 Subject: Entreprise level python tcp server In-Reply-To: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> References: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> Message-ID: EVE online uses stackless python (http://highscalability.com/eve-online-architecture) and has seen a max of some 40k simultaneous users. You might want to look into how they do it. Emile On 7/9/2014 3:36 AM, Arulnambi Nandagoban wrote: > Hello all, > > Can anyone tell me the reliability level of python server in enterprise > application ? I already developed a tcp server in python as a prototype. > > Our requirement for tcp server to handle more than 10000 connection > simultaneously . Since, I am the only python fanatic in my company, it > is difficult > > to make them convince. If you could provide me with source for benchmark > for tcp server with different language, it will be great. > > I like to convert the python script to windows application. For the > moment, I use Pyinstaller to do this task. Is there any other tool > available to do this task. > > BR, > > Arulnambi > > R&D engineer > > Traxens SAS > > France > > > From ian.g.kelly at gmail.com Wed Jul 9 13:26:26 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Jul 2014 11:26:26 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bd739b$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bd739b$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 10:53 AM, Steven D'Aprano > Cast your 64-bit float into a 64-bit int. Or, if it's a C single rather > than a double, cast the 32-bit float into a 32-bit int. Now you can > compare them for equality without carrying about NANs, and without losing > data. Later, when you're ready to start doing some numeric work on them, > you cast back to floats. That's the idea I had in mind. Perhaps it > doesn't match your use-case. Unfortunately, it's not that simple: >>> import math, struct >>> def float_to_int(x): ... return struct.unpack('L', struct.pack('d', x))[0] ... >>> 0.0 == -0.0 True >>> float_to_int(0.0) == float_to_int(-0.0) False >>> nan1 = struct.unpack('d', b'\x00'*6+b'\xf1\x7f')[0] >>> math.isnan(nan1) True >>> nan2 = struct.unpack('d', b'\x00'*6+b'\xf2\x7f')[0] >>> math.isnan(nan2) True >>> float_to_int(nan1) == float_to_int(nan1) True >>> float_to_int(nan2) == float_to_int(nan2) True >>> float_to_int(nan1) == float_to_int(nan2) False From 2014 at jmunch.dk Wed Jul 9 13:44:21 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Wed, 09 Jul 2014 19:44:21 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53bd739b$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bc26ca$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bc8861$0$29995$c3e8da3$5496439d@news.astraweb.com> <53bd739b$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53BD7F75.5080801@jmunch.dk> Steven D'Aprano wrote: > I assumed that you realised that the 64-bit(?) values you were receiving > in binary could be interpreted as ints. After all, you have to unpack > them from some bytes. > Since that's not what you're doing, I have no idea what it is. Stop obsessing over how NaN's came to exist in my software. That's just context. The argument is over how those NaNs should behave. Their provenance is not relevant. >> I have no idea how you imagine >> processing IEEE-754 floating-point values in int form. > Cast your 64-bit float into a 64-bit int. I can construct a bijective mapping between any data structure and a subset of the natural numbers, but that has nothing to do with practical programming. A "cast" value would be impossible to work with. > >> My use case is: Working with IEEE-754 floating-point values. That means >> storing and retrieving them, serialising and transferring them, >> accepting them as user input, printing them, all the usual things you do >> with values. > But apparently not arithmetic? Of course also arithmetic. I left it out of the list because then you would say "hah! if you're doing arithmetic then it's not a generic algorithm". Apparently I can't win, you are going to nitpick anything I write. > Ah, well there's your problem. NANs are special, as a signed zeroes and INFs. > Does it distress you that x + x = x when x is an INF? No. >> When the same algorithm is capable of dealing with ints, bytestrings, >> text string, tuples, list, dictionaries, time stamps, NoneType's, bools, >> floating-point floats and a thousand other things, > ^^^^^^^^^^^^^^^^^^^^^ > > Obviously not, or you wouldn't be complaining about the inability to > handle floats. NaNs are not floating-point values. A floating-point value has a sign, an exponent and a mantissa. They are "IEEE 754 floating point" values, though. > The hardware devices generating your float data... do they also generate > ints, bytestrings, text strings, tuples, lists, dicts, time stamps, None, > bools, and a thousand other things? If not, I wonder why you are > insisting that you have to handle a *specialised* data type using a > *generic* algorithm. All the other types are also specialised, for their separate purpose. That doesn't make them non-reflexive. > I'm not unsympathetic to your problem, which is why I proposed two new > operators, === and !==, and a change to == and !=, in another thread. > Would == always doing an identity test before calling __eq__ solve your > problem? If not, what would it take to solve your problem? It would not solve it. Two bitwise identical NaNs would still compare different. What would solve the problem is making identical NaNs compare equal. regards, Anders From ian.g.kelly at gmail.com Wed Jul 9 13:50:01 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Jul 2014 11:50:01 -0600 Subject: Proposal: === and !=== operators In-Reply-To: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Wed, Jul 9, 2014 at 3:17 AM, Steven D'Aprano wrote: > People are already having problems, just listen to Anders. He's > (apparently) not doing NAN-aware computations on his data, he just wants > to be able to do something like > > this_list_of_floats == that_list_of_floats > > without NANs screwing it up. But by the same token, if I want to use NANs > the way they're supposed to be used, I should still be able to use an > equals operator (rather than a function or method). Well, if we're talking about *lists*, then the comparison operator already compares identity of individual elements: >>> nan = float('nan') >>> l1 = [1.0, 2.0, nan, 4.0] >>> l2 = [1.0, 2.0, nan, 4.0] >>> l1 == l2 True So the comparison "x is y or x == y" could also be written "[x] == [y]", without requiring any changes to the language. I suspect that just adding identity comparison is not sufficient to solve Anders' problem, though. > But the problem is, most people will need to us "x is y or x == y" nearly > everywhere! And that doesn't help with containers: > > py> alist = [1.0, 2, float('NAN'), 4] > py> blist = [1, 2.0, float('nan'), 4] > py> alist is blist or alist == blist > False The only reason this fails is because the two nans are neither identical nor equal. The proposed == semantics would also fail here. From python.list at tim.thechases.com Wed Jul 9 14:05:22 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 9 Jul 2014 13:05:22 -0500 Subject: Proposal: === and !=== operators In-Reply-To: <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <20140709130522.246ec550@bigbox.christie.dr> On 2014-07-09 12:48, Steven D'Aprano wrote: > On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote: > > > We would have *three* ways to compare for equality (==, ===, and > > is). > > `is` does not, never has, and never will, be a test for equality. > > py> x = [] > py> y = [] > py> x is y > False I too am in the -1 category for adding an extra operator-suite because of the confusion it will add (this is one of my biggest pet peeves with PHP/JS). If you want to compare things in a NaN-aware way, you can either spell it out explicitly: if x == y or (math.isnan(x) and math.isnan(y)): do_stuff() or create a wrapper function to do that for you: def equalish(x, y): return x == y or (math.isnan(x) and math.isnan(y)) if equalish(w, z): print("yep") else: print("nope") -tkc From ian.g.kelly at gmail.com Wed Jul 9 14:16:41 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Jul 2014 12:16:41 -0600 Subject: Help me write better Code In-Reply-To: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: On Wed, Jul 9, 2014 at 8:27 AM, sssdevelop wrote: > prev = 0 > blocks = [] > tmp = [] > last = 0 > for element in a: > if prev == 0: Is 0 allowed to be in the input list? What would happen if it were? > next This line doesn't do anything. It looks up the builtin function named next and then does nothing with it. I suspect you meant to use the keyword 'continue' here. > if tmp: > pass > else: > tmp.append(prev) if not tmp: tmp.append(prev) Also, give tmp a more meaningful name. Call it "current_block" or something descriptive like that. From ian.g.kelly at gmail.com Wed Jul 9 14:31:28 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Jul 2014 12:31:28 -0600 Subject: Proposal: === and !=== operators In-Reply-To: <20140709130522.246ec550@bigbox.christie.dr> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> <20140709130522.246ec550@bigbox.christie.dr> Message-ID: On Wed, Jul 9, 2014 at 12:05 PM, Tim Chase wrote: > def equalish(x, y): > return x == y or (math.isnan(x) and math.isnan(y)) With more generality: def nan_type(x): if isinstance(x, numbers.Complex): if cmath.isnan(x): return 'qnan' elif isinstance(x, decimal.Decimal): if x.is_qnan(): return 'qnan' if x.is_snan(): return 'snan' return None def equalish(x, y): if x is y or x == y: return True x_nan = nan_type(x) return x_nan is not None and x_nan == nan_type(y) Have I missed any cases? From tjreedy at udel.edu Wed Jul 9 14:46:48 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 09 Jul 2014 14:46:48 -0400 Subject: Help me write better Code In-Reply-To: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: On 7/9/2014 10:27 AM, sssdevelop wrote: > Hello, > > I have working code - but looking for better/improved code. Better coding practices, better algorithm :) > > Problem: Given sequence of increasing integers, print blocks of consecutive integers. > Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > Outout: [67, 68], [91, 92, 93, 94] Recommendations: 1. If you are just beginning Python, use the current version, now 3.4. 2. Separate interface code that gets input and presents output from the function that processes the increasing sequence. The function should not care whether the ints come from a user, file, or calculation. 3. Think in terms of iterables and iterators rather than lists (this is clearer in 3.x, where some builtins have been converted). The function should not care what class is used to convey the sequence of numbers. This happens to make it easier to solve the 'pump-priming' problem you stumbled over. 4. For designing a loop, what is the loop invariant that you want, that will make writing the code easy. For this problem, "tem is a non-emptly list of consecutive integers". Remember that a list of one int qualifies. Using for loops with the proper iterable solves the other part of the loop invariant: the current item is the next item to be compared to the last item of tem. If tem is always non-empty, that comparison is always possible. 5. Remember that Python code is generic unless constrained. What should happen if the function gets non-int numbers, with or without an integer value? What should happen if the sequence is not increasing, but contains consecutive subsequences. For beginning code, one could decide to meet the spec given for input that meets the condition and not care otherwise. The code below works for any sequence (even infinite) of objects that can be incremented by 1 and compared to the next. 6. Write an automated test. For one test, something like this works. ci = consec([51, 53, 55, 67, 68, 91, 92, 93, 94, 99]) print(next(ci) == [67, 68], next(ci) == [91, 92, 93, 94]) but since you (properly) noted several test cases a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] #a = [] #a = [10] #a = [10, 11, 12, 15] I went ahead and used unittest, at the cost of three lines of 'boilerplate' code. I added a case with a final consecutive sequence. Good thing, because it initially failed because I initially forgot to check tem after the loop. import unittest def consec(iterable): "Yield blocks of consecutive integers as a list." it = iter(iterable) first = next(it) tem = [first] for n in it: # tem is a non-empty list of consecutive ints if n == tem[-1] + 1: tem.append(n) else: if len(tem) >= 2: yield tem tem = [n] if len(tem) >= 2: yield tem class Test(unittest.TestCase): def test_consec(self): def eq(seq, blocks): self.assertEqual(list(consec(seq)), blocks) eq((), []) eq([1], []) eq([1,2,3], [[1,2,3]]) # block at beginning or end eq([-1, 1,2,3, 5], [[1,2,3]]) # block in middle eq((-1, 1,2,3, 5, 7,8,9, 11), [[1,2,3], [7,8,9]]) # 2 blocks unittest.main(verbosity=2) >>> test_consec (__main__.Test) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.016s OK -- Terry Jan Reedy From davea at davea.name Wed Jul 9 14:55:11 2014 From: davea at davea.name (Dave Angel) Date: Wed, 9 Jul 2014 14:55:11 -0400 (EDT) Subject: Writing Python File at Specific Interval References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Message-ID: subhabangalore at gmail.com Wrote in message: > > > In the next part, I am trying to store the daily > results to a new file. > > As I researched I found some tips around time module, > logging module, pythoncom etc. But not getting any important > lead. > What exactly is the problem? Perhaps you want the file name to encode the date, so that today's filename might be 2014-07-09.txt ? So you need to look up the current date, make a string from it, and create that file. What have you tried, and what went wrong? -- DaveA From tjreedy at udel.edu Wed Jul 9 15:18:06 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 09 Jul 2014 15:18:06 -0400 Subject: Entreprise level python tcp server In-Reply-To: References: <002b01cf9b61$9cf8d580$d6ea8080$@traxens.com> Message-ID: > On 7/9/2014 3:36 AM, Arulnambi Nandagoban wrote: >> I like to convert the python script to windows application. The proper way to do asynchronous io on Windows is quite different from the proper way to do it on posix systems (more or less everything other than Windows). If you plan on using a Windows server, pay no attention to benchmarks run on posix servers. More on this below. On 7/9/2014 1:12 PM, Emile van Sebille wrote: > EVE online uses stackless python > (http://highscalability.com/eve-online-architecture) and has seen a max > of some 40k simultaneous users. You might want to look into how they do > it. Stackless used 'micro threads' managed by the interpreter without involving the OS. These are called 'green threads' because they save resources. They are available as 'greenlets' on PyPI and used by, among others, gevent. See https://en.wikipedia.org/wiki/Stackless_Python Python 3.4 comes with something similar -- tasks -- in the new asyncio library. On feature of asyncio is that it transparently implementation so the same asyncio code works well on Windows as well as posix. I don't know if this is true of other alternatives. Python has an ftplib module. I suspect it could still be improved to work better with asyncio. -- Terry Jan Reedy From tomarshubham24 at gmail.com Wed Jul 9 13:17:11 2014 From: tomarshubham24 at gmail.com (Shubham Tomar) Date: Wed, 9 Jul 2014 22:47:11 +0530 Subject: Writing Python File at Specific Interval In-Reply-To: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Message-ID: Hi Subhabrata, You can use open(name, 'w'), which creates the file if the file does not exist, but it will truncate the existing file. Alternatively, you can use open(name, 'a'); this will create the file if the file does not exist, but will not truncate the existing file. Ref.: open() Regards, Shubham On Wed, Jul 9, 2014 at 8:06 PM, wrote: > Dear Group, > > I am trying to write a file, which would create a new file name > as the code runs. > > The code (a basic crawler) would run every morning > or evening, on a predefined time. [This part is fine]. > > In the next part, I am trying to store the daily > results to a new file. > > As I researched I found some tips around time module, > logging module, pythoncom etc. But not getting any important > lead. > > If any one of the esteemed members may kindly suggest. > > Regards, > Subhabrata Banerjee. > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From abhi.darkness at gmail.com Wed Jul 9 13:39:23 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 9 Jul 2014 23:09:23 +0530 Subject: Writing Python File at Specific Interval In-Reply-To: References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Message-ID: Looping in the list to improve on my suggestion or suggest an alternative On Wed, Jul 9, 2014 at 11:03 PM, Abhiram R wrote: > Hi Subha, > What is the current methodology you're using? If your code is already > being called every 24 hours or whatever, you can use a "touch" command > inside an os.system() call and create a new file and append your results to > it, right? Is that what your objective is? > > > On Wed, Jul 9, 2014 at 8:06 PM, wrote: > >> Dear Group, >> >> I am trying to write a file, which would create a new file name >> as the code runs. >> >> The code (a basic crawler) would run every morning >> or evening, on a predefined time. [This part is fine]. >> >> In the next part, I am trying to store the daily >> results to a new file. >> >> As I researched I found some tips around time module, >> logging module, pythoncom etc. But not getting any important >> lead. >> >> If any one of the esteemed members may kindly suggest. >> >> Regards, >> Subhabrata Banerjee. >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Abhiram.R > M.Tech CSE (Sem 3) > RVCE > Bangalore > -- Abhiram.R M.Tech CSE (Sem 3) RVCE Bangalore -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexjeffburke at gmail.com Wed Jul 9 15:54:56 2014 From: alexjeffburke at gmail.com (Alex Burke) Date: Wed, 9 Jul 2014 21:54:56 +0200 Subject: error handling when opening files In-Reply-To: References: Message-ID: > If that's what you're expecting, then your message is wrong, because > you say "file never opened" - but you possibly DID open it, and maybe > read something from it. The choice between the two forms should be > based on whether you want to distinguish between errors on opening and > errors on reading, or conflate them as "file unreadable". There are > times and places for each style. Yeah, got you - most of the responses echoed that it comes down to what the error situations are and whether they genuinely can or cannot be dealt with in the same way. In the case where you do want to handle the cases differently (i.e. it was there but oh my the contents turned out to be garbage) it does make me wonder how you deals with that without ending up with nested try/catch - but perhaps that would be time to use functions to make it read better. Thanks! From alexjeffburke at gmail.com Wed Jul 9 15:59:49 2014 From: alexjeffburke at gmail.com (Alex Burke) Date: Wed, 9 Jul 2014 21:59:49 +0200 Subject: error handling when opening files In-Reply-To: <53bbb33b$0$2926$c3e8da3$76491128@news.astraweb.com> References: <53bbb33b$0$2926$c3e8da3$76491128@news.astraweb.com> Message-ID: > Interestingly, did you know that even *closing* a file can fail? No I didn't, interesting piece on information for sure! I thought close() is usually made to always succeed regardless if it actually hosed up. Any idea what the context manager will do in that case? (I ask as that else-with form looks vulnerable in that case but may not be). Thanks! From roy at panix.com Wed Jul 9 16:47:22 2014 From: roy at panix.com (Roy Smith) Date: Wed, 09 Jul 2014 16:47:22 -0400 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <53bd3a1d$0$29995$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > On Wed, 09 Jul 2014 08:27:28 -0400, Roy Smith wrote: > > > We would have *three* ways to compare for equality (==, ===, and is). > > `is` does not, never has, and never will, be a test for equality. > > py> x = [] > py> y = [] > py> x is y > False That is a very narrow legalistic way of looking at things. If you don't like the word "equality", substitute a more generic word, such as "sameness" We continually have threads about when to use "==" and when to use "is". Clearly, there is confusion about them. Adding another way to test for sameness will just increase the confusion. From 2014 at jmunch.dk Wed Jul 9 17:09:36 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Wed, 09 Jul 2014 23:09:36 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BD70F4.4000504@stoneleaf.us> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> Message-ID: <53BDAF90.8010709@jmunch.dk> Ethan Furman: > I would suggest you ask for this on the numerical mailing lists instead of > here -- and you may not want to offer a beer to everyone that has an anecdote > for NaN behavior being useful. I don't have time to start this discussion over again on another mailing list. Don't anyone on those lists read python-list also? regards, Anders From joel.goldstick at gmail.com Wed Jul 9 18:16:35 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Wed, 9 Jul 2014 18:16:35 -0400 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BDAF90.8010709@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: On Wed, Jul 9, 2014 at 5:09 PM, Anders J. Munch <2014 at jmunch.dk> wrote: > Ethan Furman: > > I would suggest you ask for this on the numerical mailing lists instead >> of here -- and you may not want to offer a beer to everyone that has an >> anecdote for NaN behavior being useful. >> > I don't have time to start this discussion over again on another mailing > list. Don't anyone on those lists read python-list also? I've been following along here, and it seems you haven't received the answer you want or need. Since you are the one in search of a solution it seems that you might take more kindly to a pointer in a direction that might serve you better. Best of luck > > > regards, Anders > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Wed Jul 9 18:21:34 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 09 Jul 2014 15:21:34 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BDAF90.8010709@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: <53BDC06E.5040608@stoneleaf.us> On 07/09/2014 02:09 PM, Anders J. Munch wrote: > Ethan Furman: >> >> I would suggest you ask for this on the numerical mailing lists instead of here -- and you may not want to offer a >> beer to everyone that has an anecdote for NaN behavior being useful. > > I don't have time to start this discussion over again on another mailing list. Don't anyone on those lists read > python-list also? I believe there are a handful, but I don't know how active they are here. For a straight-up numbers type question, especially about NaN and who's using it to what effect, a numbers or scientific mailing list is really the way to go. -- ~Ethan~ From 2014 at jmunch.dk Wed Jul 9 19:03:15 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Thu, 10 Jul 2014 01:03:15 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: <53BDCA33.3020100@jmunch.dk> Joel Goldstick wrote: > I've been following along here, and it seems you haven't received the answer > you want or need. So far I received exactly the answer I was expecting. 0 examples of NaN!=NaN being beneficial. I wasn't asking for help, I was making a point. Whether that will lead to improvement of Python, well, I'm not too optimistic, but I feel the point was worth making regardless. regards, Anders From cs at zip.com.au Wed Jul 9 19:16:23 2014 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 10 Jul 2014 09:16:23 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <20140709231623.GA66358@cskk.homeip.net> TL;DR: I've got an alternative proposal at the bottom of this message. On 09Jul2014 09:17, Steven D'Aprano wrote: >On Wed, 09 Jul 2014 17:21:20 +1000, Chris Angelico wrote: >> First thought: It will just add confusion. Currently, there are small >> pockets of confusion surrounding the few cases where something's >> non-reflexive, and there are occasional threads on the subject, like we >> have now. > >It's a reoccurring issue that keeps coming up over and over again. Most >people have no need of NANs, and want them to behave like "normal" >objects. I'm sympathetic to this idea. But most people also expect float addition to act as though they were Decimals. I think the real problem here is that "float" is IEEE float and this isn't what a naive user imagines. >Whenever this comes up, no-one has suggested any non-reflexive values >other than NANs, SQL NUL, and "Always Compares Unequal", which I suspect >is more of a toy than an actual useful example. So there are *very, very* >few people who actually need NANs. > >(But those who do ought to be able to easily get it.) I agree people should have a noncumbersome way to get particular behaviours. I have a (possibly ghastly) alternative suggestion, lower down. >> Adding another pair of equality operators will mean that >> everyone has to think "Do I want == or ===?", > >I don't think so. Nearly everyone will just use ==, those who want === >will know they need it. Um, I disagree. And I also think that === in Python being different to (say) PHP === or JS === will further confuse things, since they are spelt the same. At the moment Python has "is", which is very simple in concept, and ==, which is also conceptually simple (equal values, for the relevant values in the object). I agree that "is" not implying "==" is confusing when it happens, but that is only for a few types. Regrettably, float is heavily used. >> and we just need to look >> at PHP and ECMAScript to see what happens - people pick the wrong >> operator and have no end of subtle problems. > >People are already having problems, just listen to Anders. He's >(apparently) not doing NAN-aware computations on his data, he just wants >to be able to do something like > >this_list_of_floats == that_list_of_floats > >without NANs screwing it up. I think Ian Kelly has pointed out that this already works, and that therefore Andres' problem may be more comoplicated and not fixed by your proposal. I think, based entirely on my subjective memory of discussion rates on python-list and doubtless influences by not hanging our in numeric computing lists, that float not being a plain decimal construct causes more confusion and surprise. >But by the same token, if I want to use NANs >the way they're supposed to be used, I should still be able to use an >equals operator (rather than a function or method). > >> There will be blog posts >> around saying "always use === in Python", or "never use === in Python", > >I doubt that this would even come into the radar of most bloggers. I have (hazy) memories of seeing plenty of little pseudo-informative magazine articles discussing this kind of thing for PHP etc. The very presence of the extra very similar operator spawns clarification articles. [...] >> I think this is a big fat YAGNI. The two operators will differ in so few >> situations that you may as well just define a few cases as "x is y or x >> == y" instead of creating thew new operator; > >But the problem is, most people will need to us "x is y or x == y" nearly >everywhere! And that doesn't help with containers: > >py> alist = [1.0, 2, float('NAN'), 4] >py> blist = [1, 2.0, float('nan'), 4] >py> alist is blist or alist == blist >False > >There ought to be a simple way for people to get alist == blist, while >still allowing IEEE-754 aware code to work. Ok, here is my alternative proposal: dynamic float behaviour selection. Consider this code snippet: with float.behaviour(nan_eq=True): ... code here ... This sets a thread-local behaviour flag on the entire float type and undoes it on exit from the context. This has the following advantages: - it is very easy to use, and makes plain that this particular chunk of code has special rules - it makes NaN == behaviour as requested in a particular window - it can wrap all code called inside the suite - because it is thread local it doesn't asynchronously affect other running code - it doesn't introduce a new operator - it affects a tightly constrainted behaviour, and can obviously be extended to other special cases if they arise The downside is that it could break code depending on NaN being nonreflexive _if_ that code is called within the suite. Personally, I would take this over a new and only-subtly-different-from-== "===" operator. Cheers, Cameron Simpson Check out Doohan's rear/all wheel slide in the French GP. Oh yeah. "I was just mucking around. I won't do that again." - Mick Doohan From ian.g.kelly at gmail.com Wed Jul 9 19:34:48 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 9 Jul 2014 17:34:48 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BDCA33.3020100@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53BDCA33.3020100@jmunch.dk> Message-ID: On Wed, Jul 9, 2014 at 5:03 PM, Anders J. Munch <2014 at jmunch.dk> wrote: > Joel Goldstick wrote: >> >> I've been following along here, and it seems you haven't received the >> answer you want or need. > > > So far I received exactly the answer I was expecting. 0 examples of > NaN!=NaN being beneficial. > I wasn't asking for help, I was making a point. Whether that will lead to > improvement of Python, well, I'm not too optimistic, but I feel the point > was worth making regardless. If the reason there were 0 examples is because the group that you posed the question to is lacking the kind of experience needed to be able to provide them (speaking for myself, I wouldn't know because I don't ever do anything with NaN beyond checking for it as an error condition), then the point hasn't really been made, has it? From ethan at stoneleaf.us Wed Jul 9 19:17:03 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 09 Jul 2014 16:17:03 -0700 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BDCA33.3020100@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53BDCA33.3020100@jmunch.dk> Message-ID: <53BDCD6F.6030902@stoneleaf.us> On 07/09/2014 04:03 PM, Anders J. Munch wrote: > Joel Goldstick wrote: >> >> I've been following along here, and it seems you haven't received the answer you want or need. > > So far I received exactly the answer I was expecting. 0 examples of NaN!=NaN being beneficial. python-list (in whichever from you interact with it) is in no way specialized, yet you are asking for a highly specialized bit of information. > I wasn't asking for help, I was making a point. Whether that will lead to improvement of Python, well, I'm not too > optimistic, but I feel the point was worth making regardless. The only point you have made is that no-one here uses them much. You could just as easily ask how many of us use lead-alloy to shield our in-home nuclear reactors to get the same answer. On the other hand, if you go and ask on the numpy and simpy and whatever-math-or-science-py lists there are, and get affirmative answers from them that yeah, NaN != NaN is just a huge pain and everyone is working around it, then brought that information back here -- well, then you will have made the point that you want to make. -- ~Ethan~ From denismfmcmahon at gmail.com Wed Jul 9 19:51:01 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Wed, 9 Jul 2014 23:51:01 +0000 (UTC) Subject: Writing Python File at Specific Interval References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Message-ID: On Wed, 09 Jul 2014 07:36:49 -0700, subhabangalore wrote: > The code (a basic crawler) would run every morning or evening, on a > predefined time. [This part is fine]. > > In the next part, I am trying to store the daily results to a new file. So what you want to do is store each day's results in a new file, so probably you want to create a filename that looks something like an iso 8601 date. Luckily for you python has this functionality available: https://docs.python.org/2/library/datetime.html#date-objects $ python Python 2.7.3 (default, Feb 27 2014, 19:58:35) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import date >>> fn = date.today().isoformat() + ".log" >>> print fn 2014-07-10.log >>> quit() $ Once you have a string containing your filename, you might use: fp = open( fn, "w" ) fp.write( data ) fp.close() -- Denis McMahon, denismfmcmahon at gmail.com From ben at benfinney.id.au Wed Jul 9 20:57:39 2014 From: ben at benfinney.id.au (Ben Finney) Date: Thu, 10 Jul 2014 10:57:39 +1000 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53BDCA33.3020100@jmunch.dk> Message-ID: <85oawyt4ho.fsf@benfinney.id.au> "Anders J. Munch" <2014 at jmunch.dk> writes: > Joel Goldstick wrote: > > I've been following along here, and it seems you haven't received > > the answer you want or need. > > So far I received exactly the answer I was expecting. 0 examples of > NaN!=NaN being beneficial. Predictability and ease of diagnosis are the principles at work . You have already received examples of those. If those don't convince you of its usefulness, that's unfortunate, but at this point you are demonstrating a standard which is both unreasonably high (even the rationale of the committee doesn't convince you) and unreasonably low (you ask not for explanations but personal anecdotes). Good luck to you in your quest. -- \ ?Every man would like to be God, if it were possible; some few | `\ find it difficult to admit the impossibility.? ?Bertrand | _o__) Russell, _Power: A New Social Analysis_, 1938 | Ben Finney From steve+comp.lang.python at pearwood.info Wed Jul 9 21:10:24 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Jul 2014 01:10:24 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd3a1d$0$29995$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53bde7ff$0$29995$c3e8da3$5496439d@news.astraweb.com> On Wed, 09 Jul 2014 13:05:22 -0500, Tim Chase wrote: > If you want to compare things in a NaN-aware way, you can either spell > it out explicitly: > > if x == y or (math.isnan(x) and math.isnan(y)): > do_stuff() But do we really want any arbitrary NAN to compare equal-ish with every other NAN? There are 9007199254740990 distinct NANs (slightly less than 0.05% of the total number of floats). Much to my disappointment, frexp doesn't return the payload and exponent of NANs, at least not on Linux: py> math.frexp(NAN) (nan, 0) so it can't be used to distinguish different NANs. -- Steven From rustompmody at gmail.com Wed Jul 9 23:07:57 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Wed, 9 Jul 2014 20:07:57 -0700 (PDT) Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: Message-ID: <35d5eccb-3b25-4083-8001-fa268e8b377c@googlegroups.com> On Tuesday, July 8, 2014 8:23:47 PM UTC+5:30, Anders J. Munch wrote: > Most people don't need to deal with NaN's in Python at all, > fortunately. They just don't appear in normal computation, because the > interpreter raises an exception instead. > So I make this claim: float.__eq__ implementing IEEE-754 NaN > comparison rules creates real problems for developers. And it has > never, ever, helped anyone do anything. > "Never" is a strong claim, and easily disproven if false: Simply > provide a counterexample. So that is my challenge: If you have a No I dont have a direct answer for your challenge but I have two close analogies. Nan in floats is analogous (almost isomorphic) to two other areas - null in RDBMS - bottom ? ? ? in denotational semantics The denotational semantics example would really clarify the issue. I have discussed it here in the haskell context: http://blog.languager.org/2012/08/functional-programming-philosophical.html http://en.wikibooks.org/wiki/Haskell/Denotational_semantics#.E2.8A.A5_Bottom is a more general survey RDBMS nulls is probably a more familiar example. Lets say you have a dbms of people and one nullable field is 'telephone'. Now some people have no phones and the original intent of the nullable field was to take care of that. But then in data entry some people who had too many phones and could not decide which to fill kept the field null!! Are these two cases equivalent? Your request amounts to making them so. Now read your own case: > It happens in my work I come across them quite a lot. I'm writing > software that talks to embedded applications that can contain NaN > values for a variety of reasons - never-initialised storage, > initialise-to-NaN, hardware failures etc. How do you decide that all these are equivalent/ 'equal'? Someone or other somewhere or other will be unhappy!! My analysis of the problem: The *letter* of the IEEE standard describes nans (and other exotic beasties) The *spirit* describes exceptional conditions that arise in floating computations [I have not read the standard -- just guessing] The standard was made when programming languages did not have well tried and tested exception mechanisms. So with python supporting nans we have two competing exception mechanisms: - the IEEE one -- nans - the native python one -- exceptions Once this is clear it should be clear what the solution should be: DRY, no redundancy etc. Since exceptions are pythonic, nans should not be supported. If we were starting from scratch this would be the way to go. However given the currently extant support, this would be a downgrade for people like you -- who would be unhappy! So intermediate more kludgy solution: The problem is not with >>> nan==nan False But with >>> type(nan) So nan is a float but by definition is not a number!! So float a superset of all numbers??!! If instead like: >>> type(None) we had >>> type(None) then normal users would never see it and people like you could deal with it outside the float-umbrella. From fk26541598fk at gmail.com Wed Jul 9 23:19:33 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Wed, 9 Jul 2014 20:19:33 -0700 (PDT) Subject: How can i get http body?? Message-ID: <4574254f-e813-4f16-bafb-cbd649496095@googlegroups.com> https://lh5.googleusercontent.com/-6t5tmr5T4Ys/U74FdF128oI/AAAAAAAABvo/bYyaHzsdw9Q/s1600/%E6%9C%AA%E5%91%BD%E5%90%8D.jpg how can i catch the "body" when i was post ?? i want to catch body to my database and encode to base64 def hello(username): if request.method=='POST': post_insert(username) return username def post_insert(username): init_db() conn = engine.connect() encoded = base64.b64encode(username.encode('utf-8')) puresql = sqla.text("INSERT INTO friends(name) VALUES(:encoded)") conn.execute(puresql,encoded = encoded) From alister.nospam.ware at ntlworld.com Thu Jul 10 03:55:19 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Thu, 10 Jul 2014 07:55:19 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> Message-ID: On Wed, 09 Jul 2014 23:09:36 +0200, Anders J. Munch wrote: > Ethan Furman: >> I would suggest you ask for this on the numerical mailing lists instead >> of here -- and you may not want to offer a beer to everyone that has an >> anecdote for NaN behavior being useful. > I don't have time to start this discussion over again on another mailing > list. > Don't anyone on those lists read python-list also? > > regards, Anders they possibly do, but prefer to keep discussions to the proper forum -- If you are going to walk on thin ice, you may as well dance. From rxjwg98 at gmail.com Thu Jul 10 04:57:23 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Thu, 10 Jul 2014 01:57:23 -0700 (PDT) Subject: How to write match nth grouped subexpression? Message-ID: <53ada36b-e1ce-4487-b9ac-0a162e3da8c3@googlegroups.com> Hi, It says that: match checks for a match only at the beginning of the string. Then, it also says that: \1...\9 Matches nth grouped subexpression. I don't know how to write a script to include grouped subexpression in match? Thanks, From shivagunwant at gmail.com Thu Jul 10 05:22:15 2014 From: shivagunwant at gmail.com (shivagunwant at gmail.com) Date: Thu, 10 Jul 2014 02:22:15 -0700 (PDT) Subject: abrt: detected unhandled Python exception In-Reply-To: <0253dd5f-f8f3-45e7-84b0-92023c0924c9@googlegroups.com> References: <0253dd5f-f8f3-45e7-84b0-92023c0924c9@googlegroups.com> Message-ID: <099a183e-9cba-4232-b165-ed5b4ba6b98d@googlegroups.com> On Monday, 30 December 2013 01:05:32 UTC+5:30, smileso... at gmail.com wrote: > Hi all, > > I am facing a script issue whenever i run my script in /var/log/messages and it gives error something as below: > > > > > > abrt: detected unhandled Python exception in xxxxx.py. > > > > Can anybody help me figuring out how do i know which line number has thrown the python exception? > > > > Regards > > Pradeep SElinux could be the culprit here.Try resetting it to permissive mode. Restarting the abrtd service should resolve the problem. Shiva. From cs at zip.com.au Thu Jul 10 05:50:43 2014 From: cs at zip.com.au (Cameron Simpson) Date: Thu, 10 Jul 2014 19:50:43 +1000 Subject: How to write match nth grouped subexpression? In-Reply-To: <53ada36b-e1ce-4487-b9ac-0a162e3da8c3@googlegroups.com> References: <53ada36b-e1ce-4487-b9ac-0a162e3da8c3@googlegroups.com> Message-ID: <20140710095043.GA76188@cskk.homeip.net> On 10Jul2014 01:57, rxjwg98 at gmail.com wrote: >It says that: match checks for a match only at the beginning of the string. >Then, it also says that: \1...\9 Matches nth grouped subexpression. > >I don't know how to write a script to include grouped subexpression in match? A grouped subexpression is just a portion of a regexp marked out. They serve two main purposes: to refer to a portion of the expression as you intend, and to mark a section of the regexp for use by a modifier. Here's an example: Suppose you're reading a file and trying to match lines like: Hours logged: 12 You might use a regexp like this: Hours logged: (\d+) If you match with the expression above, the "\d+" portion will match one or more digits i.e. the "12" in the example line earlier. The "(\d+)" is a grouped subexpression, the first one (and only one). If you write a little test script (untested): import re TESTLINE = "Hours logged: 12" regexp = re.compile( r'Hours logged: (\d+)' ) m = regexp.match(TESTLINE) print "subgroup 1:", m.group(1) that should print "12". Cheers, Cameron Simpson Ignorance is preferable to error; and he is less remote from the truth who believes nothing, than he who believes what is wrong. - Thomas Jefferson From rxjwg98 at gmail.com Thu Jul 10 06:05:29 2014 From: rxjwg98 at gmail.com (rxjwg98 at gmail.com) Date: Thu, 10 Jul 2014 03:05:29 -0700 (PDT) Subject: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? Message-ID: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> Hi, On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f]. I test it with: >>> re.match(r'\s*\d\d*$', ' 111') <_sre.SRE_Match object at 0x03642BB8> >>> re.match(r'\t\n\r\f*\d\d*$', ' 111') # fails >>> re.match(r'[\t\n\r\f]*\d\d*$', ' 111') # fails >>> re.match(r'[\t\n\r\f]\d\d*$', ' 111') # fails >>> re.match(r'[\t\n\r\f]*$', ' 111') # fails What is wrong in above script? Thanks From python at mrabarnett.plus.com Thu Jul 10 07:18:01 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jul 2014 12:18:01 +0100 Subject: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? In-Reply-To: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> References: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> Message-ID: <53BE7669.2080109@mrabarnett.plus.com> On 2014-07-10 11:05, rxjwg98 at gmail.com wrote: > Hi, > > On a tutorial it says that '\s': Matches whitespace. Equivalent to [\t\n\r\f]. > It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so either the tutorial is wrong, or you didn't look closely enough. :-) > I test it with: > >>>> re.match(r'\s*\d\d*$', ' 111') > <_sre.SRE_Match object at 0x03642BB8> >>>> re.match(r'\t\n\r\f*\d\d*$', ' 111') # fails The string starts with ' ', not '\t'. >>>> re.match(r'[\t\n\r\f]*\d\d*$', ' 111') # fails >>>> re.match(r'[\t\n\r\f]\d\d*$', ' 111') # fails >>>> re.match(r'[\t\n\r\f]*$', ' 111') # fails The string starts with ' ', which isn't in the character set. > > What is wrong in above script? Thanks > From python at mrabarnett.plus.com Thu Jul 10 07:28:16 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jul 2014 12:28:16 +0100 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <85oawyt4ho.fsf@benfinney.id.au> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53BDCA33.3020100@jmunch.dk> <85oawyt4ho.fsf@benfinney.id.au> Message-ID: <53BE78D0.60802@mrabarnett.plus.com> On 2014-07-10 01:57, Ben Finney wrote: > "Anders J. Munch" <2014 at jmunch.dk> writes: > >> Joel Goldstick wrote: >> > I've been following along here, and it seems you haven't received >> > the answer you want or need. >> >> So far I received exactly the answer I was expecting. 0 examples of >> NaN!=NaN being beneficial. > > Predictability and ease of diagnosis are the principles at work > . You have already > received examples of those. > > If those don't convince you of its usefulness, that's unfortunate, but > at this point you are demonstrating a standard which is both > unreasonably high (even the rationale of the committee doesn't convince > you) and unreasonably low (you ask not for explanations but personal > anecdotes). > > Good luck to you in your quest. > I can think of one place where equality of NaNs would be useful: sorting. However, in that use-case, you would also want it to be orderable, perhaps greater than any other non-NaN float. From rosuav at gmail.com Thu Jul 10 07:38:00 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 10 Jul 2014 21:38:00 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53BE78D0.60802@mrabarnett.plus.com> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53BDCA33.3020100@jmunch.dk> <85oawyt4ho.fsf@benfinney.id.au> <53BE78D0.60802@mrabarnett.plus.com> Message-ID: On Thu, Jul 10, 2014 at 9:28 PM, MRAB wrote: > I can think of one place where equality of NaNs would be useful: > sorting. > > However, in that use-case, you would also want it to be orderable, > perhaps greater than any other non-NaN float. In that case, you're setting special rules, so you probably want a key-based sort. Since the sorting of tuples works by comparing elements sequentially, it's simple enough: >>> l=[1.0,2.0,1.5,float("nan"),1.7] >>> sorted(l,key=lambda n: (n!=n, n)) [1.0, 1.5, 1.7, 2.0, nan] I'm not sure what's supposed to happen if you just let sorted() go with its default comparisons. It seems to put the nan at the end, but I wouldn't bet on that being reliable, unless it's documented somewhere. Of course, with a key sort you can choose to put NaNs at the beginning just as easily: >>> sorted(l,key=lambda n: (n==n, n)) [nan, 1.0, 1.5, 1.7, 2.0] You want custom rules for sorting? You got 'em. ChrisA From rxjwg98 at gmail.com Thu Jul 10 09:32:13 2014 From: rxjwg98 at gmail.com (fl) Date: Thu, 10 Jul 2014 06:32:13 -0700 (PDT) Subject: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? In-Reply-To: References: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> Message-ID: <7593d956-f202-4d1c-9e35-1269ab3dda57@googlegroups.com> On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: > On 2014-07-10 11:05, rx at gmail.com wrote: > > It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so > > either the tutorial is wrong, or you didn't look closely enough. :-) > > > The string starts with ' ', not '\t'. > > > > > > The string starts with ' ', which isn't in the character set. > > The '\s' description is on link: http://www.tutorialspoint.com/python/python_reg_expressions.htm Could you give me an example to use the equivalent pattern? Thanks From ned at nedbatchelder.com Thu Jul 10 10:04:40 2014 From: ned at nedbatchelder.com (Ned Batchelder) Date: Thu, 10 Jul 2014 10:04:40 -0400 Subject: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? In-Reply-To: <7593d956-f202-4d1c-9e35-1269ab3dda57@googlegroups.com> References: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> <7593d956-f202-4d1c-9e35-1269ab3dda57@googlegroups.com> Message-ID: On 7/10/14 9:32 AM, fl wrote: > On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: >> On 2014-07-10 11:05, rx at gmail.com wrote: >> >> It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so >> >> either the tutorial is wrong, or you didn't look closely enough. :-) >> >> >> The string starts with ' ', not '\t'. >> >> >> >> >> >> The string starts with ' ', which isn't in the character set. >> >> > The '\s' description is on link: > > http://www.tutorialspoint.com/python/python_reg_expressions.htm > For some reason, that page shows much of its information twice. The first occurrence of \s there is: \s Matches whitespace. Equivalent to [\t\n\r\f]. The second is: \s Match a whitespace character: [ \t\r\n\f] The second one is correct. The first is wrong. You might want to send the author a bug report. Actually, neither is strictly correct, since as the official docs (https://docs.python.org/2/library/re.html) say, \s When the UNICODE flag is not specified, it matches any whitespace character, this is equivalent to the set [ \t\n\r\f\v]. The LOCALE flag has no extra effect on matching of the space. If UNICODE is set, this will match the characters [ \t\n\r\f\v] plus whatever is classified as space in the Unicode character properties database. > > Could you give me an example to use the equivalent pattern? > > Thanks > -- Ned Batchelder, http://nedbatchelder.com From roy at panix.com Thu Jul 10 10:02:11 2014 From: roy at panix.com (Roy Smith) Date: Thu, 10 Jul 2014 10:02:11 -0400 Subject: How can i get http body?? References: <4574254f-e813-4f16-bafb-cbd649496095@googlegroups.com> Message-ID: In article <4574254f-e813-4f16-bafb-cbd649496095 at googlegroups.com>, Frank Liou wrote: > https://lh5.googleusercontent.com/-6t5tmr5T4Ys/U74FdF128oI/AAAAAAAABvo/bYyaHzs > dw9Q/s1600/%E6%9C%AA%E5%91%BD%E5%90%8D.jpg > > how can i catch the "body" when i was post ?? Take a look at the wonderful requests package. It makes all of this very simple. http://docs.python-requests.org/ From rxjwg98 at gmail.com Thu Jul 10 10:04:42 2014 From: rxjwg98 at gmail.com (fl) Date: Thu, 10 Jul 2014 07:04:42 -0700 (PDT) Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? Message-ID: Hi, For me, it is difficult to understand the last line of the paragraph below in parenthesis (A ``quote'' is the character used to open the string, i.e. either ' or ".) It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '. What this different ` and ' do for here? The link is here: https://docs.python.org/2.0/ref/strings.html Thank you for helping me to learn Python. ............................ In plain English: String literals can be enclosed in matching single quotes (') or double quotes ("). They can also be enclosed in matching groups of three single or double quotes (these are generally referred to as triple-quoted strings). The backslash (\) character is used to escape characters that otherwise have a special eaning, such as newline, backslash itself, or the quote character. String literals may optionally be prefixed with a letter `r' or `R'; such strings are called raw strings and use different rules for backslash escape sequences. In triple-quoted strings, unescaped newlines and quotes are allowed (and are retained), except that three unescaped quotes in a row terminate the string. (A ``quote'' is the character used to open the string, i.e. either ' or ".) From python at mrabarnett.plus.com Thu Jul 10 10:08:23 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jul 2014 15:08:23 +0100 Subject: Why is it different about '\s' Matches whitespace and Equivalent to [\t\n\r\f]? In-Reply-To: <7593d956-f202-4d1c-9e35-1269ab3dda57@googlegroups.com> References: <1e8dbd65-bd19-4b9d-a7ec-961e8304ace0@googlegroups.com> <7593d956-f202-4d1c-9e35-1269ab3dda57@googlegroups.com> Message-ID: <53BE9E57.4050906@mrabarnett.plus.com> On 2014-07-10 14:32, fl wrote: > On Thursday, July 10, 2014 7:18:01 AM UTC-4, MRAB wrote: >> It's equivalent to [ \t\n\r\f], i.e. it also includes a space, so >> either the tutorial is wrong, or you didn't look closely enough. :-) >> >> The string starts with ' ', not '\t'. >> >> The string starts with ' ', which isn't in the character set. >> > The '\s' description is on link: > > http://www.tutorialspoint.com/python/python_reg_expressions.htm > I can see that the space is missing. It should say: \s Matches whitespace. Equivalent to [ \t\n\r\f]. > Could you give me an example to use the equivalent pattern? > (I'm using Python 3.4, which is why the match object looks different.) >>> import re >>> re.match(r'\s*\d\d*$', ' 111') <_sre.SRE_Match object; span=(0, 6), match=' 111'> >>> re.match(r'[ \t\n\r\f]*\d\d*$', ' 111') <_sre.SRE_Match object; span=(0, 6), match=' 111'> From kwpolska at gmail.com Thu Jul 10 10:14:14 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Thu, 10 Jul 2014 16:14:14 +0200 Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? In-Reply-To: References: Message-ID: On Thu, Jul 10, 2014 at 4:04 PM, fl wrote: > Hi, > > For me, it is difficult to understand the last line of the paragraph below in > parenthesis (A ``quote'' is the character used to open the string, > i.e. either ' or ".) > > It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '. > What this different ` and ' do for here? > > The link is here: > https://docs.python.org/2.0/ref/strings.html > > Thank you for helping me to learn Python. Please don?t learn from this link. It?s from 2001. You should learn from modern documentation: https://docs.python.org/ (if not running 3.4.x, change the version in the top) You also should not read the language reference, it?s meant for people who really care about what?s under the hood. The official tutorial is better for learning: https://docs.python.org/3/tutorial/index.html -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From joel.goldstick at gmail.com Thu Jul 10 10:14:28 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 10 Jul 2014 10:14:28 -0400 Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? In-Reply-To: References: Message-ID: On Thu, Jul 10, 2014 at 10:04 AM, fl wrote: > Hi, > > For me, it is difficult to understand the last line of the paragraph below in > parenthesis (A ``quote'' is the character used to open the string, > i.e. either ' or ".) > > It talks about triple-quoted strings. Where is ``quote'' from? It has two ` and '. > What this different ` and ' do for here? > > The link is here: > https://docs.python.org/2.0/ref/strings.html > > Thank you for helping me to learn Python. > > > ............................ > In plain English: String literals can be enclosed in matching single quotes (') or > double quotes ("). They can also be enclosed in matching groups of three single > or double quotes (these are generally referred to as triple-quoted strings). The > backslash (\) character is used to escape characters that otherwise have a special eaning, such as newline, backslash itself, or the quote character. String literals > may optionally be prefixed with a letter `r' or `R'; such strings are called raw > strings and use different rules for backslash escape sequences. > > In triple-quoted strings, unescaped newlines and quotes are allowed (and are > retained), except that three unescaped quotes in a row terminate the string. (A > ``quote'' is the character used to open the string, i.e. either ' or ".) > -- > https://mail.python.org/mailman/listinfo/python-list Here are some examples: 'this is a single quoted string' "this is a double quoted string" """this is a triple quoted string. Note that it starts and ends with three double quote characters. It can also span lines """ '''If you like you can use single quotes (three of them) for the same effect''' -- Joel Goldstick http://joelgoldstick.com From sssdevelop at gmail.com Thu Jul 10 10:38:19 2014 From: sssdevelop at gmail.com (sssdevelop) Date: Thu, 10 Jul 2014 07:38:19 -0700 (PDT) Subject: Help me write better Code In-Reply-To: References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: <2614ac27-fa83-49e3-8051-4c7a0043f750@googlegroups.com> Thank you so much Terry Jan Reedy. You have given best advice - yup, i am beginner in Python. Your reply has done grooming :) thx, On Thursday, July 10, 2014 12:16:48 AM UTC+5:30, Terry Reedy wrote: > On 7/9/2014 10:27 AM, sssdevelop wrote: > > > Hello, > > > > > > I have working code - but looking for better/improved code. Better coding practices, better algorithm :) > > > > > > Problem: Given sequence of increasing integers, print blocks of consecutive integers. > > > > > Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > > Outout: [67, 68], [91, 92, 93, 94] > > > > Recommendations: > > 1. If you are just beginning Python, use the current version, now 3.4. > > > > 2. Separate interface code that gets input and presents output from the > > function that processes the increasing sequence. The function should not > > care whether the ints come from a user, file, or calculation. > > > > 3. Think in terms of iterables and iterators rather than lists (this is > > clearer in 3.x, where some builtins have been converted). The function > > should not care what class is used to convey the sequence of numbers. > > This happens to make it easier to solve the 'pump-priming' problem you > > stumbled over. > > > > 4. For designing a loop, what is the loop invariant that you want, that > > will make writing the code easy. For this problem, "tem is a non-emptly > > list of consecutive integers". Remember that a list of one int > > qualifies. Using for loops with the proper iterable solves the other > > part of the loop invariant: the current item is the next item to be > > compared to the last item of tem. If tem is always non-empty, that > > comparison is always possible. > > > > 5. Remember that Python code is generic unless constrained. What should > > happen if the function gets non-int numbers, with or without an integer > > value? What should happen if the sequence is not increasing, but > > contains consecutive subsequences. For beginning code, one could decide > > to meet the spec given for input that meets the condition and not care > > otherwise. The code below works for any sequence (even infinite) of > > objects that can be incremented by 1 and compared to the next. > > > > 6. Write an automated test. For one test, something like this works. > > > > ci = consec([51, 53, 55, 67, 68, 91, 92, 93, 94, 99]) > > print(next(ci) == [67, 68], next(ci) == [91, 92, 93, 94]) > > > > but since you (properly) noted several test cases > > > > a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > #a = [] > > #a = [10] > > #a = [10, 11, 12, 15] > > > > I went ahead and used unittest, at the cost of three lines of > > 'boilerplate' code. I added a case with a final consecutive sequence. > > Good thing, because it initially failed because I initially forgot to > > check tem after the loop. > > > > import unittest > > > > def consec(iterable): > > "Yield blocks of consecutive integers as a list." > > it = iter(iterable) > > first = next(it) > > tem = [first] > > for n in it: > > # tem is a non-empty list of consecutive ints > > if n == tem[-1] + 1: > > tem.append(n) > > else: > > if len(tem) >= 2: > > yield tem > > tem = [n] > > if len(tem) >= 2: > > yield tem > > > > class Test(unittest.TestCase): > > def test_consec(self): > > def eq(seq, blocks): > > self.assertEqual(list(consec(seq)), blocks) > > eq((), []) > > eq([1], []) > > eq([1,2,3], [[1,2,3]]) # block at beginning or end > > eq([-1, 1,2,3, 5], [[1,2,3]]) # block in middle > > eq((-1, 1,2,3, 5, 7,8,9, 11), [[1,2,3], [7,8,9]]) # 2 blocks > > > > unittest.main(verbosity=2) > > >>> > > test_consec (__main__.Test) ... ok > > > > ---------------------------------------------------------------------- > > Ran 1 test in 0.016s > > > > OK > > > > -- > > Terry Jan Reedy From sssdevelop at gmail.com Thu Jul 10 10:38:55 2014 From: sssdevelop at gmail.com (sssdevelop) Date: Thu, 10 Jul 2014 07:38:55 -0700 (PDT) Subject: Help me write better Code In-Reply-To: References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: <4313ba97-689c-4a69-acf2-6a9986d14baf@googlegroups.com> thank you so much! On Wednesday, July 9, 2014 11:46:41 PM UTC+5:30, Ian wrote: > On Wed, Jul 9, 2014 at 8:27 AM, sssdevelop wrote: > > > prev = 0 > > > blocks = [] > > > tmp = [] > > > last = 0 > > > for element in a: > > > if prev == 0: > > > > Is 0 allowed to be in the input list? What would happen if it were? > > > > > next > > > > This line doesn't do anything. It looks up the builtin function named > > next and then does nothing with it. I suspect you meant to use the > > keyword 'continue' here. > > > > > if tmp: > > > pass > > > else: > > > tmp.append(prev) > > > > if not tmp: > > tmp.append(prev) > > > > Also, give tmp a more meaningful name. Call it "current_block" or > > something descriptive like that. From sssdevelop at gmail.com Thu Jul 10 10:39:55 2014 From: sssdevelop at gmail.com (sssdevelop) Date: Thu, 10 Jul 2014 07:39:55 -0700 (PDT) Subject: Help me write better Code In-Reply-To: References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: <63a40b77-f3d5-45b4-bd11-ff9c099bdb67@googlegroups.com> Mark - thank you so much. You have suggested be new best tool/module. It's going to help me many places. Was not aware of such powerful tool. thank you, On Wednesday, July 9, 2014 9:14:01 PM UTC+5:30, Mark Lawrence wrote: > On 09/07/2014 15:27, sssdevelop wrote: > > > Hello, > > > > > > I have working code - but looking for better/improved code. Better coding practices, better algorithm :) > > > > > > Problem: Given sequence of increasing integers, print blocks of consecutive integers. > > > > > > Example: > > > > > > Input: [10, 11, 12, 15] > > > Output: [10, 11, 12] > > > > > > Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > > Outout: [67, 68], [91, 92, 93, 94] > > > > > > My code looks as below: > > > ----------------------------- > > > #!/usr/bin/python > > > a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > > #a = [] > > > #a = [10] > > > #a = [10, 11, 12, 15] > > > print "Input: " > > > print a > > > > > > prev = 0 > > > blocks = [] > > > tmp = [] > > > last = 0 > > > for element in a: > > > if prev == 0: > > > prev = element > > > next > > > if element == prev + 1: > > > if tmp: > > > pass > > > else: > > > tmp.append(prev) > > > tmp.append(element) > > > else: > > > if tmp: > > > blocks.append(tmp) > > > tmp = [] > > > > > > prev = element > > > > > > if tmp: > > > blocks.append(tmp) > > > > > > if blocks: > > > #print "I have repeated elements and those are:" > > > for b in blocks: > > > print b > > > > > > ----------------------- > > > > > > thank you in advance! > > > > > > > Adopted from here https://docs.python.org/3.0/library/itertools.html > > > > data = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]): > > group = list(map(operator.itemgetter(1), g)) > > if len(group) > 1: > > print(group) > > > > >>> > > [67, 68] > > [91, 92, 93, 94] > > >>> > > > > -- > > My fellow Pythonistas, ask not what our language can do for you, ask > > what you can do for our language. > > > > Mark Lawrence > > > > --- > > This email is free from viruses and malware because avast! Antivirus protection is active. > > http://www.avast.com From breamoreboy at yahoo.co.uk Thu Jul 10 10:51:19 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 10 Jul 2014 15:51:19 +0100 Subject: Help me write better Code In-Reply-To: <63a40b77-f3d5-45b4-bd11-ff9c099bdb67@googlegroups.com> References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> <63a40b77-f3d5-45b4-bd11-ff9c099bdb67@googlegroups.com> Message-ID: On 10/07/2014 15:39, sssdevelop wrote: > > Mark - thank you so much. You have suggested be new best tool/module. > It's going to help me many places. Was not aware of such powerful tool. > > thank you, > I'm pleased to see that you have several answers. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. Would you also not top post. In other words, place your replies at the bottom or interspersed between the paragraphs that you're replying to, thanks again. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rxjwg98 at gmail.com Thu Jul 10 11:23:01 2014 From: rxjwg98 at gmail.com (fl) Date: Thu, 10 Jul 2014 08:23:01 -0700 (PDT) Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? In-Reply-To: References: Message-ID: <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> On Thursday, July 10, 2014 10:14:14 AM UTC-4, Chris "Kwpolska" Warrick wrote: > > > > > Please don't learn from this link. It's from 2001. You should learn > > from modern documentation: https://docs.python.org/ (if not running > > 3.4.x, change the version in the top) > > > > You also should not read the language reference, it's meant for people > > who really care about what's under the hood. The official tutorial is > > better for learning: https://docs.python.org/3/tutorial/index.html > > Thank you for your advice. My OP was originated from a question from this link: https://wiki.python.org/moin/RegularExpression It has several useful examples. Several of them are not clear to me. Please explain it to me. Is '\A' the same with '^'? Is '\Z' the same with '$'? Thanks, From rxjwg98 at gmail.com Thu Jul 10 11:37:18 2014 From: rxjwg98 at gmail.com (fl) Date: Thu, 10 Jul 2014 08:37:18 -0700 (PDT) Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example Message-ID: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Hi, This example is from the link: https://wiki.python.org/moin/RegularExpression I have thought about it quite a while without a clue yet. I notice that it uses double quote ", in contrast to ' which I see more often until now. It looks very complicated to me. Could you simplified it to a simple example? Thanks, import re split_up = re.split(r"(\(\([^)]+\)\))", "This is a ((test)) of the ((emergency broadcasting station.))") ...which produces: ["This is a ", "((test))", " of the ", "((emergency broadcasting station.))" ] From alexjeffburke at gmail.com Thu Jul 10 12:33:34 2014 From: alexjeffburke at gmail.com (Alex Burke) Date: Thu, 10 Jul 2014 18:33:34 +0200 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On 9 July 2014 09:00, Steven D'Aprano wrote: > At the moment, Python has two (in)equality operators, == and != which > call __eq__ and __ne__ methods. Some problems with those: > > > * Many people expect == to always be reflexive (that is, x == x for > every x) but classes which customise __eq__ may not be. > > * The == operator requires __eq__ to return True or False > (or NotImplemented) and raises TypeError if it doesn't, which > makes it impossible to use == with (say) three-valued or fuzzy > logic. > > > I propose: > > * The == operator be redefined to *always* assume reflexivity, that > is, it first compares the two arguments using `is` before calling > the __eq__ methods. > > * That's a backwards-incompatible change, so you need to enable it > using "from __future__ import equals" in Python 3.5, and then to > become the default behaviour in 3.6. (course I forgot to reply-all first first time I sent this) Hi, Aside from really reaching for Python for all my own projects (mostly due to enjoying the language and it's design) the day job is mostly writing server side code for Javascript on node.js. With that perspective I really think those extra operators will cause confusion - granted the distinction between == and === is for different reasons there but it's just complexity to need to explain why there are different modes of comparison. With == and is I think when to use which is much more clear cut. That being said though the point you raised that: different objects can implement __eq__ such that it may or may not be reflexive in different cases could do with an answer. It's the implicitness and differing behaviour that get me, and it seems to be one of the roots of the disagreement. When should NaN compare equal, when not etc. So, (this is likely a terrible idea) what if == was made always always reflexive and a from __future__ to have any NaN being compared raise a new NonReflexiveComparison exception? Advantages: * no equality special cases to explain * make potentially meaningless comparisons immediately clear * if you really want to compare NaNs you can catch the case and return math.isnan(left) and math.isnan(right) The obvious issue is possibility of exceptions from arbitrary == comparisons. PS hoping these comments comments might prove useful :-) Thanks, Alex J Burke. From drsalists at gmail.com Thu Jul 10 12:41:22 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 10 Jul 2014 09:41:22 -0700 Subject: Solution-resistant AttributeError: 'modle' object has no attribute... Message-ID: Hi folks. I'm having trouble with a strange AttributeError. I'm using RQ (Redis Queue) and Django, both of which are new to me, so perhaps they are somehow relevant. Anyway, the traceback looks like: Traceback (most recent call last): File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/worker.py", line 479, in perform_job rv = job.perform() File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/job.py", line 466, in perform self._result = self.func(*self.args, **self.kwargs) File "/home/ec2-user/science_server/higgins/tasks.py", line 276, in session_retrieval_manager dummy = higgins.models.extract_guid_from_visi_filename AttributeError: 'module' object has no attribute 'extract_guid_from_visi_filename' But looking in higgins/models.py, I see a def for extract_guid_from_visi_filename. Here's a list of things I've checked/tried, compiled from the first two pages of google hits on the error, and a couple of my own guesses: # circular dependency in imports? No. # module of same name? No, because __file__ looks correct # Not in Django's settings.py's INSTALLED_APPS? No, higgins is present in INSTALLED_APPS # No __init__.py? There is an __init__.py in the higgins directory # Old .pyc? No, I've removed it and same result # __all__ present? No # Need to from module import function? No, does not help. BTW, pylint doesn't flag an error. BTW, I can import and retrieve the function fine in django's "python manage.py shell". If I sys.stderr.write the module's __file__, it gives a full path that looks as expected. If I sys.stderr.write(dir(higgins.models)), it has some of the symbols from higgins.models, but some of them are missing, including the function I want. It's as though an old version of the module is being seen, rather than the current version. Anyone have any (further) suggestions for me? Thanks! From python at mrabarnett.plus.com Thu Jul 10 12:48:25 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jul 2014 17:48:25 +0100 Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? In-Reply-To: <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> References: <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> Message-ID: <53BEC3D9.60004@mrabarnett.plus.com> On 2014-07-10 16:23, fl wrote: > On Thursday, July 10, 2014 10:14:14 AM UTC-4, Chris "Kwpolska" Warrick wrote: >> > >> >> >> Please don't learn from this link. It's from 2001. You should learn >> >> from modern documentation: https://docs.python.org/ (if not running >> >> 3.4.x, change the version in the top) >> >> >> >> You also should not read the language reference, it's meant for people >> >> who really care about what's under the hood. The official tutorial is >> >> better for learning: https://docs.python.org/3/tutorial/index.html >> >> > Thank you for your advice. My OP was originated from a question from this link: > https://wiki.python.org/moin/RegularExpression > > It has several useful examples. Several of them are not clear to me. Please > explain it to me. > > Is '\A' the same with '^'? > Is '\Z' the same with '$'? > \A matches at the start of the string. \Z matches at the end of the string. Normally, ^ matches at the start of the string, but if the re.MULTILINE flag is turned on, it matches at the start of a line. Normally, $ matches at the end of the string, or just before the final '\n' if that '\n' is the final character, but if the re.MULTILINE flag is turned on, it matches at the end of a line. From __peter__ at web.de Thu Jul 10 12:49:28 2014 From: __peter__ at web.de (Peter Otten) Date: Thu, 10 Jul 2014 18:49:28 +0200 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: fl wrote: > Hi, > > This example is from the link: > > https://wiki.python.org/moin/RegularExpression > > > I have thought about it quite a while without a clue yet. I notice that it > uses double quote ", in contrast to ' which I see more often until now. > It looks very complicated to me. Could you simplified it to a simple > example? Just break it into its components. "(...)" in the context of re.split() keeps the delimiters while just "..." does not. Example: >>> re.split("a+", "abbaaababa") ['', 'bb', 'b', 'b', ''] >>> re.split("(a+)", "abbaaababa") ['', 'a', 'bb', 'aaa', 'b', 'a', 'b', 'a', ''] r"\(" matches the openening parenthesis. The "(" has to be escaped because it otherwise has a special meaning (begin group) in a regex. "[abc]" matches a, b, or c. A leading ^ inverts the set, so "[^abc]" matches anything but a, b, or c. Therefore "[^)]" matches anything but the closing parenthesis. The complete regex then is: match two opening parens, then one or more chars that are not closing parens, then two closing parens, and make the complete group part of the resulting list. PS: Note that sometimes the re.DEBUG flag may be helpful in understanding noisy regexes: subpattern 1 literal 40 literal 40 max_repeat 1 4294967295 not_literal 41 literal 41 literal 41 <_sre.SRE_Pattern object at 0x7f5740455c90> > import re > split_up = re.split(r"(\(\([^)]+\)\))", > "This is a ((test)) of the ((emergency broadcasting > station.))") > > > ...which produces: > > > ["This is a ", "((test))", " of the ", "((emergency broadcasting > [station.))" ] From rosuav at gmail.com Thu Jul 10 12:58:04 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jul 2014 02:58:04 +1000 Subject: Solution-resistant AttributeError: 'modle' object has no attribute... In-Reply-To: References: Message-ID: On Fri, Jul 11, 2014 at 2:41 AM, Dan Stromberg wrote: > It's as though an old version of the module is being > seen, rather than the current version. > > Anyone have any (further) suggestions for me? > Wipe out *.pyc and try again? Restart any processes that are running Django, in case they have it cached in memory? This is something Python isn't really designed for (coping with multiple versions of a module simultaneously). The Python import machinery seems to assume that, across one process's lifetime, all .py and .pyc (etc) files ever used will remain pristine, and can safely be cached etc. There's no good mechanism for saying "Hey, Python, I just updated this file, can you load the new version please?" - every method I've seen for doing so seems to require fiddling around with internals, and/or extreme risk of getting the wrong version. ChrisA From python at mrabarnett.plus.com Thu Jul 10 13:01:18 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 10 Jul 2014 18:01:18 +0100 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: <53BEC6DE.6050606@mrabarnett.plus.com> On 2014-07-10 16:37, fl wrote: > Hi, > > This example is from the link: > > https://wiki.python.org/moin/RegularExpression > > > I have thought about it quite a while without a clue yet. I notice that it uses > double quote ", in contrast to ' which I see more often until now. > It looks very complicated to me. Could you simplified it to a simple example? > > > Thanks, > > > > > > import re > split_up = re.split(r"(\(\([^)]+\)\))", > "This is a ((test)) of the ((emergency broadcasting station.))") > > > ...which produces: > > > ["This is a ", "((test))", " of the ", "((emergency broadcasting station.))" ] > No it doesn't; you've omitted the final string. The regex means: ( Start of capture group. \( Literal "(". \( Literal "(". [^)]+ One or more repeats of any character except a literal ")". \) Literal ")". \) Literal ")". ) End of capture group. .split returns a list of the parts of the string between the matches, and if, as in this example, there are capture groups, then those too: [ 'This is a ', # The part before the first # match. '((test))', # The first match (group 1). ' of the ', # The part between the first # and second matches. '((emergency broadcasting station.))', # The second match. '' # The part after the second # match. ] From rxjwg98 at gmail.com Thu Jul 10 13:01:39 2014 From: rxjwg98 at gmail.com (fl) Date: Thu, 10 Jul 2014 10:01:39 -0700 (PDT) Subject: I am confused about ' and " Message-ID: Hi, It is still in the Regular expression operations concept, this link: has example using single quote mark: ' https://docs.python.org/2/library/re.html#re.split While in this link: https://docs.python.org/3/howto/regex.html It gives table with quote: " Regular String Raw string "ab*" r"ab*" "\\\\section" r"\\section" "\\w+\\s+\\1" r"\w+\s+\1" and link: https://docs.python.org/2/library/re.html m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") Please tell me because I have looked it around for one hour about it. Thanks, From joel.goldstick at gmail.com Thu Jul 10 13:05:49 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 10 Jul 2014 13:05:49 -0400 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: On Thu, Jul 10, 2014 at 11:37 AM, fl wrote: > Hi, > > This example is from the link: > > https://wiki.python.org/moin/RegularExpression > > > I have thought about it quite a while without a clue yet. I notice that it uses > double quote ", in contrast to ' which I see more often until now. Double quotes or single quotes -- doesn't matter. > It looks very complicated to me. Could you simplified it to a simple example? > You might read up first here: https://docs.python.org/2/library/re.html If you are just new to learning python, regular expressions are not a good place to start. But if you insist, the page you are looking at is more of a cheat sheet . Try the python docs, and tutorial first. Or google. > > Thanks, > > > > > > import re > split_up = re.split(r"(\(\([^)]+\)\))", > "This is a ((test)) of the ((emergency broadcasting station.))") > > The outer parens are for grouping. I'm not good at regexes but it looks like it wants two open parens followed by any number of characters that are anything but a close paren, followed by two close parens. So whenever it finds that pattern it splits off what is on either side of it. > ...which produces: > > > ["This is a ", "((test))", " of the ", "((emergency broadcasting station.))" ] > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com From gordon at panix.com Thu Jul 10 13:16:18 2014 From: gordon at panix.com (John Gordon) Date: Thu, 10 Jul 2014 17:16:18 +0000 (UTC) Subject: I am confused about ' and " References: Message-ID: In fl writes: > Please tell me because I have looked it around for one hour about it. There is no difference between ' and " when used to enclose strings, with one exception: a double-quoted string can contain single-quotes without the need to escape them with a backslash, and vice-versa. For example: string2 = "It's a beautiful day in the neighboorhood." string1 = 'He said to me, "Hello Thomas."' -- John Gordon Imagine what it must be like for a real medical doctor to gordon at panix.com watch 'House', or a real serial killer to watch 'Dexter'. From drsalists at gmail.com Thu Jul 10 13:23:37 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 10 Jul 2014 10:23:37 -0700 Subject: Solution-resistant AttributeError: 'modle' object has no attribute... In-Reply-To: References: Message-ID: On Thu, Jul 10, 2014 at 9:41 AM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks like: > Traceback (most recent call last): > File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/worker.py", > line 479, in perform_job > rv = job.perform() > File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/job.py", > line 466, in perform > self._result = self.func(*self.args, **self.kwargs) > File "/home/ec2-user/science_server/higgins/tasks.py", line 276, in > session_retrieval_manager > dummy = higgins.models.extract_guid_from_visi_filename > AttributeError: 'module' object has no attribute > 'extract_guid_from_visi_filename' It turned out I needed to restart my RQ (Redis Queue) processes. From ian.g.kelly at gmail.com Thu Jul 10 12:22:20 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 10 Jul 2014 10:22:20 -0600 Subject: What does (A ``quote'' is the character used to open the string, i.e. either ' or ".) mean? In-Reply-To: <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> References: <47595855-295a-43ee-8b4b-98dda4466669@googlegroups.com> Message-ID: On Thu, Jul 10, 2014 at 9:23 AM, fl wrote: > Is '\A' the same with '^'? > Is '\Z' the same with '$'? The meanings of these are explained at: https://docs.python.org/library/re.html#regular-expression-syntax Outside of multiline mode, they're equivalent. In multiline mode, ^ and $ will also match at the beginning and end of individual lines, while \A and \Z still only match the beginning and end of the input string. From joel.goldstick at gmail.com Thu Jul 10 13:31:56 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 10 Jul 2014 13:31:56 -0400 Subject: Solution-resistant AttributeError: 'modle' object has no attribute... In-Reply-To: References: Message-ID: On Thu, Jul 10, 2014 at 12:41 PM, Dan Stromberg wrote: > Hi folks. > > I'm having trouble with a strange AttributeError. I'm using RQ (Redis > Queue) and Django, both of which are new to me, so perhaps they are > somehow relevant. > > Anyway, the traceback looks like: > Traceback (most recent call last): > File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/worker.py", > line 479, in perform_job > rv = job.perform() > File "/home/ec2-user/miniconda/envs/sciencedb/lib/python2.7/site-packages/rq/job.py", > line 466, in perform > self._result = self.func(*self.args, **self.kwargs) > File "/home/ec2-user/science_server/higgins/tasks.py", line 276, in > session_retrieval_manager > dummy = higgins.models.extract_guid_from_visi_filename > AttributeError: 'module' object has no attribute > 'extract_guid_from_visi_filename' Do you need to add parens? is this a method, not at attribute? dummy = higgins.models.extract_guid_from_visi_filename() > > But looking in higgins/models.py, I see a def for > extract_guid_from_visi_filename. > > Here's a list of things I've checked/tried, compiled from the first > two pages of google hits on the error, and a couple of my own guesses: > # circular dependency in imports? No. > # module of same name? No, because __file__ looks correct > # Not in Django's settings.py's INSTALLED_APPS? No, higgins is > present in INSTALLED_APPS > # No __init__.py? There is an __init__.py in the higgins directory > # Old .pyc? No, I've removed it and same result > # __all__ present? No > # Need to from module import function? No, does not help. > > BTW, pylint doesn't flag an error. > > BTW, I can import and retrieve the function fine in django's "python > manage.py shell". > > If I sys.stderr.write the module's __file__, it gives a full path that > looks as expected. > > If I sys.stderr.write(dir(higgins.models)), it has some of the symbols > from higgins.models, but some of them are missing, including the > function I want. It's as though an old version of the module is being > seen, rather than the current version. > > Anyone have any (further) suggestions for me? > > Thanks! > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com From rosuav at gmail.com Thu Jul 10 13:57:17 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jul 2014 03:57:17 +1000 Subject: I am confused about ' and " In-Reply-To: References: Message-ID: On Fri, Jul 11, 2014 at 3:01 AM, fl wrote: > Please tell me because I have looked it around for one hour about it. > It's high time you started at the beginning, rather than trying to learn regexps without understanding Python. https://docs.python.org/3/tutorial/index.html Start there. You will much better understand Python, and you won't have to ask for help with these sorts of things. ChrisA From marko at pacujo.net Thu Jul 10 13:56:09 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 10 Jul 2014 20:56:09 +0300 Subject: Emperor's New Coroutines? References: <87lhs5h5dn.fsf@elektro.pacujo.net> Message-ID: <877g3l85dy.fsf@elektro.pacujo.net> Marko Rauhamaa : > The asyncio module comes with coroutine support. Investigating the > topic on the net reveals that FSM's are for old people and the brave > new world uses coroutines. Unfortunately, all examples I could find > seem to be overly simplistic, and I'm left thinking coroutines have > few practical uses in network programming. > > [...] > > but how would I modify the philosopher code to support such master > resets? Ok. I think I have found the answer to my question: asyncio.wait(coroutines, return_when=asyncio.FIRST_COMPLETED) That facility makes it possible to multiplex between several stimuli. The code below implements a modified dining philosophers protocol. The philosophers are accompanied by an assistant who occasionally prods the philosophers to immediately resume thinking, thus breaking the deadlock. Whether the coroutine style is easier on the eye than, say, callbacks and state machines is a matter of personal opinion. Marko ===clip-clip-clip======================================================= #!/usr/bin/env python3 import os, sys, asyncio, random, enum, time T0 = time.time() def main(): loop = asyncio.get_event_loop() try: fork1 = Fork() fork2 = Fork() fork3 = Fork() nag = Nag() loop.run_until_complete(asyncio.wait([ Philosopher("Plato", fork1, fork2, nag).philosophize(), Philosopher("Nietsche", fork2, fork3, nag).philosophize(), Philosopher("Hintikka", fork3, fork1, nag).philosophize(), assistant(nag) ])) finally: loop.close() class Philosopher: def __init__(self, name, left, right, nag): self.name = name self.left = left self.right = right self.nag = nag @asyncio.coroutine def philosophize(self): yield from self.nag.acquire() try: while True: self.nag_count = self.nag.count pending = yield from self.think() if pending is None: continue pending = yield from self.grab_fork("left", self.left, pending) if pending is None: continue try: pending = yield from self.wonder_absentmindedly(pending) if pending is None: continue pending = yield from self.grab_fork( "right", self.right, pending) if pending is None: continue try: pending = yield from self.dine(pending) if pending is None: continue finally: self.say("put back right fork") self.right.release() pending = yield from self.wonder_absentmindedly(pending) if pending is None: continue finally: self.say("put back left fork") self.left.release() finally: self.nag.release() def say(self, message): report("{} {}".format(self.name, message)) def nagged(self): return self.nag.count > self.nag_count @asyncio.coroutine def think(self): self.say("thinking") result, pending = yield from multiplex( identify(Impulse.TIME, random_delay()), identify(Impulse.NAG, self.nag.wait_for(self.nagged))) if result is Impulse.NAG: self.say("nagged") return None assert result is Impulse.TIME self.say("hungry") return pending @asyncio.coroutine def grab_fork(self, which, fork, pending): self.say("grabbing {} fork".format(which)) result, pending = yield from multiplex( identify(Impulse.FORK, fork.acquire()), *pending) if result is Impulse.NAG: self.say("has been nagged") return None assert result is Impulse.FORK self.say("got {} fork".format(which)) return pending @asyncio.coroutine def wonder_absentmindedly(self, pending): self.say("now, what was I doing?") result, pending = yield from multiplex( identify(Impulse.TIME, random_delay()), *pending) if result is Impulse.NAG: self.say("nagged") return None assert result is Impulse.TIME self.say("oh, that's right!") return pending @asyncio.coroutine def dine(self, pending): self.say("eating") result, pending = yield from multiplex( identify(Impulse.TIME, random_delay()), *pending) if result is Impulse.NAG: self.say("nagged") return None assert result is Impulse.TIME self.say("that hit the spot!") return pending @asyncio.coroutine def assistant(nag): n = 1 while True: report("assistant sleep {}".format(n)) yield from asyncio.sleep(n) report("assistant nag") yield from nag.nag() n += 1 def report(info): sys.stdout.write("{:9.3f} {}\n".format(time.time() - T0, info)) class Impulse(enum.Enum): TIME = 1 NAG = 2 FORK = 3 class Fork(asyncio.Lock): pass class Nag(asyncio.Condition): count = 0 @asyncio.coroutine def nag(self): yield from self.acquire() try: self.count += 1 self.notify_all() finally: self.release() @asyncio.coroutine def random_delay(): yield from asyncio.sleep(random.randint(1, 100) / 10) @asyncio.coroutine def identify(result, coroutine): yield from coroutine return result @asyncio.coroutine def multiplex(*coroutines): done, pending = yield from asyncio.wait( coroutines, return_when=asyncio.FIRST_COMPLETED) return done.pop().result(), pending if __name__ == '__main__': main() ===clip-clip-clip======================================================= From joel.goldstick at gmail.com Thu Jul 10 14:12:08 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Thu, 10 Jul 2014 14:12:08 -0400 Subject: I am confused about ' and " In-Reply-To: References: Message-ID: On Thu, Jul 10, 2014 at 1:01 PM, fl wrote: > Hi, > > It is still in the Regular expression operations concept, this link: You must have missed my comment about quote and double quote. In python you can write a string using either. Just make sure if you start with double quote, you must end with double quote. Before tackling regular expressions, go to the python tutorial and learn about strings. > > has example using single quote mark: ' > > https://docs.python.org/2/library/re.html#re.split > > > While in this link: > > https://docs.python.org/3/howto/regex.html > > > It gives table with quote: " > > Regular String Raw string > "ab*" r"ab*" > "\\\\section" r"\\section" > "\\w+\\s+\\1" r"\w+\s+\1" > > > and link: > > https://docs.python.org/2/library/re.html > > > m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") > > > Please tell me because I have looked it around for one hour about it. > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com From kwpolska at gmail.com Thu Jul 10 14:25:39 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Thu, 10 Jul 2014 20:25:39 +0200 Subject: I am confused about ' and " In-Reply-To: References: Message-ID: On Jul 10, 2014 7:53 PM, "fl" wrote: > > Hi, > > It is still in the Regular expression operations concept, this link: > > has example using single quote mark: ' > > https://docs.python.org/2/library/re.html#re.split > > > While in this link: > > https://docs.python.org/3/howto/regex.html > > > It gives table with quote: " > > Regular String Raw string > "ab*" r"ab*" > "\\\\section" r"\\section" > "\\w+\\s+\\1" r"\w+\s+\1" > > > and link: > > https://docs.python.org/2/library/re.html > > > m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") > > > Please tell me because I have looked it around for one hour about it. > > Thanks, > -- > https://mail.python.org/mailman/listinfo/python-list Both characters (' and ") are interchangeable, the only difference being the one you need to escape if you want to use in a string: "you're" vs 'you\'re', and the other way around. Also, please read the Python tutorial[0] before getting into bigger things, and please don?t mix documentation versions. If you were to read the tutorial, you?d quickly find out, that > 3.1.2. Strings > > Besides numbers, Python can also manipulate strings, which can be > expressed in several ways. They can be enclosed in single quotes > ('...') or double quotes ("...") with the same result [2]. \ can be > used to escape quotes. > > [snip] > > [2] Unlike other languages, special characters such as \n have the > same meaning with both single ('...') and double ("...") quotes. > The only difference between the two is that within single quotes > you don?t need to escape "(but you have to escape \') and vice > versa. [0]: https://docs.python.org/2/tutorial/index.html -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From rustompmody at gmail.com Thu Jul 10 14:38:09 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 10 Jul 2014 11:38:09 -0700 (PDT) Subject: Help me write better Code In-Reply-To: References: <3a608dd2-d8bf-429e-af21-ce5ac8f18272@googlegroups.com> Message-ID: On Wednesday, July 9, 2014 9:14:01 PM UTC+5:30, Mark Lawrence wrote: > On 09/07/2014 15:27, sssdevelop wrote: > > Hello, > > I have working code - but looking for better/improved code. Better coding practices, better algorithm :) > > Problem: Given sequence of increasing integers, print blocks of consecutive integers. > > Example: > > Input: [10, 11, 12, 15] > > Output: [10, 11, 12] > > Input: [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > Outout: [67, 68], [91, 92, 93, 94] > > My code looks as below: > > ----------------------------- > > #!/usr/bin/python > > a = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > > #a = [] > > #a = [10] > > #a = [10, 11, 12, 15] > > print "Input: " > > print a > > prev = 0 > > blocks = [] > > tmp = [] > > last = 0 > > for element in a: > > if prev == 0: > > prev = element > > next > > if element == prev + 1: > > if tmp: > > pass > > else: > > tmp.append(prev) > > tmp.append(element) > > else: > > if tmp: > > blocks.append(tmp) > > tmp = [] > > prev = element > > if tmp: > > blocks.append(tmp) > > if blocks: > > #print "I have repeated elements and those are:" > > for b in blocks: > > print b > > ----------------------- > > thank you in advance! > Adopted from here https://docs.python.org/3.0/library/itertools.html > data = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] > for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]): > group = list(map(operator.itemgetter(1), g)) > if len(group) > 1: > print(group) > [67, 68] > [91, 92, 93, 94] > -- Mark's version without the print. Which says in a different way, Terry's point-2 : > 2. Separate interface code that gets input and presents output from the > function that processes the increasing sequence. The function should not > care whether the ints come from a user, file, or calculation. $ python3 Python 3.4.1 (default, Jun 9 2014, 10:28:44) [GCC 4.8.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from operator import itemgetter >>> from itertools import groupby >>> data = [51, 53, 55, 67, 68, 91, 92, 93, 94, 99] >>> [group for k,g in groupby(enumerate(data), lambda t:t[0]-t[1]) ... for group in [list(map(itemgetter(1), g))] ... if len(group) > 1 ... ... ] [[67, 68], [91, 92, 93, 94]] >>> You can replace the outermost '[]' with '()' From fomcl at yahoo.com Thu Jul 10 15:15:16 2014 From: fomcl at yahoo.com (Albert-Jan Roskam) Date: Thu, 10 Jul 2014 12:15:16 -0700 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: <1405019716.74147.YahooMailNeo@web163804.mail.gq1.yahoo.com> ----- Original Message ----- > From: Joel Goldstick > To: fl > Cc: "python-list at python.org" > Sent: Thursday, July 10, 2014 7:05 PM > Subject: Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example > > On Thu, Jul 10, 2014 at 11:37 AM, fl wrote: >> Hi, >> >> This example is from the link: >> >> https://wiki.python.org/moin/RegularExpression >> >> >> I have thought about it quite a while without a clue yet. I notice that it > uses >> double quote ", in contrast to ' which I see more often until now. > > Double quotes or single quotes -- doesn't matter. > >> It looks very complicated to me. Could you simplified it to a simple > example? >> > You might read up first here: https://docs.python.org/2/library/re.html > > If you are just new to learning python, regular expressions are not a > good place to start.? But if you insist, the page you are looking at > is more of a cheat sheet . The free sample chapter from Mark Summerfield's book is about regular expressions: http://www.informit.com/content/images/9780321680563/samplepages/0321680561_Sample.pdf That whole book is superb, and the regex chapter is no exception. From as at sci.fi Thu Jul 10 15:40:21 2014 From: as at sci.fi (Anssi Saari) Date: Thu, 10 Jul 2014 22:40:21 +0300 Subject: open() and EOFError References: <53ba11fc$0$29985$c3e8da3$5496439d@news.astraweb.com> <53ba538d$0$2926$c3e8da3$76491128@news.astraweb.com> <20140708102033.13efb3a4@bigbox.christie.dr> Message-ID: Roy Smith writes: > I once knew a guy who linked /dev/tty.c to /dev/tty, then he could do > "cc /dev/tty.c" and type a C program in to the compiler from the > terminal. I thought some old C compilers took input from stdin without that kind of trickery? Oh, looks like modern gcc does it too, as long as the language is specified with -x. From steve+comp.lang.python at pearwood.info Thu Jul 10 18:50:52 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 10 Jul 2014 22:50:52 GMT Subject: Solution-resistant AttributeError: 'modle' object has no attribute... References: Message-ID: <53bf18cb$0$9505$c3e8da3$5496439d@news.astraweb.com> On Thu, 10 Jul 2014 13:31:56 -0400, Joel Goldstick wrote: >> dummy = higgins.models.extract_guid_from_visi_filename >> AttributeError: 'module' object has no attribute >> 'extract_guid_from_visi_filename' > > Do you need to add parens? is this a method, not at attribute? > dummy = higgins.models.extract_guid_from_visi_filename() That cannot be the solution. Before extract_guid_from_visi_filename can be called, it first has to be looked up, and that fails with AttributeError: 'module' object has no attribute 'extract_guid_from_visi_filename' Whenever I get a mysterious "module has no such attribute" error, I immediately check two things: - check for typos: have I misspelled the function I want? - check for shadowing: am I looking in the module I think I'm looking? have I accidentally added a module with the same name? -- Steven From cs at zip.com.au Thu Jul 10 20:20:36 2014 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 11 Jul 2014 10:20:36 +1000 Subject: context manager based alternative to Re: Proposal: === and !=== Message-ID: <20140711002036.GA68939@cskk.homeip.net> operators Reply-To: In-Reply-To: <20140709231623.GA66358 at cskk.homeip.net> I posted this the other day and haven't seen a response, not even a scathing rejection... Here's an alternative proposal that doesn't involve a new operator. Consider this code snippet: with float.behaviour(nan_eq=True): ... code here ... This is intended to set a thread-local behaviour flag on the entire float type and undo it on exit from the context. This has the following advantages: - it is very easy to use, and makes plain that this particular chunk of code has special rules - it makes NaN == behave as requested in a particular window - it effectively wraps all code called inside the suite - because it is thread local it doesn't asynchronously affect other running code - it doesn't introduce a new operator - it affects a tightly constrainted behaviour, and can obviously be extended to other special cases if they arise, for example to only make the same flavour of NaN compare equal - if the special Nan != Nan checks occur only in the Nan instances themselves (eg by monkey patching __eq__ onto one) then it should not affect performance outside the NaN instances The downside is that it could break code depending on NaN being nonreflexive _if_ that code is called within the suite. Personally, I would take this over a new and only-subtly-different-from-== "===" operator. It also seems to give more control to the programmer, in that they can set the domain in which the behaviour obtains. Cheers, Cameron Simpson Q: How many user support people does it take to change a light bulb? A: We have an exact copy of the light bulb here and it seems to be working fine. Can you tell me what kind of system you have? From ethan at stoneleaf.us Thu Jul 10 20:34:17 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Thu, 10 Jul 2014 17:34:17 -0700 Subject: context manager based alternative to Re: Proposal: === and !=== In-Reply-To: <20140711002036.GA68939@cskk.homeip.net> References: <20140711002036.GA68939@cskk.homeip.net> Message-ID: <53BF3109.4070604@stoneleaf.us> On 07/10/2014 05:20 PM, Cameron Simpson wrote: > > I posted this the other day and haven't seen a response, not even a scathing rejection... > > Here's an alternative proposal that doesn't involve a new operator. [snip float-context manager stuff] Decimal has a context manager like that already (I don't know if it supports allowing NaNs to equal each other, though). Rather than adding the whole thing to float, perhaps extending Decimal's context with that option is a possible route. I would also prefer something like this to a new equals operator. -- ~Ethan~ From roy at panix.com Thu Jul 10 21:17:28 2014 From: roy at panix.com (Roy Smith) Date: Thu, 10 Jul 2014 21:17:28 -0400 Subject: context manager based alternative to Re: Proposal: === and !=== References: Message-ID: In article , Cameron Simpson wrote: > Q: How many user support people does it take to change a light bulb? > A: We have an exact copy of the light bulb here and it seems to be > working fine. Can you tell me what kind of system you have? So, what are we talking about here? my_lightbulb == your_lightbulb, or my_lightbulb === your_lightbulb, or my_lightbulb is your_lightbulb? Or just sha1(my_lightbulb) == sha1(your_lightbulb)? From fk26541598fk at gmail.com Thu Jul 10 21:20:46 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Thu, 10 Jul 2014 18:20:46 -0700 (PDT) Subject: How can i get http body?? In-Reply-To: References: <4574254f-e813-4f16-bafb-cbd649496095@googlegroups.com> Message-ID: <28c2db6c-952c-4ca9-af22-7a877ae8a65b@googlegroups.com> Got it Thanks you From cs at zip.com.au Thu Jul 10 21:29:34 2014 From: cs at zip.com.au (Cameron Simpson) Date: Fri, 11 Jul 2014 11:29:34 +1000 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: <20140711012934.GA41427@cskk.homeip.net> On 10Jul2014 08:37, fl wrote: >This example is from the link: > >https://wiki.python.org/moin/RegularExpression > >I have thought about it quite a while without a clue yet. >I notice that it uses >double quote ", in contrast to ' which I see more often until now. With raw strings (r', r") this doesn't matter. I tend to use r' myself. You want raw strings with regular expressions because otherwise their heavy use of sloshes "\" overlap with Python's use of sloshes, making everything harder. >It looks very complicated to me. Could you simplified it to a simple example? > >import re >split_up = re.split(r"(\(\([^)]+\)\))", > "This is a ((test)) of the ((emergency broadcasting station.))") > >...which produces: > >["This is a ", "((test))", " of the ", "((emergency broadcasting station.))" ] Rip off the python punctuation and get the regexp itself: (\(\([^)]+\)\)) then start from the inside out: [^)] Any character except a closing bracket. + One or more of the preceeding. Therefore: [^)]+ One or more characters which are not closing brackets. Also phrased: at least one character which is not a closing bracket. Outside this are \( and \): these are literal opening and closing bracket characters. So: \(\([^)]+\)\) Two opening brackets, then at least one character which is not a closing bracket, then two closing brackets. The outermost ( and ) are regexp grouping brackets, not text. On their own you don't need them, but they mark out the regexp between them for later reference or for use with a repeating modifier like ?, * or +. So in this instance they do not add anything special to the regexp. Given the above inside-to-out explaination, does that explain the re.split result for you? Cheers, Cameron Simpson I thought the DoD was a bunch of licensed squids. The last thing you need is a bunch of unregulated, amateur squids running loose. - David Wood From roy at panix.com Thu Jul 10 22:18:27 2014 From: roy at panix.com (Roy Smith) Date: Thu, 10 Jul 2014 22:18:27 -0400 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: In article , Cameron Simpson wrote: > Outside this are \( and \): these are literal opening and closing bracket > characters. So: > > \(\([^)]+\)\) > Two opening brackets, then at least one character which is not a > closing bracket, then two closing brackets. This is a perfectly OK way to write this, but personally I find my eyes start to glaze over whenever I see things like \(\(, so I would probably have written it as \({2}. I find that a little easier to read. So, for the whole thing up to this point: \({2}[^)]+\){2} although, even better would be to use to utterly awesome re.VERBOSE flag, and write it as: \({2} [^)]+ \){2} From python.list at tim.thechases.com Thu Jul 10 22:37:00 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Thu, 10 Jul 2014 21:37:00 -0500 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: <20140710213700.174e0ffc@bigbox.christie.dr> On 2014-07-10 22:18, Roy Smith wrote: > > Outside this are \( and \): these are literal opening and closing > > bracket characters. So: > > > > \(\([^)]+\)\) > > although, even better would be to use to utterly awesome >> re.VERBOSE > flag, and write it as: > > \({2} [^)]+ \){2} Or heck, use a multi-line verbose expression and comment it for clarity: r = re.compile(r""" ( # begin a capture group \({2} # two literal "(" characters [^)]+ # one or more non-close-paren characters \){2} # two literal ")" characters ) # close the capture group """, re.VERBOSE) -tkc From roy at panix.com Thu Jul 10 23:33:27 2014 From: roy at panix.com (Roy Smith) Date: Thu, 10 Jul 2014 23:33:27 -0400 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: In article , Tim Chase wrote: > On 2014-07-10 22:18, Roy Smith wrote: > > > Outside this are \( and \): these are literal opening and closing > > > bracket characters. So: > > > > > > \(\([^)]+\)\) > > > > although, even better would be to use to utterly awesome > >> re.VERBOSE > > flag, and write it as: > > > > \({2} [^)]+ \){2} > > Or heck, use a multi-line verbose expression and comment it for > clarity: > > r = re.compile(r""" > ( # begin a capture group > \({2} # two literal "(" characters > [^)]+ # one or more non-close-paren characters > \){2} # two literal ")" characters > ) # close the capture group > """, re.VERBOSE) > > -tkc Ugh. That reminds me of the classic commenting anti-pattern: l = [] # create an empty list for i in range(10): # iterate over the first 10 integers l.append(i) # append each one to the list From rosuav at gmail.com Fri Jul 11 00:31:25 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jul 2014 14:31:25 +1000 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: On Fri, Jul 11, 2014 at 1:33 PM, Roy Smith wrote: >> Or heck, use a multi-line verbose expression and comment it for >> clarity: >> >> r = re.compile(r""" >> ( # begin a capture group >> \({2} # two literal "(" characters >> [^)]+ # one or more non-close-paren characters >> \){2} # two literal ")" characters >> ) # close the capture group >> """, re.VERBOSE) >> >> -tkc > > Ugh. That reminds me of the classic commenting anti-pattern: > > l = [] # create an empty list > for i in range(10): # iterate over the first 10 integers > l.append(i) # append each one to the list Small difference between the two. Python is designed to be a readable language... regexps combine all the power and unreadability of machine code with the portability of machine code. ChrisA exaggerating... but only a little From rosuav at gmail.com Fri Jul 11 00:37:07 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 11 Jul 2014 14:37:07 +1000 Subject: context manager based alternative to Re: Proposal: === and !=== In-Reply-To: References: Message-ID: On Fri, Jul 11, 2014 at 11:17 AM, Roy Smith wrote: > In article , > Cameron Simpson wrote: > >> Q: How many user support people does it take to change a light bulb? >> A: We have an exact copy of the light bulb here and it seems to be >> working fine. Can you tell me what kind of system you have? > > So, what are we talking about here? my_lightbulb == your_lightbulb, or > my_lightbulb === your_lightbulb, or my_lightbulb is your_lightbulb? Or > just sha1(my_lightbulb) == sha1(your_lightbulb)? Probably type(my_lightbulb).__name__ == type(your_lightbulb).__name__, knowing the reliability of support people... I'm a bit wary of anything that makes a global, even if temporary, change to comparisons' behaviours. What happens if, deep in a call tree, something utterly unrelated happens to do a comparison of this nature? Does C-level code have to check this flag before comparing nans, or is this applicable only to the Python float objects and only when compared in Python? Is isnan() still usable? (Consider that x!=x == math.isnan(x) normally.) ChrisA From fk26541598fk at gmail.com Fri Jul 11 03:06:07 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Fri, 11 Jul 2014 00:06:07 -0700 (PDT) Subject: base64 convert to binary by binascii is that right? Message-ID: <6990c637-0d84-4ce4-b6ef-892290e56c74@googlegroups.com> conn = engine.connect() encoded = base64.b64encode(getbody) binary_string = binascii.a2b_base64(encoded) puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)") conn.execute(puresql,binary_string = binary_string) first getbody trans to base64 then i convert to binary is that right? getbody is '123AAA????' this is my result?123AAA\357\274\201\357\274\201\344\270\255\346\226\207 From alister.nospam.ware at ntlworld.com Fri Jul 11 04:00:45 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Fri, 11 Jul 2014 08:00:45 GMT Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: On Thu, 10 Jul 2014 23:33:27 -0400, Roy Smith wrote: > In article , > Tim Chase wrote: > >> On 2014-07-10 22:18, Roy Smith wrote: >> > > Outside this are \( and \): these are literal opening and closing >> > > bracket characters. So: >> > > >> > > \(\([^)]+\)\) >> > >> > although, even better would be to use to utterly awesome >> >> re.VERBOSE >> > flag, and write it as: >> > >> > \({2} [^)]+ \){2} >> >> Or heck, use a multi-line verbose expression and comment it for >> clarity: >> >> r = re.compile(r""" >> ( # begin a capture group >> \({2} # two literal "(" characters [^)]+ # one or more >> non-close-paren characters \){2} # two literal ")" >> characters >> ) # close the capture group """, re.VERBOSE) >> >> -tkc > > Ugh. That reminds me of the classic commenting anti-pattern: > > l = [] # create an empty list for i in range(10): # > iterate over the first 10 integers > l.append(i) # append each one to the list to some extent yes, but when it comes to regexs stating "The bleedin obvious" can be useful because as this whole thread shows it is not always "bleedin obvious" especially after a nights sleep -- "The identical is equal to itself, since it is different." -- Franco Spisani From info at egenix.com Fri Jul 11 04:05:29 2014 From: info at egenix.com (eGenix Team: M.-A. Lemburg) Date: Fri, 11 Jul 2014 10:05:29 +0200 Subject: ANN: eGenix mx Base Distribution 3.2.8 (mxDateTime, mxTextTools, etc.) Message-ID: <53BF9AC9.5070202@egenix.com> ________________________________________________________________________ ANNOUNCING eGenix.com mx Base Distribution mxDateTime, mxTextTools, mxProxy, mxURL, mxUID, mxBeeBase, mxStack, mxQueue, mxTools Version 3.2.8 Open Source Python extensions providing important and useful services for Python programmers. This announcement is also available on our web-site for online reading: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.8-GA.html ________________________________________________________________________ ABOUT The eGenix.com mx Base Distribution for Python is a collection of professional quality software tools which enhance Python's usability in many important areas such as fast text searching, date/time processing and high speed data types. The tools have a proven track record of being portable across many Unix and Windows platforms. You can write applications which use the tools on Windows and then run them on Unix platforms without change due to the consistent platform independent interfaces. Contents of the distribution: * mxDateTime - Easy to use Date/Time Library for Python * mxTextTools - Fast Text Parsing and Processing Tools for Python * mxProxy - Object Access Control for Python * mxBeeBase - On-disk B+Tree Based Database Kit for Python * mxURL - Flexible URL Data-Type for Python * mxUID - Fast Universal Identifiers for Python * mxStack - Fast and Memory-Efficient Stack Type for Python * mxQueue - Fast and Memory-Efficient Queue Type for Python * mxTools - Fast Everyday Helpers for Python The package also include a number of helpful smaller modules in the mx.Misc subpackage, such as mx.Misc.ConfigFile for config file parsing or mx.Misc.CommandLine to quickly write command line applications in Python. All available packages have proven their stability and usefulness in many mission critical applications and various commercial settings all around the world. For more information, please see the distribution page: http://www.egenix.com/products/python/mxBase/ ________________________________________________________________________ NEWS The 3.2.8 release of the eGenix mx Base Distribution is the latest release of our open-source Python extensions. It includes these fixes and enhancements: Installation Enhancements ------------------------- * Added web installer support to mxSetup, the distutils extension module which drives all our product installations. Uploaded web installer package to PyPI which simplifies installation. In addition to the usual ways of installing eGenix mx Base, we have uploaded a web installer to PyPI, so that it is now also possible to use one of these installation methods on all supported platforms (Windows, Linux, FreeBSD, Mac OS X): - easy_install egenix-mx-base via PyPI - pip install egenix-mx-base via PyPI - egenix-mx-base egg reference in zc.buildout via PyPI - running "python setup.py install" in the unzipped web installer archive directory The web installer will automatically detect the platform and choose the right binary download package for you. All downloads are verified before installation. Fixes ----- * mxDateTime: Protected delta.strftime() against segfaults on Windows, which only allows day values <= 31 and segfaults for higher values. Thanks to Frank Boje for reporting this problem. * mxTextTools: Fixed a double decref in the tagging engine that surfaced when using custom tag objects and appending the results to them. Thanks to Richard Moseley for the report. Compatibility Enhancements -------------------------- * Prepared eGenix mx Base for two digit Python patch level numbers such as Python 2.7.10 eGenix mx Base Distribution 3.2.0 was release on 2012-08-28. Please see the announcement for new features in the 3.2 major release compared to earlier releases: http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html For a full list of changes, please refer to the eGenix mx Base Distribution change log and the change logs of the various included Python packages. http://www.egenix.com/products/python/mxBase/changelog.html ________________________________________________________________________ UPGRADING We encourage all users to upgrade to this latest eGenix mx Base Distribution release. If you are upgrading from eGenix mx Base 3.1.x, please see the eGenix mx Base Distribution 3.2.0 release notes for details on what has changed since the 3.1 major release. http://www.egenix.com/company/news/eGenix-mx-Base-Distribution-3.2.0-GA.html ________________________________________________________________________ LICENSE The eGenix mx Base package is distributed under the eGenix.com Public License 1.1.0 which is an Open Source license similar to the Python license. You can use the packages in both commercial and non-commercial settings without fee or charge. This open source distribution package comes with full source code. ________________________________________________________________________ DOWNLOADS The download archives and instructions for installing the packages can be found on the eGenix mx Base Distribution page: http://www.egenix.com/products/python/mxBase/ If you want to try the package, please jump straight to the download instructions or simply run "pip install egenix-mx-base". As always, we are providing pre-built binaries for all common platforms: Windows 32/64-bit, Linux 32/64-bit, FreeBSD 32/64-bit, Mac OS X 32/64-bit. Source code archives are available for installation on all other Python platforms, such as Solaris, AIX, HP-UX, etc. To simplify installation in Zope/Plone and other egg-based systems, we have also precompiled egg distributions for all platforms. These are available on our own PyPI-style index server for easy and automatic download. Please see the download instructions for details: http://www.egenix.com/products/python/mxBase/#Download Whether you are using a prebuilt package or the source distribution, installation is a simple "python setup.py install" command in all cases. The only difference is that the prebuilt packages do not require a compiler or the Python development packages to be installed. ________________________________________________________________________ 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. ________________________________________________________________________ MORE INFORMATION For more information on the eGenix mx Base Distribution, documentation and installation notes, please visit our web-site: http://www.egenix.com/products/python/mxBase/ 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 project services and professional quality products for companies, Python users and developers. Enjoy,-- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jul 11 2014) >>> Python Projects, Consulting and Support ... http://www.egenix.com/ >>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ >>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/ ________________________________________________________________________ 2014-07-21: EuroPython 2014, Berlin, Germany ... 10 days to go ::::: Try our 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 nicholascannon1 at gmail.com Fri Jul 11 04:32:32 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Fri, 11 Jul 2014 01:32:32 -0700 (PDT) Subject: Standard library Help Message-ID: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> Hey i would like to know alot more about the standard library and all of its functions and so on and i know it is huge and i would basically like to learn only the useful stuff that i could use and all of those features. i have been looking around and i cant really find anything so i wondering if you guys would know any places to learn it. From marco.nawijn at colosso.nl Fri Jul 11 04:40:29 2014 From: marco.nawijn at colosso.nl (marco.nawijn at colosso.nl) Date: Fri, 11 Jul 2014 01:40:29 -0700 (PDT) Subject: Standard library Help In-Reply-To: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> References: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> Message-ID: On Friday, July 11, 2014 10:32:32 AM UTC+2, Nicholas Cannon wrote: > Hey i would like to know alot more about the standard library and all of its functions and so on and i know it is huge and i would basically like to learn only the useful stuff that i could use and all of those features. i have been looking around and i cant really find anything so i wondering if you guys would know any places to learn it. Hi Nicholas, Have you tried the library reference [1]? If so, can you explain why it is not sufficient for your needs? [1] https://docs.python.org/3/library/index.html From steve at pearwood.info Fri Jul 11 04:41:14 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 11 Jul 2014 08:41:14 GMT Subject: Standard library Help References: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> Message-ID: <53bfa32a$0$2746$c3e8da3$76491128@news.astraweb.com> On Fri, 11 Jul 2014 01:32:32 -0700, Nicholas Cannon wrote: > Hey i would like to know alot more about the standard library and all of > its functions and so on and i know it is huge and i would basically like > to learn only the useful stuff that i could use and all of those > features. i have been looking around and i cant really find anything so > i wondering if you guys would know any places to learn it. All of the standard library is useful to *somebody*. If you tell us what you want to do, we'll tell us which parts will be useful to you. You can start by reading, or at least skimming, the docs: # For Python 2: https://docs.python.org/2/library/index.html # For Python 3: https://docs.python.org/3/library/index.html You can also read the Python Module Of the Week: http://pymotw.com/2/ -- Steven From jaorozco at estudiantes.uci.cu Fri Jul 11 04:43:14 2014 From: jaorozco at estudiantes.uci.cu (Jorge Alberto =?ISO-8859-1?Q?D=EDaz?= Orozco) Date: Fri, 11 Jul 2014 04:43:14 -0400 Subject: python app hosting Message-ID: <1405068194.3995.2.camel@lucy> Hi, I'm looking for some server to host an xmlrpc server app I've made. Can someone help me find any? VII Escuela Internacional de Verano en la UCI del 30 de junio al 11 de julio de 2014. Ver www.uci.cu From ben at benfinney.id.au Fri Jul 11 04:50:10 2014 From: ben at benfinney.id.au (Ben Finney) Date: Fri, 11 Jul 2014 18:50:10 +1000 Subject: Standard library Help References: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> Message-ID: <85fvi8th31.fsf@benfinney.id.au> Nicholas Cannon writes: > Hey i would like to know alot more about the standard library and all > of its functions and so on Welcome! This is a good goal, familiarity with the standard library is a very important way to save yourself time in programming. > and i know it is huge and i would basically like to learn only the > useful stuff that i could use and all of those features. i have been > looking around and i cant really find anything so i wondering if you > guys would know any places to learn it. Doug Hellman has impressive groundwork, with his ?Python Module of the Week? series. The Python 3 version is a work in progress, but the Python 2 version is still an excellent resource with the caveat that, as a Python newcomer, you need to know Python 3 primarily. -- \ ?The shortest distance between two points is under | `\ construction.? ?Noelie Alito | _o__) | Ben Finney From wolfgang.maier at biologie.uni-freiburg.de Fri Jul 11 04:53:48 2014 From: wolfgang.maier at biologie.uni-freiburg.de (Wolfgang Maier) Date: Fri, 11 Jul 2014 10:53:48 +0200 Subject: Standard library Help In-Reply-To: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> References: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> Message-ID: <53BFA61C.2030109@biologie.uni-freiburg.de> On 07/11/2014 10:32 AM, Nicholas Cannon wrote: > Hey i would like to know alot more about the standard library and all of its functions and so on and i know it is huge and i would basically like to learn only the useful stuff that i could use and all of those features. i have been looking around and i cant really find anything so i wondering if you guys would know any places to learn it. > Consult the documentation: https://docs.python.org/3/library/index.html It's probably the only place that has everything documented. Instead of reading everything from A-Z though, the more typical approach is to skim through it to know what is available, then read in-depth the parts that seem useful for a concrete problem you're trying to solve currently. In my experience, a thorough understanding of most chapters doesn't come with reading alone, but with practice. Best, Wolfgang From steve at pearwood.info Fri Jul 11 05:04:02 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 11 Jul 2014 09:04:02 GMT Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> Message-ID: <53bfa881$0$2746$c3e8da3$76491128@news.astraweb.com> On Thu, 10 Jul 2014 23:33:27 -0400, Roy Smith wrote: > In article , > Tim Chase wrote: > >> On 2014-07-10 22:18, Roy Smith wrote: >> > > Outside this are \( and \): these are literal opening and closing >> > > bracket characters. So: >> > > >> > > \(\([^)]+\)\) >> > >> > although, even better would be to use to utterly awesome >> >> re.VERBOSE >> > flag, and write it as: >> > >> > \({2} [^)]+ \){2} >> >> Or heck, use a multi-line verbose expression and comment it for >> clarity: >> >> r = re.compile(r""" >> ( # begin a capture group >> \({2} # two literal "(" characters [^)]+ # one or more >> non-close-paren characters \){2} # two literal ")" >> characters >> ) # close the capture group """, re.VERBOSE) >> >> -tkc > > Ugh. That reminds me of the classic commenting anti-pattern: The sort of dead-simple commenting shown below is not just harmless but can be *critically important* for beginners, who otherwise may not know what "l = []" means. > l = [] # create an empty list > for i in range(10): # iterate over the first 10 integers > l.append(i) # append each one to the list The difference is, most people get beyond that level of competence in a matter of a few weeks or months, whereas regexes are a different story. (1) It's possible to have spent a decade programming in Python without ever developing more than a basic understanding of regexes. Regular expressions are a specialist mini-language for a specialist task, and one might go months or even *years* between needing to use them. (2) We're *Python* programmers, not *Regex* programmers, so regular expressions are as much a foreign language to us as Perl or Lisp or C might be. (And if you personally read any of those languages, congratulations. How about APL, J, REBOL, Smalltalk, Forth, or PL/I?) (3) The syntax for regexes is painfully terse and violates a number of import rules of good design. Larry Wall has listed no fewer than 19 problems with regex syntax/culture: http://perl6.org/archive/doc/design/apo/A05.html So all things considered, for the average Python programmer who has a basic understanding of regexes but has to keep turning to the manual to find out how to do even simple things, comments explaining what the regex does is an excellent idea. -- Steven From davea at davea.name Fri Jul 11 05:26:27 2014 From: davea at davea.name (Dave Angel) Date: Fri, 11 Jul 2014 05:26:27 -0400 (EDT) Subject: base64 convert to binary by binascii is that right? References: <6990c637-0d84-4ce4-b6ef-892290e56c74@googlegroups.com> Message-ID: Frank Liou Wrote in message: > conn = engine.connect() > encoded = base64.b64encode(getbody) > binary_string = binascii.a2b_base64(encoded) > puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)") > conn.execute(puresql,binary_string = binary_string) > > Start by specifying Python version. Since you're only asking about two lines, replace the rest with something that people can actually run. And instead of just printing binary_string, show its type as well. -- DaveA From fk26541598fk at gmail.com Fri Jul 11 05:37:17 2014 From: fk26541598fk at gmail.com (Frank Liou) Date: Fri, 11 Jul 2014 02:37:17 -0700 (PDT) Subject: how can i get "body" values? Message-ID: <773bcf4f-cda9-4c22-8922-23732a50a94c@googlegroups.com> how can i get body values use variable to Separate catch? https://lh3.googleusercontent.com/-6Ywp4GukuCM/U7-vhF0nzuI/AAAAAAAABv4/Ovcr1O2FScs/s1600/321.jpg i want to catch name and key values now i use request.data i can catch all the body but how can i use variable to separate and catch? From marco.nawijn at colosso.nl Fri Jul 11 06:10:23 2014 From: marco.nawijn at colosso.nl (marco.nawijn at colosso.nl) Date: Fri, 11 Jul 2014 03:10:23 -0700 (PDT) Subject: how can i get "body" values? In-Reply-To: <773bcf4f-cda9-4c22-8922-23732a50a94c@googlegroups.com> References: <773bcf4f-cda9-4c22-8922-23732a50a94c@googlegroups.com> Message-ID: On Friday, July 11, 2014 11:37:17 AM UTC+2, Frank Liou wrote: > how can i get body values use variable to Separate catch? > > > > https://lh3.googleusercontent.com/-6Ywp4GukuCM/U7-vhF0nzuI/AAAAAAAABv4/Ovcr1O2FScs/s1600/321.jpg > > > > i want to catch name and key values > > > > now i use request.data > > > > i can catch all the body > > > > but how can i use variable to separate and catch? Hi Frank, In general, you will get better response from the group if you post the code that you have so far and ask questions on why it doesn't work or how to proceed. In case of your particular problem, the answer is "it depends". Do you use the Python standard library, or a webserver framework like tornado or cherrypy? If you still have a choice, I would recommend to use a framework like cherrypy. It makes your life a lot easier. Regards, Marco From antonio.dalvit at gmail.com Fri Jul 11 07:00:00 2014 From: antonio.dalvit at gmail.com (Antonio Dalvit) Date: Fri, 11 Jul 2014 04:00:00 -0700 (PDT) Subject: Hello. I'm new here... Message-ID: Hello! Im Antonio, from Italy. I'm new here and i'd like to introduce myself: i'm learning python language after years working in ICT sector. I decided to study python after fortran basic, c++, java and php for fun and because i'm tired to spend lines and lines of code to make something working as I want. I'll lurk and sometimes i wall ask something that i cannot understand. I'm sorry if my questions can sound simple or trivial... good day! From davea at davea.name Fri Jul 11 07:22:52 2014 From: davea at davea.name (Dave Angel) Date: Fri, 11 Jul 2014 06:22:52 -0500 (CDT) Subject: Hello. I'm new here... References: Message-ID: Antonio Dalvit Wrote in message: > Hello! > > Im Antonio, from Italy. I'm new here and i'd like to introduce myself: i'm learning python language after years working in ICT sector. I decided to study python after fortran basic, c++, java and php for fun and because i'm tired to spend lines and lines of code to make something working as I want. > > I'll lurk and sometimes i wall ask something that i cannot understand. I'm sorry if my questions can sound simple or trivial... > > Welcome to tutor list. Thanks for posting in text format. Don't worry about whether a question might sound trivial. If it's an honest question, it's welcome. And frequently what seems simple can have lots of subtlety. Just try to keep each new question self-contained. Tell us python version, OS version, and use copy/paste on source code and error tracebacks. Try to narrow the code to a minimal case that demonstrates the problem, state what you expected, and paste what actually happened. Assume that people can refer back to that first message, so you don't need to repeat that stuff as the thread unfolds. And when you have a new question, start a new thread, starting over with python version, os ver...... -- DaveA From neilc at norwich.edu Fri Jul 11 08:51:11 2014 From: neilc at norwich.edu (Neil D. Cerutti) Date: Fri, 11 Jul 2014 08:51:11 -0400 Subject: Standard library Help In-Reply-To: <53BFA61C.2030109@biologie.uni-freiburg.de> References: <41e4eaa1-5161-409c-a439-4d8e07eb6353@googlegroups.com> <53BFA61C.2030109@biologie.uni-freiburg.de> Message-ID: On 7/11/2014 4:53 AM, Wolfgang Maier wrote: > On 07/11/2014 10:32 AM, Nicholas Cannon wrote: >> Hey i would like to know alot more about the standard library and all >> of its functions and so on and i know it is huge and i would basically >> like to learn only the useful stuff that i could use and all of those >> features. i have been looking around and i cant really find anything >> so i wondering if you guys would know any places to learn it. >> > > Consult the documentation: > > https://docs.python.org/3/library/index.html > > It's probably the only place that has everything documented. > Instead of reading everything from A-Z though, the more typical approach > is to skim through it to know what is available, then read in-depth the > parts that seem useful for a concrete problem you're trying to solve > currently. In my experience, a thorough understanding of most chapters > doesn't come with reading alone, but with practice. I recommend reading and becoming familiar with the first five sections first. You won't get far without the Built-in types and functions. list, dict, set, open, etc., are not in a "library", per se, as other languages usually define it, but that's where they're described in Python's docs. -- Neil Cerutti From fomcl at yahoo.com Fri Jul 11 11:18:09 2014 From: fomcl at yahoo.com (Albert-Jan Roskam) Date: Fri, 11 Jul 2014 08:18:09 -0700 Subject: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example In-Reply-To: <53bfa881$0$2746$c3e8da3$76491128@news.astraweb.com> References: <981c1f5f-2c19-4efc-8397-796bde07f39b@googlegroups.com> <53bfa881$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <1405091889.18114.YahooMailNeo@web163803.mail.gq1.yahoo.com> ----- Original Message ----- > From: Steven D'Aprano > To: python-list at python.org > Cc: > Sent: Friday, July 11, 2014 11:04 AM > Subject: Re: How to decipher :re.split(r"(\(\([^)]+\)\))" in the example > > On Thu, 10 Jul 2014 23:33:27 -0400, Roy Smith wrote: > >> In article , >> ? Tim Chase wrote: >> >>> On 2014-07-10 22:18, Roy Smith wrote: >>> > > Outside this are \( and \): these are literal opening > and closing >>> > > bracket characters. So: >>> > > >>> > >? ? \(\([^)]+\)\) >>> > >>> > although, even better would be to use to utterly awesome >>> >> re.VERBOSE >>> > flag, and write it as: >>> > >>> >? ? ? \({2} [^)]+ \){2} >>> >>> Or heck, use a multi-line verbose expression and comment it for >>> clarity: >>> >>> ? r = re.compile(r""" >>> ? ? (? ? ? ? ? ? # begin a capture group >>> ? ? ? \({2}? ? ? # two literal "(" characters [^)]+? > ? ? # one or more >>> ? ? ? non-close-paren characters \){2}? ? ? # two literal > ")" >>> ? ? ? characters >>> ? ? )? ? ? ? ? ? # close the capture group """, > re.VERBOSE) >>> >>> -tkc >> >> Ugh.? That reminds me of the classic commenting anti-pattern: > > The sort of dead-simple commenting shown below is not just harmless but > can be *critically important* for beginners, who otherwise may not know > what "l = []" means. > >> l = []? ? ? ? ? ? ? ? ? # create an empty list >> for i in range(10):? ? # iterate over the first 10 integers >> ? ? l.append(i)? ? ? ? # append each one to the list > Anything better than this hideous type of commenting: (?#...), e.g >>> re.match("(19|20)[0-9]{2}(?#year)-[0-9]{2}(?#month)", "2010-12") Same thing for the 'limsux' modifiers, although *maybe* they can be useful. From rosuav at gmail.com Fri Jul 11 12:14:03 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 02:14:03 +1000 Subject: Hello. I'm new here... In-Reply-To: References: Message-ID: On Fri, Jul 11, 2014 at 9:00 PM, Antonio Dalvit wrote: > Im Antonio, from Italy. I'm new here and i'd like to introduce myself: i'm learning python language after years working in ICT sector. I decided to study python after fortran basic, c++, java and php for fun and because i'm tired to spend lines and lines of code to make something working as I want. > > I'll lurk and sometimes i wall ask something that i cannot understand. I'm sorry if my questions can sound simple or trivial... Welcome! Glad to have you here, and I'm sure you'll love Python after experience with those languages! One thing though. There's a saying "Never offend people with style when you can offend them with substance", which applies to ... well, pretty much every form of communication, and I know someone who's fluent in over six million of them. So feel free to spout crazy theories about what Python ought to be like, because we'll happily debate with you on that, but please consider avoiding Google Groups, which has a strong tendency to make your posts extremely annoying in a few ways, including double-spacing all quoted text, and making your paragraphs into single long lines instead of properly wrapping them. There are ways around this, but they're quite manual; personally, I recommend either getting an actual news reader (something like Mozilla Thunderbird), or signing up for the mailing list, which is what I do: https://mail.python.org/mailman/listinfo/python-list Either of those options will also make it easier for you to follow the generally-recommended quoting style on these sorts of lists - interleaved. https://en.wikipedia.org/wiki/Posting_style#Interleaved_style So, let's get started on offending each other with substance :) ChrisA From niklastroedsson at yahoo.com Fri Jul 11 13:33:14 2014 From: niklastroedsson at yahoo.com (Niklas Troedsson) Date: Fri, 11 Jul 2014 10:33:14 -0700 Subject: Error after sympy lambdify function update using vector() dot.class Message-ID: <1405099994.42214.YahooMailNeo@web164601.mail.gq1.yahoo.com> I am new to the forum and programming Python. Recently I updated both Canopy and its packages, I am now using Canopy 1.4.1.1975 and sympy 0.7.5-1. In an earlier version my code to solve algebra and substitute a lot of constants and transfer functions with more than 1001 frequency points worked. But after the package update to the versions above, lambdify function stopped working and shows an invalid syntax error, pointing to the "dot" in alg.const1. Can anybody help to get around this without changing the original code of using alg.const1, instead of the cumbersome fix of renaming all variables and make them single variable names such as alg_const1. %run testofdotclasslambdify.py ? File "", line 1 ??? lambda alg.npnt1,alg.npnt2,alg.ntf1,alg.const1: (alg.const1*(alg.npnt2 + alg.ntf1)/(alg.const1 + alg.npnt2 + alg.ntf1)) ????????????? ^ SyntaxError: invalid syntax ? I have attached the *.py code and copied in below. Thank you! testofdotclasslambdify.py . import numpy as np import pylab as pl import sympy as sy # empty class for variables class vector: pass # # frequency, radians and Laplace representation fqaxst = 1.0e2 fqaxsp = 100.0e6 fqnop = 1001 fq = np.logspace(np.log10(fqaxst),np.log10(fqaxsp),fqnop) wq = 2*np.pi*fq s = 1.0j*wq ntf1 = np.exp(-s*1.0/10e6) npnt1 = 1 npnt2 = 1 const1 = 1 ### solve #1 with lambdify # set equation, variables and constants to solve alg_phiout, alg_npnt1, alg_npnt2 = sy.symbols('alg_phiout, alg_npnt1, alg_npnt2') alg_ntf1, alg_const1 = sy.symbols('alg_ntf1, alg_const1', complex = True) subst1 = (alg_npnt1, alg_npnt2, alg_ntf1, alg_const1) sol = vector() sol.algnpnt1 = (alg_npnt1-alg_phiout/alg_const1)*(alg_ntf1+alg_npnt2)-alg_phiout sol.solnpnt1 = sy.simplify(sy.diff(sy.solve(sol.algnpnt1, alg_phiout)[0], alg_npnt1,1)) sol.refnum1 = sy.lambdify(subst1, sol.solnpnt1) tf1 = sol.refnum1(npnt1, npnt2, ntf1, const1) # plot pl.figure(1) pl.semilogx(fq,10*np.log10(np.abs(tf1)**2),label='tf1') pl.legend(loc='lower right') pl.title('TF') pl.xlabel('Frequency, Hz') pl.ylabel('Spectrum, dB') pl.grid(b='on') pl.show() ### solve #2 with lambdify using vector as dot-class variables # problem with code below, which wasn't a probelm before updating Canopy package manager 2014-July-01 # I do not want all variables as signle variables but bundled in a vector dot.class # set equation, variables and constants to solve alg = vector() alg.phiout, alg.npnt1, alg.npnt2 = sy.symbols('alg.phiout, alg.npnt1, alg.npnt2') alg.ntf1, alg.const1 = sy.symbols('alg.ntf1, alg.const1', complex = True) subst2 = (alg.npnt1, alg.npnt2, alg.ntf1, alg.const1) sol.algnpnt2 = (alg.npnt1-alg.phiout/alg.const1)*(alg.ntf1+alg.npnt2)-alg.phiout sol.solnpnt2 = sy.simplify(sy.diff(sy.solve(sol.algnpnt2, alg.phiout)[0], alg.npnt1,1)) sol.refnum2 = sy.lambdify(subst2, sol.solnpnt2) # problem with new version of lambdify in new sympy, old version of lambdify/sympy worked # Gives the following error code: tf2 = sol.refnum2(npnt1, npnt2, ntf1, const1) # tf2 = sol.refnum2(npnt1, npnt2, ntf1, const1) # In [10]: %run testofdotclasslambdify.py # File "", line 1 # lambda alg.npnt1,alg.npnt2,alg.ntf1,alg.const1: (alg.const1*(alg.npnt2 + alg.ntf1)/(alg.const1 + alg.npnt2 + alg.ntf1)) # ^ # SyntaxError: invalid syntax # In [11]: # plot pl.figure(2) pl.semilogx(fq,10*np.log10(np.abs(tf1)**2),label='tf1') pl.legend(loc='lower right') pl.title('TF') pl.xlabel('Frequency, Hz') pl.ylabel('Spectrum, dB') pl.grid(b='on') pl.show() -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: testofdotclasslambdify.py URL: From ed at edgewood.to Fri Jul 11 15:16:19 2014 From: ed at edgewood.to (Ed Blackman) Date: Fri, 11 Jul 2014 15:16:19 -0400 Subject: Save/restore breakpoints between pdb runs Message-ID: <1405104539.54db53@strabo.loghyr> I've recently started using Python for my job (as opposed to writing smallish scripts for personal use), and so have needed to debug quite a bit more. I've been using pdb mainly via 'python -m pdb script args'. Perhaps it's my Java background, but even when I have permissions to change the source, I find editing source to insert 'import pdb; pdb.set_trace()' unnatural. The consequence is that I have to recreate my breakpoints when I have to exit pdb. I've written the following code, which I load from .pdbrc with 'execfile(os.path.expanduser('~/.pydb.py'))' Is there an alternate solution to keeping persistant breakpoints that works much better? My python editing happens on a lot of different machines/VMs, so I prefer alternate solutions that allow me to sync over a couple of files, not install new binaries. If not: 1) If is there a way in pdb to set a breakpoint on a function that isn't in the current file? I can see the .funcname property of the breakpoint, and would prefer restoring breakpoints on functions so they don't break if I change line numbers. "b func_name" works in the current file, but "b file:func_name" doesn't. 2) Is there a way to list the commands for each breakpoint, so that they can be restored as well? Any other comments or suggestions for improvement would be welcome. def savebps(): import pdb bp_num = 0 for bp in pdb.bdb.Breakpoint.bpbynumber: # pdb commands operate on breakpoint number, so keep track of # the number the recreated breakpoint would have if bp is None: continue else: bp_num += 1 command = 'tbreak' if bp.temporary else 'b' cond = '' if bp.cond is None else ', ' + bp.cond print("%s %s:%d%s" % (command, bp.file, bp.line, cond)) if not bp.enabled: print("disable %d" % (bp_num)) if bp.ignore > 0: print("ignore %d %d" % (bp_num, bp.ignore)) print('') -- Ed Blackman From cs at zip.com.au Fri Jul 11 18:42:44 2014 From: cs at zip.com.au (Cameron Simpson) Date: Sat, 12 Jul 2014 08:42:44 +1000 Subject: context manager based alternative to Re: Proposal: === and !=== In-Reply-To: <53BF3109.4070604@stoneleaf.us> References: <53BF3109.4070604@stoneleaf.us> Message-ID: <20140711224244.GA18822@cskk.homeip.net> On 10Jul2014 17:34, Ethan Furman wrote: >On 07/10/2014 05:20 PM, Cameron Simpson wrote: >>Here's an alternative proposal that doesn't involve a new operator. >[snip float-context manager stuff] > >Decimal has a context manager like that already (I don't know if it >supports allowing NaNs to equal each other, though). Interesting. I did not know that. [...] Ah, 9.4.3 Context Objects. Cool. >Rather than adding the whole thing to float, perhaps extending Decimal's >context with that option is a possible route. The OP needed to work with floats. The data storage systems he was using stored IEEE floats IIRC, so Decimal may not be suitable and possibly has performance effects too - dunno. I would think he'd need something implemented in the float type. Cheers, Cameron Simpson Nothing is impossible for the man who doesn't have to do it. From cs at zip.com.au Fri Jul 11 18:37:55 2014 From: cs at zip.com.au (Cameron Simpson) Date: Sat, 12 Jul 2014 08:37:55 +1000 Subject: context manager based alternative to Re: Proposal: === and !=== In-Reply-To: References: Message-ID: <20140711223755.GA1909@cskk.homeip.net> On 11Jul2014 14:37, Chris Angelico wrote: >On Fri, Jul 11, 2014 at 11:17 AM, Roy Smith wrote: >> In article , >> Cameron Simpson wrote: [... context manager changing NaN comparisons ...] >I'm a bit wary of anything that makes a global, even if temporary, >change to comparisons' behaviours. What happens if, deep in a call >tree, something utterly unrelated happens to do a comparison of this >nature? Weirdness, possibly very subtle weirdness. Possibly harmless weirdness. It reall depends on what reliance the unrelated (but called) code has on nonreflexivity. I would think most code almost never depends on it. What happens to nontrivial geometric proofs if you switch "parallel" from "lines never meet" to "lines meet at infinity"? Do the proofs become invalid? (Surely yes in some circumstances.) How do geometers know when validating proofs? I agree this is a risk. As a matter of interest, in what scenarios do people typically rely on NaN != NaN? The OP (Anders) broadly wanted to be able to compare datasets that included real python float NaNs and not have otherwise identical datasets claim to differ because they had NaNs (possible the same NaN instance) in the same spot. Also, he wasn't doing "blind" data comparison - he still needed to use real floats because his code did arithmetic with them, and therefore was not helped by suggestions of "casting" floats to integers (bytewise the same in memory) to sidestep the NaN specialness. >Does C-level code have to check this flag before comparing >nans, If you mean: float x, y; [...] if (x == y) { action... } then no. >or is this applicable only to the Python float objects and only >when compared in Python? The former but not the latter, in my mind. Comparing Python float objects should obey the rule, whether in pure Python or extensions using a PyFloat. But I'd hope they get that for free by indirecting through PyFloat's methods. >Is isnan() still usable? Yes. >(Consider that x!=x == math.isnan(x) normally.) Can you elaborate on this statement please? Cheers, Cameron Simpson Automobile: device used to drive slower than motorcycles. From steve+comp.lang.python at pearwood.info Fri Jul 11 23:30:48 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Jul 2014 03:30:48 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Thanks to everyone who has commented. Some responses: * I was completely mistaken about == enforcing the rule that __eq__ returns True or False. I have no idea where I got that idea from, sorry for the noise. * I disagree that having two equals operators, == and ===, would be confusing. The Javascript/PHP model doesn't apply: - In Javascript and PHP, the shorter, more attractive version == does the wrong thing and is harmful, hence everyone needs to learn about === immediately. - In my proposal, the shorter, more attractive version == does what everyone already assumes == will do. It's only specialists who need to learn about === . * But having said that, I find myself trying to solve a problem reported by Anders which I do not understand, cannot replicate, and although I'm willing to give him the good faith benefit of the doubt, I find myself less and less convinced that the problem is what he thinks it is. To be specific, the one concrete piece of code Anders has posted is a completely generic "detect changes" function which he claims is broken by the presence of NANs. That may be, but his code is not runnable (it uses undefined methods that could do anything) so cannot be tested, and I cannot replicate his problem. NANs or no NANs, a generic "detect changes" function already fails to work in some circumstances: py> data = [1, 2.0, 3.0, 4.0] py> old = data[:] py> old == data # No changes made yet, should return True True py> data[0] = 1.0 # Change of type. py> old == data # Should return False True But perhaps we only care about changes in value, not type. NAN or no NAN, list equality works fine: py> data = [1.0, 2.0, float('nan'), 4.0] py> old = data[:] py> old == data # No changes made yet, should return True True py> data[3] = 104.0 py> old == data # Should return False False The only time it may fail, for some definition of "fail", is when the NAN is replaced by another NAN of the same payload but different identity. But I still fail to understand Ander's use-case here, how a NAN might be replaced by another NAN, or why he wants to compare two different NANs as equal. Since I do not understand Ander's problem, I cannot hope to solve it. So I withdraw my suggestion. Thanks to everyone who listened. -- Steven From alan at scooby-doo.csail.mit.edu Sat Jul 12 01:07:28 2014 From: alan at scooby-doo.csail.mit.edu (Alan Bawden) Date: Sat, 12 Jul 2014 01:07:28 -0400 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: Steven D'Aprano writes: > But perhaps we only care about changes in value, not type. NAN or no NAN, > list equality works fine: > > py> data = [1.0, 2.0, float('nan'), 4.0] > py> old = data[:] > py> old == data # No changes made yet, should return True > True You lost me right here. If list equality is determined by comparing lists element-by-element, and the second element of old is _not_ equal to the second element of data, then why should old and data be equal? In fact, I find myself puzzled about exactly how list equality is actually defined. Consider: >>> a = float('nan') >>> x = [1, a, 9] >>> y = [1, a, 9.0] >>> x == y True So is there some equality predicate where corresponding elements of x and y are equal? >>> map(operator.eq, x, y) [True, False, True] It's not "==". >>> map(operator.is_, x, y) [True, True, False] And it's not "is". -- Alan Bawden From rosuav at gmail.com Sat Jul 12 01:53:04 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 15:53:04 +1000 Subject: context manager based alternative to Re: Proposal: === and !=== In-Reply-To: <20140711223755.GA1909@cskk.homeip.net> References: <20140711223755.GA1909@cskk.homeip.net> Message-ID: On Sat, Jul 12, 2014 at 8:37 AM, Cameron Simpson wrote: > On 11Jul2014 14:37, Chris Angelico wrote: >> >> Does C-level code have to check this flag before comparing >> nans, > > > If you mean: > > float x, y; > [...] > if (x == y) { > action... > } > > then no. > > >> or is this applicable only to the Python float objects and only >> when compared in Python? > > > The former but not the latter, in my mind. Comparing Python float objects > should obey the rule, whether in pure Python or extensions using a PyFloat. > But I'd hope they get that for free by indirecting through PyFloat's > methods. Suppose you have some C extension that works with numbers (I have NumPy in mind as I write this, but I'm not familiar with its inner workings; certainly it'd be possible for this to be implemented how I describe). You pack a bunch of Python float objects into an array, pack another bunch into another array, and then compare them. >>> from numpy import array >>> x=array([1.0,2.0]) >>> y=array([1.0,2.1]) >>> x==y array([ True, False], dtype=bool) So far, so good. Now let's introduce a NaN. >>> nan=float("nan") >>> x=array([1.0,2.0,nan]) >>> y=array([1.0,2.1,nan]) >>> x==y array([ True, False, False], dtype=bool) I deliberately used the exact same nan so that an identity or bit-pattern check would return True; but numpy says False, these are not the same. Now, if I replace array with this list-like thing, then your context manager would control that last result: >>> class array(list): def __eq__(self, other): if not isinstance(other, type(self)) or len(other)!=len(self): return False return [self[i] == other[i] for i in range(len(self))] But if, instead, the array is packed into a C-level array of floats (which can be done without losing any information other than object identity), then this would no longer be affected by your context manager, unless the extension unnecessarily reconstructs two Python floats to compare them, or else is made specifically aware of the change. >> Is isnan() still usable? > > Yes. > >> (Consider that x!=x == math.isnan(x) normally.) > > Can you elaborate on this statement please? def isnan(x): return isinstance(x, float) and x!=x Fairly standard way of defining isnan(). It would be extremely surprising if that correlation didn't work. Let's suppose you want to sort a list of floats with all NaNs coming first: new_list = sorted(old_list, key=lambda x: (x==x, x)) new_list = sorted(old_list, key=lambda x: (not math.isnan(x), x)) The first one is much briefer (and faster, as it doesn't need to look up math and math.isnan and then call a function), and people will assume they're equivalent. If this kind of thing happens deep inside a call tree, it'll be extremely surprising that the two act differently. So there has to be some other way to implement isnan(), which will probably involve poking around with the bit pattern, and everyone MUST use that instead of the simple comparison. ChrisA From dieter at handshake.de Sat Jul 12 02:05:27 2014 From: dieter at handshake.de (dieter) Date: Sat, 12 Jul 2014 08:05:27 +0200 Subject: Save/restore breakpoints between pdb runs References: <1405104539.54db53@strabo.loghyr> Message-ID: <87d2db863c.fsf@handshake.de> Ed Blackman writes: > I've recently started using Python for my job (as opposed to writing > smallish scripts for personal use), and so have needed to debug quite > a bit more. > > I've been using pdb mainly via 'python -m pdb script args'. Perhaps > it's my Java background, but even when I have permissions to change > the source, I find editing source to insert 'import pdb; > pdb.set_trace()' unnatural. The consequence is that I have to > recreate my breakpoints when I have to exit pdb. > > I've written the following code, which I load from .pdbrc with > 'execfile(os.path.expanduser('~/.pydb.py'))' This approach does not seem very robust to me: "pdb" resolves all breakpoints to lines (in source files) - and any modification to the source may change the lines. As a consequence, your breakpoints may no longer be at the places where you expect them. A long time ago, I have developped "dm.pdb" - a slight extension/improvement over "pdb". One of the extensions has been to make it possible to set breakpoints from outside the debugger -- without too many surprises. It looks somehow like that: from dm.pdb import Pdb; D = Pdb() ... from ... import f from ... import g from ... import C ... D.do_break("f") # set breakpoint on "f" D.do_break("g") # set breakpoint on "g" D.do_breack("C.m") # set breakpoint on method "m" of class "C" ... D.run("...") It is more robust than breakpoints on line numbers - but, of course, it cannot be automated but must be targeted to individual programs. In addition, the robustness is limited to breakpoints on executable objects; setting breakpoints on line numbers is possible, too -- but has the same problem with moving lines. In the meantime, "pdb" itself may support this form of external control (maybe even better then "dm.pdb"). From rosuav at gmail.com Sat Jul 12 02:06:51 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 16:06:51 +1000 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Jul 12, 2014 at 3:07 PM, Alan Bawden wrote: > Steven D'Aprano writes: > >> But perhaps we only care about changes in value, not type. NAN or no NAN, >> list equality works fine: >> >> py> data = [1.0, 2.0, float('nan'), 4.0] >> py> old = data[:] >> py> old == data # No changes made yet, should return True >> True > > You lost me right here. If list equality is determined by comparing > lists element-by-element, and the second element of old is _not_ equal > to the second element of data, then why should old and data be equal? > > In fact, I find myself puzzled about exactly how list equality is > actually defined. In the Python 3 docs, it's made a bit clearer, at least as regards the 'in' and 'not in' operators: it's an identity check followed by an equality check - "x is y or x == y". The same comparison is done for equality, although it's not strictly described there (at least, I couldn't find it). There are a lot of these sorts of corner cases that aren't made really clear in the docs, because the verbosity would be more of a problem than the omission - I consider them to be like "The land continues to burn" on Obsidian Fireheart [1] or the reminder text on Madness [2]; if you go to the Magic: The Gathering Comprehensive Rulebook, you can find the exact "code-accurate" details on how either one works, but that takes several pages of verbiage, and it's much better to just say "you may cast it for its madness cost instead of putting it into your graveyard". For the most part, the identity check is a pure optimization. Most Python objects compare equal to themselves. It only VERY occasionally matters (like when there's a NaN in your list), and for those cases, you have the interactive interpreter to try things at. ChrisA [1] http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=192224 [2] eg http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=118892 From bronger at physik.rwth-aachen.de Sat Jul 12 02:05:19 2014 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Jul 2014 08:05:19 +0200 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <874mynjen4.fsf@physik.rwth-aachen.de> Hall?chen! Alan Bawden writes: > [...] > > You lost me right here. If list equality is determined by > comparing lists element-by-element, and the second element of old > is _not_ equal to the second element of data, then why should old > and data be equal? I think Python first tests for identity, and falls back to equality (or the other way round). This behaviour is questionable in my opinion. Tsch?, Torsten. -- Torsten Bronger Jabber ID: torsten.bronger at jabber.rwth-aachen.de or http://bronger-jmp.appspot.com From bronger at physik.rwth-aachen.de Sat Jul 12 02:14:24 2014 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Sat, 12 Jul 2014 08:14:24 +0200 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <874mynjen4.fsf@physik.rwth-aachen.de> Message-ID: <87zjgfhznj.fsf@physik.rwth-aachen.de> Hall?chen! Torsten Bronger writes: > Alan Bawden writes: > >> [...] >> >> You lost me right here. If list equality is determined by >> comparing lists element-by-element, and the second element of old >> is _not_ equal to the second element of data, then why should old >> and data be equal? > > I think Python first tests for identity, and falls back to > equality (or the other way round). This behaviour is questionable > in my opinion. See also https://mail.python.org/pipermail/python-bugs-list/2006-August/035010.html Tsch?, Torsten. -- Torsten Bronger Jabber ID: torsten.bronger at jabber.rwth-aachen.de or http://bronger-jmp.appspot.com From rosuav at gmail.com Sat Jul 12 02:32:55 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 16:32:55 +1000 Subject: Error after sympy lambdify function update using vector() dot.class In-Reply-To: <1405099994.42214.YahooMailNeo@web164601.mail.gq1.yahoo.com> References: <1405099994.42214.YahooMailNeo@web164601.mail.gq1.yahoo.com> Message-ID: On Sat, Jul 12, 2014 at 3:33 AM, Niklas Troedsson wrote: > I am new to the forum and programming Python. > > Recently I updated both Canopy and its packages, I am now using Canopy > 1.4.1.1975 and sympy 0.7.5-1. > This is a general Python list, not Canopy or Sympy specific. If you don't get a useful response here, you may want to try looking for their mailing lists; Canopy appears to be (sorry, I'm not familiar with it) an Enthought package, so you could ask Enthought for support; and Sympy doubtless has its own lists, which you could find with a Google search. I suspect that what you're asking about may be sufficiently specialized that you'll get better responses there. But you might get a response here. Never know! We do have some pretty awesome experts on python-list. ChrisA From ethan at stoneleaf.us Sat Jul 12 02:11:37 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Jul 2014 23:11:37 -0700 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53C0D199.8070804@stoneleaf.us> On 07/11/2014 10:07 PM, Alan Bawden wrote: > Steven D'Aprano writes: > >> But perhaps we only care about changes in value, not type. NAN or no NAN, >> list equality works fine: >> >> py> data = [1.0, 2.0, float('nan'), 4.0] >> py> old = data[:] >> py> old == data # No changes made yet, should return True >> True > > You lost me right here. If list equality is determined by comparing > lists element-by-element, and the second element of old is _not_ equal > to the second element of data, then why should old and data be equal? > > In fact, I find myself puzzled about exactly how list equality is > actually defined. Consider: > > >>> a = float('nan') > >>> x = [1, a, 9] > >>> y = [1, a, 9.0] > >>> x == y > True > > So is there some equality predicate where corresponding elements of x > and y are equal? > > >>> map(operator.eq, x, y) > [True, False, True] > > It's not "==". > > >>> map(operator.is_, x, y) > [True, True, False] > > And it's not "is". class list: def __eq__(self, other): if len(self) != len(other): return False for this, that in zip(self, other): if this is that or this == that: continue break else: return True return False -- ~Ethan~ From rosuav at gmail.com Sat Jul 12 02:39:35 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 16:39:35 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53C0D199.8070804@stoneleaf.us> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <53C0D199.8070804@stoneleaf.us> Message-ID: On Sat, Jul 12, 2014 at 4:11 PM, Ethan Furman wrote: > class list: > def __eq__(self, other): > if len(self) != len(other): > return False > for this, that in zip(self, other): > if this is that or this == that: > continue > break > else: > return True > return False Seems a little elaborate. Why not just return straight from the loop, instead of breaking and using else? :) ChrisA From marko at pacujo.net Sat Jul 12 03:06:11 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 12 Jul 2014 10:06:11 +0300 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <53C0D199.8070804@stoneleaf.us> Message-ID: <87mwcf6opo.fsf@elektro.pacujo.net> Chris Angelico : > On Sat, Jul 12, 2014 at 4:11 PM, Ethan Furman wrote: >> class list: >> def __eq__(self, other): >> if len(self) != len(other): >> return False >> for this, that in zip(self, other): >> if this is that or this == that: >> continue >> break >> else: >> return True >> return False > > Seems a little elaborate. Why not just return straight from the loop, > instead of breaking and using else? :) But look at that keyword density! That single function demonstrates 80% of Python syntax making it a great educational tool. Marko From ethan at stoneleaf.us Sat Jul 12 02:53:49 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Fri, 11 Jul 2014 23:53:49 -0700 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <53C0D199.8070804@stoneleaf.us> Message-ID: <53C0DB7D.20108@stoneleaf.us> On 07/11/2014 11:39 PM, Chris Angelico wrote: > On Sat, Jul 12, 2014 at 4:11 PM, Ethan Furman wrote: >> class list: >> def __eq__(self, other): >> if len(self) != len(other): >> return False >> for this, that in zip(self, other): >> if this is that or this == that: >> continue >> break >> else: >> return True >> return False > > Seems a little elaborate. Why not just return straight from the loop, > instead of breaking and using else? :) Because I'm tired, and it seemed like a good excuse to show else with for, and because I'm tired. :) -- ~Ethan~ From rosuav at gmail.com Sat Jul 12 03:25:39 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 12 Jul 2014 17:25:39 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53C0DB7D.20108@stoneleaf.us> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> <53C0D199.8070804@stoneleaf.us> <53C0DB7D.20108@stoneleaf.us> Message-ID: On Sat, Jul 12, 2014 at 4:53 PM, Ethan Furman wrote: > Because I'm tired, and it seemed like a good excuse to show else with for, > and because I'm tired. :) Excellent justification. I withdraw the criticism. :) ChrisA From plog at voxteneo.com Sat Jul 12 03:54:23 2014 From: plog at voxteneo.com (plog) Date: Sat, 12 Jul 2014 00:54:23 -0700 (PDT) Subject: We are looking for talented and motivated PYTHON Developers for our office in Bandung, West Java. Message-ID: <1405151663240-5063819.post@n6.nabble.com> http://www.voxteneo.com/jobs/#job-indonesia *PYTHON Developers #12* We are looking for talented and motivated PYTHON Developers for our office in Bandung, West Java. We offer a permanent contract with a competitive salary package You will join our team to take charge of analysis and development of ambitious projects within a growing company You will be part of a skilled, dynamic team in a friendly environment As developer, you will translate companies? needs into functional specifications and develop new applications. Skills Mini. 2 year of significant software development experience Must have delivered production level code (Python) in a commercial environment Excellent analytical and decision making skills Server-side Python coding, both in Django and straight WSGI Client-side development with HTML, JS/JQuery, and CSS SQL database design and coding Experience with AWS Degree in Computer Science a plus http://www.voxteneo.com/jobs/#job-indonesia -- View this message in context: http://python.6.x6.nabble.com/We-are-looking-for-talented-and-motivated-PYTHON-Developers-for-our-office-in-Bandung-West-Java-tp5063819.html Sent from the Python - python-list mailing list archive at Nabble.com. From steve+comp.lang.python at pearwood.info Sat Jul 12 04:33:03 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Jul 2014 08:33:03 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53c0abe8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53c0f2be$0$9505$c3e8da3$5496439d@news.astraweb.com> On Sat, 12 Jul 2014 01:07:28 -0400, Alan Bawden wrote: > Steven D'Aprano writes: > >> But perhaps we only care about changes in value, not type. NAN or no >> NAN, list equality works fine: >> >> py> data = [1.0, 2.0, float('nan'), 4.0] >> py> old = data[:] >> py> old == data # No changes made yet, should return True True > > You lost me right here. If list equality is determined by comparing > lists element-by-element, and the second element of old is _not_ equal > to the second element of data, then why should old and data be equal? Because practicality beats purity. Outside of the specialist areas of IEEE-754 floating point NANs, and SQL NUL, it is a basic property of *nearly everything* that x equals itself, for any x. This property is called "reflexivity", and is considered by some (although not me) to be absolutely fundamental, never to be violated under any circumstances. (To be clear, I'm talking about reflexivity of *equality* specifically, not of every operator. We wouldn't expect x > x, for example -- the "greater than" operator is not reflexive.) While IEEE-754, and SQL, have good reasons for violating the reflexivity of equals, that upsets a lot of people. Given: data = [1.0, 2.0, 3.0] data == data it would be surprising, and annoying, more often than useful if the equality test returned False. Replace any of the floats with a NAN, and the same surprise and annoyance applies. In the case of Python, lists and other builtin containers partially violate the specialist rules of IEEE-754 NAN handling, by using "is" identity test as a shortcut for equality. Effectively, they assume that equality is always reflexive. This was introduced as an optimization, since == can be quite expensive in Python, whereas "is" requires only a fast pointer comparison and is very cheap. I support this optimization, even if it violates the non-reflexivity of NANs. NANs are specialised values, and outside of the narrow confines of IEEE-754 arithmetic, their non-reflexivity is more of a nuisance than anything else. (Some would argue that *even within* IEEE-754 arithmetic, non-reflexivity is a nuisance. For now, I prefer to remain neutral in that argument.) > In fact, I find myself puzzled about exactly how list equality is > actually defined. You'd have to check the C source code, but I would expect something like this (only written in C): class list: def __eq__(self, other): if self is other: return True elif isinstance(other, list): if len(self) != len(other): return False for a, b in zip(self, other): if not (a is b or a == b): return False return True else: return NotImplemented # Let other decide. -- Steven From mmanns at gmx.net Fri Jul 11 20:50:12 2014 From: mmanns at gmx.net (Martin Manns) Date: Sat, 12 Jul 2014 02:50:12 +0200 Subject: [ANN] pyspread 0.3.1 Message-ID: ============== pyspread 0.3.1 ============== Pyspread 0.3.1 is released. This is a bugfix release that removes an annoying warning on the console. About pyspread ============== Pyspread is a non-traditional spreadsheet application that is based on and written in the programming language Python. The goal of pyspread is to be the most pythonic spreadsheet application. Pyspread is free software. It is released under the GPL v3. Project website: http://manns.github.com/pyspread/ Download page: https://pypi.python.org/pypi/pyspread What is new in 0.3.1 ==================== + Bugfix + Updated German localization + Updated Ukrainian localization Enjoy Martin From dfnsonfsduifb at gmx.de Sat Jul 12 07:54:07 2014 From: dfnsonfsduifb at gmx.de (Johannes Bauer) Date: Sat, 12 Jul 2014 13:54:07 +0200 Subject: Proposal: === and !=== operators In-Reply-To: <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On 09.07.2014 11:17, Steven D'Aprano wrote: > People are already having problems, just listen to Anders. He's > (apparently) not doing NAN-aware computations on his data, he just wants > to be able to do something like > > this_list_of_floats == that_list_of_floats This is a horrible example. There's no pretty way of saying this: Comparing floats using equals operators has always and will always be an incredibly dumb idea. The same applies obviously to containers containing floats. I also agree with Chris that I think an additional operator will make things worse than better. It'll add confusion with no tangible benefit. The current operators might have the deficiency that they're not relexive, but then again: Why should == be always reflexive while the other operators aren't? Why should I be able to assume that x == x -> True but not when x < x -> False If you're arguing from a mathematical/logical standpoint then if you want the former you'll also have to want the latter. Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht ?ffentlich! Ah, der neueste und bis heute genialste Streich unsere gro?en Kosmologen: Die Geheim-Vorhersage. - Karl Kaos ?ber R?diger Thomas in dsa From neeraj.bakhtani at gmail.com Sat Jul 12 09:11:42 2014 From: neeraj.bakhtani at gmail.com (neeraj.bakhtani at gmail.com) Date: Sat, 12 Jul 2014 06:11:42 -0700 (PDT) Subject: Rest WebService Testing using Python Message-ID: Hi folks, This is Neeraj , I want to develop some standalone python Scripts to Test Rest Webservices i.e. WADL services with endpoints. Particularly I need "A script for logging in would pass the xml to the rest api with variables for all the payload fields python" So Can Anyone please provide me some sample scripts or tutorials or package that can help me in above Scenario for automating the Rest WebService Testing for me I am new to python.So please bear with me..:) Thanks in advance From roy at panix.com Sat Jul 12 09:47:06 2014 From: roy at panix.com (Roy Smith) Date: Sat, 12 Jul 2014 09:47:06 -0400 Subject: Rest WebService Testing using Python References: Message-ID: In article , neeraj.bakhtani at gmail.com wrote: > Hi folks, > This is Neeraj , I want to develop some standalone python Scripts to Test > Rest Webservices i.e. WADL services with endpoints. > > Particularly I need "A script for logging in would pass the xml to the rest > api with variables for all the payload fields python" > > > So Can Anyone please provide me some sample scripts or tutorials or package > that can help me in above Scenario for automating the Rest WebService Testing > for me > > I am new to python.So please bear with me..:) > > Thanks in advance The question you are asking is broad, so I can only make some general suggestions. You've really got two needs here. One is you need some kind of test framework, the other is that you need some way to talk to an HTTP server. Let's attack those one at a time. Test framework. Testing is all about writing down a list of things you believe to be true, and then exercising the code to verify that they are indeed true. When I do X, I expect Y to happen. If it does, the test passes. If not, the test fails. Generally you write a large number of these tests, and run them all. A lot of this is boilerplate. You need some way to organize all the individual tests. Run them (or perhaps run subsets of them). Record which ones passed or not. Set up the right environment for each test to run, and possibly clean up after each one. The idea of a test framework is that it takes care of most of this for you automatically, letting you concentrate on the test logic. There's a couple of choices for test frameworks. The standard one that comes packaged with Python is unittest (https://docs.python.org/2/library/unittest.html). I used to use it a lot, but I've come to regard it as somewhat klunky. Still, it's the standard. If you've used JUnit, it has the advantage that it will feel very familiar. A newer alternative is nose (https://nose.readthedocs.org/), which is what I mostly use now. Nose simplifies some things, but sometimes can be a bit difficult to understand (the docs can be a bit obtuse in places). The big advantage of nose is it has some very powerful tools for running tests in parallel. If you have a lot of tests that are I/O bound, this can seriously reduce the time to run your test suite. There's also doctest (https://docs.python.org/2/library/doctest.html), but for the kind of testing you want to do, it's probably not the right tool. I include it only for completeness. OK, so now, how to talk to your HTTP service. That's easy. You want to use requests (http://docs.python-requests.org). If your web service involves persisting state on the client side with cookies, you'll want to explore requests' session functionality. From steve+comp.lang.python at pearwood.info Sat Jul 12 12:35:07 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 12 Jul 2014 16:35:07 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> On Sat, 12 Jul 2014 13:54:07 +0200, Johannes Bauer wrote: > On 09.07.2014 11:17, Steven D'Aprano wrote: > >> People are already having problems, just listen to Anders. He's >> (apparently) not doing NAN-aware computations on his data, he just >> wants to be able to do something like >> >> this_list_of_floats == that_list_of_floats > > This is a horrible example. > > There's no pretty way of saying this: Comparing floats using equals > operators has always and will always be an incredibly dumb idea. The > same applies obviously to containers containing floats. That's a myth. It simply is not true that you should never compare floats with the equals operator, it comes from the dark ages of numeric computing prior to IEEE-754. If you said, "for many purposes, one should not compare floats for equality, but should use some sort of fuzzy comparison instead" then I would agree with you. But your insistence that equality "always" is wrong takes it out of good advice into the realm of superstition. Quoting Professor William Kahan from the foreword to the "Apple Numerics Manual", second edition: [B]ecause so many computers in the 1960s and 1970's possessed so many different arithmetic anomalies, computational lore has become encumbered with a vast body of superstition purporting to cope with them. One such superstitious rule is "*Never* ask whether floating-point numbers are exactly equal." That was written in 1987, just two years after the introduction of the IEEE-754 standard. It is heart-breaking that 26 years later this bogus "rule" is still being treated as gospel. Bruce Dawson has written an awesome series of blog posts dealing with floating point issues. In this post: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ he discusses some of the issues with comparing two C floats or doubles for equality. If you read the entire post, he emphasises how hard it is to compare floats, and gives three methods: - test whether they differ by an absolute error - test whether they differ by a relative error - test whether they differ by a certain number of Units In Last Place (one method he misses is the one used by Python unittest module, which rounds the values before comparing them) and describes some of the weaknesses of each. In a reply to a comment, he warns about using == to compare a float (single precision) and a double. But if you keep reading all the way down to this comment: https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/#comment-9989 he says: [T]he default equality comparison absolutely should be true equality. To do otherwise risks madness. I have a post almost ready that uses exact floating-point comparisons to validate math, thus proving that exact comparisons are valid. [...] So, standard fuzzy comparison functions would be nice, but the default should remain exact comparisons. There's one obvious use-case for exact comparison: "Has this value changed to some other value?" old = x x = function(x) if x != old: print "changed!" is fine. Changing the inequality to some fuzzy comparison is bogus, because that means that *some changes will not be detected*. > I also agree with Chris that I think an additional operator will make > things worse than better. It'll add confusion with no tangible benefit. > The current operators might have the deficiency that they're not > relexive, but then again: Why should == be always reflexive while the > other operators aren't? You're not going to hear me arguing that the non-reflexivity of NANs and SQL NULL is a bad idea, although some very smart people have: http://bertrandmeyer.com/2010/02/06/reflexivity-and-other-pillars-of-civilization/ Mathematical equality is reflexive. It is fundamental to the nature of numbers and equality that a number is always equal to itself. To the degree that floats are supposed to model real numbers, they should obey the same laws of real numbers. However, they already fail to obey them, so the failure of reflexivity is just one more problem that makes floating point such a hard problem. Compared to floating point arithmetic, calculus is easy. > Why should I be able to assume that > > x == x -> True > > but not > > when x < x -> False Because not all types are ordered: py> x = 1+3j py> x < x Traceback (most recent call last): File "", line 1, in TypeError: unorderable types: complex() < complex() -- Steven From rosuav at gmail.com Sat Jul 12 12:54:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Jul 2014 02:54:44 +1000 Subject: Proposal: === and !=== operators In-Reply-To: <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 13, 2014 at 2:35 AM, Steven D'Aprano wrote: > You're not going to hear me arguing that the non-reflexivity of NANs and > SQL NULL is a bad idea, although some very smart people have: > > http://bertrandmeyer.com/2010/02/06/reflexivity-and-other-pillars-of-civilization/ > > Mathematical equality is reflexive. It is fundamental to the nature of > numbers and equality that a number is always equal to itself. To the > degree that floats are supposed to model real numbers, they should obey > the same laws of real numbers. However, they already fail to obey them, > so the failure of reflexivity is just one more problem that makes > floating point such a hard problem. Compared to floating point > arithmetic, calculus is easy. > And there are plenty of other laws of real numbers that floats violate (or, let's be generous, "approximate to rather than following perfectly"). For instance, adding two positive (non-zero) numbers should result in a number which is greater than either, but thanks to rounding, that's not always true. (Not to mention that "infinity" isn't a number, but it is a floating-point value.) The problem is not equality comparisons, the problem is the expectation that the rules of reals apply to floats. ChrisA From phamp at mindspring.com Sat Jul 12 13:50:04 2014 From: phamp at mindspring.com (pyotr filipivich) Date: Sat, 12 Jul 2014 10:50:04 -0700 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <87d2euazi9.fsf@elektro.pacujo.net> <4s5lo91dpa4e7iakbdtq4umar01o6vte7f@4ax.com> Message-ID: Steve Hayes on Sun, 01 Jun 2014 05:05:05 +0200 typed in comp.lang.python the following: >On Sat, 31 May 2014 15:44:46 +0300, Marko Rauhamaa wrote: > >>Steve Hayes : >> >>> I'll leave Python 3.2 on my computer, but 2.7.5 will be the one I'm >>> installing now. Even if I could *find* a book that deals with Python >>> 3.x, couldn't afford to but yet another Python book. >> >>Unfortunately, in the computer field, if there's a book written on a >>topic, it will most likely be out of date. >> >>In the 1990's, I used to buy computer books on various topics. I don't >>think I have bought one for ten years. Either it is online or it doesn't >>exist. >> >>There's enough Python material online to become a pro in it: > >I hate reading stuff online, and find it diffucult to learn anything with that >method. I use MS Word 97 in preference to Libre Office wor Word 2010 (both of >which I have) because I have a book on the first, but not on the others. I >can't read online books in the bath or in bed. Hear, hear! -- pyotr filipivich The fears of one class of men are not the measure of the rights of another. -- George Bancroft From dfnsonfsduifb at gmx.de Sat Jul 12 14:14:32 2014 From: dfnsonfsduifb at gmx.de (Johannes Bauer) Date: Sat, 12 Jul 2014 20:14:32 +0200 Subject: Proposal: === and !=== operators In-Reply-To: <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 12.07.2014 18:35, Steven D'Aprano wrote: > If you said, "for many purposes, one should not compare floats for > equality, but should use some sort of fuzzy comparison instead" then I > would agree with you. But your insistence that equality "always" is wrong > takes it out of good advice into the realm of superstition. Bullshit. Comparing floats by their representation is *generally* a bad idea because of portability issues. You don't know if IEEE754 is used to represent floats on the systems that your code is used on. You're hairsplitting: when I'd have said "in 99.9% of cases" you'd agree with me but since I said "always" you disagree. Don't lawyer out. Comparing binary representation of floats is a crappy idea. Even more so in the age of cloud computing where your code is executed on who knows which architecture where the exact same high level interpretation might lead to vastly different results. Not to mention high performance computing, where specialized FPUs can numerously be found which don't give a shit about IEEE754. Another thing why it's good to NEVER compare floats with regards to their binary representation: Do you exactly know how your FPU is configured by your operating system. Do you know that your FPUs on a multiprocessor system are configured all identically with regards to 754? Rounding modes, etc? Just don't fall in the pit. Don't compare floats via equals. >> when x < x -> False > > Because not all types are ordered: > > py> x = 1+3j > py> x < x > Traceback (most recent call last): > File "", line 1, in > TypeError: unorderable types: complex() < complex() Oh, so then you also don't want refelexivity of equals, I think. Because, obviously, not all types support comparison for equality: #!/usr/bin/python3 class Yeah(object): def __eq__(self, other): raise TypeError("Booya") Yeah() == Yeah() You cherrypick your logic and hairsplit in your reasoning. It's not consistent. Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht ?ffentlich! Ah, der neueste und bis heute genialste Streich unsere gro?en Kosmologen: Die Geheim-Vorhersage. - Karl Kaos ?ber R?diger Thomas in dsa From drsalists at gmail.com Sat Jul 12 16:28:24 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Sat, 12 Jul 2014 13:28:24 -0700 Subject: Python 3 is killing Python In-Reply-To: References: Message-ID: On Wed, May 28, 2014 at 12:23 PM, Larry Martell wrote: > Somthing I came across in my travels through the ether: > > https://medium.com/@deliciousrobots/5d2ad703365d/ Hey kids, maybe if we all chant this enough times, we can make it true! Wouldn't that be fun? From roy at panix.com Sat Jul 12 16:39:38 2014 From: roy at panix.com (Roy Smith) Date: Sat, 12 Jul 2014 16:39:38 -0400 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > And there are plenty of other laws of real numbers that floats violate > (or, let's be generous, "approximate to rather than following > perfectly"). For instance, adding two positive (non-zero) numbers > should result in a number which is greater than either, but thanks to > rounding, that's not always true. Not to mention that whole "sum of all the positive integers" thing :-) From rosuav at gmail.com Sat Jul 12 19:01:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Jul 2014 09:01:09 +1000 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 13, 2014 at 4:14 AM, Johannes Bauer wrote: > Bullshit. Comparing floats by their representation is *generally* a bad > idea because of portability issues. You don't know if IEEE754 is used to > represent floats on the systems that your code is used on. No, you don't, but I think you can safely assume that 1.0 == 1.0 on any system that Python runs on. ChrisA From roy at panix.com Sat Jul 12 19:06:34 2014 From: roy at panix.com (Roy Smith) Date: Sat, 12 Jul 2014 19:06:34 -0400 Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article , Chris Angelico wrote: > On Sun, Jul 13, 2014 at 4:14 AM, Johannes Bauer wrote: > > Bullshit. Comparing floats by their representation is *generally* a bad > > idea because of portability issues. You don't know if IEEE754 is used to > > represent floats on the systems that your code is used on. > > No, you don't, but I think you can safely assume that 1.0 == 1.0 on > any system that Python runs on. > > ChrisA But, you can still have: >>> print x 1.0 >>> print y 1.0 >>> print x == y False which, I know, isn't really what you were talking about, but it is part of the general confusion of using floats. From rosuav at gmail.com Sat Jul 12 19:15:56 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Jul 2014 09:15:56 +1000 Subject: Proposal: === and !=== operators In-Reply-To: References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 13, 2014 at 9:06 AM, Roy Smith wrote: > But, you can still have: > >>>> print x > 1.0 >>>> print y > 1.0 >>>> print x == y > False > > > which, I know, isn't really what you were talking about, but it is part > of the general confusion of using floats. This is partly because of the oh-so-handy magic of Python's float reprs, rounding them off. Can you do the same trick in Python 3, where the repr rules changed? If so, I would say this is a potential flaw in the display, although not really a serious one. But in terms of the OP's complaint, this is still fine, as the state must have changed for it to be unequal. If you care about equality differences and NOT about the above change, well, I think I've found your solution: instead of "x == y", you should use "repr(x) == repr(y)" :) ChrisA From rodrick.brown at gmail.com Sat Jul 12 22:05:34 2014 From: rodrick.brown at gmail.com (Rodrick Brown) Date: Sat, 12 Jul 2014 22:05:34 -0400 Subject: codingbat question broken? Message-ID: I'm working on the following problem set from codingbat.com http://codingbat.com/prob/p107863 Given 3 int values, a b c, return their sum. However, if one of the values is 13 then it does not count towards the sum and values to its right do not count. So for example, if b is 13, then both b and c do not count. lucky_sum(1, 2, 3) ? 6 lucky_sum(1, 2, 13) ? 3 lucky_sum(1, 13, 3) ? 1 The solution I came up with was - def lucky_sum(a, b, c): t = 0 for ints in (a, b, c): if a == 13: t = b + c elif b == 13: t = a elif c == 13: t = a + b else: t = a + b + c return t However the following tests fail lucky_sum(13, 2, 3) ? 05X lucky_sum(13, 2, 13) ? 015X lucky_sum(13, 13, 2) ? 015X Can anyone show me an example where all test are success? -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sat Jul 12 22:19:18 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 13 Jul 2014 12:19:18 +1000 Subject: codingbat question broken? In-Reply-To: References: Message-ID: On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown wrote: > > Can anyone show me an example where all test are success? No, because that's asking for the answer :) What you need to do is look at the failing test cases, and figure out why your function is giving the wrong result. Do you see what's true of all the failing cases and is not true of any others? That might give you a clue as to what's wrong. ChrisA From drsalists at gmail.com Sun Jul 13 00:21:45 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Sat, 12 Jul 2014 21:21:45 -0700 Subject: codingbat question broken? In-Reply-To: References: Message-ID: This runs on 2.7 or 3.4, unmodified (other than the #!): #!/usr/local/cpython-2.7/bin/python #!/usr/local/cpython-3.4/bin/python def lucky_sum(*list_): lucky_total = 0 for element in list_: if element == 13: break lucky_total += element return lucky_total if __name__ == '__main__': print('starting tests') assert lucky_sum(1, 2, 3) == 6 assert lucky_sum(1, 2, 13) == 3 assert lucky_sum(1, 13, 3) == 1 print('ending tests') On Sat, Jul 12, 2014 at 7:05 PM, Rodrick Brown wrote: > I'm working on the following problem set from codingbat.com > > http://codingbat.com/prob/p107863 > > Given 3 int values, a b c, return their sum. However, if one of the values > is 13 then it does not count towards the sum and values to its right do not > count. So for example, if b is 13, then both b and c do not count. > > lucky_sum(1, 2, 3) ? 6 > lucky_sum(1, 2, 13) ? 3 > lucky_sum(1, 13, 3) ? 1 > > The solution I came up with was - > > def lucky_sum(a, b, c): > t = 0 > for ints in (a, b, c): > if a == 13: > t = b + c > elif b == 13: > t = a > elif c == 13: > t = a + b > else: > t = a + b + c > return t > > However the following tests fail > > lucky_sum(13, 2, 3) ? 05X lucky_sum(13, 2, 13) ? 015X lucky_sum(13, > 13, 2) ? 015X > > Can anyone show me an example where all test are success? > > > -- > https://mail.python.org/mailman/listinfo/python-list > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Sun Jul 13 00:36:06 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 12 Jul 2014 22:36:06 -0600 Subject: codingbat question broken? In-Reply-To: References: Message-ID: On Sat, Jul 12, 2014 at 8:05 PM, Rodrick Brown wrote: > if a == 13: > t = b + c This looks incorrect. So no, I don't think the problem is with codingbat. -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Sun Jul 13 00:48:34 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 13 Jul 2014 04:48:34 GMT Subject: Proposal: === and !=== operators References: <53bce8a3$0$2746$c3e8da3$76491128@news.astraweb.com> <53bd08b4$0$2746$c3e8da3$76491128@news.astraweb.com> <53c163ba$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53c20fa1$0$9505$c3e8da3$5496439d@news.astraweb.com> On Sat, 12 Jul 2014 20:14:32 +0200, Johannes Bauer wrote: > On 12.07.2014 18:35, Steven D'Aprano wrote: > >> If you said, "for many purposes, one should not compare floats for >> equality, but should use some sort of fuzzy comparison instead" then I >> would agree with you. But your insistence that equality "always" is >> wrong takes it out of good advice into the realm of superstition. > > Bullshit. Comparing floats by their representation is *generally* a bad > idea because of portability issues. You don't know if IEEE754 is used to > represent floats on the systems that your code is used on. How many systems do you know of are there that support Python but don't support IEEE-754? Here's a thread from 2008 which discusses this: https://mail.python.org/pipermail/python-dev/2008-February/076680.html If you're running my code on an implementation of Python without IEEE-754 floats, then I'm quite happy to say "Sorry guys, that's not my problem, you're on your own." And if you're running an implementation of Python where 1.0 != 1.0, well, your system is so broken that there is no hope for it. None what so ever. > You're hairsplitting: when I'd have said "in 99.9% of cases" you'd agree > with me I never said that. I would not put a percentage to it, because it depends on the context and what you are trying to do. For some uses, exact equality is the right solution. For others, an absolute epsilon comparison is better. For yet others still, a relative error, or a ULP comparison, are better solutions. There's no way of putting a percentage to those. You have to understand what you are doing, and not just mindlessly follow some superstition. When you mindlessly follow superstition, you end up with bogus warnings like this: https://gcc.gnu.org/ml/gcc/2001-08/msg00853.html > but since I said "always" you disagree. Don't lawyer out. > Comparing binary representation of floats is a crappy idea. Yes. And *not* comparing floats with == is a crappy idea too. *EVERY* method of comparing two floats to see if they are the same can break under some circumstances. Everything about floats is crappy, except that avoiding floats completely is *worse*. Nevertheless, floats are not magically cursed. They are deterministic, for any fixed combination of CPU (or FPU) + machine code, and if you understand how floats work, then you can understand when to use exact equality and when not to: http://randomascii.wordpress.com/2012/06/26/doubles-are-not-floats-so- dont-compare-them/ Using any sort of fuzzy comparison means that you lose transitivity: if x == y and y == z then x == z This holds for any sane floating point system, but it doesn't hold with fuzzy comparisons. By default, APL uses fuzzy comparisons instead of exact equality. Out of the thousands of programming languages ever designed, APL is unique, or at most one of a tiny handful of languages, which eschews exact float equality. Why do you think that is? The idea of tolerant comparisons and fuzzy functions is a fundamental design feature of APL: http://www.jsoftware.com/papers/satn23.htm nevertheless even in APL there are uses for setting the tolerance to zero (i.e. to get exact equality). Robert Bernecky gives one such example, and writes "In such a search exact comparison is absolutely necessary." [Aside: I note that despite providing fuzzy comparison functions, and a system variable that controls the amount of fuzz, APL merely pushes the decision of how much fuzz is appropriate onto the user: "In general, ?ct should be chosen to be the smallest value which is large enough to mask common arithmetic errors." And what about uncommon arithmetic errors, I wonder? But I digress.] > Even more so in the age of cloud computing where your code is executed > on who knows which architecture where the exact same high level > interpretation might lead to vastly different results. If so, then that is a bug in the cloud computing platform. Not my problem. Complain to the provider. > Not to mention > high performance computing, where specialized FPUs can numerously be > found which don't give a shit about IEEE754. Why should I support such broken platforms? If I run Python code on some horrible platform which only checks the first 8 characters of a string for equality "for performance reasons": if "monumentless" == "monumental": print "Your Python is broken" we'd all agree that the implementation was broken. Failure to meet at least the semantics of CPython floats is likewise broken. > Another thing why it's good to NEVER compare floats with regards to > their binary representation: Do you exactly know how your FPU is > configured by your operating system. Do you know that your FPUs on a > multiprocessor system are configured all identically with regards to > 754? Rounding modes, etc? > > Just don't fall in the pit. Don't compare floats via equals. And this is why that advise is purest superstition. If you don't compare floats via equals, what are you supposed to do? Compare via an absolute epsilon? Which epsilon? Do you know if (x - y) is correctly rounded? In the bad old days of the 1960's and 70's, there used to be systems where x - y would underflow to zero even though x != y. If you're telling me that in 2014 I should write my Python code to support such ancient machines (machines that don't even have a Python interpreter, I might add!) I'm going to just laugh at you. No I don't have to support such machines, or their more modern (but equally broken) equivalent. The same fears of buggy float implementations and misconfigured FPUs that you use to argue against floating point == apply to every other technique as well. Do you know if (x-y) <= y*err is correctly rounded? What happens if x*err overflows? What if x-y overflows? Are you sure that your crappy FPU even guarantees that HUGE_NEGATIVE_NUMBER - HUGE_POSITIVE NUMBER will return a negative value instead of overflowing to positive number? >>> when x < x -> False >> >> Because not all types are ordered: >> >> py> x = 1+3j >> py> x < x >> Traceback (most recent call last): >> File "", line 1, in >> TypeError: unorderable types: complex() < complex() > > Oh, so then you also don't want refelexivity of equals, I think. > Because, obviously, not all types support comparison for equality: > > #!/usr/bin/python3 > class Yeah(object): > def __eq__(self, other): > raise TypeError("Booya") > Yeah() == Yeah() > > You cherrypick your logic and hairsplit in your reasoning. It's not > consistent. Who says it has to be consistent? Being consistent is a Nice To Have, but not a Must Have. "A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines." -- Ralph Waldo Emerson. Practicality beats purity. If you want some sort of pure logic language, then Python is not the language for you. In Python, there are good, useful, practical reasons for the built-in containers to assume reflexivity of equality but not of other order comparisons. -- Steven From shieldfire at gmail.com Sun Jul 13 03:01:12 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 13 Jul 2014 09:01:12 +0200 Subject: Newbie: unexpected indenting error Message-ID: While coding a rating calculator I am using a for-loop within if-elif-else. When using the for-loop in the first if instance my editor accepts this, but when using the same for-loop within the elif instance it complain about "unexpected indent". Like so: def function(x): if rdiff >=500: for .... [do stuff] elif rdiff >=410: for ... <== unexpected indent [do other stuff] What the...? What am I doing wrong? (hopefully the indents translate; else def, if/elif, for and [dostuff] are indented) /Martin S -- Regards, Martin S From ben at benfinney.id.au Sun Jul 13 03:09:54 2014 From: ben at benfinney.id.au (Ben Finney) Date: Sun, 13 Jul 2014 17:09:54 +1000 Subject: Newbie: unexpected indenting error References: Message-ID: <8561j1u43h.fsf@benfinney.id.au> Martin S writes: > What the...? What am I doing wrong? > (hopefully the indents translate; else def, if/elif, for and [dostuff] > are indented) They're all indented by different amounts. I don't see anything that would cause the parser to tell you ?unexpected indent?, though. For those reasons together, I suspect what you've posted here does not match exactly what is in your Python code. My recommendation: * Instruct your text editor to highlight any U+0009 characters (horizontal tab) as an error, and remove them. Indent with U+0020 SPACE characters only; PEP 8 recommends four spaces per indent level. * Ensure your emails are composed in plain text (AFAICT, you're already doing this), and show us *exactly* a complete example of code that will demonstrate the behaviour you're seeing. Make a new one, if you need to; just make sure it's complete so you can expect others to be able to run it too. -- \ ?If I haven't seen as far as others, it is because giants were | `\ standing on my shoulders.? ?Hal Abelson | _o__) | Ben Finney From breamoreboy at yahoo.co.uk Sun Jul 13 05:01:23 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 13 Jul 2014 10:01:23 +0100 Subject: Newbie: unexpected indenting error In-Reply-To: References: Message-ID: On 13/07/2014 08:01, Martin S wrote: > While coding a rating calculator I am using a for-loop within if-elif-else. > When using the for-loop in the first if instance my editor accepts > this, but when using the same for-loop within the elif instance it > complain about "unexpected indent". > > Like so: > > def function(x): > if rdiff >=500: > for .... > [do stuff] > elif rdiff >=410: > for ... <== unexpected indent > [do other stuff] > > > What the...? What am I doing wrong? > (hopefully the indents translate; else def, if/elif, for and [dostuff] > are indented) > > /Martin S > You've gone A Space Too Far. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From shieldfire at gmail.com Sun Jul 13 05:03:30 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 13 Jul 2014 11:03:30 +0200 Subject: Newbie: unexpected indenting error In-Reply-To: <53C2350E.5050307@digipen.edu> References: <53C2350E.5050307@digipen.edu> Message-ID: Thanks, the problem was apparently a mix of way to indent the code. It's confused the H out of the editor. Using standard indentation solved the error. 2014-07-13 9:28 GMT+02:00 Gary Herron : > On 07/13/2014 12:01 AM, Martin S wrote: >> >> While coding a rating calculator I am using a for-loop within >> if-elif-else. >> When using the for-loop in the first if instance my editor accepts >> this, but when using the same for-loop within the elif instance it >> complain about "unexpected indent". >> >> Like so: >> >> def function(x): >> if rdiff >=500: >> for .... >> [do stuff] >> elif rdiff >=410: >> for ... <== unexpected indent >> [do other stuff] >> >> >> What the...? What am I doing wrong? >> (hopefully the indents translate; else def, if/elif, for and [dostuff] >> are indented) >> >> /Martin S > > > The code looks OK, but looks can be deceiving if you've manage to mix tabs > and spaces to achieve that. > > Check for a mixture, and settle on one. Tabs would work, but the > recommendation is to use spaces. > > If you don't have a mixture of the two, then we have a mystery. Send your > file as an attachment, and we'll take a closer look at it. > > Gary Herron > > > > -- > Dr. Gary Herron > Department of Computer Science > DigiPen Institute of Technology > (425) 895-4418 > -- Regards, Martin S From nhatminh179 at gmail.com Sun Jul 13 14:00:37 2014 From: nhatminh179 at gmail.com (Orakaro) Date: Sun, 13 Jul 2014 11:00:37 -0700 (PDT) Subject: Twitter Client on Terminal by Python Message-ID: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> Hello! I'm @dtvd88 on Twitter and very new here. I read from python.org that anything Python-related can be discussed, and not sure if I can share my OSS package here to get feedback or not ? I just wrote a Twitter Client on Terminal by Python, it has very beautiful display and even can display image on terminal. Check it out and maybe you guys will love it :) Homepage: http://www.rainbowstream.org/ Github: https://github.com/DTVD/rainbowstream Thanks for any feedback and sorry if this kind of topics is not tolerated here. From rosuav at gmail.com Sun Jul 13 14:20:43 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Jul 2014 04:20:43 +1000 Subject: Twitter Client on Terminal by Python In-Reply-To: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> Message-ID: On Mon, Jul 14, 2014 at 4:00 AM, Orakaro wrote: > Thanks for any feedback and sorry if this kind of topics is not tolerated here. No no, announcements of this sort are perfectly welcome here! I notice you have both README.md and README.rst - is there a reason for that? What Python versions does rainbowstream support? Your README hints that both 2.x and 3.x are supported, but I can't see a specific set of versions (eg "2.6+, 3.3+"). ChrisA From kartikjagdale11 at gmail.com Sun Jul 13 16:16:47 2014 From: kartikjagdale11 at gmail.com (Orochi) Date: Sun, 13 Jul 2014 13:16:47 -0700 (PDT) Subject: What Next After Python Basics Message-ID: Hi, I am beginner in Python I have Completed Basic Python Course from Codecademy.com . Now that I have a hands on the basics what is the next thing I should do. I mean should I learn more or start a small Project(Any Ideas are Welcomed) or any Other suggestions. Where to Start? Thank You, Orochi From kartikjagdale11 at gmail.com Sun Jul 13 16:44:05 2014 From: kartikjagdale11 at gmail.com (Orochi) Date: Sun, 13 Jul 2014 13:44:05 -0700 (PDT) Subject: codingbat question broken? In-Reply-To: References: Message-ID: <44a21cf0-8de0-48d3-a304-fe98ab3fc327@googlegroups.com> On Sunday, 13 July 2014 07:49:18 UTC+5:30, Chris Angelico wrote: > On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown wrote: > > > > > > Can anyone show me an example where all test are success? > > > > No, because that's asking for the answer :) What you need to do is > > look at the failing test cases, and figure out why your function is > > giving the wrong result. Do you see what's true of all the failing > > cases and is not true of any others? That might give you a clue as to > > what's wrong. > > > > ChrisA On Sunday, 13 July 2014 07:49:18 UTC+5:30, Chris Angelico wrote: > On Sun, Jul 13, 2014 at 12:05 PM, Rodrick Brown wrote: > > > > > > Can anyone show me an example where all test are success? > > > > No, because that's asking for the answer :) What you need to do is > > look at the failing test cases, and figure out why your function is > > giving the wrong result. Do you see what's true of all the failing > > cases and is not true of any others? That might give you a clue as to > > what's wrong. > > > > ChrisA This Is My Code(using Python 2.7) Its working fine with the given test cases. #Lucky_Sum a =[] def lucky_sum(list): t = 0 for item in list: if item == 13: break else: t=t+item return t list=[] type(list) n = raw_input("Enter Numebr of item in list: ") n = int(n) for x in range (0,n): list.append(int(raw_input())) print "List is :",list print lucky_sum(list) From paul.lafollette at gmail.com Sun Jul 13 19:53:09 2014 From: paul.lafollette at gmail.com (Paul LaFollette) Date: Sun, 13 Jul 2014 19:53:09 -0400 Subject: Multiprocessing question Message-ID: Kind people, I have thrown together a little C/UNIX program that forks a child process, then proceeds to let the child and parent alternate. Either can run until it pauses itself and wakes the other. I would like to know if there be a way to create the same behavior in Python 3, preferably in a non-platform dependent fashion. I would prefer to use processes rather than threads, but could live with threads if I had to. I've studied the documentation for the multiprocessing and thread modules, but I can't see an easy way to do what I want to do. I need minimal communication between processes beyond what i have described, so creating queues or pipes seems like overkill. Unlike what I have written here, I will want to exec the child rather than write the whole thing in the else clause. Is there a reasonably simple way to do this? A reference to useful documentation would be appreciated. Sample code even more so, of course. Thank you Paul ------------------------- Paul S. LaFollette, Jr CIS Department Temple University +1 215 204 6822 paul.lafollette at temple.edu http://knight.cis.temple.edu/~lafollet #include #include #include #include #include #include int main(int argc, char **argv) { void handler(int); pid_t pid; signal(SIGCONT, handler); pid = fork(); if (pid < 0) //failure { printf("Unable to fork\n"); exit(1); } else if (pid > 0) // parent { while (1) { printf("Parent waiting for child to do something\n"); pause(); printf("Parent doing nifty stuff.\n"); sleep(1); printf("Parent waking child\n"); errno = 0; if (kill(pid, SIGCONT) < 0) perror("Parent failed to SIGCONT child."); } } else //pid == 0 so child { while (1) { printf (" Child doing useful work.\n"); sleep(1); printf(" Child waking parent\n"); if (kill(getppid(), SIGCONT) < 0) perror("Child failed to SIGCONT parent."); printf(" Child waiting for parent to do something\n"); pause(); } } } void handler(int signum) { } =============================================================================== Output: Parent waiting for child to do something Child doing useful work. Child waking parent Child waiting for parent to do something Parent doing nifty stuff. Parent waking child Parent waiting for child to do something Child doing useful work. Child waking parent Child waiting for parent to do something Parent doing nifty stuff. Parent waking child Parent waiting for child to do something Child doing useful work. Child waking parent Child waiting for parent to do something -------------- next part -------------- An HTML attachment was scrubbed... URL: From denismfmcmahon at gmail.com Sun Jul 13 20:14:08 2014 From: denismfmcmahon at gmail.com (Denis McMahon) Date: Mon, 14 Jul 2014 00:14:08 +0000 (UTC) Subject: Newbie: unexpected indenting error References: Message-ID: On Sun, 13 Jul 2014 09:01:12 +0200, Martin S wrote: > While coding a rating calculator I am using a for-loop within > if-elif-else. > When using the for-loop in the first if instance my editor accepts this, > but when using the same for-loop within the elif instance it complain > about "unexpected indent". > > Like so: > > def function(x): > if rdiff >=500: > for .... > [do stuff] > elif rdiff >=410: > for ... <== unexpected indent > [do other stuff] > > > What the...? What am I doing wrong? > (hopefully the indents translate; else def, if/elif, for and [dostuff] > are indented) You seem to have posted what you believe is an equivalent structure to your code, rather than your actual code. The structure you have posted looks fine, but it's not a runnable snippet that we can actually test. Can you actually reproduce the problem in a single block of code that we can try and run ourselves? For example, if you copy your "problem" function to a new file and edit the function def line and the code and lines after the for statements as follows, does the problem persist? for rdiff in range( 450, 600, 100 ): if rdiff >=500: for i in range( 1, 3 ): print rdiff, i elif rdiff >=410: for i in range( 1, 3 ): print i, ridff -- Denis McMahon, denismfmcmahon at gmail.com From gary.herron at islandtraining.com Sun Jul 13 20:07:21 2014 From: gary.herron at islandtraining.com (Gary Herron) Date: Sun, 13 Jul 2014 17:07:21 -0700 Subject: Multiprocessing question In-Reply-To: References: Message-ID: <53C31F39.5070606@islandtraining.com> On 07/13/2014 04:53 PM, Paul LaFollette wrote: > Kind people, > I have thrown together a little C/UNIX program that forks a child > process, then proceeds to let the child and parent alternate. Either > can run until it pauses itself and wakes the other. > > I would like to know if there be a way to create the same behavior in > Python 3, preferably in a non-platform dependent fashion. I would > prefer to use processes rather than threads, but could live with > threads if I had to. I've studied the documentation for the > multiprocessing and thread modules, but I can't see an easy way to do > what I want to do. I need minimal communication between processes > beyond what i have described, so creating queues or pipes seems like > overkill. Unlike what I have written here, I will want to exec the > child rather than write the whole thing in the else clause. Is there > a reasonably simple way to do this? A reference to useful > documentation would be appreciated. Sample code even more so, of course. > Thank you > Paul There is a quite reasonable way to do what you want, but that involves the multiprocessing and queue modules, both of which you have eliminated from consideration. So you have to ask yourself: What do you gain from using Python if you eliminate all the tools Python provides? Gary Herron > > ------------------------- > Paul S. LaFollette, Jr > CIS Department > Temple University > +1 215 204 6822 > paul.lafollette at temple.edu > http://knight.cis.temple.edu/~lafollet > > > #include > #include > #include > #include > #include > #include > > int main(int argc, char **argv) > { > void handler(int); > pid_t pid; > > signal(SIGCONT, handler); > > pid = fork(); > if (pid < 0) //failure > { > printf("Unable to fork\n"); > exit(1); > } > else if (pid > 0) // parent > { > while (1) > { > printf("Parent waiting for child to do something\n"); > pause(); > printf("Parent doing nifty stuff.\n"); > sleep(1); > printf("Parent waking child\n"); > errno = 0; > if (kill(pid, SIGCONT) < 0) > perror("Parent failed to SIGCONT child."); > } > } > else //pid == 0 so child > { > while (1) > { > printf (" Child doing useful > work.\n"); > sleep(1); > printf(" Child waking > parent\n"); > if (kill(getppid(), SIGCONT) < 0) > perror("Child failed to SIGCONT parent."); > printf(" Child waiting for > parent to do something\n"); > pause(); > } > } > } > > void handler(int signum) > { > } > =============================================================================== > Output: > Parent waiting for child to do something > Child doing useful work. > Child waking parent > Child waiting for parent to do > something > Parent doing nifty stuff. > Parent waking child > Parent waiting for child to do something > Child doing useful work. > Child waking parent > Child waiting for parent to do > something > Parent doing nifty stuff. > Parent waking child > Parent waiting for child to do something > Child doing useful work. > Child waking parent > Child waiting for parent to do > something > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From drsalists at gmail.com Sun Jul 13 20:38:31 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Sun, 13 Jul 2014 17:38:31 -0700 Subject: What Next After Python Basics In-Reply-To: References: Message-ID: On Sun, Jul 13, 2014 at 1:16 PM, Orochi wrote: > Hi, > I am beginner in Python > I have Completed Basic Python Course from Codecademy.com . > Now that I have a hands on the basics what is the next thing I should do. > I mean should I learn more or start a small Project(Any Ideas are Welcomed) or any Other suggestions. > Where to Start? That really depends on how quickly (or slowly) you get frustrated. If you're able to say "I don't understand this yet, but I'll tuck it in the back of my mind for later" a lot, and google for answers as needed, I'd dive into a project. If not, maybe try another course and/or monitor this group and Stackoverflow. The best kind of project to pick, now or later, is the kind that you will actually use yourself. From chris at cdreimer.com Sun Jul 13 17:46:20 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sun, 13 Jul 2014 14:46:20 -0700 Subject: What Next After Python Basics In-Reply-To: References: Message-ID: <53C2FE2C.8000505@cdreimer.com> On 7/13/2014 1:16 PM, Orochi wrote: > Hi, > I am beginner in Python > I have Completed Basic Python Course from Codecademy.com . > Now that I have a hands on the basics what is the next thing I should do. > I mean should I learn more or start a small Project(Any Ideas are Welcomed) or any Other suggestions. > Where to Start? > > Thank You, > Orochi My first project after barely learning the basics of Python was reading a spreadsheet with 600+ website URLs, taking a screenshot of each website, and building a HTML webpage to display the 600+ screenshots. If I was to do this manually (i.e., clicking and looking at each website), this would take two weeks of my spare time. By automating this task into a Python script (which took two weeks of my spare time), the script runs for two hours in the background and I take 15 minutes to glance at the HTML pages with screenshots. If I find something wrong with a particular screenshot, I can click on the website URL to investigate further. Chris Reimer From nhatminh179 at gmail.com Sun Jul 13 22:18:13 2014 From: nhatminh179 at gmail.com (Orakaro) Date: Sun, 13 Jul 2014 19:18:13 -0700 (PDT) Subject: Twitter Client on Terminal by Python In-Reply-To: References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> Message-ID: <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> On Monday, July 14, 2014 3:20:43 AM UTC+9, Chris Angelico wrote: > On Mon, Jul 14, 2014 at 4:00 AM, Orakaro wrote: > > > Thanks for any feedback and sorry if this kind of topics is not tolerated here. > > > > No no, announcements of this sort are perfectly welcome here! > > > > I notice you have both README.md and README.rst - is there a reason for that? > > > > What Python versions does rainbowstream support? Your README hints > > that both 2.x and 3.x are supported, but I can't see a specific set of > > versions (eg "2.6+, 3.3+"). > > > > ChrisA Hi Angelico I use README.md for Github and README.rst for PyPi. Is there a way to use only one file for both sites ? I tested my package on Python 2.7 and Python 3.4 But do I have to install all Python 2.6, Python 3.* in my system and test in all environment for sure ? Thanks very much. From steve+comp.lang.python at pearwood.info Sun Jul 13 22:44:16 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 14 Jul 2014 02:44:16 GMT Subject: Multiprocessing question References: Message-ID: <53c34400$0$9505$c3e8da3$5496439d@news.astraweb.com> On Sun, 13 Jul 2014 19:53:09 -0400, Paul LaFollette wrote: > I have thrown together a little C/UNIX program that forks a child > process, then proceeds to let the child and parent alternate. Either > can run until it pauses itself and wakes the other. > > I would like to know if there be a way to create the same behavior in > Python 3, preferably in a non-platform dependent fashion. The most direct way of duplicating the Unix idiom of forking a child process is to use the os.fork function, which is (I believe) just a thin wrapper around the C fork function. https://docs.python.org/3/library/os.html#os.fork But this is not platform-independent, it is Unix only. Alternatively, you can look at the various os.exec* functions, which are available on Windows and Unix, and see if any of them are useful. But the best way to solve this in a platform independent way is to use one of the concurrency modules: https://docs.python.org/3/library/concurrency.html such as multiprocessing. Although these are written for Python 2 rather than 3, you may find them useful: http://pymotw.com/2/multiprocessing/index.html#module-multiprocessing https://www.ibm.com/developerworks/aix/library/au-multiprocessing/ -- Steven From rosuav at gmail.com Sun Jul 13 23:51:29 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Jul 2014 13:51:29 +1000 Subject: Twitter Client on Terminal by Python In-Reply-To: <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> Message-ID: On Mon, Jul 14, 2014 at 12:18 PM, Orakaro wrote: > I use README.md for Github and README.rst for PyPi. Is there a way to use only one file for both sites ? Ah. I don't know; check the docs for one or the other and see what they'll do. > I tested my package on Python 2.7 and Python 3.4 But do I have to install all Python 2.6, Python 3.* in my system and test in all environment for sure ? You can state that it supports 2.7 and 3.4, without testing on any other versions. Those are the two current versions - my example was showing support for more than just the one latest, but that was just an example, nothing more. When Python 3.5 comes out, you'll probably want to test on that (and then say "supports 2.7 and 3.4+"), but at the moment, "2.7 and 3.4" is fine. If people want to use this with, say, 3.3, then they're welcome to try, but they'll know not to presume that it'll work. ChrisA From nhatminh179 at gmail.com Mon Jul 14 00:24:22 2014 From: nhatminh179 at gmail.com (Orakaro) Date: Sun, 13 Jul 2014 21:24:22 -0700 (PDT) Subject: Twitter Client on Terminal by Python In-Reply-To: References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> Message-ID: <0f14252e-e471-4e3b-91cf-69d0d2ae7528@googlegroups.com> On Monday, July 14, 2014 12:51:29 PM UTC+9, Chris Angelico wrote: > On Mon, Jul 14, 2014 at 12:18 PM, Orakaro wrote: > > > I use README.md for Github and README.rst for PyPi. Is there a way to use only one file for both sites ? > > > > Ah. I don't know; check the docs for one or the other and see what they'll do. > > > > > I tested my package on Python 2.7 and Python 3.4 But do I have to install all Python 2.6, Python 3.* in my system and test in all environment for sure ? > > > > You can state that it supports 2.7 and 3.4, without testing on any > > other versions. Those are the two current versions - my example was > > showing support for more than just the one latest, but that was just > > an example, nothing more. When Python 3.5 comes out, you'll probably > > want to test on that (and then say "supports 2.7 and 3.4+"), but at > > the moment, "2.7 and 3.4" is fine. If people want to use this with, > > say, 3.3, then they're welcome to try, but they'll know not to presume > > that it'll work. > > > > ChrisA Angelico, Thank you very much! From marko at pacujo.net Mon Jul 14 01:07:49 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Mon, 14 Jul 2014 08:07:49 +0300 Subject: Multiprocessing question References: Message-ID: <87sim45xzu.fsf@elektro.pacujo.net> Gary Herron : > On 07/13/2014 04:53 PM, Paul LaFollette wrote: >> I have thrown together a little C/UNIX program that forks a child >> process, then proceeds to let the child and parent alternate. Either >> can run until it pauses itself and wakes the other. >> >> [...] > > What do you gain from using Python if you eliminate all the tools > Python provides? The language core itself. Anyway, the subprocessing.Popen is perfect for process creation. For event multiplexing, Python3.4 has the asyncio module, although multiplexing pipes might be platform-dependent (works in linux at least). Marko From steve at pearwood.info Mon Jul 14 02:09:32 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 14 Jul 2014 06:09:32 GMT Subject: Logging all uncaught exceptions Message-ID: <53c3741b$0$2746$c3e8da3$76491128@news.astraweb.com> I want to catch all uncaught exceptions in my application, log them, then handle as normal. Which, in practice, means a traceback. Is this the right way to do it? import logging import sys logger = logging.getLogger('mylogger') def my_handler(type, value, tb): msg = "Uncaught %s: %s" % (type, value) logger.exception(msg) sys.__excepthook__(type, value, tb) # Install exception handler sys.excepthook = my_handler # Run your main script here: if __name__ == '__main__': main() From steve at pearwood.info Mon Jul 14 05:07:24 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 14 Jul 2014 09:07:24 GMT Subject: Logging all uncaught exceptions References: <53c3741b$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53c39dcb$0$2746$c3e8da3$76491128@news.astraweb.com> On Mon, 14 Jul 2014 06:09:32 +0000, Steven D'Aprano wrote: > I want to catch all uncaught exceptions in my application, log them, > then handle as normal. Which, in practice, means a traceback. Is this > the right way to do it? I think I've answered my own question, which leads to the next question. I'm logging with the syslog handler, and I can see all the logged messages *except* those generated by my logger's exception method. Here's my code, consisting of two modules: # === mylogging.py === import logging import logging.handlers name = 'Spam' mylogger = logging.getLogger(name) handler = logging.handlers.SysLogHandler(address='/dev/log') mylogger.addHandler(handler) mylogger.setLevel(logging.DEBUG) mylogger.info('started logging ' + name) # === main.py === from mylogging import mylogger mylogger.info('main.py running') mylogger.debug('I can see debugging messages too') import sys def my_error_handler(type, value, tb): msg = "Uncaught %s: %s" % (type, value) mylogger.exception(msg) sys.__excepthook__(type, value, tb) # Install exception handler. sys.excepthook = my_error_handler mylogger.info('testing exception logging...') raise RuntimeError('a fake error occurred') I run it from the command line on a Debian squeeze system: steve at runes:~/test_logging$ python2.6 main.py Traceback (most recent call last): File "main.py", line 15, in raise RuntimeError('a fake error occurred') RuntimeError: a fake error occurred The debug and info messages are logged: root at runes:/var/log# tail -1 debug Jul 14 19:04:39 runes I can see debugging messages too root at runes:/var/log# tail -3 messages Jul 14 19:04:39 runes started logging Spam Jul 14 19:04:39 runes main.py running Jul 14 19:04:39 runes testing exception logging... but the exception info which should have been generated by mylogger.exception doesn't appear anywhere I can see. What am I doing wrong? -- Steven From rosuav at gmail.com Mon Jul 14 05:21:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 14 Jul 2014 19:21:44 +1000 Subject: Logging all uncaught exceptions In-Reply-To: <53c39dcb$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53c3741b$0$2746$c3e8da3$76491128@news.astraweb.com> <53c39dcb$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On Mon, Jul 14, 2014 at 7:07 PM, Steven D'Aprano wrote: > but the exception info which should have been generated by > mylogger.exception doesn't appear anywhere I can see. > > > What am I doing wrong? I'm not specifically familiar with the logging module, but something I'd look at would be 'ls /var/log -lt|head' to see what files get updated. (Works well with 'watch' - a file gets changed, it jumps up to the top of the list.) Maybe the exceptions are going into a different file (they go at the ERROR level, IIUI). If that doesn't help: the exception method says "This method should only be called from an exception handler", so I don't know if it uses magic to get extra info. What happens if you explicitly use .debug() instead? But you probably know a lot more about this than I do. ChrisA From steve at pearwood.info Mon Jul 14 05:42:55 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 14 Jul 2014 09:42:55 GMT Subject: Logging all uncaught exceptions References: <53c3741b$0$2746$c3e8da3$76491128@news.astraweb.com> <53c39dcb$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53c3a61f$0$2746$c3e8da3$76491128@news.astraweb.com> On Mon, 14 Jul 2014 19:21:44 +1000, Chris Angelico wrote: > On Mon, Jul 14, 2014 at 7:07 PM, Steven D'Aprano > wrote: >> but the exception info which should have been generated by >> mylogger.exception doesn't appear anywhere I can see. >> >> >> What am I doing wrong? > > I'm not specifically familiar with the logging module, but something I'd > look at would be 'ls /var/log -lt|head' to see what files get updated. > (Works well with 'watch' - a file gets changed, it jumps up to the top > of the list.) Maybe the exceptions are going into a different file (they > go at the ERROR level, IIUI). That's it! Thanks. Under Debian, ERROR level messages go to /var/log/syslog instead of debug or messages. -- Steven From roy at panix.com Mon Jul 14 08:59:19 2014 From: roy at panix.com (Roy Smith) Date: Mon, 14 Jul 2014 08:59:19 -0400 Subject: Multiprocessing question References: <53c34400$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: In article <53c34400$0$9505$c3e8da3$5496439d at news.astraweb.com>, Steven D'Aprano wrote: > On Sun, 13 Jul 2014 19:53:09 -0400, Paul LaFollette wrote: > > > I have thrown together a little C/UNIX program that forks a child > > process, then proceeds to let the child and parent alternate. Either > > can run until it pauses itself and wakes the other. > > > > I would like to know if there be a way to create the same behavior in > > Python 3, preferably in a non-platform dependent fashion. [...] > But the best way to solve this in a platform independent way is to use > one of the concurrency modules: > > https://docs.python.org/3/library/concurrency.html > > such as multiprocessing. Although these are written for Python 2 rather > than 3, you may find them useful: > > http://pymotw.com/2/multiprocessing/index.html#module-multiprocessing > > https://www.ibm.com/developerworks/aix/library/au-multiprocessing/ Let me toss out one other possibility. If you are going to build some kind of message queue between two processes, you might want to look at an external queue mechanism such as http://kr.github.io/beanstalkd/ or http://www.celeryproject.org/. The advantage of these over rolling your own using the built-in Python modules is they handle a lot of queueing, locking, and persistence problems which you might end up having to deal with yourself. They also give you the ability to locate the two processes on different machines. You might not want to do that today, but if your application grows, it might be how you want to scale your processing power. It is easy, for example, to have one process pushing tasks onto the queue, and a large number of workers pulling them off. The producer doesn't have to know anything about how many workers there are (nor does there need to be a fixed number). They are also language independent. You might discover at some point in the future that you want to rewrite one side of the queue in a different language for some reason (perhaps to take advantage of a library that's not available in Python). A queue like Beanstalk or Celery makes that easy. Of course, to do this, you would need to format your messages in some language-neutral way (JSON, MessagePack, etc). From krzysztof.zelechowski at syncron.com Mon Jul 14 10:59:59 2014 From: krzysztof.zelechowski at syncron.com (krzysztof.zelechowski at syncron.com) Date: Mon, 14 Jul 2014 16:59:59 +0200 Subject: Do I need to call close on the handle returned by urlopen? Message-ID: The tutorial says that I should use "with open" to close the file handle properly. The reference documentation for urlopen mentions that the handle returned is like a file handle but the code samples below do not bother to close the handle at all. Isn?t it inconsistent? From skip at pobox.com Mon Jul 14 11:09:42 2014 From: skip at pobox.com (Skip Montanaro) Date: Mon, 14 Jul 2014 10:09:42 -0500 Subject: Do I need to call close on the handle returned by urlopen? In-Reply-To: References: Message-ID: > The tutorial says that I should use "with open" to close the file > handle properly. The reference documentation for urlopen mentions > that the handle returned is like a file handle but the code samples > below do not bother to close the handle at all. Isn?t it > inconsistent? I think two things might be happening here. 1. Code samples are just that. They often demonstrate usage with the smallest amount of code possible, so that the key part of what they are demonstrating isn't lost in a bunch of other clutter. That often means leaving out error checking and not completely cleaning up after themselves, especially if those bits might obscure the actual concept being conveyed. 2. The "with" statement is (relative to many other parts of the language) still pretty new, so it's not all that surprising that examples in the documentation haven't all been updated to reflect the latest recommended practice. Skip From krzysztof.zelechowski at syncron.com Mon Jul 14 11:08:26 2014 From: krzysztof.zelechowski at syncron.com (krzysztof.zelechowski at syncron.com) Date: Mon, 14 Jul 2014 17:08:26 +0200 Subject: Do I need to call close on the handle returned by urlopen? In-Reply-To: References: Message-ID: http://bugs.python.org/issue12955 U?ytkownik napisa? w wiadomo?ci grup dyskusyjnych:lq0sar$r6e$1 at mx1.internetia.pl... The tutorial says that I should use "with open" to close the file handle properly. The reference documentation for urlopen mentions that the handle returned is like a file handle but the code samples below do not bother to close the handle at all. Isn?t it inconsistent? From roy at panix.com Mon Jul 14 11:12:56 2014 From: roy at panix.com (Roy Smith) Date: Mon, 14 Jul 2014 11:12:56 -0400 Subject: python-aware wdiff? Message-ID: Does anybody know of a wdiff-like tool (http://www.gnu.org/software/wdiff/) which is aware of python syntax and can show token changes instead of word changes. Wdiff is can turn - if not metar.is_in_temp_range_f(situation.weather.low_temperature, situation.weather.high_temperature): + if not info.is_in_temp_range_f(situation.weather.low_temperature, situation.weather.high_temperature): into if not [-metar.is_in_temp_range_f(situation.weather.low_temperature,-] {+info.is_in_temp_range_f(situation.weather.low_temperature,+} situation.weather.high_temperature): but what I really want is: if not [-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature, situation.weather.high_temperature): which makes it more obvious that the change is just the one token. Does such a tool exist? --- Roy Smith roy at panix.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Mon Jul 14 11:20:35 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 14 Jul 2014 16:20:35 +0100 Subject: Do I need to call close on the handle returned by urlopen? In-Reply-To: References: Message-ID: On 14/07/2014 15:59, krzysztof.zelechowski at syncron.com wrote: > The tutorial says that I should use "with open" to close the file handle > properly. The reference documentation for urlopen mentions that the handle > returned is like a file handle but the code samples below do not bother to > close the handle at all. Isn?t it inconsistent? Yes it is. The latter probably hasn't been updated after the introduction of the 'with' keyword and context managers. Would you like to click on the "Report a bug" link on the page in question and suggest a change? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From 1248283536 at qq.com Mon Jul 14 09:16:01 2014 From: 1248283536 at qq.com (=?utf-8?B?5rC06Z2Z5rWB5rex?=) Date: Mon, 14 Jul 2014 21:16:01 +0800 Subject: Not enough memory. Message-ID: >>> import os >>> help(os.path) Not enough memory.? Why i get it?Not enough memory , not help info?,not -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Mon Jul 14 12:20:40 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 14 Jul 2014 17:20:40 +0100 Subject: Not enough memory. In-Reply-To: References: Message-ID: On 14/07/2014 14:16, ???? wrote: > >>> import os > >>> help(os.path) > Not enough memory.? > > Why i get it?Not enough memory , not help info?,not > A known problem see http://bugs.python.org/issue19914 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From zachary.ware+pylist at gmail.com Mon Jul 14 12:40:03 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Mon, 14 Jul 2014 11:40:03 -0500 Subject: Not enough memory. In-Reply-To: References: Message-ID: On Mon, Jul 14, 2014 at 8:16 AM, ???? <1248283536 at qq.com> wrote: >>>> import os >>>> help(os.path) > Not enough memory.? > > Why i get it?Not enough memory , not help info?,not In future, it's very helpful to tell us what OS is running which version of Python when you get an error, but in this case I'm betting on Python 3 on Windows with code page 65001 active: C:\>chcp 65001 Active code page: 65001 C:\>py -3 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> help(help) Not enough memory. >>> exit() C:\>chcp 437 Active code page: 437 C:\>py -3 Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> help(help) Help on _Helper in module _sitebuiltins object: ... The 'Not enough memory.' message is actually coming from the Windows 'more' utility (C:\Windows\System32\more.com), as stated in the bug linked to in Mark's message. To work around that, you can either use a different codepage (anecdotal evidence tells me that cp65001 is barely supported by anything, even Windows itself), or set the PAGER environment variable to "type", which will disable paging, but allow the help text to print. -- Zach From 2014 at jmunch.dk Mon Jul 14 12:44:15 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Mon, 14 Jul 2014 18:44:15 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> Message-ID: <53C408DF.8020309@jmunch.dk> alister wrote: > I don't have time to start this discussion over again on another mailing > list. > Don't anyone on those lists read python-list also? > > they possibly do, but prefer to keep discussions to the proper forum The semantics of the Python programming language is on-topic for python-list. This is about float.__eq__, not about numpy or SciPy. Maybe they just don't like beer? regards, Anders From wxjmfauth at gmail.com Mon Jul 14 13:37:10 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Mon, 14 Jul 2014 10:37:10 -0700 (PDT) Subject: Not enough memory. In-Reply-To: References: Message-ID: Le lundi 14 juillet 2014 18:40:03 UTC+2, Zachary Ware a ?crit?: > On Mon, Jul 14, 2014 at 8:16 AM, ???? <1248283536 at qq.com> wrote: > > >>>> import os > > >>>> help(os.path) > > > Not enough memory.? > > > > > > Why i get it?Not enough memory , not help info?,not > > > > In future, it's very helpful to tell us what OS is running which > > version of Python when you get an error, but in this case I'm betting > > on Python 3 on Windows with code page 65001 active: > > > > C:\>chcp 65001 > > Active code page: 65001 > > > > C:\>py -3 > > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 > > 32 bit (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> help(help) > > Not enough memory. > > > > >>> exit() > > > > C:\>chcp 437 > > Active code page: 437 > > > > C:\>py -3 > > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 > > 32 bit (Intel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> help(help) > > Help on _Helper in module _sitebuiltins object: > > ... > > > > The 'Not enough memory.' message is actually coming from the Windows > > 'more' utility (C:\Windows\System32\more.com), as stated in the bug > > linked to in Mark's message. To work around that, you can either use > > a different codepage (anecdotal evidence tells me that cp65001 is > > barely supported by anything, even Windows itself), or set the PAGER > > environment variable to "type", which will disable paging, but allow > > the help text to print. > > > > -- > > Zach ------ Maybe. It still remains I never succeeded to find a problem with go or ruby. Or even with a TeX unicode variant ("log output"). Depending on fonts glyphs may be not displayed. That's a different problem. D:\jm\jmgo>chcp 65001 Page de codes active?: 65001 D:\jm\jmgo>hello3.exe ASCII abcde xyz German ??? ??? ? Polish ?????? Russian ??????? ??? CJK ?? French ???? Misc ??????* D:\jm\jmgo> jmf From breamoreboy at yahoo.co.uk Mon Jul 14 13:51:25 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 14 Jul 2014 18:51:25 +0100 Subject: Not enough memory. In-Reply-To: References: Message-ID: On 14/07/2014 17:40, Zachary Ware wrote: > On Mon, Jul 14, 2014 at 8:16 AM, ???? <1248283536 at qq.com> wrote: >>>>> import os >>>>> help(os.path) >> Not enough memory.? >> >> Why i get it?Not enough memory , not help info?,not > > In future, it's very helpful to tell us what OS is running which > version of Python when you get an error, but in this case I'm betting > on Python 3 on Windows with code page 65001 active: > > C:\>chcp 65001 > Active code page: 65001 > > C:\>py -3 > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 > 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> help(help) > Not enough memory. > >>>> exit() > > C:\>chcp 437 > Active code page: 437 > > C:\>py -3 > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 > 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> help(help) > Help on _Helper in module _sitebuiltins object: > ... > > The 'Not enough memory.' message is actually coming from the Windows > 'more' utility (C:\Windows\System32\more.com), as stated in the bug > linked to in Mark's message. To work around that, you can either use > a different codepage (anecdotal evidence tells me that cp65001 is > barely supported by anything, even Windows itself), or set the PAGER > environment variable to "type", which will disable paging, but allow > the help text to print. > See also https://bugs.python.org/issue21927, specifically msg222761 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Mon Jul 14 13:52:41 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 14 Jul 2014 18:52:41 +0100 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53C408DF.8020309@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53C408DF.8020309@jmunch.dk> Message-ID: On 14/07/2014 17:44, Anders J. Munch wrote: > alister wrote: >> I don't have time to start this discussion over again on another mailing >> list. >> Don't anyone on those lists read python-list also? >> >> they possibly do, but prefer to keep discussions to the proper forum > > The semantics of the Python programming language is on-topic for > python-list. This is about float.__eq__, not about numpy or SciPy. > Maybe they just don't like beer? > > regards, Anders > Maybe they recognise the eqivalent of our resident unicode expert. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ian.g.kelly at gmail.com Mon Jul 14 15:42:01 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 14 Jul 2014 13:42:01 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53C408DF.8020309@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53C408DF.8020309@jmunch.dk> Message-ID: On Mon, Jul 14, 2014 at 10:44 AM, Anders J. Munch <2014 at jmunch.dk> wrote: > alister wrote: >> >> I don't have time to start this discussion over again on another mailing >> list. >> Don't anyone on those lists read python-list also? >> >> they possibly do, but prefer to keep discussions to the proper forum > > > The semantics of the Python programming language is on-topic for > python-list. This is about float.__eq__, not about numpy or SciPy. > Maybe they just don't like beer? Well, I don't see anybody with numerical expertise chiming in here to say they agree with you either, so that tells me you've probably got the wrong audience. From tjreedy at udel.edu Mon Jul 14 16:01:55 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Jul 2014 16:01:55 -0400 Subject: python-aware wdiff? In-Reply-To: References: Message-ID: On 7/14/2014 11:12 AM, Roy Smith wrote: > Does anybody know of a wdiff-like tool > (http://www.gnu.org/software/wdiff/) which is aware of python syntax and > can show token changes instead of word changes. Wdiff is can turn > > - if not metar.is > _in_temp_range_f(situation.weather.low_temperature, > situation.weather.high_temperature): > + if not info.is > _in_temp_range_f(situation.weather.low_temperature, > situation.weather.high_temperature): > > into > > if not > [-metar.is_in_temp_range_f(situation.weather.low_temperature,-] > {+info.is_in_temp_range_f(situation.weather.low_temperature,+} > situation.weather.high_temperature): > > but what I really want is: > > if not > [-metar-]{+info+}.is_in_temp_range_f(situation.weather.low_temperature, > situation.weather.high_temperature): > > which makes it more obvious that the change is just the one token. Does > such a tool exist? The under-known difflib.differ shows within line differences. Your example would look like: - if not metar.is_in_temp_range_f(...): ? ^^^^^ + if not info.is_in_temp_range_f ? ^^^^ Deletions and insertions are indicated with '-' and '+'. I use this routinely, when backporting patches, in a script that differs the 2.7 and 3.4 versions of repository files. -- Terry Jan Reedy From tjreedy at udel.edu Mon Jul 14 16:36:40 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 14 Jul 2014 16:36:40 -0400 Subject: Twitter Client on Terminal by Python In-Reply-To: References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> Message-ID: On 7/13/2014 11:51 PM, Chris Angelico wrote: > On Mon, Jul 14, 2014 at 12:18 PM, Orakaro wrote: >> I use README.md for Github and README.rst for PyPi. Is there a way to use only one file for both sites ? > > Ah. I don't know; check the docs for one or the other and see what they'll do. > >> I tested my package on Python 2.7 and Python 3.4 But do I have to install all Python 2.6, Python 3.* in my system and test in all environment for sure ? You don't *have* do anything for free. However, if your package works on 2.7 and 3.4, it *probably* works as is for 3.2 and 3.3. On Windows at least, installing multiple versions is trivial (5 minutes for each). The more important issue, I think, is what system you have tested on. Up to 3.2, including all 2.x, Python had 'wide' and 'narrow' unicode builds. On narrow builds (Windows, some *nix), astral (non-BMP) chars count as 2. Given Twitter's 140 char limitation, this bug (solved in 3.3) could affect a Twitter client by giving the length of a 140 char tweet as more than 140 chars. > You can state that it supports 2.7 and 3.4, without testing on any > other versions. Those are the two current versions - my example was > showing support for more than just the one latest, but that was just > an example, nothing more. When Python 3.5 comes out, you'll probably > want to test on that (and then say "supports 2.7 and 3.4+"), but at > the moment, "2.7 and 3.4" is fine. If people want to use this with, > say, 3.3, then they're welcome to try, but they'll know not to presume > that it'll work. Even if you test on, say, 2.6, it is up to you whether you want to 'support' 2.6 with bugfixes, in case a patch for 2.7 does not work on 2.6. -- Terry Jan Reedy From ian.g.kelly at gmail.com Mon Jul 14 16:59:14 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Mon, 14 Jul 2014 14:59:14 -0600 Subject: python-aware wdiff? In-Reply-To: References: Message-ID: On Mon, Jul 14, 2014 at 2:01 PM, Terry Reedy wrote: > The under-known difflib.differ shows within line differences. > Your example would look like: > > - if not metar.is_in_temp_range_f(...): > ? ^^^^^ > + if not info.is_in_temp_range_f > ? ^^^^ > > Deletions and insertions are indicated with '-' and '+'. > I use this routinely, when backporting patches, in a script that differs the > 2.7 and 3.4 versions of repository files. That will produce a minimal diff though, not a syntax-aware diff. If the latter is important, something could probably be cooked up using tokenize and difflib. Not sure how much work that would be. From rantingrickjohnson at gmail.com Mon Jul 14 18:12:25 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 14 Jul 2014 15:12:25 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On Wednesday, May 28, 2014 3:15:45 PM UTC-5, Chris Angelico wrote: > On Thu, May 29, 2014 at 5:58 AM, Larry Martell wrote: > > No company that I work for is using python 3 - they just > > have too much of an investment in a python 2 code base > > to switch. I'm just saying. > And that's not a problem. Every whinging blog author seems > to forget [...] Or maybe the complaint is that there are > fancy new features in Python 3.x that aren't in 2.7? Oh > wait, that directly contradicts the whine. So if Python 3 > has added nothing, what's the rush to move onto it? What's wrong with people wanting new features WITHOUT suffering through the headaches of porting code? I think your missing the point Chris. You and i both know that most of the features could be added without breaking Python, but the choice was made to break Python anyway, and that would have been fine IF the powers that be would have REALLY made Python better, but they only "slightly" improved the language! Look, along the course of ANY learning curve, a designer, or an artist, or an engineer, is going to realize he made some catastrophic mistakes -- okay, no problem, we are ALL but human after all, even the "Anointed One" is not beyond mistakes, HOWEVER, the choice to fracture a community over "minor improvements" was a poor choice and i think some "owning up" is in order! Also, this "idea" of yours that people should just shut up and do what the "regime" commands, is just utter nonsense. Python is a public offering, and as such is equally subject to both praise and ridicule. FREEDOM OF SPEECH IS A REAL BEECH! If the "powers that be" cannot handle the heat, then they should withdraw Python from the public and then they can decree any ridiculous fascist rules they please, until then, what's that old adage about "reaping" and "sewing"...? QUESTION: "What's worse than fracturing a community?" ANSWER: "Creating a leadership vacuum." --And nature *abhors* a vacuum! Besides, "opposing and competing forces" are a fundamental part of evolution (psst: do you remember that little thing called "evolution" Chris?) and so we must NEVER forget the absolute necessity of dissent! Just think of what our world would be like if every idea was NOT placed under the microscope for scrutiny. I SHUTTER TO THINK! Image, for a moment, a world WITHOUT the great USA! Yes, i know you little commies love to curse the USA, and yes, there are many dark sins committed within AND beyond her borders, but try to tell me you bass-turds, what nation in modern history has contributed more technological achievements [1] or engendered a revolution of social justice around the world, or, propagated the idea that all men are created equal and endowed by their creator with unalienable rights? What would have happened if the colonies just threw their hands and and said: "WELL, GEORGE KNOWS BEST!" > Whiners gonna whine. And brown-nosing little shills gonna shill! [1]: even IF many of them were "borrowed". HEY, TO THE VICTOR GO THE SPOILS! From rantingrickjohnson at gmail.com Mon Jul 14 18:31:22 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 14 Jul 2014 15:31:22 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: Message-ID: <5db8cfb0-5121-4ff9-b907-8eaaf1ab9298@googlegroups.com> On Wednesday, May 28, 2014 7:41:53 PM UTC-5, Terry Reedy wrote: > Claim: "Python 3 languishes in disuse." > Fact: in 2013, there were around 14 million downloads of > windows installers for each of 2.7.x and 3.3.x. 3.3 is > over twice as popular as 3.2 (to be expected). Terry, you cannot simply take the download numbers as a "one-to-one" ratio representing the "actual" usage of anything. Consider: * HOW MANY DOWNLOADED AND NEVER USED? Might be difficult to believe, but i am one of those people. Even though i don't "actively" write code for Python3, i still keep a current version on my machine just in case i need to test a code snippet for a NOOB -- i don't remember the last time i even ran Python 3, must have been a year or more! * HOW MANY DOWNLOADED, TRIED, CURSED, AND NEVER USED AGAIN? * HOW MANY DOWNLOADED, TRIED, CURSED, AND ONLY USE BECAUSE THEY ARE FORCED? * HOW MANY DOWNLOADED, TRIED, WERE "AMUSED", BUT NOT ENOUGH TO ACTUALLY WRITE 3.X CODE? * HOW MANY DOWNLOADED, TRIED, LIKED, AND ARE "ACTIVELY" WRITING 3.X CODE? I would venture to say that at least half the downloads fall into the first three categories, and the other half are split between the last two categories -- equally split, WHO KNOWS! Sheesh! Metrics measured on download statistics are about as reliable as that ridiculous TIOBE drivel, hey, watching Python climb the index might give GvR a raging semi, but only a moron would take it for truth! PIPING HOT CUP OF WISHFUL THINKING ANYONE? From none at mailinator.com Mon Jul 14 18:37:18 2014 From: none at mailinator.com (mm0fmf) Date: Mon, 14 Jul 2014 23:37:18 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On 14/07/2014 23:12, Rick Johnson wrote: > I SHUTTER TO THINK! It's "I shudder to think"! shut?ter [shuht-er] noun 1. a solid or louvered movable cover for a window. 2. a movable cover, slide, etc., for an opening. 3. a person or thing that shuts. 4. Photography . a mechanical device for opening and closing the aperture of a camera lens to expose film or the like. verb (used with object) 5. to close or provide with shutters: She shuttered the windows. 6. to close (a store or business operations) for the day or permanently. shud?der [shuhd-er] verb (used without object) 1. to tremble with a sudden convulsive movement, as from horror,fear, or cold. noun 2. a convulsive movement of the body, as from horror, fear, or cold. From python at mrabarnett.plus.com Mon Jul 14 18:47:14 2014 From: python at mrabarnett.plus.com (MRAB) Date: Mon, 14 Jul 2014 23:47:14 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: <53C45DF2.6010909@mrabarnett.plus.com> On 2014-07-14 23:12, Rick Johnson wrote: > On Wednesday, May 28, 2014 3:15:45 PM UTC-5, Chris Angelico wrote: >> On Thu, May 29, 2014 at 5:58 AM, Larry Martell wrote: >>> No company that I work for is using python 3 - they just have too >>> much of an investment in a python 2 code base to switch. I'm just >>> saying. >> And that's not a problem. Every whinging blog author seems to >> forget [...] Or maybe the complaint is that there are fancy new >> features in Python 3.x that aren't in 2.7? Oh wait, that directly >> contradicts the whine. So if Python 3 has added nothing, what's the >> rush to move onto it? > > What's wrong with people wanting new features WITHOUT suffering > through the headaches of porting code? I think your missing the point > Chris. > > You and i both know that most of the features could be added without > breaking Python, but the choice was made to break Python anyway, and > that would have been fine IF the powers that be would have REALLY > made Python better, but they only "slightly" improved the language! > > Look, along the course of ANY learning curve, a designer, or an > artist, or an engineer, is going to realize he made some catastrophic > mistakes -- okay, no problem, we are ALL but human after all, even > the "Anointed One" is not beyond mistakes, HOWEVER, the choice to > fracture a community over "minor improvements" was a poor choice and > i think some "owning up" is in order! > > Also, this "idea" of yours that people should just shut up and do > what the "regime" commands, is just utter nonsense. Python is a > public offering, and as such is equally subject to both praise and > ridicule. > > FREEDOM OF SPEECH IS A REAL BEECH! > > If the "powers that be" cannot handle the heat, then they should > withdraw Python from the public and then they can decree any > ridiculous fascist rules they please, until then, what's that old > adage about "reaping" and "sewing"...? > Why it should "they" withdraw it (whatever that means)? "They" are entitled to keep it public if they want to. Those who aren't interested are not obliged to take any notice of it, and any group or individual who wants to develop Python 2 further can just fork Python 2.7 and continue from there. > QUESTION: "What's worse than fracturing a community?" > > ANSWER: "Creating a leadership vacuum." > > --And nature *abhors* a vacuum! > > Besides, "opposing and competing forces" are a fundamental part of > evolution (psst: do you remember that little thing called "evolution" > Chris?) and so we must NEVER forget the absolute necessity of > dissent! Just think of what our world would be like if every idea was > NOT placed under the microscope for scrutiny. > Evolution is also about competition, and there's nothing stopping someone creating a fork of Python 2 to compete with Python 3. > I SHUTTER TO THINK! > [snip] BTW, that's "SHUDDER", not "SHUTTER". From Catherine.M.Moroney at jpl.nasa.gov Mon Jul 14 18:24:26 2014 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine M Moroney) Date: Mon, 14 Jul 2014 15:24:26 -0700 Subject: initializing "parameters" class in Python only once? Message-ID: <53C4589A.9040109@jpl.nasa.gov> Hello, Pardon me for not using the proper Python language terms, but I hope that people can still understand the question: The problem: I'm writing a large Python program and I have a bunch of parameters (whose values are static) that I want to make available to the rest of the code with minimum overhead and duplicate processing. I think that the simplest way would be to create a file called "Params.py" and then simply have statements like a = 1, b = 2, etc. in there (no classes, no methods, just a bunch of declarations). But, some of these static parameters have to be calculated rather than simply hard-coded. I thought of creating a class called Params and having a bunch of methods (decorated with @classmethod) that set/calculate the value of all the parameters. Easy enough, but then I have to create a Params object in every source file that uses these parameters, and that seems wasteful. The actual scope of the problem is very small, so memory/cpu time is not an issue. I'm just looking for the most pythonic/elegant way of doing this. What is the recommended way of passing a bunch of static (hard-coded and calculated) parameters to various parts of the code? Thank you for any advice, Catherine From Catherine.M.Moroney at jpl.nasa.gov Mon Jul 14 18:32:13 2014 From: Catherine.M.Moroney at jpl.nasa.gov (Catherine M Moroney) Date: Mon, 14 Jul 2014 15:32:13 -0700 Subject: initializing "parameters" class in Python only once? Message-ID: <53C45A6D.9040401@jpl.nasa.gov> Hello, Pardon me for not using the proper Python language terms, but I hope that people can still understand the question: The problem: I'm writing a large Python program and I have a bunch of parameters (whose values are static) that I want to make available to the rest of the code with minimum overhead and duplicate processing. I think that the simplest way would be to create a file called "Params.py" and then simply have statements like a = 1, b = 2, etc. in there (no classes, no methods, just a bunch of declarations). But, some of these static parameters have to be calculated rather than simply hard-coded. I thought of creating a class called Params and having a bunch of methods (decorated with @classmethod) that set/calculate the value of all the parameters. Easy enough, but then I have to create a Params object in every source file that uses these parameters, and that seems wasteful. The actual scope of the problem is very small, so memory/cpu time is not an issue. I'm just looking for the most pythonic/elegant way of doing this. What is the recommended way of passing a bunch of static (hard-coded and calculated) parameters to various parts of the code? Thank you for any advice, Catherine From rgaddi at technologyhighland.invalid Mon Jul 14 19:07:04 2014 From: rgaddi at technologyhighland.invalid (Rob Gaddi) Date: Mon, 14 Jul 2014 16:07:04 -0700 Subject: initializing "parameters" class in Python only once? References: <53C4589A.9040109@jpl.nasa.gov> Message-ID: <20140714160704.11ac7b4d@rg.highlandtechnology.com> On Mon, 14 Jul 2014 15:24:26 -0700 Catherine M Moroney wrote: > Hello, > > Pardon me for not using the proper Python language terms, but I hope > that people can still understand the question: > > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. > > I think that the simplest way would be to create a file called > "Params.py" and then simply have statements like a = 1, b = 2, etc. > in there (no classes, no methods, just a bunch of declarations). But, > some of these static parameters have to be calculated rather than simply > hard-coded. > > I thought of creating a class called Params and having a bunch of > methods (decorated with @classmethod) that set/calculate the value of > all the parameters. Easy enough, but then I have to create a Params > object in every source file that uses these parameters, and that seems > wasteful. > > The actual scope of the problem is very small, so memory/cpu time is not > an issue. I'm just looking for the most pythonic/elegant way of doing this. > > What is the recommended way of passing a bunch of static (hard-coded and > calculated) parameters to various parts of the code? > > Thank you for any advice, > > Catherine You're 90% of the way there. You can just create params.py, fill it with statements that are either hard-coded or calculated as necessary, and import params from all over the rest of the program. Once the interpreter has imported it for the first time, everyone else just gets a link to the same instance of the module rather than running it all over and over again. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. From ckaynor at zindagigames.com Mon Jul 14 19:21:27 2014 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Mon, 14 Jul 2014 16:21:27 -0700 Subject: initializing "parameters" class in Python only once? In-Reply-To: <53C4589A.9040109@jpl.nasa.gov> References: <53C4589A.9040109@jpl.nasa.gov> Message-ID: On Mon, Jul 14, 2014 at 3:24 PM, Catherine M Moroney < Catherine.M.Moroney at jpl.nasa.gov> wrote: > Hello, > > Pardon me for not using the proper Python language terms, but I hope that > people can still understand the question: > > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. > > I think that the simplest way would be to create a file called "Params.py" > and then simply have statements like a = 1, b = 2, etc. > in there (no classes, no methods, just a bunch of declarations). But, > some of these static parameters have to be calculated rather than simply > hard-coded. > Within a module (such as "Params.py"), you can put any statements or code you want, without needing classes or functions. Depending on the complexity of the calculations, you may want to put some of the functionality into functions, which could then be run on import (just put the function call at the bottom of the module file). The interpreter will take care to only import one copy, with the exception of if the Params.py file is accessible from multiple paths in sys.path (generally not an issue). For example, the following is a valid module (untested): # Params.py a = 1 b = 5 c = a * b + 42 d = c - b # End Params.Py You could also go farther and read external configuration files at the root scope. The main thing to remember is that all intermediate variables will be visible outside, and thus should be prefixed with an underscore (Python's standard for private). I thought of creating a class called Params and having a bunch of > methods (decorated with @classmethod) that set/calculate the value of > all the parameters. Easy enough, but then I have to create a Params > object in every source file that uses these parameters, and that seems > wasteful. > If all the methods of a class as decorated with @classmethod or @staticmethod, and all variables are declared on the class, and not inside of any non-class/static methods (include __init__), you would not need to create instances of the object. For example, if you have a class like follows (untested): class Params(): myVar = 0 @classmethod def myMethod(cls): cls.myVar += 1 return cls.myVar you can access them without an instance, by using Params.myVar or Params.myMethod(). > The actual scope of the problem is very small, so memory/cpu time is not > an issue. I'm just looking for the most pythonic/elegant way of doing > this. > For most configuration, I would recommend using a combination of the above. Create the module and place some configuration variables inside the module directly. Use classes (which shouldn't be instantiated) for namespacing. If you start to get a LOT of parameters, you may also want to consider making the entire params a package (folder/directory) with multiple modules and possibly classes, however that is likely overkill. Note that, in any case, I would recommend treating the parameters as constants, meaning do not change their values, except during the initialization of the parameters module. This is mostly to ensure thread-safety and prevent difficult to track bugs. > > What is the recommended way of passing a bunch of static (hard-coded and > calculated) parameters to various parts of the code? > > Thank you for any advice, > > Catherine > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Jul 14 19:28:19 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 09:28:19 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On Tue, Jul 15, 2014 at 8:12 AM, Rick Johnson wrote: > If the "powers that be" cannot handle the heat, then they > should withdraw Python from the public and then they can > decree any ridiculous fascist rules they please, until then, > what's that old adage about "reaping" and "sewing"...? You've already been told about "shutter" vs "shudder", but I'd like to also point out that this would be "sowing", as it's a reference to this passage from the Bible: https://www.biblegateway.com/passage/?search=Galatians+6%3A7-8&version=NIV which is itself a reference to the work of planting (sowing seeds) and then harvesting (reaping). > Besides, "opposing and competing forces" are a fundamental > part of evolution (psst: do you remember that little thing > called "evolution" Chris?) Actually, no. I don't remember evolving from anything else. Do you? Because I've always been the same thing I am now. What am I supposed to be remembering, exactly? > Image, for a moment, a world WITHOUT the great USA! "Imagine". If you were worth the effort, I could easily "image" a world without the USA, by Photoshopping something out of a world map. (I'd probably use the Gimp, or Pike's image manipulation libraries, but everyone knows what Photoshopping is.) And I know what would happen if the USA weren't here. People in other countries would have made similar improvements to the world. Oh, and just for reference, I'm not in the US. I'm an Aussie, and we boast a fairly impressive per-capita invention rate. Some of them (like the stump-jump plough) are specific to our peculiar land, but there are plenty of awesome tools of general interest that have come from here. Just start poking around in various technical documents (RFCs, ISO and ANSI standards, etc, etc) and see how many contributors' addresses say Australia; chances are it'll be a lot more than our ~20M population would suggest. There are a few European countries that, similarly, contribute far more than their apparent size would imply. > what nation in > modern history has contributed more technological > achievements [1] or engendered a revolution of social > justice around the world, or, propagated the idea that all > men are created equal and endowed by their creator with > unalienable rights? Social justice? Do you honestly think the USofA is the example to hold up and say "Look, we have perfectly solved the problems of social injustice"? I guess you've eliminated racism since I last heard. Oh, and I agree that all people are created equal. (I'll leave aside the argument about whether your statement is proof that English is sexist, or that the US founding fathers were the sexist ones.) I also believe that our Creator sees us as equal. But all through history, we flawed human beings have had a problem with seeing people differently, for various reasons. The Apostle James wrote about a major problem with "wealthist" Christians: https://www.biblegateway.com/passage/?search=James+2%3A1-4&version=NIV And there've been plenty of other problems creeping in. God treats us all the same way: flawed, fallible people whom He loves enough to die for. If you want to believe in true equality, you need to follow His example. ChrisA From rosuav at gmail.com Mon Jul 14 19:41:48 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 09:41:48 +1000 Subject: initializing "parameters" class in Python only once? In-Reply-To: <53C45A6D.9040401@jpl.nasa.gov> References: <53C45A6D.9040401@jpl.nasa.gov> Message-ID: On Tue, Jul 15, 2014 at 8:32 AM, Catherine M Moroney wrote: > The actual scope of the problem is very small, so memory/cpu time is not > an issue. I'm just looking for the most pythonic/elegant way of doing this. Small job? Use the simplest possible technique. Just create "params.py" with a bunch of assignments in it: # params.py a = 1 b = 2 c = a + b # every other file import params print("c is",params.c) # if you need to change anything: params.c += 5 # everyone else will see the change, because there can be # only one instance of the module (Highlander!) Works nicely for anything even moderately complex. Also serves as a convenient way to separate configs from code; for instance, I do this any time I need to have a program with database passwords, or per-installation setup, or stuff like that. Two examples: https://github.com/Rosuav/Yosemite/blob/master/config.py https://github.com/Rosuav/Flask1/blob/master/1.py In the latter case, config.py doesn't even exist in the repository, as its main purpose is to store the database connection string - both private (don't want that published on Github) and per-installation (my dev and production systems use different connection strings). The Yosemite config is actually a bit legacy now; I used to have two distinctly different instances of it, one running on Windows and the other on Linux, but now I have a large number of identical instances (all on Linux and all referencing the same disk server - which, incidentally, is the one that I've weaponized with Alice, Elsa, Anya, a Vorpal blade, and a Portal turret). Either way, though, config.py consists generally of simple assignments (and comments), but it's most welcome to use all the power of Python to calculate values. ChrisA From breamoreboy at yahoo.co.uk Mon Jul 14 19:59:46 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 00:59:46 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On 15/07/2014 00:28, Chris Angelico wrote: > On Tue, Jul 15, 2014 at 8:12 AM, Rick Johnson > wrote: > >> Image, for a moment, a world WITHOUT the great USA! > > "Imagine". If you were worth the effort, I could easily "image" a > world without the USA, by Photoshopping something out of a world map. > (I'd probably use the Gimp, or Pike's image manipulation libraries, > but everyone knows what Photoshopping is.) > No more World Series in sport. No more hunting for weapons of mass destruction in Iraq. No more big mouthed Yanks who insist that they won WWII despite the fact that as usual they didn't bother turning up at the start. And apart from that... -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ben at benfinney.id.au Mon Jul 14 20:04:05 2014 From: ben at benfinney.id.au (Ben Finney) Date: Tue, 15 Jul 2014 10:04:05 +1000 Subject: initializing "parameters" class in Python only once? References: <53C4589A.9040109@jpl.nasa.gov> Message-ID: <85vbqzsd1m.fsf@benfinney.id.au> Catherine M Moroney writes: > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. Better than putting these in executable code, then, is to put them in a configuration file read as *data*, not code, when your program starts. Look at the ?configparser? module from the Python standard library for a robust way to read run-time configuration parameters from a non-executable file. The result of reading the config file (or set of them, if your use case is complex enough) is an object containing the parameters, which can be interrogated as normal by getting its attributes. See the documentation for examples. -- \ ?[T]he great menace to progress is not ignorance but the | `\ illusion of knowledge.? ?Daniel J. Boorstin, historian, | _o__) 1914?2004 | Ben Finney From breamoreboy at yahoo.co.uk Mon Jul 14 20:05:32 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 01:05:32 +0100 Subject: initializing "parameters" class in Python only once? In-Reply-To: <53C45A6D.9040401@jpl.nasa.gov> References: <53C45A6D.9040401@jpl.nasa.gov> Message-ID: On 14/07/2014 23:32, Catherine M Moroney wrote: > Hello, > > Pardon me for not using the proper Python language terms, but I hope > that people can still understand the question: > > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. > > I think that the simplest way would be to create a file called > "Params.py" and then simply have statements like a = 1, b = 2, etc. > in there (no classes, no methods, just a bunch of declarations). But, > some of these static parameters have to be calculated rather than simply > hard-coded. > > I thought of creating a class called Params and having a bunch of > methods (decorated with @classmethod) that set/calculate the value of > all the parameters. Easy enough, but then I have to create a Params > object in every source file that uses these parameters, and that seems > wasteful. > > The actual scope of the problem is very small, so memory/cpu time is not > an issue. I'm just looking for the most pythonic/elegant way of doing > this. > > What is the recommended way of passing a bunch of static (hard-coded and > calculated) parameters to various parts of the code? > > Thank you for any advice, > > Catherine Besides the answers you've already had, you might like to consider using the enum module for some of your parameters. IIRC it's only available in 3.4 but there's what I understand to be pretty much the same thing on pypi. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From luisjosenovoa at gmail.com Mon Jul 14 20:10:47 2014 From: luisjosenovoa at gmail.com (LJ) Date: Mon, 14 Jul 2014 17:10:47 -0700 (PDT) Subject: Iterating through set Message-ID: Hi All. I'm coding a Dynamic Programming algorithm to solve a network flow problem. At some point in the algorithm I have to iterate through a set of nodes, while adding and/or removing elements, until the set is empty. I know a regular set() object does not work in a case like this, so I wonder if anyone knows of an efficient pythonic way to handle this. Thanks in advance! From roy at panix.com Mon Jul 14 20:30:52 2014 From: roy at panix.com (Roy Smith) Date: Mon, 14 Jul 2014 20:30:52 -0400 Subject: Iterating through set References: Message-ID: In article , LJ wrote: > Hi All. > > I'm coding a Dynamic Programming algorithm to solve a network flow problem. > At some point in the algorithm I have to iterate through a set of nodes, > while adding and/or removing elements, until the set is empty. I know a > regular set() object does not work in a case like this, so I wonder if anyone > knows of an efficient pythonic way to handle this. You've already figured out that you can't alter a set while you're iterating over it. Which means you basically have two choices: 1) Build a new set while you're iterating over the first one, then delete the first set. This might make sense if you expect there will be a large number of items (relative to the size of the original set) added or deleted. 2) Keep lists, of those items which need adding or deleting, and do them in bulk, after the iteration is completed. Then, delete the lists. This makes sense if you expect the number of add/deletes will be small. Either way is O(n) in the size of the set, so which you pick is a second-order optimization. From rantingrickjohnson at gmail.com Mon Jul 14 21:00:42 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 14 Jul 2014 18:00:42 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: <48e22633-0779-44cc-945a-8238ea9be77c@googlegroups.com> On Monday, July 14, 2014 5:47:14 PM UTC-5, MRAB wrote: > Why it should "they" withdraw it (whatever that means)? > "They" are entitled to keep it public if they want to. I'm not suggesting they *must* withdraw Python, I'm only suggesting that IF they wish to *prevent* dissent or scrutiny, then the only remedy they can employ is to "withdraw" the language from public view. I'm merely highlighting the difference between public and private property. Python is currently public property, and just as a public park is open to whoever wishes to visit, so too is the the Python language. Sure, nobody wants to see the unwashed homeless people there, feeding the pigeons until they grow so fat they can only muster sporadic momentary flight, in between Jackson Pollock inspired park bench repainting sessions via cementitious bowel ejections... THOSE VERMIN! But we must suffer them, because if we believe in freedom, we must celebrate the "comfortable" whilst suffering the "uncomfortable". > Those who aren't interested are not obliged to take any > notice of it, and any group or individual who wants to > develop Python 2 further can just fork Python 2.7 and > continue from there. Actually, no. You need to understand some ground rules of free societies: ============================================================ When a *public* "entity" is created, an "individual" *may*: ============================================================ * Ignore the entity altogether. At which point, no future interaction occurs UNLESS the "individual" decides to change his relationship with the *public* "entity" * Engage the entity in one or more forms: 1. Participate in debate. Which may include accolades, dissent, or even vile rebukes. 2. Take from the entity any offerings the entity may provide. 3. All of the above. You see, the "entity" merely offers something for the taking, and the "individual" decides to take the offering, or not to take the offering; to participate, or not to participate; -- extrapolations to infinity...! And not only does the "individual" control the time, place, and manner of the interaction, he also has the capacity to insert or remove himself from participation at any time. THIS, is the manner of free "individuals" operating in the realm of *public* "entities". An "individual", a FREE individual that is, has many more choices than the single choice you provided. What you're attempting to do is "compel" an "individual" to engage a *public* entity in a manner that is most pleasing to YOU, and i will not allow that to happen! I've seen this "vulgar display of animosity" before, predominately in short, angry white women driving "Scandinavian armored personnel carriers" (aka: Volvo), with closely trimmed eyebrows, and beaming scowls of superiority down on the "little people" as she transports her "honor role student" to school at twenty miles below the speed limit! From ckaynor at zindagigames.com Mon Jul 14 21:08:43 2014 From: ckaynor at zindagigames.com (Chris Kaynor) Date: Mon, 14 Jul 2014 18:08:43 -0700 Subject: Iterating through set In-Reply-To: References: Message-ID: On Mon, Jul 14, 2014 at 5:10 PM, LJ wrote: > Hi All. > > I'm coding a Dynamic Programming algorithm to solve a network flow > problem. At some point in the algorithm I have to iterate through a set of > nodes, while adding and/or removing elements, until the set is empty. I > know a regular set() object does not work in a case like this, so I wonder > if anyone knows of an efficient pythonic way to handle this. > Your description of your need is somewhat vague, but this sounds like a queue/stack which should be handled with a while loop and poping items. Something like (untested): mySet = [] # Typically, this would be a list. If you only want items processed once per iteration, you'd likely use a separate set, however the exact structure would vary based on the data and use-case. # Some code to add initial items. while mySet: item = mySet.pop() # Do something with item, which may call mySet.add(), and possibly mySet.remove(). > Thanks in advance! > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Mon Jul 14 21:18:07 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 11:18:07 +1000 Subject: Python 3 is killing Python In-Reply-To: <48e22633-0779-44cc-945a-8238ea9be77c@googlegroups.com> References: <7xha49wumw.fsf@ruckus.brouhaha.com> <48e22633-0779-44cc-945a-8238ea9be77c@googlegroups.com> Message-ID: On Tue, Jul 15, 2014 at 11:00 AM, Rick Johnson wrote: > On Monday, July 14, 2014 5:47:14 PM UTC-5, MRAB wrote: >> Why it should "they" withdraw it (whatever that means)? >> "They" are entitled to keep it public if they want to. > > I'm not suggesting they *must* withdraw Python, I'm only > suggesting that IF they wish to *prevent* dissent or scrutiny, > then the only remedy they can employ is to "withdraw" the > language from public view. Python 3 stands up just fine to scrutiny, and dissent is a normal part of life. > I'm merely highlighting the difference between public and > private property. Python is currently public property, and > just as a public park is open to whoever wishes to visit, so > too is the the Python language. Python is not public property. Whatever gave you that idea? > I've seen this "vulgar display of animosity" before, > predominately in short, angry white women driving > "Scandinavian armored personnel carriers" (aka: Volvo), with > closely trimmed eyebrows, and beaming scowls of superiority > down on the "little people" as she transports her "honor > role student" to school at twenty miles below the speed > limit! Wow. There is just so much US-centrism in that paragraph... I don't understand half of it half as well as I'd like, and I like less than half of it half as well as it deserves. ChrisA From rantingrickjohnson at gmail.com Mon Jul 14 21:54:07 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 14 Jul 2014 18:54:07 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> On Monday, July 14, 2014 6:28:19 PM UTC-5, Chris Angelico wrote: > And I know what would happen if the USA weren't here. > People in other countries would have made similar > improvements to the world. Yes, i wholeheartedly agree with that statement. Is the USA the *ONLY* country to have ever liberated the world from the clutches of evil?...No! Will the USA be the *LAST* to do so?...OF COURSE NOT! I'm not so blind as you may believe. But, if the USA *DID NOT* exist during the perilous times of the world wars, how many generations of people would have suffered before a powerful enough contender came along to unclench the grips of evil? I "SHUDDER" TO THINK! How many minutes, or hours, or days in a concentration camp would YOU, Chris Angelico, trade so you could have your selfish wish to wipe USA's prestige from the history books? You see Chris, the battle between "good" and "evil" [1] will always exist, and in fact, if it did not exist, the world would be a stagnate cess-pool of rot and decay because it is the very battle that is waged against "evil", which is just another form of competition, that spins the cogs of evolution. Of course the "moral authority" of "doing good" has it's hormonal payoffs, yes? SELFISHNESS, MEET GLUTTONY GLUTTONY, SELFISHNESS! Ha, however, our "chemically induced" happiness is just a method of pacification, and protects our delicate emotional "beings" from the most abysmal of apathetic truths. Living creatures are lazy by nature, and we will, if not "challenged", waste away, in order to maintain forward evolution, the tools of pain, jealously, terror, envy, etc, etc... are employed to "compel" us to compete with each other --from the friendliest of banter to the deepest depths of human depravity-- we are but pawns in a greater game! LET THE GAMES BEGIN! > Social justice? Do you honestly think the USofA is the > example to hold up and say "Look, we have perfectly solved > the problems of social injustice"? Point to my statement that mentioned ANYTHING about "perfect". I don't believe in perfection, since such an "idea" is unattainable by both the human hand, or human mind. > I guess you've eliminated racism since I last heard. Yup. And next we've decided to solve the middle east crisis! > Oh, and I agree that all people are created equal. (I'll > leave aside the argument about whether your statement is > proof that English is sexist, or that the US founding > fathers were the sexist ones.) I also believe that our > Creator sees us as equal. But all through history, we > flawed human beings have had a problem with seeing people > differently, for various reasons. The Apostle James wrote > about a major problem with "wealthist" Christians: And > there've been plenty of other problems creeping in. God > treats us all the same way: flawed, fallible people whom > He loves enough to die for. If you want to believe in true > equality, you need to follow His example. I'm confused by your logic. First you admit all humans are fallible, but somehow, you believe that a collection of humans should be "infallible". Please explain this enigma. REFERENCES: [1] And i use the terms very loosely here. Please, let's not get into a debate of what "good" and "evil" are with all the religious nonsense and such. From rosuav at gmail.com Mon Jul 14 22:11:47 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 12:11:47 +1000 Subject: Python 3 is killing Python In-Reply-To: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: On Tue, Jul 15, 2014 at 11:54 AM, Rick Johnson wrote: > But, if the USA *DID NOT* exist during the perilous times of > the world wars, how many generations of people would have > suffered before a powerful enough contender came along to > unclench the grips of evil? > > I "SHUDDER" TO THINK! > > How many minutes, or hours, or days in a concentration camp > would YOU, Chris Angelico, trade so you could have your > selfish wish to wipe USA's prestige from the history books? I dunno. It's not like Great Britain, Australia, or New Zealand did anything significant in either war, is it. And a lot of US citizens fought in British or other military units, because the US wasn't in the war yet. That's what I mean by "if the US were not, others would take up the slack" - the same people would do the same work, under a different flag. > You see Chris, the battle between "good" and "evil" [1] will > always exist, and in fact, if it did not exist, the world > would be a stagnate cess-pool of rot and decay because it is > the very battle that is waged against "evil", which is just > another form of competition, that spins the cogs of > evolution. > > [1] And i use the terms very loosely here. Please, let's not > get into a debate of what "good" and "evil" are with all > the religious nonsense and such. Easiest to use the Dungeons & Dragons definitions of those terms (which don't conflict with most religious definitions): evil is selfishness, good is altruism. >> I guess you've eliminated racism since I last heard. > > Yup. And next we've decided to solve the middle east crisis! Good. Call me when you get there, and I'll give you the rest of the directions. Some people in Australia are still racist, but racism is nothing like the problem it is in America, where you boast so much of equality. >> Oh, and I agree that all people are created equal. (I'll >> leave aside the argument about whether your statement is >> proof that English is sexist, or that the US founding >> fathers were the sexist ones.) I also believe that our >> Creator sees us as equal. But all through history, we >> flawed human beings have had a problem with seeing people >> differently, for various reasons. The Apostle James wrote >> about a major problem with "wealthist" Christians: And >> there've been plenty of other problems creeping in. God >> treats us all the same way: flawed, fallible people whom >> He loves enough to die for. If you want to believe in true >> equality, you need to follow His example. > > I'm confused by your logic. First you admit all humans are > fallible, but somehow, you believe that a collection of > humans should be "infallible". Please explain this enigma. Where do I say anything about a collection of humans being infallible? I believe I specifically said *fallible*. That's, uhh, the opposite of infallible. ChrisA From renatooliveira.cin at gmail.com Mon Jul 14 22:53:24 2014 From: renatooliveira.cin at gmail.com (Renato Oliveira) Date: Mon, 14 Jul 2014 23:53:24 -0300 Subject: [Python Brasil 10] Registrations are now open! In-Reply-To: References: Message-ID: Hi all, The call for papers are now open! http://2014.pythonbrasil.org.br/dashboard/proposals/ We're going to hava an English Track, so feel free to submit your proposals! See you at Python Brasil 10! Renato Oliveira @_renatooliveira Labcodes - www.labcodes.com.br On Mon, Jul 7, 2014 at 11:16 AM, Renato Oliveira < renatooliveira.cin at gmail.com> wrote: > Hey everyone! > Registrations for Python Brasil are now open! > > http://2014.pythonbrasil.org.br/register > > Sadly the payment form is in portuguese, so if you have any trouble please > let me know (in private message). > The call for papers will open on Jul 10th as you can see here > > http://2014.pythonbrasil.org.br/about > > For now the announced keynotes are: > Alex Gaynor > http://2014.pythonbrasil.org.br/news/keynotes-alex-gaynor > > Fernando Perez > http://2014.pythonbrasil.org.br/news/keynotes-fernando-perez > > Lynn Root > http://2014.pythonbrasil.org.br/news/keynotes-lynn-root > > And this beach is waiting for you: > http://2014.pythonbrasil.org.br/venue > > Please, help us by spreading the word :) > Thanks > Renato Oliveira > > @_renatooliveira > Labcodes - www.labcodes.com.br > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From renatooliveira.cin at gmail.com Mon Jul 14 22:53:34 2014 From: renatooliveira.cin at gmail.com (Renato Oliveira) Date: Mon, 14 Jul 2014 23:53:34 -0300 Subject: [Python Brasil 10] Registrations are now open! In-Reply-To: References: Message-ID: have* Renato Oliveira @_renatooliveira Labcodes - www.labcodes.com.br On Mon, Jul 14, 2014 at 11:53 PM, Renato Oliveira < renatooliveira.cin at gmail.com> wrote: > Hi all, > > The call for papers are now open! > > http://2014.pythonbrasil.org.br/dashboard/proposals/ > > We're going to hava an English Track, so feel free to submit your > proposals! > > See you at Python Brasil 10! > > Renato Oliveira > @_renatooliveira > Labcodes - www.labcodes.com.br > > > > On Mon, Jul 7, 2014 at 11:16 AM, Renato Oliveira < > renatooliveira.cin at gmail.com> wrote: > >> Hey everyone! >> Registrations for Python Brasil are now open! >> >> http://2014.pythonbrasil.org.br/register >> >> Sadly the payment form is in portuguese, so if you have any trouble >> please let me know (in private message). >> The call for papers will open on Jul 10th as you can see here >> >> http://2014.pythonbrasil.org.br/about >> >> For now the announced keynotes are: >> Alex Gaynor >> http://2014.pythonbrasil.org.br/news/keynotes-alex-gaynor >> >> Fernando Perez >> http://2014.pythonbrasil.org.br/news/keynotes-fernando-perez >> >> Lynn Root >> http://2014.pythonbrasil.org.br/news/keynotes-lynn-root >> >> And this beach is waiting for you: >> http://2014.pythonbrasil.org.br/venue >> >> Please, help us by spreading the word :) >> Thanks >> Renato Oliveira >> >> @_renatooliveira >> Labcodes - www.labcodes.com.br >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ethan at stoneleaf.us Mon Jul 14 22:57:30 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Mon, 14 Jul 2014 19:57:30 -0700 Subject: [Python-Dev] Python Job Board In-Reply-To: References: <53C40256.3020101@stoneleaf.us> <53C42077.9070408@stoneleaf.us> Message-ID: <53C4989A.7040203@stoneleaf.us> On 07/14/2014 06:01 PM, Wes Turner wrote: > From http://www.reddit.com/r/Python/comments/17c69p/i_was_told_by_a_friend_that_learning_python_for/c84bswd > : > >> * http://www.python.org/community/jobs/ >> * https://jobs.github.com/positions?description=python >> * http://careers.joelonsoftware.com/jobs?searchTerm=python >> * http://www.linkedin.com/jsearch?keywords=python >> * http://www.indeed.com/q-Python-jobs.html >> * http://www.simplyhired.com/a/jobs/list/q-python >> * http://seeker.dice.com/jobsearch/servlet/JobSearch?op=300&FREE_TEXT=python >> * http://careers.stackoverflow.com/jobs/tag/python >> * http://www.pythonjobs.com/ >> * http://www.djangojobs.org/ Nice, thanks! -- ~Ethan~ From davea at davea.name Mon Jul 14 23:55:11 2014 From: davea at davea.name (Dave Angel) Date: Mon, 14 Jul 2014 22:55:11 -0500 (CDT) Subject: initializing "parameters" class in Python only once? References: <53C45A6D.9040401@jpl.nasa.gov> Message-ID: Catherine M Moroney Wrote in message: > Hello, > > Pardon me for not using the proper Python language terms, but I hope > that people can still understand the question: > > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. > > I think that the simplest way would be to create a file called > "Params.py" and then simply have statements like a = 1, b = 2, etc. > in there (no classes, no methods, just a bunch of declarations). But, > some of these static parameters have to be calculated rather than simply > hard-coded. > > I thought of creating a class called Params and having a bunch of > methods (decorated with @classmethod) that set/calculate the value of > all the parameters. Easy enough, but then I have to create a Params > object in every source file that uses these parameters, and that seems > wasteful. No, you don't want to create separate instances of the Params class. You want to create exactly one object, and have each source file get their attributes from the same object. That object could be the same module object as already mentioned. Or it could be an object created in the module exactly once. I like the latter method and I'll explain why after showing how. In parametersetup.py, you do something like: class Foo: # assuming python 3.x def __init__(self ): self.parm1 = 42 self.otherparm =3 parms = Foo () # this is the sole instance and its only created here. del Foo # in case you want to make sure. In each source file you have something like: from parametersetup import parms and you refer to parms.param1 Now, why the extra fuss? In case you later want a different set of parms for each thread, or for certain modules, or for debugging. You're halfway there. -- DaveA From torriem at gmail.com Mon Jul 14 23:58:05 2014 From: torriem at gmail.com (Michael Torrie) Date: Mon, 14 Jul 2014 21:58:05 -0600 Subject: Python 3 is killing Python In-Reply-To: <2d66f199-ceea-4cfe-b35f-436041398817@googlegroups.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <2d66f199-ceea-4cfe-b35f-436041398817@googlegroups.com> Message-ID: <53C4A6CD.2000702@gmail.com> On 06/03/2014 12:12 AM, wxjmfauth at gmail.com wrote: > I was myself really suprised to fall on such a case and > after thinking no, such cases may logically happen. Putting in this comment not for JMF but for poor souls who find this thread on a search and are led astray by jmf's trolling. Either it was your code or an issue with the Windows console that caused the exception. When you try to print out unicode strings, Python must convert them to the character encoding of the terminal in order to print them out. On sane systems this is UTF-8. On Windows it could be anything. Do you want Python to fail silently or do you want to fail with a useful message, with the option of specifying the exact behavior you want (replace unrepresentable characters with spaces, question marks, etc)? Seems like jmf, though being a self-proclaimed unicode expert, continually confusing unicode with encoding schemes. > > It's not important. I'm no more writing Py apps, only > considering software through an unicode eye. Please just stop posting to this list. thanks. From torriem at gmail.com Mon Jul 14 23:47:32 2014 From: torriem at gmail.com (Michael Torrie) Date: Mon, 14 Jul 2014 21:47:32 -0600 Subject: Python 3 is killing Python In-Reply-To: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> Message-ID: <53C4A454.9010600@gmail.com> On 05/31/2014 09:48 AM, jmf wrote: > Absolutely FALSE. Python 3.3 and up can handle any and all unicode characters you want to throw at it, without surprises such as what you get in javascript. Python 3 uses UTF-4 encoding under the hood, with a compression optimization that removes leading zeros from binary representation of each character. Windows command consoles are not unicode compliant, and so running python programs a command prompt console will often lead to exceptions because Python must convert unicode to the character set that the console is using, and when a character is hit that cannot be encoded Python defaults to being correct and throws an exception, instead of failing silently. From rantingrickjohnson at gmail.com Tue Jul 15 00:18:05 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Mon, 14 Jul 2014 21:18:05 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote: > I dunno. It's not like Great Britain, Australia, or New > Zealand did anything significant in either war, is it. Most of Europe occupied, London bombed into the stone age; things were looking grim Chris! Maybe you should read up on some WW2 history, it's quite humbling to think what *could* have happened. > Some people in Australia are still racist, but racism is > nothing like the problem it is in America, where you boast > so much of equality. Where do you get your info about America, from CNN? And for someone who is a self-described "Aussie" you sure seem to know more about Americans than Americans know about themselves... hmm, another enigma! Chris, one thing you need to understand about America is that a whole grievance industry exists to perpetuate hate. And sadly, most Americans are too stupid to realize this. You see, a divided people are not going to cause the rulers any troubles because they are too busy fighting amongst themselves -- the same effect is employed in prison populations to protect the guards. In ancient Rome, the Caesars used games and bread to control the masses, today, they use the grievance industry and, for the complete moronic zombies, sporting events. All "isms" and social problems just boil down to hate. And since you can never remove hate from the heart of man, you will *NEVER* solve these issues. The best you can hope for is to reduce the levels a bit via "intelligent interventions". So in short, none of these issues will ever be solved until people realize who the real enemy is -> themselves. MIRROR, MIRROR, ON THE WALL, WHO'S THE MOST JUDGMENTAL OF THEM ALL? ============================================================ The origins of xenophobia: ============================================================ In order to defeat our own hatred of others, we must circumvent our per-programmed primal fears, which is not easy to do, and while these fears play a vital survival role in *early* development of both the *individuals* of a group AND the group itself, in modern times, these fears have become a crutch preventing humans from evolving socially. HENCE THE GRIEVANCE INDUSTRY PERPETRATED BY A MEDIA CIRCUS THAT WILL DO ANYTHING TO GET RATINGS! ==================== THOUGHT EXPERIMENT ==================== Imagine your a small kitten: innocent, carefree, and full of curiosity! You love exploring the world, stuffing yourself into boxes, climbing to high places, and chasing balls of strings -- ah what a life! You see your siblings and notice they have fur like you , and whiskers like you, and paws and tails and blah like you. And you are comfortable because these other "lifeforms" resemble you, and so you consider them to be "safe". Then one day, whilst frolicking in the backyard, you see a glimmer from under a log, ooh, whats this you ask rhetorically...? So you get closer to inspect, and you see two eyes, and you think, hmm, it has two eyes just like my bothers and sisters so it must be safe...! And so you get yet closer, but just then you start to notice some differences, whoa, this thing has no fur, it has no paws, and no whiskers, and it has strange patterns on it's back and it's making a rattling noise, oh well, no need to let fear get in my way, i'll just go over and introduce myself... AND THAT WAS THE END OF "FLUFFY THE KITTEN"! MEOW! You see, since hate is merely an extrapolation of xenophobia, which is itself a per-programmed reflex utilized unconsciously to protect an organism from self destruction via *utter* ignorance of dangerous predators, we are fighting a losing battle when we expect the vast majority of earths "intelligent" inhabitants, of which most are zombie-fied *idiots*, to violate their own source code. JUST GO GRAB A BEER AND WATCH THE GAME YOU BEER-BELLIED FOOL! PS: That was a "general" you, not to be taken as a literal statement to Chris. From rosuav at gmail.com Tue Jul 15 00:20:36 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 14:20:36 +1000 Subject: Python 3 is killing Python In-Reply-To: <53C4A454.9010600@gmail.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Tue, Jul 15, 2014 at 1:47 PM, Michael Torrie wrote: > Python 3 uses UTF-4 encoding under the hood, with a > compression optimization that removes leading zeros from binary > representation of each character. Sorry to nitpick, but in the interests of terminological accuracy I have to point out that it's UTF-32 or UCS-4, not UTF-4 :) But otherwise, yes, quite correct. And a system that few, but not no, other languages use; I do wonder if other languages have considered switching to this kind of system, but avoided it lest jmf start haunting them too... ChrisA From rosuav at gmail.com Tue Jul 15 00:40:14 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 14:40:14 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: On Tue, Jul 15, 2014 at 2:18 PM, Rick Johnson wrote: > On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote: >> I dunno. It's not like Great Britain, Australia, or New >> Zealand did anything significant in either war, is it. > > Most of Europe occupied, London bombed into the stone age; > things were looking grim Chris! Maybe you should read up on > some WW2 history, it's quite humbling to think what *could* > have happened. Yeah, because nobody managed to do anything during all that time, the Royal Air Force was nowhere to be seen, and the various Resistances in occupied countries were completely ineffectual. >> Some people in Australia are still racist, but racism is >> nothing like the problem it is in America, where you boast >> so much of equality. > > Where do you get your info about America, from CNN? And for > someone who is a self-described "Aussie" you sure seem to > know more about Americans than Americans know about > themselves... hmm, another enigma! No... I have friends who are America experts. Actually, when I say friends... they're more like family really. I don't want to scare you, they can be a little bit inappropriate... and loud... and heavy. Really, morbidly obese. I'm talking about the genuine article here, and I converse with them on a daily basis. And this is distinctly off-topic for this list. Talk about Python or drop the issue, it really isn't as significant as you think it is. ChrisA From shieldfire at gmail.com Tue Jul 15 00:31:13 2014 From: shieldfire at gmail.com (Martin S) Date: Tue, 15 Jul 2014 06:31:13 +0200 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: <2cea6dcc-7307-4973-92f8-0c77b4f5511d@gmail.com> Yes, we all know that Abu Ghraib, Guantanamo, school shootings and the lack of proper health care for all are the pinnacle of US culture. Or figments of the imagination of Baghdad Bob. Now, maybe return to Python? /martin On 15 Jul 2014, Rick Johnson wrote: >On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote: >> I dunno. It's not like Great Britain, Australia, or New >> Zealand did anything significant in either war, is it. > >Most of Europe occupied, London bombed into the stone age; >things were looking grim Chris! Maybe you should read up on >some WW2 history, it's quite humbling to think what *could* >have happened. > >> Some people in Australia are still racist, but racism is >> nothing like the problem it is in America, where you boast >> so much of equality. > >Where do you get your info about America, from CNN? And for >someone who is a self-described "Aussie" you sure seem to >know more about Americans than Americans know about >themselves... hmm, another enigma! > >Chris, one thing you need to understand about America is >that a whole grievance industry exists to perpetuate hate. >And sadly, most Americans are too stupid to realize this. > >You see, a divided people are not going to cause the rulers >any troubles because they are too busy fighting amongst >themselves -- the same effect is employed in prison >populations to protect the guards. > >In ancient Rome, the Caesars used games and bread to control >the masses, today, they use the grievance industry and, for >the complete moronic zombies, sporting events. > >All "isms" and social problems just boil down to hate. And >since you can never remove hate from the heart of man, you >will *NEVER* solve these issues. The best you can hope for >is to reduce the levels a bit via "intelligent interventions". > >So in short, none of these issues will ever be solved until >people realize who the real enemy is -> themselves. > > MIRROR, MIRROR, ON THE WALL, WHO'S THE MOST JUDGMENTAL > OF THEM ALL? > >============================================================ > The origins of xenophobia: >============================================================ > >In order to defeat our own hatred of others, we must >circumvent our per-programmed primal fears, which is not >easy to do, and while these fears play a vital survival role >in *early* development of both the *individuals* of a group >AND the group itself, in modern times, these fears have >become a crutch preventing humans from evolving socially. > > HENCE THE GRIEVANCE INDUSTRY PERPETRATED BY A MEDIA > CIRCUS THAT WILL DO ANYTHING TO GET RATINGS! > > ==================== > THOUGHT EXPERIMENT > ==================== > > Imagine your a small kitten: innocent, carefree, and full > of curiosity! You love exploring the world, stuffing > yourself into boxes, climbing to high places, and chasing > balls of strings -- ah what a life! > > You see your siblings and notice they have fur like you , > and whiskers like you, and paws and tails and blah like > you. And you are comfortable because these other > "lifeforms" resemble you, and so you consider them to be > "safe". > > Then one day, whilst frolicking in the backyard, you see a > glimmer from under a log, ooh, whats this you ask > rhetorically...? > > So you get closer to inspect, and you see two eyes, and > you think, hmm, it has two eyes just like my bothers and > sisters so it must be safe...! > > And so you get yet closer, but just then you start to > notice some differences, whoa, this thing has no fur, it > has no paws, and no whiskers, and it has strange patterns > on it's back and it's making a rattling noise, oh well, no > need to let fear get in my way, i'll just go over and > introduce myself... AND THAT WAS THE END OF "FLUFFY THE > KITTEN"! > > MEOW! > >You see, since hate is merely an extrapolation of >xenophobia, which is itself a per-programmed reflex utilized >unconsciously to protect an organism from self destruction >via *utter* ignorance of dangerous predators, we are >fighting a losing battle when we expect the vast majority of >earths "intelligent" inhabitants, of which most are >zombie-fied *idiots*, to violate their own source code. > > JUST GO GRAB A BEER AND WATCH THE GAME YOU BEER-BELLIED FOOL! > >PS: That was a "general" you, not to be taken as a literal >statement to Chris. -- Sent with K-@ Mail - the evolution of emailing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Tue Jul 15 01:19:47 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 05:19:47 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> Message-ID: <53c4b9f3$0$11125$c3e8da3@news.astraweb.com> On Mon, 14 Jul 2014 18:44:15 +0200, Anders J. Munch wrote: > alister wrote: >> I don't have time to start this discussion over again on another >> mailing list. >> Don't anyone on those lists read python-list also? >> >> they possibly do, but prefer to keep discussions to the proper forum > > The semantics of the Python programming language is on-topic for > python-list. This is about float.__eq__, not about numpy or SciPy. Maybe > they just don't like beer? It's about NAN != NAN. The heaviest uses of NANs are numpy and scipy users. You remind me of the proverbial drunk who lost his keys in the park, but looks for them in the street under the street light because that's where the light is. That's assuming that you actually want an honest answer to your question. If you wanted to learn about use-cases for NANs, you ought to ask somewhere where there was a high proportion of numeric programmers, not on some list merely because it was convenient. I'll give you the benefit of the doubt, and assume that when you first posted you hadn't realised that the audience here does not have the relevant experience, but by refusing to ask the question elsewhere, and by making snide comments that "they don't like beer", that pretty much gives the game away that you're looking to have your opinion confirmed rather than looking for an honest answer. -- Steven From steve at pearwood.info Tue Jul 15 01:28:19 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 05:28:19 GMT Subject: initializing "parameters" class in Python only once? References: <53C4589A.9040109@jpl.nasa.gov> Message-ID: <53c4bbf2$0$2746$c3e8da3$76491128@news.astraweb.com> On Mon, 14 Jul 2014 15:24:26 -0700, Catherine M Moroney wrote: > The problem: I'm writing a large Python program and I have a bunch of > parameters (whose values are static) that I want to make available to > the rest of the code with minimum overhead and duplicate processing. > > I think that the simplest way would be to create a file called > "Params.py" and then simply have statements like a = 1, b = 2, etc. in > there (no classes, no methods, just a bunch of declarations). That sounds exactly right to me. > But, some > of these static parameters have to be calculated rather than simply > hard-coded. I don't think that should be a problem. You can include calculations: a = 1 b = 2 c = a**2 + b**2 - a + 1 The only difficulty is if you want those values to be calculated on demand, rather than at program startup. If that's the case, I think the best solution is to turn them into functions: def c(): return a**2 + b**2 - a + 1 This, sadly, requires you to tell the difference between params that should be constants and those which should be function calls. If that is a serious problem, you should consider a singleton class with properties, but if the simpler solution works for you, stick to the simpler solution! > I thought of creating a class called Params and having a bunch of > methods (decorated with @classmethod) that set/calculate the value of > all the parameters. Easy enough, but then I have to create a Params > object in every source file that uses these parameters, and that seems > wasteful. I don't think that Params with class methods is the best solution. I would do something like this: # === module params.py === class Params(object): a = 1 b = 2 @property def c(self): return self.a**2 + self.b**2 - self.a + 1 params = Params() del Params # hide the class Then callers just say: from params import params print params.c All modules now see the same params instance, so it is (almost) a singleton. -- Steven From steve at pearwood.info Tue Jul 15 01:41:29 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 05:41:29 GMT Subject: Python 3 is killing Python References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> On Mon, 14 Jul 2014 21:18:05 -0700, Rick Johnson wrote: > London bombed into the stone age Sigh. How can one even begin to answer a statement of such ignorance? For what little it is worth, if any one country won World War Two, it was the USSR. I don't recall the exact numbers off the top of my head, but while the Brits and Americans were having a relatively easy time of it fighting the second-best German soldiers, the best, and by far the majority, of the German armed forces were on the Eastern Front engaged in the biggest, fiercest, most brutal battles of the war, bar none. The Soviets destroyed the German airforce, smashed their tank battalions, bled their armies dry, then steamrolled over Eastern Europe, East Germany, and Berlin. The Western Front was, in comparison, a school picnic. One can understand why, following WW2, the western powers formed NATO and were so worried about the Red Army that they invited the Germans to join. -- Steven From omar.aboumrad at gmail.com Tue Jul 15 02:27:15 2014 From: omar.aboumrad at gmail.com (Omar Abou Mrad) Date: Tue, 15 Jul 2014 09:27:15 +0300 Subject: Twitter Client on Terminal by Python In-Reply-To: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> Message-ID: Dear Orakaro, Cool app you have there. Please consider the following comments as feedback in the most positive sense possible: - I didn't care for the figlet, it's noise beyond anything else, if you drop it, you would drop the pyfiglet dependency as well - What's with the SQLAlchemy dependency? I checked your table definitions and if I'm not mistaken all you're using is Theme, Message, Tweet. My first question on that front is why are message and tweet stored locally? Are you doing local caching to speed things up? What about theme? Good job and take care! Regards, Omar On Sun, Jul 13, 2014 at 9:00 PM, Orakaro wrote: > Hello! > > I'm @dtvd88 on Twitter and very new here. > I read from python.org that anything Python-related can be discussed, and > not sure if I can share my OSS package here to get feedback or not ? > > I just wrote a Twitter Client on Terminal by Python, it has very beautiful > display and even can display image on terminal. Check it out and maybe you > guys will love it :) > > Homepage: http://www.rainbowstream.org/ > Github: https://github.com/DTVD/rainbowstream > > Thanks for any feedback and sorry if this kind of topics is not tolerated > here. > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Tue Jul 15 03:05:10 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 08:05:10 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: On 15/07/2014 05:40, Chris Angelico wrote: > On Tue, Jul 15, 2014 at 2:18 PM, Rick Johnson > wrote: > > Yeah, because nobody managed to do anything during all that time, the > Royal Air Force was nowhere to be seen, and the various Resistances in > occupied countries were completely ineffectual. > Some might like to know that some US guys gave up their passports to fight with the RAF. The most successful squadron during the Battle of Britain was 303 which was Polish flyers. Apparently they were brilliant having learnt their trade flying biplanes against Messerschmitt BF109s. 1940 invasion of Britain? No chance, we took years building the moat we call the English Channel. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From wxjmfauth at gmail.com Tue Jul 15 03:23:00 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Tue, 15 Jul 2014 00:23:00 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <2d66f199-ceea-4cfe-b35f-436041398817@googlegroups.com> Message-ID: <6dec659d-b21a-4154-80a9-cb39fb1b60a9@googlegroups.com> Le mardi 15 juillet 2014 05:58:05 UTC+2, Michael Torrie a ?crit?: > On 06/03/2014 12:12 AM, wxjmfauth at gmail.com wrote: > > > > > Seems like jmf, though being a self-proclaimed unicode expert, > > continually confusing unicode with encoding schemes. > > > Sorry, but no. I have always been very consistent and attempted to be very concise. Eg. not mixing Unicode Transformation Unit and byte. I you wish an example of a confused discussion, read the pep 393 (?) discussion and you will see how people are discussing Unicode without being able to use a unicode terminology. At least the Py core developper, who wrote (I do not remember if it was in one of the lists or a private mail and I do not remember exactly the phrasing) "If you are not happy, switch to Py 2.7, use Ruby or try to convince the BDFL" has, in my mind, a little bit more undersanding of the situation. jmf From breamoreboy at yahoo.co.uk Tue Jul 15 03:31:44 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 08:31:44 +0100 Subject: Python 3 is killing Python In-Reply-To: <53C4A6CD.2000702@gmail.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <2d66f199-ceea-4cfe-b35f-436041398817@googlegroups.com> <53C4A6CD.2000702@gmail.com> Message-ID: On 15/07/2014 04:58, Michael Torrie wrote: > On 06/03/2014 12:12 AM, wxjmfauth at gmail.com wrote: >> I was myself really suprised to fall on such a case and >> after thinking no, such cases may logically happen. > > Putting in this comment not for JMF but for poor souls who find this > thread on a search and are led astray by jmf's trolling. > > Either it was your code or an issue with the Windows console that caused > the exception. When you try to print out unicode strings, Python must > convert them to the character encoding of the terminal in order to print > them out. On sane systems this is UTF-8. On Windows it could be > anything. Do you want Python to fail silently or do you want to fail > with a useful message, with the option of specifying the exact behavior > you want (replace unrepresentable characters with spaces, question > marks, etc)? Sorry if I'm repeating myself but this is relevant http://bugs.python.org/issue21927 specifically msg222761. > > Seems like jmf, though being a self-proclaimed unicode expert, > continually confusing unicode with encoding schemes. He's been spouting his bile on this subject on this list for IIRC nearly two years. Still he gets away with it. Is he sleeping with the right people I ask myself? > >> >> It's not important. I'm no more writing Py apps, only >> considering software through an unicode eye. > > Please just stop posting to this list. > > thanks. > -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From varun292006 at gmail.com Tue Jul 15 04:10:57 2014 From: varun292006 at gmail.com (varun bhatnagar) Date: Tue, 15 Jul 2014 10:10:57 +0200 Subject: xslt with python Message-ID: I am trying to merge two xmls using xslt in python but the content of first xml is not getting copied. The rules written in xsl file created are correct because if I am executing it without python (directly from eclipse as I have xslt plugin installed) it is getting merged fine. Can anybody help me? I am pasting my code snippet below: *import lxml.etree as ET* *dom = ET.parse(r'test_file_2.xml')* *xslt = ET.parse(r'TestMergeRules.xsl')* *transform = ET.XSLT(xslt)* *print transform* *newdom = transform(dom)* *print(ET.tostring(newdom, pretty_print=True))* I am opening other xml file (test_file_1.xml) in xsl file using "document()" function. Once this code is executed I can see only the content of test_file_2.xml. Am I doing something wrong? Is there any other way to do this because my xslt rules are working fine without python. Thanks, BR, Varun -------------- next part -------------- An HTML attachment was scrubbed... URL: From phani.lav at gmail.com Tue Jul 15 06:11:11 2014 From: phani.lav at gmail.com (u2107) Date: Tue, 15 Jul 2014 03:11:11 -0700 (PDT) Subject: networkx plot random graph Error Message-ID: <0d48b8fc-0ed0-434f-8004-5e0ff3693171@googlegroups.com> I am trying to read a file with 3 columns with col 1 and 2 as nodes/edges and column 3 as weight (value with decimal) I am trying to execute this code import networkx as nx G = nx.read_edgelist('file.txt', data=[("weight")]) G.edges(data=True) edge_labels = dict(((u, v), d["weight"]) for u, v, d in G.edges(data=True)) pos = nx.random_layout(G) nx.draw(G, pos) nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels) import matplotlib.pyplot as plt; plt.show() Error: File "graph_one.py", line 4, in G = nx.read_edgelist('File.txt', data=[("weight")]) File "", line 2, in read_edgelist File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 241, in _open_file fobj = _dispatch_dict[ext](path, mode=mode) IOError: [Errno 2] No such file or directory: 'contactUSC_nodes_diff_small.txt' lavanya at peerformance:~/Desktop/INRIA_Papers/Python$ python graph_one.py Traceback (most recent call last): File "graph_one.py", line 4, in G = nx.read_edgelist('contactUSC_node_diff_small.txt', data=[("weight")]) File "", line 2, in read_edgelist File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 263, in _open_file result = func(*new_args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 367, in read_edgelist data=data) File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 286, in parse_edgelist for (edge_key,edge_type),edge_value in zip(data,d): ValueError: too many values to unpack From fabien.maussion at gmail.com Tue Jul 15 08:17:54 2014 From: fabien.maussion at gmail.com (Fabien) Date: Tue, 15 Jul 2014 14:17:54 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: My two cents as a new pythonista and a scientist: isn't python2 killing python? This old stuff is everywhere in the tutorials, docs, etc. and this is quite annoying. When I download a python notebook, the first thing I have to do is to translate it to py3. Which is not an easy task, given the fact that I am the tutorial *user* and am supposed to learn ;) Side note: Debian/Ubuntu/Mint announced the total migration to python3, which is good but still work in progress: https://wiki.ubuntu.com/Python/3 From alister.nospam.ware at ntlworld.com Tue Jul 15 08:19:33 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Tue, 15 Jul 2014 12:19:33 GMT Subject: Python 3 is killing Python References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: > > Image, for a moment, a world WITHOUT the great USA! Yes, i know you > little commies love to curse the USA, and yes, > there are many dark sins committed within AND beyond her borders, but > try to tell me you bass-turds, what nation in modern history has > contributed more technological achievements [1] The one you revolted from. The Same one that is your first port of call for assistance whenever you get yourselves involved in conflict. I think you will find that more inventions have originated on this desolate windswept island of the north coast of Europe than the USA. We are called Great Britain, the clue is in the name. -- Charm is a way of getting the answer "Yes" -- without having asked any clear question. From khamenya at gmail.com Tue Jul 15 08:20:40 2014 From: khamenya at gmail.com (Valery Khamenya) Date: Tue, 15 Jul 2014 14:20:40 +0200 Subject: Anything better than asyncio.as_completed() and asyncio.wait() to manage execution of large amount of tasks? Message-ID: Hi, both asyncio.as_completed() and asyncio.wait() work with lists only. No generators are accepted. Are there anything similar to those functions that pulls Tasks/Futures/coroutines one-by-one and processes them in a limited task pool? I have gazillion of Tasks, and do not want to instantiate them all at once, but to instantiate and to address them one by one as the running tasks are completed. best regards -- Valery -------------- next part -------------- An HTML attachment was scrubbed... URL: From 2014 at jmunch.dk Tue Jul 15 08:32:53 2014 From: 2014 at jmunch.dk (Anders J. Munch) Date: Tue, 15 Jul 2014 14:32:53 +0200 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53c4b9f3$0$11125$c3e8da3@news.astraweb.com> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53c4b9f3$0$11125$c3e8da3@news.astraweb.com> Message-ID: <53C51F75.8040100@jmunch.dk> Steven D'Aprano: > I'll give you the benefit of the doubt, and assume that when you first > posted you hadn't realised that the audience here does not have the > relevant experience, but by refusing to ask the question elsewhere, and > by making snide comments that "they don't like beer", that pretty much > gives the game away that you're looking to have your opinion confirmed > rather than looking for an honest answer. I really did run out of time when I said I did: I spent the last 5 days running a chess tournament with 137 participants, with the tournament management software written in Python by yours truly. Which worked beautifully, Python is a great language. And I'm going to Iceland on vacation tomorrow, so I'm not going to start a new discussion of a different mailing list just now, maybe later. Not everyone is as prolific a writer as you are, Steven. The talk about "the wrong list" would have carried more weight if you had started out by saying "wrong list", instead of going through every other argument first, before punting like that. By the way, which list is the appropriate one? The numpy and SciPy mailing lists are first and foremost about numpy and SciPy, I presume. Is there a general numerics-list somewhere also? I don't see any on https://mail.python.org/mailman/listinfo. By the way, you guys seem to have overlooked the opportunity for arbitrage: *Anyone* can go to a numerical list, poll for examples, and come back and earn some beer :) regards, Anders From alister.nospam.ware at ntlworld.com Tue Jul 15 08:30:11 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Tue, 15 Jul 2014 12:30:11 GMT Subject: Python 3 is killing Python References: <7xha49wumw.fsf@ruckus.brouhaha.com> <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> Message-ID: On Mon, 14 Jul 2014 21:18:05 -0700, Rick Johnson wrote: > On Monday, July 14, 2014 9:11:47 PM UTC-5, Chris Angelico wrote: >> I dunno. It's not like Great Britain, Australia, or New Zealand did >> anything significant in either war, is it. > > Most of Europe occupied, London bombed into the stone age; things were > looking grim Chris! Maybe you should read up on some WW2 history, it's > quite humbling to think what *could* have happened. Perhaps you should read history more thoroughly. Great Britain had successfully fended off German plans to invade BEFORE the USA joined the war (Google Battle of Britain). Had we failed there would have been nowhere available to launch the 'D' Day landings & the USSR would almost certainly have rolled over the whole of Europe. so contrary to the much held belief by Americans that they saved or bottoms in WWII the opposite is in fact the case. > >> Some people in Australia are still racist, but racism is nothing like >> the problem it is in America, where you boast so much of equality. > > Where do you get your info about America, from CNN? And for someone who > is a self-described "Aussie" you sure seem to know more about Americans > than Americans know about themselves... hmm, another enigma! I guarantee he knows more about he USA than the average Ammerican knows about Australia or anywhere outside their own border, I once had an American ask what state London was in (& we are quite a big part of your history)! > > Chris, one thing you need to understand about America is that a whole > grievance industry exists to perpetuate hate. > And sadly, most Americans are too stupid to realize this. Now that is the 1st thing you have read that I agree with 100% -- You'll never see all the places, or read all the books, but fortunately, they're not all recommended. From rosuav at gmail.com Tue Jul 15 09:00:51 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 15 Jul 2014 23:00:51 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Tue, Jul 15, 2014 at 10:17 PM, Fabien wrote: > My two cents as a new pythonista and a scientist: isn't python2 killing > python? You're new to Python, and so you correctly want to work with Python 3. That's fine. That's excellent, in fact. You're starting out the right way, and avoiding all the problems that Py3 specifically set out to solve. However, people-new-to-Python is not the only audience that the language supports. Everyone who *already has code*, written for (say) Python 2.5, wants some sort of assurance that it will still be runnable. It's a matter of trust; python.org implicitly promises that it's not a waste of time writing code in Python, and that's a promise that would be broken by cutting off Py2 support. The problem isn't Python 2, nor Python 3, nor even the fact that there are two Pythons. The problem is that a lot of people don't understand when to choose one or the other, don't understand what the promises of support are, and (perhaps worst of all) keep hearing FUD about how Python 3 is killing Python. And so the confusion perpetuates. Eventually the world will get past that, but in the meantime, we have to deal with these sorts of storms-in-teacups from people who simply cannot comprehend what's going on. ChrisA From jtim.arnold at gmail.com Tue Jul 15 09:12:53 2014 From: jtim.arnold at gmail.com (Tim) Date: Tue, 15 Jul 2014 06:12:53 -0700 (PDT) Subject: xslt with python In-Reply-To: References: Message-ID: On Tuesday, July 15, 2014 4:10:57 AM UTC-4, varun bhatnagar wrote: > I am trying to merge two xmls using xslt in python but the content of first xml is not getting copied. The rules written in xsl file created are correct because if I am executing it without python (directly from eclipse as I have xslt plugin installed) it is getting merged fine. Can anybody help me? I am pasting my code snippet below: > > import lxml.etree as ET > dom = ET.parse(r'test_file_2.xml') > xslt = ET.parse(r'TestMergeRules.xsl') > transform = ET.XSLT(xslt) > print transform > > newdom = transform(dom) > print(ET.tostring(newdom, pretty_print=True)) > > I am opening other xml file (test_file_1.xml) in xsl file using "document()" function. > > Once this code is executed I can see only the content of test_file_2.xml. > Am I doing something wrong? Is there any other way to do this because my xslt rules are working fine without python. > Hi BR, Your code looks very close but not exactly equal to the tutorial here: http://lxml.de/xpathxslt.html#xslt Can you try the example on that page and report the results? Plus your platform, python version and lxml details as described here: http://lxml.de/FAQ.html#i-think-i-have-found-a-bug-in-lxml-what-should-i-do thanks, --Tim Arnold From wxjmfauth at gmail.com Tue Jul 15 09:33:00 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Tue, 15 Jul 2014 06:33:00 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <852b2cfd-d425-460e-8d10-6256e4884433@googlegroups.com> Le mardi 15 juillet 2014 14:17:54 UTC+2, Fabien a ?crit?: > My two cents as a new pythonista and a scientist: isn't python2 killing > > python? This old stuff is everywhere in the tutorials, docs, etc. and > > this is quite annoying. When I download a python notebook, the first > > thing I have to do is to translate it to py3. Which is not an easy task, > > given the fact that I am the tutorial *user* and am supposed to learn ;) > > > > Side note: Debian/Ubuntu/Mint announced the total migration to python3, > > which is good but still work in progress: > > https://wiki.ubuntu.com/Python/3 ------ One more good reason to stay away from these products. jmf From varun292006 at gmail.com Tue Jul 15 09:58:57 2014 From: varun292006 at gmail.com (varun bhatnagar) Date: Tue, 15 Jul 2014 15:58:57 +0200 Subject: xslt with python In-Reply-To: References: Message-ID: Hi Tim, Thanks a lot for the reply. I think I got the root cause of the problem. Before merging I am creating one dummy xml file on the fly and I am copying the content of first xml into that. This dummy file I am mentioning in xsl file and the URI is changing because of which it is not getting merged. I have to see how can I resolve the URI problem. //Varun On Tue, Jul 15, 2014 at 3:12 PM, Tim wrote: > On Tuesday, July 15, 2014 4:10:57 AM UTC-4, varun bhatnagar wrote: > > I am trying to merge two xmls using xslt in python but the content of > first xml is not getting copied. The rules written in xsl file created are > correct because if I am executing it without python (directly from eclipse > as I have xslt plugin installed) it is getting merged fine. Can anybody > help me? I am pasting my code snippet below: > > > > import lxml.etree as ET > > dom = ET.parse(r'test_file_2.xml') > > xslt = ET.parse(r'TestMergeRules.xsl') > > transform = ET.XSLT(xslt) > > print transform > > > > newdom = transform(dom) > > print(ET.tostring(newdom, pretty_print=True)) > > > > I am opening other xml file (test_file_1.xml) in xsl file using > "document()" function. > > > > Once this code is executed I can see only the content of test_file_2.xml. > > Am I doing something wrong? Is there any other way to do this because my > xslt rules are working fine without python. > > > Hi BR, > Your code looks very close but not exactly equal to the tutorial here: > http://lxml.de/xpathxslt.html#xslt > > Can you try the example on that page and report the results? > Plus your platform, python version and lxml details as described here: > http://lxml.de/FAQ.html#i-think-i-have-found-a-bug-in-lxml-what-should-i-do > > thanks, > --Tim Arnold > -- > https://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Tue Jul 15 09:57:15 2014 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 15 Jul 2014 09:57:15 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On 7/15/14, 9:00 AM, Chris Angelico wrote: > The problem isn't Python 2, nor Python 3, nor even the fact that there > are two Pythons. The problem is that a lot of people don't understand > when to choose one or the other, don't understand what the promises of > support are, and (perhaps worst of all) keep hearing FUD about how > Python 3 is killing Python. And so the confusion perpetuates. > Eventually the world will get past that, but in the meantime, we have > to deal with these sorts of storms-in-teacups from people who simply > cannot comprehend what's going on. I think it's more than a tempest in a teacup. The number of language revisions that result in deliberate, code-level incompatibility out there is pretty small. People rightly expect that code written for version 2.x of a language will continue to work with version 3.x, even if 3.x is designed to go in another direction. I can only think of two widely used languages in the last decade where there was this type of major break in binary compatibility: Perl and Visual Basic. Perl 6 is kind of a moot point because it's never shipped (insert reference to Duke Nukem or GNU HURD here, as appropriate), and Perl 5 has not just seen continued development, but invigorated development in recent years. But the example of VB is instructive. VB.NET is similar, but not identical, to classic VB, and as far as I am aware its uptake has not been nearly as wide as classic VB. Microsoft was able to force what limited migration we've seen mainly because VB is not open source and they can simply drop support for it from Windows. I've stayed with Python 2.7 because I've seen no benefit in 3.x that outweighs the hassle of going through my code line by line to make it compatible. As a Mac developer I deal with this kind of code/API churn with each release of Mac OS X, and I have no desire to increase my headaches. Though I expect I will eventually update to 3.x, however, like many other developers I am also annoyed by the decision to break backwards compatibility in Python. The decision strikes me as arrogant. Cruft and backwards compatibility are an inevitable part of any mature programming language, and maintaining compatibility is important--more important than bolting on shiny new features, in my view. If shiny new features must be added, they should be added side-by-side with older API's. I think the Python developers have undervalued the conservator part of their role. Yes, they have provided tools to help application and library developers migrate their code, but it should not be incumbent on third-party developers to re-architect stable, working code simply because the language has broken binary compatibility. Defenders of the 3.x migration portray such developers as laggards, but I see Python 3.x's failure to silently and successfully import 2.x code as a failure on the language's end. I won't go so far as to say that Python 3 is killing Python. Python will survive. But the headaches of migration are substantial, and should not be necessary. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From rosuav at gmail.com Tue Jul 15 10:31:31 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 00:31:31 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Tue, Jul 15, 2014 at 11:57 PM, Kevin Walzer wrote: > The number of language revisions that result in deliberate, code-level > incompatibility out there is pretty small. People rightly expect that code > written for version 2.x of a language will continue to work with version > 3.x, even if 3.x is designed to go in another direction. That's not strictly true. I would generally expect some concept of version numbering along the lines of semver.org's recommendations, or the Debian packaging guidelines (I think), or, or, or, or, or. You know the sort of thing: major.minor.revision, where "revision" changes shouldn't break anything unless you were, perhaps unwittingly, depending on a bug; "minor" changes add features, and might break code that was, say, using a new language keyword as an identifier (eg you can use "with" as a function name in Python 2.4, but in Python 2.6 that won't work); and "major" changes can cause backward incompatibility. That's not absolutely strictly true of all Python versions, but it's certainly very close. You would expect Python version 3.x to be broadly the same language as Python 2.x, but you cannot expect code to automatically run unmodified. That's the whole point of a major version number change. And that's exactly what we see; the similarities between Python 2.7 and 3.4 are pretty huge compared to the differences. They are definitely the same language. > I can only think of two widely used languages in the last decade where there > was this type of major break in binary compatibility: Perl and Visual Basic. ANSI C broke quite a bit compared to previous C implementations. Doesn't have quite a "version number", but it's the same concept. Object REXX (OREXX) breaks several things in Classic REXX (REXX). Both of those precede "the last decade", but I'd say the same thing applies: if the name or major version number changes, you can expect differences. (For this reason, I have never actually released a RosMud version 2.0; once I went stable with 1.0, I never needed to make backward-incompatible changes. The latest - and probably last - version is 1.7.0, and the project has been succeeded by Gypsum, which is a brand new project... new name, incompatible APIs.) > I've stayed with Python 2.7 because I've seen no benefit in 3.x that > outweighs the hassle of going through my code line by line to make it > compatible. And that's fine! The python-dev team has promised that 2.7 will continue to be supported; that means some headaches, especially on Windows (the Python 2.7 support will long outlast upstream Microsoft support for the compiler it's built on), but it's a promise that you can continue to run your 2.7 code. That said, though, I would advise you to give 2to3 a shot. You never know, it might do exactly what you need right out-of-the-box and give you a 3.x-compatible codebase in one hit. > Though I expect I will eventually update to 3.x, however, like many other > developers I am also annoyed by the decision to break backwards > compatibility in Python. The decision strikes me as arrogant. Cruft and > backwards compatibility are an inevitable part of any mature programming > language, and maintaining compatibility is important--more important than > bolting on shiny new features, in my view. If shiny new features must be > added, they should be added side-by-side with older API's. Big problem with that: it means that everyone who learns the language has to wrestle with *both* APIs. It's impossible to fix bugs. So how about this as a compromise: We'll have this special flag at the top of the program that says whether it should be in "compatibility mode" or "shiny new features mode". And hey, let's write it like this: #!/usr/local/bin/python2 # This program runs in compatibility mode. #!/usr/local/bin/python3 # This program gets all the new features. Python *is* maintaining backward compatibility. It's fundamentally not possible to add some of Python 3's features without some pretty big changes (look at, for instance, the str/bytes changes - essential to proper i18n, but impossible to do to a Py2-compatible interpreter), so the only way to do it is to continue to support Py2 while doing new development on Py3. > I think the Python developers have undervalued the conservator part of their > role. No, they haven't. That's exactly why Python 2.7 is to be supported for so long (2020 according to current plans), and why PEP 466 and such are so important. There's a lot of Python 2 code out there, and python-dev's taking the responsibility very seriously. > ... I see Python 3.x's failure to silently and > successfully import 2.x code as a failure on the language's end. Fine. Tell me how you would go about adding true Unicode support to Python 2.7, while still having it able to import an unchanged program. Trick question - it's fundamentally impossible, because an unchanged program will not distinguish between bytes and text, but true Unicode support requires that they be distinguished. The best you could do would be to rewrite your code into some kind of hybrid, which would then be able to run on both versions; there are ways of doing this, but if you're going to rewrite your code, you may as well go straight to Py3 and take advantage of its features. Ultimately, the solution is simply to keep Python 2.7 around for a good long time, until the carrot of new Py3 features becomes attractive enough for it to be worth switching. And if that's not before 2020, no problem. Even if it's after 2020, there's a fair chance that you'll still be able to run your 2.7 code - it's just that there's no promise (at the moment) of patches, even security patches, from python.org. If you're running RHEL, you might get full support for several more years after 2020. That's a pretty long time, when you consider that Python 3.1 came out in 2009. ChrisA From wegge at wegge.dk Tue Jul 15 11:02:30 2014 From: wegge at wegge.dk (Anders Wegge Keller) Date: 15 Jul 2014 17:02:30 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <87d2d6d5rt.fsf@huddi.jernurt.dk> Kevin Walzer writes: > I can only think of two widely used languages in the last decade where > there was this type of major break in binary compatibility: Perl and > Visual Basic. Lua 5.1, 5.2 and 5.3 are all incompatible to some extent. It's debatable how widely used Lua is as a stand-alone language, but the usage is pretty widespread; it's just mostly concealed inside another application. -- /Wegge Leder efter redundant peering af dk.*,linux.debian.* From python at mrabarnett.plus.com Tue Jul 15 10:50:46 2014 From: python at mrabarnett.plus.com (MRAB) Date: Tue, 15 Jul 2014 15:50:46 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: <53C53FC6.6020806@mrabarnett.plus.com> On 2014-07-15 13:19, alister wrote: >> >> Image, for a moment, a world WITHOUT the great USA! Yes, i know >> you little commies love to curse the USA, and yes, there are many >> dark sins committed within AND beyond her borders, but try to tell >> me you bass-turds, what nation in modern history has contributed >> more technological achievements [1] > > The one you revolted from. The Same one that is your first port of > call for assistance whenever you get yourselves involved in > conflict. > > I think you will find that more inventions have originated on this > desolate windswept island of the north coast of Europe than the USA. > I'd say it's more north-west than north. > We are called Great Britain, the clue is in the name. > "Great Britain" is the name of the largest island in the "British Isles". From breamoreboy at yahoo.co.uk Tue Jul 15 11:29:20 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 16:29:20 +0100 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53C51F75.8040100@jmunch.dk> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53c4b9f3$0$11125$c3e8da3@news.astraweb.com> <53C51F75.8040100@jmunch.dk> Message-ID: On 15/07/2014 13:32, Anders J. Munch wrote: > By the way, which list > is the appropriate one? The numpy and SciPy mailing lists are first and > foremost about numpy and SciPy, I presume. Is there a general > numerics-list somewhere also? I don't see any on > https://mail.python.org/mailman/listinfo. > Try here http://news.gmane.org/index.php?prefix=gmane.comp.python -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Tue Jul 15 11:35:35 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 16:35:35 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On 15/07/2014 13:19, alister wrote: >> >> Image, for a moment, a world WITHOUT the great USA! Yes, i know you >> little commies love to curse the USA, and yes, >> there are many dark sins committed within AND beyond her borders, but >> try to tell me you bass-turds, what nation in modern history has >> contributed more technological achievements [1] > > I think you will find that more inventions have originated on this > desolate windswept island of the north coast of Europe than the USA. > Like the technology that was used to break the sound barrier? Handed to the Yanks in a deal that they promptly broke but refused to hand the technology back. Special relationship, yep, they were kind enough to give us 60 years to pay off the loans we took out during WWII. As Aurthur Daley used to say "nice little earner". -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Tue Jul 15 11:44:34 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 16:44:34 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On 15/07/2014 15:31, Chris Angelico wrote: > On Tue, Jul 15, 2014 at 11:57 PM, Kevin Walzer wrote: > >> I've stayed with Python 2.7 because I've seen no benefit in 3.x that >> outweighs the hassle of going through my code line by line to make it >> compatible. > > And that's fine! The python-dev team has promised that 2.7 will > continue to be supported; that means some headaches, especially on > Windows (the Python 2.7 support will long outlast upstream Microsoft > support for the compiler it's built on), but it's a promise that you > can continue to run your 2.7 code. > > That said, though, I would advise you to give 2to3 a shot. You never > know, it might do exactly what you need right out-of-the-box and give > you a 3.x-compatible codebase in one hit. > Or any one of https://pypi.python.org/pypi/six/1.7.3 https://github.com/mitsuhiko/python-modernize http://python-future.org/ https://github.com/nandoflorestan/nine -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From invalid at invalid.invalid Tue Jul 15 11:43:02 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 15 Jul 2014 15:43:02 +0000 (UTC) Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On 2014-07-15, Kevin Walzer wrote: > I think it's more than a tempest in a teacup. > > The number of language revisions that result in deliberate, code-level > incompatibility out there is pretty small. People rightly expect that > code written for version 2.x of a language will continue to work with > version 3.x, even if 3.x is designed to go in another direction. I disagree. I don't expect backwards compatability across major version number changes. I've been doing software development for 30 years, and that has always been a pretty common rule for the projects I've worked on. -- Grant Edwards grant.b.edwards Yow! I feel partially at hydrogenated! gmail.com From rosuav at gmail.com Tue Jul 15 11:48:41 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 01:48:41 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Wed, Jul 16, 2014 at 1:44 AM, Mark Lawrence wrote: > Or any one of > > https://pypi.python.org/pypi/six/1.7.3 > https://github.com/mitsuhiko/python-modernize > http://python-future.org/ > https://github.com/nandoflorestan/nine AIUI most of those sorts of things are designed for people maintaining a dual-version codebase, not for making a one-time switch. But yes, there are a variety of tools to help make the changes necessary. ChrisA From marko at pacujo.net Tue Jul 15 13:38:40 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 15 Jul 2014 20:38:40 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <87zjga4j4v.fsf@elektro.pacujo.net> Chris Angelico : > Fine. Tell me how you would go about adding true Unicode support to > Python 2.7, while still having it able to import an unchanged program. > Trick question - it's fundamentally impossible, because an unchanged > program will not distinguish between bytes and text, but true Unicode > support requires that they be distinguished. Python 2 has always had unicode strings and [byte] strings. They were always clearly distinguished. You really didn't have to change anything for "true Unicode support". > you may as well go straight to Py3 and take advantage of its features. The first real new feature in Python 3 is asyncio. I've been perfectly happy with select.epoll myself and written my own 50-line asyncio equivalents so it remains to be seen how much traction asyncio will have. Marko From alister.nospam.ware at ntlworld.com Tue Jul 15 13:38:56 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Tue, 15 Jul 2014 17:38:56 GMT Subject: Python 3 is killing Python References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On Tue, 15 Jul 2014 15:50:46 +0100, MRAB wrote: > On 2014-07-15 13:19, alister wrote: >>> >>> Image, for a moment, a world WITHOUT the great USA! Yes, i know you >>> little commies love to curse the USA, and yes, there are many dark >>> sins committed within AND beyond her borders, but try to tell me you >>> bass-turds, what nation in modern history has contributed more >>> technological achievements [1] >> >> The one you revolted from. The Same one that is your first port of call >> for assistance whenever you get yourselves involved in conflict. >> >> I think you will find that more inventions have originated on this >> desolate windswept island of the north coast of Europe than the USA. >> > I'd say it's more north-west than north. Doesn't roll of the tongue as well though > >> We are called Great Britain, the clue is in the name. >> > "Great Britain" is the name of the largest island in the "British > Isles". Never let the facts get in the way of a good punchline :-) -- The one day you'd sell your soul for something, souls are a glut. From rantingrickjohnson at gmail.com Tue Jul 15 14:01:53 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 15 Jul 2014 11:01:53 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> On Tuesday, July 15, 2014 9:31:31 AM UTC-5, Chris Angelico wrote: > [...] That said, though, I would advise you to give 2to3 a > shot. You never know, it might do exactly what you need > right out-of-the-box and give you a 3.x-compatible > codebase in one hit. Ha! Are you so foolish as to believe that if code runs cleanly *immediately* after translating via "2to3", that the code is now completely free from translation bugs? You act as if 2to3 is some "magical" code that can root out every bug no matter how subtle. No, for those of us who care about our reputation, we are not about to release code that could blow chunks and leave egg all over our face, or worse, cause us to loose a contract! > Ultimately, the solution is simply to keep Python 2.7 > around for a good long time, until the carrot of new Py3 > features becomes attractive enough for it to be worth > switching. And if that's not before 2020, no problem. Even > if it's after 2020, there's a fair chance that you'll > still be able to run your 2.7 code - So in other words, "we're" know now we made a bad decision by creating this Python3000 thing, because nobody seems to be jumping on the bandwagon, but instead of admitting we were wrong, we'll just cling to our new shiny *THING* and hope *EVENTUALLY*, if we brow-beat *ENOUGH* people, that well, *MAYBE* most of them will embrace this *ABORTION* and join us. > it's just that there's no promise (at the moment) of > patches, even security patches, from python.org. Oh yes, i see... when brow-beating does not work, we adopt the malevolent tactics of $MS and $OS by allowing security holes and virus infections to riddle the code base obsolete. COME AND GET THE NEXT NEW SHINY RATTLE YOU INFANTS! MEET THE NEW RATTLE... SAME AS THE OLD RATTLE... i pray we don't get fooled again! From marko at pacujo.net Tue Jul 15 14:08:03 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 15 Jul 2014 21:08:03 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> Message-ID: <87r41m4hrw.fsf@elektro.pacujo.net> Rick Johnson : > So in other words, "we're" know now we made a bad decision by creating > this Python3000 thing, because nobody seems to be jumping on the > bandwagon, but instead of admitting we were wrong, we'll just cling to > our new shiny *THING* and hope *EVENTUALLY*, if we brow-beat *ENOUGH* > people, that well, *MAYBE* most of them will embrace this *ABORTION* > and join us. I agree it was a grave mistake. However, what's done is done. Instead of fighting it or defending it, just cope with it and move on. Marko From invalid at invalid.invalid Tue Jul 15 14:23:17 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Tue, 15 Jul 2014 18:23:17 +0000 (UTC) Subject: Python 3 is killing Python References: <7xha49wumw.fsf@ruckus.brouhaha.com> Message-ID: On 2014-07-15, alister wrote: > Never let the facts get in the way of a good punchline :-) Ah! That explains it! The Iraq war must have been a _joke_. It sure went over my head... -- Grant Edwards grant.b.edwards Yow! My Aunt MAUREEN was a at military advisor to IKE & gmail.com TINA TURNER!! From ian.g.kelly at gmail.com Tue Jul 15 14:53:31 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Jul 2014 12:53:31 -0600 Subject: Python 3 is killing Python In-Reply-To: <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> Message-ID: On Tue, Jul 15, 2014 at 12:01 PM, Rick Johnson wrote: > On Tuesday, July 15, 2014 9:31:31 AM UTC-5, Chris Angelico wrote: >> [...] That said, though, I would advise you to give 2to3 a >> shot. You never know, it might do exactly what you need >> right out-of-the-box and give you a 3.x-compatible >> codebase in one hit. > > Ha! > > Are you so foolish as to believe that if code runs cleanly > *immediately* after translating via "2to3", that the code is > now completely free from translation bugs? > > You act as if 2to3 is some "magical" code that can root out > every bug no matter how subtle. No, for those of us who care > about our reputation, we are not about to release code that > could blow chunks and leave egg all over our face, or worse, > cause us to loose a contract! This is what tests are for: so you know whether your code is working or not. 1) Run 2to3. 2) Run your test suite. 3) If there's a UI, exercise it manually. At that point you should know how many things you need to fix. If that number is 0, then you're basically ready to release (depending on your test coverage and your release cycle and your overall level of comfort with releasing the result). From steve+comp.lang.python at pearwood.info Tue Jul 15 14:53:27 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 18:53:27 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> Message-ID: <53c578a7$0$9505$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Jul 2014 11:01:53 -0700, Rick Johnson wrote: > Are you so foolish as to believe that if code runs cleanly *immediately* > after translating via "2to3", that the code is now completely free from > translation bugs? If your code has a thorough set of unittests that continue to pass, then changes are better than excellent that it is free of translation bugs. > You act as if 2to3 is some "magical" code that can root out every bug no > matter how subtle. Of course not. 2to3 certainly won't remove bugs that already exist in your code. It will happily translate them to version 3 dialect for you, so you can have the fun of fixing them yourself. [...snip foolish grandstanding...] >> Ultimately, the solution is simply to keep Python 2.7 around for a good >> long time, until the carrot of new Py3 features becomes attractive >> enough for it to be worth switching. And if that's not before 2020, no >> problem. Even if it's after 2020, there's a fair chance that you'll >> still be able to run your 2.7 code - > > So in other words, "we're" know now we made a bad decision by creating > this Python3000 thing, because nobody seems to be jumping on the > bandwagon, Don't be childish. There are still people using Python 2.3. There are even a few people -- just a handful -- happily using Python 1.5, which is probably older than you. People have all sorts of reasons for sticking to what works, instead of jumping from version to version and having to deal with code churn every 18 months. And they have the right to do so. No adult expect them to upgrade just because there is a new version out. Redhat still offers commercial support for Python 2.4. I believe that Python 2.3 has only *just* come out of commercial support a few months ago. Some people will upgrade, some are happy to keep using a product that works, and require no support. The choice is theirs. The same will apply to Python 2.7. The Python developers have promised to give 2.7 extended support until 2020, and Red Hat has committed to extended commercial support until 2023. Capitalism at work: Red Hat expects to be able to make money from supporting this for nearly another decade, and good on them. [...snip childish insults...] >> it's just that there's no promise (at the moment) of patches, even >> security patches, from python.org. > > Oh yes, i see... when brow-beating does not work, we adopt the > malevolent tactics of $MS and $OS by allowing security holes and virus > infections to riddle the code base obsolete. No software developer is obliged to support their software forever, especially if they are giving it away for free, and writing it out of love. Nobody but nobody is supporting Python 1.1 any more, no matter how many security holes it has. So what? Who cares? Python 2.7 is open source software, if you think that there is a market for providing support for it for the next twenty years, go right ahead. You can even charge money for it. But of course you won't. Because it's much easier to bitch and moan and pretend to be oh-so-superior than to actually write code, fix bugs, and provide support. -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 15 14:57:49 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 18:57:49 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> <87r41m4hrw.fsf@elektro.pacujo.net> Message-ID: <53c579ad$0$9505$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Jul 2014 21:08:03 +0300, Marko Rauhamaa wrote: > I agree it was a grave mistake. On what basis do you believe it was a mistake? -- Steven From steve+comp.lang.python at pearwood.info Tue Jul 15 15:06:23 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 15 Jul 2014 19:06:23 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Jul 2014 20:38:40 +0300, Marko Rauhamaa wrote: > Python 2 has always had unicode strings and [byte] strings. They were > always clearly distinguished. You really didn't have to change anything > for "true Unicode support". If that were true, then migrating from Python 2 to 3 would be much simpler than it is. Unicode strings in Python 2 are second class entities. It's not just that people will, in general, take the lazy way and write "foo" instead of u"foo" for their strings. But it is that the whole Python virtual machine is based on byte-strings, not Unicode strings, and u"" strings are bolted on top. [steve at ando ~]$ python3.3 -c "? = 3.14; print(?+1)" 4.140000000000001 [steve at ando ~]$ python2.7 -c "? = 3.14; print(?+1)" File "", line 1 ? = 3.14; print(?+1) ^ SyntaxError: invalid syntax Python 2 "helpfully" tries to guess what you want when you work with bytes-pretending-to-be-strings, and when it guesses right, it's nice, but when it guesses wrongly, you'll left with mysterious encoding and decoding errors from code that don't appear to involve either. The whole thing is a mess. -- Steven From marko at pacujo.net Tue Jul 15 15:49:07 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 15 Jul 2014 22:49:07 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> <87r41m4hrw.fsf@elektro.pacujo.net> <53c579ad$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87mwca4d3g.fsf@elektro.pacujo.net> Steven D'Aprano : > On Tue, 15 Jul 2014 21:08:03 +0300, Marko Rauhamaa wrote: > >> I agree it was a grave mistake. > > On what basis do you believe it was a mistake? The supposed flaws in Python 2 weren't a good enough reason to break backward-compatibility. Marko From marko at pacujo.net Tue Jul 15 16:01:25 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Tue, 15 Jul 2014 23:01:25 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87iomy4ciy.fsf@elektro.pacujo.net> Steven D'Aprano : > Unicode strings in Python 2 are second class entities. I don't see that. They form a type just like, say, complex. > It's not just that people will, in general, take the lazy way and > write "foo" instead of u"foo" for their strings. People live with their choices, and I don't see the consequences of that lazy way as very bad. In fact, I find the lazy use of Unicode strings at least as scary as the lazy use of byte strings, especially since Python 3 sneaks Unicode to the outer interfaces of the program (files, IPC). > But it is that the whole Python virtual machine is based on > byte-strings, not Unicode strings, and u"" strings are bolted on top. The internal implementation of the VM is free to change as long as the external semantics stay the same. > [steve at ando ~]$ python3.3 -c "? = 3.14; print(?+1)" > 4.140000000000001 > [steve at ando ~]$ python2.7 -c "? = 3.14; print(?+1)" > File "", line 1 > ? = 3.14; print(?+1) > ^ > SyntaxError: invalid syntax My native language uses ? and ?, but I don't see any pressing need to embed those characters in identifiers. > Python 2 "helpfully" tries to guess what you want when you work with > bytes-pretending-to-be-strings, and when it guesses right, it's nice, but > when it guesses wrongly, you'll left with mysterious encoding and > decoding errors from code that don't appear to involve either. The whole > thing is a mess. I can't think of a matching example. Marko From breamoreboy at yahoo.co.uk Tue Jul 15 16:24:07 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 21:24:07 +0100 Subject: Python 3 is killing Python In-Reply-To: <87zjga4j4v.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 15/07/2014 18:38, Marko Rauhamaa wrote: > Chris Angelico : > >> Fine. Tell me how you would go about adding true Unicode support to >> Python 2.7, while still having it able to import an unchanged program. >> Trick question - it's fundamentally impossible, because an unchanged >> program will not distinguish between bytes and text, but true Unicode >> support requires that they be distinguished. > > Python 2 has always had unicode strings and [byte] strings. They were > always clearly distinguished. You really didn't have to change anything > for "true Unicode support". > That is the funniest tongue in cheek comment I've read in the 10+ years I''ve been hanging around here. It was tongue in cheek, wasn't it? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rantingrickjohnson at gmail.com Tue Jul 15 16:20:07 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 15 Jul 2014 13:20:07 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <53c578a7$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> <53c578a7$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tuesday, July 15, 2014 1:53:27 PM UTC-5, Steven D'Aprano wrote: > No software developer is obliged to support their software > forever, especially if they are giving it away for free > [...] Nobody but nobody is supporting Python 1.1 any more, > no matter how many security holes it has. Of course not, Python 1.1 is pre-1999, heck, it's so old i cannot find a release date for it, and it's probably completely useless in today's world BUT THAT IS NOT MY POINT! What you fail to realize is that the *MAJORITY* of Python programmers cut their teeth on the Python 2.x line, and as such, the majority of today's Python programmers are still using the Python 2.x line -- anything to with Python 1.1 might as well be ancient history, it's irrelevant due to age and it's abysmal utilization. Python's popularity started increasing significantly only *AFTER* Python 2 was rolled out. If you look at the TIOBE stats (2003-2013), Python made the *MOST* improvements in the years of 2007 and 2013 PYTHON-2.0.1 WAS RELEASED ON JUNE 22, 2001 But nothing *significant* happened until Python-2.5 PYTHON-2.5.0 WAS RELEASED ON SEPT. 19, 2006 Which coincides with the spike of 2007! Now begs the question, what caused the 2013 spike? Simple, the 2013 spike was a result of all the *BUZZ* of Python-3000, NOT *BECAUSE* OF PYTHON-3000, but, because of the *BUZZ*. Remember, GvR went on an extensive campaign to sale this "new and improved" snake oil, with all his Google speeches and evangelizing and whatnot. But very quickly the "curiosity" and "excitement" turned into the "summer of discontent". I remember watching some speeches where the audience was not at all pleased with the breaks and "great new functionality". The blogisphere has been set ablaze with bemoaning of breaking code over such "miniscule" things as lazy iterators, print, input,etc... and the misguided attempts to "sanitize" Python of functional programming! SHOULD I DRAW YOU A "MAP"? I think we can all agree that the roll out of Python3 was not as "smooth" as the dictator has expected Also, keep in mind that most of the tutorials and books out there are written for Python 2.x, whereas Python 3.x is very limited[1]. Too many noobs have downloaded Python3 and whilst unwittingly following a "Googled tutorial" or book, get hammered with esoteric exception messages and then quickly give up and move on to another language, unaware that the versions are incompatible in many respects. Kind of sad when you realize that most of the functions that were broken are the same functions a noob is using during "day one" (print, input, etc...) 2.x also has years and years of *MATURE* third party modules for the taking, whereas Python 3.x is quite disappointing[1]. > Python 2.7 is open source software, if you think that > there is a market for providing support for it for the > next twenty years, go right ahead There *WILL* be a market for Python for the next ten or so years no matter what happens to Python3! Since the vast majority of Python code (in the wild) is written in the 2.x line (most likely written using Python-2.5), python-3000 was a lame duck before it was even released! print("QUACK!") [1]: yes, yes, i know there are 3.x resources but no where even close to 2.x! From charleshixsn at earthlink.net Tue Jul 15 16:32:08 2014 From: charleshixsn at earthlink.net (Charles Hixson) Date: Tue, 15 Jul 2014 13:32:08 -0700 Subject: multiprocessing problem: queue.get() not finding pushed values Message-ID: <53C58FC8.2030202@earthlink.net> I don't think I can reduce it much beyond this. I'm trying to run Sqlite in a separate process, but I'm running into problems. *The code:* from collections import namedtuple from multiprocessing import Process, Queue, current_process from queue import Empty, Full Msg = namedtuple ("Msg", ['act', 'id', 'vals']) DBW_to = Queue() DBW_from = Queue() class DBW (Process): def __init__ (self, qin, qout): self.qin = qin self.qout = qout super (DBW, self).__init__() def run (self): msg = self.qin.get(True, 3) print ("msg = {0}".format(repr(msg) ) ) if __name__ == "__main__": dbw = DBW(DBW_to, DBW_from) dbw.run() DBW_to.put(Msg("a", 1, wrd) ) DBW_to.put(Msg("b", 2, wrd) ) DBW_to.put(Msg("c", 0, None) ) *The result:* Traceback (most recent call last): File "test7a.py", line 23, in dbw.run() File "test7a.py", line 18, in run msg = self.qin.get(True, 3) File "/usr/lib/python3.4/multiprocessing/queues.py", line 107, in get raise Empty queue.Empty *$ python3 --version* Python 3.4.1 *The system:* Linux 3.14-1-amd64 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeanpierreda at gmail.com Tue Jul 15 16:47:22 2014 From: jeanpierreda at gmail.com (Devin Jeanpierre) Date: Tue, 15 Jul 2014 13:47:22 -0700 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On Tue, Jul 15, 2014 at 1:24 PM, Mark Lawrence wrote: > On 15/07/2014 18:38, Marko Rauhamaa wrote: >> >> Chris Angelico : >> >>> Fine. Tell me how you would go about adding true Unicode support to >>> Python 2.7, while still having it able to import an unchanged program. >>> Trick question - it's fundamentally impossible, because an unchanged >>> program will not distinguish between bytes and text, but true Unicode >>> support requires that they be distinguished. >> >> >> Python 2 has always had unicode strings and [byte] strings. They were >> always clearly distinguished. You really didn't have to change anything >> for "true Unicode support". >> > > That is the funniest tongue in cheek comment I've read in the 10+ years > I''ve been hanging around here. It was tongue in cheek, wasn't it? What isn't "true" about Python 2.x's unicode support? The only feature I ever missed was case folding. (Not that 3.x does much better at that... :) The stdlib had poor unicode support, if that's what you mean. That could've been fixed without introducing backwards-incompatible changes, though. -- Devin From abhi.darkness at gmail.com Tue Jul 15 17:37:23 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 03:07:23 +0530 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: Annd I just saw that the lifetime has been pushed up to 2020 :) #SelfCorrected On Wed, Jul 16, 2014 at 3:05 AM, Abhiram R wrote: > Umm..Guido Van Rossum said in Pycon 2014 that Py 2.x would be supported > only until 2015 :-| So...you know.. you have like an year before you *do *have > to migrate to 3.x . > > > On Wed, Jul 16, 2014 at 2:17 AM, Devin Jeanpierre > wrote: > >> On Tue, Jul 15, 2014 at 1:24 PM, Mark Lawrence >> wrote: >> > On 15/07/2014 18:38, Marko Rauhamaa wrote: >> >> >> >> Chris Angelico : >> >> >> >>> Fine. Tell me how you would go about adding true Unicode support to >> >>> Python 2.7, while still having it able to import an unchanged program. >> >>> Trick question - it's fundamentally impossible, because an unchanged >> >>> program will not distinguish between bytes and text, but true Unicode >> >>> support requires that they be distinguished. >> >> >> >> >> >> Python 2 has always had unicode strings and [byte] strings. They were >> >> always clearly distinguished. You really didn't have to change anything >> >> for "true Unicode support". >> >> >> > >> > That is the funniest tongue in cheek comment I've read in the 10+ years >> > I''ve been hanging around here. It was tongue in cheek, wasn't it? >> >> What isn't "true" about Python 2.x's unicode support? The only feature >> I ever missed was case folding. (Not that 3.x does much better at that... >> :) >> >> The stdlib had poor unicode support, if that's what you mean. That >> could've been fixed without introducing backwards-incompatible >> changes, though. >> >> -- Devin >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > > > > -- > Abhiram.R > M.Tech CSE (Sem 3) > RVCE > Bangalore > -- Abhiram.R M.Tech CSE (Sem 3) RVCE Bangalore -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Tue Jul 15 16:46:35 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Tue, 15 Jul 2014 14:46:35 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <753ef4fc-4abd-4128-bc26-63dc309c0b44@googlegroups.com> <53c578a7$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Tue, Jul 15, 2014 at 2:20 PM, Rick Johnson wrote: > On Tuesday, July 15, 2014 1:53:27 PM UTC-5, Steven D'Aprano wrote: > >> No software developer is obliged to support their software >> forever, especially if they are giving it away for free >> [...] Nobody but nobody is supporting Python 1.1 any more, >> no matter how many security holes it has. > > Of course not, Python 1.1 is pre-1999, heck, it's so old i > cannot find a release date for it, and it's probably > completely useless in today's world > > BUT THAT IS NOT MY POINT! > > What you fail to realize is that the *MAJORITY* of Python > programmers cut their teeth on the Python 2.x line, and as > such, the majority of today's Python programmers are still > using the Python 2.x line -- anything to with Python 1.1 > might as well be ancient history, it's irrelevant due to age > and it's abysmal utilization. When Python 2.0 was released, the majority of Python programmers at the time had learned on Python 1.x, and for a while the majority of them were still using 1.x. That's the same situation you're describing today. At some point in the future, Python 2.x will be "ancient history" also. > Python's popularity started increasing significantly only > *AFTER* Python 2 was rolled out. If you look at the TIOBE > stats (2003-2013), Python made the *MOST* improvements in > the years of 2007 and 2013 > > PYTHON-2.0.1 WAS RELEASED ON JUNE 22, 2001 > > But nothing *significant* happened until Python-2.5 Seriously? If you ask me, the changes introduced in 2.2 were a lot more significant than anything in 2.5. 2.2 fixed the type system by giving us new-style classes. It also added the iterator interface, introduced generators, and removed the distinction between int and long. All of those things were huge. What did Python 2.5 add? Conditional expressions and the with statement, both of which are useful but not nearly as compelling. > Now begs the question, what caused the 2013 spike? Simple, > the 2013 spike was a result of all the *BUZZ* of Python-3000, > NOT *BECAUSE* OF PYTHON-3000, but, because of the *BUZZ*. Python 3.0 was released in 2008. I don't understand why you think the buzz surrounding that would have occurred 5 years later. > Remember, GvR went on an extensive campaign to sale this > "new and improved" snake oil, with all his Google speeches > and evangelizing and whatnot. But very quickly the > "curiosity" and "excitement" turned into the "summer of > discontent". No, I have no idea what you're referring to. If Guido was talking more about Python 3 in 2012 than at any time in the six years prior, then I for one didn't notice. > [1]: yes, yes, i know there are 3.x resources but no where even > close to 2.x! Actually, the Wall of Superpowers is showing quite a lot of green these days. https://python3wos.appspot.com/ From abhi.darkness at gmail.com Tue Jul 15 17:35:17 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 03:05:17 +0530 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: Umm..Guido Van Rossum said in Pycon 2014 that Py 2.x would be supported only until 2015 :-| So...you know.. you have like an year before you *do *have to migrate to 3.x . On Wed, Jul 16, 2014 at 2:17 AM, Devin Jeanpierre wrote: > On Tue, Jul 15, 2014 at 1:24 PM, Mark Lawrence > wrote: > > On 15/07/2014 18:38, Marko Rauhamaa wrote: > >> > >> Chris Angelico : > >> > >>> Fine. Tell me how you would go about adding true Unicode support to > >>> Python 2.7, while still having it able to import an unchanged program. > >>> Trick question - it's fundamentally impossible, because an unchanged > >>> program will not distinguish between bytes and text, but true Unicode > >>> support requires that they be distinguished. > >> > >> > >> Python 2 has always had unicode strings and [byte] strings. They were > >> always clearly distinguished. You really didn't have to change anything > >> for "true Unicode support". > >> > > > > That is the funniest tongue in cheek comment I've read in the 10+ years > > I''ve been hanging around here. It was tongue in cheek, wasn't it? > > What isn't "true" about Python 2.x's unicode support? The only feature > I ever missed was case folding. (Not that 3.x does much better at that... > :) > > The stdlib had poor unicode support, if that's what you mean. That > could've been fixed without introducing backwards-incompatible > changes, though. > > -- Devin > -- > https://mail.python.org/mailman/listinfo/python-list > -- Abhiram.R M.Tech CSE (Sem 3) RVCE Bangalore -------------- next part -------------- An HTML attachment was scrubbed... URL: From breamoreboy at yahoo.co.uk Tue Jul 15 17:49:47 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 22:49:47 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 15/07/2014 22:35, Abhiram R wrote: > Umm..Guido Van Rossum said in Pycon 2014 that Py 2.x would be supported > only until 2015 :-| So...you know.. you have like an year before you /do > /have to migrate to 3.x . > -- > Abhiram.R > M.Tech CSE (Sem 3) > RVCE > Bangalore > > a) please don't top post, this is almost as heinous a crime as using the infamous google groups b) complete nonsense, it's actually 2020 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From abhi.darkness at gmail.com Tue Jul 15 18:13:24 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 03:43:24 +0530 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: a) What is "top post"? b)I did correct myself in the next post. Or maybe you missed that. On Wed, Jul 16, 2014 at 3:19 AM, Mark Lawrence wrote: > On 15/07/2014 22:35, Abhiram R wrote: > >> Umm..Guido Van Rossum said in Pycon 2014 that Py 2.x would be supported >> only until 2015 :-| So...you know.. you have like an year before you /do >> /have to migrate to 3.x . >> >> -- >> Abhiram.R >> M.Tech CSE (Sem 3) >> RVCE >> Bangalore >> >> >> > a) please don't top post, this is almost as heinous a crime as using the > infamous google groups > b) complete nonsense, it's actually 2020 > > > -- > My fellow Pythonistas, ask not what our language can do for you, ask what > you can do for our language. > > Mark Lawrence > > --- > This email is free from viruses and malware because avast! Antivirus > protection is active. > http://www.avast.com > > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Abhiram.R -------------- next part -------------- An HTML attachment was scrubbed... URL: From kw at codebykevin.com Tue Jul 15 18:30:15 2014 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 15 Jul 2014 18:30:15 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: "Top posting" is the practice of responding to an e-mail thread by putting your response at the top of the text you are quoting. It's standard practice in the corporate world... On 7/15/14, 6:13 PM, Abhiram R wrote: > a) What is "top post"?? ...but Unix/newsgroup ettiquette says that it's gauche to do this, because it presents an unacceptable cognitive burden to the user trying to catch the context of the thread by forcing them to read your reply first, before they read the preceding quoted comments. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From breamoreboy at yahoo.co.uk Tue Jul 15 18:38:40 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Tue, 15 Jul 2014 23:38:40 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 15/07/2014 23:13, Abhiram R wrote: > a) What is "top post"? > b)I did correct myself in the next post. Or maybe you missed that. > > On Wed, Jul 16, 2014 at 3:19 AM, Mark Lawrence > wrote: > > On 15/07/2014 22:35, Abhiram R wrote: > > Umm..Guido Van Rossum said in Pycon 2014 that Py 2.x would be > supported > only until 2015 :-| So...you know.. you have like an year before > you /do > /have to migrate to 3.x . > > -- > Abhiram.R > M.Tech CSE (Sem 3) > RVCE > Bangalore > > a) please don't top post, this is almost as heinous a crime as using > the infamous google groups > b) complete nonsense, it's actually 2020 > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > --- Top posting is the extremely annoying habit of replying to a message at the top instead of at the bottom as I'm doing here, or interspersing your answers in with the related paragraphs. I did see your correction but it gave me an opportunity to mention google groups, something that just can't be missed :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From abhi.darkness at gmail.com Tue Jul 15 18:40:29 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 04:10:29 +0530 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 4:00 AM, Kevin Walzer wrote: > "Top posting" is the practice of responding to an e-mail thread by putting > your response at the top of the text you are quoting. It's standard > practice in the corporate world... > > On 7/15/14, 6:13 PM, Abhiram R wrote: > >> a) What is "top post"?? >> > > ...but Unix/newsgroup ettiquette says that it's gauche to do this, > because it presents an unacceptable cognitive burden to the user trying to > catch the context of the thread by forcing them to read your reply first, > before they read the preceding quoted comments. > > > --Kevin > -- > Kevin Walzer > Code by Kevin/Mobile Code by Kevin > http://www.codebykevin.com > http://www.wtmobilesoftware.com > -- > https://mail.python.org/mailman/listinfo/python-list > ?Aah. Understood. Apologies for the "noobishness" :) ? ?-? Abhiram.R -------------- next part -------------- An HTML attachment was scrubbed... URL: From joshua at landau.ws Tue Jul 15 19:45:14 2014 From: joshua at landau.ws (Joshua Landau) Date: Wed, 16 Jul 2014 00:45:14 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 15 July 2014 23:40, Abhiram R wrote: > On Wed, Jul 16, 2014 at 4:00 AM, Kevin Walzer wrote: >> >> ...but Unix/newsgroup ettiquette says that it's gauche to [top post], >> because it presents an unacceptable cognitive burden to the user trying to >> catch the context of the thread by forcing them to read your reply first, >> before they read the preceding quoted comments. > > Aah. Understood. Apologies for the "noobishness" :) Also heinous is the crime of not trimming. A post should contain all of the context needed to understand the reply, in order, and nothing more. From rantingrickjohnson at gmail.com Tue Jul 15 19:53:39 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Tue, 15 Jul 2014 16:53:39 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On Tuesday, July 15, 2014 5:40:29 PM UTC-5, Abhiram R wrote: > [snip excessive quotations] > Aah. Understood. Apologies for the "noobishness" :) Noobishness can be tolerated for a "reasonable" time, especially when the "noob" actively seeks to improve his skills, as you are doing, so kudos to you. The next skill to learn, after NOT top posting, is the art of trimming quotations to the most relevant bits. You'll have to use your own judgment for most quoted text, however, if nothing else, be sure to remove any links to the quoted persons web site or blog, and any "famous quotes". Some folks even have software that "blabs" about how great a job it is doing protecting the posters computer (like we really care!), so if you see any taglines that mention "this is a virus free message" (oh thanks, now i can sleep at night!), or some pretentious line about "this was sent from my i-phone" -- send that crap to the bitbucket! From kw at codebykevin.com Tue Jul 15 20:43:03 2014 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 15 Jul 2014 20:43:03 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 7/15/14, 6:38 PM, Mark Lawrence wrote: > I did see your correction but it gave me an opportunity to mention > google groups, something that just can't be missed If the newgroup had a filter to trim out complaints about Google groups, half the traffic would be gone. :-) -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From python at mrabarnett.plus.com Tue Jul 15 21:57:24 2014 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 16 Jul 2014 02:57:24 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: <53C5DC04.9070600@mrabarnett.plus.com> On 2014-07-16 00:53, Rick Johnson wrote: > On Tuesday, July 15, 2014 5:40:29 PM UTC-5, Abhiram R wrote: >> [snip excessive quotations] >> Aah. Understood. Apologies for the "noobishness" :) > > Noobishness can be tolerated for a "reasonable" time, especially when > the "noob" actively seeks to improve his skills, as you are doing, so > kudos to you. > > The next skill to learn, after NOT top posting, is the art of > trimming quotations to the most relevant bits. You'll have to use > your own judgment for most quoted text, however, if nothing else, be > sure to remove any links to the quoted persons web site or blog, and > any "famous quotes". > > Some folks even have software that "blabs" about how great a job it > is doing protecting the posters computer (like we really care!), so > if you see any taglines that mention "this is a virus free message" > (oh thanks, now i can sleep at night!), or some pretentious line > about "this was sent from my i-phone" -- send that crap to the > bitbucket! > "This was sent from my iPhone" == "I have an iPhone!" Also annoying is some footnote that says that the email contains confidential information and that if you're not the intended recipient you should delete it, etc. That's somewhat pointless if it's being sent to a public forum! From nicholascannon1 at gmail.com Tue Jul 15 21:56:56 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Tue, 15 Jul 2014 18:56:56 -0700 (PDT) Subject: Mac python py2app problem Message-ID: Hey i have made an app and i have made a .msi for windows with py2exe and i have also exported it with py2app on mac. No problems here they all work fine. I then put the .msi on sourceforge and it works great but when i put the .app on there and download it it says something like i can open this on old architecture or something so i have to put it through google drive and i dont like this like i share the link and folder and people can download it there but it is dodgy. Could someone please help me out like if there is a .msi type thing for mac with py2exe? From steve+comp.lang.python at pearwood.info Tue Jul 15 22:08:20 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 02:08:20 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: <53c5de94$0$9505$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 03:07:23 +0530, Abhiram R wrote about Python 2.7: > Annd I just saw that the lifetime has been pushed up to 2020 :) > #SelfCorrected Even when free support runs out, commercial support will be available. Red Hat is already committed to supporting Python 2.7 until 2023, and if there really is demand, nothing stops people or companies supporting it for the next 30 years. -- Steven From kw at codebykevin.com Tue Jul 15 22:43:12 2014 From: kw at codebykevin.com (Kevin Walzer) Date: Tue, 15 Jul 2014 22:43:12 -0400 Subject: Mac python py2app problem In-Reply-To: References: Message-ID: On 7/15/14, 9:56 PM, Nicholas Cannon wrote: > Hey i have made an app and i have made a .msi for windows with py2exe and i have also exported it with py2app on mac. No problems here they all work fine. I then put the .msi on sourceforge and it works great but when i put the .app on there and download it it says something like i can open this on old architecture or something so i have to put it through google drive and i dont like this like i share the link and folder and people can download it there but it is dodgy. Could someone please help me out like if there is a .msi type thing for mac with py2exe? > It's hard to make sense of what you are asking for. Can you just zip up the app bundle that py2app produces and upload it that way? That works for many developers. --Kevin -- Kevin Walzer Code by Kevin/Mobile Code by Kevin http://www.codebykevin.com http://www.wtmobilesoftware.com From nhatminh179 at gmail.com Tue Jul 15 22:59:49 2014 From: nhatminh179 at gmail.com (Orakaro) Date: Tue, 15 Jul 2014 19:59:49 -0700 (PDT) Subject: Twitter Client on Terminal by Python In-Reply-To: References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> <6e3b7633-9c3b-4b3f-8337-6712edeed2c2@googlegroups.com> Message-ID: <630fb6a1-8ce0-49f9-9137-5fb895e7ca00@googlegroups.com> On Tuesday, July 15, 2014 5:36:40 AM UTC+9, Terry Reedy wrote: > On 7/13/2014 11:51 PM, Chris Angelico wrote: > > > On Mon, Jul 14, 2014 at 12:18 PM, Orakaro wrote: > > >> I use README.md for Github and README.rst for PyPi. Is there a way to use only one file for both sites ? > > > > > > Ah. I don't know; check the docs for one or the other and see what they'll do. > > > > > >> I tested my package on Python 2.7 and Python 3.4 But do I have to install all Python 2.6, Python 3.* in my system and test in all environment for sure ? > > > > You don't *have* do anything for free. However, if your package works on > > 2.7 and 3.4, it *probably* works as is for 3.2 and 3.3. On Windows at > > least, installing multiple versions is trivial (5 minutes for each). > > > > The more important issue, I think, is what system you have tested on. Up > > to 3.2, including all 2.x, Python had 'wide' and 'narrow' unicode > > builds. On narrow builds (Windows, some *nix), astral (non-BMP) chars > > count as 2. Given Twitter's 140 char limitation, this bug (solved in > > 3.3) could affect a Twitter client by giving the length of a 140 char > > tweet as more than 140 chars. > > > > > You can state that it supports 2.7 and 3.4, without testing on any > > > other versions. Those are the two current versions - my example was > > > showing support for more than just the one latest, but that was just > > > an example, nothing more. When Python 3.5 comes out, you'll probably > > > want to test on that (and then say "supports 2.7 and 3.4+"), but at > > > the moment, "2.7 and 3.4" is fine. If people want to use this with, > > > say, 3.3, then they're welcome to try, but they'll know not to presume > > > that it'll work. > > > > Even if you test on, say, 2.6, it is up to you whether you want to > > 'support' 2.6 with bugfixes, in case a patch for 2.7 does not work on 2.6. > > > > -- > > Terry Jan Reedy Hi Terry. Thanks so much for pointing all this out. I didn't know anything about the unicode builds problem. Will try to reproduce this bug even for self-learning purpose. By the way, I tested this app on Mac OSX and only one Linux distro (CentOS 5). Maybe Window is next. Regards. From nhatminh179 at gmail.com Tue Jul 15 23:30:45 2014 From: nhatminh179 at gmail.com (Orakaro) Date: Tue, 15 Jul 2014 20:30:45 -0700 (PDT) Subject: Twitter Client on Terminal by Python In-Reply-To: References: <5a2ece49-1b5a-41a5-99f1-e2c0e1bf96b8@googlegroups.com> Message-ID: <0492292c-8cfd-49dc-babc-2f3030fac2e3@googlegroups.com> On Tuesday, July 15, 2014 3:27:15 PM UTC+9, Omar Abou Mrad wrote: > Dear Orakaro, > > > Cool app you have there. Please consider the following comments as feedback in the most positive sense possible: > > > - I didn't care for the figlet, it's noise beyond anything else, if you drop it, you would drop the pyfiglet dependency as well > > - What's with the SQLAlchemy dependency? I checked your table definitions and if I'm not mistaken all you're using is Theme, Message, Tweet. My first question on that front is why are message and tweet stored locally? Are you doing local caching to speed things up? What about theme? > > > > Good job and take care! > > > Regards, > > > Omar > > > > On Sun, Jul 13, 2014 at 9:00 PM, Orakaro wrote: > > Hello! > > > > I'm @dtvd88 on Twitter and very new here. > > I read from python.org that anything Python-related can be discussed, and not sure if I can share my OSS package here to get feedback or not ? > > > > I just wrote a Twitter Client on Terminal by Python, it has very beautiful display and even can display image on terminal. Check it out and maybe you guys will love it :) > > > > Homepage: http://www.rainbowstream.org/ > > Github: https://github.com/DTVD/rainbowstream > > > > Thanks for any feedback and sorry if this kind of topics is not tolerated here. > > -- > > https://mail.python.org/mailman/listinfo/python-list Hi Omar. Thanks about the feedback. - The ascii art character... seems interesting to some people and not to others. Maybe I should add a config option for ignoring it. - I used 2 python process, ones handle the streaming API, ones listens to user's input as well as executes REST API and they need to share some variables. After tried ctypes, SyncManage or Queue, I found out that a database solution is easier and less buggy. So SQLAlchemy exists. - I only store Tweet and Message ID (not the content) locally and delete all when program exit. The reason is Twitter API's Tweet/Message ID is too long for user to type a command like "rep 489242568104095234 also like it!". In DB Tweet/Message ID is a small number which map 1-by-1 to the "real" Tweet/Message ID. - 2 process need to know the new theme when user type a command to change their current theme. So Theme exists in DB. Sorry for the long reply. Hope that there is a smarter solution and thanks very much again Regards From abhi.darkness at gmail.com Tue Jul 15 23:37:43 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 09:07:43 +0530 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 5:23 AM, Rick Johnson wrote: > On Tuesday, July 15, 2014 5:40:29 PM UTC-5, Abhiram R wrote: > > [snip excessive quotations] > > Aah. Understood. Apologies for the "noobishness" :) > > Noobishness can be tolerated for a "reasonable" time, > especially when the "noob" actively seeks to improve his > skills, as you are doing, so kudos to you. ?Thank you Rick :)? > The next skill to learn, after NOT top posting, is the art > of trimming quotations to the most relevant bits. You'll > have to use your own judgment for most quoted text, however, > if nothing else, be sure to remove any links to the quoted > persons web site or blog, and any "famous quotes". > > > Added to ?my TIL-list :D? ?? > > -- > https://mail.python.org/mailman/listinfo/python-list > -- Abhiram.R -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Tue Jul 15 23:51:56 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 03:51:56 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> Message-ID: <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Unicode strings in Python 2 are second class entities. > > I don't see that. They form a type just like, say, complex. I didn't say they were a second class type. I choose my words carefully, although I guess what I was trying to get across may have been a bit subtle, sorry about that. But if you read on, where I explain some of the consequences, it should be clear: Python 2.x has the assumption that strings are 8-bit deeply embedded in the compiler. >> It's not just that people will, in general, take the lazy way and write >> "foo" instead of u"foo" for their strings. > > People live with their choices, and I don't see the consequences of that > lazy way as very bad. The consequences are that it is too hard to write correct text handling code in Python 2, and too many programs which assume that text=ASCII as if it were 1965. In the same way that a language like Python is supposed to make it hard for programmers (good, lazy or careless programmers) to write code with (say) buffer overflow bugs, so a language like Python is supposed to make it hard for programmers to write code that assumes that text is 8-bit. It is disgraceful that in 2014 there are still languages like PHP that don't know how to handle text, and Python fortunately is not one of them. > In fact, I find the lazy use of Unicode strings at least as scary as the > lazy use of byte strings, especially since Python 3 sneaks Unicode to > the outer interfaces of the program (files, IPC). I'm not entirely sure I understand what you mean by "lazy use of Unicode strings". And I especially don't understand what you mean by "sneak". The fact that strings are Unicode is *the* biggest and most obvious new feature of Python 3. >> But it is that the whole Python virtual machine is based on >> byte-strings, not Unicode strings, and u"" strings are bolted on top. > > The internal implementation of the VM is free to change as long as the > external semantics stay the same. Which is the whole point. *They cannot*, or at least not without a level of effort far beyond what is reasonable for an all-volunteer effort. And even if they could, why bother when most developers will then ignore that and use "" byte strings because it saves one character typing? The Python devs aren't slaves, they get to choose what features they work on and which they don't. They don't owe *anybody* any feature they don't want to build, or care to support, and that includes continuing the 2.x series. That leaves you with choices: - You can follow the lead of the core developers and migrate to 3.x in your own time, when it works for you. - You can get enough people on the PSF board, and enough trusted, core developers, that the old guard get pushed out and you can take over and set the direction of Python development. - You can hunker down and stick with Python 2 forever, and do without free support after 2020. - You can stick with Python 2 until 2020, or pay for support until 2023, then reconsider the decision not to migrate. - You can fork Python and take over support of MyPython 2.7. - Or you can port your code to another language. Perhaps the *stupidest* thing the author of the "Python 3 is killing Python" blog post wrote was that it's easier to port Python code to a *completely different language*. I cannot fathom the idiocy of somebody who bitches and moans that having to re-write or redesign, oh, let's conservatively say 5% of your Python 2 code is harder than writing your code *completely from scratch* in a completely different language, with completely different third party libraries. And you can make that choice on a project-by-project basis. As of right now, *new* projects ought to be written in Python 3.3 or better, unless you have a compelling reason not to. You don't have to port old projects in order to take advantage of Python 3 for new projects. >> [steve at ando ~]$ python3.3 -c "? = 3.14; print(?+1)" 4.140000000000001 >> [steve at ando ~]$ python2.7 -c "? = 3.14; print(?+1)" >> File "", line 1 >> ? = 3.14; print(?+1) >> ^ >> SyntaxError: invalid syntax > > My native language uses ? and ?, but I don't see any pressing need to > embed those characters in identifiers. And good for you that you don't. I mean it. But there are 7 billion people in the world, and they're not all Python programmers, but most people are keen to program in their native tongues rather than English. >> Python 2 "helpfully" tries to guess what you want when you work with >> bytes-pretending-to-be-strings, and when it guesses right, it's nice, >> but when it guesses wrongly, you'll left with mysterious encoding and >> decoding errors from code that don't appear to involve either. The >> whole thing is a mess. > > I can't think of a matching example. [steve at ando ~]$ python2.7 -c "print u'?' + 'p'" ?p Where did the ? come from? [steve at ando ~]$ python3.3 -c "print('?' + 'p')" ?p -- Steven From barontronik at gmail.com Tue Jul 15 23:56:42 2014 From: barontronik at gmail.com (barontronik at gmail.com) Date: Tue, 15 Jul 2014 20:56:42 -0700 (PDT) Subject: ISO8583 Message-ID: <385182ab-db88-458d-8480-a1854125f50f@googlegroups.com> Hi, I'm very new to python programming. I would like to ask how come when I send ISO8583 to the server, I didn't get any response back. If I send it incorrect parameter, the server will reply but if I send it correctly, the server didn't response. The original client is in java using ISOMUX, I have been trying to use the pyMux.py that on the ISO8583 module but didn't succeed also. Right now i'm just using normal python socket and ISO8583 module. The original java ISOMUX code: ISOMUX isoMux = new ISOMUX(channel) { protected String getKey(ISOMsg m) throws ISOException { return m.getMTI().substring(0, 2) + m.getString(32) + m.getString(12); } }; Could someone give me example whether python have other method similar to ISOMUX? Thank you. From rosuav at gmail.com Wed Jul 16 00:20:37 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 14:20:37 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 16, 2014 at 1:51 PM, Steven D'Aprano wrote: > Perhaps the *stupidest* thing the author of the "Python 3 is killing > Python" blog post wrote was that it's easier to port Python code to a > *completely different language*. I cannot fathom the idiocy of somebody > who bitches and moans that having to re-write or redesign, oh, let's > conservatively say 5% of your Python 2 code is harder than writing your > code *completely from scratch* in a completely different language, with > completely different third party libraries. There's only one way that it's easier to port to a completely new language. Pick another language where string handling is as naive as my last boss (who told me to make sure that my code was "eight-bit clean, that is to say, Unicode safe", and used the words "Unicode" and "UTF-8" as synonymous), and then you can continue to stick your head in the sand and pretend that ASCII is what matters, that "special characters" work because of the magic of UTF-8, and that oh, yeah, I guess we'd better occasionally test our code with a few of those annoyingly different characters, but ehh, it doesn't really matter much. Having been guilty of something like that (actually, in one program I assumed all the incoming text was CP-1252, so it really *was* byte==char), I am extremely aware of the problems that it causes. But it does make initial coding a lot easier - at the expense of debugging later, when you discover that some things don't work. The Py3 approach forces you to fix things up-front, and that's hard! But then there are no bugs. I know which one I'd rather. ChrisA From rosuav at gmail.com Wed Jul 16 00:26:41 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 14:26:41 +1000 Subject: multiprocessing problem: queue.get() not finding pushed values In-Reply-To: <53C58FC8.2030202@earthlink.net> References: <53C58FC8.2030202@earthlink.net> Message-ID: On Wed, Jul 16, 2014 at 6:32 AM, Charles Hixson wrote: > from queue import Empty, Full Not sure what this is for, you never use those names (and I don't have a 'queue' module to import from). Dropped that line. In any case, I don't think it's your problem... > if __name__ == "__main__": > dbw = DBW(DBW_to, DBW_from) > dbw.run() > DBW_to.put(Msg("a", 1, wrd) ) > DBW_to.put(Msg("b", 2, wrd) ) > DBW_to.put(Msg("c", 0, None) ) ... which is here. You're not starting a subprocess; you're simply calling a method, so it runs synchronously. When you call .run(), it runs the "subprocess" to completion, which then bombs because the queue's empty, and then never gets to putting anything onto it. Change that .run() to .start() and it'll do as you expect, except that as part of cutting the example down you seem to have omitted the definition of wrd. I changed that to a quoted string and it works: # chomp unchanged code ... if __name__ == "__main__": dbw = DBW(DBW_to, DBW_from) dbw.start() DBW_to.put(Msg("a", 1, 'wrd') ) DBW_to.put(Msg("b", 2, 'wrd') ) DBW_to.put(Msg("c", 0, None) ) rosuav at sikorsky:~$ python test7a.py msg = Msg(act='a', id=1, vals='wrd') Hope that helps! ChrisA From gary.herron at islandtraining.com Wed Jul 16 00:39:57 2014 From: gary.herron at islandtraining.com (Gary Herron) Date: Tue, 15 Jul 2014 21:39:57 -0700 Subject: ISO8583 In-Reply-To: <385182ab-db88-458d-8480-a1854125f50f@googlegroups.com> References: <385182ab-db88-458d-8480-a1854125f50f@googlegroups.com> Message-ID: <53C6021D.3020407@islandtraining.com> On 07/15/2014 08:56 PM, barontronik at gmail.com wrote: > Hi, > > I'm very new to python programming. > I would like to ask how come when I send ISO8583 to the server, I didn't get any response back. This is not really a Python question, but should rather be asked of whoever created the ISO8583 module. Do you know how to contact the developers of the ISO8583 package? Gary Herron > > If I send it incorrect parameter, the server will reply but if I send it correctly, the server didn't response. > > The original client is in java using ISOMUX, I have been trying to use the pyMux.py that on the ISO8583 module but didn't succeed also. > > Right now i'm just using normal python socket and ISO8583 module. > > The original java ISOMUX code: > > ISOMUX isoMux = new ISOMUX(channel) > { > protected String getKey(ISOMsg m) > throws ISOException > { > return m.getMTI().substring(0, 2) + m.getString(32) + m.getString(12); > } > }; > > Could someone give me example whether python have other method similar to ISOMUX? > > Thank you. From marko at pacujo.net Wed Jul 16 01:52:31 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 08:52:31 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87egxl4zq8.fsf@elektro.pacujo.net> Steven D'Aprano : > On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: >> In fact, I find the lazy use of Unicode strings at least as scary as >> the lazy use of byte strings, especially since Python 3 sneaks >> Unicode to the outer interfaces of the program (files, IPC). > > I'm not entirely sure I understand what you mean by "lazy use of > Unicode strings". And I especially don't understand what you mean by > "sneak". The fact that strings are Unicode is *the* biggest and most > obvious new feature of Python 3. I mean that sys.stdin and sys.stdout should deal with byte strings. I mean that open(path) should open a file in binary mode. Thankfully, the subprocess methods exchange bytes by default. To me, the main difference between Python 2 and Python 3 is that in the former, I use "..." everywhere, and in the latter, I use b"..." everywhere. If I should need advanced text processing features, I'll go through a decode() and encode(). > The Python devs aren't slaves, they get to choose what features they > work on and which they don't. They don't owe *anybody* any feature > they don't want to build, or care to support, and that includes > continuing the 2.x series. No need to erect straw men. Of course, the Python gods do whatever they want. And you asked me to clarify my opinion, which I did. The breakage of backward compatibility wasn't worth the new features. But as I said, what is done is done. We'll live with the reality. > As of right now, *new* projects ought to be written in Python 3.3 or > better, unless you have a compelling reason not to. You don't have to > port old projects in order to take advantage of Python 3 for new > projects. But my distro only provides Python 3.2. What's wrong with Python 3.2? Why didn't anybody tell me to put off the migration? Marko From rosuav at gmail.com Wed Jul 16 02:26:03 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 16:26:03 +1000 Subject: Python 3 is killing Python In-Reply-To: <87egxl4zq8.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 3:52 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: >>> In fact, I find the lazy use of Unicode strings at least as scary as >>> the lazy use of byte strings, especially since Python 3 sneaks >>> Unicode to the outer interfaces of the program (files, IPC). >> >> I'm not entirely sure I understand what you mean by "lazy use of >> Unicode strings". And I especially don't understand what you mean by >> "sneak". The fact that strings are Unicode is *the* biggest and most >> obvious new feature of Python 3. > > I mean that sys.stdin and sys.stdout should deal with byte strings. I > mean that open(path) should open a file in binary mode. Thankfully, the > subprocess methods exchange bytes by default. Let's take a step back from the standard I/O streams and look at this one concept: Asking the user to enter his/her name. The user will have a name which consists of characters (at least, we hope so; cases where this is not true do exist, but are outside the scope of this discussion), not bytes. The program wants to use those characters, not bytes. If I create a window with tkinter and ask the user to enter a name, I'll get back a Unicode string: http://www.python-course.eu/tkinter_entry_widgets.php (By the way, this suffers from the common flaw of asking for separate first and last names. That's not reliable in terms of people's names, but it's no different in terms of bytes and strings.) (Also by the way, why is a Python course advertising that its web site is written in PHP?) Whether I use Python 2 (changing the import to Tkinter) or Python 3 (running the code unchanged), I get back a Unicode string (easily proven by looking at its repr() in show_entry_fields()), because the user typed *text* into the widget. This is what everyone will expect. Now, the standard I/O streams might be connected to a console, or might be reading from a pipe. This does add a level of complexity, as it's possible to read either text or bytes from them; but Python defaults to the most common case, where they're connected to a console, and does its best to allow print() to write Unicode to any console. (With limited success on some consoles; Windows' cmd.exe has problems. That's not Python's fault.) If you want binary, you can easily switch to binary mode. Maybe it would be better to have a simple function "change standard stream(s) to binary", but the default is still correct: most of the time, you want to work with text. > To me, the main difference between Python 2 and Python 3 is that in the > former, I use "..." everywhere, and in the latter, I use b"..." > everywhere. If I should need advanced text processing features, I'll go > through a decode() and encode(). Why do you work with the underlying representation (bytes) instead of the abstraction (strings)? To be consistent, you should probably eschew Python dictionaries in favour of a manually-implemented hashtable, and studiously avoid Python source code by hand-writing CPython bytecode. >> As of right now, *new* projects ought to be written in Python 3.3 or >> better, unless you have a compelling reason not to. You don't have to >> port old projects in order to take advantage of Python 3 for new >> projects. > > But my distro only provides Python 3.2. What's wrong with Python 3.2? > Why didn't anybody tell me to put off the migration? It's pretty easy to spin up a CPython 3.4 for Debian Wheezy. Or you might be able to just grab a package from Jessie, where CPython 3.4 is standard. Debian, like Red Hat, values stability over currency, so once Wheezy went into freeze on 2012-06-30 [1], the current-at-the-time Python was locked in (Python 3.3 wasn't released until 2012-09-29 [2]), in order to allow packages to depend on it and be able to trust it. (It's possible you're not on Debian Wheezy, but on some other distro that also ships 3.2 with its current release. The policies are likely to be similar.) ChrisA [1] https://wiki.debian.org/DebianWheezy [2] https://www.python.org/download/releases/3.3.0/ From marko at pacujo.net Wed Jul 16 02:44:39 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 09:44:39 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <87a9894xbc.fsf@elektro.pacujo.net> Chris Angelico : > Python defaults to the most common case, where they're connected to a > console, and does its best to allow print() to write Unicode to any > console. I don't know where you pull your statistics. Be that as it may, the main purpose of sys.stdin is to receive the workload and sys.stdout to deliver the goods. Marko From rosuav at gmail.com Wed Jul 16 02:50:26 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 16:50:26 +1000 Subject: Python 3 is killing Python In-Reply-To: <87a9894xbc.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <87a9894xbc.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 4:44 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Python defaults to the most common case, where they're connected to a >> console, and does its best to allow print() to write Unicode to any >> console. > > I don't know where you pull your statistics. Heaps and HEAPS of personal experience, of myself and many other people. I frequently run programs that manipulate text and work with a console that displays text, which means that a consistent encoding (usually UTF-8) can be hidden away as an implementation detail. As long as the console correctly announces the encoding it expects and the program correctly writes in that encoding, all is well, and the program can simply "write text to the console". > Be that as it may, the main purpose of sys.stdin is to receive the > workload and sys.stdout to deliver the goods. Yes, but is that workload text or bytes? To be sure, there are programs whose stdin is usually or always bytes, but most use text. The default should be the most common and most useful option, and the alternative should be available when you want it. ChrisA From charleshixsn at earthlink.net Wed Jul 16 01:47:10 2014 From: charleshixsn at earthlink.net (Charles Hixson) Date: Tue, 15 Jul 2014 22:47:10 -0700 Subject: multiprocessing problem: queue.get() not finding pushed values In-Reply-To: References: <53C58FC8.2030202@earthlink.net> Message-ID: <53C611DE.7090604@earthlink.net> On 07/15/2014 09:26 PM, Chris Angelico wrote: > On Wed, Jul 16, 2014 at 6:32 AM, Charles Hixson > wrote: >> from queue import Empty, Full > Not sure what this is for, you never use those names (and I don't have > a 'queue' module to import from). Dropped that line. In any case, I > don't think it's your problem... > >> if __name__ == "__main__": >> dbw = DBW(DBW_to, DBW_from) >> dbw.run() >> DBW_to.put(Msg("a", 1, wrd) ) >> DBW_to.put(Msg("b", 2, wrd) ) >> DBW_to.put(Msg("c", 0, None) ) > ... which is here. You're not starting a subprocess; you're simply > calling a method, so it runs synchronously. When you call .run(), it > runs the "subprocess" to completion, which then bombs because the > queue's empty, and then never gets to putting anything onto it. Change > that .run() to .start() and it'll do as you expect, except that as > part of cutting the example down you seem to have omitted the > definition of wrd. I changed that to a quoted string and it works: > > # chomp unchanged code ... > if __name__ == "__main__": > dbw = DBW(DBW_to, DBW_from) > dbw.start() > DBW_to.put(Msg("a", 1, 'wrd') ) > DBW_to.put(Msg("b", 2, 'wrd') ) > DBW_to.put(Msg("c", 0, None) ) > > rosuav at sikorsky:~$ python test7a.py > msg = Msg(act='a', id=1, vals='wrd') > > Hope that helps! > > ChrisA Thank you. I had forgotten that one wasn't supposed to call run directly. FWIW, I import Empty and Full because the multiprocessor documentations says in 17.2.2.2. Pipes and Queues Note multiprocessing uses the usual queue.Empty and queue.Full exceptions to signal a timeout. They are not available in the multiprocessing namespace so you need to import them from queue . They aren't used in the stripped down test, but they are used in the real code -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From shieldfire at gmail.com Wed Jul 16 03:05:33 2014 From: shieldfire at gmail.com (Martin S) Date: Wed, 16 Jul 2014 09:05:33 +0200 Subject: Thanks for the help Message-ID: I completed the basic version of my learning app. (It can be found here for those remotely interested: http://www.tyresoschack.se/apps/LASK.py). (LASK rating usually are in the range c 800 to c 2700 the higher the better). It's just a simple tool to calculate LASK chess rating and completely CLI based. The tutorial I was following doesn't cover GUI or error correction so that will naturally be the next steps in completing the thing. Anyway, thanks for explaining the confusing points so far. Regards, Martin S From wxjmfauth at gmail.com Wed Jul 16 03:11:57 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Wed, 16 Jul 2014 00:11:57 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <87egxl4zq8.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: Le mercredi 16 juillet 2014 07:52:31 UTC+2, Marko Rauhamaa a ?crit : > Steven D'Aprano : > > > > > On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: > > >> In fact, I find the lazy use of Unicode strings at least as scary as > > >> the lazy use of byte strings, especially since Python 3 sneaks > > >> Unicode to the outer interfaces of the program (files, IPC). > > > > > > I'm not entirely sure I understand what you mean by "lazy use of > > > Unicode strings". And I especially don't understand what you mean by > > > "sneak". The fact that strings are Unicode is *the* biggest and most > > > obvious new feature of Python 3. > > > > I mean that sys.stdin and sys.stdout should deal with byte strings. I > > mean that open(path) should open a file in binary mode. Thankfully, the > > subprocess methods exchange bytes by default. > > > > To me, the main difference between Python 2 and Python 3 is that in the > > former, I use "..." everywhere, and in the latter, I use b"..." > > everywhere. If I should need advanced text processing features, I'll go > > through a decode() and encode(). > > > > > The Python devs aren't slaves, they get to choose what features they > > > work on and which they don't. They don't owe *anybody* any feature > > > they don't want to build, or care to support, and that includes > > > continuing the 2.x series. > > > > No need to erect straw men. Of course, the Python gods do whatever they > > want. And you asked me to clarify my opinion, which I did. The breakage > > of backward compatibility wasn't worth the new features. > > > > But as I said, what is done is done. We'll live with the reality. > > > > > As of right now, *new* projects ought to be written in Python 3.3 or > > > better, unless you have a compelling reason not to. You don't have to > > > port old projects in order to take advantage of Python 3 for new > > > projects. > > > > But my distro only provides Python 3.2. What's wrong with Python 3.2? > > Why didn't anybody tell me to put off the migration? > > > > > > Marko ----------- >From a unicode perspective, Py32 is the best Python. (Yes it's ucs2). (From a BDFL example) >>> sys.version_info sys.version_info(major=3, minor=2, micro=5, releaselevel='final', serial=0) >>> timeit.repeat("a = 'hundred'; 'x' in a") [0.09090468709446498, 0.07743860966057525, 0.07695655307486504] >>> timeit.repeat("a = 'hundre EURO'; 'x' in a") [0.09373873872100091, 0.07633783502242864, 0.0762649751626725] sys.version_info sys.version_info(major=3, minor=4, micro=0, releaselevel='final', serial=0) timeit.repeat("a = 'hundred'; 'x' in a") [0.1174619090622306, 0.09338822371994088, 0.09350361798433393] timeit.repeat("a = 'hundre EURO'; 'x' in a") [0.2306057883810979, 0.21599837108983877, 0.2168407886036121] >>> sys.version_info sys.version_info(major=3, minor=4, micro=0, releaselevel='final', serial=0) >>> sys.getsizeof('hundred') 32 >>> sys.getsizeof('hundre EURO') 52 >>> sys.getsizeof('hundred') 44 >>> sys.getsizeof('hundre EURO') 44 Just an illustration of a systematical behaviour. Not only Py32 works much better than Py33+, it works much better for non ascii users! The Py devs succeeded to transform Python into a ascii product! In my mind, it would be nicer to spend time in solving bugs, instead of reinventing "unicode". And before reinventing "unicode", it would be good to undersand it (I fell by chance on a video: "The Guts of Unicode in Python"). Hobbyist tools will alway stay hobbyist tools. ------ Something different, "micropython". Luckily they are people who are understanding "unicode" as whole very correctly and are not following py devs advices. I'm thinking about this UEFI stuff. It is beyond my knowledge. it seems to me that it is a similar situation. jmf From steve at pearwood.info Wed Jul 16 03:33:03 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 07:33:03 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53c62aaf$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 14:20:37 +1000, Chris Angelico wrote: > On Wed, Jul 16, 2014 at 1:51 PM, Steven D'Aprano > wrote: >> Perhaps the *stupidest* thing the author of the "Python 3 is killing >> Python" blog post wrote was that it's easier to port Python code to a >> *completely different language*. I cannot fathom the idiocy of somebody >> who bitches and moans that having to re-write or redesign, oh, let's >> conservatively say 5% of your Python 2 code is harder than writing your >> code *completely from scratch* in a completely different language, with >> completely different third party libraries. > > There's only one way that it's easier to port to a completely new > language. Pick another language where string handling is as naive as my > last boss But even then, you still have to re-write all your code in the new language. Using different libraries. All your unit tests are obsolete (although your integration tests may not be). End-user documentation will probably be re-usable, but documentation aimed at your developers will need to be re-written. -- Steven From greg.ewing at canterbury.ac.nz Wed Jul 16 03:40:44 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Wed, 16 Jul 2014 19:40:44 +1200 Subject: Mac python py2app problem In-Reply-To: References: Message-ID: Kevin Walzer wrote: > On 7/15/14, 9:56 PM, Nicholas Cannon wrote: > > I then put the .msi on sourceforge and it works great >> but when i put the .app on there and download it it says something >> like i can open this on old architecture or something so i have to put >> it through google drive > > It's hard to make sense of what you are asking for. Can you just zip up > the app bundle that py2app produces and upload it that way? Are you aware that a .app on MacOSX is actually a directory, not a single file? So, as Kevin says, you will need to turn it into a zip file or something similar that you can upload to a web site. Another popular way to distribute a MacOSX app is using a disk image file (.dmg). Disk Utility can be used to create those. -- Greg From steve at pearwood.info Wed Jul 16 03:49:19 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 07:49:19 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 08:52:31 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: >>> In fact, I find the lazy use of Unicode strings at least as scary as >>> the lazy use of byte strings, especially since Python 3 sneaks Unicode >>> to the outer interfaces of the program (files, IPC). >> >> I'm not entirely sure I understand what you mean by "lazy use of >> Unicode strings". And I especially don't understand what you mean by >> "sneak". The fact that strings are Unicode is *the* biggest and most >> obvious new feature of Python 3. > > I mean that sys.stdin and sys.stdout should deal with byte strings. There are certainly use-cases for stdin and stdout to use bytes, but there are also use-cases for them to deal with strings. I'll certainly grant you that there ought to be an easy way to get access to the binary streams, but I think for a high-level language like Python, the default should be text, not bytes. > I mean that open(path) should open a file in binary mode. Thankfully, > the subprocess methods exchange bytes by default. Likewise for files: by default, I should be able to do this: open("foo.txt", "w").write("foo bar baz") and have something sensible happen. Although I'm open to the suggestion that maybe the Pythonic way to do that should be: print("foo bar baz", file="foo.txt") Most programming languages I know of default to opening files in text mode, not binary mode, and I don't see any strong reason for Python to go against the tide there. And I don't have an opinion on the subprocess module. > To me, the main difference between Python 2 and Python 3 is that in the > former, I use "..." everywhere, and in the latter, I use b"..." > everywhere. If I should need advanced text processing features, I'll go > through a decode() and encode(). Having len('?') == 1 is not an advanced text processing feature. [...] >> As of right now, *new* projects ought to be written in Python 3.3 or >> better, unless you have a compelling reason not to. You don't have to >> port old projects in order to take advantage of Python 3 for new >> projects. > > But my distro only provides Python 3.2. What's wrong with Python 3.2? > Why didn't anybody tell me to put off the migration? Nothing is "wrong" with Python 3.2, except in the sense that it's now about 3 years old there are better versions (3.3 and 3.4) to choose from. If you're wedded to the idea of only using the version of Python that your distro supports, you may find yourself a version or four behind the latest release. (Red Hat only recently stopped supporting a distro where the system python was 2.3. Yay.) -- Steven From breamoreboy at yahoo.co.uk Wed Jul 16 04:18:19 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 16 Jul 2014 09:18:19 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 16/07/2014 00:53, Rick Johnson wrote: Another thing that irritates is those people who insist on shouting LIKE THIS throughout their posts. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Wed Jul 16 04:44:38 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 18:44:38 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 16, 2014 at 5:49 PM, Steven D'Aprano wrote: > ... Although I'm open to the suggestion > that maybe the Pythonic way to do that should be: > > print("foo bar baz", file="foo.txt") > And I would argue against that suggestion, having worked with a language where that's the case. In REXX, you write to files using the LINEOUT and CHAROUT functions (the former adds end-of-line after its written content, the latter doesn't): call lineout "foo.txt","foo bar baz" /* or */ call charout "foo.txt","foo bar " call lineout "foo.txt","baz" And correspondingly, CHARIN and LINEIN to read from files. This is nice and convenient, but it has a number of problems: 1) Hidden global state. Somewhere there's a mapping of file names to open file handles, and it's not obvious. 2) Corollary: Surprising behaviour if you try to use a file twice in one program. 3) Closing a file is sometimes unobvious. If you terminate the program with open files, there's no problem, but if the program keeps running, its files stay open. 4) Very VERY occasionally, you might run into a problem with too many open files. (It should be noted that I learned REXX back in the 90s. It's entirely possible that "too many open files" would be at some insanely ridiculous number now.) At that point, you need to close something... but how can you know? Here's a REXX-style set of functions, implemented in Python: # files.py _filemap = {} def _open(fn, mode): _filemap[fn] = open(fn, mode) def charout(fn, s): if fn not in _filemap: _open(fn, "w") _filemap[fn].write(s) def lineout(fn, s): charout(fn, s+"\n") def charin(fn, n=1): if fn not in _filemap: _open(fn, "r") return _filemap[fn].read(n) # Okay, the stream() function does a *lot* more than # closing files, but that's all I'm implementing. def stream(fn, *args): if args != ["c","close"]: raise NotImplemented del _filemap[fn] That's more-or-less how REXX does things. There are a lot more complications (I didn't implement LINEIN, which requires buffering - more global state), but that's the basic layout. Now, that's already scaring you a bit (all that global state!), but it gets worse: you either have heaps of duplication all through your code (repeating the file name in every output statement), or you have a variable with the file name that functions as a cookie - it's the same as a file handle integer, or a FILE *fp with the C stdio library, or a file object in Python, or anything like that. Usage would be like this: fn = "foo.txt" print("foo bar baz", file=fn) print("hello, world", file=fn) close_file(fn) Which has no significant improvement over the current: f = open("foo.txt", "w") print("foo bar baz", file=f) print("hello, world", file=f) f.close() And it's worse, because if you put this into a function and return early from it, the second form will garbage-collect f and close the file, but the first form won't. That's a recipe for surprises down the track. There is a use-case where this is an improvement: you can have a function that writes to a log file or something, and it doesn't need to monitor state: def some_func(...) do_stuff() if condition: print(some_state, file="some.log") do_more_stuff() With Python's normal style, this would need to either keep on opening and closing the file (slow and inefficient), or keep track of an open file object somewhere (global state). If you're going to have global state anyway, then it's easier to push it to someone else. But I'd much rather NOT have that state... not to mention the potential problems from having aliases to the file. I've never tried, for instance, opening a file using two equivalent names, but it'd probably open the file twice. Even more confusion. It's great to be open to suggestions. It's great to be able to discuss them and figure out which ones are actually worth pursuing :) ChrisA From kwpolska at gmail.com Wed Jul 16 06:20:44 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Wed, 16 Jul 2014 12:20:44 +0200 Subject: Python 3 is killing Python In-Reply-To: <53C5DC04.9070600@mrabarnett.plus.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53C5DC04.9070600@mrabarnett.plus.com> Message-ID: A little more off-topic: On Wed, Jul 16, 2014 at 3:57 AM, MRAB wrote: > On 2014-07-16 00:53, Rick Johnson wrote: >> Some folks even have software that "blabs" about how great a job it >> is doing [?], so if you see [?] some pretentious line >> about "this was sent from my i-phone" -- send that crap to the >> bitbucket! >> > "This was sent from my iPhone" == "I have an iPhone!" I personally parse those lines as ?sent from my iPhone, which has an on-screen touch keyboard, and it?s harder to type on it?. > Also annoying is some footnote that says that the email contains > confidential information and that if you're not the intended recipient > you should delete it, etc. > > That's somewhat pointless if it's being sent to a public forum! Corporate lawyers for the win! 99.9% of people who send e-mail with this line are forced to do so by their corporation?s legal department. Also, the correct solution for all those is getting a sane client that can hide quotes and signatures. Like Gmail (which defaults to top-posting, but fixing this is one click per message away*). And if someone brings the ?people need to download it anyway? argument: it?s 2014, people: hard-drives are large nowadays (or you can just use IMAP) and if you?re paying $100 per kilobyte, you?re doing it wrong and should not be online in the first place. * trickier on mobile, though. -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From marko at pacujo.net Wed Jul 16 06:46:45 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 13:46:45 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: <871ttlfune.fsf@elektro.pacujo.net> Steven D'Aprano : > Likewise for files: by default, I should be able to do this: > > open("foo.txt", "w").write("foo bar baz") > > and have something sensible happen. I'd prefer: open("foo.txt", "wt").write("foo bar baz") or: open("foo.txt", "w", encoding="utf-8").write("foo bar baz") or: open("foo.txt", "w").write("foo bar baz".encode()) Python 3 really is on a mission to elevate text into the mainstream at the expense of bytes. I'm guessing this is done primarily to promote the cross-platform transparency of Python code. For me, a linux system and network programmer, that layer of frosting only gets in my way and I need to wash it off. > Most programming languages I know of default to opening files in text > mode, not binary mode, and I don't see any strong reason for Python to > go against the tide there. In unix and linux, there never was a separate text mode for files. When you open a file, you open a file -- and stuff bytes in it. There is no commonly accepted text file encoding. UTF-8 comes close to being a standard, but I know somebody who sticks to an ISO-8859-1 locale. > Having len('?') == 1 is not an advanced text processing feature. There are (relative rare) occasions where you'd like to treat text as text. Then, it's nice to be able to move the data on the operating table with .decode() and when the patient has been sewn back together, you can release them with .encode(). More often, len(b'?') is what I want. Marko From steve+comp.lang.python at pearwood.info Wed Jul 16 07:35:40 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 11:35:40 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53c6638b$0$9505$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 18:44:38 +1000, Chris Angelico wrote: > On Wed, Jul 16, 2014 at 5:49 PM, Steven D'Aprano > wrote: >> ... Although I'm open to the suggestion that maybe the Pythonic way to >> do that should be: >> >> print("foo bar baz", file="foo.txt") >> >> > And I would argue against that suggestion, having worked with a language > where that's the case. [...] > 1) Hidden global state. Somewhere there's a mapping of file names to > open file handles, and it's not obvious. Absolutely not! What do you take me for, the designer of REXX??? :-P What I had in mind was for print to open the file in append mode, write, then close the file. Something like this: def print(*values, sep=' ', end='\n', file=sys.stdout, flush=False): def write(f): for value in values: f.write(str(value) + sep) f.write(end) if flush: f.flush() if isinstance(file, (str, bytes)): with open(file, 'a') as f: write(f) else: write(f) The downside of this is that it doesn't handle encodings and error handlers, or any of the other, more obscure, arguments to open(). But since print is intended as a convenience function, I'm okay with that. If you need more than the default settings, you should open the file yourself: f = open('something.txt', 'w', encoding='UTF=32') print("fe fi fo fum", file=f) > 2) Corollary: Surprising > behaviour if you try to use a file twice in one program. Not with my idea. The only surprises are if you try to use it with the filename from different threads, but that's a relatively advanced thing to do. If you're using print from two threads at once, don't pass a file name. > 3) Closing a file is sometimes unobvious. If you terminate the program > with open files, there's no problem, but if the program keeps running, > its files stay open. > 4) Very VERY occasionally, you might run into a problem with too many > open files. (It should be noted that I learned REXX back in the 90s. > It's entirely possible that "too many open files" would be at some > insanely ridiculous number now.) At that point, you need to close > something... but how can you know? Neither of these will be a problem. Well, technically, if you opened like a million threads, and had every thread try to print to a different file name at the same time, that could be a problem. But if you're doing that, you deserve whatever happens. ;-) -- Steven From rosuav at gmail.com Wed Jul 16 07:54:21 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 21:54:21 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c6638b$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <53c6638b$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 16, 2014 at 9:35 PM, Steven D'Aprano wrote: > What I had in mind was for print to open the file in append mode, write, > then close the file. Ahh, okay. Very different from what I thought you were talking about, and distinctly different in behaviour from REXX :) In that case, it avoids the problems that I described, at the expense of being potentially an attractive nuisance - imagine code like this: for line in open("input.txt"): print(transform(line), file="output.txt") Looks like a really nice clean way to process a file, right? But it's going to be horrendously slow. Actually, this could be quite reasonably added as a feature of print(). Could be monkey-patched in fairly easily _origprint = print def print(*a, **kw): if isinstance(kw.get("file"), (str, bytes)): with open(kw["file"], 'a') as f: kw["file"] = f _origprint(*a, **kw) else: _origprint(*a, **kw) And it'd have its uses. The only risk would be if there's a file-like object that's a subclass of either str or bytes, which admittedly *is* theoretically possible... ChrisA From steve+comp.lang.python at pearwood.info Wed Jul 16 08:10:16 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 16 Jul 2014 12:10:16 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> Message-ID: <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 13:46:45 +0300, Marko Rauhamaa wrote: > Python 3 really is on a mission to elevate text into the mainstream at > the expense of bytes. I'm guessing this is done primarily to promote the > cross-platform transparency of Python code. Ahead of bytes? Possibly. At the expense of bytes? Certainly not. If there is anything that you cannot conveniently do with bytes, that you could do in Python 2, it's likely a bug, or at least an obviously missing feature. The core devs recognise that they missed some use-cases (e.g. mixed bytes and text) which is now harder than it should be, and are on a mission to rectify that as much as possible within the constraints of backward compatibility. E.g. having b"abc"[0] return 97 instead of b"a" was probably a mistake, but there are four versions of Python 3.x that do it that way and it's too late to change until Python 5000. (Python 4 is unlikely to break backwards compatibility in a big way.) > For me, a linux system and network programmer, that layer of frosting > only gets in my way and I need to wash it off. Linux, like all Unixes, is primarily a text-based platform. With a few exceptions, /etc is filled with text files, not binary files, and half the executables on the system are text (Python, Perl, bash, sh, awk, etc.). www.catb.org/esr/writings/taoup/html/ch05s01.html To say that *dealing with text* gets in your way on a Linux system is rather like saying that you love Mac OS X except for its gosh-awful GUI and APIs. Of course, as a network programmer, you have to deal with bytes, so I'll give you a bit of leeway. >> Most programming languages I know of default to opening files in text >> mode, not binary mode, and I don't see any strong reason for Python to >> go against the tide there. > > In unix and linux, there never was a separate text mode for files. When > you open a file, you open a file -- and stuff bytes in it. There is no > commonly accepted text file encoding. UTF-8 comes close to being a > standard, but I know somebody who sticks to an ISO-8859-1 locale. And they should be dragged out into the street and beaten with a Clue Stick. They're the sort of people who are holding us back from the shining utopia of UTF-8 everywhere! (only half joking) But seriously, I cannot imagine any *rational* reason for using a legacy encoding, but I'm willing to give this person the benefit of the doubt that he's not a raving lunatic or old West European-centric curmudgeon trying to deny the existence of the rest of the world. http://i.imgur.com/UeZan.jpg That being the case, then good luck to him. As far as everyone else: http://www.utf8everywhere.org/ >> Having len('?') == 1 is not an advanced text processing feature. > > There are (relative rare) occasions where you'd like to treat text as > text. o_O Relatively rare. Like, um, email, news, html, Unix config files, Windows ini files, source code in just about every language ever, SMSes, XML, JSON, YAML, instant messenger apps, word processors... even *graphic* applications invariably have a text tool. Now, it may be true that some of those things may not use text under the hood, but even so, text is ubiquitous. Even binary protocols often include chunks of recognisable human-readable text in them: [steve at ando Pictures]$ hexdump -n 64 -C picture.jpg 00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 01 00 00 01 |......JFIF......| 00000010 00 01 00 00 ff e2 0f 38 49 43 43 5f 50 52 4f 46 |.......8ICC_PROF| 00000020 49 4c 45 00 01 01 00 00 0f 28 61 70 70 6c 02 10 |ILE......(appl..| 00000030 00 00 6d 6e 74 72 52 47 42 20 58 59 5a 20 07 de |..mntrRGB XYZ ..| 00000040 > Then, it's nice to be able to move the data on the operating table > with .decode() and when the patient has been sewn back together, you can > release them with .encode(). > > More often, len(b'?') is what I want. Oh really? Are you sure? What exactly is b'?'? I couldn't have made up a better example of the confusion between bytes and text if I had tried. Thank you. -- Steven From rosuav at gmail.com Wed Jul 16 08:55:54 2014 From: rosuav at gmail.com (Chris Angelico) Date: Wed, 16 Jul 2014 22:55:54 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Wed, Jul 16, 2014 at 10:10 PM, Steven D'Aprano wrote: > Linux, like all Unixes, is primarily a text-based platform. With a few > exceptions, /etc is filled with text files, not binary files, and half > the executables on the system are text (Python, Perl, bash, sh, awk, > etc.). An interesting assertion. I know "half" is not meant to be an actual estimate, but out of curiosity, I whipped up a quick script to figure out just how many of my executables are text and how many aren't. #!/usr/bin/env python3 import os, subprocess text = binary = unknown = unreadable = 0 for path in os.environ["PATH"].split(":"): for file in os.listdir(path): fn = os.path.join(path, file) try: t = subprocess.check_output(["file", "-L", fn]) except subprocess.CalledProcessError: print("Unreadable: %s" % fn) unreadable += 1 continue if isinstance(t, bytes): t = t.decode("ascii") # Now to try to figure out what's text and what's binary. if "text" in t: # Most Unixes follow the convention of having "text" in # the output of all files that can be safely blatted to # a terminal - for instance, "ASCII text executable" is # used to describe most shell scripts etc; this file is # a "Python script, ASCII text executable". If I put in # a non-ASCII char, the 'file' descr becomes changes to # "Python script, UTF-8 Unicode text executable". text += 1 elif "directory" in t: # Ignore directories. pass elif "LSB executable" in t or "LSB shared object" in t: binary += 1 else: print(t.strip()) unknown += 1 print("%d text, %d binary" % (text, binary)) if unknown: print("Also %d unknowns, which are probably binary." % unknown) if unreadable: print("Plus %d files that couldn't be read." % unreadable) On my system, it says: rosuav at sikorsky:~$ python3 exectypes.py /usr/local/bin/youtube-dl: data Unreadable: /usr/bin/wine-safe /usr/bin/mptopdf: LaTeX auxiliary file, /usr/bin/gvfs-less: Palm OS dynamic library data "#!/bin/sh" Unreadable: /usr/bin/gserialver 1140 text, 2060 binary Also 3 unknowns, which are probably binary. Plus 2 files that couldn't be read. So a bit more than a third of my executables are text. That's a pretty high proportion, and not very far off the rough guesstimate of half. (And I tried this on three other Linuxes I have around the house, getting broadly the same proportion, although the numbers are quite different.) ChrisA From wxjmfauth at gmail.com Wed Jul 16 09:10:33 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Wed, 16 Jul 2014 06:10:33 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <900505a4-dd65-473f-a092-2973e5d6d56e@googlegroups.com> Le mercredi 16 juillet 2014 14:10:16 UTC+2, Steven D'Aprano a ?crit : > ... You are right iso-8859-1 is a plague. py340 >>> timeit.repeat("'abc'.find('z')") [0.3915996913892741, 0.3671049942086313, 0.3669506100733315] >>> timeit.repeat("'abc'.find('oe')") [0.5678031885837811, 0.5447948325424363, 0.5424782828388004] note py325 >>> timeit.repeat("'abc'.find('z')") [0.34638522543825445, 0.32732154158861704, 0.3253417225882629] >>> timeit.repeat("'abc'.find('oe')") [0.3162405415102256, 0.3027008165424263, 0.30290324880145647] py340 >>> sys.getsizeof('z'*123 + 'z') 149 >>> sys.getsizeof('z'*123 + 'oe') 286 py325 >>> sys.getsizeof('z'*123 + 'z') 278 >>> sys.getsizeof('z'*123 + 'oe') 278 Brillant no? jmf From marko at pacujo.net Wed Jul 16 09:11:26 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 16:11:26 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <87sim1e9dt.fsf@elektro.pacujo.net> Steven D'Aprano : > With a few exceptions, /etc is filled with text files, not binary > files, and half the executables on the system are text (Python, Perl, > bash, sh, awk, etc.). Our debate seems to stem from a different idea of what text is. To me, text in the Python sense is a sequence of UCS-4 character code points. The opposite of text is not necessarily binary. Most of those "text" files under /etc expect ASCII. In many contexts, they tolerate UTF-8 or Latin-3 or whatever, but it's a bit iffy (how are extra-ASCII passwords encoded in the /etc/shadow?). Also, the files under /etc, /var/log etc should not depend on the locale since they are typically interpreted by daemons, which typically don't possess locales. > Relatively rare. Like, um, email, news, html, Unix config files, > Windows ini files, source code in just about every language ever, > SMSes, XML, JSON, YAML, instant messenger apps, I would be especially wary of letting Python 3 interpret those files for me. Python's [text] strings could be a wonderful tool on the inside of my program, but I definitely would like to micromanage the I/O. Do I obey the locale or not? That's too big (and painful) a question for Python to answer on its own (and pretend like everything's under control). > word processors... even *graphic* applications invariably have a text > tool. Thing is, the serious text utilities like word processors probably need lots of ancillary information so Python's [text] strings might be too naive to represent even a single character. >> More often, len(b'?') is what I want. > > Oh really? Are you sure? What exactly is b'?'? That's something that ought to work in the UTF-8 paradise. Unfortunately, Python only allows ASCII in bytes. ASCII only! In this day and age! Even C is not so picky: #include int main() { printf("Hyv?? y?t?\n"); return 0; } Marko From wxjmfauth at gmail.com Wed Jul 16 09:22:46 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Wed, 16 Jul 2014 06:22:46 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <87sim1e9dt.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> Message-ID: Le mercredi 16 juillet 2014 15:11:26 UTC+2, Marko Rauhamaa a ?crit?: > Steven D'Aprano : > > > > > With a few exceptions, /etc is filled with text files, not binary > > > files, and half the executables on the system are text (Python, Perl, > > > bash, sh, awk, etc.). > > > > Our debate seems to stem from a different idea of what text is. To me, > > text in the Python sense is a sequence of UCS-4 character code points. > > The opposite of text is not necessarily binary. > > > > Most of those "text" files under /etc expect ASCII. In many contexts, > > they tolerate UTF-8 or Latin-3 or whatever, but it's a bit iffy (how are > > extra-ASCII passwords encoded in the /etc/shadow?). Also, the files > > under /etc, /var/log etc should not depend on the locale since they are > > typically interpreted by daemons, which typically don't possess locales. > > > > > Relatively rare. Like, um, email, news, html, Unix config files, > > > Windows ini files, source code in just about every language ever, > > > SMSes, XML, JSON, YAML, instant messenger apps, > > > > I would be especially wary of letting Python 3 interpret those files for > > me. Python's [text] strings could be a wonderful tool on the inside of > > my program, but I definitely would like to micromanage the I/O. Do I > > obey the locale or not? That's too big (and painful) a question for > > Python to answer on its own (and pretend like everything's under > > control). > > > > > word processors... even *graphic* applications invariably have a text > > > tool. > > > > Thing is, the serious text utilities like word processors probably need > > lots of ancillary information so Python's [text] strings might be too > > naive to represent even a single character. > > > > >> More often, len(b'?') is what I want. > > > > > > Oh really? Are you sure? What exactly is b'?'? > > > > That's something that ought to work in the UTF-8 paradise. > > Unfortunately, Python only allows ASCII in bytes. ASCII only! In this > > day and age! Even C is not so picky: > > > > #include > > > > int main() > > { > > printf("Hyv?? y?t?\n"); > > return 0; > > } > > > > > > Marko -------- And if you are visiting, spying the bugs tracker, dev lists and ... you will happily, this perpertual way of thinking: if ascii: do stuff else: find a work around It's quite funny for a tool which pretends to live in the unicode world. jmd From fomcl at yahoo.com Wed Jul 16 09:29:22 2014 From: fomcl at yahoo.com (Albert-Jan Roskam) Date: Wed, 16 Jul 2014 06:29:22 -0700 Subject: how to msi install Python to non-default target dir? Message-ID: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> hi, I am trying to create a .bat file where (among other things) Python will have to be silently installed. It needs to be installed to the non-default location "c:\program files\python27". Any idea how this can be done? I keep getting the 'Help' menu, indicating that something went wrong. I've been fighting with this for like an hour now! :-( I followed this structure [1]: msiexec /i (yourFile).msi TARGETDIR=C:\YourBin\YourApp The following does NOT work (I added the cd/md commands later, idem for the /qb) y:\>set PYTHONDIR="c:\program files\python27" y:\>cd /d "c:\program files" y:\>md python27 y:\>cd /d %temp% y:\>msiexec /i python-2.7.3 TARGETDIR="%PYTHONDIR%" /qb Thank you! Regards, Albert-Jan [1] http://stackoverflow.com/questions/3259737/command-line-option-to-tell-msi-installation-to-a-specific-location [2] Platform: Windows 7 Enterprise, it that matters. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a fresh water system, and public health, what have the Romans ever done for us? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From zachary.ware+pylist at gmail.com Wed Jul 16 09:47:31 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 16 Jul 2014 08:47:31 -0500 Subject: how to msi install Python to non-default target dir? In-Reply-To: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> Message-ID: On Wed, Jul 16, 2014 at 8:29 AM, Albert-Jan Roskam wrote: > hi, > > I am trying to create a .bat file where (among other things) Python will have to be silently installed. > It needs to be installed to the non-default location "c:\program files\python27". Any idea how this can be done? > I keep getting the 'Help' menu, indicating that something went wrong. I've been fighting with this for like an hour now! :-( > > I followed this structure [1]: msiexec /i (yourFile).msi TARGETDIR=C:\YourBin\YourApp > > The following does NOT work (I added the cd/md commands later, idem for the /qb) > > y:\>set PYTHONDIR="c:\program files\python27" > y:\>cd /d "c:\program files" > y:\>md python27 > y:\>cd /d %temp% > y:\>msiexec /i python-2.7.3 TARGETDIR="%PYTHONDIR%" /qb I'm assuming this is retyped and you missed the '.msi' in retyping? If not, that may be your issue. Also, 'set' doesn't require quotes around a value with spaces, and you're also quoting %PYTHONDIR% when you use it in the msiexec command, so you're actually double-quoting the dir name (which could also be the issue). And, not necessarily an issue that would prevent installing, but you may want to make sure you're in the correctly-bitted Program Files directory if you're on 64-bit Windows (%PROGRAMFILES% for 64-bit, %PROGRAMFILES(x86)% for 32-bit; %PROGRAMFILES(x86)% will not be defined on 32-bit Windows or in a 32-bit process on 64-bit Windows). -- Zach From invalid at invalid.invalid Wed Jul 16 09:59:15 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Wed, 16 Jul 2014 13:59:15 +0000 (UTC) Subject: Python 3 is killing Python References: <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: On 2014-07-16, Dennis Lee Bieber wrote: > On Tue, 15 Jul 2014 20:43:03 -0400, Kevin Walzer > declaimed the following: > >>On 7/15/14, 6:38 PM, Mark Lawrence wrote: >>> I did see your correction but it gave me an opportunity to mention >>> google groups, something that just can't be missed >> >>If the newgroup had a filter to trim out complaints about Google groups, >>half the traffic would be gone. :-) > > That would tend to imply that if it had a filter to trim out posts > /from/ GoogleGroups there would be no traffic left No need. My slrn configuration does filter out posts from google groups. So, all I see are the complaints about posts from google groups -- I haven't figured out how to plonk those... -- Grant Edwards grant.b.edwards Yow! Th' MIND is the Pizza at Palace of th' SOUL gmail.com From rosuav at gmail.com Wed Jul 16 10:04:41 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 00:04:41 +1000 Subject: Python 3 is killing Python In-Reply-To: <87sim1e9dt.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 11:11 PM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> With a few exceptions, /etc is filled with text files, not binary >> files, and half the executables on the system are text (Python, Perl, >> bash, sh, awk, etc.). > > Our debate seems to stem from a different idea of what text is. To me, > text in the Python sense is a sequence of UCS-4 character code points. > The opposite of text is not necessarily binary. Let's shift things a moment for an analogy. What is audio? What is sound? (Music, if you like, but I'm not going to get into the debate of whether or not Band So-and-so's output should be called music.) I have a variety of files that store music; some are RIFF WAVs, some are MPEG level 3s, some are Ogg Vorbis files, and right now I have an MKV of "Do you wanna build a snowman?" playing. (As far as I'm concerned, it's primarily there for music, and the video image is buried behind other windows. But I'll accept the argument that that's just a container for some other format of audio, probably MPEG but I haven't checked.) Sound, fundamentally, is a waveform, or a series of air pressures. Text, similarly, is not UCS-4, but a series of characters. We are fortunate enough to have Unicode and can therefore define that text is a sequence of Unicode codepoints, but the distinction isn't a feature of Unicode; if you ask a primary school child to identify the letters in a word, s/he should be able to do so, and that without any computer involvement at all. Letters, digits, and other characters exist independently of encodings or even character sets, but it's really REALLY hard for computers to manipulate what they can't identify. So let's define Unicode text as "a sequence of Unicode codepoints" or "a sequence of Unicode characters", and proceed from there. A file on a Unix or Windows file system consists of a sequence of bytes. Ergo, a file cannot actually contain text; it must store *encoded* text. But this is far and away the most common type of file on any file system. Tweaking the previous script to os.walk() my home directory, rather than scanning $PATH, the ratios are roughly 2:1 the other way - heaps more text files than binary. And this is with my Downloads/ directory being almost entirely binaries, and lots of them; various zip files, deb packages, executables of various types... about the only actual text there would be .patch files. >> Relatively rare. Like, um, email, news, html, Unix config files, >> Windows ini files, source code in just about every language ever, >> SMSes, XML, JSON, YAML, instant messenger apps, > > I would be especially wary of letting Python 3 interpret those files for > me. Python's [text] strings could be a wonderful tool on the inside of > my program, but I definitely would like to micromanage the I/O. Do I > obey the locale or not? That's too big (and painful) a question for > Python to answer on its own (and pretend like everything's under > control). That's a problem that will be solved progressively, by daemons shifting to UTF-8 for everything. But until then, you have to treat log files as "messy" - you can't trust to a simple encoding. But that's unusual compared to the common case. If you're reading your own config files, you can simply stipulate that they are to be encoded UTF-8, and if they're not, you throw an error. Simple! Works with the easy way of opening files in Python. If you're reading someone else's config files, you can either figure out what that program is documented as expecting (and error out if the file's misencoded), or treat it as messy and read it as binary. >> word processors... even *graphic* applications invariably have a text >> tool. > > Thing is, the serious text utilities like word processors probably need > lots of ancillary information so Python's [text] strings might be too > naive to represent even a single character. Ancillary information? (La)TeX files are entirely text, and have all that info in them somewhere. Open Documents are basically zip files of XML data, where XML is ... all text. Granted, it's barely-readable text, but it is UTF-8 encoded text. (I just checked an odt file that I have sitting here, and it does contain a thumbnail in PNG format. But the primary content is all XML files.) >>> More often, len(b'?') is what I want. >> >> Oh really? Are you sure? What exactly is b'?'? > > That's something that ought to work in the UTF-8 paradise. > Unfortunately, Python only allows ASCII in bytes. ASCII only! In this > day and age! Even C is not so picky: > > #include > > int main() > { > printf("Hyv?? y?t?\n"); > return 0; > } And I have a program that lets me store 1.75 in an integer variable! That's ever so much better than most programs. It's so much less picky! Actually, Python allows all bytes in a bytestring, not just ASCII. However, b'?' has no meaning; in fact, even b'asdf' is dubious, and this kind of notation exists only because there are many file formats that mix ASCII text and binary data. To be truly accurate, b'asdf' ought to be written as x'61736466' or something, because it's as likely to mean 1634952294 or 1717859169 as it is to mean "asdf". What is C actually storing in that string? Do you know? Can you be truly sure that it's UTF-8? No, you cannot. Anyone might transcode your source file, and I don't think C compilers are aware of character literals and their associated encodings. More importantly, you cannot be sure that that will print "Hyv?? y?t?" to the console; if the console is set to an encoding other than the one your source file was using, you'll get mojibake. With Python, at least the interpreter gets some idea of what's going on. ChrisA From frank at chagford.com Wed Jul 16 10:27:56 2014 From: frank at chagford.com (Frank Millman) Date: Wed, 16 Jul 2014 16:27:56 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: "Marko Rauhamaa" wrote in message news:87egxl4zq8.fsf at elektro.pacujo.net... > Steven D'Aprano : > >> On Tue, 15 Jul 2014 23:01:25 +0300, Marko Rauhamaa wrote: >>> In fact, I find the lazy use of Unicode strings at least as scary as >>> the lazy use of byte strings, especially since Python 3 sneaks >>> Unicode to the outer interfaces of the program (files, IPC). >> >> I'm not entirely sure I understand what you mean by "lazy use of >> Unicode strings". And I especially don't understand what you mean by >> "sneak". The fact that strings are Unicode is *the* biggest and most >> obvious new feature of Python 3. > > I mean that sys.stdin and sys.stdout should deal with byte strings. I > mean that open(path) should open a file in binary mode. Thankfully, the > subprocess methods exchange bytes by default. > > To me, the main difference between Python 2 and Python 3 is that in the > former, I use "..." everywhere, and in the latter, I use b"..." > everywhere. If I should need advanced text processing features, I'll go > through a decode() and encode(). > >> The Python devs aren't slaves, they get to choose what features they >> work on and which they don't. They don't owe *anybody* any feature >> they don't want to build, or care to support, and that includes >> continuing the 2.x series. > > No need to erect straw men. Of course, the Python gods do whatever they > want. And you asked me to clarify my opinion, which I did. The breakage > of backward compatibility wasn't worth the new features. > > But as I said, what is done is done. We'll live with the reality. > This sub-thread is the most constructive one I have seen yet that deals with the 'problems' that Python3 has created, and how to deal with them. I take my hat off to Marko for his approach - it has affected him adversely, but it has not prevented him from continuing to develop using Python3. FWIW, here are my thoughts - 1. There were many backward-incompatible changes made in Python3, but the only one that seems to cause problems is the change to the bytes/str types. I agree that it is a big change, but the others seem to have been accepted without argument, so it seems to me that the python devs got an awful lot right. 2. Those adversely affected by the change are very vocal, but we hear very little from those who have benefited from it. This is to be expected - they are just getting on with developing in Python3 and have no need to get involved in controversies. I just tried an experiment in my own project. Ned Batchelder, in his Pragmatic Unicode presentation, http://nedbatchelder.com/text/unipain.html, suggests that you always have some unicode characters in your data, just to ensure that they are handled correctly. He has a tongue-in-cheek example which spells the word PYTHON using various exotic unicode characters. I used this to populate a field in my database, to see if it would display in my browser-based client. The hardest part was getting it in. There are 6 characters, but utf-8 requires 16 bytes to store it - b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8') However, that was it. Without any changes to my program, it read it from the database and displayed it on the screen. IE8 could only display 2 out of the 6 characters correctly, and Chrome could display 5 out of 6, but that is a separate issue. Python3 handled it perfectly. Would this have been so easy using Python2 - I don't think so. What follows is blatant speculation, but it is quite possible that there are many non-English speakers out there that have had their lives made much easier by the changes to Python3 - a 'silent majority'? I don't mean an absolute majority, as I believe there are still more Python2 users than Python3. But of those who have made the switch from 2 to 3, maybe most of them are quite happy. If so, then the python devs got that right as well. Unfortunately, human nature being what it is, the possibility of this split in the community continuing, to the detriment of Python itself, is all too real. I don't know what more the python devs can do, but there are no guarantees of success :-( Frank Millman From fomcl at yahoo.com Wed Jul 16 10:33:00 2014 From: fomcl at yahoo.com (Albert-Jan Roskam) Date: Wed, 16 Jul 2014 07:33:00 -0700 Subject: how to msi install Python to non-default target dir? In-Reply-To: References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> Message-ID: <1405521180.31678.YahooMailNeo@web163802.mail.gq1.yahoo.com> ? ----- Original Message ----- > From: Zachary Ware > To: Albert-Jan Roskam > Cc: Python > Sent: Wednesday, July 16, 2014 3:47 PM > Subject: Re: how to msi install Python to non-default target dir? > > On Wed, Jul 16, 2014 at 8:29 AM, Albert-Jan Roskam > > wrote: >> hi, >> >> I am trying to create a .bat file where (among other things) Python will > have to be silently installed. >> It needs to be installed to the non-default location "c:\program > files\python27". Any idea how this can be done? >> I keep getting the 'Help' menu, indicating that something went > wrong. I've been fighting with this for like an hour now! :-( >> >> I followed this structure [1]: msiexec /i (yourFile).msi > TARGETDIR=C:\YourBin\YourApp >> >> The following does NOT work (I added the cd/md commands later, idem for the > /qb) >> >> y:\>set PYTHONDIR="c:\program files\python27" >> y:\>cd /d "c:\program files" >> y:\>md python27 >> y:\>cd /d %temp% >> y:\>msiexec /i python-2.7.3 TARGETDIR="%PYTHONDIR%" /qb > > I'm assuming this is retyped and you missed the '.msi' in retyping? Yes, typo, sorry. I was working in an environment without email access. > If not, that may be your issue.? Also, 'set' doesn't require quotes > around a value with spaces, and you're also quoting %PYTHONDIR% when > you use it in the msiexec command, so you're actually double-quoting > the dir name (which could also be the issue).? That was it, thank you!! >And, not necessarily an > issue that would prevent installing, but you may want to make sure > you're in the correctly-bitted Program Files directory if you're on > 64-bit Windows (%PROGRAMFILES% for 64-bit, %PROGRAMFILES(x86)% for > 32-bit; %PROGRAMFILES(x86)% will not be defined on 32-bit Windows or > in a 32-bit process on 64-bit Windows). Good point. The easiest solution would be to write?one .bat for 32bit and one for 64bit. Thanks again!!? From marko at pacujo.net Wed Jul 16 10:39:17 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 17:39:17 +0300 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> Message-ID: <87oawpe5be.fsf@elektro.pacujo.net> Chris Angelico : > On Wed, Jul 16, 2014 at 11:11 PM, Marko Rauhamaa wrote: >> I would be especially wary of letting Python 3 interpret those files for >> me. [...] > > If you're reading your own config files, you can simply stipulate that > they are to be encoded UTF-8, and if they're not, you throw an error. > Simple! Works with the easy way of opening files in Python. That's my point! It does not work. $ python3 -c " > import sys > sys.stdout.write(sys.stdin.read())" <<<"Hyv?? y?t?" Hyv?? y?t? $ LANG=en_US.ASCII python3 -c " > import sys > sys.stdout.write(sys.stdin.read())" <<<"Hyv?? y?t?" Traceback (most recent call last): File "", line 3, in File "/usr/lib/python3.2/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3\ : ordinal not in range(128) In other words, the well-meaning Python3 blindly obeys the locale even though I "simply stipulated" that my input is UTF-8. >> Thing is, the serious text utilities like word processors probably >> need lots of ancillary information so Python's [text] strings might >> be too naive to represent even a single character. > > Ancillary information? (La)TeX files are entirely text, I mean on the inside. For example, if emacs were to be written in Python3, I don't know if it could use Python3's strings. Each character position in a buffer or a string can have a text property list, much like the property list of a symbol (see Property Lists). The properties belong to a particular character at a particular place, such as, the letter ?T? at the beginning of this sentence or the first ?o? in ?foo??if the same character occurs in two different places, the two occurrences in general have different properties. . > What is C actually storing in that string? Do you know? Can you be > truly sure that it's UTF-8? No, you cannot. I happen to know it does. And again, I may "stipulate" it to use your word. Python, happily, is even more explicit about it: #!/usr/bin/env python3 # -*- coding: utf-8 -*- Marko From rosuav at gmail.com Wed Jul 16 11:18:59 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 01:18:59 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 12:27 AM, Frank Millman wrote: > FWIW, here are my thoughts - > > 1. There were many backward-incompatible changes made in Python3, but the > only one that seems to cause problems is the change to the bytes/str types. > I agree that it is a big change, but the others seem to have been accepted > without argument, so it seems to me that the python devs got an awful lot > right. There are quite a few changes that are almost completely insignificant, like renaming (eg Tkinter to tkinter), where there's this tiny difference at the top of your program and absolutely no difference elsewhere. And there are a few where, for instance, FileNotFoundError was created, as a subclass of OSError; I have a program that needs to catch that exception, and I just have a trap at the top that, if there's no FNFE, assigns it equal to OSError, and then proceeds as normal. (This does mean that, under Python 2, the mini HTTP server returns 404s for other types of OSError attempting to read from certain files; under Python 3, those will result in 500s and logged errors. I'm not overly concerned about that difference, but I prefer the Py3 behaviour.) These sorts of changes, while technically backward-incompatible, aren't going to cause argument - you just zip through your code and change stuff (probably with a script like 2to3), or else add a bit of header to ensure compatibility with both versions. Pretty easy. Then there are the changes that, while again technically backward-incompatible, are practically identical *in normal usage*. For instance, range no longer returns a list, but most range usage is with iteration anyway. Dict views rather than lists might cause some problems (if you iterate over d.keys() while mutating d, you'll have problems in Py3, but in Py2 it's fine), but again, any place where you have issues, you just tweak it to the new recommended style. Several of these changes are actually less significant than one change that happened within the 2.x line - the change from string exceptions to subclasses of (Base)Exception. There have been a few complaints, but they're not the stuff about which people say "Python 3 is killing Python". > 2. Those adversely affected by the change are very vocal, but we hear very > little from those who have benefited from it. This is to be expected - they > are just getting on with developing in Python3 and have no need to get > involved in controversies. That's very true. Sometimes you get an idea of how silent something is and therefore how successful; for example, my house has been progressively migrated almost exclusively to Linux, and the days that go by without anyone asking me for help are proof that Linux is a perfectly acceptable desktop OS. (Actually, even when people _do_ ask me for help, it's usually either something to do with git, or something advanced like "How can I find out which files in this whole directory tree have been changed recently?", which your average user wouldn't know off-hand how to do on Windows or OS/2 either.) Python 3 has served many people just fine, and those people aren't writing blog posts about how unexciting their lives have become now that they don't have to deal with bug reports about stuff the language just does for them. > I just tried an experiment in my own project. Ned Batchelder, in his > Pragmatic Unicode presentation, http://nedbatchelder.com/text/unipain.html, > suggests that you always have some unicode characters in your data, just to > ensure that they are handled correctly. He has a tongue-in-cheek example > which spells the word PYTHON using various exotic unicode characters. I used > this to populate a field in my database, to see if it would display in my > browser-based client. > > The hardest part was getting it in. There are 6 characters, but utf-8 > requires 16 bytes to store it - > > b'\xe2\x84\x99\xc6\xb4\xe2\x98\x82\xe2\x84\x8c\xc3\xb8\xe1\xbc\xa4'.decode('utf-8') > Ideally, you would have a browser-based input system as well, which would allow you to do the whole thing directly. Also, I would strongly recommend using a database back-end that stores Unicode; and if that back-end is MySQL, be aware that "utf8" is actually a messed-up encoding that's like UTF-8 only restricted to three bytes (and therefore the BMP), and you have to use "utf8mb4" to store all of Unicode. With a decent back-end like PostgreSQL, you can do this sort of thing directly: rosuav=> create table test (id serial primary key,txt text); CREATE TABLE rosuav=> insert into test (txt) values ('U+1234 is ?'); INSERT 0 1 rosuav=> insert into test (txt) values ('U+12345 is ?'); INSERT 0 1 rosuav=> select id,txt,length(txt) from test; id | txt | length ----+--------------+-------- 1 | U+1234 is ? | 11 2 | U+12345 is ? | 12 (2 rows) Looks fine to me. You should be able to read and write Unicode from Python, too. > However, that was it. Without any changes to my program, it read it from the > database and displayed it on the screen. IE8 could only display 2 out of the > 6 characters correctly, and Chrome could display 5 out of 6, but that is a > separate issue. Python3 handled it perfectly. That's more of a font issue than anything else. I played around with U+12345 in the above example, and it didn't display usefully in either my console or Chrome here, but it's still obviously there as a single character. > Would this have been so easy using Python2 - I don't think so. If all you ever do is read stuff from one place and write it to another, it doesn't make a lot of difference whether you're working with Unicode text or UTF-8 bytes. The trouble comes when you want to take the length of it, trim it, or anything like that; for instance, suppose you want to have a preview of the text, ellipsizing if the full text is longer than (say) 30 characters, with the full text available by clicking or hovering the mouse or something. At that point, UTF-8 becomes a dashed nuisance, and true Unicode support makes it a breeze. > What follows > is blatant speculation, but it is quite possible that there are many > non-English speakers out there that have had their lives made much easier by > the changes to Python3 - a 'silent majority'? I don't mean an absolute > majority, as I believe there are still more Python2 users than Python3. But > of those who have made the switch from 2 to 3, maybe most of them are quite > happy. If so, then the python devs got that right as well. It's impossible to say how many Py2 users there are and how many Py3. But I would say that there are a HUGE number of people who've either written Py3 code brand new, or ported something from Py2, and had no significant trouble. > Unfortunately, human nature being what it is, the possibility of this split > in the community continuing, to the detriment of Python itself, is all too > real. I don't know what more the python devs can do, but there are no > guarantees of success :-( What split, exactly? There are always these talks of a split... but I don't see one happening. I don't see, for instance, python2-list at python.org or comp.lang.python2 being separated out. I don't see Linux distributions choosing to support only one branch and not the other (only one can be the default and the system Python, but the other is usually just an apt-get/yum/pacman away). I don't see anyone taking the Python 2 source code and backporting a bunch of Python 3 features (and/or adding a bunch of their own features) and creating the Python 2.8 that http://blog.startifact.com/guido_no.jpg rejects. What split is actually occurring, or going to occur? I think anyone who talks of splitting has an unrealistically low idea of the costs of such a split; moving away from what the core Python devs are doing means setting up everything fresh, and it's just way too much work to do that. I don't know what's going to happen in 2020, though. There might be a split between three communities: the Python 3 community, the Red Hat supported Python 2 community, and the ActiveState supported Python 2 community. Or maybe there'll be some other commercial support. Or maybe there'll still be some measure of community support for Python 2 here on python-list and other such places, and there won't be a split even then. (People have come here talking about Python 1.5, although there isn't a huge amount of support for that anywhere!) Frankly, the Python devs need do nothing and can do nothing; the mass of users will go where it goes, 800lb gorilla style, and it's up to them to either find their own bananas or join the python.org banana plantation. One way or another, it'll work out. ChrisA From rosuav at gmail.com Wed Jul 16 11:23:25 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 01:23:25 +1000 Subject: Python 3 is killing Python In-Reply-To: <87oawpe5be.fsf@elektro.pacujo.net> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 12:39 AM, Marko Rauhamaa wrote: > In other words, the well-meaning Python3 blindly obeys the locale even > though I "simply stipulated" that my input is UTF-8. Except that you didn't - that input was not UTF-8. When you put a text string as redirected input and then change LANG, you're lying to the system, and you deserve all you get. Why are you even doing this, other than to be able to point and laugh at programs that do the wrong thing - when you've instructed them wrongly? ChrisA From neilc at norwich.edu Wed Jul 16 11:48:20 2014 From: neilc at norwich.edu (Neil D. Cerutti) Date: Wed, 16 Jul 2014 11:48:20 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On 7/16/2014 10:27 AM, Frank Millman wrote: > Would this have been so easy using Python2 - I don't think so. What follows > is blatant speculation, but it is quite possible that there are many > non-English speakers out there that have had their lives made much easier by > the changes to Python3 - a 'silent majority'? I don't mean an absolute > majority, as I believe there are still more Python2 users than Python3. But > of those who have made the switch from 2 to 3, maybe most of them are quite > happy. If so, then the python devs got that right as well. Python3 has helped me cope with unexpected non-ASCII characters in other systems on our university campus while using a program written back before I knew anything about unicode. When I first spotted mojibake appearing in a student's name and address, it was only a couple of emails and a little investigation to determine which encoding= bits to sprinkle into my program. And I was finished. I wrote these applications a decade ago in Python2, and never worried about unicode. I translated them to Python3 years ago, and still never worried about unicode. The database is supposed to be sanitized against non-ASCII by an address and name-scrubbing application, which we aspend large amounts of cash on (I don't understand why, but that's what we do). And thanks to Python3, even though "illegal" characters have crept in, and even though I had never worried about unicode before, I could fix my program(s) the instant I knew which encodings to use. It would have been much harder to get right using Python2. -- Neil Cerutti From marko at pacujo.net Wed Jul 16 11:48:18 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 18:48:18 +0300 Subject: Python 3 is killing Python References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> Message-ID: <8761ix4859.fsf@elektro.pacujo.net> Chris Angelico : > On Thu, Jul 17, 2014 at 12:39 AM, Marko Rauhamaa wrote: >> In other words, the well-meaning Python3 blindly obeys the locale even >> though I "simply stipulated" that my input is UTF-8. > > Except that you didn't - that input was not UTF-8. When you put a text > string as redirected input and then change LANG, you're lying to the > system, and you deserve all you get. Why are you even doing this, > other than to be able to point and laugh at programs that do the wrong > thing - when you've instructed them wrongly? The example was artificial to make it small enough. The point is, though, that it is dangerous to assume that the file formats agree with the locale. Marko From rosuav at gmail.com Wed Jul 16 12:07:28 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 02:07:28 +1000 Subject: Python 3 is killing Python In-Reply-To: <8761ix4859.fsf@elektro.pacujo.net> References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> <8761ix4859.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 1:48 AM, Marko Rauhamaa wrote: > it is dangerous to assume that the file formats agree with > the locale. Of course. You never assume anything about encodings. What you do is expect something about the encoding, and either throw an error if it's wrong, or figure out some other encoding to use. With anything that you broadly control (eg if your program is configured by a file in /etc that nothing else uses), you just decode with whatever you document your program as using, and any failure is *not your problem*. It's that simple. You don't replace /etc/passwd with a JPEG encoded photograph of your family tree and expect all your family to be able to log in; no more should you expect a file to be parsed correctly if it's meant to be UTF-8 and you save it in ISO-8859-4. The two cases are equally ridiculous. The only thing that might be an issue is that you can't use open(fn) to read your files, but you have to explicitly state the encoding. That would be an understandable problem, especially for someone who develops on a single platform and forgets that the default differs. As long as you always explicitly say encoding="utf-8", and document that you do so, any problems are someone else's. ChrisA From rosuav at gmail.com Wed Jul 16 12:09:42 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 02:09:42 +1000 Subject: how to msi install Python to non-default target dir? In-Reply-To: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> Message-ID: On Wed, Jul 16, 2014 at 11:29 PM, Albert-Jan Roskam wrote: > It needs to be installed to the non-default location "c:\program files\python27". Why must it? Are you aware that many programs have issues with spaces in file names? That's one reason for Python's default installation location NOT being in the stupidly-named Program Files. Putting Python there may cause trouble with, for instance, binary extensions. ChrisA From marko at pacujo.net Wed Jul 16 12:20:14 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 19:20:14 +0300 Subject: Python 3 is killing Python References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> <8761ix4859.fsf@elektro.pacujo.net> Message-ID: <871ttl46o1.fsf@elektro.pacujo.net> Chris Angelico : > The only thing that might be an issue is that you can't use open(fn) > to read your files, but you have to explicitly state the encoding. > That would be an understandable problem, especially for someone who > develops on a single platform and forgets that the default differs. As > long as you always explicitly say encoding="utf-8", and document that > you do so, any problems are someone else's. Yes. I don't like open() guessing the enconding: The default encoding is platform dependent (whatever locale.getpreferredencoding() returns) Also, I don't like sys.std* guessing the encoding: Under other platforms, the locale encoding is used (see locale.getpreferredencoding()). In each case, it would have been better to default to bytes just like subprocess does. Marko From marko at pacujo.net Wed Jul 16 12:22:47 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Wed, 16 Jul 2014 19:22:47 +0300 Subject: how to msi install Python to non-default target dir? References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> Message-ID: <87wqbd2rzc.fsf@elektro.pacujo.net> Chris Angelico : > Why must it? Are you aware that many programs have issues with spaces > in file names? That's one reason for Python's default installation > location NOT being in the stupidly-named Program Files. Putting Python > there may cause trouble with, for instance, binary extensions. One of Python's advantages over, say, bash is that it can handle spaces and other funny characters in pathnames. Marko From rosuav at gmail.com Wed Jul 16 12:27:14 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 02:27:14 +1000 Subject: how to msi install Python to non-default target dir? In-Reply-To: <87wqbd2rzc.fsf@elektro.pacujo.net> References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> <87wqbd2rzc.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 2:22 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> Why must it? Are you aware that many programs have issues with spaces >> in file names? That's one reason for Python's default installation >> location NOT being in the stupidly-named Program Files. Putting Python >> there may cause trouble with, for instance, binary extensions. > > One of Python's advantages over, say, bash is that it can handle spaces > and other funny characters in pathnames. Both Python and bash can handle spaces just fine. It's applications that have trouble. ChrisA From zachary.ware+pylist at gmail.com Wed Jul 16 12:45:34 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Wed, 16 Jul 2014 11:45:34 -0500 Subject: how to msi install Python to non-default target dir? In-Reply-To: <1405521180.31678.YahooMailNeo@web163802.mail.gq1.yahoo.com> References: <1405517362.434.YahooMailNeo@web163802.mail.gq1.yahoo.com> <1405521180.31678.YahooMailNeo@web163802.mail.gq1.yahoo.com> Message-ID: On Wed, Jul 16, 2014 at 9:33 AM, Albert-Jan Roskam wrote: > From: Zachary Ware >> Also, 'set' doesn't require quotes >> around a value with spaces, and you're also quoting %PYTHONDIR% when >> you use it in the msiexec command, so you're actually double-quoting >> the dir name (which could also be the issue). > > That was it, thank you!! Glad I could help :) >> And, not necessarily an >> issue that would prevent installing, but you may want to make sure >> you're in the correctly-bitted Program Files directory if you're on >> 64-bit Windows (%PROGRAMFILES% for 64-bit, %PROGRAMFILES(x86)% for >> 32-bit; %PROGRAMFILES(x86)% will not be defined on 32-bit Windows or >> in a 32-bit process on 64-bit Windows). > > Good point. The easiest solution would be to write one .bat for 32bit and one for 64bit. You could also do something like (untested, but I've used similar in the Doc/make.bat script): if DEFINED ProgramFiles(x86) set 64bitext=.amd64 set PYTHONDIR=%ProgramFiles%\Python27 set PYTHONMSI=python-2.7.3%64bitext%.msi msiexec /i %PYTHONMSI% TARGETDIR="%PYTHONDIR%" /qb That's for 64-bit Python on 64-bit Windows, 32-bit Python on 32-bit Windows. Or: if DEFINED ProgramFiles(x86) set PgrmFls=%ProgramFiles(x86)% if NOT DEFINED ProgramFiles(x86) set PgrmFls=%ProgramFiles% set PYTHONDIR=%PgrmFls%\Python27 msiexec /i python-2.7.3.msi TARGETDIR="%PYTHONDIR%" /qb for 32-bit Python on either platform. -- Zach From codemonkey at inbox.com Wed Jul 16 13:32:31 2014 From: codemonkey at inbox.com (Deb Wyatt) Date: Wed, 16 Jul 2014 09:32:31 -0800 Subject: This Python 3 is killing Python thread is killing me. Message-ID: Can you all stop already with the non python US bashing? Please? Deb in WA, USA ____________________________________________________________ Protect your computer files with professional cloud backup. Get PCRx Backup and upload unlimited files automatically. Learn more at http://backup.pcrx.com/mail From breamoreboy at yahoo.co.uk Wed Jul 16 13:34:36 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 16 Jul 2014 18:34:36 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On 16/07/2014 15:27, Frank Millman wrote: > > This sub-thread is the most constructive one I have seen yet that deals with > the 'problems' that Python3 has created, and how to deal with them. > How many of the Python3 'problems' were backported to 2.7 or even 2.6? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From nospam at nospam.com Wed Jul 16 13:33:44 2014 From: nospam at nospam.com (Javier) Date: Wed, 16 Jul 2014 17:33:44 +0000 (UTC) Subject: Python 3 is killing Python References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: > I don't see anyone taking the Python 2 source code and backporting a > bunch of Python 3 features (and/or adding a bunch of their own > features) and creating the Python 2.8 that > http://blog.startifact.com/guido_no.jpg rejects. What split is > actually occurring, or going to occur? I think anyone who talks of > splitting has an unrealistically low idea of the costs of such a > split; moving away from what the core Python devs are doing means > setting up everything fresh, and it's just way too much work to do > that. Up to now there have been no attemps of forking because python2.x was still being developed and they even ported some of the features of python3 to 2.6/2.7. I think there has been a severe miscalculation, and the change in the name of the interpreter python3 to python http://legacy.python.org/dev/peps/pep-0394/ is a good example of the disconnection between GvR and the real world. Arch Linux was the only distro to fall in the trap, and those who use it (as myself) need to put fake executables in /usr/local/bin for everything: (python, sphinx, virtualenv...) selecting 2 or 3 http://sindhus.bitbucket.org/manage-python-2-3.html Things are a bit more complex than just changing '#!/usr/bin/env python' to '#!/usr/bin/env python2' Let's see what it happens now that no more features are added to 2.x. 2.8 fork anybody? From abhi.darkness at gmail.com Wed Jul 16 13:42:04 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Wed, 16 Jul 2014 23:12:04 +0530 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Wed, Jul 16, 2014 at 11:02 PM, Deb Wyatt wrote: > Can you all stop already with the non python US bashing? Please? > > Deb in WA, USA > > > > -- > https://mail.python.org/mailman/listinfo/python-list > ?I'm actually picking up a lot of snippets of information from that thread by being a spectator :) ?But that's just me. -- Abhiram.R -------------- next part -------------- An HTML attachment was scrubbed... URL: From ian.g.kelly at gmail.com Wed Jul 16 13:50:24 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 16 Jul 2014 11:50:24 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Wed, Jul 16, 2014 at 11:33 AM, Javier wrote: > I think there has been a severe miscalculation, and the change in the > name of the interpreter python3 to python > http://legacy.python.org/dev/peps/pep-0394/ is a good example of the > disconnection between GvR and the real world. Er, that PEP currently recommends that python be a symlink to python2. It states that at some point in the future, the recommendation will change to have python symlink to python3. > Arch Linux was the only distro to fall in the trap You've got the order of events backward. That PEP was created *because* Arch decided to link python to python3. Neither GvR nor anybody else who work on Python have any control over that. From ian.g.kelly at gmail.com Wed Jul 16 14:17:13 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Wed, 16 Jul 2014 12:17:13 -0600 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Wed, Jul 16, 2014 at 11:32 AM, Deb Wyatt wrote: > Can you all stop already with the non python US bashing? Please? I read it more as counter-US-glorification-trolling than bashing, but in any case that subthread seems to have died down already, so you should be safe to start reading again if you want. From alister.nospam.ware at ntlworld.com Wed Jul 16 14:16:14 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Wed, 16 Jul 2014 18:16:14 GMT Subject: This Python 3 is killing Python thread is killing me. References: Message-ID: On Wed, 16 Jul 2014 09:32:31 -0800, Deb Wyatt wrote: > Can you all stop already with the non python US bashing? Please? > > Deb in WA, USA > > ____________________________________________________________ Protect > your computer files with professional cloud backup. > Get PCRx Backup and upload unlimited files automatically. > Learn more at http://backup.pcrx.com/mail Sorry Deb I was not bashing the USA as such... It was all meant to be taken in good humour. I have had a number of enjoyable holidays in the USA and 90% of the people I have met there have been great. -- Q: What's hard going in and soft and sticky coming out? A: Chewing gum. From breamoreboy at yahoo.co.uk Wed Jul 16 14:40:21 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 16 Jul 2014 19:40:21 +0100 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On 16/07/2014 18:32, Deb Wyatt wrote: > Can you all stop already with the non python US bashing? Please? > > Deb in WA, USA > rr started it with a fairly impressive piece of trolling but as you've asked so politely I will happily oblige. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From jason.swails at gmail.com Wed Jul 16 15:24:40 2014 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 16 Jul 2014 12:24:40 -0700 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Wed, Jul 16, 2014 at 11:40 AM, Mark Lawrence wrote: > On 16/07/2014 18:32, Deb Wyatt wrote: > >> Can you all stop already with the non python US bashing? Please? >> >> Deb in WA, USA >> >> > rr started it with a fairly impressive piece of trolling but as you've > asked so politely I will happily oblige. ?I honestly don't understand why you haven't kill-filed him yet. I can understand people wanting to respond to jmf to prevent newbies and the Unicode-ignorant from thinking the FSR is not a good thing (or fundamentally wrong), although I've killfiled him as well. [1] But nobody will confuse rr's posts with something of value (their only possible use can be to populate http://en.wikipedia.org/wiki/List_of_logical_fallacies and http://en.wikipedia.org/wiki/Ad_hominem). There's nobody to protect from rr-induced misconceptions. [http://xkcd.com/386/] My life lurking and learning on Python-list has been dramatically improved since I began to instantiate filters, I highly recommend it. Cheers, Jason [1] Seen one and you've seen them all, and I'm no unicode expert. -------------- next part -------------- An HTML attachment was scrubbed... URL: From numansenm at gmail.com Wed Jul 16 15:57:20 2014 From: numansenm at gmail.com (numansenm at gmail.com) Date: Wed, 16 Jul 2014 12:57:20 -0700 (PDT) Subject: Oxycontin no prescription overnight cod delivery , cheap Oxycontin cash on delivery Message-ID: Buy Oxycontin online, Really amazing prices and Free bonuses! Oxycontin BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Oxycontin <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Oxycontin http://drugeasy.biz/?q=Buy+online+Oxycontin http://drugeasy.biz/?q=Buy+order+Oxycontin http://drugeasy.biz/?q=Buy+Oxycontin http://drugeasy.biz/?q=Buy+cheap+Oxycontin http://drugeasy.biz/?q=Order+Oxycontin http://drugeasy.biz/?q=Online+Oxycontin * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Oxycontin/Oxycontin pills with every Order cheap online pharmacy Oxycontin Oxycontin online saturday delivery online Oxycontin and fedex cheap order prescription Oxycontin cheap Oxycontin by money order buy Oxycontin from mexico online Oxycontin no prescription usa fedex shipping overnight delivery Oxycontin buy Oxycontin online without a prescription and no membership buy Oxycontin paypal online without prescription Oxycontin order a prepaid mastercard no prescription needed Oxycontin cod shipped Oxycontin not expensive order prescription Oxycontin Oxycontin money order Oxycontin without a perscription online buy Oxycontin Oxycontin fedex buy no online prescription Oxycontin Oxycontin pharmacies accepting cod delivery Oxycontin online consultant online pharmacy fedex cod Oxycontin buy Oxycontin no scams Oxycontin c.o.d overnight delivery buy Oxycontin no prescription cod overnight Oxycontin order Oxycontin online doctors buy Oxycontin on line no prescription Oxycontin no prescription usa fedex shipping Oxycontin online uk watson brand Oxycontin medicine online Oxycontin order Oxycontin samples sent buy Oxycontin no prescription order Oxycontin without a prescription Oxycontin no prescription drug cheap online order Oxycontin get Oxycontin over the counter online order Oxycontin next day buy Oxycontin no perscription cod real Oxycontin fed ex Oxycontin no prescription cod does cv/ pharmacy carry Oxycontin no prescription cod Oxycontin cheap Oxycontin without rx Oxycontin online health insurance lead buy Oxycontin online with overnight delivery Oxycontin no rx fed ex buy Oxycontin without a perscription lowest prices for Oxycontin online buy Oxycontin paypal online without prescription cheap non prescription Oxycontin Oxycontin ups Oxycontin for cheap buy Oxycontin no visa online without prescription cheapest Oxycontin cash on delivery Oxycontin order a prepaid mastercard buy online Oxycontin purchase Oxycontin mail order Oxycontin without a prescription online with overnight delivery Oxycontin from canada buy Oxycontin with no rx overnight delivery of Oxycontin with no prescription cash on delivery Oxycontin no rx Oxycontin by cod buy Oxycontin over the counter cod overnight overnight Oxycontin order Oxycontin without prescription from us pharmacy cheap Oxycontin free fedex shipping order Oxycontin over the counter where to buy Oxycontin no prescription no fees only Oxycontin free consult cod delivery Oxycontin Oxycontin no prescription Oxycontin online overnight delivery cod order Oxycontin over the counter fedex Oxycontin saturday delivery buy Oxycontin money order Oxycontin without prescription mexico buy cheap Oxycontin without prescription Oxycontin non prescription for next day delivery Oxycontin ups delivery only buy Oxycontin usa cod Oxycontin with next day delivery no prescriptions needed for Oxycontin cheap Oxycontin overnight prescription Oxycontin cheap Oxycontin overnight delivery Oxycontin non prescription fedex overnight free order Oxycontin no creditcard buy cheap Oxycontin no Prescription buy Oxycontin over the counter fedex Oxycontin no doctor presribe needed cheap watson Oxycontin online cheap discount Oxycontin buy Oxycontin without a prescription online cheapest Oxycontin free delivery buy Oxycontin online overseas buy Oxycontin over the counter online not expensive Oxycontin next day shipping order Oxycontin cod next day delivery Oxycontin cheap Oxycontin buy in UK Oxycontin next day cod fedex Oxycontin to buy cheap order Oxycontin next day Oxycontin Oxycontin overnight no consult cheap watson Oxycontin no prescription needed Oxycontin without prescription medications overnight delivery of Oxycontin with no perscription buy Oxycontin.com Oxycontin cod next day delivery buy cheap discount online Oxycontin buy Oxycontin drug Oxycontin overnight delivery cheap overnight delivery of Oxycontin in US no prescription needed purchase Oxycontin free next day airOxycontin on line cheap Oxycontin without a prescription Oxycontin cheap cod Oxycontin buy no prepaid cheap Oxycontin next day buy Oxycontin cod accepted online pharmacies Oxycontin saturday delivery buy Oxycontin pay pal Oxycontin shipped on saturday Oxycontin pharmacy cod saturday delivery buy online Oxycontin prescriptions free fedex delivery Oxycontin Oxycontin without prescription cash on delivery buy discount Oxycontin Oxycontin overnight cheap best Oxycontin online pill images of Oxycontin Oxycontin U.P.S SHIPPING COD Oxycontin cod pharmacy buy Oxycontin online cod Oxycontin cod overnight delivery Oxycontin no rx overnight buy Oxycontin overnight COD online pharmacy Oxycontin cod order Oxycontin insurance Oxycontin cash delivery cod buy Oxycontin cheap cod no rx online pharmacy Oxycontin sale nextday Oxycontin Oxycontin pill Oxycontin online ordering Oxycontin online without prescription Oxycontin no script needed cod overnight how to buy Oxycontin online without a prescription cheap Oxycontin without prescription cheap Oxycontin online no rx saturday delivery order Oxycontin over the counter for sale Oxycontin next day delivery cod order Oxycontin online without prescription no prescription next day delivery Oxycontin overnight Oxycontin C.O.D Oxycontin without prescription Oxycontin discount fedex no prescription buy Oxycontin amex Oxycontin online next day Oxycontin shipped with no prescription Oxycontin online cheap cheap Oxycontin without prescription overnight delivery buy Oxycontin over the counter for sale Oxycontin no prescriptions needed cod Oxycontin fed ex cheap overnight delivery of Oxycontin free prescription Oxycontin free shipping not expensive legal Oxycontin for sale buy Oxycontin cod Oxycontin for saturday Oxycontin price cash for Oxycontin cash on delivery Oxycontin Oxycontin without a prescription and cod delivery buying Oxycontin without a prescription order Oxycontin no rx buy Oxycontin without rx Oxycontin no prescription usa fedex shipping cheapest buy Oxycontin online pharmacy buy cheap Oxycontin overnight delivery Oxycontin and online pharmacy Oxycontin next day Oxycontin drug no prescription where can i buy Oxycontin no prescription Oxycontin with saturday delivery Oxycontin online overnight Oxycontin no prescription worldwide buy cheap Oxycontin cod ordering Oxycontin online Buy Oxycontin overnight shipping Oxycontin overnight US delivery cheap real Oxycontin for sale Oxycontin no prescriptions needed COD buy Oxycontin no prescription needed Oxycontin no prescription overnight cod delivery cheap Oxycontin cash on delivery no prescription required for Oxycontin order Oxycontin c.o.d. not expensive Oxycontin prescriptions Oxycontin online Cash on Delivery buy Oxycontin overnight delivery Oxycontin online without presciption buy Oxycontin prescription online no prescription saturday delivery Oxycontin where to buy cheap Oxycontin no prescription Oxycontin wo get Oxycontin over the counter fedex Oxycontin with no rx and free shipping order Oxycontin over the counter cod overnight "Health is better than wealth", Oxycontin and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 15:57:59 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 12:57:59 -0700 (PDT) Subject: Buy Tramadol online, Really amazing prices and Free bonuses! Tramadol BEST SITES FOUND! Message-ID: Buy Tramadol online, Really amazing prices and Free bonuses! Tramadol BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Tramadol <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Tramadol http://drugeasy.biz/?q=Buy+online+Tramadol http://drugeasy.biz/?q=Buy+order+Tramadol http://drugeasy.biz/?q=Buy+Tramadol http://drugeasy.biz/?q=Buy+cheap+Tramadol http://drugeasy.biz/?q=Order+Tramadol http://drugeasy.biz/?q=Online+Tramadol * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Tramadol/Tramadol pills with every Order cheap online pharmacy Tramadol Tramadol online saturday delivery online Tramadol and fedex cheap order prescription Tramadol cheap Tramadol by money order buy Tramadol from mexico online Tramadol no prescription usa fedex shipping overnight delivery Tramadol buy Tramadol online without a prescription and no membership buy Tramadol paypal online without prescription Tramadol order a prepaid mastercard no prescription needed Tramadol cod shipped Tramadol not expensive order prescription Tramadol Tramadol money order Tramadol without a perscription online buy Tramadol Tramadol fedex buy no online prescription Tramadol Tramadol pharmacies accepting cod delivery Tramadol online consultant online pharmacy fedex cod Tramadol buy Tramadol no scams Tramadol c.o.d overnight delivery buy Tramadol no prescription cod overnight Tramadol order Tramadol online doctors buy Tramadol on line no prescription Tramadol no prescription usa fedex shipping Tramadol online uk watson brand Tramadol medicine online Tramadol order Tramadol samples sent buy Tramadol no prescription order Tramadol without a prescription Tramadol no prescription drug cheap online order Tramadol get Tramadol over the counter online order Tramadol next day buy Tramadol no perscription cod real Tramadol fed ex Tramadol no prescription cod does cv/ pharmacy carry Tramadol no prescription cod Tramadol cheap Tramadol without rx Tramadol online health insurance lead buy Tramadol online with overnight delivery Tramadol no rx fed ex buy Tramadol without a perscription lowest prices for Tramadol online buy Tramadol paypal online without prescription cheap non prescription Tramadol Tramadol ups Tramadol for cheap buy Tramadol no visa online without prescription cheapest Tramadol cash on delivery Tramadol order a prepaid mastercard buy online Tramadol purchase Tramadol mail order Tramadol without a prescription online with overnight delivery Tramadol from canada buy Tramadol with no rx overnight delivery of Tramadol with no prescription cash on delivery Tramadol no rx Tramadol by cod buy Tramadol over the counter cod overnight overnight Tramadol order Tramadol without prescription from us pharmacy cheap Tramadol free fedex shipping order Tramadol over the counter where to buy Tramadol no prescription no fees only Tramadol free consult cod delivery Tramadol Tramadol no prescription Tramadol online overnight delivery cod order Tramadol over the counter fedex Tramadol saturday delivery buy Tramadol money order Tramadol without prescription mexico buy cheap Tramadol without prescription Tramadol non prescription for next day delivery Tramadol ups delivery only buy Tramadol usa cod Tramadol with next day delivery no prescriptions needed for Tramadol cheap Tramadol overnight prescription Tramadol cheap Tramadol overnight delivery Tramadol non prescription fedex overnight free order Tramadol no creditcard buy cheap Tramadol no Prescription buy Tramadol over the counter fedex Tramadol no doctor presribe needed cheap watson Tramadol online cheap discount Tramadol buy Tramadol without a prescription online cheapest Tramadol free delivery buy Tramadol online overseas buy Tramadol over the counter online not expensive Tramadol next day shipping order Tramadol cod next day delivery Tramadol cheap Tramadol buy in UK Tramadol next day cod fedex Tramadol to buy cheap order Tramadol next day Tramadol Tramadol overnight no consult cheap watson Tramadol no prescription needed Tramadol without prescription medications overnight delivery of Tramadol with no perscription buy Tramadol.com Tramadol cod next day delivery buy cheap discount online Tramadol buy Tramadol drug Tramadol overnight delivery cheap overnight delivery of Tramadol in US no prescription needed purchase Tramadol free next day airTramadol on line cheap Tramadol without a prescription Tramadol cheap cod Tramadol buy no prepaid cheap Tramadol next day buy Tramadol cod accepted online pharmacies Tramadol saturday delivery buy Tramadol pay pal Tramadol shipped on saturday Tramadol pharmacy cod saturday delivery buy online Tramadol prescriptions free fedex delivery Tramadol Tramadol without prescription cash on delivery buy discount Tramadol Tramadol overnight cheap best Tramadol online pill images of Tramadol Tramadol U.P.S SHIPPING COD Tramadol cod pharmacy buy Tramadol online cod Tramadol cod overnight delivery Tramadol no rx overnight buy Tramadol overnight COD online pharmacy Tramadol cod order Tramadol insurance Tramadol cash delivery cod buy Tramadol cheap cod no rx online pharmacy Tramadol sale nextday Tramadol Tramadol pill Tramadol online ordering Tramadol online without prescription Tramadol no script needed cod overnight how to buy Tramadol online without a prescription cheap Tramadol without prescription cheap Tramadol online no rx saturday delivery order Tramadol over the counter for sale Tramadol next day delivery cod order Tramadol online without prescription no prescription next day delivery Tramadol overnight Tramadol C.O.D Tramadol without prescription Tramadol discount fedex no prescription buy Tramadol amex Tramadol online next day Tramadol shipped with no prescription Tramadol online cheap cheap Tramadol without prescription overnight delivery buy Tramadol over the counter for sale Tramadol no prescriptions needed cod Tramadol fed ex cheap overnight delivery of Tramadol free prescription Tramadol free shipping not expensive legal Tramadol for sale buy Tramadol cod Tramadol for saturday Tramadol price cash for Tramadol cash on delivery Tramadol Tramadol without a prescription and cod delivery buying Tramadol without a prescription order Tramadol no rx buy Tramadol without rx Tramadol no prescription usa fedex shipping cheapest buy Tramadol online pharmacy buy cheap Tramadol overnight delivery Tramadol and online pharmacy Tramadol next day Tramadol drug no prescription where can i buy Tramadol no prescription Tramadol with saturday delivery Tramadol online overnight Tramadol no prescription worldwide buy cheap Tramadol cod ordering Tramadol online Buy Tramadol overnight shipping Tramadol overnight US delivery cheap real Tramadol for sale Tramadol no prescriptions needed COD buy Tramadol no prescription needed Tramadol no prescription overnight cod delivery cheap Tramadol cash on delivery no prescription required for Tramadol order Tramadol c.o.d. not expensive Tramadol prescriptions Tramadol online Cash on Delivery buy Tramadol overnight delivery Tramadol online without presciption buy Tramadol prescription online no prescription saturday delivery Tramadol where to buy cheap Tramadol no prescription Tramadol wo get Tramadol over the counter fedex Tramadol with no rx and free shipping order Tramadol over the counter cod overnight "Health is better than wealth", Tramadol and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 15:58:27 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 12:58:27 -0700 (PDT) Subject: Buy Tramadol overnight shipping , Tramadol no prescription usa fedex shipping cheapest Message-ID: Buy Tramadol online, Really amazing prices and Free bonuses! Tramadol BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Tramadol <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Tramadol http://drugeasy.biz/?q=Buy+online+Tramadol http://drugeasy.biz/?q=Buy+order+Tramadol http://drugeasy.biz/?q=Buy+Tramadol http://drugeasy.biz/?q=Buy+cheap+Tramadol http://drugeasy.biz/?q=Order+Tramadol http://drugeasy.biz/?q=Online+Tramadol * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Tramadol/Tramadol pills with every Order cheap online pharmacy Tramadol Tramadol online saturday delivery online Tramadol and fedex cheap order prescription Tramadol cheap Tramadol by money order buy Tramadol from mexico online Tramadol no prescription usa fedex shipping overnight delivery Tramadol buy Tramadol online without a prescription and no membership buy Tramadol paypal online without prescription Tramadol order a prepaid mastercard no prescription needed Tramadol cod shipped Tramadol not expensive order prescription Tramadol Tramadol money order Tramadol without a perscription online buy Tramadol Tramadol fedex buy no online prescription Tramadol Tramadol pharmacies accepting cod delivery Tramadol online consultant online pharmacy fedex cod Tramadol buy Tramadol no scams Tramadol c.o.d overnight delivery buy Tramadol no prescription cod overnight Tramadol order Tramadol online doctors buy Tramadol on line no prescription Tramadol no prescription usa fedex shipping Tramadol online uk watson brand Tramadol medicine online Tramadol order Tramadol samples sent buy Tramadol no prescription order Tramadol without a prescription Tramadol no prescription drug cheap online order Tramadol get Tramadol over the counter online order Tramadol next day buy Tramadol no perscription cod real Tramadol fed ex Tramadol no prescription cod does cv/ pharmacy carry Tramadol no prescription cod Tramadol cheap Tramadol without rx Tramadol online health insurance lead buy Tramadol online with overnight delivery Tramadol no rx fed ex buy Tramadol without a perscription lowest prices for Tramadol online buy Tramadol paypal online without prescription cheap non prescription Tramadol Tramadol ups Tramadol for cheap buy Tramadol no visa online without prescription cheapest Tramadol cash on delivery Tramadol order a prepaid mastercard buy online Tramadol purchase Tramadol mail order Tramadol without a prescription online with overnight delivery Tramadol from canada buy Tramadol with no rx overnight delivery of Tramadol with no prescription cash on delivery Tramadol no rx Tramadol by cod buy Tramadol over the counter cod overnight overnight Tramadol order Tramadol without prescription from us pharmacy cheap Tramadol free fedex shipping order Tramadol over the counter where to buy Tramadol no prescription no fees only Tramadol free consult cod delivery Tramadol Tramadol no prescription Tramadol online overnight delivery cod order Tramadol over the counter fedex Tramadol saturday delivery buy Tramadol money order Tramadol without prescription mexico buy cheap Tramadol without prescription Tramadol non prescription for next day delivery Tramadol ups delivery only buy Tramadol usa cod Tramadol with next day delivery no prescriptions needed for Tramadol cheap Tramadol overnight prescription Tramadol cheap Tramadol overnight delivery Tramadol non prescription fedex overnight free order Tramadol no creditcard buy cheap Tramadol no Prescription buy Tramadol over the counter fedex Tramadol no doctor presribe needed cheap watson Tramadol online cheap discount Tramadol buy Tramadol without a prescription online cheapest Tramadol free delivery buy Tramadol online overseas buy Tramadol over the counter online not expensive Tramadol next day shipping order Tramadol cod next day delivery Tramadol cheap Tramadol buy in UK Tramadol next day cod fedex Tramadol to buy cheap order Tramadol next day Tramadol Tramadol overnight no consult cheap watson Tramadol no prescription needed Tramadol without prescription medications overnight delivery of Tramadol with no perscription buy Tramadol.com Tramadol cod next day delivery buy cheap discount online Tramadol buy Tramadol drug Tramadol overnight delivery cheap overnight delivery of Tramadol in US no prescription needed purchase Tramadol free next day airTramadol on line cheap Tramadol without a prescription Tramadol cheap cod Tramadol buy no prepaid cheap Tramadol next day buy Tramadol cod accepted online pharmacies Tramadol saturday delivery buy Tramadol pay pal Tramadol shipped on saturday Tramadol pharmacy cod saturday delivery buy online Tramadol prescriptions free fedex delivery Tramadol Tramadol without prescription cash on delivery buy discount Tramadol Tramadol overnight cheap best Tramadol online pill images of Tramadol Tramadol U.P.S SHIPPING COD Tramadol cod pharmacy buy Tramadol online cod Tramadol cod overnight delivery Tramadol no rx overnight buy Tramadol overnight COD online pharmacy Tramadol cod order Tramadol insurance Tramadol cash delivery cod buy Tramadol cheap cod no rx online pharmacy Tramadol sale nextday Tramadol Tramadol pill Tramadol online ordering Tramadol online without prescription Tramadol no script needed cod overnight how to buy Tramadol online without a prescription cheap Tramadol without prescription cheap Tramadol online no rx saturday delivery order Tramadol over the counter for sale Tramadol next day delivery cod order Tramadol online without prescription no prescription next day delivery Tramadol overnight Tramadol C.O.D Tramadol without prescription Tramadol discount fedex no prescription buy Tramadol amex Tramadol online next day Tramadol shipped with no prescription Tramadol online cheap cheap Tramadol without prescription overnight delivery buy Tramadol over the counter for sale Tramadol no prescriptions needed cod Tramadol fed ex cheap overnight delivery of Tramadol free prescription Tramadol free shipping not expensive legal Tramadol for sale buy Tramadol cod Tramadol for saturday Tramadol price cash for Tramadol cash on delivery Tramadol Tramadol without a prescription and cod delivery buying Tramadol without a prescription order Tramadol no rx buy Tramadol without rx Tramadol no prescription usa fedex shipping cheapest buy Tramadol online pharmacy buy cheap Tramadol overnight delivery Tramadol and online pharmacy Tramadol next day Tramadol drug no prescription where can i buy Tramadol no prescription Tramadol with saturday delivery Tramadol online overnight Tramadol no prescription worldwide buy cheap Tramadol cod ordering Tramadol online Buy Tramadol overnight shipping Tramadol overnight US delivery cheap real Tramadol for sale Tramadol no prescriptions needed COD buy Tramadol no prescription needed Tramadol no prescription overnight cod delivery cheap Tramadol cash on delivery no prescription required for Tramadol order Tramadol c.o.d. not expensive Tramadol prescriptions Tramadol online Cash on Delivery buy Tramadol overnight delivery Tramadol online without presciption buy Tramadol prescription online no prescription saturday delivery Tramadol where to buy cheap Tramadol no prescription Tramadol wo get Tramadol over the counter fedex Tramadol with no rx and free shipping order Tramadol over the counter cod overnight "Health is better than wealth", Tramadol and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 15:59:24 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 12:59:24 -0700 (PDT) Subject: Tramadol online saturday delivery , cheap online pharmacy Tramadol Message-ID: <256c844b-396d-43c3-8290-154a1f9037bc@googlegroups.com> Buy Tramadol online, Really amazing prices and Free bonuses! Tramadol BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Tramadol <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Tramadol http://drugeasy.biz/?q=Buy+online+Tramadol http://drugeasy.biz/?q=Buy+order+Tramadol http://drugeasy.biz/?q=Buy+Tramadol http://drugeasy.biz/?q=Buy+cheap+Tramadol http://drugeasy.biz/?q=Order+Tramadol http://drugeasy.biz/?q=Online+Tramadol * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Tramadol/Tramadol pills with every Order cheap online pharmacy Tramadol Tramadol online saturday delivery online Tramadol and fedex cheap order prescription Tramadol cheap Tramadol by money order buy Tramadol from mexico online Tramadol no prescription usa fedex shipping overnight delivery Tramadol buy Tramadol online without a prescription and no membership buy Tramadol paypal online without prescription Tramadol order a prepaid mastercard no prescription needed Tramadol cod shipped Tramadol not expensive order prescription Tramadol Tramadol money order Tramadol without a perscription online buy Tramadol Tramadol fedex buy no online prescription Tramadol Tramadol pharmacies accepting cod delivery Tramadol online consultant online pharmacy fedex cod Tramadol buy Tramadol no scams Tramadol c.o.d overnight delivery buy Tramadol no prescription cod overnight Tramadol order Tramadol online doctors buy Tramadol on line no prescription Tramadol no prescription usa fedex shipping Tramadol online uk watson brand Tramadol medicine online Tramadol order Tramadol samples sent buy Tramadol no prescription order Tramadol without a prescription Tramadol no prescription drug cheap online order Tramadol get Tramadol over the counter online order Tramadol next day buy Tramadol no perscription cod real Tramadol fed ex Tramadol no prescription cod does cv/ pharmacy carry Tramadol no prescription cod Tramadol cheap Tramadol without rx Tramadol online health insurance lead buy Tramadol online with overnight delivery Tramadol no rx fed ex buy Tramadol without a perscription lowest prices for Tramadol online buy Tramadol paypal online without prescription cheap non prescription Tramadol Tramadol ups Tramadol for cheap buy Tramadol no visa online without prescription cheapest Tramadol cash on delivery Tramadol order a prepaid mastercard buy online Tramadol purchase Tramadol mail order Tramadol without a prescription online with overnight delivery Tramadol from canada buy Tramadol with no rx overnight delivery of Tramadol with no prescription cash on delivery Tramadol no rx Tramadol by cod buy Tramadol over the counter cod overnight overnight Tramadol order Tramadol without prescription from us pharmacy cheap Tramadol free fedex shipping order Tramadol over the counter where to buy Tramadol no prescription no fees only Tramadol free consult cod delivery Tramadol Tramadol no prescription Tramadol online overnight delivery cod order Tramadol over the counter fedex Tramadol saturday delivery buy Tramadol money order Tramadol without prescription mexico buy cheap Tramadol without prescription Tramadol non prescription for next day delivery Tramadol ups delivery only buy Tramadol usa cod Tramadol with next day delivery no prescriptions needed for Tramadol cheap Tramadol overnight prescription Tramadol cheap Tramadol overnight delivery Tramadol non prescription fedex overnight free order Tramadol no creditcard buy cheap Tramadol no Prescription buy Tramadol over the counter fedex Tramadol no doctor presribe needed cheap watson Tramadol online cheap discount Tramadol buy Tramadol without a prescription online cheapest Tramadol free delivery buy Tramadol online overseas buy Tramadol over the counter online not expensive Tramadol next day shipping order Tramadol cod next day delivery Tramadol cheap Tramadol buy in UK Tramadol next day cod fedex Tramadol to buy cheap order Tramadol next day Tramadol Tramadol overnight no consult cheap watson Tramadol no prescription needed Tramadol without prescription medications overnight delivery of Tramadol with no perscription buy Tramadol.com Tramadol cod next day delivery buy cheap discount online Tramadol buy Tramadol drug Tramadol overnight delivery cheap overnight delivery of Tramadol in US no prescription needed purchase Tramadol free next day airTramadol on line cheap Tramadol without a prescription Tramadol cheap cod Tramadol buy no prepaid cheap Tramadol next day buy Tramadol cod accepted online pharmacies Tramadol saturday delivery buy Tramadol pay pal Tramadol shipped on saturday Tramadol pharmacy cod saturday delivery buy online Tramadol prescriptions free fedex delivery Tramadol Tramadol without prescription cash on delivery buy discount Tramadol Tramadol overnight cheap best Tramadol online pill images of Tramadol Tramadol U.P.S SHIPPING COD Tramadol cod pharmacy buy Tramadol online cod Tramadol cod overnight delivery Tramadol no rx overnight buy Tramadol overnight COD online pharmacy Tramadol cod order Tramadol insurance Tramadol cash delivery cod buy Tramadol cheap cod no rx online pharmacy Tramadol sale nextday Tramadol Tramadol pill Tramadol online ordering Tramadol online without prescription Tramadol no script needed cod overnight how to buy Tramadol online without a prescription cheap Tramadol without prescription cheap Tramadol online no rx saturday delivery order Tramadol over the counter for sale Tramadol next day delivery cod order Tramadol online without prescription no prescription next day delivery Tramadol overnight Tramadol C.O.D Tramadol without prescription Tramadol discount fedex no prescription buy Tramadol amex Tramadol online next day Tramadol shipped with no prescription Tramadol online cheap cheap Tramadol without prescription overnight delivery buy Tramadol over the counter for sale Tramadol no prescriptions needed cod Tramadol fed ex cheap overnight delivery of Tramadol free prescription Tramadol free shipping not expensive legal Tramadol for sale buy Tramadol cod Tramadol for saturday Tramadol price cash for Tramadol cash on delivery Tramadol Tramadol without a prescription and cod delivery buying Tramadol without a prescription order Tramadol no rx buy Tramadol without rx Tramadol no prescription usa fedex shipping cheapest buy Tramadol online pharmacy buy cheap Tramadol overnight delivery Tramadol and online pharmacy Tramadol next day Tramadol drug no prescription where can i buy Tramadol no prescription Tramadol with saturday delivery Tramadol online overnight Tramadol no prescription worldwide buy cheap Tramadol cod ordering Tramadol online Buy Tramadol overnight shipping Tramadol overnight US delivery cheap real Tramadol for sale Tramadol no prescriptions needed COD buy Tramadol no prescription needed Tramadol no prescription overnight cod delivery cheap Tramadol cash on delivery no prescription required for Tramadol order Tramadol c.o.d. not expensive Tramadol prescriptions Tramadol online Cash on Delivery buy Tramadol overnight delivery Tramadol online without presciption buy Tramadol prescription online no prescription saturday delivery Tramadol where to buy cheap Tramadol no prescription Tramadol wo get Tramadol over the counter fedex Tramadol with no rx and free shipping order Tramadol over the counter cod overnight "Health is better than wealth", Tramadol and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 16:00:27 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 13:00:27 -0700 (PDT) Subject: cheap Xanax without prescription overnight delivery, Xanax no prescription usa fedex shipping cheapest Message-ID: <7826a5eb-ac67-4973-b69f-f6e7c329ecc6@googlegroups.com> Buy Xanax online, Really amazing prices and Free bonuses! Xanax BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Xanax <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Xanax http://drugeasy.biz/?q=Buy+online+Xanax http://drugeasy.biz/?q=Buy+order+Xanax http://drugeasy.biz/?q=Buy+Xanax http://drugeasy.biz/?q=Buy+cheap+Xanax http://drugeasy.biz/?q=Order+Xanax http://drugeasy.biz/?q=Online+Xanax * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Xanax/Xanax pills with every Order cheap online pharmacy Xanax Xanax online saturday delivery online Xanax and fedex cheap order prescription Xanax cheap Xanax by money order buy Xanax from mexico online Xanax no prescription usa fedex shipping overnight delivery Xanax buy Xanax online without a prescription and no membership buy Xanax paypal online without prescription Xanax order a prepaid mastercard no prescription needed Xanax cod shipped Xanax not expensive order prescription Xanax Xanax money order Xanax without a perscription online buy Xanax Xanax fedex buy no online prescription Xanax Xanax pharmacies accepting cod delivery Xanax online consultant online pharmacy fedex cod Xanax buy Xanax no scams Xanax c.o.d overnight delivery buy Xanax no prescription cod overnight Xanax order Xanax online doctors buy Xanax on line no prescription Xanax no prescription usa fedex shipping Xanax online uk watson brand Xanax medicine online Xanax order Xanax samples sent buy Xanax no prescription order Xanax without a prescription Xanax no prescription drug cheap online order Xanax get Xanax over the counter online order Xanax next day buy Xanax no perscription cod real Xanax fed ex Xanax no prescription cod does cv/ pharmacy carry Xanax no prescription cod Xanax cheap Xanax without rx Xanax online health insurance lead buy Xanax online with overnight delivery Xanax no rx fed ex buy Xanax without a perscription lowest prices for Xanax online buy Xanax paypal online without prescription cheap non prescription Xanax Xanax ups Xanax for cheap buy Xanax no visa online without prescription cheapest Xanax cash on delivery Xanax order a prepaid mastercard buy online Xanax purchase Xanax mail order Xanax without a prescription online with overnight delivery Xanax from canada buy Xanax with no rx overnight delivery of Xanax with no prescription cash on delivery Xanax no rx Xanax by cod buy Xanax over the counter cod overnight overnight Xanax order Xanax without prescription from us pharmacy cheap Xanax free fedex shipping order Xanax over the counter where to buy Xanax no prescription no fees only Xanax free consult cod delivery Xanax Xanax no prescription Xanax online overnight delivery cod order Xanax over the counter fedex Xanax saturday delivery buy Xanax money order Xanax without prescription mexico buy cheap Xanax without prescription Xanax non prescription for next day delivery Xanax ups delivery only buy Xanax usa cod Xanax with next day delivery no prescriptions needed for Xanax cheap Xanax overnight prescription Xanax cheap Xanax overnight delivery Xanax non prescription fedex overnight free order Xanax no creditcard buy cheap Xanax no Prescription buy Xanax over the counter fedex Xanax no doctor presribe needed cheap watson Xanax online cheap discount Xanax buy Xanax without a prescription online cheapest Xanax free delivery buy Xanax online overseas buy Xanax over the counter online not expensive Xanax next day shipping order Xanax cod next day delivery Xanax cheap Xanax buy in UK Xanax next day cod fedex Xanax to buy cheap order Xanax next day Xanax Xanax overnight no consult cheap watson Xanax no prescription needed Xanax without prescription medications overnight delivery of Xanax with no perscription buy Xanax.com Xanax cod next day delivery buy cheap discount online Xanax buy Xanax drug Xanax overnight delivery cheap overnight delivery of Xanax in US no prescription needed purchase Xanax free next day airXanax on line cheap Xanax without a prescription Xanax cheap cod Xanax buy no prepaid cheap Xanax next day buy Xanax cod accepted online pharmacies Xanax saturday delivery buy Xanax pay pal Xanax shipped on saturday Xanax pharmacy cod saturday delivery buy online Xanax prescriptions free fedex delivery Xanax Xanax without prescription cash on delivery buy discount Xanax Xanax overnight cheap best Xanax online pill images of Xanax Xanax U.P.S SHIPPING COD Xanax cod pharmacy buy Xanax online cod Xanax cod overnight delivery Xanax no rx overnight buy Xanax overnight COD online pharmacy Xanax cod order Xanax insurance Xanax cash delivery cod buy Xanax cheap cod no rx online pharmacy Xanax sale nextday Xanax Xanax pill Xanax online ordering Xanax online without prescription Xanax no script needed cod overnight how to buy Xanax online without a prescription cheap Xanax without prescription cheap Xanax online no rx saturday delivery order Xanax over the counter for sale Xanax next day delivery cod order Xanax online without prescription no prescription next day delivery Xanax overnight Xanax C.O.D Xanax without prescription Xanax discount fedex no prescription buy Xanax amex Xanax online next day Xanax shipped with no prescription Xanax online cheap cheap Xanax without prescription overnight delivery buy Xanax over the counter for sale Xanax no prescriptions needed cod Xanax fed ex cheap overnight delivery of Xanax free prescription Xanax free shipping not expensive legal Xanax for sale buy Xanax cod Xanax for saturday Xanax price cash for Xanax cash on delivery Xanax Xanax without a prescription and cod delivery buying Xanax without a prescription order Xanax no rx buy Xanax without rx Xanax no prescription usa fedex shipping cheapest buy Xanax online pharmacy buy cheap Xanax overnight delivery Xanax and online pharmacy Xanax next day Xanax drug no prescription where can i buy Xanax no prescription Xanax with saturday delivery Xanax online overnight Xanax no prescription worldwide buy cheap Xanax cod ordering Xanax online Buy Xanax overnight shipping Xanax overnight US delivery cheap real Xanax for sale Xanax no prescriptions needed COD buy Xanax no prescription needed Xanax no prescription overnight cod delivery cheap Xanax cash on delivery no prescription required for Xanax order Xanax c.o.d. not expensive Xanax prescriptions Xanax online Cash on Delivery buy Xanax overnight delivery Xanax online without presciption buy Xanax prescription online no prescription saturday delivery Xanax where to buy cheap Xanax no prescription Xanax wo get Xanax over the counter fedex Xanax with no rx and free shipping order Xanax over the counter cod overnight "Health is better than wealth", Xanax and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 16:01:08 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 13:01:08 -0700 (PDT) Subject: buy Xanax with no rx | overnight delivery of Xanax with no prescription Message-ID: <9a207e02-b4a4-496d-89c1-01ad92875f76@googlegroups.com> Buy Xanax online, Really amazing prices and Free bonuses! Xanax BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Xanax <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Xanax http://drugeasy.biz/?q=Buy+online+Xanax http://drugeasy.biz/?q=Buy+order+Xanax http://drugeasy.biz/?q=Buy+Xanax http://drugeasy.biz/?q=Buy+cheap+Xanax http://drugeasy.biz/?q=Order+Xanax http://drugeasy.biz/?q=Online+Xanax * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Xanax/Xanax pills with every Order cheap online pharmacy Xanax Xanax online saturday delivery online Xanax and fedex cheap order prescription Xanax cheap Xanax by money order buy Xanax from mexico online Xanax no prescription usa fedex shipping overnight delivery Xanax buy Xanax online without a prescription and no membership buy Xanax paypal online without prescription Xanax order a prepaid mastercard no prescription needed Xanax cod shipped Xanax not expensive order prescription Xanax Xanax money order Xanax without a perscription online buy Xanax Xanax fedex buy no online prescription Xanax Xanax pharmacies accepting cod delivery Xanax online consultant online pharmacy fedex cod Xanax buy Xanax no scams Xanax c.o.d overnight delivery buy Xanax no prescription cod overnight Xanax order Xanax online doctors buy Xanax on line no prescription Xanax no prescription usa fedex shipping Xanax online uk watson brand Xanax medicine online Xanax order Xanax samples sent buy Xanax no prescription order Xanax without a prescription Xanax no prescription drug cheap online order Xanax get Xanax over the counter online order Xanax next day buy Xanax no perscription cod real Xanax fed ex Xanax no prescription cod does cv/ pharmacy carry Xanax no prescription cod Xanax cheap Xanax without rx Xanax online health insurance lead buy Xanax online with overnight delivery Xanax no rx fed ex buy Xanax without a perscription lowest prices for Xanax online buy Xanax paypal online without prescription cheap non prescription Xanax Xanax ups Xanax for cheap buy Xanax no visa online without prescription cheapest Xanax cash on delivery Xanax order a prepaid mastercard buy online Xanax purchase Xanax mail order Xanax without a prescription online with overnight delivery Xanax from canada buy Xanax with no rx overnight delivery of Xanax with no prescription cash on delivery Xanax no rx Xanax by cod buy Xanax over the counter cod overnight overnight Xanax order Xanax without prescription from us pharmacy cheap Xanax free fedex shipping order Xanax over the counter where to buy Xanax no prescription no fees only Xanax free consult cod delivery Xanax Xanax no prescription Xanax online overnight delivery cod order Xanax over the counter fedex Xanax saturday delivery buy Xanax money order Xanax without prescription mexico buy cheap Xanax without prescription Xanax non prescription for next day delivery Xanax ups delivery only buy Xanax usa cod Xanax with next day delivery no prescriptions needed for Xanax cheap Xanax overnight prescription Xanax cheap Xanax overnight delivery Xanax non prescription fedex overnight free order Xanax no creditcard buy cheap Xanax no Prescription buy Xanax over the counter fedex Xanax no doctor presribe needed cheap watson Xanax online cheap discount Xanax buy Xanax without a prescription online cheapest Xanax free delivery buy Xanax online overseas buy Xanax over the counter online not expensive Xanax next day shipping order Xanax cod next day delivery Xanax cheap Xanax buy in UK Xanax next day cod fedex Xanax to buy cheap order Xanax next day Xanax Xanax overnight no consult cheap watson Xanax no prescription needed Xanax without prescription medications overnight delivery of Xanax with no perscription buy Xanax.com Xanax cod next day delivery buy cheap discount online Xanax buy Xanax drug Xanax overnight delivery cheap overnight delivery of Xanax in US no prescription needed purchase Xanax free next day airXanax on line cheap Xanax without a prescription Xanax cheap cod Xanax buy no prepaid cheap Xanax next day buy Xanax cod accepted online pharmacies Xanax saturday delivery buy Xanax pay pal Xanax shipped on saturday Xanax pharmacy cod saturday delivery buy online Xanax prescriptions free fedex delivery Xanax Xanax without prescription cash on delivery buy discount Xanax Xanax overnight cheap best Xanax online pill images of Xanax Xanax U.P.S SHIPPING COD Xanax cod pharmacy buy Xanax online cod Xanax cod overnight delivery Xanax no rx overnight buy Xanax overnight COD online pharmacy Xanax cod order Xanax insurance Xanax cash delivery cod buy Xanax cheap cod no rx online pharmacy Xanax sale nextday Xanax Xanax pill Xanax online ordering Xanax online without prescription Xanax no script needed cod overnight how to buy Xanax online without a prescription cheap Xanax without prescription cheap Xanax online no rx saturday delivery order Xanax over the counter for sale Xanax next day delivery cod order Xanax online without prescription no prescription next day delivery Xanax overnight Xanax C.O.D Xanax without prescription Xanax discount fedex no prescription buy Xanax amex Xanax online next day Xanax shipped with no prescription Xanax online cheap cheap Xanax without prescription overnight delivery buy Xanax over the counter for sale Xanax no prescriptions needed cod Xanax fed ex cheap overnight delivery of Xanax free prescription Xanax free shipping not expensive legal Xanax for sale buy Xanax cod Xanax for saturday Xanax price cash for Xanax cash on delivery Xanax Xanax without a prescription and cod delivery buying Xanax without a prescription order Xanax no rx buy Xanax without rx Xanax no prescription usa fedex shipping cheapest buy Xanax online pharmacy buy cheap Xanax overnight delivery Xanax and online pharmacy Xanax next day Xanax drug no prescription where can i buy Xanax no prescription Xanax with saturday delivery Xanax online overnight Xanax no prescription worldwide buy cheap Xanax cod ordering Xanax online Buy Xanax overnight shipping Xanax overnight US delivery cheap real Xanax for sale Xanax no prescriptions needed COD buy Xanax no prescription needed Xanax no prescription overnight cod delivery cheap Xanax cash on delivery no prescription required for Xanax order Xanax c.o.d. not expensive Xanax prescriptions Xanax online Cash on Delivery buy Xanax overnight delivery Xanax online without presciption buy Xanax prescription online no prescription saturday delivery Xanax where to buy cheap Xanax no prescription Xanax wo get Xanax over the counter fedex Xanax with no rx and free shipping order Xanax over the counter cod overnight "Health is better than wealth", Xanax and enjoy! d446ca From numansenm at gmail.com Wed Jul 16 16:02:11 2014 From: numansenm at gmail.com (Sedab Bunay) Date: Wed, 16 Jul 2014 13:02:11 -0700 (PDT) Subject: online pharmacies Cialis saturday delivery, purchase Cialis free next day airCialis on line Message-ID: <8ae378fc-853b-4c8d-815f-eeabb088bfb3@googlegroups.com> Buy Cialis online, Really amazing prices and Free bonuses! Cialis BEST SITES FOUND! Just FOLLOW url below! ********************************************** >>> http://drugeasy.biz/?q=Cialis <<< - CLICK HERE! ********************************************** Full information about usage, dosage, Buy online, discounts and more other! http://drugeasy.biz/?q=Cialis http://drugeasy.biz/?q=Buy+online+Cialis http://drugeasy.biz/?q=Buy+order+Cialis http://drugeasy.biz/?q=Buy+Cialis http://drugeasy.biz/?q=Buy+cheap+Cialis http://drugeasy.biz/?q=Order+Cialis http://drugeasy.biz/?q=Online+Cialis * Special Internet Prices (up to 40% off average US price) * Best quality drugs * NO PRIOR PRESCRIPTION NEEDED! * 100% Anonimity & Discreet shipping * Fast FREE shipping (4 to 7 days) * Loyalty program * Friendly customer support * 4 Free Cialis/Cialis pills with every Order cheap online pharmacy Cialis Cialis online saturday delivery online Cialis and fedex cheap order prescription Cialis cheap Cialis by money order buy Cialis from mexico online Cialis no prescription usa fedex shipping overnight delivery Cialis buy Cialis online without a prescription and no membership buy Cialis paypal online without prescription Cialis order a prepaid mastercard no prescription needed Cialis cod shipped Cialis not expensive order prescription Cialis Cialis money order Cialis without a perscription online buy Cialis Cialis fedex buy no online prescription Cialis Cialis pharmacies accepting cod delivery Cialis online consultant online pharmacy fedex cod Cialis buy Cialis no scams Cialis c.o.d overnight delivery buy Cialis no prescription cod overnight Cialis order Cialis online doctors buy Cialis on line no prescription Cialis no prescription usa fedex shipping Cialis online uk watson brand Cialis medicine online Cialis order Cialis samples sent buy Cialis no prescription order Cialis without a prescription Cialis no prescription drug cheap online order Cialis get Cialis over the counter online order Cialis next day buy Cialis no perscription cod real Cialis fed ex Cialis no prescription cod does cv/ pharmacy carry Cialis no prescription cod Cialis cheap Cialis without rx Cialis online health insurance lead buy Cialis online with overnight delivery Cialis no rx fed ex buy Cialis without a perscription lowest prices for Cialis online buy Cialis paypal online without prescription cheap non prescription Cialis Cialis ups Cialis for cheap buy Cialis no visa online without prescription cheapest Cialis cash on delivery Cialis order a prepaid mastercard buy online Cialis purchase Cialis mail order Cialis without a prescription online with overnight delivery Cialis from canada buy Cialis with no rx overnight delivery of Cialis with no prescription cash on delivery Cialis no rx Cialis by cod buy Cialis over the counter cod overnight overnight Cialis order Cialis without prescription from us pharmacy cheap Cialis free fedex shipping order Cialis over the counter where to buy Cialis no prescription no fees only Cialis free consult cod delivery Cialis Cialis no prescription Cialis online overnight delivery cod order Cialis over the counter fedex Cialis saturday delivery buy Cialis money order Cialis without prescription mexico buy cheap Cialis without prescription Cialis non prescription for next day delivery Cialis ups delivery only buy Cialis usa cod Cialis with next day delivery no prescriptions needed for Cialis cheap Cialis overnight prescription Cialis cheap Cialis overnight delivery Cialis non prescription fedex overnight free order Cialis no creditcard buy cheap Cialis no Prescription buy Cialis over the counter fedex Cialis no doctor presribe needed cheap watson Cialis online cheap discount Cialis buy Cialis without a prescription online cheapest Cialis free delivery buy Cialis online overseas buy Cialis over the counter online not expensive Cialis next day shipping order Cialis cod next day delivery Cialis cheap Cialis buy in UK Cialis next day cod fedex Cialis to buy cheap order Cialis next day Cialis Cialis overnight no consult cheap watson Cialis no prescription needed Cialis without prescription medications overnight delivery of Cialis with no perscription buy Cialis.com Cialis cod next day delivery buy cheap discount online Cialis buy Cialis drug Cialis overnight delivery cheap overnight delivery of Cialis in US no prescription needed purchase Cialis free next day airCialis on line cheap Cialis without a prescription Cialis cheap cod Cialis buy no prepaid cheap Cialis next day buy Cialis cod accepted online pharmacies Cialis saturday delivery buy Cialis pay pal Cialis shipped on saturday Cialis pharmacy cod saturday delivery buy online Cialis prescriptions free fedex delivery Cialis Cialis without prescription cash on delivery buy discount Cialis Cialis overnight cheap best Cialis online pill images of Cialis Cialis U.P.S SHIPPING COD Cialis cod pharmacy buy Cialis online cod Cialis cod overnight delivery Cialis no rx overnight buy Cialis overnight COD online pharmacy Cialis cod order Cialis insurance Cialis cash delivery cod buy Cialis cheap cod no rx online pharmacy Cialis sale nextday Cialis Cialis pill Cialis online ordering Cialis online without prescription Cialis no script needed cod overnight how to buy Cialis online without a prescription cheap Cialis without prescription cheap Cialis online no rx saturday delivery order Cialis over the counter for sale Cialis next day delivery cod order Cialis online without prescription no prescription next day delivery Cialis overnight Cialis C.O.D Cialis without prescription Cialis discount fedex no prescription buy Cialis amex Cialis online next day Cialis shipped with no prescription Cialis online cheap cheap Cialis without prescription overnight delivery buy Cialis over the counter for sale Cialis no prescriptions needed cod Cialis fed ex cheap overnight delivery of Cialis free prescription Cialis free shipping not expensive legal Cialis for sale buy Cialis cod Cialis for saturday Cialis price cash for Cialis cash on delivery Cialis Cialis without a prescription and cod delivery buying Cialis without a prescription order Cialis no rx buy Cialis without rx Cialis no prescription usa fedex shipping cheapest buy Cialis online pharmacy buy cheap Cialis overnight delivery Cialis and online pharmacy Cialis next day Cialis drug no prescription where can i buy Cialis no prescription Cialis with saturday delivery Cialis online overnight Cialis no prescription worldwide buy cheap Cialis cod ordering Cialis online Buy Cialis overnight shipping Cialis overnight US delivery cheap real Cialis for sale Cialis no prescriptions needed COD buy Cialis no prescription needed Cialis no prescription overnight cod delivery cheap Cialis cash on delivery no prescription required for Cialis order Cialis c.o.d. not expensive Cialis prescriptions Cialis online Cash on Delivery buy Cialis overnight delivery Cialis online without presciption buy Cialis prescription online no prescription saturday delivery Cialis where to buy cheap Cialis no prescription Cialis wo get Cialis over the counter fedex Cialis with no rx and free shipping order Cialis over the counter cod overnight "Health is better than wealth", Cialis and enjoy! d446ca From breamoreboy at yahoo.co.uk Wed Jul 16 16:27:04 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Wed, 16 Jul 2014 21:27:04 +0100 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On 16/07/2014 20:24, Jason Swails wrote: > > On Wed, Jul 16, 2014 at 11:40 AM, Mark Lawrence > wrote: > > On 16/07/2014 18:32, Deb Wyatt wrote: > > Can you all stop already with the non python US bashing? Please? > > Deb in WA, USA > > > rr started it with a fairly impressive piece of trolling but as > you've asked so politely I will happily oblige. > > ?I honestly don't understand why you haven't kill-filed him yet. I can > understand people wanting to respond to jmf to prevent newbies and the > Unicode-ignorant from thinking the FSR is not a good thing (or > fundamentally wrong), although I've killfiled him as well. [1] But > nobody will confuse rr's posts with something of value (their only > possible use can be to populate > http://en.wikipedia.org/wiki/List_of_logical_fallacies and > http://en.wikipedia.org/wiki/Ad_hominem). There's nobody to protect > from rr-induced misconceptions. [http://xkcd.com/386/] > > My life lurking and learning on Python-list has been dramatically > improved since I began to instantiate filters, I highly recommend it. > > Cheers, > Jason > > [1] Seen one and you've seen them all, and I'm no unicode expert. > The difference between our most illustrious resident unicode expert and rr is that the former has only said anything of use once, whereas the latter does know about tkinter/IDLE. rr doesn't show up that often, the MIRUC has been spewing his mistruths for nearly two years and IMHO should have been booted into touch a long time ago. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From skip at pobox.com Wed Jul 16 16:40:34 2014 From: skip at pobox.com (Skip Montanaro) Date: Wed, 16 Jul 2014 15:40:34 -0500 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Wed, Jul 16, 2014 at 3:27 PM, Mark Lawrence wrote: > The difference between our most illustrious resident unicode expert and rr Sorry, who is "rr"? I went looking in the referenced thread but found nobody with those initials. Not so helpfully, Gmail elides most sigs, so I couldn't reliably scan the full text either. Thx, Skip From tjreedy at udel.edu Wed Jul 16 17:02:42 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Jul 2014 17:02:42 -0400 Subject: Python 3 is killing Python In-Reply-To: <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/16/2014 3:49 AM, Steven D'Aprano wrote: > There are certainly use-cases for stdin and stdout to use bytes, but > there are also use-cases for them to deal with strings. I'll certainly > grant you that there ought to be an easy way to get access to the binary > streams, As has been discussed before on this list, there is in 3.x. https://docs.python.org/3/library/sys.html#sys.stdin >>> b=sys.stdin.buffer.readline() a line >>> b b'a line\r\n' In other words, 3.x text mode (which essentially nothing to do with 2.x 'text' mode), is a wrapped binary mode that gives users the *choice* to read bytes or text. -- Terry Jan Reedy From python at mrabarnett.plus.com Wed Jul 16 17:32:49 2014 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 16 Jul 2014 22:32:49 +0100 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: <53C6EF81.8030709@mrabarnett.plus.com> On 2014-07-16 21:40, Skip Montanaro wrote: > On Wed, Jul 16, 2014 at 3:27 PM, Mark Lawrence wrote: >> The difference between our most illustrious resident unicode expert and rr > > Sorry, who is "rr"? I went looking in the referenced thread but found > nobody with those initials. Not so helpfully, Gmail elides most sigs, > so I couldn't reliably scan the full text either. > "rr" is "rantingrickjohnson at ...". From ethan at stoneleaf.us Wed Jul 16 17:35:57 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 16 Jul 2014 14:35:57 -0700 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: <53C6EF81.8030709@mrabarnett.plus.com> References: <53C6EF81.8030709@mrabarnett.plus.com> Message-ID: <53C6F03D.3060701@stoneleaf.us> On 07/16/2014 02:32 PM, MRAB wrote: > On 2014-07-16 21:40, Skip Montanaro wrote: >> >> Sorry, who is "rr"? I went looking in the referenced thread but found >> nobody with those initials. Not so helpfully, Gmail elides most sigs, >> so I couldn't reliably scan the full text either. >> > "rr" is "rantingrickjohnson at ...". As someone just recently said, "The clue is in the name." ;) -- ~Ethan~ From rantingrickjohnson at gmail.com Wed Jul 16 18:41:38 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 16 Jul 2014 15:41:38 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Wednesday, July 16, 2014 9:27:56 AM UTC-5, Frank Millman wrote: > 2. Those adversely affected by the change are very vocal, > but we hear very little from those who have benefited from > it. This is to be expected - they are just getting on with > developing in Python3 and have no need to get involved in > controversies. And those that "vote with their feet" are not vocal either. Now, you might think: "Why do i *I* care if people start using other languages?", Well, if you enjoy writing Python code, and understand (like i do) that Python is truly valuable to the programming community, then you should also understand that as the number of members drop, so too does the "collective intelligence" of the community. Not to mention that at some point, when the numbers get low *enough*, maintaining a project as big as Python becomes untenable. Of course, no community or project can expect expansion of members "forever", but the last thing you want is people running away from your project. At a minimum, you want to maintain a reasonable "average" of community members. I personally know of few major software developers, who whilst "shopping" for a scripting language for their API, wanted to integrate Python because of it's clean syntax and auto-encapsulation, but they where forced to choose *another* language because of all the headaches that backwards incompatibility of Python 3000 would induce in the users of the API. From tjreedy at udel.edu Wed Jul 16 18:47:37 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 16 Jul 2014 18:47:37 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/16/2014 5:02 PM, Terry Reedy wrote: > On 7/16/2014 3:49 AM, Steven D'Aprano wrote: > >> There are certainly use-cases for stdin and stdout to use bytes, but >> there are also use-cases for them to deal with strings. I'll certainly >> grant you that there ought to be an easy way to get access to the binary >> streams, > > As has been discussed before on this list, there is in 3.x. > https://docs.python.org/3/library/sys.html#sys.stdin > > >>> b=sys.stdin.buffer.readline() > a line > >>> b > b'a line\r\n' > > In other words, 3.x text mode (which essentially nothing to do with 2.x > 'text' mode), is a wrapped binary mode that gives users the *choice* to > read bytes or text. One can also convert a stream permanently with .detach() >>> import sys >>> sys.stdin = sys.stdin.detach() >>> b = sys.stdin.readline() a line >>> b b'a line\r\n' This does diable the input() function ;-). >>> b = input() Traceback (most recent call last): File "", line 1, in AttributeError: '_io.BufferedReader' object has no attribute 'errors' -- Terry Jan Reedy From breamoreboy at yahoo.co.uk Wed Jul 16 19:00:16 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 17 Jul 2014 00:00:16 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On 16/07/2014 23:41, Rick Johnson wrote: > > Not to mention that at some point, when the numbers get low > *enough*, maintaining a project as big as Python becomes > untenable. > I'm not aware of any mass exodus from core Python 3 to the fork that has consistently proposed to give the world Python 2.8. Do you know something that I don't? Further the number of people assisting on the bug tracker at the moment appears to me to be going up, not down. It therefore strikes me that Python is extremely tenable, thus indicating that people are not falling for the FUD about Python 2 versus Python 3. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From maximesteisel at gmail.com Wed Jul 16 19:09:02 2014 From: maximesteisel at gmail.com (Maxime Steisel) Date: Thu, 17 Jul 2014 01:09:02 +0200 Subject: Anything better than asyncio.as_completed() and asyncio.wait() to manage execution of large amount of tasks? In-Reply-To: References: Message-ID: 2014-07-15 14:20 GMT+02:00 Valery Khamenya : > Hi, > > both asyncio.as_completed() and asyncio.wait() work with lists only. No > generators are accepted. Are there anything similar to those functions that > pulls Tasks/Futures/coroutines one-by-one and processes them in a limited > task pool? Something like this (adapted from as_completed) should do the work: import asyncio from concurrent import futures def parallelize(tasks, *, loop=None, max_workers=5, timeout=None): loop = loop if loop is not None else asyncio.get_event_loop() workers = [] pending = set() done = asyncio.Queue(maxsize=max_workers) exhausted = False @asyncio.coroutine def _worker(): nonlocal exhausted while not exhausted: try: t = next(tasks) pending.add(t) yield from t yield from done.put(t) pending.remove(t) except StopIteration: exhausted = True def _on_timeout(): for f in workers: f.cancel() workers.clear() #Wake up _wait_for_one() done.put_nowait(None) @asyncio.coroutine def _wait_for_one(): f = yield from done.get() if f is None: raise futures.TimeoutError() return f.result() workers = [asyncio.async(_worker()) for i in range(max_workers)] if workers and timeout is not None: timeout_handle = loop.call_later(timeout, _on_timeout) while not exhausted or pending or not done.empty(): yield _wait_for_one() timeout_handle.cancel() From rantingrickjohnson at gmail.com Wed Jul 16 21:16:16 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 16 Jul 2014 18:16:16 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> On Wednesday, July 16, 2014 6:00:16 PM UTC-5, Mark Lawrence wrote: > I'm not aware of any mass exodus from core Python 3 to the > fork that has consistently proposed to give the world > Python 2.8. Do you know something that I don't? Well, currently at least, we don't even *need* a Python 2.8, not for the next couple of years anyway. But i think that when the time arrives, the "someone", or "some entity" will inevitably decide that, whilst Python2.x was the best high level language available to date, it has many flaws that cannot be worked around "cleanly", so instead of continuing on with Python "as-is", we should take all the good ideas of Python, plus all the good ideas of Ruby, plus few good ideas in Perl, Javascript, etc... and create a *whole* new language that will supersede them all. BECAUSE REMEMBER, EVOLUTION IS A GOOD THING! This is what i wished the Python dev *would* have devoted their energies to, not the abortion of "Python3" we have today. Look, i don't mean to dismiss all the difficult work invoked in creating Python3, but i just cannot support something that is a lackluster improvement at best. If we're going to break Python, let's do it "correctly". You see, people just hate updating code for what is basically the same language. HOWEVER, if you give them a *new* language, that is an "intelligent evolution" of the old language, then they will be *EXCITED* to write code again. > Further the number of people assisting on the bug tracker > at the moment appears to me to be going up, not down. It > therefore strikes me that Python is extremely tenable, > thus indicating that people are not falling for the FUD > about Python 2 versus Python 3. Again, your "metrics", are tainted. I believe the spike in bug reports has less to do with: "New community members jumping in to help" And more to do with: "Damn, this Python3 is buggy and i need to tell someone so i can get my customers off my back and this egg off my face, lest my feet move faster than Fred Flintstone!" From jason.swails at gmail.com Wed Jul 16 22:44:19 2014 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 16 Jul 2014 19:44:19 -0700 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Wed, Jul 16, 2014 at 1:27 PM, Mark Lawrence wrote: > > The difference between our most illustrious resident unicode expert and rr > is that the former has only said anything of use once, whereas the latter > does know about tkinter/IDLE. rr doesn't show up that often, the MIRUC has > been spewing his mistruths for nearly two years and IMHO should have been > booted into touch a long time ago. "Know about" is awfully vague. Start with 5 things: 1) A browser opened to effbot 2) An open python interpreter 3) A willingness to build widgets and widget collections as Frame subclasses 4) A willingness to fingerpaint with Canvas objects to create custom widgets 5) A useful(ish) program to write Within a couple hours I learned everything I later saw in all of rr's Tkinter posts, albeit without the irrelevant condescension. (I've written 3 Tkinter-based GUIs, all simple... I'm no expert with it.) But that's quite beside the point. When rr says something 'useful' about using Python, he probably doesn't need to be corrected. When he doesn't, it's often incoherent verbiage with big words, flashy/illogical/outrageous comparisons, and ad hominem attacks aimed at everyone that's disagreed with him on the interwebs. While I occasionally found it satisfying to fire back and bask in my own logical and moral superiority, the little corner of my life I devote to python-list is far more peaceful and fulfilling (not to mention productive) now. One last opinion before I sign off on this thread, I make an active effort to attach my name to useful contributions on the web and cut down on the useless. I don't want my name associated with the idea "a lot of what he sends is useless ranting or useless retaliation thereof". With the volume of material available on the web, I try to be careful not to make a poor impression with anything I author (although that is unavoidable sometimes). All the best, Jason P.S. And nobody will think you're just like if you don't bite back in a public forum. -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve at pearwood.info Wed Jul 16 22:51:56 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 02:51:56 GMT Subject: Python 3 is killing Python References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> <8761ix4859.fsf@elektro.pacujo.net> <871ttl46o1.fsf@elektro.pacujo.net> Message-ID: <53c73a4c$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 19:20:14 +0300, Marko Rauhamaa wrote: > Chris Angelico : > >> The only thing that might be an issue is that you can't use open(fn) to >> read your files, but you have to explicitly state the encoding. That >> would be an understandable problem, especially for someone who develops >> on a single platform and forgets that the default differs. As long as >> you always explicitly say encoding="utf-8", and document that you do >> so, any problems are someone else's. > > Yes. I don't like open() guessing the enconding: It doesn't *guess*. It has a sensible default encoding which, for most users most of the time, does the right thing. Ultimately though, the encoding is under your control: you can specify it if you think you know better. > The default encoding is platform dependent (whatever > locale.getpreferredencoding() returns) Right. Most text files will be written using the preferred encoding, unless the user explicitly uses something else when writing the file. In that case it's the user's responsibility. Or if they've got the file from another system with a different encoding. But even then, the most common encodings are ASCII-compatible, which means that the lowest common denominator case (reading and writing ASCII files) will Just Work. >From a purity stand-point, no, open() shouldn't have a default encoding, and the user should have to specify it. But what makes you imagine that the user will know the correct encoding better than Python does? The average coder[1] shouldn't have to care about encodings just to do file.write("Hello World"), and on the average computer they don't have to because Python sets a sensible default. But you know what? From a purity stand-point, *even binary mode* assumes an encoding of sorts. How do you know that binary files on your platform use eight-bit bytes? Some DSPs use 9-bit bytes, and historically computers had as few as 6 or as many as 60 bits per byte. This is why the C standard requires that a byte is *at least* 8 bits. But, having said that, the assumption that binary files are based on 8- bit bytes is pretty safe. It would be foolish to force the majority of people, who don't need to care about these sorts of details, to care about them just to suit the one in ten-thousand who do. Likewise with text files. Python makes sensible defaults which will suit most people, rather than force people to guess the wrong encoding. But it's only a default, you can explicitly set it if you believe the file in question uses a different encoding. [...] > In each case, it would have been better to default to bytes just like > subprocess does. Better for whom? You? Maybe. For the typical programmer that Python is designed for? Hell no. [1] Lets be honest, there still is a bias towards English and ASCII in computing, and probably this will remain the case until English ceases to be a de facto lingua franca. Most programming languages are written for J. Random Hacker, not J????????. -- Steven From steve at pearwood.info Wed Jul 16 23:14:24 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 03:14:24 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> Message-ID: <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 18:16:16 -0700, Rick Johnson wrote: > On Wednesday, July 16, 2014 6:00:16 PM UTC-5, Mark Lawrence wrote: >> I'm not aware of any mass exodus from core Python 3 to the fork that >> has consistently proposed to give the world Python 2.8. Do you know >> something that I don't? > > Well, currently at least, we don't even *need* a Python 2.8, not for the > next couple of years anyway. There will never be a Python 2.8. When push comes to shove, the people bitching about Python 3 will not do the work necessary to fork Python 2.7 and make a version 2.8. -- Steven From rosuav at gmail.com Wed Jul 16 23:15:37 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 13:15:37 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c73a4c$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> <8761ix4859.fsf@elektro.pacujo.net> <871ttl46o1.fsf@elektro.pacujo.net> <53c73a4c$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 17, 2014 at 12:51 PM, Steven D'Aprano wrote: > Most programming languages are written for > J. Random Hacker, not J????????. I had to paste that into Google Translate to be able to understand what you meant (although I could guess just fine)... but to actually see the characters, I had to paste it into my MUD client. Yeah. Figure that out. A MUD client had better font support for other languages than a web browser with a dedicated translation tool. ChrisA From steve at pearwood.info Wed Jul 16 23:16:00 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 03:16:00 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 15:41:38 -0700, Rick Johnson wrote: > I personally know of few major software developers, who whilst > "shopping" for a scripting language for their API, wanted to integrate > Python because of it's clean syntax and auto-encapsulation, but they > where forced to choose *another* language because of all the headaches > that backwards incompatibility of Python 3000 would induce in the users > of the API. Oh Really? I call bullshit. Name names. Name projects. If they are "shopping" for a scripting language, that means they don't have one yet. Which means their users have no existing scripts that need to be ported from Python 2 to 3. Whatever language is chosen, whether it is Ruby, Lua, Python 3 or something else, its all equally as new. -- Steven From rosuav at gmail.com Wed Jul 16 23:20:57 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 13:20:57 +1000 Subject: Python 3 is killing Python In-Reply-To: <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 11:16 AM, Rick Johnson wrote: > But i think that when the time arrives, the "someone", or > "some entity" will inevitably decide that, whilst Python2.x > was the best high level language available to date, it has > many flaws that cannot be worked around "cleanly", so > instead of continuing on with Python "as-is", we should take > all the good ideas of Python, plus all the good ideas of > Ruby, plus few good ideas in Perl, Javascript, etc... and > create a *whole* new language that will supersede them all. > > BECAUSE REMEMBER, EVOLUTION IS A GOOD THING! Let 'em. If you believe evolution is such a good thing, you're most welcome to arrange it. Personally, I believe that *guided development* is a good thing, and whaddayaknow, that's exactly what we have here from GvR and from the python-dev team. Proper development of a large or small project requires an intelligent person with a hand on the tiller, not randomly undirected additions (or, perhaps not "undirected" so much as "directed by every single whining mailing list post" - which is the same thing, really); someone needs to decide which ideas are good and which are bad. Undirected evolution is destructive. Directed cultivation is constructive. ChrisA From jason.swails at gmail.com Wed Jul 16 23:24:37 2014 From: jason.swails at gmail.com (Jason Swails) Date: Wed, 16 Jul 2014 20:24:37 -0700 Subject: networkx plot random graph Error In-Reply-To: <0d48b8fc-0ed0-434f-8004-5e0ff3693171@googlegroups.com> References: <0d48b8fc-0ed0-434f-8004-5e0ff3693171@googlegroups.com> Message-ID: <7EAADFAF-F959-4AE6-9E8D-099753CE17CD@gmail.com> On Jul 15, 2014, at 3:11 AM, u2107 wrote: > I am trying to read a file with 3 columns with col 1 and 2 as nodes/edges and column 3 as weight (value with decimal) > > I am trying to execute this code > > > import networkx as nx > > > G = nx.read_edgelist('file.txt', data=[("weight")]) > G.edges(data=True) > > edge_labels = dict(((u, v), d["weight"]) for u, v, d in G.edges(data=True)) > pos = nx.random_layout(G) > nx.draw(G, pos) > nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels) > > import matplotlib.pyplot as plt; plt.show() > > > > Error: > > File "graph_one.py", line 4, in > G = nx.read_edgelist('File.txt', data=[("weight")]) > File "", line 2, in read_edgelist > File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 241, in _open_file > fobj = _dispatch_dict[ext](path, mode=mode) > IOError: [Errno 2] No such file or directory: 'contactUSC_nodes_diff_small.txt' This looks like some file didn't exist which probably should have. The next line looks like you may have fixed the problem and then run the command again? Is this part of the error message? Including stuff like this is confusing (to me, at least). > lavanya at peerformance:~/Desktop/INRIA_Papers/Python$ python graph_one.py > Traceback (most recent call last): > File "graph_one.py", line 4, in > G = nx.read_edgelist('contactUSC_node_diff_small.txt', data=[("weight")]) > File "", line 2, in read_edgelist > File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/utils/decorators.py", line 263, in _open_file > result = func(*new_args, **kwargs) > File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 367, in read_edgelist > data=data) > File "/usr/local/lib/python2.7/dist-packages/networkx-1.7-py2.7.egg/networkx/readwrite/edgelist.py", line 286, in parse_edgelist > for (edge_key,edge_type),edge_value in zip(data,d): > > ValueError: too many values to unpack Collections in python can be "unpacked" using a specific syntax that assigns a tuple of individual variables (or names) to a collection (these can be nested). If there are too many or too few single names, a ValueError gets thrown. Consider: py> col = [1, 2, 3] py> a, b, c = col py> print("{0} {1} {2}".format(a, b, c)) 1 2 3 py> a, b = col Traceback (most recent call last): File "", line 1, in ValueError: too many values to unpack py> a, b, c, d = col Traceback (most recent call last): File "", line 1, in ValueError: need more than 3 values to unpack The traceback for this exception ends inside the networkx code and either indicates a bug in the networkx code or an input error that is not gracefully handled. My suggestions are twofold: 1) Upgrade to the latest release. If this is a bug, it's very possible that it was fixed in later releases (1.7 is over 2 years old and there have been a couple major releases since then. 2) Sign up for the networkx mailing list and ask your question there. You are certain to get a faster and more relevant answer. (See the "mailing list" link here: http://networkx.github.io/) Hope this helps, Jason From timr at probo.com Wed Jul 16 23:18:56 2014 From: timr at probo.com (Tim Roberts) Date: Wed, 16 Jul 2014 20:18:56 -0700 Subject: Python 3 is killing Python References: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: Steven D'Aprano wrote: > >For what little it is worth, if any one country won World War Two, it was >the USSR. I don't think that's quite accurate. It is certainly true that the USSR suffered vastly more casualties than any participant in the war, essentially losing one entire generation of young men. It is also true that the USSR faced the Germans head-on for longer than any other combatant. But it is is not at all clear that the USSR could have defeated Germany on its own. The enormous industrial capacity of the United States was an extremely significant factor that helped turn the tide in what otherwise would have been an ugly war of attrition, much like WWI. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From timr at probo.com Wed Jul 16 23:20:17 2014 From: timr at probo.com (Tim Roberts) Date: Wed, 16 Jul 2014 20:20:17 -0700 Subject: Python 3 is killing Python References: Message-ID: MRAB wrote: >On 2014-07-16 00:53, Rick Johnson wrote: >> On Tuesday, July 15, 2014 5:40:29 PM UTC-5, Abhiram R wrote: >> >> ...or some pretentious line >> about "this was sent from my i-phone" -- send that crap to the >> bitbucket! >> >"This was sent from my iPhone" == "I have an iPhone!" Please note that iPhones come configured from the factory to say that. Some users probably don't even know it is happening. -- Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From steve at pearwood.info Wed Jul 16 23:33:11 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 03:33:11 GMT Subject: Python 3 is killing Python References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <53c743f7$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 11:50:24 -0600, Ian Kelly wrote: > On Wed, Jul 16, 2014 at 11:33 AM, Javier wrote: >> I think there has been a severe miscalculation, and the change in the >> name of the interpreter python3 to python >> http://legacy.python.org/dev/peps/pep-0394/ is a good example of the >> disconnection between GvR and the real world. > > Er, that PEP currently recommends that python be a symlink to python2. > It states that at some point in the future, the recommendation will > change to have python symlink to python3. > >> Arch Linux was the only distro to fall in the trap > > You've got the order of events backward. That PEP was created *because* > Arch decided to link python to python3. Neither GvR nor anybody else > who work on Python have any control over that. This is correct. When Arch first announced this change, oh, four years ago if I remember correctly, the core devs were rather dismayed. Some of them would prefer to see "python" mean "python2" forever (which I happen to disagree with) but even those who would like to see "python" some day mean "python3" thought it was *way* too early. I think that the sensible approach is to start by migrating internal tools to "python2" rather than "python", then migrate internal tools to python3, and gradually move towards having "python" mean "the user's python" rather than "the system python". That will be future-proof for Python 4 and Python 5. -- Steven From rosuav at gmail.com Wed Jul 16 23:38:50 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 13:38:50 +1000 Subject: Python 3 is killing Python In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 1:20 PM, Tim Roberts wrote: > MRAB wrote: >>On 2014-07-16 00:53, Rick Johnson wrote: >>> On Tuesday, July 15, 2014 5:40:29 PM UTC-5, Abhiram R wrote: >>> >>> ...or some pretentious line >>> about "this was sent from my i-phone" -- send that crap to the >>> bitbucket! >>> >>"This was sent from my iPhone" == "I have an iPhone!" > > Please note that iPhones come configured from the factory to say that. Some > users probably don't even know it is happening. The sad thing is, it's on par with the "This email checked by the free version of - this message can be removed in the registered version!" messages you sometimes see. The difference is that with an iphone, you've already paid for it... ChrisA From rosuav at gmail.com Wed Jul 16 23:32:03 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 13:32:03 +1000 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 6:40 AM, Skip Montanaro wrote: > On Wed, Jul 16, 2014 at 3:27 PM, Mark Lawrence wrote: >> The difference between our most illustrious resident unicode expert and rr > > Sorry, who is "rr"? I went looking in the referenced thread but found > nobody with those initials. Not so helpfully, Gmail elides most sigs, > so I couldn't reliably scan the full text either. > He used to call himself rantingrick at gmail.com and then somehow lost access to that account (which usually means forgot the password). Now he's "Rick Johnson" but most of us still refer to him as Ranting Rick. (Apparently he was rt8396 at gmail.com years ago, but that was before my time.) ChrisA From wuwei23 at gmail.com Wed Jul 16 23:35:24 2014 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Jul 2014 13:35:24 +1000 Subject: initializing "parameters" class in Python only once? In-Reply-To: <53c4bbf2$0$2746$c3e8da3$76491128@news.astraweb.com> References: <53C4589A.9040109@jpl.nasa.gov> <53c4bbf2$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: On 15/07/2014 3:28 PM, Steven D'Aprano wrote: > # === module params.py === > class Params(object): > a = 1 > b = 2 > > @property > def c(self): > return self.a**2 + self.b**2 - self.a + 1 > > params = Params() > del Params # hide the class > > > Then callers just say: > > from params import params > print params.c I'd replace the instantiation & deletion of the class in params.py with: import sys sys.modules[__name__] = Params() ..and replace the module itself with the parameter object. I'd also add: __file__ = __file__ ...to the class definition to help with debugging. But this is really just bikeshedding. It's a shame the property decorator doesn't work at the module level, though. From ben at benfinney.id.au Thu Jul 17 00:02:35 2014 From: ben at benfinney.id.au (Ben Finney) Date: Thu, 17 Jul 2014 14:02:35 +1000 Subject: Interleaved posting style for text discussion forums (was: Python 3 is killing Python) References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> Message-ID: <85lhrsskdg.fsf_-_@benfinney.id.au> Abhiram R writes: > ?Aah. Understood. Apologies for the "noobishness" :) ? Thanks for understanding. Here is a good explanation of ?Interleaved style? which is the proper etiquette for text-based discussions. -- \ ?I used to be an airline pilot. I got fired because I kept | `\ locking the keys in the plane. They caught me on an 80 foot | _o__) stepladder with a coathanger.? ?Steven Wright | Ben Finney From ben at benfinney.id.au Thu Jul 17 00:17:02 2014 From: ben at benfinney.id.au (Ben Finney) Date: Thu, 17 Jul 2014 14:17:02 +1000 Subject: Python 3 is killing Python References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53C5DC04.9070600@mrabarnett.plus.com> Message-ID: <85ha2gsjpd.fsf@benfinney.id.au> Chris ?Kwpolska? Warrick writes: > Also, the correct solution for all those is getting a sane client that > can hide quotes and signatures. No, there is often useful (or at least interesting) information in a message signature block; the problem is with *some* of them, not all of them. And the problem is that one message presents obnoxious crap to every reader; suggesting that the recipient is the one responsible for avoiding obnoxious behaviour in a public forum is a mistake of ethics. The correct solution to obnoxious crap boilerplate in messages is for the sender to take action to stop generating obnoxious crap boilerplate in messages. And our job is to convince them to implement that solution. -- \ ?If you define cowardice as running away at the first sign of | `\ danger, screaming and tripping and begging for mercy, then yes, | _o__) Mr. Brave man, I guess I'm a coward.? ?Jack Handey | Ben Finney From steve at pearwood.info Thu Jul 17 00:25:01 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 04:25:01 GMT Subject: Python 3 is killing Python References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: <53c7501d$0$29897$c3e8da3$5496439d@news.astraweb.com> On Wed, 16 Jul 2014 17:33:44 +0000, Javier wrote: > 2.8 fork anybody? It already exists. It is called 2.7, and 2.6 before that. Python 3.0 came out on December 3rd, 2008, a couple of weeks before the last release of 2.4 and in parallel with 2.5 (2.4.6 and 2.5.3 both came out on the 19th December). 2.6 and 2.7 are the transitional versions between 2.x and 3.x. The core devs deliberately set out to have a long (10 years or more) transition period. Early adaptors can help iron out the issues with Python 3.0, 3.1 and 3.2, 3.3 starts going mainstream, and it won't be until probably 3.5 or 3.6 that Python 3 will be truly mainstream. If you're still using Python 2.7 when Python 3.7 comes out in (likely 4 or 5 years), you'll be in the same position as those who are still using Python 2.2 or 2.3 now: you'll either be happy with the status quo (and lack of external support) and will never change, or you've missed the boat. -- Steven From steve at pearwood.info Thu Jul 17 00:27:58 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 04:27:58 GMT Subject: initializing "parameters" class in Python only once? References: <53C4589A.9040109@jpl.nasa.gov> <53c4bbf2$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53c750ce$0$29897$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 13:35:24 +1000, alex23 wrote: > It's a shame the property decorator doesn't work at the module level, > though. Not necessarily the property decorator, but some sort of computed variable would be nice. -- Steven From rantingrickjohnson at gmail.com Thu Jul 17 00:47:08 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 16 Jul 2014 21:47:08 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> On Wednesday, July 16, 2014 10:16:00 PM UTC-5, Steven D'Aprano wrote: > If they are "shopping" for a scripting language, that > means they don't have one yet. Which means their users > have no existing scripts that need to be ported from > Python 2 to 3. Whatever language is chosen, whether it is > Ruby, Lua, Python 3 or something else, its all equally as > new. Sometimes, when we become proficient in an area of expertise, we forget about all the stumbling blocks that impede the neophytes -- which explains your befuddlement! Even though i will freely admit that Python is the easiest language to learn (IMHO), and more so because GvR did not allow TIM-TOWDI to run rampant, Python2 already had many stumbling blocks (new classes vs old classes crap!), but Python3 exacerbated the problem by interjecting many, *MANY* more stumbling blocks! You and i don't use "print", and especially not "input" all that much, but both of these (types of) functions are *VITAL* lifelines for the noob when learning a language! Not to mention the issues of looking at the wrong "version" of a tutorial when using the "other" version of Python. Again, you and i won't make these mistakes, but a noob will! Look, Python has gone from: "A noob friendly language" to: "A Noobie subtle bug hell!". And since not all APIs are intended for "professional programmers", choosing a language that is easy to learn, but also, not "overly confusing" and "easy to misuse", is vital! You cannot expect, say: "audio and video" people, to be "professional programmers" -- who know all the "do's" and "don'ts" of a dozen or so different languages and have degrees in computer science and extensive knowledge of algorithmic and logic theories! They are just people who need to automate this or that task, or create a functionality that does not exist via the GUI interface, and as such, they should *NOT* need to be burdened with the pitfalls of a backwards compatibility and fractured community nightmare! NO THANKS PYTHON, WE WANT OUR USERS TO BE "PRODUCTIVE"! From frank at chagford.com Thu Jul 17 01:18:54 2014 From: frank at chagford.com (Frank Millman) Date: Thu, 17 Jul 2014 07:18:54 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: "Steven D'Aprano" wrote in message news:53c66ba8$0$9505$c3e8da3$5496439d at news.astraweb.com... > > E.g. having b"abc"[0] return 97 instead of b"a" was probably a mistake, > but there are four versions of Python 3.x that do it that way and it's > too late to change until Python 5000. (Python 4 is unlikely to break > backwards compatibility in a big way.) > If it was considered important enough, couldn't they just introduce a new datatype, say B'...', with the desired behaviour. B'' would be backported to Python 2.7 as an alternative to b'', to faciliate writing code that works on both versions. There would be a lot of overlap with b'...', but the differences could be documented. Methods could be added to B'' to replicate any behaviour of b'' which has been changed. Then over time b'' could be deprecated, and in Python 4 b'' could replace B''. Frank Millman From rantingrickjohnson at gmail.com Thu Jul 17 01:15:23 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Wed, 16 Jul 2014 22:15:23 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> On Wednesday, July 16, 2014 10:18:56 PM UTC-5, Tim Roberts wrote: > Steven D'Aprano wrote: > >For what little it is worth, if any one country won World War Two, it was > >the USSR. > I don't think that's quite accurate. It is certainly true > that the USSR suffered vastly more casualties than any > participant in the war, essentially losing one entire > generation of young men. It is also true that the USSR > faced the Germans head-on for longer than any other > combatant. But it is is not at all clear that the USSR > could have defeated Germany on its own. The enormous > industrial capacity of the United States was an extremely > significant factor that helped turn the tide in what > otherwise would have been an ugly war of attrition, much > like WWI. I've been wresting with my decision to "correct Steven" every since he posted this bombastic statement of his, because, the *real* history of WW2 tells quite a different story than our friend Steven would like us to believe. Heck, after suffering terrible casualties, even the "godless tyrant" Stalin was so scared of losing the war, that he released the priests and ministers from the gulags and allowed the shrines to circulate around Moscow again. Ha, the only time a godless man seeks god is on his death bed, and Stalin was scared to death! And then Stevens comments about how "tough" the Russian army was because they "steamrolled" Germany and most of Europe -- obviously he has no capacity to distinguish between "honorable warfare" and complete "barbarism". *ANY* army can rape/kill women and children and raise peasant villages to the ground! Look, i understand the Russians earned some "payback", but not *all* forms of warfare can be justified *even* after the horrendous losses they suffered! The enemy was the third-Reich, not innocent German/Polish civilians! In fact, the atrocities committed by the Russians were only eclipsed by the SS. From greg.ewing at canterbury.ac.nz Thu Jul 17 01:36:41 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 17 Jul 2014 17:36:41 +1200 Subject: Python 3 is killing Python In-Reply-To: <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> References: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> Message-ID: Rick Johnson wrote: > *ANY* army can rape/kill women and children and raise peasant > villages to the ground! So... the villages were underground before? -- Greg From rosuav at gmail.com Thu Jul 17 01:45:08 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 15:45:08 +1000 Subject: Python 3 is killing Python In-Reply-To: <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> References: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 3:15 PM, Rick Johnson wrote: > *ANY* army can rape/kill women and children and raise peasant > villages to the ground! That would be "raze", unless those villages grow like potatoes. ChrisA From wuwei23 at gmail.com Thu Jul 17 01:48:38 2014 From: wuwei23 at gmail.com (alex23) Date: Thu, 17 Jul 2014 15:48:38 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On 15/07/2014 11:57 PM, Kevin Walzer wrote: > The number of language revisions that result in deliberate, code-level > incompatibility out there is pretty small. People rightly expect that > code written for version 2.x of a language will continue to work with > version 3.x, even if 3.x is designed to go in another direction. PHP regularly breaks compatibility between _minor_ version releases: http://php.net/manual/en/migration53.incompatible.php Even more so with major releases: http://php.net/manual/en/migration5.incompatible.php And yet I never see anywhere near as much angst and agony as Python 3.x has caused. From ethan at stoneleaf.us Thu Jul 17 00:43:48 2014 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 16 Jul 2014 21:43:48 -0700 Subject: initializing "parameters" class in Python only once? In-Reply-To: References: <53C4589A.9040109@jpl.nasa.gov> <53c4bbf2$0$2746$c3e8da3$76491128@news.astraweb.com> Message-ID: <53C75484.4080608@stoneleaf.us> On 07/16/2014 08:35 PM, alex23 wrote: > On 15/07/2014 3:28 PM, Steven D'Aprano wrote: >> # === module params.py === >> class Params(object): >> a = 1 >> b = 2 >> >> @property >> def c(self): >> return self.a**2 + self.b**2 - self.a + 1 >> >> params = Params() >> del Params # hide the class >> >> >> Then callers just say: >> >> from params import params >> print params.c > > I'd replace the instantiation & deletion of the class in params.py with: > > import sys > sys.modules[__name__] = Params() > > ..and replace the module itself with the parameter object. I'd also add: > > __file__ = __file__ > > ...to the class definition to help with debugging. But this is really just bikeshedding. Just make sure the 'sys.modules' assignment happens at the *end* of params.py. -- ~Ethan~ From rosuav at gmail.com Wed Jul 16 23:27:39 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 13:27:39 +1000 Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 4:16 AM, alister wrote: > I have had a number of > enjoyable holidays in the USA and 90% of the people I have met there have > been great. I'd go even further. I've only actually visited the US once, but everyone was great except for *one* unpleasant experience with staff at a New York railway station, and it's possible that person was just having a bad day. Of course, it's also possible that we caught a huge lot of really nasty people who just happened to be having a _good_ day when we were there, but I'll be charitable and assume they're genuinely nice people. :) Mind you, we spent most of our time in the southern states, where people are pretty amazingly hospitable and friendly as a rule. Actually, the hardest part of visiting the US was learning that before crossing the road, instead of looking right and then left, we have to look left and then right... ChrisA From rosuav at gmail.com Thu Jul 17 01:45:36 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 15:45:36 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <58636710-ecc3-48a9-8f37-a5c2b13446f1@googlegroups.com> <53c4bf09$0$2746$c3e8da3$76491128@news.astraweb.com> <89295cdd-ee8e-4f26-8039-a6b1fe56494d@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 3:36 PM, Gregory Ewing wrote: > Rick Johnson wrote: >> >> *ANY* army can rape/kill women and children and raise peasant >> villages to the ground! > > > So... the villages were underground before? *high five* We had the same thought. ChrisA From frank at chagford.com Thu Jul 17 02:31:14 2014 From: frank at chagford.com (Frank Millman) Date: Thu, 17 Jul 2014 08:31:14 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: "Chris Angelico" wrote in message news:CAPTjJmr4nPA6euD-j2uNAN==h=iDs1o5BDHGJ0FnjKJO9WfLXg at mail.gmail.com... > On Thu, Jul 17, 2014 at 12:27 AM, Frank Millman > wrote: > >> Unfortunately, human nature being what it is, the possibility of this >> split >> in the community continuing, to the detriment of Python itself, is all >> too >> real. > > What split, exactly? There are always these talks of a split... but I > don't see one happening. It is worth watching this - https://www.youtube.com/watch?v=skYBOXE02OQ This is the intro - Kenneth Reitz, Python evangelist at Heroku and author of the popular Requests library, discusses the state of Python today, the division in the community, and how we can forge ahead into a shiny future. Pythonistas unite! Frank From rosuav at gmail.com Thu Jul 17 02:41:12 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 16:41:12 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 4:31 PM, Frank Millman wrote: > It is worth watching this - > https://www.youtube.com/watch?v=skYBOXE02OQ Not in a position to watch Youtube vids at the moment. A blog post I'd read, but a talk is not well suited to all forms of delivery... What's it saying, can you summarize? ChrisA From steve at pearwood.info Thu Jul 17 03:03:06 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 07:03:06 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <53c7752a$0$29897$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 15:48:38 +1000, alex23 wrote: > On 15/07/2014 11:57 PM, Kevin Walzer wrote: >> The number of language revisions that result in deliberate, code-level >> incompatibility out there is pretty small. People rightly expect that >> code written for version 2.x of a language will continue to work with >> version 3.x, even if 3.x is designed to go in another direction. > > PHP regularly breaks compatibility between _minor_ version releases: > > http://php.net/manual/en/migration53.incompatible.php > > Even more so with major releases: > > http://php.net/manual/en/migration5.incompatible.php > > And yet I never see anywhere near as much angst and agony as Python 3.x > has caused. Thank you for pointing this out! I thought that was the case with PHP, but I wasn't sure. Nice to have it confirmed. -- Steven From frank at chagford.com Thu Jul 17 03:09:59 2014 From: frank at chagford.com (Frank Millman) Date: Thu, 17 Jul 2014 09:09:59 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: "Chris Angelico" wrote in message news:CAPTjJmoT9q2CUYy5JC6kEYCxyp8_uSjHR1y8E+Z+T70QNc54xQ at mail.gmail.com... > On Thu, Jul 17, 2014 at 4:31 PM, Frank Millman wrote: >> It is worth watching this - >> https://www.youtube.com/watch?v=skYBOXE02OQ > > Not in a position to watch Youtube vids at the moment. A blog post I'd > read, but a talk is not well suited to all forms of delivery... What's > it saying, can you summarize? I an also not in a position to watch it at the moment, but from memory ... The talk is recent - the video is dated 1st July 2014. He quotes some stats from PyPi, which shows number of downloads over a period, broken down by version. Over a recent period, Python2 downloads exceed Python3 downloads by a factor of 10:1 (subject to my memory ...) He has talked to many influential pythonistas in the recent past. He particularly comments on discussions with one of the prominent Python3 dissenters - Armin [can't remenber his surname]. He senses a great inertia in the established python community towards adopting Python3. He goes through some of the familiar reasons, most, if not all, relating to bytes/unicode. He is concerned about a growing division in the community, not only between users of the two versions, but between the mainstream users many of whom are resisting the move to Python3, and the developers, who are committed to Python3 but can only improve it by getting feedback from users. His closing plea was for users to get involved with Python3, help to improve it, and thereby help to re-unite the Python community. Frank P.S. If anyone watches the video, feel free to chip in and add to/correct what I have written above. From breamoreboy at yahoo.co.uk Thu Jul 17 03:17:06 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 17 Jul 2014 08:17:06 +0100 Subject: Python 3 is killing Python In-Reply-To: <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 17/07/2014 04:14, Steven D'Aprano wrote: > On Wed, 16 Jul 2014 18:16:16 -0700, Rick Johnson wrote: > >> On Wednesday, July 16, 2014 6:00:16 PM UTC-5, Mark Lawrence wrote: >>> I'm not aware of any mass exodus from core Python 3 to the fork that >>> has consistently proposed to give the world Python 2.8. Do you know >>> something that I don't? >> >> Well, currently at least, we don't even *need* a Python 2.8, not for the >> next couple of years anyway. > > There will never be a Python 2.8. When push comes to shove, the people > bitching about Python 3 will not do the work necessary to fork Python 2.7 > and make a version 2.8. > Actually I like the logic behind 2.8. "We've only had eight years to port our code to Python 3. That's not been long enough. So to work around the situation we'll throw all of our miniscule resources into forking Python to solve all of the problems that Python has created for us". Where is Walter Mitty when you need him? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From steve at pearwood.info Thu Jul 17 03:49:13 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 17 Jul 2014 07:49:13 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53c77ff8$0$29897$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 07:18:54 +0200, Frank Millman wrote: > "Steven D'Aprano" wrote in > message news:53c66ba8$0$9505$c3e8da3$5496439d at news.astraweb.com... >> >> E.g. having b"abc"[0] return 97 instead of b"a" was probably a mistake, >> but there are four versions of Python 3.x that do it that way and it's >> too late to change until Python 5000. (Python 4 is unlikely to break >> backwards compatibility in a big way.) >> >> > If it was considered important enough, couldn't they just introduce a > new datatype, say B'...', with the desired behaviour. B'' would be > backported to Python 2.7 as an alternative to b'', to faciliate writing > code that works on both versions. Sure, if it were considered important enough. But such an addition would add complexity and redundancy to the language, and would add one more thing that people have to learn and decide about. People would confuse which one was which, which would lead to bugs. Since b'abcd'[0:1] takes only a tiny bit more effort than b'abcd'[0], fixing this is not considered worth the cost. -- Steven From rosuav at gmail.com Thu Jul 17 03:59:30 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 17:59:30 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 5:09 PM, Frank Millman wrote: > He quotes some stats from PyPi, which shows number of downloads over a > period, broken down by version. Over a recent period, Python2 downloads > exceed Python3 downloads by a factor of 10:1 (subject to my memory ...) These kinds of stats are always flawed. In a lot of cases, they're skewed heavily by defaults, and in other cases, skewed even more heavily by long dependency trees - so, for instance, a single Django installation might involve fetching large numbers of packages from PyPI, even though no new code has been written at all. Might add quite a bit to the download stats for one version or the other. And what about upgrades? Stable installations are still likely to want to get the latest, which means downloading from PyPI, ergo it's another hit. ChrisA From nicholascannon1 at gmail.com Thu Jul 17 05:59:11 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Thu, 17 Jul 2014 02:59:11 -0700 (PDT) Subject: I need an idea for practise! Message-ID: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Ok I would say I am almost a intermediate python programer. I have made 2 programs(with GUI). And basically they are quite boring(a text editor and calculator). I love programming but i am lost of ideas i actually suck at finding good creative ideas. Now i am not looking to use these ideas make them and then try get money for it. I am only a kid and would love some like real world project ideas to learn more about python. Yeah so if any one would like to give me some ideas to train my self on that would be so cool! From nicholascannon1 at gmail.com Thu Jul 17 06:02:11 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Thu, 17 Jul 2014 03:02:11 -0700 (PDT) Subject: Mac python py2app problem In-Reply-To: References: Message-ID: <82cf4b72-25c5-4413-9550-eacd2e1a0e7c@googlegroups.com> On Wednesday, July 16, 2014 9:56:56 AM UTC+8, Nicholas Cannon wrote: > Hey i have made an app and i have made a .msi for windows with py2exe and i have also exported it with py2app on mac. No problems here they all work fine. I then put the .msi on sourceforge and it works great but when i put the .app on there and download it it says something like i can open this on old architecture or something so i have to put it through google drive and i dont like this like i share the link and folder and people can download it there but it is dodgy. Could someone please help me out like if there is a .msi type thing for mac with py2exe? Yeah i have zipped it up and put it on sourceforge and then when you download the zip it says it is incomplete. I do like the idea of making a .dmg file because i have used them downloading other apps and it works great but i dont know how to make them! would be great if you guys could give me a link to how to do this! From fabien.maussion at gmail.com Thu Jul 17 06:12:23 2014 From: fabien.maussion at gmail.com (Fabien) Date: Thu, 17 Jul 2014 12:12:23 +0200 Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 17.07.2014 06:47, Rick Johnson wrote:> Even though i will freely admit that Python is the easiest > language to learn (IMHO) For non-informatic students (i.e the vast majority of science/engineering students) I don't think that's true. Less general languages like Matlab appear much easier to me: unified doc, unified IDE, unified debugger, you can spend years without being confronted to what an "object" is, etc. > You and i don't use "print", and especially not "input" all > that much, but both of these (types of) functions are > *VITAL* lifelines for the noob when learning a language! Some argue that making print() working like all other python functions make it more consistent. Here for example: http://tinyurl.com/o2oxp9m > Not to mention the issues of looking at the wrong "version" > of a tutorial when using the "other" version of Python. > Again, you and i won't make these mistakes, but a noob will! It happened to me quite often that interesting tutorials where available in py2 only, despite the fact that all the concerned libraries were ported to py3 long ago. But on the other hand, this is not python specific. Forums keep track of all questions/answers and some very old threads remain highly visible in the search results, making new users reinvent the wheel all the time. Everyone should be able to decide if the information found on blogs, forums or even newspapers is up-to-date or not. Fab From alister.nospam.ware at ntlworld.com Thu Jul 17 06:13:26 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Thu, 17 Jul 2014 10:13:26 GMT Subject: I need an idea for practise! References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: On Thu, 17 Jul 2014 02:59:11 -0700, Nicholas Cannon wrote: > Ok I would say I am almost a intermediate python programer. I have made > 2 programs(with GUI). And basically they are quite boring(a text editor > and calculator). I love programming but i am lost of ideas i actually > suck at finding good creative ideas. Now i am not looking to use these > ideas make them and then try get money for it. I am only a kid and would > love some like real world project ideas to learn more about python. Yeah > so if any one would like to give me some ideas to train my self on that > would be so cool! How about creating an app. that interfaces with google groups so that it automatically cleans up the mess it makes before posting ;-) (single line paragraphs & double spacing ) heck i don't use google groups but would happily pay others to use such an app (not much though i am no Mark Shuttleworth) -- Make it myself? But I'm a physical organic chemist! From rosuav at gmail.com Thu Jul 17 07:12:25 2014 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 17 Jul 2014 21:12:25 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 8:12 PM, Fabien wrote: > On 17.07.2014 06:47, Rick Johnson wrote:> Even though i will freely admit > that Python is the easiest >> language to learn (IMHO) > > For non-informatic students (i.e the vast majority of science/engineering > students) I don't think that's true. Less general languages like Matlab > appear much easier to me: unified doc, unified IDE, unified debugger, you > can spend years without being confronted to what an "object" is, etc. That's always going to be true. If you have mathematical experience, you'll be much more comfortable with a math-specific setup than with a general programming environment. But for general programming, the IDE isn't that much help, and the math-specific language is going to get in the way. This is why there are so many different environments to choose from; if you want something that makes it really easy to put a Windows GUI program together, you probably grab one of the Microsoft tools, but if you want something that lets you run your program on any platform and still have a usable GUI, you want something cross-platform (tkinter, GTK, wx, Qt). This is not a problem with Python; it's simply how the world works. ChrisA From python at mrabarnett.plus.com Thu Jul 17 07:27:09 2014 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 17 Jul 2014 12:27:09 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c62e7f$0$29897$c3e8da3$5496439d@news.astraweb.com> <871ttlfune.fsf@elektro.pacujo.net> <53c66ba8$0$9505$c3e8da3$5496439d@news.astraweb.com> <87sim1e9dt.fsf@elektro.pacujo.net> <87oawpe5be.fsf@elektro.pacujo.net> <8761ix4859.fsf@elektro.pacujo.net> <871ttl46o1.fsf@elektro.pacujo.net> <53c73a4c$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53C7B30D.1020404@mrabarnett.plus.com> On 2014-07-17 04:15, Chris Angelico wrote: > On Thu, Jul 17, 2014 at 12:51 PM, Steven D'Aprano wrote: >> Most programming languages are written for >> J. Random Hacker, not J????????. > > I had to paste that into Google Translate to be able to understand > what you meant (although I could guess just fine)... but to actually > see the characters, I had to paste it into my MUD client. Yeah. Figure > that out. A MUD client had better font support for other languages > than a web browser with a dedicated translation tool. > I can see the characters in both Thunderbird and Firefox. From greg.ewing at canterbury.ac.nz Thu Jul 17 07:35:47 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Thu, 17 Jul 2014 23:35:47 +1200 Subject: Mac python py2app problem In-Reply-To: <82cf4b72-25c5-4413-9550-eacd2e1a0e7c@googlegroups.com> References: <82cf4b72-25c5-4413-9550-eacd2e1a0e7c@googlegroups.com> Message-ID: Nicholas Cannon wrote: > I do like the idea of making a .dmg file > because i have used them downloading other apps and it works great but i dont > know how to make them! In Disk Utility, use File>New>Disk Image from Folder. -- Greg From i at introo.me Thu Jul 17 05:07:32 2014 From: i at introo.me (Shiyao Ma) Date: Thu, 17 Jul 2014 17:07:32 +0800 Subject: Python3+Vim dev environment Message-ID: Hi. Anyone with working experience on setting up Python3 dev with vim? functionalities needed: code completion and jump to defintion YCM suffices but only with py2. Any vim (plugin) for py3? Or do you have any experience both running YCM and jedi-vim(for py3) ? How's that going? Regards -- ????????????????http://introo.me? From abhi.darkness at gmail.com Thu Jul 17 09:33:02 2014 From: abhi.darkness at gmail.com (Abhiram R) Date: Thu, 17 Jul 2014 19:03:02 +0530 Subject: I need an idea for practise! In-Reply-To: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 3:29 PM, Nicholas Cannon wrote: I have made 2 programs(with GUI). And basically they are quite boring(a > text editor and calculator). > -- > https://mail.python.org/mailman/listinfo/python-list > ?What library did you use for the GUI?? -- Abhiram.R -------------- next part -------------- An HTML attachment was scrubbed... URL: From wxjmfauth at gmail.com Thu Jul 17 10:13:29 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Thu, 17 Jul 2014 07:13:29 -0700 (PDT) Subject: This Python 3 is killing Python thread is killing me. In-Reply-To: References: Message-ID: Le mercredi 16 juillet 2014 22:27:04 UTC+2, Mark Lawrence a ?crit?: > On 16/07/2014 20:24, Jason Swails wrote: > > > > > > On Wed, Jul 16, 2014 at 11:40 AM, Mark Lawrence > > > wrote: > > > > > > On 16/07/2014 18:32, Deb Wyatt wrote: > > > > > > Can you all stop already with the non python US bashing? Please? > > > > > > Deb in WA, USA > > > > > > > > > rr started it with a fairly impressive piece of trolling but as > > > you've asked so politely I will happily oblige. > > > > > > I honestly don't understand why you haven't kill-filed him yet. I can > > > understand people wanting to respond to jmf to prevent newbies and the > > > Unicode-ignorant from thinking the FSR is not a good thing (or > > > fundamentally wrong), although I've killfiled him as well. [1] But > > > nobody will confuse rr's posts with something of value (their only > > > possible use can be to populate > > > http://en.wikipedia.org/wiki/List_of_logical_fallacies and > > > http://en.wikipedia.org/wiki/Ad_hominem). There's nobody to protect > > > from rr-induced misconceptions. [http://xkcd.com/386/] > > > > > > My life lurking and learning on Python-list has been dramatically > > > improved since I began to instantiate filters, I highly recommend it. > > > > > > Cheers, > > > Jason > > > > > > [1] Seen one and you've seen them all, and I'm no unicode expert. > > > > > > > The difference between our most illustrious resident unicode expert and > > rr is that the former has only said anything of use once, whereas the > > latter does know about tkinter/IDLE. rr doesn't show up that often, the > > MIRUC has been spewing his mistruths for nearly two years and IMHO > > should have been booted into touch a long time ago. > > > > -- > > My fellow Pythonistas, ask not what our language can do for you, ask > > what you can do for our language. > > > > Mark Lawrence > > -------- I would be very happy, if you try, at least, to reproduce the examples or pieces of code I gave... From rosuav at gmail.com Thu Jul 17 10:20:56 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 00:20:56 +1000 Subject: I need an idea for practise! In-Reply-To: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 7:59 PM, Nicholas Cannon wrote: > I have made 2 programs(with GUI). And basically they are quite boring(a text editor and calculator). Just for reference, those may be simple concepts, but they're anything but boring. Most of us use text editors all the time, and I have a habit of incorporating calculators into basically everything I write (if it has a command-line input system of any kind). It's worth knowing how to write both programs, because some day you'll be doing something where you want the program to just quickly pop up a little editor and let you change something on the fly, or just quickly fire up a calculator that drops the result into some part of the program's core functionality. It can be EXTREMELY handy, and useful. ChrisA From nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de Thu Jul 17 09:22:56 2014 From: nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de (Thomas Rachel) Date: Thu, 17 Jul 2014 15:22:56 +0200 Subject: Iterating through set In-Reply-To: References: Message-ID: Am 15.07.2014 02:10 schrieb LJ: > Hi All. > > I'm coding a Dynamic Programming algorithm to solve a network flow problem. At some point in the algorithm I have to iterate through a set of nodes, while adding and/or removing elements, until the set is empty. I know a regular set() object does not work in a case like this, so I wonder if anyone knows of an efficient pythonic way to handle this. > > Thanks in advance! > This sounds like you want to avoid processing of an item as soon as it is removed. Then I'd suggest the following: add = set() remove = set() while myset or add: for item in myset: if item not in remove: # process myset -= remove myset += add remove.clear() add.clear() Adding happens via add.add(item), removing via remove.add(item). If there is additionally the need to take care in which order to apply add/remove, or if it can happen that item X is added and removed in the same loop run, it gets a bit more complicated. Then adding would be like if item in remove: remove.remove(item) elif item not in myset and item not in add: add.add(item) and removing like if item in add: add.remove(item) elif item in myset: remove.add(item) HTH, Thomas From jhibschman at gmail.com Thu Jul 17 11:12:28 2014 From: jhibschman at gmail.com (Johann Hibschman) Date: Thu, 17 Jul 2014 11:12:28 -0400 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: "Anders J. Munch" <2014 at jmunch.dk> writes: > So far I received exactly the answer I was expecting. 0 examples of > NaN!=NaN being beneficial. > I wasn't asking for help, I was making a point. Whether that will > lead to improvement of Python, well, I'm not too optimistic, but I > feel the point was worth making regardless. Well, I just spotted this thread. An easy example is, well, pretty much any case where SQL NULL would be useful. Say I have lists of borrowers, the amount owed, and the amount they paid so far. nan = float("nan") borrowers = ["Alice", "Bob", "Clem", "Dan"] amount_owed = [100.0, nan, 200.0, 300.0] amount_paid = [100.0, nan, nan, 200.0] who_paid_off = [b for (b, ao, ap) in zip(borrowers, amount_owed, amount_paid) if ao == ap] I want to just get Alice from that list, not Bob. I don't know how much Bow owes or how much he's paid, so I certainly don't know that he's paid off his loan. Cheers, Johann From joepvandelft at xs4all.nl Thu Jul 17 11:32:31 2014 From: joepvandelft at xs4all.nl (Joep van Delft) Date: Thu, 17 Jul 2014 17:32:31 +0200 Subject: Multiple python versions, one dev environment??? Message-ID: <20140717173231.7cfefae5@xs4all.nl> Hello! The condensed version of the question would probably be: How does one deal with multiple interpreters and one package where you want to try some changes? The background: I made a trivial change to some package (docutils) to scratch a personal itch, and I want to offer this back to the community (whether it will be accepted or not). Because of this, I ran into some issues. Some facts: 1. Python3 is my main interpreter. 2. The tests of docutils only run under python2. 3. I desire not to touch my distribution's version of site-packagesX-Y. 4. I prefer to have one and only one development directory of my target package. My confusions: 1. Is it possible to have one source control managed directory of some package, which is used by two versions of python? 2. I assume that the *.pyc-files generated while using some python source are version dependent. What is the recommended way to have 'em both installed? 3. The way I have stumped a wall over here, is the puzzle of how to make python2 have a different $PYTHONPATH as python3. I hope to hear how this strategy is silly :) 4. I have contemplated the way of linking the source files from my development directory into user specified site-packages directories. Problem 3. still is valid. 5. Should venv and friends/foes com into play? If so: How? Appreciate any light shed on these issues. Thanks! Joep From rosuav at gmail.com Thu Jul 17 11:36:24 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 01:36:24 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: On Fri, Jul 18, 2014 at 1:12 AM, Johann Hibschman wrote: > Well, I just spotted this thread. An easy example is, well, pretty much > any case where SQL NULL would be useful. Say I have lists of borrowers, > the amount owed, and the amount they paid so far. > > nan = float("nan") > borrowers = ["Alice", "Bob", "Clem", "Dan"] > amount_owed = [100.0, nan, 200.0, 300.0] > amount_paid = [100.0, nan, nan, 200.0] > who_paid_off = [b for (b, ao, ap) in > zip(borrowers, amount_owed, amount_paid) > if ao == ap] > > I want to just get Alice from that list, not Bob. I don't know how much > Bow owes or how much he's paid, so I certainly don't know that he's paid > off his loan. > But you also don't know that he hasn't. NaN doesn't mean "unknown", it means "Not a Number". You need a more sophisticated system that allows for uncertainty in your data. I would advise using either None or a dedicated singleton (something like `unknown = object()` would work, or you could make a custom type with a more useful repr), and probably checking for it explicitly. It's entirely possible that you do virtually identical (or virtually converse) checks but with different handling of unknowns - for instance, you might have one check for "who should be sent a loan reminder letter" in which you leave out all unknowns, and another check for "which accounts should be flagged for human checking" in which you keep the unknowns (and maybe ignore every loan <100.0). You have a special business case here (the need to record information with a "maybe" state), and you need to cope with it, which means dedicated logic and planning and design and code. ChrisA From phani.lav at gmail.com Thu Jul 17 11:39:40 2014 From: phani.lav at gmail.com (lavanya addepalli) Date: Thu, 17 Jul 2014 17:39:40 +0200 Subject: New to Python and Python mail List Message-ID: Hello Everyone I am very much new to python scripting and i am here for knowledge exchange. I am trying to read a file with node pairs and weight. I have to find the neighbours of each pair individual and combined both also count them. Later find the ratio of the neighbours that each node has. I am stuck with finding nodes. infile.txt 0_node1 0_node2 0w 1_node1 1_node2 1w 2_node1 2_node2 2w 3_node1 3_node2 3w 4_node1 4_node2 4w import networkx as nx import matplotlib.pyplot as plt G=nx.Graph() G = nx.read_edgelist('infile.txt', data=[("weight", float)]) def get_triangle(G): for n1 in G.nodes: neighbors1 = set(G[n1]) for n2 in filter(lambda x: x>n1, nodes): neighbors2 = set(G[n2]) common = neighbors1 & neighbors2 for n3 in filter(lambda x: x>n2, common): print n1 print n2 print n3 Any suggestion will be appreciated. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From nospam at nospam.com Thu Jul 17 12:05:27 2014 From: nospam at nospam.com (Javier) Date: Thu, 17 Jul 2014 16:05:27 +0000 (UTC) Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: Are you using arch linux. I deal with multiple interpreters putting fake executables in /usr/local/bin for everything: (python, sphinx, virtualenv, pydoc, idle, python-config...) selecting 2 or 3. You can do the same for selecting 2.3, 2.5, 2.7. What the scripts do is to detect whether it is a system script whose prefix starts with /usr/bin, or whether it is a user script. Being in /usr/local/bin they will override executables in /usr/bin. Remember to chmod a+x the files in /usr/local/bin http://sindhus.bitbucket.org/manage-python-2-3.html http://stackoverflow.com/questions/15400985/how-to-completely- replace-python-3-with-python-2-in-arch-linux https://wiki.archlinux.org/index.php/Python#Dealing_with_ version_problem_in_build_scripts I use these scripts, but there is more than one way to do it ========/usr/local/bin/python=========================================== #!/bin/bash script=`readlink -f -- "$1"` case "$script" in /usr/bin*) exec python3 "$@" ;; esac exec python2 "$@" ========/usr/local/bin/virtualenv=========================================== #!/bin/bash script=`readlink -f -- "$1"` case "$script" in /usr/bin*) exec virtualenv3 "$@" ;; esac exec virtualenv2 "$@" Joep van Delft wrote: > Hello! > > The condensed version of the question would probably be: How does one > deal with multiple interpreters and one package where you want to try > some changes? > > The background: > I made a trivial change to some package (docutils) to scratch a > personal itch, and I want to offer this back to the community > (whether it will be accepted or not). Because of this, I ran into > some issues. > > Some facts: > 1. Python3 is my main interpreter. > 2. The tests of docutils only run under python2. > 3. I desire not to touch my distribution's version of > site-packagesX-Y. > 4. I prefer to have one and only one development directory of > my target package. > > My confusions: > 1. Is it possible to have one source control managed directory of > some package, which is used by two versions of python? > 2. I assume that the *.pyc-files generated while using some python > source are version dependent. What is the recommended way to have > 'em both installed? > 3. The way I have stumped a wall over here, is the puzzle of how to > make python2 have a different $PYTHONPATH as python3. I hope to > hear how this strategy is silly :) > 4. I have contemplated the way of linking the source files from my > development directory into user specified site-packages > directories. Problem 3. still is valid. > 5. Should venv and friends/foes com into play? If so: How? > > Appreciate any light shed on these issues. > > Thanks! > > > Joep > > > From larry.martell at gmail.com Thu Jul 17 12:26:48 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 12:26:48 -0400 Subject: Blocked thread Message-ID: I have a python cx_Oracle script that does a delete from a table. Usually this takes well under 1 second. But sometimes it takes 1 to 2 minutes. I wanted to monitor that delete and if it's taking too long I want to see what is blocking it. I run the delete sql in a thread and I do this: while self.isAlive(): self.join(5) if self.isAlive(): # run query to see who is blocking Looking at the timing on this, at 13:45:11.780 I called join and at 13:46:20.118 I was running the query to check for blocking. That query does not show that the delete is running and the next time through the loop isAlive() is False. My WAG is that when the delete query is blocked the join does not return and I am 'blocked' in the join() - does that seem like what would happen? It's not what I would expect. Can anyone think of a better way to do this? I could have a second script that does it, but that's kinda messy. From 4kir4.1i at gmail.com Thu Jul 17 12:29:54 2014 From: 4kir4.1i at gmail.com (Akira) Date: Thu, 17 Jul 2014 16:29:54 +0000 (UTC) Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: Joep van Delft wrote: > Hello! > > The condensed version of the question would probably be: How does one > deal with multiple interpreters and one package where you want to try > some changes? You could use tox to test a package using different Python versions. -- Akira From rantingrickjohnson at gmail.com Thu Jul 17 12:34:09 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 09:34:09 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> On Thursday, July 17, 2014 4:59:11 AM UTC-5, Nicholas Cannon wrote: > Ok I would say I am almost a intermediate python > programer. I have made 2 programs(with GUI). And basically > they are quite boring(a text editor and calculator). I > love programming but i am lost of ideas i actually suck at > finding good creative ideas. Now i am not looking to use > these ideas make them and then try get money for it. I am > only a kid and would love some like real world project > ideas to learn more about python. Yeah so if any one would > like to give me some ideas to train my self on that would > be so cool! Hmm, unfortunately, if you do not already posses strong imaginative and creative skills, you "may" never become proficient at writing code, although your post does indicate a "deep desire" to write code, so maybe there is yet hope! First of all, you failed to explain the *extent* of the two GUI applications you wrote, and as such, i do not know where to start with my suggestions, so i will be forced to assume that both of these apps are very "simplistic". If the text editor is simply an app that allows: opening raw text files, editing them, and then saving the changes, you have a *whole* universe of functionality you could add to that. How about writing a colorizer for source code, and why stop with *only* a Python colorizer? You can learn about regexs by doing this, AND about other languages also. How about source code analyzers or debuggers, or smart indent/dedent features and such... How about any number of text editing tools that an average user would want: like wrapping tools, searching and replacing tools, etc... Heck, how about extending a raw text editor to handle rich text! Look, i know software already exists for all these functionalities, however, in order to learn you must re- invent the wheel, because you must know what is going on "under the hood" if you expect to become proficient at anything. When someone wants to learn, say, the piano, they do not just sit down and start hammering out Rachmaninoffs "prelude in g minor" with the "key-chord-Staccatissimo-precision" of a classically trained concert pianist, NO, they start out with simple little pieces, and gradually work up towards more difficult pieces, building a wealth of knowledge along the way. If your intention is to skip over the "little pieces" and go strait to the "masterpieces", then you are doomed to failure and might as well go watch a football game or join one of the political parties, this is where the feeble minded people aggregate to perpetuate their lack of intelligence! The *true* student of any discipline will *relish* each and every opportunity (no matter how miniscule) to learn something new, because, it is the vast database of "little ideas" which the masters *PILLAGE*, and then forge together within the "roid-raging" fires of *PASSION*, the greatest *MASTERPIECES* of human ingenuity that this decrepit lot of human *FILTH* hardly deserves! From rosuav at gmail.com Thu Jul 17 13:20:13 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 03:20:13 +1000 Subject: I need an idea for practise! In-Reply-To: <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 2:34 AM, Rick Johnson wrote: > If the text editor is simply an app that allows: opening raw > text files, editing them, and then saving the changes, you > have a *whole* universe of functionality you could add to > that. > > How about writing a colorizer for source code, and why > stop with *only* a Python colorizer? You can learn about > regexs by doing this, AND about other languages also. > > How about source code analyzers or debuggers, or smart > indent/dedent features and such... > > How about any number of text editing tools that an average > user would want: like wrapping tools, searching and > replacing tools, etc... > > Heck, how about extending a raw text editor to handle > rich text! To the OP: Ranting Rick's words shouldn't be taken to heart, although it's plenty possible to learn from him. My recommendation is: Scratch your own itch. Don't add features for the sake of adding features - that's a recipe for useless piles of mess. Instead, add exactly the feature that you need right now (even if adding that feature means it's no longer "right now" when you get a chance to use it), and then you know it's being useful. For instance, I have a mini-editor built into my MUD client [1] which is inferior to most decent code editors, but it has a few special features that make it useful *to me* and *in specific circumstances*; for most of my real work, I still use SciTE, because it's a much better editor. But the pop-out editor lets me: * Work with my server via a TELNET-like connection, and simply pop up an editor * Send the contents of the edit box back to the server. Since the server controls what's edited, it'll begin with an appropriate command that says "Hey server, here's that file I was editing". * Place the initial cursor position, again under server control - handy when I pop up a "git commit" message editor * Explicitly hard-wrap text to a specific column width, or auto-wrap on send * Integrate editing of text into any server-side command - it might not be a file that's being edited All this makes it distinctly superior to either ssh'ing to the server and editing a file (possible only for actual files, possible only for people with ssh logins to the server, etc, etc, etc), or explicitly copying and pasting to another editor window (much easier to let the program do it). And since it's a feature I use on a regular basis, there's a guarantee that it's actually useful, and therefore will be developed as it has need. In contrast, features that I added to a program only because someone said they'd use it (and then probably never even used it themselves) tend to languish, left as an artifact of a previous era rather than constantly improved. By the way, one specific point about RR's advice: A colorizer should *not* be written using regexps. It'd make for an absolute nightmare of impossible-to-debug regexp strings, plus there are fundamental limitations on what you can accomplish with them. You need to use a lexer - a lexical analyzer. Basically, to correctly colorize code, you need to have something equivalent to the first part of the language interpreter, but with a lot more tolerance for errors. That's a pretty big thing to write as regexps. ChrisA [1] Code here: https://github.com/Rosuav/Gypsum/blob/master/plugins/editor.pike From rosuav at gmail.com Thu Jul 17 13:32:08 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 03:32:08 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 2:26 AM, Larry Martell wrote: > I have a python cx_Oracle script that does a delete from a table. > Usually this takes well under 1 second. But sometimes it takes 1 to 2 > minutes. I wanted to monitor that delete and if it's taking too long I > want to see what is blocking it. I run the delete sql in a thread... I don't know Oracle specifically, but if it's anything like PostgreSQL, you'll probably do better with a completely separate connection to the server, which might need to be a separate process. In PostgreSQL, I can query currently-active transactions thus: rosuav=> select state,query from pg_stat_activity; state | query ---------------------+------------------------------------------- idle in transaction | select * from pg_stat_activity; active | select state,query from pg_stat_activity; active | drop table test; (3 rows) (Better than that: Add "where pid=..." to that, using the backend PID provided by the thread you're monitoring, by "SELECT pg_backend_pid()". But that's even more PostgreSQL-specific.) With info like that, you can see what's happening, and whether it's stalled out or in a query or whatever. You should also be able to get some timestamps (Postgres can do that, I would be highly surprised if Oracle can't), such as when the transaction started, so you can see how long it's been stalled. Thing is, this requires a quite separate connection, which means you're monitoring the far end rather than the local thread. I suspect this will give you better results; Oracle's bound to have facilities for doing this, whereas your local thread may or may not be usefully monitorable. ChrisA From rantingrickjohnson at gmail.com Thu Jul 17 13:36:43 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 10:36:43 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Thursday, July 17, 2014 12:48:38 AM UTC-5, alex23 wrote: > PHP regularly breaks compatibility between _minor_ version > releases: [...] more so with major releases: [...] yet I > never see anywhere near as much angst and agony as Python > 3.x has caused. Because you *IGNORE* the fact that people *ACTIVELY* choose to use languages like Python, however, people *MOSTLY* use languages like PHP and Javascript because they are *FORCED* Of course, nature always contains "abnormalities" so i'm sure there are few instances of people "seeking out" those languages, but they *ARE* in the minority. So, keeping those facts in mind, you can now understand why people are so passionate about Python code breaks, and so un-passionate about PHP and Javascript code breaks -- they're already loathing in agony, so why would they seek to acerbate it? POOR PITIFUL FOOLS! From rosuav at gmail.com Thu Jul 17 13:52:29 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 03:52:29 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Fri, Jul 18, 2014 at 3:36 AM, Rick Johnson wrote: > they're already loathing in agony, so why would they seek to > acerbate it? This is a truly amazing demonstration. You have outdone Gaelmaen for comprehensibly incorrect use of English. ChrisA From skip at pobox.com Thu Jul 17 13:46:54 2014 From: skip at pobox.com (Skip Montanaro) Date: Thu, 17 Jul 2014 12:46:54 -0500 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 12:32 PM, Chris Angelico wrote: > I don't know Oracle specifically, but if it's anything like > PostgreSQL, you'll probably do better with a completely separate > connection to the server > Agreed. We use Sybase, and our DBA uses their tools extensively to identify problematic clients. Skip -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.martell at gmail.com Thu Jul 17 13:55:21 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 13:55:21 -0400 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 1:32 PM, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 2:26 AM, Larry Martell wrote: >> I have a python cx_Oracle script that does a delete from a table. >> Usually this takes well under 1 second. But sometimes it takes 1 to 2 >> minutes. I wanted to monitor that delete and if it's taking too long I >> want to see what is blocking it. I run the delete sql in a thread... > > I don't know Oracle specifically, but if it's anything like > PostgreSQL, you'll probably do better with a completely separate > connection to the server, which might need to be a separate process. > In PostgreSQL, I can query currently-active transactions thus: > > rosuav=> select state,query from pg_stat_activity; > state | query > ---------------------+------------------------------------------- > idle in transaction | select * from pg_stat_activity; > active | select state,query from pg_stat_activity; > active | drop table test; > (3 rows) > > (Better than that: Add "where pid=..." to that, using the backend PID > provided by the thread you're monitoring, by "SELECT > pg_backend_pid()". But that's even more PostgreSQL-specific.) > > With info like that, you can see what's happening, and whether it's > stalled out or in a query or whatever. You should also be able to get > some timestamps (Postgres can do that, I would be highly surprised if > Oracle can't), such as when the transaction started, so you can see > how long it's been stalled. > > Thing is, this requires a quite separate connection, which means > you're monitoring the far end rather than the local thread. I suspect > this will give you better results; Oracle's bound to have facilities > for doing this, whereas your local thread may or may not be usefully > monitorable. I can have as many connections to the db server as I want, that's not the issue. The issue is that my main thread seems to be blocked in the join(), so I guess I'm going to need a separate script. I was trying to avoid that. From larry.martell at gmail.com Thu Jul 17 14:00:47 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 14:00:47 -0400 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 1:46 PM, Skip Montanaro wrote: > > On Thu, Jul 17, 2014 at 12:32 PM, Chris Angelico wrote: >> >> I don't know Oracle specifically, but if it's anything like >> PostgreSQL, you'll probably do better with a completely separate >> connection to the server > > > Agreed. We use Sybase, and our DBA uses their tools extensively to identify > problematic clients. I did ask my DBA - he said "Blocking is a normal part of database operations. It's only a problem when it's a deadlock, in which case the server will detect that, kill one of the processes and log it." My situation is not a deadlock - there's just multiple scripts hitting the same tables at the same time. When one gets done the next one proceeds. I just want to find out what are the other processes causing this. From rosuav at gmail.com Thu Jul 17 14:01:13 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:01:13 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 3:55 AM, Larry Martell wrote: > I can have as many connections to the db server as I want, that's not > the issue. The issue is that my main thread seems to be blocked in the > join(), so I guess I'm going to need a separate script. I was trying > to avoid that. Right, but what you're trying to do is monitor the local thread, by spinning off a thread to do the deletion and then keeping an eye on it by attempting a timed join. I'm saying it'd probably be easier to do the monitoring on the server end, via a second connection. (It most likely doesn't need special database privileges, even; at least in PostgreSQL, any user can see pg_stat_activity entries for the same user.) That's usually going to be more reliable, plus the server can tell you whether the deletion is blocked waiting for a lock or busy writing to the disk or something else. ChrisA From larry.martell at gmail.com Thu Jul 17 14:03:26 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 14:03:26 -0400 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 2:01 PM, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 3:55 AM, Larry Martell wrote: >> I can have as many connections to the db server as I want, that's not >> the issue. The issue is that my main thread seems to be blocked in the >> join(), so I guess I'm going to need a separate script. I was trying >> to avoid that. > > Right, but what you're trying to do is monitor the local thread, by > spinning off a thread to do the deletion and then keeping an eye on it > by attempting a timed join. I'm saying it'd probably be easier to do > the monitoring on the server end, via a second connection. (It most > likely doesn't need special database privileges, even; at least in > PostgreSQL, any user can see pg_stat_activity entries for the same > user.) That's usually going to be more reliable, plus the server can > tell you whether the deletion is blocked waiting for a lock or busy > writing to the disk or something else. Yes, I agree, but the second connection will have to be in a second script, not the main thread of the script I have. From rosuav at gmail.com Thu Jul 17 14:04:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:04:09 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 4:00 AM, Larry Martell wrote: > I did ask my DBA - he said "Blocking is a normal part of database > operations. It's only a problem when it's a deadlock, in which case > the server will detect that, kill one of the processes and log it." > > My situation is not a deadlock - there's just multiple scripts hitting > the same tables at the same time. When one gets done the next one > proceeds. I just want to find out what are the other processes causing > this. Then you definitely want server-side info. The DB server's the one who knows who's waiting on whom. See if your DBA can help you with the specifics; this will be bread-and-butter monitoring work for him. Automating it might require some tweaking, but if he's at all competent at his job, he'll know how to figure out (if manually) what's blocking an important query. ChrisA From rosuav at gmail.com Thu Jul 17 14:09:33 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:09:33 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 4:03 AM, Larry Martell wrote: > On Thu, Jul 17, 2014 at 2:01 PM, Chris Angelico wrote: >> On Fri, Jul 18, 2014 at 3:55 AM, Larry Martell wrote: >>> I can have as many connections to the db server as I want, that's not >>> the issue. The issue is that my main thread seems to be blocked in the >>> join(), so I guess I'm going to need a separate script. I was trying >>> to avoid that. >> >> Right, but what you're trying to do is monitor the local thread, by >> spinning off a thread to do the deletion and then keeping an eye on it >> by attempting a timed join. I'm saying it'd probably be easier to do >> the monitoring on the server end, via a second connection. (It most >> likely doesn't need special database privileges, even; at least in >> PostgreSQL, any user can see pg_stat_activity entries for the same >> user.) That's usually going to be more reliable, plus the server can >> tell you whether the deletion is blocked waiting for a lock or busy >> writing to the disk or something else. > > Yes, I agree, but the second connection will have to be in a second > script, not the main thread of the script I have. Maybe. I don't know what facilities Oracle gives you; it might be possible to start a query asynchronously, with either a callback when it's done or a poll for completion. Then another connection could be used to keep an eye on the first one. But yes, doing it with a completely separate script would be simpler in many ways. Or you might be able to do the job with two threads. ChrisA From kartikjagdale11 at gmail.com Thu Jul 17 14:05:36 2014 From: kartikjagdale11 at gmail.com (Orochi) Date: Thu, 17 Jul 2014 11:05:36 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: <7d5885f5-118d-415f-b6ac-1ee382d600ac@googlegroups.com> Brother,I had same views and after creating some small projects I directly tried to jump over large projects (went for data mining using neural network) and FAILED. I realized small things really matter. So I suggest just couple of GUI projects are not enough go for more. start with anything. here are couple of links I am staring with: 1. http://www.reddit.com/r/beginnerprojects 2. http://www.openbookproject.net/py4fun/ and there are many more you can go for "learnstreet.com" I am too a Intermediate but I prefer to say Beginner and if you want we can make projects together. I am Currently working on a small chat application. From larry.martell at gmail.com Thu Jul 17 14:13:20 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 14:13:20 -0400 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 2:04 PM, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 4:00 AM, Larry Martell wrote: >> I did ask my DBA - he said "Blocking is a normal part of database >> operations. It's only a problem when it's a deadlock, in which case >> the server will detect that, kill one of the processes and log it." >> >> My situation is not a deadlock - there's just multiple scripts hitting >> the same tables at the same time. When one gets done the next one >> proceeds. I just want to find out what are the other processes causing >> this. > > Then you definitely want server-side info. The DB server's the one who > knows who's waiting on whom. See if your DBA can help you with the > specifics; this will be bread-and-butter monitoring work for him. > Automating it might require some tweaking, but if he's at all > competent at his job, he'll know how to figure out (if manually) > what's blocking an important query. I know what SQL to run to see who is blocking whom. The issue is that the scripts that are hitting this table run every 5 minutes 24/7 from 5 different locations (Chicago, New Jersey, London, Tokyo, and Sydney). 99% of the time it's fine and the query takes under 1 second. But every once it a while it takes 2 minutes. It will be hard to detect that manually. What I was trying to do in my threaded code was detect when it was taking more than 5 seconds, and then start monitoring it. I think I just need a second script that is always running and when it finds blocking, log it to a file. I was trying to avoid that and deal with it from within. From rosuav at gmail.com Thu Jul 17 14:19:17 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:19:17 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 4:13 AM, Larry Martell wrote: > But every once it a while it takes 2 minutes. It will be hard > to detect that manually. What I was trying to do in my threaded code > was detect when it was taking more than 5 seconds, and then start > monitoring it. Fair enough. In that case, I'd just do it the simple way: get the backend PID (or whatever other connection identification is appropriate), spin off a thread/process to do the monitoring. It sleeps five seconds, then does its first query. If the server says that connection's done its work, easy! Disconnect, job done. Otherwise, do whatever monitoring you can. But if your main goal is diagnosis, rather than monitoring, here's a really really naughty idea that might help: Refrain from committing if it's taken too long. Something like this: start = time.time() # do the actual work, but don't commit if time.time() > start + 5: # raise an alarm, tell a human being that something's wrong else: commit() Obviously you run this "dangeroussed-up version" of the script only when there's a person there to react to the alarm, otherwise you go for the normal one. But this could give you a massive insight into what's happening, because until you commit, you have all your locks and things. ChrisA From larry.martell at gmail.com Thu Jul 17 14:19:39 2014 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 17 Jul 2014 14:19:39 -0400 Subject: Blocked thread In-Reply-To: References: Message-ID: On Thu, Jul 17, 2014 at 2:09 PM, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 4:03 AM, Larry Martell wrote: >> On Thu, Jul 17, 2014 at 2:01 PM, Chris Angelico wrote: >>> On Fri, Jul 18, 2014 at 3:55 AM, Larry Martell wrote: >>>> I can have as many connections to the db server as I want, that's not >>>> the issue. The issue is that my main thread seems to be blocked in the >>>> join(), so I guess I'm going to need a separate script. I was trying >>>> to avoid that. >>> >>> Right, but what you're trying to do is monitor the local thread, by >>> spinning off a thread to do the deletion and then keeping an eye on it >>> by attempting a timed join. I'm saying it'd probably be easier to do >>> the monitoring on the server end, via a second connection. (It most >>> likely doesn't need special database privileges, even; at least in >>> PostgreSQL, any user can see pg_stat_activity entries for the same >>> user.) That's usually going to be more reliable, plus the server can >>> tell you whether the deletion is blocked waiting for a lock or busy >>> writing to the disk or something else. >> >> Yes, I agree, but the second connection will have to be in a second >> script, not the main thread of the script I have. > > Maybe. I don't know what facilities Oracle gives you; it might be > possible to start a query asynchronously, with either a callback when > it's done or a poll for completion. Then another connection could be > used to keep an eye on the first one. But yes, doing it with a > completely separate script would be simpler in many ways. Or you might > be able to do the job with two threads. I do not think Oracle support async or non-blocking queries as Postgres does. But what I think I can do is not call join(), and just start monitoring the server when I kick off the thread with the mail sql it in. From rantingrickjohnson at gmail.com Thu Jul 17 14:15:59 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 11:15:59 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Thursday, July 17, 2014 5:12:23 AM UTC-5, Fabien wrote: > For non-informatic students [...] I don't think that's true. > Less general languages like Matlab appear much easier to > me: unified doc, unified IDE, unified debugger I'll agree that the lack of a "quality" IDE in Python is a point of inadequacy. Sure, IDLE is not *useless*, however, it is in fact woefully inadequate and should be embarrassing to the whole community, both in it's buggy-ness and it's poorly written source code. I would love to see IDLE become a bit more "polished", because, i believe that even though the software is outdated and poorly structured , a simplistic *INTEGRATED* IDE can be very helpful for new Python programmers who have no prior programming experience. Sadly, all of my calls to improve IDLE have been meet with rebukes about me "whining". The "powers that be" would wise to *UTILIZE* and *ENCOURAGE* my participation instead of *IGNORING* valuable talent and *IMPEDING* the expansion of this "private boys club". > you can spend years without being confronted to what an > "object" is, etc. I believe one could eaisly ignore the OOP aspects of Pyhton for as long as they wished, maybe even forever? Python is a multi-paridigm language, and i'm quite happy with that fact > Some argue that making print() work like all other > python functions made it more consistent. Yes, and i agree! Print should have been a function from day one, however, i am not lamenting the "evolution" of "print", i am merely lamenting the confusion induced from backwards incompatibility between "new print" and "old print". > It happened to me quite often that interesting tutorials > where available in py2 only, despite the fact that all the > concerned libraries were ported to py3 long ago. But on > the other hand, this is not python specific. Forums keep > track of all questions/answers and some very old threads > remain highly visible in the search results, making new > users reinvent the wheel all the time. Everyone should be > able to decide if the information found on blogs, forums > or even newspapers is up-to-date or not. Really? Even noobies? The internet is a double edged sword (when used to learn any language) because although there is a vast wealth of information out there for just about any question a noob might have, if he does not phrase his google queries "just so", he is doomed to read information that is at beast confusing, and at worse just flat out lies. I wish "we", as members of internet communities, had some control over the vast amount of information lying around in the darkest corners of the web. Because, we cannot rely *solely* on our "official" tutorials to answer every question a noob may have. And since we cannot control the content of private sites, blogs, groups, etc..., our only remedy is some sort of "official filtered search engine" that will hide the outdated information, and expose only the most relevant and updated information for the version requested. A database where pythonistas can categorize and "up vote" or "down vote" the value of each piece of information. A sort of "Stack Overflow" of the entire set of Python related information violable on the web. Of course it would need to utilize some heavy crowd sourcing, but i believe something like this would be both beneficial and feasible. From rosuav at gmail.com Thu Jul 17 14:21:39 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:21:39 +1000 Subject: Blocked thread In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 4:19 AM, Larry Martell wrote: > I do not think Oracle support async or non-blocking queries as > Postgres does. But what I think I can do is not call join(), and just > start monitoring the server when I kick off the thread with the mail > sql it in. It's more what the client library supports, rather than the server, but sure. If it doesn't do async queries, that settles it. ChrisA From rosuav at gmail.com Thu Jul 17 14:27:28 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:27:28 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 4:15 AM, Rick Johnson wrote: > Sadly, all of my calls to improve IDLE have been meet with > rebukes about me "whining". The "powers that be" would wise > to *UTILIZE* and *ENCOURAGE* my participation instead of > *IGNORING* valuable talent and *IMPEDING* the expansion of > this "private boys club". Do you write patches, or just say "This is terrible. Aorta do summing about it."? [1] If you want something done, the best way is to do it. Simply telling someone else what to do is not "participation" which should be "encourage[d]", but is indeed likely to be whining. Oh, and when you talk about it like this, you make everyone absolutely sure that it really IS just whining. ChrisA [1] http://www.textfiles.com/humor/strine.txt From no.email at nospam.invalid Thu Jul 17 14:34:14 2014 From: no.email at nospam.invalid (Paul Rubin) Date: Thu, 17 Jul 2014 11:34:14 -0700 Subject: patch request for os.urandom() Message-ID: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> Could os.urandom() be patched to use the new Linux getrandom() system call on systems where it is available? Further info: http://lists.openwall.net/linux-kernel/2014/07/17/235 I've stopped posting to the Python bug tracker because the password management issues became too annoying. From rantingrickjohnson at gmail.com Thu Jul 17 14:38:43 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 11:38:43 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: > On Fri, Jul 18, 2014 at 3:36 AM, Rick Johnson > This is a truly amazing demonstration. You have outdone > Gaelmaen for comprehensibly incorrect use of English. Of all my impassioned pleas, astute logical reasoning, and empathetic motivational speeches, of all of that "gold", all you can muster is to harp about a few misspellings? ARE YOU SERIOUS? Okay, i admit it. My spell checker is broken -- maybe it was written in Python3 and it's fuzzy logic is a little too fuzzy for it's own good? From rosuav at gmail.com Thu Jul 17 14:44:43 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:44:43 +1000 Subject: patch request for os.urandom() In-Reply-To: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> References: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> Message-ID: On Fri, Jul 18, 2014 at 4:34 AM, Paul Rubin wrote: > Could os.urandom() be patched to use the new Linux getrandom() system > call on systems where it is available? Further info: > > http://lists.openwall.net/linux-kernel/2014/07/17/235 Uhm... does that even exist in kernel trunk yet? That's pretty amazingly new. I would guess Python doesn't want to start using something like that until it's *at least* appeared in a released kernel; although of course you're welcome to run a patched Python on a patched Linux to make use of this. Trouble with that seems to be that it's reducing code paths from two to... two. Instead of having a seldom-used code path for the fall-back when there's no fd available, you instead have an alternate code path for the fall-back when getrandom() doesn't exist. But if the Linux guys decide to implement this, then you can take it to python-dev with "This is supported by Linux 3.x.y" (or probably "Linux 3.x"), and preferably a patch that includes something in ./configure to probe for availability. Patches speak louder than words :) ChrisA From marko at pacujo.net Thu Jul 17 14:44:20 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 17 Jul 2014 21:44:20 +0300 Subject: Python 3 is killing Python References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <87ha2f25bv.fsf@elektro.pacujo.net> Rick Johnson : > Sure, IDLE is not *useless*, however, it is in fact woefully > inadequate and should be embarrassing to the whole community, both in > it's buggy-ness and it's poorly written source code. This is beneath trolling. Redeem yourself by apologizing. Marko From rosuav at gmail.com Thu Jul 17 14:48:19 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:48:19 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: On Fri, Jul 18, 2014 at 4:38 AM, Rick Johnson wrote: >> This is a truly amazing demonstration. You have outdone >> Gaelmaen for comprehensibly incorrect use of English. > > Of all my impassioned pleas, astute logical reasoning, and > empathetic motivational speeches, of all of that "gold", all > you can muster is to harp about a few misspellings? > > ARE YOU SERIOUS? > > Okay, i admit it. My spell checker is broken -- maybe it > was written in Python3 and it's fuzzy logic is a little too > fuzzy for it's own good? Yeah, sure. That was absolute gold there, totally amazing stuff. I was so absolutely astonished by the sheer ... uh, amazingness of it, that I couldn't find anything to say. Either that, or it was a load of drivel. Kinda hard to tell one from the other, face like yours. But I imagine if if it were fear, your eyes would be wider. Or something like that. ChrisA From jhibschman at gmail.com Thu Jul 17 14:49:15 2014 From: jhibschman at gmail.com (Johann Hibschman) Date: Thu, 17 Jul 2014 14:49:15 -0400 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: Chris Angelico writes: > But you also don't know that he hasn't. NaN doesn't mean "unknown", it > means "Not a Number". You need a more sophisticated system that allows > for uncertainty in your data. Regardless of whether this is the right design, it's still an example of use. As to the design, using NaN to implement NA is a hack with a long history, see http://www.numpy.org/NA-overview.html for some color. Using NaN gets us a hardware-accelerated implementation with just about the right semantics. In a real example, these lists are numpy arrays with tens of millions of elements, so this isn't a trivial benefit. (Technically, that's what's in the database; a given analysis may look at a sample of 100k or so.) > You have a special business case here (the need to > record information with a "maybe" state), and you need to cope with > it, which means dedicated logic and planning and design and code. Yes, in principle. In practice, everyone is used to the semantics of R-style missing data, which are reasonably well-matched by nan. In principle, (NA == 1.0) should be a NA (missing) truth value, as should (NA == NA), but in practice having it be False is more useful. As an example, indexing R vectors by a boolean vector containing NA yields NA results, which is a feature that I never want. Cheers, Johann From marko at pacujo.net Thu Jul 17 14:50:24 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 17 Jul 2014 21:50:24 +0300 Subject: Blocked thread References: Message-ID: <87d2d3251r.fsf@elektro.pacujo.net> Chris Angelico : > It's more what the client library supports, rather than the server, > but sure. If it doesn't do async queries, that settles it. The server can't control that. At the networking/OS level, it's all asynchronous. I would recommend a process pool for blocking DB queries. Marko From rosuav at gmail.com Thu Jul 17 14:55:40 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:55:40 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: On Fri, Jul 18, 2014 at 4:49 AM, Johann Hibschman wrote: > Chris Angelico writes: > >> But you also don't know that he hasn't. NaN doesn't mean "unknown", it >> means "Not a Number". You need a more sophisticated system that allows >> for uncertainty in your data. > > Regardless of whether this is the right design, it's still an example of > use. Sure it is. And you may well have earned yourself that beer. But I don't put too much stock in hacks, at least as regards design decisions elsewhere. It's a little dubious when you grant special meaning to things and then use that meaning to justify the things' semantics. I'd much rather find an example where, for instance, numerical calculations might overflow to +inf or -inf, and then further calculations can result in a nan, etc, etc. Those are the sorts of examples that you'd find among SciPy users and such. ChrisA From rosuav at gmail.com Thu Jul 17 14:59:56 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 04:59:56 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: On Fri, Jul 18, 2014 at 4:49 AM, Johann Hibschman wrote: > In > principle, (NA == 1.0) should be a NA (missing) truth value, as should > (NA == NA), but in practice having it be False is more useful. This is actually fairly easily implemented, if you ever want it. class NAType: def __repr__(self): return "NA" def __eq__(self, other): return self __lt__ = __gt__ = __le__ = __ge__ = __ne__ = __eq__ NA = NAType() ChrisA From rosuav at gmail.com Thu Jul 17 15:01:16 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 05:01:16 +1000 Subject: Blocked thread In-Reply-To: <87d2d3251r.fsf@elektro.pacujo.net> References: <87d2d3251r.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 18, 2014 at 4:50 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> It's more what the client library supports, rather than the server, >> but sure. If it doesn't do async queries, that settles it. > > The server can't control that. At the networking/OS level, it's all > asynchronous. That's what I mean. But if your client library doesn't support async queries, it's not worth trying to hack it in. The "it" in the second sentence was referring to "client library", not "server", though I admit the grammar was a little unclear. ChrisA From breamoreboy at yahoo.co.uk Thu Jul 17 15:06:51 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 17 Jul 2014 20:06:51 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 17/07/2014 19:15, Rick Johnson wrote: > On Thursday, July 17, 2014 5:12:23 AM UTC-5, Fabien wrote: > > Sadly, all of my calls to improve IDLE have been meet with > rebukes about me "whining". The "powers that be" would wise > to *UTILIZE* and *ENCOURAGE* my participation instead of > *IGNORING* valuable talent and *IMPEDING* the expansion of > this "private boys club". > Terry Reedy and Co have been pouring improvements into IDLE via the bug tracker for months if not years. How many times have you logged on there to help out? The background that allows this to happen http://legacy.python.org/dev/peps/pep-0434/. How strongly this contrasts with '*IGNORING* valuable talent and *IMPEDING* the expansion of this "private boys club"'. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From marko at pacujo.net Thu Jul 17 15:10:08 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Thu, 17 Jul 2014 22:10:08 +0300 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: <877g3b244v.fsf@elektro.pacujo.net> Chris Angelico : > numerical calculations might overflow to +inf or -inf, and then > further calculations can result in a nan, etc, etc. Those are the > sorts of examples that you'd find among SciPy users and such. There is some inconsistency. Mathematically, there are undefined operations, for a good reason. That's because the limits are not unambiguous and that's why 0/0, 0**0, 1/0 and inf-inf are undefined. Why 0/0 results in an exception but inf-inf = nan, I don't see a justification. Marko From emile at fenx.com Thu Jul 17 15:22:53 2014 From: emile at fenx.com (Emile van Sebille) Date: Thu, 17 Jul 2014 12:22:53 -0700 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/17/2014 11:15 AM, Rick Johnson wrote: > Sadly, all of my calls to improve IDLE have been meet with > rebukes about me "whining". The "powers that be" would wise > to *UTILIZE* and *ENCOURAGE* my participation instead of > *IGNORING* valuable talent and *IMPEDING* the expansion of > this "private boys club". I imagine those that would be in a position to improve idle don't see the point of it. IMO, idle was never intended as a production development editor but more as an extensive example of gui programming with python. Yes, you _can_ use it to edit, and there are nice python hooks, but I doubt that anyone with the skills to enhance idle actually uses idle. You-can-also-program-using-notepad-eeew-ly y'rs, Emile From rantingrickjohnson at gmail.com Thu Jul 17 15:30:26 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 12:30:26 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Thursday, July 17, 2014 12:20:13 PM UTC-5, Chris Angelico wrote: > By the way, one specific point about RR's advice: A > colorizer should *not* be written using regexps. It'd make > for an absolute nightmare of impossible-to-debug regexp > strings Just because *YOU* harbor irrational fears of regexp pattern syntax, does mean the rest of us should propagate your religious beliefs and worship your "shrines of fear-mongering". Q: Is using regexps to create a colorizer the *ONLY* method to create a colorizer? A: Uh, no! Q: Is using regexps the *BEST* method to create a colorizer? A: Depends on who you ask and what the specific details are. Remember, this is "academic exercise", and i believe a damn *good* exercise because *even* a noob can understand the basic problems that need to be solved to create a colorizer: 1. I have a finite set of keywords and lexical structures that need to be located within a text. 2. I need to map colors to patterns so i can paint the keywords and lexical structures appropriately when i find them. 3. I need to institute events that will cause the colorizer to search for the patterns at appropriate times (for instance: when text is loaded, when text is edited, etc) 3a. Furthermore, i need to refine the breadth of my search area depending on the current context of the edit -- Should i search *only* the current line being edited, or, is the editing occurring inside a larger "multi-line lexical structure" that will need to be considered, OR, should i search the entire text??? > plus there are fundamental limitations on what you can > accomplish with them. Of course, *REMEMBER*, this is an "academic exercise", intended to familiarize the student with regexps and doing so in the context of a *real* world problem, who's scope is within the grasp of a noob, not some rechid flatulence pulled from the anus of a "so-called" teacher. But don't tell me for a *SECOND* that a colorizer, and a damn good one, can not be written utilizing regexps, because you're either wrong, or you're scared, or you're ignorant, or you're all of the above! > You need to use a lexer - a lexical analyzer. Basically, > to correctly colorize code, you need to have something > equivalent to the first part of the language interpreter, > but with a lot more tolerance for errors. That's a pretty > big thing to write as regexps. Great Chris, so as a "lesson" for learning *regexps* you propose that your students write a *lexer* instead. What's next? Do you propose they drive an auto whilst protruding their head from the vehicle like a canine, and observing the plant life on the side of the road to earn a degree in botany? You know, you would fit in nicely in the American public school system, since American teachers are not only free of the requirement of "teaching", they are actually *COMPELLED* not to do so by the greedy unions. I SURMISE YOUR DESK WILL BE DEVOID OF ANY "TREE BEARING" FRUITS! From nad at acm.org Thu Jul 17 15:37:57 2014 From: nad at acm.org (Ned Deily) Date: Thu, 17 Jul 2014 12:37:57 -0700 Subject: patch request for os.urandom() References: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> Message-ID: In article <7xlhrrkf6h.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: > I've stopped posting to the Python bug tracker because the password > management issues became too annoying. Can you elaborate on the problems you are having? -- Ned Deily, nad at acm.org From ned at nedbatchelder.com Thu Jul 17 15:41:44 2014 From: ned at nedbatchelder.com (Ned Batchelder) Date: Thu, 17 Jul 2014 15:41:44 -0400 Subject: Multiple python versions, one dev environment??? In-Reply-To: <20140717173231.7cfefae5@xs4all.nl> References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: On 7/17/14 11:32 AM, Joep van Delft wrote: > Hello! > > The condensed version of the question would probably be: How does one > deal with multiple interpreters and one package where you want to try > some changes? > > The background: > I made a trivial change to some package (docutils) to scratch a > personal itch, and I want to offer this back to the community > (whether it will be accepted or not). Because of this, I ran into > some issues. > > Some facts: > 1. Python3 is my main interpreter. > 2. The tests of docutils only run under python2. > 3. I desire not to touch my distribution's version of > site-packagesX-Y. > 4. I prefer to have one and only one development directory of > my target package. > > My confusions: > 1. Is it possible to have one source control managed directory of > some package, which is used by two versions of python? > 2. I assume that the *.pyc-files generated while using some python > source are version dependent. What is the recommended way to have > 'em both installed? > 3. The way I have stumped a wall over here, is the puzzle of how to > make python2 have a different $PYTHONPATH as python3. I hope to > hear how this strategy is silly :) > 4. I have contemplated the way of linking the source files from my > development directory into user specified site-packages > directories. Problem 3. still is valid. > 5. Should venv and friends/foes com into play? If so: How? > > Appreciate any light shed on these issues. Virtualenv is definitely the right way to isolate different Python environments from each other. Each one has its own PYTHONPATH, so each project of yours can have different packages installed. For testing one project on multiple versions of Python, use tox. Its entire reason for being is to test Python code against multiple environments, generally for different Python versions, but possibly for other reasons, like different versions of dependencies. Tox will manage the virtualenvs for you, it makes multi-version testing very simple. > > Thanks! > > > Joep > > > -- Ned Batchelder, http://nedbatchelder.com From joepvandelft at xs4all.nl Thu Jul 17 15:52:51 2014 From: joepvandelft at xs4all.nl (Joep van Delft) Date: Thu, 17 Jul 2014 21:52:51 +0200 Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: <20140717215251.7e3a51aa@xs4all.nl> Hello Javier! Thanks, those links are helping a bit. And: yes, I am using Archlinux. But still those links assume that there are totally separate site-packages* directories installed for both. I am not sure how I would surpass this distinction between py-X.P and py-Y.Q. Should I really create a massive amount of symlinks like this?: | #!/usr/bin/zsh | for d in ~/src/mypackage/**/*(/); do | # matches all directories | mkdir -p "~/src/py-2.7/mypackage/${d#*src/mypackage}" | mkdir -p "~/src/py-3.4/mypackage/${d#*src/mypackage}" | done | for f in ~/src/mypackage/**/^*.pyc(.); do | # matches all files except for *.pyc | ln -s "$f" "~/src/py-2.7/mypackage${f#*src/mypackage}" | ln -s "$f" "~/src/py-3.4/mypackage${f#*src/mypackage}" | done ...and then set $PYTHONPATH according to the target version in a #!/usr/local/bin-script? I can work with this (have not tried though), but there must be a more elegant solution than symlinking my way forward... Cheers! Joep On Thu, 17 Jul 2014 16:05:27 +0000 (UTC) Javier wrote: > Are you using arch linux. > > > I deal with multiple interpreters putting fake executables in > /usr/local/bin for everything: (python, sphinx, virtualenv, pydoc, > idle, python-config...) selecting 2 or 3. You can do the same for > selecting 2.3, 2.5, 2.7. What the scripts do is to detect whether > it is a system script whose prefix starts with /usr/bin, or whether > it is a user script. Being in /usr/local/bin they will override > executables in /usr/bin. Remember to chmod a+x the files > in /usr/local/bin > > http://sindhus.bitbucket.org/manage-python-2-3.html > http://stackoverflow.com/questions/15400985/how-to-completely-replace-python-3-with-python-2-in-arch-linux > https://wiki.archlinux.org/index.php/Python#Dealing_with_version_problem_in_build_scripts > > I use these scripts, but there is more than one way to do it > > ========/usr/local/bin/python=========================================== > #!/bin/bash > script=`readlink -f -- "$1"` > case "$script" in > /usr/bin*) > exec python3 "$@" > ;; > esac > exec python2 "$@" > > ========/usr/local/bin/virtualenv=========================================== > #!/bin/bash > script=`readlink -f -- "$1"` > case "$script" in > /usr/bin*) > exec virtualenv3 "$@" > ;; > esac > > exec virtualenv2 "$@" > > > > > > > > > Joep van Delft wrote: > > Hello! > > > > The condensed version of the question would probably be: How does > > one deal with multiple interpreters and one package where you > > want to try some changes? > > > > The background: > > I made a trivial change to some package (docutils) to scratch a > > personal itch, and I want to offer this back to the community > > (whether it will be accepted or not). Because of this, I ran into > > some issues. > > > > Some facts: > > 1. Python3 is my main interpreter. > > 2. The tests of docutils only run under python2. > > 3. I desire not to touch my distribution's version of > > site-packagesX-Y. > > 4. I prefer to have one and only one development directory of > > my target package. > > > > My confusions: > > 1. Is it possible to have one source control managed directory of > > some package, which is used by two versions of python? > > 2. I assume that the *.pyc-files generated while using some python > > source are version dependent. What is the recommended way to > > have 'em both installed? > > 3. The way I have stumped a wall over here, is the puzzle of how > > to make python2 have a different $PYTHONPATH as python3. I hope to > > hear how this strategy is silly :) > > 4. I have contemplated the way of linking the source files from my > > development directory into user specified site-packages > > directories. Problem 3. still is valid. > > 5. Should venv and friends/foes com into play? If so: How? > > > > Appreciate any light shed on these issues. > > > > Thanks! > > > > > > Joep > > > > > > From joepvandelft at xs4all.nl Thu Jul 17 15:54:54 2014 From: joepvandelft at xs4all.nl (Joep van Delft) Date: Thu, 17 Jul 2014 21:54:54 +0200 Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: <20140717215454.007e88a8@xs4all.nl> On Thu, 17 Jul 2014 15:41:44 -0400 Ned Batchelder wrote: > > For testing one project on multiple versions of Python, use tox. > Its entire reason for being is to test Python code against multiple > environments, generally for different Python versions, but possibly > for other reasons, like different versions of dependencies. > > Tox will manage the virtualenvs for you, it makes multi-version > testing very simple. > Excellent, Ned and Akira, I will look into it! Cheers, Joep From sturla.molden at gmail.com Thu Jul 17 15:54:48 2014 From: sturla.molden at gmail.com (Sturla Molden) Date: Thu, 17 Jul 2014 21:54:48 +0200 Subject: patch request for os.urandom() In-Reply-To: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> References: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> Message-ID: On 17/07/14 20:34, Paul Rubin wrote: > Could os.urandom() be patched to use the new Linux getrandom() system > call on systems where it is available? /dev/urandom exists on other Unix-like systems as well. Right now os.urandom only uses special system calls on Windows. Sturla From rowen at uw.edu Thu Jul 17 16:06:55 2014 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 17 Jul 2014 13:06:55 -0700 Subject: Mac python py2app problem References: <82cf4b72-25c5-4413-9550-eacd2e1a0e7c@googlegroups.com> Message-ID: In article , Gregory Ewing wrote: > Nicholas Cannon wrote: > > I do like the idea of making a .dmg file > > because i have used them downloading other apps and it works great but i > > dont > > know how to make them! > > In Disk Utility, use File>New>Disk Image from Folder. Or...open Disk Utility and drop the app onto its dock icon. -- Russell From christian at python.org Thu Jul 17 16:12:16 2014 From: christian at python.org (Christian Heimes) Date: Thu, 17 Jul 2014 22:12:16 +0200 Subject: patch request for os.urandom() In-Reply-To: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> References: <7xlhrrkf6h.fsf@ruckus.brouhaha.com> Message-ID: On 17.07.2014 20:34, Paul Rubin wrote: > Could os.urandom() be patched to use the new Linux getrandom() system > call on systems where it is available? Further info: > > http://lists.openwall.net/linux-kernel/2014/07/17/235 > > I've stopped posting to the Python bug tracker because the password > management issues became too annoying. > The feature will be implemented as soon as the first Linux distribution comes with a kernel version that supports the new syscall. By the way Python 3.4 is not vulnerable to fd exhaustion attack. The interpreter keeps an open file descriptor on /dev/urandom. The wrapper code ensures that the fd is not replaced. From breamoreboy at yahoo.co.uk Thu Jul 17 16:37:31 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 17 Jul 2014 21:37:31 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 17/07/2014 20:22, Emile van Sebille wrote: > On 7/17/2014 11:15 AM, Rick Johnson wrote: > >> Sadly, all of my calls to improve IDLE have been meet with >> rebukes about me "whining". The "powers that be" would wise >> to *UTILIZE* and *ENCOURAGE* my participation instead of >> *IGNORING* valuable talent and *IMPEDING* the expansion of >> this "private boys club". > > I imagine those that would be in a position to improve idle don't see > the point of it. IMO, idle was never intended as a production > development editor but more as an extensive example of gui programming > with python. Yes, you _can_ use it to edit, and there are nice python > hooks, but I doubt that anyone with the skills to enhance idle actually > uses idle. > > You-can-also-program-using-notepad-eeew-ly y'rs, > > Emile > Some of the top core developers teach classes using IDLE as it's the only tool guaranteed to be available on all the major platforms. You might also like to view this https://www.youtube.com/watch?v=d1a4Jbjc-vU -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ian.g.kelly at gmail.com Thu Jul 17 16:39:42 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Jul 2014 14:39:42 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <877g3b244v.fsf@elektro.pacujo.net> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <877g3b244v.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 1:10 PM, Marko Rauhamaa wrote: > Mathematically, there are undefined operations, for a good reason. > That's because the limits are not unambiguous and that's why 0/0, 0**0, > 1/0 and inf-inf are undefined. Well, 0**0 is usually defined as 1, despite the limits being ambiguous. Also, 1/0 in IEEE 754 is defined as inf. > Why 0/0 results in an exception but inf-inf = nan, I don't see a > justification. I expect that float division by zero was made to raise an exception for consistency with integer division by zero, where it might be considered inappropriate to switch types and return inf or nan. Granted that nowadays integer division returns a float anyway, but there is still floor division to think about. Maybe this should have been fixed in Python 3, but it wasn't. From marko at pacujo.net Thu Jul 17 17:08:02 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 18 Jul 2014 00:08:02 +0300 Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <877g3b244v.fsf@elektro.pacujo.net> Message-ID: <87tx6fzob1.fsf@elektro.pacujo.net> Ian Kelly : > Well, 0**0 is usually defined as 1, despite the limits being > ambiguous. But if it could be defined, what "should" it be? 0 or 1? Marko From tjreedy at udel.edu Thu Jul 17 17:30:12 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Jul 2014 17:30:12 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/17/2014 3:22 PM, Emile van Sebille wrote: > I imagine those that would be in a position to improve idle don't see > the point of it. IMO, idle was never intended as a production > development editor but more as an extensive example of gui programming > with python. Yes, you _can_ use it to edit, and there are nice python > hooks, but I doubt that anyone with the skills to enhance idle actually > uses idle. That is something of a problem as people 'graduate' to multi-language environments. However, while I have programmed in about 20 languages during my lifetime, I have now 'contracted' to using only Python (except for the occasional .bat file). So I use Idle to work on both my own stuff and on fixing Idle. When I notice an issue while working on an issue, I file a new issue. -- Terry Jan Reedy From tjreedy at udel.edu Thu Jul 17 17:46:51 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Jul 2014 17:46:51 -0400 Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On 7/17/2014 1:20 PM, Chris Angelico wrote: > By the way, one specific point about RR's advice: A colorizer should > *not* be written using regexps. It'd make for an absolute nightmare of > impossible-to-debug regexp strings, plus there are fundamental > limitations on what you can accomplish with them. You need to use a > lexer - a lexical analyzer. Basically, to correctly colorize code, you > need to have something equivalent to the first part of the language > interpreter, but with a lot more tolerance for errors. That's a pretty > big thing to write as regexps. It depends on how deeply one wants to colorize. idlelib.ColorDelegator colors comments, strings, keywords, builtin names, and names following 'def' and 'class' with the following regexes. def any(name, alternates): "Return a named group pattern matching list of alternates." return "(?P<%s>" % name + "|".join(alternates) + ")" def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(builtins) if not name.startswith('_') and \ name not in keyword.kwlist] # self.file = open("file") : # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) stringprefix = r"(\br|u|ur|R|U|UR|Ur|uR|b|B|br|Br|bR|BR|rb|rB|Rb|RB)?" sqstring = stringprefix + r"'[^'\\\n]*(\\.[^'\\\n]*)*'?" dqstring = stringprefix + r'"[^"\\\n]*(\\.[^"\\\n]*)*"?' sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?" dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?' string = any("STRING", [sq3string, dq3string, sqstring, dqstring]) return kw + "|" + builtin + "|" + comment + "|" + string +\ "|" + any("SYNC", [r"\n"]) prog = re.compile(make_pat(), re.S) idrog = re.compile(r"\s+(\w+)", re.S) asprog = re.compile(r".*?\b(as)\b") I am not sure if the separate definition for as is still needed, or is a holdover from when 'as' was not a keyword except in certain contexts. -- Terry Jan Reedy From nospam at nospam.com Thu Jul 17 17:52:57 2014 From: nospam at nospam.com (Javier) Date: Thu, 17 Jul 2014 21:52:57 +0000 (UTC) Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> <20140717215251.7e3a51aa@xs4all.nl> Message-ID: > I can work with this (have not tried though), but there must be a > more elegant solution than symlinking my way forward... I don't really understand what you are trying to do, but I would advise to use environment variables to control the behaviour of the fake scripts in /usr/local/bin In bash you can do export PYVERSION=2.5 And from that time onwards everything defaults to python2.5. note the ${PYVERSION} that I have included now in the sample scripts below to select the python version. I don't think you need to, but if you want to change the environment variable inside python you can set environment variables with something like os.environ.????? Look at the docs. Caveat1: I have not tested this, but it should work ok. The setup I use is much simpler: just default to python2.7 Caveat2: Arch linux packagers dont use a consistent naming of things: There exists /usr/bin/virtualenv3, but there does not exist /usr/bin/sphinx-build3 (it is /usr/bin/sphinx-build) Somebody should send a bug to the package maintainer. PS: Once you setup a workaround to bypass all the python=python3 nonsense, Arch Linux is a nice linux distro, the best out there. I will stick to it. HTH ========/usr/local/bin/python=========================================== #!/bin/bash script=`readlink -f -- "$1"` case "$script" in /usr/bin*) exec python3 "$@" ;; esac exec python${PYVERSION} "$@" ========/usr/local/bin/virtualenv=========================================== #!/bin/bash script=`readlink -f -- "$1"` case "$script" in /usr/bin*) exec virtualenv3 "$@" ;; esac exec virtualenv${PYVERSION} "$@" Joep van Delft wrote: > Hello Javier! > > Thanks, those links are helping a bit. And: yes, I am using Archlinux. > > But still those links assume that there are totally separate > site-packages* directories installed for both. I am not sure how I > would surpass this distinction between py-X.P and py-Y.Q. > > Should I really create a massive amount of symlinks like this?: > > | #!/usr/bin/zsh > | for d in ~/src/mypackage/**/*(/); do > | # matches all directories > | mkdir -p "~/src/py-2.7/mypackage/${d#*src/mypackage}" > | mkdir -p "~/src/py-3.4/mypackage/${d#*src/mypackage}" > | done > | for f in ~/src/mypackage/**/^*.pyc(.); do > | # matches all files except for *.pyc > | ln -s "$f" "~/src/py-2.7/mypackage${f#*src/mypackage}" > | ln -s "$f" "~/src/py-3.4/mypackage${f#*src/mypackage}" > | done > > ...and then set $PYTHONPATH according to the target version in a > #!/usr/local/bin-script? > > I can work with this (have not tried though), but there must be a > more elegant solution than symlinking my way forward... > > Cheers! > > > Joep > From fiedzia at gmail.com Thu Jul 17 18:01:14 2014 From: fiedzia at gmail.com (Maciej Dziardziel) Date: Thu, 17 Jul 2014 15:01:14 -0700 (PDT) Subject: Python package index in elasticsearch Message-ID: Hi Being frustrated with speed and inflexibility of pip search, I played with elasticsearch and set up my own index. Maybe someone will find it useful too. Site: http://pypisearch.linuxcoder.co.uk Code: https://github.com/Fiedzia/pypisearch Full lucene syntax is allowed. Note: indexing is in progress, but over 60% of pypi packages are there, it should get to 100% within max few hours. Having the basics working, I hope to polish it soon. Maciej Dziardziel fiedzia at gmail.com From hauzer at gmx.com Thu Jul 17 18:10:36 2014 From: hauzer at gmx.com (=?UTF-8?B?0J3QuNC60L7Qu9CwINCS0YPQutC+0YHQsNCy0ZnQtdCy0LjRmw==?=) Date: Fri, 18 Jul 2014 00:10:36 +0200 Subject: Python package index in elasticsearch In-Reply-To: References: Message-ID: <53C849DC.2020107@gmx.com> On 18.7.2014 0:01, Maciej Dziardziel wrote: > Hi > > Being frustrated with speed and inflexibility of pip search, I played with elasticsearch and set up my own index. > Maybe someone will find it useful too. > > Site: http://pypisearch.linuxcoder.co.uk > > Code: https://github.com/Fiedzia/pypisearch > > Full lucene syntax is allowed. > > Note: indexing is in progress, but over 60% of pypi packages are there, > it should get to 100% within max few hours. > > Having the basics working, I hope to polish it soon. > > Maciej Dziardziel > fiedzia at gmail.com > Looks great! From yasar11732 at gmail.com Thu Jul 17 17:38:04 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Fri, 18 Jul 2014 00:38:04 +0300 Subject: L-system equations drawing tool Message-ID: Hi, I wrote a small program to draw L-system equations using tkinter. You can find it on https://github.com/yasar11732/tklsystem It is still under development, but seems to be working nice so far. I could only try it on windows, but it should work on Linux too. You will need Python 3.x to run it. PIL/Pillow is optional but highly recommended. It allows faster rendering and ability to save images. You can also save your equations and load them later. Try it and comment it if you are interested. Bug reports and contributions are also welcome. -- http://ysar.net/ From breamoreboy at yahoo.co.uk Thu Jul 17 18:54:58 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Thu, 17 Jul 2014 23:54:58 +0100 Subject: Python 3 is killing Python In-Reply-To: <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> Message-ID: On 17/07/2014 02:16, Rick Johnson wrote: > On Wednesday, July 16, 2014 6:00:16 PM UTC-5, Mark Lawrence wrote: > >> Further the number of people assisting on the bug tracker >> at the moment appears to me to be going up, not down. It >> therefore strikes me that Python is extremely tenable, >> thus indicating that people are not falling for the FUD >> about Python 2 versus Python 3. > > Again, your "metrics", are tainted. I believe the spike in > bug reports has less to do with: Where did I say anything about a spike in bug reports? There are a large number of open reports, but a backlog built up as the core developers were at one point having to commit changes to five different versions. Design work is being done to simplify this process and hence free up core developers' time. It will take time but in a year or three I expect to see the number of open bugs dropping considerably. > > "New community members jumping in to help" The above is true, greatly helped by the core mentorship mailing list. > > And more to do with: > > "Damn, this Python3 is buggy and i need to tell someone > so i can get my customers off my back and this egg off > my face, lest my feet move faster than Fred Flintstone!" > Wrong, e.g. there were far more bug reports about encode or decode errors in Python 2 than we (the Python community) see for Python 3. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From ian.g.kelly at gmail.com Thu Jul 17 19:00:44 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Jul 2014 17:00:44 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <87tx6fzob1.fsf@elektro.pacujo.net> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <877g3b244v.fsf@elektro.pacujo.net> <87tx6fzob1.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 3:08 PM, Marko Rauhamaa wrote: > Ian Kelly : > >> Well, 0**0 is usually defined as 1, despite the limits being >> ambiguous. > > > > But if it could be defined, what "should" it be? 0 or 1? I did say "usually". There's not one single Holy Keeper of the Definitions for mathematics. Wikipedia lists some differing opinions on the subject: http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero I note that mathworld.wolfram.com also lists it as undefined, though. From ian.g.kelly at gmail.com Thu Jul 17 19:07:38 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Thu, 17 Jul 2014 17:07:38 -0600 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <877g3b244v.fsf@elektro.pacujo.net> <87tx6fzob1.fsf@elektro.pacujo.net> Message-ID: On Thu, Jul 17, 2014 at 5:00 PM, Ian Kelly wrote: > On Thu, Jul 17, 2014 at 3:08 PM, Marko Rauhamaa wrote: >> Ian Kelly : >> >>> Well, 0**0 is usually defined as 1, despite the limits being >>> ambiguous. >> >> >> >> But if it could be defined, what "should" it be? 0 or 1? > > I did say "usually". There's not one single Holy Keeper of the > Definitions for mathematics. Wikipedia lists some differing opinions > on the subject: > > http://en.wikipedia.org/wiki/Exponentiation#Zero_to_the_power_of_zero > > I note that mathworld.wolfram.com also lists it as undefined, though. Incidentally, as noted in the Wikipedia article you left out some options -- it's not just between 0 or 1. It's also possible to derive a limit of positive infinity or any nonnegative real. From roy at panix.com Thu Jul 17 19:44:21 2014 From: roy at panix.com (Roy Smith) Date: Thu, 17 Jul 2014 19:44:21 -0400 Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: In article , Ned Batchelder wrote: > On 7/17/14 11:32 AM, Joep van Delft wrote: > > Hello! > > > > The condensed version of the question would probably be: How does one > > deal with multiple interpreters and one package where you want to try > > some changes? > Virtualenv is definitely the right way to isolate different Python > environments from each other. Each one has its own PYTHONPATH, so each > project of yours can have different packages installed. Absolutely. Don't even consider any other alternative. Just do it. Our deployment process builds a new virtualenv for every release. Then you don't even have to think about what got added and what got deleted. We have a requirements file which we feed to pip and it creates exactly what we need for that release. We use wheel to speed things up, that's just an optimization. From tjreedy at udel.edu Thu Jul 17 20:13:44 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 17 Jul 2014 20:13:44 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/17/2014 2:15 PM, Rick Johnson wrote: a partial disinformation rant again Idle that repeats things said before, more than once. In general, your rants seem to serve the social purpose of providing cover to other people to join in loose, off-topic discussions. In this one, you align yourself with the 'private boys club' idle haters you profess to disdain. Some facts. Idlelib has about 60 modules. The tracker has, as I write, 133 open issues (behavior and enhancements, with the boundary sometimes fuzzy) marked Component: Idle. That is about two issues per module. It is definitely less than 1 bug per 100 lines. There is only 1 bug, Windows-specific, that routinely gets in my way. The stdlib has, I believe, less than 1000 modules. There are right now 4545 open issues, or at least 4, maybe more, per module. Anyone who calls Idle (or anything else) 'buggy' and 'embarassing' should do some research and say 'compared to what' and 'by what standard'. Last January, I discovered that tokenize.untokenize had about 5 bugs in about 25 lines of code. The new mode was hardly usable. I think *that* could be called 'embarassing' -- compared to the rest of the stdlib and by the standard of being basically usable. I fixed all but 1 of the implementation bugs. More facts. Since 2.7 was released in July 2010, there have been 94 issues with improvements recorded in idlelib/news.txt (extracted from the 2.7 news/changelog). (Some issues have multiple patches, and some patches no recorded issue, but we can stick with the recorded issue count.) Has the patch rate gone down or up? Over half (46) of the issue patches are recorded in the last 15 months out of 48, less than a third, after the release of 2.7.5 on 2013 April 4. The reason for the uptick is PEP 434, which ended the blockage of Idle patches by useless debates over 'behavior' versus 'enhancement' and backport or not'. It also ended (most of) the Idle hate rants on pydev. > Sadly, all of my calls to improve IDLE have been meet with > rebukes about me "whining". Each of the 133 issues on the tracker is a specific, usually actionable, 'call' to improve Idle. They are gradually being attended to. Generic 'calls for improvement' on this list are useless. > The "powers that be" When it comes to Idle, that means me as much as anyone. > would wise to *UTILIZE* and *ENCOURAGE* my participation Still more facts ;-). About three (four?) years ago, you posted a similar rant. Being wise, I encouraged your participation and utilized the patch you anonymously posted on the tracker (to maintain your Ranting Rick pose) in one of my first commits. I invite you to resume your participation, either anonymously or openly. As before, you can email me privately to discuss what would best suite you and also be helpful. I will mention that one barrier to improving Idle code, beyond making small local fixes, is the need for automated tests before refactoring. I started a unittest suite in May 2013 with the help of GSOC (Google Summer of Code) students. In May 2014, this year's student and I collected together and improved the human-run tests. -- Terry Jan Reedy From paul at mcnettware.com Thu Jul 17 16:21:30 2014 From: paul at mcnettware.com (Paul McNett) Date: Thu, 17 Jul 2014 13:21:30 -0700 Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: <53C8304A.8010201@mcnettware.com> On 7/17/14, 12:30 PM, Rick Johnson wrote: > You know, you would fit in nicely in the American public > school system, since American teachers are not only free of > the requirement of "teaching", they are actually*COMPELLED* > not to do so by the greedy unions. Hi Rick, I know a lot of American public school teachers, and they are among the hardest-working people I've ever encountered. I have no clue what you mean about them being free of the requirement to teach. Do you find that insulting people achieves your goals? Paul From breamoreboy at yahoo.co.uk Thu Jul 17 20:26:36 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 01:26:36 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 01:13, Terry Reedy wrote: > On 7/17/2014 2:15 PM, Rick Johnson wrote: > a partial disinformation rant again Idle > that repeats things said before, more than once. > > Still more facts ;-). About three (four?) years ago, you posted a > similar rant. Being wise, I encouraged your participation and utilized > the patch you anonymously posted on the tracker (to maintain your > Ranting Rick pose) in one of my first commits. I invite you to resume > your participation, either anonymously or openly. As before, you can > email me privately to discuss what would best suite you and also be > helpful. > I'm looking forward to see the massive number of fixes that come from rr, assuming of course that he signs the CLA to make this possible. Or has he already done so? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From aberg010 at my.hennepintech.edu Thu Jul 17 20:45:10 2014 From: aberg010 at my.hennepintech.edu (Andrew Berg) Date: Thu, 17 Jul 2014 19:45:10 -0500 Subject: Python 3 is killing Python In-Reply-To: References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <53C86E16.5030300@my.hennepintech.edu> On 2014.07.17 19:26, Mark Lawrence wrote: > I'm looking forward to see the massive number of fixes that come from > rr, assuming of course that he signs the CLA to make this possible. Or > has he already done so? > Maybe he's too busy working on RickPy 4000 (or whatever it was called). From wuwei23 at gmail.com Thu Jul 17 21:15:14 2014 From: wuwei23 at gmail.com (alex23) Date: Fri, 18 Jul 2014 11:15:14 +1000 Subject: Multiple python versions, one dev environment??? In-Reply-To: References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: On 18/07/2014 9:44 AM, Roy Smith wrote: > In article , > Ned Batchelder wrote: >> Virtualenv is definitely the right way to isolate different Python >> environments from each other. > > Absolutely. Don't even consider any other alternative. Just do it. Not even buildout? :) From roy at panix.com Thu Jul 17 21:29:06 2014 From: roy at panix.com (Roy Smith) Date: Thu, 17 Jul 2014 21:29:06 -0400 Subject: Multiple python versions, one dev environment??? References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: In article , alex23 wrote: > On 18/07/2014 9:44 AM, Roy Smith wrote: > > In article , > > Ned Batchelder wrote: > >> Virtualenv is definitely the right way to isolate different Python > >> environments from each other. > > > > Absolutely. Don't even consider any other alternative. Just do it. > > Not even buildout? :) OK, I will admit I'm not familiar with buildout. Perhaps I should have said, "Don't even consider trying to manage all this stuff manually. From rosuav at gmail.com Thu Jul 17 22:03:40 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 12:03:40 +1000 Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 5:30 AM, Rick Johnson wrote: > But don't tell me for a *SECOND* that a colorizer, and a > damn good one, can not be written utilizing regexps, because > you're either wrong, or you're scared, or you're ignorant, > or you're all of the above! It might well be able to *utilize* regexps (as Terry showed, the one in idlelib apparently does use them), but very few modern programming languages can be fully and correctly defined within the limits of regexp syntax. For instance, how can you recognize and thus colorize assignments differently from name references, to distinguish between "foo = 1" and "foo == 1"? Can you do that with a regexp? And there's plenty more syntax that's tricky to define. I might be wrong, and I might be ignorant, but I'm not scared. I know what a regular expression can and can't do, and it's not fear to avoid using them for jobs they can't do. ChrisA From rosuav at gmail.com Thu Jul 17 22:04:31 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 12:04:31 +1000 Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 7:46 AM, Terry Reedy wrote: > # self.file = open("file") : > # 1st 'file' colorized normal, 2nd as builtin, 3rd as string Is this pair of comments a hold-over from when it was common to use the file() constructor? Looks like it got searched-and-replaced. ChrisA From nicholascannon1 at gmail.com Thu Jul 17 22:03:07 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Thu, 17 Jul 2014 19:03:07 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> Message-ID: When I say i suck at finding good creative ideas I dont mean like I can think of anything its more like i cant think of anything that is within my scope of skill. These ideas are great guys thanks. Also the gui tool kit i used for the apps is tkinter because i am reading a book about python and it covers that tool kit. Also i like this idea of ssh'ing to a server where i could have a python program that allows files to be uploaded to a database and brought down from the data base. I am just not so good with the hardware so I dont really now how to create one. Also I wouldnt mind putting more functionality into my programs and stuff that sounds alright and also re inventing the wheel sounds like good practise. From rosuav at gmail.com Thu Jul 17 22:15:15 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 12:15:15 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 7:30 AM, Terry Reedy wrote: > That is something of a problem as people 'graduate' to multi-language > environments. However, while I have programmed in about 20 languages during > my lifetime, I have now 'contracted' to using only Python (except for the > occasional .bat file). So I use Idle to work on both my own stuff and on > fixing Idle. When I notice an issue while working on an issue, I file a new > issue. Glad to hear it. Best way to make sure Idle stays developed is for its core developers to actively use it. For myself, though, I completely do not use the editor half of it; but it's spectacularly useful (with limitations) as my primary interactive interpreter. That's partly because, on Windows, the command-line interpreter absolutely *sucks* (because most of its UI comes from cmd.exe - my view might be different if I had a different shell, but there's no point because Idle just blows it away), and partly because command recall/editing works on entire syntactic units rather than on lines. In fact, if I were to name *one single feature* that made Idle useful rather than a mere toy, it would have to be the ability to recall an entire function/class definition from command history for further editing. That is hugely helpful to me. It's what makes Python actually 100% usable in interactive mode - go right ahead, define functions and classes just as you would in a file! (Okay, you have to watch out about blank lines. Not usually an issue, but you'll possibly notice that I seldom have any internal blanks when I post a class definition on-list - it's because I usually write them in Idle.) The only problem I have with it is that blatting ridiculous amounts of text to the console can take a very long time, esp on Windows. If I accidentally display a large object when I thought I was displaying a small one, it'll hang for quite a while, churning through something, and it's not easy to see why or to halt it. But I suspect that's more of a Windows and/or Tk issue than an Idle one. ChrisA From rantingrickjohnson at gmail.com Thu Jul 17 22:24:34 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 19:24:34 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <87ha2f25bv.fsf@elektro.pacujo.net> References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On Thursday, July 17, 2014 1:44:20 PM UTC-5, Marko Rauhamaa wrote: > Rick Johnson : > > Sure, IDLE is not *useless*, however, it is in fact > > woefully inadequate and should be embarrassing to the > > whole community, both in it's buggy-ness and it's poorly > > written source code. > This is beneath trolling. Redeem yourself by apologizing. Apologize for what? For telling the truth? I have been using IDLE since around 2006, well at least, that is as far back as i remember. When i first learned Python, IDLE was my editor of choice, and i *STILL* use IDLE to this very day! -- although not as much as i have written my own IDE. I have logged thousands upon thousands of hours with IDLE, how many hours have *YOU* logged? I would even venture to say, and the comments on this list have supported my evidence for years, that i may be the *SOLE* heavy user of IDLE in the *ENTIRE* community. Although, i need to compare my stats with Terry because he claims to use the software quite often also. If *ANYBODY* in this damn community has a *RIGHT* to complain about IDLE, then *I* am that person. HOW DARE YOU chastise me for voicing my grievances regarding a software that *YOU* most likely have *NEVER*, or only *SLIGHTLY*, used! From rosuav at gmail.com Thu Jul 17 22:39:15 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 12:39:15 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 18, 2014 at 12:24 PM, Rick Johnson wrote: > I would even venture to say, and the comments on this list > have supported my evidence for years, that i may be the > *SOLE* heavy user of IDLE in the *ENTIRE* community. > ... > > If *ANYBODY* in this damn community has a *RIGHT* to > complain about IDLE, then *I* am that person. HOW DARE YOU > chastise me for voicing my grievances regarding a > software that *YOU* most likely have *NEVER*, or only > *SLIGHTLY*, used! Even if it is true that you're the only *user* of IDLE (or Idle; Terry seems to spell it the latter way, I'm not sure what's the official recommendation now), that does not give you any right whatsoever to complain about it. There are two valid reasons for claiming a right to complain: 1) You are the primary *developer* of the system, and put in many hours of work actually making it happen; or 2) You have paid money to someone, paying them a reasonable hourly rate for the same sort of level of work. So I would say Terry has a right to complain. I certainly don't, even though it's my primary Windows Python interface (on Linux boxes, I usually use 'python' or 'python3' in a regular xfce4-terminal; I do use IDLE on Linux as well, but not as often and certainly not as my primary interface to Python). To me, IDLE is a gift; a freely-granted boon to my use of this language. It's a huge step up from REXXTry (or even EREXXTry, the 'extended' version that has decent command-line editing tools); due to limitations on the REXX 'INTERPRET' command, it's impossible to define functions interactively, and a few other things. (That said, though, EREXXTry was for over a decade my sole interactive interpreter for any language. It was either that or save something to a file and run it.) Do I whine and complain because my gift isn't absolutely perfect? No. I might *humbly* open a discussion, but it's with the attitude of "these people have given hugely of their time" rather than "these people have done something which is WRONG". ChrisA From rosuav at gmail.com Thu Jul 17 22:42:26 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 12:42:26 +1000 Subject: Multiple python versions, one dev environment??? In-Reply-To: References: <20140717173231.7cfefae5@xs4all.nl> Message-ID: On Fri, Jul 18, 2014 at 11:29 AM, Roy Smith wrote: > In article , alex23 > wrote: > >> On 18/07/2014 9:44 AM, Roy Smith wrote: >> > In article , >> > Ned Batchelder wrote: >> >> Virtualenv is definitely the right way to isolate different Python >> >> environments from each other. >> > >> > Absolutely. Don't even consider any other alternative. Just do it. >> >> Not even buildout? :) > > OK, I will admit I'm not familiar with buildout. > > Perhaps I should have said, "Don't even consider trying to manage all > this stuff manually. I'd put this on par with source control. You'll see arguments about whether git or hg is the better option, but frankly, either of them (or bzr, or any of a bunch of others) is just so far ahead of *not* using source control that it's less important to distinguish than to say "Don't even consider trying to do this manually". ChrisA From wuwei23 at gmail.com Thu Jul 17 22:49:05 2014 From: wuwei23 at gmail.com (alex23) Date: Fri, 18 Jul 2014 12:49:05 +1000 Subject: Python 3 is killing Python In-Reply-To: <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 17/07/2014 1:14 PM, Steven D'Aprano wrote: > There will never be a Python 2.8. When push comes to shove, the people > bitching about Python 3 will not do the work necessary to fork Python 2.7 > and make a version 2.8. +1 The idea that forking and maintaining Python 2.8 is somehow _less effort_ than porting code to Python 3.x is batshit crazy. The Py2.8 claims seem to me to be nothing more than a shallow attempt to blackmail the core devs. From wuwei23 at gmail.com Thu Jul 17 22:54:12 2014 From: wuwei23 at gmail.com (alex23) Date: Fri, 18 Jul 2014 12:54:12 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 10:26 AM, Mark Lawrence wrote: > I'm looking forward to see the massive number of fixes that come from > rr I'm still waiting for RickPython, the One True Python. Remember when he used to rant as if he was actually working on it and not just pissing in the wind? From wuwei23 at gmail.com Thu Jul 17 23:01:13 2014 From: wuwei23 at gmail.com (alex23) Date: Fri, 18 Jul 2014 13:01:13 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 10:45 AM, Andrew Berg wrote: > Maybe he's too busy working on RickPy 4000 (or whatever it was called). I believe the new working name is PypeDream. From rantingrickjohnson at gmail.com Thu Jul 17 23:07:27 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 20:07:27 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Thursday, July 17, 2014 9:03:40 PM UTC-5, Chris Angelico wrote: > [colorizers] might well be able to *utilize* regexps [...] > but very few modern programming languages can be fully and > correctly defined within the limits of regexp syntax. We're not talking about "defining" or "interpreting" languages Chris, we're simply talking about "colorizers" -- which simply search for lexical patterns and apply *COLOR* to the resulting matches! PAY ATTENTION! > For instance, how can you recognize and thus colorize > assignments differently from name references, to > distinguish between "foo = 1" and "foo == 1"? First of all, why the heck would want to colorize something like that? And if your intention is "highlight" cases where a programmer uses "==" in a condition, then you need to use a "source code analyzer", like Pylint! Secondly, as the number of colorizer targets increases, the effectiveness of colored text decreases -- from a "human comprehension" perspective that is. For me, only the following targets need colorizing: Keywords Built-ins Terminated Strings Un-terminated Strings Comments Annotations That's it! Anymore color and your code starts to resemble a Pollock drip painting. Now, finally, if you cannot write a regexp that matches: 1. One or more alphanumeric chars(or the US) followed by zero or more spaces followed by two equals chars followed by zero or more spaces followed by one or more alphanumeric chars(or the US) or 2. One or more alphanumeric_chars(or the US) followed by zero or more spaces followed by one equals char followed by zero or more spaces, followed by one or more alphanumeric chars(or the US) Then you are either joking or trolling or you need to read the Python re docs. https://docs.python.org/2/library/re.html#module-re From rosuav at gmail.com Thu Jul 17 23:23:50 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 13:23:50 +1000 Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 1:07 PM, Rick Johnson wrote: > For me, only the following targets need colorizing: > > Keywords > Built-ins And be sure *not* to colorize built-ins (but *do* colorize keywords) in contexts where the tokens are actually identifiers, like "x.open = 1". Plus, if you want this to be truly general, you need to have it understand that some keywords aren't keywords if the shebang is different, although with 2.7 vs 3.4 that only really applies to nonlocal (if True/False/None are colored as keywords even though they're technically builtins, that's not a big deal); if you want to support Python 2.5, you'd also have to cope with a __future__ directive adding a keyword, but that's quite optional. It's not as simple as you might think. I've worked with plenty of syntax highlighters that get something wrong in some context, and it's extremely annoying; in some cases it makes the colorization actually harmful, rather than helpful. And it's absolutely *essential* that the lexer and the language agree on, for instance, what characters constitute identifiers; if I have a partially non-ASCII variable name and only the ASCII half of it gets highlighted, that can be highly distracting. ChrisA From drsalists at gmail.com Thu Jul 17 23:34:25 2014 From: drsalists at gmail.com (Dan Stromberg) Date: Thu, 17 Jul 2014 20:34:25 -0700 Subject: Python 3 is killing Python In-Reply-To: References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Thu, Jul 17, 2014 at 7:49 PM, alex23 wrote: > On 17/07/2014 1:14 PM, Steven D'Aprano wrote: >> >> There will never be a Python 2.8. When push comes to shove, the people >> bitching about Python 3 will not do the work necessary to fork Python 2.7 >> and make a version 2.8. > > > +1 > > The idea that forking and maintaining Python 2.8 is somehow _less effort_ > than porting code to Python 3.x is batshit crazy. Probably. I'd say that if anything kills Python, it'll be the people who are afraid of a small dose of positive change. From rantingrickjohnson at gmail.com Thu Jul 17 23:37:07 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 20:37:07 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: > For myself, though, I completely do not use the editor half of [IDLE]; but > it's spectacularly useful (with limitations) as my primary interactive > interpreter. Yes Chris, i also think that the IDLE shell is "spectacular" when i'm using it, especially when i press "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* the start of the interactive command marker " >>>", an area where key presses are not allowed, so *NOW* I must press "CONTROL+RIGHT_ARROW" three times to get to my destination! I'm also just "gushing with exuberance" when i open a new block and i get *EIGHT SPACE INDENTION*! And I get a raging semi each time IDLE hangs between run sessions when i'm editing Tkinter code, yes Chris, I GET A BIG FAT ERECTION! Sometimes, when it does not go away after four hours, i have to visit the local emergency room and take some pills. THAT'S HOW MUCH I JUST *LOVE* THIS CRAPPY SOFTWARE CHRIS! I'M SO GLAD WE CAN SHARE THESE "WONDERFUL" EXPERIENCES TOGETHER! MAYBE NEXT WE CAN RE-INACT THE LAST SCENE OF ROMEO AND JULIETTE? > [...] The only problem I have with it is that blatting > ridiculous amounts of text to the console can take a very > long time, esp on Windows. If I accidentally display a > large object when I thought I was displaying a small one, > it'll hang for quite a while, churning through something, > and it's not easy to see why or to halt it. But I suspect > that's more of a Windows and/or Tk issue than an Idle one. The *PROBLEM* is that user has no method of "undo-ing" an accidental display of huge amounts of data , forcing the user to close and then re-open the entire software -- can you understand now *WHY* i complain about this software? This is *EMBARRASSING*, and you should *ALL* be ashamed that, not only does Python include such an amateurish piece of crap software, but it has been there for years! UNCHANGED FOR YEARS!!! From torriem at gmail.com Thu Jul 17 23:40:59 2014 From: torriem at gmail.com (Michael Torrie) Date: Thu, 17 Jul 2014 21:40:59 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: <53C8974B.3070008@gmail.com> On 07/17/2014 08:24 PM, Rick Johnson wrote: > i *STILL* use IDLE > to this very day! -- although not as much as i have written > my own IDE. Maybe you should release it so we can make demands of you without bothering to contribute to it's development, either in code, or in bug reports. From rantingrickjohnson at gmail.com Fri Jul 18 00:06:19 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Thu, 17 Jul 2014 21:06:19 -0700 (PDT) Subject: I need an idea for practise! In-Reply-To: References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> Message-ID: <4ce425e1-4c51-4ad2-91a3-fbf3577bd1a9@googlegroups.com> On Thursday, July 17, 2014 10:23:50 PM UTC-5, Chris Angelico wrote: > And be sure *not* to colorize built-ins (but *do* colorize > keywords) in contexts where the tokens are actually > identifiers, like "x.open = 1". Just check for word boundaries on all your keywords and built-ins and you're *DONE*! > Plus, if you want this to be truly general, you need to > have it understand that some keywords aren't keywords if > the shebang is different, although with 2.7 vs 3.4 that > only really applies to nonlocal (if True/False/None are > colored as keywords even though they're technically > builtins, that's not a big deal); if you want to support > Python 2.5, you'd also have to cope with a __future__ > directive adding a keyword, but that's quite optional. > It's not as simple as you might think. Stop it, you're embarrassing yourself with all this rambling! You should have shut up a long time ago. Just like the thread where you embarrassed yourself with your limited knowledge of IDLE[1] and Tkinter, you're now really loosing all respect as a competent programmer if you cannot even write these "simple" regexps. > I've worked with plenty of syntax highlighters that get > something wrong in some context, and it's extremely > annoying; in some cases it makes the colorization actually > harmful, rather than helpful. And it's absolutely > *essential* that the lexer and the language agree on, for > instance, what characters constitute identifiers; if I > have a partially non-ASCII variable name and only the > ASCII half of it gets highlighted, that can be highly > distracting. Oh i get it now, your confusing Python with REXX again... *face palm* [1] Heck, you don't even realize that IDLE and an "acronym". From modulok at gmail.com Fri Jul 18 00:46:07 2014 From: modulok at gmail.com (Modulok) Date: Thu, 17 Jul 2014 22:46:07 -0600 Subject: OT - information theory thing... Message-ID: I'm trying to remember something I read one night to do with information theory to vague for Google to help much. If anyone could help me remember that would be wonderful! It had something to do with the fact that, given a transmission medium, you can control whether information flows or not, but it is impossible to control *what* information flows. (Due to the possibility of nested encoding, stenography, etc.) Was this a Claude Shannon thing or Alan Turing or... I really don't recall. Thoughts? Cheers! -Modulok- -------------- next part -------------- An HTML attachment was scrubbed... URL: From nad at acm.org Fri Jul 18 01:14:46 2014 From: nad at acm.org (Ned Deily) Date: Thu, 17 Jul 2014 22:14:46 -0700 Subject: Python package index in elasticsearch References: Message-ID: In article , Maciej Dziardziel wrote: > Being frustrated with speed and inflexibility of pip search, I played with > elasticsearch and set up my own index. > Maybe someone will find it useful too. > > Site: http://pypisearch.linuxcoder.co.uk > > Code: https://github.com/Fiedzia/pypisearch > > Full lucene syntax is allowed. > > Note: indexing is in progress, but over 60% of pypi packages are there, > it should get to 100% within max few hours. Nice. But you should take a look at Warehouse, which is the anticipated replacement for PyPI. Perhaps you can give Donald a hand. https://warehouse.python.org https://pypi.python.org/pypi/warehouse -- Ned Deily, nad at acm.org From marko at pacujo.net Fri Jul 18 01:24:50 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 18 Jul 2014 08:24:50 +0300 Subject: Python 3 is killing Python References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: <87k37bz1b1.fsf@elektro.pacujo.net> Rick Johnson : > On Thursday, July 17, 2014 1:44:20 PM UTC-5, Marko Rauhamaa wrote: >> Rick Johnson : >> > Sure, IDLE is not *useless*, however, it is in fact woefully >> > inadequate and should be embarrassing to the whole community, both >> > in it's buggy-ness and it's poorly written source code. >> This is beneath trolling. Redeem yourself by apologizing. > > Apologize for what? > > For telling the truth? The truth has nothing to do about it. You just don't talk like that about somebody's labor of love. Marko From rosuav at gmail.com Fri Jul 18 01:34:31 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 15:34:31 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 1:37 PM, Rick Johnson wrote: > I'm also just "gushing with exuberance" when i open a new > block and i get *EIGHT SPACE INDENTION*! Actually, you don't. And it wouldn't be a bug if you did. ChrisA From rosuav at gmail.com Fri Jul 18 02:00:16 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 16:00:16 +1000 Subject: I need an idea for practise! In-Reply-To: <4ce425e1-4c51-4ad2-91a3-fbf3577bd1a9@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <467108ec-19e7-4089-8d5f-53a80244adaf@googlegroups.com> <4ce425e1-4c51-4ad2-91a3-fbf3577bd1a9@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 2:06 PM, Rick Johnson wrote: > On Thursday, July 17, 2014 10:23:50 PM UTC-5, Chris Angelico wrote: >> And be sure *not* to colorize built-ins (but *do* colorize >> keywords) in contexts where the tokens are actually >> identifiers, like "x.open = 1". > > Just check for word boundaries on all your keywords and > built-ins and you're *DONE*! Of course, because (True.real) is just as much not-a-keyword as (real.True), naturally. >> Plus, if you want this to be truly general, you need to >> have it understand that some keywords aren't keywords if >> the shebang is different, although with 2.7 vs 3.4 that >> only really applies to nonlocal (if True/False/None are >> colored as keywords even though they're technically >> builtins, that's not a big deal); if you want to support >> Python 2.5, you'd also have to cope with a __future__ >> directive adding a keyword, but that's quite optional. >> It's not as simple as you might think. > > Stop it, you're embarrassing yourself with all this rambling! > > You should have shut up a long time ago. Just like the > thread where you embarrassed yourself with your limited > knowledge of IDLE[1] and Tkinter, you're now really loosing > all respect as a competent programmer if you cannot even > write these "simple" regexps. Simple regexps that differ in one tiny part based on something way earlier? Sure, they're simple in the sense that you can devolve them into very simple components. By the same token, all Python programs are simple, because there are only 101 opcodes. Doesn't make it readable. >> I've worked with plenty of syntax highlighters that get >> something wrong in some context, and it's extremely >> annoying; in some cases it makes the colorization actually >> harmful, rather than helpful. And it's absolutely >> *essential* that the lexer and the language agree on, for >> instance, what characters constitute identifiers; if I >> have a partially non-ASCII variable name and only the >> ASCII half of it gets highlighted, that can be highly >> distracting. > > Oh i get it now, your confusing Python with REXX again... > > *face palm* I am? Oh right, because REXX totally has non-ASCII variable names, and because I was always using syntax highlighting back in the 90s, but I don't do it now. Of course. ChrisA From breamoreboy at yahoo.co.uk Fri Jul 18 03:24:54 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 08:24:54 +0100 Subject: Python 3 is killing Python In-Reply-To: <53C86E16.5030300@my.hennepintech.edu> References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53C86E16.5030300@my.hennepintech.edu> Message-ID: On 18/07/2014 01:45, Andrew Berg wrote: > On 2014.07.17 19:26, Mark Lawrence wrote: >> I'm looking forward to see the massive number of fixes that come from >> rr, assuming of course that he signs the CLA to make this possible. Or >> has he already done so? >> > Maybe he's too busy working on RickPy 4000 (or whatever it was called). > I believe that rick would be a very apt word in this case. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Fri Jul 18 03:34:14 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 08:34:14 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On 18/07/2014 03:24, Rick Johnson wrote: > On Thursday, July 17, 2014 1:44:20 PM UTC-5, Marko Rauhamaa wrote: >> Rick Johnson : >>> Sure, IDLE is not *useless*, however, it is in fact >>> woefully inadequate and should be embarrassing to the >>> whole community, both in it's buggy-ness and it's poorly >>> written source code. >> This is beneath trolling. Redeem yourself by apologizing. > > Apologize for what? > > For telling the truth? > > I have been using IDLE since around 2006, well at least, > that is as far back as i remember. When i first learned > Python, IDLE was my editor of choice, and i *STILL* use IDLE > to this very day! -- although not as much as i have written > my own IDE. > > I have logged thousands upon thousands of hours with IDLE, > how many hours have *YOU* logged? > > I would even venture to say, and the comments on this list > have supported my evidence for years, that i may be the > *SOLE* heavy user of IDLE in the *ENTIRE* community. > Although, i need to compare my stats with Terry because he > claims to use the software quite often also. > > If *ANYBODY* in this damn community has a *RIGHT* to > complain about IDLE, then *I* am that person. HOW DARE YOU > chastise me for voicing my grievances regarding a > software that *YOU* most likely have *NEVER*, or only > *SLIGHTLY*, used! > Please list for everybody to see the issue numbers that you've worked on, on IDLE, on the bug tracker. Thank you. I now routinely use IDLE as it has been so much improved due to the efforts of Terry & Co. You are conspicious by your absence. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From shieldfire at gmail.com Fri Jul 18 03:50:13 2014 From: shieldfire at gmail.com (Martin S) Date: Fri, 18 Jul 2014 09:50:13 +0200 Subject: Two more newbie questions Message-ID: My little newbie app is now coming along nicely. It calculates both LASK and Elo ratings for chess, so basic functionality is pretty much complete for my needs. Now, a/ What is the "easiest" way of putting a web interface on this CLI application. I've been looking at various web frameworks but that seems pretty much targeted more towards larger projects. Not "slapping a gui" on a cli application. Any pointers and suggestions appreciated. b/ Catching user input errors. What is generally the best way of catching those and doing something sane with it. Entering "asdf" instead of a rating (like 2014) pretty much kills the little tool horribly. Again, pointers to relevant info appreciated. Maybe I've already seen it but didn't really understand the content ... =/ Regards, Martin S From ian.g.kelly at gmail.com Fri Jul 18 04:21:13 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Fri, 18 Jul 2014 02:21:13 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Thu, Jul 17, 2014 at 9:37 PM, Rick Johnson wrote: > On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >> For myself, though, I completely do not use the editor half of [IDLE]; but >> it's spectacularly useful (with limitations) as my primary interactive >> interpreter. > > Yes Chris, i also think that the IDLE shell is "spectacular" > when i'm using it, especially when i press > "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* > the start of the interactive command marker " >>>", an > area where key presses are not allowed, so *NOW* I must press > "CONTROL+RIGHT_ARROW" three times to get to my destination! I just tried to reproduce this using IDLE 3.4 on Windows and was not able to. > I'm also just "gushing with exuberance" when i open a new > block and i get *EIGHT SPACE INDENTION*! In the file editor when I press Tab I get four spaces as I would expect, using the default configuration. In the interactive interpreter I get an actual tab character again as I would expect. That's probably as it should be since I wouldn't want to not be able to type a tab character there. From ben at benfinney.id.au Fri Jul 18 04:23:39 2014 From: ben at benfinney.id.au (Ben Finney) Date: Fri, 18 Jul 2014 18:23:39 +1000 Subject: Two more newbie questions References: Message-ID: <85tx6fqdmc.fsf@benfinney.id.au> Martin S writes: > a/ What is the "easiest" way of putting a web interface on this CLI > application. I've been looking at various web frameworks but that > seems pretty much targeted more towards larger projects. Not "slapping > a gui" on a cli application. > Any pointers and suggestions appreciated. My suggestion: Have a firmer idea of what you want the UI to do. UI design is a very difficult problem; you are essentially making all kidns of compromises because humans and their expectations are messy, unpredictable, and expensive to work with. So, if by ?slap a GUI onto? you mean something that is a no-frills plain-HTML form, with essentially no assistance for the user and no error handling, this will be a lot simpler to implement than something easier for the human to use. > b/ Catching user input errors. What is generally the best way of > catching those and doing something sane with it. Entering "asdf" > instead of a rating (like 2014) pretty much kills the little tool > horribly. Right. Handling errors is very much a matter of UX policy for the application, and can easily consume far more of the programming effort than merely getting the back-end processing done. So again, the work to be done here is less Python-specific and much more about being tediously precise about how you want the user experience to work. It's difficult, exacting, fiddly work. Fortunately, the more exact you can be, the more likely a specific recommendation can be made. -- \ ?I knew things were changing when my Fraternity Brothers threw | `\ a guy out of the house for mocking me because I'm gay.? | _o__) ?postsecret.com, 2010-01-19 | Ben Finney From rosuav at gmail.com Fri Jul 18 04:27:03 2014 From: rosuav at gmail.com (Chris Angelico) Date: Fri, 18 Jul 2014 18:27:03 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On Fri, Jul 18, 2014 at 6:21 PM, Ian Kelly wrote: >> Yes Chris, i also think that the IDLE shell is "spectacular" >> when i'm using it, especially when i press >> "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* >> the start of the interactive command marker " >>>", an >> area where key presses are not allowed, so *NOW* I must press >> "CONTROL+RIGHT_ARROW" three times to get to my destination! > > I just tried to reproduce this using IDLE 3.4 on Windows and was not able to. Actually, now you mention it, I do recall experiencing a bug like this in previous versions. It's not the case in either my 2.7 (point something, but I don't remember what) nor 3.4, so I'm guessing it's been fixed. ChrisA From shieldfire at gmail.com Fri Jul 18 05:08:02 2014 From: shieldfire at gmail.com (Shieldfire) Date: Fri, 18 Jul 2014 11:08:02 +0200 Subject: Two more newbie questions In-Reply-To: <85tx6fqdmc.fsf@benfinney.id.au> References: <85tx6fqdmc.fsf@benfinney.id.au> Message-ID: <1405674482.7795.9.camel@mobileDragon> On fre, 2014-07-18 at 18:23 +1000, Ben Finney wrote: > Martin S writes: > > > a/ What is the "easiest" way of putting a web interface on this CLI > > application. I've been looking at various web frameworks but that > > seems pretty much targeted more towards larger projects. Not "slapping > > a gui" on a cli application. > > Any pointers and suggestions appreciated. > > My suggestion: Have a firmer idea of what you want the UI to do. > > So, if by ?slap a GUI onto? you mean something that is a no-frills > plain-HTML form, with essentially no assistance for the user and no > error handling, this will be a lot simpler to implement than something > easier for the human to use. Pretty much this. Because anyone using the tool would understand what to enter. There are things like opponent, result, tournament and rating without which there wouldn't be a need to use the tool in the first place. The only fancy thing I've done in the cli version is for it to remember some options the users has made previously (like Tournament defaults to previous post when entering several games) > > > b/ Catching user input errors. What is generally the best way of > > catching those and doing something sane with it. Entering "asdf" > > instead of a rating (like 2014) pretty much kills the little tool > > horribly. > > Right. Handling errors is very much a matter of UX policy for the > application, and can easily consume far more of the programming effort > than merely getting the back-end processing done. > > So again, the work to be done here is less Python-specific and much more > about being tediously precise about how you want the user experience to > work. Basically afaics at this time it is to ensure someone doesn't enter an incorrect value by mistake (like '' for result, or rating without it being an integer) and then letting the user correct the entries before committed. /Martin S From ben at benfinney.id.au Fri Jul 18 05:45:55 2014 From: ben at benfinney.id.au (Ben Finney) Date: Fri, 18 Jul 2014 19:45:55 +1000 Subject: Two more newbie questions References: <85tx6fqdmc.fsf@benfinney.id.au> <1405674482.7795.9.camel@mobileDragon> Message-ID: <85mwc7q9t8.fsf@benfinney.id.au> Shieldfire writes: > On fre, 2014-07-18 at 18:23 +1000, Ben Finney wrote: > > So, if by ?slap a GUI onto? you mean something that is a no-frills > > plain-HTML form, with essentially no assistance for the user and no > > error handling, this will be a lot simpler to implement than > > something easier for the human to use. > > Pretty much this. Because anyone using the tool would understand what to > enter. There are things like opponent, result, tournament and rating > without which there wouldn't be a need to use the tool in the first > place. In that case, design the UI as an HTML form; this is a task that requires no knowledge of Python, since you're just writing according to basic HTML. The Amazing Gezundheiticator

The Amazing Gezundheiticator

Fill out the inputs to the program and submit the form.

That's the input part of the UI; the other part is a response page with whatever result (error output, requested output, whatever) your back-end program will create. You'll need to write HTML pages for all the different kinds of responses your program can produce. It submits the input as an HTTP request to ?/uri/to/backend-program?. The web server's job is to turn that URI into a call to your Python program; and your program then needs to extract from the HTTP request the values to process, and generate an HTTP response. So you have these additional, related tasks for your UI: * Accepting HTTP requests and routing them to your back-end program. You'll need to run a web server of some kind, and configure a map of routes from incoming URIs to the corresponding program to handle them . * Generating HTML for all the different kinds of response (requested output, error output, requests to re-try, etc.) from the back-end program. This is the job of an HTML templating library; see for details. Start simple, with a very bare HTML template populated using the standard library's ?string.Template? class . * Serving the resulting generated page as an HTTP response. This needs to be handled in a standard way to conform to networking and web-browser expectations. The library handling your interface to the web server is the best candidate for this task. If you want a small framework to handle these while letting you keep your configuration work reasonably simple, I recommend Bottle . Good hunting! -- \ ?Perchance you who pronounce my sentence are in greater fear | `\ than I who receive it.? ?Giordano Bruno, burned at the stake by | _o__) the Catholic church for the heresy of heliocentrism, 1600-02-16 | Ben Finney From phani.lav at gmail.com Fri Jul 18 06:12:00 2014 From: phani.lav at gmail.com (lavanya addepalli) Date: Fri, 18 Jul 2014 12:12:00 +0200 Subject: Node Neighbours Message-ID: I am trying to find the neighbour of pair of Nodes. Individual and Combined. I am not getting any idea how to start about. Any suggestion will be appreciated Thanks Lav -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicholascannon1 at gmail.com Fri Jul 18 07:40:08 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Fri, 18 Jul 2014 04:40:08 -0700 (PDT) Subject: I am stuck on OOP Message-ID: Just quickly i am quite stuck on OOP and i really need like a good video and i cant find any. If anyone knows any please link it i really need it because i know OOP is important. From varun7rs at gmail.com Fri Jul 18 07:53:02 2014 From: varun7rs at gmail.com (varun7rs at gmail.com) Date: Fri, 18 Jul 2014 04:53:02 -0700 (PDT) Subject: Checking netlists for equivalence Message-ID: <68406b4d-bb85-462a-aa1b-88298fc7201d@googlegroups.com> Hello Everyone, I have tried to understand a code but I'm finding it extremely difficult in getting it through my head. I'd be glad if any of you could help me. I understood the parsexml function and I'm trying to understand the rest but finding it very hard. If any of you could spare your valuable time in explaining this code to me,I'd be very grateful and I also can learn a lot from your explanations. Thank You import sys import math import copy final_list = [] def sat(cnf): while( len(cnf) > 1 ): in_item = single_clause(cnf) if in_item != None: del_sat(cnf, in_item) else: break for i in cnf: if len(i) == 0: cnf.remove(i) return if len(cnf) == 1: final_list.extend( [cnf[0][0]] ) for i in range(0, len(final_list)): #print final_list if final_list[i] > 0: print final_list[i] print "Not equivalent!" sys.exit(0) return final_list deep_copy = copy.deepcopy(cnf) list2 = cnf[0][0] del_sat(deep_copy,list2) sat(deep_copy) del_sat(cnf,-list2) sat(cnf) return def parseXml(file_1, file_2): global cnf readfile_1 = open(file_1, "r") readfile_2 = open(file_2, "r") sum_a = int(readfile_1.readline()) sum_b = int(readfile_2.readline()) inputs_1 = readfile_1.readline().split() inputs_1.sort() inputs_2 = readfile_2.readline().split() inputs_2.sort() outputs_1 = readfile_1.readline().split() outputs_1.sort() outputs_2 = readfile_2.readline().split() outputs_2.sort() inputmap_1 = {} inputmap_2 = {} outputmap_1 = [] outputmap_2 = [] while True: line = readfile_1.readline().strip() if not line: break net,item = line.split() inputmap_1[item] = int(net) while True: line = readfile_2.readline().strip() if not line: break net,item = line.split() inputmap_2[item] = int(net) for line in readfile_1.readlines(): inp1 = line.split() gate = inp1.pop(0) mapping = map(int, inp1) outputmap_1.extend([(gate, mapping)]) for line in readfile_2.readlines(): inp2 = line.split() gate = inp2.pop(0) mapping = map(int, inp2) outputmap_2.extend([(gate, mapping)]) return inputs_1, inputs_2, outputs_1, outputs_2, inputmap_1, inputmap_2, outputmap_1, outputmap_2 def single_clause(cnf): for i in cnf: if len(i) == 1: return i[0] return None def del_sat(cnf,in_item): cnf2 = cnf[:] for k in cnf2: if k.count(in_item): cnf.remove(k) for i in cnf: if i.count( -in_item): i.remove(-in_item) def cnf_out(miter): miter_len = len(miter) cnf = [] while (miter_len > 0): x = miter.pop(0) if ( x[0] == "and" ): cnf.extend( [[x[1][0], -x[1][2]]] ) cnf.extend( [[x[1][1], -x[1][2]]] ) cnf.extend( [[-x[1][0], -x[1][1], x[1][2]]] ) elif ( x[0] == "or" ): cnf.extend( [[x[1][0], x[1][1], -x[1][2]]] ) cnf.extend( [[-x[1][0], x[1][2]]] ) cnf.extend( [[-x[1][1], x[1][2]]] ) elif ( x[0] == "xor" ): cnf.extend( [[x[1][0], x[1][1], -x[1][2]]] ) cnf.extend( [[-x[1][0], -x[1][1], -x[1][2]]] ) cnf.extend( [[-x[1][0], x[1][1], x[1][2]]] ) cnf.extend( [[x[1][0], -x[1][1], x[1][2]]] ) else: cnf.extend( [[x[1][0], x[1][1]]] ) cnf.extend( [[-x[1][0], -x[1][1]]] ) miter_len = miter_len - 1 return cnf inputs_1, inputs_2, outputs_1, outputs_2, inputmap_1, inputmap_2, outputmap_1, outputmap_2 = parseXml(sys.argv[1], sys.argv[2]) incoming1=[] incoming2=[] outgoing1=[] outgoing2=[] for i in inputs_1: incoming1.extend([inputmap_1[i]]) for j in inputs_2: incoming2.extend([inputmap_2[j]]) for k in outputs_1: outgoing1.extend([inputmap_1[k]]) for l in outputs_2: outgoing2.extend([inputmap_2[l]]) gate_num = 0 for output in outputmap_1: for j in output[1]: if gate_num < j: gate_num = j map2 = outputmap_2 num = len( map2 ) for i in range(1, num + 1): j = len( map2[i-1][1] ) for k in range(0, j): if map2[i-1][1][k] not in incoming2: total = 0 for l in incoming2: if map2[i-1][1][k] > l: total = total + 1 map2[i-1][1][k] = map2[i-1][1][k] + gate_num - total else: x = incoming2.index( map2[i-1][1][k] ) map2[i-1][1][k] = incoming1[x] miter = outputmap_1 miter.extend(map2) out_len = len(outgoing1) for i in range(out_len): total = 0 for j in incoming2: if outgoing2[i] > j: total = total + 1 outgoing2[i] = outgoing2[i] + gate_num - total xor_gate = [( 'xor', [outgoing1[i], outgoing2[i], 9000+i] )] miter.extend(xor_gate) if out_len > 1: or_gate_1 = [( 'or', [9000, 9000+1, 9000 + out_len] )] miter.extend(or_gate_1) for i in range(out_len - 2): or_gate=[( 'or', [9000 + out_len + i, 9000 +i + 2, 9000 + i + out_len + 1] )] miter.extend(or_gate) built_cnf = cnf_out(miter) count = 0 built_len = len(built_cnf) for i in range(0, built_len): built_leni = len(built_cnf[i]) for j in range(0, built_leni): if abs( built_cnf[i][j] ) > count: count = abs( built_cnf[i][j]) value = sat(built_cnf) print value print "Equivalent!" From joel.goldstick at gmail.com Fri Jul 18 08:12:24 2014 From: joel.goldstick at gmail.com (Joel Goldstick) Date: Fri, 18 Jul 2014 08:12:24 -0400 Subject: I am stuck on OOP In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 7:40 AM, Nicholas Cannon wrote: > Just quickly i am quite stuck on OOP and i really need like a good video > and i cant find any. If anyone knows any please link it i really need it > because i know OOP is important. > -- > https://mail.python.org/mailman/listinfo/python-list > That's odd. I just googled with this string: "python oop tutorial". I found enough information to keep me busy all day. -- Joel Goldstick http://joelgoldstick.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benfinney.id.au Fri Jul 18 08:29:40 2014 From: ben at benfinney.id.au (Ben Finney) Date: Fri, 18 Jul 2014 22:29:40 +1000 Subject: Node Neighbours References: Message-ID: <85iomurgsr.fsf@benfinney.id.au> lavanya addepalli writes: > I am trying to find the neighbour of pair of Nodes. Individual and > Combined. Is this a homework question? You might find better assistance over at the Tutor forum . > I am not getting any idea how to start about. You will need to provide (either here, or at the Tutor forum) much more information on the problem. What is the data you're working with? What code do you already have? What do you need to produce as a result? What have you already tried? If those questions are too overwhelming, I would definitely recommend going to the Python Tutor forum where they can help get to the bottom of what's needed. -- \ ?See, in my line of work you gotta keep repeating things over | `\ and over and over again, for the truth to sink in; to kinda | _o__) catapult the propaganda.? ?George W. Bush, 2005-05 | Ben Finney From kwpolska at gmail.com Fri Jul 18 08:37:47 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Fri, 18 Jul 2014 14:37:47 +0200 Subject: I am stuck on OOP In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 1:40 PM, Nicholas Cannon wrote: > Just quickly i am quite stuck on OOP and i really need like a good video and i cant find any. If anyone knows any please link it i really need it because i know OOP is important. > video There?s your problem: video tutorials are the most evil invention of the human race. It?s hard to learn from them. You should not watch any ? use text tutorials instead. -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From cjwilliams43 at gmail.com Fri Jul 18 09:29:58 2014 From: cjwilliams43 at gmail.com (cjwilliams43 at gmail.com) Date: Fri, 18 Jul 2014 06:29:58 -0700 (PDT) Subject: Python 3.4.1 64 bit Version Message-ID: The version given on Python.org is "Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32". This question is prompted by difficulties installing PyScripter. What does "on win32" mean in the above. I was using PyScripter on an AMD64 processor with Python 2.7. Now, with an attempt to move to Python 3, I have grief. How does one install "python-3.4.1.amd64-pdb"? I would welcome any advice. Thanks, Colin W. From kwpolska at gmail.com Fri Jul 18 09:48:36 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Fri, 18 Jul 2014 15:48:36 +0200 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 3:29 PM, wrote: > The version given on Python.org is "Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32". > > This question is prompted by difficulties installing PyScripter. What does "on win32" mean in the above. I was using PyScripter on an AMD64 processor with Python 2.7. Now, with an attempt to move to Python 3, I have grief. > > How does one install "python-3.4.1.amd64-pdb"? > > I would welcome any advice. > > Thanks, > > Colin W. > -- > https://mail.python.org/mailman/listinfo/python-list ?win32? is the name given to the Windows API as of Windows NT 3.1 and Windows 95. The ?AMD64? part in parentheses tells the truth, that you?re actually running the 64-bit version (which can cause problems, though ? it?s better to use the 32-bit version, IMO) -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From zachary.ware+pylist at gmail.com Fri Jul 18 09:53:03 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Fri, 18 Jul 2014 08:53:03 -0500 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 8:29 AM, wrote: > The version given on Python.org is "Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32". > > This question is prompted by difficulties installing PyScripter. What does "on win32" mean in the above. I was using PyScripter on an AMD64 processor with Python 2.7. Now, with an attempt to move to Python 3, I have grief. > > How does one install "python-3.4.1.amd64-pdb"? > > I would welcome any advice. The problem there isn't "on win32", it's ".4" :). Unless I've just missed the announcement PyScripter has not been updated to support Python 3.4, and I haven't figured out a way to trick it into working. However, PyScripter works fine with Python 3.3, and there were no syntax changes between 3.3 and 3.4. What I have found to work fairly well is to use PyScripter with 3.3, then test your program from a command prompt with 3.4. For the record, all versions of CPython on Windows (not counting anything relating to cygwin) are "on win32" regardless of the bittedness of the processor or the interpreter. Hope this helps, -- Zach From zachary.ware+pylist at gmail.com Fri Jul 18 09:54:50 2014 From: zachary.ware+pylist at gmail.com (Zachary Ware) Date: Fri, 18 Jul 2014 08:54:50 -0500 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 8:48 AM, Chris ?Kwpolska? Warrick wrote: > ?win32? is the name given to the Windows API as of Windows NT 3.1 and > Windows 95. The ?AMD64? part in parentheses tells the truth, that > you?re actually running the 64-bit version (which can cause problems, > though ? it?s better to use the 32-bit version, IMO) What problems have you run into with the 64-bit version? The only issues I've had have been my own problems with installing some versions as 32-bit and others as 64, and forgetting which was which. -- Zach From aberg010 at my.hennepintech.edu Fri Jul 18 09:59:27 2014 From: aberg010 at my.hennepintech.edu (Andrew Berg) Date: Fri, 18 Jul 2014 08:59:27 -0500 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: <53C9283F.7070901@my.hennepintech.edu> On 2014.07.18 08:53, Zachary Ware wrote: > For the record, all versions of CPython on Windows (not counting > anything relating to cygwin) are "on win32" regardless of the > bittedness of the processor or the interpreter. > And in case you need more reassurance, there is the platform module in the stdlib. https://docs.python.org/3/library/platform.html From invalid at invalid.invalid Fri Jul 18 10:17:03 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 18 Jul 2014 14:17:03 +0000 (UTC) Subject: Python 3 is killing Python References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <35c7f9e5-e4ab-4673-88f7-d41e5a4be26b@googlegroups.com> <53c73f90$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 2014-07-18, alex23 wrote: > On 17/07/2014 1:14 PM, Steven D'Aprano wrote: >> There will never be a Python 2.8. When push comes to shove, the people >> bitching about Python 3 will not do the work necessary to fork Python 2.7 >> and make a version 2.8. > > +1 > > The idea that forking and maintaining Python 2.8 is somehow _less > effort_ than porting code to Python 3.x is batshit crazy. The Py2.8 > claims seem to me to be nothing more than a shallow attempt to blackmail > the core devs. IMO, it's not even a credible "threat". It's more like idle whinging from people whom if given a brand new free BMW with lifetime maintenance, gasoline, insurance, taxes and registration paid (and a garage to keep it in) would bitch about the color of the interior. -- Grant Edwards grant.b.edwards Yow! I'm pretending that at we're all watching PHIL gmail.com SILVERS instead of RICARDO MONTALBAN! From invalid at invalid.invalid Fri Jul 18 10:19:59 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 18 Jul 2014 14:19:59 +0000 (UTC) Subject: Python 3 is killing Python References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On 2014-07-18, Rick Johnson wrote: > On Thursday, July 17, 2014 1:44:20 PM UTC-5, Marko Rauhamaa wrote: >> Rick Johnson : >>> Sure, IDLE is not *useless*, however, it is in fact woefully >>> inadequate and should be embarrassing to the whole community, both in >>> it's buggy-ness and it's poorly written source code. >> This is beneath trolling. Redeem yourself by apologizing. > > Apologize for what? Oh dear. Where should we start... > For telling the truth? Possibly, yes. Truth is no excuse for being rude and insulting. I've never used IDLE, so don't know much about it. But, I do know that a decent, civilized person just doesn't make insulting comments like that about somebody else's work even if it is true (which I very much doubt). -- Grant Edwards grant.b.edwards Yow! If I am elected no one at will ever have to do their gmail.com laundry again! From invalid at invalid.invalid Fri Jul 18 10:25:01 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Fri, 18 Jul 2014 14:25:01 +0000 (UTC) Subject: Node Neighbours References: Message-ID: On 2014-07-18, lavanya addepalli wrote: > I am trying to find the neighbour of pair of Nodes. Individual and > Combined. Well start in one of the Node's front room. Step out the front door and look around. Write down all the house numbers you can see. Maybe do the same thing outside of the back door. Repeat for the second node. Then do something with those two lists. Or not. > I am not getting any idea how to start about. I am not getting any idea of what the problem is about. More seriously, you're going to have to define "node" "neighbor", "individual" and "combined" before anybody can even hope to help you. -- Grant Edwards grant.b.edwards Yow! ONE LIFE TO LIVE for at ALL MY CHILDREN in ANOTHER gmail.com WORLD all THE DAYS OF OUR LIVES. From larry.martell at gmail.com Fri Jul 18 10:35:18 2014 From: larry.martell at gmail.com (Larry Martell) Date: Fri, 18 Jul 2014 08:35:18 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On Fri, Jul 18, 2014 at 8:19 AM, Grant Edwards wrote: > But, I do know that a > decent, civilized person just doesn't make insulting comments like > that about somebody else's work even if it is true (which I very much > doubt). Now, _that's_ funny. This is the internet. If you can't stand the heat get out of the kitchen. From bronger at physik.rwth-aachen.de Fri Jul 18 11:25:13 2014 From: bronger at physik.rwth-aachen.de (Torsten Bronger) Date: Fri, 18 Jul 2014 17:25:13 +0200 Subject: Python 3 is killing Python References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: <87tx6eofja.fsf@physik.rwth-aachen.de> Hall?chen! Larry Martell writes: > On Fri, Jul 18, 2014 at 8:19 AM, Grant Edwards wrote: > >> But, I do know that a decent, civilized person just doesn't make >> insulting comments like that about somebody else's work even if >> it is true (which I very much doubt). > > Now, _that's_ funny. This is the internet. If you can't stand the > heat get out of the kitchen. Now, _that's_ funny. This is the internet. If you can't stand people who can't stand the heat get out of the kitchen. Tsch?, Torsten. -- Torsten Bronger Jabber ID: torsten.bronger at jabber.rwth-aachen.de or http://bronger-jmp.appspot.com From iamAudreyJean at gmail.com Fri Jul 18 11:42:43 2014 From: iamAudreyJean at gmail.com (AudreyJean) Date: Fri, 18 Jul 2014 08:42:43 -0700 Subject: I need an idea for practise! In-Reply-To: <7d5885f5-118d-415f-b6ac-1ee382d600ac@googlegroups.com> References: <6239bcaa-828f-499b-936d-69d022bb94ac@googlegroups.com> <7d5885f5-118d-415f-b6ac-1ee382d600ac@googlegroups.com> Message-ID: On 07/17/2014 11:05 AM, Orochi wrote: > > > and there are many more you can go for "learnstreet.com" > > FYI: Learnstreet sent out an email a few weeks ago saying that they are shutting down. Here is a link I found about it. https://news.ycombinator.com/item?id=7986979 -- Deb in WA, USA From breamoreboy at yahoo.co.uk Fri Jul 18 11:45:51 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 16:45:51 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 04:01, alex23 wrote: > On 18/07/2014 10:45 AM, Andrew Berg wrote: >> Maybe he's too busy working on RickPy 4000 (or whatever it was called). > > I believe the new working name is PypeDream. > For me a very good day just got better with that one, thanks :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From python at mrabarnett.plus.com Fri Jul 18 11:46:31 2014 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Jul 2014 16:46:31 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <53C94157.9060500@mrabarnett.plus.com> On 2014-07-18 04:37, Rick Johnson wrote: > On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >> For myself, though, I completely do not use the editor half of [IDLE]; but >> it's spectacularly useful (with limitations) as my primary interactive >> interpreter. > > Yes Chris, i also think that the IDLE shell is "spectacular" > when i'm using it, especially when i press > "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* > the start of the interactive command marker " >>>", an > area where key presses are not allowed, so *NOW* I must press > "CONTROL+RIGHT_ARROW" three times to get to my destination! > > I'm also just "gushing with exuberance" when i open a new > block and i get *EIGHT SPACE INDENTION*! > > And I get a raging semi each time IDLE hangs between run > sessions when i'm editing Tkinter code, yes Chris, I GET A > BIG FAT ERECTION! Sometimes, when it does not go away > after four hours, i have to visit the local emergency room > and take some pills. > > THAT'S HOW MUCH I JUST *LOVE* THIS CRAPPY SOFTWARE CHRIS! > > I'M SO GLAD WE CAN SHARE THESE "WONDERFUL" EXPERIENCES TOGETHER! > > MAYBE NEXT WE CAN RE-INACT THE LAST SCENE OF ROMEO AND JULIETTE? > >> [...] The only problem I have with it is that blatting >> ridiculous amounts of text to the console can take a very >> long time, esp on Windows. If I accidentally display a >> large object when I thought I was displaying a small one, >> it'll hang for quite a while, churning through something, >> and it's not easy to see why or to halt it. But I suspect >> that's more of a Windows and/or Tk issue than an Idle one. > > The *PROBLEM* is that user has no method of "undo-ing" an > accidental display of huge amounts of data , forcing the > user to close and then re-open the entire software -- can > you understand now *WHY* i complain about this software? > > This is *EMBARRASSING*, and you should *ALL* be ashamed > that, not only does Python include such an amateurish piece > of crap software, but it has been there for years! > > UNCHANGED FOR YEARS!!! > I'm sorry to hear that you've been suffering all these years. If only there were a way to fix it. Here's a suggestion for the Python community: how about opening up the source code and letting people contribute fixes? We could call this "open source". We could even open the source for CPython itself! Could that work? What do you think? From breamoreboy at yahoo.co.uk Fri Jul 18 11:49:17 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 16:49:17 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 04:37, Rick Johnson wrote: > On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >> For myself, though, I completely do not use the editor half of [IDLE]; but >> it's spectacularly useful (with limitations) as my primary interactive >> interpreter. > > Yes Chris, i also think that the IDLE shell is "spectacular" > when i'm using it, especially when i press > "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* > the start of the interactive command marker " >>>", an > area where key presses are not allowed, so *NOW* I must press > "CONTROL+RIGHT_ARROW" three times to get to my destination! > > I'm also just "gushing with exuberance" when i open a new > block and i get *EIGHT SPACE INDENTION*! > > And I get a raging semi each time IDLE hangs between run > sessions when i'm editing Tkinter code, yes Chris, I GET A > BIG FAT ERECTION! Sometimes, when it does not go away > after four hours, i have to visit the local emergency room > and take some pills. > > THAT'S HOW MUCH I JUST *LOVE* THIS CRAPPY SOFTWARE CHRIS! > > I'M SO GLAD WE CAN SHARE THESE "WONDERFUL" EXPERIENCES TOGETHER! > > MAYBE NEXT WE CAN RE-INACT THE LAST SCENE OF ROMEO AND JULIETTE? > >> [...] The only problem I have with it is that blatting >> ridiculous amounts of text to the console can take a very >> long time, esp on Windows. If I accidentally display a >> large object when I thought I was displaying a small one, >> it'll hang for quite a while, churning through something, >> and it's not easy to see why or to halt it. But I suspect >> that's more of a Windows and/or Tk issue than an Idle one. > > The *PROBLEM* is that user has no method of "undo-ing" an > accidental display of huge amounts of data , forcing the > user to close and then re-open the entire software -- can > you understand now *WHY* i complain about this software? > > This is *EMBARRASSING*, and you should *ALL* be ashamed > that, not only does Python include such an amateurish piece > of crap software, but it has been there for years! > > UNCHANGED FOR YEARS!!! > This is patently wrong, IDLE is constantly being improved. I also don't recall ever seeing a bug report from yourself about IDLE. Your gretest strength seems to be complaining, your biggest weakness doing anything about whatever it is that you're complaining about. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Fri Jul 18 11:50:44 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 16:50:44 +0100 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 18/07/2014 09:27, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 6:21 PM, Ian Kelly wrote: >>> Yes Chris, i also think that the IDLE shell is "spectacular" >>> when i'm using it, especially when i press >>> "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* >>> the start of the interactive command marker " >>>", an >>> area where key presses are not allowed, so *NOW* I must press >>> "CONTROL+RIGHT_ARROW" three times to get to my destination! >> >> I just tried to reproduce this using IDLE 3.4 on Windows and was not able to. > > Actually, now you mention it, I do recall experiencing a bug like this > in previous versions. It's not the case in either my 2.7 (point > something, but I don't remember what) nor 3.4, so I'm guessing it's > been fixed. > > ChrisA > Fixed by whom, Terry Reedy & Co or rr? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Fri Jul 18 12:22:04 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 17:22:04 +0100 Subject: Python 3 is killing Python In-Reply-To: <53C94157.9060500@mrabarnett.plus.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53C94157.9060500@mrabarnett.plus.com> Message-ID: On 18/07/2014 16:46, MRAB wrote: > On 2014-07-18 04:37, Rick Johnson wrote: >> On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >>> For myself, though, I completely do not use the editor half of >>> [IDLE]; but >>> it's spectacularly useful (with limitations) as my primary interactive >>> interpreter. >> >> Yes Chris, i also think that the IDLE shell is "spectacular" >> when i'm using it, especially when i press >> "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* >> the start of the interactive command marker " >>>", an >> area where key presses are not allowed, so *NOW* I must press >> "CONTROL+RIGHT_ARROW" three times to get to my destination! >> >> I'm also just "gushing with exuberance" when i open a new >> block and i get *EIGHT SPACE INDENTION*! >> >> And I get a raging semi each time IDLE hangs between run >> sessions when i'm editing Tkinter code, yes Chris, I GET A >> BIG FAT ERECTION! Sometimes, when it does not go away >> after four hours, i have to visit the local emergency room >> and take some pills. >> >> THAT'S HOW MUCH I JUST *LOVE* THIS CRAPPY SOFTWARE CHRIS! >> >> I'M SO GLAD WE CAN SHARE THESE "WONDERFUL" EXPERIENCES TOGETHER! >> >> MAYBE NEXT WE CAN RE-INACT THE LAST SCENE OF ROMEO AND JULIETTE? >> >>> [...] The only problem I have with it is that blatting >>> ridiculous amounts of text to the console can take a very >>> long time, esp on Windows. If I accidentally display a >>> large object when I thought I was displaying a small one, >>> it'll hang for quite a while, churning through something, >>> and it's not easy to see why or to halt it. But I suspect >>> that's more of a Windows and/or Tk issue than an Idle one. >> >> The *PROBLEM* is that user has no method of "undo-ing" an >> accidental display of huge amounts of data , forcing the >> user to close and then re-open the entire software -- can >> you understand now *WHY* i complain about this software? >> >> This is *EMBARRASSING*, and you should *ALL* be ashamed >> that, not only does Python include such an amateurish piece >> of crap software, but it has been there for years! >> >> UNCHANGED FOR YEARS!!! >> > I'm sorry to hear that you've been suffering all these years. If only > there were a way to fix it. > > Here's a suggestion for the Python community: how about opening up the > source code and letting people contribute fixes? We could call this > "open source". > > We could even open the source for CPython itself! Could that work? > > What do you think? > That plan is so cunning it makes Baldrick's cunning plans look good :) http://en.wikipedia.org/wiki/Baldrick Actually I believe we should just leave things alone, if it ain't broke, don't fix it. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From steve+comp.lang.python at pearwood.info Fri Jul 18 13:57:03 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jul 2014 17:57:03 GMT Subject: NaN comparisons - Call For Anecdotes References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> Message-ID: <53c95fef$0$9505$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Jul 2014 01:36:24 +1000, Chris Angelico wrote: > On Fri, Jul 18, 2014 at 1:12 AM, Johann Hibschman > wrote: >> Well, I just spotted this thread. An easy example is, well, pretty >> much any case where SQL NULL would be useful. Say I have lists of >> borrowers, the amount owed, and the amount they paid so far. >> >> nan = float("nan") >> borrowers = ["Alice", "Bob", "Clem", "Dan"] amount_owed = [100.0, >> nan, 200.0, 300.0] amount_paid = [100.0, nan, nan, 200.0] >> who_paid_off = [b for (b, ao, ap) in >> zip(borrowers, amount_owed, amount_paid) >> if ao == ap] >> >> I want to just get Alice from that list, not Bob. I don't know how >> much Bow owes or how much he's paid, so I certainly don't know that >> he's paid off his loan. >> >> > But you also don't know that he hasn't. NaN doesn't mean "unknown", it > means "Not a Number". You need a more sophisticated system that allows > for uncertainty in your data. I would advise using either None or a > dedicated singleton (something like `unknown = object()` would work, or > you could make a custom type with a more useful repr) Hmmm, there's something to what you say there, but IEEE-754 NANs seem to have been designed to do quadruple (at least!) duty with multiple meanings, including: - Missing values ("I took a reading, but I can't read my handwriting"). - Data known only qualitatively, not quantitatively (e.g. windspeed = "fearsome"). - Inapplicable values, e.g. the average depth of the oceans on Mars. - The result of calculations which are mathematically indeterminate, such as 0/0. - The result of real-valued calculations which are invalid due to domain errors, such as sqrt(-1) or acos(2.5). - The result of calculations which are conceptually valid, but are unknown due to limitations of floats, e.g. you have two finite quantities which have both overflowed to INF, the difference between them ought to be finite, but there's no way to tell what it should be. It seems to me that the way you treat a NAN will often depend on which category it falls under. E.g. when taking the average of a set of values, missing values ought to be skipped over, while actual indeterminate NANs ought to carry through: average([1, 1, 1, Missing, 1]) => 1 average([1, 1, 1, 0/0, 1]) => NAN I know that R distinguishes between NA and IEEE-754 NANs, although I'm not sure how complete its support for NANs is. But many (most?) R functions take an argument controlling whether or not to ignore NA values. In principle, you can encode the different meanings into NANs using the payload. There are 9007199254740988 possible Python float NANs. Half of these are signalling NANs, half are quiet NANs. Ignoring the sign bit leaves us with 2251799813685247 distinct sNANs and the same qNANs. That's enough to encode a *lot* of different meanings. [Aside: I find myself perplexed why IEEE-754 says that the sign bit of NANs should be ignored, but then specifies that another bit is to be used to distinguish signalling from quiet NANs. Why not just interpret NANs with the sign bit set are signalling, those with it clear are quiet?] -- Steven From steve+comp.lang.python at pearwood.info Fri Jul 18 14:01:25 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jul 2014 18:01:25 GMT Subject: Python 3 is killing Python References: <57ajo9poljjre4c4ig0n0ss8kph8k78lp0@4ax.com> <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> Message-ID: <53c960f5$0$9505$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 10:36:43 -0700, Rick Johnson wrote: > On Thursday, July 17, 2014 12:48:38 AM UTC-5, alex23 wrote: >> PHP regularly breaks compatibility between _minor_ version releases: >> [...] more so with major releases: [...] yet I never see anywhere near >> as much angst and agony as Python 3.x has caused. > > Because you *IGNORE* the fact that people *ACTIVELY* choose to use > languages like Python, however, people *MOSTLY* use languages like PHP > and Javascript because they are *FORCED* That explains all those concentration camps in North Korea, filled with political prisoners sentenced to 30 years of PHP programming. -- Steven From steve+comp.lang.python at pearwood.info Fri Jul 18 14:20:10 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jul 2014 18:20:10 GMT Subject: Python 3 is killing Python References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 11:15:59 -0700, Rick Johnson wrote: > On Thursday, July 17, 2014 5:12:23 AM UTC-5, Fabien wrote: >> For non-informatic students [...] I don't think that's true. Less >> general languages like Matlab appear much easier to me: unified doc, >> unified IDE, unified debugger > > I'll agree that the lack of a "quality" IDE in Python is a point of > inadequacy. https://wiki.python.org/moin/IntegratedDevelopmentEnvironments PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, Geany, IEP, Spyder, Boa Constructor, PyScripter, NetBeans, Emacs, KDevelop, BlackAdder, ... [...] > Sadly, all of my calls to improve IDLE have been meet with rebukes about > me "whining". Why don't you go volunteer to fix a few IDLE bugs, instead of just demanding that others do it? http://bugs.python.org/issue17620 -- Steven From breamoreboy at yahoo.co.uk Fri Jul 18 14:31:23 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Fri, 18 Jul 2014 19:31:23 +0100 Subject: Python 3 is killing Python In-Reply-To: <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 18/07/2014 19:20, Steven D'Aprano wrote: > On Thu, 17 Jul 2014 11:15:59 -0700, Rick Johnson wrote: > >> Sadly, all of my calls to improve IDLE have been meet with rebukes about >> me "whining". > > Why don't you go volunteer to fix a few IDLE bugs, instead of just > demanding that others do it? > > http://bugs.python.org/issue17620 > Has time to complain but doesn't have time to fix bugs? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From cjwilliams43 at gmail.com Fri Jul 18 14:16:21 2014 From: cjwilliams43 at gmail.com (Colin J. Williams) Date: Fri, 18 Jul 2014 14:16:21 -0400 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: Thanks to Chris and Zachary, I shall retreat to Python 3.3 *pro tem* *Colin W.* On 18 July 2014 09:53, Zachary Ware wrote: > On Fri, Jul 18, 2014 at 8:29 AM, wrote: > > The version given on Python.org is "Python 3.4.1 (v3.4.1:c0e311e010fc, > May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32". > > > > This question is prompted by difficulties installing PyScripter. What > does "on win32" mean in the above. I was using PyScripter on an AMD64 > processor with Python 2.7. Now, with an attempt to move to Python 3, I > have grief. > > > > How does one install "python-3.4.1.amd64-pdb"? > > > > I would welcome any advice. > > The problem there isn't "on win32", it's ".4" :). Unless I've just > missed the announcement PyScripter has not been updated to support > Python 3.4, and I haven't figured out a way to trick it into working. > However, PyScripter works fine with Python 3.3, and there were no > syntax changes between 3.3 and 3.4. What I have found to work fairly > well is to use PyScripter with 3.3, then test your program from a > command prompt with 3.4. > > For the record, all versions of CPython on Windows (not counting > anything relating to cygwin) are "on win32" regardless of the > bittedness of the processor or the interpreter. > > Hope this helps, > -- > Zach > -------------- next part -------------- An HTML attachment was scrubbed... URL: From steve+comp.lang.python at pearwood.info Fri Jul 18 14:32:00 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jul 2014 18:32:00 GMT Subject: I am stuck on OOP References: Message-ID: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> On Fri, 18 Jul 2014 14:37:47 +0200, Chris ?Kwpolska? Warrick wrote: > On Fri, Jul 18, 2014 at 1:40 PM, Nicholas Cannon > wrote: >> Just quickly i am quite stuck on OOP and i really need like a good >> video and i cant find any. If anyone knows any please link it i really >> need it because i know OOP is important. > >> video > > There?s your problem: video tutorials are the most evil invention of the > human race. It?s hard to learn from them. You should not watch any ? > use text tutorials instead. Oh, I think that's a bit harsh. I would normally agree with you about text being better than video, but I watched a video explaining git and it made much more sense than anything I've read. -- Steven From steve+comp.lang.python at pearwood.info Fri Jul 18 14:38:21 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 18 Jul 2014 18:38:21 GMT Subject: Python 3 is killing Python References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <53c9699c$0$9505$c3e8da3$5496439d@news.astraweb.com> On Thu, 17 Jul 2014 20:13:44 -0400, Terry Reedy wrote: > On 7/17/2014 2:15 PM, Rick Johnson wrote: a partial disinformation rant > again Idle that repeats things said before, more than once. [...] Thanks for the detailed explanation Terry, and especially thanks for the good work you have done on IDLE. I'll admit I don't use it, I dislike the UI, but given all the solid work you and the GSOC students have put into it, perhaps I ought to check it out again soon. > Still more facts ;-). About three (four?) years ago, you posted a > similar rant. Being wise, I encouraged your participation and utilized > the patch you anonymously posted on the tracker (to maintain your > Ranting Rick pose) in one of my first commits. Well well, I must admit I am shocked to learn that Rick has actually written some Python code. -- Steven From kwpolska at gmail.com Fri Jul 18 14:45:57 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Fri, 18 Jul 2014 20:45:57 +0200 Subject: I am stuck on OOP In-Reply-To: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Jul 18, 2014 8:36 PM, "Steven D'Aprano" < steve+comp.lang.python at pearwood.info> wrote: > I would normally agree with you about > text being better than video, but I watched a video explaining git and it > made much more sense than anything I've read. Yes, exceptions do exist. But most video tutorials are produced by people without enough knowledge, and people that should not be working on educational material. This is especially visible in videos about basic things: they can be produced by just about anyone with a microphone ? which never leads to anything good. (In order to be more precise, I'd have to be politically incorrect.) -- Chris ?Kwpolska? Warrick Sent from my SGS3. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kwpolska at gmail.com Fri Jul 18 14:56:23 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Fri, 18 Jul 2014 20:56:23 +0200 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On Fri, Jul 18, 2014 at 3:54 PM, Zachary Ware wrote: > On Fri, Jul 18, 2014 at 8:48 AM, Chris ?Kwpolska? Warrick > wrote: >> ?win32? is the name given to the Windows API as of Windows NT 3.1 and >> Windows 95. The ?AMD64? part in parentheses tells the truth, that >> you?re actually running the 64-bit version (which can cause problems, >> though ? it?s better to use the 32-bit version, IMO) > > What problems have you run into with the 64-bit version? The only > issues I've had have been my own problems with installing some > versions as 32-bit and others as 64, and forgetting which was which. This is one of the issues: you can easily mess up 32-bit and 64-bit, and not even notice that (AppVeyor had an issue with that lately ? they switched python to 64 but left VC++ as 32). It?s also slightly easier to find pre-made binaries for 32-bit than 64-bit. In general, life in 64-bits on Windows is kinda hard, for everyone involved. -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From memilanuk at gmail.com Fri Jul 18 15:10:02 2014 From: memilanuk at gmail.com (memilanuk) Date: Fri, 18 Jul 2014 12:10:02 -0700 Subject: OT: usenet reader software Message-ID: Given the ongoing hub-bub about Google Groups and some recent long threads where I *really* wanted to be able to mute/ignore certain individuals/subjects... I started looking into other choices for Usenet reader software again. I use news.gmane.org as a mail2news gateway for reading a lot of lists besides just this one, and gmane is about the most convenient way to do so without being bombarded by emails every day. I'm on Ubuntu (14.04 LTS, if it matters) and I've been using Thunderbird for a loooong time... I've tinkered with slrn off and on over the years, tried pan occasionally due to recommendations... but I keep ending up back @ Thunderbird. About the only thing it doesn't do that I really want is scoring/kill-files. Slrn has those, and I do use vim on occasion so that worked well enough... but when people *do* post links or html it didn't handle that stuff gracefully like Thunderbird. Pan... locks up and crashes often enough to be annoying, and I can't get it to display 'Threads with Unread' (i.e. new unread posts *with* their associated threads for context) - just 'Unread' or 'everything'. Never messed with gnus... emacs was never really my thing. Guess where I'm going with this is... is there anything out there worth trying - on Linux - that I'm missing? From python at mrabarnett.plus.com Fri Jul 18 15:44:23 2014 From: python at mrabarnett.plus.com (MRAB) Date: Fri, 18 Jul 2014 20:44:23 +0100 Subject: Python 3 is killing Python In-Reply-To: <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53C97917.2000901@mrabarnett.plus.com> On 2014-07-18 19:20, Steven D'Aprano wrote: > On Thu, 17 Jul 2014 11:15:59 -0700, Rick Johnson wrote: > >> On Thursday, July 17, 2014 5:12:23 AM UTC-5, Fabien wrote: >>> For non-informatic students [...] I don't think that's true. Less >>> general languages like Matlab appear much easier to me: unified >>> doc, unified IDE, unified debugger >> >> I'll agree that the lack of a "quality" IDE in Python is a point of >> inadequacy. > > https://wiki.python.org/moin/IntegratedDevelopmentEnvironments > > PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, Geany, IEP, > Spyder, Boa Constructor, PyScripter, NetBeans, Emacs, KDevelop, > BlackAdder, ... > [snip] Yes, but _apart_ from PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, Geany, IEP, Spyder, Boa Constructor, PyScripter, NetBeans, Emacs, KDevelop and BlackAdder, why isn't there a "quality" IDE? (Sorry, but it had to be said. :-)) From marko at pacujo.net Fri Jul 18 15:40:49 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Fri, 18 Jul 2014 22:40:49 +0300 Subject: OT: usenet reader software References: Message-ID: <878unqzc8u.fsf@elektro.pacujo.net> memilanuk : > Guess where I'm going with this is... is there anything out there > worth trying - on Linux - that I'm missing? I use GNUS under emacs for both news and mail. Its main selling point is that the same keyboard commands work for news, mail, Python, C, gdb, pdb, guile. IOW, there is one tool for typing and editing text. Marko From rosuav at gmail.com Fri Jul 18 15:49:00 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 05:49:00 +1000 Subject: NaN comparisons - Call For Anecdotes In-Reply-To: <53c95fef$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <53BC05FB.4050707@jmunch.dk> <53BD70F4.4000504@stoneleaf.us> <53BDAF90.8010709@jmunch.dk> <53c95fef$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Jul 19, 2014 at 3:57 AM, Steven D'Aprano wrote: > Hmmm, there's something to what you say there, but IEEE-754 NANs seem to > have been designed to do quadruple (at least!) duty with multiple > meanings, including: > > - Missing values ("I took a reading, but I can't read my handwriting"). > > - Data known only qualitatively, not quantitatively (e.g. windspeed = > "fearsome"). > > - Inapplicable values, e.g. the average depth of the oceans on Mars. > > - The result of calculations which are mathematically indeterminate, > such as 0/0. > > - The result of real-valued calculations which are invalid due to > domain errors, such as sqrt(-1) or acos(2.5). > > - The result of calculations which are conceptually valid, but are > unknown due to limitations of floats, e.g. you have two finite > quantities which have both overflowed to INF, the difference > between them ought to be finite, but there's no way to tell what > it should be. Huh, okay. I thought the definition of NaN was based on the fourth one (mathematically indeterminate) and then it logically accepted the subsequent two (sqrt(-1) IMO is better handled by either a complex number or a thrown error, but NaN does make some sense there; definitely inf-inf => nan is as logical as 0/0 => nan). The first two seem to be better handled by SQL's NULL value (or non-value, or something, or maybe not something); the third is a bit trickier. Although "the average of no values" is logically calculated as 0/0 (ergo NaN makes sense there), I would say NaN isn't really right for a truly inapplicable value - for instance, recording the mass of a non-physical object. In an inventory system, it's probably simplest to use 0.0 to mean "non-physical item", but it might be worth distinguishing between "physical item with sufficiently low mass that it underflows our measurements" (like a single sheet of paper when you're working with postal scales) and "non-physical item with no meaningful mass" (like credit card fees). In that case, I'm not sure that NaN is really appropriate to the situation, but would defer to IEE 754 on the subject. Obviously it's possible to abuse anything to mean anything (I do remember using nullable fields in DB2 to mean everything from "inherit this value from parent" to "here be magic, code will work out the real value on the fly"), but this is a question of intent and good design. ChrisA From aberg010 at my.hennepintech.edu Fri Jul 18 15:34:20 2014 From: aberg010 at my.hennepintech.edu (Andrew Berg) Date: Fri, 18 Jul 2014 14:34:20 -0500 Subject: OT: usenet reader software In-Reply-To: References: Message-ID: <53C976BC.7000200@my.hennepintech.edu> On 2014.07.18 14:10, memilanuk wrote: > I'm on Ubuntu (14.04 LTS, if it matters) and I've been using Thunderbird > for a loooong time... I've tinkered with slrn off and on over the years, > tried pan occasionally due to recommendations... but I keep ending up > back @ Thunderbird. About the only thing it doesn't do that I really > want is scoring/kill-files. Tools -> Message Filters... From warren at invalid.invalid Fri Jul 18 16:23:04 2014 From: warren at invalid.invalid (Warren Post) Date: Fri, 18 Jul 2014 14:23:04 -0600 Subject: OT: usenet reader software In-Reply-To: References: Message-ID: On 07/18/2014 01:10 PM, memilanuk wrote: > ... is there anything out there worth > trying - on Linux - that I'm missing? You've already tried them, but I bounce between Thunderbird and Pan. The former because it's integrated with the most of the rest of my messaging (mail, RSS); the latter for its great filtering. I too have had stability problems with Pan, but compiling from source fixed that for me. -- Warren Post https://warrenpost.wordpress.com/ From alister.nospam.ware at ntlworld.com Fri Jul 18 16:27:56 2014 From: alister.nospam.ware at ntlworld.com (alister) Date: Fri, 18 Jul 2014 20:27:56 GMT Subject: OT: usenet reader software References: Message-ID: On Fri, 18 Jul 2014 12:10:02 -0700, memilanuk wrote: > Given the ongoing hub-bub about Google Groups and some recent long > threads where I *really* wanted to be able to mute/ignore certain > individuals/subjects... I started looking into other choices for Usenet > reader software again. I use news.gmane.org as a mail2news gateway for > reading a lot of lists besides just this one, and gmane is about the > most convenient way to do so without being bombarded by emails every > day. > > I'm on Ubuntu (14.04 LTS, if it matters) and I've been using Thunderbird > for a loooong time... I've tinkered with slrn off and on over the years, > tried pan occasionally due to recommendations... but I keep ending up > back @ Thunderbird. About the only thing it doesn't do that I really > want is scoring/kill-files. Slrn has those, and I do use vim on > occasion so that worked well enough... but when people *do* post links > or html it didn't handle that stuff gracefully like Thunderbird. Pan... > locks up and crashes often enough to be annoying, and I can't get it to > display 'Threads with Unread' (i.e. new unread posts *with* their > associated threads for context) - just 'Unread' or 'everything'. Never > messed with gnus... emacs was never really my thing. > > Guess where I'm going with this is... is there anything out there worth > trying - on Linux - that I'm missing? interesting apart from an issue i had with multiple postings (due to a setting change i made) I have never had any issues with pan -- Newman's Discovery: Your best dreams may not come true; fortunately, neither will your worst dreams. From sturla.molden at gmail.com Fri Jul 18 16:46:17 2014 From: sturla.molden at gmail.com (Sturla Molden) Date: Fri, 18 Jul 2014 20:46:17 +0000 (UTC) Subject: OT: usenet reader software References: Message-ID: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> > Guess where I'm going with this is... is there anything out there worth > trying - on Linux - that I'm missing? leafnode From memilanuk at gmail.com Fri Jul 18 17:07:49 2014 From: memilanuk at gmail.com (memilanuk) Date: Fri, 18 Jul 2014 14:07:49 -0700 Subject: OT: usenet reader software In-Reply-To: <53C976BC.7000200@my.hennepintech.edu> References: <53C976BC.7000200@my.hennepintech.edu> Message-ID: On 07/18/2014 12:34 PM, Andrew Berg wrote: > On 2014.07.18 14:10, memilanuk wrote: >> I'm on Ubuntu (14.04 LTS, if it matters) and I've been using Thunderbird >> for a loooong time... I've tinkered with slrn off and on over the years, >> tried pan occasionally due to recommendations... but I keep ending up >> back @ Thunderbird. About the only thing it doesn't do that I really >> want is scoring/kill-files. > Tools -> Message Filters... > Yeah... never seems to work quite the same - or consistently. From paul.nospam at rudin.co.uk Fri Jul 18 16:10:50 2014 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Fri, 18 Jul 2014 21:10:50 +0100 Subject: OT: usenet reader software References: Message-ID: <85d2d2e8c5.fsf@rudin.co.uk> memilanuk writes: > Guess where I'm going with this is... is there anything out there worth trying > - on Linux - that I'm missing? emacs/gnus. From memilanuk at gmail.com Fri Jul 18 17:09:26 2014 From: memilanuk at gmail.com (memilanuk) Date: Fri, 18 Jul 2014 14:09:26 -0700 Subject: OT: usenet reader software In-Reply-To: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> Message-ID: On 07/18/2014 01:46 PM, Sturla Molden wrote: >> Guess where I'm going with this is... is there anything out there worth >> trying - on Linux - that I'm missing? > > leafnode > Used leafnode way back when... correct me if I'm wrong, but if memory serves its a small news spool /server, not really a client/reader type application. Used to be popular back before slrnpull came about. From rantingrickjohnson at gmail.com Fri Jul 18 17:37:23 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Fri, 18 Jul 2014 14:37:23 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <5389cb53$0$29978$c3e8da3$5496439d@news.astraweb.com> <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> On Friday, July 18, 2014 1:20:10 PM UTC-5, Steven D'Aprano wrote: > PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, > Geany, IEP, Spyder, Boa Constructor, PyScripter, NetBeans, > Emacs, KDevelop, BlackAdder, ... And tell me Steven, how many of those "quality" IDEs that you listed actually *SHIP* with Python? The *WHOLE* reason for GvR *CREATING* and then *SHIPPING* IDLE, was to provide a simplistic native IDE for the noobs. That was his gift to the noobs, HOWEVER, this community has *SQUANDERED* that gift, and allowed it putrefy for over a decade and a half! A noob has not idea what an IDE *IS*, much less where to find a decent IDE, or what IDEs are even compatible with Python! IDLE was meant to provide a tool by which noobs can use to start writing Python code "out of the box". Do you remember the acronym of "CP4E"[1]? Sadly, most people in this community seem to forgotten, *MAYBE* even the dicktator himself! [1]: https://www.python.org/doc/essays/cp4e/ From sturla.molden at gmail.com Fri Jul 18 17:45:08 2014 From: sturla.molden at gmail.com (Sturla Molden) Date: Fri, 18 Jul 2014 21:45:08 +0000 (UTC) Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> Message-ID: <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> memilanuk wrote: > Used leafnode way back when... correct me if I'm wrong, but if memory > serves its a small news spool /server, not really a client/reader type > application. Used to be popular back before slrnpull came about. Leafnode is an NNTP proxy server. It allows you to filter messages on headers, etc. Just run Leafnode and tell Thunderbird to use localhost as NNTP server. Whomever you plonk with Leafnode's killfilter will never be seen in Thunderbird. Sturla From memilanuk at gmail.com Fri Jul 18 17:52:11 2014 From: memilanuk at gmail.com (memilanuk) Date: Fri, 18 Jul 2014 14:52:11 -0700 Subject: OT: usenet reader software In-Reply-To: <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> Message-ID: On 07/18/2014 02:45 PM, Sturla Molden wrote: > memilanuk wrote: > >> Used leafnode way back when... correct me if I'm wrong, but if memory >> serves its a small news spool /server, not really a client/reader type >> application. Used to be popular back before slrnpull came about. > > Leafnode is an NNTP proxy server. It allows you to filter messages on > headers, etc. Just run Leafnode and tell Thunderbird to use localhost as > NNTP server. Whomever you plonk with Leafnode's killfilter will never be > seen in Thunderbird. > Ah... I see. Guess I never explored that facet of leafnode's functionality. Thanks, Monte From ned at nedbatchelder.com Fri Jul 18 18:09:30 2014 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 18 Jul 2014 18:09:30 -0400 Subject: Python 3 is killing Python In-Reply-To: <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> Message-ID: On 7/18/14 5:37 PM, Rick Johnson wrote: > On Friday, July 18, 2014 1:20:10 PM UTC-5, Steven D'Aprano wrote: >> PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, >> Geany, IEP, Spyder, Boa Constructor, PyScripter, NetBeans, >> Emacs, KDevelop, BlackAdder, ... > > And tell me Steven, how many of those "quality" IDEs that > you listed actually *SHIP* with Python? > > The *WHOLE* reason for GvR *CREATING* and then *SHIPPING* > IDLE, was to provide a simplistic native IDE for the noobs. > That was his gift to the noobs, HOWEVER, this community has > *SQUANDERED* that gift, and allowed it putrefy for over a > decade and a half! > > A noob has not idea what an IDE *IS*, much less where to > find a decent IDE, or what IDEs are even compatible with > Python! IDLE was meant to provide a tool by which noobs can > use to start writing Python code "out of the box". > > Do you remember the acronym of "CP4E"[1]? Sadly, most people > in this community seem to forgotten, *MAYBE* even the > dicktator himself! > > [1]: https://www.python.org/doc/essays/cp4e/ > As a group, we have dealt with caustic respondents before. The way to get them to stop dragging threads into pointless arguments is to ignore them. I would advise doing the same in this case. All I see here is disrespectful trolling. -- Ned Batchelder, http://nedbatchelder.com From tjreedy at udel.edu Fri Jul 18 19:11:02 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 19:11:02 -0400 Subject: L-system equations drawing tool In-Reply-To: References: Message-ID: On 7/17/2014 5:38 PM, Ya?ar Arabac? wrote: > Hi, > > I wrote a small program to draw L-system equations using tkinter. You > can find it on https://github.com/yasar11732/tklsystem > > It is still under development, but seems to be working nice so far. I > could only try it on windows, but it should work on Linux too. > > You will need Python 3.x to run it. PIL/Pillow is optional but highly > recommended. It allows faster rendering and ability to save images. > > You can also save your equations and load them later. > > Try it and comment it if you are interested. Bug reports and > contributions are also welcome. As near as I can tell, this is a collection of modules rather than a package. This means that for imports like these to work: from l_system_utils import cached_expand_string from lsturtle import Turtle the containing directory must be added to the search path, as is done by running from within the directory. That is ok for now and what I will try. However, if your repository were a package, lsystem, with a blank __init__.py and __main__.py containing from lsystem import main main.main() and main.py contained an expanded version of the current ending def main(): root = tk.Tk() app = Main(root) root.bind("", lambda _: app.render_image()) app.run() if __name__ == "__main__": main() and the module names prefixed wither either 'lsystem/' or './' (for relative imports) and the package were installed in lib/site-packages, it would then run with pythonw -m lsystem (or pyw -3 -m lsystem, I believe) pip (at least by default) installs packages in site-packages. It will also add a file to /scripts though I don't know the setup to do that. ----------------------- Copying the examples directory withing the non-package directory to my home directory with this self.lsf_dir = expanduser(join("~", "lsf-files")) if not isdir(self.lsf_dir): from shutil import copytree from os.path import dirname examples = join(dirname(__file__), "examples") copytree(examples, self.lsf_dir) means that deleting the directory will not remove everything. Not nice. Also unnecessary. Regardless of where you save, read them from the original directory. Actually, the files are so small, that you could instead make them entries in one examples.cfg file, much like Idle does with extensions (for instance) using configparser.ConfigParser. You could then save to a single user.cfg file. Example entry: [dragon curve] iterations= 12 angle= 90 axiom= FX rule1= X:X+YF+ rule2= Y:-FX-Y rule3= rule4= constants= ------- If I hit 'load', the file dialog opens in idlelib. If I hit [cancel], I get an error, probably from trying to open None. Traceback (most recent call last): File "C:\Programs\Python34\lib\tkinter\__init__.py", line 1487, in __call__ return self.func(*args) File "main.pyw", line 248, in load_from_file with open(fname, "r") as f: FileNotFoundError: [Errno 2] No such file or directory: '' -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 18 19:23:09 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 19:23:09 -0400 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On 7/18/2014 2:56 PM, Chris ?Kwpolska? Warrick wrote: > It?s also slightly easier to find pre-made binaries for 32-bit than > 64-bit. Searching 'python windows binaries' on Google and the first hit is http://www.lfd.uci.edu/~gohlke/pythonlibs/ "This page provides 32- and 64-bit Windows binaries of many scientific open-source extension packages for the official CPython distribution of the Python programming language." He or they are currently compiling both 32 and 64 bits binaries for 2.7, 3.3, and 3.4. -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 18 19:26:04 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 19:26:04 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <99b7b2a2-7521-42d7-a5a0-1a35d4d5b922@googlegroups.com> <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/17/2014 8:26 PM, Mark Lawrence wrote: > On 18/07/2014 01:13, Terry Reedy wrote: >> On 7/17/2014 2:15 PM, Rick Johnson wrote: >> a partial disinformation rant again Idle >> that repeats things said before, more than once. >> >> Still more facts ;-). About three (four?) years ago, you posted a >> similar rant. Being wise, I encouraged your participation and utilized >> the patch you anonymously posted on the tracker (to maintain your >> Ranting Rick pose) in one of my first commits. I invite you to resume >> your participation, either anonymously or openly. As before, you can >> email me privately to discuss what would best suite you and also be >> helpful. >> > > I'm looking forward to see the massive number of fixes that come from > rr, assuming of course that he signs the CLA to make this possible. Or > has he already done so? I don't remember the alias to check. -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 18 19:45:21 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 19:45:21 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <87ha2f25bv.fsf@elektro.pacujo.net> Message-ID: On 7/17/2014 10:39 PM, Chris Angelico wrote: > IDLE (or Idle; Terry > seems to spell it the latter way, I'm not sure what's the official > recommendation now), You found me out ;-). FORTRAN is now Fortran, and I hate typing IDLE, and that spelling somehow strikes me as pretentious, so I decided to un-officially promote Idle by typing it this way. -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 18 21:21:36 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 21:21:36 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/17/2014 11:37 PM, Rick Johnson wrote: > On Thursday, July 17, 2014 9:15:15 PM UTC-5, Chris Angelico wrote: >> For myself, though, I completely do not use the editor half of [IDLE]; but >> it's spectacularly useful (with limitations) as my primary interactive >> interpreter. > > Yes Chris, i also think that the IDLE shell is "spectacular" > when i'm using it, especially when i press > "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* > the start of the interactive command marker " >>>", What ancient version, or oddball system are you using? For me, Win 7, both 2.7.8 and 3.4.1 >>> abc "CONTROL+LEFT_ARROW" and the cursor is before the 'a'. The HOME key goes to the same place first, and they before >>> on the second press (and before 'a' on the third). > an > area where key presses are not allowed, so *NOW* I must press > "CONTROL+RIGHT_ARROW" three times to get to my destination! If see different behavior with *current* Python+Idle, please give details. Let's try to find out why and fix it. Check .idlerc/config-keys.cfg in your home directory. > I'm also just "gushing with exuberance" when i open a new > block and i get *EIGHT SPACE INDENTION*! http://bugs.python.org/issue7676 "IDLE shell shouldn't use TABs" is a high-priority for me. The problem is agreeing on an *exact* specification for new behavior, that takes into account both the limitations and flexibility of tk. Maybe I should start a thread here or python-ideas, where people are willing to discuss details. > IDLE hangs between run > sessions when i'm editing Tkinter code I cannot connect this description to behavior I have seen. >> [...] The only problem I have with it is that blatting >> ridiculous amounts of text to the console can take a very >> long time, esp on Windows. If I accidentally display a >> large object when I thought I was displaying a small one, >> it'll hang for quite a while, churning through something, >> and it's not easy to see why or to halt it. But I suspect >> that's more of a Windows and/or Tk issue than an Idle one. ^C 'should' stop output 'eventually'. Sometimes does, sometimes not. > The *PROBLEM* is that user has no method of "undo-ing" an > accidental display of huge amounts of data , forcing the > user to close and then re-open the entire software I believe there is a proposal to be able to clear the shell window. We just need to add "Clear and restart shell". There is also an idea to put help output in an output window. Undo-ing the result of hitting seems like a sensible extension of undoing the result of hitting a key in the editor. I opened "Idle: better management of Shell window output" http://bugs.python.org/issue22010 for all three ideas, and gave you credit for part of the undo idea. > UNCHANGED FOR YEARS!!! So sign the contributor agreement and volunteer to write and review patches. -- Terry Jan Reedy From tjreedy at udel.edu Fri Jul 18 21:27:47 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Fri, 18 Jul 2014 21:27:47 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: On 7/18/2014 11:50 AM, Mark Lawrence wrote: > On 18/07/2014 09:27, Chris Angelico wrote: >> On Fri, Jul 18, 2014 at 6:21 PM, Ian Kelly wrote: >>>> Yes Chris, i also think that the IDLE shell is "spectacular" >>>> when i'm using it, especially when i press >>>> "CONTROL+LEFT_ARROW" and the insertion cursor lands *BEHIND* >>>> the start of the interactive command marker " >>>", an >>>> area where key presses are not allowed, so *NOW* I must press >>>> "CONTROL+RIGHT_ARROW" three times to get to my destination! >>> >>> I just tried to reproduce this using IDLE 3.4 on Windows and was not >>> able to. >> >> Actually, now you mention it, I do recall experiencing a bug like this >> in previous versions. It's not the case in either my 2.7 (point >> something, but I don't remember what) nor 3.4, so I'm guessing it's >> been fixed. I know there was an issue and fix for in the shell. I suspect Control+LeftArrow was looked at and fixed at the same time, if not before. > Fixed by whom, Terry Reedy & Co or rr? Other people. -- Terry Jan Reedy From swdunning at me.com Fri Jul 18 21:21:52 2014 From: swdunning at me.com (Scott Dunning) Date: Fri, 18 Jul 2014 18:21:52 -0700 Subject: Java Message-ID: <1F978F2A-4C67-4ACD-8ADE-8587E00A73AD@me.com> Hello everyone, I hope this question does not piss anyone off seeing as how it has nothing to do with Python?.But I was wondering if anyone knew of a good mailinglist for Java? I love this mailinglist for Python but have been unsuccessfull in finding one for Java. Any suggestions would be greatly appreciated. Thanks, Scott From shieldfire at gmail.com Sat Jul 19 01:28:27 2014 From: shieldfire at gmail.com (Martin S) Date: Sat, 19 Jul 2014 07:28:27 +0200 Subject: OT: usenet reader software In-Reply-To: References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> Message-ID: <093d2303-9e7d-497e-bb85-b9f16d5d61af@gmail.com> Is there a point to still use Usenet? Last time I checked noise overwhelmed signal by a factor of something close to 542. (Just curiou) /martin s On 18 Jul 2014, memilanuk wrote: >On 07/18/2014 02:45 PM, Sturla Molden wrote: >> memilanuk wrote: >> >>> Used leafnode way back when... correct me if I'm wrong, but if >memory >>> serves its a small news spool /server, not really a client/reader >type >>> application. Used to be popular back before slrnpull came about. >> >> Leafnode is an NNTP proxy server. It allows you to filter messages on >> headers, etc. Just run Leafnode and tell Thunderbird to use localhost >as >> NNTP server. Whomever you plonk with Leafnode's killfilter will never >be >> seen in Thunderbird. >> > >Ah... I see. Guess I never explored that facet of leafnode's >functionality. > >Thanks, > >Monte -- Sent with K-@ Mail - the evolution of emailing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benfinney.id.au Sat Jul 19 01:45:58 2014 From: ben at benfinney.id.au (Ben Finney) Date: Sat, 19 Jul 2014 15:45:58 +1000 Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <093d2303-9e7d-497e-bb85-b9f16d5d61af@gmail.com> Message-ID: <85bnslrje1.fsf@benfinney.id.au> Martin S writes: > Is there a point to still use Usenet? Last time I checked noise > overwhelmed signal by a factor of something close to 542. My experience is quite the opposite; Usenet discussions are far easier to filter for useful content than e.g. Google Groups. So that's a major reason for continuing to discuss on Usenet. -- \ ?Of all classes the rich are the most noticed and the least | `\ studied.? ?John Kenneth Galbraith, _The Age of Uncertainty_, | _o__) 1977 | Ben Finney From marko at pacujo.net Sat Jul 19 02:10:32 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 19 Jul 2014 09:10:32 +0300 Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> Message-ID: <87tx6dyj3b.fsf@elektro.pacujo.net> Martin S : > Is there a point to still use Usenet? Last time I checked noise > overwhelmed signal by a factor of something close to 542. Well, here you are at , in the middle of all that noise. Marko From rosuav at gmail.com Sat Jul 19 02:20:40 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 16:20:40 +1000 Subject: OT: usenet reader software In-Reply-To: <87tx6dyj3b.fsf@elektro.pacujo.net> References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> Message-ID: On Sat, Jul 19, 2014 at 4:10 PM, Marko Rauhamaa wrote: > Martin S : > >> Is there a point to still use Usenet? Last time I checked noise >> overwhelmed signal by a factor of something close to 542. > > Well, here you are at , in the middle of all > that noise. Or at python-list at python.org - a lot of the newsgroup spam simply doesn't make it across the bridge. ChrisA From marko at pacujo.net Sat Jul 19 02:51:07 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 19 Jul 2014 09:51:07 +0300 Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> Message-ID: <87pph1yh7o.fsf@elektro.pacujo.net> Chris Angelico : > On Sat, Jul 19, 2014 at 4:10 PM, Marko Rauhamaa wrote: >> Martin S : >> >>> Is there a point to still use Usenet? Last time I checked noise >>> overwhelmed signal by a factor of something close to 542. >> >> Well, here you are at , in the middle of >> all that noise. > > Or at python-list at python.org - a lot of the newsgroup spam simply > doesn't make it across the bridge. Spam? What spam? There's a lot of hot air but I have yet to encounter spam. Marko From rosuav at gmail.com Sat Jul 19 03:02:17 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 17:02:17 +1000 Subject: OT: usenet reader software In-Reply-To: <87pph1yh7o.fsf@elektro.pacujo.net> References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> <87pph1yh7o.fsf@elektro.pacujo.net> Message-ID: On Sat, Jul 19, 2014 at 4:51 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Sat, Jul 19, 2014 at 4:10 PM, Marko Rauhamaa wrote: >>> Martin S : >>> >>>> Is there a point to still use Usenet? Last time I checked noise >>>> overwhelmed signal by a factor of something close to 542. >>> >>> Well, here you are at , in the middle of >>> all that noise. >> >> Or at python-list at python.org - a lot of the newsgroup spam simply >> doesn't make it across the bridge. > > Spam? What spam? > > There's a lot of hot air but I have yet to encounter spam. That means you have good filtering. There are several levels of spam filtering happening. Fortunately, they do a pretty good job of catching most of it; I occasionally see junk mail on the list, but most of it gets caught and discarded. ChrisA From steve+comp.lang.python at pearwood.info Sat Jul 19 03:28:40 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 19 Jul 2014 07:28:40 GMT Subject: Python and IDEs [was Re: Python 3 is killing Python] References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> Message-ID: <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Earlier, I mentioned a considerable number of IDEs which are available for Python, including: PyDev, Eric, Komodo, PyCharm, WingIDE, SPE, Ninja-IDE, Geany, IEP, Spyder, Boa Constructor, PyScripter, NetBeans, Emacs, KDevelop, and BlackAdder. https://wiki.python.org/moin/IntegratedDevelopmentEnvironments There is also IDLE, which is part of the standard Python installation, as well as my preference: Unix/Linux as an IDE. http://blog.sanctum.geek.nz/series/unix-as-ide/ http://michaelochurch.wordpress.com/2013/01/09/ide-culture-vs-unix-philosophy/ Some people ask: "How many of those quality IDEs ship with Python?" Most don't, of course, since they are third-party tools. Not that it matters: it's 2014, not 1974, and anyone in the developed world interested in computer programming has easy access to the information superhighway sometimes know as "the Internet". (Many people in developing nations also have access to the Internet, and those who don't probably have bigger problems to worry about.) With the Internet, most of these IDEs are normally just a few clicks away. People using Linux will generally find that they can install some of these IDEs using their package manager. For example, Red Hat Linux based systems such on Centos or Fedora can use the yum package manager, e.g.: yum install geany geany-plugins while Debian and Ubuntu based systems (such as Mint) can use apt-get or aptitude, e.g.: aptitude install eric apt-get install spe Of course, most Linux distros include a GUI front-end to their package manager, but frankly if you're programming on Linux and you're unwilling to use the command line, you're making life harder for yourself than it need be. Windows and OS X users, sadly, miss out on the power of an integrated package manager. OS X have a couple of third-party packaging systems, MacPorts and Homebrew: http://www.macports.org/ http://brew.sh/ Unfortunately, software development on Windows is something of a ghetto, compared to the wide range of free tools available for Linux. Outside of a few oases like Microsoft's own commercial development tools, it's hard to do development on Windows. Hard, but not impossible, of course, and there are quite a few resources available for the Windows user willing to download installers from the Internet. For Python users, the IDEs from Wingware and Activestate are notable: https://wingware.com/ http://komodoide.com/ Some people are under the impression that IDEs are mostly or even solely for the benefit of "newbies" or "n00bs". That's a gross misunderstanding of the situation: the average newbie is likely to be happy writing code using Notepad, or whatever bare-bones text editor they're used to, and may not even know what an IDE is. It's those with some experience in programming (particularly in the Java and Visual Basic worlds) who are more likely to expect an IDE. Another patronising view is that those who are new to programming are automatically too incompetent or ignorant to download or install an IDE without hand-holding. Even if that were the case, there is no shortage of hand-holding available on the Internet, with dozens or hundreds of forums, mailing lists, tutorial, videos and blogs offering to help. (It is undeniable that the quality of these is *extremely* variable, but that's another story.) This is the Internet generation, if software has a downloadable installer, or can be installed using a package manager, most people can deal with it, and those who can't have many opportunities to learn. (It's probably a bit much to expect the average newbie to install software from source, especially on Windows which doesn't come with much in the way of compilers and other development tools, but still, it has to be said that if you're hoping to become a programmer, installing software from source is one of the skills you should learn.) So why does Python ship with IDLE? It's not because Python requires an IDE, or that newbies need one, or that there aren't alternatives. The biggest reason for Python shipping with an IDE is not that people are unable to install alternatives, but that a lot of people are *prohibited* from doing so. For those of us who have control over our computing environment, it's all too easy to forget that a lot of people (e.g. students using school computers, or people in corporate environments where the desktops are locked down to a standard operating environment) aren't able to install the IDE of their choice. It's relatively easy to get Python itself approved -- on many systems, Python comes pre-installed -- but trying to get approval to also install third-party software is difficult or impossible. It is for the sake of those people, people who prefer or require an IDE but don't have the choice to install third-party software, that Python ships with a minimal but usable IDE. -- Steven From marko at pacujo.net Sat Jul 19 03:32:23 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 19 Jul 2014 10:32:23 +0300 Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> <87pph1yh7o.fsf@elektro.pacujo.net> Message-ID: <87fvhxyfaw.fsf@elektro.pacujo.net> Chris Angelico : > On Sat, Jul 19, 2014 at 4:51 PM, Marko Rauhamaa wrote: >> There's a lot of hot air but I have yet to encounter spam. > > That means you have good filtering. Interesting. Who's filtering comp.lang.python? Marko From rosuav at gmail.com Sat Jul 19 03:40:53 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 17:40:53 +1000 Subject: OT: usenet reader software In-Reply-To: <87fvhxyfaw.fsf@elektro.pacujo.net> References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> <87pph1yh7o.fsf@elektro.pacujo.net> <87fvhxyfaw.fsf@elektro.pacujo.net> Message-ID: On Sat, Jul 19, 2014 at 5:32 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> On Sat, Jul 19, 2014 at 4:51 PM, Marko Rauhamaa wrote: >>> There's a lot of hot air but I have yet to encounter spam. >> >> That means you have good filtering. > > Interesting. Who's filtering comp.lang.python? Possibly your provider, possibly your client, hard to say. But I'm pretty confident you do NOT see all the spam that goes through, because it's definitely there. ChrisA From yasar11732 at gmail.com Sat Jul 19 03:19:54 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Sat, 19 Jul 2014 10:19:54 +0300 Subject: Pip doesn't install my scripts Message-ID: Hi, I am trying to package my file, but I am having problems with installing my Scripts. Here is my package: https://github.com/yasar11732/tklsystem Here is my package's PyPi page: https://pypi.python.org/pypi/TkLsystem The problem I face is that, when I run `python setup.py install` from my development directory, I see that script file is installed. However, if I run `pip install TkLsystem`, my script file is not copied to Scripts directory. What am I doing wrong here? -- http://ysar.net/ From marko at pacujo.net Sat Jul 19 03:54:35 2014 From: marko at pacujo.net (Marko Rauhamaa) Date: Sat, 19 Jul 2014 10:54:35 +0300 Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <87tx6dyj3b.fsf@elektro.pacujo.net> <87pph1yh7o.fsf@elektro.pacujo.net> <87fvhxyfaw.fsf@elektro.pacujo.net> Message-ID: <87bnslye9w.fsf@elektro.pacujo.net> Chris Angelico : > On Sat, Jul 19, 2014 at 5:32 PM, Marko Rauhamaa wrote: >> Interesting. Who's filtering comp.lang.python? > > Possibly your provider, possibly your client, hard to say. But I'm > pretty confident you do NOT see all the spam that goes through, > because it's definitely there. Well, anyway, spam is not a reason to avoid comp.lang.python. Marko From swdunning at me.com Sat Jul 19 03:17:33 2014 From: swdunning at me.com (Scott Dunning) Date: Sat, 19 Jul 2014 00:17:33 -0700 Subject: Java In-Reply-To: References: <1F978F2A-4C67-4ACD-8ADE-8587E00A73AD@me.com> Message-ID: <01D3795B-EF2B-478E-9E5B-0033142B818B@me.com> On Jul 18, 2014, at 8:19 PM, Dan Stromberg wrote: > There's comp.lang.java if you have an NNTP feed. > > There are also the OpenJDK mailing lists. > > I had a Java problem once - I'd decided to recode one of my Python > scripts into Java, just to demonstrate to myself that I could do it. > I asked about the problem on comp.lang.java, and I got a handful of > irrelevant responses. Posting to an OpenJDK list got me a solution > pretty quickly though. > > The OpenJDK lists are a bit more focused on specific areas of OpenJDK > than comp.lang.python is; you could end up subscribing to several of > them to get the same effect. Thanks Dan! I checked out the OpenJDK mailing lists they?re a little confusing but I?m sure I can find something. Thanks for the suggestions! From kwpolska at gmail.com Sat Jul 19 05:24:08 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Sat, 19 Jul 2014 11:24:08 +0200 Subject: Python 3.4.1 64 bit Version In-Reply-To: References: Message-ID: On Sat, Jul 19, 2014 at 1:23 AM, Terry Reedy wrote: > On 7/18/2014 2:56 PM, Chris ?Kwpolska? Warrick wrote: > >> It?s also slightly easier to find pre-made binaries for 32-bit than >> 64-bit. > > > Searching 'python windows binaries' on Google and the first hit is > http://www.lfd.uci.edu/~gohlke/pythonlibs/ > "This page provides 32- and 64-bit Windows binaries of many scientific > open-source extension packages for the official CPython distribution of the > Python programming language." > > He or they are currently compiling both 32 and 64 bits binaries for 2.7, > 3.3, and 3.4. I know that site, but its binaries are not used by `pip` while wheels published on PyPI are ? and those wheels are not always available for 64-bit. -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From kwpolska at gmail.com Sat Jul 19 05:44:19 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Sat, 19 Jul 2014 11:44:19 +0200 Subject: Pip doesn't install my scripts In-Reply-To: References: Message-ID: On Sat, Jul 19, 2014 at 9:19 AM, Ya?ar Arabac? wrote: > Hi, > > I am trying to package my file, but I am having problems with > installing my Scripts. Here is my package: > https://github.com/yasar11732/tklsystem > > Here is my package's PyPi page: https://pypi.python.org/pypi/TkLsystem > > The problem I face is that, when I run `python setup.py install` from > my development directory, I see that script file is installed. > However, if I run `pip install TkLsystem`, my script file is not > copied to Scripts directory. > > What am I doing wrong here? > > -- > http://ysar.net/ > -- > https://mail.python.org/mailman/listinfo/python-list Tons of things are wrong. * SyntaxError: Non-ASCII character '\xc5' in file lsystem/__init__.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details * you should not import your package in setup.py * you are python 3-only for no real reason at all * the zip on PyPI is for version 0.1.3. It ignores the version 0.1-5, because of the dash, which should not be used in names of stable software * and, most importantly, you?re doing things using ancient methods. Upgrade your setup.py to use setuptools, and its entry points mechanism. I?ve sent a PR to fix all of your errors: https://github.com/yasar11732/tklsystem/pull/1 -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From cl at isbd.net Sat Jul 19 05:40:51 2014 From: cl at isbd.net (cl at isbd.net) Date: Sat, 19 Jul 2014 10:40:51 +0100 Subject: OT: usenet reader software References: Message-ID: <32rp9b-nsu.ln1@chris.zbmc.eu> memilanuk wrote: > > Guess where I'm going with this is... is there anything out there worth > trying - on Linux - that I'm missing? > If slrn was a maybe then there's also tin for text mode news readers, it's what I have always used. I don't know what it does with HTML as none of the groups I frequent ever have any HTML in them. It does add one 'GUIness' to its text mode, it's mouse aware so you can click on messages in a list to open them. -- Chris Green ? From cl at isbd.net Sat Jul 19 05:41:47 2014 From: cl at isbd.net (cl at isbd.net) Date: Sat, 19 Jul 2014 10:41:47 +0100 Subject: OT: usenet reader software References: Message-ID: Sturla Molden wrote: > > Guess where I'm going with this is... is there anything out there worth > > trying - on Linux - that I'm missing? > > leafnode > That doesn't address the problem at all! :-) You still need a news reader. -- Chris Green ? From bv8bv8bv8 at gmail.com Sat Jul 19 05:49:12 2014 From: bv8bv8bv8 at gmail.com (BV BV) Date: Sat, 19 Jul 2014 02:49:12 -0700 (PDT) Subject: MISCONCEPTIONS ABOUT ISLAM Message-ID: MISCONCEPTIONS ABOUT ISLAM What do you REALLY know? Islam is one of the world's largest religions yet it is also one of the most misunderstood. For various reasons - be they political, economic, biased media or fear of the "other" - mistruths and misconceptions have been spread about Islam. The key to understanding Islam and Muslims is to resist stereotypes and examine each situation according to Islamic teachings and authentic sources. Misconception 1 - "Muslims Do Not Share Good and Noble Values with non-Muslims" "The best among you are those who have the best manners and character." - Prophet Muhammad (peace be upon him) Some people allege that Islamic values are somehow incompatible with decent "Western" values. Such claims could not be further from the truth. Muslims cherish noble and universal values such as: ? being honest and just ? keeping one's word ? allowing freedom of religion ? respecting parents, relatives, neighbours, and the elderly ? being charitable, generous, and looking after the poor and needy ? not lying, cheating, swearing or backbiting anyone Muslims are required to contribute positively towards society and to always conduct themselves with the highest of morals and best of actions. Misconception 2 - "Muslims Worship a New God Called Allah" Muslims worship the same God worshipped by Prophets Noah, Abraham, Moses and Jesus. The word "Allah" is simply the Arabic word for Almighty God - an Arabic word of rich meaning, denoting the one and only God. Allah is also the same word that Arabic speaking Christians and Jews use to refer to God. However, although Muslims, Jews and Christians believe in the same God (the Creator), their concepts regarding Him differ significantly. For example, Muslims reject the idea of God having any partners or being part of a 'trinity', and ascribe perfection only to God, the Almighty. Misconception 3 - "Islam Permits Terrorism" The media generally portrays any Muslim who fights as a terrorist, regardless of whether they fight justly or unjustly, or whether they are oppressing others or being oppressed. In war, the targeting of innocent non-combatants is a despicable act which Islam clearly prohibits. In fact, Muslims are not allowed to destroy plants and animals unnecessarily, let alone innocent humans. However, it is important to distinguish between terrorism and legitimate resistance to occupation, as the two are very different. The Quran clearly demonstrates the seriousness of killing an innocent person, and emphasises the value of human life. "If anyone murders an innocent person, it will be as if he has murdered the whole of humanity. And if anyone saves a person it will be as if he has saved the whole of humanity."Quran 5:32 Misconception 4 - "Islam Oppresses Women" In Islam, men and women are viewed as equals before God, in terms of both receiving equal reward and accountability for their actions. The only thing that distinguishes people in the sight of God is their level of piety. "Verily the most honourable of you in the sight of Allah is the most God conscious."Quran 49:13 This verse proves that real honour and status is not attained because a person is rich or poor, black or white, male or female, but attained through piety and devoutness. Allah, the Creator of both genders, has assigned different roles and responsibilities for each, taking into account their differences. Women are given the utmost respect and honour, such as the right to equal pay, choice of spouse, pursuit of education, and the right to divorce and inheritance. Unfortunately, there are some Muslim women who are oppressed and not given their rights. This is not the fault of Islam. The problem is that in some countries, people follow certain cultural practices and traditions which have nothing to do with Islam. Misconception 5 - "The Quran is Just another History or Poetry Book" The Quran is the divine literal word of God Almighty, revealed to Prophet Muhammad (peace be upon him), through the angel Gabriel. It is a criterion for the truth, containing guidance for humanity to live by. The Quran cites lessons from preceding generations and the history of the Prophets in order that we may learn from their experiences. It further teaches us about ourselves and our Creator, as well as the purpose of our existence which is to acknowledge God, worshipping Him alone. God did not create humans to simply wander aimlessly. The test of one's faith is in using one's intellect, free will and reasoning abilities to contemplate and recognise God's signs - one of the greatest signs being The Quran. The Quran contains within it many miracles, so that we can have no doubt about its authenticity. The best way to discover what the Quran is actually about, is to read it for yourself. Misconception 6 - "Hijab is Oppressive" To observe the hijab, Muslim women are required to modestly cover their body with clothes that do not reveal their figure in front of non-closely related males. However, hijab is not just about outer appearances; it is also about noble speech, modesty, and dignified conduct. Although there are many benefits of the hijab, the key reason Muslim women observe hijab is because it is a command from Allah (God), and He knows what is best for His creation. The hijab empowers a woman by emphasising her inner spiritual beauty, rather than her superficial appearance. It gives women the freedom to be active members of society, while maintaining their modesty. The hijab does not symbolize suppression, oppression or silence. Rather, it is a guard against degrading remarks, unwanted advances and unfair discrimination. So the next time you see a Muslim woman, know that she covers her physical appearance, not her mind or intellect. Misconception 7 - "All Muslims are Arabs" Only about 20% of Muslims in the world are Arabs, meaning that up to about 80% of Muslims are non-Arabs. For example, there are more Indian and Indonesian Muslims than Arab Muslims. Islam teaches that an individual is not superior to another because of race or colour, and is strictly against any form of racism. Islam has a universal message for all of mankind - that is, that everyone can gain peace and success only by acknowledging and worshipping the One True God. Misconception 8 - "Jihad is Terrorism" The essence of Jihad is to struggle and sacrifice for one's religion in a manner which is pleasing to God. Linguistically, it means to "struggle" and can refer to one's striving to do good deeds, give charity, or to join an Islamic military action. The most commonly known form is the military Jihad which is permitted in order to preserve the well being of society, to prevent oppression from spreading, and to promote justice. This can be either defensive or offensive, depending on the circumstance. Misconception 9 - "Muslims Worship Muhammad or the Moon God" Yet another misconception is that Muslims worship Prophet Muhammad (peace be upon him). This is entirely untrue, and is easily refuted by the actual saying of the Prophet (peace be upon him): "Do not over-praise me as the Christians over-praised Jesus, the son of Mary. I am His slave, so refer to me as 'God's slave and Messenger.' " Islam teaches Muslims to respect all of God's Prophets and Messengers - but respecting and loving them does not mean worshipping them. A related claim is that Muslims worship the "moon God" which is also totally incorrect. Worshipping the moon, or anything other than Allah, is strictly prohibited in Islam: "Do not prostrate to the sun or to the moon, but prostrate to Allah Who created them, if you really worship Him."Quran 41:37 Islam acknowledges the complete perfection, greatness and uniqueness of God with absolutely no compromises. He is the Most Just and the Most Merciful. Worshipping Him alone is the most important belief in Islam, as mentioned in the Quran in numerous places. Misconception 10 - "Islam Permits Forced Marriages" Arranged marriages are cultural practices which are predominant in certain countries throughout the world. Although not restricted to Muslims, forced marriages have become incorrectly associated with Islam. In Islam, both males and females have the right to choose or reject their potential spouse, and a marriage is considered null and void if a woman's genuine approval is not granted prior to the marriage. Misconception 11 - "Islam Forces People to Become Muslim" God says, "Let there be no compulsion in religion. Truth has been made clear from error."Quran 2:256 Although it is a duty on Muslims to convey and share the beautiful message of Islam to others, no one can be compelled to accept Islam. To accept Islam, a person must sincerely and voluntarily believe and obey God, so, by definition, no one can (or should) be forced to accept Islam. Consider the following: ? Indonesia has the largest Muslim population yet no battles were fought to bring Islam there. ? There are around 14 million Arab Coptic Christians that have been living in the heart of Arabia for generations. ? Islam is one of the fastest growing religions in the western world today. ? Although fighting oppression and promoting justice are valid reasons for waging jihad, forcing people to accept Islam is not one of them. ? Muslims ruled Spain for around 800 years yet never coerced people to convert. Conclusion Learning about Islam from unqualified sources without verification is dangerous and leads to misunderstandings. Do not be misled into accepting misconceptions and false information about Islam - the belief shared by more than a quarter of mankind. Does not the guidance for all humanity, the message of Islam, deserve to be carefully pondered over and reflected on? http://islamicpamphlets.com/misconceptions-about-islam/ Thank you From nicholascannon1 at gmail.com Sat Jul 19 06:52:18 2014 From: nicholascannon1 at gmail.com (Jerry lu) Date: Sat, 19 Jul 2014 03:52:18 -0700 (PDT) Subject: Confused with Functions and decorators Message-ID: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another function. eg def outer(): def inner(): x = 5 return inner why not just use inner and forget about the whole outer function? 2. This is more yes or no question when you pass in a func into another func as a parameter do you need to specify the parameter that the func is being passed into as func? eg def passinto(func) pass def param(): x = 5 p = passinto(param) also is this above statement correct????? From rosuav at gmail.com Sat Jul 19 07:03:55 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 21:03:55 +1000 Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: On Sat, Jul 19, 2014 at 8:52 PM, Jerry lu wrote: > Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. > > 1. I dont understand when i will need to use a function that returns another function. > eg > def outer(): > def inner(): > x = 5 > return inner > > why not just use inner and forget about the whole outer function? > > 2. This is more yes or no question when you pass in a func into another func as a parameter do you need to specify the parameter that the func is being passed into as func? > eg > def passinto(func) > pass > > def param(): > x = 5 > > p = passinto(param) > > also is this above statement correct????? In Python, a function is a real thing, on par with integers, lists, modules, files, etc. You can create them, dispose of them, pass them as parameters, receive them as return values, store them in lists, everything. When you call outer(), it creates a function (which does nothing useful, and then returns None) and returns a reference to it. And yes, in that case, there's no particular value in that setup; but an inner function can be a "closure" (you can look that up later): def outer(x): def inner(y): return x + y return inner The x inside inner() will refer to the x that was in scope when it was created, so you can call outer() several times with different arguments and get back different functions that do different things. Since functions are objects of equal standing to any other (called "first-class" objects - look that up too), you can pass them as parameters just the same as you would any other type of object. There's no reason to call an integer 'i', so there's no reason to call a function 'func'. You can if you like, but it'll work the same regardless. There is no magic happening here. None of this has anything to do with decorators, though. ChrisA From nicholascannon1 at gmail.com Sat Jul 19 07:40:19 2014 From: nicholascannon1 at gmail.com (Jerry lu) Date: Sat, 19 Jul 2014 04:40:19 -0700 (PDT) Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? and also with the first example you say x is in the scope when is was created can you define x in the outer func and refer to it in the inner func? From rosuav at gmail.com Sat Jul 19 07:50:42 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sat, 19 Jul 2014 21:50:42 +1000 Subject: Confused with Functions and decorators In-Reply-To: References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: On Sat, Jul 19, 2014 at 9:40 PM, Jerry lu wrote: > oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? > > and also with the first example you say x is in the scope when is was created can you define x in the outer func and refer to it in the inner func? Firstly, please don't use Google Groups, or if you must, please clean up its messes. It's conventional on mailing lists and newsgroups to quote a bit of text to give context; so, for instance, you mention one of my examples, without quoting it. Secondly: Don't worry about decorators. You almost never need them, and they're very simple. (Python avoids magic whenever it can!) These two are equivalent: def inner(): pass inner = outer(inner) @outer def inner(): pass That's all the decorator does. It's that simple. As to scoping... read up on closures. There's a lot that I could say, but you'll find some excellent articles on the internet about it. Also, you'll learn how to find information, which is a skill you are going to need in this life :) ChrisA From nkshirsagar at gmail.com Sat Jul 19 07:58:46 2014 From: nkshirsagar at gmail.com (nkshirsagar at gmail.com) Date: Sat, 19 Jul 2014 04:58:46 -0700 (PDT) Subject: Python-2.6.1 ctypes test cases failing In-Reply-To: References: Message-ID: libffi fails on cavium for python 2.7 ctypes still doesnt build :(O On Wednesday, 7 March 2012 11:25:59 UTC-8, Terry Reedy wrote: > On 3/7/2012 12:43 PM, Naresh Bhat wrote: > > > Hi All, > > > > > > I have the following setup > > > > > > Kernel version: linux-2.6.32.41 > > > Python Version: Python-2.6.1 > > > Hardware target: MIPS 64bit > > > > > > I am just trying to run python test cases, Observed that on my MIPS > > > 64bit system only _ctypes related test cases are failing. > > > > > > Is there any available patch for this issue ?? > > > > There have been patches to ctypes since 2.6.1. At minimum, you should be > > using the latest version of 2.6. Even better, perhaps, would be the > > latest version of 2.7, since it contain patches applied after 2.6 went > > to security fixes only. > > > > -- > > Terry Jan Reedy From nicholascannon1 at gmail.com Sat Jul 19 08:01:25 2014 From: nicholascannon1 at gmail.com (Jerry lu) Date: Sat, 19 Jul 2014 05:01:25 -0700 (PDT) Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <9f07f9b5-df7e-467f-8db1-f9fa294dc922@googlegroups.com> Ok thanks man I have never used forums and stuff before but it is great help thank you so much. From yasar11732 at gmail.com Sat Jul 19 07:39:19 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Sat, 19 Jul 2014 14:39:19 +0300 Subject: Pip doesn't install my scripts In-Reply-To: References: Message-ID: Hi Chris, Thanks a lot for your fixes. I have merged your PR and updated PyPi package. I have one more question; is it documented somewhere that one shouldn't use dash for stable version names? I am not professional in programming and I thought for some reason that release numbers should be separated with dashes. 2014-07-19 12:44 GMT+03:00 Chris ?Kwpolska? Warrick : > On Sat, Jul 19, 2014 at 9:19 AM, Ya?ar Arabac? wrote: >> Hi, >> >> I am trying to package my file, but I am having problems with >> installing my Scripts. Here is my package: >> https://github.com/yasar11732/tklsystem >> >> Here is my package's PyPi page: https://pypi.python.org/pypi/TkLsystem >> >> The problem I face is that, when I run `python setup.py install` from >> my development directory, I see that script file is installed. >> However, if I run `pip install TkLsystem`, my script file is not >> copied to Scripts directory. >> >> What am I doing wrong here? >> >> -- >> http://ysar.net/ >> -- >> https://mail.python.org/mailman/listinfo/python-list > > Tons of things are wrong. > > * SyntaxError: Non-ASCII character '\xc5' in file lsystem/__init__.py > on line 6, but no encoding declared; see > http://python.org/dev/peps/pep-0263/ for details > * you should not import your package in setup.py > * you are python 3-only for no real reason at all > * the zip on PyPI is for version 0.1.3. It ignores the version 0.1-5, > because of the dash, which should not be used in names of stable > software > * and, most importantly, you?re doing things using ancient methods. > Upgrade your setup.py to use setuptools, and its entry points > mechanism. > > I?ve sent a PR to fix all of your errors: > https://github.com/yasar11732/tklsystem/pull/1 > > -- > Chris ?Kwpolska? Warrick > PGP: 5EAAEA16 > stop html mail | always bottom-post | only UTF-8 makes sense -- http://ysar.net/ From wojtekgiel at gmail.com Sat Jul 19 08:06:19 2014 From: wojtekgiel at gmail.com (Wojciech Giel) Date: Sat, 19 Jul 2014 13:06:19 +0100 Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <53CA5F3B.1030900@gmail.com> On 19/07/14 11:52, Jerry lu wrote: > Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. > > 1. I dont understand when i will need to use a function that returns another function. > eg > def outer(): > def inner(): > x = 5 > return inner > > why not just use inner and forget about the whole outer function? function compositing is one possible use. Functions are first class objects so they can be passed as arguments to other functions. in math you can define function composition f(x) * g(x) by saying that (f * g )(x) = f(g(x)). so composition of two functions gives you a new function with behaviour the same as applying fist function to the output of the second. ex. you are give two functions f and g to construct their composition: >>> def outer(f, g): ... def inner(x): ... return f(g(x)) ... return inner ... >>> def f(x): ... print("f ({}) called".format(x)) ... return x ... >>> def g(x): ... print("g ({}) called".format(x)) ... return x ... >>> h = outer(f, g) >>> h("test") g (test) called f (test) called 'test' > 2. This is more yes or no question when you pass in a func into another func as a parameter do you need to specify the parameter that the func is being passed into as func? > eg > def passinto(func) > pass > > def param(): > x = 5 > > p = passinto(param) > > also is this above statement correct????? > From wojtekgiel at gmail.com Sat Jul 19 08:10:14 2014 From: wojtekgiel at gmail.com (Wojciech Giel) Date: Sat, 19 Jul 2014 13:10:14 +0100 Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <53CA6026.4000609@gmail.com> On 19/07/14 11:52, Jerry lu wrote: > Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. > > 1. I dont understand when i will need to use a function that returns another function. > eg > def outer(): > def inner(): > x = 5 > return inner > > why not just use inner and forget about the whole outer function? function compositing is one possible use. Functions are first class objects so they can be passed as arguments to other functions. in math you can define function composition f(x) * g(x) by saying that (f * g )(x) = f(g(x)). so composition of two functions gives you a new function with behaviour the same as applying fist function to the output of the second. ex. you are give two functions f and g to construct their composition: >>> def outer(f, g): ... def inner(x): ... return f(g(x)) ... return inner ... >>> def f(x): ... print("f ({}) called".format(x)) ... return x ... >>> def g(x): ... print("g ({}) called".format(x)) ... return x ... >>> h = outer(f, g) >>> h("test") g (test) called f (test) called 'test' cheers Wojciech From wojtekgiel at gmail.com Sat Jul 19 08:44:25 2014 From: wojtekgiel at gmail.com (Wojciech Giel) Date: Sat, 19 Jul 2014 13:44:25 +0100 Subject: Confused with Functions and decorators In-Reply-To: References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <53CA6829.60206@gmail.com> On 19/07/14 12:40, Jerry lu wrote: > oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? yes. syntax was added because with very long function definitions it was dificult to track reassignment to the name when it followed definition of the function. decorators is just abbreviation. >>> def outer(f): ... def inner(*args, **kwargs): ... print("inner function") ... return f(*args, **kwargs) ... return inner ... >>> @outer ... def myfunc(x): ... print("Myfunc", x) ... >>> myfunc("test") inner function Myfunc test it is exactly equivalent to: >>> def outer(f): ... def inner(*args, **kwargs): ... print("inner function") ... return f(*args, **kwargs) ... return inner ... >>> def myfunc(x): ... print("Myfunc", x) ... >>> myfunc = outer(myfunc) >>> myfunc("test") inner function Myfunc test cheers Wojciech > > and also with the first example you say x is in the scope when is was created can you define x in the outer func and refer to it in the inner func? check nonlocal. From yasar11732 at gmail.com Sat Jul 19 10:23:10 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Sat, 19 Jul 2014 17:23:10 +0300 Subject: Creating Windows Start Menu or Desktop shortcuts using setuptools bdist_winst installer Message-ID: This is a cross-post from stackoverflow: http://stackoverflow.com/q/24841130/886669 I am not sure about cross-posting policies of python-list. I am sorry if this is discouraged. Here is my problem; I want to create a start menu or Desktop shortcut for my Python windows installer package. I am trying to follow https://docs.python.org/3.4/distutils/builtdist.html#the-postinstallation-script Here is my script; import sys from os.path import dirname, join, expanduser pyw_executable = sys.executable.replace('python.exe','pythonw.exe') script_file = join(dirname(pyw_executable), 'Scripts', 'tklsystem-script.py') w_dir = expanduser(join('~','lsf_files')) print(sys.argv) if sys.argv[1] == '-install': print('Creating Shortcut') create_shortcut( target=pyw_executable, description='A program to work with L-System Equations', filename='L-System Tool', arguments=script_file, workdir=wdir ) I also specified this script in scripts setup option, as indicated by aforementioned docs. Here is the command I use to create my installer; python setup.py bdist_wininst --install-script tklsystem-post-install.py After I install my package using created windows installer, I can't find where my shorcut is created, nor I can confirm whether my script run or not. How can I make setuptools generated windows installer to create desktop or start menu shortcuts? -- http://ysar.net/ From nulla.epistola at web.de Sat Jul 19 11:44:27 2014 From: nulla.epistola at web.de (Sibylle Koczian) Date: Sat, 19 Jul 2014 17:44:27 +0200 Subject: I am stuck on OOP In-Reply-To: References: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53CA925B.8030600@web.de> Am 18.07.2014 20:45, schrieb Chris ?Kwpolska? Warrick: > Yes, exceptions do exist. But most video tutorials are produced by > people without enough knowledge, and people that should not be working > on educational material. This is especially visible in videos about > basic things: they can be produced by just about anyone with a > microphone ? which never leads to anything good. (In order to be more > precise, I'd have to be politically incorrect.) > Moreover people knowing enough about the subject and being able to explain it really well won't necessarily speak clearly. And spoken English is so far away from the written version anyway that it's simply a pain for everybody with another first language. Much worse than learning Python 3 with a version 2 tutorial or vice versa. Greetings Sibylle From nulla.epistola at web.de Sat Jul 19 11:44:27 2014 From: nulla.epistola at web.de (Sibylle Koczian) Date: Sat, 19 Jul 2014 17:44:27 +0200 Subject: I am stuck on OOP In-Reply-To: References: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53CA925B.8030600@web.de> Am 18.07.2014 20:45, schrieb Chris ?Kwpolska? Warrick: > Yes, exceptions do exist. But most video tutorials are produced by > people without enough knowledge, and people that should not be working > on educational material. This is especially visible in videos about > basic things: they can be produced by just about anyone with a > microphone ? which never leads to anything good. (In order to be more > precise, I'd have to be politically incorrect.) > Moreover people knowing enough about the subject and being able to explain it really well won't necessarily speak clearly. And spoken English is so far away from the written version anyway that it's simply a pain for everybody with another first language. Much worse than learning Python 3 with a version 2 tutorial or vice versa. Greetings Sibylle From rantingrickjohnson at gmail.com Sat Jul 19 12:29:08 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 19 Jul 2014 09:29:08 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> Message-ID: <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> On Friday, July 18, 2014 8:21:36 PM UTC-5, Terry Reedy wrote: > What ancient version, or oddball system are you using? For > me, Win 7, both 2.7.8 and 3.4.1 "CONTROL+LEFT_ARROW" and > the cursor is before the 'a' of [>>> abc]. The HOME key > goes to the same place first, and they before >>> on the > second press (and before 'a' on the third). On versions 2.7.2 and 3.2.2 CONTROL+LEFT_ARROW is landing *properly* in front of the prompt, so apparently that bug was fixed since last i checked, my apologies for being ignorant of the situation, but you should understand that i had given up after years of no improvements. However, a *bare* HOME_KEY press is placing the insertion cursor *BEHIND* the prompt of the current line. In a shell environment, you never want to be *BEHIND* the command prompt. Now, in the case of CONTROL+HOME (which places the insertion cursor at the very *first* position of the entire text buffer) and CONTROL+END (which places the insertion cursor at the very *last* position of the text buffer), we should leave the default behaviors alone. I don't see any benefit of changing them. > "IDLE shell shouldn't use TABs" is a high-priority for me. > The problem is agreeing on an *exact* specification for > new behavior, that takes into account both the limitations > and flexibility of tk. Maybe I should start a thread here > or python-ideas, where people are willing to discuss > details. First, i need to admit that i was wrong when i said: "eight space indention", since the IDLE shell is using *tabs* for indention, not spaces! However, a single tab is just as annoying as 8 spaces Now, even as much as i dislike tabs, i must admit there is a benefit to using tabs over spaces, since tabs require only *ONE* backspace key-press per "pseudo 4 spaces" as compared to spaces which require a 1:1 ratio of key-presses. Of course, even this problem can be abstracted away by "backspace automation code", which the IDLE editor window already employs! But my point is: We *MUST* remove this *excessive* indentation width from the IDLE shell! > I cannot connect [your complaint about IDLE hanging] to > behavior I have seen. IDLE will hang when editing Tkinter code. It seems to happen most often in two cases: 1. When running code that results in a Tkinter error. This can happen when mixing the "grid" and "pack" geometry managers within the same "container" widget, which is a Tkinter NO-NO, but it can also happen during other Tkinter errors! 2. During "quickly successive" back-to-back "run sessions" of Tkinter GUI apps. It seems that sometimes, if you don't give IDLE enough time to release resources from the *LAST* run session, it will freeze and then throw a "sub-process connection failure" message, which, sometimes you can remedy by just "trying again", but all to often you are forced to kill the entire IDLE (and related sub-) processes. THIS IS EXTREMELY ANNOYING! However, *EVEN* in the instances where a problem is a direct result of a "Tkinter NO-NO" (being witting or unwitting), the user of IDLE should *NEVER* be forced to kill processes because: THERE MUST BE A BETTER SOLUTION! And this bug is making the whole Python community look like a bunch of amateurs! > I believe there is a proposal to be able to clear the > shell window. We just need to add "Clear and restart > shell". There is also an idea to put help output in an > output window. Undo-ing the result of hitting > seems like a sensible extension of undoing the > So sign the contributor agreement and volunteer to write > and review patches. I would be willing to help *IF* i received more thoughtful and engaging replies like the type you always provide. Thank you Terry for continuing to be a valuable and welcoming resource for this community! If not for you and a handful of others, i would have given up on this community a long time ago. NOBODY IS GOING TO HELP WHEN THEY GET RESISTANCE! I will visit the bug tracker again and see if i can provide some assistance there. Although, the last time i visited, i remember being annoyed by the tracker interface -- which i feel is overly noisy and far too complicated. All we need is a flat list of issues. Is there some method to export something more "readable"? Or, some sort of documentation? I must admit, my excitement to help is usually depleted by the tracker interface before i even have a chance to offer anything substantial. If this bug tracker does not improve, i will be forced to continue posting my grievances here. From rosuav at gmail.com Sat Jul 19 12:41:27 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 02:41:27 +1000 Subject: Python 3 is killing Python In-Reply-To: <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 2:29 AM, Rick Johnson wrote: > On versions 2.7.2 and 3.2.2 CONTROL+LEFT_ARROW is landing > *properly* in front of the prompt, so apparently that bug was > fixed since last i checked, my apologies for being ignorant > of the situation, but you should understand that i had given > up after years of no improvements. Standard rule: Before complaining about something, upgrade to the latest version - at least the latest bugfix version of that branch. That would be 2.7.8 and either 3.2.5 or 3.4.1. Complaining about a bug in an old release is quite pointless if that bug has already been fixed. > However, a *bare* HOME_KEY press is placing the insertion > cursor *BEHIND* the prompt of the current line. In a shell > environment, you never want to be *BEHIND* the command > prompt. I don't know about the old versions, but in 3.4, it seems to be set so the Home key toggles between the beginning of the code and the beginning of the line. Seems a useful feature, although I can understand if you'd want to disable it and set the Home key to only ever go to the beginning of code. But that's a configuration question; this does not appear to be a bug. > But my point is: We *MUST* remove this *excessive* > indentation width from the IDLE shell! Why *must*? Is it really that big a problem? > THERE MUST BE A BETTER SOLUTION! > > And this bug is making the whole Python community look like > a bunch of amateurs! Frankly, I doubt it. It's pretty obscure. Yes, all bugs should be fixed where possible, but something of the nature you're describing does NOT make Python look bad. (Side point: There's nothing bad about being an amateur. I don't know why so many people think it's an insulting term.) ChrisA From kwpolska at gmail.com Sat Jul 19 12:36:53 2014 From: kwpolska at gmail.com (=?UTF-8?B?Q2hyaXMg4oCcS3dwb2xza2HigJ0gV2Fycmljaw==?=) Date: Sat, 19 Jul 2014 18:36:53 +0200 Subject: I am stuck on OOP In-Reply-To: <53CA925B.8030600@web.de> References: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CA925B.8030600@web.de> Message-ID: On Sat, Jul 19, 2014 at 5:44 PM, Sibylle Koczian wrote: > Am 18.07.2014 20:45, schrieb Chris ?Kwpolska? Warrick: > >> Yes, exceptions do exist. But most video tutorials are produced by >> people without enough knowledge, and people that should not be working >> on educational material. This is especially visible in videos about >> basic things: they can be produced by just about anyone with a >> microphone ? which never leads to anything good. (In order to be more >> precise, I'd have to be politically incorrect.) >> > > Moreover people knowing enough about the subject and being able to explain > it really well won't necessarily speak clearly. And spoken English is so far > away from the written version anyway that it's simply a pain for everybody > with another first language. Depends on the person. I?m perfectly fine with spoken English (as long at it isn?t produced by Asians and other badly-speaking people), and it?s not my mother tongue. -- Chris ?Kwpolska? Warrick PGP: 5EAAEA16 stop html mail | always bottom-post | only UTF-8 makes sense From rosuav at gmail.com Sat Jul 19 12:48:35 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 02:48:35 +1000 Subject: I am stuck on OOP In-Reply-To: References: <53c96820$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CA925B.8030600@web.de> Message-ID: On Sun, Jul 20, 2014 at 2:36 AM, Chris ?Kwpolska? Warrick wrote: > On Sat, Jul 19, 2014 at 5:44 PM, Sibylle Koczian wrote: >> Am 18.07.2014 20:45, schrieb Chris ?Kwpolska? Warrick: >> >>> Yes, exceptions do exist. But most video tutorials are produced by >>> people without enough knowledge, and people that should not be working >>> on educational material. This is especially visible in videos about >>> basic things: they can be produced by just about anyone with a >>> microphone ? which never leads to anything good. (In order to be more >>> precise, I'd have to be politically incorrect.) >>> >> >> Moreover people knowing enough about the subject and being able to explain >> it really well won't necessarily speak clearly. And spoken English is so far >> away from the written version anyway that it's simply a pain for everybody >> with another first language. > > Depends on the person. I?m perfectly fine with spoken English (as > long at it isn?t produced by Asians and other badly-speaking people), > and it?s not my mother tongue. My main issue with spoken (as opposed to written) English is that it becomes so fundamentally linear. You can't skim a podcast and then read in detail the parts you want; it's fiddly to go back and reread something; and it's extremely fiddly to go back and re*write* something, so a lot of errors slip through. (Imagine if you had to type python-list posts without any cursor movement or backspace functionality, but you could go back and retype any one paragraph from scratch. I posit you would leave the odd typo in there, because it's just not worth the effort of fixing it.) Of course, its linearity is a feature for a lot of people, who tend to skim things poorly and not properly learn, but when they're forced to concentrate on what's being fed to them right this second and not worry about the rest, they can comprehend it better; but if you can properly grok a wall of text, that's usually going to be more efficient. ChrisA From chris at cdreimer.com Sat Jul 19 13:38:47 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 10:38:47 -0700 Subject: What's the proper style for a library string function? Message-ID: <53CAAD27.9010207@cdreimer.com> Greetings, I typically write a Python 2.7 string function in my library like this: def getCompletedTime(start, end): return "Time completed:", str(end - start) And called it like this: print getCompletedTime(start, end) Since every Python script I write is executed from the command line, I rewrote the string function like this: def getCompletedTime(start, end): print "Time completed:", str(end - start) And call it like this: getCompletedTime(start, end) The first version is what I'm familiar with having reluctantly learned Java at community college, which couldn't afford a Microsoft site license for Visual C++ and taught every class in Java. (The Linux instructor rebelled against this policy by teaching basic C/C++ and shell scripting in his classes.) I recently read an article that Python is replacing Java as a teaching language. The second version is more straight forward but seems less readable (i.e., "print getCompletedTime(start, end)" vs. "getCompletedTime(start, end)") from the calling script. Alternatively, I thought about rewriting the string function to accept an extra parameter to do either and default to the print statement. def getCompletedTime(start, end, type = 'p'): string = "Time completed: " + str(end - start) if type == 'p': print string else: return string I'm curious as to what the proper Python style would be for this. Thank you, Chris Reimer From ian.g.kelly at gmail.com Sat Jul 19 14:00:29 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 19 Jul 2014 12:00:29 -0600 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On Sat, Jul 19, 2014 at 10:41 AM, Chris Angelico wrote: >> However, a *bare* HOME_KEY press is placing the insertion >> cursor *BEHIND* the prompt of the current line. In a shell >> environment, you never want to be *BEHIND* the command >> prompt. > > I don't know about the old versions, but in 3.4, it seems to be set so > the Home key toggles between the beginning of the code and the > beginning of the line. Seems a useful feature, although I can > understand if you'd want to disable it and set the Home key to only > ever go to the beginning of code. But that's a configuration question; > this does not appear to be a bug. I'd say that moving the cursor to a position where you can't type is a bug. In that case, "beginning of the line" should be understood to be after the prompt. I see the use for it in an editing environment (I have an Emacs macro that does the same thing), but I don't really see the point of having the same feature in the shell other than for harmless consistency. From chris at cdreimer.com Sat Jul 19 14:08:10 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 11:08:10 -0700 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53CAB40A.4030704@cdreimer.com> On 7/19/2014 12:28 AM, Steven D'Aprano wrote: > Earlier, I mentioned a considerable number of IDEs which are available > for Python, including: I prefer to use Notepad++ (Windows) and TextWrangler (Mac). Text editors with code highlighting can get the job done as well, especially if the project is modest and doesn't require version control. Chris Reimer From breamoreboy at yahoo.co.uk Sat Jul 19 14:24:58 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 19 Jul 2014 19:24:58 +0100 Subject: What's the proper style for a library string function? In-Reply-To: <53CAAD27.9010207@cdreimer.com> References: <53CAAD27.9010207@cdreimer.com> Message-ID: On 19/07/2014 18:38, C.D. Reimer wrote: > Greetings, > > I typically write a Python 2.7 string function in my library like this: > > def getCompletedTime(start, end): return "Time completed:", str(end > - start) > > And called it like this: > > print getCompletedTime(start, end) > > Since every Python script I write is executed from the command line, I > rewrote the string function like this: > > def getCompletedTime(start, end): print "Time completed:", str(end > - start) > > And call it like this: > > getCompletedTime(start, end) > > The first version is what I'm familiar with having reluctantly learned > Java at community college, which couldn't afford a Microsoft site > license for Visual C++ and taught every class in Java. (The Linux > instructor rebelled against this policy by teaching basic C/C++ and > shell scripting in his classes.) I recently read an article that Python > is replacing Java as a teaching language. > > The second version is more straight forward but seems less readable > (i.e., "print getCompletedTime(start, end)" vs. "getCompletedTime(start, > end)") from the calling script. > > Alternatively, I thought about rewriting the string function to accept > an extra parameter to do either and default to the print statement. > > def getCompletedTime(start, end, type = 'p'): > string = "Time completed: " + str(end - start) > if type == 'p': > print string > else: > return string > > I'm curious as to what the proper Python style would be for this. > > Thank you, > > Chris Reimer Besides that I wouldn't write the function on one line, the first. Once you return your data you can do what you want with it. The second you can only write by default to stdout. The third is really horrible in my book, YMMV. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From tjreedy at udel.edu Sat Jul 19 14:31:10 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Jul 2014 14:31:10 -0400 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On 7/19/2014 3:28 AM, Steven D'Aprano wrote: > So why does Python ship with IDLE? On Windows the Idle shell is needed for sensible interactive use. For simply editing a Python file, running it, and fixing it, the Idle editor seems *about* as good as anything. > It's not because Python requires an > IDE, or that newbies need one, or that there aren't alternatives. The > biggest reason for Python shipping with an IDE is not that people are > unable to install alternatives, but that a lot of people are *prohibited* > from doing so. This is true, but I think it understates the case. -- Terry Jan Reedy From chris at cdreimer.com Sat Jul 19 14:52:49 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 11:52:49 -0700 Subject: What's the proper style for a library string function? In-Reply-To: References: <53CAAD27.9010207@cdreimer.com> Message-ID: <53CABE81.7040003@cdreimer.com> On 7/19/2014 11:24 AM, Mark Lawrence wrote: > Besides that I wouldn't write the function on one line, the first. I've seen code samples for simple functions with the definition and return statements written on one line. > Once you return your data you can do what you want with it. Returning data from a function is probably the part I'm overlooking. > The third is really horrible in my book, YMMV. That if/else version was something I've been thinking about doing and didn't it put it together until I wrote my email. If I couldn't write a better version, I wouldn't keep it myself. Chris Reimer From ian.g.kelly at gmail.com Sat Jul 19 14:56:55 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 19 Jul 2014 12:56:55 -0600 Subject: What's the proper style for a library string function? In-Reply-To: References: <53CAAD27.9010207@cdreimer.com> Message-ID: On Sat, Jul 19, 2014 at 12:24 PM, Mark Lawrence wrote: > Besides that I wouldn't write the function on one line, the first. Once you > return your data you can do what you want with it. The second you can only > write by default to stdout. The third is really horrible in my book, YMMV. I agree. Optional flags that alter the behavior of functions are considered unpythonic; usually it's better to let the alternative behavior have its own function, particularly if they can share implementation. With that in mind, I would suggest to the OP that you might want to have *two* functions: def format_completed_time(start, end): return "Time completed: " + str(end - start) def print_completed_time(start, end): print(get_completed_time(start, end)) Also notice that I changed the function naming style from mixedCase to lower_case_with_underscores. This is the style recommended for Python by PEP 8, which you should read if you haven't already. http://legacy.python.org/dev/peps/pep-0008/#naming-conventions I also changed the verb from "get" to "format". "get" suggests to me that it will retrieve the completed time as a processable value, not as a part of a formatted string. From ian.g.kelly at gmail.com Sat Jul 19 15:00:23 2014 From: ian.g.kelly at gmail.com (Ian Kelly) Date: Sat, 19 Jul 2014 13:00:23 -0600 Subject: What's the proper style for a library string function? In-Reply-To: <53CABE81.7040003@cdreimer.com> References: <53CAAD27.9010207@cdreimer.com> <53CABE81.7040003@cdreimer.com> Message-ID: On Sat, Jul 19, 2014 at 12:52 PM, C.D. Reimer wrote: > I've seen code samples for simple functions with the definition and return > statements written on one line. Personally, I use this style sometimes for easily understood one-line if statements or loops. Named functions consist of an interface declaration and an implementation, and those should be visually separated by a newline. From breamoreboy at yahoo.co.uk Sat Jul 19 15:14:15 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sat, 19 Jul 2014 20:14:15 +0100 Subject: What's the proper style for a library string function? In-Reply-To: <53CAAD27.9010207@cdreimer.com> References: <53CAAD27.9010207@cdreimer.com> Message-ID: On 19/07/2014 18:38, C.D. Reimer wrote: > Greetings, > > I typically write a Python 2.7 string function in my library like this: > > def getCompletedTime(start, end): return "Time completed:", str(end > - start) > Further to my earlier post are you aware of the behaviour of your "string function"? >>> def getCompletedTime(start, end): return "Time completed:", str(end - start) ... >>> t = getCompletedTime(0, -1) >>> type(t) >>> t[0] 'Time completed:' >>> t[1] '-1' Is this what you intended? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From chris at cdreimer.com Sat Jul 19 15:43:24 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 12:43:24 -0700 Subject: What's the proper style for a library string function? In-Reply-To: References: <53CAAD27.9010207@cdreimer.com> Message-ID: <53CACA5C.30504@cdreimer.com> On 7/19/2014 11:56 AM, Ian Kelly wrote: > On Sat, Jul 19, 2014 at 12:24 PM, Mark Lawrence wrote: > > > Also notice that I changed the function naming style from mixedCase to > lower_case_with_underscores. This is the style recommended for Python > by PEP 8, which you should read if you haven't already. > http://legacy.python.org/dev/peps/pep-0008/#naming-conventions I love how that section of PEP 8 begins with: "The naming conventions of Python's library are a bit of a mess, so we'll never get this completely consistent -- nevertheless, here are the currently recommended naming standards." My code is certainly in "a bit of a mess" as I'm still learning Python. Following the "Core Python Programming" book for the most part, and writing scripts to solve the problems that I'm having. I got an associate degree in computer programming but never mastered a programming language outside of web development. I'll need to unlearn all the bad habits I picked up with PHP over the years. Chris Reimer From chris at cdreimer.com Sat Jul 19 16:03:16 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 13:03:16 -0700 Subject: What's the proper style for a library string function? In-Reply-To: References: <53CAAD27.9010207@cdreimer.com> Message-ID: <53CACF04.3040103@cdreimer.com> On 7/19/2014 12:14 PM, Mark Lawrence wrote: > > Is this what you intended? > I'm in the process of generalizing a library module from my first Python programming project to make it more accessible to other projects. The code I wrote for that project doesn't make sense anymore. As I generalize the library module, I'm also cleaning up the calling code from that project and other scripts. The corrected version of the string function should be: def format_completed_time(start, end): return "Time completed: " + str(end - start) Chris Reimer From mathias.moe at gmail.com Sat Jul 19 16:26:41 2014 From: mathias.moe at gmail.com (mathias.moe at gmail.com) Date: Sat, 19 Jul 2014 13:26:41 -0700 (PDT) Subject: What Next After Python Basics In-Reply-To: References: Message-ID: <08d0e743-004b-41c2-a760-a062c7a7d12c@googlegroups.com> On Sunday, July 13, 2014 10:16:47 PM UTC+2, Orochi wrote: > Hi, > I am beginner in Python > I have Completed Basic Python Course from Codecademy.com . > Now that I have a hands on the basics what is the next thing I should do. > I mean should I learn more or start a small Project(Any Ideas are Welcomed) or any Other suggestions. > Where to Start? > > Thank You, > Orochi > I started up going through a few problems on projecteuler.net, and then casually escalated to look through codegolf.stackexchange.com for fun code to study, and even some problem to mimic. So, there's *an* idea. (mind you, might not be the best of ideas). If you're up for it, there's even rosettacode.org, with crazy code which I found fun to study. But mostly, just code. Anything. For my studies, I get assignments to go through large bodies of text and sort them for some criteria, and while I'm given tools to do it, I try to make my own tools to get the job done. That is to say, if there's something in your day that you use in some way, and it's fairly simple, or its essential functionality can be copied, then that's something to copy. I apologize for the raving suggestions. Mathias H. M. From rantingrickjohnson at gmail.com Sat Jul 19 16:39:17 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 19 Jul 2014 13:39:17 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: [A missed point from my last reply...] Terry Reedy said: > I believe there is a proposal to be able to clear the > shell window. We just need to add "Clear and restart > shell". A command that allows clearing the *entire* shell display and also resets the global and local symbol tables, *WITHOUT* requiring a re- start of the entire IDLE application, would be a great addition! However, sometimes you just want to remove the displayed result of the *LAST* command executed --for instance, in the case of accidentally printing a *very large* data structure-- and i believe this "output undo action" should be clearly *DISTINCT* from your normal "edit undo" actions via: "CONTROL+Z" To solve this dilemma in *MY* command shell, i use the "ALT+UP_ARROW" to delete everything from the "last command prompt" to the "end of the text buffer". I think IDLE needs both functionality! > There is also an idea to put help output in an > output window. I believe more windows just creates more confusion for the user. Sometimes you have no choice but add additional "views", however, in this case at least, i believe a menu command (coupled with a keyboard event) is the only solution that can keep the interface "manageable". From tjreedy at udel.edu Sat Jul 19 16:45:07 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Jul 2014 16:45:07 -0400 Subject: Improving Idle (was Re: Python 3 ...) In-Reply-To: <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On 7/19/2014 12:29 PM, Rick Johnson wrote: > On Friday, July 18, 2014 8:21:36 PM UTC-5, Terry Reedy wrote: > >> What ancient version, or oddball system are you using? For >> me, Win 7, both 2.7.8 and 3.4.1 "CONTROL+LEFT_ARROW" and >> the cursor is before the 'a' of [>>> abc]. The HOME key >> goes to the same place first, and they before >>> on the >> second press (and before 'a' on the third). > > On versions 2.7.2 and 3.2.2 These are ancient versions from years ago that no one should be running Idle on now. Before you say another word about Idle, and I mean this literally, update to current versions. There have been about 80 issues fixed since 2.7.2 and well more than 100 patches pushed. > CONTROL+LEFT_ARROW is landing *properly* in front of the prompt, Re-read my comment that you quoted. This has been fixed. > But my point is: We *MUST* remove this *excessive* > indentation width from the IDLE shell! To repeat: I agree, Raymond Hettigner agrees, everyone seems to agree, and we all have for years. http://bugs.python.org/issue7676 is over 4 years old. But a patch can only implement a specific new behavior, not just 'stop the old'. >> I cannot connect [your complaint about IDLE hanging] to >> behavior I have seen. > > IDLE will hang when editing Tkinter code. It seems to happen > most often in two cases: If you are running your tkinter code in the same process with Idle's tkinter code, either with ancient Idle or the '-n' startup option (possibly buried in a script), the situation is hopeless. If you are running your code in a separate process (now the default), then, most likely, Idle is not hanging. It is just waiting for your hung process. If so, Shell / Restart shell (^F6) will end the user process and start a new one. > 1. When running code that results in a Tkinter error. > > This can happen when mixing the "grid" and "pack" geometry > managers within the same "container" widget, which is a > Tkinter NO-NO, but it can also happen during other Tkinter > errors! The user process might hang trying to display a message from *tk*, as oppose to Python code, including tkinter. If you start Idle in a console window with 'python -m idlelib' or in the console interpreter with 'import idlelib.idle', you might see messages from tk, as I sometimes do (especially with a repository debug build). > 2. During "quickly successive" back-to-back "run sessions" > of Tkinter GUI apps. > > It seems that sometimes, if you don't give IDLE enough > time to release resources from the *LAST* run session, it > will freeze and then throw a "sub-process connection > failure" message, which, sometimes you can remedy by just > "trying again", but all to often you are forced to kill > the entire IDLE (and related sub-) processes. Use one of the startup options directly above to see if you can get more information. A repeatable or at least semi-repeatable failure case is needed to do anything. > However, *EVEN* in the instances where a problem is a direct > result of a "Tkinter NO-NO" (being witting or unwitting), > the user of IDLE should *NEVER* be forced to kill processes If you are talking about user processes, and we are talking about patching Idle, as opposed to Python or the OS (such as Windows), I disagree. If you are talking about the Idle process, then yes, I would prefer that once Idle starts, it run forever, and recover from any problems caused by users. Roger Serwy fixed many Idle shutdowns before being swallowed by a PhD program a year ago, but there is more to do. >> I believe there is a proposal to be able to clear the >> shell window. We just need to add "Clear and restart >> shell". There is also an idea to put help output in an >> output window. Undo-ing the result of hitting >> seems like a sensible extension of undoing the > >> So sign the contributor agreement and volunteer to write >> and review patches. In particular, go to https://www.python.org/psf/contrib to read *about* the contributor agreement and then go to https://www.python.org/psf/contrib-form/ (when the page is working -- it is not at the moment) with Javascript turned on to submit on-line (or submit by old-fashioned s-mail). When the form is processed, the Contributor Form Received field of your user profile at http://bugs.python.org/user12501 will be updated. Also, please update the email on that page to your current one. We are much stricter about getting Contributor Agreements than we used to be. I will usually not look as non-trivial patches until the author has at least signed the agreement and will not commit until it is recorded. > I would be willing to help *IF* i received more thoughtful and > engaging replies like the type you always provide. On the tracker at least, be polite and ignore impolite posts. I get them occasionally. > NOBODY IS GOING TO HELP WHEN THEY GET RESISTANCE! PEP 434 negated some forms of Idle resistance. However, it did not stop resistance in the form of criticism based on how Idle was (or might have been) years ago. > I will visit the bug tracker again and see if i can provide > some assistance there. Although, the last time i visited, i > remember being annoyed by the tracker interface -- which i > feel is overly noisy and far too complicated. The tracker could stand improvement, and there is a meta-tracker for that, though not many devs work on it. There is an infrastructure committee working on overhauling the entire workflow process, not just the tracker. In the meanwhile, the tracker serves to keep track of issue and patches well enough to get some work done. > All we need is > a flat list of issues. Is there some method to export > something more "readable"? If you do a search, such as for open issues with component 'Idle', the results page has a button to download *all* the results, not just those displayed, as a .csv file. Do whatever you want with that. > Or, some sort of documentation? The Tracker Documentation link at the bottom of the left margin now goes to https://docs.python.org/devguide/triaging.html. Most of the page is only relevant when opening an issue or editing the headers. The last section is relevant for posting messages. How to upload a patch (the Browse button) is not described. > I must admit, my excitement to help is usually depleted by > the tracker interface before i even have a chance to offer > anything substantial. Buck up ;-) > If this bug tracker does not improve, i will be forced to > continue posting my grievances here. As long as you base them on current Idle and are specific, that's fine. Patches you must upload yourself, for the responsibility trail. -- Terry Jan Reedy From timothy.c.delaney at gmail.com Sat Jul 19 17:50:05 2014 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Sun, 20 Jul 2014 07:50:05 +1000 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53CAB40A.4030704@cdreimer.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CAB40A.4030704@cdreimer.com> Message-ID: On 20 July 2014 04:08, C.D. Reimer wrote: > On 7/19/2014 12:28 AM, Steven D'Aprano wrote: > >> Earlier, I mentioned a considerable number of IDEs which are available >> for Python, including: >> > > I prefer to use Notepad++ (Windows) and TextWrangler (Mac). Text editors > with code highlighting can get the job done as well, especially if the > project is modest and doesn't require version control. > IMO there is no project so modest that it doesn't require version control. Especially since version control is as simple as: cd project hg init hg add hg commit FWIW I also don't find a need for an IDE for Python - I'm quite happy using EditPlus (which I preferred enough to other alternatives on Windows to pay for many years ago). Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From wojtekgiel at gmail.com Sat Jul 19 14:40:25 2014 From: wojtekgiel at gmail.com (Wojciech Giel) Date: Sat, 19 Jul 2014 19:40:25 +0100 Subject: What's the proper style for a library string function? In-Reply-To: <53CAAD27.9010207@cdreimer.com> References: <53CAAD27.9010207@cdreimer.com> Message-ID: <53CABB99.8020009@gmail.com> On 19/07/14 18:38, C.D. Reimer wrote: > Greetings, > > I typically write a Python 2.7 string function in my library like this: > > def getCompletedTime(start, end): return "Time completed:", > str(end - start) > > And called it like this: > > print getCompletedTime(start, end) > > Since every Python script I write is executed from the command line, I > rewrote the string function like this: > > def getCompletedTime(start, end): print "Time completed:", str(end > - start) > > And call it like this: > > getCompletedTime(start, end) > > The first version is what I'm familiar with having reluctantly learned > Java at community college, which couldn't afford a Microsoft site > license for Visual C++ and taught every class in Java. (The Linux > instructor rebelled against this policy by teaching basic C/C++ and > shell scripting in his classes.) I recently read an article that > Python is replacing Java as a teaching language. > > The second version is more straight forward but seems less readable > (i.e., "print getCompletedTime(start, end)" vs. > "getCompletedTime(start, end)") from the calling script. > > Alternatively, I thought about rewriting the string function to accept > an extra parameter to do either and default to the print statement. > > def getCompletedTime(start, end, type = 'p'): > string = "Time completed: " + str(end - start) > if type == 'p': > print string > else: > return string > > I'm curious as to what the proper Python style would be for this. You might look into PEP8 "Style Guide for Python Code" it will give you recommendation how to write a code. among other gives most sensible answer: "Consistency within a project is more important. Consistency within one module or function is most important...... When in doubt, use your best judgment. Look at other examples and decide what looks best." http://legacy.python.org/dev/peps/pep-0008/#function-names for me if you will be reusing this function I would just use: def getCompletedTime(start, end): return "Time completed:", str(end - start) if you need to print just add print, if you want result from this function somewhere else you got it. adding additional arguments necessary adds complexity. do you really need it. Keep it simple stupid expression can be applied everywhere. cheers Wojciech From sturla.molden at gmail.com Sat Jul 19 18:32:02 2014 From: sturla.molden at gmail.com (Sturla Molden) Date: Sat, 19 Jul 2014 22:32:02 +0000 (UTC) Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <093d2303-9e7d-497e-bb85-b9f16d5d61af@gmail.com> Message-ID: <408657451427501842.393182sturla.molden-gmail.com@news.gmane.org> Martin S wrote: > Is there a point to still use Usenet? Last time I checked noise > overwhelmed signal by a factor of something close to 542. news.gmane.org can be a convinient way to read mailing lists instead of getting tons of mail. Sturla From sturla.molden at gmail.com Sat Jul 19 18:38:00 2014 From: sturla.molden at gmail.com (Sturla Molden) Date: Sat, 19 Jul 2014 22:38:00 +0000 (UTC) Subject: OT: usenet reader software References: Message-ID: <1215729054427502033.453669sturla.molden-gmail.com@news.gmane.org> wrote: > That doesn't address the problem at all! :-) You still need a news > reader. The problem was that Thunderbird does not support killfiles when used as a newsreader. Leafnode adds filtering capabilities which Thunderbird (supposedly) does not have. Sturla From rantingrickjohnson at gmail.com Sat Jul 19 18:50:19 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 19 Jul 2014 15:50:19 -0700 (PDT) Subject: Python 3 is killing Python In-Reply-To: <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: [A missed point from my last reply...] Terry Reedy said: > I believe there is a proposal to be able to clear the > shell window. We just need to add "Clear and restart > shell". A command that allows a user to clear the *ENTIRE* "shell IO" and *ALSO* resets the global and local symbol tables *WITHOUT* requiring a re-start of the IDLE application, would be a great addition indeed! Currently "IDLE shell" has *ONLY* the "Restart Shell" command, which simply resets the symbol table whilst leaving all previous "shell IO" untouched. Which is useful in some situations, but not all... CONSIDER, Sometimes you just want to remove the displayed result of the *LAST* command executed *WHILST* maintaining any previous displayed "shell IO" -- for instance, in the case of accidentally printing a *very large* data structure, or a horrendously untrimmed "dir()" requests. ############################################################ # DISAMBIGUATION: "EditUndo" vs "OutputUndo" # ############################################################ # In order to prevent confusion with the typical "edit- # # undo" of "CONTROL+Z", we should refer to the action of # # "remove the last output displayed" as an "output-undo". # ############################################################ To solve this dilemma in *MY* command shell, i use the "ALT+UP_ARROW" to delete everything from the "last command prompt" up to "the end of the text buffer", in effect, creating an "output-undo" command without *DEFILING* the standard semantics of ubiquitous "CONTROL+Z". I think IDLE needs all three functionality of: 1. Reset symbol tables *WHILST* retaining previous "shell IO" (Already exists via "Shell->Restart Shell") 2. Reset symbol tables *AND* clear all "shell IO" (Maybe: "Shell->Reset Shell") 3. Remove the displayed result of the *LAST* command processed. (Maybe: "Shell->Remove Last Output") Hotkeys for all three are a must and should be configurable by the user. > There is also an idea to put help output in an > output window. I believe more windows just creates more confusion for the user. Sometimes you have no choice but to add additional "views" to a GUI interface, however, in this case at least, i believe a menu command (coupled with a keyboard event) is a best solution to maintain the highest level of "interface manageability" -- IMHO. From rosuav at gmail.com Sat Jul 19 19:10:49 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 09:10:49 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 4:00 AM, Ian Kelly wrote: > On Sat, Jul 19, 2014 at 10:41 AM, Chris Angelico wrote: >>> However, a *bare* HOME_KEY press is placing the insertion >>> cursor *BEHIND* the prompt of the current line. In a shell >>> environment, you never want to be *BEHIND* the command >>> prompt. >> >> I don't know about the old versions, but in 3.4, it seems to be set so >> the Home key toggles between the beginning of the code and the >> beginning of the line. Seems a useful feature, although I can >> understand if you'd want to disable it and set the Home key to only >> ever go to the beginning of code. But that's a configuration question; >> this does not appear to be a bug. > > I'd say that moving the cursor to a position where you can't type is a > bug. In that case, "beginning of the line" should be understood to be > after the prompt. You can copy and paste from there. It's functionally equivalent to being able to press Up arrow and move above the currently-editable line. But even if it weren't for that, my statement would still be correct: It's not a bug, and therefore not embarrassment, because it's a feature that you may or may not like. ChrisA From rosuav at gmail.com Sat Jul 19 19:13:57 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 09:13:57 +1000 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 6:39 AM, Rick Johnson wrote: > To solve this dilemma in *MY* command shell, i use the > "ALT+UP_ARROW" to delete everything from the "last command > prompt" to the "end of the text buffer". I think IDLE needs > both functionality! Okay, now I understand Rick's attitude. So long as Idle has one single bug of which he is aware, or lacks one single feature which he can think of, it is an utter and total embarrassment to the entire Python community - not just those who work to make Idle what it is, but also everyone who uses Idle... and everyone who doesn't use Idle, too. Rick, start writing patches, and stop moaning like this just because someone hasn't thought of something you've thought of. It may or may not even be worth implementing this, but definitely you have the wrong attitude toward feature requests. ChrisA From rosuav at gmail.com Sat Jul 19 19:19:34 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 09:19:34 +1000 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CAB40A.4030704@cdreimer.com> Message-ID: On Sun, Jul 20, 2014 at 7:50 AM, Tim Delaney wrote: > IMO there is no project so modest that it doesn't require version control. > Especially since version control is as simple as: > > cd project > hg init > hg add > hg commit That said, though, there are some projects so modest they don't require dedicated repositories. I have a repo called "shed" - it's a collection of random tools that I've put together, no more logical grouping exists. Generally each one is a single file, although I have a couple of related ones in there. (Code at https://github.com/Rosuav/shed if anyone's curious.) If I have an idea for a program that doesn't really merit a full repo, I'll just save it into shed. Keeps the "where did I put that, what did I call that" to a minimum :) ChrisA From tjreedy at udel.edu Sat Jul 19 19:23:43 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 19 Jul 2014 19:23:43 -0400 Subject: Python 3 is killing Python In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On 7/19/2014 6:50 PM, Rick Johnson wrote: > > [A missed point from my last reply...] > > Terry Reedy said: >> I believe there is a proposal to be able to clear the >> shell window. We just need to add "Clear and restart >> shell". > # In order to prevent confusion with the typical "edit- # > # undo" of "CONTROL+Z", we should refer to the action of # > # "remove the last output displayed" as an "output-undo". # That would make implementation easier. > I think IDLE needs all three functionality of: > > 1. Reset symbol tables *WHILST* retaining previous "shell > IO" (Already exists via "Shell->Restart Shell") > > 2. Reset symbol tables *AND* clear all "shell IO" (Maybe: > "Shell->Reset Shell") > > 3. Remove the displayed result of the *LAST* command > processed. (Maybe: "Shell->Remove Last Output") > > Hotkeys for all three are a must I consider them a nicety. We will eventually run out of simple hot keys. > and should be configurable by the user. I believe anything Idle controls is. >> There is also an idea to put help output in an >> output window. In the new issue, I said 'move the last output' from the shell to a window, so it would be entirely optional. > I believe more windows just creates more confusion for the > user. I expect to eventually look at G.Polo's patch for using tabbed notebooks, which will help with this. -- Terry Jan Reedy From timothy.c.delaney at gmail.com Sat Jul 19 20:41:31 2014 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Sun, 20 Jul 2014 10:41:31 +1000 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CAB40A.4030704@cdreimer.com> Message-ID: On 20 July 2014 09:19, Chris Angelico wrote: > On Sun, Jul 20, 2014 at 7:50 AM, Tim Delaney > wrote: > > IMO there is no project so modest that it doesn't require version > control. > > Especially since version control is as simple as: > > > > cd project > > hg init > > hg add > > hg commit > > That said, though, there are some projects so modest they don't > require dedicated repositories. I have a repo called "shed" - it's a > collection of random tools that I've put together, no more logical > grouping exists. Agreed. I have a "utils" one - but I do like "shed" and think I'm going to rename :) The main thing is that versioning should be automatic now - it's almost free, and the benefits are huge because even trivial scripts end up evolving. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sat Jul 19 20:41:56 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 10:41:56 +1000 Subject: What's the proper style for a library string function? In-Reply-To: <53CABB99.8020009@gmail.com> References: <53CAAD27.9010207@cdreimer.com> <53CABB99.8020009@gmail.com> Message-ID: On Sun, Jul 20, 2014 at 4:40 AM, Wojciech Giel wrote: > You might look into PEP8 "Style Guide for Python Code" it will give you > recommendation how to write a code. among other gives most sensible answer: > "Consistency within a project is more important. Consistency within one > module or function is most important...... When in doubt, use your best > judgment. Look at other examples and decide what looks best." But perhaps the most crucial part of PEP 8 is up in the introductory text: """ But most importantly: know when to be inconsistent -- sometimes the style guide just doesn't apply. ... Some other good reasons to ignore a particular guideline: 1. When applying the guideline would make the code less readable, even for someone who is used to reading code that follows this PEP. """ This is a very New Testament style of guidebook: your conscience is very important, the details of the rules are subordinate to the overriding principle of readability. In Dungeons & Dragons terms, you're called to be a paladin with an emphasis on Good where it conflicts with Lawful. This is PEP 8's anti-bureaucracy rule. ChrisA From breamoreboy at yahoo.co.uk Sat Jul 19 20:49:51 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 20 Jul 2014 01:49:51 +0100 Subject: OT: usenet reader software In-Reply-To: <1215729054427502033.453669sturla.molden-gmail.com@news.gmane.org> References: <1215729054427502033.453669sturla.molden-gmail.com@news.gmane.org> Message-ID: On 19/07/2014 23:38, Sturla Molden wrote: > wrote: > >> That doesn't address the problem at all! :-) You still need a news >> reader. > > The problem was that Thunderbird does not support killfiles when used as a > newsreader. Leafnode adds filtering capabilities which Thunderbird > (supposedly) does not have. > > Sturla > So what does clicking on Message->Create filter from message... do exactly? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Sat Jul 19 20:59:48 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 10:59:48 +1000 Subject: Repo/directory names (was Re: Python and IDEs [was Re: Python 3 is killing Python]) Message-ID: On Sun, Jul 20, 2014 at 10:41 AM, Tim Delaney wrote: > On 20 July 2014 09:19, Chris Angelico wrote: >> >> That said, though, there are some projects so modest they don't >> require dedicated repositories. I have a repo called "shed" - it's a >> collection of random tools that I've put together, no more logical >> grouping exists. > > Agreed. I have a "utils" one - but I do like "shed" and think I'm going to > rename :) I first met that name on our old DOS and OS/2 systems, set up by my Dad. It was a directory on whichever drive was appropriate (exactly one per installation - we wouldn't risk a network dependency here), and had programs that would probably go in /usr/bin or /usr/local/bin on a Unix system. Part of setting up a new OS/2 installation was always copying E:\SHED (the network drive) to D:\SHED, and putting D:\SHED\NPSWPS\NPSWPS.EXE into Startup. (NPS WPS Enhancer, awesome program. If you have OS/2, get it. What, you don't have OS/2 anywhere? What a surprise.) Other people had, for instance, a C:\BELFRY (best place to have BATs, you know), or other such names. What's your favorite directory/repository name for a concretion of ... random stuff? ChrisA From chris at cdreimer.com Sat Jul 19 21:24:12 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 18:24:12 -0700 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53CAB40A.4030704@cdreimer.com> Message-ID: <53CB1A3C.4070802@cdreimer.com> On 7/19/2014 5:41 PM, Tim Delaney wrote: > The main thing is that versioning should be automatic now - it's > almost free, and the benefits are huge because even trivial scripts > end up evolving. I keep my modest Python scripts in a Dropbox directory and run a weekly Python script to zip up the Dropbox directory for safekeeping on the home file server and Microsoft OneDrive. If I really need a recent copy of a script, Time Machine on the Mac should have a copy from the Drop Box folder. The only time I use version control is when I have a big project with many moving parts and/or I'm publishing software for other people to use. Chris Reimer From steve+comp.lang.python at pearwood.info Sat Jul 19 21:23:30 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Jul 2014 01:23:30 GMT Subject: Python and IDEs [was Re: Python 3 is killing Python] References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> On Sat, 19 Jul 2014 14:31:10 -0400, Terry Reedy wrote: > On 7/19/2014 3:28 AM, Steven D'Aprano wrote: > >> So why does Python ship with IDLE? > > On Windows the Idle shell is needed for sensible interactive use. One might say that *some* IDE is needed, but Idle itself isn't compulsory :-) It also depends on what you consider sensible. I haven't used Python on Windows much, but when I did use it, I found the standard Python interactive interpreter running under cmd.exe to be bare- bones but usable for testing short snippets. If I recall correctly, it is missing any sort of command history or line editing other than backspace, which I guess it would have been painful to use for extensive interactive work, but when I started using Python on Linux the interactive interpreter had no readline support either so it was just like old times :-) -- Steven From rosuav at gmail.com Sat Jul 19 21:29:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 11:29:44 +1000 Subject: What Next After Python Basics In-Reply-To: <08d0e743-004b-41c2-a760-a062c7a7d12c@googlegroups.com> References: <08d0e743-004b-41c2-a760-a062c7a7d12c@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 6:26 AM, wrote: > But mostly, just code. Anything. For my studies, I get assignments to go through large bodies of text and sort them for some criteria, and while I'm given tools to do it, I try to make my own tools to get the job done. That is to say, if there's something in your day that you use in some way, and it's fairly simple, or its essential functionality can be copied, then that's something to copy. > > > I apologize for the raving suggestions. No, that's not raving. The way to get good at something is to do it, and do it a lot. That's why I don't play lasertag, that's why I don't butcher my own meat, that's why I don't write optimizing C compilers. I don't have time to get good at any of those things. (Not that I have a philosophical objection to any. If my circumstances change, I might take one of them up at some point, but for the moment, I don't.) To become a programmer, you need to write programs. As a student programmer, you get very specific tasks: Write a program that, given this input, produces this output; and use exactly these tools (language statements, library functions, etc) to do so. There's a definite "right answer" and a whole lot of "wrong answers". (And it's really obvious when someone asks for help. When the problem's that specific, it's bound to be homework.) As a novice, you generally have fairly specific goals, but now you have flexibility in how you implement it. Import this CSV file into an SQL database, converting "25 Mar 01" into "2001-03-25" as it goes through. You could do that with a preparse script, or you could import into a temporary table and convert it in the database, or you could parse and import in one step. It's fairly straight-forward to figure out whether you've accomplished the goal or made a mess of it, but there's no longer a "right way to do it". An expert programmer has to cope with much vaguer requirements. Reduce the number of data entry errors in invoicing. Adding something to a UI that helps people notice errors earlier may not clearly and demonstrably be working, until they've had a chance to get accustomed to it and you start seeing that the error average per week is lower than it was before the feature went in. (And even then, you can't be sure; something else might have caused the improvement.) (An expert will also sometimes get really clear goals. These are good days. These are luxuries. These are the times when you profusely thank the previous programmer for putting in such comprehensive unit tests that the porting process is reduced to "make sure all tests pass, then we're done". These are rarities, sadly, but they definitely do exist.) Before you can handle the complex and less-clear jobs, you have to get enough experience to know what you're doing. That means doing jobs that have really clear requirements. Will they be boring? Maybe. Derivative? Almost certainly. But pointless? Absolutely not. And maybe you'll recreate something in almost the same way, but with one little tweak that makes it now absolutely perfect for you. Or recreate something in a different language, just because it's better that way. (I did that myself recently - see http://rosuav.com/1/?id=1009 - even though the old one was working fine.) Never useless, because of what it does for you, the programmer. It takes ten thousand hours of practice to achieve competence. Fortunately, those hours will be enjoyable, if spent programming. :) ChrisA From rantingrickjohnson at gmail.com Sat Jul 19 21:31:27 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sat, 19 Jul 2014 18:31:27 -0700 (PDT) Subject: Improving Idle (was Re: Python 3 ...) In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> On Saturday, July 19, 2014 3:45:07 PM UTC-5, Terry Reedy wrote: > On 7/19/2014 12:29 PM, Rick Johnson wrote: > [2.7.2 and 3.2.2] are ancient versions from years ago that > no one should be running Idle on now. I have just downloaded and installed versions 2.7.8 and 3.4.1, and i am happy to report that both the "HOME_KEY" *AND* the "CONTROL+LEFT_ARROW" events are working properly and intuitively. I also would like to give my deepest gratitude and thanks to those who corrected these abnormalities! KEEP UP THE GOOD WORK GUYS! > To repeat: I agree [that tab indention is bad], Raymond > Hettigner agrees, everyone seems to agree, and we all have > for years. http://bugs.python.org/issue7676 is over 4 > years old. But a patch can only implement a specific new > behavior, not just 'stop the old'. Just checked 3.4.1, and it is still using a tab for indention. I know this issue is going to be a bit more trouble to solve than the previous two "event" issues that i mentioned, however, i feel it is an important issue to solve. To understand *HOW* we might resolve this issue, *FIRST* we must understand the origins of the issue -- and as such, a few basic "rules" of how the IDLE shell "interacts" with a user is prerequisite. 1. The shell presents a prompt (in the case of the IDLE shell the prompt is ">>> "), as a "starting" point for interactive commands. 2. The user begins typing his command at the prompt... 2a. In the process of typing his command, each time the user presses the "ENTER" or "RETURN" keys (which i shall from now on refer to them *singularly* as the: "ER- KEYS"), the shell "intuits" whether the user intended to complete his command "at-the-current-line" *OR* that the user intends to "continue-writing-more-code", on subsequent lines. Note: As you can see the actions taken by pressing the "ER-KEYS" depend on the context in which they where pressed! If the command is "believed" to be *COMPLETE*, then the action will be: "evaluate the users command now and display a result", however, if the command is "believed" to be *INCOMPLETE*, the action will be: "allow the user to continue entering his command". 2b. If the "shell" believes that the user is finished writing his command, the shell will evaluate the *ENTIRETY* of the command (which could span one or more lines!) and then display the result of that evaluation *BENEATH* the command, however, if the shell "believes" that the user intends to "continue-writing-more-code", then the shell will allow the user to continue writing more code. STEP[N:]. There is much more to the interaction between "shells" and "users", however, these first two steps, and their subsequent "sub-steps", are all we need to concern ourselves with at this time, in order to solve *THIS* particular problem. Now, between the "shell" and its "user" exists a contract, and the preceding steps i outlined describe most of thast contract, however, i realized that i can describe the full contract more clearly by conflating the "shell" with "god" and the "user" as some poor disciple. If we view the contract through "the eyes of a *GODLIKE* shell" it might read something like: And the "shell" so-eth declared: Ye shall be presented with a prompt, and from that prompt thou shalt humbly enter requests. When i find thouest requests pleasing, i shall reward thou with my vast knowledge by displaying to you the result utilizing an esthetically pleasing shade of blue, HOWEVER, shall i find thou request to be illogical or malformed, i shall punish thou with furious displays of my rebukes, utilizing the "fear color" of *BLOOD* red! And thou shalt know my name is the SHELL! Furthermore, ye shall not be allowed to edit previous request, no matter how blasphemous they may be! No, they shall live as a testimate to thouest ignorance, a *PUBLIC* testiment for all to see -- until which time thou decideth to terminate our contract. Now that we understand the contract between "shells" and "users" we can focus in on the problem. The problem manifests itself when the user wants to write commands that span *MORE* than one line. For instance, when i write the first line of a "multi-line source code" like this: >>> for x in range(10): And then i press the "enter key", the current IDLE shell is going to insert a tab char (not good!), when it *SHOULD* have inserted a "buffer prompt" of some kind, and then calculated the correct "extrapolation-indentation" (by adding four to the indent of line #1, which is four!) for this new line of code. >>> for x in range(10): ... do_something Notice the "buffer prompt" of "... ", after which follows the "extrapolation indent" of " ", after which defines the *BEGINNING* of my next command of "do_something"? Seems simple enough huh? Oh but, my friend, *NOTHING* is simple in this damn community is it! ============================================================ Summary of the attempts to solve "INDENTION ISSUE" (at IDLE Bugs) ============================================================ The comments on how to solve this problem read like a book titled: "devils advocate for dummies". IDEA_1: Hey, lets just use 8 space indention for the *FIRST* level of indentation, and 4 space indention for any *SUBSEQUENT* levels of indentation, that would not solve the copy-paste problem *DIRECTLY*, however, it would RESPONSE_1: Shhhhh! Are you nuts! Be quiet! We cannot allow such easy remedies, because if we did, we would not need a bug tracker! No sir, this software dev team takes the protestant approach to problems -- we will suffer and we will like it!!! IDEA_2: Hey, lets just insert a "buffer prompt" for every line that is *NOT* the *FIRST LINE* of the command, and then use 4 spaces for indention... problem solved! RESPONSE_2: Hardly! Can't do that because people cannot be denied their "adolescent accessorizing" via font choice. How can you expect people to use *ONLY* mono-spaced fonts, i mean, geez, that's fascism! Besides, web-dings is vital for the those of us who need to encrypt our code so "peeping toms" cannot steal our snippets -- you never know who might be watching! >_> <_< IDEA_3: Hey, let's remove the embedded prompt from the main shell window altogether and display it in a separate "thin" area to the left -- sort of like how line numbers are displayed in other IDEs. This would solve the copy paste issue *AND* the indention issue. Plus, we can take credit for Ricks idea from circa 2005, nobody listens to him anyway! RESPONSE_2: You fool! That would require *ACTUAL* skills that we *DON'T* have. Only rr knows how to "lock" the scrolling events of two Tkinter widgets, plus, he'd have to change the underlying design of the entire shell contract in such a *DRAMATIC* fashion that he'd be better off just starting from scratch -- the IDLE source is a discombobulated mess! Does the IDLE bug-tracker exist to *SOLVE* problems or to *PERPETUATE* them? > If you are running your tkinter code in the same process > with Idle's tkinter code, either with ancient Idle or the > '-n' startup option (possibly buried in a script), the > situation is hopeless. If you are running your code in a > separate process (now the default), then, most likely, > Idle is not hanging. It is just waiting for your hung > process. If so, Shell / Restart shell (^F6) will end the > user process and start a new one. Now that i have the most current releases of both Python2 and Python3, i will use IDLE exclusively to determine if this "hanging issue" has been resolved, and if it has, i will go from IDLEs loudest dissenter, to it's most exuberant supporter. Granted, this "hanging" issue is not the *ONLY* remaining issue, however, it is the *SOLE* issue that has motivated me to stop using the software and write my own. I will only change my position once i have not experienced this nuance for a reasonable time... and only time will tell. > Use one of the startup options directly above to see if > you can get more information. A repeatable or at least > semi-repeatable failure case is needed to do anything. Yes. The very next time i get a hang, i'm going to post a test case for all to see, so we might figure this out. > > However, *EVEN* in the instances where a problem is a > > direct result of a "Tkinter NO-NO" (being witting or > > unwitting), the user of IDLE should *NEVER* be forced to > > kill processes > If you are talking about user processes, and we are > talking about patching Idle, as opposed to Python or the > OS (such as Windows), I disagree. If you are talking about > the Idle process, then yes, I would prefer that once Idle > starts, it run forever, and recover from any problems > caused by users. Roger Serwy fixed many Idle shutdowns > before being swallowed by a PhD program a year ago, but > there is more to do. My point is, that, when i run a Python program using "IDLE->Run->Run Program", i expect that IDLE is going to execute my program, catch any errors, and then report them to me. What i don't expect, is that IDLE is going to hang, freeze, churn, or totally go bonkers. If IDLE, which is written in Python, cannot understand when a Python program has failed, and take necessary actions to exit cleanly *OR* allow the user to *MANUALLY* exit cleanly at *ANY* time, then it is useless as an IDE, and should be "repackaged" and "sold" as a "texteditor(with aspirations of being an IDE one day)". IF YOU CAN'T RUN WITH THE BIG DOGS, STAY ON THE PORCH! PS: I do promise though to hold an optimistic view until proven otherwise. From rosuav at gmail.com Sat Jul 19 21:39:34 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 11:39:34 +1000 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sun, Jul 20, 2014 at 11:23 AM, Steven D'Aprano wrote: > If I recall correctly, it [Python under cmd.exe] is > missing any sort of command history or line editing other than backspace, Not quite, but it has some extreme oddities. I'd have to call them features because I can't imagine them to be bugs, but they're very surprising... like how you can recall something, but if you enter it without any editing, your "current recall position" is retained. This means you can re-enter a series of lines by recalling the first and then pressing Down, Enter for each subsequent line (it's a feature!), but it means that any usage where the lines are truly independent will start getting very awkward. In contrast, Idle recalls entire suites, rather than individual lines, which (IMO) makes it superior to a readline-based interface. ChrisA From rosuav at gmail.com Sat Jul 19 21:42:30 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 11:42:30 +1000 Subject: Improving Idle (was Re: Python 3 ...) In-Reply-To: <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 11:31 AM, Rick Johnson wrote: > Does the IDLE bug-tracker exist to *SOLVE* problems or to > *PERPETUATE* them? Definitely the latter. If it weren't for that tracker, bugs would just quietly die on their own. The PSU has a roster for feeding the bugs, changing their litter, and all other bug-related duties, and when someone goes on holidays and forgets to schedule a replacement, heaps of bugs just inexplicably die. (The PSU generally conceals this faux pas under the name of a "release".) ChrisA From steve+comp.lang.python at pearwood.info Sat Jul 19 21:41:40 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Jul 2014 01:41:40 GMT Subject: What's the proper style for a library string function? References: Message-ID: <53cb1e54$0$6574$c3e8da3$5496439d@news.astraweb.com> On Sat, 19 Jul 2014 10:38:47 -0700, C.D. Reimer wrote: > Greetings, > > I typically write a Python 2.7 string function in my library like this: > > def getCompletedTime(start, end): > return "Time completed:", str(end - start) > > And called it like this: > > print getCompletedTime(start, end) > > Since every Python script I write is executed from the command line, I > rewrote the string function like this: > > def getCompletedTime(start, end): > print "Time completed:", str(end - start) > > And call it like this: > > getCompletedTime(start, end) In general, I much prefer the first version. The general principle I follow is, as much as possible, to separate calculation from display. Advantages include: - You can easily re-use the getCompletedTime function in situations where you don't want to display the time, or pass the result on to another function for further processing before display. - It makes automated testing of the functions much easier. - It makes it easier to vary the type of display. Today you want to print to the standard output. Tomorrow you might want to output to a file, or display in a GUI window. - It makes it easier to understand the large-scale structure of your code. Seeing "print getCompletedTime(a, b)" makes it pretty clear that you are printing the result of the calculation, whereas "getCompletedTime(a, b)" does not. -- Steven From chris at cdreimer.com Sat Jul 19 21:53:02 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 18:53:02 -0700 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53CB20FE.6050300@cdreimer.com> On 7/19/2014 6:23 PM, Steven D'Aprano wrote: > I haven't used Python on Windows much, but when I did use it, I found > the standard Python interactive interpreter running under cmd.exe to > be bare- bones but usable for testing short snippets. If I recall > correctly, it is missing any sort of command history or line editing > other than backspace, which I guess it would have been painful to use > for extensive interactive work, but when I started using Python on > Linux the interactive interpreter had no readline support either so it > was just like old times :-) Windows PowerShell supports very basic Linux commands and has a command history. I'm always typing "ls" for a directory listing when I'm on a Windows machine. The regular command line would throw a DOS fit. PowerShell lets me get away with it. http://en.wikipedia.org/wiki/Windows_PowerShell#Comparison_of_cmdlets_with_similar_commands I prefer working on my vintage 2006 Black MacBook. Alas, the CPU fan is dying and MacBook shuts down after 15 minutes. I'm surprised at how well I was able to set up a equivalent programming environment on Windows. Chris Reimer From wingusr at gmail.com Sat Jul 19 22:03:01 2014 From: wingusr at gmail.com (TP) Date: Sat, 19 Jul 2014 19:03:01 -0700 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> References: <53C4A454.9010600@gmail.com> <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sat, Jul 19, 2014 at 12:28 AM, Steven D'Aprano < steve+comp.lang.python at pearwood.info> wrote: > For Python users, the IDEs from > Wingware and Activestate are notable: > > https://wingware.com/ > http://komodoide.com/ > I would say that since PyCharm (https://www.jetbrains.com/pycharm/) now has a free Community Edition it is an even more notable IDE as the above two programs cost $. And as a Windows user, for version control I really like TortoiseHg ( http://tortoisehg.bitbucket.org/) for Mercurial. Likewise I tend to use TortoiseSVN and TortoiseGit rather than the command line. PyCharm even has support for those but I still like right-clicking on folders in Windows Explorer and activating various hg commands from the popup menu. Especially since not every program I write is written in Python :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicholascannon1 at gmail.com Sat Jul 19 22:24:41 2014 From: nicholascannon1 at gmail.com (Jerry lu) Date: Sat, 19 Jul 2014 19:24:41 -0700 (PDT) Subject: Confused with Functions and decorators In-Reply-To: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <140fdf49-b4db-45a5-a52d-1b5ae89e7bd3@googlegroups.com> ok I seem to very confused about this. Is there like a page or web page that like completely sums this up so i can study. I am going to look up 'functions in python'. I am not sure if this is what we a talking about as a whole here but I'am sure that I'll find something. I am all good with decorators just I can't wrap my head around why we need a function within a function? like the outer and inner thing. for example if we have like: >>> def multi_squared(func): def multi(): return (func)**2 return math >>> >>>@math #does decorator go here or when we call the function??? >>>def number(x, y): return x*y is this above example valid? like this is the stuff i am stuck on like i know what todo or i think i know but not sure if it is perfectly valid. I am going to search for something now but if you know where i could find something like this or if you could sort it out that would be great. From rosuav at gmail.com Sat Jul 19 22:27:19 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 12:27:19 +1000 Subject: Confused with Functions and decorators In-Reply-To: <140fdf49-b4db-45a5-a52d-1b5ae89e7bd3@googlegroups.com> References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> <140fdf49-b4db-45a5-a52d-1b5ae89e7bd3@googlegroups.com> Message-ID: On Sun, Jul 20, 2014 at 12:24 PM, Jerry lu wrote: > ok I seem to very confused about this. Is there like a page or web page that like completely sums this up so i can study. I am going to look up 'functions in python'. Yep, look up stuff like that. I gave you some keywords to search for (web search - Google, Bing, Yahoo, whatever you're comfortable with) in my last email. They'll start you off with some of the important topics. ChrisA From nicholascannon1 at gmail.com Sat Jul 19 22:33:01 2014 From: nicholascannon1 at gmail.com (Jerry lu) Date: Sat, 19 Jul 2014 19:33:01 -0700 (PDT) Subject: Confused with Functions and decorators In-Reply-To: References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> <140fdf49-b4db-45a5-a52d-1b5ae89e7bd3@googlegroups.com> Message-ID: <6a3acf78-a7d8-4bb4-b6d7-0f08ce70613a@googlegroups.com> Ok thanks so much i really want to get good. I also found this MIT open course lectures for python. Is this good to use as a source of learning? I think it would because it is MIT. From chris at cdreimer.com Sat Jul 19 23:10:35 2014 From: chris at cdreimer.com (C.D. Reimer) Date: Sat, 19 Jul 2014 20:10:35 -0700 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> Message-ID: <53CB332B.3080000@cdreimer.com> On 7/19/2014 7:03 PM, TP wrote: > I would say that since PyCharm (https://www.jetbrains.com/pycharm/) > now has a free Community Edition it is an even more notable IDE as the > above two programs cost $. PyCharm look really nice as an IDE. Thanks for the heads up. Chris Reimer From shieldfire at gmail.com Sat Jul 19 23:29:36 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 20 Jul 2014 05:29:36 +0200 Subject: OT: usenet reader software In-Reply-To: References: <1215729054427502033.453669sturla.molden-gmail.com@news.gmane.org> Message-ID: <1a638cbb-cf43-4ab5-97e4-22095e365619@gmail.com> >From what I've seen so far it's more like your limited standard mail filtering tool. IIRC when I used Usenet much gnus on Emacs had much more powerful capabilities. /martin s On 20 Jul 2014, Mark Lawrence wrote: On 19/07/2014 23:38, Sturla Molden wrote: < cl at isbd.net> wrote: That doesn't address the problem at all! :-) You still need a news reader. The problem was that Thunderbird does not support killfiles when used as a newsreader. Leafnode adds filtering capabilities which Thunderbird (supposedly) does not have. Sturla So what does clicking on Message->Create filter from message... do exactly? -- Sent with K-@ Mail - the evolution of emailing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From shieldfire at gmail.com Sat Jul 19 23:07:00 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 20 Jul 2014 05:07:00 +0200 Subject: OT: usenet reader software In-Reply-To: References: <1215729054427502033.453669sturla.molden-gmail.com@news.gmane.org> Message-ID: <77f4ae0a-aecb-4719-b329-783cdfdfa87c@gmail.com> >From what I've seen so far it's more like your limited standard mail filtering tool. IIRC when I used Usenet much gnus on Emacs had much more powerful capabilities. /martin s On 20 Jul 2014, Mark Lawrence wrote: >On 19/07/2014 23:38, Sturla Molden wrote: >> wrote: >> >>> That doesn't address the problem at all! :-) You still need a news >>> reader. >> >> The problem was that Thunderbird does not support killfiles when used >as a >> newsreader. Leafnode adds filtering capabilities which Thunderbird >> (supposedly) does not have. >> >> Sturla >> > >So what does clicking on Message->Create filter from message... do >exactly? -- Sent with K-@ Mail - the evolution of emailing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From memilanuk at invalid.com Sat Jul 19 23:44:51 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Sun, 20 Jul 2014 03:44:51 +0000 (UTC) Subject: OT: usenet reader software References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <093d2303-9e7d-497e-bb85-b9f16d5d61af@gmail.com> Message-ID: On 2014-07-19, Martin S wrote: > Is there a point to still use Usenet? Last time I checked noise overwhelm > ed signal by a factor of something close to 542. Martin, Fair enough question. Seems like a lot of usenet groups have become spam-fests, and using it to d/l various binaries of questionable origin seems to be the major 'driving force' for a lot of people any more - for pure usenet. As others point out, you can filter the spam fairly easily with a good client program. You don't get (as much of) that kind of spam in forums, depending on the authentication process and the vigilance of the forum staff/moderators. I used to subscribe to a bunch of different Linux and programming-related mailing lists... some of which could run to several hundred messages per month *each*. Yeah, decent filters and storage can mute a lot of that, but not as effeciently as reading the groups via news.gmane.org which provides a mail2news gateway for a lot of mailing lists like this one. I don't have to receive or store all those messages anymore (most of which I skim the subject and then mark as read). That said, the irony that there seems to be a distinct *lack* of GUI usenet reader programs for Linux just kills me. Seems like its either Pan, or knode if you're into KDE. Otherwise... you get to go dredge up old CLI programs like this one (slrn). Works pretty well (better than I remember, actually) but still... having to exit the program and restart it to open a different server is *very* old-school :/ From memilanuk at invalid.com Sat Jul 19 23:48:39 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Sun, 20 Jul 2014 03:48:39 +0000 (UTC) Subject: OT: usenet reader software References: <32rp9b-nsu.ln1@chris.zbmc.eu> Message-ID: On 2014-07-19, cl at isbd.net wrote: > memilanuk wrote: >> >> Guess where I'm going with this is... is there anything out there worth >> trying - on Linux - that I'm missing? >> > If slrn was a maybe then there's also tin for text mode news readers, > it's what I have always used. I don't know what it does with HTML as > none of the groups I frequent ever have any HTML in them. > > It does add one 'GUIness' to its text mode, it's mouse aware so you > can click on messages in a list to open them. slrn does have that option as well... just needs turned on (its off by default) in the config file. I seem to recall it not working so hot... but I tried it on a link in a post last night and it worked like a peach. For whatever reason I never really tried tin (or trn). I might have to give them a whirl... though I must say that using slrn seems kind of like riding a bicycle... my fingers apparently remember more than my brain does ;) From timothy.c.delaney at gmail.com Sun Jul 20 00:18:54 2014 From: timothy.c.delaney at gmail.com (Tim Delaney) Date: Sun, 20 Jul 2014 14:18:54 +1000 Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: <53CB20FE.6050300@cdreimer.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> <53CB20FE.6050300@cdreimer.com> Message-ID: On 20 July 2014 11:53, C.D. Reimer wrote: > > On 7/19/2014 6:23 PM, Steven D'Aprano wrote: > >> I haven't used Python on Windows much, but when I did use it, I found the >> standard Python interactive interpreter running under cmd.exe to be bare- >> bones but usable for testing short snippets. If I recall correctly, it is >> missing any sort of command history or line editing other than backspace, >> which I guess it would have been painful to use for extensive interactive >> work, but when I started using Python on Linux the interactive interpreter >> had no readline support either so it was just like old times :-) >> > > Windows PowerShell supports very basic Linux commands and has a command > history. I'm always typing "ls" for a directory listing when I'm on a > Windows machine. The regular command line would throw a DOS fit. PowerShell > lets me get away with it. > > http://en.wikipedia.org/wiki/Windows_PowerShell#Comparison_ > of_cmdlets_with_similar_commands > > I prefer working on my vintage 2006 Black MacBook. Alas, the CPU fan is > dying and MacBook shuts down after 15 minutes. I'm surprised at how well I > was able to set up a equivalent programming environment on Windows. I advise anyone who works cross-platform to install MSYS on their Windows boxes (for the simplest, most consistent behaviour ignore rxvt and just launch bash -l - i directly). Or use cygwin if you prefer. Tim Delaney -------------- next part -------------- An HTML attachment was scrubbed... URL: From rosuav at gmail.com Sun Jul 20 00:21:04 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 14:21:04 +1000 Subject: OT: usenet reader software In-Reply-To: References: <878077080427409149.032995sturla.molden-gmail.com@news.gmane.org> <207103364427412353.673868sturla.molden-gmail.com@news.gmane.org> <093d2303-9e7d-497e-bb85-b9f16d5d61af@gmail.com> Message-ID: On Sun, Jul 20, 2014 at 1:44 PM, Monte Milanuk wrote: > That said, the irony that there seems to be a distinct *lack* of GUI > usenet reader programs for Linux just kills me. Seems like its either Pan, > or knode if you're into KDE. Otherwise... you get to go dredge up old > CLI programs like this one (slrn). Works pretty well (better than I > remember, actually) but still... having to exit the program and restart > it to open a different server is *very* old-school :/ When I wanted to post a question to sci.math, I ended up with Xpn, which seems decent. Got it from the Debian Wheezy repo, so it's convenient to grab. Out of curiosity I just now went back there, found the thread I'd started (no new posts), and skimmed everything that had come in since then. What I'm seeing is: 1) Heaps of threads by one John Gabriel, which have in several cases been followed up with public service announcements saying "CRANK ALERT". He seems to be the sci.math equivalent of either Ranting Rick or jmf... but worse than either by a significant margin. Seriously, he makes me happy about how well-off c.l.p is. 2) Other "crank" threads, boasting of how Newton is right and Einstein wrong, or something. I'm not sure if Archimedes Plutonium is an alias of John Gabriel or not, but I can't be bothered reading the threads to find out. 3) Straight-up spam about adwords, "Islam is not a Religion of Extremism" (which comes through to c.l.p too, and even crosses the boundary to python-list at times; I see some of that in my Gmail spam box), etc 4) A few homework problems, again similar to what we see here 5) About two threads, and this across roughly two and a half weeks, that are actually interesting and potentially useful. I might be overstating the problem a bit; a sci.math regular might read a bunch of them and find that a few more are useful than the ones that I picked out based on their subject lines. But certainly there is a LOT of spam there. Not as much as there is utter junk that isn't spam (ridiculous crank-posted rubbish outnumbers spam threads by probably 3:1 or more), but still a lot of spam. ChrisA From rosuav at gmail.com Sun Jul 20 00:23:45 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 14:23:45 +1000 Subject: OT: usenet reader software In-Reply-To: References: <32rp9b-nsu.ln1@chris.zbmc.eu> Message-ID: On Sun, Jul 20, 2014 at 1:48 PM, Monte Milanuk wrote: > For whatever reason I never really tried tin (or trn). I might have to > give them a whirl... though I must say that using slrn seems kind of > like riding a bicycle... my fingers apparently remember more than my > brain does ;) Heh, totally. I go back to an old game for some reason, and my fingers know exactly what the Quick Save key is. My brain knows that there are function keys for quick save and quick load in a lot of programs, but is never sure which is which (and it'd be pretty bad to hit the wrong one)... but my fingers always get it right. F1 and F4 for American McGee's Alice, and F9 and F10 for Captain Bible... F6 in C&C Renegade (that one's easy, there's no quick load)... Ctrl-X in Angband, although that doesn't quite count... yep, my fingers know them a lot better than my brain does. ChrisA From greg.ewing at canterbury.ac.nz Sun Jul 20 01:32:15 2014 From: greg.ewing at canterbury.ac.nz (Gregory Ewing) Date: Sun, 20 Jul 2014 17:32:15 +1200 Subject: Repo/directory names (was Re: Python and IDEs [was Re: Python 3 is killing Python]) In-Reply-To: References: Message-ID: Chris Angelico wrote: > Other people had, for instance, a C:\BELFRY (best place to have BATs, > you know), or other such names. What's your favorite > directory/repository name for a concretion of ... random stuff? My project directories typically contain a directory called "Attic" for putting stuff in that I probably won't use any more, but want to keep just in case. Fortunately, it doesn't have the same space restrictions as its physical namesake. :-) -- Greg From steve+comp.lang.python at pearwood.info Sun Jul 20 02:41:08 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 20 Jul 2014 06:41:08 GMT Subject: Confused with Functions and decorators References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <53cb6484$0$6574$c3e8da3$5496439d@news.astraweb.com> On Sat, 19 Jul 2014 03:52:18 -0700, Jerry lu wrote: > Ok so i am trying to learn this and i do not understand some of it. I > also tried to searched the web but i couldnt find any answers. > > 1. I dont understand when i will need to use a function that returns > another function. eg > def outer(): > def inner(): > x = 5 > return inner > > why not just use inner and forget about the whole outer function? For the example given, there's no point in using an inner function. (Especially since the inner function does nothing useful.) But there are three common reasons for writing inner functions: #1 Encapsulation and information hiding. If you've ever programmed in Pascal, this may be familiar to you. You use inner functions to hide them away from code outside of the function. Here is a toy example that shows the basic idea: def function(x): def increment(x): return x + 1 y = increment(x) print x, y In Python, I would rarely bother to write code like that. I'd just make the increment function a top-level function, marked as "private" with a leading underscore: _increment. One place where the Pascal-style nested function may be useful is with recursive functions: def factorial(n): if not isinstance(n, int): raise TypeError("n must be an integer") if not n >= 0: raise ValueError("n must be zero or positive") def inner_fact(n): if n <= 1: return 1 return n*inner_fact(n-1) return inner_fact(n) This has three advantages: * The caller cannot (easily) bypass the outer function and call the inner function directly. * The outer function performs all the argument checking and any pre- processing once only, the inner function can safely assume the argument is valid and eschew pointless error checking. * The outer function can be renamed without breaking the recursion. #2 Don't Repeat Yourself (DRY) Sometimes you may have a big function that performs the same chunk of code in two places. For example, you might write a function which processes a file, and you want to accept either an open file object or a file name: def process(the_file): def do_stuff(fp): for line in fp: print line if isinstance(the_file, str): with open(the_file, 'r') as f: do_stuff(f) else: do_stuff(the_file) Again, it is common to put do_stuff as a private top-level function, but if you want to hide it away as an internal function, you can. #3 Closures and factory functions But now we come to the most important reason to use internal functions. All of the inner functions I've shown so far have been ordinary functions that merely happened to be nested inside another function. But when we come to closures, that is not the case. A closure is an inner function which "remembers" the state of its environment when called. Here's a basic example: def make_incrementer(inc): """Make an new function which increments its argument by inc. Examples of use: >>> add_one = make_incrementer(1) >>> add_two = make_incrementer(2) >>> add_one(7) 8 >>> add_two(7) 9 """ def incrementer(x): return x + inc return incrementer This takes more effort to explain than to write! The "make_incrementer" function is a *factory function*. It builds a new function each time it is called, then returns it. What does this new, inner, function do? It takes a single argument, x, and returns x + inc. Where does the inner function get the value of inc from? This is what makes it a closure -- it gets the value of inc from the outer function, the factory. How it works is something like like this: make_incrementer(3) => build a function "incrementer" which takes a single argument x => take a snap-shot of the state of make_incrementer function which includes inc=3 => stuff that snap-shot into the incrementer function => return the incrementer function Now, whenever you call that newly returned function, it will always see its own private snap-shot that includes inc=3. The use of closures and factory functions is the most common, and powerful, use for inner functions. 9 times out of 10, if you see a decoratored function: @decorator def func(arg): pass the decorator is a factory function which takes an function as argument, and returns a new function which which includes the old function inside the closure. But that's now getting into more advanced territory. > 2. This is more yes or no question when you pass in a func into another > func as a parameter do you need to specify the parameter that the func > is being passed into as func? No. You can pass functions around from place to place until the cows come how, stuff them into lists and dicts, extract them again, and not care one iota about its arguments until you actually call it. -- Steven From shieldfire at gmail.com Sun Jul 20 05:40:15 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 20 Jul 2014 11:40:15 +0200 Subject: stripping (from item in list) Message-ID: While preparing to my gui to the app I made I thought it would be nice to be able to parse a text file with results using the same tool. So: I read a result file to a list, and every record gets appended with "\n" ... OK, so I look up how to remove it. And this doesn't work while c >=0: x=games[c][0] if x=="#": del games[c] #This removes the comments from the file parsed else: games[c].rstrip('\n') #This does nothing, expected to remove \n c=c-1 # Now we have a list with only proper lines While all records in the remaining list now are valid, all also still have "\n" at the end. What did I miss here? Regards, Martin S From rosuav at gmail.com Sun Jul 20 05:57:30 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 19:57:30 +1000 Subject: stripping (from item in list) In-Reply-To: References: Message-ID: On Sun, Jul 20, 2014 at 7:40 PM, Martin S wrote: > games[c].rstrip('\n') #This does nothing, expected to remove \n > > While all records in the remaining list now are valid, all also still > have "\n" at the end. What did I miss here? Strings don't change. When you call rstrip(), it returns a new string which is the stripped value. You'll need to slot that back in: games[c] = games[c].rstrip('\n') However, there may be a better way to do this - possibly a cleaner parser. ChrisA From shieldfire at gmail.com Sun Jul 20 06:06:03 2014 From: shieldfire at gmail.com (Martin S) Date: Sun, 20 Jul 2014 12:06:03 +0200 Subject: stripping (from item in list) In-Reply-To: References: Message-ID: Craps should have guessed that was the problem. Must have misunderstood the examples. But thanks =) And yes, definately should be able to build a better parser ... I want it to work first. /Martin S 2014-07-20 11:57 GMT+02:00 Chris Angelico : > On Sun, Jul 20, 2014 at 7:40 PM, Martin S wrote: >> games[c].rstrip('\n') #This does nothing, expected to remove \n >> >> While all records in the remaining list now are valid, all also still >> have "\n" at the end. What did I miss here? > > Strings don't change. When you call rstrip(), it returns a new string > which is the stripped value. You'll need to slot that back in: > > games[c] = games[c].rstrip('\n') > > However, there may be a better way to do this - possibly a cleaner parser. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list -- Regards, Martin S From rosuav at gmail.com Sun Jul 20 06:07:54 2014 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 20 Jul 2014 20:07:54 +1000 Subject: stripping (from item in list) In-Reply-To: References: Message-ID: On Sun, Jul 20, 2014 at 8:06 PM, Martin S wrote: > And yes, definately should be able to build a better parser ... I want > it to work first. Fair enough. That's why I answered your actual question before mentioning that as a tacked-on almost postscript. :) ChrisA From subhabangalore at gmail.com Sun Jul 20 07:15:30 2014 From: subhabangalore at gmail.com (subhabangalore at gmail.com) Date: Sun, 20 Jul 2014 04:15:30 -0700 (PDT) Subject: Writing Python File at Specific Interval In-Reply-To: References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> Message-ID: <2c676709-ac9d-4623-971a-f6d089818601@googlegroups.com> On Thursday, July 10, 2014 5:21:01 AM UTC+5:30, Denis McMahon wrote: > On Wed, 09 Jul 2014 07:36:49 -0700, subhabangalore wrote: > > > > > The code (a basic crawler) would run every morning or evening, on a > > > predefined time. [This part is fine]. > > > > > > In the next part, I am trying to store the daily results to a new file. > > > > So what you want to do is store each day's results in a new file, so > > probably you want to create a filename that looks something like an iso > > 8601 date. > > > > Luckily for you python has this functionality available: > > > > https://docs.python.org/2/library/datetime.html#date-objects > > > > $ python > > Python 2.7.3 (default, Feb 27 2014, 19:58:35) > > [GCC 4.6.3] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> from datetime import date > > >>> fn = date.today().isoformat() + ".log" > > >>> print fn > > 2014-07-10.log > > >>> quit() > > $ > > > > Once you have a string containing your filename, you might use: > > > > fp = open( fn, "w" ) > > fp.write( data ) > > fp.close() > > > > -- > > Denis McMahon, denismfmcmahon at gmail.com Dear Group, Thank you for your kind suggestion. It worked. Regards, Subhabrata Banerjee. From breamoreboy at yahoo.co.uk Sun Jul 20 07:40:09 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 20 Jul 2014 12:40:09 +0100 Subject: Improving Idle (was Re: Python 3 ...) In-Reply-To: References: <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 20/07/2014 02:42, Chris Angelico wrote: > On Sun, Jul 20, 2014 at 11:31 AM, Rick Johnson > wrote: >> Does the IDLE bug-tracker exist to *SOLVE* problems or to >> *PERPETUATE* them? > > Definitely the latter. If it weren't for that tracker, bugs would just > quietly die on their own. The PSU has a roster for feeding the bugs, > changing their litter, and all other bug-related duties, and when > someone goes on holidays and forgets to schedule a replacement, heaps > of bugs just inexplicably die. (The PSU generally conceals this faux > pas under the name of a "release".) > > ChrisA > An alternative is that the PSU wait until some raving lunatic, sado-masochistic nutter who actually likes triaging comes only and bumps some of the sillier, lonely bugs, e.g a three year old failing test case on a buildbot. Result, bug is closed as out of date. Click on the stats link at bugs.python.org and observe the result of this crazy type of behaviour. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From breamoreboy at yahoo.co.uk Sun Jul 20 07:46:18 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 20 Jul 2014 12:46:18 +0100 Subject: Writing Python File at Specific Interval In-Reply-To: <2c676709-ac9d-4623-971a-f6d089818601@googlegroups.com> References: <33d2582e-06b6-4cb9-8d60-7f94aa32283c@googlegroups.com> <2c676709-ac9d-4623-971a-f6d089818601@googlegroups.com> Message-ID: On 20/07/2014 12:15, subhabangalore at gmail.com wrote: > > Dear Group, > Thank you for your kind suggestion. It worked. > Regards, > Subhabrata Banerjee. > I'm pleased to see that you have a solution. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single line paragraphs, thanks. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From khamenya at gmail.com Sun Jul 20 08:16:24 2014 From: khamenya at gmail.com (Valery Khamenya) Date: Sun, 20 Jul 2014 14:16:24 +0200 Subject: Anything better than asyncio.as_completed() and asyncio.wait() to manage execution of large amount of tasks? In-Reply-To: References: Message-ID: Hi Maxime, many thanks for your great solution. It would be so great to have it in stock asyncio and use it out-of-the-box... I've made 4 fixes to it that are rather of "cosmetic" nature. Here is the final version: import asyncio from concurrent import futures def as_completed_with_max_workers(tasks, *, loop=None, max_workers=5, timeout=None): loop = loop if loop is not None else asyncio.get_event_loop() workers = [] pending = set() done = asyncio.Queue(maxsize=max_workers, loop=loop) # Valery: respect the "loop" parameter exhausted = False timeout_handle = None # Valery: added to see, if we indeed have to call timeout_handle.cancel() @asyncio.coroutine def _worker(): nonlocal exhausted while not exhausted: try: t = next(tasks) pending.add(t) yield from t yield from done.put(t) pending.remove(t) except StopIteration: exhausted = True def _on_timeout(): for f in workers: f.cancel() workers.clear() # Wake up _wait_for_one() done.put_nowait(None) @asyncio.coroutine def _wait_for_one(): f = yield from done.get() if f is None: raise futures.TimeoutError() return f.result() workers = [asyncio.async(_worker(), loop=loop) for _ in range(max_workers)] # Valery: respect the "loop" parameter if workers and timeout is not None: timeout_handle = loop.call_later(timeout, _on_timeout) while not exhausted or pending or not done.empty(): yield _wait_for_one() if timeout_handle: # Valery: call timeout_handle.cancel() only if it is needed timeout_handle.cancel() best regards -- Valery A.Khamenya -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjreedy at udel.edu Sun Jul 20 13:15:58 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 13:15:58 -0400 Subject: stripping (from item in list) In-Reply-To: References: Message-ID: On 7/20/2014 5:40 AM, Martin S wrote: > while c >=0: > x=games[c][0] > if x=="#": > del games[c] #This removes the comments from the file parsed > else: > games[c].rstrip('\n') #This does nothing, expected to remove \n Chris already pointed out error here. > c=c-1 > # Now we have a list with only proper lines I believe what you are aiming for is games = [line.rstrip('\n') for line in games if line[0] != '#'] -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sun Jul 20 17:14:09 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 20 Jul 2014 14:14:09 -0700 (PDT) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! Message-ID: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> ============================================================ BUG 1: FileDialog Duplicity: ============================================================ If you open the IDLE application (either utilizing the "shell window" or "editor window") and then go to the "File" menu and choose the "Open" command you will see a file dialog appear, okay, nothing wrong with that. HOWEVER, if you go to the "File" menu *AGAIN* choose the "Open" command, you will see *ANOTHER* file dialog open. Note that on windows (at least), the new file dialogs are stacked *perfectly* on top of old filedialogs, so you will need to move the top dialog before you can see any hiding below. And not only can you open more than one dialog ,there seems to be no limit on the number of dialogs you can open! Modal dialogs *MUST* be limited to a "one dialog at a time" policy. And even *IF* the designers of Tkinter were too naieve to relize this, the designers of IDLE should have been intelligent enough to ensure this cannot happen, because, opening more than one filedialog is about has useful as buying shoes in sets of greater than two. Two feet -> two shoes. One document -> one dialog or rather, One dialog per "active" document! And since IDLE is not a "tabbed editor", only *1* document is going to be displayed at a time. The troubling issue is, Tkinter filedialogs are working fine (see my code at the end of this message which proves my statement!), whereas the IDLE dialogs which utilize Tkinter code are not! ============================================================ POSSIBLE FIX FOR "BUG 1": ============================================================ If for some reason IDLE is not using the tkFileDialogs, a simple "request contract" can solve the issue by setting a "counter variable" like "activeFileDialogs = 0", then incrementing the counter by 1 each time a filedialog is displayed, and then decrementing the value by one each time a filedialog is closed. Furturemore, each time a filedialog is "requested", the logic will deny the request *IF* the value of "activeFileDialogs" is greater than one. However, this all seems rediculous since Tkinter filedialogs are working as expected! (see code at end of this message) ============================================================ BUG 2: FileDialog "Hide and go seek": ============================================================ When you have a filedialog displayed *AND* the "parent window" from which you spawned the filedialog is in "full screen" mode, if you (or your OS) decides to "unfocus" the "parent window" window, when you return you will *NOT* see the open dialog, because the filedialog will be hidden *BEHIND* the full screen "parent window". Again, this only happens in IDLE, but in my example code at the end of this message you will find that the dialog behaves as expected. ============================================================ BUG 3: FileDialog not using "native" dialogs anymore. ============================================================ Currently, when opening a filedialog in IDLE, i don't get the "shortcut pane" that is visible in my Windows Explorer application, *HOWEVER*, before i updated to version 2.7.8 i swear it was there! WHAT THE HECK HAPPNED? ============================================================ REFERENCES: ============================================================ ############################################################ # BEGIN CODE ############################################################ # The following code proves that Tkinter filedialogs are # behaving in expected manners (properly placed as children # of the windows which "own" them, and following normal # focus patterns of "child windows" -- therfore, the problem # *MUST* be an IDLE problem. # # Tested on Python 2.7.8 # import Tkinter as tk from tkFileDialog import askopenfilename, asksaveasfilename class App(tk.Tk): def __init__(self): tk.Tk.__init__(self) self._createMenus() def _createMenus(self): menubar = tk.Menu(self) self.config(menu=menubar) filemenu = tk.Menu(menubar) menubar.add_cascade(label='File', menu=filemenu) filemenu.add_command(label='Open', command=self.requestOpenDialog) filemenu.add_command(label='Save As', command=self.requestSaveAsDialog) def _requestFileDialog(self, func, **kw): path = func(**kw) return path def requestOpenDialog(self, **kw): return self._requestFileDialog(askopenfilename, **kw) def requestSaveAsDialog(self, **kw): return self._requestFileDialog(asksaveasfilename, **kw) if __name__ == '__main__': app = App() app.mainloop() # ############################################################ # END CODE ############################################################ From breamoreboy at yahoo.co.uk Sun Jul 20 17:36:50 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Sun, 20 Jul 2014 22:36:50 +0100 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> Message-ID: On 20/07/2014 22:14, Rick Johnson wrote: > [loads of stuff snipped] Why bother writing all that here, why not put it all on the bug tracker, or has that already been done, either by you or someone else? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From irmen.NOSPAM at xs4all.nl Sun Jul 20 17:40:59 2014 From: irmen.NOSPAM at xs4all.nl (Irmen de Jong) Date: Sun, 20 Jul 2014 23:40:59 +0200 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> Message-ID: <53cc376e$0$2898$e4fe514c@news.xs4all.nl> On 20-7-2014 23:14, Rick Johnson wrote: > And since IDLE is not a "tabbed editor", only *1* document > is going to be displayed at a time. False. Idle opens any number of documents at the same time just fine (in different windows - rather than tabs). While I don't see the use case for the possibility of having multiple file dialogs open at the same time, it doesn't really hurt either does it? > ============================================================ > BUG 3: FileDialog not using "native" dialogs anymore. > ============================================================ > > Currently, when opening a filedialog in IDLE, i don't get > the "shortcut pane" that is visible in my Windows Explorer > application, *HOWEVER*, before i updated to version 2.7.8 i > swear it was there! Not sure what you mean. What's the "shortcut pane"? I do notice that my Idle from Python 3.4.1 does indeed not use a native file dialog, it has a weird icon bar at the left side (win xp era layout?) My idle from 2.7.6 (haven't upgraded yet) uses the native explorer dialog. That is odd indeed. Maybe there's a reason for it, maybe it's a bug, I don't know. Irmen From tjreedy at udel.edu Sun Jul 20 17:52:36 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 17:52:36 -0400 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 7/19/2014 9:31 PM, Rick Johnson wrote: > On Saturday, July 19, 2014 3:45:07 PM UTC-5, Terry Reedy wrote: Idle's Shell currently uses a primary prompt ('>>> '), no secondary prompt*, and tabs for indents. This is a compromise between conflicting goals. It works but perhaps we can do better. * The third paragraph below explains that Shell's prompt is a statement prompt rather than line prompt, so that a secondary line prompt would not be appropriate. The problem with tabs is that tk displays them as a jump to the next 'tab stop'. For fixed pitch fonts, the virtual tab stops are set at 8 space intervals. For proportional fonts, I suspect the spacing is 8 em quads, where an em quad is the height of the font, which is also about the width of the widest character. An em quad is much larger than the width of a space character, perhaps 4x larger and perhaps 1.5 times the average width. Because of no secondary prompt, the first fixed-pitch indent looks like an indent of 4 spaces after a 'secondary prompt' of ' ', while subsequent indents are really 8 spaces. The indents appear are uneven and the subsequent indents chew up screen width too quickly. For proportional fonts, the problem is worst as the indents are about 12 characters. >> http://bugs.python.org/issue7676 > indention. I know this issue is going to be a bit more > trouble to solve than the previous two "event" issues > > To understand *HOW* we might resolve this issue, *FIRST* we > must understand the origins of the issue The problem originates in differences between the console - interactive python interaction and Idle Shell - execution server interaction. Interactive python prints prompts to and reads lines from the console. Once the user submits a line by hitting return, it cannot be edited. (This is true on Widows. Could any linux and mac user confirm for their systems?) The Idle Shell is much more active than at least the Windows console, and it is statement rather than line oriented. This is the important point. The Shell '>>> ' prompt is prompting for a complete statement, not a single line. This difference of meaning should be documented if it is not now. Until a user indicates that a statement is completed, the user can edit *any* part of the statement, not just the last line. While Shell monitors keystrokes and modifies the text accordingly with color and indents, it does not send the statement to the execution server, which is running idle code in batch-mode python, until the statment is complete. The execution server then exec()s the statement inside the Executive.run_code method and sends and response back. Being able to enter, edit, and recall complete statements is an valuable Shell feature. > The problem manifests itself when the user wants to write > commands that span *MORE* than one line. Right. Multiline statement issues go away when a statement is a single line. Now to the ideas on the tracker. > IDEA_1: Hey, lets just use 8 space indention for the Or a tab for the first indent (this works if consistent) > *FIRST* level of indentation, and 4 space indention for > any *SUBSEQUENT* levels of indentation, I am considering this as an option when the font is fixed pitch. > that would not solve the copy-paste problem *DIRECTLY*, The advantage of a single tab is that it is easy to turn it into 4 spaces either in a custom copy or after pasting. > IDEA_2: Hey, lets just insert a "buffer prompt" for every > line that is *NOT* the *FIRST LINE* of the command, and > then use 4 spaces for indention... problem solved! > > RESPONSE_2: Hardly! Can't do that because people cannot be > denied their "adolescent accessorizing" via font choice. This idea, and your response, ignores the fact that Shell is *statement* oriented. Inserting a secondary prompts inside statement text would mean that they would have to first be protected from user editing and then deleted by Idle before the statement is sent to the Executive. > IDEA_3: Hey, let's remove the embedded prompt from the > main shell window altogether and display it in a separate > "thin" area to the left -- sort of like how line numbers > are displayed in other IDEs. This would solve the copy paste > issue *AND* the indention issue. http://bugs.python.org/issue17535 GSOC Idle student Saimadhav Heblekar has worked on adding *optional* line numbers to Idle editor windows. I plan to adapt the final patch to the shell with, for instance '>>> ' and 'out:' labels. As I said on the tracker, I think that output that is no longer dedented with respect to input will then need some more to distinguish it. For my copy of Idle, I have added blue and red background tint to standard and error output and I think that works well. > we can take credit for Ricks idea from circa 2005, Ideas don't count until recorded on the tracker. > RESPONSE_2: You fool! That would require *ACTUAL* skills > that we *DON'T* have. Only rr knows how to "lock" the > scrolling events of two Tkinter widgets, Saimadhav has locked together a thin canvas with the text for line numbers. It works in all my texts. I am just waiting for him to try it with a thin text instead. If you know some secret you think he missed. please describe it here. Idea 4 (which I already suggested on the tracker). Put statement input prompts and output separators on lines by themselves. As with 3. above, use standard 4 space indents, as with >>>: def f(x): if x: print('got it') return 'something' >>>: f(3) --- got it >>>: Idle users other than Rick, any comments on the possible improvements? -- Terry Jan Reedy From rantingrickjohnson at gmail.com Sun Jul 20 18:44:49 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 20 Jul 2014 15:44:49 -0700 (PDT) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <53cc376e$0$2898$e4fe514c@news.xs4all.nl> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> Message-ID: <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> On Sunday, July 20, 2014 4:40:59 PM UTC-5, Irmen de Jong wrote: > On 20-7-2014 23:14, Rick Johnson wrote: > > And since IDLE is not a "tabbed editor", only *1* > > document is going to be displayed at a time. > False. Idle opens any number of documents at the same time > just fine (in different windows - rather than tabs). Yes, your statement is true, and here are a few facts about the IDLE interface that support your statement: 1. IDLE allows the "spawning" of an unlimited number of "IDLE editor windows", which each "editor window" acting as a (potential) container for a document -- which "loosely" emulates (albeit in a discombobulated manner) a "tabbed editor". 2. IDLE also allows one *OPTIONAL* instance of the "IDLE shell window" to exist. > While I don't see the use case for the possibility of > having multiple file dialogs open at the same time, it > doesn't really hurt either does it? Actually yes, it does, for the reasons i explained in my OP: Filedialogs should be "truly modal", and like any modal dialog, should present themselves to the user utilizing blocking -- that is the whole point of "modal dialogs", to *BLOCK* further execution of the application *UNTIL* the user provides (generally speaking) an "answer" to a "question". In order to facilitate *SMOOTH* interfacing between the user and the modal dialog, the "contract of modal dialogs" must be strictly obeyed: When presented with a modal dialog, a user is given only two choices -- he must *interact* with the dialog, or he must cancel the dialog. During the time which the dialog is displayed, all attempts by the user to unfocus, minimize, or otherwise exit the dialog will not be allowed -- except via the *explicitly* defined interaction mechanisms of the dialog itself, for instance, via "okay" and "cancel" buttons. So, even if IDLE does allow multiple "editor windows" to exists concurrently, allowing multiple filedialogs to exist concurrently is not only un-useful, it is downright confusing. GUI programming has been around for decades, so there is no excuse for us not creating smooth interactions between a user and his modal dialogs. > Not sure what you mean. What's the "shortcut pane"? I do > notice that my Idle from Python 3.4.1 does indeed not use > a native file dialog, it has a weird icon bar at the left > side (win xp era layout?) Yes, that is the legacy "shortcut bar" i'm referring to! Before upgrading, IDLE was utilizing the more updated version of windows explorer that includes quite a few personalized shortcuts. From rosuav at gmail.com Sun Jul 20 20:55:02 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 10:55:02 +1000 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 7:52 AM, Terry Reedy wrote: > On 7/19/2014 9:31 PM, Rick Johnson wrote: > The problem originates in differences between the console - interactive > python interaction and Idle Shell - execution server interaction. > Interactive python prints prompts to and reads lines from the console. Once > the user submits a line by hitting return, it cannot be edited. (This is > true on Widows. Could any linux and mac user confirm for their systems?) If you mean that individual lines are separately edited, then yes, that's the same on Linux. > The Idle Shell is much more active than at least the Windows console, and it > is statement rather than line oriented. This is the important point. The > Shell '>>> ' prompt is prompting for a complete statement, not a single > line. This difference of meaning should be documented if it is not now. This is, in fact, Idle's greatest feature IMO. The ability to recall, edit, and resubmit an entire function/class definition as a single unit. > The advantage of a single tab is that it is easy to turn it into 4 spaces > either in a custom copy or after pasting. If you're weighing up those two options specifically, I would tip the balance toward a custom copy. If you paste into some other application, it would be more consistent to work with four spaces for every indentation level, rather than having every line begin with a tab and then some spaces. > This idea, and your response, ignores the fact that Shell is *statement* > oriented. Inserting a secondary prompts inside statement text would mean > that they would have to first be protected from user editing and then > deleted by Idle before the statement is sent to the Executive. The secondary prompts are actually quite annoying in copy/paste. Anything that suppresses them is a distinct advantage IMO. > As I said on the tracker, I think that output that is no longer dedented > with respect to input will then need some more to distinguish it. For my > copy of Idle, I have added blue and red background tint to standard and > error output and I think that works well. I'd have to have a look and see how that feels before I can judge properly, but the notion of output not being indented by a prompt is one that's found on... well, pretty much everything. Most command-line interfaces work that way. Good MUD clients work hard to make sure that the user's input is correctly indented by the prompt, even if the two are quite separate in chronology; if you use input("........") and print(), you'll end up with the same kind of interface. Explaining the difference in color will be different, so it'll have to work extra well to make up for that. Also, you can copy and paste into an email, which will lose color. Count me dubious but reserving judgment. >> RESPONSE_2: You fool! That would require *ACTUAL* skills >> that we *DON'T* have. Only rr knows how to "lock" the >> scrolling events of two Tkinter widgets, > > Saimadhav has locked together a thin canvas with the text for line numbers. > It works in all my texts. I am just waiting for him to try it with a thin > text instead. > > If you know some secret you think he missed. please describe it here. Huh, is combined scrolling really such an amazing thing? Only one person in the whole world knows how to do it? So.... like this: http://www.phdcomics.com/comics/archive.php?comicid=1723 http://catb.org/esr/writings/unix-koans/mcse.html Considering that some GUI toolkits have that functionality as a core feature (GTK scrolling is a bit more complex to support this exact concept), I would be very much surprised if exactly one person knows how to do it in Tk. > Idea 4 (which I already suggested on the tracker). Put statement input > prompts and output separators on lines by themselves. As with 3. above, use > standard 4 space indents, as with > >>>>: > def f(x): > if x: > print('got it') > return 'something' > >>>>: > f(3) > --- > got it >>>>: > > Idle users other than Rick, any comments on the possible improvements? I can't comment on how it interacts with the editor half of Idle, but for the shell as a stand-alone app, and for copying and pasting into other programs, this last idea is rather interesting. I'm broadly happy with the current system (>>> def f(x):), and the prompt is a little weird (">>>:"? but maybe "Python:" would be less weird; I don't advise "Idle:" as it implies that something is idle that might be busy), but this would make copy/paste that bit easier. It would tend to de-emphasize the difference between input and output, though, which may or may not be an issue. But definitely interesting. ChrisA From python.list at tim.thechases.com Sun Jul 20 20:56:40 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 20 Jul 2014 19:56:40 -0500 Subject: Tabbed IDLE (was PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!) In-Reply-To: <53cc376e$0$2898$e4fe514c@news.xs4all.nl> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> Message-ID: <20140720195640.5a3f9579@bigbox.christie.dr> On 2014-07-20 23:40, Irmen de Jong wrote: > > And since IDLE is not a "tabbed editor", only *1* document > > is going to be displayed at a time. > > False. Idle opens any number of documents at the same time just > fine (in different windows - rather than tabs). This sounds like a failing of the OP's window-manager. Fluxbox lets me combine any number of windows into a tabbed interface, so IDLE *is* a tabbed editor on my machine (just like the Gimp). Moreover, it can even include other windows, so I just pulled together a tabbed IDLE interface that also has a terminal for interacting with git, a file-manager window for project management, and a mail window (because Zawinski's law[1]). ;-) -tkc [1] """ Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. """ . From rosuav at gmail.com Sun Jul 20 21:02:11 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 11:02:11 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 8:44 AM, Rick Johnson wrote: > Filedialogs should be "truly modal", and like any modal > dialog, should present themselves to the user utilizing > blocking -- that is the whole point of "modal dialogs", to > *BLOCK* further execution of the application *UNTIL* the > user provides (generally speaking) an "answer" to a > "question". > > In order to facilitate *SMOOTH* interfacing between the user > and the modal dialog, the "contract of modal dialogs" must > be strictly obeyed: File dialogs can be modal or modeless. That's been true since the very first time I met them (which, admittedly, wasn't until the early 90s; maybe someone remembers earlier and can tell me if they were inherently modal 25+ years ago?), and there are good reasons for both operation styles. Even if your dialog is modal, it's extremely common to NOT block the application, but merely prevent interaction; otherwise, your main window won't repaint, which is generally considered to be a flaw. Rick, have you ever done any serious GUI programming in anything other than Tkinter? Are you seriously unaware of standard GUI widget functionality? ChrisA From rosuav at gmail.com Sun Jul 20 21:04:40 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 11:04:40 +1000 Subject: Tabbed IDLE (was PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!) In-Reply-To: <20140720195640.5a3f9579@bigbox.christie.dr> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <20140720195640.5a3f9579@bigbox.christie.dr> Message-ID: On Mon, Jul 21, 2014 at 10:56 AM, Tim Chase wrote: > On 2014-07-20 23:40, Irmen de Jong wrote: >> > And since IDLE is not a "tabbed editor", only *1* document >> > is going to be displayed at a time. >> >> False. Idle opens any number of documents at the same time just >> fine (in different windows - rather than tabs). > > This sounds like a failing of the OP's window-manager. Fluxbox lets > me combine any number of windows into a tabbed interface, so IDLE > *is* a tabbed editor on my machine (just like the Gimp). I would draw a distinction there. With Fluxbox you may be able to build a tabbed interface out of a non-tabbed one, but that doesn't mean the program is tabbed. That's like saying that, with any of a large number of Linux desktop managers and window managers, I can have multiple virtual desktops, which means that I have infinite space on my display. No, I don't; I have an extra layer in there that provides that, but my display is still what it is. ChrisA From rantingrickjohnson at gmail.com Sun Jul 20 21:22:37 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 20 Jul 2014 18:22:37 -0700 (PDT) Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Sunday, July 20, 2014 4:52:36 PM UTC-5, Terry Reedy wrote: > On 7/19/2014 9:31 PM, Rick Johnson wrote: > > On Saturday, July 19, 2014 3:45:07 PM UTC-5, Terry Reedy wrote: > * The third paragraph below explains that Shell's prompt > is a statement prompt rather than line prompt, so that a > secondary line prompt would not be appropriate. Speaking strictly from the point of view of the *current* IDLE implementation, yes. > > To understand *HOW* we might resolve this issue, *FIRST* we > > must understand the origins of the issue > The problem originates in differences between the console > - interactive python interaction and Idle Shell - > execution server interaction Actually, the "problem" you are describing is fundamentally different from what i was talking about, but you *are* getting closer to the *real* source of the design flaws that prevent *easy* evolution of the IDLE software. The *real* problem is that the "interactive events" of the "editor window" and the "interactive events" of the "shell window" are far too tightly integrated with one another. I myself appreciate the finger saving principles of "DRY", however, sometimes, two distinct functionalities just cannot be implemented *IN A CLEAR MANNER* without repeating *some* of the code. We need to understand that IDLE is split into two distinct "modes", if you will -- the "interactive shell" and the "editor window". Attempting to use the same code to handle keystrokes for the shell *AND* the editor is a stumbling block to extending this mess. Instead, IDLE needs two distinct "pipelines" for which events for each *SIDE* of this "split personality" can be *written* and later, easily *COMPREHENDED* by the maintenance programmer. Our "real problem" is discombobulation, and until we wrangle the beast of discombobulation, we will never improve this software in a meaningful or clear manner. Instead, we will only render the software exponentially less readable. YOU CANNOT IMPROVE ANY SOFTWARE UNTIL YOU CAN GROK IT'S SOURCE > This idea, and your response, ignores the fact that Shell > is *statement* oriented. Inserting a secondary prompts > inside statement text would mean that they would have to > first be protected from user editing and then deleted by > Idle before the statement is sent to the Executive. Yes and no. ;-) Hiding the "secondary prompts" from the "execution server" is as simple as running the "command" through a "cleaner function" *BEFORE* it gets evaluated. As for the other issue of protecting the user from editing the "secondary prompts", all you need to do is add a few bits of extra logic to the backspace and clipboard events. But you *could* even just let the user be responsible for his own mistakes and allow documentation handle that issue. But either way, both can be achieved without a complete re- write *OR* fundamental architecture re-design. > Saimadhav Heblekar has worked on adding *optional* line > numbers to Idle editor windows. I plan to adapt the final > patch to the shell with, for instance '>>> ' and 'out:' > labels. As I said on the tracker, I think that output that > is no longer de-dented with respect to input will then need > some more to distinguish it. For my copy of Idle, I have > added blue and red background tint to standard and error > output and I think that works well. That sounds fine to me. There are many methods one can utilize to differentiate input from output. And i like your idea of input being black(with colorizer modification of course), valid output as *ALL* blue, and error output as *ALL* red. > Ideas don't count until recorded on the tracker. Hmm, okay. > Saimadhav has locked together a thin canvas with the text > for line numbers. It works in all my texts. I am just > waiting for him to try it with a thin text instead. If you > know some secret you think he missed. please describe it > here. How can i offer improvements if i don't know where to find the code? And besides, if my comments here "don't count" i will levy the punishment of Eric Theodore Cartman upon you: SCREW YOU GUYS, I'M GOING HOME! From rosuav at gmail.com Sun Jul 20 21:32:14 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 11:32:14 +1000 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 11:22 AM, Rick Johnson wrote: > How can i offer improvements if i don't know where to find > the code? Look in hg.python.org/cpython and see what you find. You never know, it might even be there! ChrisA From breamoreboy at yahoo.co.uk Sun Jul 20 21:54:29 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 21 Jul 2014 02:54:29 +0100 Subject: Improving Idle (was Re: Python 3 ...) In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> Message-ID: On 19/07/2014 21:45, Terry Reedy wrote: > > If you are talking about user processes, and we are talking about > patching Idle, as opposed to Python or the OS (such as Windows), I > disagree. If you are talking about the Idle process, then yes, I would > prefer that once Idle starts, it run forever, and recover from any > problems caused by users. Roger Serwy fixed many Idle shutdowns before > being swallowed by a PhD program a year ago, but there is more to do. > Which has just reminded me of this http://idlex.sourceforge.net/ which is available from pypi, with the last update dated 2014-06-02. I'll quote from the sourceforge page "IdleX is a collection of over twenty extensions and plugins that provide additional functionality to IDLE, a Python IDE provided in the standard library. It transforms IDLE into a more useful tool for academic research and development as well as exploratory programming. IdleX runs with Python 2.6, 2.7, and 3.x." -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rantingrickjohnson at gmail.com Sun Jul 20 22:06:43 2014 From: rantingrickjohnson at gmail.com (Rick Johnson) Date: Sun, 20 Jul 2014 19:06:43 -0700 (PDT) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> Message-ID: <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> On Sunday, July 20, 2014 8:02:11 PM UTC-5, Chris Angelico wrote: > File dialogs can be modal or modeless. [...] and there are > good reasons for both operation styles [...] Are you > seriously unaware of standard GUI widget functionality? Chris i get so tired of your trolling, you cannot just post chastisements of me without proving your side beyond a shadow of a doubt, which you have failed (yet again) to do. Since most people in this community are not experienced with the bugs of IDLE, i will now present you with the steps required to reproduce the two filedialog bugs i mentioned in my first post of this thread. Chris, i challenge you to follow these direction and then report back on this thread your opinion on what "benefits" these buggy filedialog displays are offering to IDLE. Myself and others would just *love* to hear your opinions. ============================================================ STEPS TO REPRODUCE BUG 1: "Attack of the clones!" ============================================================ 1. Open the IDLE application 2. Maximize the window that appears 3. Go to the "File Menu" and choose the "Open" command Now repeat step 3 at least one more time, but feel free to keep opening new dialogs until your fingers bleed and/or eyes pop out. Okay, now tell us, in what manner can an "interface bug" like this be "beneficial"? ============================================================ STEPS TO REPRODUCE BUG 2: "Hide and go seek!" ============================================================ 1. Open the IDLE application 2. Maximize the window that appears 3. Go to the "File Menu" and choose the "Open" command 4. Without disturbing the dialog, minimize the main window 5. Using the taskbar icon, maximize the window Where is the dialog? How will you retrieve it *WITHOUT* reducing the size of the window? And even if you are smart enough to "intuit" what happened to the dialog, and how to retrieve it, how will a noobie "intuit" such a disappearing act? And how in the hell can this be beneficial? From tim at thechases.com Sun Jul 20 20:55:59 2014 From: tim at thechases.com (Tim Chase) Date: Sun, 20 Jul 2014 19:55:59 -0500 Subject: Tabbed IDLE (was PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"!) In-Reply-To: <53cc376e$0$2898$e4fe514c@news.xs4all.nl> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> Message-ID: <20140720195559.5b9f7b7a@bigbox.christie.dr> On 2014-07-20 23:40, Irmen de Jong wrote: > > And since IDLE is not a "tabbed editor", only *1* document > > is going to be displayed at a time. > > False. Idle opens any number of documents at the same time just > fine (in different windows - rather than tabs). This sounds like a failing of the OP's window-manager. Fluxbox lets me combine any number of windows into a tabbed interface, so IDLE *is* a tabbed editor on my machine (just like the Gimp). Moreover, it can even include other windows, so I just pulled together a tabbed IDLE interface that also has a terminal for interacting with git, a file-manager window for project management, and a mail window (because Zawinski's law[1]). ;-) -tkc [1] """ Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. """ . From python.list at tim.thechases.com Sun Jul 20 22:30:08 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Sun, 20 Jul 2014 21:30:08 -0500 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: <20140720213008.221b7bc9@bigbox.christie.dr> On 2014-07-20 19:06, Rick Johnson wrote: > ============================================================ > STEPS TO REPRODUCE BUG 1: "Attack of the clones!" > ============================================================ > > 1. Open the IDLE application > 2. Maximize the window that appears > 3. Go to the "File Menu" and choose the "Open" command > > Now repeat step 3 at least one more time, but feel free to > keep opening new dialogs until your fingers bleed and/or > eyes pop out. In the versions of IDLE that I have here (2.7.3 and 3.2.3), both prevent me from repeating step #3 multiple times. > ============================================================ > STEPS TO REPRODUCE BUG 2: "Hide and go seek!" > ============================================================ > > 1. Open the IDLE application > 2. Maximize the window that appears > 3. Go to the "File Menu" and choose the "Open" command > 4. Without disturbing the dialog, minimize the main window > 5. Using the taskbar icon, maximize the window > > Where is the dialog? Right where I left it? Are you running with a broken window manager that prevents you from seeing the dialog? Sure, because I activated the main IDLE window, it covers the dialog, but I can just select the Open dialog in my task-bar and it pops to the top (alternatively, I could have it display at a higher layer to prevent it from getting covered by the main IDLE window). This is the behavior I want and expect (I often want to refer to text in one window to inform my decisions in a modal window). I've got it running under Fluxbox on Debian Stable and it does exactly what I want/expect. -tkc From rosuav at gmail.com Sun Jul 20 22:38:44 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 12:38:44 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 12:06 PM, Rick Johnson wrote: > STEPS TO REPRODUCE BUG 1: "Attack of the clones!" > > 1. Open the IDLE application > 2. Maximize the window that appears > 3. Go to the "File Menu" and choose the "Open" command > > Now repeat step 3 at least one more time, but feel free to > keep opening new dialogs until your fingers bleed and/or > eyes pop out. > > Okay, now tell us, in what manner can an "interface bug" > like this be "beneficial"? You call it a bug because you can't think of any way it could be beneficial. That's the wrong way of looking at it. Something isn't a bug because you find it annoying; it's a bug because it fails to implement the programmer's intentions and/or the docs/specification. Opening multiple dialogs is *often* useful. The extras don't conflict, and you can open multiple files, so why should it be prevented? > STEPS TO REPRODUCE BUG 2: "Hide and go seek!" > > 1. Open the IDLE application > 2. Maximize the window that appears > 3. Go to the "File Menu" and choose the "Open" command > 4. Without disturbing the dialog, minimize the main window > 5. Using the taskbar icon, maximize the window > > Where is the dialog? How will you retrieve it *WITHOUT* > reducing the size of the window? And even if you are smart > enough to "intuit" what happened to the dialog, and how to > retrieve it, how will a noobie "intuit" such a disappearing > act? And how in the hell can this be beneficial? I'm not sure what platform you're on, and this depends a lot on your window manager. I'm guessing you may be on Windows, as Linux people are more likely to be aware of what DE/WM they use, so I tried it out on Windows. The file dialog appears in the alt-tab list, which seems perfectly sane and sensible, and in fact alt-tab is the most logical way to move between maximized windows anyway. This is not an Idle bug at all. It's a window manager issue. ChrisA From breamoreboy at yahoo.co.uk Sun Jul 20 22:45:37 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 21 Jul 2014 03:45:37 +0100 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: [snipped to bits] On 21/07/2014 03:38, Chris Angelico wrote: > On Mon, Jul 21, 2014 at 12:06 PM, Rick Johnson > wrote: >> STEPS TO REPRODUCE BUG 1: "Attack of the clones!" > > This is not an Idle bug at all. It's a window manager issue. > > ChrisA > Attack of the clown? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From tjreedy at udel.edu Sun Jul 20 22:59:11 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 22:59:11 -0400 Subject: Idle open file dialogs (was ...) In-Reply-To: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> Message-ID: On 7/20/2014 5:14 PM, Rick Johnson wrote: Idle's Open file dialog is not modal. More than one can be open at one time. The all open as the same place. They can all be hidden by other windows, including the parent, especially if the parent is full screen. These might or might not be design bugs, I do not know that any are implementation bugs. They are definitely minor issues compared to some other Idle issues. > Modal dialogs *MUST* be limited to a "one dialog at a time" These are not modal. > If for some reason IDLE is not using the tkFileDialogs, Easily investigated from within Idle itself, using Find in Files Alt+F3 to search for tkFileDialog in idlelib, which became tkinter.filedialog in 3.x. Searching 'tkFileDialog' in lib/idlelib/*.py ... lib/idlelib\IOBinding.py: 7: import tkinter.filedialog as tkFileDialog lib/idlelib\IOBinding.py: 496: self.opendialog = tkFileDialog.Open(master=self.text, lib/idlelib\IOBinding.py: 516: self.savedialog = tkFileDialog.SaveAs( lib/idlelib\configHelpSourceEdit.py: 8: import tkinter.filedialog as tkFileDialog lib/idlelib\configHelpSourceEdit.py: 94: opendialog = tkFileDialog.Open(parent=self, filetypes=filetypes) Hits found: 5 (Hint: right-click to open locations.) As the output says, a right click will take one to the usage sites. > # The following code proves that Tkinter filedialogs are > # behaving in expected manners (properly placed as children > # of the windows which "own" them, and following normal > # focus patterns of "child windows" -- therfore, the problem > # *MUST* be an IDLE problem. > # > # Tested on Python 2.7.8 > # > import Tkinter as tk > from tkFileDialog import askopenfilename, asksaveasfilename > > class App(tk.Tk): > def __init__(self): > tk.Tk.__init__(self) > self._createMenus() > > def _createMenus(self): > menubar = tk.Menu(self) > self.config(menu=menubar) > filemenu = tk.Menu(menubar) > menubar.add_cascade(label='File', menu=filemenu) > filemenu.add_command(label='Open', command=self.requestOpenDialog) > filemenu.add_command(label='Save As', command=self.requestSaveAsDialog) > > def _requestFileDialog(self, func, **kw): > path = func(**kw) > return path > > def requestOpenDialog(self, **kw): > return self._requestFileDialog(askopenfilename, **kw) > > def requestSaveAsDialog(self, **kw): > return self._requestFileDialog(asksaveasfilename, **kw) > > if __name__ == '__main__': > app = App() > app.mainloop() I will save this to look at some time. -- Terry Jan Reedy From tjreedy at udel.edu Sun Jul 20 23:05:01 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 23:05:01 -0400 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 7/20/2014 10:38 PM, Chris Angelico wrote: > on Windows. The file dialog appears in the alt-tab list, which seems > perfectly sane and sensible, and in fact alt-tab is the most logical > way to move between maximized windows anyway. Thank you for the fact, and the suggestion. -- Terry Jan Reedy From rosuav at gmail.com Sun Jul 20 23:09:06 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 13:09:06 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 1:05 PM, Terry Reedy wrote: > On 7/20/2014 10:38 PM, Chris Angelico wrote: > >> on Windows. The file dialog appears in the alt-tab list, which seems >> perfectly sane and sensible, and in fact alt-tab is the most logical >> way to move between maximized windows anyway. > > > Thank you for the fact, and the suggestion. Not sure what suggestion you mean there, as I didn't think I was making any, but... sure. You're welcome! ChrisA From tjreedy at udel.edu Sun Jul 20 23:28:21 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 23:28:21 -0400 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 7/20/2014 8:55 PM, Chris Angelico wrote: >> Idea 4 (which I already suggested on the tracker). Put statement input >> prompts and output separators on lines by themselves. As with 3. above, use >> standard 4 space indents, as with >> >>>>> : >> def f(x): >> if x: >> print('got it') >> return 'something' >> >>>>> : >> f(3) >> --- >> got it >>>>> : >> >> Idle users other than Rick, any comments on the possible improvements? Note that single multiline statements can be directly copied for pasting by the normal method. > I can't comment on how it interacts with the editor half of Idle, but > for the shell as a stand-alone app, and for copying and pasting into > other programs, this last idea is rather interesting. I'm broadly > happy with the current system (>>> def f(x):), and the prompt is a > little weird (">>>:"? but maybe "Python:" would be less weird; I don't > advise "Idle:" as it implies that something is idle that might be > busy), but this would make copy/paste that bit easier. It would tend > to de-emphasize the difference between input and output, though, which > may or may not be an issue. But definitely interesting. The prompt and separator could be configurable. A few users have noticed (and complained) that setting sys.ps1 and sys.ps2 *in the batch mode user process* has no effect. The Idle doc should better explain why this is and should be. User code should not affect the operation of Idle. Idle is separately configured through dialogs. -- Terry Jan Reedy From rosuav at gmail.com Sun Jul 20 23:34:01 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 13:34:01 +1000 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 1:28 PM, Terry Reedy wrote: > A few users have noticed (and complained) that setting sys.ps1 and sys.ps2 > *in the batch mode user process* has no effect. The Idle doc should better > explain why this is and should be. User code should not affect the > operation of Idle. Idle is separately configured through dialogs. As I understand it, setting them has *absolutely* no effect, currently, right? There's no situation in which it would be useful to set them? In that case, it might be useful to put some magic in there (although I'm not sure it's possible; can't use @property at top level in a module) that gives a notification - pointing users to the dialog. No idea how you'd go about it, but telling someone when what s/he does is useless can be helpful. ChrisA From tjreedy at udel.edu Sun Jul 20 23:49:37 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Sun, 20 Jul 2014 23:49:37 -0400 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 7/20/2014 9:22 PM, Rick Johnson wrote: > On Sunday, July 20, 2014 4:52:36 PM UTC-5, Terry Reedy wrote: > The *real* problem is that the "interactive events" of the > "editor window" and the "interactive events" of the "shell > window" are far too tightly integrated with one another. > > I myself appreciate the finger saving principles of "DRY", > however, sometimes, two distinct functionalities just > cannot be implemented *IN A CLEAR MANNER* without repeating > *some* of the code. > > We need to understand that IDLE is split into two distinct > "modes", if you will -- the "interactive shell" and the > "editor window". Attempting to use the same code to handle > keystrokes for the shell *AND* the editor is a stumbling > block to extending this mess. Slightly simplifying, the shell window and output windows are subclasses of the current editor window. I have thought about making all three inherit from a base interactive window. This would be a bit cleaner than the current design. I am not convinced of the need for more drastic change. >> Ideas don't count until recorded on the tracker. Which, as I reported back here, is why I promptly included both your OutputUndo idea and suggestion for a separate event and shortcut key in a new issue on the tracker. > Hmm, okay. >> Saimadhav has locked together a thin canvas with the text >> for line numbers. It works in all my texts. I am just >> waiting for him to try it with a thin text instead. If you >> know some secret you think he missed. please describe it >> here. > > How can i offer improvements if i don't know where to find > the code? http://bugs.python.org/issue17535 > And besides, if my comments here "don't count" The ideas that I think are worth preserving and that I think are appropriate for the tracker I will put on the tracker. You can comment directly on the tracker yourself, but you would have to moderate your style. -- Terry Jan Reedy From memilanuk at invalid.com Mon Jul 21 00:06:47 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 04:06:47 +0000 (UTC) Subject: OT: usenet reader software References: <32rp9b-nsu.ln1@chris.zbmc.eu> Message-ID: On 2014-07-20, Chris Angelico wrote: > Ctrl-X in Angband, Ah-HAH! I've been trying to remember what the name was of an old CLI game that I used to play via a dialup ssh connection (using PuTTY) to a Panix.com account (they ran on NetBSD). Screen was my friend due to dropped connections, and I eventually moved from pine/pico to mutt/slrn/vim/bitchx (though to be honest I never warmed up to mutt all that much) until I got a Mac (OS X) and then later started dual-booting my PCs with Linux. Angband was the name of the game I played back then... sweet! From rosuav at gmail.com Mon Jul 21 00:11:59 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 14:11:59 +1000 Subject: OT: usenet reader software In-Reply-To: References: <32rp9b-nsu.ln1@chris.zbmc.eu> Message-ID: On Mon, Jul 21, 2014 at 2:06 PM, Monte Milanuk wrote: > On 2014-07-20, Chris Angelico wrote: >> Ctrl-X in Angband, > > Ah-HAH! I've been trying to remember what the name was of an old CLI > game that I used to play via a dialup ssh connection (using PuTTY) to a > Panix.com account (they ran on NetBSD). Screen was my friend due to > dropped connections, and I eventually moved from pine/pico to > mutt/slrn/vim/bitchx (though to be honest I never warmed up to mutt all that > much) until I got a Mac (OS X) and then later started dual-booting my > PCs with Linux. Angband was the name of the game I played back then... sweet! Heh. I still have, sitting around, a modified Angband - which I did before I knew about source control, so it'd be a bit of a pain to try to rebase my changes onto a newer build. It has a whole lot of UI improvements, a new character class, a few new races (they're easy), a new gear slot, racial abilities, and a bunch of smaller features that don't come to mind right now. I should clean it up and throw it onto Github or something. ChrisA From paul.nospam at rudin.co.uk Mon Jul 21 01:51:48 2014 From: paul.nospam at rudin.co.uk (Paul Rudin) Date: Mon, 21 Jul 2014 06:51:48 +0100 Subject: OT: usenet reader software References: Message-ID: <85wqb7cl8r.fsf@rudin.co.uk> Sturla Molden writes: > wrote: > >> That doesn't address the problem at all! :-) You still need a news >> reader. > > The problem was that Thunderbird does not support killfiles when used as a > newsreader. Leafnode adds filtering capabilities which Thunderbird > (supposedly) does not have. > There are plenty of non-Thunderbird news clients... From shieldfire at gmail.com Mon Jul 21 02:37:13 2014 From: shieldfire at gmail.com (Martin S) Date: Mon, 21 Jul 2014 08:37:13 +0200 Subject: OT: usenet reader software In-Reply-To: <85wqb7cl8r.fsf@rudin.co.uk> References: <85wqb7cl8r.fsf@rudin.co.uk> Message-ID: <6503b63b-5ff1-4f76-9dd4-0be1f4744f8f@gmail.com> I'm trying gnus again, and immediately see the beauty of it. Actually Usenet is fast and commercial free, and easier to secure from prying NSA etc al (?) so maybe it will receive a general revival eventually. /martin s On 21 Jul 2014, Paul Rudin wrote: >Sturla Molden writes: > >> wrote: >> >>> That doesn't address the problem at all! :-) You still need a news >>> reader. >> >> The problem was that Thunderbird does not support killfiles when used >as a >> newsreader. Leafnode adds filtering capabilities which Thunderbird >> (supposedly) does not have. >> > >There are plenty of non-Thunderbird news clients... -- Sent with K-@ Mail - the evolution of emailing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicholascannon1 at gmail.com Mon Jul 21 03:20:13 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Mon, 21 Jul 2014 00:20:13 -0700 (PDT) Subject: Html Parsing stuff Message-ID: Ok i get the basics of this and i have been doing some successful parsings and using regular expressions to find html tags. I have tried to find an img tag and write that image to a file. I have had no success. It says it has successfully wrote the image to the file with a try... except statement but when i try to open this it says that the image has like no been saved correctly or is damaged. This was just reading the src attribute of the tag and trying to save that link to a .jpg(the extension of the image). Ok so i looked deeper and added a forward slash to the url and then added the image src attribute to it. I then opened that link with the urllib.urlopen() and then read the contents and saved it to the file again. I still got the same result as before. Is there a function in beautiful soup or the urllib module that i can use to save and image. This is just a problem i am sorting out not a whole application so the code is small. Thanks From dihedral88888 at gmail.com Mon Jul 21 03:30:00 2014 From: dihedral88888 at gmail.com (CHIN Dihedral) Date: Mon, 21 Jul 2014 00:30:00 -0700 (PDT) Subject: Confused with Functions and decorators In-Reply-To: References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> Message-ID: <49a2e178-62e7-4186-a32c-488a2fa530a6@googlegroups.com> On Saturday, July 19, 2014 8:44:25 PM UTC+8, Wojciech Giel wrote: > On 19/07/14 12:40, Jerry lu wrote: > > > oh yeah i forgot about the decorators. Um say that you wanted to decorate a function with the outer() func you would just put @outer on top of it? And this is the same as passing another func into the outer func? > > yes. > > syntax was added because with very long function definitions it was > > dificult to track reassignment to the name when it followed definition > > of the function. decorators is just abbreviation. > > > > >>> def outer(f): > > ... def inner(*args, **kwargs): > > ... print("inner function") > > ... return f(*args, **kwargs) > > ... return inner > > ... > > >>> @outer > > ... def myfunc(x): > > ... print("Myfunc", x) > > ... > > >>> myfunc("test") > > inner function > > Myfunc test > > > > it is exactly equivalent to: > > > > >>> def outer(f): > > ... def inner(*args, **kwargs): > > ... print("inner function") > > ... return f(*args, **kwargs) > > ... return inner > > ... > > >>> def myfunc(x): > > ... print("Myfunc", x) > > ... > > >>> myfunc = outer(myfunc) > > >>> myfunc("test") > > inner function > > Myfunc test > > > > cheers > > Wojciech > > > > > > and also with the first example you say x is in the scope when is was created can you define x in the outer func and refer to it in the inner func? > > check nonlocal. Uhn, a local object inside a function can be passed back in Python. Of course, a local function is treated as an object in Python,and the GC is built-in. From steve at pearwood.info Mon Jul 21 03:45:18 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 21 Jul 2014 07:45:18 GMT Subject: Confused with Functions and decorators References: <99846e1f-1ec1-4ed4-9ad4-5c8377b2e1f6@googlegroups.com> <49a2e178-62e7-4186-a32c-488a2fa530a6@googlegroups.com> Message-ID: <53ccc50e$0$29897$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Jul 2014 00:30:00 -0700, CHIN Dihedral wrote: > Uhn, a local object inside a function can be passed back in Python. > > Of course, a local function is treated as an object in Python,and the GC > is built-in. Sigh, the Dihedral bot is not what it used to be... -- Steven From shieldfire at gmail.com Mon Jul 21 03:51:09 2014 From: shieldfire at gmail.com (Martin S) Date: Mon, 21 Jul 2014 09:51:09 +0200 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <20140720213008.221b7bc9@bigbox.christie.dr> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> <20140720213008.221b7bc9@bigbox.christie.dr> Message-ID: 2014-07-21 4:30 GMT+02:00 Tim Chase : > On 2014-07-20 19:06, Rick Johnson wrote: >> ============================================================ >> STEPS TO REPRODUCE BUG 1: "Attack of the clones!" >> ============================================================ >> >> 1. Open the IDLE application >> 2. Maximize the window that appears >> 3. Go to the "File Menu" and choose the "Open" command >> >> Now repeat step 3 at least one more time, but feel free to >> keep opening new dialogs until your fingers bleed and/or >> eyes pop out. > > In the versions of IDLE that I have here (2.7.3 and 3.2.3), both > prevent me from repeating step #3 multiple times. Not on 2.7.6 and 3.4 on Linux Mint either -- Regards, Martin S From tjreedy at udel.edu Mon Jul 21 05:00:15 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Jul 2014 05:00:15 -0400 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 7/20/2014 11:34 PM, Chris Angelico wrote: > On Mon, Jul 21, 2014 at 1:28 PM, Terry Reedy wrote: >> A few users have noticed (and complained) that setting sys.ps1 and sys.ps2 >> *in the batch mode user process* has no effect. The Idle doc should better >> explain why this is and should be. User code should not affect the >> operation of Idle. Idle is separately configured through dialogs. > > As I understand it, setting them has *absolutely* no effect, > currently, right? As far as I know, setting sys.ps1 and sys.ps2 have no effect in any batch mode program. This has nothing to do with Idle. > There's no situation in which it would be useful to > set them? In that case, it might be useful to put some magic in there > (although I'm not sure it's possible; can't use @property at top level > in a module) that gives a notification - pointing users to the dialog. In general, Idle should execute user code the same way that the interpreter does, subject to the limitations of the different execution environment. > No idea how you'd go about it, but telling someone when what s/he does > is useless can be helpful. What needs better documentation is what the execution environment is, and how the shell is different from a line-buffered console. -- Terry Jan Reedy From nicholascannon1 at gmail.com Mon Jul 21 05:13:55 2014 From: nicholascannon1 at gmail.com (Nicholas Cannon) Date: Mon, 21 Jul 2014 02:13:55 -0700 (PDT) Subject: Html Parsing stuff In-Reply-To: References: Message-ID: dont worry it has been solved From memilanuk at invalid.com Mon Jul 21 05:38:43 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 09:38:43 +0000 (UTC) Subject: OT: usenet reader software References: <85wqb7cl8r.fsf@rudin.co.uk> Message-ID: On 2014-07-21, Paul Rudin wrote: > Sturla Molden writes: > >> wrote: >> >>> That doesn't address the problem at all! :-) You still need a news >>> reader. >> >> The problem was that Thunderbird does not support killfiles when used as a >> newsreader. Leafnode adds filtering capabilities which Thunderbird >> (supposedly) does not have. >> > > There are plenty of non-Thunderbird news clients... But relatively few GUI clients on Linux... which was what I was looking for. From rosuav at gmail.com Mon Jul 21 06:56:11 2014 From: rosuav at gmail.com (Chris Angelico) Date: Mon, 21 Jul 2014 20:56:11 +1000 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Mon, Jul 21, 2014 at 7:00 PM, Terry Reedy wrote: > In general, Idle should execute user code the same way that the interpreter > does, subject to the limitations of the different execution environment. Agreed, but I think the setting of prompts is a "different execution environment" case. It's a fundamental difference between batch mode and interactive, and Idle uses batch mode to implement interactive mode. So something like: >>> sys.ps1="Python> " "Setting sys.ps1 has no effect in Idle; see the Options menu." >>> It might not be possible, but if it is, it wouldn't break any actual viable use-cases. ChrisA From invalid at invalid.invalid Mon Jul 21 10:27:18 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Jul 2014 14:27:18 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Chris Angelico wrote: > You call it a bug because you can't think of any way it could be > beneficial. That's the wrong way of looking at it. Something isn't a > bug because you find it annoying; it's a bug because it fails to > implement the programmer's intentions and/or the docs/specification. I was always taught that it's a "bug" is when a program doesn't do what a reasonable user expects -- that it's got nothing to do with the programmer's intent. -- Grant Edwards grant.b.edwards Yow! I'm RELIGIOUS!! at I love a man with gmail.com a HAIRPIECE!! Equip me with MISSILES!! From i at introo.me Mon Jul 21 10:40:23 2014 From: i at introo.me (Shiyao Ma) Date: Mon, 21 Jul 2014 22:40:23 +0800 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: No intent to pollute this thread. But really interested in the invalid at invalid.invalid mailing address. And,,, obviously, I cannot send to invalid at invalid.invalid, so How does you(he) make this? 2014-07-21 22:27 GMT+08:00 Grant Edwards : > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. > > -- > -- > https://mail.python.org/mailman/listinfo/python-list -- ????????????????http://introo.me? From rosuav at gmail.com Mon Jul 21 10:48:03 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 00:48:03 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Tue, Jul 22, 2014 at 12:27 AM, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: > >> You call it a bug because you can't think of any way it could be >> beneficial. That's the wrong way of looking at it. Something isn't a >> bug because you find it annoying; it's a bug because it fails to >> implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. There are many definitions of the word, and sometimes they disagree. (That's why it's common to have an "issue tracker" rather than a "bug tracker"; often the "is this a bug report or a feature request" question doesn't even matter. In theory, version x.y.? releases should have bug fixes but not feature additions, but sometimes some bug fix might potentially break code, so it's deferred till the next x.? release. Or a feature addition is allowed to be backported, because it's Idle, not the core language.) But even using that definition, I would not say that one single person saying "this can't possibly be useful" is enough to define something as a bug. Take, for instance, the behaviour of Windows's cmd.exe editing keys: enter three commands, then up-arrow three times and hit enter, then press down, enter, down, enter. You'll repeat the three commands. In other interfaces (eg GNU readline), you'd do the same job by pressing up, up, up, enter each time. Personally, I find the cmd.exe behaviour extremely surprising, especially when I've been working with some very similar commands (imagine: ./configure some_bunch_of_args; make; some_command_to_test; rm -rf *; git checkout HEAD - then repeat with a different set of configure arguments), and I end up "stuck half way up command history", wondering why I'm not seeing what I wanted. Can be extremely awkward. But even so, I don't call this a bug. It's entirely possible that it is one - some internal state that isn't being reset correctly - as I don't have docs or the programmer's intention to compare against. However, I can't honestly call it a bug based on just my own use-cases. I personally find it useless and unhelpful, but that doesn't make it a bug any more than a colourblind person would find a colour-based UI phenomenon a bug. ChrisA From rosuav at gmail.com Mon Jul 21 10:51:28 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 00:51:28 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Tue, Jul 22, 2014 at 12:40 AM, Shiyao Ma wrote: > No intent to pollute this thread. > > But really interested in the invalid at invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid at invalid.invalid, so > > How does you(he) make this? When you send email, you have to have a valid envelope-from address, which can be found in the headers. But the From: address doesn't technically have to be valid. And if the email you received actually came from the news<->mail gateway, then it's even less significant; the address used is simply whatever Grant chose to key into his newsreader, which in this case is a marker saying "Please don't email me, just follow-up to the group" :) ChrisA From memilanuk at invalid.com Mon Jul 21 10:55:28 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 14:55:28 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Shiyao Ma wrote: > But really interested in the invalid at invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid at invalid.invalid, so > > How does you(he) make this? Some usenet clients, such as slrn which it looks like Grant is using according to the message header, support using different addresses for 'From:' and 'Reply-To:', and the comments in the default .slrnrc config file recommend using some form of 'invalid' in your 'From:' address to cut down on spam. Looks like Grant took that quite literally ;) Not sure if it really matters... probably can't hurt... Monte From breamoreboy at yahoo.co.uk Mon Jul 21 11:19:22 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 21 Jul 2014 16:19:22 +0100 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 21/07/2014 15:27, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: > >> You call it a bug because you can't think of any way it could be >> beneficial. That's the wrong way of looking at it. Something isn't a >> bug because you find it annoying; it's a bug because it fails to >> implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. > As in my entire career I've never come across a "reasonable user" then by that definition there are no bugs. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Mon Jul 21 11:27:32 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 01:27:32 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Tue, Jul 22, 2014 at 1:19 AM, Mark Lawrence wrote: > On 21/07/2014 15:27, Grant Edwards wrote: >> >> On 2014-07-21, Chris Angelico wrote: >> >>> You call it a bug because you can't think of any way it could be >>> beneficial. That's the wrong way of looking at it. Something isn't a >>> bug because you find it annoying; it's a bug because it fails to >>> implement the programmer's intentions and/or the docs/specification. >> >> >> I was always taught that it's a "bug" is when a program doesn't do >> what a reasonable user expects -- that it's got nothing to do with the >> programmer's intent. >> > > As in my entire career I've never come across a "reasonable user" then by > that definition there are no bugs. Absence of evidence is not the same as evidence of absence. It may be that there is a single platinum "reasonable user", kept at the International Bureau of Bugs, that we may all look on it and know what the SI Standard User is. ChrisA From dihedral88888 at gmail.com Mon Jul 21 11:37:40 2014 From: dihedral88888 at gmail.com (CHIN Dihedral) Date: Mon, 21 Jul 2014 08:37:40 -0700 (PDT) Subject: Python and IDEs [was Re: Python 3 is killing Python] In-Reply-To: References: <87zjga4j4v.fsf@elektro.pacujo.net> <53c57bae$0$9505$c3e8da3$5496439d@news.astraweb.com> <87iomy4ciy.fsf@elektro.pacujo.net> <53c5f6dc$0$9505$c3e8da3$5496439d@news.astraweb.com> <87egxl4zq8.fsf@elektro.pacujo.net> <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <53c9655a$0$9505$c3e8da3$5496439d@news.astraweb.com> <368c1e4f-9328-445b-9876-9f26560a50c2@googlegroups.com> <53ca1e27$0$9505$c3e8da3$5496439d@news.astraweb.com> <53cb1a12$0$6574$c3e8da3$5496439d@news.astraweb.com> Message-ID: On Sunday, July 20, 2014 9:53:02 AM UTC+8, C.D. Reimer wrote: > On 7/19/2014 6:23 PM, Steven D'Aprano wrote: > > > I haven't used Python on Windows much, but when I did use it, I found > > > the standard Python interactive interpreter running under cmd.exe to > > > be bare- bones but usable for testing short snippets. If I recall > > > correctly, it is missing any sort of command history or line editing > > > other than backspace, which I guess it would have been painful to use > > > for extensive interactive work, but when I started using Python on > > > Linux the interactive interpreter had no readline support either so it > > > was just like old times :-) > > > > Windows PowerShell supports very basic Linux commands and has a command > > history. I'm always typing "ls" for a directory listing when I'm on a > > Windows machine. The regular command line would throw a DOS fit. > > PowerShell lets me get away with it. > > > > http://en.wikipedia.org/wiki/Windows_PowerShell#Comparison_of_cmdlets_with_similar_commands > > > > I prefer working on my vintage 2006 Black MacBook. Alas, the CPU fan is > > dying and MacBook shuts down after 15 minutes. I'm surprised at how well > > I was able to set up a equivalent programming environment on Windows. > > > > Chris Reimer Well, Python could be used as a scripting language for routine jobs in various Oses. But Python has been designed to be a cross-platform high-level general purpose programming language from the birth. One can be sure that the investing in most of the programming concepts and skills in Python 2.XX is still valid in Python 3.XX. Forget those non-investing imitators' flase spamming claims. From lele at metapensiero.it Mon Jul 21 11:57:22 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Mon, 21 Jul 2014 17:57:22 +0200 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: <87egxewvq5.fsf@nautilus.nautilus> Chris Angelico writes: > Take, for instance, the behaviour of Windows's cmd.exe > editing keys: enter three commands, then up-arrow three times and hit > enter, then press down, enter, down, enter. You'll repeat the three > commands. In other interfaces (eg GNU readline), you'd do the same job > by pressing up, up, up, enter each time. Personally, I find the > cmd.exe behaviour extremely surprising, especially when I've been > working with some very similar commands (imagine: ./configure > some_bunch_of_args; make; some_command_to_test; rm -rf *; git checkout > HEAD - then repeat with a different set of configure arguments), and I > end up "stuck half way up command history", wondering why I'm not > seeing what I wanted. Can be extremely awkward. But even so, I don't > call this a bug. Granted, the readline library exposes a "operate-and-get-next" function, by default bound to \C-o, with the same behaviour as the cmd.exe one. I find it very handy in the scenario you picted. So again, "feature" and "bug" may be effectively subjective :-) ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From rosuav at gmail.com Mon Jul 21 12:05:09 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 02:05:09 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <87egxewvq5.fsf@nautilus.nautilus> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> <87egxewvq5.fsf@nautilus.nautilus> Message-ID: On Tue, Jul 22, 2014 at 1:57 AM, Lele Gaifax wrote: > Granted, the readline library exposes a "operate-and-get-next" function, > by default bound to \C-o, with the same behaviour as the cmd.exe > one. I find it very handy in the scenario you picted. So again, > "feature" and "bug" may be effectively subjective :-) I've never used it, but from the name, I would take it to be equivalent to "enter, down-arrow" in the above scenario. As a single action, that's less surprising and just as useful. The problem isn't when you consciously want the feature - it's when you DON'T want it and get this unexpected state. ChrisA From memilanuk at invalid.com Mon Jul 21 12:07:22 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 16:07:22 +0000 (UTC) Subject: Network/multi-user program Message-ID: So... this is a fairly general / hypothetical question, and I'm more looking for direction than specifics - though it may be useful as well. I need to create a particular application for administering a sporting event. 95% (and this may be understating the case) of the 'users' would likely be single-machine, single user scenarios. For those exceptions (which are important enough that I'm concerned over them) there would be one person 'administering' the event and a small number of others (probably <5, no more than 10) doing basic data entry - competitor registration and later entering scores. Before (setting up event), in between (squadding competitors based on classification, equipment, available positions on relays, etc.) and taking care of final reports for awards, etc. would be done only from the main program. The end-users are likely not tech-saavy, and most likely running Windows or maybe a Mac. Being able to do the data entry from a tablet would be nice but by no means necessary. Installation needs to be as stone-simple as possible - running from a pre-configured USB stick or a browser would be ideal. Use would be over small wired or wi-fi LAN enviroment - no exposure to Internet. Given that the vast majority of the 'work' is going to be done on one computer by one user, but wanting to retain the flexibility/ability to later have addtional 'clients' connect for data entry purposes... I'm trying to decide what would be a better option: create a stand-alone GUI desktop app and figure out how to create a separate 'client' program that can connect and perform basic CRUD operations, or start out with some sort of web framework and have everything literally run from the 'server' via a browser-based interface. The scope of the project in terms of users appears to be small enough that using something like sqlite would be feasible (the data entry clients would not be working on the same records), and the small development web servers that most projects like web2py, flask, django come with should (maybe?) be able to carry the (minimal) load as well. Having to throw html/css/js plus browser compatibility issues on top of everything else starts making the project look a whole lot bigger than I'm comfortable with... but on the other hand I have no idea how to go about connecting a client app to a running GUI program either. The whole project is fairly ambitious for my current skill level (basically small addressbook/task-list type apps) but I figured I'd have to stretch/grow a bit either way I go. So I guess I'm asking for advice or simplified examples of how to go about connecting a client desktop app to a parent/master desktop app, so I can get some idea of how big of a task I'm looking at here, and whether that would be more or less difficult than trying to do the equivalent job using a web framework. Thanks, Monte From rosuav at gmail.com Mon Jul 21 12:40:25 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 02:40:25 +1000 Subject: Network/multi-user program In-Reply-To: References: Message-ID: On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: > So I guess I'm asking for advice or simplified examples of how to > go about connecting a client desktop app to a parent/master desktop app, > so I can get some idea of how big of a task I'm looking at here, and > whether that would be more or less difficult than trying to do the > equivalent job using a web framework. Easier way: Don't have a "master desktop app", but instead have a master database. Since you're posting this to python-list, I'll assume you currently intend writing this in Python; you can make a really simple transition from single-user-single-desktop to a networked system, although of course you'll want to think in terms of multiple users from the start. All you need to do is pick a database engine at the top of the script. As a general rule, I would say that it's okay to have more complicated installation instructions for a more demanding job, so you can have the single-user setup done with SQLite3 (no need to install a database and worry about passwords), but for the multi-user setup, they have to install (say) PostgreSQL on a single central server, and then possibly key in some authentication on each client (or even maybe not, depending on how much you trust the LAN - you did say there's no internet exposure). This is going to be comparable difficulty to setting up a centralized web server, but with the advantage that you can short-cut the whole thing when it's to be used on only one computer (not really possible with a browser-based system). Your UI would, obviously, be absolutely the same for both scenarios - it'd be all the same code, doing exactly the same things. (Obviously you'd have to make sure your SQL isn't specific to either engine, but that's easy enough. You won't warp your code much around that.) The only difference would be if you have to worry about update conflicts and other inherently multi-user issues, but ultimately there's no difference between the multi-user scenario where nobody else happens to be doing anything, and the dedicated single-user scenario. So, how big a task is it? If you're already familiar with the Python databasing API, and at least broadly familiar with a multi-user DBMS like PostgreSQL, and especially if you already know the important aspects of coping with simultaneous users, then this will be pretty easy - much easier than working it into a web browser. (And you'd need to worry about the issues of simultaneous users anyway. There's really no difference on that.) In terms of setup complexity for your users, it's *possible* that you could develop a low-performance web server that would be easier to deploy. You'd just need to either embed an HTTP server in your Python script, or use a framework that includes one; and if you make it single-threaded (ie all requests are serialized), you could use SQLite for the database back-end. In contrast, I'm suggesting a central database, which has to be installed and configured (most databases won't, by default, accept connections from anyone but localhost), which at very least will require a bit more chugging (you can automate all or at least most of it, but it'll still take time to install). The advantages are that you can trust your code (because it's all the same everywhere), and yet you have an extremely light single-user mode, plus your UI is flexible - you're not restricted to a web browser, you can build an actual application with whatever UI you like. And, in fact, you could have several different UIs, if you wanted to, because it's the database that's king. Maybe it'd be helpful to have a really REALLY cut-down UI for the basic data entry, with no clutter from the admin functions. It'd all work fine. (And you could add that later, without breaking anything.) It is, of course, possible to write a desktop application that can be remotely scripted for data entry. But I don't think it's necessary. :) ChrisA From lele at metapensiero.it Mon Jul 21 12:41:25 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Mon, 21 Jul 2014 18:41:25 +0200 Subject: Network/multi-user program References: Message-ID: <87a982wtoq.fsf@nautilus.nautilus> Monte Milanuk writes: > I need to create a particular application for administering a sporting > event. 95% (and this may be understating the case) of the 'users' would > likely be single-machine, single user scenarios. For those exceptions > (which are important enough that I'm concerned over them) there would be > one person 'administering' the event and a small number of others > (probably <5, no more than 10) doing basic data entry - competitor > registration and later entering scores. Before (setting up event), in > between (squadding competitors based on classification, equipment, > available positions on relays, etc.) and taking care of final reports > for awards, etc. would be done only from the main program. The > end-users are likely not tech-saavy, and most likely running Windows or > maybe a Mac. Being able to do the data entry from a tablet would be > nice but by no means necessary. Installation needs to be as > stone-simple as possible - running from a pre-configured USB stick or a > browser would be ideal. Use would be over small wired or wi-fi LAN > enviroment - no exposure to Internet. I developed SoL[1] with almost the same goal, to manage Carrom tournaments. It started many years ago as a Windows only desktop application, but evolved into a much nicer and fun-to-develop web application, based on Python on the backend (using Pyramid and SQLAlchemy, with a SQLite database) and ExtJS on the frontend. That basically means that the backend may be installed with little effort on any Python-supported OS, and the frontend runs on most modern browsers. I manage small events with a single notebook and a low cost printer, without network connection, while major events with a network connection may be managed online. You can try it out at http://sol3.arstecnica.it/, using guest/guest as username/password. Hope this helps, ciao, lele. [1] https://pypi.python.org/pypi/SoL -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From Michael.Coll-Barth at VerizonWireless.com Mon Jul 21 10:51:57 2014 From: Michael.Coll-Barth at VerizonWireless.com (Coll-Barth, Michael) Date: Mon, 21 Jul 2014 10:51:57 -0400 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: <1fbbc39f-0191-4e3f-b330-feca48687bb3@OHTWI1EXH002.uswin.ad.vzwcorp.com> References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> <1fbbc39f-0191-4e3f-b330-feca48687bb3@OHTWI1EXH002.uswin.ad.vzwcorp.com> Message-ID: <3hH5W92GYCz7Lv1@mail.python.org> > -----Original Message----- > From: Python-list [mailto:python-list-bounces+michael.coll- > barth=verizonwireless.com at python.org] On Behalf Of Grant Edwards > Sent: Monday, July 21, 2014 10:27 AM > To: python-list at python.org > Subject: Re: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! > > On 2014-07-21, Chris Angelico wrote: > > > You call it a bug because you can't think of any way it could be > > beneficial. That's the wrong way of looking at it. Something isn't a > > bug because you find it annoying; it's a bug because it fails to > > implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. > > -- I have to agree with Chris. A bug is what you call something that happens contrary to design or intent. Only. I build a program, regardless of the platform, with my intent, not yours. When it blows up or doesn't do what I want, then it's a bug and it's a bug even if there are no users for my program. Something that happens contrary to user expectations is an annoyance to that user. You might want to get your money back from those that taught you otherwise. BTW, there ain't no such thing as a 'reasonable' user. That's what they call an oxymoron. From bdastur at gmail.com Mon Jul 21 12:36:18 2014 From: bdastur at gmail.com (Behzad Dastur) Date: Mon, 21 Jul 2014 09:36:18 -0700 Subject: Installing Python 2.6.2 on Ubuntu 12.1 Message-ID: Question: How to install Python manually and make sure that all the necessary modules and .so files get built (eg: _sha256.so, zlib.so) Details: I am trying to install Python2.6.2 version manually, installation goes through fine, but later installing setuptools fails due to _sha256 Module not found. These are the steps I did for manually installing python in my private folder: 1. ./configure --help 2. ./configure --prefix=/home/brd/priv_env 3. make; make install The installation went through successfully, however I noticed that some of the _*.so files did not get built under lib/python2.6/lib-dynload/ folder (eg _sha256.so) , which is likely the reason why my setuptools install failed due to the error: " File "/home/cisco/priv_env/lib/python2.6/hashlib.py", line 138, in sha224 = __get_builtin_constructor('sha224') File "/home/cisco/priv_env/lib/python2.6/hashlib.py", line 66, in __get_builtin_constructor import _sha256 ImportError: No module named _sha256" Note that I have the necessary libraries installed on this machine eg: libzlib.so, libssl.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libssl3.so /usr/lib/x86_64-linux/gnu/libz.so.1 Another note, is that the standard python installation on this system (Python 2.7.3), does not have this problem, and has all the modules and .so files built. Sincere Regards, Behzad -------------- next part -------------- An HTML attachment was scrubbed... URL: From invalid at invalid.invalid Mon Jul 21 12:51:39 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Jul 2014 16:51:39 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Shiyao Ma wrote: > No intent to pollute this thread. > > But really interested in the invalid at invalid.invalid mailing address. > And,,, obviously, I cannot send to invalid at invalid.invalid, so FWIW, my real e-mail address is at the bottom of every post. > How does you(he) make this? I execute the following slang code via my slrn startup file: username = "grant.b.edwards"; host = "gmail.com"; -- Grant Edwards grant.b.edwards Yow! Does someone from at PEORIA have a SHORTER gmail.com ATTENTION span than me? From invalid at invalid.invalid Mon Jul 21 12:55:27 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Jul 2014 16:55:27 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Chris Angelico wrote: > On Tue, Jul 22, 2014 at 12:40 AM, Shiyao Ma wrote: >> No intent to pollute this thread. >> >> But really interested in the invalid at invalid.invalid mailing address. >> And,,, obviously, I cannot send to invalid at invalid.invalid, so >> >> How does you(he) make this? > > When you send email, you have to have a valid envelope-from address, > which can be found in the headers. But the From: address doesn't > technically have to be valid. Note that a lot of mail servers and/or spam filters will think it's spam if it isn't. > And if the email you received actually came from the news<->mail > gateway, It did. > then it's even less significant; the address used is simply whatever > Grant chose to key into his newsreader, which in this case is a > marker saying "Please don't email me, just follow-up to the group" :) If people really do want to e-mail me, that's fine. What I'm trying to avoid is people who e-mail my without knowing they're doing so because that's the default setting for whatever broken-by-design email client, web-UI, or newsreading they happen to be using. If people conciously want to e-mail me, all they can by using the address in my sig. -- Grant Edwards grant.b.edwards Yow! Wait ... is this a FUN at THING or the END of LIFE in gmail.com Petticoat Junction?? From invalid at invalid.invalid Mon Jul 21 12:56:08 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Jul 2014 16:56:08 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Mark Lawrence wrote: > On 21/07/2014 15:27, Grant Edwards wrote: >> On 2014-07-21, Chris Angelico wrote: >> >>> You call it a bug because you can't think of any way it could be >>> beneficial. That's the wrong way of looking at it. Something isn't a >>> bug because you find it annoying; it's a bug because it fails to >>> implement the programmer's intentions and/or the docs/specification. >> >> I was always taught that it's a "bug" is when a program doesn't do >> what a reasonable user expects -- that it's got nothing to do with the >> programmer's intent. > > As in my entire career I've never come across a "reasonable user" then > by that definition there are no bugs. Well done! -- Grant Edwards grant.b.edwards Yow! Hello. Just walk at along and try NOT to think gmail.com about your INTESTINES being almost FORTY YARDS LONG!! From invalid at invalid.invalid Mon Jul 21 12:57:46 2014 From: invalid at invalid.invalid (Grant Edwards) Date: Mon, 21 Jul 2014 16:57:46 +0000 (UTC) Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 2014-07-21, Grant Edwards wrote: > On 2014-07-21, Shiyao Ma wrote: >> No intent to pollute this thread. >> >> But really interested in the invalid at invalid.invalid mailing address. >> And,,, obviously, I cannot send to invalid at invalid.invalid, so > > FWIW, my real e-mail address is at the bottom of every post. > >> How does you(he) make this? > > I execute the following slang code via my slrn startup file: > > username = "grant.b.edwards"; > host = "gmail.com"; Oops, I cut and pasted the wrong code: variable username = "invalid"; variable host="invalid.invalid"; set_string_variable("hostname", host); set_string_variable("username", username); -- Grant Edwards grant.b.edwards Yow! Was my SOY LOAF left at out in th'RAIN? It tastes gmail.com REAL GOOD!! From steve+comp.lang.python at pearwood.info Mon Jul 21 13:03:56 2014 From: steve+comp.lang.python at pearwood.info (Steven D'Aprano) Date: 21 Jul 2014 17:03:56 GMT Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: <53cd47fc$0$6574$c3e8da3$5496439d@news.astraweb.com> On Mon, 21 Jul 2014 17:57:22 +0200, Lele Gaifax wrote: > Chris Angelico writes: > >> Take, for instance, the behaviour of Windows's cmd.exe editing keys: >> enter three commands, then up-arrow three times and hit enter, then >> press down, enter, down, enter. You'll repeat the three commands. In >> other interfaces (eg GNU readline), you'd do the same job by pressing >> up, up, up, enter each time. Personally, I find the cmd.exe behaviour >> extremely surprising, especially when I've been working with some very >> similar commands (imagine: ./configure some_bunch_of_args; make; >> some_command_to_test; rm -rf *; git checkout HEAD - then repeat with a >> different set of configure arguments), and I end up "stuck half way up >> command history", wondering why I'm not seeing what I wanted. Can be >> extremely awkward. But even so, I don't call this a bug. > > Granted, the readline library exposes a "operate-and-get-next" function, > by default bound to \C-o, with the same behaviour as the cmd.exe one. I > find it very handy in the scenario you picted. So again, "feature" and > "bug" may be effectively subjective :-) Have you actually got that working in Python with the readline module? I've tried and tried and cannot get it to work. Any hints gratefully appreciated. -- Steven From lele at metapensiero.it Mon Jul 21 13:40:21 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Mon, 21 Jul 2014 19:40:21 +0200 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> <53cd47fc$0$6574$c3e8da3$5496439d@news.astraweb.com> Message-ID: <8761iqwqyi.fsf@nautilus.nautilus> Steven D'Aprano writes: >> Granted, the readline library exposes a "operate-and-get-next" function, >> by default bound to \C-o, with the same behaviour as the cmd.exe one. I >> find it very handy in the scenario you picted. So again, "feature" and >> "bug" may be effectively subjective :-) > > Have you actually got that working in Python with the readline module? > I've tried and tried and cannot get it to work. Any hints gratefully > appreciated. I was pretty sure it worked when I revamped the readline support[1], many years ago, but effectively I'm not able to do it now, and I find this https://github.com/ipython/ipython/issues/41 where Chet Ramey says it's something that bash injects into the library... and that it should be easy to implement by the calling application. So I guess my memory is faulty. ciao, lele. [1] http://ftp.vim.org/languages/python/python/contrib-09-Dec-1999/System/Pyrl.README -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From rosuav at gmail.com Mon Jul 21 13:56:57 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 03:56:57 +1000 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On Tue, Jul 22, 2014 at 2:55 AM, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: >> >> When you send email, you have to have a valid envelope-from address, >> which can be found in the headers. But the From: address doesn't >> technically have to be valid. > > Note that a lot of mail servers and/or spam filters will think it's > spam if it isn't. Yes, which is why I said "technically". Most often, a difference between envelope-from and From: header is because of a resending, like when Mailman sends mail on behalf of someone else; the From is still a valid address, but it's not the same one as the envelope-from (which will be the list-bounces address). That said, though, I've often telnetted to a mail server and done something like this: """ helo mail from: rcpt to: data From: me To: me Subject: Test Test! . quit """ Generally that sort of thing gets through. Sometimes it lands in a spam box, but more often it doesn't. I don't remember it ever getting rejected, other than for issues of relaying (which usually come from typoing the recipient domain). ChrisA From memilanuk at invalid.com Mon Jul 21 14:16:49 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 18:16:49 +0000 (UTC) Subject: Network/multi-user program References: Message-ID: On 2014-07-21, Chris Angelico wrote: > On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: >> So I guess I'm asking for advice or simplified examples of how to >> go about connecting a client desktop app to a parent/master desktop app, >> so I can get some idea of how big of a task I'm looking at here, and >> whether that would be more or less difficult than trying to do the >> equivalent job using a web framework. > > Easier way: Don't have a "master desktop app", but instead have a > master database. Since you're posting this to python-list, I'll assume > you currently intend writing this in Python; you can make a really > simple transition from single-user-single-desktop to a networked > system, although of course you'll want to think in terms of multiple > users from the start. So... if everybody is using the same application to access the same database, how would you prevent say, a data entry user from accidentally breaking something above their pay-grade? Set up some sort of role-based privilege system to limit them to write access for some portions and read-only for others? Thanks, Monte From memilanuk at invalid.com Mon Jul 21 14:19:55 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 18:19:55 +0000 (UTC) Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> Message-ID: On 2014-07-21, Lele Gaifax wrote: > I manage small events with a single notebook and a low cost printer, > without network connection, while major events with a network connection > may be managed online. > > You can try it out at http://sol3.arstecnica.it/, using guest/guest as > username/password. Wow. I have no idea how the game/events run, but that is a very nice looking program! How hard was it to migrate from a desktop app to what you have now? Would you recommend this route for someone starting out? Monte From rosuav at gmail.com Mon Jul 21 14:26:27 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 04:26:27 +1000 Subject: Network/multi-user program In-Reply-To: References: Message-ID: On Tue, Jul 22, 2014 at 4:16 AM, Monte Milanuk wrote: > On 2014-07-21, Chris Angelico wrote: >> On Tue, Jul 22, 2014 at 2:07 AM, Monte Milanuk wrote: >>> So I guess I'm asking for advice or simplified examples of how to >>> go about connecting a client desktop app to a parent/master desktop app, >>> so I can get some idea of how big of a task I'm looking at here, and >>> whether that would be more or less difficult than trying to do the >>> equivalent job using a web framework. >> >> Easier way: Don't have a "master desktop app", but instead have a >> master database. Since you're posting this to python-list, I'll assume >> you currently intend writing this in Python; you can make a really >> simple transition from single-user-single-desktop to a networked >> system, although of course you'll want to think in terms of multiple >> users from the start. > > So... if everybody is using the same application to access the same > database, how would you prevent say, a data entry user from accidentally > breaking something above their pay-grade? Set up some sort of > role-based privilege system to limit them to write access for some > portions and read-only for others? That would be one way, yes. The first question you'd need to ask is: How do you know who's data-entry and who's admins? As soon as you solve that (probably with some sort of login), you tie the access level to that. If you need absolute security, you would have the user enter a login and password which would actually be the database credentials. Then you grant exact rights in the database manager, permitting ONLY what that user is allowed to do. It's then utterly impossible, even for someone who knows Python and SQL, to do damage. But more likely, what you really want is a cut-down UI that simplifies things: if the user is data-entry level, you take away all the admin-type options. It might be possible to fiddle around in internals and gain elevated access, but that's not an issue in many environments. In any case, these are issues you'd need to figure out regardless of the development model. Ultimately, you could treat the entire computer, network, database, etc as a black box, and just look at two entities: the human, and the UI s/he is using. All permissions issues can be explained at that level. ChrisA From tjreedy at udel.edu Mon Jul 21 14:30:30 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Jul 2014 14:30:30 -0400 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On 7/21/2014 6:56 AM, Chris Angelico wrote: > On Mon, Jul 21, 2014 at 7:00 PM, Terry Reedy wrote: >> In general, Idle should execute user code the same way that the interpreter >> does, subject to the limitations of the different execution environment. > > Agreed, but I think the setting of prompts is a "different execution > environment" case. It's a fundamental difference between batch mode > and interactive, and Idle uses batch mode to implement interactive > mode. So something like: > >>>> sys.ps1="Python> " > "Setting sys.ps1 has no effect in Idle; see the Options menu." >>>> > > It might not be possible, but if it is, it wouldn't break any actual > viable use-cases. It would be a lot of work for close to 0 gain. It could not work consistent without special-casing sys assignments. Consider >>> prompt1 = 'Me>' >>> setps1 = sys.ps1 >>> setps1(prompt1) ;-(. Idle cannot exactly imitate the interactive interpreter (II) because it does not execute code in exactly the same way. For instance, http://bugs.python.org/issue21997 reported that fact that the sequence >>>def dodebug(): pdb.set_trace() >>>dodebug() behaves differently in Idle and II. Not knowing the details of Idle (currently only available in the code), the OP claimed that this is an Idle bug. It turns out that running dodebug indirectly >>> def run_code(code): exec(code, globals()) >>> run('dodebug()') *in the II* behaves like Idle. The above is essentially how Idle runs code. (The difference is that it substitutes a custom namespace designed to look like the globals() of a main modules, include having __name__ == '__main__'.) Well, at least I know now, so I know how to review claims that Idle is buggy when it acts a bit differently than the II. The exec abstraction has a few tiny leaks if one looks hard enough, such as with the debugger. Using inspect to look at the frame stack would also show a difference. -- Terry Jan Reedy From rosuav at gmail.com Mon Jul 21 14:35:37 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 04:35:37 +1000 Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: On Tue, Jul 22, 2014 at 4:30 AM, Terry Reedy wrote: > It would be a lot of work for close to 0 gain. It could not work consistent > without special-casing sys assignments. The latter doesn't much matter (this is just a theory to help people realize what they've done, not an actual preventative - it's like if someone types "quit" and it comes back with a custom repr that tells them about quit() or EOF), but the former is the important bit here. Not a big deal, not worth a huge amount of effort. At best, this is something to docket away as "here's another thing that we could do if we had an equivalent for @property at module-level", nothing more. (Because with that, it would be pretty easy.) ChrisA From yasar11732 at gmail.com Mon Jul 21 14:38:49 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Mon, 21 Jul 2014 21:38:49 +0300 Subject: Event loop documentation error Message-ID: I was reading https://docs.python.org/3/library/asyncio-eventloop.html#example-set-signal-handlers-for-sigint-and-sigterm and wanted to test the example, however, I am getting this error when I run the code; Traceback (most recent call last): File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler raise NotImplementedError NotImplementedError I was wondering if there is something I am doing wrong, or is this behaviour platform specific (I am on windows 7). I wanted to ask in the list before I file a bug report. -- http://ysar.net/ From rosuav at gmail.com Mon Jul 21 14:45:05 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 04:45:05 +1000 Subject: Event loop documentation error In-Reply-To: References: Message-ID: On Tue, Jul 22, 2014 at 4:38 AM, Ya?ar Arabac? wrote: > Traceback (most recent call last): > File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in > loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) > File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler > raise NotImplementedError > NotImplementedError > > I was wondering if there is something I am doing wrong, or is this > behaviour platform specific (I am on windows 7). I wanted to ask in > the list before I file a bug report. SIGINT is a Unix signal. There is an equivalent for Windows, but it wouldn't at all surprise me if trying to hook signals raises NotImplementedError. See if there's a different way to hook Ctrl-C on Windows; if not, you may want to word your report as a feature request. ChrisA From yasar11732 at gmail.com Mon Jul 21 14:55:28 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Mon, 21 Jul 2014 21:55:28 +0300 Subject: Fwd: Event loop documentation error In-Reply-To: References: Message-ID: ---------- Forwarded message ---------- From: Ya?ar Arabac? Date: 2014-07-21 21:54 GMT+03:00 Subject: Re: Event loop documentation error To: Chris Angelico 2014-07-21 21:45 GMT+03:00 Chris Angelico : > SIGINT is a Unix signal. There is an equivalent for Windows, but it > wouldn't at all surprise me if trying to hook signals raises > NotImplementedError. See if there's a different way to hook Ctrl-C on > Windows; if not, you may want to word your report as a feature > request. > > ChrisA After reading the next page of the documentation, I realized that "add_signal_handler() and remove_signal_handler() are not supported" on Windows. Moreover, dev3.5 version of the docs are also saying that they are not supported, so I think they are not planning to supports those features on Windows anytime soon. In that case, should I make a bug report on docs that it should be mentioned on example that this feature is not supported on Windows. As for the feature request, I think there is a good reason that they didn't include it already. I will try to look into it, before making a feature request. -- http://ysar.net/ -- http://ysar.net/ From rosuav at gmail.com Mon Jul 21 15:00:10 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 05:00:10 +1000 Subject: Event loop documentation error In-Reply-To: References: Message-ID: On Tue, Jul 22, 2014 at 4:55 AM, Ya?ar Arabac? wrote: > After reading the next page of the documentation, I realized that > "add_signal_handler() and remove_signal_handler() are not supported" > on Windows. Moreover, dev3.5 version of the docs are also saying that > they are not supported, so I think they are not planning to supports > those features on Windows anytime soon. If I had to guess, I would say that the reason there's no Windows Ctrl-C handler would simply be that nobody's yet volunteered to write one. So you might be in a position to add what you want to 3.5 :) ChrisA From breamoreboy at yahoo.co.uk Mon Jul 21 15:15:00 2014 From: breamoreboy at yahoo.co.uk (Mark Lawrence) Date: Mon, 21 Jul 2014 20:15:00 +0100 Subject: Event loop documentation error In-Reply-To: References: Message-ID: On 21/07/2014 20:00, Chris Angelico wrote: > On Tue, Jul 22, 2014 at 4:55 AM, Ya?ar Arabac? wrote: >> After reading the next page of the documentation, I realized that >> "add_signal_handler() and remove_signal_handler() are not supported" >> on Windows. Moreover, dev3.5 version of the docs are also saying that >> they are not supported, so I think they are not planning to supports >> those features on Windows anytime soon. > > If I had to guess, I would say that the reason there's no Windows > Ctrl-C handler would simply be that nobody's yet volunteered to write > one. So you might be in a position to add what you want to 3.5 :) > > ChrisA > I'd check the bug tracker before doing anything. It's perfectly possible that somebody has already done this but the patch hasn't been reviewed yet. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com From rosuav at gmail.com Mon Jul 21 15:16:47 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 05:16:47 +1000 Subject: Event loop documentation error In-Reply-To: References: Message-ID: On Tue, Jul 22, 2014 at 5:15 AM, Mark Lawrence wrote: > On 21/07/2014 20:00, Chris Angelico wrote: >> >> On Tue, Jul 22, 2014 at 4:55 AM, Ya?ar Arabac? >> wrote: >>> >>> After reading the next page of the documentation, I realized that >>> "add_signal_handler() and remove_signal_handler() are not supported" >>> on Windows. Moreover, dev3.5 version of the docs are also saying that >>> they are not supported, so I think they are not planning to supports >>> those features on Windows anytime soon. >> >> >> If I had to guess, I would say that the reason there's no Windows >> Ctrl-C handler would simply be that nobody's yet volunteered to write >> one. So you might be in a position to add what you want to 3.5 :) >> >> ChrisA >> > > I'd check the bug tracker before doing anything. It's perfectly possible > that somebody has already done this but the patch hasn't been reviewed yet. Or that, yes. My point is, I doubt there's a strong philosophical reason for there to be a lack of support, but merely that it hasn't been done yet. ChrisA From tjreedy at udel.edu Mon Jul 21 15:16:48 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Jul 2014 15:16:48 -0400 Subject: PyWart(2.7.8) IDLE is more buggy than "Joe's apartment"! In-Reply-To: References: <232acf45-096d-466a-aa75-06d8c378b128@googlegroups.com> <53cc376e$0$2898$e4fe514c@news.xs4all.nl> <53926733-5e65-482f-96bc-0171c6a93d59@googlegroups.com> <4882fd4d-b772-4ebb-8aaa-0c20be6051b6@googlegroups.com> Message-ID: On 7/21/2014 10:27 AM, Grant Edwards wrote: > On 2014-07-21, Chris Angelico wrote: > >> You call it a bug because you can't think of any way it could be >> beneficial. That's the wrong way of looking at it. Something isn't a >> bug because you find it annoying; it's a bug because it fails to >> implement the programmer's intentions and/or the docs/specification. > > I was always taught that it's a "bug" is when a program doesn't do > what a reasonable user expects -- that it's got nothing to do with the > programmer's intent. For the Python issue tracker at bugs.python.org, one definition of a behavior ('bug') issue, one that might lead to a patch in maintenance releases of current versions, is a discrepancy between doc claim and code behavior. Discrepancies can be fixed by changing either doc or code to match the other, depending on which is considered to be wrong. Of course, sometime the doc is absent, partial, ambiguous, or confusing. People (such as Rick) proposing enhancements often consider matching code and doc to be buggy by design. But this is different type of issue. For Idle, the doc briefly specifies behavior at a high, user level. File / open should 'open an existing file'. A text box for entry of a path would minimally suffice. The current open file dialog adds the option of filling in the box by clicking around the directory tree. -- Terry Jan Reedy From wxjmfauth at gmail.com Mon Jul 21 16:00:26 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Mon, 21 Jul 2014 13:00:26 -0700 (PDT) Subject: Idle's Shell: prompts and indents (was ...) Idle users please read In-Reply-To: References: <53c73ff0$0$29897$c3e8da3$5496439d@news.astraweb.com> <9ef930a0-5a41-4a20-a13a-003c9e8246fe@googlegroups.com> <9b5557e3-45ea-4d3b-81cd-90d69322c556@googlegroups.com> <64e2ac85-5c95-4834-b140-2189b884fb02@googlegroups.com> Message-ID: Le lundi 21 juillet 2014 11:00:15 UTC+2, Terry Reedy a ?crit?: > On 7/20/2014 11:34 PM, Chris Angelico wrote: > > > On Mon, Jul 21, 2014 at 1:28 PM, Terry Reedy wrote: > > >> A few users have noticed (and complained) that setting sys.ps1 and sys.ps2 > > >> *in the batch mode user process* has no effect. The Idle doc should better > > >> explain why this is and should be. User code should not affect the > > >> operation of Idle. Idle is separately configured through dialogs. > > > > > > As I understand it, setting them has *absolutely* no effect, > > > currently, right? > > > > As far as I know, setting sys.ps1 and sys.ps2 have no effect in any > > batch mode program. This has nothing to do with Idle. > > > > > There's no situation in which it would be useful to > > > set them? In that case, it might be useful to put some magic in there > > > (although I'm not sure it's possible; can't use @property at top level > > > in a module) that gives a notification - pointing users to the dialog. > > > > In general, Idle should execute user code the same way that the > > interpreter does, subject to the limitations of the different execution > > environment. > > > > > No idea how you'd go about it, but telling someone when what s/he does > > > is useless can be helpful. > > > > What needs better documentation is what the execution environment is, > > and how the shell is different from a line-buffered console. > > ----- Just the coding of characters is making a gui application different from a console application. A gui application is living with its own coding, and not necessarly with the operating system coding. That's why in my py3* interactive interpreters, I have (I defined) very correctly things like this: >>> sys.stdout.encoding '' >>> sys.stderr.encoding '' >>> sys.stdin.encoding '' The "sys coding" is not the operating system, it is the "coding of the gui". In Py3, one does not pass or populate a text widget with an "encoded string", a string is passed directly as a "unicode type", because the gui is built to work like this. Something like an coding-less string. In the console ("dos-box"), the following is correct: >>> sys.stdout.encoding 'cp1252' ------ Generally, speaking, this is a perpetual annoyment (to be polite) in Python. Python is always attempting to find a solution for the "Python user", to enforce a coding usage instead of letting the user/programmer doing the task correctly. I'm not alone to think like this and I have seen many times people complaining about this. jmf From rxjwg98 at gmail.com Mon Jul 21 16:14:18 2014 From: rxjwg98 at gmail.com (fl) Date: Mon, 21 Jul 2014 13:14:18 -0700 (PDT) Subject: How to extract digit from a number? Message-ID: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> Hi, I see the following example on line, but it does not work. I do not know what is wrong. Could you correct it for me? Thanks, ........................ I'm not sure what [1, 1, 0, 0, 0, 0, ...] has to do with 128, but if you want the base 10 digits: >>> a = 1234 >>> [int(d) for d in str(a)] >>> [1, 2, 3, 4] From python.list at tim.thechases.com Mon Jul 21 16:26:25 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Jul 2014 15:26:25 -0500 Subject: How to extract digit from a number? In-Reply-To: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> References: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> Message-ID: <20140721152625.573bb830@bigbox.christie.dr> On 2014-07-21 13:14, fl wrote: > I see the following example on line, but it does not work. I do not > know what is wrong. Could you correct it for me? > > I'm not sure what [1, 1, 0, 0, 0, 0, ...] has to do with 128, but > if you want the base 10 digits: > > >>> a = 1234 > >>> [int(d) for d in str(a)] > >>> [1, 2, 3, 4] You don't specify *what* is wrong or what constitutes "does not work". If you provide an example of what you *do* want, folks here can help you get closer to the code you need to do what you intend. -tkc From rxjwg98 at gmail.com Mon Jul 21 16:42:26 2014 From: rxjwg98 at gmail.com (fl) Date: Mon, 21 Jul 2014 13:42:26 -0700 (PDT) Subject: How to extract digit from a number? In-Reply-To: References: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> Message-ID: On Monday, July 21, 2014 4:26:25 PM UTC-4, Tim Chase wrote: > On 2014-07-21 13:14, fl wrote: > You don't specify *what* is wrong or what constitutes "does not > work". If you provide an example of what you *do* want, folks here > can help you get closer to the code you need to do what you intend. > > -tkc The original source input is: >>> a = 1234 >>> [int(d) for d in str(a)] He hopes the output is: >>> [1, 2, 3, 4] In fact, I get the output is: >>> a = 1234 >>> [int(d) for d in str(a)] Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable BTW, I just add input: >>> import string The error is still there. Why does it say :"TypeError: 'str' object is not callable"? From rxjwg98 at gmail.com Mon Jul 21 16:46:13 2014 From: rxjwg98 at gmail.com (fl) Date: Mon, 21 Jul 2014 13:46:13 -0700 (PDT) Subject: How to use string constant? Message-ID: <2b1f7af1-1967-4610-a10c-d4ce625ec184@googlegroups.com> Hi, I learn string constant on Python tutorial at: https://docs.python.org/2/library/string.html Although it gives explanation, it does not show me any example usage. Could you give me an example on using these options? string.digits string.ascii_letters Thanks, From roy at panix.com Mon Jul 21 16:53:10 2014 From: roy at panix.com (Roy Smith) Date: Mon, 21 Jul 2014 16:53:10 -0400 Subject: How to extract digit from a number? References: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> Message-ID: In article , fl wrote: > >>> a = 1234 > >>> [int(d) for d in str(a)] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'str' object is not callable This looks like you've overwritten str with an *instance* of a string. When a python interpreter starts up, there are certain pre-defined symbols. For example, 'str' is bound to the string class. But, there's nothing to prevent you from re-defining it. Here's an example which produces the same result you got: --------------------------------------------------------------------- $ python Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> str = "foo" >>> a = 1234 >>> [int(d) for d in str(a)] Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable --------------------------------------------------------------------- From python.list at tim.thechases.com Mon Jul 21 16:57:00 2014 From: python.list at tim.thechases.com (Tim Chase) Date: Mon, 21 Jul 2014 15:57:00 -0500 Subject: How to extract digit from a number? In-Reply-To: References: <12e1f726-c083-49db-86bd-1c9ae3151b2a@googlegroups.com> Message-ID: <20140721155700.0ae4baf5@bigbox.christie.dr> On 2014-07-21 13:42, fl wrote: > The original source input is: > >>> a = 1234 > >>> [int(d) for d in str(a)] > > He hopes the output is: > >>> [1, 2, 3, 4] > > In fact, I get the output is: > > >>> a = 1234 > >>> [int(d) for d in str(a)] > Traceback (most recent call last): > File "", line 1, in > TypeError: 'str' object is not callable This sounds suspiciously like you have shadowed the str() function. You might search your code for something like str = "test" which shadows the built-in str() function. The code you have works at the command-line as long as you haven't shadowed the previously-existing str() function: $ python Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 1234 >>> [int(d) for d in str(a)] [1, 2, 3, 4] -tkc From lele at metapensiero.it Mon Jul 21 15:06:51 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Mon, 21 Jul 2014 21:06:51 +0200 Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> Message-ID: <871ttewmyc.fsf@nautilus.nautilus> Monte Milanuk writes: > On 2014-07-21, Lele Gaifax wrote: >> I manage small events with a single notebook and a low cost printer, >> without network connection, while major events with a network connection >> may be managed online. >> >> You can try it out at http://sol3.arstecnica.it/, using guest/guest as >> username/password. > > Wow. I have no idea how the game/events run, but that is a very nice > looking program! Thank you! > How hard was it to migrate from a desktop app to what you have now? Well, basically I rewrote everything, there's nothing in common. The original application was written in Delphi, using Paradox tables, no i18n, no multiuser, no PDF printouts... On the other hand, with Python is far easier to get something working, and databasing with SQLAlchemy is a pleasure. On the frontend, ExtJS is impressive, even if it has its own drawbacks. > Would you recommend this route for someone starting out? Yes, absolutely. You learn something that you can reuse over and over. Do not hesitate to ask for further hints. ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From tjreedy at udel.edu Mon Jul 21 17:50:57 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Jul 2014 17:50:57 -0400 Subject: Event loop documentation error In-Reply-To: References: Message-ID: On 7/21/2014 2:38 PM, Ya?ar Arabac? wrote: > I was reading https://docs.python.org/3/library/asyncio-eventloop.html#example-set-signal-handlers-for-sigint-and-sigterm > and wanted to test the example, With 3.4.0, 3.4.1, or 3.5.0a0 in the repository (available to view at hg.python.org, I believe)? Asyncio is patched at least once a week You can access the latest version of the 3.5 docs online (see the box in upper left corner) also to check how the example is written today. however, I am getting this error when > I run the code; > > Traceback (most recent call last): > File "C:/Users/gorki/Documents/Python Scripts/as-io.py", line 14, in > loop.add_signal_handler(SIGINT, partial(ask_exit, "SIGINT")) > File "C:\Python34\lib\asyncio\events.py", line 329, in add_signal_handler > raise NotImplementedError > NotImplementedError > > I was wondering if there is something I am doing wrong, or is this > behaviour platform specific (I am on windows 7). I wanted to ask in > the list before I file a bug report. > -- Terry Jan Reedy From tjreedy at udel.edu Mon Jul 21 17:52:20 2014 From: tjreedy at udel.edu (Terry Reedy) Date: Mon, 21 Jul 2014 17:52:20 -0400 Subject: How to use string constant? In-Reply-To: <2b1f7af1-1967-4610-a10c-d4ce625ec184@googlegroups.com> References: <2b1f7af1-1967-4610-a10c-d4ce625ec184@googlegroups.com> Message-ID: On 7/21/2014 4:46 PM, fl wrote: > Hi, > > I learn string constant on Python tutorial at: > https://docs.python.org/2/library/string.html > > Although it gives explanation, it does not show me any example usage. > > Could you give me an example on using these options? > > > string.digits > > string.ascii_letters >>> import string >>> 'a' in string.ascii_letters True >>> 'a' in string.digits False -- Terry Jan Reedy From yasar11732 at gmail.com Mon Jul 21 18:19:42 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Tue, 22 Jul 2014 01:19:42 +0300 Subject: asyncip application hangs Message-ID: I am trying to grasp how asyncio works today. Based on the examples that I found on the docs, I write a simple program like this; import asyncio import urllib.request import urllib.parse @asyncio.coroutine def print_status_code(url_q): while True: url = yield from url_q.get() print('URL recieved from q:', url) if url is None: return url = urllib.parse.urlsplit(url) reader, writer = yield from asyncio.open_connection(url.hostname, 80) query = ('GET {url.path} HTTP/1.0\r\n' 'Host: {url.hostname}\r\n' '\r\n').format(url=url) writer.write(query.encode('latin-1')) line = yield from reader.readline() code = line.decode('latin1').split()[0] print("(%s) %s", code, url.path) if __name__ == "__main__": from bs4 import BeautifulSoup as bs sitemap = urllib.request.urlopen('http://ysar.net/sitemap.xml').read() soup = bs(sitemap) print('soup created') tasks = [] num_coroutines = 10 q = asyncio.Queue() for i in range(num_coroutines): # start 10 tasks tasks.append(asyncio.Task(print_status_code(q))) for loc in soup.find_all('loc'): q.put(loc.string) for i in range(num_coroutines): # Put poison pil. q.put(None) loop = asyncio.get_event_loop() loop.run_until_complete(asyncio.wait(tasks)) This program is supposed to give me status codes for web pages that are found on my sitemap.xml file. But program hangs as Tasks wait for getting something out of the Queue. I think it has something to do with how I am using asyncio.Queue, but I couldn't figure out what am I doing wrong here. Can anyone help me with that? -- http://ysar.net/ From yasar11732 at gmail.com Mon Jul 21 18:34:57 2014 From: yasar11732 at gmail.com (=?UTF-8?B?WWHFn2FyIEFyYWJhY8Sx?=) Date: Tue, 22 Jul 2014 01:34:57 +0300 Subject: asyncip application hangs In-Reply-To: References: Message-ID: 2014-07-22 1:19 GMT+03:00 Ya?ar Arabac? : > This program is supposed to give me status codes for web pages that > are found on my sitemap.xml file. But program hangs as Tasks wait for > getting something out of the Queue. I think it has something to do > with how I am using asyncio.Queue, but I couldn't figure out what am I > doing wrong here. Can anyone help me with that? Ok, I figured out what was wrong with my code. Since asyncio.Queue.put() is a coroutine, I should have wrapped those with asyncio.Task in order for them to start executing. Therefore, this works; q = asyncio.Queue() loop = asyncio.get_event_loop() for i in range(num_coroutines): # start 10 tasks tasks.append(asyncio.Task(print_status_code(q))) for loc in soup.find_all('loc'): asyncio.Task(q.put(loc.string)) for i in range(num_coroutines): # Put poison pil. asyncio.Task(q.put(None)) print("%i items in queue" % q.qsize()) loop.run_until_complete(asyncio.wait(tasks)) -- http://ysar.net/ From memilanuk at invalid.com Mon Jul 21 18:53:14 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Mon, 21 Jul 2014 22:53:14 +0000 (UTC) Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: On 2014-07-21, Lele Gaifax wrote: > Monte Milanuk writes: >> How hard was it to migrate from a desktop app to what you have now? > > Well, basically I rewrote everything, there's nothing in common. The > original application was written in Delphi, using Paradox tables, no > i18n, no multiuser, no PDF printouts... On the other hand, with Python > is far easier to get something working, and databasing with SQLAlchemy > is a pleasure. On the frontend, ExtJS is impressive, even if it has its > own drawbacks. Any hints/opinions on what those drawbacks might be? I know literally almost nothing about JS. I worked thru a short generic tutorial a couple years ago, but nothing like these libraries I see people talking about now like jquery, angular, ext, and so on. Hence my hesitation at adding another learning curve on top of python and the various libraries needed for this first 'real' project. Monte From ben+python at benfinney.id.au Mon Jul 21 19:12:53 2014 From: ben+python at benfinney.id.au (Ben Finney) Date: Tue, 22 Jul 2014 09:12:53 +1000 Subject: A Pythonista Meets =?utf-8?Q?JavaScript=E2=84=A2?= (was: Network/multi-user program) References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: <85k376paq2.fsf_-_@benfinney.id.au> Monte Milanuk writes: > I know literally almost nothing about JS. At the Melbourne Python Users's Group this year, I gave a presentation on my initial learnings of JavaScript? (and ECMAScript) from a Python programmer's perspective. Hope that's useful to anyone interested in the intersection of these languages and their cultures. -- \ ?If consumers even know there's a DRM, what it is, and how it | `\ works, we've already failed.? ?Peter Lee, Disney corporation, | _o__) 2005 | Ben Finney From roy at panix.com Mon Jul 21 19:15:15 2014 From: roy at panix.com (Roy Smith) Date: Mon, 21 Jul 2014 19:15:15 -0400 Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: In article , Monte Milanuk wrote: > Any hints/opinions on what those drawbacks might be? I know literally > almost nothing about JS. I worked thru a short generic tutorial a couple > years ago, but nothing like these libraries I see people talking about > now like jquery, angular, ext, and so on. Hence my hesitation at adding > another learning curve on top of python and the various libraries needed > for this first 'real' project. In the beginning, there was javascript. It was used to do cutesy little things like animated U/I elements and perform certain actions when your browser detected events like clicking on a button or moving the mouse cursor over an image. But, javascript is a real (if bletcherous) programming language. It's got functions and variables and loops and if statements and classes (OK, it doesn't really have classes, but it has things that we can pretend are classes, if we squint hard). It can talk to the network and generate HTML on the fly. So, people started building a whole new kind of web site. Instead of having an application running on the server which spits out HTML and CSS, and little bits of javascript to tweak those, we've got a full-blown javascript application running in the browser. That application is retrieving data from the server, doing useful things with it, and totally managing the HTML that you see rendered in your browser window. Things like jquery and (even more so) angular, backbone, ember, etc, are frameworks which make it easier to write these applications, in much the same way frameworks like django make it easier to write server-side web applications in Python. The truly sucky part of this picture is that javascript is a horrible language, but you have no choice. It's the only thing that runs in browsers. On the server side, if you don't like Python, you can write your app in Java, or Go, or Ruby, or a host of other languages (even javascript, if you want). On the client side, no so much. From electronixtar at gmail.com Mon Jul 21 22:00:28 2014 From: electronixtar at gmail.com (est) Date: Tue, 22 Jul 2014 10:00:28 +0800 Subject: async, on-demand lazy rendering for jinja2 possible? Message-ID: Hi all, Been reading @igrigorik's posts https://www.igvita.com/archives/ I found that flush response as early as possible is crucial for a website performance. I wanna make Time To First Byte (TTTFB) happen as early as possible with a Jinja2 site, Suppose a typical Jinja2 template: {{ site_title }}
    {% for item in items %}
  • item
  • {% endfor %}
Let's presume site_title is static and known in view function from the start, I wanna flush everything before to the client as early as possible, then items was a query from db, it's kinda slower, let's flush the everything below later in a second TCP packet. This looks like impossible at the moment. I searched the Jinja2 docs, the closest thing I've found is the streaming template API jinja2.Template('Hello {{ name }}!').stream(name='foo') Which still requires all variables to be ready before rendering. Is there a way to stream partial template results with partial template variables? This would be great help making faster websites. Other template engine than Jinja2 is welcome as long as it's in python! Thanks in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: From miki.tebeka at gmail.com Tue Jul 22 01:05:57 2014 From: miki.tebeka at gmail.com (Miki Tebeka) Date: Mon, 21 Jul 2014 22:05:57 -0700 (PDT) Subject: Installing Python 2.6.2 on Ubuntu 12.1 In-Reply-To: References: Message-ID: Greetings, > The installation went through successfully, however I > noticed that some of the _*.so files did not get built under > lib/python2.6/lib-dynload/ folder (eg _sha256.so) , which is likely the reason > why my setuptools install failed due to the error: I believe you need the developer libraries for that (including the C header files). IIRC "sudo apt-get build-dep python" should install all the required packages. HTH, -- Miki From frank at chagford.com Tue Jul 22 02:18:08 2014 From: frank at chagford.com (Frank Millman) Date: Tue, 22 Jul 2014 08:18:08 +0200 Subject: Unicode, stdout, and stderr Message-ID: Hi all This is not important, but I would appreciate it if someone could explain the following, run from cmd.exe on Windows Server 2003 - C:\>python Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (In tel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = '\u2119' >>> x # this uses stderr '\u2119' >>> print(x) # this uses stdout Traceback (most recent call last): File "", line 1, in File "C:\Python34\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in position 0: character maps to >>> It seems that there is a difference between writing to stdout and writing to stderr. My questions are - 1. What is the difference? 2. Is there an easy way to get stdout to behave the same as stderr? Thanks Frank Millman From lele at metapensiero.it Tue Jul 22 02:32:20 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 08:32:20 +0200 Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: <87ppgx29aj.fsf@nautilus.nautilus> Monte Milanuk writes: > On 2014-07-21, Lele Gaifax wrote: >> Monte Milanuk writes: >>> How hard was it to migrate from a desktop app to what you have now? >> >> Well, basically I rewrote everything, there's nothing in common. The >> original application was written in Delphi, using Paradox tables, no >> i18n, no multiuser, no PDF printouts... On the other hand, with Python >> is far easier to get something working, and databasing with SQLAlchemy >> is a pleasure. On the frontend, ExtJS is impressive, even if it has its >> own drawbacks. > > Any hints/opinions on what those drawbacks might be? I know literally > almost nothing about JS. I worked thru a short generic tutorial a couple > years ago, but nothing like these libraries I see people talking about > now like jquery, angular, ext, and so on. Hence my hesitation at adding > another learning curve on top of python and the various libraries needed > for this first 'real' project. I completely agree with Roy on the language itself, it has several tricky parts that require some training to learn how to avoid, "defects" that are inherent to language and to the syntax, that no framework or library can really eliminate. There is a very good book by Douglas Crockford, "JS: the good parts" that I recommend reading. On the framework, ExtJS is the one I know better and its quite good and powerful: it has a dual license, GPL for free software projects and a commercial version, very good documentation and a lot of users. My main complaint is about their (Sencha's) release policy which frankly sucks, on both sides (free and commercial): they do not have a clear roadmap, you report bugs in a forum and from then on you cannot know if and when the bug gets fixed, or even released. They do not promise any kind of backward compatibility, and several times they irremediably broke the internal implementation of a few widgets I used from one minor version to the next and eventually released a proper fix only for the commercial version. They assert to have an extensive suite of unit and functional tests, but sometime I have the doubt they do not run it as often as one would expect :-) On the other hand, it has good and extensive examples, so the learning curve is not so steep (I'm clearly biased here, but I introduced several young developers to that environment and that's what they said too). Anyway, don't be scared: start on the Python side, laying down the foundations of the application, the database model, the main business logic, unit and functional tests, and so on. Any kind of frontend, be it a traditional desktop application or a web based one will build on that. ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From dihedral88888 at gmail.com Tue Jul 22 02:41:49 2014 From: dihedral88888 at gmail.com (CHIN Dihedral) Date: Mon, 21 Jul 2014 23:41:49 -0700 (PDT) Subject: Network/multi-user program In-Reply-To: References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: > > almost nothing about JS. I worked thru a short generic tutorial a couple > Please check Pyjs and Python with flash in http://pyjs.org/examples/Space.html for the front end part of GUI under a browser. From lele at metapensiero.it Tue Jul 22 02:49:13 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 08:49:13 +0200 Subject: Unicode, stdout, and stderr References: Message-ID: <87lhrl28ie.fsf@nautilus.nautilus> "Frank Millman" writes: > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit > (In > tel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> x = '\u2119' >>>> x # this uses stderr > '\u2119' >>>> print(x) # this uses stdout > Traceback (most recent call last): > File "", line 1, in > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > position > 0: character maps to >>>> No, both statements actually emit noise on the standard output, but the former prints the *repr* of the string, the latter tries to encode it to CP437, which you console seems to be using. One approach could be changing the "code page" (that is, the encoding) of the "terminal" (see the "chcp" command), to select one that actually have that glyph. But I'm really guessing here... ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From stuffstorehouse2014 at gmail.com Tue Jul 22 02:47:42 2014 From: stuffstorehouse2014 at gmail.com (stuffstorehouse2014 at gmail.com) Date: Mon, 21 Jul 2014 23:47:42 -0700 (PDT) Subject: Top online steroid pharmacies - 2009 Best Site! In-Reply-To: References: Message-ID: <715b2732-4446-43f8-897e-904d3b5789de@googlegroups.com> GET A GOOD LOOKING AND SEXY BODY HERE We are suppliers and whole sellers chemical supplements. BEFORE WE SUPPLY TO YOU MAKE SURE YOU ARE NOT UNDER 18. we supply chemical supplements such as HIGH QUALITY STEROID HORMONES, HGH ,SEX PILLS, HIGH QUALITY PAIN KILLERS, MEDICAL KUSH AND HIGH QUALITY KUSH, ACTIVIS PURPLE SYRUPS OF ALL CATEGORIES. we sell high quality KATAMIN, XANAX PILLS NEMBROTER and also some high quality weight loss products. Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com We have agents located in the Germany , USA, Asia, and others.we sell high quality chemical supplements and at the best prices. we provide prescriptions to body builders and to those who are novice in the field, we do prescription for free. Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com we also supply chemical supplements and also top quality powder and crystals such as -high quality 2ci and 2ce 2ci, 2CP 2CE ,2CB 2CD,FLY 2CC ,2CP 2CT21, 2CT4 Meo-crystal and powder 5-Meo-DMT 4-Aco-DMT 4-Ho-MIPT 5-Methylmethylone crystal and powder 5-Methylethylone 2-Methylbutylone 5-Methylbutylone Butylone Eutylone Pentylone -Grade(?.96) Mephedrone (2- methylamino 1-one also known as 4-methylmethcathinone(4-MMC).We are one of the top suppliers in wholesale and retail of mephedrone and Mephedrone crystal and powder methedrone Flephedrone Mathedrone Buphedrone Ethedrone Brephedrone Mdma and BK mdma crystals and powder methylone butylone NAPHYRONE MBDB Mdai 5-Methylmethylone crystal and powder 5-Methylethylone 2-Methylbutylone 5-Methylbutylone Butylone Eutylone Pentylone 4-MEC large and small crystals ( (RS)-1-(4-methylphenyl)- 2-methylaminopropan-1-one ). methamphetamine detrophetamine Ethcathinone Methoxetamine Dimethocaine Dimethylcathinone crystal and powder Diethylpropion Methcathinone Ethcathinone 3-MMC,3-MEC,3-EMC 3-EEC,4-EMC,4-EEC 3-MOMC,2-FMC,2-FEC,a-PVP 3-FMC,3-FEC,3-CMC, FPVP 3-BMC,N,N-DEMC,3,4-DMMC 4-MePPP,MOPPP, FPPP MPBP,MPHP,MDPPP, MDPBP Powder and crystals AM 2201 AM2202 am1220 am122 compliments of 2ci and 2ce 2ci, 2CP 2CE ,2CB 2CD,FLY 2CC ,2CP 2CT21, 2CT4 compliments of jwh- JWH-018 , JWH-250 JWH-018,JWH-073 JWH-200,JWH-250 JWH-240,jwh-350 compliments of Meo-crystal and powder 5-Meo-DMT 4-Aco-DMT 4-Ho-MIPT 4 Our quality is the best you can find around and we sell in small/large quantities with guaranteed discreet delivery in good time Shipping is done Via DHL TNT FedEx.Please Do Include Your Contact Number . All inquiries are welcomed at Text or call us on (407)-4852249 Email: stuffstorehouse2014(AT)gmail.com From wxjmfauth at gmail.com Tue Jul 22 02:54:01 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Mon, 21 Jul 2014 23:54:01 -0700 (PDT) Subject: Unicode, stdout, and stderr In-Reply-To: References: Message-ID: Le mardi 22 juillet 2014 08:18:08 UTC+2, Frank Millman a ?crit?: > Hi all > > > > This is not important, but I would appreciate it if someone could explain > > the following, run from cmd.exe on Windows Server 2003 - > > > > C:\>python > > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit > > (In > > tel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> x = '\u2119' > > >>> x # this uses stderr > > '\u2119' > > >>> print(x) # this uses stdout > > Traceback (most recent call last): > > File "", line 1, in > > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > > position > > 0: character maps to > > >>> > > > > It seems that there is a difference between writing to stdout and writing to > > stderr. My questions are - > > > > 1. What is the difference? > > > > 2. Is there an easy way to get stdout to behave the same as stderr? > > > %%%%%%%%%% This is an example of what I explained in my last msg in the "Python 3 is killing Python". Quote of my comment: "Generally, speaking, this is a perpetual annoyment (to be polite) in Python. Python is always attempting to find a solution for the "Python user", to enforce a coding usage instead of letting the user/programmer doing the task correctly. I'm not alone to think like this and I have seen many times people complaining about this." ---- Something different. >>> x = '\u2119' >>> x # this uses stderr This not stderr, but stdout (I doubt you redirected it). What you see is the *representation* of x >>> print(x) # this uses stdout Correct. This is supposed to print, understand desplay, the "x as litteral" (I do not find a proper name). Solution: Work properly. Undestand the coding of chars eco-system as a whole correctly. In short: *encode* I explained that many times (including on wx-list). jmf From lele at metapensiero.it Tue Jul 22 02:59:27 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 08:59:27 +0200 Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> Message-ID: <87ha29281c.fsf@nautilus.nautilus> CHIN Dihedral writes: >> > almost nothing about JS. I worked thru a short generic tutorial a couple >> > Please check Pyjs and Python with flash > in http://pyjs.org/examples/Space.html > for the front end part of GUI under a > browser. > Yes, that's an option: I used Pyjamas (btw, did it survive the schism?) to build one non trivial application, and while it allows using the language we all know and love, it introduces one more step of indirection between you and the actual code that the browser run, so in the end I didn't repeat the experience. ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From steve at pearwood.info Tue Jul 22 02:58:30 2014 From: steve at pearwood.info (Steven D'Aprano) Date: 22 Jul 2014 06:58:30 GMT Subject: Unicode, stdout, and stderr References: Message-ID: <53ce0b96$0$29897$c3e8da3$5496439d@news.astraweb.com> On Tue, 22 Jul 2014 08:18:08 +0200, Frank Millman wrote: > Hi all > > This is not important, but I would appreciate it if someone could > explain the following, run from cmd.exe on Windows Server 2003 - > > C:\>python > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 > bit (In > tel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> x = '\u2119' >>>> x # this uses stderr > '\u2119' What makes you think it uses stderr? To the best of my knowledge, it uses stdout. >>>> print(x) # this uses stdout > Traceback (most recent call last): > File "", line 1, in > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > position 0: character maps to I think your problem is that print tries to encode the string to your terminal's encoding, which appears to be CP-437 ("MS DOS" code page). Can you convince cmd.exe to use UTF-8? That should fix the problem. (Although apparently Window's handling of UTF-8 is buggy, so it will create many wonderful new problems, yay!) http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how http://stackoverflow.com/questions/14109024/how-to-make-unicode-charset-in-cmd-exe-by-default http://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8 > It seems that there is a difference between writing to stdout and > writing to stderr. I would be surprised if that were the case, but I don't have a Windows box to test it. Try this: import sys print(x, file=sys.stderr) # I expect this will fail print(repr(x), file=sys.stdout) # I expect this will succeed -- Steven From frank at chagford.com Tue Jul 22 03:06:15 2014 From: frank at chagford.com (Frank Millman) Date: Tue, 22 Jul 2014 09:06:15 +0200 Subject: Unicode, stdout, and stderr References: <87lhrl28ie.fsf@nautilus.nautilus> Message-ID: "Lele Gaifax" wrote in message news:87lhrl28ie.fsf at nautilus.nautilus... > "Frank Millman" writes: > >> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 >> bit >> (In >> tel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> x = '\u2119' >>>>> x # this uses stderr >> '\u2119' >>>>> print(x) # this uses stdout >> Traceback (most recent call last): >> File "", line 1, in >> File "C:\Python34\lib\encodings\cp437.py", line 19, in encode >> return codecs.charmap_encode(input,self.errors,encoding_map)[0] >> UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in >> position >> 0: character maps to >>>>> > > No, both statements actually emit noise on the standard output, but the > former prints the *repr* of the string, the latter tries to encode it to > CP437, which you console seems to be using. > Thanks, Lele, but I don't think that is quite right - see my separate response to Steven Frank From wxjmfauth at gmail.com Tue Jul 22 03:07:18 2014 From: wxjmfauth at gmail.com (wxjmfauth at gmail.com) Date: Tue, 22 Jul 2014 00:07:18 -0700 (PDT) Subject: Unicode, stdout, and stderr In-Reply-To: References: Message-ID: Le mardi 22 juillet 2014 08:18:08 UTC+2, Frank Millman a ?crit?: > Hi all > > > > This is not important, but I would appreciate it if someone could explain > > the following, run from cmd.exe on Windows Server 2003 - > > > > C:\>python > > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit > > (In > > tel)] on win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> x = '\u2119' > > >>> x # this uses stderr > > '\u2119' > > >>> print(x) # this uses stdout > > Traceback (most recent call last): > > File "", line 1, in > > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > > position > > 0: character maps to > > >>> > > > > It seems that there is a difference between writing to stdout and writing to > > stderr. My questions are - > > > > 1. What is the difference? > > > > 2. Is there an easy way to get stdout to behave the same as stderr? > > > %%%%%%%%%%% Again, from my "magic" interactive intepreter. >>> x = 'a\u2119z' >>> sys.stdout.encoding '' >>> x 'a?z' >>> sys.stdout.encoding = 'cp437' >>> print(x) Traceback (most recent call last): File "", line 1, in File "D:\jm\jmpy\eta\eta41beta1\etastdio.py", line 158, in write s = s.encode(self.pencoding).decode('cp1252') File "c:\python32\lib\encodings\cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in position 1: character maps to >>> print(x.encode(sys.stdout.encoding, 'replace')) 'a?z' >>> # voil?, no error jmf From frank at chagford.com Tue Jul 22 03:15:39 2014 From: frank at chagford.com (Frank Millman) Date: Tue, 22 Jul 2014 09:15:39 +0200 Subject: Unicode, stdout, and stderr References: <53ce0b96$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: "Steven D'Aprano" wrote in message news:53ce0b96$0$29897$c3e8da3$5496439d at news.astraweb.com... > On Tue, 22 Jul 2014 08:18:08 +0200, Frank Millman wrote: > >> Hi all >> >> This is not important, but I would appreciate it if someone could >> explain the following, run from cmd.exe on Windows Server 2003 - >> >> C:\>python >> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 >> bit (In >> tel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> x = '\u2119' >>>>> x # this uses stderr >> '\u2119' > > > What makes you think it uses stderr? To the best of my knowledge, it uses > stdout. > This is from the docs on sys.stdxxx sys.stdin sys.stdout sys.stderr File objects used by the interpreter for standard input, output and errors: - stdin is used for all interactive input (including calls to input()); - stdout is used for the output of print() and expression statements and for the prompts of input(); - The interpreter's own prompts and its error messages go to stderr. > >> It seems that there is a difference between writing to stdout and >> writing to stderr. > > I would be surprised if that were the case, but I don't have a Windows > box to test it. Try this: > > > import sys > print(x, file=sys.stderr) # I expect this will fail It does not fail. > print(repr(x), file=sys.stdout) # I expect this will succeed > It fails. The clue that led me to stderr is that the logging module displays unicode strings to the console without a problem. I delved into the source code, and found that it writes to stderr. When I changed mine to stderr, it also worked. Frank From __peter__ at web.de Tue Jul 22 03:19:49 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 22 Jul 2014 09:19:49 +0200 Subject: Unicode, stdout, and stderr References: Message-ID: Frank Millman wrote: > Hi all > > This is not important, but I would appreciate it if someone could explain > the following, run from cmd.exe on Windows Server 2003 - > > C:\>python > Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 > bit (In > tel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> x = '\u2119' >>>> x # this uses stderr > '\u2119' No, both print to stdout, but just >>> x is passed to the display hook of the interactive interpreter. This applies repr() and then tries to print the result. If this fails it makes another effort, roughly (the actual code is written in C) sys.stdout.buffer.write(repr(x).encode( sys.stdout.encoding, "backslashreplace")) >>>> print(x) # this uses stdout > Traceback (most recent call last): > File "", line 1, in > File "C:\Python34\lib\encodings\cp437.py", line 19, in encode > return codecs.charmap_encode(input,self.errors,encoding_map)[0] > UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in > position > 0: character maps to >>>> > > It seems that there is a difference between writing to stdout and writing > to stderr. My questions are - > > 1. What is the difference? > > 2. Is there an easy way to get stdout to behave the same as stderr? You could set the PYTHONIOENCODING environment variable with an error handler: [simulating the behaviour you are seeing on a linux/utf-8 machine] $ PYTHONIOENCODING=cp437 python3.4 Python 3.4.0rc1+ (default:16384988a526+, Mar 11 2014, 16:56:15) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> "\u2112" '\u2112' >>> print("\u2112") Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/encodings/cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2112' in position 0: character maps to >>> [the proposed fix] $ PYTHONIOENCODING=cp437:backslashreplace python3.4 Python 3.4.0rc1+ (default:16384988a526+, Mar 11 2014, 16:56:15) [GCC 4.8.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> "\u2112" '\u2112' >>> print("\u2112") \u2112 From lele at metapensiero.it Tue Jul 22 03:20:51 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 09:20:51 +0200 Subject: Unicode, stdout, and stderr References: <87lhrl28ie.fsf@nautilus.nautilus> Message-ID: <87d2cx271o.fsf@nautilus.nautilus> "Frank Millman" writes: >> No, both statements actually emit noise on the standard output, but the >> former prints the *repr* of the string, the latter tries to encode it to >> CP437, which you console seems to be using. >> > > Thanks, Lele, but I don't think that is quite right - see my separate > response to Steven Maybe sent as a private message? I do not see it, neither on the newsgroup I'm reading, nor in the mailing list archives... ciao, lele. BTW: checking the mailing list, I somewhat appreciate that the usual unicode spam(mer) doesn't reach the newsgroup anymore... :-) -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From lele at metapensiero.it Tue Jul 22 03:36:10 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 09:36:10 +0200 Subject: Unicode, stdout, and stderr References: <53ce0b96$0$29897$c3e8da3$5496439d@news.astraweb.com> Message-ID: <878unl26c5.fsf@nautilus.nautilus> "Frank Millman" writes: > "Steven D'Aprano" wrote in message > news:53ce0b96$0$29897$c3e8da3$5496439d at news.astraweb.com... >> I would be surprised if that were the case, but I don't have a Windows >> box to test it. Try this: >> >> >> import sys >> print(x, file=sys.stderr) # I expect this will fail > > It does not fail. Effectively it does not, but for some reason it actually print the repr() of the string. >> print(repr(x), file=sys.stdout) # I expect this will succeed >> > > It fails. This surprises me as well, why does it fail here? >>> repr('\u2119') "'\u2119'" >>> print(repr('\u2119')) Traceback ... UnicodeEncodeError ... On GNU/Linux, I get: >>> repr('\u2119') "'?'" >>> print(repr('\u2119')) '?' Uhm, it must be related to the fact that on Py3 the repr() of something is a unicode object too, so the output machinery tries to encode it to the output encoding.... Still, I miss the difference between stdout and stderr (both are cp437, accordingly to sys.xxx.encoding). ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From frank at chagford.com Tue Jul 22 03:37:36 2014 From: frank at chagford.com (Frank Millman) Date: Tue, 22 Jul 2014 09:37:36 +0200 Subject: Unicode, stdout, and stderr References: <87lhrl28ie.fsf@nautilus.nautilus> <87d2cx271o.fsf@nautilus.nautilus> Message-ID: "Lele Gaifax" wrote in message news:87d2cx271o.fsf at nautilus.nautilus... > "Frank Millman" writes: > >>> No, both statements actually emit noise on the standard output, but the >>> former prints the *repr* of the string, the latter tries to encode it to >>> CP437, which you console seems to be using. >>> >> >> Thanks, Lele, but I don't think that is quite right - see my separate >> response to Steven > > Maybe sent as a private message? I do not see it, neither on the > newsgroup I'm reading, nor in the mailing list archives... > I can see it on gmane. Maybe just give it some time. Frank From lele at metapensiero.it Tue Jul 22 03:38:51 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 09:38:51 +0200 Subject: Unicode, stdout, and stderr References: Message-ID: <874my9267o.fsf@nautilus.nautilus> Peter Otten <__peter__ at web.de> writes: > No, both print to stdout, but just > >>>> x > > is passed to the display hook of the interactive interpreter. This applies > repr() and then tries to print the result. If this fails it makes another > effort, roughly (the actual code is written in C) > > sys.stdout.buffer.write(repr(x).encode( > sys.stdout.encoding, "backslashreplace")) Ah-moment! Thanks, ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From frank at chagford.com Tue Jul 22 03:41:38 2014 From: frank at chagford.com (Frank Millman) Date: Tue, 22 Jul 2014 09:41:38 +0200 Subject: Unicode, stdout, and stderr References: Message-ID: "Peter Otten" <__peter__ at web.de> wrote in message news:lql3am$2q7$1 at ger.gmane.org... > Frank Millman wrote: > >> Hi all >> >> This is not important, but I would appreciate it if someone could explain >> the following, run from cmd.exe on Windows Server 2003 - >> >> C:\>python >> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 >> bit (In >> tel)] on win32 >> Type "help", "copyright", "credits" or "license" for more information. >>>>> x = '\u2119' >>>>> x # this uses stderr >> '\u2119' > > No, both print to stdout, but just > >>>> x > > is passed to the display hook of the interactive interpreter. This applies > repr() and then tries to print the result. If this fails it makes another > effort, roughly (the actual code is written in C) > > sys.stdout.buffer.write(repr(x).encode( > sys.stdout.encoding, "backslashreplace")) > > Thanks, Peter. Very interesting. Out of interest, does the same thing happen when writing to sys.stderr? Frank From memilanuk at invalid.com Tue Jul 22 03:54:56 2014 From: memilanuk at invalid.com (Monte Milanuk) Date: Tue, 22 Jul 2014 07:54:56 +0000 (UTC) Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> <87ppgx29aj.fsf@nautilus.nautilus> Message-ID: On 2014-07-22, Lele Gaifax wrote: > On the other hand, it has good and extensive examples, so the learning > curve is not so steep (I'm clearly biased here, but I introduced several > young developers to that environment and that's what they said too). Any experience with angular js? Browsing the web showed a few mentions of it vs. ext js. Mostly I'm still at the curious stage on this... either one is completely foreign to anything I've done before. > Anyway, don't be scared: start on the Python side, laying down the > foundations of the application, the database model, the main business > logic, unit and functional tests, and so on. Any kind of frontend, be it > a traditional desktop application or a web based one will build on that. Well... thats part of where my lack of experience with js or complex projects using anything other than just python is going to show: initially I thought javascript was just for buttons/effects in the client browser as thats all the trivial examples I looked at years ago did. The bits n pieces I'm seeing of these 'modern' javascript MVC frameworks like sencha, angular, etc. is making me think that a lot of the 'work' is moving from the server to the client via the javascript... which just blurs the heck out of things and confuses me as to what should be in the browser and what should be on the 'server'? And where the testing goes? If more of the 'heavy lifting' is being done on the client, is there a need for a full-service python framework like django or would something lightweight like flask be more appropriate? Again, I know almost nothing about pyramid and where it falls into the mix. I can read the propaganda on their respective web sites, but that is necessarily skewed. :/ Monte From lele at metapensiero.it Tue Jul 22 04:50:44 2014 From: lele at metapensiero.it (Lele Gaifax) Date: Tue, 22 Jul 2014 10:50:44 +0200 Subject: Network/multi-user program References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> <87ppgx29aj.fsf@nautilus.nautilus> Message-ID: <87zjg1zsij.fsf@nautilus.nautilus> Monte Milanuk writes: > On 2014-07-22, Lele Gaifax wrote: >> On the other hand, it has good and extensive examples, so the learning >> curve is not so steep (I'm clearly biased here, but I introduced several >> young developers to that environment and that's what they said too). > > Any experience with angular js? Browsing the web showed a few mentions > of it vs. ext js. Mostly I'm still at the curious stage on this... > either one is completely foreign to anything I've done before. Very, very little. I evaluated it quickly, but then my boss at the time "dictated" the Pyjamas route... >> Anyway, don't be scared: start on the Python side, laying down the >> foundations of the application, the database model, the main business >> logic, unit and functional tests, and so on. Any kind of frontend, be it >> a traditional desktop application or a web based one will build on that. > > Well... thats part of where my lack of experience with js or complex > projects using anything other than just python is going to show: > initially I thought javascript was just for buttons/effects in the > client browser as thats all the trivial examples I looked at years ago > did. The bits n pieces I'm seeing of these 'modern' javascript MVC > frameworks like sencha, angular, etc. is making me think that a lot of > the 'work' is moving from the server to the client via the javascript... > which just blurs the heck out of things and confuses me as to what > should be in the browser and what should be on the 'server'? And where > the testing goes? Yes, that is effectively the fuzzy dichotomy you'll have to deal with. >From my point of view, I tend to see the JS frontend as the GUI library that I use to "draw" the application, and I try to keep it separate from the "logic" as much as I can. It does not matter if the GUI is written in JS, GTK+, curses, NeXTstep or Delphi: it has been *always* a nightmare to implement serious automatic tests on that side of all my apps, and that's the main reason I keep complicated things on the backend side. And you know, with Python even complicated things are manageable. > If more of the 'heavy lifting' is being done on the > client, is there a need for a full-service python framework like django > or would something lightweight like flask be more appropriate? Again, I > know almost nothing about pyramid and where it falls into the mix. I > can read the propaganda on their respective web sites, but that is > necessarily skewed. :/ Even if I used some Django apps, I never developed anything with it: it does not seem a good choice for the kind of applications I happen to write. Its main selling point is the somewhat automatic CRUD view generation, something I'm always going to implement in other ways anyway. Its main "no thank you" point is the hassle with its "son of a minor god" ORM. I started using Flask for a couple of applications that at first appeared to be "very simple", but actually most of the time any application seems "simple enough" at first but very quickly become "complicated enough" to warrant a better infrastructure: after a few weeks I retargeted them to Pyramid, which I find robust, well documented and versatile. ciao, lele. -- nickname: Lele Gaifax | Quando vivr? di quello che ho pensato ieri real: Emanuele Gaifas | comincer? ad aver paura di chi mi copia. lele at metapensiero.it | -- Fortunato Depero, 1929. From __peter__ at web.de Tue Jul 22 05:09:37 2014 From: __peter__ at web.de (Peter Otten) Date: Tue, 22 Jul 2014 11:09:37 +0200 Subject: Unicode, stdout, and stderr References: Message-ID: Frank Millman wrote: > > "Peter Otten" <__peter__ at web.de> wrote in message > news:lql3am$2q7$1 at ger.gmane.org... >> Frank Millman wrote: >> >>> Hi all >>> >>> This is not important, but I would appreciate it if someone could >>> explain the following, run from cmd.exe on Windows Server 2003 - >>> >>> C:\>python >>> Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 >>> bit (In >>> tel)] on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>>>>> x = '\u2119' >>>>>> x # this uses stderr >>> '\u2119' >> >> No, both print to stdout, but just >> >>>>> x >> >> is passed to the display hook of the interactive interpreter. This >> applies >> repr() and then tries to print the result. If this fails it makes >> another effort, roughly (the actual code is written in C) >> >> sys.stdout.buffer.write(repr(x).encode( >> sys.stdout.encoding, "backslashreplace")) >> >> > > Thanks, Peter. Very interesting. > > Out of interest, does the same thing happen when writing to sys.stderr? If you are asking about the fallback mechanism, that is specific to sys.displayhook in the interactive interpreter. But stdout and stderr do handle errors differently: >>> import sys >>> sys.stdout.errors 'strict' >>> sys.stderr.errors 'backslashreplace' So a codepoint written to stdout that cannot be encoded with stdout.encoding raises an error while a codepoint written to stderr that cannot be encoded with stderr.encoding is escaped. Another way to make stdout more forgiving: >>> import sys >>> print("\u2119") Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.4/encodings/cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2119' in position 0: character maps to >>> sys.stdout = open(1, mode="w", errors="xmlcharrefreplace", encoding=sys.stdout.encoding, closefd=False) >>> print("\u2119") ℙ From rosuav at gmail.com Tue Jul 22 05:18:42 2014 From: rosuav at gmail.com (Chris Angelico) Date: Tue, 22 Jul 2014 19:18:42 +1000 Subject: Network/multi-user program In-Reply-To: References: <87a982wtoq.fsf@nautilus.nautilus> <871ttewmyc.fsf@nautilus.nautilus> <87ppgx29aj.fsf@nautilus.nautilus> Message-ID: On Tue, Jul 22, 2014 at 5:54 PM, Monte Milanuk wrote: > Well... thats part of where my lack of experience with js or complex > projects using anything other than just python is going to show: > initially I thought javascript was just for buttons/effects in the > client browser as thats all the trivial examples I looked at years ago > did. The bits n pieces I'm seeing of these 'modern' javascript MVC > frameworks like sencha, angular, etc. is making me think that a lot of > the 'work' is moving from the server to the client via the javascript... > which just blurs the heck out of things and confuses me as to what > should be in the browser and what should be on the 'server'? And where > the testing goes? If more of the 'heavy lifting' is being done on the > client, is there a need for a full-service python framework like django > or would something lightweight like flask be more appropriate? Again, I > know almost nothing about pyramid and where it falls into the mix. I > can read the propaganda on their respective web sites, but that is > necessarily skewed. :/ Lots of things getting messed in together here, so I'm going to start right back at some basics. You probably know some of what I'm going to say already, but I'm not sure exactly how much, so I'll just say it anyway. Hopefully this won't be TOO long. :) Communication between the server and the client is over HTTP. (Usually. I'm ignoring SPDY and other protocols, and I'm also ignoring the distinction with HTTPS, which just adds an encryption layer and doesn't affect any of this.) HTTP is a stateless protocol, where the client sends a request to the server and the server sends back a response. Simple, and works really beautifully for the simple case where you just want a page. If you go to http://rosuav.com/hymns/LetHerGo2.png in your browser, it sends a request "GET /hymns/LetHerGo2.png" to my server, and my server responds with "\x89PNG" and about 100KB of PNG-encoded data, which your browser then displays as an image. So far, so good. For something more interactive, though, HTTP isn't really ideal. The server can send back a frames-based page (either with or with