User Profile
Collapse
-
Thank you! Just what I was looking for. -
Actually Glenton....by using the above AND your second suggestion, it seems to work!
Now I just need to add together all of the first/lasts so I have 1 total number.Code:for item in a: Sum1stLast= int(str(item)[0]) + int(str(item)[-1]) print Sum1stLastLeave a comment:
-
Thanks for the reply. I was thinking about trying to separate each prime and then try to implement the adding of the first & last numbers.
That will print each one separately....n ow just gotta figure out how to do the adding of each 'item'. :) Getting there.Code:for item in a: print itemLeave a comment:
-
Selecting numbers in a list to be added together
Hi. I am trying to enter a number into this script and have it do several things. 1st I want it to find all of the prime numbers from the one that's entered by the user. I found some code online that does that (below). Then I want only every other prime in the list, which I've managed with "a=primeLis t[1::2]". I'm not sure how to go about the next part which will be to take the first number of a multi-digit prime and add it to the last... -
Are you just typing "setup.py"? If so, it's telling you that you need to add command arguments to it. You can type:
setup.py cmd --help
for options.
This line tells you the usage for setup.py:
and these give you options for the usage. Notice the last line says "no commands supplied:Code:usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
...Code:# or: setup.py
Leave a comment:
-
I know this isn't exactly what you're looking for, but maybe you could build off of this:
...Code:>>>for k in range(999,989,-1): print '"APN"=' + "'999-99-%s'" % str(k) "APN"='999-99-999' "APN"='999-99-998' "APN"='999-99-997' "APN"='999-99-996' "APN"='999-99-995' "APN"='999-99-994' "APN"='999-99-993'
Leave a comment:
-
dwblas, thank you for that. It worked on my linux without the need for commit but I couldn't figure out why it wouldn't work on windows. That does the trick.Leave a comment:
-
I don't have python on this particular computer but how about:
...Code:line='ACSSF,2009e5,ca,000,0100,0013344,309,11,0,0,0,0,11,0,10,0,0,0,0,10,0,93,0,0,0,38,55,0,54,0,0,0,12,42,0,43,12,0,8,21,2,0,20,11,0,0,9,0,0,78,33,39,6,0,0,0,593,0,0,0,0,0,0,0,0,17,0,0,0,0,0,11,0,0,0,0,17,10,45,308,185,789200,909500,1000001,.,.,.,.,.,.,.,.,.,.,.,.,.,593,474,159,49,110,0,315,119,541772500,438522500,103250000,.,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.,593,474,0,0,0,0,0,0,0,0,0,17,20,22,62,69,284,119,0,0,0,0,0,32,0,0,19,30,38,2909,4001,628,2035900,1966500,69300,593,474,49,48,91,81,51,49,8,39,58,0,119,77,42,0,0,0,0,0,0,0,0,19.4,23.0,7.7,593,0,0,0,0,0,0,0,41,0,0,0,10,31,0,358,144,81,44,31,58,0,194,163,0,7,8,16,0,593,0,0,0,32,0,19,30,21,17,0,37,22,415\n'
Leave a comment:
-
I think another issue will be if a value is a fraction like:
line='.,.45,.25 ,.,100,7.5,.'Leave a comment:
-
I was going to suggest just replacing the 'period comma' with a blank space which works except if the last value is a period:
Code:# line='2.5,3,.,100,.,4.10,.,8,.,.,.,8.9,.' # line.replace('.,','') # '2.5,3,100,4.10,8,8.9,.'Leave a comment:
-
Wouldn't something like this work where you could replace the 'comma period comma' with just a 'comma':
Code:>>> line='2.5,3,.,100,.,4.10,.,8' >>> line.replace(',.,',',') '2.5,3,100,4.10,8'Leave a comment:
-
problem with mysql 'insert'; not working.
I'm having trouble getting my python scripts to insert into a mysql database. I'm able to do other commands successfully such as adding or dropping tables, selecting items from tables but inserting into tables isn't working. I can manually insert but the script won't do it.
I have an entry field for a last name and am using .get() to grab the data. If I enter the name 'Jones' into the field and submit it, I get this error:
OperationalErro r:... -
I'm new to mysql and have not heard of database normalization until now but after googling and reading about it, it seems to be the direction I should head. Thanks for the suggestion!Leave a comment:
-
Need advice on how I should set up my db/tables/columns
I've been working on a project lately that is written in python and I want to incorporate mysql into it. The python code is basically a report writing system in which every report will have it's own number such as 10-0001, 10-0002 and will contain information like first & last names, addresses, phone numbers, etc. There is also a page, if needed, for items such as televisions, brand names of items, color of items, serial numbers of items, values... -
That solved it, thanks! I was trying to set 'global' in "def SaveIt" and elsewhere because of the error. This was the basis of the error:
In SaveIt line 22 NameError: global name 'cursor' is not definedLeave a comment:
-
help with tkinter/sql global error.
I've hit another snag with tkinter and mysql. After the last post, I'm able to now have a user login that when username and password are entered, a successful mysql connection can be made. The problem now is that "cursor isn't global" and I'm not sure how to make it that way, or how to correct this code. So after logging in and clicking the "Next" button from the root window, I get error messages.
...Code: -
-
help making a tk/msql user login
I've decided to try and make a login window using tkinter that will connect to a mysql database if the proper username and password are entered. I can connect automatically if I have that info already in the script, but can't quite make it work if it's entered into entry fields. I was trying something like this:
...Code:from Tkinter import * import sys import MySQLdb # Get the info entered in the root window
-
Ok, so I read about get() and played around with it and I got my code to work:
...Code:from Tkinter import * import sys import MySQLdb conn = MySQLdb.connect (host = "localhost", user = "thekid", passwd = "pwd", db = "maindb") cursor = conn.cursor ()Leave a comment:
-
help combining tkinter & mysql
I can't seem to find anything that shows how to use tkinter with mysql. I do know how to connect to mysql with python scripting but I need to know how to enter information into a tkinter window and have it store into mysql. Here's an example:
...Code:from Tkinter import * root = Tk() ent_frame = Frame(root) Label(ent_frame, text="FIRST NAME:").pack(side=LEFT) Entry(ent_frame, width=15).pack(side=LEFT)
No activity results to display
Show More
Leave a comment: