Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
Excellent, thank you. http://bugs.python.org/issue14573 -alfred -- https://mail.python.org/mailman/listinfo/python-list

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 4:05 PM, Alfred Morgan wrote: > On Wednesday, October 1, 2014 3:55:19 PM UTC-7, Chris Angelico wrote: >> At some point, you'll have to port your patch to the latest codebase > > Okay, done. > > https://github.com/Zectbumo/cpython/compare/master > > Iterators for JSON is now

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Wednesday, October 1, 2014 3:55:19 PM UTC-7, Chris Angelico wrote: > At some point, you'll have to port your patch to the latest codebase Okay, done. https://github.com/Zectbumo/cpython/compare/master Iterators for JSON is now Python 3 ready. -- https://mail.python.org/mailman/listinfo/pytho

Re: Obscuring Python source from end users

2014-10-01 Thread Marko Rauhamaa
Dan Stromberg : > On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano >> Yes. Distribute the pyc files only. > > Yes, this is the way it's usually done. Has the .pyc file format stabilized? A decade ago, my employer shipped an application as .pyc files but had to ship the matching CPython binary wit

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Travis Griggs
Sent from my iPhone > On Oct 1, 2014, at 04:12, Peter Otten <__pete...@web.de> wrote: > > `lambda` is just a fancy way to define a function inline Not sure "fancy" is the correct adjective; more like syntactic tartness (a less sweet version of syntactic sugar). :) -- https://mail.python.org

Re: Function passed as an argument returns none

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 12:29 PM, Rustom Mody wrote: > So by now you know there are 2 kinds of return: > > So the morals in short: > > 1. Stick to the return that works -- python's return statement -- > and avoid the return that seems to work -- the print statement Please. There are not two types

Re: Function passed as an argument returns none

2014-10-01 Thread Rustom Mody
On Thursday, October 2, 2014 4:07:44 AM UTC+5:30, Shiva wrote: > Hi, > I am learning Python (version 3.4) strings.I have a function that takes in a > parameter and prints it out as given below. > def donuts(count): > if count <= 5: > print('Number of donuts: ',count) > else: > print('N

Error from pandas.io.data import DataReader

2014-10-01 Thread ryanshuell
I am trying to run this snippet of code. from pandas.io.data import DataReader from pandas import Panel, DataFrame import datetime start = datetime.datetime(2010, 1, 1) end = datetime.datetime(2013, 1, 27) with open('dow.txt') as f: symbols = f.read().splitlines() # ['AAPL', 'GLD', 'SPX',

Re: Function passed as an argument returns none

2014-10-01 Thread Denis McMahon
On Wed, 01 Oct 2014 22:37:13 +, Shiva wrote: > Hi, > I am learning Python (version 3.4) strings.I have a function that takes > in a parameter and prints it out as given below. > > def donuts(count): > if count <= 5: > print('Number of donuts: ',count) > else: > print('Number of do

Re: Function passed as an argument returns none

2014-10-01 Thread Mark Lawrence
On 01/10/2014 23:37, Shiva wrote: Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count <= 5: print('Number of donuts: ',count) else: print('Number of donuts: many') return It

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 8:01 AM, Alfred Morgan wrote: > On Wednesday, October 1, 2014 6:07:23 AM UTC-7, Chris Angelico wrote: >> On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: >> > What do you think now? >> >> I think that you're adding features to Python 2.7, which isn't getting >> new featu

Re: Function passed as an argument returns none

2014-10-01 Thread Chris Kaynor
Chris On Wed, Oct 1, 2014 at 3:37 PM, Shiva wrote: > Hi, > I am learning Python (version 3.4) strings.I have a function that takes in > a > parameter and prints it out as given below. > > def donuts(count): > if count <= 5: > print('Number of donuts: ',count) > else: > print('Number

Re: Function passed as an argument returns none

2014-10-01 Thread Andrew Berg
On 2014.10.01 17:37, Shiva wrote: > Only 'None' gets passed on to parameter 'got' instead of the expected value > of 4. > Any idea why 'None' is getting passed even though calling the donuts(4) > alone returns the expected value? donuts() prints what you tell it to ("Number of donuts: 5"), and then

Function passed as an argument returns none

2014-10-01 Thread Shiva
Hi, I am learning Python (version 3.4) strings.I have a function that takes in a parameter and prints it out as given below. def donuts(count): if count <= 5: print('Number of donuts: ',count) else: print('Number of donuts: many') return It works fine if I call donuts(5) It retu

Re: Obscuring Python source from end users

2014-10-01 Thread Dan Stromberg
On Mon, Sep 29, 2014 at 4:47 AM, Steven D'Aprano wrote: > norman.i...@gmail.com wrote: > >> Hello list >> >> Python 3.4 applies. >> >> I have a project that involves distributing Python code to users in an >> organisation. Users do not interact directly with the Python code; they >> only know this

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Wednesday, October 1, 2014 6:07:23 AM UTC-7, Chris Angelico wrote: > On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: > > What do you think now? > > I think that you're adding features to Python 2.7, which isn't getting > new features. That won't be merged into trunk. Does your patch apply

Re: Clearing globals in CPython

2014-10-01 Thread Terry Reedy
On 10/1/2014 12:00 PM, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. As you discovered, this reduces the interpreter to a pure syntax machine

Re: Clearing globals in CPython

2014-10-01 Thread Mark Lawrence
On 01/10/2014 17:00, Steven D'Aprano wrote: Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. I expected that global variables would be all lost, but built-ins would rem

Re: Restarting Python

2014-10-01 Thread Terry Reedy
On 10/1/2014 10:47 AM, Steven D'Aprano wrote: Inside the interactive interpreter, I can restart the interpreter with four keystrokes: - Ctrl-D - UP-ARROW - ENTER Ctrl-D exits Python and returns me to the shell, UP-ARROW fetches the previous command ("python"), and ENTER runs that command. On W

Re: Python 3.4.1 installer on Mac links Python to old Tcl/Tk

2014-10-01 Thread Ned Deily
In article , "Peter Tomcsanyi" wrote: > "Ned Deily" wrote in message > news:nad-d2ddcb.14070824062...@news.gmane.org... > It's October... > So I tried Python 3.4.2rc1 and it seems that it still links to Tk 8.5 on > Mac. > Does it mean that there is no plan to link to Tk 8.6 in Python 3.4.2 on

Re: Clearing globals in CPython

2014-10-01 Thread Peter Otten
Steven D'Aprano wrote: > Out of curiosity, I ran: > > globals().clear() > > in the interactive interpreter. It broke much more than I expected! > Built-ins were no longer available, and import stopped working. > > I expected that global variables would be all lost, but built-ins would > remain,

Re: Clearing globals in CPython

2014-10-01 Thread Chris Kaynor
On Wed, Oct 1, 2014 at 9:14 AM, Chris Angelico wrote: > On Thu, Oct 2, 2014 at 2:00 AM, Steven D'Aprano > wrote: > > Obviously the easiest way to recover is to exit the current session and > > restart it, but as a challenge, can we recover from this state? > > Oooh interesting. This is kinda lik

Re: how to parse standard algebraic notation

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 2:45 AM, Steven D'Aprano wrote: > Code for evaluating mathematical expressions are very common, if you google > for "expression parser" I am sure you will find many examples. Don't limit > yourself to Python code, you can learn from code written in other languages > too, e.g

Re: how to parse standard algebraic notation

2014-10-01 Thread Steven D'Aprano
math math wrote: > Hi, > > I am trying to learn Python while solving exercises. > > I want to basically write a program that inputs a polynomial in standard > algebraic notation and outputs its derivative. > > I know that I need to get the exponent somehow, but I am not sure how to > accomplish

Re: Python code in presentations

2014-10-01 Thread Jean-Michel Pichavant
- Original Message - > From: "Wolfgang Keller" > To: python-list@python.org > Sent: Wednesday, 1 October, 2014 11:42:34 AM > Subject: Re: Python code in presentations > > > Right now the method I'm using is write the code in notepad++, use > > a > > plugin (NppExport) to copy paste code i

Re: Clearing globals in CPython

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 2:00 AM, Steven D'Aprano wrote: > Obviously the easiest way to recover is to exit the current session and > restart it, but as a challenge, can we recover from this state? Oooh interesting. This is kinda like breaking out of a sandbox, and I know there are people here who a

Clearing globals in CPython

2014-10-01 Thread Steven D'Aprano
Out of curiosity, I ran: globals().clear() in the interactive interpreter. It broke much more than I expected! Built-ins were no longer available, and import stopped working. I expected that global variables would be all lost, but built-ins would remain, since they don't live in the global names

Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?

2014-10-01 Thread Chris Angelico
On Thu, Oct 2, 2014 at 12:49 AM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> I'd agree, where "trivial limits" is defined by each individual item. >> Going with straight Python code is fine for huge projects with long >> config files, as long as each config entry is itself simple. You even

Re: Restarting Python

2014-10-01 Thread Steven D'Aprano
Seymore4Head wrote: > Since the developers of Python decided to make Python 3 non backward > compatible, I can't help but wonder why they don't think a command to > restart would be a useful addition? Possibly because it isn't a useful addition? Or maybe they just never thought of it. But more li

Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?

2014-10-01 Thread Steven D'Aprano
Chris Angelico wrote: > I'd agree, where "trivial limits" is defined by each individual item. > Going with straight Python code is fine for huge projects with long > config files, as long as each config entry is itself simple. You even > get a form of #include: "from otherfile import *". I would

Re: Restarting Python

2014-10-01 Thread Rustom Mody
On Wednesday, October 1, 2014 6:39:11 PM UTC+5:30, Steven D'Aprano wrote: > Terry Reedy wrote: > > Python does not have 'commands'. > Terry, even experienced Python developers sometimes describe functions and > statements as "commands", e.g. "Use the print command to display results". > I think w

Re: Python 3.4.1 installer on Mac links Python to old Tcl/Tk

2014-10-01 Thread Kevin Walzer
On 10/1/14, 7:51 AM, Peter Tomcsanyi wrote: "Ned Deily" wrote in message news:nad-d2ddcb.14070824062...@news.gmane.org... The easiest option would be a downloadable package that would allow the default python.org 8.5-linked _tkinter to be overridden with an 8.6 version. There may be some news

Re: Restarting Python

2014-10-01 Thread Steven D'Aprano
Terry Reedy wrote: > Python does not have 'commands'. Terry, even experienced Python developers sometimes describe functions and statements as "commands", e.g. "Use the print command to display results". I think we can cut a beginner like Seymore a bit of slack for misusing terminology. -- Stev

Re: JSON-encoding very long iterators

2014-10-01 Thread Chris Angelico
On Wed, Oct 1, 2014 at 8:13 PM, Alfred Morgan wrote: > I added a stream flag (off by default) and also added file streaming (thanks > for the idea). > > https://github.com/Zectbumo/cpython/compare/2.7 > > What do you think now? I think that you're adding features to Python 2.7, which isn't getti

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread cl
Joel Goldstick wrote: > On Wed, Oct 1, 2014 at 5:58 AM, wrote: > > I have a dictionary as follows:- > > > > { > > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', > > conv=6834.374834509803, > Description=u'Starter Amps'), > > u'LeisureVolts': Row(id=1, ain=u'AIN0', name=u'Leisur

Re: how to parse standard algebraic notation

2014-10-01 Thread Marco Buttu
On 01/10/2014 09:01, math math wrote: What would be a good starting strategy for writing a program to take the derivative of a polynomial expression, such as this below?: "x**3 + x**2 + x + 1" You can look at sympy: >>> from sympy import * >>> equation = simplify("x**3 + x**2 + x + 1") >>> e

Re: how to parse standard algebraic notation

2014-10-01 Thread Marco Buttu
On 01/10/2014 09:01, math math wrote: What would be a good starting strategy for writing a program to take the derivative of a polynomial expression, such as this below?: "x**3 + x**2 + x + 1" You can look at sympy: >>> from sympy import * >>> equation = simplify("x**3 + x**2 + x + 1") >>> eq

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread cl
Joel Goldstick wrote: > On Wed, Oct 1, 2014 at 6:45 AM, wrote: > > Peter Otten <__pete...@web.de> wrote: > >> c...@isbd.net wrote: > >> > >> > I have a dictionary as follows:- > >> > > >> > { > >> > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', > >> > conv=6834.374834509803, Desc

Re: how to parse standard algebraic notation

2014-10-01 Thread math math
Thanks a lot, I will give this a shot. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.4.1 installer on Mac links Python to old Tcl/Tk

2014-10-01 Thread Peter Tomcsanyi
"Ned Deily" wrote in message news:nad-d2ddcb.14070824062...@news.gmane.org... The easiest option would be a downloadable package that would allow the default python.org 8.5-linked _tkinter to be overridden with an 8.6 version. There may be some news on that front in the near future. It's Octo

Re: SNI support in python 2.7 for Locust load tests

2014-10-01 Thread Reddy
Hi, > > Reddy writes: > > > ... > > > I'm trying to use locust (http://locust.io/) to run load test of one site > > > we're developing. Everything was running nice and smooth until we switch > > > the servers to use SNI. SNI is not officially supported in python 2.7.5 > > > you have two option

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Peter Otten
c...@isbd.net wrote: > Peter Otten <__pete...@web.de> wrote: >> c...@isbd.net wrote: >> >> > I have a dictionary as follows:- >> > >> > { >> > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', >> > conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts': >> > Row(id=1,

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Joel Goldstick
On Wed, Oct 1, 2014 at 6:45 AM, wrote: > Peter Otten <__pete...@web.de> wrote: >> c...@isbd.net wrote: >> >> > I have a dictionary as follows:- >> > >> > { >> > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', >> > conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts'

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread cl
Peter Otten <__pete...@web.de> wrote: > c...@isbd.net wrote: > > > I have a dictionary as follows:- > > > > { > > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', > > conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts': > > Row(id=1, ain=u'AIN0', name=u'LeisureVolts

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Joel Goldstick
On Wed, Oct 1, 2014 at 5:58 AM, wrote: > I have a dictionary as follows:- > > { > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', > conv=6834.374834509803, Description=u'Starter Amps'), > u'LeisureVolts': Row(id=1, ain=u'AIN0', name=u'LeisureVolts', > conv=29.01374215995874, Descr

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Mark Lawrence
On 01/10/2014 10:58, c...@isbd.net wrote: I have a dictionary as follows:- { u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts': Row(id=1, ain=u'AIN0', name=u'LeisureVolts', conv=29.01374215995874, Description=u'L

Re: How to show a dictionary sorted on a value within its data?

2014-10-01 Thread Peter Otten
c...@isbd.net wrote: > I have a dictionary as follows:- > > { > u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', > conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts': > Row(id=1, ain=u'AIN0', name=u'LeisureVolts', conv=29.01374215995874, > Description=u'Leisure Vol

Re: JSON-encoding very long iterators

2014-10-01 Thread Alfred Morgan
On Monday, September 29, 2014 7:10:18 PM UTC-7, Ian wrote: > This would cause things that aren't lists to be encoded as lists. > Sometimes that may be desirable, but in general if e.g. a file object > sneaks its way into your JSON encode call, it is more likely correct > to raise an error than to s

How to show a dictionary sorted on a value within its data?

2014-10-01 Thread cl
I have a dictionary as follows:- { u'StarterAmps1': Row(id=4, ain=u'AIN3', name=u'StarterAmps1', conv=6834.374834509803, Description=u'Starter Amps'), u'LeisureVolts': Row(id=1, ain=u'AIN0', name=u'LeisureVolts', conv=29.01374215995874, Description=u'Leisure Volts'), u'RudderPos': Row(id=6, ain

Re: Python code in presentations

2014-10-01 Thread Wolfgang Keller
> Right now the method I'm using is write the code in notepad++, use a > plugin (NppExport) to copy paste code into powerpoint. After using it > a little bit, I'm really not satisfied with this method, it's > expensive and all this copy paste stuff is driving me crazy. Not to > mention that the syn

Re: SNI support in python 2.7 for Locust load tests

2014-10-01 Thread Reddy
Hi, > Reddy writes: > > ... > > I'm trying to use locust (http://locust.io/) to run load test of one site > > we're developing. Everything was running nice and smooth until we switch > > the servers to use SNI. SNI is not officially supported in python 2.7.5 > you have two options: > > Python

Re: Thoughts on python classes to represent an ebook reader

2014-10-01 Thread Wolfgang Maier
On 01.10.2014 10:14, math math wrote: Hi, I hope there are people here with strong OOP experience. Which classes would an object-oriented python programmer create for the design of a e-book reader for example? I am not really interested in the code, just the OOP classes that would come to one

Re: how to parse standard algebraic notation

2014-10-01 Thread Chris Angelico
On Wed, Oct 1, 2014 at 5:01 PM, math math wrote: > What would be a good starting strategy for writing a program to take the > derivative of a polynomial expression, such as this below?: > "x**3 + x**2 + x + 1" > > I am a bit confused about my overall strategy. Should one be writing a parser > cl

Re: Weird SSL problem

2014-10-01 Thread Roland Hedberg
30 sep 2014 kl. 00:55 skrev Ned Deily : > In article , > Roland Hedberg wrote: > >> Hi! >> >> I¹m trying to access >> https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration >> >> Doing it the simplest way I get the following: >> > import urllib > f = > urllib.

Thoughts on python classes to represent an ebook reader

2014-10-01 Thread math math
Hi, I hope there are people here with strong OOP experience. Which classes would an object-oriented python programmer create for the design of a e-book reader for example? I am not really interested in the code, just the OOP classes that would come to one's mind for a task like this. It should

Re: how to parse standard algebraic notation

2014-10-01 Thread Mark Lawrence
On 01/10/2014 08:01, math math wrote: [mega-snip] You are far more likely to get answers if you access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing double line spacing and single

Re: Python code in presentations

2014-10-01 Thread Glenn Hutchings
On Tuesday, 30 September 2014 12:51:00 UTC+1, Jean-Michel Pichavant wrote: > I'm currently writing a presentation to help my co-workers ramp up on new > features of our tool (written in python (2.7)). > > I have some difficulties presenting code in an efficient way (with some basic > syntax hig

Re: how to parse standard algebraic notation

2014-10-01 Thread math math
On Tuesday, 30 September 2014 23:15:24 UTC+2, Gary Herron wrote: > On 09/30/2014 01:53 PM, math math wrote: > > > Hi, > > > > > > I am trying to learn Python while solving exercises. > > > > > > I want to basically write a program that inputs a polynomial in standard > > algebraic notation a