• Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Dealing with datetime objects

    You could perhaps try df[...] = df[...].map(lambda x: datetime.strptime(x, '%H:%M:%S'))
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in HP printing

    Did you run hp-setup ? [https://help.ubuntu.com/community/sane](https://help.ubuntu.com/community/sane) Edit: the hplip page [http://hplipopensource.com/hplip-web/models/other/envy_5640_series.html](http://hplipopensource.com/hplip-web/models/other/envy_5640_series.html) gives a list of distros for which the scanner works. If your distro is in the list, there must …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Working With PDF files

    I discovered by ixquick(ing) that LibreOffice can create **pdf forms** too. It seems quite plausible to me that python can be used to fill the forms by altering the opendocument …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Working With PDF files

    Note that libreoffice can also convert files from the command line using a syntax such as soffice --headless -env:UserInstallation="file:///home/user/.libreoffice-alt" --convert-to pdf[:filter] --outdir "/tmp" myfile.odt Edit: different filter parameter are possible, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Working With PDF files

    From my experience, it is usually easier to create pdf from another format, such as latex or rst or doconce or whatever. I never created a pdf file with *forms* …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to megaflo in parsing xbrl

    Please put the shovel down before the hole gets too big and you can't climb out :) Regular expressions are not the way to go for something that is XML …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python /

    There is no backslash in your string, so I don't see the problem. there is only an ordinary slash, which has no special effect. Please describe what you expect.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to get SRC of img tag

    This seems to be working >>> url = urllib2.urlopen('http://www.python.org') >>> soup = BeautifulSoup(url) >>> srcs = [img['src'] for img in soup.find_all('img')] >>> srcs ['/static/img/python-logo.png'] >>>
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Bigner

    It seems to me that you only need to remove lines 14 and 18 from the above program to get a start.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Hangman

    Remove all the `aNa` variables from this program. Use `word[N]` etc.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in usb stick not auto mounting

    Did you read this help page https://help.ubuntu.com/community/Mount/USB ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in decode string

    Note that in python 3, the built-in function `open()` has an `encoding` parameter. You don't need to use `codecs.open()`. Otherwise, use `io.open()` for cross-python code :) Python 3.4.0 (default, Jun …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in rsync from a script not working right

    I had a lot of success using [luckybackup](http://luckybackup.sourceforge.net/manual.html) instead of rsync (actually, luckybackup wraps rsync but I think it is much easier to use). You can install it with apt-get. …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Fibonacci program

    I don't understand why the result needs to be 1 1 3 5 8 13, as the number 2 belongs to the Fibonacci sequence https://en.wikipedia.org/wiki/Fibonacci_number .
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python objects and references

    AFAIK, there is no inplace augmented assignment operator for integers in python. It means that in foo = 4 foo += 1 the second statement creates a **new** int object …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in moving and renaming files using Python

    Start by walking the source folder with `os.walk()` for d, dirs, files in os.walk(sourcedir): print(d, dirs, files)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Calculator

    The arithmetic operations don't work for me. Only the sqrt works.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to sent the output into a txt file (with giving the destination path)

    It is very easy to write the output to a text file with io.open(textfilename, mode='w', encoding='utf-8') as ofh: ofh.write(theoutput) If you want to enter interactively a directory path to save …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python script hang over the screen method in cloud

    You probably need to find some documentation about the timeout parameter in `requests.get()`, or perhaps you could try [this solution](http://stackoverflow.com/questions/21965484/timeout-for-python-requests-get-entire-response) with `eventlet.Timeout()`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python script hang over the screen method in cloud

    This function should be rewritten in a non recursive style. If the connection times out every time, it will call itself indefinitely until it reaches the recursion limit. Did you …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to DragonMastur in Converting C loops to Python

    karmstrong ask in the Python chat if any one was farmilar with converting a for loop in C to Python. Here is a program in python that will do it …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Converting C loops to Python

    Instead of parsing the C code by hand, you could start from an ast produced by an existing C parser written in python: module [pycparser](https://github.com/eliben/pycparser). Here is an example, adapted …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    Sorry I don't understand this code. I think I explained what I meant as clearly as I could, but if you really don't understand it, you can use your own …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to exec functions with arguments in a namespace??

    Great! A small detail: >>> from types import FunctionType >>> FunctionType <type 'function'> Using `FunctionType` instead of `function` is a little less *amateur*.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Fibonacci Numbers

    Because a new total is computed at line 7. This total is never tested at line 6. What you can do is while True: total = number1 + number2 number1, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to exec functions with arguments in a namespace??

    A more complete example would be useful. I don't see where it fails. Did you create the clone function with the NS dictionary ? One thing to try is NS['__builtins__'] …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to exec functions with arguments in a namespace??

    I tend to think that the separate exec is not necessary. Try to pass the execution namespace directly when the clone is created.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    You need to compute the save_path from the filename argument (which is the path to the source file). The idea is that you dont dictate the path individually, but you …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to exec functions with arguments in a namespace??

    Here is something >>> def f2(): print 'test failed' ... >>> def f(a1,a2): f2() ... >>> function = type(f) >>> fclone = function(f.__code__, {}) # function with empty func_globals >>> …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    There is still a for loop in destination_csv(). You dont need it. This function handles only a single filename which is already a parameter of the function. > do you …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    You dont need to copy or move or rename any file. You only need to create a *string*, the system path to the destination file. You don't need to create …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    Indentation of line 87 is incorrect. Now here is an hypothetical example which shows how destination_csv() should work >>> obj.destination_csv('C:\\Playground\\Samples\\FOO.xml') C:\Playground\Samples\CSV_Reports\FOO.csv Edit: I shortened the path for the example.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    You don't need to change the initial `findFiles()` function which calls `open_and_parse()`. The `destination_csv()` function must **not** rename any file **nor** iterate over a listdir etc. In your original code, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    The directory needs to be made only once. `destination_csv()` does not *rename* the XML file. It only creates a *new* destination filename where the csv data will be written without …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how to exec functions with arguments in a namespace??

    You could use exec "f()" in {'f':f}
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    You did not understand my advice the function `destination_csv()` is only supposed to take a filename argument (such as `C:\foo\bar\baz\awesomedata.xml`) and return another string, such as `"C:\\Users\\Desktop\\Playground\\Samples\\CSV_Records\\awesomedata.csv"`. It is not …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python Checkers Multiple Jumps not Working Properly

    For an even better debugging experience while applying woooee's advice, use the [printat module](https://www.daniweb.com/software-development/python/code/479747/print-with-line-and-file-information) and write from printat import printat print = printat at the top of your file.
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to Harsha_1 in cli-github

    # GITHUB INSIDE THE CLI # This is my repo : [https://github.com/harshasrinivas/cli-github](https://github.com/harshasrinivas/cli-github) It's a **python app** to display **Github inside the Command line Interface** It uses the GITHUB API I …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubleshooting utility to parse XML objects

    You can write dest = self.destination_csv(filename) with open(dest, 'wt') as fh: writer = csv.writer(fh) writer.writerows(self.makerows(flatten_dict(root))) Then you need a method def destination_csv(self, filename): """Compute a destination filename from a source …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Alternative Email Platform Server

    I know universities which use zimbra, and it works very well.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Can't find syntax error

    A dictionary is created with `{}` delimiters, not `[]`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in chown not working

    `chown` has a `-v` option, it may help.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Ubuntu and Zorin not opening thunderbird and firefox?

    No problem with firefox in kubuntu.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Paper, Scissors, Rock program not working?

    You can also use while playermove not in ('paper', 'scissors', 'rock'): ...
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to Louis_2 in Paper, Scissors, Rock program not working?

    I solved it, The second while loop needed `and` instead of `or` because it checks for one of the three parameters not all three.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Restart your python program.

    Here is a small tkinter example which shows this import Tkinter as tk # adapted from http://www.python-course.eu/python_tkinter.php counter = 0 def counter_label(label): def count(): global counter counter += 1 label.config(text=str(counter)) …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Restart your python program.

    > I'm using IDLE Idle has 2 processes, the first one (say process A) to run the IDLE GUI, the second one (say process B) to run your python code. *Restarting …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python 3 TypeError: 'str' object cannot be interpreted as an integer.

    The signature of the `bytes()` function gives the solution class bytes(object) | bytes(iterable_of_ints) -> bytes | bytes(string, encoding[, errors]) -> bytes | bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer | bytes(int) …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in looking for a good fun DDOS script in python

    Do you really mean a distributed denial of service attack ? Where would it be funny or cool ?
  • Member Avatar for Gribouillis
    Gribouillis

    Liked / Shared looking for a good fun DDOS script in python

    Hello everybody. I'm looking for a good cool and fun DDOS script in python. Any suggestion? How can I create a good fun DDOS script using URLLIB?!

The End.