The Texas Python Unconference is Almost Here!
The first regional Python unconference is coming to Houston on September 15-16 (Sat-Sun). Being held at the Texas Learning Computing Center on the University of Houston main campus, this is a FREE event for Pythoneers from all over the Texas region. http://pycamp.python.org/Texas/ And being an unconference, participation by those who attend is welcome and greatly sought. The topics to be presented are purely up to the attendees. Details about the facility and a sign-up registration list is available on the wiki. Please add your name if you think you might attend, so that we can have some estimate of who is coming. Also add to the wiki topics on which you are coming prepared to present, or that you would like to see. Often people can present on many topics but don't know what others are interested in. And a big thanks go out to Robin Friedrich and those in Houston for hosting us. Let's roll up our sleeves and help them out! Involvement is key to making an unconference successful. For those not familiar with unconferences, check out this description: http://en.wikipedia.org/wiki/Unconference See you all there... Jeff Rush Python Advocacy Coordinator P.S. Please repost this to other Texas Python organizations. -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ShowMeDo.com Announces Winner of Most-Video-Plays of the Month
ShowMeDo.com, a website offering over 361 instructional screencasts about topics both Python and non-Python, has announced their first winner of the month for the most-played video. And the winner is: Learn Django: Create a Wiki in 20 minutes by Siddharta Govindaraj, founder of Silver Stripe Software, with 1851 views in August, far outpacing the second-place entry. The prize is a £20 (UK) voucher to Amazon. Congratulations, Siddhi! You can watch it at: http://showmedo.com/videos/video?name=110fromSeriesID=110 Siddhi is also helping Doug Napoleone with PyCon this year, providing a program for generating attendee badges and working to integrate it into the Django-based conference site. You can find Siddhi at: http://siddhi.blogspot.com/ http://www.silverstripesoftware.com/ So who will win this month? It could be you! How about a screencast showcasing a different web framework like TurboGears or Twisted Web? Or something about databases, either relational or object. Jeff Rush Python Advocacy Coordinator -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Announcing a Bugfix update of YaMA, the meeting assistant
Hi, Yet Another Meeting Assistant (YaMA), will help you with the Agenda and Minutes of a Meeting. If you are the assigned minute taker at any meeting, this tool is for you. Checkout http://yama.sourceforge.net/ YaMA is written in Python and Tkinter, is open source software released under GPL, and is hosted by SourceForge (www.sourceforge.net) Whats New: 1. Usability enhancements 2. Minor Bug Fixes Thanks and Regards, -- Atul -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
ShowMeDo.com Announces Winner of Most-Video-Plays of the Month
ShowMeDo.com, a website offering over 361 instructional screencasts about topics both Python and non-Python, has announced their first winner of the month for the most-played video. And the winner is: Learn Django: Create a Wiki in 20 minutes by Siddharta Govindaraj, founder of Silver Stripe Software, with 1851 views in August, far outpacing the second-place entry. The prize is a £20 (UK) voucher to Amazon. Congratulations, Siddhi! You can watch it at: http://showmedo.com/videos/video?name=110fromSeriesID=110 Siddhi is also helping Doug Napoleone with PyCon this year, providing a program for generating attendee badges and working to integrate it into the Django-based conference site. You can find Siddhi at: http://siddhi.blogspot.com/ http://www.silverstripesoftware.com/ So who will win this month? It could be you! How about a screencast showcasing a different web framework like TurboGears or Twisted Web? Or something about databases, either relational or object. Jeff Rush Python Advocacy Coordinator -- -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Python-URL! - weekly Python news and links (Sep 3)
QOTW: If there were a protein that could only be folded by proving the Riemann Hypothesis, the gene that coded for it would quickly get weeded out of the gene pool. - Scott Aaaronson http://scottaaronson.com/blog/?p=266 We read Knuth so you don't have to. - Tim Peters The first Python 3000 release is out -- Python 3.0a1. Anouncement by Guido van Rossum: http://groups.google.com/group/comp.lang.python/browse_thread/thread/267a7b9f3619022b/d7ff1cf24fd44510 Download it: http://python.org/download/releases/3.0/ The first Python Unconference is under two weeks away: http://pycamp.python.org/Texas/ Using set operations instead of list.index(), why there is no list.find(), and the right way to pronounce troll. http://groups.google.com/group/comp.lang.python/browse_thread/thread/6edd7c3363cf2834/262d7a0affcba78e Analyzing a very slow Python code (loops, xrange and integer arithmetic only) http://groups.google.com/group/comp.lang.python/browse_thread/thread/94fade7f69fd9d6/5ab70849893ecfc2 Free memory, garbage collection, and the reuse of integer objects. http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b3f78fe88686940/fe19a8ccfcf6272d An old PEP on Programming by Contract revisited http://groups.google.com/group/comp.lang.python/browse_thread/thread/fecfac3549230a0b/67b8a02147e22143 Started about client/server applications, then people comment about their favorite architectures. http://groups.google.com/group/comp.lang.python/browse_thread/thread/273797276173ea97/b1e2d8f0ff7871e4 Using fcntl to syncronize file access by two processes http://groups.google.com/group/comp.lang.python/browse_thread/thread/c09abd7272f739ff/2b44e4382cd30a1b The difference between os.getenv/os.putenv and os.environ[] http://groups.google.com/group/comp.lang.python/browse_thread/thread/60a59bbf8207aeb0/4e9e51c84dc7a01f Python sort-of joins the 21st century of Web 2.0, and video, and ... well, the technical point is that Django's a solution liked by many: http://groups.google.com/group/comp.lang.python/msg/79e2137000b89417 Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiats: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among
Colorado Python training in October
Python author and trainer Mark Lutz will be teaching another 3-day Python class at a conference center in Longmont, Colorado, on October 23-25, 2007. This is a public training session open to individual enrollments, and covers the same topics as the 3-day onsite sessions that Mark teaches, with hands-on lab work. For more information on this class, please visit this web page: http://home.earthlink.net/~python-training/longmont-public-classes.htm Thanks for your interest. --Python Training Services -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations.html
Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers
Steven D'Aprano [EMAIL PROTECTED] writes: A big question mark in my mind is Lisp, which according to aficionados is just as dynamic as Python, but has native compilers that generate code running as fast as highly optimized C. I'm not qualified to judge whether the lessons learnt from Lisp can be applied to Python, but in any case Lisp is an old, old language -- only Fortran is older. The amount of development effort and money put into Lisp dwarfs that put into Python by possibly a hundred or more. Writing a simple Lisp compiler is not all that difficult. There's a chapter in SICP about how to do it, so it's sometimes part of introductory courses. To get C-like performance you end up having to rely on user-supplied type declarations and/or type inference, but even without that you can still do ok. I'd say Lisp is a less dynamic language than Python. Lisp doesn't have duck typing and doesn't represent class instance variables as dictionary elements that have to be looked up at runtime all the time. This maybe even applies to locals, e.g. in Python if you say x = 3 print hello y = x + 4 you're possibly not guaranteed that y=7, because you might have bound sys.stdout to something with a .write method that reaches up the call stack and messes with the caller's local variables, and if the langref manual says this is supposed to work, then the compiler has to do it like CPython. Maybe Python 4.0 will fix some of this stuff. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On Sun, 2007-09-02 at 17:21 -0700, llothar wrote: I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. What is the status about that for the future of python? The GIL is an implementation specific issue with CPython. It will not be removed in CPython for the forseeable future, but you can already get a GIL-free interpreter with Jython and IronPython. AFAIK there are plans to remove the GIL in PyPy. According to the last PyPy release announcement, they're running at about half the speed of CPython, and have a preliminary JIT that can translate certain integer operations into assembly, and will be expanded upon in future releases. If you're looking for a progressive alternative to CPython, I'd keep an eye on that project ;-) -- Evan Klitzke [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: advice about `correct' use of decorator
En Wed, 29 Aug 2007 07:32:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def f(*args, **kwargs): if global_state.the_user.is_logged_in: return func(*args, **kwargs) return show_login_page() return f I think there is a semantic problem, perhaps we are not talking about the same thing. I'm considering the software complexity AS PERCEIVED BY THE PROGRAMMER, looking at the interactions between a program and a programmer who is working on some task; some people would say cognitive complexity to make it clear. There is no semantic problem. You are just mistaken in your belief that the complexity that the user of the decorator has to deal with is different from the complexity in implementing the decorator. But they ARE different. That's the whole point of abstractions, code reuse, layered design... Designing a simple interfase on top of a complex system is very common. Nobody writes X-Window code, as nobody writes a raw event loop for Windows anymore: there are very good GUI toolkits, even portable frameworks, that put an abstract layer on top of that so the programmer has a much simple and coherent view. The complexity is behind the scenes. Which API is more complex: one in which you can play a movie with just a single call like PlayMovie(Title), or one on which you must call a zillion functions to firtly initialize the stream format, configure the display, disable undesired user interfase elements, locate the movie file, load it in chunks, etc.? The first one is certainly much simpler to use (simpler = less complex), and maybe internally it calls the same functions as the second one, but nobody cares. nobody cares is your guess. I'd bet that the caller of the PlayMovie function cares a lot: Is the movie played full screened? Which encodings are supported? Can you set the title of the movie window? Is streaming supported? Does it even work on windows? Which URI schemes does it support? And so on and so on. That is why no video decoding API:s have a PlayMovie(Title) function and why I haven't seen a single 3d engine with a MakeReallyCoolDoomCloneFPSGame() function. (yet!). What about urlopen? Using a single call one can be authenticated and retrieve any file in the other side of the planet. I consider it a simple interfase, altough it does complex things. Would you say it is better to use plain sockets everywhere? Or, since sockets are abstractions themselves, would you say it is better to use lower level primitives instead? Each time you descend a level, you have to use many simpler functions - but their combination is more complex. hiding details only works if the client programmer really doesn't care about the details. Why should he care? Isn't hiding implementation details a good design principle? When I use urlopen, I don't even care of the underlying socket implementation. I don't care which interfase the request is sent thru. I don't care if the answer got fragmented and some packets had to be reassembled. urlopen gives me something that looks like a file, and I just read() from it. Back to your example, the fact that a decorator builds a higher order function, does NOT make it more complex - because the programmer does not see that. In fact, hiding the details makes it simpler. Yes, the programmer does see that. The example decorator I posted requires about a zillion preconditions to work correctly and will fail in weird ways when those preconditions are not satisfied. The programmer is interested in the crazy failures he or she will experience. I dare you to try and implementing the code both as a decorator and as a function, then write the unit tests and documentation. The complexity of those three items together (implementation + tests + documentation) will be much higher for the decorator choice because the complexity of the decorator implementation is a bit higher than using a plain old function. Testing the decorator is as hard as testing any other function. Testing the decorated functions might involve *only* checking if the decorator is actually used for those functions. Going to your posted example, I don't see the difference - I should say, I don't see the advantage. Using a decorator hides some implementation details and reduces coupling between modules, both good things on my book; your function with no decorator does quite the opposite, and doesn't look like good coding style (on my book, of course). Note also that it is extremely rare to see well-documented or well-tested code, which means that the programmer WILL have to analyze the implementation which means that implementation complexity matters a lot. In any case, that would require testing and analyzing
Re: How does super() work?
En Fri, 31 Aug 2007 17:58:24 -0300, Lamonte Harris [EMAIL PROTECTED] escribi�: I've searched Google, and other search engines to try to find out how super() works. Can someone explain in short detail how super() works? I may and may not need to know this information, but it is good to know. See http://www.python.org/download/releases/2.2.3/descrintro/#cooperation -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On Sep 3, 2:21 am, llothar [EMAIL PROTECTED] wrote: I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. What is the status about that for the future of python? This is FAQ. You will find thousands of discussion on the net about that. My personal opinion (and I am not the only one in the Python community) is that if you want to scale the way to go is to use processes, not threads, so removing the GIL would be a waste of effort anyway. Look at the 'processing' module in PyPI. Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONPATH not working on Windows XP (?)
Hi, Any suggestions for adding my path to sys.path permanently? You can write a file in Lib/site-packages with a 'pth' extension (the name itself doesn't matter) containing the path you want to add. Example: MyCustomLib.pth: C:/docs/utils And be careful with path separator on win32. It should be / or \\, never \. Regards, Olivier -- http://mail.python.org/mailman/listinfo/python-list
Re: How does super() work?
En Fri, 31 Aug 2007 17:58:24 -0300, Lamonte Harris [EMAIL PROTECTED] escribi?: I've searched Google, and other search engines to try to find out how super() works. Can someone explain in short detail how super() works? I may and may not need to know this information, but it is good to know. You may also look at my ACCU lectures on advanced Python: http://www.phyast.pitt.edu/~micheles/oxford-lectures.zip -- http://mail.python.org/mailman/listinfo/python-list
Re: Ayuda
2007-08-30, Dr. José Contreras [EMAIL PROTECTED]: Gente Inteligente y Distinguida, soy un aficionado y apelo a Ustedes, para resolver éste problema. Para WebMaster de Google, me solicita instalar o ejecución de pitón, cómo comprenderán no dispongo de ningún guru de web, por lo que solicito en la medida de sus posibilidades me ayuden a ejecutar pitón para WebMaster, para ingresar a sitemap.xlm. Les saludo con distinguida consideración y respeto. José Si son tan amables, les agradeceré cualquiera sea la Repuesta, en Español o castellano. Gracias Entiendo que desea usar la herramienta Google Sitemap Generator para generar el fichero sitemap.xml.gz. De ser éste el caso, en el servidor donde se alberga el sitio web es necesario lo siguiente: 1.- Que haya instalada una versión adecuada de Python (mínimo: 2.2; recomendable: 2.3 ó posterior). No es necesario ningún módulo de integración con el programa que sirve las páginas web. 2.- Tener acceso por línea de comandos con permisos suficientes como para poder ejecutar Python y para ver la estructura de directorios que define el sitio web a indexar. Para ambos puntos, quien mejor puede indicarle las posibilidades es el personal del servicio de hospedaje y/o administradores del servidor web. Salud. -- Gonzalo HIGUERA DÍAZ [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
I was trying to motivate the idea by means of analogy. This is a legitimate thing to do. It helps lead people to a conceptual understanding long before they understand the minutae. You're mixing terms again. Analogy is saying 'something is like something else.' What you are saying is 'Something is used to represent something.' You also make a scalar - vector distinction which is neither here nor there and implies that complex numbers are vectors, as opposed to real numbers. Are you seriously saying that the imaginary unit is a small detail when explaining complex numbers? If you don't even mention the form 'a + bi' how can anyone make heads or tails of it? You omit many logical steps in what you think to be a simple explanation. In fact, a proper vector in physics has 4 features: point of application, magnitude, direction and sense. In case of a vector in two dimensions (a special case, which you also fail to stress not to mention that you were talking about space) the magnitude and sense can be described by one number and the direction as another. Since a complex number is composed of two numbers it can be used to describe those features of a vector. Numbers are commonly used to represent breast sizes. This doesn't mean numbers are breasts, alas. If someone asks you what numbers are and you say only that they are used to denote breasts sizes, you might create the wrong impression. I just didn't think that was the best place to start explicating the *concept*. I find concrete examples that then can lead to theoretical underpinnings a better way to go than the reverse. 1. Actual answer to the question can hardly be regarded as 'theoretical underpinnings' 2. You don't mention that answer at all. 3. Your 'concrete example' is equally sloppy and full of omissions. It is so hard to grasp that learning happens in layers, and that each layer need not be complete or even precise? Is it so hard to grasp that you completely omit certain important layers? Evidently you've either never taught (or were very bad at it). You have to motivate concept and interest before you can get to the precise detail. If someone asks a question their interest is evident, I think. I also reckon they expect a simple answer which in this case is either a link or something along the lines: 'As you know, square roots of negative numbers aren't real numbers. We are taught at school that they don't exist. However, if we denote square root of -1 as i we can represent any such root as a product of a real number and i. Eg. sqrt(-9) = sqrt(9 * -1) = 3 * i sqrt(-0.25) = sqrt(0.25 * -1) = 0.5i etc. Since sqrt(-1) has little representation in the surrounding world (saying I have 2i apples makes no sense) it's called the imaginary unit. Now, complex numbers are numbers of the form a + bi where a and b are real numbers. They have been invented because they have many applications in mathematics, physics, engineering etc. They have many useful properties, perhaps most important of which being that i2 = -1. Explanation of complex plane as an example of application Note that real numbers are a subset of complex numbers. They are complex numbers with imaginary part equal to 0. Also, since i also means current in physics and electrical engineering, the imaginary unit is denoted as j in those contexts. This is also the case in Python (presumably because i is a common name for an integer variable). Speaking of which, they are a built-in type in Py. Try performing operations on them in the interactive mode: c = 4 + 1j d = 1 + 2j c + d (5+5j) c = 1j # 1 is necessary because 'j' is a legit name for a variable c * c (-1+0j)' And no, I've never taught professionally. Have you? For instance, you start with Newtonian physics, not quantum physics. The entry level physics classes ignore things like the the non-linear behavior of springs, or the effects when you don't actually do things in a vacuum. By your definition these lectures would be wrong .. but they're not. They are attempting to introduce a topic painlessly. And that's what I was doing. That's not what you were doing. You were doing the equivalent of 'Hello, today we shall discuss gravity. I have 23 apples here, and I will throw them at 45 degrees - let's denote this by a vector. I throw them. Oh look, they fell! Well, that's gravity. Thank you for your attention.' does it come from, why is it 'imaginary' etc. Since we're being arses here I'd hazard a guess you were educated in the USA where doing without understanding has been mastered by teachers and students alike. You're I was initially educated in Europe where being rude was sometimes encouraged to mask insecurity with a false sense of self-importance. I was later educated in both Canada and the US wherein I learned both they why and the how I'm sorry I made a generalisation from a tendency that I encountered. I shouldn't have done that. But
Re: how can I find out the process ids with a process name
cd /proc for i in ls [0-9]*/status do echo $i `grep '^Name' $i | cut -f2` | sed 's/\/status//g' done Um... cd /proc for i in `ls [0-9]*/status` do echo $i `grep '^Name' $i | cut -f2` | sed 's/\/status//g' done --- Let the wookie win. -- http://mail.python.org/mailman/listinfo/python-list
Re: PYTHONPATH not working on Windows XP (?)
Thanks! It worked straightforward, and it's easier than messing with the enviromental variables or the registry. BTW, I'm still wondering how did Autohotkey got included in sys.path (there are no other .pht files on my PC) Regards, Sergio On 9/3/07, olivier [EMAIL PROTECTED] wrote: Hi, Any suggestions for adding my path to sys.path permanently? You can write a file in Lib/site-packages with a 'pth' extension (the name itself doesn't matter) containing the path you want to add. Example: MyCustomLib.pth: C:/docs/utils And be careful with path separator on win32. It should be / or \\, never \. Regards, Olivier -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Soemthing wrong w/ urllib module or something.
Lamonte Harris wrote: Error Message in cmd: Traceback (most recent call last): File wniamp_lastest5_playlist.py, line 25, in module response = urllib2.urlopen(request) File C:\Python25\lib\urllib2.py, line 121, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 374, in open response = self._open(req, data) File C:\Python25\lib\urllib2.py, line 392, in _open '_open', req) File C:\Python25\lib\urllib2.py, line 353, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 1100, in http_open return self.do_open(httplib.HTTPConnection, req) File C:\Python25\lib\urllib2.py, line 1075, in do_open raise URLError(err) urllib2.URLError: urlopen error (10053, 'Software caused connection abort') For some reason its not acting right when trying to run. I get that error message and I never seen anything like it. My experience is that that error message represents the local firewall or virus scanner blocking your network activity. That said, it doesn't seem likely that your firewall is blocking activity on port 80 without your having noticed! Maybe the domain you're posting to is selectively blacklisted by your local firewall? To do the obvious, can you open a socket connection to the domain you're using? code from socket import socket socket ().connect ((DOMAINHERE, 80)) /code or does it give you the same error? TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Grzegorz Słodkowicz wrote: You're mixing terms again. Analogy is saying 'something is like something else.' Actually, that's a simile. -- http://mail.python.org/mailman/listinfo/python-list
TypeError: 'module object is not callable'
Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I have a Step.py class: class Step(object) def __init__(self, sName): Initialise a new Step instance self.sName = sName self.depSteps = [] self.remDepSteps = [] self.isCompleted = 0 Then I have created a new file within the same directory called main.py: import Step a = Step(magn) The following however generates the error Traceback (most recent call last): File main.py, line 3, in ? a = Step(magn) TypeError: 'module' object is not callable If anyone could help point me in the right direction, how to fix this problem it would be much appreciated. Chris -- http://mail.python.org/mailman/listinfo/python-list
ShowMeDo.com Announces Winner of Most-Video-Plays of the Month
ShowMeDo.com, a website offering over 361 instructional screencasts about topics both Python and non-Python, has announced their first winner of the month for the most-played video. And the winner is: Learn Django: Create a Wiki in 20 minutes by Siddharta Govindaraj, founder of Silver Stripe Software, with 1851 views in August, far outpacing the second-place entry. The prize is a £20 (UK) voucher to Amazon. Congratulations, Siddhi! You can watch it at: http://showmedo.com/videos/video?name=110fromSeriesID=110 Siddhi is also helping Doug Napoleone with PyCon this year, providing a program for generating attendee badges and working to integrate it into the Django-based conference site. You can find Siddhi at: http://siddhi.blogspot.com/ http://www.silverstripesoftware.com/ So who will win this month? It could be you! How about a screencast showcasing a different web framework like TurboGears or Twisted Web? Or something about databases, either relational or object. Jeff Rush Python Advocacy Coordinator -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
On 9/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I have a Step.py class: class Step(object) def __init__(self, sName): Initialise a new Step instance self.sName = sName self.depSteps = [] self.remDepSteps = [] self.isCompleted = 0 Then I have created a new file within the same directory called main.py: import Step a = Step(magn) The following however generates the error Traceback (most recent call last): File main.py, line 3, in ? a = Step(magn) TypeError: 'module' object is not callable If anyone could help point me in the right direction, how to fix this problem it would be much appreciated. Chris The exception is being raised as you are being confused about the names ie: you have a class named Step in a module named Step.py . And by importing the module the only Step python sees is the module not the names declared within the module. To access a name defined in the module you can do : example1: import Step a = Step.Step(magn) # It refers the name Step defined IN the module Step example 2: from Step import Step # You directly import the class ( and make the name visible in your name space) a = Step(magn) Also have a look at: http://effbot.org/zone/import-confusion.htm http://docs.python.org/ref/import.html Cheers, -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
On Sep 3, 9:15 am, Michele Simionato [EMAIL PROTECTED] wrote: On Sep 3, 2:21 am, llothar [EMAIL PROTECTED] wrote: My personal opinion (and I am not the only one in the Python community) is that if you want to scale the way to go is to use processes, not threads, so removing the GIL would be a waste of effort anyway. Look at the 'processing' module in PyPI. Michele Simionato I second that. You may also look here, http://www.parallelpython.com/ I tested it and work as expected. You can see all your processing- cores work nicely and balanced. -- http://mail.python.org/mailman/listinfo/python-list
Re: ShowMeDo.com Announces Winner of Most-Video-Plays of the Month
Jeff Rush wrote: ShowMeDo.com, a website offering over 361 instructional screencasts about topics both Python and non-Python, has announced their first winner of the month for the most-played video. And the winner is: Learn Django: Create a Wiki in 20 minutes by Siddharta Govindaraj, founder of Silver Stripe Software, with 1851 views in August, far outpacing the second-place entry. The prize is a £20 (UK) voucher to Amazon. Congratulations, Siddhi! You can watch it at: http://showmedo.com/videos/video?name=110fromSeriesID=110 Siddhi is also helping Doug Napoleone with PyCon this year, providing a program for generating attendee badges and working to integrate it into the Django-based conference site. You can find Siddhi at: http://siddhi.blogspot.com/ http://www.silverstripesoftware.com/ So who will win this month? It could be you! How about a screencast showcasing a different web framework like TurboGears or Twisted Web? Or something about databases, either relational or object. Great work. I just have one small remark: given the increasing amount of spam in the NG/ML that reads go bla.com to learn everything about ..., I was at first convinced that your post was one amongst these. Maybe a subject line that shows somewhat more python context would be a good idea? Just a suggestion. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
On Sep 3, 10:48 am, [EMAIL PROTECTED] wrote: Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I have a Step.py class: class Step(object) def __init__(self, sName): Initialise a new Step instance self.sName = sName self.depSteps = [] self.remDepSteps = [] self.isCompleted = 0 Then I have created a new file within the same directory called main.py: import Step a = Step(magn) The following however generates the error Traceback (most recent call last): File main.py, line 3, in ? a = Step(magn) TypeError: 'module' object is not callable This is because when you issue import Step you're actually importing the Step _module_, not the Step class inside the module. You can do this in at least two ways: -- import Step a = Step.Step(magn) # access the Step class inside Step module -- or -- from Step import Step # insert in the current namespace the Step class a = Step(magn) -- If anyone could help point me in the right direction, how to fix this problem it would be much appreciated. Chris HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] wrote: Hi I am new to Python and have recieved this error message when trying to instantiate an object from a class from another file within the same directory and wondered what I have done wrong. I have a Step.py class: class Step(object) def __init__(self, sName): Initialise a new Step instance self.sName = sName self.depSteps = [] self.remDepSteps = [] self.isCompleted = 0 Then I have created a new file within the same directory called main.py: import Step a = Step(magn) The following however generates the error Traceback (most recent call last): File main.py, line 3, in ? a = Step(magn) TypeError: 'module' object is not callable If anyone could help point me in the right direction, how to fix this problem it would be much appreciated. Do you by any chance come from a java-background? Your actual problem is simply solved by this: import Step Step.Step(magn) That's because Step.py is a module, and _not_ the class - there is no file-class-correspondence as it is in e.g. Java. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Weird gcc errors while installing MySQL-python module
Jonas Schneider wrote: Hi guys, I´m experiencing weird error messages while installing MySQL-python with easy_install... I have no idea where the errors come from. Read the whole output at http://pastebin.com/m3859cf40 It´s really a lot... Someone got ideas? The pastebin errormessage didn't work for me, on two different machines actually. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
Amit Khemka a écrit : (snip) The exception is being raised as you are being confused about the names ie: you have a class named Step in a module named Step.py . nitpicking Actually, the module is named 'Step', not 'Setp.py' !-) /nitpicking -- http://mail.python.org/mailman/listinfo/python-list
The Texas Python Unconference is Almost Here!
The first regional Python unconference is coming to Houston on September 15-16 (Sat-Sun). Being held at the Texas Learning Computing Center on the University of Houston main campus, this is a FREE event for Pythoneers from all over the Texas region. http://pycamp.python.org/Texas/ And being an unconference, participation by those who attend is welcome and greatly sought. The topics to be presented are purely up to the attendees. Details about the facility and a sign-up registration list is available on the wiki. Please add your name if you think you might attend, so that we can have some estimate of who is coming. Also add to the wiki topics on which you are coming prepared to present, or that you would like to see. Often people can present on many topics but don't know what others are interested in. And a big thanks go out to Robin Friedrich and those in Houston for hosting us. Let's roll up our sleeves and help them out! Involvement is key to making an unconference successful. For those not familiar with unconferences, check out this description: http://en.wikipedia.org/wiki/Unconference See you all there... Jeff Rush Python Advocacy Coordinator P.S. Please repost this to other Texas Python organizations. -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
On 9/3/07, Bruno Desthuilliers [EMAIL PROTECTED] wrote: Amit Khemka a écrit : (snip) The exception is being raised as you are being confused about the names ie: you have a class named Step in a module named Step.py . nitpicking Actually, the module is named 'Step', not 'Setp.py' !-) /nitpicking humble-acknowledgment Yup, My Bad ! Thanks. /humble-acknowledgment -- Amit Khemka website: www.onyomo.com wap-site: www.owap.in -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding attributes stored in a list to a class dynamically.
Brian Munroe a écrit : On Sep 2, 3:33 pm, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: In a nutshell, like all double-underscore methods, __setattr__ are for overriding behaviour in your own classes. With very few exceptions, you shouldn't need to directly call double-underscore methods (although you often may _write_ double-underscore methods). I think I understand. You are saying that if I wanted to override the normal behavior when doing something like p1.firstName = Brian then I'd override __setattr__()? That's one possible solution. Another one is to use a property object or a custom descriptor (you should find relevant documentation on python.org). But if I am doing something like creating dynamic attributes, the more 'correct' way is to use setattr? Even though they both appear to do the same thing, the more Pythonic way is to never directly call magic methods (if you can help it)? Mainly, yes. -- http://mail.python.org/mailman/listinfo/python-list
SOAP : ZSI error
hello i need some help with ZSI module i want to use the web service located here www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch the wsdl file : http://www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/wsdl/IDutch that web service is very simple , the function NumToStr converts numbers to dutch words (description http://www.xmethods.net/ve2/ViewListing.po?key=uuid:01EF9AE1-6DD3-7317-AFA5-05A8A52FCD56) i have generated IDutchservice_services with wsdl2py here is my code : import IDutchservice_services soap = IDutchservice_services.IDutchbindingSOAP(www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch) ok = IDutchservice_services.NumToStr0Request() ok.Num=5 print soap.NumToStr(ok) that prints an error RuntimeError: must specify transport or url startswith https/http what's wrong in my script ? thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
Michele Simionato [EMAIL PROTECTED] writes: On Sep 3, 2:21 am, llothar [EMAIL PROTECTED] wrote: I'm afraid that the GIL is killing the usefullness of python for some types of applications now where 4,8 oder 64 threads on a chip are here or comming soon. This is FAQ. You will find thousands of discussion on the net about that. My personal opinion (and I am not the only one in the Python community) is that if you want to scale the way to go is to use processes, not threads, so removing the GIL would be a waste of effort anyway. Yes. Processes are cheap on well-designed operating systems, and using processes to subdivide your processor usage encourages simple, modular interfaces between parts of a program. Threads, while also cheap, are much more difficult and fiddly to program correctly, hence are rarely an overall win. One common response to that is Processes are expensive on Win32. My response to that is that if you're programming on Win32 and expecting the application to scale well, you already have problems that must first be addressed that are far more fundamental than the GIL. -- \Pinky, are you pondering what I'm pondering? Umm, I think | `\ so, Brain, but three men in a tub? Ooh, that's unsanitary! -- | _o__)_Pinky and The Brain_ | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
I was wondering (and maybe i still do) about this GIL problem. I am relatively new to Python (less than a year) and when i started to think about it i said: Oh, this IS a problem. But when i dig a little more, i found that Ah, maybe it isn't. I strongly believe that the best usage of multiple cores processor will be achieved if programming languages are modified to support this on their hearts. Code blocks that would be identified by the compiler and run in parallel and such things. Laboratories are working on these stuff but i do not expect something in the very-near future. So, as i mentioned above, there are solutions for that right now (parallel python and others) that enabled us with little effort to spawn a new python interpreter, thus allowing the OS to schedule it on a different core and do the job this way relatively cheap. I wouldn't recommend going to IronPython despite the fact that the CLR better utilize MP. The reason for this is that i would NEVER give up the freedom that CPython gives me by exchange better usage of the MP and platform lock-in. -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Python 3.0 remove the global interpreter lock (GIL)
I was wondering (and maybe i still do) about this GIL problem. I am relatively new to Python (less than a year) and when i started to think about it i said: Oh, this IS a problem. But when i dig a little more, i found that Ah, maybe it isn't. I strongly believe that the best usage of multiple cores processor will be achieved if programming languages are modified to support this on their hearts. Code blocks that would be identified by the compiler and run in parallel and such things. Laboratories are working on these stuff but i do not expect something in the very-near future. So, as i mentioned above, there are solutions for that right now (parallel python and others) that enabled us with little effort to spawn a new python interpreter, thus allowing the OS to schedule it on a different core and do the job this way relatively cheap. I wouldn't recommend going to IronPython despite the fact that the CLR better utilize MP. The reason for this is that i would NEVER give up the freedom that CPython gives me by exchange better usage of the MP and platform lock-in. -- http://mail.python.org/mailman/listinfo/python-list
Re: advice about `correct' use of decorator
Gabriel Genellina wrote: En Wed, 29 Aug 2007 07:32:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: On 8/24/07, Gabriel Genellina [EMAIL PROTECTED] wrote: En Thu, 23 Aug 2007 09:20:21 -0300, BJörn Lindqvist [EMAIL PROTECTED] escribi�: def check_user_logged_in(func): def f(*args, **kwargs): if global_state.the_user.is_logged_in: return func(*args, **kwargs) return show_login_page() return f I think there is a semantic problem, perhaps we are not talking about the same thing. I'm considering the software complexity AS PERCEIVED BY THE PROGRAMMER, looking at the interactions between a program and a programmer who is working on some task; some people would say cognitive complexity to make it clear. There is no semantic problem. You are just mistaken in your belief that the complexity that the user of the decorator has to deal with is different from the complexity in implementing the decorator. But they ARE different. That's the whole point of abstractions, code reuse, layered design... Designing a simple interfase on top of a complex system is very common. Nobody writes X-Window code, as nobody writes a raw event loop for Windows anymore: there are very good GUI toolkits, even portable frameworks, that put an abstract layer on top of that so the programmer has a much simple and coherent view. The complexity is behind the scenes. Which API is more complex: one in which you can play a movie with just a single call like PlayMovie(Title), or one on which you must call a zillion functions to firtly initialize the stream format, configure the display, disable undesired user interfase elements, locate the movie file, load it in chunks, etc.? The first one is certainly much simpler to use (simpler = less complex), and maybe internally it calls the same functions as the second one, but nobody cares. nobody cares is your guess. I'd bet that the caller of the PlayMovie function cares a lot: Is the movie played full screened? Which encodings are supported? Can you set the title of the movie window? Is streaming supported? Does it even work on windows? Which URI schemes does it support? And so on and so on. That is why no video decoding API:s have a PlayMovie(Title) function and why I haven't seen a single 3d engine with a MakeReallyCoolDoomCloneFPSGame() function. (yet!). What about urlopen? Using a single call one can be authenticated and retrieve any file in the other side of the planet. I consider it a simple interfase, altough it does complex things. Would you say it is better to use plain sockets everywhere? Or, since sockets are abstractions themselves, would you say it is better to use lower level primitives instead? Each time you descend a level, you have to use many simpler functions - but their combination is more complex. hiding details only works if the client programmer really doesn't care about the details. Why should he care? Isn't hiding implementation details a good design principle? When I use urlopen, I don't even care of the underlying socket implementation. I don't care which interfase the request is sent thru. I don't care if the answer got fragmented and some packets had to be reassembled. urlopen gives me something that looks like a file, and I just read() from it. Back to your example, the fact that a decorator builds a higher order function, does NOT make it more complex - because the programmer does not see that. In fact, hiding the details makes it simpler. Yes, the programmer does see that. The example decorator I posted requires about a zillion preconditions to work correctly and will fail in weird ways when those preconditions are not satisfied. The programmer is interested in the crazy failures he or she will experience. I dare you to try and implementing the code both as a decorator and as a function, then write the unit tests and documentation. The complexity of those three items together (implementation + tests + documentation) will be much higher for the decorator choice because the complexity of the decorator implementation is a bit higher than using a plain old function. Testing the decorator is as hard as testing any other function. Testing the decorated functions might involve *only* checking if the decorator is actually used for those functions. Going to your posted example, I don't see the difference - I should say, I don't see the advantage. Using a decorator hides some implementation details and reduces coupling between modules, both good things on my book; your function with no decorator does quite the opposite, and doesn't look like good coding style (on my book, of course). Note also that it is extremely rare to see well-documented or well-tested code, which means that the programmer WILL have to analyze the implementation which means that implementation complexity matters a lot.
Re: Will Python 3.0 remove the global interpreter lock (GIL)
I was wondering (and maybe i still do) about this GIL problem. I am relatively new to Python (less than a year) and when i started to think about it i said: Oh, this IS a problem. But when i dig a little more, i found that Ah, maybe it isn't. I strongly believe that the best usage of multiple cores processor will be achieved if programming languages are modified to support this on their hearts. Code blocks that would be identified by the compiler and run in parallel and such things. Laboratories are working on these stuff but i do not expect something in the very-near future. So, as i mentioned above, there are solutions for that right now (parallel python and others) that enabled us with little effort to spawn a new python interpreter, thus allowing the OS to schedule it on a different core and do the job this way relatively cheap. I wouldn't recommend going to IronPython despite the fact that the CLR better utilize MP. The reason for this is that i would NEVER give up the freedom that CPython gives me by exchange better usage of the MP and platform lock-in. -- http://mail.python.org/mailman/listinfo/python-list
Re: metaclasses: timestamping instances
Hi, But why does it show varied difference in the time between a and b instance creations when __metaclass__ hook is used and when not used in class Y ? I dont understand that point ! KM On 9/1/07, Michele Simionato [EMAIL PROTECTED] wrote: On Sep 1, 6:07 pm, Steve Holden [EMAIL PROTECTED] wrote: snip Debugging with Wing IDE and examining the classes at a breakpoint shows this to be true (even after Y's __metaclass__ assignment is commented out): X.__metaclass__ class '__main__.Meta' Y.__metaclass__ class '__main__.Meta' For the benefit of the readers I will just point out that in order to determine the metaclass of a class it is far better NOT to relay on the __metaclass__ attribute. The right thing to to is to look at the __class__ attribute, or to use type. Here is a (made up) example where .__metaclass__ gives the wrong result: In [9]: class M(type): pass ...: In [10]: class B: __metaclass__ = M : In [11]: B.__metaclass__ = None # now the hook is set to None, but the metaclass does not change In [12]: B.__class__ Out[12]: class '__main__.M' Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Does shuffle() produce uniform result ?
On 2007-08-26, tooru honda [EMAIL PROTECTED] wrote: By incorporating Alex's code, I got another performance boost of 20%. It is mostly due to Alex's more efficient implementation of block random than my own version. If I understand correctly that you are using urandom as a random generator I wouldn't trust too much on this performance. Urandom uses the systemwide entropy-pool. If other programs need this pool too, your performance can drop spectaculary. If you are using a linux machine just try to execute od -x /dev/random at the same time as your program. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
Thank you for your help that seems to have done the trick. You are correct Diez B. Roggisch that I come from a java background! I have a new tiny problem I can't understand either. Withing Step.py I have the following method def isCompleted(self): Check whether data step has been processed return self.isCompleted Then within main.py I simply wish to print the value of isCompleted which I try to do by the following print 'Magn completed status is',a.isCompleted() Which returns the following error: a.isCompleted() TypeError: 'int' object is not callable I have tried ideas such as int(a.isCompleted) but to no prevail. Any ideas? Regards Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Grzegorz Słodkowicz wrote: In fact, a proper vector in physics has 4 features: point of application, magnitude, direction and sense. OK, help me out here: What 'direction' does |Ψ (a state-vector in quantum mechanics) have? Also, doesn't sense directly follow from the point of application. How about we quit being wiseasses right now. The wikipedia-article is good enough, so what's the point? /W -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] wrote: Thank you for your help that seems to have done the trick. You are correct Diez B. Roggisch that I come from a java background! I have a new tiny problem I can't understand either. Withing Step.py I have the following method def isCompleted(self): Check whether data step has been processed return self.isCompleted Then within main.py I simply wish to print the value of isCompleted which I try to do by the following print 'Magn completed status is',a.isCompleted() Which returns the following error: a.isCompleted() TypeError: 'int' object is not callable I have tried ideas such as int(a.isCompleted) but to no prevail. Any ideas? Without more code, not really. It seems as if a is an integer, and not an instance of Step. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] a écrit : Thank you for your help that seems to have done the trick. You are correct Diez B. Roggisch that I come from a java background! I have a new tiny problem I can't understand either. Withing Step.py I have the following method def isCompleted(self): Check whether data step has been processed return self.isCompleted Java background, indeed !-) In Python, everything (including functions, methods, modules, classes etc) is an object, and methods are just attributes like every others - ie, there's no separate namespaces for methods. So when you set an instance attribute 'isCompleted', it shadows the class attribute by the same name. The obvious solution is to give attributes different names. The perhaps less obvious but much more pythonic solution is to get get rid of the getter if all it does is returning the attribute. I know this sounds strange when coming from Java, but there's no problem doing so - Python has support for computed attributes (aka properties), so you can always replace a plain attribute by a computed one latter if you need to do so, this won't impact the client code. HTH -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] wrote: Thank you for your help that seems to have done the trick. You are correct Diez B. Roggisch that I come from a java background! I have a new tiny problem I can't understand either. Withing Step.py I have the following method def isCompleted(self): Check whether data step has been processed return self.isCompleted Java, ey? ;) Why do you write a method that jut returns a variable anyway? Forget that. Python doesn't need getters and setters. Then within main.py I simply wish to print the value of isCompleted which I try to do by the following print 'Magn completed status is',a.isCompleted() Which returns the following error: a.isCompleted() TypeError: 'int' object is not callable That is (I think) because you have two things called isCompleted in your class: The variable of type int (which BTW had better been of type bool) and the method. As I said, just scrap the method. In Python it's perfectly OK to expose variables in the API. If you still want getters and setters, use look into properties. /W -- http://mail.python.org/mailman/listinfo/python-list
Urgently Required SAP CO-COPA Functional Lead
We urgently require following skill set for singapore client SAP CO-COPA Functional Lead: Person with a strong Costing background. Should have hands on SAP COPA experience Minimum two implementations in Controling based Profitability Analysis (COPA) and Product Costing (COPC) in the SAP COPA skill set. Project Asset and Project costing Must have 5+ years of SAP experience Should be capable of handling Blueprinting and be a good Communicator. O Base location: Al Khobar, KSA ( near Dhaharan) As the spec suggest, we are looking at predominantly a Costing person. He should have at least 2 implementation experience on costing preferably Project Asset, + Profitability Analysis and Product costing. A muslim candidate would be ideal, but this is not mandatory. Pakistani / Indonesian and Malay apart from Indians will be a good bet. O Duration: 15 months O Rate: US$ 7500 per month (housing included) + medical insurance + Air travel Please feel free to refer your friends for same cv's to be send to [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: advice about `correct' use of decorator
Gerardo Herzig schrieb: @is_logued_in def change_pass(): bla bla And so on for all the other functions who needs that the user is still loged in. where obviosly the is_logued_in() function will determine if the dude is still loged in, and THEN execute change_pass(). If the dude is not loged in, change_pass() is NOT executed at all. Instead, it will be redirected to the `login' screen. Something in my mind tells me that this is not the pythonic way...But i like the idea, so please tell me that im in the right way :) That's how turbogears does it. See: http://docs.turbogears.org/1.0/UsingIdentity?highlight=%28identity%29 Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
On 9/3/07, Wildemar Wildenburger [EMAIL PROTECTED] wrote: Grzegorz Słodkowicz wrote: In fact, a proper vector in physics has 4 features: point of application, magnitude, direction and sense. OK, help me out here: What 'direction' does |Ψ (a state-vector in quantum mechanics) have? Also, doesn't sense directly follow from the point of application. For instance, you can apply a force to a point and it can be outward or inward. The direction of a state vector is completely specified by its decomposition (given finite norm and completeness of the basis), just like ordinary vectors. But since actually in quantum mechanics you are dealing with unit rays and everything is defined up to a phase (which could be relevant given the topic of this thread!)... I'd say that kets are not the most recommendable way to introduce the concept of vector, or of complex variables :-) francesco -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
On Sep 2, 6:13 am, Grzegorz S odkowicz [EMAIL PROTECTED] wrote: In fact, a proper vector in physics has 4 features: point of application, magnitude, direction and sense. so whats the point of application of the sum of two vectors? Do tell. -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] wrote: Thank you for your help that seems to have done the trick. You are correct Diez B. Roggisch that I come from a java background! I have a new tiny problem I can't understand either. Withing Step.py I have the following method def isCompleted(self): Check whether data step has been processed return self.isCompleted Then within main.py I simply wish to print the value of isCompleted which I try to do by the following print 'Magn completed status is',a.isCompleted() Which returns the following error: a.isCompleted() TypeError: 'int' object is not callable I have tried ideas such as int(a.isCompleted) but to no prevail. Any ideas? The others spottet the error I missed. But I can offer something else: http://dirtsimple.org/2004/12/python-is-not-java.html It's a worthy read for someone coming from Java, needing time to adjust. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: How does super() work?
Lamonte Harris wrote: I've searched Google, and other search engines to try to find out how super() works. Can someone explain in short detail how super() works? I may and may not need to know this information, but it is good to know. There is at least one explanation in the python.org site, among other topics related to super() usage: http://www.python.org/download/releases/2.2.3/descrintro/#cooperation Cheers, Gerardo -- http://mail.python.org/mailman/listinfo/python-list
400 Bad Request calling urllib2.urlopen()
Hi, I have an url which redirects the client to another url. If I paste the url into a browser, it works fine. If I open it via urllib2.urlopen() I get the following error: Traceback (most recent call last): File ...\crawlRawDocuments.py, line 16, in module body = urlopen(url).read() File C:\Python25\lib\urllib2.py, line 121, in urlopen return _opener.open(url, data) File C:\Python25\lib\urllib2.py, line 380, in open response = meth(req, response) File C:\Python25\lib\urllib2.py, line 491, in http_response 'http', request, response, code, msg, hdrs) File C:\Python25\lib\urllib2.py, line 412, in error result = self._call_chain(*args) File C:\Python25\lib\urllib2.py, line 353, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 575, in http_error_302 return self.parent.open(new) File C:\Python25\lib\urllib2.py, line 380, in open response = meth(req, response) File C:\Python25\lib\urllib2.py, line 491, in http_response 'http', request, response, code, msg, hdrs) File C:\Python25\lib\urllib2.py, line 418, in error return self._call_chain(*args) File C:\Python25\lib\urllib2.py, line 353, in _call_chain result = func(*args) File C:\Python25\lib\urllib2.py, line 499, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request I'm using Python 2.5.1 and Google did not help. Any hint on how to fix or debug this problem? regards, Achim -- http://mail.python.org/mailman/listinfo/python-list
Re: Soemthing wrong w/ urllib module or something.
[Tim Golden] To do the obvious, can you open a socket connection to the domain you're using? code from socket import socket socket ().connect ((DOMAINHERE, 80)) /code or does it give you the same error? [Lamonte Harris] Yeah I basically got the same error. Traceback (most recent call last): File stdin, line 1, in module File string, line 1, in connect socket.error: (10053, 'Software caused connection abort') OK, then *something's* blocking access to that host (at least) on port 80. Can you browse the web normally from this machine? In particular, can you browse to that site (DOMAINHERE)? TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers
Thanks for all the answers to my question. I think what I need to take away from this is that xrange is an object - I thought it was just some loop construct, and that maths is slow in python - so avoid pathological looping.I remember the first time I tried Objective-C on OS X I used the NSNumber class for arithmetic - the results that time were pretty awful too! -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I wait for all the threads I spawn for 5 minutes
On 2007-08-31, herman [EMAIL PROTECTED] wrote: Hi, In my python program, I would to like to spwan 5 threads, for the them for 5 minutes maximum and the continue. Here is my script: threads = [] for j in range(5): t = MyThread() threads.append(t) for t in threads: t.join(60*5) print thread join\n # wait for 5 minutes for all the threads to complete , and # then continue But this code ends up waiting 5 minutes for **each** thread. that is not what I want. I just want to wait for 5 minutes for all threads. how can I do that? And after 5 minutes, i want to kill off all the threads I spawn earlier, how can I do that in python. You may wish to look at this. No guarantee though. http://groups.google.com/group/comp.lang.python/browse_thread/thread/2002d29c965534cc/5833130893cee567?lnk=stq=rnum=2hl=nl#5833130893cee567 -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers
On 3 Sep, 15:39, [EMAIL PROTECTED] wrote: Thanks for all the answers to my question. I think what I need to take away from this is that xrange is an object Indeed, but using xrange can be faster than converting your for loops to while loops plus a counter; I converted your code to use the latter arrangement and it was noticeably slower. Perhaps the repeated invocation of each xrange object's next method is less expensive than repeatedly obtaining new incremented int objects and testing them against other int objects. - I thought it was just some loop construct, and that maths is slow in python - so avoid pathological looping. You'd be wise to avoid doing unnecessary work deep within nested loops in any programming language. Sadly, it's not possible for the compiler to work out that some calculations can be lifted out of the innermost loops in Python, since the various guarantees that make such operations possible in other languages are not offered by Python. I remember the first time I tried Objective-C on OS X I used the NSNumber class for arithmetic - the results that time were pretty awful too! Obviously, it'd be a fairer test if you used comparable numeric types in both implementations, but a more capable numeric type would be overkill for the C implementation of this program, and a less capable numeric type doesn't exist for Python unless you're willing to use a dialect such as Pyrex (as others have shown). Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers
Martin v. Löwis a écrit : (2) it is a interpretation language Not quite. It's compiled to byte-code - just like Java (would you call Java an 'interpreted language' ?) Python is not implemented like Java. In Java (at least in HotSpot), the byte code is further compiled to machine code before execution; This is a VM-specific feature. in Python, the byte code is interpreted. Idem. Whether this makes Python an interpreter or a compiler, I don't know. This is an old troll^Mdiscussion !-) Now IANAL, but AFAIK, the byte-code compilation stage can make a great difference performances-wide, and for a same language, a byte-compiled implementation is likely to be faster than a pure-interpreted one, at least because of the saving on parsing time (please someone correct me if I'm wrong) ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Automation and scheduling of FrontPage publishing using Python
On Sep 2, 4:22 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: On Sep 1, 10:48 pm, Jerry [EMAIL PROTECTED] wrote: andrew, I would try looking into Windows automation with Python.http://www.google.com/search?q=windows+automation+pythonshouldget you started. The winGuiAuto package may help you out as it is like have a human click and move throughout the interface. The only downside is that there is no recorder to help you build the script, so I would try to do as much in VBA as you can (does FrontPage even support VBA?) and then just write your python script to get through the program enough to execute the macro. Yes.. Front page can be run by VB macro but I really did not want to go down that road if it could be avoided. This looks very promising. I've installed the module and run a couple of the basic examples.. Very cool. After a bit of patience, I was able to get this to work. Still fine-tuning the process but the basic elements are there. What is interesting is that once I submitted the proof-of-concept code, management decided that they would like to see what other companies are doing for this requirement and weigh the pros/cons of this approach. -- http://mail.python.org/mailman/listinfo/python-list
Problem with extremely small real number
Hi, I need to calculate this probability P!/{n \choose p}, varying both n and p, n takes values in this range [512:1024] and p in [2:12]. So i write this code in python: def factorial(n): result=1 if n==0: return 1 for i in xrange(1, abs(n)+1): result = i*result if n = 0: return result else: return -result def binomial(n, k): assert n0 and isinstance(n, (int, long)) and isinstance(k, (int,long)) if k 0 or k n: return 0 if k == 0 or k == n: return 1 return factorial(n) // (factorial(k) * factorial(n-k)) I want to call factorial(2)//binomial(1024,2) for example, in this way trivially I obtain 0 as probability, how can I obtain the probability forcing this division to output extremely small real numbers I want to produce a program that provide a set of data of this probability on varying n and p, in order to plot a surface with this data set with gnuplot, any comments or suggestion? thanks in advance, Andrea -- http://mail.python.org/mailman/listinfo/python-list
Re: Adding attributes stored in a list to a class dynamically.
On Sep 3, 6:34 am, Steven D'Aprano [EMAIL PROTECTED] cybersource.com.au wrote: The underscore versions are for customizing the lookup process, not for dynamically looking up names. If your class needs to do something non- standard when you write obj.name, you might need to write methods __getattr__ etc. I absolutely understand that much. In a nutshell: getattr() etc. are for looking up attributes dynamically when you don't know the name of the attribute until runtime. __getattr__ etc. are for looking up attributes when you need to compute the value on the fly. (But an easier, less troublesome way of doing that is with properties.) If I think about this in the context of a property, which in my newbie mind gives you the ability to 'override' the standard behavior when getting, setting or I suppose deleting a specific attribute. I think I understand what you meant by 'compute the value on the fly', the keyword being *compute*? thanks for taking the time to explain this (over and over, heh!) -- brian -- http://mail.python.org/mailman/listinfo/python-list
How do I get triangles from a vtkPolyData object?
I posted this question to the vtk mailing list last week: I've been Googling and wandering through the class references most of the afternoon, but I can't figure out how to get the triangles out of the vtkPolyData that vtkDelaunay2D produces? I can get the vertex corredinates like this: delny = vtk.vtkDelaunay2D() delny.SetInput(profile) delny.SetTolerance(0.001) delny.Update() o = delny.GetOutput() vertexes = [o.GetPoint(i) for i in xrange(o.GetNumberOfPoints())] I can see that there are 84 triangles, and 'o' is a vtkPolyData object that has 84 cells and 84 polygons, so they obviously represent the triangles, but I can't figure out how to get something useful out of the cells or polys. I got multiple replies telling me that I need to make calls to o.GetNextCell(). The posters were even kind enough to include examples in C++ showing how to do a delaunay triangulation and retrieve the triangle info. However, the Python version of a vtkCellArray object (which is what's created as output from the Delaunay triangulation module) doesn't make the GetNextCell() (or GetCell()) method visible. It does have a GetNumberOfCells() object, and methods to set and insert cells, but how do I _get_ a cell? -- Grant Edwards grante Yow! .. I'll make you at an ASHTRAY!! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Looking for Delaunay triangulation module...
On 2007-09-02, Robert Kern [EMAIL PROTECTED] wrote: Can anybody point me to a Delaunay triangulation module (for Win32)? I'm currently using http://flub.stuffwillmade.org/delny/ under Linux, but I have been unable to find a build for Windows. I don't have the tools (or skills) to build libqhull and Pythion extensions on Win32). I've also found the delaunay module in scipy's sandbox. I could never get that module to work under Linux, and I can't build it for Windows anyway. I'm working on it today. I'm going to break it out into a separate package. If you can remember what problems you had, I'd like to fix them. I'm clearing up a number of (really dumb) memory leaks. I'm sorry I don't remember what the problems were. It was some time ago (probably 14-16 months) when I was trying to use the module. After spending a day or two on it, I switched to the Delny module (which I had used in the past). I do have Dlaunay triangulation working using VTK (which is included in Enthought Python), but I haven't been able to figure out how to extract the triangle list from the object containing the resulting triangulation. The object method that people on the VTK mailing list tell me to call isn't available in the Python binding. -- Grant Edwards grante Yow! .. does your DRESSING at ROOM have enough ASPARAGUS? visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with extremely small real number
Andrea wrote: Hi, I need to calculate this probability P!/{n \choose p}, varying both n and p, n takes values in this range [512:1024] and p in [2:12]. So i write this code in python: def factorial(n): result=1 if n==0: return 1 for i in xrange(1, abs(n)+1): result = i*result if n = 0: return result else: return -result def binomial(n, k): assert n0 and isinstance(n, (int, long)) and isinstance(k, (int,long)) if k 0 or k n: return 0 if k == 0 or k == n: return 1 return factorial(n) // (factorial(k) * factorial(n-k)) I want to call factorial(2)//binomial(1024,2) for example, in this way trivially I obtain 0 as probability, how can I obtain the probability forcing this division to output extremely small real numbers '//' is floor division. 2/523776 0 2//523776 0 float(2)/523776 3.8184261974584555e-006 from __future__ import division 2/523776 3.8184261974584555e-006 2//523776 0 Duncan -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with extremely small real number
Il Mon, 03 Sep 2007 07:56:10 -0700, Andrea ha scritto: [cut] I want to call factorial(2)//binomial(1024,2) for example, in this way trivially I obtain 0 as probability, how can I obtain the probability forcing this division to output extremely small real numbers int to float will help print float(factorial(2))/binomial(1024,2) bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with extremely small real number
On Sep 3, 3:56 pm, Andrea [EMAIL PROTECTED] wrote: Hi, I need to calculate this probability P!/{n \choose p}, varying both n and p, n takes values in this range [512:1024] and p in [2:12]. So i write this code in python: def factorial(n): result=1 if n==0: return 1 for i in xrange(1, abs(n)+1): result = i*result if n = 0: return result else: return -result def binomial(n, k): assert n0 and isinstance(n, (int, long)) and isinstance(k, (int,long)) if k 0 or k n: return 0 if k == 0 or k == n: return 1 return factorial(n) // (factorial(k) * factorial(n-k)) I want to call factorial(2)//binomial(1024,2) for example, in this way trivially I obtain 0 as probability, how can I obtain the probability forcing this division to output extremely small real numbers I want to produce a program that provide a set of data of this probability on varying n and p, in order to plot a surface with this data set with gnuplot, any comments or suggestion? thanks in advance, Andrea You're using integer division, that's why you probabilities are 0! In python (up to 2.5 at list), if one integer/long is divided by another, integer division is used. But if one of the operands is a float, then the other one is converted to a float and float division is used. * convert your integers to floats first. * Don't use //, use / (// is 'true division', it will always give you the rounded answer) [This can cause confusion, and I think it has been changed from v2.6 on - which I haven't got to try so correct me if I'm wrong] Thus: \ float(factorial(2)) / binomial(1024, 2) 3.8184261974584555e-06 BTW p! / nCp = p! / (n! / p!(n-p)!) = (p!)^2 * (n! / (n-p)!) = (p!)^2 / \prod_{i=n-p+1}^n i Therefore: def product(a, b): return reduce(lambda x, y: x*y, xrange(a, b+1)) def f(n, p): return float(product(1, p))**2 / product(n-p+1, n) f(1024, 2) 3.8184261974584555e-06 This will be more efficient. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I wait for all the threads I spawn for 5 minutes
[cut] But this code ends up waiting 5 minutes for **each** thread. that is not what I want. I just want to wait for 5 minutes for all threads. how can I do that? I've written a little code for you using threading. Hope it will help you: #! /usr/bin/env python # -*- coding: utf8 -*- import threading import time class MyLittleThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): time.sleep(5) if __name__ == __main__: # create a list of 10 MyLittleThread # total time to wait is 5 sec (NOT 5sec*10) lt = [] for i in range(10): lt.append(MyLittleThread()) for th in lt: th.start() bye -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
The others spottet the error I missed. But I can offer something else: http://dirtsimple.org/2004/12/python-is-not-java.html It's a worthy read for someone coming from Java, needing time to adjust. Diez- Hide quoted text - - Show quoted text - That deffinately was a useful read, thanks. Thankyou to everyone who sorted these problems for me, I have progressed very well with this python program throughout the day now. I have another little question before I finish today: I am currently struggling to use a global variable in my static functions. I'll explain further Within my main.py file I have class Main(object): stepStore = StepStore() @staticmethod def createDepSteps(): stepStore.addStep([bol7, pre5]) ... @staticmethod def processSteps(): for step in stepStore.stepList[:]: .. Main.createDepSteps() Main.processSteps() Trying this approach I am getting a error saying with the processSteps() method, stepStore is undefined To solve this problem I am currently passing in the processSteps() parameter a stepStore instance created within createDepSteps() but there is surely a way stepStore can be a global attribute which can be accessed from both methods? Any help would be much appreciated again Cheers Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
On Mon, 03 Sep 2007 16:13:28 +, christophertidy wrote: Within my main.py file I have class Main(object): stepStore = StepStore() @staticmethod def createDepSteps(): stepStore.addStep([bol7, pre5]) ... @staticmethod def processSteps(): for step in stepStore.stepList[:]: .. Main.createDepSteps() Main.processSteps() What's `Main` useful for? Is Java shining through again? A class with just static methods isn't a class but just a container for functions. But functions usually live in modules in Python so get rid of that class and move the functions to module level. Trying this approach I am getting a error saying with the processSteps() method, stepStore is undefined `stepStore` is searched in the function and then in the module. But it is defined in the class. So you have to access `Main.stepStore`. Unless you are modifying `stepStore.stepList` while iterating over it, you don't need to make a copy by the way. Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] wrote: The others spottet the error I missed. But I can offer something else: http://dirtsimple.org/2004/12/python-is-not-java.html It's a worthy read for someone coming from Java, needing time to adjust. Diez- Hide quoted text - - Show quoted text - That deffinately was a useful read, thanks. Thankyou to everyone who sorted these problems for me, I have progressed very well with this python program throughout the day now. I have another little question before I finish today: I am currently struggling to use a global variable in my static functions. I'll explain further Within my main.py file I have class Main(object): stepStore = StepStore() @staticmethod def createDepSteps(): stepStore.addStep([bol7, pre5]) ... @staticmethod def processSteps(): for step in stepStore.stepList[:]: .. Main.createDepSteps() Main.processSteps() Trying this approach I am getting a error saying with the processSteps() method, stepStore is undefined To solve this problem I am currently passing in the processSteps() parameter a stepStore instance created within createDepSteps() but there is surely a way stepStore can be a global attribute which can be accessed from both methods? Any help would be much appreciated again You are dep down in javaland again. first of all, with the exception of factory methods, staticmethods or classmethods usually aren't needed. In Python, you can define functions directly. So move the above methods toplevel, aka out of the class-context. and just make stepStore a module-global variable. Then things should work. The distinction between staticmethod and classmethod is, that staticmethod is a pure method, something unknown in Java. the classmethod OTOH is a method that gets the class as first argument (instead of the instance, as in an instance-method): class Foo(object): @classmethod def bar(cls): print cls However: get rid of unnecessary classes. Java is severely limited regarding the definition of pure code, the permanently needed class-context for e.g. a main-method is absurd - to say the least. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: Does shuffle() produce uniform result ?
Antoon Pardon [EMAIL PROTECTED] writes: If I understand correctly that you are using urandom as a random generator I wouldn't trust too much on this performance. Urandom uses the systemwide entropy-pool. If other programs need this pool too, your performance can drop spectaculary. No the idea is that once there's enough entropy in the pool to make one encryption key (say 128 bits), the output of /dev/urandom is computationally indistinguishable from random output no matter how much data you read from it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with extremely small real number
On 3 sep, 10:56, Andrea [EMAIL PROTECTED] wrote: def binomial(n, k): assert n0 and isinstance(n, (int, long)) and isinstance(k, (int,long)) Don't use assert to check whether the parameters have the right value. assert should be used to claim that a certain condition always hold in your program. Prefer the following form, which will make debugging clearer: if n = 0: raise ValueError(Wrong value of n) if not isinstance(n, (int, long)): raise TypeError(Wrong type of n) if not isinstance(k, (int, long)): raise TypeError(Wrong type of k) Anyway, you shouldn't be checking the type of the parameters either. It could be more useful if you cast to the desired type. This way, your function will handle gracefully the case when you accidentally pass a string as a parameter: n = int(n) k = int(k) if n = 0: raise ValueError(Wrong value of n: %d % n) Best regards, -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAP : ZSI error
linuxprog wrote: hello i need some help with ZSI module i want to use the web service located here www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch the wsdl file : http://www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/wsdl/IDutch that web service is very simple , the function NumToStr converts numbers to dutch words (description http://www.xmethods.net/ve2/ViewListing.po?key=uuid:01EF9AE1-6DD3-7317-AFA5-05A8A52FCD56) i have generated IDutchservice_services with wsdl2py here is my code : import IDutchservice_services soap = IDutchservice_services.IDutchbindingSOAP(www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch) ok = IDutchservice_services.NumToStr0Request() ok.Num=5 print soap.NumToStr(ok) that prints an error RuntimeError: must specify transport or url startswith https/http what's wrong in my script ? thanks Is startswith https/http part of the error message ? What would it refer to ? -- http://mail.python.org/mailman/listinfo/python-list
Re: So what exactly is a complex number?
Lamonte Harris wrote: Like in math where you put letters that represent numbers for place holders to try to find the answer type complex numbers? Not quite. Relating them to (plane) trigonometry is much closer to the mark. Complex numbers are like a subclass of real numbers that elegantly extends the usual arithmetic operations to provide access to trigonometric functions and related goodies. This then allows you to think of trigonometric problems as simple arithmetic problems. -- http://mail.python.org/mailman/listinfo/python-list
Re: 400 Bad Request calling urllib2.urlopen()
Achim Domma wrote: urllib2.HTTPError: HTTP Error 400: Bad Request I'm using Python 2.5.1 and Google did not help. Any hint on how to fix or debug this problem? Use e. g. wireshark to look at the raw stream data and check if the request is malformed. Regards, Björn -- BOFH excuse #123: user to computer ratio too high. -- http://mail.python.org/mailman/listinfo/python-list
trap setting attribute when the attribute is dict
Hello all, I have a question which might be simple or need some work around. I want to do something like this. My class/instance has a dict as a property. I want the instance to catch the change in the dict (change in some values, addition/deletion of key/value etc) to be recognized by the class instance. How can I do this? Any suggestions are very well appreciated. Here is an example of what I want my class to behave: class test(object): def __init__(self): self._d = {} self._changed = False def getd(self): print 'called getd' return self._d # dont know what to do next def setd(self,val): print 'called setd', key, val self._d[key] = val self._changed = True d = property(getd,setd,None,None) def getc(self): return self._changed changed = property(getc,None,None,None) if __name__ == '__main__': obj = test() print 'obj.changed = ', obj.changed print # I want obj to know that its propety d being changed here print t.d['a'] = 1 obj.d['a'] = 1 print # I want the changed property to be True print 'obj.changed = ', obj.changed -- yosuke kimura Center for Energy and Environmental Resources The Univ. of Texas at Austin, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: 400 Bad Request calling urllib2.urlopen()
I have an url which redirects the client to another url. If I paste the url into a browser, it works fine. If I open it via Any redirection is setup using either of the 301, 302, 303, 307 return codes of HTTP. Atleast, thats what standard determines. File C:\Python25\lib\urllib2.py, line 575, in http_error_302 return self.parent.open(new) Here we see that redirect handler http_error_302 has taken effect. File C:\Python25\lib\urllib2.py, line 499, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request The redirected page is not getting fetched by the OpenerDirector of urllib2. This could be due to various reasons. - the protocol is unsupported. - there is some prevention from accessing the resource directly. If its possible, can you share the url which is throwing this error? To me, it does seem urllib2 issue, it could be the (improper ??) redirection setup at webserver. -- http://mail.python.org/mailman/listinfo/python-list -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-list
Applying transformation matrix to 3D vertex coordinates
''' Task:- to apply a translation array to an array of 3D vertex coordinates to produce the resulting location of each vertices. Translation array and vertex coordinates taken from a Truespace COB file. The text in the COB file looks like this:- Transform -2.11786 -0.817596 0.946387 0.864939 0.405189 1.25484 2.11894 0.434915 -1.16679 1.9198 -0.981965 1.13894 0 0 0 1 World Vertices 8 -0.20 -0.029486 -0.236313 0.20 0.029486 -0.163687 -0.20 0.370514 -0.282911 -0.20 0.370514 0.117089 -0.20 -0.029486 0.163687 0.20 0.029486 0.236313 0.20 0.429486 -0.210286 0.20 0.429486 0.189714 ### ''' # script start import Numeric transArray = Numeric.array(( (-2.11786, -0.817596, 0.946387, 0.864939), (0.405189, 1.25484, 2.11894, 0.434915), (-1.16679, 1.9198, -0.981965, 1.1389), (0, 0, 0, 1) )) # a 1 added to the end of each set of vertix coordinates vertArray = Numeric.array(( (-0.20, -0.029486, -0.236313, 1), (0.20, 0.029486, -0.163687, 1), (-0.20, 0.370514, -0.282911, 1), (-0.20, 0.370514, 0.117089, 1), (-0.20, -0.029486, 0.163687, 1), (0.20, 0.029486, 0.236313, 1), (0.20, 0.429486, -0.210286, 1), (0.20, 0.429486, 0.189714, 1) )) print transArray print print vertArray print transArray = Numeric.reshape(transArray,(4,4)) vertArray = Numeric.reshape(vertArray,(4,8)) print Numeric.matrixmultiply(transArray,vertArray) # script end ''' ## Result:- [[ 0.5708016 0.10309048 0.70481144 -1.12413 0.1022124 0.03400637 0.63866924 -1.12413 ] [-0.6688108 0.57729922 -0.19537307 4.2138840.3408408 0.72615216 0.66384632 4.213884 ] [ 0.2735711.26381257 -0.66763452 0.909945 -0.585931 1.13709619 0.39979 0.909945 ] [ 0.2 0.429486 -0.2102861. 0.2 0.4294860.1897141.]] Am I going in the right direction? What do I do with the result? :) Thanks, PhilC ''' -- http://mail.python.org/mailman/listinfo/python-list
ShowMeDo.com Announces Winner of Most-Video-Plays of the Month
ShowMeDo.com, a website offering over 361 instructional screencasts about topics both Python and non-Python, has announced their first winner of the month for the most-played video. And the winner is: Learn Django: Create a Wiki in 20 minutes by Siddharta Govindaraj, founder of Silver Stripe Software, with 1851 views in August, far outpacing the second-place entry. The prize is a £20 (UK) voucher to Amazon. Congratulations, Siddhi! You can watch it at: http://showmedo.com/videos/video?name=110fromSeriesID=110 Siddhi is also helping Doug Napoleone with PyCon this year, providing a program for generating attendee badges and working to integrate it into the Django-based conference site. You can find Siddhi at: http://siddhi.blogspot.com/ http://www.silverstripesoftware.com/ So who will win this month? It could be you! How about a screencast showcasing a different web framework like TurboGears or Twisted Web? Or something about databases, either relational or object. Jeff Rush Python Advocacy Coordinator -- -- O.R.Senthil Kumaran http://uthcode.sarovar.org -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
* Terry Reedy (Fri, 31 Aug 2007 02:28:36 -0400) Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | On Thu, 30 Aug 2007 17:09:36 +1000, Ben Finney wrote: | [EMAIL PROTECTED] writes: | What's with the index() function of lists throwing an exception on not | found? | | It's letting you know that the item isn't in the list. There's no | sensible return value from an index function in that condition. | | What about -1? C programmers do this all the time. :-) Because they do not have exceptions. They have plenty of - but they can't catch them :) Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: trap setting attribute when the attribute is dict
On Sep 3, 7:00 pm, [EMAIL PROTECTED] wrote: Hello all, I have a question which might be simple or need some work around. I want to do something like this. My class/instance has a dict as a property. I want the instance to catch the change in the dict (change in some values, addition/deletion of key/value etc) to be recognized by the class instance. How can I do this? Any suggestions are very well appreciated. Here is an example of what I want my class to behave: class test(object): def __init__(self): self._d = {} self._changed = False def getd(self): print 'called getd' return self._d # dont know what to do next def setd(self,val): print 'called setd', key, val self._d[key] = val Where does the 'key' come from? Perhaps you need to look further into how properties work. self._changed = True d = property(getd,setd,None,None) def getc(self): return self._changed changed = property(getc,None,None,None) if __name__ == '__main__': obj = test() print 'obj.changed = ', obj.changed print # I want obj to know that its propety d being changed here print t.d['a'] = 1 obj.d['a'] = 1 print # I want the changed property to be True print 'obj.changed = ', obj.changed You can't do that with plain dicts, and I'm not sure it is often a good idea. However you could create a class that behaves like a dict but calls a function each time an item is set, e.g. (made up terminology): class TriggerDict(object): ... def __init__(self, trigger, val=None): ... self.trigger = trigger ... self.dict_ = val or {} ... def __setitem__(self, key, val): ... self.trigger(self, key, val) ... self.dict_[key] = val ... def __getitem__(self, key): ... return self.dict_[key] ... def trigger(d, k, v): ... print '%s = %s' % (k, v) ... td = TriggerDict(trigger) td['spanish'] = 'inquisition' # see side effect below. spanish = inquisition td['spanish'] 'inquisition' Obviously your trigger function would set the _changed attribute of the test object instead. And again it is probably not a good idea unless you know exactly what you are doing. If it was me, I'd try to rethink my design instead. HTH -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
* Ben Finney (Thu, 30 Aug 2007 18:02:15 +1000) Bruno Desthuilliers [EMAIL PROTECTED] writes: What's with using your brain instead of whining ? Now now, no need for snappiness. Actually there was. The OP's claim | There are a million situations where you can have an item not be in | a list and it is not an exception situation. ...is just plain nonsense. zzbbaadd neither does understand exceptions nor what they are used for in Python. An item not being in a list is an exception situation /by definition/. Thorsten -- http://mail.python.org/mailman/listinfo/python-list
Re: trap setting attribute when the attribute is dict
Arnaud Delobelle [EMAIL PROTECTED] wrote: On Sep 3, 7:00 pm, [EMAIL PROTECTED] wrote: I want to do something like this. My class/instance has a dict as a property. I want the instance to catch the change in the dict (change in some values, addition/deletion of key/value etc) to be recognized by the class instance. How can I do this? Any suggestions are very well appreciated. Here is an example of what I want my class to behave: class test(object): def __init__(self): self._d = {} self._changed = False def getd(self): print 'called getd' return self._d # dont know what to do next def setd(self,val): print 'called setd', key, val self._d[key] = val Where does the 'key' come from? Perhaps you need to look further into how properties work. This obviously doesn't work... self._changed = True d = property(getd,setd,None,None) def getc(self): return self._changed changed = property(getc,None,None,None) if __name__ == '__main__': obj = test() print 'obj.changed = ', obj.changed print # I want obj to know that its propety d being changed here print t.d['a'] = 1 obj.d['a'] = 1 print # I want the changed property to be True print 'obj.changed = ', obj.changed You can't do that with plain dicts, and I'm not sure it is often a good idea. However you could create a class that behaves like a dict but calls a function each time an item is set, e.g. (made up terminology): class TriggerDict(object): ... def __init__(self, trigger, val=None): ... self.trigger = trigger ... self.dict_ = val or {} ... def __setitem__(self, key, val): ... self.trigger(self, key, val) ... self.dict_[key] = val ... def __getitem__(self, key): ... return self.dict_[key] ... def trigger(d, k, v): ... print '%s = %s' % (k, v) ... td = TriggerDict(trigger) td['spanish'] = 'inquisition' # see side effect below. spanish = inquisition td['spanish'] 'inquisition' Obviously your trigger function would set the _changed attribute of the test object instead. And again it is probably not a good idea unless you know exactly what you are doing. If it was me, I'd try to rethink my design instead. Thank you for suggestion, Arnaud. Since you are discouraging this idea of trigger, may I ask an advice of if my intention was legitimate one or not? My intention was to have a propery 'sum' in my object, and which has sum of all the values() of the dict (i have code to make sure that the value of dict are all numeric). I could just the propery being calculated everytime the property got __getattr__. But I thought that it was inefficient to calculate the same number over and over when the value is already known. So I was thiking of calculating the number only when the dict got modified. I also experimented with the idea of subclassing dict itself to calculate the sum. Is this what would be better solution? Thank you again, -- Arnaud -- yosuke kimura Center for Energy and Environmental Resources The Univ. of Texas at Austin, USA -- http://mail.python.org/mailman/listinfo/python-list
Re: Let's Unite Against Jews and Mongrels!
On Sep 2, 9:18 am, Richard B. Gilbert [EMAIL PROTECTED] wrote: Zentrader wrote: On Aug 28, 4:50 am, Richard B. Gilbert [EMAIL PROTECTED] wrote: Unless, of course, someone has a working Killbot. If anyone has such a thing, please kill that MI5victim moron as well! I reported MI5victim to [EMAIL PROTECTED] and it appears to be gone, as well as the free air conditioner's posts. (Thanks Steve Holden for the reminder that it doesn't have to be personal e-mail spam in order to be reported). If the OP posts again, report it. Something like 75% of internet mail is spam. MI5victim was alive and (I won't say well!!) a week ago. It remains to be seen if he's gone. And if you believe that reporting spam to [EMAIL PROTECTED] actually has any effect on spam, you must believe in the Tooth Fairy as well! There will be spam as long as there are morons who will send the spammers money for whatever they're peddling! I still get two or three Spanish Prisoner a/k/a 401 scams each week (this is the one where somebody has $30,000,000 US and will share it with you if only you will send him a little of your money)! The US government does seem to have cracked down on the Pharmacy spam and the internet pharmacies that were behind it. Remember, it costs essentially nothing to send spam to 30,000,000 people and if the spammer gets 0.5% response, he's ahead of the game! HEY! NOBODY BASHES THE TOOTH FAIRY! -- http://mail.python.org/mailman/listinfo/python-list
Python object - XML
Hi, Say you have the following XML: item ref=1 nameitem 1/name /item item ref=2 nameitem 2/name /item group item ref=1 / item ref=2 / namemy group/name /group Is there an easy way (i.e. without writing a sax/dom parser) to load this into a (number of) Python object(s), manipulate the instance, and save the result back to XML? -Samuel -- http://mail.python.org/mailman/listinfo/python-list
Re: Python object - XML
Samuel napisał(a): Say you have the following XML: item ref=1 nameitem 1/name /item item ref=2 nameitem 2/name /item group item ref=1 / item ref=2 / namemy group/name /group Is there an easy way (i.e. without writing a sax/dom parser) to load this into a (number of) Python object(s), manipulate the instance, and save the result back to XML? Yea, use ElementTree and you'd get a bunch of nested lists of very simple objects. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
Re: TypeError: 'module object is not callable'
[EMAIL PROTECTED] a écrit : (snip) I have another little question before I finish today: I am currently struggling to use a global variable in my static functions. I'll explain further Within my main.py file I have class Main(object): stepStore = StepStore() @staticmethod def createDepSteps(): stepStore.addStep([bol7, pre5]) ... @staticmethod def processSteps(): for step in stepStore.stepList[:]: .. Main.createDepSteps() Main.processSteps() (snip) Marc and Diez already gave you the good answers on this (basically: get rid of useless classes, and use plain functions instead of staticmethods). I'd just add a couple comments: First point: OO is not about classes, it's about objects - FWIW, the mere concept of 'class' is nowhere in the definition of OO, and some OOPLs don't even have that concept (cf Self and Javascript). Second point : in Python, everything (well... almost - at least everything that can be bound to a name) is an object. So Python's modules and functions are objects. Third point : top-level (aka 'module level', aka 'globals') names (names defined outside classes or functions) are in fact module attributes. So, to make a long story short, you can consider a module as a kind of a singleton. What I wanted to point out here is that there's much more to OO than what one learns with Java - and, FWIW, much more to Python's object model than what it may seems at first. Ah, and, BTW : welcome here !-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python object - XML
On Sep 3, 10:19 pm, Jarek Zgoda [EMAIL PROTECTED] wrote: Is there an easy way (i.e. without writing a sax/dom parser) to load this into a (number of) Python object(s), manipulate the instance, and save the result back to XML? Yea, use ElementTree and you'd get a bunch of nested lists of very simple objects. Sorry for being unclear. By load this into a number of Python objects I mean, filling already existing objects with data. In other words: class Item(object): def __init__(self, ref, name): self.ref = ref self.name = name class Group(object): def __init__(self, ref, name, item = []): self.ref = ref self.name = name self.item = item mapper = Mapper() objects = mapper.load('data.xml') print objects['1'] Item object at 0x324235a (Obviously, in my example the mapper could not always know where a list is required, but an existing mapper will surely have a solution implemented.) I guess what I am looking for is pretty much an ORM that also works with XML. -Samuel -- http://mail.python.org/mailman/listinfo/python-list
Re: status of Programming by Contract (PEP 316)?
Russ a écrit : (snip) Frankly, Mr. Holden, I'm getting a bit tired of the clannish behavior here, where outsiders like me are held to a higher standard than your insider friends. I don't know who you are, nor do I care what you and your little group think about me. If you took time to follow discussions on this group, you'd notice that newcomers are usually welcome. It's not a problem of being an outsider of an insider, and there's nothing clannish (or very few, specially when compared to some other places on usenet), it's mostly a problem with your attitude. And please notice, once again, that I'm not talking about *you* - as a person - but about how you behave(d). (snip) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python object - XML
Samuel wrote: Hi, Say you have the following XML: item ref=1 nameitem 1/name /item item ref=2 nameitem 2/name /item group item ref=1 / item ref=2 / namemy group/name /group Is there an easy way (i.e. without writing a sax/dom parser) to load this into a (number of) Python object(s), manipulate the instance, and save the result back to XML? -Samuel I dont know if this suit your needs: http://uche.ogbuji.net/tech/4suite/amara/ Take a look at the Amara Bindery: http://uche.ogbuji.net/tech/4suite/etc/amara-manual.html#bindery A+ Laurent. -- http://mail.python.org/mailman/listinfo/python-list
Python-URL! - weekly Python news and links (Sep 3)
QOTW: If there were a protein that could only be folded by proving the Riemann Hypothesis, the gene that coded for it would quickly get weeded out of the gene pool. - Scott Aaaronson http://scottaaronson.com/blog/?p=266 We read Knuth so you don't have to. - Tim Peters The first Python 3000 release is out -- Python 3.0a1. Anouncement by Guido van Rossum: http://groups.google.com/group/comp.lang.python/browse_thread/thread/267a7b9f3619022b/d7ff1cf24fd44510 Download it: http://python.org/download/releases/3.0/ The first Python Unconference is under two weeks away: http://pycamp.python.org/Texas/ Using set operations instead of list.index(), why there is no list.find(), and the right way to pronounce troll. http://groups.google.com/group/comp.lang.python/browse_thread/thread/6edd7c3363cf2834/262d7a0affcba78e Analyzing a very slow Python code (loops, xrange and integer arithmetic only) http://groups.google.com/group/comp.lang.python/browse_thread/thread/94fade7f69fd9d6/5ab70849893ecfc2 Free memory, garbage collection, and the reuse of integer objects. http://groups.google.com/group/comp.lang.python/browse_thread/thread/6b3f78fe88686940/fe19a8ccfcf6272d An old PEP on Programming by Contract revisited http://groups.google.com/group/comp.lang.python/browse_thread/thread/fecfac3549230a0b/67b8a02147e22143 Started about client/server applications, then people comment about their favorite architectures. http://groups.google.com/group/comp.lang.python/browse_thread/thread/273797276173ea97/b1e2d8f0ff7871e4 Using fcntl to syncronize file access by two processes http://groups.google.com/group/comp.lang.python/browse_thread/thread/c09abd7272f739ff/2b44e4382cd30a1b The difference between os.getenv/os.putenv and os.environ[] http://groups.google.com/group/comp.lang.python/browse_thread/thread/60a59bbf8207aeb0/4e9e51c84dc7a01f Python sort-of joins the 21st century of Web 2.0, and video, and ... well, the technical point is that Django's a solution liked by many: http://groups.google.com/group/comp.lang.python/msg/79e2137000b89417 Everything Python-related you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the marvelous daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. Just beginning with Python? This page is a great place to start: http://wiki.python.org/moin/BeginnersGuide/Programmers The Python Papers aims to publish the efforts of Python enthusiats: http://pythonpapers.org/ The Python Magazine is a technical monthly devoted to Python: http://pythonmagazine.com Readers have recommended the Planet sites: http://planetpython.org http://planet.python.org comp.lang.python.announce announces new Python software. Be sure to scan this newsgroup weekly. http://groups.google.com/groups?oi=djqas_ugroup=comp.lang.python.announce Python411 indexes podcasts ... to help people learn Python ... Updates appear more-than-weekly: http://www.awaretek.com/python/index.html Steve Bethard continues the marvelous tradition early borne by Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim Lesher of intelligently summarizing action on the python-dev mailing list once every other week. http://www.python.org/dev/summary/ The Python Package Index catalogues packages. http://www.python.org/pypi/ The somewhat older Vaults of Parnassus ambitiously collects references to all sorts of Python resources. http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Success Stories--from air-traffic control to on-line match-making--can inspire you or decision-makers to whom you're subject with a vision of what the language makes practical. http://www.pythonology.com/success The Python Software Foundation (PSF) has replaced the Python Consortium as an independent nexus of activity. It has official responsibility for Python's development and maintenance. http://www.python.org/psf/ Among
Colorado Python training in October
Python author and trainer Mark Lutz will be teaching another 3-day Python class at a conference center in Longmont, Colorado, on October 23-25, 2007. This is a public training session open to individual enrollments, and covers the same topics as the 3-day onsite sessions that Mark teaches, with hands-on lab work. For more information on this class, please visit these web pages: http://home.earthlink.net/~python-training/longmont-public-classes.htm Thanks for your interest. --Python Training Services -- http://mail.python.org/mailman/listinfo/python-list
Re: trap setting attribute when the attribute is dict
On Sep 3, 8:47 pm, [EMAIL PROTECTED] wrote: [...] My intention was to have a propery 'sum' in my object, and which has sum of all the values() of the dict (i have code to make sure that the value of dict are all numeric). I could just the propery being calculated everytime the property got __getattr__. But I thought that it was inefficient to calculate the same number over and over when the value is already known. So I was thiking of calculating the number only when the dict got modified. I also experimented with the idea of subclassing dict itself to calculate the sum. Is this what would be better solution? Why not simply have a method to update the dictionary that also keeps the sum up to date? Something like that: class MyObj(object): ... def __init__(self): ... self._d = {} ... self._sum = 0 ... def set_key(self, key, val): ... self._sum += val - self._d.get(key, 0) ... self._d[key] = val ... def get_key(self, key): ... return self._d[key] ... def sum(self): ... return self._sum ... a = MyObj() a.set_key(1, 2) a.sum() 2 a.set_key('a', 10) a.set_key(1, 5) a.sum() 15 Of course this is only worth it if you need to use the sum often enough. If you update the dictionary a lot but only need the sum from time to time, then it might not be worth it at all. Of course you could subclass dict: class MyDict(dict): def __init__(self, *args, **kwargs): self._sum = sum(self.itervalues()) def __setitem__(self, key, val): self._sum += val - self.get(key, 0) dict.__setitem__(self, key, val) def sum(self): return self._sum # overload all other methods that mutate the dict # to keep _sum up to date d = MyDict() d.sum() 0 d['a']=5 d.sum() 5 d['b']=10 d['a']=8 d.sum() 18 HTH -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list
Re: Let's Unite Against Jews and Mongrels!
On Sep 3, 12:57 pm, [EMAIL PROTECTED] wrote: On Sep 2, 9:18 am, Richard B. Gilbert [EMAIL PROTECTED] wrote: HEY! NOBODY BASHES THE TOOTH FAIRY! -Shrug- I fucked her. mvm -- http://mail.python.org/mailman/listinfo/python-list
Re: Let's Unite Against Jews and Mongrels!
Barry OGrady napisał(a): What could anyone have against mongrels? You clearly don't know how abusive ROR can be. -- Jarek Zgoda http://jpa.berlios.de/ -- http://mail.python.org/mailman/listinfo/python-list
ANN: lfm 2.0
Hi out there, After a few years working silently I'm very pleased to announce here the so much awaited new version of 'lfm'. Last File Manager is a simple but powerful file manager for the UNIX console. It's written in Python, using curses module. Licensed under GNU Public License version 3. Some of the features you could find in lfm: - console-based file manager for UNIX platforms - 1-pane or 2-pane view - bookmarks - vfs for compressed files - dialogs with entry completion - fast access to a shell - direct integration of find/grep, df and other tools - tabs per pane - color files by extension [Andrey Skvortsov] - fast file viewer with text and binary modes - ...and many others Download it from: http://www.terra.es/personal7/inigoserna/lfm or if it doesn't show last version (crap of ISP reverse proxy), try this low-bandwidth home server: http://inigo.katxi.org/devel/lfm Of course, all comments, suggestions etc. are welcome. Changes since previous version: Version 2.0 (Nine 1/2 weeks... ok, ok, and 3 years) - 2007/09/03: + tabs implemented + color files by extension [Andrey Skvortsov] + new IPC code and API; more flexible, powerful and stable + new un/compress vfs API, added support for .zip and .rar files + make sort mode per tab, not globally + support locale [Andrey Skvortsov] + speed up loading directory contents + speed cursor movement, don't waste much CPU + use logging module in lfm and pyview for debugging + overwrite_all_none: yes, all, no = new options: none, skip all + rewrite/refactor most of code to make lfm more robust and clean + preferences: - change file name preferences.py = config.py - use ConfigParser + use tempfile secure versions mkdtemp() and mkstemp() + added man pages [Sebastien Bacher] + use reST for documentation + check for python version 2.3 or higher in lfm and pyview + updated to GPL v3 license + and fixed lot of bugs, some of them: - general: . delete garbage if user stops action . run 'do_special_view_file' as dettached from lfm window . path expand in bookmarks (~/) [Andrey Skvortsov] . an ugly traceback crash appears when user starts lfm path and has no permissions to enter. Show error message and default to current directory . lfm crashes when filename is not encoded with same codec than g_encoding utils.{decode|encode}. Needs curses module linked against ncursesw to work properly . sort_mix_cases = 1 performance degrades on larger dirs. Reported by Andrey Skvortsov . escape filenames with chars $ . Reported by Andrey Skvortsov - user interface: . maximize/minimize window don't crash lfm anymore . dialogs appear at bad position after terminal is resized . handle window resize in Tree mode . refresh display after canceling completion dialog . the size of the right pane does not fill the last column in terminal if their number is odd [Andrey Skvortsov] . fix crash when df shows entries in two different lines (device name is too large, f.e. in linux lvm2 volumes) . if you try to enter a directory with insufficient permissions, after the error message is closed the cursorline refreshes to the first line - compress: . added -i flag (--ignore-zeros) flag to tar [Andrey Skvortsov] . standard tar needs - for flags - vfs: . vfs.py: regenerate_file, if user stops process, tempfile can't be deleted - find/grep: . escape special chars (- \ ( ) [ ]) in patterns . don't crash when find/grep returns no results . bug when matches occur in binary files - pyview: . goto line 0 in pyview showed a blank screen . crash in file info if filename is too long Version 1.0 was never released in public Best regards, Iñigo Serna -- http://mail.python.org/mailman/listinfo/python-list
Python411 Podcast: Python for Mobile Interfaces
Python for Mobile Interfaces is a clarion call for Pythonistas to pioneer the future of alternative user interfaces for mobile phones, PDA's, and wearable computers, including voice recognition, gesture recognition, and wearable computing. www.awaretek.com -- http://mail.python.org/mailman/listinfo/python-list
Can you use -getattr- to get a function in the current module?
This works: # Module spam.py import eggs print getattr(eggs, 'omelet')(100) That is, I just call the function omelet inside the module eggs and evaulate it with the argument 100. But what if the function 'omelet' is in the module where I do the getattr (that is, in spam.py). If I do any of this print getattr(spam, 'omelet')(100) print getattr('','omelet')(100) print getattr('omelet')(100) It wont work. Any ideas? Thanks, Sergio -- http://mail.python.org/mailman/listinfo/python-list
Re: Registering a python function in C
Is Maya a different python build than what is contained at python.org? If so, I suggest you get your C program to work with the latest python build from python.org. Then see if you can get it to work with the Maya version. Ok, did that. If I write a normal C++ program and use the python installed in my system, everything works ok and I can call the python funtions. From within maya(where the C code is running as a plugin), nothing happens. I tried removing my python installation so that only the one that comes with maya is running, but then I have no python.h or libs to compile against!! I found no help at the maya/python newsgroup, is there anyone who has done this before??? Thanks for all the help! -- http://mail.python.org/mailman/listinfo/python-list
Re: list index()
Thorsten Kampe [EMAIL PROTECTED] writes: * Ben Finney (Thu, 30 Aug 2007 18:02:15 +1000) Bruno Desthuilliers [EMAIL PROTECTED] writes: What's with using your brain instead of whining ? Now now, no need for snappiness. Actually there was. The OP's claim [...] ...is just plain nonsense. Which was pointed out in several ways without snapping. Hence the part of my response you omitted. Ben Finney wrote: If you don't feel a constructive response is merited, please ignore. There's no need to fuel flames with content-free flaming, and Bruno agreed with that when it was pointed out. If one doesn't have the time or inclination to post a constructive response, not responding at all is better than flaming. The Python community is remarkable for its low level of flaming and high level of content in this forum, even in response to poor attitudes and cluelessness. I'd like it to remain that way. -- \ I don't like country music, but I don't mean to denigrate | `\ those who do. And for the people who like country music, | _o__) denigrate means 'put down'. -- Bob Newhart | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: trap setting attribute when the attribute is dict
On Sep 4, 5:47 am, [EMAIL PROTECTED] wrote: Arnaud Delobelle [EMAIL PROTECTED] wrote: On Sep 3, 7:00 pm, [EMAIL PROTECTED] wrote: I want to do something like this. My class/instance has a dict as a property. I want the instance to catch the change in the dict (change in some values, addition/deletion of key/value etc) to be recognized by the class instance. How can I do this? Any suggestions are very well appreciated. Here is an example of what I want my class to behave: class test(object): def __init__(self): self._d = {} self._changed = False def getd(self): print 'called getd' return self._d # dont know what to do next def setd(self,val): print 'called setd', key, val self._d[key] = val Where does the 'key' come from? Perhaps you need to look further into how properties work. This obviously doesn't work... self._changed = True d = property(getd,setd,None,None) def getc(self): return self._changed changed = property(getc,None,None,None) if __name__ == '__main__': obj = test() print 'obj.changed = ', obj.changed print # I want obj to know that its propety d being changed here print t.d['a'] = 1 obj.d['a'] = 1 print # I want the changed property to be True print 'obj.changed = ', obj.changed You can't do that with plain dicts, and I'm not sure it is often a good idea. However you could create a class that behaves like a dict but calls a function each time an item is set, e.g. (made up terminology): class TriggerDict(object): ... def __init__(self, trigger, val=None): ... self.trigger = trigger ... self.dict_ = val or {} ... def __setitem__(self, key, val): ... self.trigger(self, key, val) ... self.dict_[key] = val ... def __getitem__(self, key): ... return self.dict_[key] ... def trigger(d, k, v): ... print '%s = %s' % (k, v) ... td = TriggerDict(trigger) td['spanish'] = 'inquisition' # see side effect below. spanish = inquisition td['spanish'] 'inquisition' Obviously your trigger function would set the _changed attribute of the test object instead. And again it is probably not a good idea unless you know exactly what you are doing. If it was me, I'd try to rethink my design instead. Thank you for suggestion, Arnaud. Since you are discouraging this idea of trigger, may I ask an advice of if my intention was legitimate one or not? My intention was to have a propery 'sum' in my object, and which has sum of all the values() of the dict (i have code to make sure that the value of dict are all numeric). I could just the propery being calculated everytime the property got __getattr__. But I thought that it was inefficient to calculate the same number over and over when the value is already known. So I was thiking of calculating the number only when the dict got modified. I also experimented with the idea of subclassing dict itself to calculate the sum. Is this what would be better solution? And what's wrong with calculating the value when you need it ... def thedictsum(self): return sum(self.thedict.itervalues()) How big will the dict be, how often will it be updated, how often will the sum be required? Have you done timings of any of the options? You say you have code to check that the values are numeric; why not put this together with maintenance of the sum into a method which clients must use to update the dict? BTW, my motto: __ == Danger, Will Robinson! == Wrong way, go back :-) HTH, John -- http://mail.python.org/mailman/listinfo/python-list
Re: SOAP : ZSI error
En Mon, 03 Sep 2007 06:43:27 -0300, linuxprog [EMAIL PROTECTED] escribi�: import IDutchservice_services soap = IDutchservice_services.IDutchbindingSOAP(www.ebob42.com/cgi-bin/NumberToWordsInDutch.exe/soap/IDutch) ok = IDutchservice_services.NumToStr0Request() ok.Num=5 print soap.NumToStr(ok) that prints an error RuntimeError: must specify transport or url startswith https/http what's wrong in my script ? thanks Just a guess based on the error message, try using: IDutchservice_services.IDutchbindingSOAP(http://www.ebob42.com/cgi-bin/...) -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list