• Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Open CSV file and write new file

    When the string is `"Wired Performance Testing ONeTouch AT"`, the first line in `does_match()` calculates the same in lower case: `"wired performance testing onetouch at"`. Then it checks if this …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Open CSV file and write new file

    You must take the time to understand the code. I wrote lowercase strings in `searched`. If you don't understand the code, it is a waste of time.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Copy/move all sub-directories from a folder to another folder using python

    Here is the code of `distutils.dir_util.copy_tree()` def copy_tree(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0): """Copy an entire directory tree 'src' to a new location 'dst'. Both 'src' and 'dst' …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to iterate a list of imported modules

    Perhaps try [this code snippet](http://www.daniweb.com/software-development/python/code/238387/really-simple-plugins-loader-import-all-modules-in-a-folder-in-one-swoop). Also please post code with correct syntax, preferably runable code.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Open CSV file and write new file

    You can write searched = ['onetouch at', 'linkrunner at', 'aircheck'] def does_match(string): stringl = string.lower() return any(s in stringl for s in searched) for row in reader: if any(does_match(col) for …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Copy/move all sub-directories from a folder to another folder using python

    I think [shutil.copytree](http://docs.python.org/2/library/shutil.html#shutil.copytree) should work.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubles with EOFs...

    I don't know how you launch the program from notepad++, but if you can invoke python with option -i, it should prevent the cmd from closing.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Troubles with EOFs...

    Apparently, the stream `sys.stdin` was closed when your program attempted to read a line. In which context did you run the program ? Which OS first ? was it in …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Solving the quest of the knights who say ni

    First, use the `threading` module instead of `thread`, so start a thread with t = threading.Thread(target = runner, args = (list(previous_moves), processing, i)) t.start() I wrote `list(previous_moves)` because this creates …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Convert between various ieee754 floating formats.

    This code snippet provides methods to convert between various ieee754 floating point numbers format. For example double precision to single precision. The format is given by a pair (w, p) …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Convert between various ieee754 floating formats.

    This code snippet provides methods to convert between various ieee754 floating point numbers format. For example double precision to single precision. The format is given by a pair (w, p) …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in floating point arithmatic, WTF am I doing wrong?

    There is still no bug in my code from anyfloat import anyfloat _size = { 4 : (8, 23), 5 : (8, 31)} def variable_float(n, bytes = 4): return float(anyfloat.from_ieee(n, …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Calling external scripts from different buttons ina GUI in Python

    I think the first thing to do is avoid the `import *` expression as much as possible. For example, use from tkinter import * from tkinter.messagebox import * from tkinter …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in password program from txt file

    I could not explain this better than [the python documentation](http://docs.python.org/3/library/functions.html?highlight=repr#repr). An advantage of printing the repr of a string is that you can see the non printable characters contained in …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in password program from txt file

    After line 3, add print(repr(password)) print(repr(userguess)) then you can compare visually the two strings.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python script and SMTP server

    I don't know this subject but did you try to connect using the standard module `smtplib` ? Also do you have a way to check that the server is running …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to scudzilla in Self Naming Varibles

    Why not use a list? Or maybe a dictionary?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how do I use a module as a class?

    I see that Alex Martelli's solution is the same as mine. This is very encouraging.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in how do I use a module as a class?

    Normally, you can't do that and you should not be doing that. However this is python and most things happen to be possible. A trick is to replace the module …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help in python SQL

    Try sql = ("SELECT * FROM `emaillogs`" " WHERE `id` BETWEEN {i1:d} AND {i2:d}" " ORDER BY `id` DESC").format( i1 = int(limit1), # type checking with conversion i2 = int(limit2), …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help in python SQL

    It seems that you must use the LIMIT keyword in the SELECT statement, as described in the [mysql documentation](http://dev.mysql.com/doc/refman/5.0/en/select.html). For example SELECT * FROM tbl LIMIT 5,10; # Retrieve rows …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in need help with python trig and Taylor Series

    For the `cos(x)`, add `pi/2` to x, then compute `sin(x)`. For this use the Taylor series as ddanbe said above, but for faster convergence you can replace x with `x …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in receiving text from external application

    Then I must have missed something. I don't have the sublime editor to test your code unfortunately.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in receiving text from external application

    I don't see how you can receive input from an external editor using `subprocess.Popen()` since the external editor does not usually send user input to the outside world (via stdout …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in receiving text from external application

    I think you are trying to do something completely impossible. The first argument in Popen() must be a valid command line (either a string or a list, see the doc) …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in replacing dynamic replacement of class instances

    As always, your code violates every rule of good design. It is possible, in theory, with a statement such as C.__class__ = B However you may find more help if …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Created Print the structure of an sqlite3 database

    This python script prints all the columns of an sqlite database which path is given as argument.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to search sqlite3 collumns

    Here is another way without sqlalchemy import sqlite3 conn = sqlite3.connect('menus.sqlite') cur = conn.cursor() s = "PRAGMA table_info(`menu`)" try: cur.execute(s) print(cur.fetchall()) finally: cur.close() conn.close() See [table_info](http://www.sqlite.org/pragma.html#pragma_table_info) and also try the …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in How to search sqlite3 collumns

    This works for me with sqlalchemy from sqlalchemy import create_engine from sqlalchemy.engine import reflection engine = create_engine('sqlite:///menus.sqlite') # //// for abs path insp = reflection.Inspector.from_engine(engine) print insp.get_table_names() # print list …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in convex hull

    I suggest that you translate [wikipedia's pseudo-code](https://en.wikipedia.org/wiki/Graham_scan) into python. It looks like 20 lines of code ...
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in sorting of list using list.sort

    Replace last line with words[:] = [word for count, word in vow_count] This will replace the contents of list 'words' by your result. Also the line count = 0 should …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Restoring data in web2py

    I don't know web2py but did you explore the database with an external tool (phpmyadmin, sqliteman, ... depending on your db) to see if the data is still there ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Optimize Code

    *Optimizing* is different from reducing code size. Optimizing usually means change the code in order to reduce the execution time. Changing the code in order to have a better looking …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Best way to construct a class with multiple choices

    You can also rename the class `_Foo` and expose an alias class _Foo(object): ... Foo = _Foo.figure_it_out In client code, you get `Foo(a=2)` etc, and you are still free to …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Best way to construct a class with multiple choices

    > Do you think a class decorator might be a suitable way to do this? I don't know what you mean exactly. This would make sense in order to add …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Restart your python program.

    This snippet defines a function restart_program() which restarts your python program from within your python program.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Is current user member of group www-data ?

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

    Replied To a Post in please who can solve this for me

    > thanks but can you please help with the program preview First meditate what Dani wrote at the top of the [software development page](http://www.daniweb.com/software-development/2) > Our Software Development forum category …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Best way to construct a class with multiple choices

    One thing is clear: the `__new__()` method is *not* the place where this should be implemented. The role of the `__new__()` method is to create an instance before this instance …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in properties

    The assignment statement r.size = 150, 100 is equivalent to r.size = (150, 100) As far as python's syntax is concerned, a single value is assigned, which is a tuple …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in please who can solve this for me

    Consider a combination `(c,t,b)` with `n-4` tyres, if any. Add a car: you get a combination with `n` tyres. This covers all combinations having at least one car. It remains …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python linux executable

    Try [PyInstaller](http://www.pyinstaller.org/) perhaps. Notice that most linux distributions ship with python 2 or 3 installed or both, or the other one can be installed with a few keystrokes, so I …
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to akiva.berger in Reading Excel file in Python

    just put this together for myself in the event your still in need: from openpyxl.reader.excel import load_workbook def readxl(): database = [] wb=load_workbook('file name') for sheet in wb.worksheets: for row …

The End.