Re: Help with "Guess the number" script

2014-03-02 Thread Dave Angel
Scott W Dunning Wrote in message: > Here are the directions I’m stuck on and what I have so far, I’ll bold the part That assumes that people can see which parts of your message are bold. Rather a poor assumption in a text list like these two python forums. You should be posting in text,

Re: Origin of 'self'

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 11:16 PM, 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

Re: Origin of 'self'

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 22:16:31 -0800, 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

Re: Password validation security issue

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 10:44 PM, Chris Angelico wrote: > Of course, the whole concept depends on being able to use long > memorable passwords. Any system that sets a maximum password length of > anything less than about 30-40 characters is causing its users > problems. There's almost never any rea

Re:Origin of 'self'

2014-03-02 Thread Dave Angel
Westley Martínez Wrote in message: > 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 k

Origin of 'self'

2014-03-02 Thread Westley Martínez
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 kind of a silly question, but one that I'm curi

Re: Password validation security issue

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 3:38 PM, Steven D'Aprano wrote: > Oh really? Chances are you're wallet is *full* of pieces of paper that > people would steal, given half the chance. Alas no... around here, wallets get filled with pieces of plastic [1], of which my wallet is sadly devoid. And I can't imagi

Re: Coding a simple state machine in python

2014-03-02 Thread alex23
On 25/02/2014 8:01 PM, Peter Otten wrote: alex23 wrote: No, the _easy_ solution is [find a suitable package on PyPI] Easy? By the time I have evaluated these I've written my own ;) It's never writing a solution that's the problem...it's maintaining it over time :) -- https://mail.python.o

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 18:52:40 -0700, Ian Kelly wrote: > On Sun, Mar 2, 2014 at 6:16 PM, Steven D'Aprano > wrote: >> People have managed physical keys for *centuries*. Yes, there are a >> class of threats where you lose your key, or someone steals it, or >> makes a copy, but the risks are well-unde

Re: Help with "Guess the number" script

2014-03-02 Thread Scott W Dunning
On Mar 2, 2014, at 8:52 PM, Ben Finney wrote: > > Once again, Scott, this discussion should be happening at the Tutor > forum. Please don't continue the fragmentation of this discussion; keep > the discusson over at the Tutor forum. Sorry, I was just replying to replies to my post. I get the po

Re: Help with "Guess the number" script

2014-03-02 Thread Ben Finney
Scott W Dunning writes: > This is what Im having trouble with now. Once again, Scott, this discussion should be happening at the Tutor forum. Please don't continue the fragmentation of this discussion; keep the discusson over at the Tutor forum. -- \ “I like to fill my bathtub up with wa

Re: Help with "Guess the number" script

2014-03-02 Thread Scott W Dunning
On Mar 2, 2014, at 6:40 PM, Scott W Dunning wrote: This is what Im having trouble with now. Here are the directions I’m stuck on and what I have so far, I’ll bold the part that’s dealing with the instructions if anyone could help me figure out where I’m going wrong. Thanks! from random im

Re: Password validation security issue

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 12:52 PM, Ian Kelly wrote: > On Sun, Mar 2, 2014 at 6:16 PM, Steven D'Aprano > wrote: >> People have managed physical keys for *centuries*. Yes, there are a class >> of threats where you lose your key, or someone steals it, or makes a >> copy, but the risks are well-underst

Re: Password validation security issue

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 6:16 PM, Steven D'Aprano wrote: > People have managed physical keys for *centuries*. Yes, there are a class > of threats where you lose your key, or someone steals it, or makes a > copy, but the risks are well-understood and can be managed even by your > grandmother. We have

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 15:10:06 -0800, Renato wrote: > I would like to thank every one who posted a reply. I learnt a lot from > you, guys! I appreciate your attention and your help :) > > I took a class on Computer Simulation last year. It was told that > deterministic (pseudo-)random numbers are e

Re: Error compressing tar file

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 17:11:19 -0800, Mike wrote: > without ")" i have the same sintax error: > > [root@master ~]# python bkp_db.py > Traceback (most recent call last): > File "bkp_db.py", line 19, in > tar = tarfile.open(dumpfile + '.tar.gz','w:gz') > TypeError: unsupported operand type(s)

Re: Functional programming

2014-03-02 Thread Steven D'Aprano
On Mon, 03 Mar 2014 06:14:09 +0700, musicdenotation wrote: > If Python is not a fnctional language, then which programming paradigmis > dominant? Object oriented and procedural are about equally dominant, with a strong influence from functional paradigm. There are small amounts of imperative pa

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 13:33:11 +0200, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Sun, 02 Mar 2014 11:35:43 +0200, Marko Rauhamaa wrote: >>> Now, what kinds of object are those constants? We are not supposed to >>> know or care. >> >> Incorrect. We are supposed to know and care. > > Then, th

Re: Password validation security issue

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 4:10 PM, Renato wrote: > I would like to thank every one who posted a reply. I learnt a lot from you, > guys! I appreciate your attention and your help :) > > I took a class on Computer Simulation last year. It was told that > deterministic (pseudo-)random numbers are exce

Re: how to get bytes from bytearray without copying

2014-03-02 Thread Cameron Simpson
On 02Mar2014 17:55, Ian Kelly wrote: > On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson wrote: > > Have you considered subclassing memoryview and giving the subclass > > a __hash__ method? > > >>> class MyMemoryView(memoryview): > ... def __hash__(self): return 42 > ... > Traceback (most rece

Re: Help with "Guess the number" script

2014-03-02 Thread Scott W Dunning
On Mar 1, 2014, at 6:16 PM, Chris Angelico wrote: > > Another consideration: Susan's code is written for Python 3, but you > seemed to be using Python 2. You'll find that the code won't even run > on your version of Python. > > (If you have the chance, ask if the course writer would consider >

Re: Help with "Guess the number" script

2014-03-02 Thread Scott W Dunning
On Mar 2, 2014, at 12:38 AM, Larry Hudson wrote: > > Another 'problem' is what you failed to mention in your post, but is apparent > from the instructions that you posted -- this assignment is NOT the complete > program, just the beginning of one. Your instructor obviously wants you to > wor

Re: how to get bytes from bytearray without copying

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 5:07 PM, Juraj Ivančić wrote: > Is it possible to somehow 'steal' bytearray's buffer and make it a read-only > bytes? I failed to find a way to do this, and would like to make sure. > > My use case is, I would expect, fairly common. I read a certain (potentially > very large

Re: Functional programming

2014-03-02 Thread Ned Batchelder
On 3/2/14 6:14 PM, musicdenotat...@gmail.com 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. Python has more functional constructs than Pascal, and fewer than Haske

Re: Password validation security issue

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 15:01:09 -0500, Roy Smith wrote: > Security is as much about cryptography as it is about human factors and > business drivers. You can make things resistant to brute-force attacks > by using longer keys, but people are still going to pick bad passwords. Yes. But: > You can f

Re: Error compressing tar file

2014-03-02 Thread Mike
El domingo, 2 de marzo de 2014 21:38:49 UTC-3, Mike escribió: > Hello, > > I have the script that make a backup file (this process is ok), but now i > wish compress the file on tar file format. But i have problem syntax in the > line of the tar function. > > > > The error is > > > > [ro

Re: how to get bytes from bytearray without copying

2014-03-02 Thread Ian Kelly
On Sun, Mar 2, 2014 at 5:44 PM, Cameron Simpson wrote: > Have you considered subclassing memoryview and giving the subclass > a __hash__ method? >>> class MyMemoryView(memoryview): ... def __hash__(self): return 42 ... Traceback (most recent call last): File "", line 1, in TypeError: type

Re: how to get bytes from bytearray without copying

2014-03-02 Thread Mark Lawrence
On 03/03/2014 00:07, Juraj Ivančić wrote: Is it possible to somehow 'steal' bytearray's buffer and make it a read-only bytes? I failed to find a way to do this, and would like to make sure. My use case is, I would expect, fairly common. I read a certain (potentially very large) amount of data fr

Re: how to get bytes from bytearray without copying

2014-03-02 Thread Cameron Simpson
On 03Mar2014 01:07, Juraj Ivančić wrote: > Is it possible to somehow 'steal' bytearray's buffer and make it a > read-only bytes? I failed to find a way to do this, and would like > to make sure. > > My use case is, I would expect, fairly common. I read a certain > (potentially very large) amount

Re: Error compressing tar file

2014-03-02 Thread Joel Goldstick
On Mar 2, 2014 7:41 PM, "Joel Goldstick" wrote: > > > On Mar 2, 2014 7:40 PM, "Mike" wrote: > > > > Hello, > > I have the script that make a backup file (this process is ok), but now i wish compress the file on tar file format. But i have problem syntax in the line of the tar function. > > > > Th

Re: Error compressing tar file

2014-03-02 Thread Joel Goldstick
On Mar 2, 2014 7:40 PM, "Mike" wrote: > > Hello, > I have the script that make a backup file (this process is ok), but now i wish compress the file on tar file format. But i have problem syntax in the line of the tar function. > > The error is > > [root@master ~]# python bkp_db.py > File "bkp_db

Error compressing tar file

2014-03-02 Thread Mike
Hello, I have the script that make a backup file (this process is ok), but now i wish compress the file on tar file format. But i have problem syntax in the line of the tar function. The error is [root@master ~]# python bkp_db.py File "bkp_db.py", line 19 tar = tarfile.open(dumpfile)+'

Re: Functional programming

2014-03-02 Thread Roy Smith
In article , Terry Reedy wrote: > On 3/2/2014 6:14 PM, musicdenotat...@gmail.com wrote: > > If Python is not a fnctional language, then which programming paradigmis > > dominant? > > Python is an object based procedural language with builtin classes and > many functional features. Arguing abo

how to get bytes from bytearray without copying

2014-03-02 Thread Juraj Ivančić
Is it possible to somehow 'steal' bytearray's buffer and make it a read-only bytes? I failed to find a way to do this, and would like to make sure. My use case is, I would expect, fairly common. I read a certain (potentially very large) amount of data from the network into a pre-allocated byt

Re: Functional programming

2014-03-02 Thread Ben Finney
musicdenotat...@gmail.com writes: > If Python is not a fnctional language, then which programming > paradigmis dominant? Python uses a mixture of programming paradigms. Object-oriented, procedural, functional, and probably some I don't recall. So it's not accurate to say “Python is not a functio

Re: Functional programming

2014-03-02 Thread Terry Reedy
On 3/2/2014 6:14 PM, musicdenotat...@gmail.com wrote: If Python is not a fnctional language, then which programming paradigmis dominant? Python is an object based procedural language with builtin classes and many functional features. Arguing about the precise wording of such a statement is n

Re: 3.4rc2 and pip on windows

2014-03-02 Thread Terry Reedy
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:\Python34\Scripts\pip3.4.exe install pytts

Functional programming

2014-03-02 Thread musicdenotation
If Python is not a fnctional language, then which programming paradigmis dominant? -- https://mail.python.org/mailman/listinfo/python-list

3.4rc2 and pip on windows

2014-03-02 Thread Mark Lawrence
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:\Python34\Scripts\pip3.4.exe install pyttsx Downloading/unpacking pyttsx Download

Re: Password validation security issue

2014-03-02 Thread Renato
I would like to thank every one who posted a reply. I learnt a lot from you, guys! I appreciate your attention and your help :) I took a class on Computer Simulation last year. It was told that deterministic (pseudo-)random numbers are excellent for simulations, because they allow debugging and

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

2014-03-02 Thread Dave Angel
Chris Angelico Wrote in message: > > } > > so in that case, the array size is inside the malloc'd block, but it's > still invisible to the calling function. > Please quit using negative language when you're so vehemently agreeing with me. The data is sometimes not at the beginning of the m

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Michael Torrie : > And one could also set A=1 and B=1 if he was trying to be stupid. > [...] > If Mark H wants to use an idiom that isn't conventional, or isn't > widely used, he is free to do so; I can't see much harm in it. But > certainly it's not the "normal" way that it's done in Python from

Re: Boxes of O's

2014-03-02 Thread Michael Torrie
On 03/02/2014 07:43 AM, genius...@gmail.com wrote: > I agree with you and really appreciate your experience. But what I > was looking for is clues. Thank you anyway Not sure what you mean. Chris certainly offered you clues to solving this problem. Certainly he pointed you in the right direction t

Re: Can global variable be passed into Python function?

2014-03-02 Thread Michael Torrie
On 03/02/2014 02:03 PM, Marko Rauhamaa wrote: > Michael Torrie : > >> I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM >> became an object of a different type. > > It probably would. > > If one were begging for trouble, one *could* define: > >class ABC: >A = 1 >

Re: Boxes of O's

2014-03-02 Thread Glazner
On Sunday, March 2, 2014 4:43:48 PM UTC+2, geni...@gmail.com wrote: > I agree with you and really appreciate your experience. But what I was > looking for is clues. Thank you anyway #not tested for i in range(n): for j in range(n*2): if i in (0, n - 1) or j in (0, n*2 - 1): print('o',

Re: Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 8:03 AM, Marko Rauhamaa wrote: > If one were begging for trouble, one *could* define: > >class ABC: >A = 1 >B = 1.0 >C = 1+0j You're missing the point of flags, though. One does not use floats for flags. Flags are normally going to be integers (p

Re: Can global variable be passed into Python function?

2014-03-02 Thread Roy Smith
In article <87txbg48kd@elektro.pacujo.net>, Marko Rauhamaa wrote: > Michael Torrie : > > > I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM > > became an object of a different type. > > It probably would. > > If one were begging for trouble, one *could* define: > >

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Michael Torrie : > I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM > became an object of a different type. It probably would. If one were begging for trouble, one *could* define: class ABC: A = 1 B = 1.0 C = 1+0j Now: ABC.A == ABC.B ABC.B ==

Re: Password validation security issue

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 7:01 AM, Roy Smith wrote: > We recently got a frothing email from a user, which basically said, "You > farking idiots, you emailed me my password in plain text!" It turns > out, his user name was the same as his password and what we had sent him > (in response to an account

Re: Password validation security issue

2014-03-02 Thread Roy Smith
In article , Christian Heimes wrote: > On 01.03.2014 21:11, Chris Angelico wrote: > > The problem isn't SHA-256. The problem is insecure passwords, the way > > we've been taught to make them by the banks. Hence, XKCD 936. > > Your argumentation is just wrong. You are saying "It's OK to use a >

Re: passing an option to the python interpreter

2014-03-02 Thread Anssi Saari
Marko Rauhamaa writes: > Jabba Laci : > >> I tried this: >> >> #!/usr/bin/env python -u > > The hash-bang notation is quite rigid; it only accepts a single argument > ("python") to the command ("/usr/bin/env"). > > I don't know if there is a simple workaround. Using the relevant environment vari

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

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 6:17 AM, Dave Angel wrote: > Array size is inside the malloc block, but outside the struct > block. As you can see if you try to delete without the brackets > when you used new [], some runtimes will crash. As in, you have to use "delete [] x" to correspond with "x = new

Re: Password validation security issue

2014-03-02 Thread Christian Heimes
On 01.03.2014 21:11, Chris Angelico wrote: > The problem isn't SHA-256. The problem is insecure passwords, the way > we've been taught to make them by the banks. Hence, XKCD 936. Your argumentation is just wrong. You are saying "It's OK to use a totally insecure way to hash passwords because passw

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

2014-03-02 Thread Chris Angelico
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 >> address of the first field in a struture object _is_

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

2014-03-02 Thread Dave Angel
Chris Angelico Wrote in message: > On Mon, Mar 3, 2014 at 12:22 AM, Dave Angel wrote: >> Sure, for some definition of "usable". Overhead such as block >> size, freelist pointer etc., are obviously outside of the >> returned block. But the array size that's specified in a call to >> new [],

Re: why indentation should be part of the syntax

2014-03-02 Thread Nicholas Cole
On Sun, Mar 2, 2014 at 2:38 PM, Roy Smith wrote: > In article , > Stefan Behnel wrote: > >> 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 du

Re: Can global variable be passed into Python function?

2014-03-02 Thread Michael Torrie
On 03/02/2014 03:07 AM, Chris Angelico wrote: > import os type(os.POSIX_FADV_RANDOM) > > > So use ==. If it's later changed and you have to instead use 'is', you > can change your code. I don't see why == wouldn't continue to work if os.POSIX_FADV_RANDOM became an object of a differen

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

2014-03-02 Thread Mark Lawrence
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 address of the first field in a struture object _is_ the address of the structure object. You say struture, I'll say

Re: Can global variable be passed into Python function?

2014-03-02 Thread Mark Lawrence
On 02/03/2014 16:23, Chris Angelico wrote: A switch block that works with constants and equality *can* be turned into a dict. If the constants are hashable, use them as the keys directly; if they're not hashable and/or you want to use object identity as the criterion (effectively like using 'is'

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

2014-03-02 Thread Grant Edwards
On 2014-03-02, Dave Angel wrote: > Grant Edwards Wrote in message: >> On 2014-02-24, Michael Torrie wrote: >> >>> >>> Why would you think that? The address of the start of your malloc'ed >>> structure is the same as the address of the first element. Surely >>> this is logical? >> >> Not only

Job - Senior Python Engineer - User Interface Applications, Cambridge MA

2014-03-02 Thread scigenium
Senior Python Engineer - User Interface Applications Location : Cambridge MA Who We Are: Gen9 is transforming synthetic biology by creating novel technologies to increase innovation within several industries including biopharmaceuticals, fine chemicals and bio-fuels. Currently such genes are

Re: Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 2:52 AM, Marko Rauhamaa wrote: > Roy Smith : > >> In article <87fvn08vux@elektro.pacujo.net>, >> Marko Rauhamaa wrote: >>> 3. TRY-EXCEPT (3500% slower than DICT DISPATCH TABLE) >> >> I'm glad to hear that. I hope nobody took me seriously when I >> suggested this. > > I

Re: source code control and documentation

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 2:56 AM, Rita wrote: > I am trying to achieve this, every time I commit to svn I automatically run > hooks to test my libraries, ATM I am doing this manually > > cd libs > PYTHONPATH=. python test_lib.py > > and if everything passes I do a svn commit -m 'committing code' >

source code control and documentation

2014-03-02 Thread Rita
Hi, I am trying to achieve this, every time I commit to svn I automatically run hooks to test my libraries, ATM I am doing this manually cd libs PYTHONPATH=. python test_lib.py and if everything passes I do a svn commit -m 'committing code' I don't have access to my svn server so I can't crea

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Roy Smith : > In article <87fvn08vux@elektro.pacujo.net>, > Marko Rauhamaa wrote: >> 3. TRY-EXCEPT (3500% slower than DICT DISPATCH TABLE) > > I'm glad to hear that. I hope nobody took me seriously when I > suggested this. I actually have employed the idea before in a related but slightly d

Re: Can global variable be passed into Python function?

2014-03-02 Thread Roy Smith
In article <87fvn08vux@elektro.pacujo.net>, Marko Rauhamaa wrote: > Marko Rauhamaa : > > > Roy Smith : > > > >> Python already has a switch statement. It's just spelled funny... > >> > >> [...] > >> > >> try: > >>raise value > >> except Case1: > >>print "did case 1" > >> except (Ca

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Marko Rauhamaa : > Roy Smith : > >> Python already has a switch statement. It's just spelled funny... >> >> [...] >> >> try: >>raise value >> except Case1: >>print "did case 1" >> except (Case2, Case3): >>print "did either case 2 or 3" >> else: >>print "did default" > > Not bad! D

Re: Boxes of O's

2014-03-02 Thread Mark Lawrence
On 02/03/2014 14:43, genius...@gmail.com wrote: I agree with you and really appreciate your experience. But what I was looking for is clues. Thank you anyway Sorry, can't resist this one https://www.youtube.com/watch?v=oaGpaj2nHIo :) -- My fellow Pythonistas, ask not what our language can do

Re: Boxes of O's

2014-03-02 Thread geniusrko
I agree with you and really appreciate your experience. But what I was looking for is clues. Thank you anyway -- https://mail.python.org/mailman/listinfo/python-list

Re: why indentation should be part of the syntax

2014-03-02 Thread Roy Smith
In article , Stefan Behnel wrote: > 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 to accidentally > duplicated code not actually being as

Re: Tuples and immutability

2014-03-02 Thread albert visser
On Sun, 02 Mar 2014 15:17:11 +0100, Eric Jacoboni wrote: Le 02/03/2014 15:05, Mark Lawrence a écrit : The behaviour is consistent except when you try to modify a tuple. Not in my opinion... li = [10, 30] li = li + "spam" --> TypeError: can only concatenate list (not "str") li += "spam

Re: why indentation should be part of the syntax

2014-03-02 Thread Tim Chase
On 2014-03-03 01:08, Chris Angelico wrote: > > if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) > > { goto fail; > > goto fail; > > } > > Put it this way: If I saw two gotos in a row like that, with or > without braces, I would be firing up gitk or git gui blame or > s

Re: Tuples and immutability

2014-03-02 Thread Eric Jacoboni
Le 02/03/2014 15:05, Mark Lawrence a écrit : > The behaviour is consistent except when you try to modify a tuple. > Not in my opinion... li = [10, 30] li = li + "spam" --> TypeError: can only concatenate list (not "str") li += "spam" --> Ok So, not, that's not what i call consistent.

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

2014-03-02 Thread Chris Angelico
On Mon, Mar 3, 2014 at 12:22 AM, Dave Angel wrote: > Sure, for some definition of "usable". Overhead such as block > size, freelist pointer etc., are obviously outside of the > returned block. But the array size that's specified in a call to > new [], and the vptr, are definitely inside the

Re: why indentation should be part of the syntax

2014-03-02 Thread Chris Angelico
On Sun, Mar 2, 2014 at 11:36 PM, Ned Batchelder wrote: > As much as I like indentation as syntax, and am amused by this bug, I'm not > sure we can chalk it all up to space-vs-brace. After all, who would have > wanted two goto's in a row even with braces? It's not like there's some > engineer at A

Re: Tuples and immutability

2014-03-02 Thread Mark Lawrence
On 02/03/2014 13:38, Eric Jacoboni wrote: Le 02/03/2014 13:32, Ian Kelly a écrit : On Sat, Mar 1, 2014 at 7:04 PM, Eric Jacoboni wrote: In fact, i think i'm gonna forget += on lists :) Well, do what you want, but I think you're taking the wrong lesson from this. Don't forget about using +=

Re: Tuples and immutability

2014-03-02 Thread Eric Jacoboni
Le 02/03/2014 13:32, Ian Kelly a écrit : > On Sat, Mar 1, 2014 at 7:04 PM, Eric Jacoboni wrote: >> In fact, i think i'm gonna forget += on lists :) > > Well, do what you want, but I think you're taking the wrong lesson > from this. Don't forget about using += on lists. Instead, forget > about u

HUMANS HAVE ORIGINS IN THE DEVONIAN, AND YOU KNOW IT!

2014-03-02 Thread THRINASSODON1
>BREAKING FUCKING NEWS, ASSHOLES! > THRINAXODON JUST FOUND THREE HUMAN FOSSILS FROM DEVONIAN STRATA IN GREENLAND; THE FOSSILS WERE A HUMAN FEMUR, KNEECAP, AND SKULLCAP. > THE SMITHSONIAN IS CHASTISING OVER THESE FINDS, DOING EVERY

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

2014-03-02 Thread Dave Angel
Chris Angelico Wrote in message: > On Sun, Mar 2, 2014 at 3:02 PM, Dave Angel wrote: >> The quote you make from the C standard doesn't mention malloc, so >> you're arguing different things. It's not the compiler that casts >> the malloc return value to the struct type. >> >> C++ does implicit

Re: Can global variable be passed into Python function?

2014-03-02 Thread Mark Lawrence
On 02/03/2014 09:35, Marko Rauhamaa wrote: Steven D'Aprano : On Sat, 01 Mar 2014 19:29:41 +0200, Marko Rauhamaa wrote: Michael Torrie : No, '==' works fine no matter what objects you assign to your state variables. Well, it doesn't since >>> a = float("nan") >>> a is a True

Re: Can global variable be passed into Python function?

2014-03-02 Thread Mark Lawrence
On 02/03/2014 10:59, Ben Finney wrote: Marko Rauhamaa writes: Ben Finney : The unreliability is “will objects defined elsewhere have a different identity?” That question is not interesting in my context, and has no bearing on the correctness of the program. You keep vacillating between t

Re: why indentation should be part of the syntax

2014-03-02 Thread Ned Batchelder
On 3/2/14 5:41 AM, Stefan Behnel wrote: 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 to accidentally duplicated code not actually being as ind

Re: Tuples and immutability

2014-03-02 Thread Ian Kelly
On Sat, Mar 1, 2014 at 7:04 PM, Eric Jacoboni wrote: > In fact, i think i'm gonna forget += on lists :) Well, do what you want, but I think you're taking the wrong lesson from this. Don't forget about using += on lists. Instead, forget about using assignments, augmented or otherwise, on tuple e

Re: Can tuples be replaced with lists all the time?

2014-03-02 Thread Ashish Panchal
No, not always. You can use yuples as dictionary key as keys are immutable and you can't use it as list. -- https://mail.python.org/mailman/listinfo/python-list

Re: posting code snippets

2014-03-02 Thread Gene Heskett
On Sunday 02 March 2014 07:05:06 Alister did opine: > On Sun, 02 Mar 2014 09:16:35 +1100, Chris Angelico wrote: > > On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards > > > > > > wrote: > >> You drag out the lab scope, logic analyzer, spectrum analyzer, sweep > >> generator, strip plotter, and the ma

Re: why indentation should be part of the syntax

2014-03-02 Thread Bernd Nawothnig
On 2014-03-02, Stefan Behnel wrote: > 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 to accidentally > duplicated code not actually being as i

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Steven D'Aprano : > On Sun, 02 Mar 2014 11:35:43 +0200, Marko Rauhamaa wrote: >> Now, what kinds of object are those constants? We are not supposed to >> know or care. > > Incorrect. We are supposed to know and care. Then, the documentation is seriously flawed. It gives no hint whatsoever on the

Re: posting code snippets

2014-03-02 Thread Alister
On Sun, 02 Mar 2014 09:16:35 +1100, Chris Angelico wrote: > On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards > wrote: >> You drag out the lab scope, logic analyzer, spectrum analyzer, sweep >> generator, strip plotter, and the machine that goes "ping". You start >> to get everything set up to nail

Re: Can global variable be passed into Python function?

2014-03-02 Thread Ben Finney
Marko Rauhamaa writes: > Ben Finney : > > > The unreliability is “will objects defined elsewhere have a different > > identity?” > > That question is not interesting in my context, and has no bearing on > the correctness of the program. You keep vacillating between two positions: pick one for th

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
On Sun, 02 Mar 2014 11:35:43 +0200, Marko Rauhamaa wrote: > Nobody is saying there's a bug in the implementation of "==". I'm just > saying "==" cannot be taken as a universal superset of "is". Therefore a > program cannot blindly use "==" to test for identity. Um, yes? Nor can you use ">" to tes

why indentation should be part of the syntax

2014-03-02 Thread Stefan Behnel
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 to accidentally duplicated code not actually being as indented as it looked: https://www.imperialv

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Chris Angelico : > And there's another thing you can do to test. > import os type(os.POSIX_FADV_RANDOM) > Is that what you do in your programs? > So use ==. If it's later changed and you have to instead use 'is', you > can change your code. Quite a robust API, huh? Anyway, you recog

Re: Can global variable be passed into Python function?

2014-03-02 Thread Chris Angelico
On Sun, Mar 2, 2014 at 8:35 PM, Marko Rauhamaa wrote: > However, on the same reference page, os.posix_fadvise() is defined. We > read: > >advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL, >POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED or >POSIX_FADV_DONTNEED > > N

Re: Mac vs. Linux for Python Development

2014-03-02 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:35 PM, Frank Millman wrote: > I assume by 'warm cache' you mean that I had used the decimal module before > and not switched the machine off before trying the above exercise. > > In my case, the machine was switched off before I started. I switched it on > and executed the

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Marko Rauhamaa : > If I take the API documentation on its face value, [...] > I *must* use "is" for os.POSIX_FAVD_*: > > if fsavd_flag is os.POSIX_FADV_RANDOM: > ... However, since a documentation flaw is more than likely, it is even more prudent to avoid both "==" and "is" and create

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Steven D'Aprano : > On Sat, 01 Mar 2014 19:29:41 +0200, Marko Rauhamaa wrote: >> Michael Torrie : >>> No, '==' works fine no matter what objects you assign to your state >>> variables. >> >> Well, it doesn't since >> >>>>> a = float("nan") >>>>> a is a >>True >>>>> a == a >>F

Re: Can global variable be passed into Python function?

2014-03-02 Thread Steven D'Aprano
On Sat, 01 Mar 2014 19:29:41 +0200, Marko Rauhamaa wrote: > Michael Torrie : > >> No, '==' works fine no matter what objects you assign to your state >> variables. > > Well, it doesn't since > >>>> a = float("nan") >>>> a is a >True >>>> a == a >False No, that is working co

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Ben Finney : > The unreliability is “will objects defined elsewhere have a different > identity?” That question is not interesting in my context, and has no bearing on the correctness of the program. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Roy Smith : > Python already has a switch statement. It's just spelled funny... > > [...] > > try: >raise value > except Case1: >print "did case 1" > except (Case2, Case3): >print "did either case 2 or 3" > else: >print "did default" Not bad! Definitely worth considering. > No f

Re: Can global variable be passed into Python function?

2014-03-02 Thread Marko Rauhamaa
Grant Edwards : > any decent compiler should be able to generate the same code for a > switch statement and for an equivalent chained if/else. It's not so easy to be decent, especially when it comes to a language as dynamic as Python. Marko -- https://mail.python.org/mailman/listinfo/python-li

  1   2   >