2,646 Posted Topics
Re: A very simple thing to do is to launch a graphical disk usage analyser such as filelight or baobab. | |
Re: I'm not a Java programmer but any pythonista would answer to use the beautifulsoup library. From what I read here and there, the java equivalent is named **JSoup**. I think you could try this library. | |
Re: You must use lists for this A = [] Y = [] val = [12, 5, -12, 1, 120, -1, 10] for i, v in enumerate(val): t = test() name = 'word_{}'.format(i) j = t.job(x=name, y=v) A.append(t) Y.append(j) | |
Re: Post your code. You don't need `__call__()` methods, you only need one `__init__()` method per class, and also `__add__()` and perhaps `__radd__()` methods. | |
Re: You can get the path to the python command by pasting this in a terminal: python -c "import sys; print(sys.executable)" edit: @AndrisP what you say will only work if the python scripts start with the correct shebang line containing the call to the python executable, unless the system has been … | |
| |
Re: Have a look at this quickstart page [Click Here](https://docs.scipy.org/doc/numpy-dev/user/quickstart.html) explaining how to build numpy arrays. | |
Re: You could write cipher = [(key[(key.index(char) + offset) % 26] if char in key else char) for char in text] | |
Re: For a tree with N nodes, the function will be called exactly 2N+1 times in my opinion (N times with a real node and N+1 times with a null node). You can prove this by induction on N by adding a leaf to a tree or by using the induction … | |
Re: What you can do is add print statements in the code in order to see what's getting executed. For example you can add `print(line)` at line 66 because the `interpretor()` function is supposed to be called with a line containing the game to be diplayed. You can use my `printat()` … | |
Re: I suggest def Density(rho0, r, Rc, Rd): return rho0 * np.exp(-np.maximum(r-Rc, 0)/Rd) | |
Re: You could complain to virustotal.com (which appears to be another appendix of google)... | |
Re: Hello, I think you can start a long list of missing features. The first in sight are 1. A shortcut to exit the editor 2. Why is there no menubar ? Is it by design ? 3. The text area does not update as it should when the window is … | |
Re: I suggest a shell script [code=sh] #!/bin/sh python f4761sk3.py python f4761sk2.py python f4761sk1.py python f4761se3.py python f4761se2.py python f4761se1.py python f4761pl3.py python f4761pl2.py python f4761pl1.py python f4761no3.py python f4761no2.py python f4761no1.py python f4761nl3.py python f4761nl2.py python f4761nl1.py python f4761ie3.py python f4761ie2.py python f4761ie1.py python f4761hu3.py python f4761hu2.py python f4761hu1.py python … | |
Re: You could download `subprocess.py` from the python 2.7 distribution and try to use its methods. If your server is a linux server, it may work. | |
Re: I can't run the script in kubuntu 14.04. I get Traceback (most recent call last): File "foo.py", line 99, in <module> clicker = Game() File "foo.py", line 11, in __init__ self.createwidgets() File "foo.py", line 90, in createwidgets self.create_styles() File "foo.py", line 15, in create_styles frame_style.theme_use('normal') File "/usr/lib/python3.4/tkinter/ttk.py", line 523, in … | |
Re: Try to remove all the calls to `float()`. They are not necessary, and numpy uses its own float type. | |
Re: Your code needs an `if` statement to determine if `stu_points` is below 60 and print an F in that case. | |
Re: A block of python code, showing serious attempts to solve the problem is missing in your question. Helpers here are not attending a programming course, and usually don't do student's homework for them. | |
Re: @hericles The comma trick works only in python 2. With python 3, `print` is a full fledged function and the way to prevent the newline is to use the parameter `end=''` in the call to `print()` . | |
Re: According to the python documentation > The combobox widget generates a <<ComboboxSelected>> virtual event when the user selects an element from the list of values. It means that you could bind this event to one of your methods mywidget.bind('<<ComboboxSelected>>', self.mymethod) Then define a method def mymethod(self, *args): print(args) and see … | |
Re: Hello, effbot.org says to keep a reference to the image object to prevent it from being garbage collected. You could try self.our_image = tk.PhotoImage(master=self, file="side.png") [http://effbot.org/tkinterbook/label.htm](http://effbot.org/tkinterbook/label.htm) | |
Re: What about Renaud Le Van Kim ? More seriously, I can't run your code because my python has pandas 0.13.1 in ubuntu 14.04, and this version does not understand the parameter `expand=` in `split()`. | |
Re: Thanks for the link, I didn't know that. You can perhaps have windows on an external drive and run it in virtualbox. This would be a portable windows. I like the LTS versions of ubuntu, kubuntu, etc for stability. However, I still need windows now and then because some companies … | |
Re: There is a problem in the indention of function `add_number()` at the beginning of your code. Apart from that, don't only post `ValueError`, instead, post the whole error message sent by python in your console. This error message contains most of the time the precise position in your code where … | |
Re: Start with print(os.listdir('/')) | |
Re: This works for me from tkinter import * from time import time, sleep, clock class Splash: def __init__(self, root, file, wait): self.__root = root self.__file = file self.__wait = wait + clock() def __enter__(self): # Hide the root while it is built. self.__root.withdraw() # Create components of splash screen. window … | |
Re: `Invalid syntax` is always a very simple error. The only strange thing in your code is the colon at the end of the line. This can happen only when the line starts with a keyword such as `if, elif, else, for, while, def, class, try, except, finally, with, lambda`. What … | |
Re: I would remove `get_dollars()` and `get_left_over_cents()`. You can write at line 13 total_value = get_total(pennies, nickels, dimes, quarters) dollars = int(total_value) left_over_cents = int(100 * (total_value - dollars)) It seems to me that calling `get_dollars()` instead of `get_total()` at line 29 and 34 is a mistake. | |
Re: It seems implicit to me that the code should keep argument2 unchanged and return a new value (new list or set). I suggest def manipulate_data(typename, instance): if typename == 'list': result = instance[::-1] elif typename == 'set': result = instance | set(['ANDELA','TIA','AFRICA']) elif typename == 'dictionary': result = list(instance.keys()) return … | |
Re: The result of `if keycode == foo or bar` is probably not what you are expecting. You probably meant `if keycode in (foo, bar)` | |
Re: You could use nan from math import sqrt nan = float('nan') def mysqrt(x): return sqrt(x) if x >= 0.0 else nan See https://en.wikipedia.org/wiki/NaN Edit: Hi Tony! It's been a while... Edit2: `numpy.sqrt()` already returns nan for negative numbers! Edit3: please @steven.rose.94, use python tag as well as python3 to increase … | |
Re: Hint: type `help(str.find)` in a python console. You can also try `help(str.index)` ! | |
Re: You need to store state variables. The best thing to do is to create a class instance class App(object): def __init__(self): self.username = None self.password = None def login(self): if self.username is not None: print "Already Logged In" return u = raw_input("enter username:").strip() p = raw_input("enter password:").strip() if check_login(u, p): … | |
Re: Try `id = j['id']`, and read a python tutorial! | |
Re: The list `list(swn.senti_synsets(i,'a'))` is probably the empty list `[ ]` You could check this by printing its `repr()` for example. Your program does not (yet) handle the case where this list is empty. You must add some code. | |
Re: Which version of python are you using. If you are with python 2.7, a good thing to do first is to import from __future__ import unicode_literals at the top of the file, so that literal strings are automatically unicode. If it doesn't suffice, you can also try fsencoding = sys.getfilesystemencoding() … | |
Re: @srujana_1 I don't have windows, but you can try and replace the lambda with lambda e: os.startfile("C:\Users\hello\Desktop\filename.pdf") Please start new threads with the tag "python" when you have different questions. edit: bugfix | |
Re: @lavanyarao `list index out of range` is a very general message. You must post the whole error traceback to see which list is involved. Also, it is better if you start your own forum thread with the tag `python` instead of reviving an old thread. | |
Re: What kind of data does the database contain ? Do you know how you want the data to appear in the file ? | |
Re: 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 = query.getvalue("do") if isinstance(val, (str, unicode)): val = (val,) for i in val: etc In python 3, use` (bytes, str)` instead … | |
Re: 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 + '.txt') if os.path.isfile(name): while True: overwrite = input("Would you like to overwrite this file? Yes or No: ") overwrite = … | |
Re: `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()`. | |
Re: 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 on your server ? | |
Re: 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 also improve the input part: scoreList.append(int(input('Enter score {:d}/{:d}: '.format(i, count)))) | |
Re: Once the text item is created, you can obtain a bounding box with `canvas.bbox(item=text)`, or something similar. | |
Re: When python says invalid syntax, it shows a point in code near the point where there is an error File "foo.py", line 11 print("Therefore, your total shipping charge would be " total) ^ SyntaxError: invalid syntax If you look at your code at line 11, you will see the error. … | |
Re: 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 v= 0.23 omega = 0.2 r0 = v/omega t=np.linspace(0,T,N+1) r= v*t #theta = a + r/r0 theta = omega*t x=r* … | |
Re: 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. |
The End.