Hi,
I want to create a method within a class that is able to accept either a class
or an instance.
class MyClass(object):
@magic_decorator
def method(param):
# param can be MyClass (cls) or an instance of MyClass (self)
so I can do something like:
instance = MyClass()
MyClass.
On Thursday, November 22, 2012 4:51:30 PM UTC+1, Peter Otten wrote:
> Marc Aymerich wrote:
>
>
>
> > Hi,
>
> >
>
> > I want to create a method within a class that is able to accept either a
>
> > class or an instance.
>
> >
>
On Thursday, November 22, 2012 5:26:59 PM UTC+1, Dave Angel wrote:
> On 11/22/2012 11:12 AM, Thomas Bach wrote:
>
> > On Thu, Nov 22, 2012 at 10:52:56AM -0500, Dave Angel wrote:
>
> >> On 11/22/2012 10:14 AM, Marc Aymerich wrote:
>
> >>> I want to create
Dear all,
I want to monkey patch a method that has lots of code so I want to avoid
copying all the original method for changing just two lines. The thing is that
I don't know how to do this kind of monkey patching.
Consider the following code:
class OringinalClass(object):
def origina_metho
Hi,
I've been trying very, very hard to load an RSA key using M2Crypto but without
any success.
basically this is what I'm trying to do:
>>> from M2Crypto import BIO, RSA
>>>
>>> pubkey = """-BEGIN RSA PUBLIC KEY-
... MIIBCgKCAQEApwotnfHT9RAmxnuaGEMdI3lYPYE4aaqSD9v4KbTh1E7Le3GNJQb7
...
On Thursday, January 17, 2013 1:32:25 AM UTC+1, Piet van Oostrum wrote:
> Marc Aymerich writes:
>
>
>
> > Hi,
>
> > I've been trying very, very hard to load an RSA key using M2Crypto but
> > without any success.
>
> >
>
> > basicall
On Thursday, January 17, 2013 5:39:57 PM UTC+1, Piet van Oostrum wrote:
> > Converting to X.501 isn't difficult (assuming this is a 2048 bit key):
>
> > Get rid of the 'RSA' in header and trailer
>
> > Prepend X.501 header 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A' to the data
>
> > Reformat the lines
On Fri, Jan 18, 2013 at 12:10 AM, Piet van Oostrum wrote:
> Marc Aymerich writes:
>
>> Thank you very much Piet,
>> I'm just starting to grasp these cryptography related concepts and your code
>> is helping me a lot to understand how to handle these keys in a low
Hi,
I'm playing a bit with python dynamic methods and I came up with a
scenario that I don't understant. Considering the follow code:
# Declare a dummy class
class A(object):
pass
# generate a dynamic method and insert it to A class
for name in ['a', 'b', 'c']:
if name == 'b':
@p
On Feb 23, 2:05 pm, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > Hi,
>
> > I'm playing a bit with python dynamic methods and I came up with a
> > scenario that I don't understant. Considering the follow code:
>
> > # Declar
Hi,
I'm trying to define a function that has an optional parameter which
should be an empty list whenever it isn't given. However, it takes as
value the same value as the last time the function was executed. What
is the reason of this behaviour? How does python deal with default
values (i.e. when a
Hi,
I'm developing a reusable app splited into modules. The end user
chooses what modules wants to keep installed.
Most of this modules are quite independent from each other, but I have
one of them (called moduleP) with a pretty strong dependency with
another another(called moduleBase). So I need t
I would like to throw at you some problem that I don't know how to best
approach :)
Have an interactive CLI python program that holds credentials entered by
the user. I want users to be able to spawn a new instance of this program
(on another TTY) without the need of reentering credentials. Want t
Hi,
I'm playing with python internals to make objects behave like this:
if I access to "object.attribute" I want to return the result of an
HTTP GET request. However if i call "object.attribute()" I want an
HTTP POST request to be executed.
So far I have been able to do the POST part, using two c
On Sun, Nov 24, 2013 at 2:45 PM, Steven D'Aprano
wrote:
> On Sun, 24 Nov 2013 05:04:16 -0800, Devin Jeanpierre wrote:
>
>> On Sun, Nov 24, 2013 at 4:52 AM, Marc Aymerich
>> wrote:
>>> Hi,
>>> I'm playing with python internals to make ob
On Sun, Nov 24, 2013 at 3:13 PM, Chris Angelico wrote:
> On Mon, Nov 25, 2013 at 12:45 AM, Steven D'Aprano
> wrote:
>> Not quite impossible. All you need is an object that behaves like a
>> string, except it has a __call__ method. Here's a sketch of a solution,
>> completely untested.
>>
>> class
On Sun, Nov 24, 2013 at 3:37 PM, Chris Angelico wrote:
> On Mon, Nov 25, 2013 at 1:16 AM, Marc Aymerich wrote:
>> ... def do_get(self):
>> ... # Do a HTTP GET request.
>> ... return "Get stuff"
>> ... def do_put(self):
&
On Sat, Jan 4, 2014 at 5:26 AM, Alec Taylor wrote:
> What is the highest performance REST microframework?
>
> Happy if it's mostly written in C or C++; as long as it provides a
> simple routes interface in Python.
>
> Currently using bottle and utilising its application, @route and
> app.merge(app
On Fri, Jan 17, 2014 at 6:18 PM, San D wrote:
> What is the best Graph or Chart software used with Django (libraries &
> products), preferably open source?
>
> Need something stable and robust, and used by many developers, so active on
> community channels.
what I use is a JS library called hig
On Fri, Jan 17, 2014 at 6:22 PM, San D wrote:
> Can someone suggest a few templating engines that work really well with
> Django and help in coding efficiency?
>
> Where can I fin comparison of tempating engines I can find to know their pros
> and cons?
I believe the most widely used template e
Dear all,
I have a very simple module
glic3@e4200:# cat globalstate.py
GLOBAL = 0
def update():
GLOBAL += 1
however it doesn't work!!
glic3@e4200:# python
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more informat
On Thu, Jan 30, 2014 at 11:53 PM, Chris Angelico wrote:
> On Fri, Jan 31, 2014 at 9:46 AM, Marc Aymerich wrote:
>> GLOBAL = 0
>>
>> def update():
>> GLOBAL += 1
>
> If you assign to a name, Python makes it local, unless you explicitly
> tell it that you
Hi,
I have to run the asyncio.loop on a separated thread because the main
thread is running FUSE. Apparently fuse needs to run on the main
thread because it uses signal():
File "/usr/local/lib/python3.4/dist-packages/fuse.py", line 390, in __init__
old_handler = signal(SIGINT, SIG_DFL)
V
On Tue, Nov 24, 2015 at 4:29 PM, Marc Aymerich wrote:
> Hi,
>
> I have to run the asyncio.loop on a separated thread because the main
> thread is running FUSE. Apparently fuse needs to run on the main
> thread because it uses signal():
>
>
> File "/usr/loca
definitive solution I'll be doing a
os.kill(os.getpid(), signal.SIGKILL) inside the finally block.
[1] https://docs.python.org/3.5/library/threading.html#threading.Thread.daemon
On Tue, Nov 24, 2015 at 4:46 PM, Marc Aymerich wrote:
> On Tue, Nov 24, 2015 at 4:29 PM, Marc Aymerich wrote:
>&
On Tue, Nov 24, 2015 at 7:11 PM, Zachary Ware
wrote:
> On Tue, Nov 24, 2015 at 9:46 AM, Marc Aymerich wrote:
>> if __name__ == '__main__':
>> loop_container = {}
>> handler = threading.Thread(target=run_loop, args=(loop_container, ))
&g
On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware
wrote:
> On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote:
>> still it appears to work only if the main thread is in the foreground
>> (as of calling Thread() with deamon=True), I don't get why it behaves
>> differen
On Tue, Nov 24, 2015 at 9:17 PM, Marc Aymerich wrote:
> On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware
> wrote:
>> On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote:
>>> still it appears to work only if the main thread is in the foreground
>>> (as of calling
On Tue, Nov 24, 2015 at 9:17 PM, Marc Aymerich wrote:
> On Tue, Nov 24, 2015 at 8:41 PM, Zachary Ware
> wrote:
>> On Tue, Nov 24, 2015 at 12:37 PM, Marc Aymerich wrote:
>>> still it appears to work only if the main thread is in the foreground
>>> (as of calling
On Wed, Nov 5, 2014 at 11:31 PM, Joel Goldstick
wrote:
> On Tue, Nov 4, 2014 at 9:07 PM, Peter Irbizon
> wrote:
> > Hello,
> > please how can I detect mouse pointer type? I would like to print every
> > mouse pointer change (arrow, hand, ...) while moving my mouse over
> screen.
> > How can I do
On Tue, Nov 11, 2014 at 4:48 PM, Larry Martell wrote:
>
> I have a PHP app that I want to convert to django. But I want to do it
> stages. All the heavy lifting is in the PHP code, so first, I want to
> just use templates and views to generate the HTML, but still call the
> PHP code. Then later co
On Tue, Nov 11, 2014 at 5:43 PM, Larry Martell wrote:
> On Tue, Nov 11, 2014 at 11:00 AM, Marc Aymerich wrote:
>> On Tue, Nov 11, 2014 at 4:48 PM, Larry Martell
>> wrote:
>>>
>>> I have a PHP app that I want to convert to django. But I want to do it
>>&g
On Tue, Nov 11, 2014 at 6:26 PM, Larry Martell wrote:
> On Tue, Nov 11, 2014 at 12:18 PM, Marc Aymerich wrote:
>> On Tue, Nov 11, 2014 at 5:43 PM, Larry Martell
>> wrote:
>>> On Tue, Nov 11, 2014 at 11:00 AM, Marc Aymerich wrote:
>>>> On Tue, No
On Tue, Feb 3, 2015 at 4:53 AM, Rustom Mody wrote:
> How many people (actually machines) out here are vulnerable?
>
>
> http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure
>
> shows a python 1-liner to check
> --
> https://mail.python.o
Hi,
I'm writting an application that saves historical state in a log file.
I want to be really efficient in terms of used bytes.
What I'm doing now is:
1) First use zlib.compress
2) And then remove all new lines using binascii.b2a_base64, so I have
a log entry per line.
but b2a_base64 is far fro
On Wed, Oct 28, 2015 at 11:30 PM, Marc Aymerich wrote:
> Hi,
> I'm writting an application that saves historical state in a log file.
> I want to be really efficient in terms of used bytes.
>
> What I'm doing now is:
>
> 1) First use zlib.compress
> 2) A
On Thu, Oct 29, 2015 at 11:52 AM, Chris Angelico wrote:
> On Thu, Oct 29, 2015 at 9:35 PM, Marc Aymerich wrote:
>> 1) Each node on the cluster needs to keep track of *all* the changes
>> that ever ocurred. So far, each node is storing each change as
>> individual lines on a
On Thu, Oct 29, 2015 at 11:57 PM, Laura Creighton wrote:
> In a message of Fri, 30 Oct 2015 09:47:42 +1100, Cameron Simpson writes:
>>Another post suggests that the OP is transferring log info in UDP packets and
>>hopes to keep the state within a maximum packet size, hence his desire for
>>compact
Hi, I'm desperately trying to construct an XML with the following document
declaration:
http://www.w3.org/2001/XMLSchema-instance”>
I'm using LXML, and what I'm doing is this
>>> from lxml import etree
>>> from lxml.builder import E
>>> doc = E.Document(
... {
... 'xmlns': "urn:iso:s
On Tue, Jul 29, 2014 at 8:19 PM, Marc Aymerich wrote:
> Hi, I'm desperately trying to construct an XML with the following document
> declaration:
>
> xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”>
>
> I'm using LXML, and what I'm doing is
Hi all,
I want to provide an encapsulated static attribute called _registry
for several classes.
I try to use inheritance in order to make it DRY: all classes inherit
from a BaseClass that implements the _registry encapsulation. But with
inheritance it doesn't work how I want, because a single ins
On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > Hi all,
> > I want to provide an encapsulated static attribute called _registry
> > for several classes.
>
> > I try to use inheritance in order to make it DRY: all class
On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > Hi all,
> > I want to provide an encapsulated static attribute called _registry
> > for several classes.
>
> > I try to use inheritance in order to make it DRY: all class
On Feb 2, 12:18 pm, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote:
> >> Marc Aymerich wrote:
> >> > Hi all,
> >> > I want to provide an encapsulated static attribute c
On Feb 2, 5:58 pm, Michele Simionato
wrote:
> Notice that Peter's approach also works without inheritance:
>
> registries = {}
>
> @property
> def per_class(self):
> cls = type(self)
> try:
> return registries[cls]
> except KeyError:
> result = registries[cls] = []
> ret
On Feb 3, 10:24 am, Peter Otten <__pete...@web.de> wrote:
> Marc Aymerich wrote:
> > On Feb 2, 12:11 am, Peter Otten <__pete...@web.de> wrote:
> >> Marc Aymerich wrote:
> > Hi!,
> > Unfortunately per_class attribute losses the "independence&quo
Hi!
I need to create a pretty complex class at runtime. something like
this one:
(note: "" means that the number of attributes can be variable)
class VirtualUserLimitForm(ModelForm):
swap_limit = forms.CharField(max_length=100,
initial=monitor1.default_limit)
memory_limit = forms.Char
Thank you all for the answers!
I'll try to give you the context in which I need to generate classes
like this.
I'm developing a reusable control panel for an ISP. I have several
modules (VirtualUser, SystemUser, VPS, VirtualHost, ...) and they all
share the fact that you can have limits on resour
On Feb 5, 1:06 pm, Marc Aymerich wrote:
> Thank you all for the answers!
>
> I'll try to give you the context in which I need to generate classes
> like this.
>
> I'm developing a reusable control panel for an ISP. I have several
> modules (VirtualUser, SystemUser,
49 matches
Mail list logo