Re: [Tutor] can't install

2013-12-30 Thread Tobias M.
Quoting Lolo Lolo : Hi, can i ask why the name ~/my_venv/  .. is that just to indicate ~ as the home directory? The name was just an example. Yes, '~' is your home directory. You can actually use this in your shell instead of typing the whole path. You probably want to put virtual enviro

Re: [Tutor] can't install

2013-12-29 Thread Tobias M.
Quoting "Tobias M." : Quoting Lolo Lolo : Hi Tobias can i just ask. As i already have Python 3.3, when i install this separate version of 3.3, will there be a conflict on the command line when i type python3.3? This install i want just for virtualenvs but i wonder if it would

Re: [Tutor] can't install

2013-12-29 Thread Tobias M.
Quoting Lolo Lolo : Hi Tobias can i just ask. As i already have Python 3.3, when i install this separate version of 3.3, will there be a conflict on the command line when i type python3.3? This install i want just for virtualenvs but i wonder if it would replace my other 3.3 as the defa

Re: [Tutor] can't install

2013-12-24 Thread Tobias M.
On 24.12.2013 20:15, Lolo Lolo wrote: ive struggled all day to install pip on ubuntu 12.04 for python 3.3 . The only pip in the apt-get cache is for python 2. i tried to download pip from source but setuptools is missing when it tries to import it. This made me download setuptools with apt-get

Re: [Tutor] Using asyncio in event-driven network library

2013-12-23 Thread Tobias M.
On 22.12.2013 16:59, Tobias M. wrote: On 12/22/2013 04:50 PM, Mark Lawrence wrote: I'm sorry that I can't help directly, but the asyncio module is so new that I don't know if any of the other regulars here can help either :( I'd be inclined to wait for 24 hours from tim

Re: [Tutor] Using asyncio in event-driven network library

2013-12-22 Thread Tobias M.
On 12/22/2013 04:50 PM, Mark Lawrence wrote: I'm sorry that I can't help directly, but the asyncio module is so new that I don't know if any of the other regulars here can help either :( I'd be inclined to wait for 24 hours from time of posting and if you don't get any positive responses, the

[Tutor] Using asyncio in event-driven network library

2013-12-22 Thread Tobias M.
Hello, I am currently writing an event-driven client library for a network protocol [1] and chose to use the new asyncio module. I have no experience with asynchronous IO and don't understand all the concepts in asyncio yet. So I'm not sure if asyncio is actually the right choice . My goal:

Re: [Tutor] Logging script output

2013-12-15 Thread Tobias M.
Hi Reuben, Yes, I think the logging module is the best way to do it. And it's pretty easy, see this minimal example: import logging logging.basicConfig(filename="foo.log", level=logging.DEBUG) logging.debug("This is a log message") The log levels are a great way, to control how much will be lo

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-12 Thread Tobias M.
Peter Otten wrote: You are right; the misunderstanding is that I wasn't advertising the above "fancy" solution (which is buggy, btw). Yes, I wasn't sure about the irony in you last post ;) Peter Otten wrote: I have now implemented what I had in mind with the protocol to function name mapping,

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Am 10.01.2013 15:15, schrieb Peter Otten: Of course handle_1_42() is not exactly the method name one would hope for. You could, again, strive for simplicity and add a lookup table that maps protocol tuples to function /names/ , but as simplicity doesn't seem to be your cup of tea: class Handlers

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Dave Angel wrote: But as it's the simplest solution, and one with no runtime overhead, you really should consider it. Having a line or two following the class definition is not uncommon in Python, and comments can make sure the reader of the code understands it's part of the class initialization

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Tobias M. wrote: Well I think this is an elegant solution. But due to my protocol a packet type is uniquely defined by a combination of two header fields (that contain integers). Building a verbose method name from these would complicate it again. EDIT: I actually meant "meaningful m

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Am 10.01.2013 13:48, schrieb Peter Otten: If you adopt this approach you might omit the lookup dictionary and use getattr(): ... @classmethod ... def handle_foo(cls): print "Hello from B.handle_foo()" ... @classmethod ... def get_handler(cls, packet_type): ... return

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Am 10.01.2013 13:57, schrieb eryksun: That should be cls.method_list[0].__get__(None, cls)() The way you have it binds the method to type(MyClass), which in this case is "type" itself. See cm_descr_get in funcobject.c, CPython 2.7 (line 645): http://hg.python.org/cpython/file/70274d53c1dd

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Steven D'Aprano wrote: To answer your direct question, all you need to do is manually imitate what Python does when you call a descriptor (see below): py> MyClass.method_list[0].__get__(MyClass, None)() Hello World So, inside the foo() method, do this: @classmethod def foo(cls):

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Tobias M.
Peter Otten wrote: Build the list outside the class: MyClass.method_list = [MyClass.bar] Thanks, that is a solution. But I don't really like to put the list outside the class as it is strongly related to the class and not used outside. Hugo Arts wrote: What piece of your code requires this li