• Member Avatar for Gribouillis
    Gribouillis

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

    You can define a function to do the same easily @post_process(list) def gather(xml_doc, paths): for p in paths: node = xml_doc for word in p: node = getitem(node, word) yield …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Resize an image with PythonMagick

    Not python, but related to the topic, the [converseen](http://converseen.sourceforge.net/) GUI program converts images manually with imagemagick.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in (Too many levels of symbolic links)

    I'm not sure too many levels automatically means circular links. There are [various limits](http://sourceware.org/ml/libc-alpha/2012-07/msg00639.html) for the number of levels.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Lowest/highest bit set in integer.

    These two functions compute the orders of the lowest bit and the highest bit set in the binary representation of an integer. I expect them to handle securely very large …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Lowest/highest bit set in integer.

    These two functions compute the orders of the lowest bit and the highest bit set in the binary representation of an integer. I expect them to handle securely very large …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in (Too many levels of symbolic links)

    If you only changed the file `.bashrc`, why don't you simply restore the backup to see if it works ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Caeser Shift - Small Question

    Unindent line 13 to take the `print()` call out of the `for` loop.
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to snippsat in Parse large one line text file

    One way. f_object = open('filename', 'rb') while True: chunk = f_object.read(180) if not chunk: break do_something_with(chunk) f_object.close() More modern an pythonic. from functools import partial with open('filename', 'rb') as f_object: …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Postfix calculator on python

    Think about how to evaluate the list [5, 1, 2, '+', 4, '*', '+', 3, '-'] The `evaluate_list()` function must return 14.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to Update Local Module

    A way I know is to distribute using setuptools in [development mode](https://pythonhosted.org/setuptools/setuptools.html#develop-deploy-the-project-source-in-development-mode). Use the command python setup.py develop in the development directory and you can edit the module indefinitely.
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to codehimn in Resize an image with PythonMagick

    import PythonMagick img = PythonMagick.Image("elixir.png") img.resize("20%") img.write('out_name.JPG') # this works for me :)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python doubts

    The function `get_inverse_dict()` currently returns `None`. After you insert your code, it is supposed to return the dictionary {'a': 'z', 'c': 'x', 'b': 'y', 'e': 'v', 'd': 'w', 'g': 't', …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in creating graph using pyqt and overlay controls ontop

    QDirModel ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python File Handling

    > Can a python program write to the cherrytree database as well as fetch data from it? I did not try this. Here is some basic code to fetch node …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python File Handling

    I would suggest using a user friendly python application such as [cherrytree](http://www.giuspen.com/cherrytree/). Each recipe could go in a separate node of the tree, wich could be organised like a cookbook. …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Returning only tags with certain siblings (Beautiful Soup)

    Perhaps play with the [.next_siblings](http://www.crummy.com/software/BeautifulSoup/bs4/doc/#next-siblings-and-previous-siblings) and `.sibling` attributes of the title tag.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Posting like cURL using python

    If you are looking for http requests in python, the [requests](https://pypi.python.org/pypi/requests) module should provide the necessary tools. Otherwise, there is a [pycurl](http://pycurl.sourceforge.net/) ...
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Copy path to an .bat file from .xml file

    This is a typical use case for generators and tools for iterables. Instead of writing to a file, use a generator import os import xml.etree.ElementTree as ET from itertools import …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to check if a file exist

    You only need to keep the set of already seen PC Numbers seen = set() # ... for row in ...: n = row['PC Number'].strip() mode = 'ab+' if n …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to check if a file exist

    Use `os.path.exists()` or `os.path.isfile()` depending on what you want to do.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Binary File Facts

    Yes, python traditionally represents binary strings with the prefix '0b'. In this case, you can ignore this prefix. Passing the same string without '0b' gives the same result. In the same …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Binary File Facts

    Install the bitstring module from pypi (type `pip install bitstring` in a terminal or cmd). You can easily play with strings of bits. Here is an example with python 2.7 …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Binary File Facts

    > By binary I meant read/write 0"s and 1"s of the file The 0's and 1's are read, but you can't *see* them. They are read in bytes (for example …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in using image from the label and processing it using tkinter

    Read the doc ! [Apparently](http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#cv2.imread) `cv2.imread()` expects a filename.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in display image from the selected path

    Use one of vegaseat's tkinter [examples](http://www.daniweb.com/software-development/python/code/467528/show-internet-image-with-tkinter). You can adapt the example by reading the file from your disk instead of the internet.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Binary File Facts

    > but .read() just prints the file contents not its binary What do you mean exactly ? Give a binary example (you can attach a zip or an image to …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how do I print a string backwards?

    A well known snippet >>> 'real'[::-1] 'laer' >>>
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in My code breaks in a raw_input

    Why not post the code and the exception traceback ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Object-Oriented-Programming

    Here is a long [video tutorial](https://www.youtube.com/watch?v=iyXyxvs-544) about this.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in ImportError: No module named Crypto.Cipher

    I'm using kubuntu, but it should work in debian: make sure you have the development packages for python (python-dev and libpython-dev): sudo aptitude search python-dev # then may be sudo …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to vegaseat in Starting Python

    Python 3.4.0 has just been released and has a nice new module called statistics. Here is a test ... ''' statistics_test101.py testing Python 3.4.0 and its module statistics ''' import …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in First Python project. Command line show database.

    You can improve the program by using the standard module `cmd` which purpose is to write interactive command line interpreters. I wrote an enhanced class of cmd.Cmd in [this code …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Issue with executing external python scripts from GUI

    You're welcome. Why not click on the *Mark Question Solved* button ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to find all occurrences of a substring in a string python

    I used this lst = re.findall(r"{\s[^}]*0x01\s}",str1) and it worked.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to find all occurrences of a substring in a string python

    Use `re.findall()`
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Where to download Python for Linux

    Python 3 is probably already installed in your linux system. Open a terminal and type python3 to see what it does.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Where to download Python for Linux

    I see 2 solutions 1. You wait until python 3.4 is the packaged python 3 version in your linux distro (this is currently python 3.3.2+ in my kubuntu). 2. You …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Issue with executing external python scripts from GUI

    Try to use [this command class](http://www.daniweb.com/software-development/python/code/257449/a-command-class-to-run-shell-commands) instead of `subprocess.call()` com = Command(scriptPath).run() print(com.output) print(com.error)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Detecting Button Presses

    Did you consider using a GUI such as tkinter to implement the controls ? GUIs make a difference between a button press and button release.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help with multiplication

    Use the format method. Here are the different ways to print a floating number centered in a field of length 10, with precision of 2 digits >>> s = "{val:^10.2e}{val:^10.2E}{val:^10.2f}{val:^10.2F}{val:^10.2g}{val:^10.2G}{val:^10.2n}{val:^10.2%}" …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to delete a list from a set?

    My previous post does remove a whole list from a set. You can do a = set(list1) - set(list2) or a = set(list1) a -= set(list2) # notice the minus …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to delete a list from a set?

    >>> s = set(range(10)) >>> s set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> s -= set([3,4,5]) >>> s set([0, 1, 2, 6, 7, 8, 9]) >>> …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to disable Copy/Cut/Paste on a textbox?

    Please don't revive 6 years old threads. Also this thread is about python's tkinter. It is not at all related te asp.net or jquery.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Detecting Button Presses

    Here is a very simple example using the microframework [bottle](http://bottlepy.org/docs/0.11/tutorial.html) (install with pip for example) # -*-coding: utf8-*- # webrobot.py from bottle import get, post, request from bottle import route, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Naming a variable by an item in a list

    The answer is yes it is possible to create *global* variables this way, but it is considered _poor_ programming. Here is this forbidden fruit globals().update((name, 'foo') for name in list1) …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in getting values from file records

    I don't know, it seems that you are copying and pasting code without understanding it. It can't work this way. Your code is not properly indented with 4 spaces. I gave …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with loops

    You can iterate on sorted keys: for channel_key in sorted(channels): ... The other thing you can do is use channels = OrderedDict() instead of `channels = {}`. In py 2.6, …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to slate in Questions About Auxiliary Functions

    Some remarks... I would say that a function is auxiliary if it is called and used by a limited set of functions (methods, other callables) and does not provide functionality(meaning) …
  • Member Avatar for Gribouillis
    Gribouillis

    Marked Solved Status for get timezone from time.struct_time() ?

    Hello, I am writing a little script that needs to get the timezone from an rss feed, and I am using [URL="http://www.feedparser.org/"]Feed Parser[/URL] to parse the rss feeds. The way …
  • Member Avatar for Gribouillis
    Gribouillis

    Revoked Solved Status for get timezone from time.struct_time() ?

    Hello, I am writing a little script that needs to get the timezone from an rss feed, and I am using [URL="http://www.feedparser.org/"]Feed Parser[/URL] to parse the rss feeds. The way …

The End.