Re: Python 3 removes name binding from outer scope
On 07/24/2017 11:47 PM, Rustom Mody wrote: Interesting to see this adjacent to news that non-participation is about to be criminalized double of [snip] Rustom, All, This is a Python mailing list. Please keep the topics marginally on-topic. Thanks. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
Ben Finney schrieb am 25.07.2017 um 08:34: > Ethan Furman writes: > >> Something like: >> >> try: >> >> except ZeroDivisionError as dead_exc: >> exc = dead_exc >> >> >> print(text_template.format(exc=exc) > > That strikes me as busy-work; the name in the ‘except’ clause already > *has* the object, and is a servicable name already. > > Having to make another name for the same object, merely to avoid some > surprising behaviour, is IMO un-Pythonic. It's an extremely rare use case and keeping the exception alive after handling has clear drawbacks in terms of resource usage (exception information, tracebacks, frames, local variables, chained exceptions, ...) This tradeoff was the reason why this was changed in Py3k at the time, together with the introduction of exception chaining (and some other cleanups in that corner). Basically, it's better to save resources by default and let users explicitly keep them alive if they still need them, than to implicitly hold on to them in a deep corner of CPython (sys.exc_info()) and let users figure out how to release them explicitly if they find out that they hurt and then additionally manage to debug where they are stored. Py2.x did the latter, and guess how many users knew about it? Stefan -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
Ben Finney writes: > Having to make another name for the same object, merely to avoid some > surprising behaviour, is IMO un-Pythonic. I suppose my objection is rooted in the fact this behaviour is implicit; my code has not issued a ‘del’ statement, and so I don't expect one; yet it occurs implicitly. This violates the Zen of Python. > PEP 3000 documents the change:: I got the wrong number there; it's PEP 3110. -- \ “Please do not feed the animals. If you have any suitable food, | `\ give it to the guard on duty.” —zoo, Budapest | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Mon, 24 Jul 2017 21:48:56 -0700, Rustom Mody wrote: > On Tuesday, July 25, 2017 at 7:12:44 AM UTC+5:30, Ben Finney quoted > Thomas Jefferson's : > >> The cost of education is trivial compared to the cost of ignorance. > > > An interesting standard of “trivial”… given… You're reading the quote out of context. When Thomas Jefferson wrote what he did, he was comparing the cost to the US government of paying for universal education for a subset of the population (mostly white males under 16, I expect) to the relatively low standards required at the time, versus the societal costs of a broad population of know-nothings. Especially know-nothings who have the vote. Despite the shift to universal education, and the general increase in standards, I believe Jefferson's equation still broadly holds. We probably wouldn't find it cost effective to educate everyone to a Ph.D. standard, but to a secondary school standard is very affordable. Jefferson wasn't comparing the cost of ignorance to *student debt* because such a thing didn't exist in his day. I don't believe that Jefferson imagined that a societal Good like universal education would be treated as not just a *profit centre*, but *weaponized* and deployed against the middle class. In the US and UK, and a lesser extend Australia, we have managed to combine the worst of both worlds: - a system which spends a huge amount of money for degrees which, for the majority of people, will never repay their cost; - that cost is charged to the receiver, ensuring that the majority of them will start their working career in debt, and often that they will never pay of that debt during their working life; - ultimately leading to a transfer of assets from the middle-class to the elites; - while nevertheless keeping the general population remarkably ignorant. Jefferson was, in a sense, naive: while he recognised the rather brutal costs of ignorance, he assumed that well-meaning people of good will would agree that they were costs. Unfortunately ignorance is an exploitable externality and to some people, the ignorance of others is a benefit, not a cost. The people who gain benefit from ignorance are not the ones who pay the costs. Consequently we have sectors of the political elite who gain benefit from the ignorance of others, while the rest of us have to pay the costs: - ignorance encourages people to vote against their own interests; - ignorance can be manipulated by demagogues; - the ignorant and fearful has become a powerful voting block that votes in politicians who do their best to make them more ignorant and more fearful (a vicious circle); - ignorance can be used against subsections of the public by increasing apathy and discouraging them from voting. Likewise there is a vast collection of economic interest groups who thrive on ignorance: - scammers and spammers; - the advertising profession in general; - merchants of woo, such as those who invent dangerous fad diets and the anti-vaxxers; - PR firms that exist to obfuscate the facts ("Doubt is our product", as one such firm said to the tobacco companies); - media that thrives on inventing fake controversy and false equivalency; and so on. -- “You are deluded if you think software engineers who can't write operating systems or applications without security holes, can write virtualization layers without security holes.” —Theo de Raadt -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, Jul 25, 2017 at 4:47 PM, Rustom Mody wrote: > +1 > You can call it bug or bug-promoted-to-feature :D > > I call it surprising because I dont know of any other case in python where > a delete is user-detectable > ie python's delete of objects always works quietly behind the scenes whereas > this adds a leakiness to the memory-management abstraction You're conflating two things. There's nothing here that forces the destruction of an object; the name is simply unbound. You can confirm this from the disassembly in CPython: >>> import dis >>> def f(): ... try: 1/0 ... except Exception as e: pass ... >>> dis.dis(f) 2 0 SETUP_EXCEPT12 (to 14) 2 LOAD_CONST 1 (1) 4 LOAD_CONST 2 (0) 6 BINARY_TRUE_DIVIDE 8 POP_TOP 10 POP_BLOCK 12 JUMP_FORWARD34 (to 48) 3 >> 14 DUP_TOP 16 LOAD_GLOBAL 0 (Exception) 18 COMPARE_OP 10 (exception match) 20 POP_JUMP_IF_FALSE 46 22 POP_TOP 24 STORE_FAST 0 (e) 26 POP_TOP 28 SETUP_FINALLY6 (to 36) 30 POP_BLOCK 32 POP_EXCEPT 34 LOAD_CONST 0 (None) >> 36 LOAD_CONST 0 (None) 38 STORE_FAST 0 (e) 40 DELETE_FAST 0 (e) 42 END_FINALLY 44 JUMP_FORWARD 2 (to 48) >> 46 END_FINALLY >> 48 LOAD_CONST 0 (None) 50 RETURN_VALUE >>> It actually does the equivalent of: finally: e = None del e In the normal case, this will leave the original exception loose and garbage-collectable, but if it's been bound to another name, it won't. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Recent Spam problem
On Tue, Jul 25, 2017 at 4:50 PM, wrote: > I see two solutions: > > 1. We build new architecture or adept current one so it's more like a > blockchain, have to calculate some hash before being able to post and upload > and such. > > or > > 2. We counter-attack by installing a special tool, so we all denial of > service attack the source of the message, I am not sure if the source is > genuine information, what you make of it: > > NNTP-Posting-Host: 39.52.70.224 > > > Now the first solution would require a lot of work. > > The second solution would be easy to do. > > My question to you is: > > What solution do you pick of any ? =D There are bad people in the world. I know! Let's all go and drop nuclear bombs on them. That'll fix the problem! OR... you could try just filtering it all out, and not stooping to their level. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, 25 Jul 2017 00:01:11 -0700, Ethan Furman wrote: > On 07/24/2017 11:47 PM, Rustom Mody wrote: > >> Interesting to see this adjacent to news that non-participation is >> about to be criminalized double of [snip] > > Rustom, All, > > This is a Python mailing list. Please keep the topics marginally > on-topic. Thanks. Is this a new rule? :-P This list has always (well, at least for a decade or more) been relatively forgiving of off-topic posts. But we should at least label the subject lines as off-topic, which I admit I forgot to do on my previous post. Sorry. -- “You are deluded if you think software engineers who can't write operating systems or applications without security holes, can write virtualization layers without security holes.” —Theo de Raadt -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, 25 Jul 2017 17:02:48 +1000, Ben Finney wrote: > Ben Finney writes: > >> Having to make another name for the same object, merely to avoid some >> surprising behaviour, is IMO un-Pythonic. > > I suppose my objection is rooted in the fact this behaviour is implicit; > my code has not issued a ‘del’ statement, and so I don't expect one; yet > it occurs implicitly. This violates the Zen of Python. Technically, *all* garbage collection is implicit. You don't have to explicitly delete your local variables when you return from a function, they are implicitly deleted when they go out of scope. So consider this as a de-facto "the except clause "as name" variable is treated *as if* it exists in its own scope. I agree that the behaviour of except is a little surprising, but that's (according to the core devs) the lesser of two evils. The alternative is a memory leak when the traceback keeps data alive that you didn't expect. -- “You are deluded if you think software engineers who can't write operating systems or applications without security holes, can write virtualization layers without security holes.” —Theo de Raadt -- https://mail.python.org/mailman/listinfo/python-list
I am new here and i need your help please
I have never execute any program before using python and a task was given to me by my teacher ~ to write a python program to print my details and store in a third party variables. ~ the details include name, age, height, status. so please your help is highly needed, thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
Steven D'Aprano writes: > On Tue, 25 Jul 2017 17:02:48 +1000, Ben Finney wrote: > > > I suppose my objection is rooted in the fact this behaviour is > > implicit; my code has not issued a ‘del’ statement, and so I don't > > expect one; yet it occurs implicitly. This violates the Zen of > > Python. > > Technically, *all* garbage collection is implicit. The surprising behaviour is not garbage collection; I hadn't noticed anything different with garbage collection. The surprising behaviour is the unasked-for removal of a name binding from the context, that was bound earlier in the same context. > So consider this as a de-facto "the except clause "as name" variable > is treated *as if* it exists in its own scope. It is not, though. “as if it exists in its own scope” would mean that it should not affect the earlier binding in a different scope. That's not what happens; an earlier binding is re-bound (explicitly, by ‘as target’) and then *implicitly* removed so the name is unbound. > I agree that the behaviour of except is a little surprising, but > that's (according to the core devs) the lesser of two evils. The > alternative is a memory leak when the traceback keeps data alive that > you didn't expect. I think those are not the only two options (the “except clause has its own scope” behaviour is an option that could have been chosen, for example). At this point the behaviour and motivation are clear, having been revealed; I disagree with the behaviour, and think the motivation could have been met better. -- \ “If you always want the latest and greatest, then you have to | `\ buy a new iPod at least once a year.” —Steve Jobs, MSNBC | _o__) interview 2006-05-25 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: I am new here and i need your help please
On Tue, 25 Jul 2017 00:48:25 -0700, yasirrbadamasi wrote: > I have never execute any program before using python and a task was > given to me by my teacher ~ to write a python program to print my > details and store in a third party variables. > ~ the details include name, age, height, status. so please your help is > highly needed, thanks What part of the assignment don't you understand? -- “You are deluded if you think software engineers who can't write operating systems or applications without security holes, can write virtualization layers without security holes.” —Theo de Raadt -- https://mail.python.org/mailman/listinfo/python-list
OT was Re: Python 3 removes name binding from outer scope
On Mon, 24 Jul 2017 23:47:17 -0700, Rustom Mody wrote: [...] > Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html Heh, at first I read that as a bill to criminalise BSD support :-) -- “You are deluded if you think software engineers who can't write operating systems or applications without security holes, can write virtualization layers without security holes.” —Theo de Raadt -- https://mail.python.org/mailman/listinfo/python-list
RELEASED] Python 3.4.7rc1 and Python 3.5.4rc1 are now available
On behalf of the Python development community and the Python 3.4 and Python 3.5 release teams, I'm relieved to announce the availability of Python 3.4.7rc1 and Python 3.5.4rc1. Python 3.4 is now in "security fixes only" mode. This is the final stage of support for Python 3.4. Python 3.4 now only receives security fixes, not bug fixes, and Python 3.4 releases are source code only--no more official binary installers will be produced. Python 3.5.4 will be the final 3.5 release in "bug fix" mode. After 3.5.4 is released, Python 3.5 will also move into "security fixes mode". Both these releases are "release candidates". They should not be considered the final releases, although the final releases should contain only minor differences. Python users are encouraged to test with these releases and report any problems they encounter. You can find Python 3.4.7rc1 here: https://www.python.org/downloads/release/python-347rc1/ And you can find Python 3.5.4rc1 here: https://www.python.org/downloads/release/python-354rc1/ Python 3.4.7 final and Python 3.5.4 final are both scheduled for release on August 6th, 2017. Happy Pythoning, //arry/ -- https://mail.python.org/mailman/listinfo/python-list
Re: OT was Re: Python 3 removes name binding from outer scope
On Tue, Jul 25, 2017 at 6:33 PM, Steven D'Aprano wrote: > On Mon, 24 Jul 2017 23:47:17 -0700, Rustom Mody wrote: > > > [...] >> Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html > > > Heh, at first I read that as a bill to criminalise BSD support :-) > I spluttered my drink on reading that. Good job Steven! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, Jul 25, 2017 at 6:10 PM, Ben Finney wrote: > I think those are not the only two options (the “except clause has its > own scope” behaviour is an option that could have been chosen, for > example). > > At this point the behaviour and motivation are clear, having been > revealed; I disagree with the behaviour, and think the motivation could > have been met better. Having a new scope introduced by a non-function would also be surprising. List comprehensions (as of Py3) introduce a new scope, but they do so by being wrapped in a function. Would you expect that an except block is wrapped in a function too? And whether or not it's a function, the fact would remain that except blocks would differ from other name-binding blocks (with/as and for). There's a reasonable argument for with/as to introduce a new scope, but a for loop definitely shouldn't, so there's going to be a difference there. And if it's its own function, you'd need to use nonlocal/global inside it to make any other changes. That would be a royal pain. Consider: try: raw_input except NameError: global raw_input # blech raw_input = input I'm not actually sure what happens if you use a global declaration at top level. Is it ignored? Is it an error? One potential solution would be to have *just the exception name* in a sort of magic scope. But I'm not sure how that would go. TBH, I rather suspect that the exact semantics here aren't too critical. If there's a solid argument for some variation on the current system, one that still prevents the refloop between the exception and a function's variables, it'd be worth discussing as a proposal. At very least, it's worth raising it on -ideas... worst case, it gets shut down quickly. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: how to group by function if one of the group has relationship with another one in the group?
Ho Yeung Lee wrote: > from itertools import groupby > > testing1 = [(1,1),(2,3),(2,4),(3,5),(3,6),(4,6)] > def isneighborlocation(lo1, lo2): > if abs(lo1[0] - lo2[0]) == 1 or lo1[1] == lo2[1]: > return 1 > elif abs(lo1[1] - lo2[1]) == 1 or lo1[0] == lo2[0]: > return 1 > else: > return 0 > > groupda = groupby(testing1, isneighborlocation) > for key, group1 in groupda: > print key > for thing in group1: > print thing > > expect output 3 group > group1 [(1,1)] > group2 [(2,3),(2,4] > group3 [(3,5),(3,6),(4,6)] groupby() calculates the key value from the current item only, so there's no "natural" way to apply it to your problem. Possible workarounds are to feed it pairs of neighbouring items (think zip()) or a stateful key function. Below is an example of the latter: $ cat sequential_group_class.py from itertools import groupby missing = object() class PairKey: def __init__(self, continued): self.prev = missing self.continued = continued self.key = False def __call__(self, item): if self.prev is not missing and not self.continued(self.prev, item): self.key = not self.key self.prev = item return self.key def isneighborlocation(lo1, lo2): x1, y1 = lo1 x2, y2 = lo2 dx = x1 - x2 dy = y1 - y2 return dx*dx + dy*dy <= 1 items = [(1,1),(2,3),(2,4),(3,5),(3,6),(4,6)] for key, group in groupby(items, key=PairKey(isneighborlocation)): print key, list(group) $ python sequential_group_class.py False [(1, 1)] True [(2, 3), (2, 4)] False [(3, 5), (3, 6), (4, 6)] -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On 2017-07-25 09:28, Chris Angelico wrote: > On Tue, Jul 25, 2017 at 4:47 PM, Rustom Mody wrote: >> +1 >> You can call it bug or bug-promoted-to-feature :D >> >> I call it surprising because I dont know of any other case in python where >> a delete is user-detectable >> ie python's delete of objects always works quietly behind the scenes whereas >> this adds a leakiness to the memory-management abstraction > > You're conflating two things. There's nothing here that forces the > destruction of an object; the name is simply unbound. You can confirm > this from the disassembly in CPython: > import dis def f(): > ... try: 1/0 > ... except Exception as e: pass > ... dis.dis(f) > 2 0 SETUP_EXCEPT12 (to 14) > 2 LOAD_CONST 1 (1) > 4 LOAD_CONST 2 (0) > 6 BINARY_TRUE_DIVIDE > 8 POP_TOP > 10 POP_BLOCK > 12 JUMP_FORWARD34 (to 48) > > 3 >> 14 DUP_TOP > 16 LOAD_GLOBAL 0 (Exception) > 18 COMPARE_OP 10 (exception match) > 20 POP_JUMP_IF_FALSE 46 > 22 POP_TOP > 24 STORE_FAST 0 (e) > 26 POP_TOP > 28 SETUP_FINALLY6 (to 36) > 30 POP_BLOCK > 32 POP_EXCEPT > 34 LOAD_CONST 0 (None) > >> 36 LOAD_CONST 0 (None) > 38 STORE_FAST 0 (e) > 40 DELETE_FAST 0 (e) > 42 END_FINALLY > 44 JUMP_FORWARD 2 (to 48) > >> 46 END_FINALLY > >> 48 LOAD_CONST 0 (None) > 50 RETURN_VALUE > > It actually does the equivalent of: > > finally: > e = None I wonder why it would bother to load None... (as someone not very familiar with Python at the bytecode level) -- Thomas > del e > > In the normal case, this will leave the original exception loose and > garbage-collectable, but if it's been bound to another name, it won't. > > ChrisA > -- https://mail.python.org/mailman/listinfo/python-list
Re: Recent Spam problem
On Tue, 25 Jul 2017 17:29:56 +1000, Chris Angelico wrote: > On Tue, Jul 25, 2017 at 4:50 PM, wrote: >> I see two solutions: >> >> 1. We build new architecture or adept current one so it's more like a >> blockchain, have to calculate some hash before being able to post and >> upload and such. >> >> or >> >> 2. We counter-attack by installing a special tool, so we all denial of >> service attack the source of the message, I am not sure if the source >> is genuine information, what you make of it: >> >> NNTP-Posting-Host: 39.52.70.224 >> >> >> Now the first solution would require a lot of work. >> >> The second solution would be easy to do. >> >> My question to you is: >> >> What solution do you pick of any ? =D > > There are bad people in the world. I know! Let's all go and drop nuclear > bombs on them. That'll fix the problem! > > OR... you could try just filtering it all out, and not stooping to their > level. > > ChrisA i say nuke em/ otherwise my /dev/null is going to need expanding ;-) -- "To YOU I'm an atheist; to God, I'm the Loyal Opposition." -- Woody Allen -- https://mail.python.org/mailman/listinfo/python-list
python file downloader not working
So I recently tried to write a script using urllib2 module. Here is the code below: import urllib2 file = 'metasploitable-linux-2.0.0.zip' url='https://downloads.sourceforge.net/project/metasploitable/Metasploitable2/metasploitable-linux-2.0.0.zip' response = urllib2.urlopen(url) fh=open(file,'w') fh.write(response.read()) fh.close() I am getting this error in the output. Traceback (most recent call last): File "urllib_read.py", line 6, in fh.write(response.read()) File "E:\Python27\lib\socket.py", line 355, in read data = self._sock.recv(rbufsize) File "E:\Python27\lib\httplib.py", line 597, in read s = self.fp.read(amt) File "E:\Python27\lib\socket.py", line 384, in read data = self._sock.recv(left) File "E:\Python27\lib\ssl.py", line 766, in recv return self.read(buflen) File "E:\Python27\lib\ssl.py", line 653, in read v = self._sslobj.read(len) socket.error: [Errno 10053] An established connection was aborted by the software in your host machine. Please someone help me out. -- https://mail.python.org/mailman/listinfo/python-list
Python BeautifulSoup extract html table cells that contains images and text
Hi all, I need help extracting the table from this url...? from bs4 import BeautifulSoup url = "https://www.marinetraffic.com/en/ais/index/ports/all/per_page:50"; headers = {'User-agent': 'Mozilla/5.0'} raw_html = requests.get(url, headers=headers) raw_data = raw_html.text soup_data = BeautifulSoup(raw_data, "lxml") td = soup_data.findAll('tr')[1:] country = [] for data in td: col = data.find_all('td') country.append(col) -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, Jul 25, 2017 at 8:43 AM, Chris Angelico wrote: > > I'm not actually sure what happens if you use a global declaration at > top level. Is it ignored? Is it an error? It isn't ignored, but it shouldn't make a difference since normally at module level locals and globals are the same. It makes a difference in an exec() that uses separate locals and globals dicts. For example: >>> exec('print(x)', {'x':'G'}, {'x':'L'}) L >>> exec('global x; print(x)', {'x':'G'}, {'x':'L'}) G -- https://mail.python.org/mailman/listinfo/python-list
Re: Recent Spam problem
On Mon, 24 Jul 2017 23:01:43 -0700, Paul Rubin wrote: > Rustom Mody writes: >> Since spammers are unlikely to be choosy about whom they spam: >> Tentative conclusion: Something about the USENET-ML gateway is more leaky >> out here than elsewhere > > It could be a sort-of DOS attack by some disgruntled idiot. I wonder if > the email address in those spam posts actually works. Then there's the > weird Italian rants. No idea about those. The posts are being made through Google Groups. Forwarding the posts with headers to groups-ab...@google.com might help. I have sent a couple but if everyone here did it maybe Google will pay attention and do something. The same goes for our Italian "friend". -- GNU/Linux user #557453 The cow died so I don't need your bull! -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Tue, Jul 25, 2017 at 5:38 AM, Thomas Jollans wrote: > On 2017-07-25 09:28, Chris Angelico wrote: >> It actually does the equivalent of: >> >> finally: >> e = None > > I wonder why it would bother to load None... (as someone not very > familiar with Python at the bytecode level) If I may hazard a guess, it's because simply deleting the variable will raise a NameError if the variable is not already bound, e.g. if there was no exception and only the finally block is being executed, or if the programmer already deleted it. Assigning None to ensure the variable is bound is likely faster than testing it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Wed, Jul 26, 2017 at 4:36 AM, eryk sun wrote: > On Tue, Jul 25, 2017 at 8:43 AM, Chris Angelico wrote: >> >> I'm not actually sure what happens if you use a global declaration at >> top level. Is it ignored? Is it an error? > > It isn't ignored, but it shouldn't make a difference since normally at > module level locals and globals are the same. It makes a difference in > an exec() that uses separate locals and globals dicts. For example: > > >>> exec('print(x)', {'x':'G'}, {'x':'L'}) > L > >>> exec('global x; print(x)', {'x':'G'}, {'x':'L'}) > G Thanks. Of course, that doesn't change the fact that it'll look very odd - but at least it won't cause a problem. Now, if you wanted to write Py2/Py3 compatibility code inside a function, you'd have issues, because you can't use nonlocal in Py2... but that's a separate issue. Hmm. Aside from messing around with exec, is there any way to have a local and a global with the same name, and use the global? You could do it with a nonlocal: x = "G" def f(): x = "L" def g(): global x print(x) g() but is there any way to engineer this actual situation without exec? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: I am new here and i need your help please
On Tue, 25 Jul 2017 00:48:25 -0700, yasirrbadamasi wrote: > I have never execute any program before using python and a task was given to > me by my teacher > ~ to write a python program to print my details and store in a third party > variables. > ~ the details include name, age, height, status. so please your help is > highly needed, thanks Read the material and write some code the best you can and post it here. Someone will try to help you. No one here is going to do your homework for you. -- GNU/Linux user #557453 May the Source be with you. -- https://mail.python.org/mailman/listinfo/python-list
Re: Recent Spam problem
On 2017-07-25, Wildman via Python-list wrote: > The posts are being made through Google Groups. Forwarding > the posts with headers to groups-ab...@google.com might help. I never has in the past. I (and many others) have for years and years been plonking all posts made through Google Groups. Trust me, you'll not miss out on anything worthwile. :) > I have sent a couple but if everyone here did it maybe Google will > pay attention and do something. They won't. Just configure your .score file (or bogofilter or spamassassin or whatever) to throw out all posts that have a Message-ID: header field that ends in 'googlegroups.com'. That, grashopper, is the path to serenity. -- Grant Edwards grant.b.edwardsYow! I like your SNOOPY at POSTER!! gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Recent Spam problem
On 2017-07-25 10:03, alister wrote: On Tue, 25 Jul 2017 17:29:56 +1000, Chris Angelico wrote: On Tue, Jul 25, 2017 at 4:50 PM, wrote: I see two solutions: 1. We build new architecture or adept current one so it's more like a blockchain, have to calculate some hash before being able to post and upload and such. 2. We counter-attack by installing a special tool, so we all denial of service attack the source of the message, I am not sure if the source is genuine information, what you make of it: There are bad people in the world. I know! Let's all go and drop nuclear bombs on them. That'll fix the problem! OR... you could try just filtering it all out, and not stooping to their level. i say nuke em/ otherwise my /dev/null is going to need expanding ;-) I just got a new nulldev from Data General about a week back: username@hostname$ ll /dev/null crw-rw-rw- 1 root root 1, 3 Jul 16 15:22 /dev/null username@hostname$ Its performance is awesome, and it comes with a powerful GUI for configuring and customizing. -- Michael F. Stemper Indians scattered on dawn's highway bleeding; Ghosts crowd the young child's fragile eggshell mind. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python 3 removes name binding from outer scope
On Wed, 26 Jul 2017 06:06 am, Chris Angelico wrote: > Hmm. Aside from messing around with exec, is there any way to have a > local and a global with the same name, and use the global? Use globals['name']. There's no way to do it with regular name look ups. This doesn't work: spam = 'outside' def func(): spam = 'inside' assert spam == 'inside' global spam assert spam == 'outside' The problem is that global is a declaration, not an executable statement, and if it is *anywhere* inside function, it is deemed to apply to the entire function. Apart from that, you could try hacking the byte-code. It should be a matter of just replacing LOAD_FAST with LOAD_GLOBAL, I think. -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to group by function if one of the group has relationship with another one in the group?
"Ho Yeung Lee" a écrit dans le message de news:ef0bd11a-bf55-42a2-b016-d93f3b831...@googlegroups.com... from itertools import groupby testing1 = [(1,1),(2,3),(2,4),(3,5),(3,6),(4,6)] def isneighborlocation(lo1, lo2): if abs(lo1[0] - lo2[0]) == 1 or lo1[1] == lo2[1]: return 1 elif abs(lo1[1] - lo2[1]) == 1 or lo1[0] == lo2[0]: return 1 else: return 0 groupda = groupby(testing1, isneighborlocation) for key, group1 in groupda: print key for thing in group1: print thing expect output 3 group group1 [(1,1)] group2 [(2,3),(2,4] group3 [(3,5),(3,6),(4,6)] Its not clear to me how you build the groups Why (1,1) is not in group2 since (1,1) is a neighbor to both (2,3) and (2,4) ? -- https://mail.python.org/mailman/listinfo/python-list
Re: I am new here and i need your help please
yasirrbadam...@gmail.com writes: > I have never execute any program before using python and a task was given to > me by my teacher I suggest to start by reading the Python tutorial: "https://docs.python.org/3/tutorial/index.html";. -- https://mail.python.org/mailman/listinfo/python-list
Re: python file downloader not working
Rahul Sircar writes: > So I recently tried to write a script using urllib2 module. > Here is the code below: > import urllib2 > file = 'metasploitable-linux-2.0.0.zip' > url='https://downloads.sourceforge.net/project/metasploitable/Metasploitable2/metasploitable-linux-2.0.0.zip' > response = urllib2.urlopen(url) > fh=open(file,'w') > fh.write(response.read()) > fh.close() > > I am getting this error in the output. > Traceback (most recent call last): > ... > v = self._sslobj.read(len) > socket.error: [Errno 10053] An established connection was aborted by the > software in your host machine. This error tells you that the server (i.e. "downloads.sourcefourge.net") has closed the connection. This can happen occationally. Should the error persist, something may be wrong/special with your network/firewall. You may try an alternative way to download the file. On my "*nix" platform, I would use the command "wget" for a download trial. You could also try a browser. -- https://mail.python.org/mailman/listinfo/python-list
Re: I am new here and i need your help please
On Wednesday, July 26, 2017 at 12:11:27 PM UTC+5:30, dieter wrote: > yasirrbadamasi: > > > I have never execute any program before using python and a task was given > > to me by my teacher > > I suggest to start by reading the Python tutorial: > "https://docs.python.org/3/tutorial/index.html";. I was about to say that… Some additions: You will also need to have python installed on your computer. Have you done that? Do you need help with that? Start here and if any issue report with details including your OS (windows/linux/Mac): https://www.python.org/downloads/ After that, for a beginner below list may be more helpful than this one [recommended]: https://mail.python.org/mailman/listinfo/tutor -- https://mail.python.org/mailman/listinfo/python-list