argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
I currently use ActivePython 2.5.1. Consider the following code which I saved as cmdline.py: import sys print sys.argv[0] If I invoke this code as 'python cmdline.py', then the output is: cmdline.py If I invoke it as 'cmdline.py', then the output is: C:\Users\hai\src\python\cmdline.

Re: argv[0] and __file__ inconsistency

2007-12-31 Thread Hai Vu
> use os.path.abspath Bingo! This is just what the doctor ordered. Thank you. Hai -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing links within a html file.

2008-01-16 Thread Hai Vu
ml#outline ? > Thanks > Shriphani P. Try Mark Pilgrim's excellent example at: http://www.diveintopython.org/http_web_services/index.html >From the above link, you can retrieve openanything.py which I use in my example: # list_url.py # created by Hai Vu on 1/16/2008 from openanythi

Re: reading a specific column from file

2008-01-17 Thread Hai Vu
Here is another suggestion: col = 2 # third column filename = '4columns.txt' third_column = [line[:-1].split('\t')[col] for line in open(filename, 'r')] third_column now contains a list of items in the third column. This solution is great for small files (up to a couple of thousand of lines). Fo

Re: "Code Friendly" Blog?

2008-01-17 Thread Hai Vu
On Jan 17, 2:50 pm, Miki <[EMAIL PROTECTED]> wrote: > Hello, > > Posting code examples to blogger.com hosted blog is not fun (need to > remember alway escape < and >). > Is there any free blog hosting that is more "code friendly" (easy to > post code snippets and such)? > > Thanks, > -- > Miki <[EM

Re: "Code Friendly" Blog?

2008-01-18 Thread Hai Vu
Miki, Why don't you try to use Code Colorizer: http://www.chamisplace.com/colorizer/cc.asp -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating variables from dicts

2010-02-23 Thread Hai Vu
On Feb 23, 12:53 pm, vsoler wrote: > Hi, > > I have two dicts > > n={'a', 'm', 'p'} > v={1,3,7} > > and I'd like to have > > a=1 > m=3 > p=7 > > that is, creating some variables. > > How can I do this? I think you meant to use the square brackets [ ] instead of the curly ones { } to define the li

Re: stripping fields from xml file into a csv

2010-02-27 Thread Hai Vu
On Feb 27, 12:50 pm, Hal Styli wrote: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite > in python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="dick" product=

Re: stripping fields from xml file into a csv

2010-02-28 Thread Hai Vu
On Feb 28, 12:05 am, Stefan Behnel wrote: > Hal Styli, 27.02.2010 21:50: > > > I have a sed solution to the problems below but would like to rewrite > > in python... > > Note that sed (or any other line based or text based tool) is not a > sensible way to handle XML. If you want to read XML, use a