14,946 Topics

Member Avatar for
Member Avatar for ndombko1

Hello I need to add a zero in front of a number if it is 3 or less so that it has 4 digits total. I only need this for row 6 or row 5 to be python specifc. I need this to write to the same csv file. AFI12001 …

Member Avatar for Gribouillis
0
125
Member Avatar for A-M-G

I asked this question on StackOverflow and they just linked me to other questions that I already read and tried. I have been trying to create a zip file using zipfile in Python, but it keeps zipping all folders that are included in the absolute path. I just want to …

Member Avatar for Gribouillis
0
5K
Member Avatar for flebber

Just looking for a push in the right direction. I am overwhelmed by the choice with python at the moment. What are the best tools for managing consitent ETL operations with data in XML and CSV formats to database, graphs and in future a web app. for example should I …

Member Avatar for Yamil_1
0
658
Member Avatar for kxjakkk

My code is the following: import cgi data = cgi.FieldStorage() productdescription = data.getvalue('product_description') listprice = data.getvalue('list_price') discountpercent = data.getvalue('discount_percent') def calc(discountpercent): if discountpercent > 100: raise ValueError("Percentage discount cannot exceed 100%") elif discountpercent < 100: percent = float(discountpercent) / 100 discount = float(listprice) * percent return discount else: raise ValueError("Invalid …

Member Avatar for kxjakkk
0
273
Member Avatar for DragonMastur

I want to make a game that requires the arrow keys to be pressed. How do I detect if a key has been pressed?

Member Avatar for Gribouillis
0
458
Member Avatar for lewashby

builtins.UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 14: invalid continuation byte I'm getting the following error that pops up not in my script but in the codecs.py file. I've used code exactly like this in another program and it worked just fine. Any ideas? Script below. #/usr/bin/env python3 …

Member Avatar for snippsat
0
817
Member Avatar for kartikdani

i am using cartridge-mezzanine for site but now it not saved order when i goes in complete.html it shows a "page not found error" because it can't access in order object in shop/views.py in def complete(request, template="shop/complete.html"): try: order = Order.objects.from_request(request) except Order.DoesNotExist: raise Http404 items = order.items.all() how i …

0
147
Member Avatar for kxjakkk

I'm trying to make a calculator of a sort in python that works on a local web server. I have the localhost all set up and all. import cgi data = cgi.FieldStorage() product_description = data.getvalue('product_description') list_price = data.getvalue('list_price') discount_percent = data.getvalue('discount_percent') total = data.getvalue('total') def total_price(): data.getvalue('total') - discount return …

Member Avatar for snippsat
0
469
Member Avatar for vegaseat

This program takes a text string and creates a list of words. Any attached punctuation marks are removed and the words are converted to lower case for sorting. Now you can generate a dictionary of the words and their frequencies. The result is displayed using a sorted list of dictionary …

Member Avatar for snippsat
2
1K
Member Avatar for vegaseat

The Fibonacci series of numbers was used by Leonardo of Pisa, a.k.a. Fibonacci (around the year 1200), to describe the growth of a rabbit population. The series has been noted to appear in biological settings, such as the branching patterns of leaves in grasses and flowers. We take a look …

Member Avatar for Stefan_3
1
2K
Member Avatar for vegaseat

Because of their demand only nature, generators are ideal for finding the combinations of larger sequences. This code applies a Python generator to find the combinations of the sequence. Since permutations are a special case of combinations for all the items in a sequence, I have expanded the result to …

Member Avatar for Stefan_3
1
397
Member Avatar for MartinIT2type

Hello, I'm pretty new to Python, and I've been making simple projects to practice in. The issue I've run into though is I'm creating a GUI (Using Tkinter with Python 2.6) to take a text input and bring out "Name". What I want to do though is keep that "Name" …

Member Avatar for jules1234567
0
7K
Member Avatar for Chrome 142

Hi, I am trying to make my "Save All" button to save whatever is selected from the option menu or dropdown to that particular file. So if I have "animation" selected from the option menu it saves to the animation file 'ji.txt','r+'. Or if I have "compositing" selected from the …

Member Avatar for Chrome 142
-1
400
Member Avatar for b6huss

Hi, I am extremely new to python, and I am completely stuck regarding filtering the contents of a list. I have a list of the first thirty elements, and i have been told to identify any beginning with the letter 's' and any that are four letters long. I have …

Member Avatar for snippsat
0
399
Member Avatar for krystosan

Does anyone have idea how to fetch a file split into defined number of ranges using the requests module instead of urllib2 ?

Member Avatar for snippsat
0
123
Member Avatar for awahqn

Hi, I have a code in perl that does some mail things and I would like to translate it to perl can someone help me please? I dont know perl so i want it in python so i can edit it. here is the code: #!/usr/bin/perl -w # USAGE : …

Member Avatar for TrustyTony
0
212
Member Avatar for kxjakkk

I'm trying to modify this code: class Tree: def __init__(self, cargo, left=None, right=None): self.cargo = cargo self.left = left self.right = right def __str__(self): return str(self.cargo) def print_tree_inorder(tree): if tree is None: return print_tree_inorder(tree.left) print(tree.cargo, end=" ") print_tree_inorder(tree.right) So that it adds parentheses around every operator and pair of operands. …

Member Avatar for kxjakkk
0
461
Member Avatar for caltech

Hi, I've had a rather ambitious project on my mind for as long as I've been at my job (almost a year) -- to pretty much rewrite their central application, which is a listing database/"portal", around and upon which their entire IT infrastructure and web and computing tasks and operations …

Member Avatar for il_doc
0
305
Member Avatar for yuimikazuki

print "Let's practice everything." print 'You'd need to know 'bout escapes with \\ that do \n newlines and \t tabs.' poem = """ \tThe lovely world with logic so firmly planted cannot discern \n the needs of love nor comprehend passion from intuition and requires an explanation \n\t\twhere there is …

Member Avatar for HiHe
0
160
Member Avatar for lewashby

(Linux) I just installed eyed3 for python using apt-get, everything installed fine but when I tried to import eyed3 I got a trackback error, no such module. Do I need to do something special to let python know where the module is at or do I need to move the …

Member Avatar for Gribouillis
0
1K
Member Avatar for henry.moore.319247

this is my first attempt on python and i would really love some help heres my code class Customers(object): def __init__(self, Surname = None, FirstName = None, Address = None, Town = None, Postcode = None, PhoneNumber = None, Date = None, Email = None): self.Surname = Surname self.FirstName = …

Member Avatar for TrustyTony
0
314
Member Avatar for Jack_9

I'm still kinda uncertain about python. But if you can, How would you go about making a instant messaging webapp? This isn't for any homework or paid jobs, just curious for my website.

Member Avatar for Hiroshe
-1
103
Member Avatar for abaddon2031

Im working on a project where i have to get the number of printers that are allocated to a certain job and need to split the file name up so that i can read the type and the number of printers and if its a half bed or not. The …

Member Avatar for snippsat
0
265
Member Avatar for yuimikazuki

from sys import argv from os.path import exists script, from_file, to_file = argv print "Copying from %s to %s" % (from_file, to_file) # we could do these two on one line too, how? in_file = open(from_file) indata = in_file.read() print "The input file is %d bytes long" % len(indata) print …

Member Avatar for David W
0
219
Member Avatar for analys

Hi, I'm new to python. I'm creating python script that will copy file from different destination to another destination. It will copy as well the access for different user. I'm trying to output any results to the logfile but it didn't seem to output it. Here's my code. Hope anyone …

Member Avatar for analys
0
417
Member Avatar for analys

Hi, I want to develop Python script for server automation (server backup) that able to copy the files with user access permission as well. I want to do it with Python but I'm not sure how to start on the active directory scripting with Python. Can somebody help me?

0
184
Member Avatar for kxjakkk

I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help. What I've gotten so …

Member Avatar for David W
0
441
Member Avatar for Jack_9

In my opinion, python is a fantastic language, but is it possible to develop an operating system with python, BUT one thing that I do know is that if you were going to develop something with python it would probably have to be the gui. Because python dosen't even really …

Member Avatar for mike_2000_17
0
258
Member Avatar for kxjakkk

I wanted to format this string but I don't know how I can do the formatting part at all. class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs if self.seconds >= 60: self.minutes += self.seconds // 60 self.seconds = self.seconds % 60 if …

Member Avatar for sepp2k
0
260
Member Avatar for kxjakkk

This is my code: class MyTime: def __init__(self, hrs=0, mins=0, secs=0): self.hours = hrs self.minutes = mins self.seconds = secs if self.seconds >= 60: self.minutes += self.seconds // 60 self.seconds = self.seconds % 60 if self.minutes >= 60: self.hours += self.minutes // 60 self.minutes = self.minutes % 60 if self.hours …

Member Avatar for kxjakkk
0
283

The End.