Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Steven D'Aprano
ary minus and - for binary subtraction, and doesn't include unary plus. The reason was to simplify the parser, so that every symbol had exactly one meaning. So in an alternate universe where Guido was less influenced by C, or where he wasn't as good as writing parsers as the real GvR

Re: Jython standalone

2015-11-14 Thread Steven D'Aprano
e installer doesn't run, you will probably get a bunch of error messages printed to the terminal window. COPY and PASTE those error messages, and send them to us here. Don't re-type them, and don't try to summarise. We need to see the EXACT messages. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: A Program that prints the numbers from 1 to 100

2015-11-14 Thread Steven D'Aprano
print(i) One you get that far, you will need to decide which numbers are multiples of 3, which are multiples of 5, and which are multiples of both 3 and 5. Hint: # Multiples of 7. for i in range(1, 11): print(i) if i % 7 == 0: print("multiple of seven") If you n

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-14 Thread Steven D'Aprano
On Sun, 15 Nov 2015 02:43 am, Ian Kelly wrote: > On Fri, Nov 13, 2015 at 10:40 PM, Steven D'Aprano > wrote: >> Python has operator overloading, so it can be anything you want it to be. >> E.g. you might have a DSL where +feature turns something on and -feature >&g

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-16 Thread Steven D'Aprano
On Mon, 16 Nov 2015 05:15 pm, Gregory Ewing wrote: > Ian Kelly wrote: >> Unary integer division seems pretty silly since the only possible results >> would be 0, 1 or -1. > > Ints are not the only thing that // can be applied to: > > >>> 1.0//0.01 > 99.0

Re: What meaning is 'a[0:10:2]'?

2015-11-16 Thread Steven D'Aprano
these two slices are the same: a[0:10:2] a[:10:2] If the start or end position are out of range, the slice will only include positions that actually exist: py> a[:10000:5] [100, 105, 110, 115, 120] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Names [was Re: What meaning is 'a[0:10:2]'?]

2015-11-16 Thread Steven D'Aprano
e-internet-nobody-can-tell-if-your-name-really-is-Mxyzptlk-ly yr's, -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Question about yield

2015-11-16 Thread Steven D'Aprano
st(). See example below. Here is a generator which takes a list as argument, and returns a running sum of the list values: def running_sum(alist): total = 0 for value in alist: total += value yield total And here is an example of using it: py> gen = running_sum(

Re: Problems using struct pack/unpack in files, and reading them.

2015-11-16 Thread Steven D'Aprano
On Sun, 15 Nov 2015 01:23 pm, Chris Angelico wrote: > On Sun, Nov 15, 2015 at 1:08 PM, Steven D'Aprano > wrote: >> number = +raw_input("enter a number: ") >> >> versus: >> >> text = raw_input("enter a number: ") >> try: >>

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Steven D'Aprano
'not where'])" "x in S" 1000 loops, best of 3: 0.101 usec per loop That's better! But only *marginally* faster than the tuple, and to get the speed increase you have to factor out the set into a constant. So for Python 2, I would say that tuples are the clean winner,

Re: Which type should be used when testing static structure appartenance

2015-11-18 Thread Steven D'Aprano
On Wed, 18 Nov 2015 11:40 pm, Chris Angelico wrote: > On Wed, Nov 18, 2015 at 10:37 PM, Steven D'Aprano > wrote: >> How about Python 3? Python 3 has the advantage of using set literals. > > 2.7 has set literals too. Ah, so it does. I forgot about that. Most of my code

Re: non-blocking getkey?

2015-11-18 Thread Steven D'Aprano
thful to say and write, often gets abbreviated as "astral planes". Hence the characters themselves are called "astral characters". Even today, some programming languages and systems have difficulty dealing with characters that require more than two bytes. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
ject with TWO names: py> a = [1, 2, 3, 4] py> b = a py> b.append(999) py> print(a) [1, 2, 3, 4, 999] If we delete one of those names, the other name keeps the list alive: py> del a py> print(b) [1, 2, 3, 4, 999] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
is responsible for ensuring that x is not deleted. If it is deleted, then you will get a NameError trying to evaluate the default value. Whichever option you choose, there will be a multitude of people on the internet telling you that you got it wrong. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
dict, a float, or some other instance, the behaviour is the same: the default value is the specific instance which the default expression evaluates to when the function is created. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
On Fri, 20 Nov 2015 12:19 am, BartC wrote: > On 19/11/2015 12:19, Steven D'Aprano wrote: >> On Thu, 19 Nov 2015 10:14 am, BartC wrote: > >> Consider this pair of functions: >> >> >> def expensive(): >> # Simulate some expensive c

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
t *copying the reference* to B, not copying B. [Aside: there is some ambiguity here. If I say "a reference to B", I actually mean a reference to the object referenced to by B. I don't mean a reference to the *name* B. Python doesn't support that feature: names are not values in Python.] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Late-binding of function defaults (was Re: What is a function parameter =[] for?)

2015-11-19 Thread Steven D'Aprano
executed only once. The function body, conveniently indented to make it stand out: y = [] is executed every time you call the function. [Aside: that nice clean design is somewhat muddied by docstrings. Despite being indented, docstrings are actually part of the declaration in the

Re: What is a function parameter =[] for?

2015-11-19 Thread Steven D'Aprano
On Fri, 20 Nov 2015 04:30 am, BartC wrote: > On 19/11/2015 16:01, Steven D'Aprano wrote: [...] > The whole concept of 'mutable' default is alien to me. A default is just > a convenient device to avoid having to write: > >fn(0) or fn("") or fn([]) Sa

Re: Generate a random list of numbers

2015-11-19 Thread Steven D'Aprano
andom.randrange(10) produces a random digit between 0 and 9 (10 is excluded). So we end up with something like: [6, 4, 2, 2, 6, 9] for example. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: *= operator

2015-11-21 Thread Steven D'Aprano
On Sun, 22 Nov 2015 12:20 am, Cai Gengyang wrote: > Does bill *= 1.08 mean bill = bill * 1.15 ? No. It means `bill = bill * 1.08`, not 1.15. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-21 Thread Steven D'Aprano
On Fri, 20 Nov 2015 10:59 pm, BartC wrote: > On 20/11/2015 01:05, Steven D'Aprano wrote: >> Here's another use for function defaults, as static storage: [...] >> This is a quick and easy way to memoise a function which would otherwise >> be horribly slow. And it on

Re: What is a function parameter =[] for?

2015-11-21 Thread Steven D'Aprano
On Fri, 20 Nov 2015 02:42 am, Ian Kelly wrote: > On Thu, Nov 19, 2015 at 5:45 AM, Steven D'Aprano > wrote: >> But if you want the default value to be evaluated exactly once, and once >> only, there is no real alternative to early binding. You could use a >> global

Re: What is a function parameter =[] for?

2015-11-22 Thread Steven D'Aprano
y(query, database=global_database): ... global_database = DB("xyz") initiate_query(query) # here, the database used is "abc", not "xyz" But with late binding, or "late evaluation", the opposite is the case: when you finally call initiate_query, the dat

Re: What is a function parameter =[] for?

2015-11-22 Thread Steven D'Aprano
ied response to make when multiple people have spent a lot of their own time, gratis, to explain what is going on. If you are willing, you can learn a lot here, one of the few places left where education is still free. > * The insistence (I think largely from Steven) that the way this feature > w

Re: What is a function parameter =[] for?

2015-11-22 Thread Steven D'Aprano
r and more general concept than roasting." -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-22 Thread Steven D'Aprano
On Monday 23 November 2015 10:43, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Memoisation isn't "esoteric", it is a simple, basic and widely-used >> technique used to improve performance of otherwise expensive functions. > > That may be true, but I d

Re: pip does not work anymore

2015-11-23 Thread Steven D'Aprano
ing SUSE for breaking this, please run this at the interactive interpreter: import urllib2 print urllib2.__file__ Have you perhaps accidentally shadowed the std lib module? -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What is a function parameter =[] for?

2015-11-23 Thread Steven D'Aprano
On Mon, 23 Nov 2015 09:40 pm, BartC wrote: > On 23/11/2015 07:47, Steven D'Aprano wrote: > >> I think it would be cleaner and better if Python had dedicated syntax for >> declaring static local variables: > > Interesting. So why is it that when /I/ said: > &

Re: tuples in conditional assignment

2015-11-24 Thread Steven D'Aprano
opposite. Fortunately, it is very simple to test these things out at the interactive interpreter. I cannot imagine doing any Python programming without having a Python shell open and ready for me to try out code snippets. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Getting math scores (Dictionary inside dictionary)

2015-11-24 Thread Steven D'Aprano
ot;: 13} > } > > How do you get gengyang's maths scores ? Break the problem into two steps: - get Gengyang's scores; - then get the maths score: scores = results['gengyang'] maths_score = scores['maths'] Now you can simplify the process: maths_score = results['gengyang']['maths'] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
On Thu, 05 Jun 2014 14:01:50 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> The whole concept of stdin and stdout is based on the idea of having a >> console to read from and write to. > > Not really; stdin and stdout are frequently connected to files, or pipes

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
tified. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
On Thu, 05 Jun 2014 05:56:07 -0700, Rustom Mody wrote: > On Thursday, June 5, 2014 2:09:34 PM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 04 Jun 2014 22:43:05 -0400, Terry Reedy wrote: > >> > Many mail readers treat \t as a null char since it actually has no >> &g

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
*. In the Unix world, text formats and text processing is much more common in user-space apps than binary processing. Perhaps the definitive explanation and celebration of the Unix way is Eric Raymond's "The Art Of Unix Programming": http://www.catb.org/esr/writings/taoup/html/

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
n't libel Python by pretending that bytes is anything less than one of the most important and fundamental types in the language. bytes are so important that there are TWO implementations for them, a mutable and immutable version (bytearray and bytes), while text strings only have an immut

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
hatever the situation, and despite our differences of opinion about Unicode, THANK YOU for having updated ReportLabs to 3.3. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
example, the amount of space spent on fixing Windows Unicode handling here: http://www.utf8everywhere.org/ -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
bject to str implicitly [...] >> When I compile Cython modules I use LLVM on this computer. > > Cython is not Python, it is another language, with an incompatible > syntax. Cython is best considered a superset of Python, with a pure-Python compatibility mode. It can run standard Python c

Re: Python 3.2 has some deadly infection

2014-06-05 Thread Steven D'Aprano
riendly, but it's conceptually simple: * Does sys.stdout have a buffer attribute? Then write raw bytes to the buffer. * If not, then write raw bytes to sys.stdout. * If either fails, then somebody has replaced stdout with something weird, and they deserve whatever horrible fate their

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
e go so far as to say that weakly typed is a meaningless concept, but I would agree that there are degrees of weakness. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
s a language feature: within limits, instances can change their type. It has been around for a long, long time, back to Python 1.5 or older, and it has real-world use-cases: http://code.activestate.com/recipes/68429-ring-buffer/ -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-05 Thread Steven D'Aprano
cal is a "bondage and discipline" language, while C lets you escape from the discipline of types with the freedom of casts and other dangerous weak-typing features. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Unicode and Python - how often do you index strings?

2014-06-06 Thread Steven D'Aprano
the file. In binary mode, newlines are *never* changed. In Python 3, you can return end-of-lines unchanged by passing newline='' to the open() function. https://docs.python.org/2/library/functions.html#open https://docs.python.org/3/library/functions.html#open -- Steven D'Apra

Re: Python 3.2 has some deadly infection

2014-06-06 Thread Steven D'Aprano
On Fri, 06 Jun 2014 02:21:54 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> In any case, I reject your premise. ALL data types are constructed on >> top of bytes, > > Only in a very dull sense. I agree with you that this is a very dull, unimportant sens

Re: Python 3.2 has some deadly infection

2014-06-06 Thread Steven D'Aprano
f bytes in some encoding, but as an array of code points. Eventually the abstraction will leak, all abstractions do, but not for a very long time. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Decorating one method of a class C with another method of class C?

2014-06-06 Thread Steven D'Aprano
ot;self" as normal, and such references won't be evaluated until call- time when self exists. It's only inside the decorator itself, and the body of the class, that self doesn't yet exist. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-06 Thread Steven D'Aprano
fundamental model is very similar to Objective-C, Python's is not. Apple already developed a version of Ruby, "MacRuby", which was designed to call directly into the Objective-C APIs without an intermediate interface layer, but they have abandoned that to focus on Swift. (Besides, Apple is unlikely to commit to a core language being something they don't control.) -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: strange behaivor of nested function

2014-06-07 Thread Steven D'Aprano
at is sig? You've said it is a local variable, and at this point it doesn't have a value yet. Lua allows you to do this: sig = sig[0] will look up a global sig and assign it to the local sig first, but that can be confusing and Python doesn't do that. -- Steven D'Apr

Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
ile it is true that the G4 was classified as a supercomputer, that was only for four months until the Clinton administration changed the laws. Apple, of course, played that for every cent of advertising as it could.] -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.pyt

Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
C is not a safe language, and code written in C is not safe. Using C for application development is like shaving with a cavalry sabre -- harder than it need be, and you're likely to remove your head by accident. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https:/

Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
for a 50% reduction in my electricity bill. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-08 Thread Steven D'Aprano
s air- cooling. The last mass market car that used it, the Citroën GS, ceased production in 1986. The Porsche 911 ceased production in 1998, making it, I think, the last air-cooled vehicle apart from custom machines. With the rise of all-electric vehicles, perhaps we will see a return to ai

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Steven D'Aprano
ot sure how this sort of design ambiguity is fixed by importing names into the current namespace. (Note that Forth is brilliant here, as it exposes the argument stack and gives you a rich set of stack manipulation commands.) While we're talking about chaining method and function calls, I&

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Steven D'Aprano
if __name__ == '__main__': return "NOBODY expects the Spanish Inquisition!" else: return __name__ raise AttributeError("no attribute %r" % name) :-) -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-08 Thread Steven D'Aprano
On Sun, 08 Jun 2014 19:24:52 -0700, Rustom Mody wrote: > On Monday, June 9, 2014 7:14:24 AM UTC+5:30, Steven D'Aprano wrote: >> The fact that CPUs need anything more than a passive heat sink is >> *exactly* the problem. A car engine has to move anything up to a tonne >>

Re: Uniform Function Call Syntax (UFCS)

2014-06-08 Thread Steven D'Aprano
ou have to do is just handle the cases you care about, and return NotImplemented for everything else. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: Uniform Function Call Syntax (UFCS)

2014-06-09 Thread Steven D'Aprano
On Mon, 09 Jun 2014 09:25:33 +0300, Marko Rauhamaa wrote: > In a word, > Python has predefined a handful of *generic functions/methods*, That's nine words :-) -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-09 Thread Steven D'Aprano
On Sun, 08 Jun 2014 23:32:33 -0700, Rustom Mody wrote: > On Monday, June 9, 2014 9:50:38 AM UTC+5:30, Steven D'Aprano wrote: >> On Sun, 08 Jun 2014 19:24:52 -0700, Rustom Mody wrote: >> >> >> > On Monday, June 9, 2014 7:14:24 AM UTC+5:30, Steven D'A

Re: Uniform Function Call Syntax (UFCS)

2014-06-09 Thread Steven D'Aprano
On Mon, 09 Jun 2014 19:13:40 +1000, Chris Angelico wrote: > On Mon, Jun 9, 2014 at 7:09 PM, Steven D'Aprano > wrote: >> On Mon, 09 Jun 2014 09:25:33 +0300, Marko Rauhamaa wrote: >> >>> In a word, >>> Python has predefined a handful of *generic funct

Re: None in string => TypeError?

2014-06-09 Thread Steven D'Aprano
sed to swallow a lot more exceptions than it does now, and order comparisons (less than, greater than etc.) of dissimilar types used to return a version-dependent arbitrary but consistent result (e.g. all ints compared less than all strings), but in Python 3 that is now an error. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: None in string => TypeError?

2014-06-09 Thread Steven D'Aprano
x27;re doing something wrong, and told so. This, I think, is the important factor. `x in somestring` is almost always an error if x is not a string. If you want to accept None as well: x is not None and x in somestring does the job nicely. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: try/except/finally

2014-06-10 Thread Steven D'Aprano
On Wed, 11 Jun 2014 06:37:01 +1000, Chris Angelico wrote: > I don't know > a single piece of programming advice which, if taken as an inviolate > rule, doesn't at some point cause suboptimal code. "Don't try to program while your cat is sleeping on the keyboard.

Re: Micro Python -- a lean and efficient implementation of Python 3

2014-06-10 Thread Steven D'Aprano
l-file his posts and be done. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
ater-cooled engines are really air-cooled too, just not > by air flowing directly over the engine block. (Although marine engines > may be an exception.)) Yes, technically water-cooled engines are cooled by air too. The engine heats a coolant (despite the name, usually not water these days)

Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 19:41:12 +1200, Gregory Ewing wrote: > Steven D'Aprano wrote: >> Everything *eventually* gets converted to heat, but not immediately. >> There's a big difference between a car that gets 100 miles to the >> gallon, and one that gets 1 mile to t

Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 08:48:36 -0400, Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> Yes, technically water-cooled engines are cooled by air too. The engine >> heats a coolant (despite the na

Re: OT: This Swift thing

2014-06-11 Thread Steven D'Aprano
On Wed, 11 Jun 2014 08:28:43 -0700, Rustom Mody wrote: > Steven D'Aprano wrote: > >> Not the point. There's a minimum amount of energy required to flip a >> bit. Everything beyond that is, in a sense, just wasted. You mentioned >> this yourself in your previous

Re: About python while statement and pop()

2014-06-11 Thread Steven D'Aprano
return y This does not copy in reverse order. To make it copy in reverse order, index should start at len(x) - 1 and end at 0. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Thu, 12 Jun 2014 12:16:08 +1000, Chris Angelico wrote: > On Thu, Jun 12, 2014 at 12:08 PM, Steven D'Aprano > wrote: >> I'm just pointing out that our computational technology uses over a >> million times more energy than the theoretical minimum, and therefore &

Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Thu, 12 Jun 2014 05:54:47 -0700, Rustom Mody wrote: > On Thursday, June 12, 2014 2:36:50 PM UTC+5:30, Steven D'Aprano wrote: [...] >> > The laws of physics tend to put >> > boundaries that are ridiculously far from where we actually work - I >> > think most

Re: http://bugs.python.org/issue19495 timeit enhancement

2014-06-12 Thread Steven D'Aprano
http://code.activestate.com/recipes/577896 I'll clean it up and submit it on the bug tracker. -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/mailman/listinfo/python-list

Re: OT: This Swift thing

2014-06-12 Thread Steven D'Aprano
On Fri, 13 Jun 2014 03:18:00 +1000, Chris Angelico wrote: > On Fri, Jun 13, 2014 at 3:04 AM, Steven D'Aprano > wrote: [...] >> Take three numbers, speeds in this case, s1, s2 and c, with c a strict >> upper-bound. We can take: >> >> s1 < s2 < c >>

Python's numeric tower

2014-06-14 Thread Steven D'Aprano
Does anyone know any examples of values or types from the standard library or well-known third-party libraries which satisfies isinstance(a, numbers.Number) but not isinstance(a, numbers.Complex)? -- Steven D'Aprano http://import-that.dreamwidth.org/ -- https://mail.python.org/ma

Re: OT: This Swift thing

2014-06-14 Thread Steven D'Aprano
On Sun, 15 Jun 2014 02:51:49 +0100, Joshua Landau wrote: > On 12 June 2014 03:08, Steven D'Aprano > wrote: >> We know *much more* about generating energy from E = mc^2 than we know >> about optimally flipping bits: our nuclear reactions convert something >> of the o

Re: Python's numeric tower

2014-06-15 Thread Steven D'Aprano
On Sun, 15 Jun 2014 01:22:50 -0600, Ian Kelly wrote: > On Sat, Jun 14, 2014 at 8:51 PM, Steven D'Aprano > wrote: >> Does anyone know any examples of values or types from the standard >> library or well-known third-party libraries which satisfies >> isinstan

Re: Python's numeric tower

2014-06-15 Thread Steven D'Aprano
On Sun, 15 Jun 2014 13:28:44 -0400, Roy Smith wrote: > In article <[email protected]>, > Steven D'Aprano wrote: > >> On Sun, 15 Jun 2014 01:22:50 -0600, Ian Kelly wrote: >> >> > On Sat, Jun 14, 2014 at 8:51 PM, Steve

Re: My Christmas wish list

2014-06-15 Thread Steven D'Aprano
it all depends on him. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: python newbie

2014-06-18 Thread Steven D'Aprano
free to show us your code (especially snippets) if there is anything unclear. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: DHCP query script not work.

2014-06-19 Thread Steven D'Aprano
e a string by an int. Perhaps you need to change the line to this? dnsNB = int(data[268]) / 4 -- Steven D'Aprano -- https://mail.python.org/mailman/listinfo/python-list

Re: pyhon 1.5.2 problem

2014-06-19 Thread Steven D'Aprano
,'8N1') > AttributeError : set_speed Do you have two files called SER, perhaps in different directories? One contains set_speed function, the other does not? You should rename one of the files. Also watch out for left-over SER.pyc files, you should delete them. -- Steven D'Aprano -- https://mail.python.org/mailman/listinfo/python-list

Re: py2app dependency determination?

2014-06-21 Thread Steven D'Aprano
y2app installer. Create a minimal script hello.py (as above) Run py2app hello.py The result is ... [whatever actually happens] -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: old python

2014-06-23 Thread Steven D'Aprano
File "", line 1 >>> There's no lambda built-in, but there is a version in the standard library! def lambda(args, expr): if '\n' in args or '\n' in expr: raise RuntimeError, 'lambda: no cheating!' stmt = '

Off-Topic: The Machine

2014-06-23 Thread Steven D'Aprano
one might last 2-3 months on a single charge. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.44 float addition bug?

2014-06-23 Thread Steven D'Aprano
, then explicitly round them: py> x = sum([0.01]*6) py> y = 0.06 py> round(x, 12) == round(y, 12) True Not that I'm recommending that you do it this way, but an explicit round is better than using string formatting. See also this: http://randomascii.wordpress.com/20

Re: Off-Topic: The Machine

2014-06-24 Thread Steven D'Aprano
On Tue, 24 Jun 2014 13:06:56 +0200, Johannes Bauer wrote: > On 24.06.2014 03:23, Steven D'Aprano wrote: >> http://www.iflscience.com/technology/new-type-computer-capable- >> calculating-640tbs-data-one-billionth-second-could >> >> Relevance: The Machine uses *

Re: python 3.44 float addition bug?

2014-06-25 Thread Steven D'Aprano
gt; sum( [x]*23 ) == 1 # Surprise! False py> (Decimal(19)/Decimal(17))*Decimal(17) == 19 # Surprise! False -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: python 3.44 float addition bug?

2014-06-25 Thread Steven D'Aprano
On Thu, 26 Jun 2014 13:13:45 +1000, Chris Angelico wrote: > On Thu, Jun 26, 2014 at 12:56 PM, Steven D'Aprano > wrote: >> That's a myth. decimal.Decimal *is* a floating point value, and is >> subject to *exactly* the same surprises as binary floats, except for &g

Re: python 3.44 float addition bug?

2014-06-26 Thread Steven D'Aprano
On Thu, 26 Jun 2014 13:39:23 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> On Wed, 25 Jun 2014 14:12:31 -0700, Maciej Dziardziel wrote: >> >> > Floating points values use finite amount of memory, and cannot >> > accurately represent

Re: python 3.44 float addition bug?

2014-06-26 Thread Steven D'Aprano
On Thu, 26 Jun 2014 19:38:45 +1000, Chris Angelico wrote: > On Thu, Jun 26, 2014 at 7:15 PM, Steven D'Aprano > wrote: >> Here's an error that *cannot* occur with binary floats: the average of >> two numbers x and y is not guaranteed to lie between x and y! >

Re: print statements and profiling a function slowed performance

2014-06-26 Thread Steven D'Aprano
is recommended for logging, if you expect that logging will be faster than print, I expect you will be disappointed. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: What can Nuitka do?

2014-06-27 Thread Steven D'Aprano
PyPy may technically speed it up, but probably not enough to notice. Some problems are inherently slow. Some are fixable by using better algorithms. And some are fixable by using an optimizing compiler like PyPu or Nuitka. We are given no reason to think that the OP's problems

Re: What can Nuitka do?

2014-06-27 Thread Steven D'Aprano
the actual path to your program.) Confirm that your program is there: at the shell prompt, type dir then hit Enter, and make sure you see your program, something_or_other.py. Now type nuitka --recurse-all something_or_other.py and hit Enter. What happens? (Don't be discouraged if there are a bunch of errors.) -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: why i can't install ez_setup

2014-06-28 Thread Steven D'Aprano
On Sat, 28 Jun 2014 18:24:21 +0100, Mark Lawrence wrote: [snip] > Or get Python 3.4 which can get pip for you if you so desire. Hey Mark, how about trimming your replies a little, please? Thanks. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Translation of Python!

2014-06-30 Thread Steven D'Aprano
ic.com/writings/diary/archive/2007/06/01/lolpython.html http://www.staringispolite.com/likepython/ -- Steven -- https://mail.python.org/mailman/listinfo/python-list

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

2014-07-01 Thread Steven D'Aprano
VCS, almost as good as hg, there's something about git culture which attracts geek wankery. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Statically type-checked variant of Python

2014-07-02 Thread Steven D'Aprano
static typing. Some of the features strike me as good ideas, such as contracts and unit tests, some as dubious (there's a lot of changes to the syntax which, in my opinion, hurt readability). But overall, it strikes me as a very exciting language. -- Steven -- https://mail.python.org/mailm

Re: How can I catch values from other def by flask???

2014-07-02 Thread Steven D'Aprano
return value1 def post_test(): return 'POST it works' > def get_test(value2): > value2='GET it works' def get_test(): return 'GET it works' -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: 1-0.95

2014-07-02 Thread Steven D'Aprano
/design.html#why-am-i-getting-strange-results-with-simple-arithmetic-operations http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html http://effbot.org/pyfaq/why-are-floating-point-calculations-so-inaccurate.htm http://blog.codinghorror.com/why-do-computers-suck-at-math/ https://ran

Re: 1-0.95

2014-07-02 Thread Steven D'Aprano
On Wed, 02 Jul 2014 19:59:25 +0300, Marko Rauhamaa wrote: > Steven D'Aprano : > >> This is a problem with the underlying C double floating point format. >> Actually, it is not even a problem with the C format, since this >> problem applies to ANY floating point form

<    77   78   79   80   81   82   83   84   85   86   >