Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 11:18 AM, Serhiy Storchaka wrote: > $ ./python -m timeit -s 'import sys; sys.modules["_functools"] = None; del > sys.modules["functools"]; from functools import lru_cache; f = > lru_cache(maxsize=None)(int)' -- 'f()' > 10 loops, best of 5: 3.39 usec per loop Interesting

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 10:02 AM, Ian Kelly wrote: > Fixed: > > $ python3 -m timeit -s 'from simple_cache import simple_cache; f = > simple_cache(int)' -- 'f()' > 100 loops, best of 3: 0.167 usec per loop > $ python3 -m timeit -s 'import sys; sys.mod

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:55 AM, Serhiy Storchaka wrote: > 03.08.17 18:36, Ian Kelly пише: >> >> The single variable is only a dict lookup if it's a global. Locals and >> closures are faster. >> >> def simple_cache(function): >> s

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:44 AM, wrote: > I hope you washed them! Yes, well as noted in my followup I was comparing pure-Python implementations, not the C implementation. -- https://mail.python.org/mailman/listinfo/python-list

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 9:36 AM, Ian Kelly wrote: > On Thu, Aug 3, 2017 at 8:35 AM, Paul Moore wrote: >> On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: >>> > _sentinel = object() >>> > _val = _sentinel >>> > def val(): >>>

Re: @lru_cache on functions with no arguments

2017-08-03 Thread Ian Kelly
On Thu, Aug 3, 2017 at 8:35 AM, Paul Moore wrote: > On Tuesday, 1 August 2017 15:54:42 UTC+1, t...@tomforb.es wrote: >> > _sentinel = object() >> > _val = _sentinel >> > def val(): >> > if _val is _sentinel: >> > # Calculate _val >> > return _val >> > >> > seems entirely sufficie

Re: Get list of attributes from list of objects?

2017-08-02 Thread Ian Kelly
On Wed, Aug 2, 2017 at 11:49 AM, Chris Angelico wrote: > On Thu, Aug 3, 2017 at 3:21 AM, Ian Pilcher wrote: >> Given a list of objects that all have a particular attribute, is there >> a simple way to get a list of those attributes? >> >> In other words: >> >> class Foo(object): >> def __

Re: Python 3 removes name binding from outer scope

2017-07-25 Thread Ian Kelly
On Tue, Jul 25, 2017 at 5:38 AM, Thomas Jollans wrote: > On 2017-07-25 09:28, Chris Angelico wrote: >> It actually does the equivalent of: >> >> finally: >> e = None > > I wonder why it would bother to load None... (as someone not very > familiar with Python at the bytecode level) If I may ha

Re: Write this accumuator in a functional style

2017-07-11 Thread Ian Kelly
On Tue, Jul 11, 2017 at 12:47 AM, Wolfgang Maier wrote: > On 07/11/2017 08:11 AM, Steven D'Aprano wrote: >> >> I have a colleague who is allergic to mutating data structures. Yeah, I >> know, he needs to just HTFU but I thought I'd humour him. >> >> Suppose I have an iterator that yields named tup

Re: Check Python version from inside script? Run Pythons script in v2 compatibility mode?

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 3:49 PM, wrote: > Is there any particular reason the Windows python does it that way? > Certainly it wouldn't be too difficult to include a "python2.exe" and > "python3.exe", even as symbolic links. Windows associates file types with applications by extension. When you

Re: Python3 : import

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 2:00 PM, Andrew Z wrote: > [az@hp tst1]$ python3 ./uno.py > Traceback (most recent call last): > File "./uno.py", line 1, in > from . import db > SystemError: Parent module '' not loaded, cannot perform relative import That error message is a bit confusing, but relat

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Fri, Jul 7, 2017 at 8:41 AM, Nathan Ernst wrote: > Looks like single expression statements are handled a bit differently than > multiple expression statements: > > Python 3.5.2 (default, Nov 17 2016, 17:05:23) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" fo

Re: About the implementation of del in Python 3

2017-07-07 Thread Ian Kelly
On Thu, Jul 6, 2017 at 12:56 PM, Nathan Ernst wrote: > In Python, "==" is not a reference equality operator (and I hate Java for > their misuse of the operator), so I absolutely disagree with using the Java > description to describe Python's "==" operator, primarily because, well, > it's wrong. Si

Re: About the implementation of del in Python 3

2017-07-06 Thread Ian Kelly
On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa wrote: > As a good example of the style I'm looking for, take a look at: > >https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html> Java reference types have basically the same concept of identity as Python objects, so I dug around to find

Re: Teaching the "range" function in Python 3

2017-06-29 Thread Ian Kelly
On Thu, Jun 29, 2017 at 2:57 PM, Irv Kalb wrote: > Now I am looking at the change in the range function. I completely > understand the differences between, and the reasons for, how range works > differently in Python 2 vs Python 3. The problem that I've run into has to > do with how to explai

Re: How to build a simple neural network in 9 lines of Python code

2017-06-27 Thread Ian Kelly
On Tuesday, June 27, 2017, Steve D'Aprano wrote: > On Wed, 28 Jun 2017 02:23 am, Sam Chats wrote: > > > > https://medium.com/technology-invention-and-more/how-to- > build-a-simple-neural-network-in-9-lines-of-python-code-cc8f23647ca1 > > > The derivative of the sigmoid curve given is completely w

Re: cdecimal.Decimal v. decimal.Decimal

2017-06-20 Thread Ian Kelly
On Tue, Jun 20, 2017 at 2:49 PM, Skip Montanaro wrote: > I'd not used the Decimal classes before, but some data I was receiving > from a database via pyodbc came that way. In writing some test cases, > I had a hard time making things work out. I eventually figure out what > was going on: > im

Re: Developers Who Use Spaces Make More Money!

2017-06-15 Thread Ian Kelly
On Thu, Jun 15, 2017 at 8:51 PM, Larry Martell wrote: > On Thu, Jun 15, 2017 at 6:35 PM, Christopher Reimer > wrote: >> One commentator on a tech website admonished programmers for wasting time by >> pressing the space bar four times instead of using tab. O_o > > Not in vi with > > set autoinden

Re: Cannot get any Python commands to work

2017-06-12 Thread Ian Kelly
On Mon, Jun 12, 2017 at 8:47 AM, David Marquand wrote: > I am trying to learn Django and cannot get easy_install to work. Python > working on PyDev fine. > > > PS C:\Windows\system32> python > Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit > (AMD64)] on win32 > Type "hel

Re: Psycopg2 pool clarification

2017-06-08 Thread Ian Kelly
On Thu, Jun 8, 2017 at 10:47 AM, Israel Brewster wrote: >> On Jun 7, 2017, at 10:31 PM, dieter wrote: >> >> israel writes: >>> On 2017-06-06 22:53, dieter wrote: >>> ... >>> As such, using psycopg2's pool is essentially >>> worthless for me (plenty of use for it, i'm sure, just not for me/my >>>

Re: Generator and return value

2017-06-07 Thread Ian Kelly
On Wed, Jun 7, 2017 at 10:00 AM, Rob Gaddi wrote: > > On 06/06/2017 11:13 PM, Frank Millman wrote: >> >> Hi all >> >> It would be nice to write a generator in such a way that, in addition to 'yielding' each value, it performs some additional work and then 'returns' a final result at the end. >> >>

Re: Circular iteration on tuple starting from a specific index

2017-06-01 Thread Ian Kelly
On Thu, Jun 1, 2017 at 4:14 AM, Gregory Ewing wrote: > guillaume.pau...@giome.fr wrote: >> >> def cycle_once(iterable, start): >> return chain(islice(iterable, start, None), islice(iterable, start)) This assumes that iterable is restartable, which is not the case if iterable is itself an iter

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Ian Kelly
On Wed, May 31, 2017 at 4:26 AM, Jon Ribbens wrote: > On 2017-05-31, Ian Kelly wrote: >> On Tue, May 30, 2017 at 4:57 PM, Jon Ribbens >> wrote: >>> A DB-API "cursor" is a database connection >> >> Baloney. Creating a cursor does not spawn a new

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Ian Kelly
It works just fine with every DB-API client I've used, including those which only fetch results as needed. cx_Oracle, for instance. It's not Python's fault if the underlying MySQL client interface is shitty. On Wed, May 31, 2017 at 6:29 AM, Jon Ribbens wrote: > On 2017-05-31, Peter Otten <__pete.

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-31 Thread Ian Kelly
On Wed, May 31, 2017 at 8:18 AM, Chris Angelico wrote: > Technically you CAN commit from the cursor: > > cur.connection.commit() Technically cur.connection is an optional extension. ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 4:57 PM, Jon Ribbens wrote: > On 2017-05-30, Ian Kelly wrote: >> On Tue, May 30, 2017 at 1:27 PM, Jon Ribbens >> wrote: >> A cursor is just a control structure for traversing over a result set. > > Exactly - so it makes no sense at all t

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 1:27 PM, Jon Ribbens wrote: > Indeed. As I say, I think perhaps the source of the confusion is that > DB-API cursors make no sense at all, rather than the problem being > transactions per se. > > It's almost as if DB-API was written by someone who had never seen > a databas

Re: Circular iteration on tuple starting from a specific index

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 10:25 AM, Beppe wrote: > hi all > > I've a tuple, something like > > x = ("A","B","C","D","E","F","G","H",) > > I would want to iterate on all tuple's elements > starting from a specific index > > > something like > > Python 2.7.9 (default, Jun 29 2016, 13:08:31) > [GCC 4.9

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 8:19 AM, Joseph L. Casale wrote: > -Original Message- > From: Python-list [mailto:python-list- > bounces+jcasale=activenetwerx@python.org] On Behalf Of Ian Kelly > Sent: Tuesday, May 30, 2017 8:12 AM > To: Python > Subject: Re: Python D

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 8:21 AM, Chris Angelico wrote: > On Wed, May 31, 2017 at 12:12 AM, Ian Kelly wrote: >> There's no difference I'm aware of in the implementations I've used, >> but having a consistent API does allow for constructions such as: >> >

Re: Python DB API - commit() v. execute("commit transaction")?

2017-05-30 Thread Ian Kelly
On Tue, May 30, 2017 at 7:29 AM, Skip Montanaro wrote: > Assuming the underlying database supports transactions, is there any > difference between calling the commit() method on the connection and > calling the execute method on the cursor with the "commit transaction" > statement? It seems a bit

Re: Dictionary order (Is it consistent up to py3.3 unless using -R or PYTHONHASHSEED is set)

2017-05-28 Thread Ian Kelly
On May 28, 2017 8:23 AM, "Jon Ribbens" wrote: > On 2017-05-28, Steve D'Aprano wrote: >> What exactly did you think I got wrong? > > 3.6 does preserve the dict order. It isn't a guarantee so may change > in future versions, but it is what 3.6 actually does. No, it's what CPython 3.6 actually does

Re: Verifiably better, validated Enum for Python

2017-05-24 Thread Ian Kelly
On Wed, May 24, 2017 at 8:49 PM, wrote: > On Tuesday, May 23, 2017 at 11:47:21 PM UTC-4, bream...@gmail.com wrote: >> Well that's what is says here https://github.com/ofek/venum so it must be >> true. Please move over Ethan, your time is up :-) >> >> Kindest regards. >> >> Mark Lawrence. > > He

Re: Verifiably better, validated Enum for Python

2017-05-24 Thread Ian Kelly
On Wed, May 24, 2017 at 4:11 PM, bartc wrote: > On 24/05/2017 15:31, Steve D'Aprano wrote: >> If you don't want to assign to a name, then >> just don't assign to it. No need to build support for constants into the >> language when you can trust the developer to Don't Do That. > > Yet the language

Re: Verifiably better, validated Enum for Python

2017-05-24 Thread Ian Kelly
On Wed, May 24, 2017 at 3:10 AM, Steve D'Aprano wrote: > The page says: > > venum provides an Enum that is actually just a namedtuple, No kidding. This is the entirety of the code for it: from collections import namedtuple def Enum(*args, **kwargs): fields, values = zip(*args) ret

Re: Hi everyone

2017-05-24 Thread Ian Kelly
On Wed, May 24, 2017 at 11:20 AM, Spaarwiel wrote: > > Hi there, i was always interested in coding but never took the time to learn it. > > So at age 34 i'm going to try and see if i can win this. > > Saw on a website this is good group page to come for help so i will def. be asking alot of questi

Re: How to install Python package from source on Windows

2017-05-18 Thread Ian Kelly
On Thu, May 18, 2017 at 1:29 PM, bartc wrote: > > On 18/05/2017 19:50, Chris Angelico wrote: > >> Now this, however, is more serious. Those warnings scare me, too. (I >> just tried it.) Instead of being "gcc is noisy", these are "your code >> is sloppy". These are exactly why I tell most people NO

Re: How to install Python package from source on Windows

2017-05-18 Thread Ian Kelly
On Thu, May 18, 2017 at 8:02 AM, bartc wrote: > > On 18/05/2017 12:37, Rhodri James wrote: >> >> but (a) you have no leg to stand on >> criticising configure scripts with that file, > > You think so? > > After the first 50 lines, there are no #includes, no #defines, no #ifs or #ifdefs, in fact I t

Re: How to install Python package from source on Windows

2017-05-17 Thread Ian Kelly
On Wed, May 17, 2017 at 2:52 PM, bartc wrote: > > On 17/05/2017 21:17, Michael Torrie wrote: >> >> On 05/17/2017 01:32 PM, bartc wrote: >>> >>> Sometimes, if there's a problem. But usually the code is doing something >>> sensible. The stuff in configure is complete gobbledygook (if anyone >>> does

Re: Practice Python

2017-05-10 Thread Ian Kelly
On Mon, May 8, 2017 at 3:50 AM, Lutz Horn wrote: > A strange way to publish code. Not if your goal is to drive traffic toward your YouTube channel. -- https://mail.python.org/mailman/listinfo/python-list

Re: Ten awesome things you are missing out on if you're still using Python 2

2017-05-08 Thread Ian Kelly
Overall a nice preso. I disagree with the slides on a few points. Slide 8: I don't see why I would want to refactor def f(a, b, *args): stuff into def f(*args): a, b, *args = args stuff The first one has a cleaner signature and is also shorter. Slide 55: What makes the "Better" ex

Re: Write a function group(L).

2017-04-21 Thread Ian Kelly
On Fri, Apr 21, 2017 at 2:01 PM, Mohammed Ahmed wrote: > Write a function group(L) that takes a list of integers. The function returns > a list of > two lists one containing the even values and another containing the odd > values. > > it is a python question This group will be happy to help you

Re: Goto Considered Harmful [was Re: Python and the need for speed]

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 12:51 PM, Nathan Ernst wrote: > Thank you for that Alan Kay quote. Brightened up my day. Since you also > mentioned COBOL, and this is a thread about "goto", reminded me of the > single most abhorrent thing I ever saw in COBOL (I had to convert a single > COBOL batch proces

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 4:59 PM, bartc wrote: > On 13/04/2017 22:58, Ian Kelly wrote: >> >> On Thu, Apr 13, 2017 at 3:27 PM, Dennis Lee Bieber >> wrote: >>> >>> On Thu, 13 Apr 2017 15:52:24 +0100, bartc declaimed the >>> following: >>&g

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 3:27 PM, Dennis Lee Bieber wrote: > On Thu, 13 Apr 2017 15:52:24 +0100, bartc declaimed the > following: > >>'goto' would be one easy-to-execute byte-code; no variables, objects or >>types to worry about. If implemented properly (with the byte-code >>compiler using a dedic

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 11:39 AM, Rustom Mody wrote: > My broader point (vive la Trump) was that if we learn to actively tolerate > people with views wildly far from ours, the world would be a better place. I fail to see how my comment "Functions and exceptions are considered 'bells and whistles'

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 11:25 AM, Mikhail V wrote: > On 13 April 2017 at 18:48, Ian Kelly wrote: >> On Thu, Apr 13, 2017 at 10:23 AM, Mikhail V wrote: >>> Now I wonder, have we already collected *all* bells and whistles of Python >>> in these two examples, or

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 11:13 AM, Rustom Mody wrote: > What to do?? > Ask Trump? > [I guess we now need a Godwin 2.0 with :s/Hitler/Trump ] Not even close. Whatever one's opinion may be of Trump, he hasn't murdered millions of people. -- https://mail.python.org/mailman/listinfo/python-list

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 10:23 AM, Mikhail V wrote: > Now I wonder, have we already collected *all* bells and whistles of Python > in these two examples, or is there something else for expressing trivial > thing. Functions and exceptions are considered "bells and whistles"? -- https://mail.pytho

Re: "Goto" statement in Python

2017-04-13 Thread Ian Kelly
On Thu, Apr 13, 2017 at 8:52 AM, bartc wrote: > On 13/04/2017 15:35, Chris Angelico wrote: >> Personally, I can't remember the last time I yearned for "goto" in >> Python, and the only times I've ever wished for it or used it in other >> languages have been multi-loop breaks or "for...else" blocks

Re: Merging multiple sorted sequences.

2017-04-12 Thread Ian Kelly
On Wed, Apr 12, 2017 at 4:44 PM, Ian Kelly wrote: > On Wed, Apr 12, 2017 at 4:15 PM, Erik wrote: >> while len(items) > 1: >> items.sort(key=lambda item: item[0]) > > This might be okay since Timsort on an already-sorted list should be > O(n). But there&#x

Re: Merging multiple sorted sequences.

2017-04-12 Thread Ian Kelly
On Wed, Apr 12, 2017 at 4:15 PM, Erik wrote: > Hi. > > I need to be able to lazily merge a variable number of already-sorted(*) > variable-length sequences into a single sorted sequence. The merge should > continue until the longest sequence has been exhausted. > > (*) They may in practice be a la

Re: Python and the need for speed

2017-04-12 Thread Ian Kelly
On Tue, Apr 11, 2017 at 8:08 PM, Steve D'Aprano wrote: > Comprehensions may have been around for a decade or two in Haskell, but most > older languages don't have them. I'm pretty sure Java doesn't. Java does not have comprehensions per se, but the Streams API introduced in Java 8 is similar in c

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 8:24 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:19:27 μ.μ. UTC+3, ο χρήστης Ian έγραψε: > >> You need to change the placeholders back. The poster who told you to >> replace them was misinformed. > > okey altered them back to > > cur.execute('''UPDATE visitors

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 8:07 AM, Νίκος Βέργος wrote: > Τη Κυριακή, 26 Μαρτίου 2017 - 5:04:27 μ.μ. UTC+3, ο χρήστης INADA Naoki This > error came from MySQL. If there are no logs in error_log, it's >> your configuration issue. >> >> See https://dev.mysql.com/doc/refman/5.7/en/update.html for Upda

Re: Escaping confusion with Python 3 + MySQL

2017-03-26 Thread Ian Kelly
On Sun, Mar 26, 2017 at 7:39 AM, MeV wrote: > On Sunday, March 26, 2017 at 6:34:30 AM UTC-7, Νίκος Βέργος wrote: >> with import cgitb; cgitb.enable() >> >> ProgrammingError(1064, "You have an error in your SQL syntax; check the >> manual that corresponds to your MariaDB server version for the rig

Re: Who are the "spacists"?

2017-03-25 Thread Ian Kelly
On Tue, Mar 21, 2017 at 7:28 PM, Ben Finney wrote: > Grant Edwards writes: > >> Question: is it still successfull trolling if we all knew that was the >> intent and are just playing along for the entertainment value? > > Yes, it creates more noise and drives away signal from people who don't > wa

Re: Subprocess .wait() is not waiting

2017-03-24 Thread Ian Kelly
n Sat, Mar 25, 2017 at 6:40 AM, Ian Kelly wrote: >>> > > If that's what's happening it would be a bug. Are you sure that the >>> > > other program isn't simply crashing or otherwise failing to complete? >>> > > >>> > >>

Re: Surprised by the lack of constant folding

2017-03-24 Thread Ian Kelly
On Fri, Mar 24, 2017 at 1:35 PM, Tim Chase wrote: > Playing around, I came across the following > > $ python3 > Python 3.4.2 (default, Oct 8 2014, 10:45:20) > [GCC 4.9.1] on linux > Type "help", "copyright", "credits" or "license" for more information. from dis import dis def f(x): > ..

Re: Subprocess .wait() is not waiting

2017-03-24 Thread Ian Kelly
On Fri, Mar 24, 2017 at 12:42 PM, adam.c.bernier wrote: > Hi, > > I am on Windows 7. Python 2.7 > > I'm trying to have a program run another program using `subprocess.Popen` > > import subprocess as sp > > args = shlex.split(args) > proc = sp.Popen(args,stdout=sp.PIPE,stderr=sp.PIPE) >

Re: Dynamically replacing an objects __class__; is it safe?

2017-03-16 Thread Ian Kelly
On Thu, Mar 16, 2017 at 7:56 PM, Dennis Lee Bieber wrote: > On Fri, 17 Mar 2017 10:03:04 +1300, Gregory Ewing > declaimed the following: > >>Chris Angelico wrote: >>> I just asked my father, and he believes that a satellite DOES fly, on >>> the basis that it is perpetually falling and forever mis

Re: Python3.6 a little conundrum

2017-03-14 Thread Ian Kelly
On Tue, Mar 14, 2017 at 2:25 PM, Gilmeh Serda wrote: > Thanks. I guess I could get a new(-er) copy when that day comes and redo > all this. I trust 3.6.0 won't be the last one. :) As it says in the Book of Armaments, Chapter 2, verses 9–21: """ Three shall be the number thou shalt count, and the

Re: https://pygame.org/

2017-03-10 Thread Ian Kelly
On Fri, Mar 10, 2017 at 4:01 AM, René Dudfield wrote: > https://pygame.org/ Did you have a question, or something that you wish to discuss with regard to pygame? -- https://mail.python.org/mailman/listinfo/python-list

Re: concurrent futures, async futures and await

2017-02-23 Thread Ian Kelly
On Thu, Feb 23, 2017 at 9:44 AM, Nagy László Zsolt wrote: > >> My guess: because asyncio wouldn't know what to do with a >> concurrent.futures.Future. > I see that as a problem. >> >> The tornado docs say that "You can also use >> tornado.gen.convert_yielded to convert anything that would work wit

Re: concurrent futures, async futures and await

2017-02-22 Thread Ian Kelly
On Wed, Feb 22, 2017 at 12:50 PM, Nagy László Zsolt wrote: > > I'm in a situation where I would like to refactor some code to use > native coroutine functions (aync def) instead of "normal" coroutines > that use yield. Most of the code is asnyc, but some of the operations > are performed in differ

Re: python decorator

2017-02-22 Thread Ian Kelly
On Wed, Feb 22, 2017 at 8:16 AM, Pavol Lisy wrote: > Maybe this technique could be reusable (and maybe part of functools?) > > With this decorator: > > def wrap_args(decorator): > def decor_out(*args, **kwargs): > def decor_in(func): > return decorator(func,

Re: Python3 using requests to grab HTTP Auth Data

2017-02-02 Thread Ian Kelly
On Wed, Feb 1, 2017 at 5:22 PM, Νίκος Βέργος wrote: > > # Give user the file requested > > print(''' content="5;url=http://superhost.gr/data/files/%s";>''' % realfile) > > authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' ) > print( authuser ) >

Re: Python3 using requests to grab HTTP Auth Data

2017-02-01 Thread Ian Kelly
On Wed, Feb 1, 2017 at 2:51 PM, Νίκος Βέργος wrote: > Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 11:41:28 μ.μ. UTC+2, ο χρήστης Michael > Torrie έγραψε: >> On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: >> > as well as input() for both user & pass combo but iam not getting in >> > chrome the basic pop-up HTT

Re: Python doesn't catch exceptions ?

2017-02-01 Thread Ian Kelly
On Wed, Feb 1, 2017 at 8:11 AM, Ivo Bellin Salarin wrote: > This code generates instead the messages: > ``` > ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError, > defined in server/libs/googleapiclient/errors.pyc. we are in > /Users/nilleb/dev/gae-sample-project/app > ERROR 47

Re: What are your opinions on .NET Core vs Python?

2017-01-31 Thread Ian Kelly
On Jan 30, 2017 8:00 PM, "Michael Torrie" wrote: > In any case, partial classes seems like a misfeature of C# to me but > apparently they are used when making Windows Forms GUI-based apps. > Apparently VS autogenerates the class that backs the form, and then the > developer creates a partial class

Re: What are your opinions on .NET Core vs Python?

2017-01-31 Thread Ian Kelly
On Jan 30, 2017 11:32 PM, "Gregory Ewing" wrote: > That's the thing I find most frustrating about both C# and Java, > the lack of anything like Python's "from ... import ...". You get > a choice of either effectively doing "import *" on the contents > of a whole class and polluting your namespace,

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 6:07 PM, "Steve D'Aprano" wrote: > Hey Ian, > > Your news reader or mail client has stopped quoting the text you are > quoting, so it appears as if you have written it. > > See: > > https://mail.python.org/pipermail/python-list/2017-January/719015.html Well, nuts. It looks fine in

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 1:32 AM, "Irv Kalb" wrote: I teach intro to programming using Python. In my first assignment, students are asked to assign variables of different types and print out the values. One student (who really did not understand Booleans) turned in the following for his/her interpretati

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 2:00 AM, "Chris Angelico" wrote: (Interestingly, Ellipsis is not included in that.) Perhaps because it's rather unusual for a program to depend upon the value of Ellipsis. -- https://mail.python.org/mailman/listinfo/python-list

Re: Need reviews for my book on introductory python

2017-01-27 Thread Ian Kelly
On Jan 27, 2017 2:13 PM, "bob gailer" wrote: On 1/26/2017 8:05 PM, Sandeep Nagar wrote: > Hi > > As I mentioned, a scaled down version is available for free at > bookmuft.Com which can be used to judge in this case. > Maybe I am blind, but I don't see any mention of bookmuft.Co. I pulled up th

Re: With class as contextmanager

2017-01-24 Thread Ian Kelly
On Tue, Jan 24, 2017 at 2:31 PM, This Wiederkehr wrote: > Hellou > > having a class definition: > > class Test(): > > @classmethod > def __enter__(cls): > pass > > @classmethod > def __exit__(cls, exception_type, execption_value, callback): > pass > > now using this as a contextmanager doe

Re: Python, asyncio, and systemd

2017-01-17 Thread Ian Kelly
On Tue, Jan 17, 2017 at 9:57 AM, Chris Angelico wrote: > If I write a web server using asyncio (and the aiohttp package), I can > spin up the server with: > > await loop.create_server(app.make_handler(), "0.0.0.0", 8080) > > This works fine for a high port, but if I want to bind to port 80, I > ne

Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread Ian Kelly
On Jan 13, 2017 3:33 PM, wrote: The issue I am having is that when i enter the sentinel value of QUIT, it gets initialized as the name and printed out. How can I get around this? I hope this makes sense. Hard to say for certain without seeing your code, but the most likely cause of this is th

Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 11:07 AM, BartC wrote: > Even when it turns out that the actual code on github is 1000 lines rather > than 500! Maybe it grew a bit since the 500 lines was quoted. I assume they're excluding blank lines, comments and docstrings. And I don't know whether the 500 lines is a

Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 3:46 AM, Steve D'Aprano wrote: > > http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html Neat. But not really surprising IMO that it can fit into 500 lines, since it doesn't handle compiling Python into bytecode (which is the hard part) and doesn't includ

Re: Is there an peekable similar to peekable but in additional allowing one to put some data to it?

2017-01-11 Thread Ian Kelly
On Wed, Jan 11, 2017 at 10:07 AM, Ian Kelly wrote: > On Wed, Jan 11, 2017 at 8:51 AM, Peng Yu wrote: >> Hi, peekable from more-itertools only allow peeking an iterator. But >> sometimes, one may want to take a look at an element, manipulate it, >> then put it back to the

Re: Is there an peekable similar to peekable but in additional allowing one to put some data to it?

2017-01-11 Thread Ian Kelly
On Wed, Jan 11, 2017 at 8:51 AM, Peng Yu wrote: > Hi, peekable from more-itertools only allow peeking an iterator. But > sometimes, one may want to take a look at an element, manipulate it, > then put it back to the iterator. Is there a class in python that can > help do this? Not that I'm aware

Re: learning and experimenting python.

2017-01-02 Thread Ian Kelly
On Jan 2, 2017 10:57 AM, "Wildman via Python-list" wrote: On Sun, 01 Jan 2017 23:02:34 -0800, einstein1410 wrote: > I really don't care the person like you. > Leave my posts, if don't like it. > Why wasting your as well as my time. > Just get lost man, or shut up. [Obscene gesture trimmed] Way

Re: learning and experimenting python.

2017-01-01 Thread Ian Kelly
On Mon, Jan 2, 2017 at 12:15 AM, Ian Kelly wrote: > Since they're unlikely to do that however, Then again, I see that einstein1410 made a couple of rather aggressive posts 11 hours ago that haven't made it to my email, so maybe he did manage to get himself banned. -- https://ma

Re: learning and experimenting python.

2017-01-01 Thread Ian Kelly
On Sun, Jan 1, 2017 at 11:30 AM, Grant Edwards wrote: > On 2016-12-31, Ian Kelly wrote: >> On Dec 31, 2016 3:12 AM, wrote: >> >> That's true. >> >> Please include quoted context in your replies. I have no idea who or what >> you're respon

Re: New re feature in 3.6: local flags and example use

2017-01-01 Thread Ian Kelly
On Sun, Jan 1, 2017 at 8:25 PM, Terry Reedy wrote: \> 3.6 added syntax for 'local flags'. > ''' > (?imsx-imsx:...) > > (Zero or more letters from the set 'i', 'm', 's', 'x', optionally > followed by '-' followed by one or more letters from the same set.) The > letters set or removes the corres

Re: learning and experimenting python.

2016-12-31 Thread Ian Kelly
On Dec 31, 2016 3:12 AM, wrote: That's true. Please include quoted context in your replies. I have no idea who or what you're responding to. -- https://mail.python.org/mailman/listinfo/python-list

Re: learning and experimenting python.

2016-12-31 Thread Ian Kelly
On Dec 31, 2016 1:48 AM, "mm0fmf" wrote: On 30/12/2016 17:50, einstein1...@gmail.com wrote: > Hello everyone, > I am the new comer and learner of python. > I have a doubt that when I type python and press enter it shows a prompt > like > >> But why it is >>> ? > Is there any special reason?

Re: Problem with running python 3.6.0 on a 32 bit windows 7 ultimate operating system.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 10:53 PM, Sagar Utlas wrote: > I am new to python, I've been using C++ as as a student till last 3 years. > To expand my knowledge, I installed Python 3.6.0 and when tried to open it, > a pop up window appeared saying- "The program can't start because > api-ms-win-crt-runti

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 6:05 PM, wrote: > But in his website, he recommended that post your questions here, he will > answer it. > But still as you told me I will send him an personal e-mail. This is a good place for asking questions about Python, but you should know that Guido himself doesn't

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Dec 30, 2016 4:42 PM, wrote: Yes, I am not confusing you all, rather I thought that this is the best place to solve any doubts, soy only question for you is Why python uses >>> instead of >, or any other special characters? Do you know about this, if yes then please answer it. I will be so mu

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 11:50 AM, wrote: > Hello everyone, > I am the new comer and learner of python. > I have a doubt that when I type python and press enter it shows a prompt like > But why it is >>> ? > Is there any special reason? > Why it is not setted as @,& or any other special chara

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:43 PM, Ian Kelly wrote: > On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell > wrote: >> >> I have a list containing a list of strings that I want to sort >> numerically by one of the fields. I am doing this: >> >> sorted(rows, ke

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell wrote: > > I have a list containing a list of strings that I want to sort > numerically by one of the fields. I am doing this: > > sorted(rows, key=float(itemgetter(sortby))) I'm guessing that you left out a lambda here since the key argument takes a

Re: Metaclasses - magic functions

2016-12-23 Thread Ian Kelly
On Fri, Dec 23, 2016 at 5:14 AM, Mr. Wrobel wrote: > Hi,thanx for answers, let's imagine that we want to add one class attribute > for newly created classess with using __init__ in metaclass, here's an > example: > > #!/usr/bin/env python > > class MetaClass(type): > # __init__ manipulation: >

Re: US/Eastern offset

2016-12-22 Thread Ian Kelly
On Thu, Dec 22, 2016 at 4:19 PM, Ian Kelly wrote: > On Thu, Dec 22, 2016 at 2:49 PM, Skip Montanaro > wrote: >> In a small application I realized I needed all my timestamps to have >> timezone info. Some timestamp strings come in with no TZ markings, but >> I know th

Re: US/Eastern offset

2016-12-22 Thread Ian Kelly
On Thu, Dec 22, 2016 at 2:49 PM, Skip Montanaro wrote: > In a small application I realized I needed all my timestamps to have > timezone info. Some timestamp strings come in with no TZ markings, but > I know they are US/Eastern. so, I built one: > import pytz tz = pytz.timezone("US/Easte

Re: Metaclasses - magic functions

2016-12-20 Thread Ian Kelly
On Tue, Dec 20, 2016 at 2:04 PM, Mr. Wrobel wrote: > Hi, > > Quick question, can anybody tell me when to use __init__ instead of __new__ > in meta programming? > > I see that __new__ can be used mostly when I want to manipulate with class > variables that are stored into dictionary. > > But when t

Re: Python constructors have particular semantics, and ‘Foo.__init__’ doesn't qualify

2016-12-15 Thread Ian Kelly
On Thu, Dec 15, 2016 at 11:05 AM, Terry Reedy wrote: > On 12/14/2016 11:14 PM, Thomas 'PointedEars' Lahn wrote: > >> According to >> , >> “Foo.__init__” is _not_ an instance method. Were it an instance >> method, the following would

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Ian Kelly
On Wed, Dec 14, 2016 at 12:53 PM, Chris Angelico wrote: > On Thu, Dec 15, 2016 at 6:27 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> asyncio.spin_off(parallel()) # ??? >>> >>> [...] >>> >>> What code should go on the "???" line to accomplish this? >> >> asyncio.ensure_future(parallel()

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