Re: A matter of queues, tasks and multiprocessing

2010-11-12 Thread Emanuele D'Arrigo
On Nov 11, 3:13 pm, Tim Golden wrote: > Try Celery > >    http://ask.github.com/celery/getting-started/introduction.html Thank you Tim, looks very interesting! Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: A matter of queues, tasks and multiprocessing

2010-11-11 Thread Emanuele D'Arrigo
On Nov 10, 9:19 pm, "danmcle...@yahoo.com" wrote: > If you are using Python 2.6 or greater, look into the multiprocessing > module. It may contain 90% of what you need. Thank you Dan, indeed the multi-processing module has been my first port of call and indeed it has all the basic ingredients. Wh

A matter of queues, tasks and multiprocessing

2010-11-10 Thread Emanuele D'Arrigo
Greetings everybody, I've tried to come up with this message for a couple of weeks now and it doesn't look like I'm getting any clearer in my thoughts so I decided that it's probably best to take the plunge and ask you guys to kindly throw me a rope... What I'm trying to come up with is some kind

Re: Python Statements/Keyword Localization

2009-11-30 Thread Emanuele D'Arrigo
Thank you all for the insights. I particularly like the broad spread of opinions on the subject. Indeed when I wrote the original post my thoughts were with those young students of non-English speaking countries that start learning to program before they learn English. My case is almost one of tho

Python Statements/Keyword Localization

2009-11-25 Thread Emanuele D'Arrigo
Greetings everybody, some time ago I saw a paper that used an XSL transformation sheet to transform (if I remember correctly) a Chinese xml file (inclusive of Chinese-script XML tags) into an XHTML file. More recently you might have all heard how the ICANN has opened up the way for non-latin char

Re: Does Class implements Interface?

2009-08-30 Thread Emanuele D'Arrigo
Jonathan, Stephen and Max, thank you all for the tips and tricks. Much appreciated. Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: Does Class implements Interface?

2009-08-27 Thread Emanuele D'Arrigo
On Aug 27, 9:42 pm, Jonathan Gardner wrote: > Have you heard of duck typing? Yes. > Ignore all those things and rely on human (aka natural language) > documentation. That is, if you want to see if a class will work for an > interface, go read the docs on the interface (or rather, what the > func

Does Class implements Interface?

2009-08-27 Thread Emanuele D'Arrigo
Greetings everybody, let's say I have a Class C and I'd like to verify if it implements Interface I. If I is available to me as a class object I can use issubclass(C, I) and I can at least verify that I is a superclass of C. There are a couple of issues with this approach however: 1) C might over

Re: List iterator thread safety

2009-08-27 Thread Emanuele D'Arrigo
On Aug 27, 2:01 am, a...@pythoncraft.com (Aahz) wrote: > Well, I'm not sure about exceptions, but you almost certainly won't get > the results you want. What I'd like in this context is to iterate through the items in the list without processing the same item twice and without skipping item that a

List iterator thread safety

2009-08-24 Thread Emanuele D'Arrigo
Let's say I have a list accessed by two threads, one removing list items via "del myList[index]" statement the other iterating through the list and printing out the items via "for item in myList:" statement. Am I right to say this -won't- generate exceptions because the list iterator is not concern

Re: Executing untrusted code

2009-08-20 Thread Emanuele D'Arrigo
Christian, Rami and Steven, thank you all for your help. It wasn't meant to be a challenge, I knew it ought to be easily breakable. I'm no hacker and it just helps to have some examples to better understand the issue. On Aug 20, 7:42 pm, Steven D'Aprano On a related topic, you should read this po

Re: Executing untrusted code

2009-08-20 Thread Emanuele D'Arrigo
Sorry for digging this back from the grave. I've had to chew on it for a little while. On Aug 8, 1:40 am, Nobody wrote: > If you want to support restricted execution within a language, it > has to be built into the language from day one. Trying to bolt it > on later > is a fool's errand. Fair e

Re: exec("dir()",d)

2009-08-10 Thread Emanuele D'Arrigo
Thank you both for the explanation. As a matter of fact RTFM doesn't -always- help. Sometimes I'm just thick and I can read the manual 10 times and still not understand, as it happened on this particular matter. Your contribution focused my attention on the right bit of the manual which I somehow

exec("dir()",d)

2009-08-09 Thread Emanuele D'Arrigo
Greetings everybody, I don't quite understand why if I do this: >>> d = {} >>> exec("dir()", d) 1) d is no longer empty 2) the content of d now looks like __builtins__.__dict__ but isn't quite it d == __builtins__.__dict__ returns false. Can anybody shed some light? Manu -- http://mail.python

Executing untrusted code

2009-08-07 Thread Emanuele D'Arrigo
Greetings everybody, I've been reading and mulling about python and security, specifically in terms of executing code that may or may not be trustworthy. I understand that libraries such as Rexec and Bastion are now deprecated because they have known vulnerabilities that may be exploited to circum

Re: import vs imp and friends.

2009-07-24 Thread Emanuele D'Arrigo
Christian, Robert, thank you both for the replies, much appreciated. Manu -- http://mail.python.org/mailman/listinfo/python-list

import vs imp and friends.

2009-07-23 Thread Emanuele D'Arrigo
Greetings, I was looking in the archive of this newsgroup and I found this snippet: import imp sourcecode = 'def foo(x): return 11*x' mod = imp.new_module('foo') exec sourcecode in mod.__dict__ mod.foo(16) Together with similar and sometimes more complete snippets available they show how a modul

property using a classmethod

2009-07-09 Thread Emanuele D'Arrigo
Greetings, today I did something like this: class MyClass(object): @classmethod def myClassMethod(self): print "ham" myProperty = property(myClassMethod, None, None) As many of you know this doesn't work and returns a TypeError: the object passed to the property is not a

Re: etree, lxml unexpected behaviour

2009-06-19 Thread Emanuele D'Arrigo
Thank you for the clarification Stefan, I understand. -- http://mail.python.org/mailman/listinfo/python-list

etree, lxml unexpected behaviour

2009-06-17 Thread Emanuele D'Arrigo
Hi everybody, I just tried the following: >>> import xml.etree.ElementTree as etree >>> e = etree.fromstring('>> xmlns:ans="anotherNamespace">>> ans:anotherAttr="2"/>') >>> e.getchildren()[0].attrib {'anAttr': '1', '{anotherNamespace}anotherAttr': '2'} Notice the lack of namespace before the attr

Re: DOM implementation

2009-05-19 Thread Emanuele D'Arrigo
Hello Paul, sorry for the long delay, I was trying to wrap my mind around DOM and Events implementations... On May 15, 7:08 pm, Paul Boddie wrote: > Another implementation is probably a good thing, though, since I don't > trust my own interpretation of the specifications. ;-) Tell me about it. I

Re: Conceptual flaw in pxdom?

2009-05-19 Thread Emanuele D'Arrigo
On May 19, 6:50 am, Stefan Behnel wrote: > It's pretty easy to write unmaintainable code that uses the DOM API, though. I'm finding that at my own expenses... Why would anybody want to use the DOM? I suppose the main reason is that it is one of the most reliable standards around. It might be mor

Conceptual flaw in pxdom?

2009-05-17 Thread Emanuele D'Arrigo
Hi everybody, I'm looking at pxdom and in particular at its foundation class DOMObject (source code at the end of the message). In it, the author attempts to allow the establishment of readonly and read&write attributes through the special methods __getattr__ and __setattr__. In so doing is possib

Re: Swapping superclass from a module

2009-05-17 Thread Emanuele D'Arrigo
Wow, thank you all. Lots of ideas and things to try! I wish I knew which one is going to work best. The module I'm trying to (monkey!) patch is pxdom, and as it is a bit long (5700 lines of code in one file!) I'm not quite sure if the simplest patching method will work or the more complicated o

Re: Swapping superclass from a module

2009-05-16 Thread Emanuele D'Arrigo
On May 16, 8:17 pm, Arnaud Delobelle wrote: > # Insert Wedge into each subclass of modfoo.Base > for subclass in modfoo.Base.__subclasses__(): >     if subclass.__module__ != 'modfoo': continue >     attrs = dict(item for item in subclass.__dict__.items() >                       if item[0][:2] !=

Swapping superclass from a module

2009-05-16 Thread Emanuele D'Arrigo
Hi everybody, let's assume I have a module with loads of classes inheriting from one class, from the same module, i.e.: ## myFile.py class SuperClass(object) class SubClass1(SuperClass) class SubClass2(SuperClass) class SubClass3(SuperClass) In a separate file I also have: ## myOtherFile.py cla

Re: DOM implementation

2009-05-15 Thread Emanuele D'Arrigo
Hi Paul, thank you for your swift reply! On May 15, 3:42 pm, Paul Boddie wrote: > Sure! Just keep your observations coming! I've made a very lazy > attempt at DOM Events support in libxml2dom, I just had a look at libxml2dom, in particular its events.py file. Given that we are working from a sta

Re: DOM implementation

2009-05-15 Thread Emanuele D'Arrigo
Hey Paul, would you mind continuing this thread on Python + DOM? I'm trying to implement a DOM Events-like set of classes and I could use another brain that has some familiarity with the DOM to bounce ideas with. If you are too busy never mind. Also, I thought of keeping the discussion here rather

Re: DOM implementation

2009-05-14 Thread Emanuele D'Arrigo
Thank you Paul for your reply! I'm looking into pxdom right now and it looks very good and useful! Thank you again! Manu -- http://mail.python.org/mailman/listinfo/python-list

DOM implementation

2009-05-13 Thread Emanuele D'Arrigo
Hi everybody, I just spent the past hour or so trying to have a better understanding of how the various DOM-supporting libraries (xml.dom, xml.dom.minidom) work. I've used etree and lxml successfully before but I wanted to understand how close I can get to the W3C DOM standards. Ok, I think more

On Integration Testing

2009-04-07 Thread Emanuele D'Arrigo
Hi everybody, I just finished unit-testing a couple of tightly related modules and it's now time to test them together to a) check if they do talk to each other in the ways they should, b) check how fast they can talk to each other. The problem? Well, the problem is that potentially they can have

Re: How to go about. On read/write locks

2009-04-06 Thread Emanuele D'Arrigo
On Apr 6, 12:44 pm, Piet van Oostrum wrote: > 3. See also http://code.activestate.com/recipes/465156/ Thank you for the useful suggestions Piet. In particular I just had a look at the SharedLock class provided through the link above and it seems to fit the bill quite nicely. I'll give it a go! T

Re: How to go about. On read/write locks

2009-04-06 Thread Emanuele D'Arrigo
On Apr 6, 7:49 am, "Diez B. Roggisch" wrote: > The CPython-specific answer is that the GIL takes care of that for you > right now anyway. So unless you plan for a distant future where some > kind of swallows fly around that don't have a GIL, you are safe to > simply read and write in threads witho

How to go about. On read/write locks

2009-04-05 Thread Emanuele D'Arrigo
Hi everybody, I'm having a threading-related design issue and I suspect it has a name that I just don't know. Here's a description. Let's assume a resource (i.e. a dictionary) that needs to be accessed by multiple threads. A simple lock will do the job but in some circumstances it will create an

Re: Class methods read-only by default?

2009-04-03 Thread Emanuele D'Arrigo
Thank you both, Steven and Andrew, for the insightful explanation. I shall keep it in mind when thinking about classes methods and instances. Thank you again. Manu -- http://mail.python.org/mailman/listinfo/python-list

Class methods read-only by default?

2009-04-02 Thread Emanuele D'Arrigo
Hi Everybody! I just tried this: >>> class C(object): ...def method(self): ...pass ... >>> c = C() >>> delattr(c, "method") Traceback (most recent call last): File "", line 1, in AttributeError: 'C' object attribute 'method' is read-only How come? Who told the class to make the m

Re: PyGTK and skins?

2009-03-29 Thread Emanuele D'Arrigo
On Mar 29, 12:28 am, Cousin Stanley wrote: >     You might try the pygtk mailing list available >     via the  news.gmane.org  server Than you Stanley, much appreciated! Manu -- http://mail.python.org/mailman/listinfo/python-list

PyGTK and skins?

2009-03-28 Thread Emanuele D'Arrigo
Hi everybody, Is GTK/PyGTK able to support application-based (rather than os-based) skins? I.e. round corners, redesigned scrollbars, arbitrarily shaped buttons and so on? Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: Another of those "is" issues.

2009-03-22 Thread Emanuele D'Arrigo
Thank you all for the replies! Manu -- http://mail.python.org/mailman/listinfo/python-list

Another of those "is" issues.

2009-03-20 Thread Emanuele D'Arrigo
Hi everybody, I was unit testing some code today and I eventually stumbled on one of those "is" issues quickly solved replacing the "is" with "==". Still, I don't quite see the sense of why these two cases are different: >>> def aFunction(): ... pass ... >>> f = aFunction >>> f is aFunction T

Re: Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Thank you everybody for the informative replies. I'll have to comb my code for all the instances of "item in sequence" statement because I suspect some of them are as unsafe as my first example. Oh well. One more lesson learned. Thank you again. Manu -- http://mail.python.org/mailman/listinfo/py

Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Sorry for the double-post, the first one was sent by mistake before completion. Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] comp

Can I rely on...

2009-03-19 Thread Emanuele D'Arrigo
Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Take the following code: pattern = "aPattern" compiledPatterns = [ ] compiledPatterns.append(re.compile(pattern)) if(re.compile(pattern) in compiledPatte

Re: "/a" is not "/a" ?

2009-03-07 Thread Emanuele D'Arrigo
On Mar 6, 10:46 pm, "Martin v. Löwis" wrote: > For b), the rationale is that such string literals > in source code are often used to denote names, e.g. > for getattr() calls and the like. As all names are interned, > name-like strings get interned also. Thank you Martin, and all others who have r

Re: "/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
On 6 Mar, 19:46, Gary Herron wrote: > It is an implementation choice (usually driven by efficiency considerations) > to choose when two strings with the same value are stored in memory once or > twice.  In order for Python to recognize when a newly created string has the > same value as an alre

Re: "/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
Thank you everybody for the contributions and sorry if I reawoke the recurring "is vs ==" issue. I -think- I understand how Python's object model works, but clearly I'm still missing something. Let me reiterate my original example without the distracting aspect of the "==" comparisons and the four

"/a" is not "/a" ?

2009-03-06 Thread Emanuele D'Arrigo
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # ek! Why c

Re: thread-local data

2009-02-06 Thread Emanuele D'Arrigo
Thank you both MRAB and Diez. I think I'll stick to making copies inside a thread-protected section unless I need to speed up things, at which point I might go for the key exception path. Thank you again! Manu -- http://mail.python.org/mailman/listinfo/python-list

thread-local data

2009-02-06 Thread Emanuele D'Arrigo
Hi everybody, Assuming a snippet such as: threadLocalData = threading.local() threadLocalData.myDictionary = self.myDictionary is it correct to say that threadLocalData.myDictionary is NOT a thread- local -copy- of self.myDictionary but it's actually pointing to the same object? If that's the c

Re: re.sub and named groups

2009-02-04 Thread Emanuele D'Arrigo
On Feb 4, 5:17 pm, MRAB wrote: > You could use the lazy form "*?" which tries to match as little as > possible, eg "\(\?P.*?\)" where the ".*?" matches: > spam:(?P.*) ham:(?P.*) > giving "spam:foo ham:(?P.*)". A-ha! Of course! That makes perfect sense! Thank you! Problem solved! Ciao! Manu --

re.sub and named groups

2009-02-04 Thread Emanuele D'Arrigo
Hi everybody, I'm having a ball with the power of regular expression but I stumbled on something I don't quite understand: theOriginalString = "spam:(?P.*) ham:(?P.*)" aReplacementPattern = "\(\?P.*\)" aReplacementString= "foo" re.sub(aReplacementPattern , aReplacementString, theOriginalString)

re.match() performance

2008-12-18 Thread Emanuele D'Arrigo
Sorry for the previous post, hit the Enter button by mistake... here's the complete one: Hi everybody! I've written the code below to test the differences in performance between compiled and non-compiled regular expression matching but I don't quite understand the results. It appears that the com

re.match() performance

2008-12-18 Thread Emanuele D'Arrigo
Hi everybody! I've written the code below to test the differences in performance between compiled and non-compiled regular expression matching but I don't quite understand the results. It appears that the performance difference is only around 2%, even if I run the import re import

Re: Bidirectional Networking

2008-12-16 Thread Emanuele D'Arrigo
Thanks everybody and in particular Gabriel and Bryan for their contributions to this thread. Very much useful information. Manu -- http://mail.python.org/mailman/listinfo/python-list

Re: Bidirectional Networking

2008-12-14 Thread Emanuele D'Arrigo
On Dec 14, 2:40 am, Brian Allen Vanderburg II wrote: > But what I think it means is that during the listen for an incoming > connection on the listening socket, if multiple connection attempts are > coming in at one time it can keep a backlog of up to 5 of these > connection attempts for that indi

Re: Bidirectional Networking

2008-12-14 Thread Emanuele D'Arrigo
On Dec 14, 4:10 am, "Gabriel Genellina" wrote: > daemon became a property in Python 2.6; setDaemon was the only way to set > it in previous versions. I thought that might be the case! The documentation is a bit vague: http://docs.python.org/library/threading.html?highlight=threading#threading.Th

Re: Bidrectional Subprocess Communication

2008-12-14 Thread Emanuele D'Arrigo
On Dec 14, 4:48 am, "Gabriel Genellina" wrote: > - you have to close server.stdin when you don't have more data to send. > The server will see an end-of-file and knows it has to exit the loop. > Same thing on the client side. Hi Gabriel, thanks for modifying the code to make it work. I've just tr

Re: Bidirectional Networking

2008-12-13 Thread Emanuele D'Arrigo
On Dec 13, 11:13 pm, Bryan Olson wrote: > Software firewalls will often simply refuse incoming connections. The > basic protection of the garden-variety home router comes from "network > address translation" (NAT), in which case TCP connections initiated from > the inside will generally work, rega

Bidrectional Subprocess Communication

2008-12-13 Thread Emanuele D'Arrigo
Hi everybody, I'm trying to replicate the positive results of the Client/Server scripts from the thread "Bidirectional Networking", but this time using a Process/SubProcess architecture. The SubProcess, acting as a server, is working just fine. But the Process executing the SubProcess, the client

Re: Bidirectional Networking

2008-12-13 Thread Emanuele D'Arrigo
Hey Bryan, thank you for your reply! On Dec 13, 3:51 am, Bryan Olson wrote: > > Is it possible then to establish both a server and a client in the > > same application? > > Possible, and not all that hard to program, but there's a gotcha. > Firewalls, including home routers and software firewalls

Re: Bidirectional Networking

2008-12-13 Thread Emanuele D'Arrigo
On Dec 13, 12:08 am, "James Mills" wrote: > Just as a matter of completeness for my own suggestion, here > is my implementation of your code (using circuits): It's longer! But I bet is a little bit more resilient against all sorts of problems that arise while using network connections. Well, tha

Re: Bidirectional Networking

2008-12-13 Thread Emanuele D'Arrigo
On Dec 12, 9:04 pm, "Gabriel Genellina" wrote: > If you're using 2.5 or older, override serve_forever: > > def serve_forever(self): > while not getattr(self, 'quit', False): > self.handle_request() > > and set the server 'quit' attribute to True in response to some comma

Re: Bidirectional Networking

2008-12-12 Thread Emanuele D'Arrigo
Thank you both for the suggestions! Eventually I tried with threading as illustrated in the code below. And it works pretty well! The only problem I'm having with it is that as the server is a daemon the program should end when the client thread cease to be alive. But it doesn't seem to work that w

Bidirectional Networking

2008-12-11 Thread Emanuele D'Arrigo
Hi everybody! A networking question! I've been looking at and tinkering a little with the various networking modules in python. The examples are pretty clear and a module such as the SimpleXMLRPCServer is actually simple! All the examples though are based on a client interrogating a server, with

Re: Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
On Dec 11, 11:46 pm, greg wrote: > Emanuele D'Arrigo wrote: > > -IF- the application was single-user yes, it wouldn't be a big deal. > > But as it is potentially multi-user, I don't want one party to corrupt > > the application for everybody else. > >

Re: Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
On Dec 11, 7:48 pm, Bruno Desthuilliers wrote: > > or to provide read-only > > access. I.e. right now I'm working on the graphical client which > > potentially could be rewritten entirely by the users. It is necessary > > and perfectly reasonable for the client module to access some of the > > obj

Re: Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
Thank you all for the confirmation and the suggestions (including the tangential ones: I didn't know one could remove your his own posts!). As much as I really like Python (which I've been using full-time only for the past two months) I really wish it did have regular private/ protected/public met

Preventing execution of a method

2008-12-11 Thread Emanuele D'Arrigo
Sorry if I'm a bit thick here... can any of the esteemed participant in this noble newsgroup confirm that is not possible to prevent a python module's code from executing the methods of another module? I.e. if I have a class with two methods, doSomethingSafe() and doSomethingDangerous(), is there

Re: Two attributes! Why?

2008-12-01 Thread Emanuele D'Arrigo
On Nov 29, 5:21 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > This is a side-effect of name-mangling. Double-underscore names are only > mangled when they are referred to directly as attributes, not when they > are passed to setattr, getattr etc. Those functions don't do any n

Re: Exhaustive Unit Testing

2008-11-28 Thread Emanuele D'Arrigo
On Nov 29, 12:35 am, Fuzzyman <[EMAIL PROTECTED]> wrote: > Your experiences are one of the reasons that writing the tests *first* > can be so helpful. You think about the *behaviour* you want from your > units and you test for that behaviour - *then* you write the code > until the tests pass. Than

Two attributes! Why?

2008-11-28 Thread Emanuele D'Arrigo
Hi everybody, I'm having a naming/scoping/mangling issue. I have a class like this: class MyClass(object): __init__(self): self.__myAttribute = None def myMethod(self, aValue): attributeName = "__myAttribute" setattr(self, attributeName, aValue) It all looks

Re: Exhaustive Unit Testing

2008-11-28 Thread Emanuele D'Arrigo
Thank you to everybody who has replied about the original problem. I eventually refactored the whole (monster) method over various smaller and simpler ones and I'm now testing each individually. Things have gotten much more tractable. =) Thank you for nudging me in the right direction! =) Manu --

Re: Exhaustive Unit Testing

2008-11-27 Thread Emanuele D'Arrigo
On Nov 27, 5:00 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Refactor until your code is simple enough to unit-test effectively, then > unit-test effectively. Ok, I've taken this wise suggestion on board and of course I found immediately ways to improve the method. -However- this generates ano

Re: Exhaustive Unit Testing

2008-11-27 Thread Emanuele D'Arrigo
On Nov 27, 5:00 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Refactor until your code is simple enough to unit-test effectively, then > unit-test effectively. I suspect you are right... Ok, thank you! Manu -- http://mail.python.org/mailman/listinfo/python-list

Exhaustive Unit Testing

2008-11-26 Thread Emanuele D'Arrigo
Hi everybody, another question on unit testing, admittedly not necessarily a python- specific one... I have a class method about 60 lines long (*) and due to some 9 non- trivial IFs statements (3 and 2 of which nested) the number of possible paths the program flow can take is uncomfortably large,

Re: Restricted Execution of untrusted code

2008-11-18 Thread Emanuele D'Arrigo
Thanks to those who replied and sorry for not having replied sooner. Ok, got the message: chroot jail. I understand chroot is available for unix-like OS as a kernel-provided facility. If I was developing for, say, Linux or maybe even MacOSX, it might even be easy. My target OS however are XP and V

Re: To throw or to throw not?

2008-11-15 Thread Emanuele D'Arrigo
Thank you all for the insightful replies! Much appreciated! Manu -- http://mail.python.org/mailman/listinfo/python-list

To throw or to throw not?

2008-11-13 Thread Emanuele D'Arrigo
I'm pondering on what is a bit of a philosophical dilemma. When should I throw an exception and when should I not? Suppose I have myFunc1() calling myFunc2() which in turn calls myFunc3 (). Suppose myFunc3() has detected a problem. What should it do? Throw an exception, forcing myFunc2() to handl

Re: Restricted Execution of untrusted code

2008-11-02 Thread Emanuele D'Arrigo
On Nov 1, 12:44 am, Lawrence D'Oliveiro wrote: > I think the most reliable solution is to take advantage of a level in the > system that already has to provide protection against malicious code: use a > chroot jail. Or run a complete virtualized machine with its own OS > installation. Then the code

Re: Exec and Scope

2008-10-31 Thread Emanuele D'Arrigo
Ahh... before you guys reply: I found the way. Between you James sounding the horn of alarm and you Rafe pointing me in the right direction I sorted it out. Eventually I didn't end up using getAttr but looking into it I learned the difference between myResult = instance.method() and myMethod =

Re: Exec and Scope

2008-10-31 Thread Emanuele D'Arrigo
On Oct 31, 4:38 am, Rafe <[EMAIL PROTECTED]> wrote: > If you are just looking to execute an attribute (be it a property, > module-level function, instance or class method, or anything else > which is an attribute of an object), just use getattr(). I must check this out. My understanding is that ge

Re: Exec and Scope

2008-10-31 Thread Emanuele D'Arrigo
On Oct 31, 3:56 am, "James Mills" <[EMAIL PROTECTED]> wrote: > Good lord man, what are you trying to solve ? > Describe your "actual problem" you're attempting > to solve... This looks really really ugly and I would > advise against any solution that relies on exec() I knew I was going to get some

Re: Restricted Execution of untrusted code

2008-10-31 Thread Emanuele D'Arrigo
On Oct 30, 8:50 pm, Aaron Brady <[EMAIL PROTECTED]> wrote: > Otherwise, you might be able to remove access to it by modifying > however it is the 'cust' list is obtained.  Perhaps you can use the > technique that's used to change the value of integers.  Keep us > posted.  Does this give you any ide

Exec and Scope

2008-10-30 Thread Emanuele D'Arrigo
Hi everybody! I'm trying to do something in a way that is probably not particularly wise but at this point I don't know any better, so bear with me. Suppose in main.py I have the following statements: myObject = MyObject() execThis("myObject.myCommand()") Now suppose the method def execThis(aC

Restricted Execution of untrusted code

2008-10-30 Thread Emanuele D'Arrigo
I noticed that this issue has been discussed in this newsgroup periodically over the years and I seem to understand that - comprehensive- safe/restricted execution of untrusted code in python is currently quite hard to achieve. What if the safety requirements are a little relaxed though? All I'd w

Re: Unit Testing: a couple of questions

2008-10-30 Thread Emanuele D'Arrigo
Thank you all for the very instructive replies! Much appreciated! By the sound of it I just have to relax a little and acquire a little bit more experience on the matter as I go along. =) Thank you again! Manu -- http://mail.python.org/mailman/listinfo/python-list

Unit Testing: a couple of questions

2008-10-28 Thread Emanuele D'Arrigo
Hi everybody, I'm just having a go with Unit Testing for the first time and my feeling about it in short is: Neat! I'm a bit worried about the time it's taking me to develop the tests but after only a day or so I'm already much faster than when I started with it and the code is already much impro