#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    80
    Rep Power
    3

    Strings and that silly backslash... (also, timeit)


    So, this is back on the original auto-timeit function I was discussing earlier.

    Code:
    Traceback (most recent call last):
      File "C:\Documents and Settings\*****\Desktop\Console\benchmarking.py", line 26, in <module>
        benchmark(1000,**test)
      File "C:\Documents and Settings\*****\Desktop\Console\benchmarking.py", line 16, in benchmark
        result=timeit.timeit(test,setup,runcount)
      File "C:\Python27\lib\timeit.py", line 230, in timeit
        return Timer(stmt, setup, timer).timeit(number)
      File "C:\Python27\lib\timeit.py", line 136, in __init__
        code = compile(src, dummy_src_name, "exec")
      File "<timeit-src>", line 4
        pull= storage_functions(extension=".tmp",location="C:\Documents and Settings\*****\Desktop\Console\Temp\")[0]
                                                                                                                          ^
    SyntaxError: EOL while scanning string literal
    The problem is, as best I can discern, found while the interpreter is sending code to the shell, it's parsing the link down to the point where it's only sending a single backslash and not a double backslash as is required for python to parse it into a proper file directory.

    So, I guess the question is, 'How to I sanitize my string input in such a way that I can send it double backslashes?'

    or, if that's not the case:

    What's the EOL error I'm getting here?

    any help would be appreciated.

    Also, the name of that folder is not a series of asterisks, I'm just using my own computer and I don't want everyone on the internet to know the name of my grandmother. :P
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Posts
    530
    Rep Power
    34
    Python allows forward slashes to avoid this problem
    pull= storage_functions(extension=".tmp",location="C:/Documents and Settings/****/Desktop/Console/Temp/")[0]
    Last edited by dwblas; July 13th, 2013 at 02:24 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    80
    Rep Power
    3
    Ah. XD
    Thank you.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    80
    Rep Power
    3
    Does the timeit lack read permissions? I can't get it to open the dang file. :\

IMN logo majestic logo threadwatch logo seochat tools logo