Re: looping versus comprehension
In article <5109fe6b$0$11104$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > On Thu, 31 Jan 2013 02:49:31 +1100, Chris Angelico wrote: > > > it's worth > > noting that list appending is not going to be O(N*N), because it's going > > to allow room for expansion. > > This is true for list.append, which is amortized constant time. But it is > not true for list addition, alist + blist, which is O(N**2) and hence > gets really, really slow: > > steve@runes:~$ python -m timeit "L = []" "for i in xrange(1000): L = L + [1]" > 100 loops, best of 3: 3.08 msec per loop > steve@runes:~$ python -m timeit "L = []" "for i in xrange(5000): L = L + [1]" > 10 loops, best of 3: 71 msec per loop > steve@runes:~$ python -m timeit "L = []" "for i in xrange(25000): L = L + [1]" > 10 loops, best of 3: 2.06 sec per loop > > > Notice that as the number of list additions goes up by a factor of 5, > the time taken goes up by a factor of 25. It's not the addition, per-se, that's the problem. It's the creation of a new list each time. If you use +=, it's back to O(n): ~$ python -m timeit "L = []" "for i in xrange(1000): L += [1]" 1000 loops, best of 3: 275 usec per loop ~$ python -m timeit "L = []" "for i in xrange(5000): L += [1]" 1000 loops, best of 3: 1.34 msec per loop ~$ python -m timeit "L = []" "for i in xrange(25000): L += [1]" 100 loops, best of 3: 6.91 msec per loop -- http://mail.python.org/mailman/listinfo/python-list
Python launcher (PEP 397) and emacs python-mode.el
Has someone managed to patch python-mode.el to use the PEP 397 python launcher when you hit C-c C-c? It seems that emacs should parse the shebang line in the edited python script and pass the corresponding arguments to py.exe. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: [Distutils] A new script which creates Python 3.3 venvs with Distribute and pip installed in them
On Wed, Jan 30, 2013 at 9:09 PM, Vinay Sajip wrote: > Python 3.3 includes a script, pyvenv, which is used to create virtual > environments. > However, Distribute and pip are not installed in such environments - because, > though they are popular, they are third-party packages - not part of Python. > The Python 3.3 venv machinery allows customisation of virtual environments > fairly readily. To demonstrate how to do this, and to provide at the same time > a script which might be useful to people, I've created a script, pyvenvex.py, > at > https://gist.github.com/4673395 > which extends the pyvenv script to not only create virtual environments, but > to also install Distribute and pip into them. Excellent and one step closer to sane package management I wonder if you could not source instead the code that is directly in the virtualenv.py scripts? it also includes the packed distribute and pip Meaning that would allow the installation entirely offline (with the --never-download venv flag) And btw, why pip is not part of the standard Python? This is nowadays officially recommended on Pypi as the tool to use to install package Per http://pypi.python.org/pypi "Get Packages: To use a package from this index either "pip install package" (get pip) or download, unpack and "python setup.py install" it." This does not make sense to me: I know about some of the controversies but this is rather inconsistent to recommend using a tool and not supporting it directly. -- Philippe Ombredanne +1 650 799 0949 | pombreda...@nexb.com DejaCode Enterprise at http://www.dejacode.com nexB Inc. at http://www.nexb.com -- http://mail.python.org/mailman/listinfo/python-list
Arpex Capital seleciona:Programador Python Jr.
Arpex Capital seleciona para uma de suas startups: Programador Python Jr. Requisitos: - Python/Lua/Lisp/Go/Erlang, etc qualquer linguagem exótica vale, mesmo não sendo python; - Interesse por Software Livre; - Inglês fluente. Local de Trabalho: Centro/RJ. Formação: Gradução completa e/ou cursando Ciência da Computação e/ou afins. Aceitamos CVs de estudantes do primeiro período. Os interessados deverão enviar CV com pretensão salarial para kgar...@arpexcapital.com.br, mencionando no assunto Programador Python Jr. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python launcher (PEP 397) and emacs python-mode.el
Am 31.01.2013 10:03, schrieb Thomas Heller: Has someone managed to patch python-mode.el to use the PEP 397 python launcher when you hit C-c C-c? It seems that emacs should parse the shebang line in the edited python script and pass the corresponding arguments to py.exe. Yes, that's the way python-mode.el acts by default. AFAIU that launcher is implemented in Python3.3 and should not need any patch at all. Should it not work, please file a bug-report at https://bugs.launchpad.net/python-mode Andreas Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote: > > > Hello, > > > > I was having some trouble understanding decorators and inheritance and > > all that. This is what I was trying to do: > > > > # untested > > class A(object): > >def _protector_decorator(fcn): > > def newfcn(self, *args, **kwargs): > > return fcn(self, *args, **kwargs) > > return newfcn > > Well, that surely isn't going to work, because it always decorates the > same function, the global "fcn". > I don't think this is right. fcn is a passed function (at least if it acts as a decorator) that is declared locally in the _protector_decorator scope. Since newfcn is bound in the same scope and fcn is not defined inside newfcn, I'm pretty sure that newfcn will just grab the fcn passed into the decorator. The following code illustrates what I'm trying to say (I think): test.py: #!/usr/bin/env python a = 3 print 'Global namespace:', a def myfunc(a): def nested_func(): print 'nested_func a is:', a, 'id(a) =', id(a) print 'passed a is:', a, 'id(a) = ', id(a) nested_func() myfunc(10) $ python test.py Global namespace: 3 passed a is: 10 id(a) = 6416096 nested_func a is: 10 id(a) = 6416096 Likewise, newfcn will use the function bound to the passed argument to the decorator. This syntax appears to work in my 'real' program. > You probably want to add an extra parameter to the newfcn definition: > > def newfcn(self, fcn, *args, **kwargs): > I don't think I want to do that, since fcn will simply become the first argument that I pass to the decorated myfunc(), and if it's not callable I'll get a traceback. Also, I trust you realise that this is a pointless decorator that doesn't > do anything useful? It just adds an extra layer of indirection, without > adding any functionality. > Naturally. I tried to contrive the simplest example to demonstrate what I wanted. In retrospect I should've picked something functional instead. > Am I correct here? My workaround was to simply copy the method from > > class A to class B, after which B._protector_decorator decorated the > > methods in B. > > That's not a work-around, that's an anti-pattern. > > Why is B inheriting from A if you don't want it to be able to use A's > methods? That's completely crazy, if you don't mind me saying so. If you > don't want B to access A's methods, simply don't inherit from A. > > I really don't understand what you are trying to accomplish here. > Again, my example code is over-simplified. A brief description of my class is a list of 'patch' (diff) files with various attributes. If I want information from any of those files, I instantiate a Patch instance (and cache it for later use if desired) and return any of the information I want from that patch (like when it was created, who created it, what files will be altered in the patch, etc.). But a lot of these patches are stored online, so I wanted a new class (a RemotePatchList) to handle lists of patches in an online repository. I can do many of the things with an online patch that I can with one stored locally, but not everything, hence my desire to squash the methods I don't want to support. I'd imagine a much more sensible approach is to generate a base class that implements all methods common to both and simply raises an exception in those methods that aren't. I agree it doesn't make much sense to inherit from an object that has MORE functionality than you want. However, my desire to use decorators was not to disable methods in one class vs. another. The _protector_decorator (a name borrowed from my actual code), is designed to wrap a function call inside a try/except, to account for specific exceptions I might raise inside. One of my classes deals with local file objects, and the other deals with remote file objects via urllib. Naturally, the latter has other exceptions that can be raised, like HTTPError and the like. So my desire was to override the decorator to handle more types of exceptions, but leave the underlying methods intact without duplicating them. I can do this without decorators easily enough, but I thought the decorator syntax was a bit more elegant and I saw an opportunity to learn more about them. Possibly Java. > I took a Java class in high school once ~10 years ago... haven't used it since. :) Truth be told, outside of Python, the languages I can work in are Fortran (and to a much lesser extent), C and C++. import functools > I need to support Python 2.4, and the docs suggest this is 2.5+. Too bad, too, since functools appears pretty useful. Thanks for the help! Jason -- http://mail.python.org/mailman/listinfo/python-list
advice, python for binary to xml
I'm looking for knowlegde about how best to go about converting a binary file (from a GPS unit) to GPX/XML. I am completely clueless on this, so any start-from-the-beginning info would be greatly appreciated! I'm guessing the level of effort will be huge? Python 2.7, Windows 7 -- http://mail.python.org/mailman/listinfo/python-list
Re: The best, friendly and easy use Python Editor.
On Thu, 24 Jan 2013, Tim Chase wrote: On 01/24/13 13:34, Leonard, Arah wrote: All true (especially the holy wars bit!). OP didn't (as far as I can see) even say which OS he is using. Anyway, my suggestion is generally that people use the editor with which they are already comfortable. Sound advice. [snip] Whatever works is what works. It's just a text file after all. So even "ed" or "edlin" or even "cat" would do ;-) ? -tkc ? wq ed *is* the standard editor. Also, I see what you did there ;) -w . wq -- http://mail.python.org/mailman/listinfo/python-list
Re: advice, python for binary to xml
On Thursday, January 31, 2013 2:33:48 PM UTC+1, noydb wrote: > I'm looking for knowlegde about how best to go about converting a binary file > (from a GPS unit) to GPX/XML. I am completely clueless on this, so any > start-from-the-beginning info would be greatly appreciated! I'm guessing the > level of effort will be huge? I assume that you've looked into GPSBabel? http://www.gpsbabel.org/ Maarten -- http://mail.python.org/mailman/listinfo/python-list
PyGresql 4.1.1 for python2.7
Hello, I'm trying to upgrade to python2.7. Installed PyGresql 4.1.1 for python 2.7. When running "import pg" command I get the following error: from _pg import * ImportError: DLL load failed: The operating system cannot run %1. I'm using Windows XP SP3, and have PostgreSQL 8.4 installed. The command runs fine in python 2.6. Is this due to having multiple versions of python installed? Or some kind of dll incompatibility with 2.7 (maybe libpq.dll)? Thanks for the help -- http://mail.python.org/mailman/listinfo/python-list
Re: security quirk
RichD contributed wisdom to news:badd4188-196b- 45e3-ba8a-511d47128...@nh8g2000pbc.googlegroups.com: > On Jan 30, Gandalf Parker > wrote: >> > Web gurus, what's going on? >> >> That is the fault of the site itself. >> If they are going to block access to users then they should also block >> access to the automated spiders that hit the site to collect data. > > well yeah, but what's going on, under the hood? > How does it get confused? How could this > happen? I'm looking for some insight, regarding a > hypothetical programmimg glitch - (from alt.hacker) You dont understand. It is not in the code. It is in the site. It is as if someone comes and picks fruit off of your tree, and you are questioning the tree for how it bears fruit. The site creates web pages. Google collects web pages. The site needs to set things like robot.txt to tell Google to NOT collect the pages in the archives. Which is not an absolute protection but at least its an effort that works for most sites. -- http://mail.python.org/mailman/listinfo/python-list
"Writing Idiomatic Python" book now available
Just wanted to let everyone know I've just released a book: Writing Idiomatic Python (http://www.jeffknupp.com/writing-idiomatic-python-ebook/). It's presented as a series of examples of Pythonic code broken down by topic (e.g. lists, strings, classes, arranging your code, etc.). There are separate versions for Python 2.7.3 and Python 3.3. It's also available on Google Play Books and Amazon. Hopefully, some people in this group will find it useful. -- http://mail.python.org/mailman/listinfo/python-list
Re: advice, python for binary to xml
On Thursday, January 31, 2013 8:41:34 AM UTC-5, Maarten wrote: > On Thursday, January 31, 2013 2:33:48 PM UTC+1, noydb wrote: > > > I'm looking for knowlegde about how best to go about converting a binary > > file (from a GPS unit) to GPX/XML. I am completely clueless on this, so > > any start-from-the-beginning info would be greatly appreciated! I'm > > guessing the level of effort will be huge? > > > > I assume that you've looked into GPSBabel? http://www.gpsbabel.org/ > > > > Maarten Yes, I have. Was hoping to use it, but client is very resistent to adding such things to their system - python is desireable. So what GPSbabel does is what I need, just one translation, from Garmin's gdb file (binary) to gpx. -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
On Fri, Feb 1, 2013 at 12:25 AM, Jason Swails wrote: > On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano > wrote: >> >> On Wed, 30 Jan 2013 19:34:03 -0500, Jason Swails wrote: >> >> > Hello, >> > >> > I was having some trouble understanding decorators and inheritance and >> > all that. This is what I was trying to do: >> > >> > # untested >> > class A(object): >> >def _protector_decorator(fcn): >> > def newfcn(self, *args, **kwargs): >> > return fcn(self, *args, **kwargs) >> > return newfcn >> >> Well, that surely isn't going to work, because it always decorates the >> same function, the global "fcn". > > > I don't think this is right. fcn is a passed function (at least if it acts > as a decorator) that is declared locally in the _protector_decorator scope. > Since newfcn is bound in the same scope and fcn is not defined inside > newfcn, I'm pretty sure that newfcn will just grab the fcn passed into the > decorator. Yet it adds a level of indirection that achieves nothing. Why not simply: def _protector_decorator(fcn): return fcn ? I'm not understanding the purpose here. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico wrote: > > >> Well, that surely isn't going to work, because it always decorates the > >> same function, the global "fcn". > > > > > > I don't think this is right. fcn is a passed function (at least if it > acts > > as a decorator) that is declared locally in the _protector_decorator > scope. > > Since newfcn is bound in the same scope and fcn is not defined inside > > newfcn, I'm pretty sure that newfcn will just grab the fcn passed into > the > > decorator. > > Yet it adds a level of indirection that achieves nothing. Why not simply: > def _protector_decorator(fcn): > return fcn > > ? I'm not understanding the purpose here. > Bad example. A better (longer) one that is closer to my true use-case: from somewhere.exceptions import MyTypeError from somewhere.different import AuthorClass, RemoteAuthorClass from urllib2 import HTTPError class A(object): authorclass = AuthorClass def __init__(self, obj_list): """ Instantiate a list of obj_list objects that may have an "author" attribute """ self.things = [] for o in obj_list: if not isinstance(o, self.authorclass): raise MyTypeError('Bad type given to constructor') self.things.append(o) def _protector(fcn): def newfcn(self, *args, **kwargs): try: return fcn(self, *args, **kwargs) # returns a string except AttributeError: return 'Attribute not available.' except IndexError: return 'Not that many AuthorClasses loaded' return newfcn @_protector def author(self, idx): return self.things[idx].author @_protector def description(self, idx): return self.things[idx].description @_protector def hobbies(self, idx): return self.things[idx].hobbies class B(A): authorclass = RemoteAuthorClass def _protector(fcn): def newfcn(self, *args, **kwargs): try: return fcn(self, *args, **kwargs) except AttributeError: return 'Attribute not available' except IndexError: return 'Not that many RemoteAuthorClasses loaded' except HTTPError: return 'Could not connect' return fcn Basically, while RemoteAuthorClass and AuthorClass are related (via inheritance), the RemoteAuthorClass has the potential for HTTPError's now. I could just expand the A class decorator to catch the HTTPError, but since that should not be possible in AuthorClass, I'd rather not risk masking a bug. I'm under no impressions that the above code will decorate A-inherited functions with the B-decorator (I know it won't), but that's the effect I'm trying to achieve... Thanks! Jason -- Jason M. Swails Quantum Theory Project, University of Florida Ph.D. Candidate 352-392-4032 -- http://mail.python.org/mailman/listinfo/python-list
Re: Python launcher (PEP 397) and emacs python-mode.el
Am 31.01.2013 12:05, schrieb Andreas Röhler: Am 31.01.2013 10:03, schrieb Thomas Heller: Has someone managed to patch python-mode.el to use the PEP 397 python launcher when you hit C-c C-c? It seems that emacs should parse the shebang line in the edited python script and pass the corresponding arguments to py.exe. Yes, that's the way python-mode.el acts by default. AFAIU that launcher is implemented in Python3.3 and should not need any patch at all. Should it not work, please file a bug-report at https://bugs.launchpad.net/python-mode Well, let me make these remarks: 1. I'm on Windows, using gnu-emacs 24.2.1, and python-mode.el 6.1.0. I do not understand how the shebang line is used by python-mode.el, depending on what I write into it either 'python.exe' is started when I hit C-c C-c, or I get 'Spawning child process: invalid argument'. The latter occurs most often when the shebang string contains 'jython'. 2. I would like to use the PEP 397 python launcher to start the python version that is specified in the shebang line. The python launcher py.exe parses this line when I run 'py script.py', and then starts the corresponding python interpreter version. The launcher parses the shebang line by its own rules (see pep397 for exact details). One example is this: #!/usr/bin/python3.1-32 import sys; print(sys.version) The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'. I would like emacs to do the same; however this would require emacs to do the same shebang line parsing as the launcher does. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Need some help confirming transactions using sha256
I'm wondering if anyone can help me as I can't seem to get this to work. There is an online dice game that is provably fair by calculating the 'dice roll' using using a sha256 hash calculated against my transaction ID generated by me. The secret used to make the calculation is revealed at the end of each day thus allowing you to prove they didn't cheat. So they provide the following to allow you to verify the calculation of the dice roll: Secret used = r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA Secret hash sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA) = 48d78d573b9b8e11a13a72d9a78011f2e5d9754d89de47b209f32c51777f535d Lucky hash sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA:108128 06653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1) = dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4 Lucky Number 0x48e4 = 18660 So, I'm doing the following: C:\Python27>python Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib, hmac >>> txid = >>> 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' >>> secret = >>> '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' >>> for nout in range(10): print nout, int(hmac.new(secret, "%s:%d" % (txid, >>> nout), hashlib.sha256).hexdigest()[:4], 16) ... 0 39800 1 4705 2 24058 3 11188 4 36307 5 781 6 62165 7 44612 8 17042 9 46099 >>> idx 1 should equal 18660 but it doesn't. What am I doing wrong? Secondly, I'm wondering if someone could help take it one step further. I would like to import a .txt file with a unique transaction ID on each line. So txid = transactions.txt or something like this. I would like it to get the "lucky number" based on a static sha256 which I would supply and the script would output the result to a text file. I'd like the output to be for idx 1 only. ie. "txid here", "lucky number for idx 1" Thanks for any help in advance! Edit/Delete Message -- http://mail.python.org/mailman/listinfo/python-list
Re: advice, python for binary to xml
On Thursday, January 31, 2013 4:05:43 PM UTC+1, noydb wrote: > > I assume that you've looked into GPSBabel? http://www.gpsbabel.org/ > > Yes, I have. Was hoping to use it, but client is very resistent to adding > such things to their system - python is desireable. So what GPSbabel does is > what I need, just one translation, from Garmin's gdb file (binary) to gpx. They realize that they'll get a much higher bill, and more bugs to boot? I don't think there is an easy way around this, but at least you have some code to start reading gdb - as far as I know the GPSBabel sources are the only public description of the gdb file format. It is not trivial, but restricting yourself to the parts needed for the application may provide some shortcuts. Maarten - pay more, get less: way to go. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need some help confirming transactions using sha256
Ok, I'm still stuck! :( I do however now think that I'm not supposed to use hmac here. -- http://mail.python.org/mailman/listinfo/python-list
Re: advice, python for binary to xml
:-) yeah... -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
On Thu, Jan 31, 2013 at 11:00 AM, Jason Swails wrote: > > > On Thu, Jan 31, 2013 at 10:28 AM, Chris Angelico wrote: > >> >> >> Well, that surely isn't going to work, because it always decorates the >> >> same function, the global "fcn". >> > >> > >> > I don't think this is right. fcn is a passed function (at least if it >> acts >> > as a decorator) that is declared locally in the _protector_decorator >> scope. >> > Since newfcn is bound in the same scope and fcn is not defined inside >> > newfcn, I'm pretty sure that newfcn will just grab the fcn passed into >> the >> > decorator. >> >> Yet it adds a level of indirection that achieves nothing. Why not simply: >> def _protector_decorator(fcn): >> return fcn >> >> ? I'm not understanding the purpose here. >> > > Bad example. A better (longer) one that is closer to my true use-case: > > > from somewhere.exceptions import MyTypeError > from somewhere.different import AuthorClass, RemoteAuthorClass > from urllib2 import HTTPError > > class A(object): > >authorclass = AuthorClass > >def __init__(self, obj_list): > """ > Instantiate a list of obj_list objects that may have an "author" > attribute > """ > self.things = [] > for o in obj_list: > if not isinstance(o, self.authorclass): > raise MyTypeError('Bad type given to constructor') > self.things.append(o) > >def _protector(fcn): > def newfcn(self, *args, **kwargs): > try: > return fcn(self, *args, **kwargs) # returns a string > except AttributeError: > return 'Attribute not available.' > except IndexError: > return 'Not that many AuthorClasses loaded' > > return newfcn > >@_protector >def author(self, idx): > return self.things[idx].author > >@_protector >def description(self, idx): > return self.things[idx].description > >@_protector >def hobbies(self, idx): > return self.things[idx].hobbies > > class B(A): > >authorclass = RemoteAuthorClass > >def _protector(fcn): > def newfcn(self, *args, **kwargs): > try: > return fcn(self, *args, **kwargs) > except AttributeError: > return 'Attribute not available' > except IndexError: > return 'Not that many RemoteAuthorClasses loaded' > except HTTPError: > return 'Could not connect' > return fcn > > Basically, while RemoteAuthorClass and AuthorClass are related (via > inheritance), the RemoteAuthorClass has the potential for HTTPError's now. > I could just expand the A class decorator to catch the HTTPError, but > since that should not be possible in AuthorClass, I'd rather not risk > masking a bug. I'm under no impressions that the above code will decorate > A-inherited functions with the B-decorator (I know it won't), but that's > the effect I'm trying to achieve... > The approach I'm switching to here is to make the decorators wrappers instead that are passed the functions that need to be called. Basically, wrap at run-time rather than 'compile time' (i.e., when the Python code is 'compiled' into class definitions). That way each child of the main class can simply change the wrapping behavior by implementing the wrapping functions instead of duplicating all of the code. And since this part of the code is not performance-intensive, I don't care about the overhead of extra function calls. It seems to me to be the more appropriate course of action here, since decorators don't seem to naturally lend themselves to what I'm trying to do. --Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Need some help confirming transactions using sha256
On Thu, 31 Jan 2013 08:43:03 -0800 (PST), kryptox.excha...@gmail.com wrote: > I'm wondering if anyone can help me as I can't seem to get > this to work. There is an online dice game that is > provably fair by calculating the 'dice roll' using using a > sha256 hash calculated against my transaction ID generated > by me. The secret used to make the calculation is revealed > at the end of each day thus allowing you to prove they > didn't cheat. So they provide the following to allow you > to verify the calculation of the dice roll: > > Secret used = > r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA > Secret hash > sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA) > = 48d78d573b9b8e11a13a72d9a78011f2e5d9754d89de47b209f32c51777f535d > Lucky hash > sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA:108128 > 06653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1) = > dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4 > > Lucky Number 0x48e4 = 18660 > > So, I'm doing the following: > > C:\Python27>python > Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. import hashlib, hmac txid = 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' secret = '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' [snip] >>> txid = >>> 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' >>> secret = >>> '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' >>> hashlib.sha256(txid+":"+secret).hexdigest() 'dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4' >>> 0x48e4 18660 >>> . . . which is the number you wanted, right? -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python launcher (PEP 397) and emacs python-mode.el
Am 31.01.2013 17:35, schrieb Thomas Heller: Am 31.01.2013 12:05, schrieb Andreas Röhler: Am 31.01.2013 10:03, schrieb Thomas Heller: Has someone managed to patch python-mode.el to use the PEP 397 python launcher when you hit C-c C-c? It seems that emacs should parse the shebang line in the edited python script and pass the corresponding arguments to py.exe. Yes, that's the way python-mode.el acts by default. AFAIU that launcher is implemented in Python3.3 and should not need any patch at all. Should it not work, please file a bug-report at https://bugs.launchpad.net/python-mode Well, let me make these remarks: 1. I'm on Windows, using gnu-emacs 24.2.1, and python-mode.el 6.1.0. I do not understand how the shebang line is used by python-mode.el, it uses py-shebang-regexp to determine - if a shebang is given - if, yes, which interpreter to run depending on what I write into it either 'python.exe' is started when I hit C-c C-c, or I get 'Spawning child process: invalid argument'. The latter occurs most often when the shebang string contains 'jython'. please file a bug-report giving some example script which triggers the bug 2. I would like to use the PEP 397 python launcher to start the python version that is specified in the shebang line. The python launcher py.exe parses this line when I run 'py script.py', and then starts the corresponding python interpreter version. The launcher parses the shebang line by its own rules (see pep397 for exact details). One example is this: #!/usr/bin/python3.1-32 import sys; print(sys.version) The python launcher starts 'c:\Python31\python.exe -3.1-32 script.py'. unfortunatly don't have a windows at my disposal. At linux it would run exactly the interpreter specified. Might be okay for windows as shown. I would like emacs to do the same; however this would require emacs to do the same shebang line parsing as the launcher does. So we do - looks like python-mode.el precedes PEP 397 :) Expecting the bug elsewhere. Thomas -- http://mail.python.org/mailman/listinfo/python-list
Re: Need some help confirming transactions using sha256
On Thursday, January 31, 2013 6:55:05 PM UTC+1, Peter Pearson wrote: > On Thu, 31 Jan 2013 08:43:03 -0800 (PST), kryptox.excha...@gmail.com wrote: > > > > > I'm wondering if anyone can help me as I can't seem to get > > > this to work. There is an online dice game that is > > > provably fair by calculating the 'dice roll' using using a > > > sha256 hash calculated against my transaction ID generated > > > by me. The secret used to make the calculation is revealed > > > at the end of each day thus allowing you to prove they > > > didn't cheat. So they provide the following to allow you > > > to verify the calculation of the dice roll: > > > > > > Secret used = > > r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA > > > Secret hash > > sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA) > > = 48d78d573b9b8e11a13a72d9a78011f2e5d9754d89de47b209f32c51777f535d > > > Lucky hash > > sha256(r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA:108128 > > 06653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1) = > > dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4 > > > > > > Lucky Number 0x48e4 = 18660 > > > > > > So, I'm doing the following: > > > > > > C:\Python27>python > > > Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] > > on win32 > > > Type "help", "copyright", "credits" or "license" for more information. > > import hashlib, hmac > > txid = > 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' > > secret = > '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' > > [snip] > > > > >>> txid = > >>> 'r7A7clvs9waizF+6QEiI0tgAq1ar48JItK3kg9kaeAFXz2vsMsHmOd9r9fhkmtxTz3CQnGAPMaDeKLvgb1A2VA' > > >>> secret = > >>> '10812806653842663997bf5971637f86f26c71a4716276d7fa8f323a83588d91:1' > > >>> hashlib.sha256(txid+":"+secret).hexdigest() > > 'dfa8769be81a543002865c88a5b52fa07f3b67fc7cd9b519c3f6a6452bcd48e4' > > >>> 0x48e4 > > 18660 > > >>> > > > > . . . which is the number you wanted, right? > > > > > > -- > > To email me, substitute nowhere->spamcop, invalid->net. Yes, thank you Peter! -- http://mail.python.org/mailman/listinfo/python-list
(any)dbm module lacks a context manager
I don't know if this has been remedied in a more recent version than I've got on my box (Debian Stable), but it seems like it should work out of the box: Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dbm >>> with dbm.open("mydb", 'c') as d: ... d["hello"] = "world" ... Traceback (most recent call last): File "", line 1, in AttributeError: '_dbm.dbm' object has no attribute '__exit__' I'm guessing it's an easy fix? (or even already fixed) -tkc -- http://mail.python.org/mailman/listinfo/python-list
RE: (any)dbm module lacks a context manager
> >>> import dbm > >>> with dbm.open("mydb", 'c') as d: > ... d["hello"] = "world" > ... > Traceback (most recent call last): > File "", line 1, in > AttributeError: '_dbm.dbm' object has no attribute '__exit__' This error message is somewhat misleading... it actually means you're trying to use an object as a context manager, and it doesn't implement the context manager protocol (defined __enter__ and __exit__ methods). In this case, db.open() returns a dict -like object that is not a context manager. You'd need to refactor your code to something like: import dbm d = dbm.open("mydb", 'c') d["hello"] = "world" d.close() You may want to wrap any actions on d with a try-except-finally so you can always close the db. If dbm objects were real context managers, they would do this for you. This does seem like a useful enhancement. It might be slightly involved to do, as the dbm module has multiple implementations depending on what libraries are available on the OS. -Nick Cash -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
Steven D'Aprano wrote: >> def _protector_decorator(fcn): >> def newfcn(self, *args, **kwargs): >> return fcn(self, *args, **kwargs) >> return newfcn > > Well, that surely isn't going to work, because it always decorates the > same function, the global "fcn". Good grief, I can't believe I failed to see that fcn was declared as a parameter to _protector_decorator. > You probably want to add an extra parameter to the newfcn definition: > > def newfcn(self, fcn, *args, **kwargs): And that's also rubbish. The right place for the fcn parameter is the decorator function itself, exactly where it already is. Whatever crack I was smoking yesterday, it must have been pretty awful stuff. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
xlrd 0.9.0 released, now with Python 3 support!
Hi All, I'm pleased to announce the release of xlrd 0.9.0: http://pypi.python.org/pypi/xlrd/0.9.0 This release means the supported versions of Python supported by xlrd are 2.6, 2.7, 3.2 and 3.3! Very exciting stuff, and a massive thank you to Thomas Kluyver (@takluyver on GitHub) for doing the bulk of the work to make this happen. Also thanks to Martin Panter (@vadmium in GitHub, if I'm following correctly) for his additional work on the pull request and Manfred Moitzi for re-licensing his unit tests so we could include them. This is obviously a big release, so I wouldn't recommend jumping on it in production just yet, but it would be great if people could get testing on both Python 2 and Python 3. If you find any problems, please ask about them on the python-ex...@googlegroups.com list, or submit an issue on GitHub: https://github.com/python-excel/xlrd/issues Full details of all things Python and Excel related can be found here: http://www.python-excel.org/ cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk -- http://mail.python.org/mailman/listinfo/python-list
Re: (any)dbm module lacks a context manager
On 1/31/2013 2:03 PM, python.l...@tim.thechases.com wrote: I don't know if this has been remedied in a more recent version than I've got on my box (Debian Stable), but it seems like it should work out of the box: Python 3.1.3 (r313:86834, Nov 28 2010, 10:01:07) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. import dbm with dbm.open("mydb", 'c') as d: ... d["hello"] = "world" ... Traceback (most recent call last): File "", line 1, in AttributeError: '_dbm.dbm' object has no attribute '__exit__' I'm guessing it's an easy fix? (or even already fixed) Go to our public tracker, enter 'dbm context manager' in the top search box, (change Status to 'don't care' in case there is a closed issue,) and you get one hit: http://bugs.python.org/issue11287 (Awaiting response to most recent patch review.) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
Jason Swails wrote: > On Thu, Jan 31, 2013 at 12:46 AM, Steven D'Aprano < > steve+comp.lang.pyt...@pearwood.info> wrote: >> Well, that surely isn't going to work, because it always decorates the >> same function, the global "fcn". > > I don't think this is right. It certainly isn't. Sorry for the noise. [...] > Again, my example code is over-simplified. A brief description of my > class > is a list of 'patch' (diff) files with various attributes. If I want > information from any of those files, I instantiate a Patch instance (and > cache it for later use if desired) and return any of the information I > want from that patch (like when it was created, who created it, what files > will be altered in the patch, etc.). > > But a lot of these patches are stored online, so I wanted a new class (a > RemotePatchList) to handle lists of patches in an online repository. I > can do many of the things with an online patch that I can with one stored > locally, but not everything, hence my desire to squash the methods I don't > want to support. Normally, subclasses should extend functionality, not take it away. A fundamental principle of OO design is that anywhere you could sensibly allow an instance, should also be able to use a subclass. So if you have a Patch class, and a RemotePatch subclass, then everything that a Patch can do, a RemotePatch can do too, because RemotePatch instances *are also* instances of Patch. But the rule doesn't go in reverse: you can't necessarily use a Patch instance where you were using a RemotePatch. Subclasses are allowed to do *more*, but they shouldn't do *less*. On the other hand, if you have a Patch class, and a RemotePatchList class, inheritance does not seem to be the right relationship here. A RemotePatchList does not seem to be a kind of Patch, but a kind of list. > I'd imagine a much more sensible approach is to generate a base class that > implements all methods common to both and simply raises an exception in > those methods that aren't. I agree it doesn't make much sense to inherit > from an object that has MORE functionality than you want. If a method is not common to both, it doesn't belong in the base class. The base should only include common methods. In fact, I'm usually rather suspicious of base classes that don't ever get used except as a base for subclassing. I'm not saying it's wrong, but it could be excessive abstraction. Abstraction is good, but you can have too much of a good thing. If the base class is not used, consider a flatter hierarchy: class Patch: ... class RemotePatch(Patch): ... rather than: class PatchBase: ... class Patch(PatchBase): ... class RemotePatch(Patch): ... although this is okay: class PatchBase: ... class Patch(PatchBase): ... class RemotePatch(PatchBase): ... > However, my desire to use decorators was not to disable methods in one > class vs. another. The _protector_decorator (a name borrowed from my > actual code), is designed to wrap a function call inside a try/except, to > account for specific exceptions I might raise inside. Ah, your example looked like you were trying to implement some sort of access control, where some methods were flagged as "protected" to prevent subclasses from using them. Hence my quip about Java. What you describe here makes more sense. > One of my classes > deals with local file objects, and the other deals with remote file > objects > via urllib. Naturally, the latter has other exceptions that can be > raised, > like HTTPError and the like. So my desire was to override the decorator > to handle more types of exceptions, but leave the underlying methods > intact without duplicating them. >>> decorated(3) 4 One way to do that is to keep a list of exceptions to catch: class Patch: catch_these = [SpamException, HamException] def method(self, arg): try: do_this() except self.catch_these: do_that() The subclass can then extend or replace that list: class RemotePatch(Patch): catch_these = Patch.catch_these + [EggsException, CheeseException] >> import functools > > I need to support Python 2.4, and the docs suggest this is 2.5+. Too bad, > too, since functools appears pretty useful. functools.wraps is pretty simple. You can use this as an equivalent: # `functools.wraps` was added in Python 2.5. def wraps(func_to_wrap): """Return a decorator that wraps its argument. This is a reimplementation of functools.wraps() which copies the name, module, docstring and attributes of the base function to the decorated function. wraps() is available in the standard library from Python 2.5. >>> def undecorated(x): ... '''This is a doc string.''' ... return x+1 ... >>> undecorated.__module__ = 'parrot' >>> undecorated.attr = 'something' >>> @wraps(undecorated) ... def decorated(x): ... return undecorated(x) ... >>
Re: Python launcher (PEP 397) and emacs python-mode.el
Thomas Heller ctypes.org> writes: > What I meant to write is this: > > when the shebang line in script.py contains this: >#!/usr/bin/python3.1-32 > then emacs SHOULD run >py.exe -3.1-32 script.py > and the launcher runs >c:\Python31\python.exe script.py IMO it would be better for emacs to just run py.exe script.py and py.exe can read the shebang and do the right thing. This saves the emacs code from having to duplicate the shebang line processing logic that py.exe uses (which, as we know, is unusual. So for a cross-platform you can have a shebang line of #!/usr/bin/python3.2, and on Windows it will still call the appropriate Python 3.2 even if it's not in /usr/bin, as there's no /usr/bin :-)) Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
Help the visibility of Python in computational science
Hi everyone, There is currently a competition running that could help give Python in computational science a bit of visibility. The competition is for the most popular recently published article on the Scholarpedia website, one of which is about a Python package "Brian" for computational neuroscience simulations. If you could take one minute to make sure you are signed in to your Google+ account and click the g+1 icon near the top right of the page, it has a chance of winning the competition. Here's the link to the article: http://www.scholarpedia.org/article/Brian_simulator Full disclosure, I'm the first author of that article, and I'd be happy to win the competition too. :) More details: Scholarpedia is an alternative to wikipedia with slightly tighter control: contributions only allowed from scholars, etc. "Brain Corporation" is offering $1 in prizes to the top 3 most popular entries published between last October and this June based on google +1 votes. It's a bit of a silly popularity contest because of this, but I still think it would be great if a Python based thing could win it. "Brian" is a package I wrote (with several others) to do simulations of spiking neural networks in Python. Read the article if you want to know more! :) Thanks all for your attention, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Help the visibility of Python in computational science
On Fri, Feb 1, 2013 at 12:05 PM, wrote: > "Brian" is a package I wrote (with several others) to do simulations of > spiking neural networks in Python. Read the article if you want to know > more! :) Ah, I don't need to read it. You're simulating a brain; the rest is mere appendix! (couldn't resist quoting the great detective being wrong) I don't do social networking though, sorry. Networking is my antidote to being social. :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: why no pydoc python?
rh writes: > I installed python from tarball and I wonder if I did something wrong. > pydoc pydoc works fine but there's no pydoc python. What would you expect ‘pydoc python’ to show? The word “python” is not a keyword, is not a built-in identifier, is not a standard library module. > There is a man page for python. Maybe there is no python doc for > pydoc? There is a man page for the command ‘python’ because it's a command that can be invoked from the operating system shell. Python's documentation (accessed with the ‘pydoc’ command) is not the place to document that. -- \“My doctor told me to stop having intimate dinners for four. | `\ Unless there are three other people.” —Orson Welles | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Help the visibility of Python in computational science
On 1/31/2013 8:05 PM, dg.google.gro...@thesamovar.net wrote: Hi everyone, There is currently a competition running that could help give Python in computational science a bit of visibility. The competition is for the most popular recently published article on the Scholarpedia website, one of which is about a Python package "Brian" for computational neuroscience simulations. If you could take one minute to make sure you are signed in to your Google+ account and click the g+1 icon near the top right of the page, it has a chance of winning the competition. Here's the link to the article: http://www.scholarpedia.org/article/Brian_simulator 'Brian' is obviously a play on 'brain', with two letters transposed. But comparison of the logo on the page above with the image on https://en.wikipedia.org/wiki/Life_of_brian shows another source ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: confusion with decorators
On Thu, Jan 31, 2013 at 6:16 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > Normally, subclasses should extend functionality, not take it away. A > fundamental principle of OO design is that anywhere you could sensibly > allow an instance, should also be able to use a subclass. > > So if you have a Patch class, and a RemotePatch subclass, then everything > that a Patch can do, a RemotePatch can do too, because RemotePatch > instances *are also* instances of Patch. > > But the rule doesn't go in reverse: you can't necessarily use a Patch > instance where you were using a RemotePatch. Subclasses are allowed to do > *more*, but they shouldn't do *less*. > > On the other hand, if you have a Patch class, and a RemotePatchList class, > inheritance does not seem to be the right relationship here. A > RemotePatchList does not seem to be a kind of Patch, but a kind of list. > > > > I'd imagine a much more sensible approach is to generate a base class > that > > implements all methods common to both and simply raises an exception in > > those methods that aren't. I agree it doesn't make much sense to inherit > > from an object that has MORE functionality than you want. > > If a method is not common to both, it doesn't belong in the base class. The > base should only include common methods. > Yes, I agree here. The only reason I was considering NOT doing this was because I wanted to control the exception that gets raised rather than let through a simple NameError. The reason, in case you care, is that I like creating my own custom excepthook() which optionally suppresses tracebacks of the base exception class of my program (which can be overridden by a --debug option of some sort). That way I don't worry about returning error codes and the like and my exceptions double as error messages which don't scare users away. Of course, if I didn't raise the exception myself, then I definitely want to know what line that error occurred on so I can fix it (since that typically means it's a bug or error I did not handle gracefully). I suppose I could get the same effect by dumping everything into a main() function somewhere and wrapping that in a try/except where I catch my base class, but I like the flexibility > In fact, I'm usually rather suspicious of base classes that don't ever get > used except as a base for subclassing. I'm not saying it's wrong, but it > could be excessive abstraction. Abstraction is good, but you can have too > much of a good thing. If the base class is not used, consider a flatter > hierarchy: > > class Patch: ... > class RemotePatch(Patch): ... > > > rather than: > > class PatchBase: ... > class Patch(PatchBase): ... > class RemotePatch(Patch): ... > > although this is okay: > > class PatchBase: ... > class Patch(PatchBase): ... > class RemotePatch(PatchBase): ... > This last one is what I've settled on. Patch and RemotePatch have common functionality. But RemotePatch can be downloaded and Patch can be parsed through (in my app, if you're going to spend the time to parse through the whole RemotePatch, it just gets downloaded and instantiated as a Patch). So this last form of inheritance made the most sense to me. > > > > However, my desire to use decorators was not to disable methods in one > > class vs. another. The _protector_decorator (a name borrowed from my > > actual code), is designed to wrap a function call inside a try/except, to > > account for specific exceptions I might raise inside. > > Ah, your example looked like you were trying to implement some sort of > access control, where some methods were flagged as "protected" to prevent > subclasses from using them. Hence my quip about Java. What you describe > here makes more sense. > > > > One of my classes > > deals with local file objects, and the other deals with remote file > > objects > > via urllib. Naturally, the latter has other exceptions that can be > > raised, > > like HTTPError and the like. So my desire was to override the decorator > > to handle more types of exceptions, but leave the underlying methods > > intact without duplicating them. > > >>> decorated(3) > 4 > > One way to do that is to keep a list of exceptions to catch: > > > class Patch: > catch_these = [SpamException, HamException] > def method(self, arg): > try: > do_this() > except self.catch_these: > do_that() > > The subclass can then extend or replace that list: > > class RemotePatch(Patch): > catch_these = Patch.catch_these + [EggsException, CheeseException] > Ha! I use this technique all the time to avoid code duplication (it's used several times in the program I'm writing). It didn't even occur to me in this context... Thanks for pointing this out! As always, the time you put into responses and helping is appreciated. All the best, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: Help the visibility of Python in computational science
On Thursday, January 31, 2013 10:06:44 PM UTC-5, Terry Reedy wrote: > On 1/31/2013 8:05 PM, dg.google.gro...@thesamovar.net wrote: > > Here's the link to the article: > > http://www.scholarpedia.org/article/Brian_simulator > > 'Brian' is obviously a play on 'brain', with two letters transposed. But > > comparison of the logo on the page above with the image on > > https://en.wikipedia.org/wiki/Life_of_brian > > shows another source ;-). > Pure coincidence I assure you, I'm just very stuck in the old days of web design with 3D text logos. ;) Dan -- http://mail.python.org/mailman/listinfo/python-list
Python 2 multiprocessing examples in docs.python.org
Hey all, I ran the example code on multiprocessing. On the "Pool example", an assertion failed with "testing garbage collection". Traceback (most recent call last): File "test.py", line 314, in test() File "test.py", line 295, in test assert not worker.is_alive() AssertionError The relevant example code reads: pool = multiprocessing.Pool(2) DELTA = 0.1 processes = pool._pool ignore = pool.apply(pow3, [2]) results = [pool.apply_async(time.sleep, [DELTA]) for i in range(100)] results = pool = None time.sleep(DELTA * 2) for worker in processes: assert not worker.is_alive() My questions are 1) How does that GC test work, and 2) Does that mean my GC isn't working as fast as it should have been? The machine's Python: xav ❖ /tmp > python Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list
Re: why no pydoc python?
rh writes: > pydoc can be invoked from the operating system shell. Which is irrelevant to what ‘pydoc’ produces, since it is looking in the Python documentation. You'll notice that ‘pydoc pydoc’ does not give the contents of the ‘pydoc’ manpage. Instead, it gives documentation for the ‘pydoc’ module, as expected. > So the question remains, why not? Because the ‘pydoc’ command is for displaying Python documentation, not man pages. -- \ “Are you pondering what I'm pondering?” “I think so, Brain, but | `\ pants with horizontal stripes make me look chubby.” —_Pinky and | _o__) The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Help the visibility of Python in computational science
dg.google.gro...@thesamovar.net wrote: > If you could take one minute to make sure you > are signed in to your Google+ account Which Google+ account would that be? I have so few. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Help the visibility of Python in computational science
On Fri, Feb 1, 2013 at 4:00 PM, Steven D'Aprano wrote: > dg.google.gro...@thesamovar.net wrote: > >> If you could take one minute to make sure you >> are signed in to your Google+ account > > Which Google+ account would that be? I have so few. > It's a thing non-nerds do, Steven. You wouldn't understand. http://xkcd.com/918/ ChrisA *ducking for cover* -- http://mail.python.org/mailman/listinfo/python-list
Re: Python launcher (PEP 397) and emacs python-mode.el
Am 01.02.2013 00:59, schrieb Vinay Sajip: Thomas Heller ctypes.org> writes: What I meant to write is this: when the shebang line in script.py contains this: #!/usr/bin/python3.1-32 then emacs SHOULD run py.exe -3.1-32 script.py and the launcher runs c:\Python31\python.exe script.py IMO it would be better for emacs to just run py.exe script.py and py.exe can read the shebang and do the right thing. This saves the emacs code from having to duplicate the shebang line processing logic that py.exe uses (which, as we know, is unusual. So for a cross-platform you can have a shebang line of #!/usr/bin/python3.2, and on Windows it will still call the appropriate Python 3.2 even if it's not in /usr/bin, as there's no /usr/bin :-)) Regards, Vinay Sajip https://bugs.launchpad.net/python-mode/+bug/1112207 -- http://mail.python.org/mailman/listinfo/python-list
Re: Cheat Engine In Python
On Fri, Feb 1, 2013 at 6:21 PM, wrote: > Why there isn't any replys ? . Because you posted it only a couple of hours ago, for one :) My initial guess is: No. Feel free to disprove me by searching on Google and finding one. ChrisA -- http://mail.python.org/mailman/listinfo/python-list