2,646 Posted Topics
Re: string = 'Hello' print(string) string = 'Bye' print(string) | |
![]() | Re: Instead of writing an OS, why don't you join a team working on the linux OS ? |
Re: 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 … | |
Re: 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 … | |
Re: 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. | |
Re: You can try L2.config(text='Foo') | |
Re: 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. | |
Re: This is equivalent to tmp = [] for student in collection.find(): if student['mark'] == 99.0: tmp.append(student['mark']) students = tmp | |
Re: 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)")" | |
Re: > 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. | |
Re: Try to replace `self.Scenes.get(start).enter()` with `self.Scenes[start].enter()` . | |
Re: > 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. | |
Re: @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. | |
Re: hi! `get_class_average()` takes a list of students, not a list of strings. Use get_class_average([alice]) | |
Re: 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. | |
![]() | Re: 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 … ![]() |
This snippet defines a function returning new identifiers created from reading the computer's time. | |
Re: How do you expect the looping menu to work ? Can you describe its behavior ? | |
Re: 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 + … | |
Re: 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 … | |
Re: I think lines 15 to 17 should be indented to become part of the 'for' loop. | |
Re: 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 … | |
Re: [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. | |
Re: 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} | |
Re: 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 | |
Re: 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 | |
Re: @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 … | |
Re: 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 ? | |
Re: Perhaps the `isEnabled()` method ? Try `pydoc PyQt4.QtGui.QPushButton`. | |
Re: 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 … | |
Re: 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 {} + | |
![]() | Re: Isn't it an example of UUOC ? It seems to me that `sort -r -o newfile file` should work. |
Re: 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/ | |
Re: My choice is Kubuntu 14.04 long term support. Download it from here http://kubuntu.org/getkubuntu/ | |
Re: 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 | |
Re: If you can connect to the remote PC with ssh, you can install or uninstall everything you want on the remote PC. | |
Re: Why not use search engines ? https://en.wikipedia.org/wiki/Linux_kernel | |
Re: 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. | |
Re: 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") | |
Re: 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 ! | |
Re: 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) | |
Re: Install module pyasn1 https://pypi.python.org/pypi/pyasn1 . You can probably install it by typing pip install pyasn1 in a terminal. | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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)`. | |
Re: A disk usage analyser such as filelight or baobab would find visually where the GB are hiding. |
The End.