Generic dictionary

2016-11-20 Thread Thorsten Kampe
[Crossposted to tutor and general mailing list] Hi, I'd like to extend the dictionary class by creating a class that acts like a dictionary if the class is instantiated with a dictionary and acts like a "dictitem" ([(key1, value1), (key2, value2), ...]) if instantiated with a list (that is dic

Re: Generic dictionary

2016-11-20 Thread Peter Otten
Thorsten Kampe wrote: > [Crossposted to tutor and general mailing list] > > Hi, > > I'd like to extend the dictionary class by creating a class that acts > like a dictionary if the class is instantiated with a dictionary and > acts like a "dictitem" ([(key1, value1), (key2, value2), ...]) if > i

Re: Couldn't load SIP module.

2016-11-20 Thread Xristos Xristoou
Τη Σάββατο, 19 Νοεμβρίου 2016 - 10:45:16 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > hello > i using python 2.7.12 on ubuntu 16.04 and i have that error with SIP : > > Couldn't load SIP module. > > > Traceback (most recent call last): > File "", line 1, in > ImportError: /usr/local/lib/

Re: Generic dictionary

2016-11-20 Thread Steve D'Aprano
On Sun, 20 Nov 2016 08:27 pm, Thorsten Kampe wrote: > I'd like to extend the dictionary class by creating a class that acts > like a dictionary if the class is instantiated with a dictionary and > acts like a "dictitem" ([(key1, value1), (key2, value2), ...]) if > instantiated with a list (that is

Re: Generic dictionary

2016-11-20 Thread Anny Mous
On Sun, 20 Nov 2016 08:43 pm, Peter Otten wrote: > Thorsten Kampe wrote: > >> [Crossposted to tutor and general mailing list] >> >> Hi, >> >> I'd like to extend the dictionary class by creating a class that acts >> like a dictionary if the class is instantiated with a dictionary and >> acts lik

Re: Generic dictionary

2016-11-20 Thread Steve D'Aprano
Further thoughts come to mind, after looking more closely at your code. On Sun, 20 Nov 2016 08:27 pm, Thorsten Kampe wrote: > class GenericDict: > """ > a GenericDict is a dictionary or a list of tuples (when the keys > are not hashable) > """ > def __init__(inst, generic_dict

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

2016-11-20 Thread Bev in TX
From the Python 3.5.2 docs: 6.15. Evaluation order Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand side. Thus, spam = eggs = cheese = obj is equivalent to: spam = (eggs = (cheese = obj)) which

Re: Generic dictionary

2016-11-20 Thread Thorsten Kampe
* Peter Otten (Sun, 20 Nov 2016 10:43:01 +0100) > > Thorsten Kampe wrote: > > > > I'd like to extend the dictionary class by creating a class that acts > > like a dictionary if the class is instantiated with a dictionary and > > acts like a "dictitem" ([(key1, value1), (key2, value2), ...]) if >

Re: Generic dictionary

2016-11-20 Thread Thorsten Kampe
* Anny Mous (Sun, 20 Nov 2016 21:46:25 +1100) > > On Sun, 20 Nov 2016 08:43 pm, Peter Otten wrote: > > > Thorsten Kampe wrote: > > > >> [Crossposted to tutor and general mailing list] > >> > >> Hi, > >> > >> I'd like to extend the dictionary class by creating a class that acts > >> like a dict

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

2016-11-20 Thread Tristan B. Kildaire
On Tue, 15 Nov 2016 22:16:07 +, Erik wrote: > On 15/11/16 14:43, Michael Torrie wrote: >> As you've been told several times, if you "import deen" then you can >> place a new object into the deen namespace using something like: >> >> deen.foo=bar >> >> Importing everything from an imported modu

Guido? Where are you?

2016-11-20 Thread Tristan B. Kildaire
Is Guido active on this newsgroup. Sorry for the off-topic ness. -- https://mail.python.org/mailman/listinfo/python-list

Re: Generic dictionary

2016-11-20 Thread Thorsten Kampe
* Steve D'Aprano (Sun, 20 Nov 2016 21:10:08 +1100) > > On Sun, 20 Nov 2016 08:27 pm, Thorsten Kampe wrote: > > > I'd like to extend the dictionary class by creating a class that acts > > like a dictionary if the class is instantiated with a dictionary and > > acts like a "dictitem" ([(key1, value

Re: Generic dictionary

2016-11-20 Thread Chris Angelico
On Sun, Nov 20, 2016 at 11:19 PM, Thorsten Kampe wrote: > The whole point of my posting was non hashable keys (like lists): > > ``` dictitem > [([1], '11'), ([2], '22'), ([4], '33'), ([3], '44')] dict(dictitem) > - > Typ

Re: Guido? Where are you?

2016-11-20 Thread Ned Batchelder
On Sunday, November 20, 2016 at 7:24:43 AM UTC-5, Tristan B. Kildaire wrote: > Is Guido active on this newsgroup. Sorry for the off-topic ness. He is definitely not active on this list. The most recent message from him here (not cross-posted) seems to be in September 2014. Maybe there's something

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

2016-11-20 Thread Chris Angelico
On Sun, Nov 20, 2016 at 10:47 PM, Bev in TX wrote: > From the Python 3.5.2 docs: > > 6.15. Evaluation order > Python evaluates expressions from left to right. Notice that while > evaluating an assignment, the right-hand side is evaluated before the > left-hand side. > > Thus, spam = eggs = cheese

Re: Generic dictionary

2016-11-20 Thread Thorsten Kampe
* Steve D'Aprano (Sun, 20 Nov 2016 22:40:19 +1100) > > Further thoughts come to mind, after looking more closely at your code. > > On Sun, 20 Nov 2016 08:27 pm, Thorsten Kampe wrote: > > > def values(inst): > > if isinstance(inst._generic, dict): > > return inst._generic.

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

2016-11-20 Thread Ned Batchelder
On Sunday, November 20, 2016 at 6:47:35 AM UTC-5, Bev in TX wrote: > From the Python 3.5.2 docs: > > 6.15. Evaluation order > Python evaluates expressions from left to right. Notice that while > evaluating an assignment, the right-hand side is evaluated before the > left-hand side. > > Thus, sp

Re: Generic dictionary

2016-11-20 Thread Thorsten Kampe
* Chris Angelico (Sun, 20 Nov 2016 23:35:52 +1100) > I see. So you want to be able to have something that looks and > feels > like a dictionary, but uses a different way of looking things up. > Makes reasonable sense, on the surface. > > Before you go down that route, I strongly recommend reading

Re: Generic dictionary

2016-11-20 Thread Chris Angelico
On Mon, Nov 21, 2016 at 12:12 AM, Thorsten Kampe wrote: > Chris, it's up to the consumer to decide which key/keyfunc to use. > The lists as keys (that is first element in an tuple) are created on > the fly and not used for anything. They are mutable but not mutated. > > Mutating the list would be

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

2016-11-20 Thread Bev in TX
Thanks to ChrisA and Ned for that clarification. Bev in TX -- https://mail.python.org/mailman/listinfo/python-list

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

2016-11-20 Thread jfong
Tristan B. Kildaire at 2016/11/20 8:23:37PM wrote: > From deen import * imports all the things in deen but accessable with no > `deen.` These "accessible" objects become read-only even if it's mutable. For immutable objects, you can't even create a new one in the deen's namespace. > import deen

Re: Numpy slow at vector cross product?

2016-11-20 Thread BartC
On 20/11/2016 20:46, DFS wrote: import sys, time, numpy as np loops=int(sys.argv[1]) x=np.array([1,2,3]) y=np.array([4,5,6]) start=time.clock() for i in range(loops): np.cross(x,y) print "Numpy, %s loops: %.2g seconds" %(loops,time.clock()-start) x=[1,2,3] y=[4,5,6] z=[0,0,0] start=time.clo

Re: Numpy slow at vector cross product?

2016-11-20 Thread Steve D'Aprano
On Mon, 21 Nov 2016 07:46 am, DFS wrote: > import sys, time, numpy as np > loops=int(sys.argv[1]) > > x=np.array([1,2,3]) > y=np.array([4,5,6]) > start=time.clock() > for i in range(loops): > np.cross(x,y) > print "Numpy, %s loops: %.2g seconds" %(loops,time.clock()-start) [...] > $ python

TemplateError

2016-11-20 Thread iivri . andre
THIS error is constantly showing up when I run my python script eloiim:build iivri.andre$ python run.py * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) [2016-11-21 01:15:26,561] ERROR in app: Exception on / [GET] Traceback (most recent call last): File "/usr/local/lib/python2.7/sit

Re: TemplateError

2016-11-20 Thread Chris Angelico
On Mon, Nov 21, 2016 at 5:22 PM, wrote: > TemplateNotFound: index.html > > return render_template('index.html', author=author, name=name) The render_template function looks for a directory called "templates" and a file in that of the given name. So you'll need to have "templates/index.html"

Clean way to return error codes

2016-11-20 Thread Steven D'Aprano
I have a script that can be broken up into four subtasks. If any of those subtasks fail, I wish to exit with a different exit code and error. Assume that the script is going to be run by system administrators who know no Python and are terrified of tracebacks, and that I'm logging the full trace

Re: TemplateError

2016-11-20 Thread Vincent Vande Vyvre
Le 21/11/2016 à 07:22, iivri.an...@gmail.com a écrit : THIS error is constantly showing up when I run my python script eloiim:build iivri.andre$ python run.py * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) [2016-11-21 01:15:26,561] ERROR in app: Exception on / [GET] Traceback (mos

Re: Clean way to return error codes

2016-11-20 Thread Jussi Piitulainen
Steven D'Aprano writes: > I have a script that can be broken up into four subtasks. If any of > those subtasks fail, I wish to exit with a different exit code and > error. > > Assume that the script is going to be run by system administrators who > know no Python and are terrified of tracebacks, a