convert string to raw string?

2004-12-05 Thread Phd
Hi,
I'm writing a regex related program that lets the user supplies the 
regex definition. Is there an easy way to convert a string into a raw 
string?

Cheers
--
http://mail.python.org/mailman/listinfo/python-list


how can I import a module without using pythonpath?

2004-12-14 Thread Phd
Hi,
I'm using python 2.2, I want to import a module by referring to its 
relative location. The reason for this is that there is another module 
with the same name that's already in pythonpath( not my decision, but I 
got to work around it, bummer). So is there any easy way to do it?

something like
import module "from this location"
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: how can I import a module without using pythonpath?

2004-12-14 Thread Phd
Nice, thanks so much!

Doug Holton wrote:
Phd wrote:
Hi,
I'm using python 2.2, I want to import a module by referring to its 
relative location. The reason for this is that there is another module 
with the same name that's already in pythonpath( not my decision, but 
I got to work around it, bummer). So is there any easy way to do it?

import sys, os
sys.path.insert(0,os.path.abspath("relative path"))
import module
sys.path.remove(os.path.abspath("relative path"))
--
http://mail.python.org/mailman/listinfo/python-list


Re: from string to raw string

2004-12-14 Thread Phd
Hi,
I recently asked the same question, the response I got was that just use 
 the string. There is no raw string object so the conversion doesn't 
exist. As far as I know, I haven't run into any problem

Take a try. Please let me know if there is any problem with this approach.
Good luck

Dan Perl wrote:
Is there a way to convert a regular string to a raw string so that one could 
get from '\bblah' to r'\bblah' other than parsing the string and modifying 
the escapes?

I am interested in this for the use of regular expressions.  I would like to 
be able to accept re patterns as inputs either from a file or from a GUI 
tool and I would like to allow those inputs as regular strings and not force 
users to write patterns with double escapes.

I naively thought there could be utilities for such a conversion either in 
the string module or the StringIO module but I don't see any utilities like 
that.

So, any suggestions?
Dan 


--
http://mail.python.org/mailman/listinfo/python-list