Re: Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 3:34 PM, Gayathri J wrote: > Below is the code I tried to check if itertools.product() was faster than > normal nested loops... > > they arent! arent they supposed to be...or am i making a mistake? any idea? Don't worry about what's faster. That almost never matters. Worry,

Re: Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Gayathri J
Dear Peter Below is the code I tried to check if itertools.product() was faster than normal nested loops... they arent! arent they supposed to be...or am i making a mistake? any idea? ** *# -*- coding: utf-8 -*-* *import numpy as np*

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 3:31 PM, Travis Griggs wrote: >> On Aug 4, 2014, at 22:57, Chris Angelico wrote: >> >> On Tue, Aug 5, 2014 at 3:47 PM, Satish ML wrote: >> bytes = file.read() >> >> You've just shadowed the built-in type 'bytes' with your own 'bytes'. >> Pick a different name for this,

Re: TypeError: 'bytes' object is not callable error while trying to converting to bytes.

2014-08-05 Thread Travis Griggs
> On Aug 4, 2014, at 22:57, Chris Angelico wrote: > > On Tue, Aug 5, 2014 at 3:47 PM, Satish ML wrote: > bytes = file.read() > > You've just shadowed the built-in type 'bytes' with your own 'bytes'. > Pick a different name for this, and you'll be fine. 'data' would work. Until python4 in

Re: Making every no-arg method a property?

2014-08-05 Thread Grant Edwards
On 2014-08-05, Gregory Ewing wrote: > Grant Edwards wrote: >> Did I miss a news story? Have the parentesis mines all exploded >> causing the price of parenthesis to skyrocket? > > The Unicode Consortium has been secretly buying them > up for some time now. Pretty soon you won't be able > to get c

Re: Making every no-arg method a property?

2014-08-05 Thread alex23
On 6/08/2014 9:49 AM, Ben Finney wrote: Christian Calderon writes: I like that in ruby I don't have to type parenthesis at the end of each function call if I don't need to provide extra arguments. Having the same name sometimes refer to “get this as a value” and other times “call this as a f

Re: Tkinter menu crash

2014-08-05 Thread Terry Reedy
On 8/5/2014 7:33 PM, Nicholas Cannon wrote: I am confused. When I did menu bar.add_cascade why don't I do filemenu.add_cascade. Is it because I am adding a cascade to the main menubar? Let us start with a widget, that can 'contain' other widgets (and possibly other things). We create a child

Re: Making every no-arg method a property?

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 10:49 AM, Steven D'Aprano wrote: > A > plethora of argument-less methods is a code smell -- that doesn't mean it's > *necessarily* a bad idea, but the class design really needs a careful > review. There are plenty of no-argument mutator methods, where the name of the method

Re: Making every no-arg method a property?

2014-08-05 Thread Steven D'Aprano
Christian Calderon wrote: > I have been using python for 4 years now, and I just started learning > ruby. I like that in ruby I don't have to type parenthesis at the end of > each function call if I don't need to provide extra arguments. That's one of the things which I dislike most about Ruby.

Re: Making every no-arg method a property?

2014-08-05 Thread Ben Finney
Christian Calderon writes: > I like that in ruby I don't have to type parenthesis at the end of > each function call if I don't need to provide extra arguments. Whereas I like the opposite: there is a clear syntactic distinction between “get the value of ‘foo.bar.baz’” versus “get the value retu

Re: Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
I am confused. When I did menu bar.add_cascade why don't I do filemenu.add_cascade. Is it because I am adding a cascade to the main menubar? -- https://mail.python.org/mailman/listinfo/python-list

Re: Controlling py.exe launcher on Windows

2014-08-05 Thread Terry Reedy
On 8/5/2014 7:02 PM, Terry Reedy wrote: On 8/5/2014 1:27 PM, Edward Diener wrote: I am trying to control the default version of the py.exe launcher on Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32 bit and 64 bit versions, all in different directories. I assume that .py an

Re: Tkinter menu crash

2014-08-05 Thread Terry Reedy
On 8/5/2014 6:28 PM, Nicholas Cannon wrote: Ok so I am on 2.7.8. What x.y.z version of Python. How did you run it, exactly? Adding filemenu as a submenu of filemenu leads to infinite loop regress. On 3.4.1 with tcl/tk 8.6, this does not crash, but it might on an earlier version of Python an

Re: Controlling py.exe launcher on Windows

2014-08-05 Thread Terry Reedy
On 8/5/2014 1:27 PM, Edward Diener wrote: I am trying to control the default version of the py.exe launcher on Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32 bit and 64 bit versions, all in different directories. I assume that .py and .pyw files are associated with the py.e

Re: Making every no-arg method a property?

2014-08-05 Thread Gregory Ewing
Grant Edwards wrote: Did I miss a news story? Have the parentesis mines all exploded causing the price of parenthesis to skyrocket? The Unicode Consortium has been secretly buying them up for some time now. Pretty soon you won't be able to get cheap ASCII parentheses any more, only the fancy h

Re: Controlling py.exe launcher on Windows

2014-08-05 Thread Edward Diener
On 8/5/2014 1:27 PM, Edward Diener wrote: I am trying to control the default version of the py.exe launcher on Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32 bit and 64 bit versions, all in different directories. I assume that .py and .pyw files are associated with the py.e

Re: Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
Ok so I am on 2.7.8. > What x.y.z version of Python. How did you run it, exactly? > Adding filemenu as a submenu of filemenu leads to infinite loop regress. > > On 3.4.1 with tcl/tk 8.6, this does not crash, but it might on an > > earlier version of Python and tcl/tk. > Since menubar is left e

Re: Python 3.4.1 install does not create a file association for .py files on Windows

2014-08-05 Thread Edward Diener
On 8/5/2014 6:16 PM, Terry Reedy wrote: On 8/5/2014 3:36 PM, Edward Diener wrote: I install Python 3.4.1 64-bit on Windows. After the install I type: I have done the same, on Win 7, but I had previous installs going back 3 years on this machine. assoc .py and I get back: File association n

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-05 Thread Wiktor
On 05 Aug 2014 20:26:08 GMT, Tony the Tiger wrote: > On Mon, 04 Aug 2014 00:52:29 +0200, Wiktor wrote: > >> okumenty\python\kolony\menu.py", line 14, in > > This works for me on Linux: I believe you, but I use Windows and its cmd.exe (as mentioned in subject). -- Best regards, Wiktor M

Re: Python 3.4.1 install does not create a file association for .py files on Windows

2014-08-05 Thread Terry Reedy
On 8/5/2014 3:36 PM, Edward Diener wrote: I install Python 3.4.1 64-bit on Windows. After the install I type: I have done the same, on Win 7, but I had previous installs going back 3 years on this machine. assoc .py and I get back: File association not found for extension .py I get C:\U

Re: Making every no-arg method a property?

2014-08-05 Thread Ian Kelly
On Tue, Aug 5, 2014 at 1:39 PM, Christian Calderon wrote: > I have been using python for 4 years now, and I just started learning ruby. > I like that in ruby I don't have to type parenthesis at the end of each > function call if I don't need to provide extra arguments. I just realized > right now

Re: Tkinter menu crash

2014-08-05 Thread Terry Reedy
On 8/5/2014 8:15 AM, Nicholas Cannon wrote: Ok so the first part of the program(until the start of the menu) worked fine. It ran and did what I wanted it to do. What x.y.z version of Python. How did you run it, exactly? I wanted to then implement a new menu(for practise) and then it crashes

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-05 Thread TP
On Tue, Aug 5, 2014 at 12:25 PM, Duncan Booth wrote: > So far they seem to have kept a pretty low profile; I suspect largely > because until recently PTVS only worked with the pay versions of Visual > Studio. > Not true. When it didn't work with the free express versions of VS, it worked with th

Re: Making every no-arg method a property?

2014-08-05 Thread Grant Edwards
On 2014-08-05, Christian Calderon wrote: > I have been using python for 4 years now, and I just started learning > ruby. I like that in ruby I don't have to type parenthesis at the end > of each function call if I don't need to provide extra arguments. Did I miss a news story? Have the parentes

Re: Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Frank Miles
On Tue, 05 Aug 2014 20:06:05 +, Frank Miles wrote: > I need to evaluate a complicated function over a multidimensional space > as part of an optimization problem. This is a somewhat general problem > in which the number of dimensions and the function being evaluated can > vary from problem to

Re: Making every no-arg method a property?

2014-08-05 Thread Rob Gaddi
On Tue, 5 Aug 2014 12:39:18 -0700 Christian Calderon wrote: > I have been using python for 4 years now, and I just started learning ruby. > I like that in ruby I don't have to type parenthesis at the end of each > function call if I don't need to provide extra arguments. I just realized > right n

Re: Making every no-arg method a property?

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 5:39 AM, Christian Calderon wrote: > I have been using python for 4 years now, and I just started learning ruby. > I like that in ruby I don't have to type parenthesis at the end of each > function call if I don't need to provide extra arguments. I just realized > right now

Making every no-arg method a property?

2014-08-05 Thread Christian Calderon
I have been using python for 4 years now, and I just started learning ruby. I like that in ruby I don't have to type parenthesis at the end of each function call if I don't need to provide extra arguments. I just realized right now that I can do something similar in python, if I make all methods wi

Re: Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Peter Otten
Frank Miles wrote: > I need to evaluate a complicated function over a multidimensional space > as part of an optimization problem. This is a somewhat general problem > in which the number of dimensions and the function being evaluated can > vary from problem to problem. > > I've got a working ve

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-05 Thread Grant Edwards
On 2014-08-05, Tony the Tiger wrote: > On Mon, 04 Aug 2014 00:52:29 +0200, Wiktor wrote: > >> okumenty\python\kolony\menu.py", line 14, in > > This works for me on Linux: > > ---8<- > # coding:utf-8 > > test = """ > ┌──╖ > │ Construction ║ > │ Production ║ > │ Re

Pythonic way to iterate through multidimensional space?

2014-08-05 Thread Frank Miles
I need to evaluate a complicated function over a multidimensional space as part of an optimization problem. This is a somewhat general problem in which the number of dimensions and the function being evaluated can vary from problem to problem. I've got a working version (with loads of conditional

Python 3.4.1 install does not create a file association for .py files on Windows

2014-08-05 Thread Edward Diener
I install Python 3.4.1 64-bit on Windows. After the install I type: assoc .py and I get back: File association not found for extension .py Why does not the Python install to associate extension .py with the Python Launcher for Windows ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-05 Thread Duncan Booth
Steven D'Aprano wrote: > Duncan Booth wrote: > >> Steven D'Aprano wrote: >> >>> Unfortunately, software development on Windows is something of a >>> ghetto, compared to the wide range of free tools available for >>> Linux. > > I remember writing this. But I don't remember when it was. Presum

Controlling py.exe launcher on Windows

2014-08-05 Thread Edward Diener
I am trying to control the default version of the py.exe launcher on Windows. I have the Python 2.7.8 and 3.4.1 installed with both the 32 bit and 64 bit versions, all in different directories. I assume that .py and .pyw files are associated with the py.exe launcher. I am trying to control whi

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-05 Thread Steven D'Aprano
Duncan Booth wrote: > Steven D'Aprano wrote: > >> Unfortunately, software development on Windows is something of a >> ghetto, compared to the wide range of free tools available for Linux. I remember writing this. But I don't remember when it was. Presumably some time in the last six months :-)

Re: eval [was Re: dict to boolean expression, how to?]

2014-08-05 Thread Steven D'Aprano
Duncan Booth wrote: > Steven D'Aprano wrote: [...] >> My refactoring, with the bare minimum use of exec necessary: >> >> https://code.activestate.com/recipes/578918-yet-another-namedtuple/ > > > This may be a silly question, but what would stop you moving the exec > inside the class? I don't

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
Marko Rauhamaa wrote: > What's the inherent difference between an attribute and a key. Here is my bucket. The handle of the bucket is part of the bucket: bucket.handle The pieces of coal I carry in the bucket is part of its content: bucket['coal'] Of course, we can blur the distinction betw

Re: Python Classes

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 1:37 AM, Neil D. Cerutti wrote: > In simple cases like that, functions could do very well by including a > little bundle of data (probably a dict) as one of the parameters for each > related function. And this is exactly how object orientation is done in C. You just have a

Re: Python Classes

2014-08-05 Thread Neil D. Cerutti
On 8/4/2014 6:44 PM, John Gordon wrote: In Shubham Tomar writes: classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the same purpose. Can someone please explain the idea of classes If a function simply accepts some data, does

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread MRAB
On 2014-08-05 14:19, Marko Rauhamaa wrote: Skip Montanaro : On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes ≠ keys. When you see something.somethingelse anywhere else in Python

Re: Davis putnam algorithm for satisfiability...

2014-08-05 Thread varun7rs
Thank you Cameron. Your post was very helpful. If you don't mind I'd like to ask you the purpose of the final list in the very beginning of the code. It is being updated and then checked for the presence of a literal. If a literal is found it returns not equivalent. Could you brief me the use of

Re: Python and IDEs [was Re: Python 3 is killing Python]

2014-08-05 Thread Duncan Booth
Steven D'Aprano wrote: > Unfortunately, software development on Windows is something of a > ghetto, compared to the wide range of free tools available for Linux. > Outside of a few oases like Microsoft's own commercial development > tools, it's hard to do development on Windows. Hard, but not > i

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Marko Rauhamaa
Skip Montanaro : > On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: >> I wonder if that should be built into dict. > > Short answer, no. I'm sure it's been proposed before. Attributes ≠ > keys. When you see something.somethingelse anywhere else in Python, > "somethingelse" is an attribute re

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Chris Angelico
On Tue, Aug 5, 2014 at 10:43 PM, Steven D'Aprano wrote: > Because it's horrible and a bad idea. > > d = {'this': 23, 'word': 42, 'frog': 2, 'copy': 15, 'lunch': 93} > e = d.copy() > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'int' object is not callable > > > Confl

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Chris Angelico
On Tue, Aug 5, 2014 at 10:31 PM, Skip Montanaro wrote: > JavaScript objects have that feature. I find it mildly confusing > because whenever I see it I have to pause to consider whether the name > I am looking at is an attribute or a key. This little JS code I just > typed at my console prompt was

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Steven D'Aprano
Marko Rauhamaa wrote: > Why can't I have: > >>>> d = {} >>>> d.x = 3 >>>> d >{'x': 3} Because it's horrible and a bad idea. d = {'this': 23, 'word': 42, 'frog': 2, 'copy': 15, 'lunch': 93} e = d.copy() Traceback (most recent call last): File "", line 1, in ? TypeError: 'int'

RE: Python-list Digest, Vol 131, Issue 6

2014-08-05 Thread J Prashanthan
Sent from my Windows Phone From: python-list-requ...@python.org Sent: ‎05-‎08-‎2014 15:37 To: python-list@python.org Subject: Python-list Digest, Vol 131, Issue 6 Send Python-list mailing list submissions to python-list@python.org To subscribe or unsubscribe via the World Wide Web, visit

Re: How to pack a string variable of length 1 as a char using struct.pack?

2014-08-05 Thread Thomas Orozco
On Tue, Aug 5, 2014 at 2:15 PM, wrote: > Hi, > How to pack a string variable of length 1 as a char using struct.pack? > The following works fine: > p = struct.pack('c', b'1') > > Whereas this causes an error "char format requires a bytes object of > length 1": > s = '1' > p = struct.pack('c', s)

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Skip Montanaro
On Tue, Aug 5, 2014 at 7:04 AM, Marko Rauhamaa wrote: > > I wonder if that should be built into dict. Short answer, no. I'm sure it's been proposed before. Attributes ≠ keys. When you see something.somethingelse anywhere else in Python, "somethingelse" is an attribute reference. When you see som

Re: How to pack a string variable of length 1 as a char using struct.pack?

2014-08-05 Thread Steven D'Aprano
danwgr...@gmail.com wrote: > Hi, > How to pack a string variable of length 1 as a char using struct.pack? > The following works fine: > p = struct.pack('c', b'1') Here you use a byte string of length 1, b'1'. > Whereas this causes an error "char format requires a bytes object of > length 1": >

How to pack a string variable of length 1 as a char using struct.pack?

2014-08-05 Thread danwgrace
Hi, How to pack a string variable of length 1 as a char using struct.pack? The following works fine: p = struct.pack('c', b'1') Whereas this causes an error "char format requires a bytes object of length 1": s = '1' p = struct.pack('c', s) I need to pack a variable rather than a literal. Thanks.

Tkinter menu crash

2014-08-05 Thread Nicholas Cannon
Ok so the first part of the program(until the start of the menu) worked fine. It ran and did what I wanted it to do. I wanted to then implement a new menu(for practise) and then it crashes. Don't know why but it just crashes. (also tips on the code will be appreciated and I gave just started Tki

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Marko Rauhamaa
Brian Blais : > class Struct(dict): > > def __getattr__(self,name): > > try: > val=self[name] > except KeyError: > val=super(Struct,self).__getattribute__(name) > > return val > > def __setattr__(self,name,val): > > self[name]=val Co

Re: eval [was Re: dict to boolean expression, how to?]

2014-08-05 Thread Duncan Booth
Steven D'Aprano wrote: > Consider the namedtuple implementation in the standard library. > There's a lot of criticism of it, some of it justified. It uses exec > extensively, which means the code is dominated by a giant string > template. This defeats your editor's syntax colouring, makes > refac

Re: 3 Suggestions to Make Python Easier For Children

2014-08-05 Thread Brian Blais
On Sat, Aug 2, 2014 at 2:45 AM, Mark Summerfield wrote: > Last week I spent a couple of days teaching two children (10 and 13 -- too > big an age gap!) how to do some turtle graphics with Python. Neither had > programmed Python before -- one is a Minecraft ace and the other had done > Scratch.

RE: creating log file with Python logging module

2014-08-05 Thread Arulnambi Nandagoban
-Message d'origine- De : Python-list [mailto:python-list-bounces+a.nandagoban=traxens@python.org] De la part de Peter Otten Envoyé : Monday, August 4, 2014 4:03 PM À : python-list@python.org Objet : Re: creating log file with Python logging module Peter Otten wrote: > Peter Otten wro

RE: how to fix python logging to not log to stderr

2014-08-05 Thread Arulnambi Nandagoban
-Message d'origine- De : Python-list [mailto:python-list-bounces+a.nandagoban=traxens@python.org] De la part de harish.chilk...@gmail.com Envoyé : Tuesday, August 5, 2014 11:18 AM À : python-list@python.org Objet : how to fix python logging to not log to stderr I am doing this loggin

Re: cmd.exe on WIndows - problem with displaying some Unicode characters

2014-08-05 Thread Wiktor
On Tue, 05 Aug 2014 04:51:15 +0400, Akira Li wrote: > Unicode has line drawing characters [1]. win_unicode_console [2] allows > to print Unicode in cmd.exe. win_unicode_console and colorama will > probably conflict. You could look at the source to see how hard to > combine both functionalities. >

how to fix python logging to not log to stderr

2014-08-05 Thread harish . chilkoti
I am doing this logging.basiConfig(logleve=Logging.Info) then i create a file log handler and attach to it. i also have propagate as True. My logs are going to the stderr as well. How do i fix so that logs don't go to stdout? -- https://mail.python.org/mailman/listinfo/python-list