Re: a better way to invert a list?

2011-04-06 Thread Paul Rubin
scattered writes: > def invert(p): > return [ j for (i,j) in sorted(zip(p,range(len(p] return [j for i,j in sorted(enumerate(p), key=itemgetter(1))] looks a little cleaner to me. In Haskell or ML, you can use patterns that contain wild cards that play a role in the pattern

Re: Is the function filter deprecated?

2011-04-06 Thread Paul Rubin
Steven D'Aprano writes: > filter(func, *seqs) -> [x for x in itertools.chain(*seqs) if func(x)] > although I suppose functional programming purists might object :) Maybe you really want filter(func, chain.from_iterable(seqs)) -- http://mail.python.org/mailman/listinfo/python-list

Re: Feature suggestion -- return if true

2011-04-12 Thread Paul Rubin
zildjohn01 writes: > _temp = expr > if _temp: return _temp I'm trying to figure out a context where you'd even want that, and I'm thinking that maybe it's some version of a repeat-until loop? Python doesn't have repeat-until and it's been proposed a few times. -- http://mail.python.org/

Re: Feature suggestion -- return if true

2011-04-12 Thread Paul Rudin
Teemu Likonen writes: > I'm a simple Lisp guy who wonders if it is be possible to add some kind > of macros to the language... As a (now somewhat lapsed) long-time lisp programmer I sympathise with the sentiment, but suspect that it's not going to gain serious traction in python circles. -- htt

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico writes: That loop will exit at the first gap in the sequence. If that's what you want, you could try (untested): from itertools import takewhile seq = takewhile(lambda n: ('Keyword%d'%n) in dct, count(1)) lst = map(dct.get, seq) This does 2 lookups per key, which you co

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico writes: >>   sentinel = object() >>   seq = (dct.get('Keyword%d'%i,sentinel) for i in count(1)) >>   lst = list(takewhile(lambda x: x != sentinel, seq)) > > If I understand this code correctly, that's creating generators, > right? It won't evaluate past the sentinel at all? Right,

Re: Pythonic infinite for loop?

2011-04-15 Thread Paul Rubin
Chris Angelico writes: > This whole code is inside a loop that we took, in smoke testing, to a > couple hundred million rows (I think), with the intention of having no > limit at all. So this might only look at 60-100 headers, but it will > be doing so in a tight loop. If you're talking about dat

Re: [ANN] Python 2.5.6 Release Candidate 1

2011-04-19 Thread Paul Rubin
"Martin v. Löwis" writes: > On behalf of the Python development team and the Python community, I'm > happy to announce the release candidate 1 of Python 2.5.6. > > This is a source-only release that only includes security fixes. Thanks Martin, I'm glad these older releases are still getting impo

Re: No more Python support in NetBeans 7.0

2011-04-20 Thread Paul Rubin
Markus writes: > Infoworld awarded it as best Python IDE, testing: Boa Constructor, > Eric, ActiveState's Komodo, Oracle's NetBeans, Aptana's Pydev, > PyScripter, SPE, Spyder, and WingWare's Wing IDE. I saw somebody using Geany recently and it looked pretty impressive. For Python gui debuggers, w

Re: Snowball to Python compiler

2011-04-21 Thread Paul Rubin
Matt Chaput writes: > I'm looking for some code that will take a Snowball program and > compile it into a Python script. Or, less ideally, a Snowball > interpreter written in Python. > > (http://snowball.tartarus.org/) > > Anyone heard of such a thing? I never saw snowball before, it looks kind o

Re: suggestions, comments on an "is_subdict" test

2011-04-23 Thread Paul Rubin
Irmen de Jong writes: > I would use: > test_dct.items() <= base_dct.items() I think you need an explicit cast: set(test_dct.items()) <= set(base_dct.items()) -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Paul Rubin
Chris Angelico writes: > results = [function() for function in actions] results = map(apply, actions) -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple map/reduce utility function for data analysis

2011-04-25 Thread Paul Rubin
Raymond Hettinger writes: > Here's a handy utility function for you guys to play with: > http://code.activestate.com/recipes/577676/ Cute, but why not use collections.defaultdict for the return dict? Untested: d = defaultdict(list) for key,value in ifilter(bool,imap(mapper, data)):

Re: De-tupleizing a list

2011-04-25 Thread Paul Rubin
Gnarlodious writes: > I have an SQLite query that returns a list of tuples: > [('0A',), ('1B',), ('2C',), ('3D',),... > What is the most Pythonic way to loop through the list returning a > list like this?: > ['0A', '1B', '2C', '3D',... Try: tlist = [('0A',), ('1B',), ('2C',), ('3D',)] al

Re: Have you read the Python docs lately?

2011-04-27 Thread Paul Rubin
Raymond Hettinger writes: > A number of developers have been working on adding examples and useful > advice to the docs. To sharpen your skills, here are some pieces of > recommended reading: Thanks, those are nice. The logging one looks especially useful. The module always looked very confusi

Re: How to build an application in Django which will handle Multiple servers accross network

2011-04-29 Thread Paul Kölle
erface shortly. That would be awesome because PCP is developed by real engineers and has a proper architecture and is NOT a CPU sucking monstrosity of PERL-line-noise + a few hacked-together PHP frontends. just my 2cents Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Fibonacci series recursion error

2011-04-29 Thread Paul Rudin
harrismh777 writes: > lalit wrote: >> The above function return the >> return (fib(n-1)+fib(n-2)) >> >> RuntimeError: maximum recursion depth exceeded in comparison >> [36355 refs] > > There is much debate about this generally, but general wisdom is that > recursion is to be avoided when possible

Re: Fibonacci series recursion error

2011-04-30 Thread Paul Rudin
Hans Georg Schaathun writes: > On Sat, 30 Apr 2011 06:43:42 +0100, Paul Rudin >wrote: > : Writing recurive code is acceptable and is a nice clear way of > : expressing things when you have naturally recursive data structures, and > : can lead to perfectly good compiled co

Re: Fibonacci series recursion error

2011-04-30 Thread Paul Rudin
Hans Georg Schaathun writes: > On Sat, 30 Apr 2011 12:29:00 +0100, Paul Rudin >wrote: > : Clearly it makes a difference in any case where you'd hit the recursion > : limit. > > What kind of problems make you hit the limit? > > Other than when you forget the ba

Re: Development tools and practices for Pythonistas

2011-05-01 Thread Paul Rubin
>> > Look at the big two sites for open-source repositories -- github and >> > bitbucket. > Note that there are three: Launchpad (backed by Bazaar) is the other > “big site” for free-software project hosting. There is also patch-tag.com (using darcs) though it is smaller. -- http://mail.python.or

Re: Appending to dictionary of lists

2011-05-03 Thread Paul Rubin
"Alex van der Spek" writes: > refd=dict.fromkeys(csvr.fieldnames,[]) ... > I do not understand why this appends v to every key k each time. You have initialized every element of refd to the same list. Try refd = dict((k,[]) for k in csvr.fieldnames) instead. -- http://mail.python.org/mai

Re: What other languages use the same data model as Python?

2011-05-04 Thread Paul Rubin
Steven D'Aprano writes: x = "spam" > what is the value of the variable x? Is it...? > (1) The string "spam". Python works about the same way as Lisp or Scheme with regard to this sort of thing, and those languages have been described with quite a bit of mathematical formality. So if you wan

Re: Today's fun and educational Python recipe

2011-05-04 Thread Paul Rubin
Raymond Hettinger writes: > Here's a 22-line beauty for a classic and amazing algorithm: > http://bit.ly/bloom_filter The use of pickle to serialize the keys is a little bit suspicious if there might be a reason to dump the filter to disk and re-use it in another run of the program. Pickle repre

Re: Python Developers with 5 years of experience

2011-05-04 Thread Paul Rubin
Ben Finney writes: > Please do not solicit for jobs here. Instead, the Python Job Board > http://www.python.org/community/jobs/> is intended for that purpose. Wow, there's quite a lot of listings there. There had been only a few last time I looked. But, most of them seem to involve Django. --

Re: dictionary size changed during iteration

2011-05-07 Thread Paul Rubin
Roy Smith writes: > changes = [ ] > for key in d.iterkeys(): > if is_bad(key): > changes.append(key) changes = list(k for k in d if is_bad(k)) is a little bit more direct. -- http://mail.python.org/mailman/listinfo/python-list

Re: dictionary size changed during iteration

2011-05-08 Thread Paul Rubin
Hans Mulder writes: > How about: > changes = filter(is_bad, d) > Or would that be too compact? I thought of writing something like that but filter in python 3 creates an iterator that would have the same issue of walking the dictionary while the dictionary is mutating. changes = list(f

Re: Overuse of try/except/else?

2011-05-10 Thread Paul Probert
for my uses, its handy to let things raise exceptions willy nilly in the lower level functions, and do the catching in the higher level function. Paul Probert -- http://mail.python.org/mailman/listinfo/python-list

Re: Abandoning Python

2011-05-24 Thread Paul Rubin
John Lee writes: > In this thread, I'm asking about the views of Python programmers on > languages other than Python. I sympathize with what you're looking for but I don't think there's a really good answer at this time. Things IMO are converging in the direction of functional languages like H

Re: How do I find what kind of exception is thrown.

2017-09-05 Thread Paul Rubin
Antoon Pardon writes: > Now I found the following in the logs: [Errno 131] Connection reset by peer > This is a problem I would like to catch earlier I'd expect that's an IOError thrown by the socket library. You could just let it go uncaught and see what you get in the crash dump. -- https://

Simple board game GUI framework

2017-09-11 Thread Paul Moore
e seen seem to have the display and game logic intermingled (at least to my untrained eye). Any suggestions? If not, I guess I'll just have to write my own. I'm sure I could - it's just that I don't want my training to be messed up because of bugs in my code... Thanks, Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: People choosing Python 3

2017-09-11 Thread Paul Moore
the default. * It makes it harder to write cross-platform instructions that encompass Windows, which doesn't have a "python3" executable. But both of these are weak arguments and as usual, practicality beats purity. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Simple board game GUI framework

2017-09-11 Thread Paul Moore
On 11 September 2017 at 13:13, Stefan Ram wrote: > Paul Moore writes: >>write a series of classes simulating objects > > I'd say "write classes for objects". Yeah, that's just me not being precise in my mail. Sorry. >>objects moving round on a chess-s

Re: Simple board game GUI framework

2017-09-11 Thread Paul Moore
On 11 September 2017 at 14:52, Christopher Reimer wrote: >> On Sep 11, 2017, at 3:58 AM, Paul Moore wrote: >> >> I'm doing some training for a colleague on Python, and I want to look >> at a bit of object orientation. For that, I'm thinking of a small >&

Re: People choosing Python 3

2017-09-11 Thread Paul Moore
nguages on Windows usually know how to do that). And I also know that a better option on Windows is to use the "py" launcher anyway. I did say it was a weak argument :-) Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Simple board game GUI framework

2017-09-11 Thread Paul Moore
eed. But we have a tendency to spiral off into pure theory far too easily - and then my student doesn't remember what we covered because it wasn't grounded in anything practical. So I want to have a practical (and better still, visual) example to keep us focused. Thanks for the comments, Paul -- https://mail.python.org/mailman/listinfo/python-list

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

2017-09-11 Thread Paul Rubin
Chris Angelico writes: > students learning Python *today* ... they're learning Python 3. I'm not so sure of that. I do know a few people currently learning Python, and they're using Python 2. >> * static type annotation Seems like a big win if you ask me. >> * asyncio with its a-dialect > A

Re: Using Python 2

2017-09-11 Thread Paul Rubin
Steve D'Aprano writes: > Guido has ruled that Python 4 will not be a major compatibility break Looking forward to Python 5 then ;-). -- https://mail.python.org/mailman/listinfo/python-list

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

2017-09-12 Thread Paul Moore
27;s much specific here. But thanks for taking the time to explain your situation, which hopefully will act as a reminder that not everyone trying to promote Python has a clean slate to work with. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: [Tutor] beginning to code

2017-09-12 Thread Paul Moore
bject" philosophy much further than Python does, but that's where "this code was translated from another language" shows. Using map vs comprehensions is mostly a stylistic choice. Python programmers will typically choose a comprehension, so that style looks more idiomatic, but t

Re: [Tutor] beginning to code

2017-09-12 Thread Paul Moore
;s the point in comparing Ruby with years-out-of-date Python? At this point you're clearly just looking for an argument, so I'll give up on this thread. Paul -- https://mail.python.org/mailman/listinfo/python-list

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

2017-09-12 Thread Paul Rubin
Chris Angelico writes: > Why? Unless they're going to be maintaining a Py2 codebase, why should > they learn the older version with less features? Are there actually Py3 codebases? I guess there must be, even though I've never seen one. Every Python codebase of any size that I know of is Py2.

Re: Simple board game GUI framework

2017-09-13 Thread Paul Moore
not having a space after the comma, that's just sinful. Ha, by including that line I managed to distract everyone from how bad the *rest* of the code was! My plan worked! Bwahahaha :-) Paul -- https://mail.python.org/mailman/listinfo/python-list

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

2017-09-13 Thread Paul Rubin
Ben Finney writes: >> I've never seen one. > who has told you... they are working on a Python 3 code base. Just because they've told me about it doesn't mean I saw it personally. The ones I've seen, including new ones, are Python 2. Some people here use Py3 but I haven't heard (or don't remember

Re: Old Man Yells At Cloud

2017-09-16 Thread Paul Rubin
Steve D'Aprano writes: >> concept integer / integer => integer_result > That would be C, and C derived languages, perhaps? Certainly not. Fortran, machine languages, etc. all do that too. Haskell does the right thing and makes int/int a compile time type error. Its integer divisi

Re: Unicode (was: Old Man Yells At Cloud)

2017-09-17 Thread Paul Moore
\xf6' > in position 8: ordinal not in range(128) > > even when the string is manually converted: > name= unicode(self.name) > > Same sort of issue with: > name= self.name.decode('utf-8') > > > Py3 doesn't like either version. Y

Re: speech_to_text python command not working

2017-09-18 Thread Paul Moore
>Could someone kindly advise how to use "the Python debugger"? https://docs.python.org/3.6/library/pdb.html - but I would reiterate the advice that if you're not a programmer, you should get someone who is to assist you with this, as the debugger will not be easy to use without programming experience (and fixing the problem even more so). Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: speech_to_text python command not working

2017-09-18 Thread Paul Moore
With that information, my guess would be that the way the web service reports errors has changed, and the Python library is failing to handle errors nicely for you, but the basic functionality still works. So that's somewhat good news, as you can at least handle anything that *would* work, even if

Re: [Tutor] beginning to code

2017-09-18 Thread Paul Moore
non-empty string that is false\n' if not '0';" a non-empty string that is false Given this sort of silliness, I'm perfectly OK with the choices Python made :-) Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: [RELEASE] Python 3.6.3rc1 and 3.7.0a1 are now available for testing and more

2017-09-19 Thread Paul Rubin
Ned Deily writes: > You can find Python 3.7.0a1 and more information here: > https://www.python.org/downloads/release/python-370a1/ This says: The next pre-release of Python 3.7 will be 3.6.0a2, currently scheduled for 2016-10-16. :) -- https://mail.python.org/mailman/listinfo/pyth

Re: Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-20 Thread Paul Moore
cal intranet 4. The system admins may not be able or willing to upgrade or otherwise modify the system Python Writing code that works only with stdlib modules is basically the only option in such environments. Having said that, I don't advocate that everything be in the stdlib because of this.

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

2017-09-21 Thread Paul Moore
staller. > > What is the tooling for this? Is there some documentation, maybe a > mailingslist-diskussion or a but-report? There's a tool "blurb" (available from PyPI) used for this. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-21 Thread Paul Rubin
Steve D'Aprano writes: > Having to spend a few hours being paid to migrate code using "print x" > to "print(x)", or even a few months, is not a life-changing experience. Didn't someone further up the thread mention some company that had spent 1.5 years porting a py2 codebase to py3? The issue of

Re: How to ingore "AttributeError: exception

2017-09-22 Thread Paul Moore
ttributeError as e: >> >> pass > > > > try: > return self.some.attribute.or.another > except AttributeError: > return DEFAULT_VALUE > > is a perfectly good pattern to use. getattr(obj, 'attr_name', DEFAULT_VALUE) may also be useful, although if more than one of the attribute lookups in the chain you show could fail, then catching the exception is probably simpler. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-23 Thread Paul Moore
mptions explicit. Ironically, it's often the better coders that find this hard, as they are the ones who worry about error handling, or configuration options, rather than just picking a value and moving on). Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Project Euler 20.

2017-09-24 Thread Paul Rubin
"Robert L." writes: >> Find the sum of the digits in the number 100! > In Python? So you have come to plague us here too. >>> sum(ord(c)-ord('0') for c in str(reduce(lambda a,b: a*b, range(1,101),1))) 648 -- https://mail.python.org/mailman/listinfo/python-list

Re: Project Euler 20.

2017-09-24 Thread Paul Rubin
Ian Kelly writes: sum(int(c) for c in str(math.factorial(100))) Doh! Using int(c) didn't occur to me and I didn't know about math.factorial. Notice also that WJ hasn't yet dared posting his crap on comp.lang.haskell. -- https://mail.python.org/mailman/listinfo/python-list

Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
me, but this feels like the sort of calculation that comes up a lot (basically any "recipe" based exercise - cooking, manufacturing, etc) and I feel as if I'm at risk of reinventing the wheel, which I could avoid if I only knew what the techniques I need are called. Can a

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
gredient before product) and that way round doesn't work. For some reason, when thinking about topological sorts, I tend to get fixated on one direction and forget they are actually reversible... Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Paul Moore
On 25 September 2017 at 15:20, Paul Moore wrote: > On 25 September 2017 at 14:23, Ian Kelly wrote: >> You have a DAG, so you can sort it topologically. Then you can process >> it in that order so that everything that uses X will be processed >> before X so that when you

Re: TypeError with map with no len()

2017-09-25 Thread Paul Moore
) you just need to call the list constructor: y1 = list(map(math.sin, math.pi*t)) Although given that you're using numpy, it may be that there's a more idiomatic numpy way of doing this. I'm not a numpy expert though, so I can't help on that. Paul On 25 September 2017 at 17:

Re: auto installing dependencies with pip to run a python zip application ?

2017-09-26 Thread Paul Moore
er if you have binary dependencies like pillow. What you could do is pip install your binary dependencies into a directory in $TEMP using --target, then add that directory to sys.path. Probably easier than building a full virtualenv. Bundle pip with your app if you can't assume your users will

Re: auto installing dependencies with pip to run a python zip application ?

2017-09-27 Thread Paul Moore
On 26 September 2017 at 23:48, Irmen de Jong wrote: > On 09/26/2017 10:49 PM, Paul Moore wrote: >> On 26 September 2017 at 19:47, Irmen de Jong wrote: >>> Any thoughts on this? Is it a good idea or something horrible? Has >>> someone attempted something like this befo

Re: auto installing dependencies with pip to run a python zip application ?

2017-09-28 Thread Paul Moore
building the virtualenv management in yourself. (On the other hand "download this file and run it" is a much easier installation process than "install pipsi, do pipsi install myprogram, then run the program", so it may not suit your use case...) Paul On 27 September 2017 at

Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread Paul Moore
good exercise to have a problem that interests you, and work on coding it - no matter what it is, you'll learn more about understanding requirements, testing, bug fixing, and practical programming by working on a project you care about than you'll ever get reading books) and/or you can loo

Re: Spacing conventions

2017-09-28 Thread Paul Moore
that code is *not* break/continue, but the lack of structure and the fact that the code isn't properly broken into meaningful subunits. I'd rather not search for break/continue in such code, sure, but that's missing the point entirely. "Don't use break/continue in appall

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
[email protected] (Stefan Ram) writes: > I would like to write source code similar to: > country( 'USA' ) > state( 'Alabama' ) ... > It seems I can't do this with Python. Is there any workaround? _= country( 'USA' ) _= state( 'Alabama' ) _= town( 'Abbeville' ) _= town

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
[email protected] (Stefan Ram) writes: > I would like to write source code similar to: > country( 'USA' ) > state( 'Alabama' ) Aside from the workaround that I mentioned, this looks more like data than code. Maybe you really want to create a nested structure (dictionaries, JSON, XML or

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
Chris Angelico writes: > USA: > Alabama: > Abbeville > Addison > ... > and then, as Paul suggested, write a simple parser to read it. That looks like YAML, which there's already a library for. I'm not crazy about it but it might be an o

Re: when is filter test applied?

2017-10-03 Thread Paul Moore
est occurs, i.e. when the entry is generated from the filter. You say that doesn't happen, so my intuition (and yours) seems to be wrong. Can you provide a reproducible test case? I'd be inclined to run that through dis.dis to see what bytecode was produced. Paul On 3 October 2017 at

Re: when is filter test applied?

2017-10-03 Thread Paul Moore
ly as a consequence of the behaviour of generators and closures. I'd tend to steer clear of code that relied on that behaviour in practice, as I think it's likely to be hard to understand/maintain, but I'm aware that reality's never quite that simple :-) Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Good virtualenv and packaging tutorials for beginner?

2017-10-04 Thread Paul Moore
at https://github.com/pypa/python-packaging-user-guide/. Most of us working on packaging are way too involved in the details to know how it really feels to a newcomer to be faced with all this stuff, so if you have any comments (or even better, suggestions as to how we could improve things) that would be immensely valuable. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: How best to initialize in unit tests?

2017-10-04 Thread Paul Moore
ourself (although I believe it does discover unittest and doctest tests, so you don't need to change all your tests over). There's an example of an autouse fixture in pip's test suite, although it's massively more complex than what you're describing, so don't be put

Re: The "loop and a half"

2017-10-04 Thread Paul Moore
perhaps there's > peephole optimization for this common case. There is: >>> def f(): ... while True: ... pass ... >>> import dis >>> dis.dis(f) 2 0 SETUP_LOOP 4 (to 6) 3 >>2 JUMP_ABSOLUTE2 4

Re: newb question about @property

2017-10-04 Thread Paul Moore
these things, and Python's choices won't be the best in all circumstances. All we can really say is that they have turned out to be pretty useful and popular in many situations... Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Multithreaded compression/decompression library with python bindings?

2017-10-04 Thread Paul Moore
> (de)compression? Something along the lines of (say) the pbip2 program >> but with bindings for python? > > pbip2? Never heard of it, and googling comes up with nothing relevant. > > Got a link? It's a typo. pbzip2 - a search found http://compression.ca/pbzip2/ but

Re: The "loop and a half"

2017-10-04 Thread Paul Moore
the details and edge cases right of such a pattern is still a surprisingly tricky problem. So I guess it's a good "learning to program" exercise, but the "while loop with break part way through" pattern for solving it is not really what I'd want to see taught to beginning Python programmers... Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-04 Thread Paul Moore
t;", line 1, in > AttributeError: 'Point' object has no attribute 'z' > > I pretty much never bother to do this because (bart to the contrary) it > isn't useful if you're thinking in Pythonic terms, but it can be done pretty > easily. Good point. I'd forgotten that - like you say, it's not common to want to constrain things to this level in idiomatic Python code. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Paul Moore
he way the import function works, and how names in Python behave, but I can see someone with a background in other languages with "real" constants thinking "but foo is a constant, and importing it stops it being a constant!" Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: stop/start windows services -python command

2017-10-06 Thread Paul Moore
*is* available for Python 3.6. Either from https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/ (a wininst installer, which is not compatible with pip but which nevertheless can be installed in your system Python) or from http://www.lfd.uci.edu/~gohlke/pythonlibs/ which hosts a lot of

Re: why does memory consumption keep growing?

2017-10-06 Thread Paul Moore
about 8-12 hours. Not exactly high availability. But apparently in the arctic regions they are experimenting with a 24x7 version of the sky for short periods of the year... Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Paul Moore
>> to be stdin on all platforms? > > It is guaranteed on POSIX compatible OSs. I think it is also guaranteed > on Windows, Don't know about VMS or the IBM OSs. All of these work on Windows, I just tested. Which surprised me, as I thought things like S_ISFIFO were Unix specific. Today I learned... (I'd probably still use sys.stdin.fileno() as it's more self-documenting). Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Paul Moore
s long as that's done in a way that provides a good user experience. Of course, what constitutes a "good UX" is a judgement call... (Personally I think ls goes too far in how different it is in the interactive case, for example). Paul > > Since such guesswork often goes wrong, the

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Paul Moore
ve mode and non-interactive mode, which in turn limits the > extent of these changes to the defaults. It wants to be small changes > only. Everything else should be controlled with options, not magic. Yep. My real beef with ls is multi-column vs single-column. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-06 Thread Paul Moore
On 6 October 2017 at 13:22, Steve D'Aprano wrote: >> Yep. My real beef with ls is multi-column vs single-column. >> Paul > > You don't think multiple columns in interactive mode is useful? I'm surprised, > because I find it invaluable. Interactively, I use ls

Re: Introducing the "for" loop

2017-10-06 Thread Paul Moore
ctions or classes. But you're unlikely to ever care. One example: >>> f.attr = 1 >>> open.attr = 1 Traceback (most recent call last): File "", line 1, in AttributeError: 'builtin_function_or_method' object has no attribute 'attr' functions define

Re: The "loop and a half"

2017-10-06 Thread Paul Moore
-E wrote its output to a file, you'd have to read that file, manage the process of deleting it after use (and handle possible deletion of it if an error occurred), etc. Writing to stdout is very often a good design. Not always, but nothing is ever 100% black and white, but sufficiently often that building an OS based on the idea (Unix) was pretty successful :-) Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-08 Thread Paul Moore
s come from Unix-based systems. That's not "because Linux is so much better", it's because someone other than me had a good idea, and I acknowledge the fact. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: OT again sorry [Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]]

2017-10-09 Thread Paul Moore
g (and the inevitable "config manager" tools to manage them). Not that I can complain about this, as a Windows user, but I do have fond memories of those simpler times :-) Obligatory xkcd: https://xkcd.com/297/ Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Python GUI application embedding a web browser - Options?

2017-10-09 Thread Paul Moore
by project and the learning curve for PyQt (any GUI framework, really) was a bit high for the amount of spare time I had at the time. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to globally set the print function separator?

2017-10-09 Thread Paul Moore
On 9 October 2017 at 17:22, John Black wrote: > I want sep="" to be the default without having to specify it every time I > call print. Is that possible? def myprint(*args, **kw): print(*args, sep="", **kw) If you want, assign print=myprint. Paul -- https

Re: The "loop and a half"

2017-10-10 Thread Paul Moore
work on multiple operating > system platforms. > > Can we not let people be who they are, perceived warts (valid or not) > and all, and after responding (hopefully gently) to technical errors > just let them be??? +1 Thank you for saying this. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: The "loop and a half"

2017-10-10 Thread Paul Moore
iously fixed. So I've conceded that you might have a point. Are *you* willing to concede that you may have missed something when making your assertions? Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-10 Thread Paul Moore
on\Python36\Lib\inspect.py", line 2262, in _signature_from_callable skip_bound_arg=skip_bound_arg) File "C:\Users\me\AppData\Local\Programs\Python\Python36\Lib\inspect.py", line 2087, in _signature_from_builtin raise ValueError("no signature found for builtin {!r}".format(func)) ValueError: no signature found for builtin >>> try: ... sig = inspect.signature(type) ... except ValueError: ... sig = None ... >>> print(repr(sig)) None Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Python GUI application embedding a web browser - Options?

2017-10-10 Thread Paul Moore
never really went anywhere, because it ended up being more complex than I had time for. I don't recall the details any more. Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: Unable to run pip in Windows 10

2017-10-11 Thread Paul Moore
runs fine for me (Windows 10, Python 3.6, 64-bit, downloaded from python.org). Maybe check that the file you downloaded is complete, by confirming the size/checksum matches? Do you have any antivirus software that could be interfering? Paul -- https://mail.python.org/mailman/listinfo/python-list

Re: about 'setattr(o, name, value)' and 'inspect.signature(f)'

2017-10-11 Thread Paul Moore
Agreed. I was being lazy and didn't check precisely which exception was raised before writing the code. "Making this code production ready is left as an exercise for the reader" :-) On 11 October 2017 at 01:59, Steve D'Aprano wrote: > On Wed, 11 Oct 2017 02:15 am, Paul

Re: Unable to run pip in Windows 10

2017-10-11 Thread Paul Moore
nd I see that it's a Windows message (not one from pip or Python). The most obvious suggestion from that was "you're running a 64-bit application on a 32-bit Windows". I note from the above: > Latest install: Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC

Re: Unable to run pip in Windows 10

2017-10-11 Thread Paul Moore
h means they'll only be visible to you, or you need to be running as a system administrator to install them for anyone (which means running pip from a command prompt that was opened via "run as administrator") Paul On 11 October 2017 at 16:43, Michael Cuddehe wrote: > Running 64

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Paul Moore
code that constructs that string. That's where I'd start by looking. Maybe something isn't zero-terminated that should be? Maybe your code doesn't set up the character encoding information correctly? Paul On 13 October 2017 at 11:15, Thomas Jollans wrote: > On 2017-10-13 11:07, Vi

Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Paul Moore
On 13 October 2017 at 12:18, Vincent Vande Vyvre wrote: > Le 13/10/17 à 12:39, Paul Moore a écrit : >> >> As a specific suggestion, I assume the name of the created file is a >> string object constructed in the C extension code, somehow. The fact >> that you're get

<    1   2   3   4   5   6   7   8   9   10   >