User Profile

Collapse

Profile Sidebar

Collapse
diegososa
diegososa
Last Activity: Mar 26 '08, 05:29 PM
Joined: Oct 16 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • diegososa
    replied to newbie loop efficiency
    If you are worried about performance you should take a look at the module "timeit".
    Between the 2 previous codes (for & while), it's faster the while code.... but just a little, and makes the code ugliest.

    BTW, never bench functions with "print" statements, because it's too slow and make no sense.
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to Unzipping using passwd.
    You can't... :(


    You should use an external zip program with command line support, and call it with "subprocess " .
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to readlines()
    At first: Post code between [code ] [ /code] tags ...

    Second: the "f" file object has like a "pointer" pointing where it's reading... after a "for" loop, that pointer keeps on EOF until you reload the file (re create the object) or until you do f.seek(0).
    That's why function 1 works and function 2 doesn't...
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to add to file
    I think you post in the wrong section... that isn't Python, right?
    See more | Go to post

    Leave a comment:


  • diegososa
    started a topic Same Object !

    Same Object !

    This should be so easy, but i'm stuck... i want to have two local copies of an incoming object (in this case, a ConfigParser), to modify one of them and later compare them. The problem is that this code give me two names to the SAME object!!!

    [code=Python]class updater():
    def __init__(self, config):
    self.__config = config
    self.__oldconf = config [/code]

    How can i have an independent...
    See more | Go to post

  • diegososa
    replied to does int() automatically call round()?
    Where is the inconsistancy?? ?? It's pretty clear, the only thing that you have to do is read the docs...

    Code:
    int( [x[, radix]]) 
    
    Convert a string or number to a plain integer. If the argument is a string, it must contain a possibly signed decimal number representable as a Python integer, possibly embedded in whitespace. The radix parameter gives the base for the conversion and may be any integer in the range [2, 36], or
    ...
    See more | Go to post

    Leave a comment:


  • This sentence should achieve that:
    [CODE=Python]sys.stderr = sys.stdout[/CODE]


    Code:
    stdin 
    stdout
    stderr
    File objects corresponding to the interpreter's standard input, output and error streams. stdin is used for all interpreter input except for scripts but including calls to input() and raw_input(). stdout is used for the output of print and expression statements and for the prompts of input() and raw_input().
    ...
    See more | Go to post

    Leave a comment:


  • I can't figure out what do you really want, but take a look at : os.walk()
    See more | Go to post

    Leave a comment:


  • Take a look at threading.Timer...
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to directory search
    What about this:

    Code:
    import os
    
    def searchForDir( dir_looking_for, path_to_search_for, debug = False):
        results=[]
        for root, dirs, files in os.walk( path_to_search_for ):
            if dir_looking_for in dirs:
                results.append(root)
        if debug:
            if results:
                print "There is %i results for your query, and they are: " % (len(results),)
    ...
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to comparing files
    You could capture the output of the system-dependent command to get the directory size... i don't know which one is more efficient.
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to perl/CGI
    Take a look at "cgi-bin" alias and directory at "httpd.conf " .

    The default cgi-bin directory is in the Apache directory, probably not the one that you are using..
    See more | Go to post

    Leave a comment:


  • diegososa
    started a topic Send file to server unnatended

    Send file to server unnatended

    Hi! I'm new here and also new in Python, and i have a simple question:

    I have:
    -a python program running on a Linux machine
    -a Windows XP machine with a WAMP Server, and python for Windows installed too.

    I wanna:
    - send a file from the client to the server, in the easiest and most effective way possible, without user interference.

    I reed a lot about it, but i cannot made it to work....
    See more | Go to post

  • diegososa
    replied to Dreams-program giving me trouble
    You should search Python doc files about: pickle...
    See more | Go to post

    Leave a comment:


  • diegososa
    replied to Need help fixing if/while statement
    Please post the code with [code ] and [/ code] to keep indentation !
    See more | Go to post

    Leave a comment:


  • Yes... that's it. OMG, I feel so silly right now, what a dumb mistake !!

    Thanks a lot!
    See more | Go to post

    Leave a comment:


  • Here is the entire .py file, isn't so long so i decided to post it complete. Hope you can help me, thanks in advance :)
    (also hope that the "spanish locale" wasn't a problem to debug :) )


    Code:
    # -*- coding: cp1252 -*-
    import sys, urllib, urllib2, commands, os, datetime, ConfigParser, signal
    import string, time, logging, logging.handlers, subprocess
    import httplib, inspect
    
    def
    ...
    See more | Go to post

    Leave a comment:


  • diegososa
    started a topic Issue with return statement inside except of for

    Issue with return statement inside except of for

    I have this code inside a function:

    Code:
    try:
            for linea in subprocess.Popen(comando, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).stdout:
                    req = urllib2.Request(URL, "&mac_addr=" + mac_addr + " &sampled_time=" + sampled_time + " &line_data=" + linea)
                    ret = urllib2.urlopen(req).read()
    except (urllib2.URLError, httplib.HTTPException):
    ...
    See more | Go to post
    Last edited by diegososa; Oct 17 '07, 01:52 AM. Reason: change subject
No activity results to display
Show More
Working...