• Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Comprehending Python

    > However, if I'm asked to do an exercise, I cannot quite get every step down to what I should be doing. It is because what you should be doing …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Hopelessly stuck in GUI programming

    Here is a modified version which works (with python3) up to the point where the `newWindow()` method is called. You must add the code for the popup window and subsequent …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Simple numpy map

    Why not this ? >>> import numpy as np >>> a = np.array([1,2,1,3,4,5]) >>> 0.64 + 0.12 * a array([ 0.76, 0.88, 0.76, 1. , 1.12, 1.24])
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with python and SQL

    As a bonus, you can try [my sqlite snippet](https://www.daniweb.com/software-development/python/code/472186/print-the-structure-of-an-sqlite3-database) on your database to display its structure from the command line.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with python and SQL

    I opened the database with sqliteman and the table was indeed empty. What happened is that you forgot a statement conn.commit() in `dbinsert.py` before closing the connection. Your inserts occurred …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with python and SQL

    You can install sqliteman to browse the database. Type sudo apt-get install sqliteman in ubuntu or other debian distros. Then open your database file with sqliteman and examine the contents …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in wmd bot

    Why do you need a bot ? What do you want to do ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What's the best Python GUI framework?

    For simple interfaces such as displaying or capturing data, a super easy solution is [guidata](https://pythonhosted.org/guidata/).
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in script to search for .war files

    You can use a breadth-first traversal to find the webapps folders first, then walk these folders import collections as col import itertools as itt import os def breadth_first(root, subnodes_func, max_depth=None): …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Need quick help for executing a Python file in this way...

    What went wrong ? With the shebang line, it should work readily.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in set an image as a Tkinter window background

    You could perhaps create an image in a canvas widget, then draw other widgets above the canvas.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to get back GRUB to boot up?

    I suggest to use the boot-repair disk as Slavi did in [this thread](https://www.daniweb.com/hardware-and-software/linux-and-unix/threads/488911/try-hd-0-0). In principle, it should work. It seems strange to me that you don't have a linux swap …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with installing ttk module

    That's many t's and k's.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with installing ttk module

    In python 2, use import ttk why don't you read the answers ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to print letters randomaticly

    The `random` module may be helpful.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to use CURL to implement SFTP

    I don't know much about it, but there are many links about this. This one for example looks good http://www.unixlore.net/articles/using-curl-for-ftp-over-ssl-file.html . It seems to me that you should at least …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with running the program

    Why don't you use the [other thread's solution](https://www.daniweb.com/software-development/python/threads/490499/problem-with-creating-a-file) ? I wrote all the code to create the file if does not exist and also to be able to run the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in linux and unix

    https://en.wikipedia.org/wiki/History_of_Unix
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to L7Sqr in How to start file manager in specific folder without locking terminal?

    You can do this with `screen`. For example: screen -d -m nautilus . Will start a screen session to host the `nautilus` process (without attaching to it) and will exit …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to start file manager in specific folder without locking terminal?

    @JasonHippy It doesn't work with konsole and dolphin. When I close the konsole, it kills dolphin.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to start file manager in specific folder without locking terminal?

    As a pythonista, my first try is python -c "import subprocess as sp; sp.Popen(['/usr/bin/dolphin'])" 2>/dev/null and it works. Dolphin is launched and the terminal is not locked. You can even …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with Tkinter code (button and label)

    Again, your error message is for a modified code. I think you're forgetting that the `pack()` method returns None, which means that you must write a separate statement to pack …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with installing ttk module

    In python 2 in kubuntu, I can import it directly import ttk In python 3 it is from tkinter import ttk `ttk.py` should be in the folder lib-tk in your …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with Tkinter code (button and label)

    There is no line `Label['text'] = 'Good morning'` in the code you posted before. Also this error message is very explicit. You are using a variable named `Label` which has …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Problem with Tkinter code (button and label)

    Python says why it doesn't work Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'Tkinter' Nothing is more important than the error message! …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with creating a file

    Ok, here is the code section with comments. I hope it helps #!/usr/bin/env python3 # -*-coding: utf8-*- import os import pickle DBFILENAME = 'films.db' # The next line initializes a …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in The Importance of Perseverance

    I agree with Hericles that this is an impressive but incomplete achievement. Once you know why moving that line made the difference, a very important step is to find the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with creating a file

    Ok, here is a way. Try to understand every detail #!/usr/bin/env python3 # -*-coding: utf8-*- import os import pickle DBFILENAME = 'films.db' loaded = False favorite_movies = [] def pathtofile(filename=DBFILENAME): …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with creating a file

    Without the exact code, it is impossible to debug. For example in my code, there is no `pickle.load( open("films.db", "rb"))`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with creating a file

    In fact it does not matter. However, a standard program pattern is # shebang line (#! ...) # coding """program docstring """ # imports ... import os import pickle # …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in problem with creating a file

    You can create a pickle file containing an empty list of favorite movies #!/usr/bin/env python3 # -*-coding: utf8-*- import os import pickle # use db file in the same folder …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help needed to retrieve files

    On my system, `man parted` shows option -l, --list lists partition layout on all block devices
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in creating list of lists

    If you add lists of integers together, you will always obtain a list of integers. If you want a list of sublist, you must *append* sublists to pack: pack.append(sublist) This …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in count of substrings. append method

    Ok, so here is a new standard lib candidate import re def overcount(S, sub, start=0, end=None): """overcount(S, sub[, start[, end]]) -> int Return the number of overlapping occurences of substring …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Introducing the symboldict module

    Upgrade today to version 0.3.0! It is an optimized version with respect to the efficiency of attribute access. To upgrade, use pip install --upgrade symboldict 2015 jan 18 Edit: I …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to know which row of array that qualify some conditional state?

    The result `(array([2]),)` is a tuple containing a single item which is an np array. The item 0 of this tuple is the first item, ie the array. This array's …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to know which row of array that qualify some conditional state?

    Sure index = np.where((a[:,0] == 6) & (a[:,1] == 5))[0] X = index[0]
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to know which row of array that qualify some conditional state?

    You can write if np.where((a[:,0] == 6) & (a[:,1] == 5))[0]: print('yes') else: print('no') Can you explain what you want to do in a more precise way ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to know which row of array that qualify some conditional state?

    Well, as 7 is in the first column and 5 is in the second column, the result is hardly suprising >>> a[:,0] array([1, 3, 6, 7]) >>> a[:,1] array([2, 4, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How can i creat e text file to use as a database in python

    @snippsat I like the concept, although being based on top of sqlalchemy may have a performance cost for *dataset*. The greatest thing in this may be the *datafreeze* command that …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to snippsat in How can i creat e text file to use as a database in python

    A test with [dataset](http://dataset.readthedocs.org/en/latest/index.html),database as simple as it get. So here i have a player list that i store in a Sqlite(comes with Python) database. import dataset player_lst = [ …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in do-while loop in python

    There was a PEP about this, https://www.python.org/dev/peps/pep-0315/ . It was discussed and rejected by Guido Van Rossum who gave the reason: >Please reject the PEP. More variations along these lines won't …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How can i creat e text file to use as a database in python

    Being able to save data to disk and retrieve it is equivalent to being able to convert this data to string and then back to data. Indeed, you can always …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Installing Kubuntu

    You can also burn a DVD with the appropriate version of kubuntu. Go here http://www.kubuntu.org/getkubuntu and choose Kubuntu 14.04 (long term support). If your PC is 64 bits choose the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how do I make a class instance act as a class??

    Hey tcll, here is my latest version. There are probably some bugs which you can discover by testing but I think it can handle pretty complex assignment statements. It is …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to call a function from linux terminal

    Use argparse ! It is by far the best way to do this #!/usr/bin/env python3 # -*-coding: utf8-*- def sayhi(): print('hi everybody!') def goodbye(): print('see you soon!') if __name__ == …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to call a function from linux terminal

    Then the script must take an argument which is the function name. The best thing to do is to use the argparse module to parse the command line, something like …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to call a function from linux terminal

    Can you post your script? It depends on what you want to do. For example, here is a function which prints hello world #!/usr/bin/env python # -*-coding: utf8-*- # This …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Condition-controlled loop

    The else part must go with the for. It is only executed if the for loop was not interrupted by a break statement for i in range (2, 25): if …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in extracting floats from a string

    You can do it in a one-liner total = sum(float(x) for x in '1.32, 5.32, 4.4, 3.78'.split(','))

The End.