Re: Style question -- plural of class name?

2013-05-08 Thread Skip Montanaro
This one: > "A list of FooEntry instances" Besides the obvious spelling issues in the others, it's not immediately clear if the list contains just FooEntry instances, FooEntry classes (perhaps subclasses) or a mix of the two. #4 makes it clear. Skip -- http://mail.python.org/mailman/listinfo/p

Re: [Off topic] Software epigrams

2013-05-13 Thread Skip Montanaro
> 8. A programming language is low level when its programs require > attention to the irrelevant. > > So much a matter of debate. Indentation is irrelevant, why should > Python programs pay attention to it? Block delimiters are irrelevant > too, the interpreter should be able to figure them out fro

Re: ssl proxy server

2013-05-14 Thread Skip Montanaro
I haven't touched the SpamBayes setup for the usenet-to-mail gateway in a long while. For whatever reason, this message was either held and then approved by the current list moderator(s), or (more likely) slipped through unscathed. No filter is perfect. Skip On Tue, May 14, 2013 at 1:40 PM, Chr

Re: Determine actually given command line arguments

2013-05-15 Thread Skip Montanaro
> Yes, I was trying that and it sort of works with strings if I use something > sufficiently improbable like "__UNSELECTED__" as default. But it gets > difficult with boolean or even number arguments where you just may not have > valid "improbable" defaults. You could now say, so what, it's th

Re: Determine actually given command line arguments

2013-05-15 Thread Skip Montanaro
> However, maybe I could ... ... switch to getopt? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
Perhaps you want len(reader) instead? Or a counter which increments for every row read which has an item in column A? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
> len(reader) gives me an error. Apologies. len(list(reader)) should work. Of course, you'll wind up loading the entire CSV file into memory. You might want to just count row-by-row: n = 0 for row in reader: n += 1 Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
> So rather than >>a >>b >>c >>d >>e >>f > I would get [a, b, c, d, e, f] all_items = [] for row in reader: all_items.append(row[0]) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: any cherypy powred sites I can check out?

2013-05-16 Thread Skip Montanaro
On Thu, May 16, 2013 at 1:17 PM, wrote: > anyone? Perhaps asking this question (or a more precise one) on a CherryPy mailing list would elicit more (helpful) responses. If you just repeat the above though, I'm afraid most of the answers will just be, "yes." Hint: Read through this before aski

Re: sympy.nsimplify

2013-05-21 Thread Skip Montanaro
Very cool indeed. In the comments was a link to an XKCD cartoon. Its tool tip mentioned "twin primes". Looked that up. Google pointed (of course) at Wikipedia. Read that. Backed up to the Google Search, and noticed there is a news item from 15 hours ago that an unknown mathematician at the Un

Re: @staticmethods called more than once

2013-05-21 Thread Skip Montanaro
Don't confuse the use of "static" in Python with its use in C/C++. From a post on StackOverflow: A staticmethod is a method that knows nothing about the class or instance > it was called on. It just gets the arguments that were passed, no implicit > first argument. It is basically useless in Pyth

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-21 Thread Skip Montanaro
> Thank you, but let me rephrase it. I'm already using str.format() but I'd > like to use '%' (BINARY_MODULO) operator instead. That's unlikely to change. If not deprecated already string interpolation using the modulo operator has lost favor to the string object's format method. You might be a

Re: Myth Busters: % "this old style of formatting will eventually be removed from the language"

2013-05-22 Thread Skip Montanaro
>> Is this tutorial outdated or this still an issue? >> >> [1] >> http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting > > > That tutorial is out of date. %-formatting isn't being removed. OTOH, PEP 3101 also mentions deprecation, at the very end: "... both systems can co-exis

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Skip Montanaro
Please stop perpetuating this myth, see http://mail.python.org/pipermail/python-dev/2012-February/116789.html and http://bugs.python.org/issue14123 >>> What myth? >> >> The myth that % string formatting is deprecated. It is not deprecated. > Skip didn't say that it was deprecate

Surprising difference between StringIO.StringIO and io.StringIO

2013-05-30 Thread Skip Montanaro
Consider this quick session (Python 2.7 using the tip of the 2.7 branch in Mercurial): % python2.7 Python 2.7.5+ (2.7:93eb15779050, May 30 2013, 15:27:39) [GCC 4.4.6 [TWW]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import traceback >>> >>> import StringIO

Re: Surprising difference between StringIO.StringIO and io.StringIO

2013-05-30 Thread Skip Montanaro
> > I would expect io.StringIO to be a match for the io.* stuff in Python > 3. So it should care whether it is a binary stream or a text stream. > Whereas StringIO.StringIO is your good old Python 2 StringIO, which expects > strs. > > On that basis, io.StringIO is a text stream, expecting Unicode >

Re: Python #ifdef

2013-06-02 Thread Skip Montanaro
> The terror that most people feel when hearing "m4" is because m4 was associated with sendmail, not because m4 was inherently awful. In fact, m4 made sendmail configs easier to maintain. Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: How to increment date by week?

2013-06-04 Thread Skip Montanaro
Check out the rrule module in the python-dateutil package: http://labix.org/python-dateutil https://pypi.python.org/pypi/python-dateutil Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Errin when executing a cgi script that sets a cookie in the browser

2013-06-06 Thread Skip Montanaro
> Did you tried running that by a standalone Python interpreter? Did you > notice something strange, something like that an empty line is missing > between headers and body? He will get an extra blank line, since he added a newline character at the end of his Content-Type string. Skip -- http://

Re: Build Python 2.7.5 - Modules missing

2013-06-10 Thread Skip Montanaro
> It carried on with the installation OK, but I don't understand the last > sentence in the message. How can I find out exactly what modules are > missing, and what I need to do to make sure they are built next time? Some of them won't ever build, as they are platform-dependent. For example, if y

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Skip Montanaro
> Okay, now I'm a bit confused. "print" is both a and a > member of the builtins. What happens then? It's a keyword in Python < 3, a built-in function in Python >= 3: ~% python3 Python 3.4.0a0 (default:96f08a22f562, Feb 24 2013, 23:37:53) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin T

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-12 Thread Skip Montanaro
>>> int="five" >>> [int(i) for i in ["1","2","3"]] TypeError: str is not callable > Now how are you going to get the original int type back? Magic. :-) >>> int = "five" >>> int("a") Traceback (most recent call last): File "", line 1, in TypeError: 'str' object is not callable >>> from __buil

Re: Why is regex so slow?

2013-06-18 Thread Skip Montanaro
> I don't understand why the first way is so much slower. I have no obvious answers, but a couple suggestions: 1. Can you anchor the pattern at the beginning of the line? (use match() instead of search()) 2. Does it get faster it you eliminate the "(.*)" part of the pattern? It seems that if yo

Re: os.putenv() has no effect

2013-06-18 Thread Skip Montanaro
> Does anybody know why this would happen or what I could be doing wrong? os.putenv will only affect the environment in subprocesses. Consider this session fragment: % python Python 2.7.2 (default, Oct 17 2012, 03:11:33) [GCC 4.4.6 [TWW]] on sunos5 Type "help", "copyright", "credits" or "license

Problems with pkg_resources

2013-06-20 Thread Skip Montanaro
I'm trying to get setup to work on pylint source. I've installed pylint, logilab-common and astroid in the usual manner, specifying --user to get them into my private space: python setup.py install --user If I attempt to import astroid from a Python prompt, everything's fine: % PYTHONPATH=/

Re: ANN: Bubbles 0.1 – Virtual Data Object Framework

2013-06-24 Thread Skip Montanaro
When the bubbles URL fails, Chrome suggests simply databrewery.org, which seems to work, though it has no mention of bubbles. Skip On Mon, Jun 24, 2013 at 3:54 AM, Dariusz Suchojad wrote: > On 06/23/2013 07:58 PM, Stefan Urbanek wrote: > >> If you have any comments, suggestions or questions, le

Re: settrace doesn't trace builtin functions

2013-07-01 Thread Skip Montanaro
> I've been using the settrace function to write a tracer for my program, > which is working great except that it doesn't seem to work for built-in > functions, like open('filename.txt'). This doesn't seem to be documented, so > I'm not sure if I'm doing something wrong or that's the expected

Re: Python list code of conduct

2013-07-02 Thread Skip Montanaro
> Does this list have a code of conduct or a netiqeutte (sp?) > statement/requirement? > > If not, should it? No, and probably not. As Joshua Landau indicated, nobody reads the user manual anyway. In addition, this mailing list is not currently moderated in an approve-each-message sort of way (

Re: Why is CPython 2.5 a dependency for Jython 2.5?

2013-07-03 Thread Skip Montanaro
> Does anyone know why CPython 2.5 is a dependency for Jython 2.5.1+ on > Debian squeeze? Might Jython use some Python modules/packages unmodified? Does sys.path in Jython refer to the CPython tree? Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Whatever happened to the Effbot? [was Re: python adds an etc]

2013-07-03 Thread Skip Montanaro
Last I knew, Fredrik was working for Google. According to his LinkedIn profile he's a Google employee in Zurich, apparently doing YouTube stuff (assuming his profile is up-to-date). Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: analyzing time

2013-07-05 Thread Skip Montanaro
> I have a table with a column of type date, with dates and time combined (like > '1/6/2013 3:52:69PM'), that spans many months. How would I pull out records > that are the first and last entries per day? You mentioned "table" and "column", which leads me to think you are dealing with data in a

Editor Ergonomics [was: Important features for editors]

2013-07-06 Thread Skip Montanaro
> The fact that rms has crippling RSI should indicate that > emacs' ergonomics is not right. Kind of a small sample size, don't you think? Hopefully we can kill this meme that Emacs is somehow worse for your wrists than other text editors before it goes any further than your one unsupported assert

Re: Important features for editors

2013-07-08 Thread Skip Montanaro
>> I couldn't live without the keyboard macro record and playback. > > I used to work with a programmer who couldn't live without his insulin > injections. Hyperbole aside, two of my most common "crutches" are Emacs macros and bash history. Given how useful macros are, I find it very odd that rec

Re: Important features for editors

2013-07-08 Thread Skip Montanaro
> Wasn't it C-x ( ? From the manual > >In addition to the and commands described above, Emacs > also supports an older set of key bindings for defining and executing > keyboard macros. To begin a macro definition, type `C-x (' > (`kmacro-start-macro'); as with , a prefix argument appends th

homework + obfuscation ... this might work ...

2013-07-08 Thread Skip Montanaro
I have an idea. Take the threads where students ask the list to do their homework for them (but don't have the cojones to admit that's what they are doing), and merge them with the obfuscated Python idea. A group of people could come up with the solution off-list, then answer the poster's original

Re: homework + obfuscation ... this might work ...

2013-07-08 Thread Skip Montanaro
> You assume that the professor (or more likely, TA) will take the time > to ask them to explain the program and not just grade them down for > the extra work they had to do. Well, that would be fine too. :-) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: hex dump w/ or w/out utf-8 chars

2013-07-09 Thread Skip Montanaro
> It wonder if 5-bit chars was a > common compression scheme. http://en.wikipedia.org/wiki/List_of_binary_codes Baudot was pretty common, as I recall, though ASCII and EBCDIC ruled by the time I started punching cards. Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: looking for a new router

2013-07-09 Thread Skip Montanaro
As long as we are wandering off-topic. (What defines "on-topic" for spam?) > I just got a Bosch combo model (both plunge and fixed base), and I'm > very happy with it: > > http://www.boschtools.com/Products/Tools/Pages/BoschProductDetail.aspx?pid=1617EVSPK I have a 1604. Any idea if the plunge

Re: looking for a new router

2013-07-09 Thread Skip Montanaro
> But hey, the plunge router recommendations are great! Yeah, based on Grant's research, I found a used PC 690-series base on eBay for my wife for her birthday. I think she will be psyched. Lots easier to make keyhole slots with a plunge base. :-) Skip -- http://mail.python.org/mailman/listin

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Skip Montanaro
> ... meant to be the word "posted", before his sentence got cut off by the > Python Secret Underground. Argh! That which shall not be named! Please, for the sake of all that is right, please only use the initials, PS -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Skip Montanaro
> Either that or it's funny only to other Australians. Or the Dutch. S -- http://mail.python.org/mailman/listinfo/python-list

Re: Stack Overflow moderator “animuson”

2013-07-10 Thread Skip Montanaro
On Wed, Jul 10, 2013 at 7:39 AM, Joshua Landau wrote: > On 10 July 2013 13:35, Skip Montanaro wrote: >>> Either that or it's funny only to other Australians. >> >> Or the Dutch. > > Or us Brits. Hells bells... It appears everyone found it funny except the tr

Re: UTF-EBCDIC encoding?

2013-07-12 Thread Skip Montanaro
> I can't help you. I'm astonished. Trying to imagine the work environment > where this technology would be necessary http://www.iseriespython.com/app/ispMain.py/Start?job=Home Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Messages to Python-List aren't posting

2013-07-19 Thread Skip Montanaro
> Date: Thu, 18 Jul 2013 16:30:51 -0400 - timestamp of your mail > Thu, 18 Jul 2013 13:30:51 -0700 (PDT) - you posted it via HTTP > Thu, 18 Jul 2013 22:31:39 +0200 (CEST) - it reached python.org > Fri, 19 Jul 2013 09:56:14 +0200 (CEST) - it began delivery to my address > Fri, 19 Jul 2013 00:56:15 -

Re: Messages to Python-List aren't posting

2013-07-19 Thread Skip Montanaro
> Is it possible that the name "Matthew > Lefavor" has been added to a greylist or something? That's not how greylisting works. Greylisting is a scheme used to eliminate spam. The server knows what email addresses it's received mail from in the last little while (say, the last month). When it g

Re: Find and Replace Simplification

2013-07-19 Thread Skip Montanaro
Serhiy> The string replace() method is fastest (at least in Python 3.3+). See Serhiy> implementation of html.escape() etc. I trust everybody knows by now that when you want to use regular expressions you should shell out to Perl for the best performance. :-) Skip -- http://mail.python.org/mailma

Re: Homework help requested, thanks to everyone.

2013-07-22 Thread Skip Montanaro
John> Another project I thought of was a Pig Latin translator. (But do kids today John> even know what Pig Latin is? Am I showing my age?) Chris> Even if they don't, they'll grok it no problem. It's simple enough. Google for "Python pig latin" to see a lot of "prior art". And it might be usefu

Re: Python testing tools

2013-07-23 Thread Skip Montanaro
> Thank you, but I already read this page before I posted this question. What I > want to > know is whether you personally use these tools other than unit testing tools. I tried using one of the mock tools a few years ago. I found it didn't fit my brain very well. (Maybe it was just me.) I use

Re: Python testing tools

2013-07-23 Thread Skip Montanaro
> Thank you! What tool do you use for coverage? coverage. :-) > And have you used pychecker? Yes, in fact, I used to use a wrapper script I wrote that ran both pylint and pychecker, then massaged the output into suitable-for-emacs-next-error-command > I heard it is as good as pylint. What do yo

Re: Python testing tools

2013-07-23 Thread Skip Montanaro
> Could you please elaborate on the difference of the two? I heard pylint > does not import your source code when it is analyzing, while pychecker does. > Does that make some difference? Moreover, do you personally like pylint or > pycheker and why? I haven't followed pychecker development for awh

Re: Python 3: dict & dict.keys()

2013-07-24 Thread Skip Montanaro
> What do you mean? Why would you want to create a temporary list just to > iterate over it explicitly or implicitly (set, sorted, max,...)? Because while iterating over the keys, he might also want to add or delete keys to/from the dict. You can't do that while iterating over them in-place. Thi

Re: PEP8 79 char max

2013-07-29 Thread Skip Montanaro
For the purposes of limiting the length you need to scan between first and last column, I would recommend leaving the recommended line length to ~ 80 columns. Just for grins, I grabbed a non-computer book, Atul Gawande's "Checklist Manifesto," from the pile on my desk and counted the number of cha

Re: PEP8 79 char max

2013-07-30 Thread Skip Montanaro
> In that gauge I would exclude indentation (you don't count the > number of characters the margin takes) I don't think anyone reads the margins. :-) That said, I agree that code and prose are fundamentally different beasts. Still, when reading either and you get to the end of the line, you

Re: PEP8 79 char max

2013-07-30 Thread Skip Montanaro
> So if everyone basically follows PEP8 we all benefit from playing by > the same game rules, as it were. (I think I'm agreeing with you, but nonetheless, I will forge ahead.) To the extent that 80-column window widths have been common for so long, PEP 8 or not (and Python or not), there is a ton

Re: PEP8 79 char max

2013-07-31 Thread Skip Montanaro
=> Works great until one of the values changes in size. Slightly off-topic, but still sort of related (talking about the size of things), I started picking 1e+30 as my "really big" some time back because the repr of 1e+99 required more than a glance when it appeared in printed output: >>> repr(1e

Test message - please ignore

2012-08-31 Thread Skip Montanaro
We just upgraded the Mailman installation on mail.python.org. Part of that installation includes spam filtering on messages gated from Usenet to the python- l...@python.org mailing list. This message is a quick test of that function. You can ignore it. Skip Montanaro -- http

Problems building Python from hg trunk on Open SUSE

2012-10-05 Thread Skip Montanaro
I haven't messed around with Python 3 recently, so decided to give it a whirl again. I cloned the trunk (cpython) and set about it. This is on an OpenSUSE 12.1 system. I configured like so: ./configure --prefix=/home/skipm/.linux-local and ran the usual "make ; make install". I'm a bit perp

Supporting list()

2012-12-17 Thread Skip Montanaro
What method(s) does a class have to support to properly emulate a container which supports turning it into a list? For example: class Foo: pass f = Foo() print list(f) Is it just __iter__() and next()? (I'm still using 2.4 and 2.7.) Thx, Skip -- http://mail.python.org/mailman/l

Re: Supporting list()

2012-12-17 Thread Skip Montanaro
> If using __getitem__ it needs to work with integers from 0 to len(f)-1, > and raise IndexError for len(f), len(f+1), etc. Ah, thanks. I have a __getitem__ method, but it currently doesn't raise IndexError. (I'm indexing into a ring buffer, and the usage of the class pretty much precludes index

Ctypes can't find libc on Solaris

2013-01-26 Thread Skip Montanaro
27/lib/python2.7/ctypes/util.py libm.so.6 libc.so.6 libbz2.so.1 libcrypt.so.1 On my Mac: % python ~/src/python/release27-maint/Lib/ctypes/util.py /usr/lib/libm.dylib /usr/lib/libc.dylib /usr/lib/libbz2.dylib On Solaris: % python /opt/TWWfsw/python27/lib/python2.7/ctypes/util.

Re: Ctypes can't find libc on Solaris

2013-01-26 Thread Skip Montanaro
> After worming around distutils' inability to use > environment variables to add command line flags to gcc, I'm stuck with > an error trying to locate libc: ... Should have poked around bugs.python.org first. This was reported, with a patch that works for me: http://bugs.python.org/issue528

Re: Questions.

2017-09-08 Thread Skip Montanaro
> Hi, From what I see in the recent 4/5 digests, this forum seems to be for > advanced and professional programmers. > > So wondering if a newbie can post some questions to understand errors in his > code or will it look silly? While there are professional programmers here, and some questions ex

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-10 Thread Skip Montanaro
> * asyncio with its a-dialect What is a/the "a-dialect"? S -- https://mail.python.org/mailman/listinfo/python-list

Re: Python programming language vulnerabilities

2017-09-10 Thread Skip Montanaro
That link's not working for me, even after changing the double slash to a single slash. Skip On Sun, Sep 10, 2017 at 1:45 PM, Stephen Michell wrote: > My apologies. I maintain that website. > > There should have been no broken links. I will fix that. > > The previous version of TR 24772 had anne

Re: Python programming language vulnerabilities

2017-09-10 Thread Skip Montanaro
4:14 PM, Skip Montanaro wrote: > That link's not working for me, even after changing the double slash > to a single slash. > > Skip > > On Sun, Sep 10, 2017 at 1:45 PM, Stephen Michell > wrote: >> My apologies. I maintain that website. >> >> There shoul

Totally OT - Looking for someone to translate some Japanese

2017-09-11 Thread Skip Montanaro
I have a scan of a few pages of an obscure book written in Japanese about an obscure French derailleur produced in the early 1960s. (I recently happened into an early 1960s Italian bike with just this derailleur.) I don't read a single lick of Japanese. I'm hoping tha

How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
I routinely include doctests as a source of test cases in my nose runs, but I want to also coax it to check the examples in my Markdown files. Is there a way to do this? If I explicitly give a Markdown file on the command line, nose complains: Unable to load tests from file ... Am I perhaps missi

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
> I routinely include doctests as a source of test cases in my nose runs, but I > want to also coax it to check the > examples in my Markdown files. Is there a way to do this? If I explicitly > give a Markdown file on the command line, > nose complains: > > Unable to load tests from file ... I b

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
> There are tools for getting doctests out of .rst files. Is it an option to > use .rst instead of .md? Given the existence proof of md working as an extension (see my previous follow-up), my guess is that it more-or-less supports just about any nearly-plain-text format. I could use .rst, I suppo

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
Actually, I semi-lied. It seems to pick up the second of two examples, and gets a bit confused about leading whitespace. I think I need to do some more fiddling. S -- https://mail.python.org/mailman/listinfo/python-list

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
> Actually, I semi-lied. It seems to pick up the second of two examples, > and gets a bit confused about leading whitespace. I think I need to do > some more fiddling. Solved the whitespace issue with the +NORMALIZE_WHITESPACE flag. It turns out that it actually does run all examples in the docume

Re: How to get Nose to run doctests from my Markdown documentation?

2017-09-20 Thread Skip Montanaro
> I didn't mean, "Can you name your Markdown files with an .rst extension," I > meant, "Can you use ReST instead of Markdown?" I wondered if maybe I was misinterpreting your question. :-) Conceptually, yes, I could use ReST. I'm just trying to go with the flow here at work. Markdown seems to be t

Re: How does CPython build it's NEWS or changelog?

2017-09-21 Thread Skip Montanaro
> I just discovered that CPython now uses Misc/NEWS.d/next to collect > changes an there are a lot of Misc/NEWS/*.rst files for the respective > released version. I'm investigating whether to adopt this for PyInstaller. > > What is the tooling for this? Is there some documentation, maybe a > mailin

Re: The mysterious ways of Python mailing list

2017-09-30 Thread Skip Montanaro
Some of my messages take about an hour. From looking at the headers in these cases, it looks like the delay is always before the message is received (i.e., accepted) by mail.python.org. This looks like greylisting. Yes, greylisting is one of the anti-spam arrows in the wider on mail.python.org. H

How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
Suppose you want to test a package (in the general sense of the word, not necessarily a Python package). You probably have specific unit tests, maybe some doctests scattered around in doc strings. Further, suppose that package requires you call an initialize function of some sort. Where does that g

Re: How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
> I've not had this problem myself, but py.test has the idea of "autouse > fixtures" which would work for this situation. Define your setup call > in a function, declare it with the pytest.fixture decorator with > autouse=True, and it'll be run before every test. The declaration goes > in a conftes

Re: How best to initialize in unit tests?

2017-10-04 Thread Skip Montanaro
On Wed, Oct 4, 2017 at 9:53 AM, Steve D'Aprano wrote: > On Thu, 5 Oct 2017 12:07 am, Skip Montanaro wrote: > >> Suppose you want to test a package (in the general sense of the word, >> not necessarily a Python package). > > I'm... not sure I understand. Given

Re: why del is not a function or method?

2017-10-16 Thread Skip Montanaro
> What about del team[2]? > > There is no name involved here, and even a reference to team[2] won't help. (I'm not sure quite what question is asking. Apologies if my assumption was incorrect.) That is precisely why del is a statement. At byte-compile time, both "team" and "2" are available. The

Application and package of the same name

2017-10-19 Thread Skip Montanaro
I'm not understanding something fundamental about absolute/relative imports. Suppose I have an application, fribble.py, and it has a corresponding package full of goodies it relies on, also named fribble. >From the fribble package, the application wants to import the sandwich function from the lunc

Re: Application and package of the same name

2017-10-19 Thread Skip Montanaro
> My immediate reaction is "you shouldn't name your main program and > your package the same". It's not a pattern I've seen commonly used. > > However, the approaches I've seen used (a __main__.py inside the > package, so you can execute it via `python -m fribble`, or a setup.py > entry point to ge

Re: Application and package of the same name

2017-10-19 Thread Skip Montanaro
Have you toyed with "from __future__ import absolute_import" ? Not sure if it'd help or not, but worth a try. Yeah, I did, but it didn't change anything as far as I could tell. S -- https://mail.python.org/mailman/listinfo/python-list

Re: Application and package of the same name

2017-10-21 Thread Skip Montanaro
This is actually a common pattern I see when teaching the language. For example, when a student wants to test out a package like requests many seem to initially want to create a requests.py module. Then they become very confused when they get an AttributeError on requests.get(). That I should fal

Re: String changing size on failure?

2017-11-01 Thread Skip Montanaro
Leave it to DB to ask the tough questions other people won't. :-) Skip On Wed, Nov 1, 2017 at 2:26 PM, Ned Batchelder wrote: > From David Beazley (https://twitter.com/dabeaz/status/925787482515533830): > > >>> a = 'n' > >>> b = 'ñ' > >>> sys.getsizeof(a) >50 > >>> sys.getsiz

Re: replacing `else` with `then` in `for` and `try`

2017-11-01 Thread Skip Montanaro
I don't know. The word "then" doesn't connote different ways of exiting a loop to me ("else" doesn't really either, I will grant you that, but it's what we have). Here's how I would read things: - *while* some condition holds, execute the loop, possibly breaking out, *then* do some finishing

Re: replacing `else` with `then` in `for` and `try`

2017-11-02 Thread Skip Montanaro
" makes things clearer. So, perhaps while and for loops could someday grow except clauses. :-) On Thu, Nov 2, 2017 at 5:04 AM, Steve D'Aprano wrote: > On Thu, 2 Nov 2017 12:49 pm, Skip Montanaro wrote: > > > I don't know. The word "then" doesn't connote dif

Incomplete description using sqlite3

2017-11-06 Thread Skip Montanaro
I'm using sqlite3 (2.6.0, SQLite version 3.13.0, Python 2.7.13) and was hoping to introspect the types of a table using the cursor's description attribute. PEP 249 states: "The first two items (name and type_code) are mandatory..." I tried this query: conn = sqlite3("/some/existing/database") curs

Need some help with Python Job Board

2017-11-11 Thread Skip Montanaro
The Python Job Board could use a little help in a couple areas. One, we can always use help reviewing and approving (or rejecting) submissions. The backlog keeps growing, and the existing volunteers who help can't always keep up. (This is a good problem to have, reflecting on Python's broad popular

Re: Need some help with Python Job Board

2017-11-12 Thread Skip Montanaro
2, 2017 at 11:20 AM, justin walters wrote: > On Sat, Nov 11, 2017 at 3:27 PM, Skip Montanaro > wrote: > > > The Python Job Board could use a little help in a couple areas. One, we > can > > always use help reviewing and approving (or rejecting) submissions. The > >

Re: Test - you can ignore

2017-11-18 Thread Skip Montanaro
On Saturday, November 18, 2017 at 7:28:56 AM UTC-6, Skip Montanaro wrote: > This is a test posting from the Usenet side of things. Looking to see if/when > it turns up in the gate_news logs on mail.python.org... This is another test, though with a bit more Python content... (python2) ~%

Re: Test - you can ignore

2017-11-18 Thread Skip Montanaro
On Saturday, November 18, 2017 at 7:28:56 AM UTC-6, Skip Montanaro wrote: > This is a test posting from the Usenet side of things. Looking to see if/when > it turns up in the gate_news logs on mail.python.org... > > Skip Yet another test. This time with SpamBayes x-mine_usenet_hea

Re: Test - please ignore (again)

2017-11-19 Thread Skip Montanaro
> Another test of SpamBayes in comp.lang.python -> python-list gateway. Still leaning on the submit button to see what gate_news thinks... Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: General Purpose Pipeline library?

2017-11-20 Thread Skip Montanaro
> I feel like I'm reinventing a wheel here. I was wondering if there's already > something that exists? I've wondered from time-to-time about using shell pipeline notation within Python. Maybe the grapevine package could be a starting point? I realize that's probably not precisely what you're lo

Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-24 Thread Skip Montanaro
> Because if I already can't understand the words, it will be more useful > to me to be able to type them reliably at a keyboard, for replication, > search, discussion with others about the code, etc. I am probably not alone in my Americo-centric world where I can't even easily type accented Latin

Test, test, test

2017-11-24 Thread Skip Montanaro
Testing 1 2 3 ... (you can ignore) def gen_dotted_quad_clues(pfx, ips): for ip in ips: yield "%s:%s/32" % (pfx, ip) dottedQuadList = ip.split(".") if len(dottedQuadList) >= 1: yield "%s:%s/8" % (pfx, dottedQuadList[0]) if len(dottedQuadList) >= 2

Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-24 Thread Skip Montanaro
> I find it it interesting that the primary reason to want to limit the > character set to ASCII is people thinking that it would make it hard for > *them* to read/use the code, but no thought about how much harder it makes > it on the original author/team to write code that is easily understood by

Re: [META] Why are duplicate posts coming through?

2017-11-26 Thread Skip Montanaro
Chris, Please forward one or two to me. Mark Sapiro and I have been banging on the SpamBayes instance which supports the Usenet gateway. I suppose it's possible some change caused the problem you're seeing. Skip On Nov 26, 2017 5:22 PM, "Chris Angelico" wrote: Not sure whether this is an issue

Re: nospam ** infinity?

2017-11-26 Thread Skip Montanaro
> There seems to be a gateway loop of some sort going on. > I'm seeing multiple versions of the same posts in > comp.lang.python with different numbers of "nospam"s > prepended to the email address. This is the second thread about this. I was thinking it might be related to recent changes to the g

Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-27 Thread Skip Montanaro
> I strongly suspect that any recent emacs will have M-x insert-char > (earlier it was called ucs-insert) default bound C-x 8 RET (yeah thats clunky) > which will accept at the minibuffer input I tried C-x 8 e acute TAB and was prompted with "E-acute". I don't know why it would have capitalized t

Re: Increasing the diversity of people who write Python (was: Benefits of unicode identifiers)

2017-11-27 Thread Skip Montanaro
> If you have a Windows key, you can assign it to be > the Compose key. Would this be true on a machine running Windows? My work environment has me developing on Linux, with a Windows desktop. It's not clear to me that any sort of xmodmap shennanigans would work. Won't Windows itself always gobble

Re: nospam ** infinity?

2017-11-27 Thread Skip Montanaro
>> Newsreader configuration problem? > > More likely, someone was trying to obscure the email addresses, but managed to > tag my name instead. Definitely looks like some sort of automation failure. > The > only question is, whose? If it's not from gate_news, there's someone here on > the list/ng

  1   2   3   4   5   6   7   8   9   10   >