Re: for / while else doesn't make sense

2016-05-20 Thread Marko Rauhamaa
theh...@gmail.com: > You seem to have missed the point. Nobody is suggesting, I don't > believe, that all of a language should be intuitive. Rather that if > any part of it is unnecessarily counter-intuitive, it may be worth > looking for a better solution. Python is a very well designed language

Re: for / while else doesn't make sense

2016-05-20 Thread Rustom Mody
On Saturday, May 21, 2016 at 1:51:19 AM UTC+5:30, Christopher Reimer wrote: > On 5/20/2016 8:59 AM, Zachary Ware wrote: > > > On Fri, May 20, 2016 at 3:09 AM, Erik wrote: > >> On 20/05/16 00:51, Gregory Ewing wrote: > >>> It's not so bad with "else" because you need to look back > >>> to find out

Re: Summing/combining tuples

2016-05-20 Thread Dan Sommers
On Sat, 21 May 2016 03:19:49 +, Dan Sommers wrote: >> Is there something shorter and sweeter for the summation? > > from itertools import groupby > from operator import itemgetter > > result = [(k, >sum(map(itemgetter(2), v)), >sum(map(itemgetter(3

Re: How to memory dump an object?

2016-05-20 Thread Chris Angelico
On Sat, May 21, 2016 at 2:47 PM, wrote: > It's amazing the "tool" is so simple. Actually I feel a little embarrassed > that I do know every statements in it but just no idea of combining them > together. Thanks a lot, Chris. > It's a pretty complicated tool, actually - but you're using it in a

Re: How to memory dump an object?

2016-05-20 Thread Steven D'Aprano
On Sat, 21 May 2016 11:05 am, jf...@ms4.hinet.net wrote: > Is there any tools which can do the memory dump of an object so I can view > their content or implementation? No standard tool. There may be third-party tools, but they would be implementation-specific. > For example, > s1 = '\x

Re: How to memory dump an object?

2016-05-20 Thread jfong
Sorry, forget to mention that I am working on version 3.4 Following the steps given in Chris's reply, I get the result from bytes string: >>> b1 = b'\x80abc' >>> ctypes.cast(id(b1), ctypes.c_voidp) c_void_p(35495992) >>> sys.getsizeof(b1) 21 >>> b1ptr = ctypes.cast(id(b1), ctypes.POINTER(ctypes.c

Re: for / while else doesn't make sense

2016-05-20 Thread Chris Angelico
On Sat, May 21, 2016 at 1:50 PM, Steven D'Aprano wrote: > On Sat, 21 May 2016 10:24 am, Jon Ribbens wrote: > >> On 2016-05-20, Ethan Furman wrote: > >>> If you don't take the extra step of _break_ it is the usual case. >> >> Having an "for: else:" clause without a "break" would be so unusual >> t

Re: Extract the middle N chars of a string

2016-05-20 Thread boB Stepp
On Wed, May 18, 2016 at 10:47 AM, Steven D'Aprano wrote: > Getting the middle N seems like it ought to be easy: > > s[N//2:-N//2] > > but that is wrong. It's not even the right length! > > py> s = 'aardvark' > py> s[5//2:-5//2] > 'rdv' > > > So after spending a ridiculous amount of time on what s

Re: for / while else doesn't make sense

2016-05-20 Thread Steven D'Aprano
On Sat, 21 May 2016 10:24 am, Jon Ribbens wrote: > On 2016-05-20, Ethan Furman wrote: >> If you don't take the extra step of _break_ it is the usual case. > > Having an "for: else:" clause without a "break" would be so unusual > that it's literally nonexistent, because it would always be a bug.

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 7:31 PM, Chris Angelico wrote: On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer wrote: On 5/20/2016 3:43 PM, Steven D'Aprano wrote: But the idea that you should avoid a Python feature while programming in Python because Javascript doesn't have it, or Ruby, or C, is surely th

Re: Summing/combining tuples

2016-05-20 Thread Dan Sommers
On Wed, 18 May 2016 20:59:55 -0400, DFS wrote: > Have aList = [ > ('x','Name1', 1, 85), > ('x','Name2', 3, 219), > ('x','Name2', 1, 21), > ('x','Name3', 6, 169) > ] > > want > > aList = [ > ('Name1', 1, 85), > ('Name2', 4, 240), > ('Name3', 6, 169) > ] [snip] > Is there something shorter and

Re: for / while else doesn't make sense

2016-05-20 Thread Chris Angelico
On Sat, May 21, 2016 at 11:23 AM, Christopher Reimer wrote: > On 5/20/2016 3:43 PM, Steven D'Aprano wrote: > >> But the idea that you should avoid a Python feature while programming in >> Python because Javascript doesn't have it, or Ruby, or C, is surely the >> height of muddleheaded thinking. Yo

Re: How to memory dump an object?

2016-05-20 Thread Chris Angelico
On Sat, May 21, 2016 at 11:05 AM, wrote: > Is there any tools which can do the memory dump of an object so I can view > their content or implementation? For example, > s1 = '\x80abc' b1 = b'\x80abc' > > What are exactly stored in memory for each of them? Is their content really > the

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 3:43 PM, Steven D'Aprano wrote: But the idea that you should avoid a Python feature while programming in Python because Javascript doesn't have it, or Ruby, or C, is surely the height of muddleheaded thinking. You're not programming Javascript, Ruby or C, you're programming in Pytho

Re: for / while else doesn't make sense

2016-05-20 Thread Grant Edwards
On 2016-05-20, Steven D'Aprano wrote: > On Sat, 21 May 2016 05:20 am, Christopher Reimer wrote: > >> According to "Effective Python: 59 Specific Ways to Write Better Python" >> by Brett Slatkin, Item 12 recommends against using the else block after >> for and while loops (see page 25): "Avoid usin

Re: for / while else doesn't make sense

2016-05-20 Thread Chris Angelico
On Sat, May 21, 2016 at 10:35 AM, Jon Ribbens wrote: > On 2016-05-20, Steven D'Aprano wrote: >> By that logic, we ought to: >> >> - avoid using floats because their behaviour isn't intuitive and >> can be confusing; > > To be fair, I'm very sympathetic to that argument. I think programming > la

Re: How to memory dump an object?

2016-05-20 Thread Ned Batchelder
On Friday, May 20, 2016 at 9:05:51 PM UTC-4, jf...@ms4.hinet.net wrote: > Is there any tools which can do the memory dump of an object so I can view > their content or implementation? For example, > > >>> s1 = '\x80abc' > >>> b1 = b'\x80abc' > > What are exactly stored in memory for each of them

Graceful exit from Python + multiprocessing daemons

2016-05-20 Thread deva . seetharam
Hello, Greetings! I would like to get your advice wrt following situation: I have a Linux daemon written in python (version 2.7) using the python-daemon (https://pypi.python.org/pypi/python-daemon) module. The objective of using python daemon is to run as an init.d script in Linux. This gets i

How to memory dump an object?

2016-05-20 Thread jfong
Is there any tools which can do the memory dump of an object so I can view their content or implementation? For example, >>> s1 = '\x80abc' >>> b1 = b'\x80abc' What are exactly stored in memory for each of them? Is their content really the same? This kind of tool should be helpful "for me" to l

Re: for / while else doesn't make sense

2016-05-20 Thread Jon Ribbens
On 2016-05-20, Steven D'Aprano wrote: > By that logic, we ought to: > > - avoid using floats because their behaviour isn't intuitive and > can be confusing; To be fair, I'm very sympathetic to that argument. I think programming languages should never magically produce floats out of nowhere unle

Re: for / while else doesn't make sense

2016-05-20 Thread Jon Ribbens
On 2016-05-20, Ethan Furman wrote: > On 05/20/2016 04:55 AM, Jon Ribbens wrote: >> Certainly. "else:" is (almost?) invariably used in the situation where >> you are iterating through something in order to find a value which >> matches a certain condition. So the "for:" block means "find this >> va

Re: for / while else doesn't make sense

2016-05-20 Thread Ben Finney
Steven D'Aprano writes: > Just about the only things in Python which are intuitive and not > confusing to somebody are None and ints. I'll go even further: * The behaviour of ‘int’ is confusing to some. For example, to those who expect integers to produce fractions when divided. * The behavi

Re: for / while else doesn't make sense

2016-05-20 Thread Ethan Furman
On 05/20/2016 04:55 AM, Jon Ribbens wrote: On 2016-05-20, Steven D'Aprano wrote: On Fri, 20 May 2016 03:55 am, Jon Ribbens wrote: I guess we should thank our lucky stars that you don't have a time machine then, since that change would very much be one for the worse in my opinion. for...else i

Re: for / while else doesn't make sense

2016-05-20 Thread theherk
You seem to have missed the point. Nobody is suggesting, I don't believe, that all of a language should be intuitive. Rather that if any part of it is unnecessarily counter-intuitive, it may be worth looking for a better solution. Python is a very well designed language when it comes to in lingu

Re: for / while else doesn't make sense

2016-05-20 Thread Steven D'Aprano
On Sat, 21 May 2016 05:20 am, Christopher Reimer wrote: > According to "Effective Python: 59 Specific Ways to Write Better Python" > by Brett Slatkin, Item 12 recommends against using the else block after > for and while loops (see page 25): "Avoid using else blocks after loops > because their beh

Re: python for complte program ?

2016-05-20 Thread Joel Goldstick
On Fri, May 20, 2016 at 5:39 PM, Xristos Xristoou wrote: > hello i want to ask if a python is a good for to do it a complete > program(.exe)? > with user interface,module interface,background scripts where compile if > the users calls some scripts,windows with interaction with the users? > how ca

python for complte program ?

2016-05-20 Thread Xristos Xristoou
hello i want to ask if a python is a good for to do it a complete program(.exe)? with user interface,module interface,background scripts where compile if the users calls some scripts,windows with interaction with the users? how can i do that with the python? how can libs need for this ? some tutor

errors with QGIS API USING PYTHON

2016-05-20 Thread Xristos Xristoou
i want to use python API from the QGIS in my python idle out from QGIS program , but i have some errors if i try to import qgis.core in my idle. i have python 2.7 64 bit (my version) and i install QGIS via OSGeo4W64. first i try to set two PATHS PYTHONPATH = C:\OSGeo4W64\apps\qgis\pythonPYTHONP

Re: for / while else doesn't make sense

2016-05-20 Thread Christopher Reimer
On 5/20/2016 8:59 AM, Zachary Ware wrote: On Fri, May 20, 2016 at 3:09 AM, Erik wrote: On 20/05/16 00:51, Gregory Ewing wrote: It's not so bad with "else" because you need to look back to find out what condition the "else" refers to anyway. With my tongue only slightly in my cheek, if it wa

Re: How do I subclass the @property setter method?

2016-05-20 Thread Christopher Reimer
On 5/20/2016 11:50 AM, Christopher Reimer wrote: This code does work, blows up the unit test, and keeps PyCharm happy. @property def position(self): return super().position @position.setter def position(self, position): pass Re-declaring @property and calling s

How do I subclass the @property setter method?

2016-05-20 Thread Christopher Reimer
Greetings, My chess engine has a Piece class with the following methods that use the @property decorator to read and write the position value. @property def position(self): return self._position @position.setter def position(self, position): if self._first_move

Re: for / while else doesn't make sense

2016-05-20 Thread Zachary Ware
On Fri, May 20, 2016 at 3:09 AM, Erik wrote: > On 20/05/16 00:51, Gregory Ewing wrote: >> >> It's not so bad with "else" because you need to look back >> to find out what condition the "else" refers to anyway. > > > With my tongue only slightly in my cheek, if it was desirable to > "fix"/clarify t

Re: JNLP File download and run

2016-05-20 Thread Michael Torrie
On 05/20/2016 01:30 AM, Robert Clove wrote: > Hi, > > Can someone give me pseudo code to download and JNLP file from a URL and > run it? > > Looks like a advance concept in python You could use the urllib module to download the file, then use the subprocess module to spawn the javaws executable

Re: for / while else doesn't make sense

2016-05-20 Thread Michael Selik
On Thu, May 19, 2016 at 1:04 PM Ian Kelly wrote: > On Thu, May 19, 2016 at 10:31 AM, Herkermer Sherwood > wrote: > > Most keywords in Python make linguistic sense, but using "else" in for > and > > while structures is kludgy and misleading. I am under the assumption that > > this was just utiliz

Re: Wanted Python programmer to join team

2016-05-20 Thread Mike Driscoll
On Tuesday, May 17, 2016 at 12:20:53 AM UTC-5, Steven D'Aprano wrote: > On Tuesday 17 May 2016 12:56, Chris Angelico wrote: > > > On Tue, May 17, 2016 at 12:37 PM, Steven D'Aprano <> > > wrote: > >> On Tue, 17 May 2016 09:07 am, Chris Angelico wrote: > >> > >>> I'm not overly bothered by the use o

EuroPython 2016 Keynote: Jameson Rollins

2016-05-20 Thread M.-A. Lemburg
We are pleased to introduce our second keynote speaker for EuroPython 2016: *** Jameson Rollins *** About Jameson Rollins - Jameson is a staff scientist in the LIGO project, based at the California Institute of Technology: "I have worked on many as

Re: for / while else doesn't make sense

2016-05-20 Thread Jon Ribbens
On 2016-05-20, Steven D'Aprano wrote: > On Fri, 20 May 2016 03:55 am, Jon Ribbens wrote: >> I guess we should thank our lucky stars that you don't have a time >> machine then, since that change would very much be one for the worse >> in my opinion. for...else is perfectly straightforward and clear

Call to Python backtrace listing packages - show the exact location

2016-05-20 Thread rocky
A little while ago I wrote uncompyle6 which can deparse Python C bytecode. Currently it runs on 2.6-2.7 and 3.2 and up. I think an underused part of that is that you can at runtime give it a bytecode offset and it will show you where inside a line you are at. It also can show the surrounding e

Re: Python script reading from sys.stdin and debugger

2016-05-20 Thread rocky
On Thursday, May 19, 2016 at 5:10:08 PM UTC-4, Fillmore wrote: > Hello PyMasters! > > Long story short: > > cat myfile.txt | python -m pdb myscript.py > > doens't work (pdb hijacking stdin?). > > Google indicates that someone has fixed this with named pipes, but, call > me stupid, I don't unde

Re: for / while else doesn't make sense

2016-05-20 Thread Erik
On 20/05/16 00:51, Gregory Ewing wrote: It's not so bad with "else" because you need to look back to find out what condition the "else" refers to anyway. With my tongue only slightly in my cheek, if it was desirable to "fix"/clarify this syntax then I would suggest adding some optional (exist

JNLP File download and run

2016-05-20 Thread Robert Clove
Hi, Can someone give me pseudo code to download and JNLP file from a URL and run it? Looks like a advance concept in python Regards -- https://mail.python.org/mailman/listinfo/python-list