Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: Since you don't care about identity, only that the objects have different values, you should be comparing for equality with ‘==’. Ok, one last attempt. I need *identifiers*. I could simply define: class ABC: A = object() B = object()

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: But I'm not sure that there is a good reason to put the class definitions inside the __init__ method. That means every time you create a new StateMachine instance, the classes have to be re-created. [...] It will be much more

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa ma...@pacujo.net writes: Ben Finney ben+pyt...@benfinney.id.au: Since you don't care about identity, only that the objects have different values, you should be comparing for equality with ‘==’. Ok, one last attempt. I need *identifiers*. And, as you've realised, without

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
Thanks Peter and Simon for the hints it worked : ) without ' =' # Python corrupt.py -o INODE -p /ifs/1.txt -q SET -f 1 Current Default Choice : Choice: INODE Choice: SET Choice: 1 Iam done with the command line parsing but got stuck while trying to implement switch kind of

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: Use ‘==’, since that's all that matters for getting a value that will work fine. You are telling me to use '==' if I choose string objects and 'is' if I choose some other objects. I prefer a solution that works regardless of what objects I choose for

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Peter Otten
Ganesh Pal wrote: Iam using the options.name directly for manipulations is this fine or do I need to assign it to variable and then use it if options.object_type == 'LIN': corrupt_inode() This is fine. You would only consider storing the value if you are going to use it very often

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 16:43:11 +0530, Ganesh Pal wrote: Iam done with the command line parsing but got stuck while trying to implement switch kind of behavior with dictionaries. So posting 2 more questions You should start new threads for new questions. The subject line here has nothing to do

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sat, Mar 1, 2014 at 10:28 PM, Marko Rauhamaa ma...@pacujo.net wrote: Ben Finney ben+pyt...@benfinney.id.au: Use ‘==’, since that's all that matters for getting a value that will work fine. You are telling me to use '==' if I choose string objects and 'is' if I choose some other objects.

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
handler = object_type_dictionary[options.object_type] # look up the function handler() # call it The last two lines could also be merged into one object_type_dictionary[options.object_type]() but the first version may be clearer. Thanks for your valuable inputs all worked :) --

Re: Python : parsing the command line options using optparse

2014-03-01 Thread Ganesh Pal
On Sat, Mar 1, 2014 at 5:17 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: You should start new threads for new questions. The subject line here has nothing to do with the questions you ask. Sure Steven and thanks for replying and your suggestion for Question 2 ( same

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa ma...@pacujo.net writes: Ben Finney ben+pyt...@benfinney.id.au: Use ‘==’, since that's all that matters for getting a value that will work fine. You are telling me to use '==' if I choose string objects and 'is' if I choose some other objects. No. I'm telling you that

Re: insert html into ElementTree without parsing it

2014-03-01 Thread Stefan Behnel
graeme.piete...@gmail.com, 24.02.2014 10:45: I am building HTML pages using ElementTree. I need to insert chunks of untrusted HTML into the page. I do not need or want to parse this, just insert it at a particular point as is. How would you want to find out if it can be safely inserted or not

Re: Tuples and immutability

2014-03-01 Thread Mark Lawrence
On 01/03/2014 06:16, Mark H. Harris wrote: On Friday, February 28, 2014 11:16:18 PM UTC-6, Ian wrote: How would you propose doing that? Bear in mind that while Python knows that tuples specifically are immutable, it doesn't generally know whether a type is immutable. hi Ian, consider the

HUMANS HAVE ORIGINS IN THE DEVONIAN.....

2014-03-01 Thread THRINAXODON
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

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark Lawrence
On 01/03/2014 11:59, Chris Angelico wrote: On Sat, Mar 1, 2014 at 10:28 PM, Marko Rauhamaa ma...@pacujo.net wrote: There really is no taboo against string object identity if you know what you are doing. And, as proven here in this thread, you do not know what you are doing. Why do you

Re: Can global variable be passed into Python function?

2014-03-01 Thread Michael Torrie
On 03/01/2014 04:28 AM, Marko Rauhamaa wrote: Ben Finney ben+pyt...@benfinney.id.au: Use ‘==’, since that's all that matters for getting a value that will work fine. You are telling me to use '==' if I choose string objects and 'is' if I choose some other objects. No, '==' works fine no

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 22:59:52 +1100, Chris Angelico wrote: On Sat, Mar 1, 2014 at 10:28 PM, Marko Rauhamaa ma...@pacujo.net wrote: Ben Finney ben+pyt...@benfinney.id.au: Use ‘==’, since that's all that matters for getting a value that will work fine. You are telling me to use '==' if I

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 12:31:39 +0200, Marko Rauhamaa wrote: I need *identifiers*. I could simply define: class ABC: A = object() B = object() C = object() The program would work perfectly. Except, if it's got a bug. I know self.abc contains either A, B or C,

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Ben Finney ben+pyt...@benfinney.id.au: No. I'm telling you that ‘is’ is *wrong* for comparing strings, because it is unreliable. No, it isn't as long as the string object references have a common assignment pedigree. Assignment (including parameter passing) is guaranteed to preserve identity

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 01 Mar 2014 22:59:52 +1100, Chris Angelico wrote: And, as proven here in this thread, you do not know what you are doing. Steady on, that's a bit harsh. In context, I think that Marko is

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:23 AM, Marko Rauhamaa ma...@pacujo.net wrote: Ben Finney ben+pyt...@benfinney.id.au: No. I'm telling you that ‘is’ is *wrong* for comparing strings, because it is unreliable. No, it isn't as long as the string object references have a common assignment pedigree.

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Michael Torrie torr...@gmail.com: 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 More generally, it depends on how the __eq__ method has been implemented for the class. You might

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:29 AM, Marko Rauhamaa ma...@pacujo.net wrote: You might even (foolishly) define a class such that: a == b False a != b False Not necessarily even foolish; the SQL NULL value [1] behaves like that. ChrisA [1] Which isn't a value, except when it is --

Password validation security issue

2014-03-01 Thread Renato
Hello everybody, I implemented a password validation with a Python 2.7.5 script in OpenSUSE 13.1. The user calls it passing 'login' and 'password' as arguments. I made a dictionary in the format hashtable = {'login':'password'} and I use this hash table to compare the 'login' and 'password'

Re: Tuples and immutability

2014-03-01 Thread Ned Batchelder
On 3/1/14 12:50 AM, Mark H. Harris wrote: On Friday, February 28, 2014 11:34:56 PM UTC-6, Ian wrote: One very common example of tuples containing lists is when lists are passed to any function that accepts *args, because the extra arguments are passed in a tuple. A similarly common example is

Re: Help with Guess the number script

2014-03-01 Thread Susan Aldridge
Try this def guess1(upLimit = 100): import random num = random.randint(1,upLimit) count = 0 gotIt = False while (not gotIt): print('Guess a number between 1 and', upLimit, ':') guess= int(input()) count += 1 if guess == num:

Re: Can global variable be passed into Python function?

2014-03-01 Thread Michael Torrie
On 03/01/2014 10:29 AM, Marko Rauhamaa wrote: Michael Torrie torr...@gmail.com: 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 More generally, it depends on how the

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:49 AM, Renato rvernu...@gmail.com wrote: Hello everybody, I implemented a password validation with a Python 2.7.5 script in OpenSUSE 13.1. The user calls it passing 'login' and 'password' as arguments. I made a dictionary in the format hashtable = {'login':'password'}

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: It seems to me that he's just assuming that symbols ought to be singletons, hence his focus on identity rather than equality. Yes. A practical angle is this: if I used strings as symbols and compared them with ==, logically I shouldn't

Re: Password validation security issue

2014-03-01 Thread Christian Heimes
On 01.03.2014 19:11, Chris Angelico wrote: On Sun, Mar 2, 2014 at 4:49 AM, Renato rvernu...@gmail.com wrote: Hello everybody, I implemented a password validation with a Python 2.7.5 script in OpenSUSE 13.1. The user calls it passing 'login' and 'password' as arguments. I made a dictionary in

Re: Password validation security issue

2014-03-01 Thread Tim Chase
On 2014-03-02 05:11, Chris Angelico wrote: On Sun, Mar 2, 2014 at 4:49 AM, Renato rvernu...@gmail.com wrote: My question is: is there a way of preventing the user from reading the script's content? Not really. It might be a bit obfuscated, but Is there any strategy I could use to hide

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 5:38 AM, Tim Chase python.l...@tim.thechases.com wrote: That said, if the user has access to the source code, there's nothing preventing them from changing if hash(provided_password) == existing_hash: do_magic() into just if True: do_magic() and

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 5:31 AM, Christian Heimes christ...@python.org wrote: encrypted = hashlib.sha256(login+'NaCl protects your passwords'+password).hexdigest() encrypted 'b329f2674af4d8d873e264d23713ace4505c211410eb46779c27e02d5a50466c' Please don't do that. It's insecure and not the

Re: Tuples and immutability

2014-03-01 Thread Oscar Benjamin
On 27 February 2014 21:47, Nick Timkovich prometheus...@gmail.com wrote: On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico ros...@gmail.com wrote: It's unintuitive, but it's a consequence of the way += is defined. If you don't want assignment, don't use assignment :) Where is `.__iadd__()`

Boxes of O's

2014-03-01 Thread geniusrko
Hi Can anyone help with this problem Create a big box out of n rows of little o's for any desired size n. Use an input statement to allow the user to enter the value for n and then print the properly sized box. E.g. n = 3 oo oo oo

Re: Boxes of O's

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:12 AM, genius...@gmail.com wrote: Create a big box out of n rows of little o's for any desired size n. Use an input statement to allow the user to enter the value for n and then print the properly sized box. How far have you gotten so far with your homework? Show us

Re: Boxes of O's

2014-03-01 Thread geniusrko
Well, This is what i got n = int(input(enter number of o: )) for i in range(n): print(O, end = '') for j in range(n* 2): print(O, end = '') print() -- https://mail.python.org/mailman/listinfo/python-list

Re: Boxes of O's

2014-03-01 Thread MRAB
On 2014-03-01 19:28, genius...@gmail.com wrote: Well, This is what i got n = int(input(enter number of o: )) for i in range(n): print(O, end = '') for j in range(n* 2): print(O, end = '') print() From the examples: The first row has n*2 of 'o' There are n-2

Re: Tuples and immutability

2014-03-01 Thread Ian Kelly
On Fri, Feb 28, 2014 at 11:25 PM, Mark H. Harris harrismh...@gmail.com wrote: On Friday, February 28, 2014 11:16:18 PM UTC-6, Ian wrote: How would you propose doing that? Bear in mind that while Python knows that tuples specifically are immutable, it doesn't generally know whether a type is

Re: Boxes of O's

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:28 AM, genius...@gmail.com wrote: Well, This is what i got n = int(input(enter number of o: )) for i in range(n): print(O, end = '') for j in range(n* 2): print(O, end = '') print() Okay! Good. Now, presumably this isn't working yet, or you

Re: Password validation security issue

2014-03-01 Thread Christian Heimes
On 01.03.2014 19:45, Chris Angelico wrote: On Sun, Mar 2, 2014 at 5:31 AM, Christian Heimes christ...@python.org wrote: encrypted = hashlib.sha256(login+'NaCl protects your passwords'+password).hexdigest() encrypted 'b329f2674af4d8d873e264d23713ace4505c211410eb46779c27e02d5a50466c' Please

How to extract contents of inner text of html tag?

2014-03-01 Thread Golam Md. Shibly
Hi, ###in.txt kbd class=command cp -v --remove-destination /usr/share/zoneinfo/ em class=replaceablecodexxx/code/em \ /etc/localtime /kbd import sys import unicodedata from bs4 import BeautifulSoup file_name=in.txt html_doc=open(file_name,'r') soup=BeautifulSoup(html_doc)

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:54 AM, Christian Heimes christ...@python.org wrote: Yes, for most applications brute force is still the best option to crack the password. Passwords are usually rather short, have a low entropy and modern hardware is insanely fast. With software like [1] and a fast GPU

Re: Tuples and immutability

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 8:54:43 AM UTC-6, Mark Lawrence wrote: you're also using google groups... it doesn't wrap paragraphs correctly... please read and action this https://wiki.python.org/moin/GoogleGroupsPython... it does wrap paragraphs correctly... it also prevents us

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Roy Smith
In article 2465a8c7-ce0e-4606-ad3b-9135c96e3...@googlegroups.com, twiz twiza...@gmail.com wrote: Hello, I'm sure this is a common question but I can't seem to find a previous thread that addresses it. If one one exists, please point me to it. I've been developing with python

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

2014-03-01 Thread Grant Edwards
On 2014-02-23, Sam lightai...@gmail.com wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if I am wrong. In addition to the things related to

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

2014-03-01 Thread Roy Smith
In article 64af70e3-6876-4fbf-8386-330d2f487...@googlegroups.com, Sam lightai...@gmail.com wrote: My understanding of Python tuples is that they are like immutable lists. If this is the cause, why can't we replace tuples with lists all the time (just don't reassign the lists)? Correct me if

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

2014-03-01 Thread Roy Smith
In article led9s7$req$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: In constrast, tuples are often used as fixed-length heterogenous containers (more like a struct in C except the fields are named 0, 1, 2, 3, etc.). In a particular context, the Nth element of a tuple

Re: Functions help

2014-03-01 Thread Roy Smith
In article mailman.7297.1393204171.18130.python-l...@python.org, Mark Lawrence breamore...@yahoo.co.uk wrote: On 24/02/2014 00:55, alex23 wrote: On 23/02/2014 3:43 PM, Scott W Dunning wrote: I had a question regarding functions. Is there a way to call a function multiple times without

Re: Functions help

2014-03-01 Thread Grant Edwards
On 2014-02-24, Benjamin Kaplan benjamin.kap...@case.edu wrote: On Sun, Feb 23, 2014 at 5:39 PM, alex23 wuwe...@gmail.com wrote: On 24/02/2014 11:09 AM, Mark Lawrence wrote: On 24/02/2014 00:55, alex23 wrote: for _ in range(5): func() the obvious indentation error above

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

2014-03-01 Thread Grant Edwards
On 2014-02-24, Michael Torrie torr...@gmail.com wrote: On 02/24/2014 11:05 AM, j.e.ha...@gmail.com wrote: typedef struct { int value; } Number; Number *o; o = malloc(sizeof(*o)); o-value=3; printf(o%p, o-value%p\n, o, o-value); o0x9fe5008, o-value0x9fe5008 Is the compiler

Re: intersection, union, difference, symmetric difference for dictionaries

2014-03-01 Thread Grant Edwards
On 2014-02-25, mauro ma...@gmail.com wrote: Dictionaries and sets share a few properties: - Dictionaries keys are unique as well as sets items - Dictionaries and sets are both unordered - Dictionaries and sets are both accessed by key - Dictionaries and sets are both mutables So I wonder

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Grant Edwards
On 2014-02-24, Chris Angelico ros...@gmail.com wrote: So pick any distro that strikes your fancy! Try it out! If it doesn't work out, pick a different one. Start with one that your friends use (if you have any), that way you can get immediate help. That last bit of advice shouldn't be

Re: Coding a simple state machine in python

2014-03-01 Thread Roy Smith
In article 65ac9612-fd48-472a-b077-c802be96e...@googlegroups.com, Ronaldo abhishek1...@gmail.com wrote: How do I write a state machine in python? I have identified the states and the conditions. Is it possible to do simple a if-then-else sort of an algorithm? Below is some pseudo code:

Re: Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-28, Marko Rauhamaa ma...@pacujo.net wrote: Chris Angelico ros...@gmail.com: Can you elaborate on this nonliteral constants point? How is it a problem if DISCONNECTING isn't technically a constant? It follows the Python convention of being in all upper-case, so the programmer

Re: posting code snippets

2014-03-01 Thread Grant Edwards
On 2014-02-28, Chris Angelico ros...@gmail.com wrote: The problem does have to believe that the rubber duck/teddy bear/figurine is an expert, though. I've had my siblings or parents come to me with problems and, without saying a word or touching the computer or anything, I've solved them. The

Re: intersection, union, difference, symmetric difference for dictionaries

2014-03-01 Thread John Gordon
In G57Pu.24239$th2.4...@tornado.fastwebnet.it mauro ma...@gmail.com writes: - Dictionaries and sets are both accessed by key As far as I have used sets, they are not accessed by key. x = set([1, 2, 'buckle my shoe']) x set([1, 2, 'buckle my shoe']) 1 in x True 5 in x False -- John Gordon

Re: Need help in writing some code so i can re-use it in every module or class

2014-03-01 Thread Roy Smith
In article mailman.7395.1393423618.18130.python-l...@python.org, Unix SA d.josh...@gmail.com wrote: Hello Experts, I have requirement, like i want to use below command in python script. command --username username --password password Command line arguments now my requirement is i

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
On Sat, Mar 1, 2014 at 10:06 AM, Marko Rauhamaa ma...@pacujo.net wrote: A colleague of mine taught me decades back that the whole point of OO was the avoidance of if and switch statements. So if your code has an if or switch statement, chances are you are doing something wrong. This sounds

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article 87d2i7wbxs@elektro.pacujo.net, Marko Rauhamaa ma...@pacujo.net wrote: Neil Cerutti ne...@norwich.edu: Check out Go's switch statement for an example of what it might look like in Python. Except you'd get it without labeled break or the fallthrough statement. Python

Re: Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-28, Marko Rauhamaa ma...@pacujo.net wrote: Here's a use case for is with strings (or ints): class Connection: IDLE = IDLE CONNECTING = CONNECTING CONNECTED = CONNECTED DISCONNECTING = DISCONNECTING DISCONNECTED = DISCONNECTED def

Re: Tuples and immutability

2014-03-01 Thread Mark H. Harris
On Friday, February 28, 2014 11:16:18 PM UTC-6, Ian wrote: How would you propose doing that? Bear in mind that while Python knows that tuples specifically are immutable, it doesn't generally know whether a type is immutable. hi Ian, I thought of something else after I slept on it, so to

Re: Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-28, Mark Lawrence breamore...@yahoo.co.uk wrote: http://c2.com/cgi/wiki?SwitchStatementsSmell So lack of a switch state is an attempt to force Python programmers to write things in an object oriented way? -- Grant Edwards grant.b.edwardsYow! FUN is never

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article 0b414429-74ee-45dd-9465-c87e98c36...@googlegroups.com, Mark H. Harris harrismh...@gmail.com wrote: On Friday, February 28, 2014 3:03:25 PM UTC-6, Marko Rauhamaa wrote: Marko ... and between me and you, here is a snip from dmath.py from the atan(x) function: if

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article mailman.7483.1393632181.18130.python-l...@python.org, Ben Finney ben+pyt...@benfinney.id.au wrote: Of course. That's the point of describing something as a “code smell”: it may have exceptions where the smell does not indicate an actual problem, but those are not the normal

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

2014-03-01 Thread Mark Lawrence
On 23/02/2014 17:48, Roy Smith wrote: In article led9s7$req$1...@reader1.panix.com, Grant Edwards invalid@invalid.invalid wrote: In constrast, tuples are often used as fixed-length heterogenous containers (more like a struct in C except the fields are named 0, 1, 2, 3, etc.). In a

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article 87mwh9969m@elektro.pacujo.net, Marko Rauhamaa ma...@pacujo.net wrote: Michael Torrie torr...@gmail.com: 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

Re: Password validation security issue

2014-03-01 Thread Roy Smith
In article mailman.7533.1393703687.18130.python-l...@python.org, Christian Heimes christ...@python.org wrote: With software like [1] and a fast GPU it is possible to do more than 10*10^9 checks/second for SHA-256. Just out of curiosity, how does that differ from 10^10 checks/second? --

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 12:24:15 AM UTC-6, Chris Angelico wrote: much code. If you want to change anything, you potentially have to edit three places: the list of constants at the top, the condition function, and the switch. This can't be your idea of readability. Show me where

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark Lawrence
On 01/03/2014 21:40, Mark H. Harris wrote: On Saturday, March 1, 2014 12:24:15 AM UTC-6, Chris Angelico wrote: much code. If you want to change anything, you potentially have to edit three places: the list of constants at the top, the condition function, and the switch. This can't be your

Re: posting code snippets

2014-03-01 Thread Gene Heskett
On Saturday 01 March 2014 16:52:44 Grant Edwards did opine: On 2014-02-28, Chris Angelico ros...@gmail.com wrote: The problem does have to believe that the rubber duck/teddy bear/figurine is an expert, though. I've had my siblings or parents come to me with problems and, without saying a

Re: Password validation security issue

2014-03-01 Thread Christian Heimes
On 01.03.2014 21:25, Roy Smith wrote: In article mailman.7533.1393703687.18130.python-l...@python.org, Christian Heimes christ...@python.org wrote: With software like [1] and a fast GPU it is possible to do more than 10*10^9 checks/second for SHA-256. Just out of curiosity, how does

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 4:01:12 PM UTC-6, Mark Lawrence wrote: No elipses, just the paragraphs not wrapped and the double line spacing. Good old gg, I just love it. How do I fix it? Is there a setting someplace? I tried pulling up the page you linked, but blank. Thanks in

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 8:40 AM, Mark H. Harris harrismh...@gmail.com wrote: hi Chris, I don't think you're wrong. There are two issues for me (and one of them is not how the switch is implemented). 1) Is it easier for average users of python as a language to read switch case default, or

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 9:07 AM, Christian Heimes christ...@python.org wrote: On 01.03.2014 21:25, Roy Smith wrote: In article mailman.7533.1393703687.18130.python-l...@python.org, Christian Heimes christ...@python.org wrote: With software like [1] and a fast GPU it is possible to do more

Re: posting code snippets

2014-03-01 Thread Chris Angelico
On Sat, Mar 1, 2014 at 1:31 AM, Grant Edwards invalid@invalid.invalid 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 that problem securely to the dissecting board.

Re: intersection, union, difference, symmetric difference for dictionaries

2014-03-01 Thread Chris Angelico
On Wed, Feb 26, 2014 at 7:44 AM, John Gordon gor...@panix.com wrote: In G57Pu.24239$th2.4...@tornado.fastwebnet.it mauro ma...@gmail.com writes: - Dictionaries and sets are both accessed by key As far as I have used sets, they are not accessed by key. x = set([1, 2, 'buckle my shoe']) x

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa ma...@pacujo.net writes: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: It seems to me that he's just assuming that symbols ought to be singletons, hence his focus on identity rather than equality. Yes. Give that up, then. Your assumption is false in Python, and is

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Mark H. Harris
On Sunday, February 23, 2014 2:43:14 AM UTC-6, twiz wrote: I'm sure this is a common question but I can't seem to find a previous thread that addresses it. If one one exists, please point me to it. My personal preference for writing and testing python code is Gnu/Linux as a platform (free

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa ma...@pacujo.net writes: Ben Finney ben+pyt...@benfinney.id.au: No. I'm telling you that ‘is’ is *wrong* for comparing strings, because it is unreliable. No, it isn't as long as the string object references have a common assignment pedigree. Assignment (including parameter

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Grant Edwards invalid@invalid.invalid writes: On 2014-02-28, Mark Lawrence breamore...@yahoo.co.uk wrote: http://c2.com/cgi/wiki?SwitchStatementsSmell So lack of a switch state is an attempt […] Since when is the absence of action an “attempt” to do anything? You're assuming the not-doing

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 4:36:07 PM UTC-6, Ben Finney wrote: Since when is the absence of action an attempt to do anything? You're assuming the not-doing of something must have a purpose. That assumption doesn't seem justified. Correct. Argument from silence is logical fallacy; lack of

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 9:32 AM, Mark H. Harris harrismh...@gmail.com wrote: Py3.3.4 and the latest Active TCL are stable on OSX 10.6 or higher. I have been very pleased with IDLE on both Gnu/Linux and OSX ( I refuse to use Windows ever again, ever) and my latest experience has been fabulous,

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Ned Deily
In article 4e741358-ce12-40ac-97b8-3bbbf2d6d...@googlegroups.com, Mark H. Harris harrismh...@gmail.com wrote: [...] The main problem you will see with OSX (if you're not careful) is that IDLE will be unstable. To be fair about it, its not IDLE's problem, per se. Its about tcl/tk tkinter.

Re: Can global variable be passed into Python function?

2014-03-01 Thread Steven D'Aprano
On Sat, 01 Mar 2014 20:25:51 +0200, Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: It seems to me that he's just assuming that symbols ought to be singletons, hence his focus on identity rather than equality. Yes. A practical angle is this: if I used

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

2014-03-01 Thread Terry Reedy
On 3/1/2014 4:20 PM, Mark Lawrence wrote: On 23/02/2014 17:48, Roy Smith wrote: It also appears that tuples are more memory efficient. I just ran some quick tests on my OSX box. Creating a list of 10 million [1, 2, 3, 4, 5] lists gave me a 1445 MB process. The name number of (1, 2, 3, 4,

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark Lawrence
On 01/03/2014 22:07, Mark H. Harris wrote: On Saturday, March 1, 2014 4:01:12 PM UTC-6, Mark Lawrence wrote: No elipses, just the paragraphs not wrapped and the double line spacing. Good old gg, I just love it. How do I fix it? Is there a setting someplace? I tried pulling up the

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 5:21:57 PM UTC-6, Mark Lawrence wrote: https://wiki.python.org/moin/GoogleGroupsPython Thanks, Mark. Whoohoo! Looks like gg has some work to do. rats(). Ok, so I'm typing away here and when I get to the boarder I should press the enter key so that the text is forced

Re: Can global variable be passed into Python function?

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 11:23 AM, Mark H. Harris harrismh...@gmail.com wrote: On Saturday, March 1, 2014 5:21:57 PM UTC-6, Mark Lawrence wrote: https://wiki.python.org/moin/GoogleGroupsPython Thanks, Mark. Whoohoo! Looks like gg has some work to do. rats(). Ok, so I'm typing away here and

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark Lawrence
On 02/03/2014 00:23, Mark H. Harris wrote: On Saturday, March 1, 2014 5:21:57 PM UTC-6, Mark Lawrence wrote: https://wiki.python.org/moin/GoogleGroupsPython Thanks, Mark. Whoohoo! Looks like gg has some work to do. rats(). Ok, so I'm typing away here and when I get to the boarder I should

Re: extend methods of decimal module

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 12:55:07 AM UTC-6, Anssi Saari wrote: I recently watched a presentation by Jessica McKellar of PSF about what Python needs to stay popular. Other than the obvious bits (difficulties of limited support of Python on major platforms like Windows and mobile) the slight

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Cameron Simpson
On 01Mar2014 15:07, Ned Deily n...@acm.org wrote: In article 4e741358-ce12-40ac-97b8-3bbbf2d6d...@googlegroups.com, Mark H. Harris harrismh...@gmail.com wrote: [...] If you want to use terminals on OSX you'll want to install Quartz and run the terminal on the emulated X environment.

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ned Deily
In article captjjmqgh5-n8fgki+vmd8grzcw5np64kinka9_b6ewf8gv...@mail.gmail.com, Chris Angelico ros...@gmail.com wrote: What I would recommend, if you don't feel like setting up NNTP, is to subscribe to the mailing list: https://mail.python.org/mailman/listinfo/python-list All the same

Re: Help with Guess the number script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 11:03 AM, Susan Aldridge susanaldridge...@gmail.com wrote: Try this def guess1(upLimit = 100): import random num = random.randint(1,upLimit) count = 0 gotIt = False while (not gotIt): print('Guess a number between 1 and', upLimit, ':')

Re: Can global variable be passed into Python function?

2014-03-01 Thread Mark Lawrence
On 02/03/2014 00:55, Ned Deily wrote: In article captjjmqgh5-n8fgki+vmd8grzcw5np64kinka9_b6ewf8gv...@mail.gmail.com, Chris Angelico ros...@gmail.com wrote: What I would recommend, if you don't feel like setting up NNTP, is to subscribe to the mailing list:

Re: Help with Guess the number script

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 12:11 PM, Scott W Dunning swdunn...@cox.net wrote: print('You got it in ', count, 'guesses.') Thanks Susan! The only problem is he wants us to do it without loops because we haven’t learned them yet. I need to use the variables and function names that he’s given

Re: Tuples and immutability

2014-03-01 Thread Eric Jacoboni
Le 01/03/2014 22:21, Mark H. Harris a écrit : The point I'm trying to make with this post is that s[2]+=[46] and s[2]=s[2]+[46] are handled inconsistently. For my own, the fact that, in Python, a_liste += e_elt gives a different result than a_list = a_list + e_elt is a big source of

Re: Tuples and immutability

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 3:21:44 PM UTC-6, Mark H. Harris wrote: On Friday, February 28, 2014 11:16:18 PM UTC-6, Ian wrote: hi Ian, I thought of something else after I slept on it, so to speak. Consider this: s=(2,3,[42,43,44],7) s[2] [42, 43, 44] s[2] is a list. We should be able

Re: Tuples and immutability

2014-03-01 Thread Mark H. Harris
On Saturday, March 1, 2014 8:04:32 PM UTC-6, Eric Jacoboni wrote: In fact, i think i'm gonna forget += on lists :) hi Eric, well, that might be extreme, but you certainly want to avoid trying to change an immutable. Something you might want to consider is trying something like creating a new

Re: Help with Guess the number script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 9:35 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: Without loops, one part of your assignment is going to be tedious, unless the intent is to only allow for one guess per run. No, 10 guesses per game. Yes very tedious and repetative. from random import

  1   2   >