Re: Difference method vs attribut = function

2024-06-30 Thread Dieter Maurer via Python-list
Ulrich Goebel wrote at 2024-6-28 18:08 +0200: >Hi, > >a class can have methods, and it can have attributes, which can hold a >function. Both is well known, of course. > >My question: Is there any difference? I think you should make the distinction "class versus instance attribute" rather than "me

Re: Difference method vs attribut = function

2024-06-29 Thread Thomas Passin via Python-list
On 6/28/2024 12:08 PM, Ulrich Goebel via Python-list wrote: Hi, a class can have methods, and it can have attributes, which can hold a function. Both is well known, of course. My question: Is there any difference? The code snipped shows that both do what they should do. But __dict__ includes

Re: Difference method vs attribut = function

2024-06-29 Thread Mats Wichmann via Python-list
On 6/28/24 10:08, Ulrich Goebel via Python-list wrote: By the way: in my usecase I want to pass different functions to different instances of MyClass. It is in the context of a database app where I build Getters for database data and pass one Getter per instance. If I understood what you're

Re: Difference method vs attribut = function

2024-06-29 Thread Peter J. Holzer via Python-list
On 2024-06-28 18:08:54 +0200, Ulrich Goebel via Python-list wrote: > a class can have methods, and it can have attributes, which can hold a > function. Both is well known, of course. > > My question: Is there any difference? > > The code snipped shows that both do what they should do. But __dict_

Re: Difference in Setup Between Windows 10 Running Python 3.9 and Windows 11 Running Python 3.10

2022-05-03 Thread Eryk Sun
On 5/1/22, Brent Hunter wrote: > > I was recently running a Windows 10 machine Python 3.9. I simply created a > batch file titled "Start-AIG.bat" which simply contained the following: > "pythonw AIG.py". It started a python program titled "AIG.py" and the > Python dialog box was displayed on my

Re: Difference in Setup Between Windows 10 Running Python 3.9 and Windows 11 Running Python 3.10

2022-05-01 Thread MRAB
On 2022-05-02 02:56, Brent Hunter wrote: Hello, I was recently running a Windows 10 machine Python 3.9. I simply created a batch file titled "Start-AIG.bat" which simply contained the following: "pythonw AIG.py". It started a python program titled "AIG.py" and the Python dialog box was displ

Re: Difference between os.path.isdir and Path.is_dir

2019-12-14 Thread Kirill Balunov
Yeah it is True, for the last two weeks or so I can access bugs.python.org in normal way. But I totally agree with the site that the best description of this situation is "Yet". with kind regards, -gdg сб, 14 дек. 2019 г. в 19:46, Terry Reedy : > On 7/26/2019 3:12 AM, Kirill Balunov wrote: > > ч

Re: Difference between os.path.isdir and Path.is_dir

2019-12-14 Thread Terry Reedy
On 7/26/2019 3:12 AM, Kirill Balunov wrote: чт, 25 июл. 2019 г. в 20:28, eryk sun : On 7/25/19, Kirill Balunov wrote: import os from pathlib import Path dummy = " " # or "" or " " os.path.isdir(dummy) False Path(dummy).is_dir() True I can't reproduce the above result in either Li

Re: Difference between os.path.isdir and Path.is_dir

2019-07-26 Thread Kirill Balunov
чт, 25 июл. 2019 г. в 20:28, eryk sun : > On 7/25/19, Kirill Balunov wrote: > > > import os > from pathlib import Path > dummy = " " # or "" or " " > os.path.isdir(dummy) > > False > Path(dummy).is_dir() > > True > > I can't reproduce the above result in either Linu

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Cameron Simpson
On 26Jul2019 03:43, Chris Angelico wrote: On Fri, Jul 26, 2019 at 3:28 AM eryk sun wrote: On 7/25/19, Kirill Balunov wrote: import os from pathlib import Path dummy = " " # or "" or " " os.path.isdir(dummy) > False Path(dummy).is_dir() > True I can't reproduce

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Cameron Simpson
On 25Jul2019 13:40, eryk sun wrote: Windows trims trailing spaces and dots from the final component of a path, unless we use a non-normalized \\?\ path. Hoo! Well, that explains some extremely weird NAS behaviour I encountered the other month with some paths ending in spaces. (My machine and

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Chris Angelico
On Fri, Jul 26, 2019 at 6:13 AM Kirill Balunov wrote: > > > > чт, 25 июл. 2019 г. в 22:58, Chris Angelico : >> >> On Fri, Jul 26, 2019 at 5:52 AM Kirill Balunov >> wrote: >> [...] >> > No, it's not just because of curiosity. I will try to tell the background, >> > and maybe I went the wrong way

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Kirill Balunov
чт, 25 июл. 2019 г. в 22:58, Chris Angelico : > On Fri, Jul 26, 2019 at 5:52 AM Kirill Balunov > wrote: > [...] > > No, it's not just because of curiosity. I will try to tell the > background, and maybe I went the wrong way initially. There is a very cool > project https://github.com/3b1b/manim,

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Chris Angelico
On Fri, Jul 26, 2019 at 5:52 AM Kirill Balunov wrote: > > > > чт, 25 июл. 2019 г. в 19:16, Chris Angelico : >> >> On Fri, Jul 26, 2019 at 1:30 AM Kirill Balunov >> wrote: >> > >> > Hi all! It is expected that: >> > ``` >> > >>> import os >> > >>> from pathlib import Path >> > >>> dummy = " "

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Kirill Balunov
чт, 25 июл. 2019 г. в 19:16, Chris Angelico : > On Fri, Jul 26, 2019 at 1:30 AM Kirill Balunov > wrote: > > > > Hi all! It is expected that: > > ``` > > >>> import os > > >>> from pathlib import Path > > >>> dummy = " " # or "" or " " > > >>> os.path.isdir(dummy) > > False > > >>> Path(dum

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Kirill Balunov
чт, 25 июл. 2019 г. в 20:28, eryk sun : > On 7/25/19, Kirill Balunov wrote: > > > import os > from pathlib import Path > dummy = " " # or "" or " " > os.path.isdir(dummy) > > False > Path(dummy).is_dir() > > True > > I can't reproduce the above result in either Linu

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread eryk sun
On 7/25/19, Chris Angelico wrote: > On Fri, Jul 26, 2019 at 3:54 AM eryk sun wrote: > >> That's what I said. But the OP shows os.path.isdir(" ") == False and >> Path(" ").is_dir() == True, which is what I cannot reproduce and >> really should not be able to reproduce, unless there's a bug >> some

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Chris Angelico
On Fri, Jul 26, 2019 at 3:54 AM eryk sun wrote: > > On 7/25/19, Chris Angelico wrote: > > On Fri, Jul 26, 2019 at 3:28 AM eryk sun wrote: > >> > >> On 7/25/19, Kirill Balunov wrote: > >> > > >> import os > >> from pathlib import Path > >> dummy = " " # or "" or " " > >> >>>

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread eryk sun
On 7/25/19, Chris Angelico wrote: > On Fri, Jul 26, 2019 at 3:28 AM eryk sun wrote: >> >> On 7/25/19, Kirill Balunov wrote: >> > >> import os >> from pathlib import Path >> dummy = " " # or "" or " " >> os.path.isdir(dummy) >> > False >> Path(dummy).is_dir() >> > T

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Chris Angelico
On Fri, Jul 26, 2019 at 3:28 AM eryk sun wrote: > > On 7/25/19, Kirill Balunov wrote: > > > import os > from pathlib import Path > dummy = " " # or "" or " " > os.path.isdir(dummy) > > False > Path(dummy).is_dir() > > True > > I can't reproduce the above result in e

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread eryk sun
On 7/25/19, Kirill Balunov wrote: > import os from pathlib import Path dummy = " " # or "" or " " os.path.isdir(dummy) > False Path(dummy).is_dir() > True I can't reproduce the above result in either Linux or Windows. The results should only be different for an empt

Re: Difference between os.path.isdir and Path.is_dir

2019-07-25 Thread Chris Angelico
On Fri, Jul 26, 2019 at 1:30 AM Kirill Balunov wrote: > > Hi all! It is expected that: > ``` > >>> import os > >>> from pathlib import Path > >>> dummy = " " # or "" or " " > >>> os.path.isdir(dummy) > False > >>> Path(dummy).is_dir() > True > ``` > > or was it overlooked? > Was not aware

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-22 Thread Markos
Thanks Edmondo, Stephen, Mats and Steven you for the tips, I studied linear algebra many years ago and I remember only a few rudiments. But I was trying to visualize (in a geometric way) how the numpy represents arrays, and what the geometrical meaning of the transpose operation made by numpy.

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread MRAB
On 2019-06-21 02:39, Markos wrote: Hi, I'm studying Numpy and I don't understand the difference between vector_1 = np.array( [ 1,0,1 ] ) with 1 bracket and vector_2 = np.array( [ [ 1,0,1 ] ] ) with 2 brackets The shape of vector_1 is: vector_1.shape (3,) But the shape of vector_2 i

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread edmondo . giovannozzi
Keep also in mind that numpy is quite different from Matlab. In Matlab every vaiable is a matrix of at least 2 dimensions. This is not the case of numpy (and is not the case in Fortran too). every array can have a different number of dimensions. The transposition of an array with just 1 dimension

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread edmondo . giovannozzi
Every array in numpy has a number of dimensions, "np.array" is a function that can create an array numpy given a list. when you write vector_1 = np.array([1,2,1]) you are passing a list of number to thet function array that will create a 1D array. As you are showing: vector_1.shape will retur

Re: Difference between array( [1,0,1] ) and array( [ [1,0,1] ] )

2019-06-21 Thread Stephen Tucker
Markos, I can explain the difference from a non-numpy point of view - I hope you will be able to see how this difference affects what you are trying to do in numpy. vector_1 is an np.array consisting of a three-element list, with the three elements being 1, 0 and 1. vector_2 is an np.array consi

Re: Difference in behavior of GenericMeta between 3.6.0 and 3.6.1

2017-07-16 Thread Oren Ben-Kiki
Yes, it sort-of makes sense... I'll basically re-post my question there. Thanks for the link! Oren. On Sun, Jul 16, 2017 at 4:29 PM, Peter Otten <__pete...@web.de> wrote: > Oren Ben-Kiki wrote: > > > TL;DR: We need improved documentation of the way meta-classes behave for > > generic classes,

Re: Difference in behavior of GenericMeta between 3.6.0 and 3.6.1

2017-07-16 Thread Peter Otten
Oren Ben-Kiki wrote: > TL;DR: We need improved documentation of the way meta-classes behave for > generic classes, and possibly reconsider the way "__setattr__" and > "__getattribute__" behave for such classes. The typing module is marked as "provisional", so you probably have to live with the i

Re: difference with parenthese

2016-10-17 Thread chenyong20000
Hi Wolfgang, thanks for your kind reply. I got. regards skyworld -- https://mail.python.org/mailman/listinfo/python-list

Re: difference with parenthese

2016-10-17 Thread Wolfgang Maier
On 17.10.2016 16:45, chenyong20...@gmail.com wrote: Hi Wolfgang, thanks for your kind reply. I try to explain what I got from your reply: for code1, when running "foo = outer()", since outer() is callable, function outer() is running and it returns an object, which referring to function inner(

Re: difference with parenthese

2016-10-17 Thread chenyong20000
Hi Wolfgang, thanks for your kind reply. I try to explain what I got from your reply: for code1, when running "foo = outer()", since outer() is callable, function outer() is running and it returns an object, which referring to function inner(). When "foo" is running, it indicates it is referrin

Re: difference with parenthese

2016-10-17 Thread Wolfgang Maier
On 17.10.2016 10:52, chenyong20...@gmail.com wrote: Hi, i'm confused by a piece of code with parenthese as this: code 1-- def outer(): ... def inner(): ... print 'inside inner' ... return inner ... foo = outer() foo foo() inside inner

Re: Difference in RE between 3.2 and 3.3 (or Aaron Swartz memorial)

2013-03-06 Thread Matej Cepl
On 2013-02-26, 16:25 GMT, Terry Reedy wrote: > On 2/21/2013 4:22 PM, Matej Cepl wrote: >> as my method to commemorate Aaron Swartz, I have decided to port his >> html2text to work fully with the latest python 3.3. After some time >> dealing with various bugs, I have now in my repo >> https://github

Re: Difference in RE between 3.2 and 3.3 (or Aaron Swartz memorial)

2013-02-26 Thread Terry Reedy
On 2/21/2013 4:22 PM, Matej Cepl wrote: as my method to commemorate Aaron Swartz, I have decided to port his html2text to work fully with the latest python 3.3. After some time dealing with various bugs, I have now in my repo https://github.com/mcepl/html2text (branch python3) working solution wh

Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 1:21 PM, wrote: > Repr and Eval I think I get. Eval certainly. That's a familiar concept, and > one I hope to use tomorrow to feed a line to psycopg2. I hope not. Why do you need eval? It's extremely dangerous. Chances are there's a better way to do it; if your users are

Re: Difference between these two lists?

2013-01-07 Thread andydtaylor
Thanks, I think I'm clear now. I guess (map(str, stn_list)) was all about how to make a string starting with integers. I picked that up and began using it without realising it was over catering for a list already containing strings, and join(stn_list) was really all I required. Repr and Eval

Re: Difference between these two lists?

2013-01-07 Thread Dave Angel
On 01/07/2013 08:00 PM, andydtay...@gmail.com wrote: > Hi, > > Python newbie here again - this is probably a quick one. What's the > difference between the lines I've numbered 1. and 2. below, which produce the > following results: > > Results: > 1. [ANG, BAR, BPK, CTN, QGH, QHD, KXX] > 2. ['ANG

Re: Difference between these two lists?

2013-01-07 Thread Roy Smith
In article <700d2bd9-e1df-4d38-81c7-77029a36c...@googlegroups.com>, andydtay...@gmail.com wrote: > Hi, > > Python newbie here again - this is probably a quick one. What's the > difference between the lines I've numbered 1. and 2. below, which produce the > following results: > > Results: > 1

Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 12:06 PM, wrote: > I think I can answer my own question on reflection the first one is > actually a string I think? I was confused by the square brackets around the > placeholder %s. That's correct. Your first line is putting square brackets around a comma-joined li

Re: Difference between these two lists?

2013-01-07 Thread Chris Angelico
On Tue, Jan 8, 2013 at 12:00 PM, wrote: > Hi, > > Python newbie here again - this is probably a quick one. What's the > difference between the lines I've numbered 1. and 2. below, which produce the > following results: >1. print stn_fields = '[%s]' % ', '.join(map(str, stn_list_short)) >

Re: Difference between these two lists?

2013-01-07 Thread andydtaylor
I think I can answer my own question on reflection the first one is actually a string I think? I was confused by the square brackets around the placeholder %s. -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between range and xrange ??

2012-11-05 Thread Terry Reedy
On 11/5/2012 9:23 AM, inshu chauhan wrote: what is the difference between range and xrange.. both seem to work the same. ? >>> range(3) [0, 1, 2] >>> xrange(3) xrange(3) You should read the appropriate manual entries before asking trivial questions. They say pretty clearly that range returns

Re: Difference between range and xrange ??

2012-11-05 Thread Joel Goldstick
in python 2.x xrange is a generator and range returns a list. In python 3.x xrange is renamed to range replacing the list function with the generator On Mon, Nov 5, 2012 at 9:23 AM, inshu chauhan wrote: > what is the difference between range and xrange.. both seem to work the > same. ? And whi

Re: Difference between range and xrange ??

2012-11-05 Thread Dave Angel
On 11/05/2012 09:23 AM, inshu chauhan wrote: > what is the difference between range and xrange.. both seem to work the > same. ? And which should be used where and in what situations.. ?? > > One difference is that from versions of Python 3.0 and later, xrange doesn't exist, and range takes over

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-17 Thread Terry Reedy
On 5/17/2012 4:23 AM, Devin Jeanpierre wrote: str.isdecimal = isdecimal(...) S.isdecimal() -> bool Return True if there are only decimal characters in S, False otherwise. Help on method_descriptor in str: str.isdigit = isdigit(...) S.isdigit() -> bool Return True i

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-17 Thread Devin Jeanpierre
On Wed, May 16, 2012 at 5:07 PM, Thomas 'PointedEars' Lahn wrote: > RTFM. > > $ python3 -c 'print("42".isdecimal.__doc__ + "\n"); > print("42".isdigit.__doc__)' Heh, don't print docstrings. Use pydoc. $ ( export PAGER=cat && pydoc3 str.isdecimal && pydoc3 str.isdigit ) Help on method_descriptor

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-17 Thread Marco
On 05/17/2012 02:15 AM, Steven D'Aprano wrote: the Fine Manual has more detail, although I admit it isn't *entirely* clear what it is talking about if you're not a Unicode expert: http://docs.python.org/py3k/library/stdtypes.html#str.isdecimal You are right, that is clear, thanks :) Exampl

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Steven D'Aprano
On Wed, 16 May 2012 17:48:19 +0200, Marco wrote: > Hi all, because > > "There should be one-- and preferably only one --obvious way to do it", > > there should be a difference between the two methods in the subject, but > I can't find it: The Fine Manual has more detail, although I admit it isn

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 3:07 PM, Thomas 'PointedEars' Lahn wrote: > RTFM. > > $ python3 -c 'print("42".isdecimal.__doc__ + "\n"); > print("42".isdigit.__doc__)' > S.isdecimal() -> bool > > Return True if there are only decimal characters in S, > False otherwise. > > S.isdigit() -> bool > > Return

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Thomas 'PointedEars' Lahn
Marco wrote: > Hi all, because > > "There should be one-- and preferably only one --obvious way to do it", > > there should be a difference between the two methods in the subject, but > I can't find it: > > >>> '123'.isdecimal(), '123'.isdigit() > (True, True) > >>> print('\u0660123') > ٠123

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread jmfauth
On 16 mai, 17:48, Marco wrote: > Hi all, because > > "There should be one-- and preferably only one --obvious way to do it", > > there should be a difference between the two methods in the subject, but > I can't find it: > >  >>> '123'.isdecimal(), '123'.isdigit() > (True, True) >  >>> print('\u06

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Marco
On 05/16/2012 06:24 PM, Ulrich Eckhardt wrote: Marco wrote: >>>> '123'.isdecimal(), '123'.isdigit() > (True, True) >>>> print('\u0660123') > ٠123 >>>> '\u0660123'.isdigit(), '\u0660123'.isdecimal() > (True, True) >>>> print('\u216B') > Ⅻ >>>> '\u216B'.isdecimal(), '

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 10:24 AM, Ulrich Eckhardt wrote: > Marco wrote: >>  >>> '123'.isdecimal(), '123'.isdigit() >> (True, True) >>  >>> print('\u0660123') >> ٠123 >>  >>> '\u0660123'.isdigit(), '\u0660123'.isdecimal() >> (True, True) >>  >>> print('\u216B') >> Ⅻ >>  >>> '\u216B'.isdecimal(), '\

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ulrich Eckhardt
Marco wrote: > >>> '123'.isdecimal(), '123'.isdigit() > (True, True) > >>> print('\u0660123') > ٠123 > >>> '\u0660123'.isdigit(), '\u0660123'.isdecimal() > (True, True) > >>> print('\u216B') > Ⅻ > >>> '\u216B'.isdecimal(), '\u216B'.isdigit() > (False, False) [chr(a) for a in range(0x2) if

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread MRAB
On 16/05/2012 16:48, Marco wrote: Hi all, because "There should be one-- and preferably only one --obvious way to do it", there should be a difference between the two methods in the subject, but I can't find it: >>> '123'.isdecimal(), '123'.isdigit() (True, True) >>> print('\u0660123') ٠

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-16 Thread Ian Kelly
On Wed, May 16, 2012 at 9:48 AM, Marco wrote: > Hi all, because > > "There should be one-- and preferably only one --obvious way to do it", > > there should be a difference between the two methods in the subject, but I > can't find it: > '123'.isdecimal(), '123'.isdigit() > (True, True)

Re: Difference between 'imp' and 'importlib'

2012-04-20 Thread Eric Snow
On Fri, Apr 20, 2012 at 1:30 AM, Frank Millman wrote: > Hi all > > I need the ability to execute a function by parsing a string containing the > full path to the function. The string is multi-dotted. The last element is > the function name, the second-last is the name of the module containing the

Re: Difference between tempfile and spooled tempfile?

2012-04-05 Thread Steve Howell
On Apr 5, 8:10 am, Steve Howell wrote: > On Apr 5, 7:50 am, "Alex van der Spek" wrote: > > > > > > > > > > > I do not understand why the spooled write gives an error. See below. > > The normal tempfile works just fine. They are supposed to behave equal? > > > All insight you can provide is welcom

Re: Difference between tempfile and spooled tempfile?

2012-04-05 Thread Steve Howell
On Apr 5, 7:50 am, "Alex van der Spek" wrote: > I do not understand why the spooled write gives an error. See below. > The normal tempfile works just fine. They are supposed to behave equal? > > All insight you can provide is welcome. > Alex van der Spek > > +++

Re: Difference between json.load() and json.loads() [From: RE: question about file handling with "with"]

2012-03-28 Thread Nadir Sampaoli
2012/3/28 ian douglas > > The functions with an s take string parameters. The others take file > streams. > > foo = '{"age": 38}' > my_json = json.loads(foo) > I see, it makes perfectly sense now. Thanks for clearing it up. -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between json.load() and json.loads() [From: RE: question about file handling with "with"]

2012-03-28 Thread ian douglas
On Mar 28, 2012 6:54 AM, "Nadir Sampaoli" wrote: > > Hello everyone (my first message in the mailing list), > >> >> > Is the following function correct? >> Yes, though I'd use json.load(f) instead of json.loads(). > > > The docs aren't very clear (at least for me) about the difference between json

Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Ulrich Eckhardt
Am 06.02.2012 09:45, schrieb Matej Cepl: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Two approaches come

Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Serhiy Storchaka
07.02.12 00:06, Matej Cepl написав(ла): > return seq[int(random.random() * len(seq))] > > doesn't seem like something so terrible (and maintenance intense). :) _choice('abc') returns 'a' with probability P('a') = 1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with probabi

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
On 6.2.2012 20:26, Tim Chase wrote: In an ideal world, the code wouldn't have broken backwards compat. However, given the conditions, if Matej is willing to forgo bug-fixes, it's a reasonable solution. The alternate might be to try moving the recent/fixed version into the old project and updating

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Tim Chase
On 02/06/12 12:48, Aaron France wrote: On 02/06/2012 09:57 AM, Matej Cepl wrote: Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj Is the above actually a good idea though? What I understand you're doing is embedding the source from th

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Aaron France
On 02/06/2012 09:57 AM, Matej Cepl wrote: On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Mel Wilson
Steven D'Aprano wrote: > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Silly, of course, the s

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
On 6.2.2012 09:05, Steven D'Aprano wrote: You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improve

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Steven D'Aprano
On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote: [...] >> and should be treated as a bug. Raymond made a strong case arguing for >> repeatability, and then approved a bug fix that broke repeatability. I >> doubt that was deliberate. > > It was deliberate that randrange was changed to an eve

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
On 2/6/2012 12:56 AM, Steven D'Aprano wrote: On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: On 2/5/2012 11:01 PM, Steven D'Aprano wrote: Reading the docs, I would expect that when using an int as seed, you should get identical results. That is similar to expecting hash to be consist

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > >> Reading the docs, I would expect that when using an int as seed, you >> should get identical results. > > That is similar to expecting hash to be consistent from version to > version. No.

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
On 2/5/2012 11:01 PM, Steven D'Aprano wrote: Reading the docs, I would expect that when using an int as seed, you should get identical results. That is similar to expecting hash to be consistent from version to version. There is no mention that the PRNG has changed between 2.6 and 3.2; The

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote: > Strange thing is that this unit tests correctly with python3, but fails > with python2. The problem is that apparently python3 random.choice picks > different element of self[k] than the one python2 (at least, both of > them are constant in t

Re: difference between python and matlab

2011-01-21 Thread Andrea Ambu
On 20 January 2011 15:16, lakshmi wrote: > Is the programming related to image processing in python is advantageous or > else in MATLAB > Matlab comes with a lot of builtins for image processing, pattern recognition and many other engineering-related things. If it's just a quick hack and you're

Re: difference between python and matlab

2011-01-21 Thread Thomas Jollans
On Thursday 20 January 2011, it occurred to lakshmi to exclaim: > Is the programming related to image processing in python is advantageous or > else in MATLAB Tell us what you want to do, and what you know about doing this in Python and in MATLAB, if possible, ask a specific question. Then, someb

Re: difference between %s and %d

2010-10-01 Thread Arnaud Delobelle
Ethan Furman writes: > If I'm printing the number 735, or any other positive or negative > integer, is there any difference between %7s and %7d? > > ~Ethan~ To link with another thread: >>> "%s" % True 'True' >>> "%d" % True '1' -- Arnaud -- http://mail.python.org/mailman/listinfo/python-lis

Re: difference between %s and %d

2010-10-01 Thread Ethan Furman
Ethan Furman wrote: If I'm printing the number 735, or any other positive or negative integer, is there any difference between %7s and %7d? Grant Edwards wrote: > Let's ask Python: > > --> [n for n in range(-,,123) if ("%7d" % n) > != ("%7s" % n)] > [] > > --> [n

Re: difference between %s and %d

2010-10-01 Thread MRAB
On 01/10/2010 20:15, Ethan Furman wrote: If I'm printing the number 735, or any other positive or negative integer, is there any difference between %7s and %7d? "%s" uses str(). In Python 2.7: >>> class MyInt(int): ... def __init__(self, value): ... int.__init__(self, value) ...

Re: difference between %s and %d

2010-10-01 Thread Grant Edwards
On 2010-10-01, Ethan Furman wrote: > If I'm printing the number 735, or any other positive or negative > integer, is there any difference between %7s and %7d? Let's ask Python: >>> [n for n in range(-,,123) if ("%7d" % n) != ("%7s" % n)] [] >>> [n for n in range(-9,99

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Ethan Furman
Nobody wrote: On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications. Isn

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Nobody
On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: >> basically a Queue is a syncronization primitive used to >> share and pass data to and from parent/child processes. >> >> A pipe is as the name suggests, a socket pair connected >> end-to-end allowing for full-duplex communications. >> >

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Ethan Furman
James Mills wrote: On Wed, Aug 4, 2010 at 7:20 PM, Navkirat Singh wrote: I was wondering what are the differences between queues and pipes implemented using multiprocessing python module. Am I correct if I say, in pipes, if another process writes to one receiving end concurrently, then an err

Re: Difference between queues and pipes in multiprocessing

2010-08-04 Thread James Mills
On Wed, Aug 4, 2010 at 7:20 PM, Navkirat Singh wrote: > I was wondering what are the differences between queues and pipes implemented > using multiprocessing python module. Am I correct if I say, in pipes, if > another process writes to one receiving end concurrently, then an error will > be ra

Re: Difference between import in script and from interpreter

2010-07-19 Thread Jean-Michel Pichavant
Steven D'Aprano wrote: On Mon, 19 Jul 2010 00:53:56 -0400, Edward Diener wrote: In a python script a: from xxx.yyy.zzz import aaa fails with the message: "ImportError: No module named xxx.yyy.zzz" but from within the python interpreter the same line succeeds. What would be the causes of

Re: Difference between import in script and from interpreter

2010-07-19 Thread News123
Edward Diener wrote: > In a python script a: > > from xxx.yyy.zzz import aaa > > fails with the message: > > "ImportError: No module named xxx.yyy.zzz" > > but from within the python interpreter the same line succeeds. What > would be the causes of that ? > > From within the python interpreter

Re: Difference between import in script and from interpreter

2010-07-18 Thread Steven D'Aprano
On Mon, 19 Jul 2010 00:53:56 -0400, Edward Diener wrote: > In a python script a: > > from xxx.yyy.zzz import aaa > > fails with the message: > > "ImportError: No module named xxx.yyy.zzz" > > but from within the python interpreter the same line succeeds. What > would be the causes of that ? >

Re: Difference between 'is not' and '!=' ?

2010-05-10 Thread Christian Heimes
AON LAZIO wrote: As subject says, what is the differences of 'is not' and '!='. Confusing.. "is not" checks if two objects are not identical. "!=" checks if two objects are not equal. Example: Two apples may be equal in size, form and color but they can never be identical because they are m

Re: Difference between 'is not' and '!=' ?

2010-05-10 Thread Chris Rebert
On Mon, May 10, 2010 at 4:25 PM, AON LAZIO wrote: > As subject says, what is the differences of 'is not' and '!='. Confusing.. != checks value inequality, `is not` checks object identity / "pointer" inequality Unless you're doing `foo is not None`, you almost always want !=. By way of demonstrat

Re: Difference between Popen and open() for reading a file

2010-04-30 Thread Aahz
In article , J wrote: > >Say I had a file, foo.txt that I wanted to read from, only one time >and only read. > >So what's the difference between this: > >mylist = Popen(["cat","foo.txt"], stdout=PIPE).communicate()[0].splitlines() > >Is there a reason why you would not use subprocess.Popen for th

Re: Difference between Popen and open() for reading a file

2010-04-22 Thread J
On Thu, Apr 22, 2010 at 15:18, Dave Angel wrote: > The same difference as between handing the paper boy three bucks, versus > flying to London to open an account, making a deposit, going to a branch in > Sydney and asking for a bank check, then flying back home and taking the > paper boy with you

Re: Difference between Popen and open() for reading a file

2010-04-22 Thread Dave Angel
J wrote: I was reading something from a code review a little while ago and saw something that's got my curiosity up... Say I had a file, foo.txt that I wanted to read from, only one time and only read. So what's the difference between this: mylist = Popen(["cat","foo.txt"], stdout=PIPE).comm

Re: Difference between Popen and open() for reading a file

2010-04-22 Thread MRAB
J wrote: I was reading something from a code review a little while ago and saw something that's got my curiosity up... Say I had a file, foo.txt that I wanted to read from, only one time and only read. So what's the difference between this: mylist = Popen(["cat","foo.txt"], stdout=PIPE).commun

Re: Difference between Popen and open() for reading a file

2010-04-22 Thread Chris Rebert
On Thu, Apr 22, 2010 at 11:28 AM, J wrote: > I was reading something from a code review a little while ago and saw > something that's got my curiosity up... > > Say I had a file, foo.txt that I wanted to read from, only one time > and only read. > > So what's the difference between this: > > mylis

Re: Difference Between Two datetimes

2010-01-14 Thread Steve Ferg
> I'd like to start with two dates as strings, as > "1961/06/16 04:35:25" and "1973/01/18 03:45:50" > How do I get the strings into a shape that will accommodate a difference? Pyfdate http://www.ferg.org/pyfdate/index.html has a numsplit function that should do the trick: http://www.ferg.org/pyf

Re: Difference Between Two datetimes

2009-12-29 Thread Stephen Hansen
On Tue, Dec 29, 2009 at 7:21 AM, M.-A. Lemburg wrote: > If you want a more human readable, relative format use Age(): > > >>> Age(bree, nat) > 0x2b99c6e37ef0> > > i.e. 8 years, 4 months, 29 days, 49 minutes, 35 seconds. > That is... awesome. I use mx.DateTime all the time, and never knew about

Re: Difference Between Two datetimes

2009-12-29 Thread M.-A. Lemburg
W. eWatson wrote: > According to one web source, this program: > > import datetime > bree = datetime.datetime(1981, 6, 16, 4, 35, 25) > nat = datetime.datetime(1973, 1, 18, 3, 45, 50) > > difference = bree - nat > print "There were", difference, "minutes between Nat and Bree" > > yields: > Ther

Re: Difference Between Two datetimes

2009-12-29 Thread Steve Holden
W. eWatson wrote: > Peter Otten wrote: >> W. eWatson wrote: >> >>> This is quirky. >>> >>> >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S") >>> >>> t1 >>> datetime.datetime(2009, 12, 5, 22, 11) >>> >>> type(t1) >>> >>> >>> >>> t1: 2009-12-05 22:11:00 >>> >>> but in the pr

Re: Difference Between Two datetimes

2009-12-29 Thread W. eWatson
Peter Otten wrote: W. eWatson wrote: This is quirky. >>> t1=datetime.datetime.strptime("20091205_221100","%Y%m%d_%H%M%S") >>> t1 datetime.datetime(2009, 12, 5, 22, 11) >>> type(t1) >>> t1: 2009-12-05 22:11:00 but in the program: import datetime t1=datetime.datetime.strptime("2

  1   2   3   4   >