Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 4:26 PM, harrismh777 wrote: > Actually, it should be relatively easy to incorporate parts of bc into > Python as C extensions. On the other hand, when needing specialized math > work from bc, its probably just better to use bc and leave Python alone. If someone has time to

Re: hash values and equality

2011-05-19 Thread Chris Rebert
On Thu, May 19, 2011 at 10:43 PM, Ethan Furman wrote: > Several folk have said that objects that compare equal must hash equal, and > the docs also state this > http://docs.python.org/dev/reference/datamodel.html#object.__hash__ > > I'm hoping somebody can tell me what horrible thing will happen i

Re: hash values and equality

2011-05-19 Thread Peter Otten
Ethan Furman wrote: > Several folk have said that objects that compare equal must hash equal, > and the docs also state this > http://docs.python.org/dev/reference/datamodel.html#object.__hash__ > > I'm hoping somebody can tell me what horrible thing will happen if this > isn't the case? Here's

Problem running pylons webtests. ImportError and TestController is not defined error.

2011-05-19 Thread SONAL ...
I have directory structure as gnukhata/tests/functional. In functional folder I have web tests files. Following is the sample tests: *from gnukhata.tests import * class TestVendorController(TestController): def test_index(self): response = self.app.get(url(controller='vendor', action='index'

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread harrismh777
Chris Angelico wrote: I believe the 'bc' command-line calculator can do a-p non-i, and I know REXX can Yes, bc is wonderful in this regard. Actually, bc does this sort of thing in 'circles' around Python. This is one of Python's weaknesses for some problem solving... no arbitrary precision.

Re: obviscating python code for distribution

2011-05-19 Thread harrismh777
geremy condra wrote: Anonymous, "Maximum Linux Security: A Hacker's Guide to Protecting > Your Linux Server and Workstation," Indianapolis: > Sams Publishing, 2000. This is a good volume, but very dated. I'd probably pass on it. Actually, although dated, its still a very go

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 3:58 PM, Steven D'Aprano wrote: > ... until you deleted most of it :) Minimalist quoting practice! :) > If you want an *accurate* fib() function using exponentiation of φ, you > need arbitrary precision non-integers. I believe the 'bc' command-line calculator can do a-p

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread Steven D'Aprano
On Fri, 20 May 2011 09:37:59 +1000, Chris Angelico wrote: > On Fri, May 20, 2011 at 8:47 AM, Steven D'Aprano > wrote: >> On Tue, 17 May 2011 10:02:21 -0700, geremy condra wrote: >> >>> or O(1): >>> >>> φ = (1 + sqrt(5)) / 2 >>>     numerator = (φ**n) - (1 - φ)**n >> >> I'd just like to point out

hash values and equality

2011-05-19 Thread Ethan Furman
Several folk have said that objects that compare equal must hash equal, and the docs also state this http://docs.python.org/dev/reference/datamodel.html#object.__hash__ I'm hoping somebody can tell me what horrible thing will happen if this isn't the case? Here's a toy example of a class I'm

validating a class against an ABC at definition time

2011-05-19 Thread Eric Snow
Thinking about class APIs and validating a class against an API. The abc module provides the tools to do some of this. One thing I realized, that I hadn't noticed before, is that the abstractness of a class is measured when instances of the class are created. This happens in object.__new__ (pyob

Re: Recursion in Computer Science

2011-05-19 Thread rusi
On May 20, 10:18 am, Chris Angelico wrote: > On Fri, May 20, 2011 at 3:05 PM, rusi wrote: > >  - data can be code -- viruses > > It's not JUST viruses. There's plenty of legitimate reasons for your > data to actually be code... that's how compilers work! :) > > Chris Angelico Yes sure Thanks. An

Re: Recursion in Computer Science

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 3:05 PM, rusi wrote: >  - data can be code -- viruses It's not JUST viruses. There's plenty of legitimate reasons for your data to actually be code... that's how compilers work! :) Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread rusi
On May 20, 2:21 am, Rikishi42 wrote: > On 2011-05-18, Hans Georg Schaathun wrote: > > > Now Mac OS X has maintained the folder concept of older mac generations, > > and Windows has cloned it.  They do not want the user to understand > > recursive data structures, and therefore, naturally, avoid t

Recursion in Computer Science

2011-05-19 Thread rusi
There have been a number of unrelated discussions regarding recursion on this list. I believe that recursion occurs in a wider spread of areas than is usually recognised. Heres a list of some such areas. Please note I am using recursion in a broad and somewhat fuzzy sense. Narrow specific definiti

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread Hans Georg Schaathun
On Thu, 19 May 2011 23:21:30 +0200, Rikishi42 wrote: : On 2011-05-18, Hans Georg Schaathun wrote: : > Now Mac OS X has maintained the folder concept of older mac generations, : > and Windows has cloned it. They do not want the user to understand : > recursive data structures, and therefore, n

Re: obviscating python code for distribution

2011-05-19 Thread Hans Georg Schaathun
On Thu, 19 May 2011 17:56:12 -0700, geremy condra wrote: : TL;DR version: large systems have indeed been verified for their : security properties. : (...) : Yup. Nothing is safe from idiots. The difficult part is mapping those properties to actual requirements and threat models. Formal meth

starting a separate thread in maya

2011-05-19 Thread Astan Chee
Hi, I'm using python2.5 in maya 2009 x64 (in linux). I have a script running and somewhere in the script, I want to start another python script that might not return and i don't want the main maya python script to wait for it to finish, even more, after the second script started, I'd like the main

Re: turn monitor off and on

2011-05-19 Thread Astan Chee
On Mon, May 16, 2011 at 7:29 PM, Gabriel Genellina wrote: > > Your script worked fine for me, 2.6 and XP also. Perhaps your monitor > device driver is buggy or does not implement the required functionality. > Mine is from Philips. > > I'm actually using windows 7. Maybe its the difference in OS? A

Re: Inheriting Object

2011-05-19 Thread Navkirat Singh
On Fri, May 20, 2011 at 8:25 AM, MRAB wrote: > On 20/05/2011 03:13, Navkirat Singh wrote: > >> Hi Guys, >> >> I have been wondering for a while now as to why some classes inherit >> Object? And what does it really do for the class? Can anyone shed some >> light on this? >> >> Read section 3.3 "N

Re: Inheriting Object

2011-05-19 Thread William . Bai
Hi Nav: Here is the long why. http://www.python.org/download/releases/2.2.3/descrintro/ I guess for most programs, there is no big difference. But in term of some new added features in python, you might not be able to work. Say, you could not use super in type, also you can't mul

Re: Inheriting Object

2011-05-19 Thread William
Hi Nav: Here is the long why. http://www.python.org/download/releases/2.2.3/descrintro/ I guess for most programs, there is no big difference. But in term of some new added features in python, you might not be able to work. Say, you could not use super in type, also you can't mul

Re: Inheriting Object

2011-05-19 Thread William
Hi Nav: Here is the long why. http://www.python.org/download/releases/2.2.3/descrintro/ I guess for most programs, there is no big difference, but if you use some special features that might be different. Say, could use super when using type() instead of class(), also, when using m

Re: Inheriting Object

2011-05-19 Thread MRAB
On 20/05/2011 03:13, Navkirat Singh wrote: Hi Guys, I have been wondering for a while now as to why some classes inherit Object? And what does it really do for the class? Can anyone shed some light on this? Read section 3.3 "New-style and classic classes" in the Python docs. -- http://mail.pyt

Re: obviscating python code for distribution

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 12:30 PM, geremy condra wrote: >> On Fri, May 20, 2011 at 10:56 AM, geremy condra wrote: >>> Yup. Nothing is safe from idiots. > > I actually think I need to take this statement back. The more I think > about it, the less convinced I am that it's correct- I can at least >

Re: obviscating python code for distribution

2011-05-19 Thread geremy condra
On Thu, May 19, 2011 at 6:33 PM, Chris Angelico wrote: > On Fri, May 20, 2011 at 10:56 AM, geremy condra wrote: >>> Speaking of reasonable assumptions, one necessary assumption which is >>> particularly dodgy is that whoever deploys and configures it >>> understands all the assumptions and do not

Inheriting Object

2011-05-19 Thread Navkirat Singh
Hi Guys, I have been wondering for a while now as to why some classes inherit Object? And what does it really do for the class? Can anyone shed some light on this? Regards, Nav -- http://mail.python.org/mailman/listinfo/python-list

Re: obviscating python code for distribution

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 10:56 AM, geremy condra wrote: >> Speaking of reasonable assumptions, one necessary assumption which is >> particularly dodgy is that whoever deploys and configures it >> understands all the assumptions and do not break them through ignorance. > > Yup. Nothing is safe from

Re: obviscating python code for distribution

2011-05-19 Thread geremy condra
On Thu, May 19, 2011 at 11:23 AM, Hans Georg Schaathun wrote: > On Thu, 19 May 2011 10:23:47 -0700, geremy condra >   wrote: > :  Let me get this straight: your argument is that operating *systems* > :  aren't systems? > > You referred to the kernel and not the system.  The complexities of > the

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread Pascal J. Bourguignon
t...@sevak.isi.edu (Thomas A. Russ) writes: > "Pascal J. Bourguignon" writes: > >> t...@sevak.isi.edu (Thomas A. Russ) writes: >> > >> > This will only work if there is a backpointer to the parent. >> >> No, you don't need backpointers; some cases have been mentionned in the >> other answer, but

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread Thomas A. Russ
Hans Georg Schaathun writes: > ["Followup-To:" header set to comp.lang.python.] Ignored, since I don't follow that group. > On Wed, 18 May 2011 20:20:01 +0200, Raymond Wiker >wrote: > : I don't think anybody mentioned *binary* trees. The context was > : directory traversal, in which cas

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread Thomas A. Russ
"Pascal J. Bourguignon" writes: > t...@sevak.isi.edu (Thomas A. Russ) writes: > > > > This will only work if there is a backpointer to the parent. > > No, you don't need backpointers; some cases have been mentionned in the > other answer, but in general: > > (defun parent (tree node) >

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread geremy condra
On Thu, May 19, 2011 at 3:47 PM, Steven D'Aprano wrote: > On Tue, 17 May 2011 10:02:21 -0700, geremy condra wrote: > >> or O(1): >> >> φ = (1 + sqrt(5)) / 2 >> def fib(n): >>     numerator = (φ**n) - (1 - φ)**n >>     denominator = sqrt(5) >>     return round(numerator/denominator) > > I'd just li

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread Chris Angelico
On Fri, May 20, 2011 at 8:47 AM, Steven D'Aprano wrote: > On Tue, 17 May 2011 10:02:21 -0700, geremy condra wrote: > >> or O(1): >> >> φ = (1 + sqrt(5)) / 2 >>     numerator = (φ**n) - (1 - φ)**n > > I'd just like to point out that, strictly speaking, it's only O(1) if you > assume that exponentia

Re: Faster Recursive Fibonacci Numbers

2011-05-19 Thread Steven D'Aprano
On Tue, 17 May 2011 10:02:21 -0700, geremy condra wrote: > or O(1): > > φ = (1 + sqrt(5)) / 2 > def fib(n): > numerator = (φ**n) - (1 - φ)**n > denominator = sqrt(5) > return round(numerator/denominator) I'd just like to point out that, strictly speaking, it's only O(1) if you assum

Re: python2+3

2011-05-19 Thread Steven D'Aprano
On Thu, 19 May 2011 05:42:29 -0700, lkcl wrote: > has anyone considered the idea of literally creating a Python2/ > subdirectory in the python3 codebase, literally just dropping the entire > python2.N code directly into it, renaming all functions and data > structures, adding a "--2-compatible" s

Re: Trying to understand html.parser.HTMLParser

2011-05-19 Thread Ethan Furman
Andrew Berg wrote: ElementTree doesn't seem to have been updated in a long time, so I'll assume it won't work with Python 3. I don't know how to use it, but you'll find ElementTree as xml.etree in Python 3. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand html.parser.HTMLParser

2011-05-19 Thread Karim
On 05/19/2011 11:35 PM, Andrew Berg wrote: On 2011.05.16 02:26 AM, Karim wrote: Use regular expression for bad HTLM or beautifulSoup (google it), below a exemple to extract all html links: Actually, using regex wasn't so bad: import re import urllib.request url = 'http://x264.nl/x264/?dir=./6

Re: Trying to understand html.parser.HTMLParser

2011-05-19 Thread Andrew Berg
On 2011.05.16 02:26 AM, Karim wrote: > Use regular expression for bad HTLM or beautifulSoup (google it), below > a exemple to extract all html links: Actually, using regex wasn't so bad: > import re > import urllib.request > > url = 'http://x264.nl/x264/?dir=./64bit/8bit_depth' > page = str(urllib

Re: English Idiom in Unix: Directory Recursively

2011-05-19 Thread Rikishi42
On 2011-05-18, Hans Georg Schaathun wrote: > Now Mac OS X has maintained the folder concept of older mac generations, > and Windows has cloned it. They do not want the user to understand > recursive data structures, and therefore, naturally, avoid the word. You imply they want to keep their user

Re: os.access giving incorrect results on Windows

2011-05-19 Thread Andrew Berg
On 2011.05.19 03:08 PM, Tim Golden wrote: > * A R_OK check always succeeds if the file's attributes can be read >at all So is this the same as F_OK then, or does it return false if the user isn't allowed to read permissions? > * A W_OK check fails if the file has its DOS read-only attribute set

application level monitoring for python

2011-05-19 Thread Walter Chang
Hi is there any open source library for python that can allow application level monitoring ? For example,application can send per request level/ aggregated monitoring events and some remote server dump it and show in the monitoring graph in real time ? What's best way of doing that ? -- http://

Re: Windows Registry Keys

2011-05-19 Thread Elias Fotinis
On Thu, 19 May 2011 21:03:34 +0300, Mathew wrote: I have installed a new version of Python27 in a new directory. I want to get this info into the registry so, when I install Numpy, it will use my new Python If I understand correctly (you have multiple Python 2.7 installations and what to mak

Re: os.access giving incorrect results on Windows

2011-05-19 Thread Tim Golden
On 19/05/2011 20:56, Andrew Berg wrote: On 2011.05.19 02:43 PM, Tim Golden wrote: This is basically issue2528 [1]. The problem is that, although Windows (and Python) expose a version of os.access to match the Posix function, the meaning is so far removed on Windows as to be useless. Does this a

Re: os.access giving incorrect results on Windows

2011-05-19 Thread Andrew Berg
On 2011.05.19 02:43 PM, Tim Golden wrote: > This is basically issue2528 [1]. > The problem is that, although Windows (and Python) > expose a version of os.access to match the Posix function, > the meaning is so far removed on Windows as to be useless. Does this affect just os.W_OK and directories o

Re: os.access giving incorrect results on Windows

2011-05-19 Thread Tim Golden
On 19/05/2011 20:37, Ayaskanta Swain wrote: Please help me in solving this issue. I want to check the write permissions on a directory on windows from my python script. I tried to use *os.access(dirpath, os.W_OK)*to check whether the user has write access or not, but it gives me incorrect result

os.access giving incorrect results on Windows

2011-05-19 Thread Ayaskanta Swain
Hi All, Please help me in solving this issue. I want to check the write permissions on a directory on windows from my python script. I tried to use os.access(dirpath, os.W_OK) to check whether the user has write access or not, but it gives me incorrect result. It always gives me False even

Windows Registry Keys

2011-05-19 Thread Mathew
Hi I have installed a new version of Python27 in a new directory. I want to get this info into the registry so, when I install Numpy, it will use my new Python TIA -Mathew -- http://mail.python.org/mailman/listinfo/python-list

Re: obviscating python code for distribution

2011-05-19 Thread Hans Georg Schaathun
On Thu, 19 May 2011 10:23:47 -0700, geremy condra wrote: : Let me get this straight: your argument is that operating *systems* : aren't systems? You referred to the kernel and not the system. The complexities of the two are hardly comparable. There probably are different uses of system; in

Re: obviscating python code for distribution

2011-05-19 Thread geremy condra
On Wed, May 18, 2011 at 7:54 PM, harrismh777 wrote: > Littlefield, Tyler wrote: > Four resources that you will what to look into, in no particular order: > > Erickson, Jon, "Hacking: The Art of Exploitation," 2nd ed, >        San Francisco: No Starch Press, 2008. This would be a very good choi

Re: obviscating python code for distribution

2011-05-19 Thread geremy condra
On Wed, May 18, 2011 at 10:21 PM, Hans Georg Schaathun wrote: > On Wed, 18 May 2011 14:34:46 -0700, geremy condra >   wrote: > :  Systems can be designed that are absolutely secure under reasonable > :  assumptions. The fact that it has assumptions does not make your > :  statement true. > : (...

Re: how to get PID from subprocess library

2011-05-19 Thread Miki Tebeka
The best module for doing such things is subprocess. And the Popen object has a pid attribute (http://docs.python.org/library/subprocess.html#subprocess.Popen.pid) -- http://mail.python.org/mailman/listinfo/python-list

how to get PID from subprocess library

2011-05-19 Thread TheSaint
hello, I'm using to launch a program by subprocess.getstatusoutput. I'd like to know whether I can get the program ID, in order to avoid another launch. For clarity sake, I'm calling aria2 (the download manager for linux) and I wouldn't like to call one more instance of it. So what will I use t

Re: Problem with multiprocessing

2011-05-19 Thread Dan Stromberg
Share as little as possible between your various processes - shared, mutable state is a parallelism tragedy. If you can avoid sharing an entire dictionary, do so. It'd probably be better to dedicate one process to updating your dictionary, and then using a multiprocessing.Queue to pass delta reco

Re: pyjamas 0.8alpha1 release

2011-05-19 Thread lkcl
On May 18, 11:02 pm, Terry Reedy wrote: > On 5/18/2011 5:24 AM, lkcl wrote: > > There seem to be two somewhat separate requirement issues: the > interpreter binary and the language version. yes. [with the startling possibility of compiling the entire pyjs compiler into javascript and executing

Problem with multiprocessing

2011-05-19 Thread Pietro Abate
Hi all, I'm a bit struggling to understand a KeyError raised by the multiprocessing library. My idea is pretty simple. I want to create a server that will spawn a number of workers that will share the same socket and handle requests independently. The goal is to build a 3-tier structure where a

Gambit REPL app for iPhone/iPod touch/iPad

2011-05-19 Thread Marc Feeley
A version of the Gambit Scheme system for iPhone/iPod touch/iPad is now available on the Apple App Store: http://itunes.apple.com/us/app/gambit-repl/id434534076?mt=8&ls=1 "Gambit REPL" is a complete version of Gambit (http:// dynamo.iro.umontreal.ca/~gambit) including the interpreter, debugger

python2+3

2011-05-19 Thread lkcl
[changing subject, seems a good idea...] On May 19, 2:13 am, Terry Reedy wrote: > On 5/18/2011 9:42 AM, lkcl wrote: > > >   he's got a good point, terry.  breaking backwards-compatibility was a > > completely mad and incomprehensible decision. > > I see that I should take everything you (or Harri

Re: pypi mirror

2011-05-19 Thread Oisin Mulvihill
Hi Sławek, You could also do a local or private egg repository. I documented how I did this for my internal projects here: http://www.sourceweaver.com/posts/private-python-egg-repository I hadn't come across z3c.pymirror before. All the best, Oisin On 19 May 2011 10:12, Slafs wrote: > Hi the

pexpect: TIMEOUT no longer clears child.before

2011-05-19 Thread Adrian Casey
The behaviour of pexpect has changed between version 2.1 and 2.3. In version 2.1, the following code would result in child.before being cleared -: >>>child.expect(pexpect.TIMEOUT,1) In version 2.3, this is no longer the case. No matter how many times the above code is run, child.before con

Re: connect SIGINT to custom interrupt handler

2011-05-19 Thread Nobody
On Wed, 18 May 2011 07:16:40 -0700, Jean-Paul Calderone wrote: > Setting SA_RESTART on SIGINT is probably the right thing to do. It's not > totally clear to me from the messages in this thread if you managed to get > that approach working. He didn't; select() isn't SA_RESTART-able. Unfortunatel

Re: test_argparse.py FAILED (failures=6)

2011-05-19 Thread Giampaolo Rodolà
There's no point in posting this here. Use the bug tracker: http://bugs.python.org/ --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/5/17 nirinA raseliarison : > > == > FAIL: test_failures_

Re: python logging

2011-05-19 Thread Vinay Sajip
On May 18, 11:42 pm, Ian Kelly wrote: > I was wrong, it's more complicated than that. > > >>>logging.getLogger('log').warning('test') > > No handlers could be found for logger "log">>>logging.warning('test') > WARNING:root:test > >>>logging.getLogger('log').warning('test') > > WARNING:log:test > >

Re: smtplib is broken when using TLS

2011-05-19 Thread Giampaolo Rodolà
Please file a ticket on: http://bugs.python.org/ Regards, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ 2011/5/17 nirinA raseliarison : > i think this has the same origin as the ftplib test failure. > > Python 3.2.1rc1 (default, May 17 2011, 22:01:34) > [GCC

Re: obviscating python code for distribution

2011-05-19 Thread Hans Georg Schaathun
On 19 May 2011 08:47:28 GMT, Steven D'Aprano wrote: : The real barrier to cracking Oyster cards is not that the source code is : unavailable, but that the intersection of the set of those who know how : to break encryption, and the set of those who want to break Oyster cards, : is relative

pypi mirror

2011-05-19 Thread Slafs
Hi there. I would like to make a "local" mirror of some packages that are on pypi. What options do You recommend ? I am leaning towards z3c.pypimirror because it was kind of first on my google search results. Regards Sławek -- http://mail.python.org/mailman/listinfo/python-list

Re: obviscating python code for distribution

2011-05-19 Thread Steven D'Aprano
On Thu, 19 May 2011 06:21:08 +0100, Hans Georg Schaathun wrote: > : Are you talking about the Mayfair classical cipher here? > > I am talking about the system used in public transport cards like Oyster > and Octopus. I am not sure how classical it is, or whether > mayfair/mayfare referred to th

Re: How to select Python web frameworks and which one is the best framework ?

2011-05-19 Thread Kushal Kumaran
On Thu, May 19, 2011 at 9:23 AM, VGNU Linux wrote: > > > On Tue, May 17, 2011 at 1:20 PM, VGNU Linux wrote: >> >> Hi all, >> I am confused on which web framework to select for developing a small data >> driven web application. Application will have features generally found in >> now-a-days web ap

Re: python logging

2011-05-19 Thread Rafael Durán Castañeda
You are right that behavior isn't documented and might be a bug. You could report it. Bye El 19 de mayo de 2011 00:42, Ian Kelly escribió: > 2011/5/18 Ian Kelly : > > Ah, that's it. I was using Python 2.5. Using 2.7 I get the same > > result that you do. > > > > Still, it's a surprising chang