User Profile

Collapse

Profile Sidebar

Collapse
Thekid
Thekid
Last Activity: Jun 4 '14, 01:49 AM
Joined: Feb 21 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Thank you! Just what I was looking for.
    See more | Go to post

    Leave a comment:


  • Actually Glenton....by using the above AND your second suggestion, it seems to work!
    Code:
    for item in a:
        Sum1stLast= int(str(item)[0]) + int(str(item)[-1])
        print Sum1stLast
    Now I just need to add together all of the first/lasts so I have 1 total number.
    See more | Go to post

    Leave 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.


    Code:
    for item in a:
        print item
    That will print each one separately....n ow just gotta figure out how to do the adding of each 'item'. :) Getting there.
    See more | Go to post
    Last edited by Thekid; Nov 19 '11, 02:34 AM. Reason: Added code snippet as ideas are coming in.

    Leave a comment:


  • Thekid
    started a topic Selecting numbers in a list to be added together

    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...
    See more | Go to post

  • Thekid
    replied to Why doesn't py2exe work?
    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:
    Code:
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
    and these give you options for the usage. Notice the last line says "no commands supplied:
    Code:
    #    or: setup.py
    ...
    See more | Go to post

    Leave a comment:


  • Thekid
    replied to manipulating string question
    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'
    ...
    See more | Go to post

    Leave a comment:


  • Thekid
    replied to problem with mysql 'insert'; not working.
    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.
    See more | Go to post

    Leave a comment:


  • Thekid
    replied to Regex for replacing missing value period
    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'
    ...
    See more | Go to post
    Last edited by Thekid; Dec 20 '10, 11:10 PM. Reason: Forgot closing 'code' tag.

    Leave a comment:


  • Thekid
    replied to Regex for replacing missing value period
    I think another issue will be if a value is a fraction like:
    line='.,.45,.25 ,.,100,7.5,.'
    See more | Go to post

    Leave a comment:


  • Thekid
    replied to Regex for replacing missing value period
    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,.'
    See more | Go to post

    Leave a comment:


  • Thekid
    replied to Regex for replacing missing value period
    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'
    See more | Go to post

    Leave a comment:


  • Thekid
    started a topic problem with mysql 'insert'; not working.

    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:...
    See more | Go to post

  • 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!
    See more | Go to post

    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...
    See more | Go to post

  • Thekid
    replied to help with tkinter/sql global error.
    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 defined
    See more | Go to post

    Leave a comment:


  • Thekid
    started a topic help with tkinter/sql global error.

    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:
    
    
    ...
    See more | Go to post

  • Thekid
    replied to help making a tk/msql user login
    Oh, I see. So close :) Thanks.
    See more | Go to post

    Leave a comment:


  • Thekid
    started a topic help making a tk/msql user login

    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
    ...
    See more | Go to post
    Last edited by Thekid; Nov 11 '10, 10:21 PM. Reason: Added error message.

  • Thekid
    replied to help combining tkinter & mysql
    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 ()
    ...
    See more | Go to post

    Leave a comment:


  • Thekid
    started a topic help combining tkinter & mysql

    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)
    ...
    See more | Go to post
No activity results to display
Show More
Working...