15,406 Topics
![]() | |
Hi :) I'm writing a simple program where I need to create multiple lists when i start (from a file) and write them to the file when I quit. I've googled and found that the best way is to put all the lists into a tuple and then write that … | |
This python 2.7 snippet adds a thin layer of sugar on the itertools module's api, allowing many of its functions to be used as decorators and adding some new functions. Enjoy ! | |
If you have a smaller image, you can include it in your program as a base64 encoded string. This way you don't have to worry about an image file to go with your code. In your program you can then decode it back to the familiar bytes of an image … | |
Hi All, I am a newbie programmer in python and I am trying to read multiple csv files from a folder, perform some data sums based on timestamps for each row for all the csv files and then output the sums to one result csv file. So far I am … | |
Hi all, I am generating graphs using "cairo plot" in web2py project. Here I am using BytesIO() stream for generating graphs. Everything runs fine when I run on localhost but when I deploy it on apache server and then run from different machines OR from different browsers in same machine … | |
Need help with the following code, The error comes at line 20. import ogr import os, shutil,sys import osr regionShp = "ne_50m_geography_regions_polys.shp" regionFile = ogr.Open(regionShp) regionLayer = regionFile.GetLayer(0) spatRef = regionLayer.GetSpatialRef() countryShp = "ne_50m_admin_0_countries.shp" countryFile = ogr.Open(countryShp) countryLayer = countryFile.GetLayer(0) dstDir = "spatial_analysis_2" if os.path.exists(dstDef): shutil.rmtree(dstDir) os.mddir(dstDir) dstPath = os.path.join(dstDir, … | |
I am working on an assignment for my fundamentals class and we have to create a program that is going to write/read/ and append a file. I wanted to set it up to check and see if example.txt exists. If so then append, else write. My question would be how … | |
#Hello, I am working on a homework assignment that after many hours, I still cannot get to function correctly. #The point is to take a list input of ones and zeros and print a compressed version. #Example) #input: [1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,1,0,0,0,0] #output: *41*50*71001*40 #Since the compression takes up 3 symbols(asterisk, amount of … | |
Hi, I am currently getting JSON data from the discogs API (mp3 tag data) and wish to sort the results by the key's value. In this case I am trying to get data for a Guns n Roses song and the output has 1988 as the first one while the … | |
Python webpage -please help Hi I am very new in python programming.I am trying make a basic webpage where I ask user to input url like "http://www.google.ca" and a description of the url like"search engine". Using python script I will add that url and description in dbm database and print … | |
Hello guys I have got a little programme that been written in Python, I did connect it to an application been created in Visual Basic 2010, But to run the Python file, Of course you will need to install the Python software/Format to be able to run the python file, … | |
Hello First apologies for being a total newb. Everyones gotta go though this stage i guess. I'm a teacher and I've written some python 3 code that does some handy stuff to grades. I can execute the code using IDLE and it does what I want it to(averaging scores, producing … | |
Which is smarter? class HoldAttr(object): pass a = HoldAttr b = getattr(a, 'attrname', []) b.append(1) setattr(a, 'attrname', b) # or try: b.a.append(1) except AttributeError: b.a = [1] ... or something else? Trying to learn. | |
#module nametest def showName(): print("__name__ is: " + str(__name__)) If I import nametest into another module or into the shell interpreter and call nametest.showName() I find that name = "nametest", in other words __name__ gets the module name it is a built-in member of? The only exception I know of … | |
New concepts to be applied for this assignment Lists File input and output Exceptions Generating random numbers Debugging flags/messages (Note: style requirements from previous assignments e.g., functional decomposition must also be applied). Introduction Write a fitness simulation whereby a single runner is traveling a fixed distance. The runner only has … | |
Write a Python program which will read data for several students from a text file and create a list of lists to store that data. The data must be read from a text file named “Lab11.txt”. Each line in the text file contains the first name, last name, techid, number … | |
Hi, I am working on an exercise in a book and have difficulty with it. I have completed the first part of the exercise which was to create a guessing game where the the player attempts to guess a secret number randomly generated. Suggestions such as to guess Lower and … | |
I want to move/ delete not os.remove files or folder recycle bin on windows or trash in other OSes using standard lib available in python .. is it possible ? | |
well this is more about what i want to learn, todat I downlaoded send2trash package and installed it, i opened __init__.py that came with it and it had the following code which i can very well understand except for the period infront of each module name.. if sys.platform == u'darwin': … | |
so im trying to make a very basic multiplayer game that gets a players x y from a server then displays the player. the script works fine when there is only one user in the database but when more users are added the script wont display the right player. i … | |
I am a newbie to py.test , Please let me know how to run the py.test in PyScripter Editor. I have tried in the belwo way but it doesn't work. import pytest def func(x): return x + 1 def test_answer(): assert func(3) == 5 pytest.main() | |
Hi, I have a csv file im reading and this is what I have done so far: import csv filename='C:\Users\temperature.csv' with open(filename, 'rb') as csvf: reader = csv.reader(csvf) for row in reader: print row the result is as following: ['Depth (m);15.08.2012 15:39:09;15.08.2012 16:09:10;15.08.2012 16:39:10;15.08.2012 16:43:36'] ['0;53.218;52.804;52.865;51.202'] ['0.128;53.107;52.709;52.414;52.141;'] ['1.143;52.205;51.88;51.664;51.234'] ['2.159;51.026;50.846;50.842;51.258'] ['3.174;50.061;50.055;50.457;50.19'] … | |
This is a program I am working on for homework and I keep getting this error and I'm not sure what I can do to fix it. Any help would be greatly appreciated. here is the error: Traceback (most recent call last): File "C:\Users\crazyjdog\Desktop\School Stuff\CSET 1100\Programs and Charts\program121.py", line 86, … | |
Hey there, i'm relatively new to pyGame and considering this is like my second attempt at doing it by myself after watching a few tutorials, i'd say im getting the hang of it. However, as i was creating a game i realised i had no clue how to make the … | |
Hello! Sory for my English, i'am from Russia Please, Help Me... There is such code: #coding:utf-8 import wx import sys import time import cefpython class MainFrame(wx.Frame): browser = None def __init__(self): wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='wxPython example', size=(1000,800)) self.browser = cefpython.CreateBrowser(self.GetHandle(), browserSettings={}, navigateURL="http://google.com") class MyApp(wx.App): timer = None timerID = 1 … | |
I am trying to create a program that takes an input from a user for a file name and then a text string and removes the string from the file. I have been at this one for a while and I have exausted just about every idea I had to … | |
how should i save data like {username , passwords} to disk for later retrieval so that it cannot be opend and read in by a text editor? | |
Seconds since epoch should be zero, but are not: '''timetuple1.py create a time tuple for epoch 1/1/1970 00:00:00 however, seconds since epoch does not give 0 ''' import time timetuple = time.strptime("01/01/1970 00:00:00", "%m/%d/%Y %H:%M:%S") print(timetuple) print('-'*40) # seconds since epoch 1/1/1970 00:00:00 secs = time.mktime(timetuple) print(secs) '''my result >> … | |
I am running into a strange error everytime I use lxml.etree and was wondering if anyone else has ran into this problem before. It was not until, what I believe happened my lxml was updated to a new version, that I started to get this problem. the error is "File … | |
class Calculate: def __init__(self): self.prior = {} self.total = {} self.count = 0 def add(self, cls, obs): self.prior[cls] = self.prior.get(cls, 0) + 1 for idx, val in enumerate(obs): key = cls, idx, val self.total[key] = self.total.get(key, 0) + 1 self.count += 1 def discr(self, cls, obs): result = self.prior[cls]/self.count for … | |
I have this programme to discuss and I think its a challenging one.. Here I have a yml file which contains the data for an image. The image has x,y,z values and intensity data which is stored in this yml file. I have used opencv to load the data and … | |
Hello I am completely new to Python and I dont know how to prompt the user and use the information from the console in my code. So I guess the simplest example would be If I had to prompt the user for the raidus of a circle then print the … | |
Hello I need help ASAP, my problem is due by thursday.....Here is the problem my teacher has given... "Create a class that describes a box. The user should be able to submit the length, width, and height of a box. Also, you should include methods/functions to determine the surface area … | |
import wx app = wx.App() win = wx.Frame(None) win.Show() app.MainLoop() Why does the above code only work in python2.7 and not 3? | |
#!/usr/bin/python3 print('Content-type: text/plain') # prints an empty line, to end the headers print('Hello, world!') I'M trying to get the above python cgi output to load in my web browser but the browser is just displaying the code it's self. My apache program is working because I just tried the phpinfo … | |
Hello everyone Is there any way to kill the python.exe in Task Managaer "On Windows" using visual basic The Problem is that i do open more than 1 python file at the same, But on task manager it's hows me something like this Python.exe python.exe python.exe python.exe I have got … | |
I want to print a file using win32api. I have a network printer using this ip: 192.168.1.50 So i used this code: import win32api file_path="test.txt" win32api.ShellExecute(0, "print", file_path, None, ".", 0) How can i print this file on the printer that i don't have the name but the ip? Its … | |
Hello again, I am working on another homework problem for my fundamentals class and my brain just isn't working. Like always I am looking for direction not for someone to do the work for me. So I have to create a program that asks for 5 test scores and will … | |
I'm given a text document with marks and course codes, and I need to create a function where you input the directory of the file, and the course code. Doing so, the code will return the average mark of all the marks in the text with that course code. Any … | |
I am using the following code on my raspberry pi (with debian as the os), and when i run it, it says: cannot load image C:/root/desktop/Snake.bmp * Traceback (most recent call last): File "/root/game.py", line 25, in <module> background, tmp_rect = load_image('Snake.bmp') File "/root/game.py", line 11, in load_image raise SystemExit, … | |
Hi there, I just wanted to ask how I would go about writing a single function to count the frequency of numbers 0-10 including .5(such as 1.5,2.5) This is what I have done file = open ('grade.txt', 'r') s=file.readline() grade=[] while s[0:3]!="EOF": s=s.replace(' ','') lst=s.split(',') if lst[0][0]!='I': grade.append(float(lst[5])) print(lst) s=file.readline() … | |
I've been looking for a way to work with polynomials using python, did someone already wrote a code to do that?. Here's what i have until now using dictionaries as polynomials -for example: x^4-6x^2+1 would be {4:1, 2:-6, 0:1}-, someone have any suggestion to make? def degree(f): t = sorted(f.keys()) … | |
Hello. I am attempting to make a text-based game in Python. Although I assumed it would be rather easy, there are not that many examples to go by. Therefore, I've come to ask for some assistance with my code - being the relative newbie to coding that I am. Excuse … | |
Method onPaint does not change the color. Does anyone know why? (there are no errors received) # explore the wxChoice widget # a simple ComboBox (dropdown box) that combines a ListBox with an EditBox # can't get the self.onPaint method to work!!!!! import wx ID_CHOICE = 120 ID_PANEL = 130 … | |
hi master programmers ! I am new to programming and i have an assignment im working on, it seems simple but i just cant get it ! i was wondering if anyone could help ! it would be greatly appreciated ! here is the question : =================================== "The sample input … | |
Hello again, I am working on a homework problem and I am not able to get the accumulator to accumulate the tickets sales for each section. My assignment is to create a basic program that will use loops. I need to have it ask for each day of the week … | |
def get_score(word): '''(str) -> int Return the point value the word earns. Word length: < 3: 0 points 6-9: 1 point per character in word 7-11: 2 points per character in word 10+: 3 points per character in word >>> word_score('DRUDGERY') 16 ''' I have this homework I want some … | |
Hi, I seem to be having some trouble converting the output of this(which is a list) to a string of integers. What I want ultimately is for the output to just be integers. After that I also need to determine how many times an integer appears. I know I need … | |
Hey, been awhile. I'm working on a portal for distributors, some type of JIT (just in time) implementation. Now i've been reading alot on DB so i can implement the right database and the right data structure. Now i see, i can do alot more then i'm use to do. … | |
i need help i thought i was doing it right but later when i looked at data it turned out to be something else I have 4 lines of code that i want to convert to single line list comprehension `newLst=[] for each in os.listdir(locationTxt): if os.path.isdir(os.path.join(locationTxt,each)): if each not … |
The End.