Re: Python-based monads essay (Re: Assignment versus binding)

2016-10-11 Thread Paul Rubin
Anuradha Laxminarayan writes: > seq f g x = f (\s1 -> g x s1) > because naming conventions imply that h is function. Also if this operation is what it looks like, it's usually called "bind". seq is something else entirely. -- https://mail.python.org/mailman/listinfo/python-list

Re: [FAQ] "Best" GUI toolkit for python

2016-10-17 Thread Paul Rubin
If you're just getting started and you're not trying to make something super slick, I'd suggest Tkinter. It's easy to learn and use, you can bang stuff together with it pretty fast, it's included with various Python distributions so you avoid download/installation hassles, and it's pretty portable

Re: Converting the keys of a dictionary from numeric to string

2016-10-19 Thread Paul Rubin
pozz writes: > I have a dictionary where the keys are numbers: ... Python 2.7.5: >>> mydict = { 1: 1000, 2: 1500, 3: 100 } >>> keydict = { 1: "apples", 2: "nuts", 3: "tables" } >>> newdict = dict((keydict[k],v) for k,v in mydict.items()) >>> print newdict {'tables': 100, 'nut

Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Paul Rubin
pozz writes: > Is there a visual GUI builder for Tkinter? Not that I know of. I haven't felt I needed one. I generally draw my intended UI on paper and then use the Tk grid layout gadget. > Could you explain better what do you mean with "industrial-looking > UI"? Something that doesn't have

Re: Converting the keys of a dictionary from numeric to string

2016-10-20 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > assert len(keydict) == len(mydict) assert set(keydict) == set(mydict) -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-25 Thread Paul Rubin
jlada...@itu.edu writes: > ... I find myself asking why Python doesn't include a standard, > non-blocking keyboard input function. I have often wanted one myself. I agree this would be useful. Forth has a standard word KEY to read a key, and I used it in a simple game that I wrote a few months a

Re: Why doesn't Python include non-blocking keyboard input function?

2016-10-26 Thread Paul Rubin
Terry Reedy writes: > Today, ethernet-connected *nix servers have no > keyboard, mouse, or even a directly connected terminal. Usually you ssh into them and connect to a pty which supports the same ioctls that a real terminal would. I use screen editors over ssh all the time, not to mention filt

Re: distributed development methodology

2016-10-29 Thread Paul Rubin
Adam Jensen writes: > So what are some of the more successful distributed. multi-platform, > development models? Use an orchestration program to keep the systems in sync: I use ansible (ansible.com) which is written in Python and fairly simple once you get used to it, but there are lots of other

Re: Need help with coding a function in Python

2016-10-31 Thread Paul Rubin
devers.meetthebadger.ja...@gmail.com writes: > http://imgur.com/a/rfGhK#iVLQKSW ... > So far this is my best shot at it (the problem with it is that the n > that i'm subtracting or adding in the if/else part does not represent > the element's position... Right, so can you figure out the element's

Re: Pre-pep discussion material: in-place equivalents to map and filter

2016-11-03 Thread Paul Rubin
arthurhavli...@gmail.com writes: > I would gladly appreciate your returns on this, regarding: > 1 - Whether a similar proposition has been made > 2 - If you find this of any interest at all > 3 - If you have a suggestion for improving the proposal Bleccch. Might be ok as a behind-the-scenes optim

Re: N-grams

2016-11-09 Thread Paul Rubin
This can probably be cleaned up some: from itertools import islice from collections import deque def ngram(n, seq): it = iter(seq) d = deque(islice(it, n)) if len(d) != n: return for s in it: yield tuple(d) d.popleft(

Re: N-grams

2016-11-09 Thread Paul Rubin
Ian Kelly writes: > I'd use the maxlen argument to deque here. Oh that's cool, it's a Python 3 thing though. > Better to move the extra yield above the loop and reorder the loop > body so that the yielded tuple includes the element just read. Thanks, I'll give that a try. >> if len(d)

Re: Numpy slow at vector cross product?

2016-11-21 Thread Paul Rubin
Steven D'Aprano writes: > if we knew we should be doing it, and if we could be bothered to run > multiple trials and gather statistics and keep a close eye on the > deviation between measurements. But who wants to do that by hand? You might like this, for Haskell: http://www.serpentine.com/cr

Re: Question about working with html entities in python 2 to use them as filenames

2016-11-22 Thread Paul Rubin
Steven Truppe writes: > # here i would like to create a directory named after the content of > # the title... I allways get this error: > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2 The title has a à (capital A with tilde) character in it, and there is no corresponding

Re: The Case Against Python 3

2016-11-28 Thread Paul Rubin
Gregory Ewing writes: > I agree that f-strings are not to blame here. If we really want to > avoid breaking anyone's ill-conceived attempts at sandboxing eval, > we'd better not add anything more to the language, ever, because > nobody can foresee all the possible consequences. I'm surprised eval

Re: Asyncio -- delayed calculation

2016-11-28 Thread Paul Rubin
Chris Angelico writes: > Asynchronous I/O is something to get your head around I'd much > rather work with generator-based async functions... I haven't gotten my head around Python asyncio and have been wanting to read this: http://lucumr.pocoo.org/2016/10/30/i-dont-understand-asyncio/

Re: Request Help With Byte/String Problem

2016-11-29 Thread Paul Rubin
Wildman writes: > names = array.array("B", '\0' * bytes) > TypeError: cannot use a str to initialize an array with typecode 'B' In Python 2, str is a byte string and you can do that. In Python 3, str is a unicode string, and if you want a byte string you have to specify that explicitly, like

Re: Is there a replement for bsddb in python3?

2016-12-09 Thread Paul Rubin
clvanwall writes: > I found that bsddb module was removed from Python3. Is there a > replacement for it? Try "dbm" which has a few options for the underlying engine. Alternatively, try sqlite3. -- https://mail.python.org/mailman/listinfo/python-list

Re: pySerial raw data

2016-12-11 Thread Paul Rubin
Wanderer writes: > I also have a 433Mhz USB serial port jig from a TI development > tool The TI USB port registers as a COM port that I can access > with pySerial. If the TI jig has 433 mhz (LORA?) at one end and serial at the other, you have to find the port parameters in the docs for the TI

Re: OT - "Soft" ESC key on the new MacBook Pro

2016-12-13 Thread Paul Rubin
Skip Montanaro writes: > Does the lack of a physical ESC key create problems for people, especially > Emacs users? Not a Mac user and I rarely use ESC instead of ALT while editing with Emacs on a local computer, but when editing remotely I do have to use ESC because the Gnome terminal emulator st

Re: Parsing a potentially corrupted file

2016-12-14 Thread Paul Rubin
Paul Moore writes: > I'm looking for a reasonably "clean" way to parse a log file that > potentially has incomplete records in it. Basically trial and error. Code something reasonable, run your program til it crashes on a record that it doesn't know what to do with, add code to deal with that,

Re: Another security question

2016-12-23 Thread Paul Rubin
> "Salted hashing (or just hashing) with BLAKE2 or any other > general-purpose cryptographic hash function, such as SHA-256, is not > suitable for hashing passwords. See BLAKE2 FAQ for more information." > > I propose to ignore this warning. I feel that, for my purposes, the > above procedure is ad

Re: Another security question

2016-12-23 Thread Paul Rubin
Chris Angelico writes: > Solution: Don't use dictionary-attackable passwords. If you allow people to choose their own passwords, they'll too-often pick dictionary-attackable ones; or even if they choose difficult ones, they'll use them in more than one place, and eventually the weakest of those

Re: Another security question

2016-12-24 Thread Paul Rubin
Steve D'Aprano writes: > You say that as if two-factor auth was a panacea. Of course it's not a panacea, but it helps quite a lot. > That's the sort of thinking that leads to: ... Beyond that, web browsers are the new Microsoft Windows with all of its security holes and bloat and upgrade treadm

Re: Another security question

2016-12-24 Thread Paul Rubin
Chris Angelico writes: > Correct. However, weak passwords are ultimately the user's > responsibility, where the hashing is the server's responsibility. No, really, the users are part of the system and therefore the system designer must take the expected behavior of actual users into account. The

Re: Another security question

2016-12-24 Thread Paul Rubin
Chris Angelico writes: > as a sysadmin, I have lots of control over the hashing, and very > little on passwords. I could enforce a minimum password length, but I > can't prevent password reuse, and I can't do much about the other > forms of weak passwords. Right, 2FA helps with re-use, and diffic

Re: I need a lot of help...

2016-12-24 Thread Paul Rubin
Peter Pearson writes: > I don't know any definition of "matrix range" that fits this description. > Is it possible that someone means "rank"? Yes, the rank is the dimension of the range unless I'm mistaken. I think rank is what was meant. To find the rank with Gaussian elimination, I guess you

Re: Simulating int arithmetic with wrap-around

2017-01-03 Thread Paul Rubin
Steve D'Aprano writes: > Again, assume both operands are in range for an N-bit signed integer. What's > a good way to efficiently, or at least not too inefficiently, do the > calculations in Python? My first thought is towards the struct module, especially if you want to handle a bunch of such in

Re: Cleaning up conditionals

2017-01-03 Thread Paul Rubin
"Deborah Swanson" writes: > I'm still wondering if these 4 lines can be collapsed to one or two > lines. In the trade that's what we call a "code smell", a sign that code (even if it works) should probably be re-thought after taking a step back to understand what it is really trying to do. What

Re: Cleaning up conditionals

2017-01-05 Thread Paul Rubin
"Deborah Swanson" writes: > I'm still wondering if these 4 lines can be collapsed to one or two > lines. In the trade that's what we call a "code smell", a sign that code (even if it works) should probably be re-thought after taking a step back to understand what it is really trying to do. Wha

Re: Simulating int arithmetic with wrap-around

2017-01-05 Thread Paul Rubin
Steve D'Aprano writes: > Again, assume both operands are in range for an N-bit signed integer. What's > a good way to efficiently, or at least not too inefficiently, do the > calculations in Python? My first thought is towards the struct module, especially if you want to handle a bunch of such i

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > How would you implement stopmin()? Use itertools.takewhile -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-07 Thread Paul Rubin
Jussi Piitulainen writes: >> Use itertools.takewhile > How? It consumes the crucial stop element: Oh yucch, you're right, it takes it from both sides. How about this: from itertools import takewhile, islice def minabs(xs): a = iter(xs) m = min(map(abs,takewhile(lambda x:

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Jussi Piitulainen writes: > That would return 0 even when there is no 0 in xs at all. Doesn't look that way to me: >>> minabs([5,3,1,2,4]) 1 -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Paul Rubin writes: > seems to work, but is ugly. Maybe there's something better. def minabs2(xs): def z(): for x in xs: yield abs(x), x if x==0: break return min(z())[1] is the same thing but a little bit nicer. -

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Paul Rubin writes: > Doesn't look that way to me: > >>> minabs([5,3,1,2,4]) > 1 There's a different problem though: >>> minabs([1,2,3,0]) 1 I think Python's version of iterators is actually buggy and at least the first element of th

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > return min(take_until(), key=firstitem)[1] Actually, key=abs should work. I realized that after posting. -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Jussi Piitulainen writes: > It could still be added as an option, to both takewhile and iter(_, _). That's too messy, it really should be pervasive in iterators. -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Steven D'Aprano writes: > [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data] def memoize(f): cache = {} def m(x): if x in cache: return cache[x] a = f(x) cache[x] = a r

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Serhiy Storchaka writes: > gen = (expensive_calculation(x) for x in data) > result = [(tmp, tmp + 1) for tmp in gen] result = [(tmp, tmp+1) for tmp in map(expensive_calculation, data)] -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Tim Chase writes: >> result = [(tmp, tmp+1) for tmp in map(expensive_calculation, data)] > > As charmingly expressive as map() is, the wildly different behavior in > py3 (it's a generator that evaluates lazily) vs py2 (it consumes the > entire iterable in one go) leads me to avoid it in general,

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Ben Bacarisse writes: > [(lambda tmp: (tmp, tmp+1))(expensive_calculation(x)) for x in data] Nice. The Haskell "let" expression is implemented as syntax sugar for that, I believe. -- https://mail.python.org/mailman/listinfo/python-list

Re: Enum with only a single member

2017-01-10 Thread Paul Rubin
Steven D'Aprano writes: > Is it silly to create an enumeration with only a single member? No. > That is, a singleton enum? Why stop there? You can make empty ones too. (Zerotons?) > The reason I ask is that I have two functions that take an enum > argument. Sounds like a good reason. >

Re: PEP 393 vs UTF-8 Everywhere

2017-01-20 Thread Paul Rubin
Chris Angelico writes: > decoding JSON... the scanner, which steps through the string and > does the actual parsing. ... > The only way for it to be fast enough would be to have some sort of > retainable string iterator, which means exposing an opaque "position > marker" that serves no purpose oth

Re: PEP 393 vs UTF-8 Everywhere

2017-01-21 Thread Paul Rubin
Chris Angelico writes: > You can't do a look-ahead with a vanilla string iterator. That's > necessary for a lot of parsers. For JSON? For other parsers you usually have a tokenizer that reads characters with maybe 1 char of lookahead. > Yes, which gives a two-level indexing (first find the stra

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Paul Rubin
Steven D'Aprano writes: > The point is that there's nothing intrinsically obvious or right about > "return the value of the last statement in the block". Strictly speaking it returns the value of the block itself. The block is usually evaluated by PROG which returns the last value of the block

Re: Suggestion: make sequence and map interfaces more similar

2016-03-30 Thread Paul Rubin
Steven D'Aprano writes: > I want to see an actual application where adding a new key to a > mapping is expected to change the other keys. directory["mary.roommate"] = "bob" directory["mary.address"] = None # unknown address ... directory["bob.address"] = "132 Elm Street" Since Bob and Mary are

Re: Untrusted code execution

2016-04-05 Thread Paul Rubin
Jon Ribbens writes: >> isinstance(node, ast.Attribute) and node.attr.startswith("_")): >> raise ValueError("Access to private values is not allowed.") >> namespace = {"__builtins__": {"int": int, "str": str, "len": len}} > Nobody has any thoughts on this at all? W

Re: Untrusted code execution

2016-04-07 Thread Paul Rubin
Jon Ribbens writes: >> That string decodes to "__private". > Yes, and? ... The namespace > I was suggesting didn't provide access to any objects which have a > 'get()' method which would access attributes. I see, I forgot that getattr is a function, not an object method. Though, now you've got th

Re: how to convert code that uses cmp to python3

2016-04-07 Thread Paul Rubin
Chris Angelico writes: > First off, what does it actually *mean* to have a tree with numbers > and keys as strings? Are they ever equal? Are all integers deemed > lower than all strings? Something else? If the AVL tree's purpose is to be an alternative lookup structure to Python's hash-based dict

Re: how to convert code that uses cmp to python3

2016-04-07 Thread Paul Rubin
Marko Rauhamaa writes: > Guido chose a different method to implement timers for asyncio. He > decided to never remove canceled timers. Oh my, that might not end well. There are other approaches that don't need AVL trees and can remove cancelled timers, e.g. "timer wheels" as used in Erlang and f

Re: how to convert code that uses cmp to python3

2016-04-08 Thread Paul Rubin
Marko Rauhamaa writes: > On the surface, the garbage collection scheme looks dubious, but maybe > it works perfect in practice. It looked suspicious at first glance but I think it is ok. Basically on at most every timeout event (scheduling, expiration, or cancellation), it does an O(n) operation

Re: how to convert code that uses cmp to python3

2016-04-08 Thread Paul Rubin
Marko Rauhamaa writes: > With AVL trees, it's easier to be convinced about worst-case > performance. I'd have thought the main reason to use AVL trees was persistence, so you could have multiple slightly different trees sharing most of their structures. > It is more difficult to see the potentia

Re: how to convert code that uses cmp to python3

2016-04-09 Thread Paul Rubin
Ben Finney writes: > The ‘cmp’ implementation must decide *at least* between three > conditions... The implementation of ‘__lt__’ and the implementation > of ‘__eq__’ each only need to decide two conditions (true, false). > If you're saying the latter implementation is somehow *more* expensive >

Re: Remove directory tree without following symlinks

2016-04-23 Thread Paul Rubin
Steven D'Aprano writes: > I want to remove a directory, including all files and subdirectories under > it, but without following symlinks. I want the symlinks to be deleted, not > the files pointed to by those symlinks. rm -r shouldn't follow symlinks like you mention. -- https://mail.python.org

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

2016-04-28 Thread Paul Rubin
Steven D'Aprano writes: > (1) print the help text to stdout; > (2) run the help text through a pager; Stdout unless the PAGER env var is set. Otherwise, I'd say still stdout since the person can pipe it through a pager if they want, but you could use the pager or be fancy and try to detect if st

Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?]

2016-04-29 Thread Paul Rubin
Rustom Mody writes: > As with all things rms, its taking him decades to realize this defeat > [Latest makeinfo is 18 times slower than previous version!! > https://lists.gnu.org/archive/html/bug-texinfo/2013-01/msg00012.html Wait, what's it written in now? > In the meantime the so called lightwe

Re: manpage writing [rst, asciidoc, pod] was [Re: What should Python apps do when asked to show help?]

2016-04-30 Thread Paul Rubin
Rustom Mody writes: > At that point what I gleaned was that original makeinfo was in C > New one was rewritten in perl. The previous one was definitely written in C and I've looked at the code some. I hadn't known there was a new one. The C one was actually the second one. The first one was wr

Re: Mentor Request

2016-05-04 Thread Paul Rubin
Sayth Renshaw writes: > Live in New South Wales Australia somewhat regional, closest local > python group is 2 and a half hours away in Sydney. Try here: https://wiki.hackerspaces.org/RoboDojo -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a reason zip() wipes out data?

2016-05-08 Thread Paul Rubin
DFS writes: > Edit: I see they addressed this in 3.5 (maybe earlier), with an option: > "itertools.zip_longest(*iterables, fillvalue=None) This is available in 2.7 as itertools.izip_longest -- https://mail.python.org/mailman/listinfo/python-list

Re: String concatenation

2016-05-10 Thread Paul Rubin
Steven D'Aprano writes: > Australia's naming laws almost certainly wouldn't allow such a name. https://en.wikipedia.org/wiki/Facebook_real-name_policy_controversy#Vietnamese -- https://mail.python.org/mailman/listinfo/python-list

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

2016-05-10 Thread Paul Rubin
DFS writes: > But, I am dead serious about becoming a good Python developer, and I > truly appreciate all clp replies. People are more likely to reply to you if your posting style makes you enjoyable instead of annoying to engage with. That's community spirit. Friendly participation is always we

Re: Distinction between “class” and “type”

2016-05-12 Thread Paul Rubin
Ben Finney writes: > There's a big overlap because most classes are also types -- but not > the other way around! E.g. Any is a type but not a class (you can > neither inherit from Any nor instantiate it), and the same is true > for unions and type variables. […] > As a Bear of Li

Re: Distinction between “class” and “type”

2016-05-13 Thread Paul Rubin
Terry Reedy writes: > I suspect that one could produce a class that is not a type, in > Guido's meaning, with a metaclass that is not a subclass of the type > class. I don't otherwise know what Guido might have meant. I think meant that if X is a class, then X is (usually) also a type; but the r

Re: Calling python from C with OpenMP

2016-05-13 Thread Paul Rubin
Dennis Lee Bieber writes: > It's been tried -- but the non-GIL implementations tend to be > slower at everything else. Has Micropython been compared? CPython needs the GIL because of its frequent twiddling of reference counts. Without the GIL, multi-threaded CPython would have to acquire

Re: Performance with and without the garbage collector

2016-05-14 Thread Paul Rubin
Steven D'Aprano writes: > Is anyone able to demonstrate a replicable performance impact due to > garbage collection? As Laurent describes, Python uses refcounting, and then does some gc in case there was dead circular structure that the refcounting missed. Your example had no circular structure s

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

2016-05-16 Thread Paul Rubin
Grant Edwards writes: > I've actually got plenty of RAM. I just can't afford the CPU time it > takes to do the public-key crypto stuff that happens each time an SSL > connection starts up. I think you should only have to do that once, then use TLS session resumption for additional connections.

Re: META Culture of this place [was Re: for / while else doesn't make sense]

2016-05-24 Thread Paul Rubin
Ned Batchelder writes: > Once the tone gets to picking apart any detail, no matter how trivial, it's > just turned into a contest to see who can be more right. It helps to use a threaded news/mail reader (I use gnus). When a subtopic starts going off the fails, hitting control-K marks the rest o

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

2016-05-29 Thread Paul Rubin
Grant Edwards writes: >> then use TLS session resumption for additional connections. > Thanks, I'll look into that -- I've seen the term before, but that's > about it. > Is it something the server tells the client to do? > And more to the point, will all popular browsers do it? Sorry for the slow

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

2016-05-29 Thread Paul Rubin
Grant Edwards writes: > The 40MHz one is a Samsung ARM7TDMI. There's a newer model with a > 133MHz Cortex-M3. Another thing occurs to me-- do you have to support older browsers? Newer TLS stacks support elliptic curve public key, which should be a lot faster on those cpus than RSA/DHE is. --

Re: Efficient handling of fast, real-time hex data

2016-05-31 Thread Paul Rubin
jlada...@itu.edu writes: > high rate, about 5,000 16-bit unsigned integers per second > Using PySerial to handle UART over USB. Intel Core i7-4790K CPU @ > 4.00GHz. This really should not be an issue. That's not such a terribly high speed, and there's enough buffering in the kernel that you

Re: Possible PEP - two dimensional arrays?

2016-06-07 Thread Paul Rubin
Harrison Chudleigh writes: > Currently, the closest thing Python has to a 2D array is a dictionary > containing lists. Tuples work fine: d = {} d[2,3] = 5 # etc... > Is this idea PEPable? I don't think it would get any traction. If you're doing something numerical that needs 2d arrays, nu

(repost) Advisory: HTTP Header Injection in Python urllib

2016-06-17 Thread Paul Rubin
The blog post below is from a couple days ago: http://blog.blindspotsecurity.com/2016/06/advisory-http-header-injection-in.html It reports that it's possible to inject fake http headers into requests sent by urllib2(python2) and urllib(python3), by getting the library to retrieve a url concocted

Re: (repost) Advisory: HTTP Header Injection in Python urllib

2016-06-18 Thread Paul Rubin
Steven D'Aprano writes: >> The issue ... is cross-site request forgery. > Er, you may have missed that I'm talking about a single user setup. Are you > suggesting that I can't trust myself not to forge a request that goes to a > hostile site? I think the idea is you visit some website with malici

Re: Unexpected NANs in complex arithmetic

2016-06-21 Thread Paul Rubin
Steven D'Aprano writes: >> By the time Python returns a result for inf+3j, you're already in >> trouble (or perhaps Python is already in trouble). > I don't see why. It is possible to do perfectly sensible arithmetic on INFs. We sometimes think of the real line extended by +/- inf, or the complex

Re: Meta decorator with parameters, defined in explicit functions

2016-06-27 Thread Paul Rubin
Ben Finney writes: > decorator_with_args = lambda decorator: lambda *args, **kwargs: > lambda func: decorator(func, *args, **kwargs) > I would like to see a more Pythonic, more explicit and expressive > replacement with its component parts easily understood. How's this: from functools im

Re: Can math.atan2 return INF?

2016-06-30 Thread Paul Rubin
> Every time somebody tries to point to an example of a “topic that is > beyond the reach of science”, it seems to get knocked over eventually. Generate a sequence of "random" bits from your favorite physical source (radioactive decay, quantum entanglement, or whatever). Is the sequence really al

Re: Can math.atan2 return INF?

2016-06-30 Thread Paul Rubin
Lawrence D’Oliveiro writes: > The definition of “random” is “unknowable”. So all you are stating is > a tautology. What? No. You read a bunch of bits out of the device and you want to know whether they are Kolmogorov-random (you can look up what that means if you're not familiar with it). Quan

Re: Nested class doesn't see class scope

2016-07-04 Thread Paul Rubin
Steven D'Aprano writes: > ... class B: > ... x = var x = A.var -- https://mail.python.org/mailman/listinfo/python-list

Re: Touch screen development in Python

2016-07-11 Thread Paul Rubin
"Jahn" writes: > Does anyone use Python for developping applications that work with a > touch screen? I've done it on a system where the touch screen events were treated the same way as mouse events. Coding works out about the same way. -- https://mail.python.org/mailman/listinfo/python-list

Re: Were is a great place to Share your finished projects?

2016-07-13 Thread Paul Rubin
Michael Torrie writes: > So I can understand the allure of GitHub. It's shiny and free-ish. Savannah.nongnu.org is a nice free host for free software projects. I suppose it's less shiny than Github. On the other hand, Github is written in Ruby--what self-respecting Pythonista would stand for t

Re: math.frexp

2016-07-15 Thread Paul Rubin
Steven D'Aprano writes: > But this can give some protection against overflow of intermediate > values. Might be simplest to just add the logarithms. Look up Kahan summation for how to do that while minimizing loss of precision. -- https://mail.python.org/mailman/listinfo/python-list

Re: math.frexp

2016-07-16 Thread Paul Rubin
Steven D'Aprano writes: >>> protection against overflow of intermediate values. >> Might be simplest to just add the logarithms. > Simplest, but least accurate, even with Kahan summation or equivalent. Well the idea was to avoid overflow first, then hold on to whatever precision you have after th

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Paul Rubin
shrey.de...@gmail.com writes: > As a computer science undergraduate student, I don't want to spend > time writing the module but instead I want to work with it, play > around with it, and do problems with it. For educational purposes, I think writing the module yourself is part of the idea. Also,

Re: PEP Request: Advanced Data Structures

2016-07-16 Thread Paul Rubin
Chris Angelico writes: >> keep a reference to an element deep in the list, and insert a new >> element in O(1) time at that point. > at the C level, wouldn't tracing the links cost massively more than > the occasional insertion too? I'm not sure O(1) is of value at any > size, if the costs of all

Re: Stupid question, just need a quick and dirty fix

2016-07-21 Thread Paul Rubin
Jordan Bayless writes: > desired = Id < 10 or Id > 133 or Id in good_ids > When I try to validate whether I passed that check, I'm told there's a > Name error and it's not defined (using the last line of the snippet > above). Id was called IDNum in your earlier pst > Also, I guess I'm at a loss

Re: Why not allow empty code blocks?

2016-07-30 Thread Paul Rubin
Steven D'Aprano writes: >> Maybe. Lisp and Scheme are great languages to teach the theory.. > Doesn't sound like a good teaching language to me.> > Meta-reasoning is harder than regular reasoning. That's why metaclasses are > harder to use than ordinary classes. Python metaclasses are monstrousl

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Gregory Ewing writes: > The reason Lisp is easier to program in than Forth is not > because of prefix vs. postfix. It's because in Lisp a function > call is syntactically grouped together with its arguments, > whereas in Forth it's not. Forth requires you to mentally > simulate the stack to figure

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Marko Rauhamaa writes: > Gregory Ewing : >> If Forth had come out of a computer science department and Lisp had >> been invented by an astronomer, Lisp would still be the easier >> language to use. > > It is quite astounding how Lisp is steadily being reinvented by the > down-to-earth programming

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Ian Kelly writes: > What does JSON have to do with LISP? JSON is a crappy form of S-expressions. -- https://mail.python.org/mailman/listinfo/python-list

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
"D'Arcy J.M. Cain" writes: > So I have to examine every address I reply to or deal with the bounce > message later. Way to move your spam problem to someone else. It's not entirely about spam. I stopped posting addresses because people kept insisting on replying to my posts by email instead of

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Steven D'Aprano writes: > There's a real mystery why concatenative/postfix languages have > received so little attention from the academic community compared to > prefix languages. There's a wiki with lots of info: http://www.concatenative.org This LTU thread and the article it links to is kind

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Chris Angelico writes: > Yes, and we didn't have Python then. When I had a computer with 640KB > of memory, my options were (1) BASIC or (2) 8086 assembly language, > using DEBUG.EXE and its mini-assembler. Later on (much much later), I > added C to the available languages, but it was tedious and

Re: Why not allow empty code blocks?

2016-07-31 Thread Paul Rubin
Chris Angelico writes: > But out of 20MB, I easily had *space* for a compiler. The problem was > compilation time. I could mess around in BASIC with reasonable > turnaround times; I could mess around in DEBUG with excellent > turnaround times. Doing even the tiniest work in C meant delays long > e

Re: Can math.atan2 return INF?

2016-07-31 Thread Paul Rubin
Steven D'Aprano writes: > If Intuitionism influenced computer science, where is the evidence of this? > Where are the Intuitionist computer scientists? Pretty much all of them, I thought. E.g. programs in typed lambda calculus amount to intuitionistic proofs of the propositions given in the typ

Re: Why not allow empty code blocks?

2016-08-02 Thread Paul Rubin
Steven D'Aprano writes: > where power is defined (rather fuzzily) as the expressiveness > of the language, how easy it is for the programmer to read, write and > maintain code, how efficient/fast you can implement it, etc. Scheme guru Matthias Felleisen takes a stab at a precise definition here (

Re: Debugging (was Re: Why not allow empty code blocks?)

2016-08-02 Thread Paul Rubin
Terry Reedy writes: > I think it is you who is unwilling to admit that nearly everything > that would be useful also has a cost, and that the ultimate cost of > adding every useful feature, especially syntax features, would be to > make python less unusable. I think you meant "usable" ;). Some o

Re: Why not allow empty code blocks?

2016-08-03 Thread Paul Rubin
BartC writes: > sometimes you try to find a .py import module and it > doesn't seem to exist anywhere. (sys.py for example). > I would like to see how such references are translated to Lisp. (require 'sys) -- https://mail.python.org/mailman/listinfo/python-list

Re: How to use a timer in Python?

2005-09-23 Thread Paul Rubin
Nico Grubert <[EMAIL PROTECTED]> writes: > while 'transfer.lock' in os.listdir( WINDOWS_SHARE ): > print "Busy, please wait..." > time.sleep(10) > > f = open(WINDOWS_SHARE + '/myfile', 'w') But there's a race condition, and don't you have to make your own lock before writing myfile, so

Re: Productivity and economics at software development

2005-09-23 Thread Paul Rubin
Peter Hansen <[EMAIL PROTECTED]> writes: > If you focus on IDEs, your research will have pre-selected only > certain kinds of programmers and teams, and will not necessarily > include the best ones. It wouldn't have occurred to me to say that Ken Iverson (APL), Peter Deutsch (PARC Smalltalk), or D

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