User Profile

Collapse

Profile Sidebar

Collapse
jlm699
jlm699
Last Activity: Aug 5 '08, 08:36 PM
Joined: Jul 30 '07
Location: Durham, NC
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • jlm699
    replied to Find a number between 2 regular expressions
    Seeing that there is a space in your text on either side of the number, you should add spaces to your pattern so that it is like this:
    [code=python]
    pattern = re.compile(r': (.*?) \(')
    [/code]...
    See more | Go to post

    Leave a comment:


  • You should read the posting guidelines to learn about
    Code:
     tags, as they increase the readability of your posts, thereby making it easier for the other forum members to answer your question!
    
    Unfortunately, Python's open() call is not intuitive enough to look at a wildcard the same way that the command line does.  However by using the os module there are some ways around that.  I'm not sure exactly how you want your program to work in terms
    ...
    See more | Go to post

    Leave a comment:


  • You can look into the popen suite of commands for some non-blocking usage.
    Link
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Printing the digits of an integer
    Oh wait.. now I see what you were trying to do...
    [code=python]
    >>> def print_n(n):
    ... while n > 0:
    ... print n % 10,
    ... n = n / 10
    ...
    >>> print_n(492)
    2 9 4
    >>> [/code]
    Modulus 10 will give you the remainder but you want to integer divide by 10 each time to reduce the number another digit.
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Printing the digits of an integer
    In python % is the modulo operator... I'm not sure what you are trying here...

    Here's how to reverse the digits of an integer using list comprehension:
    [code=python]>>> def print_digits(n) :
    ... new_n = [lett for lett in str(n)]
    ... new_n.reverse()
    ... print ''.join(new_n)
    ...
    >>> print_digits(13 6)
    631
    >>> [/code]
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Missing command
    There is a work around that I use in a situation such as yours... at the end of all my code I simply put the following:
    [code=python]
    raw_input( 'Press enter to quit' )
    # This message is completely arbitrary, btw...
    [/code]

    This way the console will stay open and wait for the user to press enter before quitting.
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to adding arguments to buttons
    You could simply store username and password as members of whatever class is represented by self.

    In your function initialization of login, have default values for those parameters, then at the beginning of the function, if the values are default, try the self.username and self.password values.

    I do not know of any way to actually pass parameters for a bound function without actually calling it, however.
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to type conversion problem
    [code=python]
    >>> x = [1,2,3]
    >>> sum( [ i**2 for i in x ] )
    14
    >>>
    [/code]
    Why the type conversion?
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Decimal issues
    FYI, Base 2 = Binary. Base 10 = Decimal. What are you trying to say in that first line there? Are you trying to say that Python handles two-digit precision floating-point numbers? And if so, how?...
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Decimal issues
    Maybe wait for a new version of Python?? :(
    This is for sure frustrating for many, and I have a feeling that the guys working on each new version of Python keep this in mind. What version of Python do you use, for curiosity's sake?...
    See more | Go to post

    Leave a comment:


  • You can use a combo of package_dir and py_modules as below (where the packages I wanted to include in the distributable file were ../Common/[logfile, remoteCmd, and crc32])

    [code=python]
    setup(
    zipfile = None,
    # We use os.path.join for portability
    package_dir = {'': os.path.join('. .', 'Common')},
    py_modules = ['logfile', 'remoteCmd', 'crc32'],
    windows = [
    {
    ...
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Decimal issues
    I think this may take dirty tricks... Python isn't the most friendly floating point language and Decimal is nice as long as you're keeping it "in the family", as in not converting back to any other types (except string). So if there is a way for your instrument to accept a string representation of a value you could simply wrap str() around your result... other wise you'll have to do some dirty work.

    You could possibly overload...
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Python + SOAP + WSDL: Array-type
    This is not a Python related question. Please post this question in the proper forum. Also, please use code tags in the future. Read the Posting Guidelines for tips on how to use tags in your posts.
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to using multiple 'if' statements in Python
    In case you're still wondering the if, else structure in Python is:
    [code=python]
    if condition 1:
    action 1
    elif condition 2:
    action 2
    elif condition 3:
    action 3
    else:
    default action
    [/code]
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Anyone have any example python code?
    I cannot recommend this enough, but if you're looking for some great learning examples you should head on over to diveintopython. org and pick up a copy of the book for download. When you download the pdf file you will get a ton of example code.

    If you're looking for example wxPython code head on over to the wxPython download page and download the wxPython docs, demos and tools package, which will give you an interactive demo that...
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to Accessing variables
    Please use code tags in your posts. Refer to the Posting Guidelines about how to properly respond to questions....
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to wxPython AND PyGame: IMAGES
    I've gotten bitmaps to work before in wxPython, however I've never attempted such an act in PyGame. In order to get a bitmap into a wx-friendly format I used the following:
    [code=python]
    bmp = wx.Image('Splas h.bmp', wx.BITMAP_TYPE_ BMP, -1).ConvertToBit map()
    [/code]
    And then in your code you would use
    [code=python]
    quit.SetBitmap( bmp)
    [/code]
    Please let us know if that helped at all......
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to I don't even know what it's called...
    You would have to write your own utility for parsing the file, but it would probably be something like this:
    [code=python]
    f = open( my_prog.py, 'r' )

    for line in f:
    data = line.split('=')
    if len( data ) == 2:
    var_name = data[0]
    try:
    var_val = int( data[1] )
    # Now you can change the value to whatever you want
    ...
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to convert unicode type to list or tuple
    Google the python module xlrd ... it'll take care of data extraction for you.
    See more | Go to post

    Leave a comment:


  • jlm699
    replied to A problem running the pygame setup
    It should search recursively but for sanity's sake open up a Python shell and type in:
    [code=python]
    >>> import sys
    >>> sys.path
    ['', 'C:\\WINDOWS\\s ystem32\\python 24.zip', 'C:\\Python24\\ Lib\\site-packages\\wx-2.8-msw-unicode\\wx\\py ', 'C:\\Python24\\ DLLs', 'C:\\Python24\\ lib', 'C:\\Python24\\ lib\\plat-win', 'C:\\Python24\\ lib\\lib-tk', 'C:\\Python24', 'C:\\Python24\\ lib\\site-packages', 'C:\\Python24\\ lib\\site-packages\\pytho nutils',...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...