2,646 Posted Topics

Member Avatar for Juli_1
Member Avatar for Tomas_3

Instead of writing an OS, why don't you join a team working on the linux OS ?

Member Avatar for Raul Perez
0
313
Member Avatar for zelrick

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 prints the number 7. Try to understand why. Also to copy and paste in a bash terminal, you can use …

Member Avatar for zelrick
0
311
Member Avatar for المهندز

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 expect (for example a file containing some data), and the input that you intend to give to the program (for …

Member Avatar for rubberman
0
266
Member Avatar for Violet_82

You could try with gparted in ubuntu http://www.howtogeek.com/howto/17001/how-to-format-a-usb-drive-in-ubuntu-using-gparted/ edit: be careful not to format your hard drives ! Also don't use fat32 if the volume is too large. Try NTFS.

Member Avatar for Reverend Jim
0
2K
Member Avatar for Aishah_1
Member Avatar for jarograv

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
0
336
Member Avatar for lewashby

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
0
400
Member Avatar for basketmen

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 sleep(2)")"

Member Avatar for JeoSaurus
0
414
Member Avatar for checker

> 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 a `collections.OrderedDict()` instance.

Member Avatar for Gribouillis
0
2K
Member Avatar for Onion13

Try to replace `self.Scenes.get(start).enter()` with `self.Scenes[start].enter()` .

Member Avatar for Onion13
0
292
Member Avatar for IntegratedTweak

> No doubt the previous owner was convinced that "Microsoft is evil" He may have downloaded cracked Microsoft programs, and he could not use windows updates because Microsoft would have detected the fraud.

Member Avatar for Noor_7
1
338
Member Avatar for OrcaSoul

@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 start new threads with the 'python' tag instead of reviving old threads.

Member Avatar for Gribouillis
0
623
Member Avatar for ray.shahil95

hi! `get_class_average()` takes a list of students, not a list of strings. Use get_class_average([alice])

Member Avatar for ray.shahil95
0
363
Member Avatar for Prateek_2

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__()` anyway, because `__str__()` is typically an instance method.

Member Avatar for Gribouillis
0
331
Member Avatar for powerade661

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 + r # etc ... You can use this function as a black box def log_to_file(theLogger, fileOrFileobj, timefmt=""): """Connects a …

Member Avatar for powerade661
0
158
Member Avatar for Gribouillis

This snippet defines a function returning new identifiers created from reading the computer's time.

Member Avatar for Gribouillis
0
532
Member Avatar for Onion13
Member Avatar for Onion13
0
8K
Member Avatar for MrQuentin

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 import * from random import randint def rander(): i = numcolone assert 0 <= i < len(rectangle) canvas.coords(rectangle[i], 2 + …

Member Avatar for Gribouillis
0
222
Member Avatar for Amit_31

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 a few examples of using `bool()` >>> bool('') False >>> bool('hello') True >>> bool([]) False >>> bool([1, 2, 3]) True …

Member Avatar for Sean Francis
-1
133
Member Avatar for thayl0
Member Avatar for Gribouillis
0
811
Member Avatar for Money_maker_11

I'm using your code display_output_string variable = "You details are correct, you may now progress to the game" prit(display_output_string variable ) and I get File "foo.py", line 1 display_output_string variable = "You details are correct, you may now progress to the game" ^ SyntaxError: invalid syntax There must be an …

Member Avatar for Husoski
0
229
Member Avatar for arindam31

[QUOTE=arindam31;1736122]Thank you Sir[/QUOTE] When you have a useful piece of code and no issue, write a code snippet instead of a regular thread. You can choose this in the 'title' section when you start a new thread.

Member Avatar for Syed Sulaiman
3
10K
Member Avatar for bryann

You may also use this trick >>> lett = "tfc bhy qwz".split() >>> dic = {x: i for i, w in enumerate(lett, 1) for x in w} >>> dic {'c': 1, 'b': 2, 'f': 1, 'h': 2, 'q': 3, 't': 1, 'w': 3, 'y': 2, 'z': 3}

Member Avatar for snippsat
0
267
Member Avatar for lewashby

I think you are creating a *tar bomb*, a tar archive that explodes into many files instead of creating a single directory. Can't you try tar --exclude-tag-all=backups -C ../.. -cf lesson21.tar gallery

Member Avatar for Gribouillis
0
461
Member Avatar for Abdulkabir_1

You could perhaps start with `groupby` objects: grouped = df.groupby(['Date','Time']) for name, group in grouped: print(name) print(group) see http://pandas.pydata.org/pandas-docs/stable/groupby.html

Member Avatar for Abdulkabir_1
0
577
Member Avatar for gishi

@Abdulkabir_1 You say that `for index, row in iterrow:` does'nt work, but we don't know what it means because we don't have your python code. Perhaps you could start a new discussion with your code and the error message sent by python. Also, it would be a good idea to …

Member Avatar for Gribouillis
0
15K
Member Avatar for rhys1619

I think you can try and write it yourself. Obviously you know how to ask the user a question and how to handle an answer, don't you ?

Member Avatar for fonzali
0
211
Member Avatar for SpiritualMadMan
Member Avatar for Gribouillis
1
7K
Member Avatar for rhys1619

You need to enclose everything in a loop # rhys translation quiz question_list = [ ( "What is Kia ora in english", "a. Hello\nb. Bye\nc. Greetings\nd. See ya\n", "a"), ( "What is t?n? rawa atu koe in english", "a. Give it\nb. bye\nc. Thank you\nd. See ya\n", "c"), ( "What is …

Member Avatar for Gribouillis
0
330
Member Avatar for chaze

You could use a python script named `lescript` #!/usr/bin/env python3 # -*-coding: utf8-*- import os import sys if __name__ == '__main__': size = int(sys.argv[1]) for filename in sys.argv[2:]: if os.stat(filename).st_size > size: try: os.unlink(filename) except: print('Ignoring', filename) Then invoke find /home -type f -name error_log -exec lescript 5242880 {} +

Member Avatar for mouaadable
0
278
Member Avatar for MarkQ97

Isn't it an example of UUOC ? It seems to me that `sort -r -o newfile file` should work.

Member Avatar for Gribouillis
0
3K
Member Avatar for lewashby

I suggest a home backup solution using a raspberry pi and a hard drive. See this article for example http://www.howtogeek.com/139433/how-to-turn-a-raspberry-pi-into-a-low-power-network-storage-device/

Member Avatar for eroux
0
319
Member Avatar for Amr.Mohammad87

My choice is Kubuntu 14.04 long term support. Download it from here http://kubuntu.org/getkubuntu/

Member Avatar for jwenting
0
461
Member Avatar for glao

Hello. It is the same as def mine(a, b): return a >= (b - 1) see https://docs.python.org/3/reference/expressions.html#operator-precedence

Member Avatar for glao
0
149
Member Avatar for tony75

If you can connect to the remote PC with ssh, you can install or uninstall everything you want on the remote PC.

Member Avatar for rproffitt
0
374
Member Avatar for SAMMY12345

Why not use search engines ? https://en.wikipedia.org/wiki/Linux_kernel

Member Avatar for turboscrew
-2
289
Member Avatar for PyGuy123456789

You can handle each student one after the other in the `for line in infile` loop and you don't need `strList`: use `lineSplit = line.strip().split()`. Also use `int()` instead of `eval()`. Eval is rarely used by python programmers.

Member Avatar for Gribouillis
0
418
Member Avatar for Dat One Lefty

Hi Here is how to download this page from python, in file `/tmp/foo.html` import urllib urllib.urlretrieve("https://www.daniweb.com/programming/threads/500869/python-grabbing-website-data", "/tmp/foo.html")

Member Avatar for Taywin
0
207
Member Avatar for Alok_3

That's a lot of code in many languages. A good think to do is to upload it to github or some other forge. Don't forget to write the documentation !

Member Avatar for Alok_3
0
508
Member Avatar for aragonnette

Here is how I split a pdf file into pages from python by calling pdftk pdf_name = "foo.pdf" ndigits = 2 com_line = "pdftk A={src} burst output {dst}".format( src = pdf_name, dst = "%0{ndigits}d.pdf".format(ndigits=ndigits)) ) subprocess.call(com_line, shell=True)

Member Avatar for AdeleB
0
7K
Member Avatar for tony75

Install module pyasn1 https://pypi.python.org/pypi/pyasn1 . You can probably install it by typing pip install pyasn1 in a terminal.

Member Avatar for tony75
0
11K
Member Avatar for Jonah_1

You have self.file self.OpenFile self.ReadFile self.savelocation self.savelocation1 That makes a lot of file-related members. Try to use them coherently, for example at line 61, `self.file` is a string, but at line 36 it is a file object. Use different variables to store filenames and file objects. Also note that file …

Member Avatar for Gribouillis
0
2K
Member Avatar for felton
Member Avatar for rproffitt
0
146
Member Avatar for Hedge_1
Member Avatar for houndhen

Can you post the bash script ? Edit: depending on your system, the libraries for popup dialogs are different. In KDE, for example, kdialog has an option `--passivepopup` that does exactly what you want.

Member Avatar for Gribouillis
0
613
Member Avatar for lewashby

You can also run this python script #!/usr/bin/env python # -*-coding: utf8-*- '''doc ''' from __future__ import (absolute_import, division, print_function, unicode_literals) import os from os.path import join as pjoin import shutil DEBRIS = '/home/garrett/.debris' HOME = '/home/garrett' def home(path): return path.replace(DEBRIS, HOME, 1) def main(): for dirpath, dirnames, filenames in …

Member Avatar for lewashby
0
392
Member Avatar for Makara

On my kubuntu system, I get this $ ls -l /usr/bin/java lrwxrwxrwx 1 root root 22 mars 5 2014 /usr/bin/java -> /etc/alternatives/java $ ls -l /etc/alternatives/java lrwxrwxrwx 1 root root 46 mars 5 2014 /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java Your java executable may have a different location. You can also try locate …

Member Avatar for jwenting
0
247
Member Avatar for DragonMastur

You can also use `collections.OrderedDict` instead of `dict` in the record in order to preserve the items' order. Use `json.load(f_obj, object_pairs_hook=OrderedDict)`.

Member Avatar for Gribouillis
0
360
Member Avatar for lewashby

A disk usage analyser such as filelight or baobab would find visually where the GB are hiding.

Member Avatar for Gribouillis
0
278

The End.