Re: how to get bytes from bytearray without copying

2014-03-03 Thread Juraj Ivančić
On 3.3.2014. 1:44, Cameron Simpson wrote: ValueError: cannot hash writable memoryview object Have you considered subclassing memoryview and giving the subclass a __hash__ method? I have, and then, when I failed to subclass it, I considered doing aggregation, and make it behave byte-like. Bu

Re: how to get bytes from bytearray without copying

2014-03-03 Thread Juraj Ivančić
On 3.3.2014. 1:49, Mark Lawrence wrote: If your data is readonly why can't you simply read it as bytes in the first place? Failing that from http://docs.python.org/3/library/stdtypes.html#memoryview tobytes() - Return the data in the buffer as a bytestring. This is equivalent to calling the by

Re: how to get bytes from bytearray without copying

2014-03-03 Thread Juraj Ivančić
On 3.3.2014. 2:27, Ian Kelly wrote: Python 3.3 has a C API function to create a memoryview for a char*, that can be made read-only. http://docs.python.org/3/c-api/memoryview.html#PyMemoryView_FromMemory Yes, this is probably what I'll do in absence of pure Python solution. Thanks for th

Reference

2014-03-03 Thread ast
hello Consider following code: A=7 B=7 A is B True I understand that there is a single object 7 somewhere in memory and both variables A and B point toward this object 7 now do the same with a list: l1 = [1, 2] l2 = [1, 2] l1 is l2 False It seems this time that there are 2 distincts obje

[RELEASED] Python 3.3.5 release candidate 2

2014-03-03 Thread Georg Brandl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team, I'm happy to announce the release of Python 3.3.5, release candidate 2. Python 3.3.5 includes a fix for a regression in zipimport in 3.3.4 (see http://bugs.python.org/issue20621) and a few other bugs. Python

Object identity (was: Reference)

2014-03-03 Thread Ben Finney
"ast" writes: > >>> A=7 > >>> B=7 > >>> A is B > True > > I understand that there is a single object 7 somewhere in memory and > both variables A and B point toward this object 7 Try not to think in terms of “point to”. Rather, the names “A” and “B” are bound to that object. The distinction is

Re: Functional programming

2014-03-03 Thread Alister
On Mon, 03 Mar 2014 06:14:09 +0700, musicdenotation wrote: > If Python is not a fnctional language, then which programming paradigmis > dominant? Python follows the Pythonic paradigm :-) -- Hope this helps some, sorry for not being able to do a brain dump. - Mike Stump helping a clue

Re: Object identity (was: Reference)

2014-03-03 Thread ast
thanks ben, that's clear -- https://mail.python.org/mailman/listinfo/python-list

Re: Functional programming

2014-03-03 Thread Bob Martin
in 718085 20140302 231409 musicdenotat...@gmail.com wrote: >If Python is not a fnctional language, then which programming paradigmis dom= >inant?= Labels are always misleading. -- https://mail.python.org/mailman/listinfo/python-list

python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
hi folks, Python Decimal Library dmath.py v0.3 Released https://code.google.com/p/pythondecimallibrary/ This code provides the C accelerated decimal module with scientific/transcendental functions for arbitrary precision. I have also included pilib.py which is a PI library of historic algorith

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 6:57:15 AM UTC+5:30, Ned Batchelder wrote: > On 3/2/14 6:14 PM, musicdenotation wrote: > > If Python is not a fnctional language, then which programming paradigmis > > dominant? > is_a_functional_language() is not a binary condition, yes or no. It's a > continuum. Pyth

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 5:34:30 AM UTC-6, Mark H. Harris wrote: > hi folks, Terry, I posted this mod as an idea on python-ideas, as you suggested. Also, I made the additional suggestion that decimal floating point be considered as the primary floating point type for python4.x, with an optional

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Mon, Mar 3, 2014 at 10:45 PM, Rustom Mody wrote: > - cannot do a 'type-incorrect' expression like [1,2] + [[3,4],[5]] > [1, 2, [3, 4], [5]] What do you mean by "type-incorrect"? This is adding two lists and getting back a list. Seems perfectly correct to me. ChrisA -- https://mail.pytho

Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Marcus
Hello, I'm trying to use urllib and urllib2 to open an url + login_data in a for loop. How can I display when successfully logged in and how to show when the login is denied? I've tried use this: html_content = urllib2.urlopen(url).read() re.findall('ERROR: The password you entered for the us

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Marcus
This is the code right now: http://pastebin.com/pE1YZX2K -- https://mail.python.org/mailman/listinfo/python-list

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Chris Angelico
On Mon, Mar 3, 2014 at 11:44 PM, Chris Angelico wrote: > So basically, you're doing a dictionary attack. May I ask why you're > doing this, exactly? -- https://mail.python.org/mailman/listinfo/python-list

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Chris Angelico
On Mon, Mar 3, 2014 at 11:44 PM, Chris Angelico wrote: > So basically, you're doing a dictionary attack. May I ask why you're > doing this, exactly? oops, misclicked. I note that the user name 'alex' does not appear to match your name. I'm going to want a good reason for this code to be written,

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Chris Angelico
On Mon, Mar 3, 2014 at 11:35 PM, Marcus wrote: > This is the code right now: http://pastebin.com/pE1YZX2K That looks short enough to include in-line, no need to point us to an external site :) So basically, you're doing a dictionary attack. May I ask why you're doing this, exactly? ChrisA -- h

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Marcus
Yes, it's only for my own use on my local WordPress installation. Only educational use. -- https://mail.python.org/mailman/listinfo/python-list

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Chris Angelico
On Mon, Mar 3, 2014 at 11:51 PM, Marcus wrote: > Yes, it's only for my own use on my local WordPress installation. Only > educational use. What are you trying to learn, exactly? How to break into a WP site? Still dubious. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 3:42:30 AM UTC-6, ast wrote: > Consider following code: > > >>> A=7 > >>> B=7 > >>> A is B > True The names A and B are both bound to the same object (7). You will discover that this is True for all small ints less than 257; on CPython3.3.4. I just checked it. :) I

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Marcus
It's not that hard to find a program that does this already. But I'm trying to learn how to use these modules to create this. I've started it and now i want to complete it so I can create another program and learn more about other stuff, maybe a Twitter script or something. How do I learn when n

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Oscar Benjamin
On 3 March 2014 11:34, Mark H. Harris wrote: > hi folks, > > Python Decimal Library dmath.py v0.3 Released > > https://code.google.com/p/pythondecimallibrary/ Hi Mark, Is this available on PyPI? It seems there already is a "dmath" package on PyPI that was written by someone else some time ago so

modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread Jaap van Wingerde
Django views.py: ... pwd = os.path.dirname(os.path.realpath(__file__ )) home_lastmod = strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime(pwd+'/templates/art_index.html'))) ... The template gives a wrong modification time: "2014-03-02T19:03:55Z". ... jaap@liakoster:~$ python Python 2.7.3 (de

Re: Password validation security issue

2014-03-03 Thread Roy Smith
In article , Chris Angelico wrote: > The greatest threats these days are from the network, not from someone > physically walking into an office. (That said, though, the low-hanging > fruit from walking into an office can be *extremely* tempting. Pulling > off a basic password leech off sticky no

Re: Iterate through a list and try log in to a website with urllib and re

2014-03-03 Thread Roy Smith
In article , Marcus wrote: > I'm trying to use urllib and urllib2 to open an url + login_data in a for > loop. Step 1: Ignore all that crap and get http://www.python-requests.org/ > How can I display when successfully logged in and how to show when the > login is denied? > > I've tried us

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 5:50:37 PM UTC+5:30, Chris Angelico wrote: > On Mon, Mar 3, 2014 at 10:45 PM, Rustom Mody wrote: > > - cannot do a 'type-incorrect' expression like > [1,2] + [[3,4],[5]] > > [1, 2, [3, 4], [5]] > What do you mean by "type-incorrect"? This is adding two lists and > ge

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 7:18:00 PM UTC+5:30, Rustom Mody wrote: > Unfortunately modern versions give a less helpful error message > '++' is list-append, '?' is the prompt > ? [1,2] + [[3,4],[5]] Whoops Wrong cut-paste! ? [1,2] ++ [[3,4],[5]] ERROR: Type error in application

Re: Password validation security issue

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 12:41 AM, Roy Smith wrote: > I used to work at which had a typical big company IT > department which enforced all sorts of annoying pseudo-security rules. > As far as I could figure out, however, all you needed to get them to > reset anybody's password and tell you the new

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 12:48 AM, Rustom Mody wrote: > ? [1,2] + [[3,4],[5]] > ERROR: Type error in application > *** expression : [1,2] + [[3,4],[5]] > *** term : [1,2] > *** type : [Int] > *** does not match : [[Int]] > > IOW [1,2,[3,4],[5]] > is a type-wise ill-formed exp

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 12:35 AM, Jaap van Wingerde wrote: time.strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime('/var/django/test2/art/templates/art_index.html'))) > '2014-03-02T19:03:55Z' quit() > jaap@liakoster:~$ ls --full-time > /var/django/test2/art/templates/art_index.html >

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 7:30:17 PM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 12:48 AM, Rustom Mody wrote: > > ? [1,2] + [[3,4],[5]] > > ERROR: Type error in application > > *** expression : [1,2] + [[3,4],[5]] > > *** term : [1,2] > > *** type : [Int] > > ***

Re:How security holes happen

2014-03-03 Thread Neal Becker
Charles R Harris Wrote in message: > ___ > NumPy-Discussion mailing list > numpy-discuss...@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > Imo the lesson here is never write in low level c. Use modern languages with well design

Re: [OT] Can global variable be passed into Python function?

2014-03-03 Thread Grant Edwards
On 2014-03-02, Chris Angelico wrote: > On Mon, Mar 3, 2014 at 3:55 AM, Mark Lawrence wrote: >> On 02/03/2014 16:45, Grant Edwards wrote: >>> >>> >>> That's irrelevent. The actual location of the memory containing the >>> struct object (static, stack, heap, shared) doesn't matter. The >>> addres

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 1:08 AM, Rustom Mody wrote: >> How do you know that [1,2] is a list that must contain nothing but >> integers? By extension, it's also a list that must contain positive >> integers less than three, so adding [5] violates that. And [] is a >> list that must contain nothing, e

Re: [OT] Can global variable be passed into Python function?

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 1:18 AM, Grant Edwards wrote: >> Note that, technically, Grant is correct as long as you grant (heh) >> that a structure may have an invisible member, the virtual function >> table pointer. C++ only (I don't believe C has virtual functions - >> but it may have grown them in

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread Jaap van Wingerde
Op schreef Chris Angelico in bericht : > See if ls is actually giving you ctime rather than mtime - compare the > results if you ask for os.path.getctime. jaap@liakoster:~$ python Python 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "licen

Re: Reference

2014-03-03 Thread Grant Edwards
On 2014-03-03, ast wrote: > hello > > Consider following code: > A=7 B=7 A is B > True > > I understand that there is a single object 7 somewhere in memory Maybe, maybe not. Integer are immutable, so that's allowed but not required. In CPython, that's true for small integers, but

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 7:34:40 AM UTC-6, Oscar Benjamin wrote: > Python Decimal Library dmathlib.py v0.3 Released > https://code.google.com/p/pythondecimallibrary/ > Is this available on PyPI? It seems there already is a "dmath" package > on PyPI that was written by someone else some time ago

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 7:53:01 PM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 1:08 AM, Rustom Mody wrote: > >> How do you know that [1,2] is a list that must contain nothing but > >> integers? By extension, it's also a list that must contain positive > >> integers less than three, so

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 1:38 AM, Rustom Mody wrote: > If you want the (semantic) equivalent of python's [1,2,'foo'] > you need to make an explicit union Int and String and its that > *single* union type's elements that must go in. > > In all cases its always a single type. And so > sum([1,2,[3]) O

How to create a voting website by Python and Flask?

2014-03-03 Thread Harry Wood
How to create a voting website by Python and Flask? I studying Python and Flask for some months, and - Now I have some Python & Flask basic skills. - I need some advices like following example: Step 1: You could writing an voting application by Python Step 2: You could build a website by Flas

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 7:34:40 AM UTC-6, Oscar Benjamin wrote: > On 3 March 2014 11:34, Mark H. Harris wrote: > > Is this available on PyPI? It seems there already is a "dmath" package > on PyPI that was written by someone else some time ago so you might > need to use a different name: > Osc

Re: Functional programming

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 8:31:47 PM UTC+5:30, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 1:38 AM, Rustom Mody wrote: > > If you want the (semantic) equivalent of python's [1,2,'foo'] > > you need to make an explicit union Int and String and its that > > *single* union type's elements that must

Re: Reference

2014-03-03 Thread Rustom Mody
On Monday, March 3, 2014 3:12:30 PM UTC+5:30, ast wrote: > hello > Consider following code: > >>> A=7 > >>> B=7 > >>> A is B > True > I understand that there is a single object 7 somewhere in memory and > both variables A and B point toward this object 7 > now do the same with a list: > >>> l1

Re: How to create a voting website by Python and Flask?

2014-03-03 Thread David Froger
Quoting Harry Wood (2014-03-03 16:22:22) > How to create a voting website by Python and Flask? I studying Python and > Flask for some months, and > > - Now I have some Python & Flask basic skills. > - I need some advices like following example: > Step 1: You could writing an voting application

Re: Password validation security issue

2014-03-03 Thread MRAB
On 2014-03-03 13:55, Chris Angelico wrote: On Tue, Mar 4, 2014 at 12:41 AM, Roy Smith wrote: I used to work at which had a typical big company IT department which enforced all sorts of annoying pseudo-security rules. As far as I could figure out, however, all you needed to get them to reset an

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Oscar Benjamin
On 3 March 2014 15:22, Mark H. Harris wrote: > On Monday, March 3, 2014 7:34:40 AM UTC-6, Oscar Benjamin wrote: >> On 3 March 2014 11:34, Mark H. Harris wrote: >> >> Is this available on PyPI? > > Python3.3 Decimal Library v0.3 is Released here: > > https://code.google.com/p/pythondecimallibra

Re: Password validation security issue

2014-03-03 Thread Steven D'Aprano
On Tue, 04 Mar 2014 00:55:45 +1100, Chris Angelico wrote: > But it's an attack vector that MUST be considered, which is why I never > tell the truth in any "secret question / secret answer" boxes. Why some > sites think "mother's maiden name" is at all safe is beyond my > comprehension. And that's

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 10:44:16 AM UTC-6, Oscar Benjamin wrote: > Is it on PyPI though? I was referring to a PyPI name so that people > could install it with "pip install pdeclib" > Oscar hi Oscar, I'm sorry, I completely missed the point of your question. No its not on PyPI, but I don't mind

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Wolfgang Maier
Am Montag, 3. März 2014 12:34:30 UTC+1 schrieb Mark H. Harris: > hi folks, > > > > Python Decimal Library dmath.py v0.3 Released > > > > https://code.google.com/p/pythondecimallibrary/ > > > > This code provides the C accelerated decimal module with > > scientific/transcendental function

Re: Functional programming

2014-03-03 Thread Steven D'Aprano
On Tue, 04 Mar 2014 02:01:47 +1100, Chris Angelico wrote: > This is why it's tricky to put rules in based on type inference. The > programmer's intent isn't in the picture. Of course it is. If I assign 23 to variable x, that signals my intent to assign an int to x. By Occam's razor, it is reaso

Re: Password validation security issue

2014-03-03 Thread Steven D'Aprano
On Mon, 03 Mar 2014 08:41:10 -0500, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> The greatest threats these days are from the network, not from someone >> physically walking into an office. (That said, though, the low-hanging >> fruit from walking into an office can be *extremel

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 4:27 AM, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 02:01:47 +1100, Chris Angelico wrote: > >> This is why it's tricky to put rules in based on type inference. The >> programmer's intent isn't in the picture. > > Of course it is. If I assign 23 to variable x, that signals

Re: Origin of 'self'

2014-03-03 Thread Terry Reedy
On 3/3/2014 1:16 AM, Westley Martínez wrote: I understand that in an object method the first argument in the object itself, called self. However, it doesn't have to be called self, and can be called anything. So my question is why is it called self and not this like from C++ and Java. It's kin

Re: Password validation security issue

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 3:46 AM, Steven D'Aprano wrote: > On Tue, 04 Mar 2014 00:55:45 +1100, Chris Angelico wrote: > >> But it's an attack vector that MUST be considered, which is why I never >> tell the truth in any "secret question / secret answer" boxes. Why some >> sites think "mother's maiden

Re: Reference

2014-03-03 Thread Terry Reedy
On 3/3/2014 4:42 AM, ast wrote: Consider following code: A=7 B=7 A is B The 'is' operator has three uses, two intended and one not. In production code, 'is' tests that an object *is* a particular singular object, such as None or a sentinel instance of class object. In test code, 'is' can

Re: 3.4rc2 and pip on windows

2014-03-03 Thread Mark Lawrence
On 03/03/2014 00:07, Terry Reedy wrote: On 3/2/2014 6:55 PM, Mark Lawrence wrote: Trying to install pyttsx, it doesn't strike me as very clever that, as seen below, you get "Successfully installed pyttsx" despite the syntax errors and you can't actually do an import. c:\Users\Mark\CrossCode>c:\

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 11:23:13 AM UTC-6, Wolfgang Maier wrote: > def fact(x): > """ fact(x)factorial{x} int x > 0 > > return +Decimal(math.factorial(x)) > to make it return a Decimal rounded to context precision? hi Wolfgang, I'm not sure. We're doing some things wit

pip and distutils2-1.0a4

2014-03-03 Thread Mark H. Harris
hi folks, I am having a fit with pip this afternoon. I finally got pip installed on this system from a binary blob (what nightmare, talk about 1987). Anyway, pip is installed, but when I go to PyPI to pull down distutils is gives a message that no such package exists. I feel like Obeewan; "i

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread donarb
On Monday, March 3, 2014 6:28:21 AM UTC-8, Jaap van Wingerde wrote: > Op schreef Chris Angelico > in bericht > : > > > See if ls is actually giving you ctime rather than mtime - compare the > > results if you ask for os.path.getctime. > > jaap@liakoster:~$ python > Python 2.7.3 (default, Jan

Re: pip and distutils2-1.0a4

2014-03-03 Thread Mark Lawrence
On 03/03/2014 20:10, Mark H. Harris wrote: hi folks, I am having a fit with pip this afternoon. I finally got pip installed on this system from a binary blob (what nightmare, talk about 1987). Anyway, pip is installed, but when I go to PyPI to pull down distutils is gives a message that no such

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread Ben Finney
Jaap van Wingerde writes: > >>> time.strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime('/var/django/test2/art/templates/art_index.html'))) > >>> > '2014-03-02T19:03:55Z' > >>> quit() > jaap@liakoster:~$ ls --full-time > /var/django/test2/art/templates/art_index.html > -rwxrwx--- 1 lia w

Re: modification time in Python - Django: datetime != datetime :-(

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 7:22 AM, donarb wrote: > You're using the months format '%m' when you should be using minutes '%M'. Heh! I didn't even notice that. When I tested it, I didn't use strftime at all, just looked at gmtime's output. ChrisA -- https://mail.python.org/mailman/listinfo/python-li

Re: Reference

2014-03-03 Thread Ben Finney
Rustom Mody writes: > Short answer: Avoid using 'is'. This is bad advice in a Python forum. The ‘is’ operator is commonly used in Python, so please don't advise against it in an unqualified “short answer”. > Long answer: > http://www.beyondwilber.ca/healing-thinking/non-identity-korzybski.ht

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 2:03:19 PM UTC-6, Mark H. Harris wrote: > On Monday, March 3, 2014 11:23:13 AM UTC-6, Wolfgang Maier wrote: Wolfgang, answer is not so much, in fact, not at all. But it is an interesting question for me; where I am continuing to learn the limits of Decimal, and the dec

Re: Reference

2014-03-03 Thread Tim Chase
On 2014-03-04 08:10, Ben Finney wrote: > > Long answer: > > http://www.beyondwilber.ca/healing-thinking/non-identity-korzybski.html > > Interesting, but mostly a distraction for the querent here. > > Short answer: Use ‘use’ any time you need to compare object > identity. You usually do not need

Re: pip and distutils2-1.0a4

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 2:53:00 PM UTC-6, Mark Lawrence wrote: > distutils has been part of the standard library for years. hi Mark, that's fabulous, why can't I import it? Because I'm doing something wrong of course. :) marcus -- https://mail.python.org/mailman/listinfo/python-list

Re: Reference

2014-03-03 Thread Ben Finney
Tim Chase writes: > On 2014-03-04 08:10, Ben Finney wrote: > > Short answer: Use ‘use’ any time you need to compare object > > identity. You usually do not need to compare object identity. Damn it, a snappy response marred by a typo. > I think there use something wrong with that sentence...unle

Re: pip and distutils2-1.0a4

2014-03-03 Thread Robert Kern
On 2014-03-03 21:20, Mark H. Harris wrote: On Monday, March 3, 2014 2:53:00 PM UTC-6, Mark Lawrence wrote: distutils has been part of the standard library for years. hi Mark, that's fabulous, why can't I import it? Because I'm doing something wrong of course. :) Probably. If you want us t

Re: Reference

2014-03-03 Thread Mark Lawrence
On 03/03/2014 21:10, Ben Finney wrote: Rustom Mody writes: Short answer: Avoid using 'is'. This is bad advice in a Python forum. The ‘is’ operator is commonly used in Python, so please don't advise against it in an unqualified “short answer”. Long answer: http://www.beyondwilber.ca/heali

Re: pip and distutils2-1.0a4

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 3:32:43 PM UTC-6, Robert Kern wrote: > Probably. If you want us to help, you need to show us what you tried, tell us > what results you expected, and copy-paste the output that you got. > Robert Kern hi Robert, well, I finally came up with trying to find setup(). Its

Re: why indentation should be part of the syntax

2014-03-03 Thread BartC
"Stefan Behnel" wrote in message news:mailman.7568.1393756930.18130.python-l...@python.org... Haven't seen any mention of it on this list yet, but since it's such an obvious flaw in quite a number of programming languages, here's a good article on the recent security bug in iOS, which was due

Re: pip and distutils2-1.0a4

2014-03-03 Thread Roy Smith
In article <31feb451-7fb6-48a6-9986-bddce69c4...@googlegroups.com>, "Mark H. Harris" wrote: > On Monday, March 3, 2014 3:32:43 PM UTC-6, Robert Kern wrote: > > > Probably. If you want us to help, you need to show us what you tried, tell > > us > > what results you expected, and copy-paste the

Re: Reference

2014-03-03 Thread Tim Chase
On 2014-03-03 21:35, Mark Lawrence wrote: > I'd just like to know why people are so obsessed with identities, > I've never thought to use them in 10+ years of writing Python. Do > I use the KISS principle too often? There are a couple use-cases I've encountered where "is" matters: 1) the most po

Re: how to get bytes from bytearray without copying

2014-03-03 Thread Cameron Simpson
On 03Mar2014 09:15, Juraj Ivančić wrote: > On 3.3.2014. 1:44, Cameron Simpson wrote: > >>ValueError: cannot hash writable memoryview object > > > >Have you considered subclassing memoryview and giving the subclass > >a __hash__ method? > > I have, and then, when I failed to subclass it, I conside

Re: Reference

2014-03-03 Thread Jerry Hill
On Mon, Mar 3, 2014 at 4:51 PM, Tim Chase wrote: > There are a couple use-cases I've encountered where "is" matters: > > 1) the most popular: > > if foo is None: > do_stuff() I know this is the one that always comes up, but honestly, I feel like "is" doesn't matter here. That code would be

Re: Functional programming

2014-03-03 Thread Gregory Ewing
Steven D'Aprano wrote: Given that x is an integer, and that you add 1 (also an integer) to it, is it really necessary to tell the compiler that add_one returns an integer? What else could the output type be? Just because the compiler *can* infer the return type doesn't necessarily mean it *sho

Re: Reference

2014-03-03 Thread Marko Rauhamaa
Mark Lawrence : > I'd just like to know why people are so obsessed with identities, I've > never thought to use them in 10+ years of writing Python. Do I use the > KISS principle too often? Calmly choosing the right tool for the job is not an obsession. Marko -- https://mail.python.org/mailma

Re: pip and distutils2-1.0a4

2014-03-03 Thread Robert Kern
On 2014-03-03 21:37, Mark H. Harris wrote: On Monday, March 3, 2014 3:32:43 PM UTC-6, Robert Kern wrote: Probably. If you want us to help, you need to show us what you tried, tell us what results you expected, and copy-paste the output that you got. Robert Kern hi Robert, well, I finally

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 3:18:37 PM UTC-6, Mark H. Harris wrote: Yeah, you can set Emin & Emax enormously large (or small), can set off overflow, and set clamping. I am needing a small utility (tk?) that will allow the context to be set manually by the interactive user dynamically (for a particu

Re: 3.4rc2 and pip on windows

2014-03-03 Thread Zachary Ware
On Mon, Mar 3, 2014 at 1:47 PM, Mark Lawrence wrote: > FTR I raised this as http://bugs.python.org/issue20846 and it was closed 11 > minutes after I raised it. I won't say anything else as I'm extremely tired > and irritable and might well regret it later. Best I can tell, the issue was closed c

Re: Reference

2014-03-03 Thread Ben Finney
Jerry Hill writes: > if foo == None: > do_stuff() > > The only time it would give you a different result from the "is" > version is if foo was bound to an object that returned True when > compared with None. That's right. Python provides this singleton and then recommends you compare with ‘i

Re: Reference

2014-03-03 Thread Ben Finney
Marko Rauhamaa writes: > Mark Lawrence : > > > I'd just like to know why people are so obsessed with identities, I've > > never thought to use them in 10+ years of writing Python. Do I use the > > KISS principle too often? > > Calmly choosing the right tool for the job is not an obsession. Pers

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Wolfgang Maier
On Monday, March 3, 2014 9:03:19 PM UTC+1, Mark H. Harris wrote: > On Monday, March 3, 2014 11:23:13 AM UTC-6, Wolfgang Maier wrote: > > def fact(x): > > """ fact(x)factorial{x} int x > 0 > > > > return +Decimal(math.factorial(x) > > to make it return a Decimal rounded to co

Re: Reference

2014-03-03 Thread Marko Rauhamaa
Jerry Hill : > except for the fact that there has been 20 years of custom saying that > comparing to None with equality is wrong. "if foo == None" is not wrong in any manner. It's just that if you are comfortable with the "is" operator and its semantics, "if foo is None" is slightly more natural.

Re: How security holes happen

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 9:19 AM, Cameron Simpson wrote: > On 03Mar2014 09:17, Neal Becker wrote: >> Charles R Harris Wrote in message: >> > >> >> Imo the lesson here is never write in low level c. Use modern >> languages with well designed exception handling. > > What, and rely on someone else'

Re: Reference

2014-03-03 Thread Ben Finney
Marko Rauhamaa writes: > Jerry Hill : > > > except for the fact that there has been 20 years of custom saying that > > comparing to None with equality is wrong. > > "if foo == None" is not wrong in any manner. Marko, please don't keep asserting falsehoods. It's already been pointed out in this f

Re: How security holes happen

2014-03-03 Thread Cameron Simpson
On 03Mar2014 09:17, Neal Becker wrote: > Charles R Harris Wrote in message: > > > > Imo the lesson here is never write in low level c. Use modern > languages with well designed exception handling. What, and rely on someone else's low level C? -- Cameron Simpson Hag:Two

Re: Reference

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 9:22 AM, Marko Rauhamaa wrote: > You generally use "==" if more than one object could be equal. If you > know there's only one object of the kind, you convey that knowledge by > the use of "is" even when functionally, it doesn't matter. It's even simpler than that. You use

Re: Functional programming

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 9:31 AM, Ben Finney wrote: > def frobnicate(flang, splets, queeble=False): > """ Righteously frobnicate the flang. > > :param flang: A file-like object, opened for reading. I had to read that a few times before I was sure that you actually meant "fil

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Wolfgang Maier
On Monday, March 3, 2014 10:18:37 PM UTC+1, Mark H. Harris wrote: > On Monday, March 3, 2014 2:03:19 PM UTC-6, Mark H. Harris wrote: > > Wolfgang, answer is not so much, in fact, not at all. > But it is an interesting question for me; where I am > continuing to learn the limits of Decimal, and

Re: python decimal library dmath.py v0.3 released

2014-03-03 Thread Mark H. Harris
On Monday, March 3, 2014 4:15:39 PM UTC-6, Wolfgang Maier wrote: > Well, that may be your use-case, but then math.factorial is for you. > On the other hand, you may be interested in getting > context-rounded factorials and rounding to context > precision is what you'd expect from a Decimal func

Re: Functional programming

2014-03-03 Thread Ben Finney
Gregory Ewing writes: > Just because the compiler *can* infer the return type doesn't > necessarily mean it *should*. When I was playing around with > functional languages, I ended up adopting the practice of always > declaring the types of my functions, because it helps the *human* > reader. Su

Re: How security holes happen

2014-03-03 Thread Mark Lawrence
On 03/03/2014 22:25, Chris Angelico wrote: On Tue, Mar 4, 2014 at 9:19 AM, Cameron Simpson wrote: On 03Mar2014 09:17, Neal Becker wrote: Charles R Harris Wrote in message: Imo the lesson here is never write in low level c. Use modern languages with well designed exception handling.

Re: How security holes happen

2014-03-03 Thread Chris Kaynor
On Mon, Mar 3, 2014 at 2:25 PM, Chris Angelico wrote: > On Tue, Mar 4, 2014 at 9:19 AM, Cameron Simpson wrote: > > On 03Mar2014 09:17, Neal Becker wrote: > >> Charles R Harris Wrote in message: > >> > > >> > >> Imo the lesson here is never write in low level c. Use modern > >> languages with

Re: Reference

2014-03-03 Thread Roy Smith
In article , Ben Finney wrote: > That's right. Python provides this singleton and then recommends you > compare with ‘is’, precisely to protect against pathological cases like > a “return True when compared for equality with None” data type. Going off on a tangent, I've often wished Pyt

Re: How security holes happen

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 9:55 AM, Chris Kaynor wrote: > You can go much simpler than that. Merely port Python to LISP, then write a > LISP interpreter in Python. Done. Actually, here's an easier way. Just write an 80x86 assembly language interpreter in Python, then port CPython to Python. ChrisA -

Re: How security holes happen

2014-03-03 Thread Roy Smith
In article , Cameron Simpson wrote: > On 03Mar2014 09:17, Neal Becker wrote: > > Charles R Harris Wrote in message: > > > > > > > Imo the lesson here is never write in low level c. Use modern > > languages with well designed exception handling. > > What, and rely on someone else's low lev

Re: Reference

2014-03-03 Thread Chris Angelico
On Tue, Mar 4, 2014 at 10:02 AM, Roy Smith wrote: > In article , > Ben Finney wrote: > >> That's right. Python provides this singleton and then recommends you >> compare with ‘is’, precisely to protect against pathological cases like >> a “return True when compared for equality with None” data t

  1   2   >