trying idle

2014-10-08 Thread Rustom Mody
Been using emacs for over 20 years and teaching python for 10. And getting fed up that my audience looks at me like Rip van Winkle each time I start up emacs... So trying out Idle... Some specific and some general questions: My audience consists of people having linux and windows and macbooks. Do

ZMQError: Resource temporarily unavailable

2014-10-08 Thread karthik . sharma
I am using zero-mq for IPC between two machines. My zmq function is given below def recieve_messages(self): string = self.sub_socket.recv(flags=zmq.NOBLOCK) print('flow mod messages recieved {}'.format(string)) When I run the program however I get the following err

Re: Toggle

2014-10-08 Thread Chris Angelico
On Thu, Oct 9, 2014 at 4:39 PM, Rustom Mody wrote: > On Thursday, October 9, 2014 10:26:41 AM UTC+5:30, Steven D'Aprano wrote: >> On Wed, 08 Oct 2014 19:34:30 -0700, Rustom Mody wrote: > >> Color.Red >> print (Color.Red) >> > Color.Red >> > # Not sure what to make of that distinction...

Re: Toggle

2014-10-08 Thread Rustom Mody
On Thursday, October 9, 2014 10:26:41 AM UTC+5:30, Steven D'Aprano wrote: > On Wed, 08 Oct 2014 19:34:30 -0700, Rustom Mody wrote: > Color.Red > print (Color.Red) > > Color.Red > > # Not sure what to make of that distinction... > That's because the interactive interpreter displays the r

Re: Toggle

2014-10-08 Thread Travis Griggs
On Oct 8, 2014, at 9:57 PM, Gregory Ewing wrote: > Seymore4Head wrote: >> I want to toggle between color="Red" and color="Blue" Don’t forget polymorphic dispatch… class Red(object): def toggle(self): return Blue() class Blue(object): def toggle(self): return Red() B

Re: Toggle

2014-10-08 Thread Gregory Ewing
Seymore4Head wrote: I want to toggle between color="Red" and color="Blue" toggle = {"Red": "Blue", "Blue": "Red"} color = toggle[color] -- https://mail.python.org/mailman/listinfo/python-list

Re: Toggle

2014-10-08 Thread Steven D'Aprano
On Wed, 08 Oct 2014 19:34:30 -0700, Rustom Mody wrote: Color.Red > print (Color.Red) > Color.Red > > # Not sure what to make of that distinction... That's because the interactive interpreter displays the repr() of objects (except for None, which it suppresses), while print outputs th

Re: Toggle

2014-10-08 Thread Chris Angelico
On Thu, Oct 9, 2014 at 2:54 PM, wrote: > On Wed, Oct 8, 2014, at 23:02, Mark Lawrence wrote: >> When I first read this I was extremely jealous of the originator but >> having used it umpteen times I'm still extremely jealous of the >> originator!!! Why doesn't my mind work like his? :) > > You c

Re: Toggle

2014-10-08 Thread random832
On Wed, Oct 8, 2014, at 23:02, Mark Lawrence wrote: > When I first read this I was extremely jealous of the originator but > having used it umpteen times I'm still extremely jealous of the > originator!!! Why doesn't my mind work like his? :) You could also keep the ints in two variables and do

Re: Toggle

2014-10-08 Thread Mark Lawrence
On 09/10/2014 02:25, Mark Lawrence wrote: On 09/10/2014 01:11, Seymore4Head wrote: I want to toggle between color="Red" and color="Blue" Here is one: if color == "Red": color = "Blue" else: color = "Red" Here is two: if x = "True" color = "Red" else: color="Blue" x= n

Re: Toggle

2014-10-08 Thread Rustom Mody
On Thursday, October 9, 2014 7:12:41 AM UTC+5:30, Ben Finney wrote: > Seymore4Head writes: > > I want to toggle between color="Red" and color="Blue" > It's good to cultivate ongoing familiarity with the standard library And language. In recent python3: >>> class Color(Enum): ... Red = 0 ...

Re: Toggle

2014-10-08 Thread Ben Finney
Seymore4Head writes: > I want to toggle between color="Red" and color="Blue" It's good to cultivate ongoing familiarity with the standard library https://docs.python.org/3/library/itertools.html#itertools.cycle> so that you can make use of wheels already invented and maintained:: import ite

Re: operator module functions

2014-10-08 Thread Ned Batchelder
On 10/8/14 5:49 PM, Ethan Furman wrote: [redirecting back to the list] On 10/08/2014 02:23 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:53, Ethan Furman wrote: On 10/08/2014 12:49 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: LOL, no kidd

Re: Toggle

2014-10-08 Thread Steven D'Aprano
Seymore4Head wrote: > I want to toggle between color="Red" and color="Blue" > Here is one: > if color == "Red": > color = "Blue" > else: > color = "Red" Apart from the horrible spelling of colour :-) that seems fine to me. You might wish to include a comment: # Assumes th

Re: Toggle

2014-10-08 Thread Mark Lawrence
On 09/10/2014 01:11, Seymore4Head wrote: I want to toggle between color="Red" and color="Blue" Here is one: if color == "Red": color = "Blue" else: color = "Red" Here is two: if x = "True" color = "Red" else: color="Blue" x= not x Others? Here http://stackoverflow.

Re:Toggle

2014-10-08 Thread Dave Angel
Seymore4Head Wrote in message: > I want to toggle between color="Red" and color="Blue" > Here is one: > if color == "Red": > color = "Blue" > else: > color = "Red" > Here is two: > if x = "True" color = "Red" > else: > color="Blue" > x= not x > > Others? > One looks like

Toggle

2014-10-08 Thread Seymore4Head
I want to toggle between color="Red" and color="Blue" Here is one: if color == "Red": color = "Blue" else: color = "Red" Here is two: if x = "True" color = "Red" else: color="Blue" x= not x Others? -- https://mail.python.org/mailman/listinfo/python-list

Re: operator module functions

2014-10-08 Thread Ethan Furman
On 10/08/2014 03:46 PM, Terry Reedy wrote: On 10/8/2014 5:49 PM, Ethan Furman wrote: [redirecting back to the list] I'm not sure what situation you would have to type them (as opposed to simply a + b) that the operator module would help with. unittest springs to mind: self.assertRaises

Re: operator module functions

2014-10-08 Thread Terry Reedy
On 10/8/2014 5:49 PM, Ethan Furman wrote: [redirecting back to the list] I'm not sure what situation you would have to type them (as opposed to simply a + b) that the operator module would help with. unittest springs to mind: self.assertRaises(TypeError, op.add, obj1, obj2) Er, my poi

Re: how to add custom importer after the normal imports

2014-10-08 Thread Ian Kelly
On Wed, Oct 8, 2014 at 4:53 AM, Gelonida N wrote: > Hi, > > > I just read about sys.meta_path, which allows to install custom importers > *BEFORE* the default importers. > > However I have a use case where I would like to add a custom importer > *AFTER* all other import methods have failed. > > Do

Re: operator module functions

2014-10-08 Thread Chris Kaynor
On Wed, Oct 8, 2014 at 3:30 PM, Chris Angelico wrote: > > > > > > That doesn't always seem to have been the case, however. > > In Python 2.7 and 3.3, I get > > > operator.add is operator.__add__ > > False > > Huh. So it is. > > rosuav@sikorsky:~$ python3 > Python 3.5.0a0 (default:301b9a58021

Re: operator module functions

2014-10-08 Thread Chris Angelico
On Thu, Oct 9, 2014 at 8:37 AM, Gregory Ewing wrote: > Chris Angelico wrote: > > operator.add is operator.__add__ >> >> True > > > That doesn't always seem to have been the case, however. > In Python 2.7 and 3.3, I get > operator.add is operator.__add__ > False Huh. So it is. rosuav@sik

virtualenv question: include just a few site packages

2014-10-08 Thread Gelonida N
virtualenv has the switch --system-site-packages (including all system site pacgaes) and the switch --no-site-packages (to expclude all site packages) Does anyone know an easy way to include just a few site-packages? for example (PySide, but not PyQt) The reason I'm asking is following. Some si

Re: operator module functions

2014-10-08 Thread Ben Finney
random...@fastmail.us writes: > On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: > > The main reason I bother using the operator module is for the > > readability of not seeing the dunders, and the writability of not > > having to type them. > > I'm not sure what situation you would have to type

Re: operator module functions

2014-10-08 Thread Chris Kaynor
On Wed, Oct 8, 2014 at 2:05 PM, Gelonida N wrote: > On 10/8/2014 9:09 PM, Terry Reedy wrote: > >> On 10/8/2014 6:57 AM, Steven D'Aprano wrote: >> >> According to the documentation, operator.__add__ is the "official" >>> function, >>> and operator.add is just there for convenience. >>> >> >> You

Re: operator module functions

2014-10-08 Thread Ethan Furman
[redirecting back to the list] On 10/08/2014 02:23 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:53, Ethan Furman wrote: On 10/08/2014 12:49 PM, random...@fastmail.us wrote: On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: LOL, no kidding! The main reason I bother using the

Re: operator module functions

2014-10-08 Thread Gregory Ewing
Chris Angelico wrote: operator.add is operator.__add__ True That doesn't always seem to have been the case, however. In Python 2.7 and 3.3, I get >>> operator.add is operator.__add__ False -- Greg -- https://mail.python.org/mailman/listinfo/python-list

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-08 Thread Gregory Ewing
jonathan.slend...@gmail.com wrote: For each non-accepting state, determine whether it has any transitions that lead in one or more steps to an accepting state. Modify the FSM so that each such state is also an accepting state. Thanks, I'll make every state of the FSM an accepting state. Not

Re: operator module functions

2014-10-08 Thread Ian Kelly
On Wed, Oct 8, 2014 at 3:05 PM, Gelonida N wrote: > On 10/8/2014 9:09 PM, Terry Reedy wrote: >> >> On 10/8/2014 6:57 AM, Steven D'Aprano wrote: >> >>> According to the documentation, operator.__add__ is the "official" >>> function, >>> and operator.add is just there for convenience. >> >> >> You a

Re: operator module functions

2014-10-08 Thread Gelonida N
On 10/8/2014 9:09 PM, Terry Reedy wrote: On 10/8/2014 6:57 AM, Steven D'Aprano wrote: According to the documentation, operator.__add__ is the "official" function, and operator.add is just there for convenience. You are paraphrasing "The function names are those used for special class methods;

Re: operator module functions

2014-10-08 Thread random832
On Wed, Oct 8, 2014, at 15:38, Ethan Furman wrote: > LOL, no kidding! The main reason I bother using the operator module is > for the readability of not seeing the dunders, > and the writability of not having to type them. I'm not sure what situation you would have to type them (as opposed to

Re: operator module functions

2014-10-08 Thread Ethan Furman
On 10/08/2014 12:09 PM, Terry Reedy wrote: On 10/8/2014 6:57 AM, Steven D'Aprano wrote: According to the documentation, operator.__add__ is the "official" function, and operator.add is just there for convenience. You are paraphrasing "The function names are those used for special class metho

Re: strange numpy behaviour

2014-10-08 Thread Ian Kelly
On Wed, Oct 8, 2014 at 10:29 AM, George Trojan wrote: > This does not look right: > > dilbert@gtrojan> python3.4 > Python 3.4.1 (default, Jul 7 2014, 15:47:25) > [GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux > Type "help", "copyright", "credits" or "license" for more information. import nu

strange numpy behaviour

2014-10-08 Thread George Trojan
This does not look right: dilbert@gtrojan> python3.4 Python 3.4.1 (default, Jul 7 2014, 15:47:25) [GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> a=np.ma.array([0, 1], dtype=np.int8, mask=[1, 0]) >>

Re: operator module functions

2014-10-08 Thread Terry Reedy
On 10/8/2014 6:57 AM, Steven D'Aprano wrote: According to the documentation, operator.__add__ is the "official" function, and operator.add is just there for convenience. You are paraphrasing "The function names are those used for special class methods; variants without leading and trailing __

Re: "High water" Memory fragmentation still a thing?

2014-10-08 Thread bryanjugglercryptographer
Chris Angelico wrote: > Sure, and that's all well and good. But what I just cited there *is* a > shipping product. That's a live server that runs a game that I'm admin > of. So it's possible to do without the resource safety net of periodic > restarts. Nice that the non-Python server you administe

Re: Practice question

2014-10-08 Thread Rustom Mody
On Wednesday, October 8, 2014 9:58:11 PM UTC+5:30, Skip Montanaro wrote: > On Wed, Oct 8, 2014 at 11:14 AM, Rustom Mody wrote: > > So pushing beginners away from print can push them up the learning > > curve more quickly > Or more quickly discourage them. I still use print for all sorts of > thin

Re: Practice question

2014-10-08 Thread Skip Montanaro
On Wed, Oct 8, 2014 at 11:14 AM, Rustom Mody wrote: > So pushing beginners away from print can push them up the learning > curve more quickly Or more quickly discourage them. I still use print for all sorts of things. In my opinion, there is often no need for fancy loggers, str.format, or the wri

Re: Practice question

2014-10-08 Thread Chris Angelico
On Thu, Oct 9, 2014 at 3:14 AM, Rustom Mody wrote: > The issue is not only that print is bad but that the interpreter is > good for learning and trying out. > > Are these two really unconnected. Lets see... One can > > - use print without the interpreter > - use the interpreter without print > - u

Re: Practice question

2014-10-08 Thread Rustom Mody
On Tuesday, October 7, 2014 2:19:39 AM UTC+5:30, Steven D'Aprano wrote: > I have fewer issues with your conclusion and analogy than I do with the > basic premise that there is a connection between Seymore's problem here > and the use, or non-use, of print in the interactive interpreter. I don't

Re: Another time question

2014-10-08 Thread Grant Edwards
On 2014-10-07, Seymore4Head wrote: > I never really cared enough to ask anyone, but something like my cable > bill is 98$ a month. Do companies (in general) consider a month every > 30 days or every time the 14th comes around? Either/both. My pre-pay T-Mobile account is every $30 every 30 day

Re: operator module functions

2014-10-08 Thread Steven D'Aprano
marco.naw...@colosso.nl wrote: > For me it makes sense. operator.add should be used in a "global" context > (I don't know how to express it otherwise). So you provide it with the > two values that you want to add. The .__add__ variants are bound to a > particular instance and you provide it with a

how to add custom importer after the normal imports

2014-10-08 Thread Gelonida N
Hi, I just read about sys.meta_path, which allows to install custom importers *BEFORE* the default importers. However I have a use case where I would like to add a custom importer *AFTER* all other import methods have failed. Does anybody know how to do this. One way of implementing this

Re: Pythonic way to iterate through multidimensional space?

2014-10-08 Thread Gelonida N
On 10/7/2014 1:01 PM, Ned Batchelder wrote: On 10/7/14 2:10 AM, Gelonida N wrote: Disadvantage of itertools.product() is, that it makes a copy in memory. Reason ist, that itertools also makes products of generators (meaning of objects, that one can't iterate several times through) There are t

Re: ruby instance variable in python

2014-10-08 Thread flebber
The end result of a confusing sentence with no > > context is that I have no idea what you are trying to say. Could you try > > explaining again please? > > > Steven No problem my reply from phone at work a little confusing. So trying to determine what this does. def ins_var @ins_var ||

Re: Python 3.4.1 on W2K

2014-10-08 Thread Pal Acreide
Here's another quick one -- under 30 secs. -- and then I'll revert to lurker status. It's one of my favorites: "Veritas" wine & liquor search. (Teetotalers, avert your eyes.) http://youtu.be/jDtm4z7kqyI Pal A. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.4.1 on W2K?

2014-10-08 Thread Pal Acreide
random832 wrote on Tue Oct 7 22:33:23 CEST 2014 >On Tue, Oct 7, 2014, at 16:27, Michael Torrie wrote: >>That's really interesting. I looked briefly at the page. How does your python extension work with xywrite? Does it manipulate xywrite >>documents >>or does it tie in at runtime with Xyw

Re: operator module functions

2014-10-08 Thread Chris Angelico
(You didn't include any context in your post. Please quote as much text as would be helpful; it's the easiest way to show what you're talking about.) On Wed, Oct 8, 2014 at 7:46 PM, wrote: > For me it makes sense. operator.add should be used in a "global" context > (I don't know how to express i

[RELEASE] Python 3.4.2 is now available

2014-10-08 Thread Larry Hastings
On behalf of the Python development community and the Python 3.4 release team, I'm pleased to announce the availability of Python 3.4.2. Python 3.4.2 has many bugfixes and other small improvements over 3.4.1. One new feature for Mac OS X users: the OS X installers are now distributed as sig

Re: operator module functions

2014-10-08 Thread marco . nawijn
For me it makes sense. operator.add should be used in a "global" context (I don't know how to express it otherwise). So you provide it with the two values that you want to add. The .__add__ variants are bound to a particular instance and you provide it with a single value that you want to add. Y

Re: How do I check if a string is a prefix of any possible other string that matches a given regex.

2014-10-08 Thread jonathan . slenders
Le mercredi 8 octobre 2014 01:40:11 UTC+2, MRAB a écrit : > If you're not interested in generating an actual regex, but only in > > matching the prefix, then it sounds like you want "partial matching". > > > > The regex module supports that: > > > > https://pypi.python.org/pypi/regex Wow, t

Re: help with regex

2014-10-08 Thread Ben Finney
Peter Otten <__pete...@web.de> writes: > >>> pattern = re.compile("(\d+)$") > >>> match = pattern.search( "LINE: 235 : Primary Shelf Number (attempt 1): 1") > >>> match.group() > '1' An alternative way to accomplish the above using the ‘match’ method:: >>> import re >>> pattern = re.comp