Semi-Newbie needs a little help

Discussion in 'Python' started by Nile, Jul 6, 2009.

  1. Nile

    Nile Guest

    I am trying to write a simple little program to do some elementary
    stock market analysis. I read lines, send each line to a function and
    then the function returns a date which serves as a key to a
    dictionary. Each time a date is returned I want to increment the value
    associated with that date. The function seems to be working properly.
    By means of a print statement I have inserted just before the return
    value I can see there are three dates that are returned which is
    correct. The dictionary only seems to capture the last date. My test
    data consists of five stocks, each stock with five days. The correct
    answer would be a count of 5 for the second day, the third day, and
    the last day -- 11/14/2008.

    Here is the a code, followed by a portion of the output. I know
    enough to write simple little programs like this with no problems up
    until now but I don't know enough to figure out what I am doing
    wrong.

    Code

    for x in range(len(file_list)):
    d = open(file_list[x] , "r")
    data = d.readlines()
    k = above_or_below(data) # This
    function seems to work correctly
    print "here is the value that was returned " , k
    dict[k] = dict.get(k,0) + 1

    dict_list = dict.values()
    print "here is a list of the dictionary values ", dict_list
    print "the length of the dictionary is ", len(dict)

    And here is some output
    Function will return k which = 11/11/2008 # These 3 lines are
    printed from the function just before the return
    Function will return k which = 11/12/2008 # This sample shows
    stocks 4 and 5 but 1,2,3 are the same.
    Function will return k which = 11/14/2008
    here is the value that was returned 11/14/2008 # printed from
    code above - only the last day seems to be
    Function will return k which = 11/11/2008 #
    recognized.
    Function will return k which = 11/12/2008
    Function will return k which = 11/14/2008
    here is the value that was returned 11/14/2008
    here is a list of the dictionary values [5] # dict has
    counted only the last day for 5 stocks
    the length of the dictionary is 1
    >Exit code: 0
     
    Nile, Jul 6, 2009
    #1
    1. Advertising

  2. Nile

    Chris Rebert Guest

    On Mon, Jul 6, 2009 at 3:02 PM, Nile<> wrote:
    > I am trying to write a simple little program to do some elementary
    > stock market analysis.  I read lines, send each line to a function and
    > then the function returns a date which serves as a key to a
    > dictionary. Each time a date is returned I want to increment the value
    > associated with that date. The function seems to be working properly.
    > By means of a print statement I have inserted just before the return
    > value I can see there are three dates that are returned which is
    > correct.  The dictionary only seems to capture the last date. My test
    > data consists of five stocks, each stock with five days. The correct
    > answer would be a count of 5 for the second day, the third day, and
    > the last day -- 11/14/2008.
    >
    > Here is the a code, followed by a portion of the output.  I know
    > enough to write simple little programs like this with no problems up
    > until now but I don't know enough to figure out what I am doing
    > wrong.


    >    for x in range(len(file_list)):


    for filename in file_list:
    #I'm assuming the lack of indentation on the subsequent lines is a
    mere transcription error...

    >    d = open(file_list[x] , "r")


    d = open(filename , "r")

    >    data = d.readlines()
    >    k = above_or_below(data)                                # This
    > function seems to work correctly
    >    print "here is the value that was returned " , k
    >    dict[k] = dict.get(k,0) + 1


    `dict` is the name of a builtin type. Please rename this variable to
    avoid shadowing the type.
    Also, where is this variable even initialized? It's not in this code
    snippet you gave.
    Further, I would recommend using a defaultdict
    (http://docs.python.org/dev/library/collections.html#collections.defaultdict)
    rather than a regular dictionary; this would make the
    count-incrementing part nicer.

    Taking these changes into account, your code becomes:

    from collections import defaultdict

    counts = defaultdict(lambda: 0)

    for filename in file_list:
    d = open(filename , "r")
    data = d.readlines()
    k = above_or_below(data) # This function seems to work correctly
    print "here is the value that was returned " , k
    counts[k] += 1

    values = counts.values()
    print "here is a list of the dictionary values ", values
    print "the length of the dictionary is ", len(counts)


    I don't immediately see what's causing your problem, but guess that it
    might've be related to the initialization of the `dict` variable.

    Cheers,
    Chris
    --
    http://blog.rebertia.com
     
    Chris Rebert, Jul 6, 2009
    #2
    1. Advertising

  3. On Mon, Jul 6, 2009 at 17:02, Nile<> wrote:
    > Code
    >
    >    for x in range(len(file_list)):
    >    d = open(file_list[x] , "r")
    >    data = d.readlines()
    >    k = above_or_below(data)                                # This
    > function seems to work correctly
    >    print "here is the value that was returned " , k
    >    dict[k] = dict.get(k,0) + 1
    >
    >    dict_list = dict.values()
    >    print "here is a list of the dictionary values ", dict_list
    >    print "the length of the dictionary is ", len(dict)


    Correcting your indentation errors and moving your comments above the
    line they reference will attract more help from others in this list
    ;-)

    Also, I'd recommend limiting your line length to 80 chars, since lines
    are wrapped anyway.


    --
    Pablo Torres N.
     
    Pablo Torres N., Jul 6, 2009
    #3
  4. Nile

    MRAB Guest

    Chris Rebert wrote:
    > On Mon, Jul 6, 2009 at 3:02 PM, Nile<> wrote:
    >> I am trying to write a simple little program to do some elementary
    >> stock market analysis. I read lines, send each line to a function and
    >> then the function returns a date which serves as a key to a
    >> dictionary. Each time a date is returned I want to increment the value
    >> associated with that date. The function seems to be working properly.
    >> By means of a print statement I have inserted just before the return
    >> value I can see there are three dates that are returned which is
    >> correct. The dictionary only seems to capture the last date. My test
    >> data consists of five stocks, each stock with five days. The correct
    >> answer would be a count of 5 for the second day, the third day, and
    >> the last day -- 11/14/2008.
    >>
    >> Here is the a code, followed by a portion of the output. I know
    >> enough to write simple little programs like this with no problems up
    >> until now but I don't know enough to figure out what I am doing
    >> wrong.

    >
    >> for x in range(len(file_list)):

    >
    > for filename in file_list:
    > #I'm assuming the lack of indentation on the subsequent lines is a
    > mere transcription error...
    >
    >> d = open(file_list[x] , "r")

    >
    > d = open(filename , "r")
    >
    >> data = d.readlines()
    >> k = above_or_below(data) # This
    >> function seems to work correctly
    >> print "here is the value that was returned " , k
    >> dict[k] = dict.get(k,0) + 1

    >
    > `dict` is the name of a builtin type. Please rename this variable to
    > avoid shadowing the type.
    > Also, where is this variable even initialized? It's not in this code
    > snippet you gave.
    > Further, I would recommend using a defaultdict
    > (http://docs.python.org/dev/library/collections.html#collections.defaultdict)
    > rather than a regular dictionary; this would make the
    > count-incrementing part nicer.
    >
    > Taking these changes into account, your code becomes:
    >
    > from collections import defaultdict
    >
    > counts = defaultdict(lambda: 0)
    >

    Better is:

    counts = defaultdict(int)

    > for filename in file_list:
    > d = open(filename , "r")
    > data = d.readlines()
    > k = above_or_below(data) # This function seems to work correctly
    > print "here is the value that was returned " , k
    > counts[k] += 1
    >
    > values = counts.values()
    > print "here is a list of the dictionary values ", values
    > print "the length of the dictionary is ", len(counts)
    >
    >
    > I don't immediately see what's causing your problem, but guess that it
    > might've be related to the initialization of the `dict` variable.
    >

    It might be that the indentation was wrong where the count is
    incremented, but I can't tell because none of the lines were shown
    indented.
     
    MRAB, Jul 6, 2009
    #4
  5. Nile

    Nile Guest

    On Jul 6, 5:30 pm, "Pablo Torres N." <> wrote:
    > On Mon, Jul 6, 2009 at 17:02, Nile<> wrote:
    > > Code

    >
    > >    for x in range(len(file_list)):
    > >    d = open(file_list[x] , "r")
    > >    data = d.readlines()
    > >    k = above_or_below(data)                                # This
    > > function seems to work correctly
    > >    print "here is the value that was returned " , k
    > >    dict[k] = dict.get(k,0) + 1

    >
    > >    dict_list = dict.values()
    > >    print "here is a list of the dictionary values ", dict_list
    > >    print "the length of the dictionary is ", len(dict)

    >
    > Correcting your indentation errors and moving your comments above the
    > line they reference will attract more help from others in this list
    > ;-)
    >
    > Also, I'd recommend limiting your line length to 80 chars, since lines
    > are wrapped anyway.
    >
    > --
    > Pablo Torres N.


    Yup - Sorry, first post ever - next ones will be better formatted
     
    Nile, Jul 6, 2009
    #5
  6. Nile

    Guest Guest

    Newbie needs help

    Dear Python gurus,

    If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used?

    Also, I'd like to get a simulation result, like voltage, is it possible to get this value in Python environment?

    Please let me know,
    nacim
     
    Guest, Jul 7, 2009
    #6
  7. Nile

    Rhodri James Guest

    Re: Newbie needs help

    On Tue, 07 Jul 2009 00:00:39 +0100, <> wrote:

    > Dear Python gurus,
    >
    > If I'd like to set dielectric constant for the certain material, is it
    > possible to do such in Python environment? If yes, how to do or what
    > syntax can be used?
    >
    > Also, I'd like to get a simulation result, like voltage, is it possible
    > to get this value in Python environment?


    Quite possibly, however you're going to have to give us a *lot* more
    information before the answers you get will be worth anything at all.
    How is "the certain material" represented? What simulator are you
    using? Which Python environment? Which Python version for that matter?

    We may appear to be mind-readers, but we usually need a bit more
    than this to work on.

    --
    Rhodri James *-* Wildebeest Herder to the Masses
     
    Rhodri James, Jul 7, 2009
    #7
  8. Nile

    Nile Guest

    On Jul 6, 5:22 pm, Chris Rebert <> wrote:
    > On Mon, Jul 6, 2009 at 3:02 PM, Nile<> wrote:
    > > I am trying to write a simple little program to do some elementary
    > > stock market analysis.  I read lines, send each line to a function and
    > > then the function returns a date which serves as a key to a
    > > dictionary. Each time a date is returned I want to increment the value
    > > associated with that date. The function seems to be working properly.
    > > By means of a print statement I have inserted just before the return
    > > value I can see there are three dates that are returned which is
    > > correct.  The dictionary only seems to capture the last date. My test
    > > data consists of five stocks, each stock with five days. The correct
    > > answer would be a count of 5 for the second day, the third day, and
    > > the last day -- 11/14/2008.

    >
    > > Here is the a code, followed by a portion of the output.  I know
    > > enough to write simple little programs like this with no problems up
    > > until now but I don't know enough to figure out what I am doing
    > > wrong.
    > >    for x in range(len(file_list)):

    >
    > for filename in file_list:
    > #I'm assuming the lack of indentation on the subsequent lines is a
    > mere transcription error...
    >
    > >    d = open(file_list[x] , "r")

    >
    >     d = open(filename , "r")
    >
    > >    data = d.readlines()
    > >    k = above_or_below(data)                                # This
    > > function seems to work correctly
    > >    print "here is the value that was returned " , k
    > >    dict[k] = dict.get(k,0) + 1

    >
    > `dict` is the name of a builtin type. Please rename this variable to
    > avoid shadowing the type.
    > Also, where is this variable even initialized? It's not in this code
    > snippet you gave.
    > Further, I would recommend using a defaultdict
    > (http://docs.python.org/dev/library/collections.html#collections.defau...)
    > rather than a regular dictionary; this would make the
    > count-incrementing part nicer.
    >
    > Taking these changes into account, your code becomes:
    >
    > from collections import defaultdict
    >
    > counts = defaultdict(lambda: 0)
    >
    > for filename in file_list:
    >     d = open(filename , "r")
    >     data = d.readlines()
    >     k = above_or_below(data) # This function seems to work correctly
    >     print "here is the value that was returned " , k
    >     counts[k] += 1
    >
    >     values = counts.values()
    >     print "here is a list of the dictionary values ", values
    >     print "the length of the dictionary is ", len(counts)
    >
    > I don't immediately see what's causing your problem, but guess that it
    > might've be related to the initialization of the `dict` variable.
    >
    > Cheers,
    > Chris
    > --http://blog.rebertia.com- Hide quoted text -
    >
    > - Show quoted text -


    I initialized the dictionary earlier in the program like this -

    hashtable = {}

    I changed the "dict" to hashtable but I still get the same result
    I will try to learn about the defaultdict but I'm just trying to keep
    it as simple as I can for now

    Revised code

    for x in range(len(file_list)):
    d = open(file_list[x] , "r")
    data = d.readlines()
    k = 0
    k = above_or_below(data)
    print "here is the value that was returned ",k
    hashtable[k] = hashtable.get(k,0) + 1


    hashtable_list = hashtable.values()
    print "here is a list of the dictionary values ", hashtable_list
    print "the length of the dictionary is ", len(hashtable)

    Output
    # The first 3 lines are printed from the function
    # right before the return statement. This output
    # snippet shows the last two stocks. The function
    # SAYS it is returning the correct value but only
    # the last date seems to make it to the hashtable
    Function will return k which = 11/11/2008
    Function will return k which = 11/12/2008
    Function will return k which = 11/14/2008

    # this line is printed from the code above
    # I don't understand why all three dates don't
    # seem to make it to the main program. Only
    # the last date seems to be recognized
    here is the value that was returned 11/14/2008

    Function will return k which = 11/11/2008
    Function will return k which = 11/12/2008
    Function will return k which = 11/14/2008
    here is the value that was returned 11/14/2008
    here is a list of the dictionary values [5]
    the length of the dictionary is 1
    >Exit code: 0
     
    Nile, Jul 7, 2009
    #8
  9. Nile

    MRAB Guest

    Nile wrote:
    [snip]
    > I initialized the dictionary earlier in the program like this -
    >
    > hashtable = {}
    >
    > I changed the "dict" to hashtable but I still get the same result
    > I will try to learn about the defaultdict but I'm just trying to keep
    > it as simple as I can for now
    >
    > Revised code
    >
    > for x in range(len(file_list)):
    > d = open(file_list[x] , "r")
    > data = d.readlines()


    What's the point of the following line?

    > k = 0
    > k = above_or_below(data)
    > print "here is the value that was returned ",k
    > hashtable[k] = hashtable.get(k,0) + 1
    >
    >
    > hashtable_list = hashtable.values()
    > print "here is a list of the dictionary values ", hashtable_list
    > print "the length of the dictionary is ", len(hashtable)
    >
    > Output
    > # The first 3 lines are printed from the function
    > # right before the return statement. This output
    > # snippet shows the last two stocks. The function
    > # SAYS it is returning the correct value but only
    > # the last date seems to make it to the hashtable


    > Function will return k which = 11/11/2008
    > Function will return k which = 11/12/2008
    > Function will return k which = 11/14/2008
    >
    > # this line is printed from the code above
    > # I don't understand why all three dates don't
    > # seem to make it to the main program. Only
    > # the last date seems to be recognized
    > here is the value that was returned 11/14/2008
    >
    > Function will return k which = 11/11/2008
    > Function will return k which = 11/12/2008
    > Function will return k which = 11/14/2008
    > here is the value that was returned 11/14/2008
    > here is a list of the dictionary values [5]
    > the length of the dictionary is 1
    >> Exit code: 0


    I think there's a bug in 'above_or_below' which you haven't noticed.
     
    MRAB, Jul 7, 2009
    #9
  10. Nile

    Rhodri James Guest

    On Tue, 07 Jul 2009 00:29:36 +0100, Nile <> wrote:

    > Revised code
    >
    > for x in range(len(file_list)):
    > d = open(file_list[x] , "r")
    > data = d.readlines()
    > k = 0
    > k = above_or_below(data)
    > print "here is the value that was returned ",k
    > hashtable[k] = hashtable.get(k,0) + 1
    >
    >
    > hashtable_list = hashtable.values()
    > print "here is a list of the dictionary values ", hashtable_list
    > print "the length of the dictionary is ", len(hashtable)
    >
    > Output
    > # The first 3 lines are printed from the function
    > # right before the return statement. This output
    > # snippet shows the last two stocks. The function
    > # SAYS it is returning the correct value but only
    > # the last date seems to make it to the hashtable
    > Function will return k which = 11/11/2008
    > Function will return k which = 11/12/2008
    > Function will return k which = 11/14/2008


    Have you checked the indentation of the print statement
    that produces this? Is it perhaps inside a loop still?

    --
    Rhodri James *-* Wildebeest Herder to the Masses
     
    Rhodri James, Jul 7, 2009
    #10
  11. Nile

    Dave Angel Guest

    MRAB wrote:
    > <div class="moz-text-flowed" style="font-family: -moz-fixed">Nile wrote:
    > [snip]
    >> I initialized the dictionary earlier in the program like this -
    >>
    >> hashtable = {}
    >>
    >> I changed the "dict" to hashtable but I still get the same result
    >> I will try to learn about the defaultdict but I'm just trying to keep
    >> it as simple as I can for now
    >>
    >> Revised code
    >>
    >> for x in range(len(file_list)):
    >> d = open(file_list[x] , "r")
    >> data = d.readlines()

    >
    > What's the point of the following line?
    >
    >> k = 0
    >> k = above_or_below(data)
    >> print "here is the value that was returned ",k
    >> hashtable[k] = hashtable.get(k,0) + 1
    >>
    >>
    >> hashtable_list = hashtable.values()
    >> print "here is a list of the dictionary values ", hashtable_list
    >> print "the length of the dictionary is ", len(hashtable)
    >>
    >> Output
    >> # The first 3 lines are printed from the function
    >> # right before the return statement. This output
    >> # snippet shows the last two stocks. The function
    >> # SAYS it is returning the correct value but only
    >> # the last date seems to make it to the hashtable

    >
    >> Function will return k which = 11/11/2008
    >> Function will return k which = 11/12/2008
    >> Function will return k which = 11/14/2008
    >>
    >> # this line is printed from the code above
    >> # I don't understand why all three dates don't
    >> # seem to make it to the main program. Only
    >> # the last date seems to be recognized
    >> here is the value that was returned 11/14/2008
    >>
    >> Function will return k which = 11/11/2008
    >> Function will return k which = 11/12/2008
    >> Function will return k which = 11/14/2008
    >> here is the value that was returned 11/14/2008
    >> here is a list of the dictionary values [5]
    >> the length of the dictionary is 1
    >>> Exit code: 0

    >
    > I think there's a bug in 'above_or_below' which you haven't noticed.
    >
    > </div>
    >

    The code supplied doesn't match the output supplied. It'd probably help
    if the output was actually pasted from the command window, instead of
    retyped with more comments than data. And of course it'd help if you
    actually showed us the function above_or_below(), which is probably
    where the bug is. If it prints three values, but returns a string, then
    why would you be surprised? Maybe you intended it to return a list?

    Each time above_or_below() it's called, it prints three lines before
    returning, but only returns the final value. How big is file_list? I
    suspect it's of length 5.

    And the output is shown as repeated twice, but it probably was actually
    five sets of data.

    You do know you can print hashtable, don't you? You're extracting and
    printing the values, but not bothering with the keys.

    I suggest you add a print to the entry point of above_or_below(), to
    match the one you have for its return. And all of these print lines
    should be indented. That might make it easier to interpret the output,
    without lots of inserted comments.

    DaveA
     
    Dave Angel, Jul 7, 2009
    #11
  12. Re: Newbie needs help

    On Mon, 06 Jul 2009 17:00:39 -0600, nacim_bravo wrote:

    > Dear Python gurus,
    >
    > If I'd like to set dielectric constant for the certain material, is it
    > possible to do such in Python environment? If yes, how to do or what
    > syntax can be used?


    certain_material.dielectric_constant = 1.234


    > Also, I'd like to get a simulation result, like voltage, is it possible
    > to get this value in Python environment?


    Yes.



    --
    Steven
     
    Steven D'Aprano, Jul 7, 2009
    #12
  13. Nile

    Gary Herron Guest

    Re: Newbie needs help

    wrote:
    > Dear Python gurus,
    >
    > If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used?
    >
    > Also, I'd like to get a simulation result, like voltage, is it possible to get this value in Python environment?
    >
    > Please let me know,
    > nacim
    >

    This would be a good place for you to start:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Gary Herron, Jul 7, 2009
    #13
  14. En Mon, 06 Jul 2009 19:49:41 -0300, MRAB <>
    escribió:
    > Chris Rebert wrote:


    >> from collections import defaultdict
    >> counts = defaultdict(lambda: 0)
    >>

    > Better is:
    > counts = defaultdict(int)


    For speed? This is even faster:
    zerogen = itertools.repeat(0).next
    counts = defaultdict(zerogen)

    --
    Gabriel Genellina
     
    Gabriel Genellina, Jul 7, 2009
    #14
  15. >>>>> Nile <> (N) wrote:

    >N> I initialized the dictionary earlier in the program like this -


    >N> hashtable = {}


    >N> I changed the "dict" to hashtable but I still get the same result
    >N> I will try to learn about the defaultdict but I'm just trying to keep
    >N> it as simple as I can for now


    >N> Revised code


    >N> for x in range(len(file_list)):
    >N> d = open(file_list[x] , "r")
    >N> data = d.readlines()
    >N> k = 0
    >N> k = above_or_below(data)
    >N> print "here is the value that was returned ",k
    >N> hashtable[k] = hashtable.get(k,0) + 1



    >N> hashtable_list = hashtable.values()
    >N> print "here is a list of the dictionary values ", hashtable_list
    >N> print "the length of the dictionary is ", len(hashtable)


    >N> Output
    >N> # The first 3 lines are printed from the function
    >N> # right before the return statement. This output
    >N> # snippet shows the last two stocks. The function
    >N> # SAYS it is returning the correct value but only
    >N> # the last date seems to make it to the hashtable
    >N> Function will return k which = 11/11/2008
    >N> Function will return k which = 11/12/2008
    >N> Function will return k which = 11/14/2008


    >N> # this line is printed from the code above
    >N> # I don't understand why all three dates don't
    >N> # seem to make it to the main program. Only
    >N> # the last date seems to be recognized
    >N> here is the value that was returned 11/14/2008


    >N> Function will return k which = 11/11/2008
    >N> Function will return k which = 11/12/2008
    >N> Function will return k which = 11/14/2008
    >N> here is the value that was returned 11/14/2008
    >N> here is a list of the dictionary values [5]
    >N> the length of the dictionary is 1
    >>> Exit code: 0


    Now in your code there is a 1-1 relation between printing
    "here is the value that was returned" and incrementing the hashtable
    entry. In your log there are only 2 prints of "here is the value that
    was returned" so how can the count be 5? Are you hiding something from
    us?
    --
    Piet van Oostrum <>
    URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
    Private email:
     
    Piet van Oostrum, Jul 7, 2009
    #15
  16. Nile

    Nile Guest

    Thanks all for your help. I appreciate it. The problem was in the
    function. A simple bug which I should have caught but I had my mental
    blinders on and was sure the problem was outside the function. The
    answers have given me a lot to learn so thanks for that as well.
     
    Nile, Jul 7, 2009
    #16
  17. Nile

    Simon Forman Guest

    Re: Newbie needs help

    On Mon, Jul 6, 2009 at 7:00 PM, <> wrote:
    > Dear Python gurus,
    >
    > If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used?
    >
    > Also, I'd like to get a simulation result, like voltage, is it possible to get this value in Python environment?
    >
    > Please let me know,
    > nacim
    >
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    The answers to your first and third questions are, "yes" and "yes". :]
    (Generally speaking if something can be done by a computer it can be
    done with python.)

    As for your second question check out the "magnitude" package:

    http://pypi.python.org/pypi/magnitude/ and
    http://juanreyero.com/magnitude/

    (That second link also has links to three other packages that deal
    with units of measurement.)

    Ii has units for the SI measurements, including volts and coulombs, so
    you should be able to accomplish your goals with it.

    The tricky thing is, as far as I can tell from the wikipedia entry
    (http://en.wikipedia.org/wiki/Relative_static_permittivity),
    "dielectric constant" seems to be a dimensionless number, i.e. C/C...
    I could be totally daft though.

    HTH,
    ~Simon
     
    Simon Forman, Jul 7, 2009
    #17
  18. Nile

    Guest Guest

    RE: Newbie needs help

    Hello Gurus,

    Thank you for trying to help to my initial and not well written questions. I will compile more detailed information and ask again. Btw, I am giving a glimpse to: "How To Ask Questions The Smart Way".

    nacim


    -----Original Message-----
    From: Simon Forman [mailto:]
    Sent: Tuesday, July 07, 2009 7:19 AM
    To: BRAVO,NACIM (A-Sonoma,ex1)
    Cc:
    Subject: Re: Newbie needs help

    On Mon, Jul 6, 2009 at 7:00 PM, <> wrote:
    > Dear Python gurus,
    >
    > If I'd like to set dielectric constant for the certain material, is it possible to do such in Python environment? If yes, how to do or what syntax can be used?
    >
    > Also, I'd like to get a simulation result, like voltage, is it possible to get this value in Python environment?
    >
    > Please let me know,
    > nacim
    >
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >


    The answers to your first and third questions are, "yes" and "yes". :]
    (Generally speaking if something can be done by a computer it can be
    done with python.)

    As for your second question check out the "magnitude" package:

    http://pypi.python.org/pypi/magnitude/ and
    http://juanreyero.com/magnitude/

    (That second link also has links to three other packages that deal
    with units of measurement.)

    Ii has units for the SI measurements, including volts and coulombs, so
    you should be able to accomplish your goals with it.

    The tricky thing is, as far as I can tell from the wikipedia entry
    (http://en.wikipedia.org/wiki/Relative_static_permittivity),
    "dielectric constant" seems to be a dimensionless number, i.e. C/C...
    I could be totally daft though.

    HTH,
    ~Simon
     
    Guest, Jul 7, 2009
    #18
  19. Re: Newbie needs help

    On Tue, Jul 7, 2009 at 10:02, <> wrote:
    > Hello Gurus,
    >
    > Thank you for trying to help to my initial and not well written questions..  I will compile more detailed information and ask again.  Btw, I am giving a glimpse to: "How To Ask Questions The Smart Way".
    >
    > nacim


    Give this one a try too: http://www.mikeash.com/getting_answers.html
    It doesn't talk down to you...as much :p


    --
    Pablo Torres N.
     
    Pablo Torres N., Jul 7, 2009
    #19
  20. Nile

    Aahz Guest

    Aahz, Jul 8, 2009
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    6
    Views:
    512
    Adrienne
    Feb 26, 2005
  2. google account
    Replies:
    4
    Views:
    858
    Paolo G. Cantore
    Jul 29, 2003
  3. James Stroud

    py2app semi-standalone semi-works

    James Stroud, Oct 4, 2006, in forum: Python
    Replies:
    2
    Views:
    721
    James Stroud
    Oct 4, 2006
  4. ThaDoctor
    Replies:
    3
    Views:
    387
    Alan Woodland
    Sep 28, 2007
  5. Ferd Flintstone

    newbie needs little help please

    Ferd Flintstone, Dec 26, 2003, in forum: Javascript
    Replies:
    6
    Views:
    116
    Thomas 'PointedEars' Lahn
    Dec 27, 2003
Loading...

Share This Page