Re: I need a lot of help...
Peter Otten wrote: > raulmaqueda6...@gmail.com wrote: > >> I do not know how to do this exercise, does anyone help me? >> >> Define the matrix_range (m) function that returns the range of an array >> calculated by the Gaussian method. >> >> It should work with any number of rows and columns. No punctuation will >> be given to deliveries that do not respect this requirement. >> >> >> Operating example: >> > matrix_range ([[1,0,0], [0,1,0], [0,0,1]]) >> 3 > > If this were not a homework problem you'd use numpy.linalg.matrix_range(). Of course Peter Pearson's hint applies to my answer. The above function doesn't exist, it should be numpy.linalg.matrix_rank() >>> numpy.linalg.matrix_rank([[1,0,0], [0,1,0], [0,0,1]]) 3 which should not be confused with numpy.rank() that just returns the number of dimensions: >>> numpy.rank([[1,0,0], [0,1,0], [0,0,1]]) 2 >>> numpy.rank([[]]) 6 > In your case, however, your teacher wants you to implement the algorithm > yourself. > > Do you know how to calculate the matrix range with pen and paper? > > Write down the steps in plain english and then try to implement them one > after another in Python. Once you have some code and run into a problem > you have something to show us, and we'll happily give you the hints > necessary to fix it. -- https://mail.python.org/mailman/listinfo/python-list
Re: Another security question
On Sat, 24 Dec 2016 06:38 pm, Chris Angelico wrote: > weak passwords are ultimately the user's > responsibility I suppose that's true, in the same way that not getting sewerage into the drinking water supply is also ultimately the user's responsibility. You forget that weak passwords don't just hurt the user who choose the weak passwords. If I break into your system, I get the opportunity to steal your identity, which not only hurts you, but also those I steal from using your identity. I can use your account to send spam, which hurts everyone. I can use you as a springboard to attack others, to launch ransomware attacks or shutdown the electricity grid[1] or DOS people I don't like. Poor security eventually hurts everyone. I think that, eventually, one of two things will happen: - Our entire computing infrastructure (the web, email, the IOTs, banking systems, etc) will collapse under the accumulated weight of zero day attacks, malware, ransomware, cyber warfare and 24/7 surveillance by both the state and corporations. The IOT is an especially bad idea: http://www.geekculture.com/joyoftech/joyarchives/2340.html - Or governments realise that computing security (including privacy) needs to be treated as a public health measure. We're already aware of the virus metaphor when it comes to malicious code. (It's more than just a metaphor -- one can argue, correctly I think, that self-replicating code is the same kind of thing whether it is interpreted by a Word macro, compiled machine code, or DNA.) We also need to think of personal data as toxic pollution: https://www.schneier.com/blog/archives/2016/03/data_is_a_toxic.html https://www.schneier.com/blog/archives/2008/01/data_as_polluti.html We need to be thinking about security vulnerabilities as a health issue. That includes the backdoors more and more governments will want us to install, under the false claim of protecting us from terrorists/ paedophiles/whatever villain is being demonised this year. Exploitable software needs to be treated the same as building a sewer system that empties directly into the city's drinking water supply. It's *everybody's* problem when somebody can hack into your vulnerable system. That's the ultimate externality. But of course, unfortunately, we know what most governments and corporations and even individuals think about pollution and toxic waste. "If it saves me 5 seconds, or earns me $1, I don't care how many billions in damages it does to others." Merry Christmas. "My light switch is currently downloading a software update from the Internet so I can't turn my lights off. What. A. Time. To. Be. Alive." https://twitter.com/TweetsByTSD/status/655297659381661696 [1] If any country is foolish enough to put control of the electricity grid on the Internet. Of course nobody would do that. Right? -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: UTF-8 Encoding Error
Try utf-8-sig El 25 dic. 2016 2:57 AM, "Grady Martin" escribió: > On 2016年12月22日 22時38分, subhabangal...@gmail.com wrote: > >> I am getting the error: >> UnicodeDecodeError: 'utf8' codec can't decode byte 0x96 in position 15: >> invalid start byte >> > > The following is a reflex of mine, whenever I encounter Python 2 Unicode > errors: > > import sys > reload(sys) > sys.setdefaultencoding('utf8') > > A relevant Stack Exchange thread awaits you here: > > http://stackoverflow.com/a/21190382/2230956 > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Python 3.6 Embedded
I'm using the python3.6 DLL to embed Python 3 inside a Windows application. Here is some background into how Python is being used. 1. Firstly the same basic code worked fine with the earlier Python 2.7 version. 2. The code is structured as follows: Windows Executable + | + Scripting DLL + | + Pthyhon 3.6 DLL In other words the executable talks to the Scripting DLL and the scripting DLL then talks to the Python DLL. 3. To run a script the following flow control is used: a. Application loads the Scripting DLL i. The Scripting DLL calls Py_Initialize found in the Python DLL b. Application run the script file using the Scripting DLL i. The Scripting DLL calls PyRun_SimpleFileEx in the Python DLL to run the script c. Unload the scripting DLL i. The Scripting DLL calls Py_FinalizeEx in the Python DLL clean up Symptoms of the Problem --- The problem can be replicated by a script that contains nothing but a single import statement. Using this test script the script can be run and re-run any number of times: import sys Using this test script the script will run the first time but fail every subsequent time: import socket The difference in the two import statements is the former is a built-in module while the later is using a dynamically loaded module. The Cause of the Problem I tracked down the cause of the problem to the fact the python36.dll unloads just fine for the first case but fails to unloaded for the second case. So when the application loads and unloads the Scripting DLL the python36.dll remains loaded. Then when the python36.dll is used the second time it now contains pointers to stale data and crashes on the second run. The Py_FinalizeEx document found here suggests it should stop all interpreters: https://docs.python.org/dev/c-api/init.html Anyone have an idea know what might be going wrong? What code is holding on to the Python DLL? -- https://mail.python.org/mailman/listinfo/python-list