Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Mark Lawrence
On 19/02/2015 07:44, Mario Figueiredo wrote: A lot of patronizing egos running around in these groups. This is a sad thread... What is being asked is for help, not whether this is useful or needed. Jan-Hein is after some directions, not whether your bloody opinion on how he should use his free t

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Chris Angelico
On Thu, Feb 19, 2015 at 7:06 PM, Mark Lawrence wrote: > On 19/02/2015 07:44, Mario Figueiredo wrote: >> >> A lot of patronizing egos running around in these groups. This is a >> sad thread... >> >> What is being asked is for help, not whether this is useful or needed. >> Jan-Hein is after some dir

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Marko Rauhamaa
Mark Lawrence : > The opinions being expressed seem to be along the lines of > "reinventing round wheels is a waste of time. Reinventing square or > even triangular wheels is really pointless". I think it's even more pointless to mention the pointlessness of someone's hobby. Most pointless of al

urgent help

2015-02-19 Thread ismahameed
this is the error in the following python code, can any one help me error{Traceback (most recent call last): File "C:\Python27\Scripts\BeOk\getBeOKExperts.py", line 6, in from BeautifulSoup import BeautifulSoup ImportError: No module named BeautifulSoup} "#encoding=utf8 from codecs impor

Re: urgent help

2015-02-19 Thread Dave Angel
On 02/19/2015 03:35 AM, ismaham...@gcuf.edu.pk wrote: this is the error in the following python code, can any one help me error{Traceback (most recent call last): File "C:\Python27\Scripts\BeOk\getBeOKExperts.py", line 6, in from BeautifulSoup import BeautifulSoup ImportError: No module

Re: pickle error by multiprocessing

2015-02-19 Thread perfectican
I guess, The issue is not caused by multiprocessing. make sure you are pickling right object that can be pickable or not. Best way is run it in a console and test at which object the pickling error is occurring and then try to change the object which could be pickable. -- https://mail.python.or

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Mark Lawrence
On 19/02/2015 08:36, Marko Rauhamaa wrote: PS On the topic of pointlessness, why is top-posting the norm on python-dev but shunned on python-list? I don't know and I don't care provided top-posting remains the norm here. -- My fellow Pythonistas, ask not what our language can do for you, ask

Re: urgent help

2015-02-19 Thread ismahameed
On Thursday, February 19, 2015 at 4:35:18 PM UTC+8, ismah...@gcuf.edu.pk wrote: > this is the error in the following python code, can any one help me > error{Traceback (most recent call last): > File "C:\Python27\Scripts\BeOk\getBeOKExperts.py", line 6, in > from BeautifulSoup import Beautif

Re: urgent help

2015-02-19 Thread ismahameed
On Thursday, February 19, 2015 at 5:31:49 PM UTC+8, ismah...@gcuf.edu.pk wrote: > On Thursday, February 19, 2015 at 4:35:18 PM UTC+8, ismah...@gcuf.edu.pk > wrote: > > this is the error in the following python code, can any one help me > > error{Traceback (most recent call last): > > File "C:\Py

Re: urgent help

2015-02-19 Thread ismahameed
On Thursday, February 19, 2015 at 5:46:42 PM UTC+8, ismah...@gcuf.edu.pk wrote: > On Thursday, February 19, 2015 at 5:31:49 PM UTC+8, ismah...@gcuf.edu.pk > wrote: > > On Thursday, February 19, 2015 at 4:35:18 PM UTC+8, ismah...@gcuf.edu.pk > > wrote: > > > this is the error in the following pyth

Accessible tools

2015-02-19 Thread Bryan Duarte
Hello all, I have been posting to another group which directed me to this group. I am a blind software engineering student at Arizona State University. I am currently doing research and have decided to use Python as my developing language. I am in search of an accessible IDE or other tool set w

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Jonas Wielicki
Dear Jan-Hein, I read through the discussion, but until you said it directly, I did not realize that you wanted feedback on your *python* code. In that case, let me note a few things which make it unlikely that you will get (usable) feedback: 1. The code on your website is not formatted and high

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Mario Figueiredo
On Thu, Feb 19, 2015 at 9:06 AM, Mark Lawrence wrote > > > The opinions being expressed seem to be along the lines of "reinventing > round wheels is a waste of time. Reinventing square or even triangular > wheels is really pointless". > You obviously don't value the word 'exercise'. > If you d

Re: Accessible tools

2015-02-19 Thread Jacob Kruger
Brian, I am also a fully bind python/PHP developer, and all I really bother with, aside from python interpreter itself is the text editor called edSharp: http://www.empowermentzone.com/edsetup.exe That's been developed by another blind guy who's name you might have heard in other circles, Jama

Re: Accessible tools

2015-02-19 Thread Jonas Wielicki
Dear Bryan, I don’t have a finished solution for you, but I would like to link you to a previous thread on this list: The poster seems to be researching into the direction of developing a speech-friendly IDE. You may want to

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Mark Lawrence
On 19/02/2015 09:42, Mario Figueiredo wrote: On Thu, Feb 19, 2015 at 9:06 AM, Mark Lawrence mailto:breamore...@yahoo.co.uk>> wrote The opinions being expressed seem to be along the lines of "reinventing round wheels is a waste of time. Reinventing square or even triangular wheels i

A question about how plot from matplotlib works

2015-02-19 Thread ast
Hello import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = x**2 x array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) y array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81]) plt.plot(x,y) [] plt.show() The question is: plt.plot() creates an object "matplotlib.lines.Line2D" but this obj

Re: urgent help

2015-02-19 Thread Mark Lawrence
On 19/02/2015 09:48, ismaham...@gcuf.edu.pk wrote: As Dave Angel said nearly two hours ago the module is called bs4, so the command you need is:- from bs4 import BeautifulSoup In future please don't repeat the entire email just to add a sentence or two, particularly when you do so three time

Re: What the Pythons docs means by "container" ?

2015-02-19 Thread perfectican
in duck-typing, any objects can acts as Container. but only difference is type that we need to consider as a Container or not. -- https://mail.python.org/mailman/listinfo/python-list

Re: can python handle CHIME .spt files (fwd)

2015-02-19 Thread Laura Creighton
So I asked Andrew about PyMol. Here's what he said: --- Forwarded Message Return-Path: From: Andrew Dalke In-Reply-To: <201502190705.t1j75wx7024...@fido.openend.se> Date: Thu, 19 Feb 2015 10:55:09 +0100 Message-Id: <47ec31ce-33ac-4426-a874-ff4107f0c...@dalkescientific.com> On Feb 19, 2015,

Re: What the Pythons docs means by "container" ?

2015-02-19 Thread Mark Lawrence
On 19/02/2015 10:59, perfectican wrote: in duck-typing, any objects can acts as Container. but only difference is type that we need to consider as a Container or not. This comment makes no sense to me at all. Could you please rephrase it, preferably supplying some context at the same time.

Re: A question about how plot from matplotlib works

2015-02-19 Thread marco . nawijn
On Thursday, February 19, 2015 at 11:47:53 AM UTC+1, ast wrote: > Hello > > >>> import numpy as np > >>> import matplotlib.pyplot as plt > >>> x = np.arange(10) > >>> y = x**2 > >>> x > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > >>> y > array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81]) > >>> plt.plot(x

Re: sqlite3 and dates

2015-02-19 Thread Adam Funk
On 2015-02-18, Johannes Bauer wrote: > On 18.02.2015 12:21, Chris Angelico wrote: > >> SQLite3 is fine for something that's basically just a more structured >> version of a flat file. You assume that nobody but you has the file >> open, and you manipulate it just the same as if it were a big fat b

Re: sqlite3 and dates

2015-02-19 Thread Adam Funk
On 2015-02-18, Chris Angelico wrote: > On Thu, Feb 19, 2015 at 9:17 AM, wrote: >>> SQLite3 is fine for something that's basically just a more structured >>> version of a flat file. You assume that nobody but you has the file >>> open, and you manipulate it just the same as if it were a big fat b

Re: urgent help

2015-02-19 Thread Denis McMahon
On Thu, 19 Feb 2015 04:00:50 -0500, Dave Angel wrote: > On 02/19/2015 03:35 AM, ismaham...@gcuf.edu.pk wrote: >> this is the error in the following python code, can any one help me >> error{Traceback (most recent call last): >>File "C:\Python27\Scripts\BeOk\getBeOKExperts.py", line 6, in >>

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-19 05:32, Mark Lawrence wrote: > On 19/02/2015 00:08, Mario Figueiredo wrote: > > Parameterized queries is just a pet peeve of mine that I wish to > > include here. SQLite misses it and I miss the fact SQLite misses > > it. The less SQL one needs to write in their code, the happier > > o

Re: What behavior would you expect?

2015-02-19 Thread Denis McMahon
On Wed, 18 Feb 2015 21:44:12 -0700, Jason Friedman wrote: > My question is, what would be a reasonable behavior/result/return value > if: > 1. "/path/to/dir" does not exist or is not readable Normally I'd say raise an exception. Whether you choose to use an existing exception (will trying to r

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Mark Lawrence
On 19/02/2015 14:17, Tim Chase wrote: On 2015-02-19 05:32, Mark Lawrence wrote: On 19/02/2015 00:08, Mario Figueiredo wrote: Parameterized queries is just a pet peeve of mine that I wish to include here. SQLite misses it and I miss the fact SQLite misses it. The less SQL one needs to write in t

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 1:16 AM, Denis McMahon wrote: >> 2. no files match the given pattern > > Return either None, 0, False or an empty string. > > In both cases, it is then a matter for the calling code to catch the > exception or handle the return value appropriately. I'd avoid the empty stri

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 2:04 AM, Mark Lawrence wrote: >> This saves the SQL processor from recompiling the SQL into internal >> byte-code every time. It's handy if you know a given query will run >> multiple times with the same "shape" parameters. It's not essential, >> and some optimize away th

Re: Accessible tools

2015-02-19 Thread Bryan Duarte
Thank you jwi, and Jacob, I took a look at that posting and it seems pretty unique. I am not much interested in the speech driven development, but I am very interested in developing an accessible IDE. A professor and I have been throwing around the idea of developing a completely text based IDE

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Mario Figueiredo
On Thu, Feb 19, 2015 at 11:28 AM, Mark Lawrence wrote: > > No thanks as I won't be able to find any more candidates for my dream team. > > I'm glad you like me here. -- https://mail.python.org/mailman/listinfo/python-list

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread janhein . vanderburg
On Wednesday, February 18, 2015 at 11:20:12 PM UTC+1, Dave Angel wrote: > I'm not necessarily doubting it, just challenging you to provide a data > sample that actually shows it. And of course, I'm not claiming that > 7bit is in any way optimal. You cannot define optimal without first > defini

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread janhein . vanderburg
On Thursday, February 19, 2015 at 10:52:38 AM UTC+1, Jonas Wielicki wrote: > I read through the discussion, but until you said it directly, I did not > realize that you wanted feedback on your *python* code. Thanks for the tips Jonas. -- https://mail.python.org/mailman/listinfo/python-list

Re: Accessible tools

2015-02-19 Thread Jacob Kruger
I use edSharp as my primary code/text editor, and just save code from there, and while it doesn't offer too many things like design tools, it's pretty much perfect in terms of code block selection, code snippets, code navigation - to a certain extent, even in python, with regards to jumping from b

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-19 15:04, Mark Lawrence wrote: > On 19/02/2015 14:17, Tim Chase wrote: Parameterized queries is just a pet peeve of mine that I wish to include here. SQLite misses it and I miss the fact SQLite misses it. The less SQL one needs to write in their code, the happier one

matplotlib.pyplot documentation

2015-02-19 Thread ast
hello I got this module documentation with help(matplotlib.pyplot) for each function there is a demo file, for example: barbs(*args, **kw) Plot a 2-D field of barbs. **Example:** .. plot:: mpl_examples/pylab_examples/barb_demo.py but I dont find the barb_demo.py

Re: matplotlib.pyplot documentation

2015-02-19 Thread Mark Lawrence
On 19/02/2015 17:50, ast wrote: hello I got this module documentation with help(matplotlib.pyplot) for each function there is a demo file, for example: barbs(*args, **kw) Plot a 2-D field of barbs. **Example:** .. plot:: mpl_examples/pylab_examples/barb_demo.py but

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 8:45 AM, wrote: > On Wednesday, February 18, 2015 at 11:20:12 PM UTC+1, Dave Angel wrote: >> I'm not necessarily doubting it, just challenging you to provide a data >> sample that actually shows it. And of course, I'm not claiming that >> 7bit is in any way optimal. You

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 11:04 AM, Ian Kelly wrote: > There's also an optimization that can be added here if we wish to > inject a bit of cleverness. Notice that all values with more than one > group start with 11, never 10. We can borrow a trick from IEEE > floating point and make the leading 1 bi

Re: Logging with Custom Levels not working

2015-02-19 Thread Didymus
On Wednesday, February 18, 2015 at 3:16:40 PM UTC-5, Ian wrote: > > def perror(self, message, *args, **kws): > > """ Performance Error Message Level """ > > # Yes, logger takes its '*args' as 'args'. > > self._log(PERROR_NUM, message, args, **kws) > > > > logging.Logger.perror = perror

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 10:45 AM, janhein.vanderb...@gmail.com wrote: On Wednesday, February 18, 2015 at 11:20:12 PM UTC+1, Dave Angel wrote: I'm not necessarily doubting it, just challenging you to provide a data sample that actually shows it. And of course, I'm not claiming that 7bit is in any way opti

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 5:24 AM, Dave Angel wrote: > In all my experimenting, I haven't found any values where the 7bit scheme > does worse. It seems likely that for extremely large integers, it will, but > if those are to be the intended distribution, the 7bit scheme could be > replaced by somet

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Ian Kelly
On Thu, Feb 19, 2015 at 11:24 AM, Dave Angel wrote: > Here's a couple of ranges of output, showing that the 7bit scheme does > better for values between 384 and 16379. > > 382 2 80fe --- 2 7e82 > 383 2 80ff --- 2 7f82 > 384 3 81 --- 2 0083 > 384 jan grew 3 81 > 385 3 810001 --- 2 0183 > 3

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 01:34 PM, Chris Angelico wrote: On Fri, Feb 20, 2015 at 5:24 AM, Dave Angel wrote: In all my experimenting, I haven't found any values where the 7bit scheme does worse. It seems likely that for extremely large integers, it will, but if those are to be the intended distribution, t

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Dave Angel
On 02/19/2015 01:32 PM, Ian Kelly wrote: On Thu, Feb 19, 2015 at 11:24 AM, Dave Angel wrote: Here's a couple of ranges of output, showing that the 7bit scheme does better for values between 384 and 16379. 382 2 80fe --- 2 7e82 383 2 80ff --- 2 7f82 384 3 81 --- 2 0083 384 jan grew 3 81000

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 5:41 AM, Dave Angel wrote: > As I (and others) have said many times, making it optimal means making some > assumptions about the distribution of likely values. In fact, the very word "optimal" implies that. You have to have a set of criteria on which you base your evaluati

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Tim Chase
On 2015-02-18 20:05, ru...@yahoo.com.dmarc.invalid wrote: > Sqlite offers concurrent access already. > What Sqlite doesn't offer is high performance concurrent write > access. That is, it locks the entire database for the duration > of a write operation. Given that most such operations are pre

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On 02/19/2015 09:03 AM, Tim Chase wrote: > On 2015-02-19 15:04, Mark Lawrence wrote: >> On 19/02/2015 14:17, Tim Chase wrote: > Parameterized queries is just a pet peeve of mine that I wish to > include here. SQLite misses it and I miss the fact SQLite misses > it. The less SQL one need

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Terry Reedy
On 2/19/2015 3:36 AM, Marko Rauhamaa wrote: PS On the topic of pointlessness, why is top-posting the norm on python-dev ... ? It isn't, except that Guido gets a special pass and some of the posters travel a lot and read and reply on phones, which makes snipping and inline response difficult,

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Marko Rauhamaa
Terry Reedy : > It isn't, except that Guido gets a special pass Wusses... Or, it's good to be king. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: What behavior would you expect?

2015-02-19 Thread Denis McMahon
On Fri, 20 Feb 2015 02:08:49 +1100, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 1:16 AM, Denis McMahon > > wrote: >>> 2. no files match the given pattern >> >> Return either None, 0, False or an empty string. >> >> In both cases, it is then a matter for the calling code to catch the >> except

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 7:03 AM, Denis McMahon wrote: > On the one hand, the return type of a function (when it returns, rather > than raising an exception) should be consistent to itself, even if using > a language where types are not declared. > Yes, so I'd advise against having a function some

Re: How to install PIL or PILLOW on OS X Yosemite?

2015-02-19 Thread Russell Owen
On 2/15/15 8:17 PM, Ned Deily wrote: In article , KP wrote: just upgraded my Mac Mini to Yosemite and have never dabbled in Python on this OS. I see it has Python 2.7.6 installed. When I do something like from PIL import ImageFont, ImageDraw it tells me that it cannot find PIL How do I i

Re: Accessible tools

2015-02-19 Thread Tim Chase
While not blind, I have an interest in accessibility and answer a number of questions on the Blinux (Blind Linux Users) mailing list. On 2015-02-19 08:33, Bryan Duarte wrote: > A professor and I have been throwing around the idea of developing > a completely text based IDE. There are a lot of reas

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On 02/19/2015 12:07 AM, Steven D'Aprano wrote: > ru...@yahoo.com wrote: >> On 02/18/2015 07:13 PM, Steven D'Aprano wrote: >>> Chris Angelico wrote: > SQLite misses some important features that makes it better suited as a > simple datastore, not much unlike shelve. And network use is not one

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On 02/19/2015 12:23 AM, Chris Angelico wrote: > On Thu, Feb 19, 2015 at 6:07 PM, Steven D'Aprano > wrote: >> Very possibly. With modern dependency management, it isn't hard to install >> Postgresql: >> >> sudo aptitude postgresql >> >> or equivalent should work. For primitive operating systems wi

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 7:26 AM, wrote: > I'll point out that five people in this thread (by my > count) have said that Postgresql requires a significant > amount of work to setup and use. Only you and Steven claim > the opposite. (And it sounds to me like Steven does not > have a lot of experi

Re: A question about how plot from matplotlib works

2015-02-19 Thread Jason Swails
On Thu, Feb 19, 2015 at 5:47 AM, ast wrote: > Hello > > import numpy as np import matplotlib.pyplot as plt x = np.arange(10) y = x**2 x >>> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > >> y >>> array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81]) > >> plt.plot(x,y) >>> [

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On Wednesday, February 18, 2015 at 10:39:04 PM UTC-7, Ethan Furman wrote: > On 02/18/2015 09:26 PM, memilanuk wrote: > > On 02/18/2015 09:16 PM, Ben Finney wrote: > >> memilanuk writes: > >> > >>> In the past I've been waffling back and forth between a desktop > >>> client/server setup, or a web-b

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread Mario Figueiredo
On Thu, 19 Feb 2015 12:26:04 -0800 (PST), ru...@yahoo.com wrote: > >I'll point out that five people in this thread (by my >count) have said that Postgresql requires a significant >amount of work to setup and use. Only you and Steven claim >the opposite. Well, I claim the opposite too. >Or I c

Python - parsing nested information and provide it in proper format from log file

2015-02-19 Thread Jay T
have some log file which has nested data which i want to filter and provide specific for student with total counts Here is my log file sample: Student name is ABC Student age is 12 student was late student was late student was late Student name is DEF student age is 13 student was late

Re: python implementation of a new integer encoding algorithm.

2015-02-19 Thread Denis McMahon
On Tue, 17 Feb 2015 03:22:47 -0800, janhein.vanderburg wrote: > In http://optarbvalintenc.blogspot.nl/ I propose a new way to encode > arbitrarily valued integers I'm not quite sure I understand the problem that you're trying to solve with this. If I want to transmit some arbitrarily huge integ

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On 02/19/2015 01:47 PM, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 7:26 AM, wrote: >> I'll point out that five people in this thread (by my >> count) have said that Postgresql requires a significant >> amount of work to setup and use. Only you and Steven claim >> the opposite. (And it soun

Re: 'Lite' Databases (Re: sqlite3 and dates)

2015-02-19 Thread rurpy
On 02/19/2015 02:23 PM, Mario Figueiredo wrote: > On Thu, 19 Feb 2015 12:26:04 -0800 (PST), ru...@yahoo.com wrote: >> >> I'll point out that five people in this thread (by my >> count) have said that Postgresql requires a significant >> amount of work to setup and use. Only you and Steven claim >>

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Fri, 20 Feb 2015 07:11:13 +1100, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 7:03 AM, Denis McMahon > wrote: >> On the one hand, the return type of a function (when it returns, >> rather than raising an exception) should be consistent to itself, >> even if using a language where types are

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
I have need to search a directory and return the name of the most recent file matching a given pattern. Given a directory with these files and timestamps, > > q.pattern1.abc Feb 13 > r.pattern1.cdf Feb 12 > s.pattern1.efg Feb 10 > t.pattern2.abc Feb 13 > u.pattern2.xyz Feb 14 > v.pattern2.efg

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 3:54 PM, Dan Sommers wrote: > if there are no > values to return, then return an empty collection. That one makes sense only if you were going to return a collection anyway, though. If you were going to return a string, returning an empty list on failure makes no sense. He

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 4:13 PM, Jason Friedman wrote: > os.chdir(a_path) > return_list = [os.path.join(a_path, x) for x in glob.glob(a_glob) if > os.path.isfile(x)] > os.chdir(previous_dir) > return reversed(sorted(return_list, key=os.path.getmtime)) > > It's a shame that glob.glo

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
> def order_matching_files(a_path, a_glob="*"): > """Search a path for files whose names match a_glob > and return a list of the full path to such files, in descending > order of modification time. Ignore directories.""" > previous_dir = os.getcwd() > os.chdir(a_path) > retu

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Fri, 20 Feb 2015 16:16:50 +1100, Chris Angelico wrote: > On Fri, Feb 20, 2015 at 3:54 PM, Dan Sommers wrote: >> if there are no >> values to return, then return an empty collection. > > That one makes sense only if you were going to return a collection > anyway, though. If you were going to r

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
I think I came in a little late, and saw "2. no files match the given > pattern," in which case I'm sticking to my story and returning an empty > list. > > The original problem was "to search a directory and return the name of > the most recent file matching a given pattern." I'd still prefer an >

Re: What behavior would you expect?

2015-02-19 Thread Jason Friedman
> > I'd still advise using my_list.sort() rather than sorted(), as you > don't need to retain the original. > > Hmm. Trying to figure out what that looks like. If I understand correctly, list.sort() returns None. What would I return to the caller? > If you're going to call listdir, you probably

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 4:51 PM, Jason Friedman wrote: >> I'd still advise using my_list.sort() rather than sorted(), as you >> don't need to retain the original. >> > > Hmm. > > Trying to figure out what that looks like. > If I understand correctly, list.sort() returns None. > What would I return

Re: What behavior would you expect?

2015-02-19 Thread Dan Sommers
On Thu, 19 Feb 2015 22:51:57 -0700, Jason Friedman wrote: >> >> I'd still advise using my_list.sort() rather than sorted(), as you >> don't need to retain the original. >> >> > Hmm. > > Trying to figure out what that looks like. > If I understand correctly, list.sort() returns None. > What would

Re: What behavior would you expect?

2015-02-19 Thread Paul Rubin
Dan Sommers writes: > I'd still prefer an exception to None, and we agree on that an empty > string is bad because it's not a non-string and it could be too easily > mistaken for a filename. Empty string would be bad. Sometimes I like to simulate an option type, by returning the value as a 1-ele

Re: What behavior would you expect?

2015-02-19 Thread Chris Angelico
On Fri, Feb 20, 2015 at 5:18 PM, Paul Rubin wrote: > Empty string would be bad. Sometimes I like to simulate an option type, > by returning the value as a 1-element list if there's a value, otherwise > as an empty list. So you could say > > filename = get_filename(...)[0] > > if you want an ex

Re: What behavior would you expect?

2015-02-19 Thread Paul Rubin
Chris Angelico writes: >> if len(fs) == 0: ... # didn't get a filename > Bikeshedding: That could be written as simply "if not fs". :) Yeah, in that instance you could do that. It's an unsafe practice when None is used as the no-value marker, since the empty string is a perfectly good string