Re: Fixing Python install on the Mac after running 'CleanMyMac'

2015-05-29 Thread Skip Montanaro
On Fri, May 29, 2015 at 11:11 AM, Ned Deily wrote: > Well, she could just download a current Python 2.7.x for OS X from > python.org, install it, and see if that solves the problem. That would > be likely the easiest thing to do and is unlikely to make matters worse. > Might that appear to work

Re: Zero [was Re: What is considered an "advanced" topic in Python?]

2015-06-01 Thread Skip Montanaro
On Mon, Jun 1, 2015 at 7:56 AM, Dave Farrance < davefarra...@omitthisyahooandthis.co.uk> wrote: > There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. So it's 1 that engineers really don't understand? Just add 1 and you get the correct number of

Re: fork/exec & close file descriptors

2015-06-02 Thread Skip Montanaro
Reviving (and concluding) a thread I started a couple weeks ago, I asked: > The basic fork/exec dance is not a problem, but how do I discover > all the open file descriptors in the new child process to make sure > they get closed? Do I simply start at fd 3 and call os.close() on > everything up to

Re: fork/exec & close file descriptors

2015-06-02 Thread Skip Montanaro
On Tue, Jun 2, 2015 at 10:28 AM, Marko Rauhamaa wrote: > > The only problem is that you don't know how high you need to go in > general. Sure, but I didn't know anyway, so no matter what upper bound I choose (or what function I choose/implement), it's just going to be a guess. os.closerange just

Re: fork/exec & close file descriptors

2015-06-02 Thread Skip Montanaro
Folks, I'm not interested in rehashing this. I don't know what all the open file descriptors are. Some/many/most will have been opened by underlying C++ libraries and will not have been opened by code at the Python level. I do think the addition of an os.fsync() attempt on each file descriptor befo

Re: Sorting in reverse is not the same as sorting then reversing

2015-06-05 Thread Skip Montanaro
On Fri, Jun 5, 2015 at 9:50 AM, Stefan Behnel wrote: > [Stable sorting is] a general property of Python's sort algorithm. And at times an extremely valuable property. Skip -- https://mail.python.org/mailman/listinfo/python-list

Cheat sheet for the new string formatting?

2015-06-08 Thread Skip Montanaro
I have so far ignored the new string formatting (you know, the stuff with all the braces, dots and brackets that make Python strings look like Perl code ). I am still only using Python 2.7, but have recently started forcing myself to use the print() function. I figure maybe I should also start to c

Re: Cheat sheet for the new string formatting?

2015-06-08 Thread Skip Montanaro
On Mon, Jun 8, 2015 at 3:05 PM, Steven K Knight wrote: > I think http://pyformat.info/ is what you're looking for. Perfect, thanks! S -- https://mail.python.org/mailman/listinfo/python-list

Re: Cheat sheet for the new string formatting?

2015-06-08 Thread Skip Montanaro
This is counterintuitive: >>> "{:.3}".format(-0.00666762259822) '-0.00667' >>> "{:.3f}".format(-0.00666762259822) '-0.007' >>> "%.3f" % -0.00666762259822 '-0.007' >>> "{:.3s}".format(-0.00666762259822) ValueError Unknown format code 's' for object of type 'float' Why does the first form display f

Re: Cheat sheet for the new string formatting?

2015-06-09 Thread Skip Montanaro
Skip> Why don't floats support "{:.Ns}"? (I know I can use "{!s}".) random832> Why would they? The old style didn't support %.Ns either. Well, the old style does, though it appears the N is ignored: >>> "%5s" % -0.00666762259822 '-0.00666762259822' It doesn't raise an exception though. (This i

Re: Cheat sheet for the new string formatting?

2015-06-09 Thread Skip Montanaro
On Tue, Jun 9, 2015 at 7:29 AM, wrote: > Where have you looked? Have you read > https://docs.python.org/3/library/string.html#formatspec ? Yes, but I missed the None section. I looked closely at 'g', but didn't see anything like "this is the default". I will admit I was a bit frustrated to see t

Re: Python NBSP DWIM

2015-06-10 Thread Skip Montanaro
On Wed, Jun 10, 2015 at 8:28 AM, Tim Chase wrote: > Is this a bug? Looks like it's been reported a few times with slightly different context: https://bugs.python.org/issue6537 https://bugs.python.org/issue16623 https://bugs.python.org/issue20491 https://bugs.python.org/issue1390608 The couple t

Re: Classic OOP in Python

2015-06-17 Thread Skip Montanaro
On Wed, Jun 17, 2015 at 2:21 PM, Jason P. wrote: > I'm gonna try to develop a modest application from ground up using > TDD. If it had been done in Java for instance, I would made > extensive use of interfaces to define the boundaries of my > system. How would I do something like that in Python?

Re: Parsing logfile with multi-line loglines, separated by timestamp?

2015-06-30 Thread Skip Montanaro
Maybe define a class which wraps a file-like object. Its next() method (or is it __next__() method?) can just buffer up lines starting with one which successfully parses as a timestamp, accumulates all the rest, until a blank line or EOF is seen, then return that, either as a list of strings, one m

Re: "normalizing" a value

2015-07-02 Thread Skip Montanaro
This looks like a straightforward linear transformation issue to me (like Fahrenheit to Celsius). Add 50 to all input values, giving you values in the range 0 to 100. Then scale them into your 0 to 12 range by multiplying them by 12/100: >>> for n in range(-50, 50, 3): ... print n, n + 50, (n +

Re: Readline -- cannot bind to both Ctrl-tab and tab at the same time?

2015-07-09 Thread Skip Montanaro
I thought this thread had died down. I guess not quite... It makes perfect sense to me that TAB and Ctrl-TAB would generate the same keycode, as TAB is itself a control character (Ctrl-I). As the Ctrl modifier bit is effectively already set, I don't think you can really set it a second time and be

Re: (side-)effects and ...

2015-07-09 Thread Skip Montanaro
> Also, he should not post here, because all articles posted here are > automatically put on a mailing list and that list's web-accessible > archive. I thought so at first add well. It looks like the Mailman system handles the X-No-Archive and/or Archive headers. I couldn't find his name in this m

Re: (side-)effects and ...

2015-07-10 Thread Skip Montanaro
On Thu, Jul 9, 2015 at 9:05 PM, Chris Angelico wrote: > Even if it respects that, there's no way that Mailman can know to > respect his ridiculous copyright restriction. > Well, sure. But Mailman is probably not alone in this regard. In case it wasn't clear from Tony the Tiger's post (everything

A couple virtual env questions

2015-07-15 Thread Skip Montanaro
I built and installed Python from Mercurial tip (head, whatever), so I have a Python 3.6.0a0 available. I created a virtualenv using that. Q1: Suppose I install something like matplotlib into that virtualenv which itself contains extension modules. Those will depend on the include files and shared

Re: How does a dictionary work exactly?

2015-07-16 Thread Skip Montanaro
> I was trying to see how some have implemented a hashtable. I took a gather > at dictobject.h/.c. It seems that underneath it all it's a linked list and > that is used in order to store the actual information (I'm looking at > PyDictEntry.) > > Am I correct in my assumption or is there more t

Re: How does a dictionary work exactly?

2015-07-16 Thread Skip Montanaro
On Thu, Jul 16, 2015 at 1:36 PM, yoursurrogate...@gmail.com wrote: > If I understand correctly, lookup would not be a constant, yes? On the contrary, that's what you desire, nearly constant time execution. To the greatest extent possible, you want the linked lists to be of length zero or one. Par

Re: How does a dictionary work exactly?

2015-07-17 Thread Skip Montanaro
On Fri, Jul 17, 2015 at 9:32 AM, Ned Batchelder wrote: > Maybe people are reading a different implementation than I am. Python's > dict object doesn't use linked lists to deal with hash collisions, it probes > other slots instead. No, I was working a) from memory, and b) not looking at the imple

Re: how to determine for using c extension or not ?

2015-08-03 Thread Skip Montanaro
id() tells you nothing about the nature of the function. Use the inspect.isbuiltin(): >>> import bisect >>> bisect.bisect >>> import inspect >>> def foo(): pass ... >>> inspect.isbuiltin(foo) False >>> inspect.isbuiltin(bisect.bisect) True It's perhaps a b

Re: Check if dictionary empty with == {}

2015-08-19 Thread Skip Montanaro
Comparison against {} will be less efficient. You need to create a dictionary every time instead of just checking the length of your dictionary, which is likely stored in the header. So, it will work, but certainly isn't idiomatic Python. Skip -- https://mail.python.org/mailman/listinfo/python-li

Re: Check if dictionary empty with == {}

2015-08-19 Thread Skip Montanaro
On Wed, Aug 19, 2015 at 6:33 PM, MRAB wrote: > Well, that depends on the intention. > > Is it checking whether the dictionary is empty, or whether it's an > empty dictionary (and not, say, an empty list)? > Sure, that's a possibility. I would argue that "mydict == {}" is also not the idiomatic w

Re: Check if dictionary empty with == {}

2015-08-20 Thread Skip Montanaro
On Wed, Aug 19, 2015 at 10:16 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > So maybe it's a micro-optimization? Note, however, that the original post compared "mydict == {}" with "not mydict". In that case, it's decidedly not an optimization: firefly% python2.7 -m timeit

Re: Check if dictionary empty with == {}

2015-08-20 Thread Skip Montanaro
On Thu, Aug 20, 2015 at 12:44 PM, Steven D'Aprano wrote: > Testing for "any Falsey value" and "an empty dict" are not the same, > naturally they will perform differently. Sure, but the OP's original note explicitly said he had a dict and asked how to test if it was emp

Re: [a,b,c,d] = 1,2,3,4

2015-08-25 Thread Skip Montanaro
On Tue, Aug 25, 2015 at 10:24 AM, Jussi Piitulainen < harvested.address@is.invalid> wrote: > When I try it today, round brackets > also work, both in 2.6.6 and 3.4.0 - no idea what version it was where > they failed or if I'm imagining the whole thing. > You are imagining the whole thing. Either

Having no luck installing Twisted 15.3.0

2015-08-28 Thread Skip Montanaro
One of our users needs Twisted. I built and installed 15.3.0. When I tried to import it, it complained: ImportError Twisted requires zope.interface 3.6.0 or later. So I downloaded, built and installed the latest version of zope.interface (4.1.2). Still it complains. So I tried 3.7.0. Same old, sa

Re: Having no luck installing Twisted 15.3.0

2015-08-28 Thread Skip Montanaro
On Fri, Aug 28, 2015 at 12:01 PM, Skip Montanaro wrote: > One of our users needs Twisted. I built and installed 15.3.0. When I > tried to import it, it complained: > > ImportError Twisted requires zope.interface 3.6.0 or later. > > So I downloaded, built and installed the

Re: Having no luck installing Twisted 15.3.0

2015-08-28 Thread Skip Montanaro
> I've seen this. > > You used pip to install zope.interface, right? > pip installed the thing someplace like: > /usr/local/lib/python2.7/dist-packages/zope > > You want to find it in /usr/share/pyshared/zope/interface/ > > Solution, make a link. Alas... I don't think so. The zope.interface stuff

datetime.datetime.today()

2015-09-16 Thread Skip Montanaro
This surprised me today: >>> import datetime >>> datetime.datetime.today(), datetime.datetime.now() (datetime.datetime(2015, 9, 16, 8, 44, 7, 723560), datetime.datetime(2015, 9, 16, 8, 44, 7, 723577)) I naively expected today() to always return a datetime.date object. Oh well, bug in my code has

Re: datetime.datetime.today()

2015-09-16 Thread Skip Montanaro
On Wed, Sep 16, 2015 at 8:55 AM, Nick Sarbicki wrote: > Just in the case you didn't figure it out: > > >>> datetime.datetime.today() > datetime.datetime(2015, 9, 16, 14, 50, 47, 700828) > >>> datetime.date.today() > datetime.date(2015, 9, 16) > Yeah, I was aware of that. That is partly why I th

Conda problem/question

2015-09-18 Thread Skip Montanaro
I was following along with Lex Hider's PyCon Au talk about Conda: https://www.youtube.com/watch?v=Fqknoni5aX0 Everything was going swimmingly. I installed miniconda, tweaked PATH, installed some of the other stuff he talked about, then did the pip command: pip install theano keras tweepy word2ve

Parsing HTML with xml.etree in Python 2.7?

2015-10-05 Thread Skip Montanaro
Back before Fredrik Lundh's elementtree module was sucked into the Python stdlib as xml.etree, I used to use his elementtidy extension module to clean up HTML source so it could be parsed into an ElementTree object. Elementtidy hasn't be updated in about ten years, and still assumes there is a modu

Re: Parsing HTML with xml.etree in Python 2.7?

2015-10-05 Thread Skip Montanaro
On Mon, Oct 5, 2015 at 9:14 AM, Skip Montanaro wrote: > I wouldn't be surprised if there were some small API changes other than the > name change caused by the move into the xml package. Before I dive into a > rabbit hole and start to modify elementtidy, is there some other stdlib

Paramiko SSHClient.connect() problem

2015-10-27 Thread Skip Montanaro
I'm trying to use paramiko (for the first time) to connect to both the localhost and a remote host as I read along in Jesse Noller's blog post . That host is listed in ~/.ssh/known_hosts three different ways:

Re: Paramiko SSHClient.connect() problem

2015-10-27 Thread Skip Montanaro
On Tue, Oct 27, 2015 at 8:23 AM, Skip Montanaro wrote: > >>> ssh = paramiko.SSHClient() > >>> conn = ssh.connect("firefly") > SSHException Server 'firefly' not found in known_hosts > [||1] [paramiko/client.py|connect|288] > [paramiko/client.py

Re: Paramiko SSHClient.connect() problem

2015-10-27 Thread Skip Montanaro
On Tue, Oct 27, 2015 at 1:40 PM, Chris Angelico wrote: > If you hack your hosts file to have only one localhost, > does the problem disappear? > Yes, that appears to solve the problem. Thanks. I hadn't even thought there would be IPv4/IPv6 distinctions here. Interestingly enough, the box does s

Re: try/except/finally

2014-06-09 Thread Skip Montanaro
On Mon, Jun 9, 2014 at 11:23 AM, Shiyao Ma wrote: > > It would be great if someone could discuss it from the viewpoint of bytecode. > e.g., how the stack is popped, etc. BITD, you couldn't have try/except/finally. You could have try/except or try/finally. You could nest the two, which is what pe

Re: try/except/finally

2014-06-10 Thread Skip Montanaro
> Here is Dijkstra: > http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html ... > And here is Hoare... > | Ada has a plethora of features and notational conventions, many of them > | unnecessary and some of them, like exception handling, even > | dangerous. Do not

Re: 基于cython的即时编译器cyjit,欢迎大家提建议

2014-06-11 Thread Skip Montanaro
> You might say that but I couldn't possibly comment. You could run the message through Google Translate. It's not publication quality translation, but serves the needs in this instance. (Gmail offers to translate the OP's message for me.) Here's what GT produced (successfully translates the Chin

Re: Standard way to generate mail/news reply?

2014-06-24 Thread Skip Montanaro
On Tue, Jun 24, 2014 at 6:46 AM, Adam Funk wrote: > Is there some standard library or code for taking an e-mail or > newsgroup message & generating a reply to it? You might try searching for "mail reply" on pypi.python.org. That will return a number of hits. I know the python.org replybot is ther

Re: print statements and profiling a function slowed performance

2014-06-27 Thread Skip Montanaro
On Fri, Jun 27, 2014 at 10:55 AM, Mark Lawrence wrote: > Expectations don't count, measure it :) It's no contest. I have measured it (ages ago). The logging module does so many things that it's impossible for it to ever be as fast as a simple print statement. Look at the code in LogRecord.__init_

Re: print statements and profiling a function slowed performance

2014-06-27 Thread Skip Montanaro
On Fri, Jun 27, 2014 at 4:35 PM, Ian Kelly wrote: > That's got to count for > something, compared to a raw print that has to wait for the I/O to > finish. A raw print basically just tosses some bytes in a stdio buffer (at least in Unix-land). Stdio does whatever little it does, then passes the by

Re: thread.interrupt_main() behaviour

2014-07-01 Thread Skip Montanaro
On Tue, Jul 1, 2014 at 3:58 AM, Piyush Verma <114piy...@gmail.com> wrote: > > Since two threads are running same method, I wanted to know which main thread > will be interrupted in both case. I'm no threading expert, but a process can only have one main thread, the one you labeled "P". Threads T2

What's the "right" way to abandon an open source package?

2014-07-01 Thread Skip Montanaro
This is only Python-related because the package in question (lockfile at PyPI) is written in Python and hosted (at least in part) on PyPI. I have not had any interest in maintaining this package for a few years. I wrote it mostly as an exercise, and while I do happen to use it ever-so-slightly in m

Re: What's the "right" way to abandon an open source package?

2014-07-01 Thread Skip Montanaro
It's on github (by request from another person who didn't take it over). It's also on Google Code. I'm actually pretty naive and agnostic about these various hosting sites and their favorite revision control tools, but I don't have enough time to master all of them. I think I have a couple volunte

Re: 1-0.95

2014-07-02 Thread Skip Montanaro
On Wed, Jul 2, 2014 at 11:59 AM, Marko Rauhamaa wrote: > Yes, I'm making it up, but it's still true. I don't think there's any reason to be hypothetical: In [149]: d Out[149]: Decimal('2') In [150]: d.sqrt() * d.sqrt() == d Out[150]: False :-) Skip -- https://mail.python.org/mailman/listinfo

Re: What is 're.M'?

2014-07-07 Thread Skip Montanaro
Scroll down to the "Module Contents" section of this page: https://docs.python.org/2/library/re.html It explains re.M and other "constants". Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Skip Montanaro
On Tue, Jul 8, 2014 at 10:19 AM, Chris Angelico wrote: > For hash keys, float object identity will successfully look them up: d={} d[float("nan")]=1 d[float("nan")]=2 x=float("nan") d[x]=3 d[x] > 3 d > {nan: 1, nan: 2, nan: 3} Neat! S -- https://mail.python.or

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Skip Montanaro
On Tue, Jul 8, 2014 at 9:53 AM, Anders J. Munch <2...@jmunch.dk> wrote: > Most people don't need to deal with NaN's in Python at all, > fortunately. They just don't appear in normal computation, because the > interpreter raises an exception instead. In addition to what others have written, I will

Re: NaN comparisons - Call For Anecdotes

2014-07-08 Thread Skip Montanaro
s is in Python 2.7), but the division returns the appropriate value, in this case, infinity. So, yes, they forge on, and NaN taints things just about the way you'd expect. Skip On Tue, Jul 8, 2014 at 12:36 PM, Marko Rauhamaa wrote: > Skip Montanaro : > >> In addition to what oth

Re: Do I need to call close on the handle returned by urlopen?

2014-07-14 Thread Skip Montanaro
> The tutorial says that I should use "with open" to close the file > handle properly. The reference documentation for urlopen mentions > that the handle returned is like a file handle but the code samples > below do not bother to close the handle at all. Isn’t it > inconsistent? I think two thi

Re: This Python 3 is killing Python thread is killing me.

2014-07-16 Thread Skip Montanaro
On Wed, Jul 16, 2014 at 3:27 PM, Mark Lawrence wrote: > The difference between our most illustrious resident unicode expert and rr Sorry, who is "rr"? I went looking in the referenced thread but found nobody with those initials. Not so helpfully, Gmail elides most sigs, so I couldn't reliably sca

Re: Blocked thread

2014-07-17 Thread Skip Montanaro
On Thu, Jul 17, 2014 at 12:32 PM, Chris Angelico wrote: > I don't know Oracle specifically, but if it's anything like > PostgreSQL, you'll probably do better with a completely separate > connection to the server > Agreed. We use Sybase, and our DBA uses their tools extensively to identify proble

Re: Prob. Code Downloaded for Programming the Semantic Web (python code)

2014-07-25 Thread Skip Montanaro
> OK, Eclipse with PyDev doesn't like this first line, with the function: > def add(self, (sub, pred, obj)): > > It complains about the parentheses just before sub. Seems like this code is Python 2.x. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Load a CSV with different row lengths

2014-07-29 Thread Skip Montanaro
> How can I load this into python? I tried using both NumPy and Pandas. To add to Peter's response, I would be very surprised if numpy or Pandas couldn't be coaxed into loading your CSV file, but you didn't provide any details about what you expected and what you got. I've used Pandas to read CSV

Re: Getting a list of all modules

2014-07-30 Thread Skip Montanaro
On Wed, Jul 30, 2014 at 2:43 AM, Steven D'Aprano wrote: > I'm looking for a programmatic way to get a list of all Python modules > and packages. Not just those already imported, but all those which > *could* be imported. > I wrote a modified dir(), which I inject into builtins in interactive ses

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
> df = pd.read_csv('nhamcsopd2010.csv' , index_col='PATCODE', low_memory=False) > col_init = list(df.columns.values) > keep_col = ['PATCODE', 'PATWT', 'VDAY', 'VMONTH', 'VYEAR', 'MED1', 'MED2', 'MED3', 'MED4', 'MED5'] > for col in col_init: > if col not in keep_col: > del df[col] I'm n

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
(Now that I'm on a real keyboard, more complete responses are a bit easier.) Regarding the issue of missing columns from keep_col, you could create sets of what you have and what you want, and toss the rest: toss_these = list(set(df.columns) - set(keep_col)) del df[toss_these] Or something to th

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
On Wed, Jul 30, 2014 at 8:11 PM, Chris Kaynor wrote: > Another way to write this, using a list expression (untested): > new_df = [col for col in df if col.value in keep_col] As I am learning (often painfully) with pandas and JavaScript+(d3 or jQuery), loops are the enemy. You want to operate on l

Re: converting ISO8601 date and time string representations to datetime

2014-07-31 Thread Skip Montanaro
On Thu, Jul 31, 2014 at 6:52 AM, Roy Smith wrote: > Sadly, the stdlib datetime really doesn't make life easy for dealing > with ISO-8601. Dateutil is the classic answer, but it's slow. A useful feature for dateutil would be a "sniff" function which, given a date string that dateutil.parser.parse

Re: Is there a tracker target for this mailing list?

2014-07-31 Thread Skip Montanaro
On Thu, Jul 31, 2014 at 8:38 AM, Anders Wegge Keller wrote: > So where to report this issue? Perhaps postmas...@python.org? Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Skip Montanaro
On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: > > I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes ≠ keys. When you see something.somethingelse anywhere else in Python, "somethingelse" is an attribute reference. When you see som

Re: why i can not delete my email with imaplib?

2014-08-06 Thread Skip Montanaro
My apologies. I must be dense. Why do you want to do this from Python? Can't you accomplish the same thing more easily with a Gmail filter which deletes all messages sent to python-list@python.org? Also, I assume that if you use "x...@gmail.com" only so you can send mail to the list, why not just d

Re: converting ISO8601 date and time string representations to datetime

2014-08-06 Thread Skip Montanaro
On Wed, Aug 6, 2014 at 1:31 PM, Joel Goldstick wrote: > Among other features it lists this: Gaps in functionality: ISO-8601 > parsing, timespans, humanization What is "humanization"? Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Template language for random string generation

2014-08-08 Thread Skip Montanaro
One suggestion, though perhaps nothing actually needs changing. I occasionally run into sites which define their password constraints as something like "minimum 8 characters, at least one number, one uppercase letter, and one special character." Their notion of "special" (which in my mind means an

Comparisons of Python's module/import system with JavaScript?

2014-08-08 Thread Skip Montanaro
I'm struggling with some JavaScript issues related to it's lack of good support for modules. I know RequireJS exists (and appears to be the most widely used add-on for this stuff), but as a novice JS programmer, I'm having trouble wrapping my head around just what it does. In particular, I don't se

Re: Python Object Systems

2014-08-11 Thread Skip Montanaro
On Mon, Aug 11, 2014 at 3:26 PM, wrote: > has anyone created a survey of Python Object Systems? For the uninitiated, can you back up a step and define what you mean by an "object system"? The term seems kind of broad for Google ( number of hits for CLOS, etc), and Wikipedia just directs to a pag

Re: Begginer in python trying to load a .dll

2014-08-12 Thread Skip Montanaro
On Tue, Aug 12, 2014 at 1:36 PM, c1223 wrote: > I've trying with ctype, but it doesn't work. Can you post a small example of how you're trying to use cypes? I don't think a full example would be necessary, but knowing the API of one or two functions and how you're trying to call them from Python

Re: Log base 2 of large integers

2014-08-13 Thread Skip Montanaro
On Wed, Aug 13, 2014 at 8:05 AM, Mok-Kong Shen wrote: > I like to compute log base 2 of a fairly large integer n but > with math.log(n,2) I got: > > OverflowError: long int too large to convert to float. > > Is there any feasible work-around for that? A bit of googling turned up this page: http:

Re: Captcha identify

2014-08-13 Thread Skip Montanaro
On Wed, Aug 13, 2014 at 2:44 PM, Joel Goldstick wrote: > I wrote a sample form page with a simple math problem to solve -- 2 or > 3 random small integers to add ... I've also seen challenge systems where they present you with a small set of images and ask you to select one with a particular prope

Re: Optional static typing

2014-08-14 Thread Skip Montanaro
On Thu, Aug 14, 2014 at 12:02 AM, Steven D'Aprano wrote: > Does anyone here use function annotations? If so, what do you use them > for? I've used them a little when converting Python to Cython, though I readily admit that I have no idea if what Cython accepts as a type declaration is compatible

Re: PyMatch Tool.

2014-08-14 Thread Skip Montanaro
On Thu, Aug 14, 2014 at 5:49 PM, Chris Angelico wrote: > > > Tool -> https://github.com/rfunix/PyMatch > > How is this better than GNU sed? I didn't look closely at the program, but I have an idea how I might use it. Back in the dawn of Internet time (before Y2K, Django, V8, etc) I developed and

Re: Adapt bash readline operate-and-get-next

2014-08-18 Thread Skip Montanaro
On Mon, Aug 18, 2014 at 1:49 PM, Lele Gaifax wrote: > Even if I know this is not the right forum and I should (and I > eventually do, assuming a positive feedback) instead open a ticket and > attach the patch there, I'd like to hear opinions on whether this should > be enabled by default, and poss

Re: Adapt bash readline operate-and-get-next

2014-08-19 Thread Skip Montanaro
On Tue, Aug 19, 2014 at 3:44 AM, Lele Gaifax wrote: >> Does your position in the history disappear if you >> operate_and_get_next(), then modify the next recalled input line? > > Not sure what you mean with "disappear": basically o-a-g-n "accepts" the > current line (that is, "executes" it, and th

Re: 'is not' or '!='

2014-08-19 Thread Skip Montanaro
On Tue, Aug 19, 2014 at 7:42 AM, Martin S wrote: >> For example, in CPython 3.4.1: > (254 + 3) is 257 >> False > (254 + 3) == 257 >> True > ('asd' + '@sd') is 'asd@sd' >> False > ('asd' + '@sd') == 'asd@sd' >> True > > Now you have managed to confuse this newbie: What would a valid

MacroPy tracing not working for me...

2014-08-19 Thread Skip Montanaro
I just downloaded and installed MacroPy (pip install --user MacroPy), with an intention of sticking a "with trace:" inside a failing unit test being run with nosetests. If I understood the example on the PyPI page correctly, I should have been able to do this: import macropy.tracing with macropy.t

Re: Why Python 4.0 won't be like Python 3.0

2014-08-19 Thread Skip Montanaro
On Tue, Aug 19, 2014 at 9:27 AM, Grant Edwards wrote: > I'm probably conflating the 1.5.2/2.0 and the 2.6 stuff. I do > remember delaying moving from 1.5.2 -> 2.0 until I really had to, but > I don't remember why. If you were a RedHat user during that timeframe, that might have contributed to yo

Re: 'is not' or '!='

2014-08-19 Thread Skip Montanaro
On Tue, Aug 19, 2014 at 11:42 AM, Ian Kelly wrote: > When I need to do this, I use: > > SENTINEL = object() > > It's still a singleton, and why should a sentinel be mutable? Old habits die hard, I guess. I've been using Python since long before object() existed. :-) Skip -- https://mail.pyt

Re: MacroPy tracing not working for me...

2014-08-20 Thread Skip Montanaro
On Wed, Aug 20, 2014 at 7:03 AM, Chris Angelico wrote: > Sounds like something to raise as an issue. I found the macropy Google Group and asked there. There is more to do to activate it. In particular, it doesn't appear-to-operate on a less-than-module level. Since it operates on the AST, it ha

Re: Python vs C++

2014-08-22 Thread Skip Montanaro
On Fri, Aug 22, 2014 at 7:51 AM, Neil D. Cerutti wrote: > But I contend you do need to be a Medieval Scholar to compile and link it. That's only because whoever wrote your Makefile wasn't skilled in the art of make recipes. :-) Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Global indent

2014-08-22 Thread Skip Montanaro
On Fri, Aug 22, 2014 at 1:19 PM, Seymore4Head wrote: > Say I have a while statement with several lines of code and I want to > add a while outside that. That means indenting everything. Is there > a global way to do that? Depends on your text editor/IDE. In Emacs using either python-mode.el or

Switching from nose to unittest2 - how to continue after an error?

2014-08-25 Thread Skip Montanaro
It appears that unittest in Python 2.7 should be capable enough that I can abandon nose in favor of python -m unittest. How do I get it to continue past the first failure? The --help output indicates that a -f flag causes it to "fail fast", however, that appears to be the default. How do I get it t

Re: Switching from nose to unittest2 - how to continue after an error?

2014-08-25 Thread Skip Montanaro
> It appears that unittest in Python 2.7 should be capable enough that I > can abandon nose in favor of python -m unittest. How do I get it to > continue past the first failure? The --help output indicates that a -f > flag causes it to "fail fast", however, that appears to be the > default. How do

Re: Switching from nose to unittest2 - how to continue after an error?

2014-08-25 Thread Skip Montanaro
On Mon, Aug 25, 2014 at 1:59 PM, Mark Lawrence wrote: > If you wish to write tests using something that can be compiled out please > don't let me stop you. Having said that if nose or even nose2 works for you > why not stick with it? There's also testfixtures, pytest, doctest and > presumably ot

Re: Switching from nose to unittest2 - how to continue after an error?

2014-08-26 Thread Skip Montanaro
On Mon, Aug 25, 2014 at 4:47 PM, Terry Reedy wrote: > I know of two ways to collect multiple failures within a test function: Thanks, but I mean multiple test failures. I fully expect a specific test to exit when it hits an assertion failure. I suspect my problem is due to lack of support for th

Re: PyPI password rules

2014-08-26 Thread Skip Montanaro
On Tue, Aug 26, 2014 at 1:16 AM, Chris Angelico wrote: > Currently, her full dictionary is 12759 words Chris, How did you come up with that list? I took the New Academic Word List[1] + the New General Service List[2] (sans duplicates) and wound up with 1646 words of length four through six. Did

Re: PyPI password rules

2014-08-26 Thread Skip Montanaro
On Tue, Aug 26, 2014 at 9:02 AM, Chris Angelico wrote: > On my Dungeons & Dragons server, in the common room, I have a parrot > named Polly. She listens to everything people say,... Ah, okay. Nice approach. Not a D&D player, so I'll stick with my common words for now, until and unless I come up w

Re: PyPI password rules

2014-08-26 Thread Skip Montanaro
On Tue, Aug 26, 2014 at 10:52 AM, Chris Angelico wrote: > Most of what Polly hears is fairly general chatter. There are a few > jargon terms like "metamagic" that are D&D-specific, but apart from > that, it's straight English. I guess I could write a little program that listens to my incoming ema

Re: Switching from nose to unittest2 - how to continue after an error?

2014-08-26 Thread Skip Montanaro
On Tue, Aug 26, 2014 at 11:58 AM, Terry Reedy wrote: > If you want to be understood, give a snippet of code, what happens now, and > what you want to happen. Thanks, but not really necessary. I have retreated into nose-land. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: PyPI password rules

2014-08-27 Thread Skip Montanaro
On Tue, Aug 26, 2014 at 11:05 AM, Skip Montanaro wrote: > I guess I could write a little program that listens to my incoming > email via IMAP. I'll have to see what that generates. Lots of Python > and bike references, no doubt. I should have something to show the world in a day or

Re: hg, git, fossil, ... [was Re: What is acceptable as 'open-source'? [was Python vs C++]]

2014-08-27 Thread Skip Montanaro
On Wed, Aug 27, 2014 at 1:26 PM, Ethan Furman wrote: > I use hg because 1) python-dev uses hg; and 2) I understand the simple hg > commands. I find git confusing, and my main uses are commit, pull, update, > an occasional merge, and a rare rollback -- not complicated stuff. The "simple hg comm

Re: PyPI password rules

2014-08-27 Thread Skip Montanaro
On Wed, Aug 27, 2014 at 9:23 AM, Skip Montanaro wrote: > I should have something to show the world in a day or two. Here's my first crack at it. https://github.com/smontanaro/polly Thanks to Chris for the idea and the name. The README.md file should have enough to get started. B

Re: PyPI password rules

2014-08-27 Thread Skip Montanaro
On Wed, Aug 27, 2014 at 10:32 PM, Chris Angelico wrote: > I'm not sure I understand how your 'common' value works, though. Does > the default 0.6 mean you take the 60% most common words? Those above > the 60th percentile of frequency? Something else? > Yes, basically. A word has to pass the foll

Re: PyPI password rules

2014-08-27 Thread Skip Montanaro
On Thu, Aug 28, 2014 at 12:08 AM, Chris Angelico wrote: > Interesting. I suspect this may have issues, as you're doing these > checks progressively; something that's common in the early posts will > be weighted without regard to subsequent posts (you're requiring 100 > unique words before recordi

Re: PyPI password rules

2014-08-28 Thread Skip Montanaro
On Wed, Aug 27, 2014 at 11:28 PM, Skip Montanaro wrote: > Hmmm... I realize now that I'm not seeing all messages, at least I don't > think so. So much to learn about IMAP... I peeked at the code for the SpamBayes IMAP filter. Holy smokes! I think the IMAP RFC authors might h

Re: Thread terminate

2014-08-28 Thread Skip Montanaro
On Wed, Aug 27, 2014 at 1:55 PM, Ervin Hegedüs wrote: > what's the correct way to terminate a thread by itself? If this is something you need to do as a regular course of business, I'd share a Queue between the main thread and the target thread. When you want it to exit, shoot it a command to d

Re: PyPI password rules

2014-08-28 Thread Skip Montanaro
On Thu, Aug 28, 2014 at 9:21 AM, Ethan Furman wrote: > What's the value in ruling out less common words? I would think the more > the merrier! I think less common "words" are likely to actually not be words, just misspellings of other words, and thus harder for the user to remember. More cruft

<    4   5   6   7   8   9   10   11   12   >