Asynchronous programming

2016-08-10 Thread Steven D'Aprano
The latest versions of Python are introducing new keywords for asynchronous programming, async and await. See PEP 492: https://www.python.org/dev/peps/pep-0492/ Is there a good beginner's tutorial introducing the basics of asynchronous programming? Starting with, why and where would you use it?

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thursday 11 August 2016 16:21, Christian Gollwitzer wrote: > In typical GUI code, there are usually not that many places qhere ou > have sequential code. A simple exmaple might be a counter. Using asyncio > and a properly integrated GUI toolkit, you could write it as (pseudo-code) > > async de

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote: > Steven D'Aprano writes: > >> >> Is there a good beginner's tutorial introducing the basics of >> asynchronous programming? Starting with, why and where would you use it? > > You could do worse than

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 07:33 pm, Chris Angelico wrote: > Yes, > threading bugs can be harder to debug; but only when you've violated > the other principles. Especially the principle "Avoid threaded programming". Some people, when faced with a problem, Now they think "I know, I'll have use two thre

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:06 pm, Paul Rubin wrote: > The basic characteristic of asynchronous programming is that it involves > changing all your usual blocking i/o calls to non-blocking ones, so your > program can keep running as soon as your request is started. That's the bit that confuses me. I u

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 02:41 pm, Chris Angelico wrote: > Consider these three ways of doing a database transaction: > > def synchronous(id): > trn = conn.begin_transaction() > trn.execute("select name from people where id=%d", (id,)) > name, = trn.fetchone() > trn.execute("update peo

Re: Is it ‘allowed’ to get parameters like this

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 11:23 pm, Cecil Westerhof wrote: > It has been a while since I worked with Python. I wanted to get some > stats about the idle time of my computer, so that was a good moment to > pick up Python again. ;-) > > > As I understood it getopt is the way to get the parameters for yo

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
On Thu, 11 Aug 2016 03:34 pm, Paul Rudin wrote: > Steven D'Aprano writes: > >> >> Is there a good beginner's tutorial introducing the basics of >> asynchronous programming? Starting with, why and where would you use it? > > You could do worse than

Re: A strange list concatenation result

2016-08-11 Thread Steven D'Aprano
Note that your subject line is wrong. You are not doing list concatenation. Unfortunately, for technical and optimization reasons, the += assignment operator for lists is in-place, which means that it is NOT the same as ordinary list concatenation + operator. It is equivalent to calling the list.e

Re: Asynchronous programming

2016-08-11 Thread Steven D'Aprano
Thanks to everyone who has answered, I think I'm slowly starting to get it now. Let's see if we can come up with a toy example that doesn't involve low-level socket programming :-) Let me simulate a slow function call: import random, time def work(id): print("starting with id", id) work

Re: What's the best way to minimize the need of run time checks?

2016-08-12 Thread Steven D'Aprano
On Fri, 12 Aug 2016 07:38 pm, BartC wrote: > 'year' has been spelled wrongly How do you know? The point is that it is intentional that callers can set arbitrary attributes on (most) objects. It is perfectly legitimate to set: d.year d.century d.owner d.extra_seconds and, yes, even d.yaer, sinc

Re: What's the best way to minimize the need of run time checks?

2016-08-12 Thread Steven D'Aprano
On Fri, 12 Aug 2016 07:58 pm, BartC wrote: > On 12/08/2016 10:45, Chris Angelico wrote: >> On Fri, Aug 12, 2016 at 7:38 PM, BartC wrote: >>> You can be too dynamic. Take an example like this: > >>> d.yaer=1999 [...] > How would a linter know that you didn't /want/ to create a new attribute > ca

Re: Asynchronous programming

2016-08-12 Thread Steven D'Aprano
On Fri, 12 Aug 2016 03:47 pm, Paul Rudin wrote: > Steven D'Aprano writes: > >> Thanks to everyone who has answered, I think I'm slowly starting to get >> it now. Let's see if we can come up with a toy example that doesn't >> involve low-level socket

Re: A strange list concatenation result

2016-08-12 Thread Steven D'Aprano
On Sat, 13 Aug 2016 06:44 am, Mok-Kong Shen wrote: > list2 = [1,2,3] > list1 += [4,5,6] > print(list1, list2) >> [1, 2, 3, 4, 5, 6] [1, 2, 3] >> >> >> Does that help? > > I don't yet understand why in my 2nd example list2 came out as > [1, 2, 3] outside. Because you assign list2 = [1

Re: What's the best way to minimize the need of run time checks?

2016-08-12 Thread Steven D'Aprano
On Sat, 13 Aug 2016 08:12 am, Lawrence D’Oliveiro wrote: > On Friday, August 12, 2016 at 9:39:11 PM UTC+12, BartC wrote: > >> 'year' has been spelled wrongly > > That’s why Python has __slots__. No, that is OFFICIALLY *not* why Python has __slots__. Python has __slots__ in order to support app

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Fri, 12 Aug 2016 09:55 pm, BartC wrote: > On 12/08/2016 12:07, Steven D'Aprano wrote: >> On Fri, 12 Aug 2016 07:38 pm, BartC wrote: >> >>> 'year' has been spelled wrongly >> >> How do you know? > > I know because my intention was to cr

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Fri, 12 Aug 2016 11:30 pm, Michael Torrie wrote: > On 08/12/2016 05:07 AM, Steven D'Aprano wrote: >> The first time I ever compiled a full-sized application (not a particular >> large one either, it was a text editor a little more featureful than >> Notepad) it took

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Sat, 13 Aug 2016 08:09 pm, BartC wrote: > (The way I deal with records elsewhere is so ridiculously simple that it > almost makes me want to cry when I see what most dynamic languages have > to do. Example: > > record date=# define the record > var day, month, year > end >

Anyone here running Python on a PowerPC?

2016-08-13 Thread Steven D'Aprano
Is there anyone here running Python on a PowerPC willing to help me diagnose and fix this issue? http://bugs.python.org/issue27761 -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Steven D'Aprano
On Sun, 14 Aug 2016 11:53 am, John Wong wrote: > The way I solve it, and I still find that extremely ugly, is > > s = ("this string continues " + >"substring continues") You don't need the plus sign, as Python will concatenate string literals (not variables) at compile time: "foo" 'bar'

How do I tell if I'm running on a PowerPC?

2016-08-13 Thread Steven D'Aprano
I need to be able to programmatically test whether I'm running on a PowerPC. How can I do that? import platform if platform.machine() in ('ppc', 'ppc64'): print('running PowerPC') Is that right? -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, thi

Re: What's the best way to minimize the need of run time checks?

2016-08-13 Thread Steven D'Aprano
On Sun, 14 Aug 2016 06:59 am, BartC wrote: > On 13/08/2016 17:06, Steven D'Aprano wrote: >> On Sat, 13 Aug 2016 08:09 pm, BartC wrote: > >>> record date=# define the record >>> var day, month, year >>> end >>> >>&g

Re: What's the best way to minimize the need of run time checks?

2016-08-14 Thread Steven D'Aprano
On Thu, 11 Aug 2016 06:33 am, Juan Pablo Romero Méndez wrote: > I've been trying to find (without success so far) an example of a > situation where the dynamic features of a language like Python provides a > clear advantage over languages with more than one type. Python has more than one type. Do

Re: What's the best way to minimize the need of run time checks?

2016-08-14 Thread Steven D'Aprano
On Mon, 15 Aug 2016 08:45 am, Lawrence D’Oliveiro wrote: > On Monday, August 15, 2016 at 4:31:44 AM UTC+12, BartC wrote: > >> But it can't create a new record or struct type at runtime which can >> then be accessed using normal syntax, in compiled code that already >> existed before the record wa

Re: What is the trick between these?

2016-08-15 Thread Steven D'Aprano
On Tue, 16 Aug 2016 04:41 am, [email protected] wrote: > Python complained that no attribute of load_canvas_image(). It is there, > coexisting with load_label_image(). > > I cannot figure out what is wrong with it, can somebody tell me why? > Thanks! No, we cannot, because we are not psychi

Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Tuesday 16 August 2016 16:28, Lawrence D’Oliveiro wrote: > On Tuesday, August 16, 2016 at 6:26:01 PM UTC+12, Paul Rudin wrote: >> sohcahtoa82 writes: >>> squared_plus_one_list = map(lambda x: x**2 + 1, some_list) >> >> I realise that this is about understanding lambda, but it's worth noting >>

Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 04:46, alister wrote: > > squared_plus_one_list = map(lambda x: x**2 + 1, some_list) > > probably the cleanest example I have seen so far, & I still cant see the > point Hmmm. Well, let's have a look at some analogies with other kinds of values. Out of each pair of e

Re: I am new to python. I have a few questions coming from an armature!

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 06:59, Lawrence D’Oliveiro wrote: > On Wednesday, August 17, 2016 at 6:46:22 AM UTC+12, alister wrote: >> I don't think I am missing anything by not bothering with them YMMV > > Here > > are s

Re: pystl

2016-08-16 Thread Steven D'Aprano
On Wednesday 17 August 2016 16:36, Poul Riis wrote: > Can someone deliver a minimal, fully working example with the pystl module, > https://pypi.python.org/pypi/pystl/ > > The only example code mentioned is the following: > > with PySTL(‘stl_test.stl’) as stl: > stl.add_triangle( (0.0, 0.0,

Re: pystl

2016-08-17 Thread Steven D'Aprano
On Wednesday 17 August 2016 18:56, Poul Riis wrote: > I tried the following: > > from pystl import PySTL > with PySTL('stl_test.stl') as stl: > stl.add_triangle((0,0,0),(1,0,0),(0,1,0)) > > I got the following error message: Ah, bad news I am afraid. That looks like a bug in pystl. I don'

Re: What's the best way to minimize the need of run time checks?

2016-08-18 Thread Steven D'Aprano
On Thursday 18 August 2016 03:29, Michael Selik wrote: >> You might find this https://glyph.twistedmatrix.com/2016/08/attrs.html an >> interesting read. >> > > I disagree with a few points from that blog post. > > 1. I don't mind typing so much. I like to be explicit. The attrs library > uses so

Re: I am new to python. I have a few questions coming from an armature!

2016-08-18 Thread Steven D'Aprano
On Thursday 18 August 2016 06:25, Terry Reedy wrote: > On 8/17/2016 2:07 AM, Steven D'Aprano wrote: > >> I realise that there are occasions where we might deliberate choose to >> assign an intermediate value to its own variable, but all else being equal, >> whi

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Steven D'Aprano
On Monday 22 August 2016 14:33, Chris Angelico wrote: > On Mon, Aug 22, 2016 at 1:37 PM, rocky wrote: >> Sorry should have been: >> >> assert sys.version_info >= (3,0) > > The next question is: How common is code like this? I don't put > version checks in any of my modules. Adding magic comment

Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Steven D'Aprano
On Monday 22 August 2016 16:03, Stefan Behnel wrote: > Steven D'Aprano schrieb am 22.08.2016 um 07:35: >> if sys.version < '3': >> import mymodule2 as mymodule >> else: >> import mymodule3 as mymodule > > This condition is going to fail

Re: Raw Data from Website

2016-08-23 Thread Steven D'Aprano
On Tuesday 23 August 2016 10:28, [email protected] wrote: > Hi, > > I am hoping someone is able to help me. > > Is there a way to pull as much raw data from a website as possible. The > webpage that I am looking for is as follows: > http://www.homepriceguide.com.au/Research/ResearchSeeFullL

Re: degrees and radians.

2016-08-23 Thread Steven D'Aprano
On Wednesday 24 August 2016 14:26, Gary Herron wrote: > Do you really need anything more complex than this? > > >>> toRadians = math.pi/180.0 > > >>> math.sin(90*toRadians) > 1.0 > > Perhaps I'm not understanding what you mean by "clunky", but this seems > pretty clean and simple to me. The

Re: Raw Data from Website

2016-08-24 Thread Steven D'Aprano
On Wednesday 24 August 2016 17:04, Bob Martin wrote: > in 764257 20160823 081439 Steven D'Aprano > wrote: >>There are many tutorials and examples of "screen scraping" or "web scraping" >>on the internet -- try reading them. It's not somethin

Re: What's the best way to minimize the need of run time checks?

2016-08-28 Thread Steven D'Aprano
On Sunday 28 August 2016 15:56, Juan Pablo Romero Méndez wrote: > 2016-08-27 21:30 GMT-07:00 Steve D'Aprano : [...] >> Now it is true that speaking in full generality, classes and types refer to >> different things. Or to be perhaps more accurate, *subclassing* and >> *subtyping* are different thi

Re: What's the best way to minimize the need of run time checks?

2016-08-28 Thread Steven D'Aprano
On Sunday 28 August 2016 15:29, Chris Angelico wrote: > On Sun, Aug 28, 2016 at 2:30 PM, Steve D'Aprano > wrote: >> But the author of this piece ignores that standard distinction and invents >> his own non-standard one: to him, classes are merely different >> representations of the same data. E.g

Re: Would like some thoughts on a grouped iterator.

2016-09-05 Thread Steven D'Aprano
On Monday 05 September 2016 18:46, Antoon Pardon wrote: > I need an interator that takes an already existing iterator and > divides it into subiterators of items belonging together. > > For instance take the following class, wich would check whether > the argument is greater or equal to the previ

Re: easy way to return a list of absolute file or directory path within a directory

2016-09-07 Thread Steven D'Aprano
in(directory,entry) for entry in os.listdir(directory)] -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Python reverse debugger

2016-09-13 Thread Steven D'Aprano
ugger is a debugger where you can go forward and backward in time. RevDB is designed to track down the annoying, hard-to- reproduce bug in your Python program. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hil

Re: Expression can be simplified on list

2016-09-13 Thread Steven D'Aprano
thiness is expected to always succeed, while iter() is not. You're perfectly entitled to dislike duck-typed truthiness. But that makes the majority of dynamically-typed languages (like Python, Javascript, Ruby, Lua and more) a bad fit for your way of thinking. -- Steven git gets e

Re: Expression can be simplified on list

2016-09-13 Thread Steven D'Aprano
x27;s entirely unambiguous ... > > <http://lwn.net/Articles/590299/> *shrug* And if somebody designed an iterator that behaved badly or surprisingly, would you conclude that the entire concept of iteration is therefore broken? The midnight gotcha was (it has now been fixed) a design bu

Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-13 Thread Steven D'Aprano
ot;the universe exists" to any of the of Atum/Ptah/El/Coatlicue/Ranginui/Vishnu/Yahweh/Pangu/Waheguru etc., regardless of which one you pick. (Unlike *our* divine revelation, which is clearly the truth, the whole truth, and nothing but the truth, *their* divine revolution is illusion, error

Re: Oh gods can we get any more off-topic *wink* [was Re: [Python-ideas] Inconsistencies]

2016-09-14 Thread Steven D'Aprano
earth is flat, then your view is wronger than both of them put together. http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm [1] Assuming that there are any frogs left by then. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofun

Re: Python inner function parameter shadowed

2016-09-14 Thread Steven D'Aprano
onfigure it to turn off selected warnings: https://www.jetbrains.com/help/pycharm/2016.1/disabling-and-enabling-inspections.html https://www.jetbrains.com/help/pycharm/2016.1/suppressing-inspections.html -- Steven git gets easier once you get the basic idea that branches are homeomorphic end

Re: Expression can be simplified on list

2016-09-14 Thread Steven D'Aprano
On Wednesday 14 September 2016 17:16, Rustom Mody wrote: > On Wednesday, September 14, 2016 at 10:23:12 AM UTC+5:30, Steven D'Aprano > wrote: >> And if somebody designed an iterator that behaved badly or surprisingly, >> would you conclude that the entire concept of iterat

Re: how to automate java application in window using python

2016-09-17 Thread Steven D'Aprano
ll, GUI apps interact with the user not by magic, but via an event queue of mouse movements, clicks, key presses, etc. This queue is entirely under the control of the computer, which means a program can simulate a user moving the mouse, clicking, pressing keys, etc. There's no magic here.

Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-17 Thread Steven D'Aprano
inct letter of the alphabet. https://en.wikipedia.org/wiki/Diaeresis_%28diacritic%29 As far as Python goes, if all you want to do is replace ö with oe and Ö into OE (or perhaps you should use Œ and œ?) then you can use str.replace or string.translate: mystring.replace("Ö", "OE")

Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-17 Thread Steven D'Aprano
-missing-dot-kills-two-people-puts-three- more-in-jail http://www.theinquirer.net/inquirer/news/1017243/cellphone-localisation-glitch As far as I know, no natural language has a dotted capital J, but there is a dotless ȷ although I'm not sure what language it is from. (Possibly just used i

Re: How to convert 'ö' to 'oe' or 'o' (or other similar things) in a string?

2016-09-18 Thread Steven D'Aprano
On Sunday 18 September 2016 17:51, Terry Reedy wrote: > On 9/18/2016 2:45 AM, Steven D'Aprano wrote: > >> It doesn't matter whether you call them "accent" like most people do, or >> "diacritics" as linguists do. > > I am a native born Ameri

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-19 Thread Steven D'Aprano
the module object is still alive. If you are absolutely sure there are no other references to the global variable and the module, then it sounds like a leak. Can you confirm that the gc is enabled? For a work-around, I can only suggest manually killing the global. What happens if you do this: de

Re: Another å, ä, ö question

2016-09-20 Thread Steven D'Aprano
d to use UTF-8 as the encoding, and put this in line 1 or line 2 of the file: # -*- coding: utf-8 -*- That will tell Python to read your file as UTF-8 instead of ASCII. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifo

Re: Python 3.5.1 C API, the global available available is not destroyed when delete the module

2016-09-20 Thread Steven D'Aprano
On Tuesday 20 September 2016 16:19, dl l wrote: > Hi Steven, > > Thanks for reply. > > I logged bug https://bugs.python.org/issue28202. I added more info in this > bug :). > > Yes, it's a workaround to set the global variables to None. But My app just > provide

Re: Data Types

2016-09-20 Thread Steven D'Aprano
>>>> type(False) > > > Are there any other data types that will give you type(A) or type(B) = 'bool'> besides True and False? No. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Refer to a numbered heading in ReST

2016-09-22 Thread Steven D'Aprano
and Sphinx? -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Pasting code into the cmdline interpreter

2016-09-22 Thread Steven D'Aprano
paste() function. For example: > > import sys > paste = lambda: exec(sys.stdin.read(), globals()) Nice! -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Nested for loops and print statements

2016-09-26 Thread Steven D'Aprano
your keyboard broken? Every time somebody bottom-posts without trimming, a pixie dies... -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Nested for loops and print statements

2016-09-26 Thread Steven D'Aprano
ntation Use only spaces, or only tabs, never both. If you use spaces for one line, then always use spaces. If you use tabs for one line, then always use tabs. > SyntaxError: inconsistent use of tabs and spaces in indentation Same as above. -- Steven git gets easier once you get the basic id

Re: Nested for loops and print statements

2016-09-27 Thread Steven D'Aprano
the OP, complete with tabs and spaces. > READ the error messages, they are important! Indeed. And *believe* the error messages. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mai

Re: what's the difference of Template.append(...) and Template.prepend(...) in pipes module

2016-09-28 Thread Steven D'Aprano
le? We don't know which module you are talking about, which makes it hard to give you a specific answer. -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: Why searching in a set is much faster than in a list ?

2016-09-28 Thread Steven D'Aprano
u need to look at 500 items before finding the one you are looking for. With a set or dict with 1000 items, on average you need to look at 1 item before finding the one you are looking for. And that is why sets and dicts are usually faster than lists. -- Steven git gets easier once you g

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steven D'Aprano
hing a lot, which avoids them being painfully slow. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Is there a way to change the closure of a python function?

2016-09-28 Thread Steven D'Aprano
appens simultaneously. So even infinite sums or products can be calculated instantly -- if they converge. So, yes, even functions that never return are functions. You just need to collapse all of infinite time into a single instant. -- Steven git gets easier once you get the basic idea that branch

Re: Expression can be simplified on list

2016-09-29 Thread Steven D'Aprano
rror etc > are raised? Because that would be less useful and more annoying. There are a set of behaviours which nearly all objects should define, and which are nearly always the same (or at least have a sensible default): __getattribute__ __getattr__ __setattr__ __delattr__ __str__ __repr

Re: Expression can be simplified on list

2016-09-29 Thread Steven D'Aprano
On Thursday 29 September 2016 18:45, Jussi Piitulainen wrote: > Steven D'Aprano writes: > > [- -] > >> What is this truthiness abstraction? It is the difference between >> "something" and "nothing". >> >> Values which represent nothi

Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe
Hi all, i've compiled python3.5 and all went fine, i find ./python and it works, most of the make test stuff is working my only problem is that i'm not able to find libpython.so am i missing somehting ? Thianks in advance -- https://mail.python.org/mailman/listinfo/python-list

Re: Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe
I fond this in the ./configuration help: * --enable-shared disable/enable building shared python library* so i tried: $configure --enabled-shard but i can't still find a library inside my build directory. On 2016-10-01 02:23, Steven Truppe wrote: Hi all, i've compiled

Re: Could find libpython.so after succesfull compilation.

2016-09-30 Thread Steven Truppe
Damn i'm so stupid... the files where in fron on of my eyes and i was just not able to find then .. On 2016-10-01 02:23, Steven Truppe wrote: Hi all, i've compiled python3.5 and all went fine, i find ./python and it works, most of the make test stuff is working my only problem is

Locals [was Re: unintuitive for-loop behavior]

2016-10-02 Thread Steven D'Aprano
7; if False: # convince the compiler to treat y as a local del y print(x) # => 'global' in everything print(y) # => 'local' in Jython/IronPython, UnboundLocalError in CPython -- Steven git gets easier once you get the basic idea that branches ar

Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-04 Thread Steven D'Aprano
e maximum time allotted) which may be long after their first suckle. Nevertheless, there are senses other than sight. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

OFF TOPIC mov is Turing complete

2016-10-11 Thread Steven D'Aprano
just this instruction (and a single unconditional branch at the end of the program to make nontermination possible), we demonstrate how an arbitrary Turing machine can be simulated. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submani

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

2016-10-12 Thread Steven D'Aprano
o be strict about it. The closer you get to 100% functional, the less you can use it. He reckons the sweet spot is about 85% functional: http://www.johndcook.com/blog/2010/04/15/85-functional-language-purity/ -- Steven git gets easier once you get the basic idea that branches are homeomorphic

Re: Scripting Help please

2016-10-13 Thread Steven D'Aprano
com He's posted code that doesn't look anything like Python code, and all but admitted to trolling us. I don't think we should be responding. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a H

Re: How make the judge with for loop?

2016-10-16 Thread Steven D'Aprano
what some of it probably does, because it looks like Python code, but the for-loops are complicated and weird. What do they do? It might help if you show the expected results. -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python-based monads essay part 2

2016-10-20 Thread Steven D'Aprano
hat the compiler can handle them as if they were functionally pure. It doesn't mean they *actually are* functionally pure -- obviously if you delete a file or print output to the screen or pause for the user to enter data, you're making changes of state to the outside world. So

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

2016-10-24 Thread Steven D'Aprano
specify a specific key, and ignore anything else... in which case, why not specify the Enter key? raw_input('Press the Enter key to continue... ') If you are doing something more complex, waiting on different keys to do different things, then you probably should use an existing te

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

2016-10-26 Thread Steven D'Aprano
-blocking keyboard input as a standard part of the language? Python has no "peek" and "poke" memory access commands either. It's not 1972 and programming has moved on. The utility of something like this feature is very low, the amount of effort needed for a cross-platfo

Re: cx_freeze_zipimporter_instance

2016-11-01 Thread Steven D'Aprano
On Wednesday 02 November 2016 14:55, [email protected] wrote: > can anybody help me in this problem... What problem? -- Steven git gets easier once you get the basic idea that branches are homeomorphic endofunctors mapping submanifolds of a Hilbert space. -- https://mail.python.

Re: constructor classmethods

2016-11-02 Thread Steven D'Aprano
ependency (the queue, in your example above) is a useful, Pythonic thing to do. Making it optional is even more Pythonic. But factoring out the call to Queue.Queue() into its own method just for the sake of OO purity is not very Pythonic, and *requiring* the caller to call this create() method is anti-Pythonic. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

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

2016-11-03 Thread Steven D'Aprano
zero. I think the chances of Guido accepting new list/dict methods for in place map and/or filter is a tiny bit higher than zero. > The reasonning for the need of a language-level approach is the need for an > efficient implementation that would support giving an arbitrary expression > and not only a function. We already have three of those: for-loops, list comprehensions, and map. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Steven D'Aprano
On Thursday 10 November 2016 17:43, [email protected] wrote: > On Thursday, November 10, 2016 at 1:09:31 AM UTC, Steve D'Aprano wrote: >> > > [snipped] > > Steven, there is no need to be rude or condescending. Indeed, and if I thought you were sincere, or knew

Re: Help me cythonize a python routine!

2016-11-09 Thread Steven D'Aprano
t > > os.listdir(collections.__path__[0]) > > since it's already there? I was working in the interactive interpreter, and it was easier and more convenient to copy the path from a previous line's output, than to type a new expression. -- Steven 299792.458 km/s — not

Re: N-grams

2016-11-10 Thread Steven D'Aprano
(lowercase only), there are 26**10 = 141167095653376 possible 10-grams. Where are you going to find a text that includes more than a tiny fraction of those? -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: if iter(iterator) is iterator

2016-11-13 Thread Steven D'Aprano
le: def __iter__(self): self.launch_missiles() return self In general, merely testing whether something is a certain kind of thing shouldn't actually run that thing's code. (That's not always possible. E.g. the thing's metaclass might launch miss

Access to the caller's globals, not your own

2016-11-13 Thread Steven D'Aprano
c do I need? globals() is no good, because it returns the library's global namespace, not the caller's. Any solution ought to work for CPython, IronPython and Jython, at a minimum. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: if iter(iterator) is iterator

2016-11-13 Thread Steven D'Aprano
t place. If the class inherits __iter__, and you want to over-ride it, you might try setting the child class __iter__ to None. That trick works for __hash__. It doesn't work for __iter__ in Python 3.3, but it might work in more recent versions. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

urllib.request giving unexpected results

2016-11-16 Thread Steven D'Aprano
#x27;/dev/stdin: PDF document, version 1.6\n' b'/dev/stdin: PDF document, version 1.6\n' If I just read from urllib.request, I get what appears to the naked eye to be the expected data: py> with urllib.request.urlopen(TEST_URL) as f: ... file = f.read() ... py> print(file[:100]) b

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Monday 14 November 2016 16:55, eryk sun wrote: > On Mon, Nov 14, 2016 at 5:20 AM, Steven D'Aprano > wrote: >> but what magic do I need? globals() is no good, because it returns the >> library's global namespace, not the caller's. >> >> Any solut

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Tuesday 15 November 2016 07:04, [email protected] wrote: > On Monday, November 14, 2016 at 12:21:00 AM UTC-5, Steven D'Aprano wrote: > >> Don't tell me to make SPAMIFY a parameter of the function. I know that. >> That's what I would normally do, but *oc

Re: __debug__ http://stackoverflow.com/questions/15305688/conditional-debug-statement-not-executed-though-debug-is-true

2016-11-16 Thread Steven D'Aprano
n by: > > 1. 'If you rebind __debug__, it can cause symptoms' What he means is, "I didn't test this code before running it, and I am wrong." You cannot rebind __debug__. >>> __debug__ = False File "", line 1 SyntaxError: can not assign to __debug__

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
On Tuesday 15 November 2016 15:55, Dan Sommers wrote: > On Mon, 14 Nov 2016 16:20:49 +1100, Steven D'Aprano wrote: > >> import library >> SPAMIFY = False # only affects this module, no other modules >> result = library.make_spam(99) > > I must be missing some

Re: help on "from deen import *" vs. "import deen"

2016-11-16 Thread Steven D'Aprano
esn't change the russia.president. Now: from russia import president is almost the same as: import russia as _tmp president = _tmp.president del _tmp But this is more complicated: from russia import * The star import has to work out all the visible public names, and create new variables for all of them. You don't need to understand how it does that, the details are not important. What is important is that the variables it creates are different from the variables living inside the russia module. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: Access to the caller's globals, not your own

2016-11-16 Thread Steven D'Aprano
n works is not important to the user. They only need to understand that the "scheme" parameter takes its value from the first found of: - an explicit argument - a global variable called "WHATEVER" - the library default which is pretty simple to understand and use. -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: __debug__ http://stackoverflow.com/questions/15305688

2016-11-16 Thread Steven D'Aprano
On Thursday 17 November 2016 02:22, eryk sun wrote: > On Wed, Nov 16, 2016 at 8:39 AM, Steven D'Aprano > wrote: >> On Wednesday 16 November 2016 16:21, Veek M wrote: >> >>> Trying to make sense of that article. My understanding of debug was >>> simple: &

Re: help on "from deen import *" vs. "import deen"

2016-11-17 Thread Steven D'Aprano
On Thursday 17 November 2016 17:48, [email protected] wrote: > Steven D'Aprano at 2016/11/17 12:06:19PM wrote: >> You understand how this works? > > Yes, thank you for your detail explanation. > >> import russia as _tmp >> president = _tmp.president

Re: What exactly is a python variable?

2016-11-17 Thread Steven D'Aprano
'x' handled? > Symbol Table lookup at compile time? No. Symbol table lookup at run time. For functions, you can access a copy of the symbol table with: locals() You can access the actual global symbol table (not a copy) with: globals() Every module has its own independent global

Clean way to return error codes

2016-11-20 Thread Steven D'Aprano
thing cleaner I can do, or do I just have to suck it up? -- Steven 299792.458 km/s — not just a good idea, it’s the law! -- https://mail.python.org/mailman/listinfo/python-list

Re: Clean way to return error codes

2016-11-21 Thread Steven D'Aprano
On Monday 21 November 2016 18:39, Jussi Piitulainen wrote: > Steven D'Aprano writes: [...] >> It's not awful, but I don't really like the look of all those >> try...except blocks. Is there something cleaner I can do, or do I just >> have to suck it up? >

<    20   21   22   23   24   25   26   27   28   29   >