Re: What should Python apps do when asked to show help?

2016-04-29 Thread Steven D'Aprano
ger="foo" calls out to the external program "foo"; - pager=callable passes the help text to callable(). pager=print would do exactly what people are asking for, and you could then create your own wrapper to change the default: help = functools.partial(builtins.help, pager=print) I think that would make it easier to test help(). Thoughts? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should Python apps do when asked to show help?

2016-04-30 Thread Steven D'Aprano
le the door is open. Since I can't turn it off, it is not a feature! What if I want to stick my head in the microwave and cook it? *wink* Often-wanting-to-microwave-somebody-else's-head-ly y'rs, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should Python apps do when asked to show help?

2016-05-01 Thread Steven D'Aprano
but only when you already want a pager. Okay. How is > an app supposed to know whether or not to use a pager? How do you > expect them to mindread? Easy: if the READPAGERENVIRONVAR is set, then the application should read the PAGER environment variable, otherwise it should ignore it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should Python apps do when asked to show help?

2016-05-01 Thread Steven D'Aprano
our mind? Personally, I'd rather use a pager for 3 lines than print 30 lines of help text directly to the console, but others may feel differently. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should Python apps do when asked to show help?

2016-05-01 Thread Steven D'Aprano
ept me questioning the assumption that we're only talking about Unix users? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should Python apps do when asked to show help?

2016-05-01 Thread Steven D'Aprano
On Mon, 2 May 2016 03:04 am, Grant Edwards wrote: > On 2016-05-01, Steven D'Aprano wrote: >> On Mon, 2 May 2016 02:30 am, Grant Edwards wrote: >> >>>> In discussions like these, it would be important to draw from >>>> precedents. Are there commands th

Re: You gotta love a 2-line python solution

2016-05-01 Thread Steven D'Aprano
On Monday 02 May 2016 15:21, Stephen Hansen wrote: > On Sun, May 1, 2016, at 10:08 PM, DFS wrote: >> On 5/2/2016 1:02 AM, Stephen Hansen wrote: >> >> I actually use "D:\\file.html" in my code. >> > >> > Or you can do that. But the whole point of raw strings is not having to >> > escape slashes :)

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Steven D'Aprano
On Monday 02 May 2016 15:04, DFS wrote: > 0.2 is half as fast as 0.1, here. > > And two small numbers turn into bigger numbers when the webpage is big, > and soon the download time differences are measured in minutes, not half > a second. It takes twice as long to screw a screw into timber than

Re: Fastest way to retrieve and write html contents to file

2016-05-01 Thread Steven D'Aprano
On Monday 02 May 2016 15:00, DFS wrote: > I tried the 10-loop test several times with all versions. > > The results were 100% consistent: VBSCript xmlHTTP was always 2x faster > than any python method. Are you absolutely sure you're comparing the same job in two languages? Is VB using a local

Re: You gotta love a 2-line python solution

2016-05-02 Thread Steven D'Aprano
ion, retrying on error, etc. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: You gotta love a 2-line python solution

2016-05-03 Thread Steven D'Aprano
bdirectory of where you saved the main file. You'd have to recreate most of the Google environment and fetch anything that was referenced through a relative path first, to get the content to display. Of course, you may find, for example, that the Javascript at some point is doing a database lookup -- and you'd maybe have to now duplicate the database... -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Steven D'Aprano
On Wed, 4 May 2016 12:42 am, Jussi Piitulainen wrote: > Ceterum censeo, the only suggested use for .swapcase I've ever heard of > is encryption. iF YOU'RE PROGRAMMING AN EDITOR, sWAP cASE IS REALLY USEFUL FOR THOSE LITTLE capslock ACCIDENTS THAT PLAGUE TYPISTS. -- S

Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-03 Thread Steven D'Aprano
orrect uppercase to lowercase and back again should go: Dotless I: I -> ı -> I Dotted I: İ -> i -> İ Python does not quite manage to handle this correctly for Turkish applications, since it loses the dotted/dotless distinction: py> 'ı'.upper() 'I' py> 'İ'.lower() 'i' and further case conversions follow the non-Turkish rules. Note that sometimes getting this wrong can have serious consequences: http://gizmodo.com/382026/a-cellphones-missing-dot-kills-two-people-puts-three-more-in-jail -- Steven -- https://mail.python.org/mailman/listinfo/python-list

After a year using Node.js, the prodigal son returns

2016-05-04 Thread Steven D'Aprano
A year ago, Gavin Vickery decided to move away from Python and give Javascript with Node.js a try. Twelve months later, he has written about his experiences: http://geekforbrains.com/post/after-a-year-of-nodejs-in-production -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: Analytical Geometry in Python with GeoMath

2016-05-04 Thread Steven D'Aprano
On Wednesday 04 May 2016 09:48, Vinicius Mesel wrote: > I created a library called "GeoMath" that it's intent is to solve all > Analytical Geometry problems in a simple way using Python. > > If you want to check it out, here is the link: > https://github.com/vmesel/GeoMath > > And if you want to

Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-04 Thread Steven D'Aprano
On Wednesday 04 May 2016 18:34, Gregory Ewing wrote: > Jussi Piitulainen wrote: >> Ceterum censeo, the only suggested use for .swapcase I've ever heard of >> is encryption. > > Yep, all the smart terrorists these days are using a > combination of swapcase and rot13. Totally bamboozles > the FBI.

Re: Not x.islower() has different output than x.isupper() in list output...

2016-05-04 Thread Steven D'Aprano
On Thu, 5 May 2016 12:09 am, DFS wrote: > On 5/3/2016 11:28 PM, Steven D'Aprano wrote: >> Languages with two distinct lettercases, like English, are called >> bicameral. [...] > Linguist much? Possibly even a cunning one. Somebody-had-to-say-it-ly y'

Re: Whittle it on down

2016-05-04 Thread Steven D'Aprano
On Thursday 05 May 2016 14:58, DFS wrote: > Want to whittle a list like this: [...] > Want to keep all elements containing only upper case letters or upper > case letters and ampersand (where ampersand is surrounded by spaces) Start by writing a function or a regex that will distinguish strings

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: >> Start by writing a function or a regex that will distinguish strings that >> match your conditions from those that don't. A regex might be faster, but >

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
Oh, a further thought... On Thursday 05 May 2016 16:46, Stephen Hansen wrote: > On Wed, May 4, 2016, at 11:04 PM, Steven D'Aprano wrote: >> Start by writing a function or a regex that will distinguish strings that >> match your conditions from those that don't. A r

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
t in the given > dataset, and recognizing that is important. You don't have to account > for every bit of nonsense. Whenever a programmer says "This case will never happen", ten thousand computers crash. http://www.kr41.net/2016/05-03-shit_driven_development.html -- Steven D'Aprano -- https://mail.python.org/mailman/listinfo/python-list

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 06:17 pm, Peter Otten wrote: >> I get something like this: >> >> r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" >> >> >> but it fails on strings like "AA & A & A". What am I doing wrong? > tes

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:13 pm, Random832 wrote: > On Thu, May 5, 2016, at 04:41, Steven D'Aprano wrote: >> > There's no situation where "&&&&&" and " " will exist in the given >> > dataset, and recognizing that

Re: Ctypes c_void_p overflow

2016-05-05 Thread Steven D'Aprano
g, the expected result, and the result you actually get. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:32 pm, Stephen Hansen wrote: > On Thu, May 5, 2016, at 12:36 AM, Steven D'Aprano wrote: >> Oh, a further thought... >> >> On Thursday 05 May 2016 16:46, Stephen Hansen wrote: >> > I don't even care about faster: Its overly complica

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
d your response is to insult me and question my sanity. Well, DFS, I might be crazy, but I'm not stupid. If that's really how you feel about my answers, I won't make the mistake of wasting my time answering your questions in the future. Over to you now. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Thu, 5 May 2016 11:21 pm, Random832 wrote: > On Thu, May 5, 2016, at 03:36, Steven D'Aprano wrote: >> Putting non-ASCII letters aside for the moment, how would you match these >> specs as a regular expression? > > Well, obviously *your* language (not the OP's

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Fri, 6 May 2016 03:49 am, Jussi Piitulainen wrote: > Steven D'Aprano writes: > >> I get something like this: >> >> r"(^[A-Z]+$)|(^([A-Z]+[ ]*\&[ ]*[A-Z]+)+$)" >> >> >> but it fails on strings like "AA & A & A"

Re: Whittle it on down

2016-05-05 Thread Steven D'Aprano
On Fri, 6 May 2016 04:27 am, Jussi Piitulainen wrote: > Random832's pattern is fine. You need to use re.fullmatch with it. py> re.fullmatch Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute '

Re: Pylint prefers list comprehension over filter...

2016-05-06 Thread Steven D'Aprano
n `from future_builtins import *` to get most of the Python 3 behaviour: py> filter(None, []) [] py> from future_builtins import * py> filter(None, []) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is an Equal Opportunity Programming Language

2016-05-06 Thread Steven D'Aprano
enting you from establishing the sort of networks that a professional needs? If you can answer "Yes" to four or more of those questions, then perhaps there is a case for something to combat the overwhelming anti-white racism that you're suffering from. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why do these statements evaluate the way they do?

2016-05-07 Thread Steven D'Aprano
if obj == None: ... But for (nearly) everything else, always use == equality. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is an Equal Opportunity Programming Language

2016-05-07 Thread Steven D'Aprano
reatment, and drive wages down for others in the same field. But the inequities of the H1B programme are not caused by the existence of country limits. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is an Equal Opportunity Programming Language

2016-05-07 Thread Steven D'Aprano
On Sun, 8 May 2016 04:40 am, Random832 wrote: > On Sat, May 7, 2016, at 11:16, Steven D'Aprano wrote: >> > Indian and Chinese H1B holders are getting screwed, which is of course >> > the whole objective of the country limits. >> >> The *whole* objecti

Re: Pylint prefers list comprehension over filter...

2016-05-07 Thread Steven D'Aprano
tfully, not mechanically. (Cannot be repeated often enough.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-07 Thread Steven D'Aprano
doesn't everyone? You mean something like this? import spam, ham, eggs, cheese *shrug* It's a style thing. > +-++ > |consider-using-enumerate |2 | see below [1] Absolutely use enumerate. > +-----++ > |ba

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
On Sunday 08 May 2016 13:40, Random832 wrote: > On Sat, May 7, 2016, at 22:43, Steven D'Aprano wrote: >> > If not for the quotas, a citizen of some other country would have an >> > equal chance to get a green card as a citizen of India or China. >> >> If you

Re: pylint woes

2016-05-08 Thread Steven D'Aprano
, you should do things the old-fashioned way: streets, cities, states, zipcodes = [], [], [], [] for word in addr: items = word.split(',') streets.append(items[0]) cities.append(items[1].strip()) states.append(word[-8:-2]) zipcodes.append(word[-5:]) Oh, and use bette

Re: Pylint prefers list comprehension over filter...

2016-05-08 Thread Steven D'Aprano
to be biased, and that "everybody knows" not to use it to choose an item from a list because it is documented "everywhere" as being more likely to choose the first or the last item than any of the others.) [1] Sweeping generalisation. In a world of 7 billion people, there

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
On Sun, 8 May 2016 01:57 am, Marko Rauhamaa wrote: > A functional, enlightened, prosperous democracy is a very recent > historical anomaly. You don't want to jeopardize it naïvely. Perhaps by implementing per-country limits on immigration? *wink* -- Steven -- https://mail

Re: [Python-ideas] Boolean parameters guidelines

2016-05-08 Thread Steven D'Aprano
Not sure why this has migrated to this list instead of Python-Ideas. Possibly a copy-paste error? *wink* On Mon, 9 May 2016 12:24 am, Ian Kelly wrote: > On May 8, 2016 12:42 AM, "Steven D'Aprano" wrote: >> >> def pvariance(data, mu=None): >> if iter(d

Re: pylint woes

2016-05-08 Thread Steven D'Aprano
craftsman knows her tools backwards, and can choose the right tool for the job, and when the choice of tool really doesn't matter and you can use whatever happens to be the closest to hand. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python is an Equal Opportunity Programming Language

2016-05-08 Thread Steven D'Aprano
in mixed sex classes than in same sex classes; - but for girls it is the other way around. Since boys don't suffer any loss from mixed sex classes, but girls do, it is common sense to offer girls a same sex option to let them catch up. Relevant: http://www.robeastaway.com/blog/boys-versus-girls -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python PygLatin

2016-05-08 Thread Steven D'Aprano
he did go to Princeton. Ellison is the son of an unwed mother who gave him up for adoption by her aunt and uncle, comfortably middle-class. That makes him the closest out of the group as a "regular guy". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-08 Thread Steven D'Aprano
;> >> Why? Do you think that there's a world shortage of newline characters? Is >> the Enter key on your keyboard broken? > > I do it because I like it. > > if verbose: print var > > python doesn't complain. Hmmm. Well, that's not too bad. I thought you mean something like: addr = getaddress(key); addr[2] = addr.upper(); print addr which is just horrible. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Mon, 9 May 2016 07:24 am, DFS wrote: > On 5/8/2016 7:36 AM, Steven D'Aprano wrote: >> On Sun, 8 May 2016 11:16 am, DFS wrote: >> >>> address data is scraped from a website: >>> >>> names = tree.xpath() >>> addr = tree.xpath() >&

Re: pylint woes

2016-05-08 Thread Steven D'Aprano
On Mon, 9 May 2016 07:04 am, DFS wrote: > On 5/8/2016 11:51 AM, Steven D'Aprano wrote: >> On Mon, 9 May 2016 12:25 am, DFS wrote: >> >>>>> for j in range(len(nms)): >>>>> cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)" >>&g

Re: What's wrong with this concatenation statement?

2016-05-09 Thread Steven D'Aprano
On Monday 09 May 2016 09:10, DFS wrote: > sSQL = "line 1\n" > sSQL += "line 2\n" > sSQL += "line 3" Pointlessly provocative subject line edited. Since all three lines are constants know by the programmer at the time the source code is written, it should be written as: sSQL = """line 1 line 2

Re: pypi download links (e.g. for ansible)

2016-05-09 Thread Steven D'Aprano
n for 2.0.2.0 links to: https://pypi.python.org/packages/b3/0e/5f3ee8884866a3d5e3b8ba86e9caa85ecdec75adabac8924b1c122339e7f/ansible-2.0.2.0.tar.gz if that helps. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: json.loads(...) ValueError: Expecting value: line 1 column 1 (char 0)

2016-05-09 Thread Steven D'Aprano
On Tue, 10 May 2016 09:07 am, Terry Reedy wrote: > Editorial: Programming classes should teach basic debugging better. I > have seen numerous newbie Stackoverflow questions where the person > should have started with adding a print statement before posting a > question. +1

Re: String concatenation

2016-05-09 Thread Steven D'Aprano
perator. That much is true. But that is far from being deprecated. > Note the key words: “old”, “quirks”, “errors”. Irrelevant to the question of deprecation. Floats are old (they go back to the first release of Python), they have many quirks (x + y - x is not necessarily equal to y

Re: String concatenation

2016-05-09 Thread Steven D'Aprano
On Tuesday 10 May 2016 13:45, Rustom Mody wrote: > See: > http://www.alphr.com/computing/1000378/facebook-rejects-native-american- names-as-fake-again Somebody should set up a kick-starter to pay someone to change their legal name to "Facebook-Are-Arseholes", then open a Facebook account with i

Re: String concatenation

2016-05-10 Thread Steven D'Aprano
On Tuesday 10 May 2016 17:13, Paul Rubin wrote: > Steven D'Aprano writes: >> Australia's naming laws almost certainly wouldn't allow such a name. > > https://en.wikipedia.org/wiki/Facebook_real- name_policy_controversy#Vietnamese "Phuc Dat Bich" was a h

Re: TypeError: unorderable types: function() < int()

2016-05-10 Thread Steven D'Aprano
ould round the time to one decimal place: totaltime = round(totaltime, 1) before checking whether it is equal to 10. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: TypeError: unorderable types: function() < int()

2016-05-10 Thread Steven D'Aprano
On Tue, 10 May 2016 11:47 pm, Chris Angelico wrote: > On Tue, May 10, 2016 at 11:40 PM, Steven D'Aprano > wrote: >> You are asking the player to hit enter at 10 seconds. *Exactly* ten >> seconds. The computer can measure time to well under a millionth of a >> second

Re: Pylint prefers list comprehension over filter...

2016-05-10 Thread Steven D'Aprano
ch, it is removed and won't be > emitted anymore in the next release (1.6) Thanks for being so understanding! Speaking for myself, I think that the test for filter versus list comprehensions is a reasonable test to include, so long as it is disabled by default. Does PyLint support opt-in chec

Re: Pylint prefers list comprehension over filter...

2016-05-10 Thread Steven D'Aprano
Pylint isn’t smarter than you are: it may warn you about things that you have conscientiously done." https://docs.pylint.org/intro.html#what-pylint-is-not which has some nice advice for how to deal with pylint so the warnings are not overwhelming. I think it is time for me to check

What should a decorator do if an attribute already exists?

2016-05-10 Thread Steven D'Aprano
ibute? I think 5 is clearly wrong, 4 is too difficult, and 3 seems pointless. So I think either 1 or 2 is the right thing to do. Thoughts? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-10 Thread Steven D'Aprano
On Wed, 11 May 2016 02:16 am, DFS wrote: > huh? You called yourself a "master crafts/wo/man". [...] > DuhPricko *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Moderation [was Re: ...What's wrong with this concatenation statement?]

2016-05-10 Thread Steven D'Aprano
x27;s insults, but it doesn't appear here: https://mail.python.org/pipermail/python-list/2016-May/thread.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: String concatenation

2016-05-12 Thread Steven D'Aprano
On Tuesday 10 May 2016 18:15, David Palao wrote: > 2016-05-10 9:54 GMT+02:00 Steven D'Aprano > : >> I'm surprised that Spanish names are not affected. Consider a woman who goes >> by the personal name of Maria Teresa, whose father's first surname was >>

Re: Analytical Geometry in Python with GeoMath

2016-05-12 Thread Steven D'Aprano
Hi Vinicius, On Thursday 05 May 2016 04:16, Vinicius wrote: > To add a point, you do: > From geomath import point > A = point.Point(x,y) > A.distance(PointB) > A.mispoint(PointB) > A.quadrant() How does your library compare with Eukleides? http://www.eukleides.org/quickstart.html -- Steve

Re: String concatenation

2016-05-12 Thread Steven D'Aprano
On Tuesday 10 May 2016 12:42, Chris Angelico wrote: > On Tue, May 10, 2016 at 12:32 PM, Steven D'Aprano > wrote: >> Floats are old (they go back to the first release of Python), they have >> many quirks (x + y - x is not necessarily equal to y), and people make >>

Re: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?

2016-05-12 Thread Steven D'Aprano
sial at the time (and remains slightly so): https://mail.python.org/pipermail/python-dev/2004-August/046686.html My opinion is that it is great for interactive use at the Python prompt, but I would never use it in code I cared about. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Fw: Question about issue with opening Python

2016-05-13 Thread Steven D'Aprano
long to retype, then please post it as a link to imgurl: https://imgur.com/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Skipping test using unittest SkipTest and exit status

2016-05-13 Thread Steven D'Aprano
layed. See the documentation here: https://docs.python.org/2/library/unittest.html#skipping-tests-and-expected-failures -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Distinction between “class” and “type”

2016-05-13 Thread Steven D'Aprano
ing compile-time facts about code. Classes (in Python) are for specifying the behaviour and implementation of objects. [1] Actually, the function "type()" and the class "type" are implemented as the same object, which does two different things depending on how many arguments it gets. With one argument, type(x) returns the class of x. With three arguments, type(name, bases, namespace) creates and returns a new class. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Performance with and without the garbage collector

2016-05-14 Thread Steven D'Aprano
thinking that garbage collecting almost two million ints would surely show some performance difference, but it doesn't. Is anyone able to demonstrate a replicable performance impact due to garbage collection? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Performance with and without the garbage collector

2016-05-14 Thread Steven D'Aprano
With the gc on, running main() on my computer takes 11.2 seconds, with the gc off, it takes 7.5 seconds. Nice, and thank you! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to get a directory list sorted by date?

2016-05-15 Thread Steven D'Aprano
On Sunday 15 May 2016 18:47, [email protected] wrote: > What I want is a list in the order produced by:- > ls --sort=time I'm not sure if this is the best way to do it, but what I would do is sort the directory list by the file's time metadata, which you can access using os.stat. To sort the fi

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Steven D'Aprano
/252555/limit-simultaneous-connections-per-ip-with-apache2 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Steven D'Aprano
uot;I must laugh or else I will cry". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Wanted Python programmer to join team

2016-05-16 Thread Steven D'Aprano
ess of "Leave mail with the lady in the milk bar on the corner". It's not hard to run your own mail server. *I* can do it. At the very least, register a domain and tell Gmail to use that, and *pretend* you're running your own mail server. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Steven D'Aprano
of people who'll > willingly sacrifice "reliability in the face of an internet connection > outage" in favour of "less than fifteen second response time". How can you not serve a web page over your LAN in 15s? I mean, you could *almost* do it by hand, copying the files onto a USB stick and walking them across the room in 15 seconds. Maybe 30. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What should a decorator do if an attribute already exists?

2016-05-16 Thread Steven D'Aprano
On Monday 16 May 2016 18:14, Francesco Loffredo wrote: > On 10/05/2016 17:45, Steven D'Aprano wrote: >> I have a decorator that adds an attribute to the decorated function: [...] >> My question is, what should I do if the decorated function already has an >> instrumen

Re: What should a decorator do if an attribute already exists?

2016-05-16 Thread Steven D'Aprano
On Monday 16 May 2016 22:20, jmp wrote: > On 05/10/2016 05:45 PM, Steven D'Aprano wrote: >> I have a decorator that adds an attribute to the decorated function: > [snip] >> I think 5 is clearly wrong, 4 is too difficult, and 3 seems pointless. So I >> think either 1

Re: What should a decorator do if an attribute already exists?

2016-05-16 Thread Steven D'Aprano
On Monday 16 May 2016 23:06, Kevin Conway wrote: >> I have a decorator that adds an attribute to the decorated function > > I might try to argue that this is not actually a decorator or, at least, > this is not a great decorator pattern for Python. Adding the attribute to > the function object im

Re: OT: limit number of connections from browser to my server?

2016-05-16 Thread Steven D'Aprano
On Tuesday 17 May 2016 13:02, Chris Angelico wrote: > On Tue, May 17, 2016 at 12:50 PM, Steven D'Aprano > wrote: >> How can you not serve a web page over your LAN in 15s? >> >> I mean, you could *almost* do it by hand, copying the files onto a USB stick >> and

Re: Wanted Python programmer to join team

2016-05-16 Thread Steven D'Aprano
On Tuesday 17 May 2016 12:56, Chris Angelico wrote: > On Tue, May 17, 2016 at 12:37 PM, Steven D'Aprano > wrote: >> On Tue, 17 May 2016 09:07 am, Chris Angelico wrote: >> >>> I'm not overly bothered by the use of GMail for a business address, >> &

Re: Wanted Python programmer to join team

2016-05-17 Thread Steven D'Aprano
On Tuesday 17 May 2016 16:18, Marko Rauhamaa wrote: > Steven D'Aprano : >> Personally, I think that advertising a job position without saying who >> you are, what you do, and offering at least an indicative salary >> range, are *astonishingly* rude > > I don&#x

Re: Wanted Python programmer to join team

2016-05-17 Thread Steven D'Aprano
On Tuesday 17 May 2016 17:39, Steven D'Aprano wrote: > - they're more likely Er, apparently they're not more likely to do anything specific, just more likely. -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Quote of the day

2016-05-17 Thread Steven D'Aprano
Overhead in the office today: "I don't have time to learn an existing library - much faster to make my own mistakes!" -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Backwards-incompatible changes

2016-05-17 Thread Steven D'Aprano
Every change breaks somebody's workflow. http://xkcd.com/1172/ -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Extract the middle N chars of a string

2016-05-18 Thread Steven D'Aprano
: # string with odd number of characters py> for i in range(1, 8): ... print mid('abcdefg', i) ... d de cde cdef bcdef bcdefg abcdefg # string with even number of characters py> for i in range(1, 7): ... print mid('abcdef', i) ... c cd bcd bcde abcde abcdef

setrecursionlimit

2016-05-18 Thread Steven D'Aprano
hon tell if I'm setting the limit too high? (I'm assuming that if it could, it would.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Quote of the day

2016-05-18 Thread Steven D'Aprano
great, code that crashes could use improvement, but incorrect code that doesn’t crash is a horrible nightmare." -- Chris Smith while an E means that your code will cleverly raise an exception instead of doing the wrong thing :-) [1] Human or machine person, I don't care. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: setrecursionlimit

2016-05-18 Thread Steven D'Aprano
eality I more sort of absorbed it by osmosis. Nobody ever actually sat down and told me how the stack and heap work, so the model I have might be completely wrong, even for 1980s tech. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Quote of the day

2016-05-18 Thread Steven D'Aprano
failing or skipped) per week, and he's responding by writing tests which pass by not testing anything. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract the middle N chars of a string

2016-05-18 Thread Steven D'Aprano
On Thu, 19 May 2016 07:35 am, Grant Edwards wrote: > On 2016-05-18, Steven D'Aprano wrote: > >> Getting the middle N seems like it ought to be easy: > > I'm still trying to figure out when one would want to do that... I wanted to centre some text and truncate it t

Re: Extract the middle N chars of a string

2016-05-18 Thread Steven D'Aprano
my first post says, this really does seem like it ought to be a no-brainer trivial exercise in slicing. Instead, it is remarkably subtle and tricky to get right. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract the middle N chars of a string

2016-05-18 Thread Steven D'Aprano
of string.""" > if n <= 0: > return '' > if n > len(string): > return string > ofs = (len(string) - n) // 2 > return string[ofs : ofs + n] > > > If there's an odd number of characters remaining, it always has more on > the right. Thanks to you and Ian (who independently posted a similar solution), that's quite good too if you don't care about the bias. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract the middle N chars of a string

2016-05-18 Thread Steven D'Aprano
e+n] >> ... return s > >> Not exactly the same results as your implementation though. > > The extra line should fix that, but it looks, err -- odd. Nice! Thank you. I like this solution. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Program prints questions for user input, but won't show the answer output

2016-05-18 Thread Steven D'Aprano
ould that be >= 0? >= 1? I forget! print "Loop", counter counter -= 1 And its faster too. (4) Don't use "input". (The reasons are technical, if you really want to know, please ask.) Instead of writing: input("Enter pints collected: ") w

Re: Resources/pointers for writing maintable, testable Python

2016-05-18 Thread Steven D'Aprano
On Thursday 19 May 2016 13:31, Rustom Mody wrote: > On Thursday, May 19, 2016 at 6:26:26 AM UTC+5:30, Ben Finney wrote: >> Code Like A Pythonista was written in the Python 2 era >> >> but is still excellent advice today. > >

Re: for / while else doesn't make sense

2016-05-19 Thread Steven D'Aprano
o nevertheless had to memorise weird and unintuitive words like "for", "while", "if" etc. The least we English speakers can do is suck it up and memorise *one* weird case, "else". [1] Well, *almost* no matter what. If you pull the power from the computer, the finally block never gets a chance to run. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-19 Thread Steven D'Aprano
what gets executed if none of the > "if"s was true. In that sense, it's exactly the right keyword to > use. So long as you don't think too hard about what's actually going on, and only consider the most obvious case, it almost makes a bit of sense :-) But really, the else clause *actually is* an unconditional block which executes after the loop. That's how it is implemented, and that's how it is best understood. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-19 Thread Steven D'Aprano
reak was executed. There is no flag. It simply doesn't get executed because code execution jumps past it. But please do explain your execution model of "for...else". If it is better than mine, I'll be happy to use it instead. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-20 Thread Steven D'Aprano
sn't have it, or Ruby, or C, is surely the height of muddleheaded thinking. You're not programming Javascript, Ruby or C, you're programming in Python. The whole point of picking one language over another is to get access to the tools and features that language offers. Otherwise you're just wasting your time. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: for / while else doesn't make sense

2016-05-20 Thread Steven D'Aprano
ord that would be better > than "else" (even if we assumed that adding a new keyword was a > cost-free exercise). Well, that's a matter of opinion. And you know what they same about opinions... there are always two, the foolish, pig-ignorant one, and mine. :-) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: How to memory dump an object?

2016-05-20 Thread Steven D'Aprano
show is a bunch of pointers), there are other high-level introspection tools available in the `inspect` module. You can also use: sys.getsizeof to see how much memory is used by an object. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    29   30   31   32   33   34   35   36   37   38   >