Re: Help with "Guess the number" script

2014-03-01 Thread Larry Hudson
On 03/01/2014 05:11 PM, Scott W Dunning wrote: On Mar 1, 2014, at 11:03 AM, Susan Aldridge 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', upLi

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmrmJjiGMfqui=PpJco7LjtqVpUjj=xnmtybyqemxg3...@mail.gmail.com... > On Sun, Mar 2, 2014 at 4:51 PM, Frank Millman wrote: >> Which version are you talking about? >> >> I have an old, slow box running Windows Server 2003 and python 3.3.2. >> >> I have jus

Re: How to run multiple virtualenv in product server

2014-03-01 Thread Cameron Simpson
On 27Feb2014 07:29, YE SHANG wrote: > I'm starting to learn virtualenv, I wonder how run python project developed > in virtualenv. > > Here is my situation, there is a server we can access with a common user name > and password, there are many py scripts wrote by different people on this > ser

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:51 PM, Frank Millman wrote: > Which version are you talking about? > > I have an old, slow box running Windows Server 2003 and python 3.3.2. > > I have just booted it up now, called up a command prompt, typed 'python' to > start the interpreter, and typed 'import decimal'.

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmrBU9K0aoJyCUmif1FCExtbsuq27pGxiRvyNd=yvn-...@mail.gmail.com... > > The point of this thread isn't really about Windows, so I'll try to > keep it brief, but there are a couple of things I should clarify. The > first one is about the 4+ second import t

Re: posting code snippets

2014-03-01 Thread Gregory Ewing
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 that problem securely to the dissecting board. Long before you actually get to that point, the proble

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

2014-03-01 Thread Chris Angelico
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 implicitly convert the result, and the return val

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

2014-03-01 Thread Dave Angel
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 is it logical, the C standard explicitly req

Re: Boxes of O's

2014-03-01 Thread Dave Angel
genius...@gmail.com Wrote in message: > 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() > Are you permitted to write and call functions? If so,

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 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 randrange >> randrange(1,

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 n

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 shoul

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 trou

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 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 as well. I

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 , Chris Angelico 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 content, but via email instead. Take your pick betw

Re: Help with "Guess the number" script

2014-03-01 Thread Scott W Dunning
On Mar 1, 2014, at 11:03 AM, Susan Aldridge 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, ':') >guess= int(input())

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ned Deily
In article , Chris Angelico 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 content, but via email instead. Take your pick between > that and a newsreader -

Re: Mac vs. Linux for Python Development

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

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 sligh

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 p

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 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

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 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 page

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, 5

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 : > >> 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 >

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" 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. DO NOT use th

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 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, really. > My hat

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

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Grant Edwards writes: > On 2014-02-28, Mark Lawrence 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 of something must have a purpose. That a

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa writes: > Ben Finney : > > > 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 pre

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 writes: > Steven D'Aprano : > > > 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 not needed to get the behaviour you say you n

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 wrote: > In mauro > 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

Re: posting code snippets

2014-03-01 Thread Chris Angelico
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 that problem securely to the > dissecting board. Long before you

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 9:07 AM, Christian Heimes wrote: > On 01.03.2014 21:25, Roy Smith wrote: >> In article , >> Christian Heimes 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 tha

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 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 if elif else ? >

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 adv

Re: Password validation security issue

2014-03-01 Thread Christian Heimes
On 01.03.2014 21:25, Roy Smith wrote: > In article , > Christian Heimes 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? I find 10 * 10^9 easier to

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 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 tou

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 i

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

Re: Password validation security issue

2014-03-01 Thread Roy Smith
In article , Christian Heimes 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? -- https://mail.python.org/mailman/listinfo/python-list

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article <87mwh9969m@elektro.pacujo.net>, 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 > > Mo

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 , Grant Edwards 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 will always mean on

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article , Ben Finney 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 case where the smell is > encountered. More often, it indicates a problem that

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" 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 (n**2 <

Re: Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-28, Mark Lawrence 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 having to

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, Marko Rauhamaa wrote: > Here's a use case for "is" with strings (or ints): > >class Connection: >IDLE = "IDLE" >CONNECTING = "CONNECTING" >CONNECTED = "CONNECTED" >DISCONNECTING = "DISCONNECTING" >DISCONNECTED = "DISCONNECTED" > >

Re: Can global variable be passed into Python function?

2014-03-01 Thread Roy Smith
In article <87d2i7wbxs@elektro.pacujo.net>, Marko Rauhamaa wrote: > Neil Cerutti : > > > 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 already has a switch statemen

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 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 like a classic ca

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 , Unix SA wrote: > Hello Experts, > > I have requirement, like i want to use below command in python script. > > --username --passwordarguments> > > now my requirement is i want to write some class so i can re-use " > --username --password " part via importing as module > or

Re: posting code snippets

2014-03-01 Thread Grant Edwards
On 2014-02-28, Chris Angelico 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 problem itse

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

2014-03-01 Thread John Gordon
In mauro 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 Imagine what it must be like for a r

Re: Coding a simple state machine in python

2014-03-01 Thread Roy Smith
In article <65ac9612-fd48-472a-b077-c802be96e...@googlegroups.com>, Ronaldo 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: > > if state == "ABC"

Re: Can global variable be passed into Python function?

2014-03-01 Thread Grant Edwards
On 2014-02-28, Marko Rauhamaa wrote: > Chris Angelico : > >> 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 >> understands not to rebind

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

2014-03-01 Thread Grant Edwards
On 2014-02-25, mauro 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 why operat

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Grant Edwards
On 2014-02-24, Chris Angelico 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 overlooked. If you'r

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

2014-03-01 Thread Grant Edwards
On 2014-02-24, Michael Torrie 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); >> >> o<0x9fe5008>, o->value<0x9fe5008>

Re: Functions help

2014-03-01 Thread Grant Edwards
On 2014-02-24, Benjamin Kaplan wrote: > On Sun, Feb 23, 2014 at 5:39 PM, alex23 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 >> >> >> Stupid

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

2014-03-01 Thread Roy Smith
In article , Grant Edwards 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 will > always mean one thing (e.g. a person's last name

Re: Functions help

2014-03-01 Thread Roy Smith
In article , Mark Lawrence 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 recalling it over and over. Meaning > >> is there a way I can call a

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

2014-03-01 Thread Grant Edwards
On 2014-02-23, Sam 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 one being mutable a

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 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. Th

Re: Mac vs. Linux for Python Development

2014-03-01 Thread Roy Smith
In article <2465a8c7-ce0e-4606-ad3b-9135c96e3...@googlegroups.com>, twiz 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 recreationally for a

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

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:54 AM, Christian Heimes 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 > it is possible t

How to extract contents of inner text of html tag?

2014-03-01 Thread Golam Md. Shibly
Hi, ###in.txt cp -v --remove-destination /usr/share/zoneinfo/ \ /etc/localtime import sys import unicodedata from bs4 import BeautifulSoup file_name="in.txt" html_doc=open(file_name,'r') soup=BeautifulSoup(html_doc) #print soup.prettify().encode('utf-8') #file_to_write.writ

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 wrote: >> encrypted = hashlib.sha256(login+'NaCl protects your >> passwords'+password).hexdigest() >> encrypted >>> 'b329f2674af4d8d873e264d23713ace4505c211410eb46779c27e02d5a50466c' >> >> Pl

Re: Boxes of O's

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 6:28 AM, 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 woul

Re: Tuples and immutability

2014-03-01 Thread Ian Kelly
On Fri, Feb 28, 2014 at 11:25 PM, 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. > >

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: 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 Chris Angelico
On Sun, Mar 2, 2014 at 6:12 AM, 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 some code and we

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 E.g

Re: Tuples and immutability

2014-03-01 Thread Oscar Benjamin
On 27 February 2014 21:47, Nick Timkovich wrote: > On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico 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__()` called outside of `list += X`? N

Re: Password validation security issue

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

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 5:38 AM, Tim Chase 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-running the program.

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 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 the passwords f

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 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 h

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Steven D'Aprano : > 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 define them as constants but simply

Re: Password validation security issue

2014-03-01 Thread Chris Angelico
On Sun, Mar 2, 2014 at 4:49 AM, Renato 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'} > and I use thi

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 : > >> 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 h

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: print('

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

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' that

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 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 -- http

Re: Can global variable be passed into Python function?

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

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 wrote: > Ben Finney : > >> 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 pas

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 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 assuming > that the caller will only ev

Re: Can global variable be passed into Python function?

2014-03-01 Thread Marko Rauhamaa
Ben Finney : > 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 of any object. Marko -

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

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 > wrote: >> Ben Finney : >> >>> 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'

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 : > >> 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 matter what object

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 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 think I admitted him

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 EVERY

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 n

Re: Can global variable be passed into Python function?

2014-03-01 Thread Ben Finney
Marko Rauhamaa writes: > Ben Finney : > > > 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 ‘is’ is *wrong* for comparing strings

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 (

  1   2   >