• Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python program only acts on the first line of string?

    Ok, a while loop should do the trick def space_to_tab(work_string): """Replace spaces with tab at the beginning of each line of a text """ result = [] s_to_tab = 4 …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python program only acts on the first line of string?

    You can make it a helper function for a function which acts on a full text: def _space_to_tab(work_string): """Replace spaces with tab at the beginning of a line of text …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What vehicle do you drive?

    In a Prius, there is a small battery which is the same as in other cars and cost the same price. I changed it only once. There is also a …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python basic doubt

    Because your home directory is `/home/weber`. If you want the other path, use os.path.join(os.path.expanduser('~'), 'jbwrk', 'xsend.py') However, I think `/home/weber/.xsend` was probably meant. It may be a configuration file or …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python basic doubt

    It means a string representing the file system path to the file or directory `.xsend` in your home directory. A better way to obtain it is os.path.join(os.path.expanduser('~'), '.xsend') This code …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What vehicle do you drive?

    I have 2 Toyotas: a Prius, great great great hybrid car ! and an Aygo.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in cant print, but only from a site

    Sometimes there are errors in a postscript or pdf document. There are several things you can try. If you can open the document with several programs, it may print with …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to return all characters that are within the Unicode 'Lu' class

    If you do `>>> help(chr)` in python 3, you get Help on built-in function chr in module builtins: chr(...) chr(i) -> Unicode character Return a Unicode string of one character …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python-Keep only the subdirectories in a text file with paths

    I would use something like this. This code assumes that lines starting with `'` contain values and the other lines are folder lines. def filter(lines): last = None for line …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Bad computer habits

    > i have never learned to type properly I was unable to type properly until I purchased a *bépo* keyboard, which is a french version of the *dvorak* keyboard. With …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Changing all tabs to spaces line by line

    This program may help # -*-coding: utf8-*- __doc__ = ''' ''' import sys S4 = " " * 4 def main(): while True: line = sys.stdin.readline() if not line: break …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Bad computer habits

    One of my bad habits is to use the mouse when there is a keyboard shortcut to do the same task. My hand reaches the mouse before my brain has …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Number Analysis

    Start with > Write a program that asks the user to enter a series of 20 numbers. then post your code in this thread :)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Trying to write encoded byte to file, line by line

    `b64encode()` return a bytes. Convert it to str with decode result = base64.b64encode(username).decode('utf8')+'\n' Notice that `result` has type `str`, while `username` is a `bytes`. I suggest not to use the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in emptying trash using terminal

    Try sudo apt-get install trash-cli It works for me in kde, providing commands trash-put trash-empty trash-list restore-trash See [Click Here](https://pypi.python.org/pypi/trash-cli/).
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Linux shell scripting

    I did not read it, but here is an appetizing guide [Click Here](http://www.tldp.org/LDP/abs/html/)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Ancient Dragon

    Goodbye Ancient Dragon, RIP.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python 3, mix 2 lists in print

    Don't print directly, use strings operations to create new strings with your data instead, for example >>> args = (1,2,3,4) >>> L = [str(n) for n in args] >>> L …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Was wondering what type of Linux Distro ?

    The menu logo at the bottom left corner looks like a clover. I search a distro with a clover logo and I found fuduntu linux which has a very similar …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to JorgeM in Science

    You are asking about tips regarding being a teacher? Well, 1... its in your best interest to know what you are talking about before standing in front of a room …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in whats wrong with my code?

    When python says invalid syntax, it shows a point in code near the point where there is an error File "foo.py", line 11 print("Therefore, your total shipping charge would be …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to Lardmeister in Mouse position Tkinter

    Double click on the source code and it will highlight. Then copy and paste without the line numbers.
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to <M/> in What Does the Fox Say?

    the fox says: [Verse 1] Dog goes "woof" Cat goes "meow" Bird goes "tweet" And mouse goes "squeak" Cow goes "moo" Frog goes "croak" And the elephant goes "toot" Ducks …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Make a for loop assign different variables?

    The most efficient way is to append the rows one at a time to a **list**: ... matrix1_rows = input(...) matrix1_rows = int(matrix1_rows) ... matrix1 = [] for i in …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in ubuntu /boot folder missing

    Did you try to run the [boot repair disk](http://sourceforge.net/projects/boot-repair-cd/?source=directory) ? Edit: sorry, this is 6 months old :) I guess the OP managed to boot.
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to Lardmeister in Reading date from DB issue

    Is this part of the Millennium bug?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Convert string to binary

    I have a fast function in this snippet [click here](https://www.daniweb.com/software-development/python/code/221031/string-to-bits#post1484218).
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Reading date from DB issue

    Note that there may be some more trouble if the database contains '29-FEB-00' because 2000 is a leap year, and not 1900.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Controlling all the slaves from Master

    I read about a python module named [SaltStack](http://docs.saltstack.com/en/latest/) yesterday. I think it can distribute commands the way you want.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How do you round numbers in Python?

    If you want to round the number for printed output, the correct way is to use string formatting operations. [Click here](https://www.daniweb.com/software-development/python/code/232375/string-formatting-specifications) to see some examples.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Reading date from DB issue

    I don't know why it reads 1899. Here is a possible patch >>> import datetime as dt >>> def patch_datetime(x): ... delta = x - dt.datetime(x.year, x.month, x.day) ... s …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in iPython Notebook

    The main drawback of ipython's notebook is its limited editing capabilities. A web browser is far from being as responsive as an IDE and most code editing features are missing.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Name a thread and stop it

    I would tend to use a Condition object and a `wait()` with timeout instead of a timer. Here is an example #!/usr/bin/env python # -*-coding: utf8-*- from __future__ import (absolute_import, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to append a string to only consonants in a list?

    Think about where you are going to insert `op` if the phrase is `street`. You are going to insert `op` when you meet the first `e`, because it is not …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to JasonHippy in C++ graphics library

    Another alternative to SDL is [SFML](http://www.sfml-dev.org/) - Small Fast Media Library. It's in C++ and is extremely simple to use!
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python path Linux

    `import MetaMP3.py` should be `import MetaMP3`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Creating a program that creates a rectangle with two mouse clicks in Python

    >I have this but I dont know how to code it so that it works with only two clicks, 4 works but not 2. There is a line missing somewhere, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python path Linux

    write export PYTHONPATH="$HOME/bin/libpy:$PYTHONPATH" at the end of the file /home/garrett/.bashrc Then restart the terminal.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Concatenate strings in Pyhthon?

    I dont see a `return` statement in `cadena_aletoria()`. It means that it returns `None` instead of a string.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Warning: Linux security bashed by 22 year old remote code execution bug

    The test line is **not** safe. Here is my result $ env x='() { :;}; echo vulnerable' bash -c "start patching now" vulnerable start: Tâche inconnue : patching `Tâche inconnue` means …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Warning: Linux security bashed by 22 year old remote code execution bug

    I don't dare execute your test line now.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python

    The definition of the assignment statement is [click here](https://docs.python.org/3/reference/simple_stmts.html#assignment-statements) in the docs. As you can see, the left part of it can be a sequence of *targets* separated by commas. …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Dynamically update label text python Tk

    Replace the beginning of Pag01 with class Pag01(): def __init__(self, master): tk = Tkinter self.master = master self.label1_text = ... ...
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to woooee in Dynamically update label text python Tk

    grid() returns None so self.label1 equals None in the code you posted. There are two ways to update a label, illustrated below. There is way too much code here for …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Functors in Python

    I wrote a code snippet some time ago with a base class for functors in python, [click here](https://www.daniweb.com/software-development/python/code/369943/a-base-class-to-define-functors). I use this class quite often to code reasonably-sized tasks which can …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited A base class to define functors.

    A functor, or function object is sometimes a convenient way to encapsulate helper functions and data needed to achieve a small task, and also to share data between calls to …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Count seconds in the background (Python)

    You can reach the same result without a thread. Can you explain why you start a thread ? Here is my code #!/usr/bin/env python # -*-coding: utf8-*- from __future__ import …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Assigning Sublists

    > I couldn't concatenate a list & a string so I forced 'poisonous' into a list by adding brackets A more common way is poisonous = flowers[-1:] Notice that this …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to masterofpuppets in ToolTip box

    [CODE]from Tkinter import * root = Tk() tipwindow = None # Creates a tooptip box for a widget. def createToolTip( widget, text ): def enter( event ): global tipwindow x …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Print with line and file information

    Uploaded version 0.0.3 (uses `sys._getframe()` instead of `inspect.currentframe()`)

The End.