• Member Avatar for Gribouillis
    Gribouillis

    Edited Resize an image with PythonMagick

    A simple way to resize an image programmatically, using the PythonMagick module. This module is a python port of the [the magick++ library](http://www.imagemagick.org/Magick++/).
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Is current user member of group www-data ?

    The title says it all.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Command line arguments python

    Use `'--'` for long arguments (more than 1 letter).
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Command line arguments python

    The best thing to do is to add `print(args)` to your script and test it in a console with commands such as $ python filename.py -h $ python filename.py -b …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Regular expressions from python challenge

    I think you must decode the crypted text contained in the html source page.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to get the column of a called function

    You can perhaps use `tokenize.generate_tokens()` which can parse a line or any piece of codes and give you token position (column).
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to get the column of a called function

    I see 2 tools which could give you more detail: 1. You can use `sys.settrace()` to define your own trace function and count the number of calls in each line …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Counting Rows in csv

    Add `str(cnt)`. By the way, this is better: with open("foo.csv") as f: cnt = sum(1 for line in f) because the file is properly closed.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Counting Rows in csv

    You can use cnt = sum(1 for line in open("foo.csv"))
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Issue with wx 3 HTML

    Sorry I only have python-wxgtk2.8 in kubuntu :(
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to print the title from xml source

    I would go with BeautifulSoup as it produces short code, for example # -*-coding: utf8-*- from __future__ import (absolute_import, division, print_function, unicode_literals) from BeautifulSoup import BeautifulSoup def main(): filename = …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in [Beginner] local variable referenced before assignment

    The problem is that due to the assignment statement at line 34, `dealer_num` becomes a local variable in `nowviewing()`. It means that it is a different variable with the same …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Tkinter Digital Clock (Python)

    Here is a perhaps more readable version try: from Tkinter import * except ImportError: from tkinter import * import time root = Tk() clock = Label(root, font=('times', 20, 'bold'), bg='green') …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Challenges

    > os.chdir(os.getcwd()) This is a no-op :)
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Created Launch default editor for python module.

    This small script named `sourcecode.py` is a command line tool to open a python module's source file with the default editor. For example the line $ python sourcecode.py xml.dom.minidom opens …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Finding approximations of sine and cosine with given value theta in degrees

    I suggest the official [python tutorial](https://docs.python.org/3/tutorial/index.html) to start with.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Challenges

    > Regex's anyone? I would use r".*(?:\.py|\.txt)\Z(?ims)" because `glob` uses `fnmatch`, which translates shell patterns into python regex, and this is how `'.*'` is translated: >>> from fnmatch import translate …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Mysql on ubuntu

    If you want mysql for LAMP, the easiest way I know is sudo aptitude install tasksel sudo tasksel navigate the menu with arrow keys, select LAMP with spacebar, return, done.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Challenges

    Hm, `os.listdir()` returns names, one probably needs filenames = [os.path.join(directory, name) for name in os.listdir(directory) if name.endswith(('.py', '.txt'))]
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Find the Roots of a Polynomial.

    This snippet shows how to find the complex roots of a polynomial using python (tested with python 2.6). You need the scipy or numpy module.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Find the Roots of a Polynomial.

    This snippet shows how to find the complex roots of a polynomial using python (tested with python 2.6). You need the scipy or numpy module.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Computer won't start XP

    May I suggest that you install [locate32](http://www.windows8downloads.com/software-search.html?keywords=locate32&Search=) to find your files in win 8 ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Find the Roots of a Polynomial.

    It's been 2 years since I last updated this collection, but today, I found a new way to compute the roots of a polynomial from python: one can use the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in which type of variable is this?

    [This link](http://www.pygame.org/docs/ref/surface.html) tells you quite a lot about the `pygame.Surface` type, although the most important part is probably out of the class: the set of functions which use the pygame.Surface …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in which type of variable is this?

    Add print(type(variable)) # this can be useful too print(variable.__class__) there is also import inspect print(inspect.getmro(variable.__class__)) to get the ancestor classes.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Neural Network Discussion

    It may help everybody to know that this code is an [example](http://pythonhosted.org/neurolab/ex_newff.html) in module neurolab source code, which illustrates the use of the Feed Forward Multilayer Perceptron.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Which laptop should I buy?

    My father in law bought an asus which broke down rapidly. On the other hand, I had one which worked very well during almost 10 years. I bought 3 acer …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Series expansion with swiginac (linux)

    This script computes the formal series expansion of a mathematical function on the command line using the python module swiginac, an interface to the CAS Ginac. Typical invocation in a …
  • Member Avatar for Gribouillis
    Gribouillis

    Created Series expansion with swiginac (linux)

    This script computes the formal series expansion of a mathematical function on the command line using the python module swiginac, an interface to the CAS Ginac. Typical invocation in a …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to mike_2000_17 in Which laptop should I buy?

    When it comes to laptops, I have always found that Toshiba or Acer are pretty safe bets. I think HP is OK too. I've never trusted the quality of Lenovo, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How do i go backwards in code to the begining?

    I think the most inner `while ans:` serve no purpose. You could remove them. On the other hand, I would replace the `while ans` at line 2 by `while True` …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How do i go backwards in code to the begining?

    Suppose you have if ans == "2": print("foo") if ans == "3": print("bar") else: print("qux") and `ans` is the string "2". Foo is printed in the first if, but then …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How do i go backwards in code to the begining?

    Instead of if ... if ... if ... else ... use if ... elif ... elif ... else ... If you need to go to the next iteration of a …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in xmltodict - not understanding how to make it fully useful

    Of course, I said it is this code snippet: http://www.daniweb.com/software-development/python/code/374530/post-process-generated-values-with-a-decorator Here is the contents of post_process.py # python >= 2.6 from functools import update_wrapper def post_process(*filters): """Decorator to post process …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in xmltodict - not understanding how to make it fully useful

    Sorry I meant @post_process(list) def gather(xml_doc, paths): for p in paths: node = xml_doc for word in p: node = node[word] yield node `getitem()` exists, but it is in module …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in xmltodict - not understanding how to make it fully useful

    In this case, the decorator transform a function which generate values into a function which returns a list of these values. Without the decorator, I would write def gather(xml_doc, paths): …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in xmltodict - not understanding how to make it fully useful

    > How does this compare to using a Python function such as filter. Can you be more specific ? The role of `filter()` is to select a subsequence in a …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to ddanbe in Feeling Good About Yourself

    After my midlife, I still do the things you like to do. Except for the tattoo. The last 20 years I have seen and will be seeing a lot of …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What is the most famous place of interest in your country?

    The most famous place in France is the Eiffel tower (almost 7 million visitors a year), but it's not a place I would recommend. Start with the south of France. Edit: …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python ideas.

    This is the first [dadaist](https://en.wikipedia.org/wiki/Dada) thread here. Your code does not make sense. Do something useful instead !

The End.