Re: correct way to catch exception with Python 'with' statement

2016-11-27 Thread Steven D'Aprano
On Monday 28 November 2016 17:09, Ganesh Pal wrote: > Dear Python friends, > > Any suggestion on how to add exception and make the below program look > better , I am using Python 2.7 and Linux > > > >

correct way to catch exception with Python 'with' statement

2016-11-27 Thread Ganesh Pal
Dear Python friends, Any suggestion on how to add exception and make the below program look better , I am using Python 2.7 and Linux def create_files_append(): """ """ try: os.makedir

[sphinx] generating doc from neighboring folders

2016-11-27 Thread alb
Hi there, we are evaluating the possibility to use Sphinx and rst to document our projects. What we have is a project structure that would look like this: ./sandbox/project/ ├── components │   ├── module1 │   │   ├── doc │   │   │   └── module1.rst │   │   └── src │   └── module2 │   ├── doc

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Jussi Piitulainen
Veek M writes: > Jussi Piitulainen wrote: > >> Veek M writes: >> >> [snip] >> >>> Also if one can do x.a = 10 or 20 or whatever, and the class instance >>> is mutable, then why do books keep stating that keys need to be >>> immutable? After all, __hash__ is the guy doing all the work and >>> ma

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Ned Batchelder
On Sunday, November 27, 2016 at 4:53:20 AM UTC-5, Veek M wrote: > I was reading this: > http://stackoverflow.com/questions/4418741/im-able-to-use-a-mutable-object-as-a-dictionary-key-in-python-is-this-not-disa > > In a User Defined Type, one can provide __hash__ that returns a integer > as a key

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
Veek M wrote: > Jussi Piitulainen wrote: > >> Veek M writes: >> >> [snip] >> >>> Also if one can do x.a = 10 or 20 or whatever, and the class >>> instance is mutable, then why do books keep stating that keys need >>> to be >>> immutable? After all, __hash__ is the guy doing all the work and >>

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
Jussi Piitulainen wrote: > Veek M writes: > > [snip] > >> Also if one can do x.a = 10 or 20 or whatever, and the class instance >> is mutable, then why do books keep stating that keys need to be >> immutable? After all, __hash__ is the guy doing all the work and >> maintaining consistency for u

Re: how do i fix this invalid arguement error

2016-11-27 Thread eryk sun
On Sat, Nov 26, 2016 at 5:55 PM, Dennis Lee Bieber wrote: > On Sat, 26 Nov 2016 08:12:46 -0800 (PST), junko...@gmail.com declaimed the > following: > >> with open('\\192.168.0.1\fe18cb0618cabd41\ninjatrader$EURUSDTestRun >> 2016-11-25-11-11.csv','r') as f: > > Second... does Python open() accept w

Re: dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Jussi Piitulainen
Veek M writes: [snip] > Also if one can do x.a = 10 or 20 or whatever, and the class instance > is mutable, then why do books keep stating that keys need to be > immutable? After all, __hash__ is the guy doing all the work and > maintaining consistency for us. One could do: > > class Fruit: >

dictionary mutability, hashability, __eq__, __hash__

2016-11-27 Thread Veek M
I was reading this: http://stackoverflow.com/questions/4418741/im-able-to-use-a-mutable-object-as-a-dictionary-key-in-python-is-this-not-disa In a User Defined Type, one can provide __hash__ that returns a integer as a key to a dictionary. so: d = { key : value } What is the significance of __