• Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in checkbox form in python

    You probably have a tuple or a list when you check more than 1 file, and a str or unicode when you check only one file. You could try val = …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Trying to make the user write to a file and seeing if it exists

    You can start with this import os print('Enter a file name to save your database to.') name = input('Enter name of text file: ').strip() if name: name = os.path.expanduser(name + …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in if multiple statements

    If you can't upgrade to python 2.7, you could perhaps run the function check_output extracted from python 2.7's subprocess module def check_output(*popenargs, **kwargs): r"""Run command with arguments and return its …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Which is the best application to connect Linux remotely

    ssh maybe ...
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in New to Python- calculating minimum, maximum, and average of a input list?

    You must call the `min()` and `max()` functions with the argument `scoreList` instead of `count`. The same holds for `sum()` print ('Minimum: ', str(min(scoreList))) print ('Maximum: ', str(max(scoreList))) You can …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in if multiple statements

    `os.system()` is long deprecated, and it does not return the command's ouput. [Use](https://docs.python.org/2/library/subprocess.html#subprocess.check_output) import subprocess platform = subprocess.check_output("dmidecode -s system-manufacturer", stderr=subprocess.STDOUT, shell=True) also `platform.dist()` is deprecated, use `platform.linux_distribution()`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Archimedean spiral

    This code runs without error. I'm not sure it's computing what you want import numpy as np T = 5 N = 50 a= 2. # will turn the spiral …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in platform.distribution

    According to [the python documentation](https://docs.python.org/2/library/platform.html?highlight=platform#platform.linux_distribution), `platform.linux_distribution()` returns a tuple `(distname, version, id)`. For example on my computer $ python -c "import platform; print(platform.linux_distribution())" ('Ubuntu', '14.04', 'trusty') What does it print …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Python/tkinter logins/popups not working

    It is a lot of code. It seems to me that only the main window should have a `Tk `instance as `self.GenericGui`. Other windows should probably have a `Toplevel` instance.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Changing a string variable value to another string value

    string = 'Hello' print(string) string = 'Bye' print(string)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Linux - Bash Programming

    Try by reading the manual of the date command. Type man date in a terminal. Read the section about the output format. On my computer, typing date -u +%-H currently …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in chimical equations programming

    The computer does not understand much. The computer can produce some output, being given a certain input. Before writing a program, you can start by defining the output that you …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in The Cyberg Project

    Instead of writing an OS, why don't you join a team working on the linux OS ?
  • Member Avatar for Gribouillis
    Gribouillis

    Gave Reputation to cereal in How to install and use pyinstaller in Kali linux

    Hi, you should not need the win32 version, just download the archive to a specific path, for example `~/sources/`, extract and create a link to `/usr/bin/` so that the script …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Py2exe unable to use linecache

    great ;) !
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Py2exe unable to use linecache

    In the heart of the linecache module are these two lines with open(fullname, 'rU') as fp: lines = fp.readlines() You could use this to read the file's contents.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python list comprehension

    > So is student a dictionary in each iteration of this code? What student actually is depends on the pymongo api. You could `print(type(student))` to see what it is. In …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in python list comprehension

    This is equivalent to tmp = [] for student in collection.find(): if student['mark'] == 99.0: tmp.append(student['mark']) students = tmp
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in add new key-value pair to a dict

    > can't we append something to a dictionary?? No, a python dictionary does not have an `append()` method. A dictionary is not an ordered data structure, unless you are using …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help with inheritance

    We're going to track the moment where the start variable becomes None. Replace the `run()` method with this one def run(self): start="Intro" while True: next_start = self.Scenes[start].enter() if next_start is …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help with inheritance

    At line 127 above, the code returns `scene_intro` instead of `"scene_intro"`. There is a high probability that this is your bug.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help with inheritance

    You say it didn't work, but what is the error message ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Update label text after pressing a button

    You can try L2.config(text='Foo')
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Mechanize not recognized by py2exe

    @Mhmmd In a terminal, paste this python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" and hit enter. It will print the path to the python library. Also in the forum please …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Unexpected behavior of static variables in pyton

    I know very little about django, but obviously it is a part of the ORM magic. You could try return str(UserProfile._meta.get_field('name')) https://docs.djangoproject.com/en/1.8/ref/models/meta/ It is a strange way to define `__str__()` …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Help with inheritance

    Try to replace `self.Scenes.get(start).enter()` with `self.Scenes[start].enter()` .
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in traceback problem

    First a little test: >>> def av(L): ... return float(sum(L))/len(L) ... >>> 0.1 * av([100, 92, 98, 100]) + 0.3 * av([82, 83, 91]) + 0.6 *av([89, 97]) 91.14999999999999 This …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in traceback problem

    Well, are sure it is `0.1 * homework + 0.3 * quizzes + 0.6 * tests` ?
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in traceback problem

    hi! `get_class_average()` takes a list of students, not a list of strings. Use get_class_average([alice])
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What am I doing wrong?

    Does the socket actually receive the `hello` data ? You could log things log = log_to_file('bot', 'bot.log') while True: r = s.recv(1024) log.info('socket received: ' + repr(r)) readbuffer = readbuffer …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Generate unique words based on computer time

    @ddanbe I thought again about your question, and it occured to me that I was losing some granularity by converting a number of seconds since the epoch into a string. …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Generate unique words based on computer time

    > is there any particular reason for 11 characters? No, it is due to the granularity of floating numbers on a 64 bits processor :)
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Generate unique words based on computer time

    Version 0.2.1 sorts ascii letters to generate ordered words (at least as long as generated words have 11 characters). This is particularly useful if this code is used to generate …
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Generate unique words based on computer time

    This snippet defines a function returning new identifiers created from reading the computer's time.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Making a looping menu using oop on python

    Remove the test in `run()` def run(self): start="MainMenu" while True: start = self.Menus.get(start).enter() Also you could replace `exit(1)` with `exit(0)`. A value of 0 means that the program exits normally (without …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in tkinter function help!!

    Hello! This is a standard pattern when you have numbered variable names var0 var1 var2 etc. The solution is to use a list and `var[0], var[1], var[2]` etc from tkinter …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Making a looping menu using oop on python

    There are too many parameters in `stuff()`. Use simply def stuff(self): ...
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Making a looping menu using oop on python

    The key is in the Engine class class Engine(object): def __init__(self, scene_map): self.scene_map = scene_map def play(self): current_scene = self.scene_map.opening_scene() last_scene = self.scene_map.next_scene('finished') while current_scene != last_scene: next_scene_name = current_scene.enter() …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in What is SSH commands for this: run 20 times, break 2 seconds, and repeated

    If there is a python interpreter, you can try this perhaps python -c "$(echo -e "from subprocess import call\nfrom time import sleep\nwhile True:\n for i in range(20): call('wget http://test.com', shell=True)\n …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Making a looping menu using oop on python

    You are writing classes, but the program doesn't do anything besides defining those classes. It doesn't make much sense.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in While loop

    When you write while expression: ... python evaluates expression as a boolean value (which can only be True or False). The result is the same as using `bool(expression)`. Here are …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Making a looping menu using oop on python

    I don't understand your program. The first thing to do is always to solve the error messages sent by the python interpreter itself. Can you post the current state of …
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Pythod - Need help with homework assignment

    It is because your numbers are all written on one line in numbers.txt. In the first program, replace `afile.write(line)` with `afile.write(line + '\n')`.
  • Member Avatar for Gribouillis
    Gribouillis

    Replied To a Post in Pythod - Need help with homework assignment

    I think lines 15 to 17 should be indented to become part of the 'for' loop.
  • Member Avatar for Gribouillis
    Gribouillis

    Edited Pythod - Need help with homework assignment

    Random Number File Writer: Write a program that writes a series of random numbers to a file. Each random umber should be in range of 1 through 500. The application …

The End.