Re: Code hosting providers (was: Google Code Shutting Down)

2015-03-12 Thread Steven D'Aprano
vendor lock-in. What do you mean by "federated"? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-12 Thread Steven D'Aprano
ield x + 1000 ... py> a = g() py> next(a) 1 py> next(a) 2 py> next(a) 3 py> a.send(99) 1099 But don't do that. So as far as Python is concerned, a coroutine is just a generator instance which you use in a particular way, not a different kind of object. So I would use similar terminology: A generator function/factory returns a generator instance, which we use as a coroutine, so we can call it a coroutine. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 "pickle" vs. stdin/stdout - unable to get clean byte streams in Python 3

2015-03-13 Thread Steven D'Aprano
ing (2.0.3) > setuptools (12.0.5) > six (1.9.0) > > And it works fine with Python 2.7.9. > > Is there some way to force the use of the pure Python pickle module? Try renaming the _pickle module. This works on Linux: mv /usr/local/lib/python3.3/lib-dynload/_pickle.cpython-33m.so /usr/local/lib/python3.3/lib-dynload/_pickle.cpython-33m.so~ > My guess is that there's something about reusing "pickle" instances > that botches memory uses in CPython 3's C code for "cpickle". How are you reusing instances? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Google Code Shutting Down

2015-03-13 Thread Steven D'Aprano
reliably >> with PyPi and pip? > > Google has been migrating most of its own open source projects to GitHub. All that tells me is that Google is planning on buying GitHub, at which point they will continue the process of GitHub lock-in. http://nedbatchelder.com/blog/201405/github_mon

Re: Code hosting providers

2015-03-13 Thread Steven D'Aprano
if I can possibly ignore it. I have ethical issues with their corporate culture, and I dislike anything which smacks of a monoculture. The more Github gets treated as synonymous with revision control, the more I will push back, until I cannot push back any more. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: regex help

2015-03-13 Thread Steven D'Aprano
s += '0' return s And in use: py> strip_zero('-10.2500') '-10.25' py> strip_zero('123000') '123000' py> strip_zero('123000.') '123000.0' It doesn't support exponential format: py> strip_ze

Re: The idle gui

2015-03-13 Thread Steven D'Aprano
fficult to pin-point where they come from. My wife and I can sit in the same car, listening to the same noise, and she swears it is coming from the front left and I'm sure its coming from the rear right. (Invariably she's correct.) But at least the car mechanic can jump in the ca

Re: generator/coroutine terminology

2015-03-13 Thread Steven D'Aprano
o what str(obj) returns. It's not > much more than a random printable some CPython coder has cooked up in > the heat of the moment. I think that is completely wrong. The repr() and str() of generator instances is hardly "random", it reflects the consensus of the PEP authors and the Python core developers, in particular the BDFL Guido who approved the PEP, that the type of object it is should be called "generator". -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-15 Thread Steven D'Aprano
Rustom Mody wrote: > On Saturday, March 14, 2015 at 11:34:27 AM UTC+5:30, Steven D'Aprano > wrote: >> >> A generator (function) may be a function which returns an iterator,... > > I find "generator-function" misleading in the same way that "pineappl

Re: Python 2 to 3 conversion - embrace the pain

2015-03-15 Thread Steven D'Aprano
d. Or are you saying that a mere nine years isn't a long enough > time period to do an exercise like this? Mark, did you read John's post or just respond with a knee-jerk defence of Python 3? I quote: "Some of the bugs I listed are so easy to hit that I suspect those packages aren't used much. Those bugs should have been found years ago. Fixed, even. I shouldn't be discovering them in 2015." Clearly a mere nine years is NOT long enough. Which is probably why the Python core developers are supporting Python 2 until 2020. Library authors will presumably be offering Python 2 compatibility for even longer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-15 Thread Steven D'Aprano
x = random.random() Generators, as a rule, are significantly easier to write, understand, and debug. There's nothing they can do that can't be done with an iterator class, but the fiddly, unexciting bits related to halting and resuming and saving state are all handled for you, allo

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
On Monday 16 March 2015 16:39, Chris Angelico wrote: > On Mon, Mar 16, 2015 at 4:07 PM, Paul Rubin > wrote: >> Python 2 is by now pretty solid and its users don't feel like beta >> testers any more. If you're saying using Python 3 by contrast means >> "being first" and "reporting bugs", that bas

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
On Monday 16 March 2015 17:17, Paul Rubin wrote: > Chris Angelico writes: >> Ah but it isn't Py3 that's all about being first - it's the latest >> version of some third-party module. > > You know, one of the attractions of Python used to be that it came with > a powerful enough standard library

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Monday 16 March 2015 18:12, Marko Rauhamaa wrote: > Steven D'Aprano : > >> Marko Rauhamaa wrote: >>> What features do generator iterators provide on top of generic >>> iterators? >> >> The biggest difference is syntactic. Here's an iterator

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
Chris Angelico wrote: > On Mon, Mar 16, 2015 at 7:36 PM, Steven D'Aprano > wrote: >> I expect that the interpreter can tell the difference between >> >> yield spam >> >> and >> >> x = yield spam >> >> and only allow send

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
, and I expect that will give Py3 some more impetus. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
o iter([1,2,3]) ? Or >> send it a value? What happens? > > I would expect iter([1, 2, 3]) to behave highly analogously to > (x for x in [1, 2, 3]). I believe that it is an unfortunate mistake that generators which aren't coroutines support send. At the very least it is an ugly design wart, at worst it is an outright bug. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
be honest, I'm not even sure what the use-case for close() on coroutines is in the first place. If you don't want to send any more items into it, just don't send any more items into it.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
On Mon, 16 Mar 2015 07:31 pm, Paul Rubin wrote: > Steven D'Aprano writes: >> The std lib is *batteries* included. If you need a nuclear reactor, you >> turn to third-party frameworks and libraries like Twisted, Zope, numpy, >> PLY, etc. > > I always thought twi

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
] Methods are, of course, actually just functions under the hood. The conversion to MethodType is done at method-lookup time, by the descriptor protocol. [2] I'm aware that they are instances. You know what I mean. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
On Mon, 16 Mar 2015 07:25 pm, Paul Rubin wrote: > Steven D'Aprano writes: >> It may, or may not, turn out that in hindsight there might have been >> better ways to manage the Python2-3 transaction. Let's be honest, a lot >> of the changes could have been introduce

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
hat whatever object is passed to you supports close(), or else it is an error. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Tue, 17 Mar 2015 01:19 am, Rustom Mody wrote: > On Monday, March 16, 2015 at 7:10:03 PM UTC+5:30, Steven D'Aprano wrote: >> And of course, from a comp science theoretic perspective, >> generators are a kind of subroutine, not a kind of type. > > You just showed Ma

Re: generator/coroutine terminology

2015-03-16 Thread Steven D'Aprano
On Tue, 17 Mar 2015 01:35 am, Steven D'Aprano wrote: > On Tue, 17 Mar 2015 01:19 am, Rustom Mody wrote: > >> On Monday, March 16, 2015 at 7:10:03 PM UTC+5:30, Steven D'Aprano wrote: >>> And of course, from a comp science theoretic perspective, >>> generat

Re: Python 2 to 3 conversion - embrace the pain

2015-03-16 Thread Steven D'Aprano
rgue that they can't install and use Python3 because of the location where it is installed. As an application developer, apart from ensuring that the PATH is setup correctly and maybe having to adjust a few hash-bang lines, how does the location of the Python binary affect you? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Auto-completion: why not module name?

2015-03-17 Thread Steven D'Aprano
On Tuesday 17 March 2015 03:23, candide wrote: > Python 3.4 provides auto-completion facility within a Python console > embedded in a command line terminal. > > > But apparently this facility doesn't allow the user to complete with > standard module name. For instance, editing the following : >

Re: Python 2 to 3 conversion - embrace the pain

2015-03-17 Thread Steven D'Aprano
On Tuesday 17 March 2015 14:33, Michael Torrie wrote: > On 03/16/2015 09:04 PM, Mario Figueiredo wrote: >> Are you saying this is a problem for any developer? Especially >> considering this is a one-time operation... >> >> Or maybe you mean lazy developers. But lazy developers are an edge >> case

Re: [OT] Weaknesses of distro package managers - was Re: Python 2 to 3 conversion - embrace the pain

2015-03-17 Thread Steven D'Aprano
On Tuesday 17 March 2015 12:46, Michael Torrie wrote: > Python3 can be installed from Software Collections (and that is somewhat > reasonable), but it won't integrate by default, so you can't use > #!/usr/bin/python3 in your apps by default without altering the system > paths. If RedHat installs

Re: Python 2 to 3 conversion - embrace the pain

2015-03-17 Thread Steven D'Aprano
On Tue, 17 Mar 2015 09:36 am, Paul Rubin wrote: > Steven D'Aprano writes: [...] >> If we were designing Python from scratch today, here are some of the >> changes we would certainly make: [mostly good changes] > > I agree with most of those changes and I'd add

Re: Auto-completion: why not module name?

2015-03-17 Thread Steven D'Aprano
On Tue, 17 Mar 2015 11:22 pm, Oscar Benjamin wrote: > On 17 March 2015 at 08:10, Steven D'Aprano > wrote: >> On Tuesday 17 March 2015 03:23, candide wrote: >> >> You might like my tab completion and command history module: >> >> http://code.google.com/

Auto-completion of Unicode names [was why not module name?]

2015-03-17 Thread Steven D'Aprano
int(u"\N{CYRILLIC CAPITAL LETTER ZE WITH DESCENDER}") Ҙ There are currently somewhere in the vicinity of 110 thousand such names. Any interest? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Brilliant or insane code?

2015-03-17 Thread Steven D'Aprano
On Wednesday 18 March 2015 12:14, Dan Sommers wrote: > On Wed, 18 Mar 2015 00:35:42 +, Mark Lawrence wrote: > >> I've just come across this >> http://www.stavros.io/posts/brilliant-or-insane-code/ as a result of >> this http://bugs.python.org/issue23695 >> >> Any and all opinions welcomed, I

Re: Python 2 to 3 conversion - embrace the pain

2015-03-18 Thread Steven D'Aprano
om Python 2.6 to 2.7 is just the normal upgrade pains you always have to expect from any major project, but the two weeks we lost going from 2.7 to 3.3 is a sign that Python 3 is a broken mistake! Anyway, thanks John for persevering. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
dd_data(self): try: age = self.age_var.get() except ValueError: showinfo("Error:", "Please Enter A Number In Age Field.") return # Return early, do nothing. new_person = Employee(name=name, age=age, address=addr, city=city, state=state, zip=zip, ssn=ssn, phone=phone, cell=cell) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: UnboundLocalError in TKinter, SQLAlchemy script.

2015-03-18 Thread Steven D'Aprano
flow they don't insist on you posting your entire program. What if it is 100,000 lines of code split over twenty files? I think they ask for the same as the SSCCE site above, a minimum sample of code which they can run and see the error themselves. Have you got a solution to your immediate

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-18 Thread Steven D'Aprano
27;t use strings for comments anywhere else, this note pad area stands out and reminds me to remove it before releasing the code into production. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python script output in file

2015-03-18 Thread Steven D'Aprano
reversed... with open(inname, "w") as outfile, open(outname, "r") as infile: proc = Popen("cat", shell=True, stdout=outfile, stdin=infile) # do stuff with proc # when finished, save the stuff you care about result = ... print(result) Outside of the `with

Re: Python 2 to 3 conversion - embrace the pain

2015-03-19 Thread Steven D'Aprano
On Thu, 19 Mar 2015 03:35 am, Paul Rubin wrote: > Steven D'Aprano writes: >> The two weeks we lost upgrading from Python 2.6 to 2.7 is just the >> normal upgrade pains you always have to expect from any major project, > > Wait, what happened between 2.6 and 2.7

Re: Deep comparison of dicts - cmp() versus ==?

2015-03-19 Thread Steven D'Aprano
On Friday 20 March 2015 14:47, Rustom Mody wrote: > On Friday, March 20, 2015 at 9:05:19 AM UTC+5:30, Chris Angelico wrote: >> On Fri, Mar 20, 2015 at 2:27 PM, Rustom Mody wrote: >> > Numbers (not complex) satisfy the trichotomy law: ie for any 2 numbers >> > x,y: x < y or x > y o x = y >> >> Re

Re: __iadd__ with 2 args?

2015-03-20 Thread Steven D'Aprano
gument, the tuple (a,b). > So should I just abandon the idea that += could be used this way? Yes, sorry. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Using Python to put a 27-year-old Macintosh on the web

2015-03-22 Thread Steven D'Aprano
http://www.keacher.com/1216/how-i-introduced-a-27-year-old-computer-to-the- web/ or http://tinyurl.com/ksqk5kt -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Best way to calculate fraction part of x?

2015-03-23 Thread Steven D'Aprano
lement of the fraction if x is negative: py> x = -2.75 py> x % 1 0.25 Are there any other, possibly better, ways to calculate the fractional part of a number? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
; fib(3) 1 0 1 1 2 2 py> fib(5) 1 0 1 1 2 1 0 1 3 1 0 1 1 2 5 5 If you want to print a list of Fibonnaci values, you need to call the function in a loop. Removing the "print result" line again, you can do this: py> for i in range(6): ... print fib(i), ... 0 1 1 2 3 5 -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
the Fibonacci series in practice, what is mathematically straightforward is not always computationally efficient. The question is, just how inefficient is is? How many calls to `fib` are made in calling fib(n)? Answer to follow. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
ecursive algorithm is ... the nth Leonardo Number. So in a way, we need not actually bother calculating anything, but just count the number of function calls, throwing away the intermediate results! I think that is rather neat. http://en.wikipedia.org/wiki/Leonardo_number -- Steven -- https://ma

Re: fibonacci series what Iam is missing ?

2015-03-23 Thread Steven D'Aprano
ssociated sequences -- Fibonacci numbers, Pell numbers, Leonardo numbers, Perrin numbers and others -- are defined as recurrences, i.e. recursively. But that doesn't necessarily make recursion the best way to implement it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: module attributes and docstrings

2015-03-24 Thread Steven D'Aprano
iables. The docstring has to be associated with an object, and only certain objects at that. That applies to documentation which is introspectable at runtime. But of course you can do anything you like by parsing the source code! It may be that the docutils library will parse the source code and e

Re: To Change A Pdf Ebook To Kindle

2015-03-24 Thread Steven D'Aprano
request for an application which is usable by Python, it is off-topic and spam. I see Calibre is a Python application, not sure if it is importable by Python scripts though. Thank you, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex Python Help

2015-03-24 Thread Steven D'Aprano
sages you are given, you are truly going to struggle as a programmer. Read the error message. If you don't understand the error message, please say so. And choose a relevant subject line: this has nothing to do with regexes. You might as well have called it "Import Python Help".

Re: test2

2015-03-24 Thread Steven D'Aprano
unless they have an internet connection." -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Newbie looking for elegant solution

2015-03-24 Thread Steven D'Aprano
On Wednesday 25 March 2015 14:13, [email protected] wrote: > I have a list containing 9600 integer elements - each integer is either 0 > or 1. > > Starting at the front of the list, I need to combine 8 list elements into > 1 by treating them as if they were bits of one byte with 1 and 0

Re: Sudoku solver

2015-03-25 Thread Steven D'Aprano
On Wed, 25 Mar 2015 10:39 pm, Marko Rauhamaa wrote: > I have yet to find practical use for fibonacci numbers. Many people have failed to find practical uses for many things from mathematics. Doesn't mean they don't exist: http://en.wikipedia.org/wiki/Fibonacci_number#Applications

Re: Regex Python Help

2015-03-25 Thread Steven D'Aprano
ly in this thread you said "Here you go. Windows shell was easier!!!" Does Windows shell have grep? How about Powershell? If grep is available, why mix two different languages? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: time module vs. datetime module: plain language for beginners

2015-03-25 Thread Steven D'Aprano
th time and datetime from the same module. I usually only import one, or the other. For example, I might do: time.sleep(3) which doesn't require the datetime module. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-25 Thread Steven D'Aprano
al with that. In order from best to worst: (1) Don't let those combinations occur at all. Redesign your function, or split it into multiple functions, so the impossible combinations no longer exist. (2) Raise an error when an impossible combination occurs. (3) Just ignore one or more argument s

Re: test1

2015-03-25 Thread Steven D'Aprano
re not wanted here. *plonk* -- Steven -- https://mail.python.org/mailman/listinfo/python-list

RE: Function Defaults - avoiding unneccerary combinations of arguments at input

2015-03-26 Thread Steven D'Aprano
On Thu, 26 Mar 2015 08:47 pm, Ivan Evstegneev wrote: > > >> -Original Message- >> From: Python-list [mailto:python-list- >> [email protected]] On Behalf Of Steven >> D'Aprano >> Sent: Thursday, March 26, 2015 01:49 >

Re: test1

2015-03-26 Thread Steven D'Aprano
On Fri, 27 Mar 2015 02:33 am, Joel Goldstick wrote: [...] Don't give the troll the attention he craves. He has as much told us that he is beyond reason -- he's been trolling for years, you don't need to justify your actions. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: test1

2015-03-26 Thread Steven D'Aprano
On Fri, 27 Mar 2015 03:26 am, Tim Chase wrote: [...] Don't give the troll the attention he craves. He has as much told us that he is beyond reason -- he's been trolling for years, you don't need to justify your actions. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Fwd: test1

2015-03-26 Thread Steven D'Aprano
lling for years, so don't bother to engage with him. The problem with wrestling a pig in the mud is that you get dirty and the pig enjoys it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Basic Python V3 Search Tool using RE module

2015-03-26 Thread Steven D'Aprano
YPT files, but if it fails to find them when they are actually there, that's a pretty big bug. And one more quote: "The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet." — Michael A. Jackson (No, not Michael Jackson the dead pop singer.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-03-26 Thread Steven D'Aprano
(1, 7), (1, 13), 'spam = "abcd" "efgh"\n') (3, '"efgh"', (1, 14), (1, 20), 'spam = "abcd" "efgh"\n') (4, '\n', (1, 20), (1, 21), 'spam = "abcd" "efgh"\n') (0, '', (2, 0), (2, 0), '') Looks to me that the two string literals each get their own token, and are concatenated at a later stage of compilation, not during parsing. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Supply condition in function call

2015-03-26 Thread Steven D'Aprano
er than that, all those meanings are valid and have to be distinguished from context. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: module attributes and docstrings

2015-03-27 Thread Steven D'Aprano
ow... > On Tue, 24 Mar 2015 22:49:49 +1100, Steven D'Aprano > wrote: [...] >>Even if there was support from the compiler to extract the docstring, >>where would it be stored? Consider: >> >>spam = None >>"""Spammy goodness."""

Re: Sudoku solver

2015-03-27 Thread Steven D'Aprano
ing a Python regex, but given an incomplete one, probably *not* prove that it is solvable. But I can't justify that in any objective way. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Sudoku solver

2015-03-27 Thread Steven D'Aprano
monks.org/?node_id=471168 I'm not a Perl expert, but I call that cheating, as it uses the ?{ ... } construct to embed Perl code in the regex. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-27 Thread Steven D'Aprano
g like that -- dont exactly remember the syntax) Pascal is another language with a construct like that, and there's a FAQ for it: https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Supply condition in function call

2015-03-28 Thread Steven D'Aprano
y, March 27, 2015 at 10:05:21 AM UTC+5:30, Steven D'Aprano wrote: >> On Fri, 27 Mar 2015 01:21 pm, Rustom Mody wrote: >> >> > Anyway my point is that in python (after 2.2??) saying something is an >> > object is a bit of a tautology -- ie verbiage without infor

Re: Supply condition in function call

2015-03-28 Thread Steven D'Aprano
: - When I am forced to use a Windows application, middle-click *never* pastes :-( - Certain Linux applications like OpenOffice seem to have buggy implementations of middle-click, and sometimes fail to recognise when you've copied something in another application. But only sometimes. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
be awkward: t = ([1, 2, 3], None, "spam") t[0] += [4] The problem isn't that the second line raises an exception, but that the second line raises an exception and yet the addition succeeded. So I am fairly dubious about extending a mixed blessing like augmented assignment even further. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Supply condition in function call

2015-03-28 Thread Steven D'Aprano
say is absolutely correct. And yet middle-click paste is so convenient when it works that I all but cry from frustration when I find an application that doesn't support it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
ass assignments? It seems hard to > justify performance-wise since list is written in C, and if you need > to beat it, then you probably shouldn't be doing so in Python. https://www.safaribooksonline.com/library/view/python-cookbook/0596001673/ch14s05.html -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Python 2/3 versus Perl 5/6

2015-03-28 Thread Steven D'Aprano
ython programmer and member of the PSF, that's the Python Software Foundation, not the PSU, the Python Secret Underground, which most definitely does not exist. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposal for new minor syntax

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 08:53 pm, Steven D'Aprano wrote: > It saves typing. It might even allow a micro-optimization in the generated > bytecode (see below). Oops, I forgot to include the "see below" bit. Comparing a = a.spam() a .= spam() the Python compiler could

Re: VB/Pascal with statement [was Re: Proposal for new minor syntax]

2015-03-28 Thread Steven D'Aprano
On Sat, 28 Mar 2015 11:26 pm, Mark Lawrence wrote: > On 28/03/2015 06:26, Steven D'Aprano wrote: >>Pascal is another language with a construct like that, and there's a FAQ >>for it: >> >> https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-wit

Re: Sudoku solver

2015-03-28 Thread Steven D'Aprano
aster than optimized C, my first reaction is to expect that you've probably made a mistake somewhere. I would have the same reaction if somebody casually dropped into a conversation that they happened to beat Usain Bolt's 100m personal best of 9.58 seconds by almost four seconds. While car

Re: Sudoku solver

2015-03-29 Thread Steven D'Aprano
On Sun, 29 Mar 2015 03:10 pm, Chris Angelico wrote: > On Sun, Mar 29, 2015 at 2:06 PM, Steven D'Aprano > wrote: >> On Sun, 29 Mar 2015 10:50 am, BartC wrote: >> >>> (X is my own interpreted language, which is where my interest in this >>> is. This had bee

Re: Python 2/3 versus Perl 5/6

2015-03-29 Thread Steven D'Aprano
On Sun, 29 Mar 2015 06:36 am, Mario Figueiredo wrote: > On Sat, 28 Mar 2015 21:32:31 +1100, Steven D'Aprano > wrote: > >>The famous Perl coder Allison Randal writes about why Perl is not dead >>(it's just pining for the fjords *wink* ) and contrasts the Perl 5/

Re: Python 3 lack of support for fcgi/wsgi.

2015-03-29 Thread Steven D'Aprano
outdated. If only things stayed like the Good Old Days when documentation was always 100% accurate and up to date, before Python 3 ruined it for everybody! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: A simple single line, triple-quoted comment is giving syntax error. Why?

2015-04-02 Thread Steven D'Aprano
On Friday 03 April 2015 08:31, Thomas 'PointedEars' Lahn wrote: > I am sorry that you cannot see that your argument is strewn with gaping > defects in logic, but I think I will stop trying to convince you of that > now. I'm sorry, I've been away for four days and have lost track of this thread.

Re: generator/coroutine terminology

2015-04-02 Thread Steven D'Aprano
On Wednesday 01 April 2015 00:18, Albert van der Horst wrote: > In article <[email protected]>, > Steven D'Aprano wrote: >>The biggest difference is syntactic. Here's an iterator which returns a >>never-ending seque

Re: New to Programming: Adding custom functions with ipynotify classes

2015-04-03 Thread Steven D'Aprano
indentation, the function is horribly inefficient. Instead, use this: import os os.stat(filename).st_size -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to deliver different source distributions for different Python versions?

2015-04-05 Thread Steven D'Aprano
al imports: # mymodule2 mystring = u"äπЖ☃" # Also works in 3.3 or better. # mymodule3 mystring = "äπЖ☃" # main application from __future__ import print_function from future_builtins import * if sys.version < '3': import mymodule2 as mymodule else: imp

Re: Is it possible to deliver different source distributions for different Python versions?

2015-04-06 Thread Steven D'Aprano
On Mon, 6 Apr 2015 09:23 pm, Dylan Evans wrote: [content snipped] Hi Dylan, and welcome! If you're going to post in response to people's questions, would you please disable HTML email and trim your responses? This mailing list is mirrored on Usenet, as comp.lang.python, where HTML is against th

Re: implementing pyshark

2015-04-06 Thread Steven D'Aprano
as built without threading. That means you'll have to re-install to fix this problem. But first you'll need to install the necessary dependencies. What operating system and/or distro are you using? It looks like Linux or Unix, or maybe Mac OS X. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: implementing pyshark

2015-04-06 Thread Steven D'Aprano
rom importing the library, it imports your version instead. Rename your gevent.py file and the problem will hopefully go away. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Is it possible to deliver different source distributions for different Python versions?

2015-04-06 Thread Steven D'Aprano
On Tue, 7 Apr 2015 12:05 am, Ian Kelly wrote: > On Mon, Apr 6, 2015 at 5:52 AM, Steven D'Aprano > wrote: >> To the rest of the list... didn't somebody write up a wiki post on how to >> convince Gmail to be less unreasonable about top posting, quoting, etc? >&g

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
assume base 10. That's just ridiculous. In Python, like most other languages, the only thing which assumes base 10 is entry and printing of integers. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
tever their internal storage format uses, which is normally base 2. They don't work in decimal, using the same decimal routines you learned in school. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
answer until there is only one answer it hasn't given, which is right (100 guesses). I assume that the Oracle is smart enough to never repeat a guess. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
4 5 6 7 8 9. Base 16 uses 0 1 2 3 4 5 6 7 8 9 A B C D E F. Base one million uses what? How would you write down 12345 in base one-million? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
t = Timer("s[0]; max(s)", setup) py> min(t.repeat()) 7.158415079116821 That's just over 7 seconds to calculate both the first and the highest digit one million times, or about 7 microseconds each time. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
an Python's built-ins. Besides, it isn't clear to me whether Jonas wants to convert decimal 293...490 *into* base 429496729 as you have done, or *base 429496729* 293...490 into decimal. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-07 Thread Steven D'Aprano
On Wed, 8 Apr 2015 10:38 am, Steven D'Aprano wrote: > On Wed, 8 Apr 2015 03:44 am, Ian Kelly wrote: > >>>>> > to_base(2932903594368438384328325832983294832483258958495845849584958458435439543858588435856958650865490, >>>>> 429496729) >> [27

Re: try..except with empty exceptions

2015-04-10 Thread Steven D'Aprano
catch everything. I'm fairly dubious about catching everything, that sounds like a good way to hide bugs, but if you need to catch everything, using Exception is the usual way to do it. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: find all multiplicands and multipliers for a number

2015-04-10 Thread Steven D'Aprano
es.factors.factorise(2**111+1) [3, 3, 1777, 3331, 17539, 25781083, 107775231312019L] but that is the nature of factorising large numbers. http://code.google.com/p/pyprimes/source/browse/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Steven D'Aprano
On Fri, 10 Apr 2015 01:02 am, Chris Angelico wrote: > On Fri, Apr 10, 2015 at 12:53 AM, Alain Ketterlin > wrote: >> Ouch, you're right, I tried to stick with Marko's example and forgot the >> basics. I meant "signed ints", but the "removable" condition should be >> something like: >> >> if (

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Steven D'Aprano
argc, char *argv[]) { int a; a = 1; int b; b = 2147483647; printf("a = %d\n", a); printf("b = %d\n", b); printf("a+b = %d\n", a+b); return 0; } -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Exception Handling

2015-04-09 Thread Steven D'Aprano
On Thu, 9 Apr 2015 07:31 pm, Palpandi wrote: > Hi all, > > Is there any way to roll back or undo changes which are all done before > exception occurs. Not automatically. You have to program it yourself. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Best search algorithm to find condition within a range

2015-04-09 Thread Steven D'Aprano
either the skill or inclination to write correct C code. Even the Linux kernel contains bugs. Things were bad enough in the old days of classical C compilers, but modern C optimizing compilers may actively counteract your code as you have written it. How that isn't considered an outright malicious act, I don't know. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

<    70   71   72   73   74   75   76   77   78   79   >