New to python!

This is the place for queries that don't fit in any of the other categories.

New to python!

Postby ChristopherL » Tue Jul 16, 2013 2:06 pm

Hi there, seems like an amazing forum this!
I am gonna work alot with python lately, so I thought i'd make myself aquintenced with you guys!
I am a programming student in Sweden, just started to work with python.
Pleased to meet all of you!

Here's my first probelm :D
What does this mean?
Code: Select all
exposureDict[fund] += row['org_mv']*fxRates[currency]/divisor
ChristopherL
 
Posts: 13
Joined: Tue Jul 16, 2013 2:03 pm

Re: New to python!

Postby ochichinyezaboombwa » Tue Jul 16, 2013 4:27 pm

Welcome to the forum!
ChristopherL wrote:What does this mean?
Code: Select all
exposureDict[fund] += row['org_mv']*fxRates[currency]/divisor
It's a Python expression; the meaning(result) of it depends on values of its operands (row, fxRates, etc).
Any more questions?
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: New to python!

Postby Kebap » Tue Jul 16, 2013 6:56 pm

ChristopherL wrote:Here's my first probelm :D
What does this mean?


Hi Christopher, pleased to meet you too! :) Now please review the sticky threads in this forum and/or my signature on help on how to ask questions in a way that can actually be answered easily. Your above question seems much too broad for me and you do not give much indication as to what exactly you do and do not understand yet. Hope to read you soon!
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 400
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: New to python!

Postby ChristopherL » Tue Jul 16, 2013 7:36 pm

ochichinyezaboombwa wrote:Welcome to the forum!
ChristopherL wrote:What does this mean?
Code: Select all
exposureDict[fund] += row['org_mv']*fxRates[currency]/divisor
It's a Python expression; the meaning(result) of it depends on values of its operands (row, fxRates, etc).
Any more questions?


Thank you! That explained enough for me :)
ChristopherL
 
Posts: 13
Joined: Tue Jul 16, 2013 2:03 pm

Re: New to python!

Postby ChristopherL » Wed Jul 17, 2013 9:49 am

Thanks for the help last time!
Finished my assignment quickly once I got a hang of it!
However, I am now having trouble understanding this def..
It's importing someway from SQL and I don't really catch whats happening..
If anyone might be able to explain these steps for me that would be great!!

Pre-thanks! :)

Code: Select all
def getPortolioProficentreMapping(uploadDate): #get portfolio and profit center

    sql_q = "SELECT child_name FROM pf_tree_mb WHERE name = 'ATCM_#x#_STO' AND "
    sql_q += "upload_date = '%s' " % uploadDate.string('%Y-%m-%d')

    db = database.connection("DSN=armsrc.sebank.se")
    tbl = db.select(sql_q)
    portfolioList = []

    for row in tbl:
        portfolioList.append(row['child_name'])

    sql_q = "SELECT name,child_name FROM pf_tree_mb WHERE upload_date = '%s' AND " % uploadDate.string('%Y-%m-%d')
    sql_q += "child_name IN('%s') AND " % "','".join(portfolioList)
    sql_q += "type = 'profit_centre' AND name != 'MB'"

    tbl = db.select(sql_q)
   
    db.close()

    portfolioProfitcentreDict = {}
    profitCentres = []

    for row in tbl:
        portfolioProfitcentreDict[row['child_name']] = row['name']
        if row['name'] not in profitCentres:
            profitCentres.append(row['name'])
   
    return sorted(portfolioProfitcentreDict.keys()),profitCentres,portfolioProfitcentreDict
ChristopherL
 
Posts: 13
Joined: Tue Jul 16, 2013 2:03 pm

Re: New to python!

Postby Kebap » Tue Jul 23, 2013 1:35 pm

ChristopherL wrote:I don't really catch whats happening..
If anyone might be able to explain these steps :)

Please see my comment above. ;)
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 400
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe


Return to General Coding Help

Who is online

Users browsing this forum: keithterrill and 3 guests