Re: Dependency management in Python?

2013-01-12 Thread Thomas Bach
On Fri, Jan 11, 2013 at 06:42:18PM -0800, Adelbert Chang wrote: > Another question - how do we then get PIP to the latest version? Or > is it relatively easy to uninstall/reinstall PIP? Simply do a $ pip install -U distribute $ pip install -U pip from time to time in your virtual environment.

Re: Custom alphabetical sort

2012-12-24 Thread Thomas Bach
On Mon, Dec 24, 2012 at 07:32:56AM -0800, Pander Musubi wrote: > I would like to sort according to this order: > > (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', > 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', 'c', 'C', > 'ç', 'Ç', 'd', 'D', 'e',

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Thomas Bach
Hi there, On Sun, Dec 23, 2012 at 01:42:14PM -0800, prilisa...@googlemail.com wrote: > […] In the lower section you see, that the modules should execute > sqls. In case It could occur that two queries occur at the same > time. PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand, > how I

Re: [newbie] plotting pairs of data

2012-12-19 Thread Thomas Bach
but also the how is the matter of your question something like xs = [ float(x) for x, _ in map(str.split, l) ] ys = [ float(y) for _, y in map(str.split, l) ] should do the trick. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Py 3.3, unicode / upper()

2012-12-19 Thread Thomas Bach
On Wed, Dec 19, 2012 at 06:23:00AM -0800, wxjmfa...@gmail.com wrote: > I was suprised to discover this: > > >>> 'Straße'.upper() > 'STRASSE' > > I really, really do not know what I should think about that. > (It is a complex subject.) And the real question is why? Because there is no definition

Re: Pattern-match & Replace - help required

2012-12-19 Thread Thomas Bach
On Wed, Dec 19, 2012 at 02:42:26AM -0800, AT wrote: > Hi, > > I am new to python and web2py framework. Need urgent help to match a > pattern in an string and replace the matched text. > Well, what about str.replace then? >>> 'egg, ham, tomato'.replace('ham', 'spam, ham, spam') 'egg, spam, ham,

Re: counting how often the same word appears in a txt file...But my code only prints the last line entry in the txt file

2012-12-19 Thread Thomas Bach
Hi, just as a side-note On Wed, Dec 19, 2012 at 02:45:13AM -0800, dgcosgr...@gmail.com wrote: > for word in list: > if word in dict: > count = dict[word] > count += 1 > dict[word] = count > else: > dict[wor

Re: I need help with graphs in python (2.7.3.1)

2012-12-18 Thread Thomas Bach
h a solution. Hope this helps, Thomas Bach. Footnotes: [1] http://docs.python.org/2/library/configparser.html [2] http://docs.python.org/2/library/csv.html [3] http://docs.python.org/2/library/collections.html#collections.Counter [4] http://matplotlib.org/gallery.html -- http://mail.pyt

Re: Help with unittest2

2012-12-13 Thread Thomas Bach
ending on the arguments type. If you want to make sure that something is of a certain type use assertIsInstance! Hope this helps, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: scope, function, mutable

2012-12-04 Thread Thomas Bach
Hi, On Tue, Dec 04, 2012 at 02:55:44PM +0400, gusa...@gmail.com wrote: > What is the appropriate definition for the following behavior in Python 2.7 > (see code below). It has something to do with mutability of lists and that Python passes around references and not the actual objects. > > def f

Re: CSV out of range

2012-12-04 Thread Thomas Bach
o ignore the > empty arrays using if statement, but it does the same. Please provide a small, runable example with the actual code you tried that raises the exception and the complete trace back. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: List problem

2012-12-02 Thread Thomas Bach
On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote: > > len([x for x in l if x[1] == 'VBD']) > Another way is sum(1 for x in l if x[1] == 'VBD') which saves the list creation. Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare list entry from csv files

2012-11-29 Thread Thomas Bach
Can you please cut the message you are responding to the relevant parts? On Thu, Nov 29, 2012 at 11:22:28AM +0100, Anatoli Hristov wrote: > The only problem I have is that I cant compare other field than the > first one in > for ex_phone in phones: > telstr = ex_phone[0].lower() > When I u

Re: Re: Managing multiple packages

2012-11-27 Thread Thomas Bach
On Mon, Nov 26, 2012 at 07:58:22PM -0600, Evan Driscoll wrote: > I'm also pretty confused about the > distutils/setuptools/distribute/distutils2 landscape and what the > differences are (at least between the first 3) and what their > relationships with standard Python are. In my opinion packaging

Re: Managing multiple packages

2012-11-22 Thread Thomas Bach
On Tue, Nov 20, 2012 at 03:24:59PM -0600, Evan Driscoll wrote: > > Suppose I have packages A-C. In addition to being modules in the Python > sense, they are logically distinct, probably sit in different > repositories, etc., so there's a directory layout like > > [SNIP] > > Finally, suppose that

Re: method that can be called from a class and also from an instance

2012-11-22 Thread Thomas Bach
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 a method within a class that is able to accept either a > > class or an instance. > > > > I haven't tried it, but how about if you do a @classmethod decorator, > and the

Re: Web Frameworks Excessive Complexity

2012-11-22 Thread Thomas Bach
On Wed, Nov 21, 2012 at 12:49:52PM -0800, rh wrote: > > wheezy + "myvirtualenv" = 3.3MB > pyramid = 92MB $ mkvirtualenv --no-site-packages -p python2.7 pyramid $ pip install -U distribute $ pip install pyramid $ du -h .virtualenvs/pyramid 22M .virtualenvs/pyramid $ du

Re: editing conf file

2012-11-16 Thread Thomas Bach
7;, 'option').split(',') ] if you use a comma as a separator. Have a look at YAML if this is not enough for you, as I think lists are supported there. Haven't had a look myself though, yet. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help building a dictionary of lists

2012-11-13 Thread Thomas Bach
On Mon, Nov 12, 2012 at 11:41:59PM +, Joshua Landau wrote: > > Dict comprehension: > {i:[] for i in ["Test 1", "Test 2", "Test 3"]} In Python 2.6 this syntax is not supported. You can achieve the same there via dict((i, []) for i in ['Test 1', 'Test 2', 'Test 3']) Also have a look at ``coll

Re: How to use "while" within the command in -c option of python?

2012-10-13 Thread Thomas Bach
a simple statement separated by a semicolon.”, right? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Unpaking Tuple

2012-10-08 Thread Thomas Bach
Hi there, On Sat, Oct 06, 2012 at 03:08:38PM +, Steven D'Aprano wrote: > > my_tuple = my_tuple[:4] > a,b,c,d = my_tuple if len(my_tuple) == 4 else (my_tuple + (None,)*4)[:4] > Are you sure this works as you expect? I just stumbled over the following: $ python Python 3.2.3 (default, Jun 25

Re: unit testing class hierarchies

2012-10-02 Thread Thomas Bach
stD2? To me it sounds like test_base() is actually no test. Hence, I would rather give it a catchy name like _build_base_cls(). If a method name does not start with 'test' it is not considered a test to run automatically. Does this help? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing iterables in sub-generators without loosing elements

2012-09-29 Thread Thomas Bach
On Sat, Sep 29, 2012 at 09:26:00AM -0700, Paul Rubin wrote: > Thomas Bach writes: > > itertools.groupby(data, lambda (x,y) : x) > > is basically what you want. True! Thanks, Thomas Bach -- http://mail.python.org/mailman/listinfo/python-list

Slicing iterables in sub-generators without loosing elements

2012-09-29 Thread Thomas Bach
s itertools.takewhile consumes the first entry not fulfilling the pred. I currently have the intuition that the problem is not solvable without using e.g. a global to pass something back to iter_in_blocks from block_iter. Any other suggestions? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 10:03:51AM -0700, Richard Thomas wrote: > class Foo(object): > def __new__(cls, arg): > if isinstance(arg, list): > cls = FooList > elif isinstance(arg, dict): > cls = FooDict > return object.__new__(cls, arg) > > class Fo

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 12:29:21PM -0400, Dennis Lee Bieber wrote: > On Thu, 16 Aug 2012 14:52:30 +0200, Thomas Bach > declaimed the following in > gmane.comp.python.general: > > Of course, since the parse result (at least from my recent > experiment) is a Python s

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 05:10:43PM +0200, Hans Mulder wrote: > On 16/08/12 14:52:30, Thomas Bach wrote: > > > > So, my question (as far as I can see it, please correct me if I am > > wrong) is less of the "How do I achieve this?"-kind, but more of the > > &q

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 12:16:03AM +, Steven D'Aprano wrote: > Some comments: > > 1) What you show are not "use cases", but "examples". A use-case is a > description of an actual real-world problem that needs to be solved. A > couple of asserts is not a use-case. Thanks for the clarificatio

Dynamically determine base classes on instantiation

2012-08-15 Thread Thomas Bach
def do_something(self): # do something on self._obj pass Which seems ugly. Is there a way to provide the functions of `list' and `dict' in Foo's look-up path without having to write all the stubs myself? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Compiling Python (modules) on 64bit Windows - which compiler suite?

2012-03-21 Thread Thomas Bach
do we compile our own C extension? What about installing Cygwin and using the shipped GCC? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: standalone python web server

2012-02-09 Thread Thomas Bach
Rita writes: > I am building a small intranet website and I would like to use > Python. I was wondering if there was a easy and medium performance > python based web server available. Are you going to use a framework? Most of these ship with a light web server implementation… You probably want

Re: Getting the current directory path and the path where python script is saved

2011-12-13 Thread Thomas Bach
gialloporpora writes: > I would like to know how to obtain the path where script is executed > and the path where the file script is stored. Does this help: In [16]: import os In [19]: os.getcwd() Out[19]: '/home/vince' In [21]: os.__file__ Out[21]: '/home/vince/src/pyramid_install/lib/python

Re: unittest. customizing tstloaders / discover()

2011-12-12 Thread Thomas Bach
Gelonida N writes: > Do I loose anything if using nose. or example can all unit tests / doc > tests still be run from nose? AFAIK you don't loose anything by using nose – the unittests should all be found and doctests can be run via `--with-doctest', I never used doctests though. regards -- ht

Re: unittest. customizing tstloaders / discover()

2011-12-11 Thread Thomas Bach
Gelonida N writes: > I'd like to use regular expresions as include / exclude rules > and I would like to have another filter function, which would check for > the existence of certain metavariabels in test suite files Did you have a look at nose? I'm using it and it supports include/exclude rule