Operating System: Windows
Python version: 2.4
I have bookmarks.html and wumpus.c under my c:
When I tried to check the presence of the bookmarks.html, I fail.
>>> os.path.isfile('c:\bookmarks.html')
False
>>> os.path.isfile('c:\wumpus.c')
True
>>> os.path.exists('c:\wumpus.c')
True
>>> os.path.
Kent Johnson wrote:
> The problem is that \ is special in string literals. \b is a backspace
> character, not the two-character sequence you expect. \w has no special
> meaning so it *is* the two-character sequence you expect.
> The simplest fix is to use raw strings for all your Windows path need
== '__main__':
main()
but the problem with using file was it recognized both .xls (MS Excel)
and .doc ( MS Doc) as Microsoft Word Document only. I need to separate
the .xls and .doc files, I dont know if file will be helpful here.
--
If the first approach of mime
Justin Azoff wrote:
> Additionally, I would re-organize your program a bit. something like:
>
Thanks Justin, that was a helpful one. Helping me in learning python
programming.
Thanks,
Senthil
--
http://mail.python.org/mailman/listinfo/python-list
Hi all,
Part of my script is to check for pre-requisite rpms to be
installed.
If its installed, I just display the rpm version as in rpm database,
otherwise I output a message saying:
' rpm is not installed' and collect the rpm name in a list
(notInstalled).
At the end if the len(notInstal
Juho Schultz wrote:
> I think return values should be used for communication between
> functions. Maybe something like this could work for you (not tested).
>
> def checkForRpm(rpmname):
> #
> # Strings with 0 lenght are False
> if output:
> print output
> else:
> p
Hi,
I have the following directory structure in my project.
Base:
file1.py
file2.py
Directory1:
file1-dir1.py
I am able to import file1 into file2.py
What I need to do is, import file1 in the file file1-dir1.py.
I did not create the entire dir
I write a script:
#!/usr/bin/python
astring = "This is a String"
def fun1():
astring = "I modify it in fun1"
def fun2():
astring = "I modify it in fun2"
def main():
print astring
fun1()
print astring
fun2()
print astring
if __name__ == '__mai
Bjoern Schliessmann wrote:
> If you assign "astring" inside the function body, it's a local name.
>
> > - What should I do to overwrite the string variable in the global
> > section within functions?
>
> Put a "global astring" in the function to access the global name
> instead.
#!/usr/bin/python
Hi,
The following piece of code works properly when my proxy password
contains characters[a-zA-Z0-9] etc. But when my proxy password
contained something like '|\/|' , the httplib incorrectly indentified
it as separator. How do I resolve this issue.
# Proxy Address
PROXY_IP = "1.1.9.8:80"
#
Fredrik Lundh wrote:
> Phoe6 wrote:
> > Hi,
> > The following piece of code works properly when my proxy password
> > contains characters[a-zA-Z0-9] etc. But when my proxy password
> > contained something like '|\/|' , the httplib incorrectly indentified
Fredrik Lundh wrote:
Hi Fredrik,
I apologize if I offended you or have shown any
impatience. I shall try again:
> oh, please. urllib.quote is a *function*; there's no way that calling that
> function
> from code written for urllib2 will affect anything.
>
> but you can access url
Fredrik Lundh wrote:
> "Phoe6" wrote:
>
> > - use urllib.quote() to covert the proxy url to a quoted one.
>
> you should use quote to convert the *password* to quoted form, not use it on
> the entire URL.
>
Am sorry Fred. The same problem:
File "C:
Fredrik Lundh wrote:
>
> can you post the code you're using to build the URI ?
>
Okay. This piece of code fetches a page from a particular site. As I am
behind a firewall, I have to communicate through a proxy.
# Set the Proxy Address
PROXY_IP = "10.1.9.4:80"
# Trying with linear way
proxy_user
Fredrik Lundh wrote:
> "Phoe6" wrote:
>
> > proxy_password = urllib.quote(proxy_password_orig)
>
> make that:
>
> proxy_password = urllib.quote(proxy_password_orig, "")
>
Oh yeah. Wonderful!!
That worked. Thanks a lot Fredrik!. :-) (<^> p
Hi,
Following are my files.
In the format:
Filename
content
config1.txt
#DataBase Repository file
dbRepository = omsa_disney.xml
config2.txt
# Configfile for sendmail
[Sendmail]
userprefix = testuser
pyConfig.py
import re
def pyConfig():
fhandle =
Fredrik Lundh wrote:
>
> $ python -m timeit -s "import pyConfig" "pyConfig.pyConfig()"
> $ python -m timeit -s "import pyConparse" "pyConparse.pyConParse()"
> note that timeit runs the benchmarked function multiple times, so you may want
> to remove the print statements.
Thanks a lot Fredrik!. I
Hi all,
I have to uninstall an application and I don't find the uninstaller,
the option available to me is to access Add/Remove Programs, select the
application and remove from there.
I am trying to automate this task using Python:
1) Get the Application Name
2) Access the Add/Remove Program det
Tim Golden wrote:
> [Phoe6]
> and perhaps you need something like
> this (altho' obviously more sophisticated):
>
> import wmi
>
> appname = "Python 2.4.3"
> c = wmi.WMI ()
> for product in c.Win32_Product (Caption=appname):
> print product.Captio
Hi all,
Have a look at this snippet, I have a file direct.txt and I want to
read it as rfc8222.Message() so that I get the Subject: and Mood: as
Dict Keys and content separately, but I am unable to get the Content
Properly.
>>> fhandle = open('direct.txt','r')
>>> print fhandle.read()
Subject: te
Fredrik Lundh wrote:
> Phoe6 wrote:
>
> > Have a look at this snippet, I have a file direct.txt and I want to
> > read it as rfc8222.Message() so that I get the Subject: and Mood: as
> > Dict Keys and content separately, but I am unable to get the Content
> > Pr
Hi All,
I am able to use urlib2 through proxy. I give proxy credentials and use
# Set the Proxy Address
proxy_ip = "10.0.1.1:80"
proxy_user = 'senthil_or'
proxy_password_orig='password'
proxy_password = urllib.quote(proxy_password_orig,"")
# Setup the Proxy with urllib2
proxy_url = 'http://'
pyljvim is a a Livejournal Plugin for Vim. One can post to the
Livejournal directly from vim! :)
It is available at:
http://www.vim.org/scripts/script.php?script_id=1724
Installation is pretty easy and so is the usage.
Thanks,
Senthil
http://phoe6.livejournal.com
Contemptuous lights flashed
Hi,
I have a configfile, in fact, I am providing a configfile in the
format:
[Information]
Name: Foo
Author: Bar
Testcases:
tct123
tct124
tct101
The last values is a multi-line.
ConfigParser is unable to recognize a multi-line value and splits out
error.
C:\ATF-Tasks>python CreateTask.py
Trace
On Jun 20, 10:35 pm, "John Krukoff" <[EMAIL PROTECTED]> wrote:
> > Is there anyway, I can include multi-line value in the configfile? I
>
> Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html)
> indicates that you can spread values out over multiple lines as long as
> there is a s
On Jun 21, 7:34 pm, "John Krukoff" <[EMAIL PROTECTED]> wrote:
> > > > Is there anyway, I can include multi-line value in the configfile? I
>
> > > Following the link to RFC 822 (http://www.faqs.org/rfcs/rfc822.html)
> > > indicates that you can spread values out over multiple lines as long as
> > >
Hi,
Am starting a new thread as I fear the old thread which more than a
week old can go unnoticed.
Sorry for the multiple mails.
I took the approach of Subclassing ConfigParser to support multiline
values without leading white-spaces, but am struct at which position
in _read I should modify to acc
Hi all,
Consider this scenario, where in I need to use subprocess to execute a
command like 'ping 127.0.0.1' which will have a continuous non-
terminating output in Linux.
# code
>>>import subprocess
>>>process = subprocess.Popen('ping 127.0.0.1', shell=True,
>>>stdin=subprocess.PIPE, stdout=subp
Hi All,
I would like to request a code and design review of one of my program.
n-puzzle.py
http://sarovar.org/snippet/detail.php?type=snippet&id=83
Its a N-puzzle problem solver ( Wikipedia page and
http://norvig.com/ltd/test/n-puzzle.lisp
)
I have used OO Python for the above program and would l
On May 19, 2:23 pm, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> On May 18, 4:15 pm, Phoe6 <[EMAIL PROTECTED]> wrote:
> > I would like to request a code and design review of one of my program.
> > n-puzzle.pyhttp://sarovar.org/snippet/detail.php?type=snippet&id=83
On May 21, 4:48 pm, Szabolcs <[EMAIL PROTECTED]> wrote:
> In what circumstances is it advantageous to use tuples instead of lists?
> Is there a difference in performance?
>
As you should not, tuples are immutable while lists are mutable. You
can think of all the scenarios where immutable datatype
I would like to parse RFC 1123 date format and compare two dates. I
find that
datetime module does not specifically confirms to any RFC. Any
suggestions as how I can handle the RFC 1123 date format using
standard libraries before I go to re based parsing?
Thanks,
Senthil
--
http://mail.python.or
Phoe6 wrote:
> I would like to parse RFC 1123 date format and compare two dates. I
> find that
> datetime module does not specifically confirms to any RFC. Any
> suggestions as how I can handle the RFC 1123 date format using
> standard libraries before I go to re based parsing?
W
print and softspace in python
In python, whenever you use >>>print statement it will append a
newline by default. If you don't want newline to be appended, you got
use a comma at the end (>>>print 10,)
When, you have a list of characters and want them to be printed
together a string using a for loo
Hi all,
I have the following directory structure:
wallpaper/
-main.py
-ng/
-- __init__.py
-- setdesktop.py
-yb/
-- __init__.py
-- setdesktop.py
>From main.py, I would like to do:
import n
On Oct 22, 1:24 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> Phoe6 wrote:
> > Hi all,
> > I have the following directory structure:
>
> > wallpaper/
> > -main.py
> > -ng/
> > -- __init__.py
> >
Hi all,
I am trying to disable the NIC card (and other cards) enabled in my
machine to test diagnostics on that card.
I am trying to disable it programmatic using python. I checked python
wmi and i could not find ways to disable/enable, (listing is however,
possible).
Where should I look for to en
On Feb 27, 2:21 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > I am trying to disable it programmatic using python. I checked python
> > wmi and i could not find ways to disable/enable, (listing is however,
> > possible).
>
> > Where should I look for to enable/disable devices in pyth
Hi All,
I am trying to use the telnetlib module.
Manually when I do
telnet 172.31.128.244
I get:
Login: (I type root)
Password: ( I type Password)
And it enters to the Telnet Session:
[root]#
Now, I am trying to use telnetlib module
>>> import telnetlib
>>> tn = telnetlib.Telnet("172.31.128.244"
On Feb 28, 4:15 pm, Bjoern Schliessmann wrote:
> Phoe6 wrote:
> >>>> import telnetlib
> >>>> tn = telnetlib.Telnet("172.31.128.244")
> >>>> tn.read_until("Login: ")
> > '\r\nLogin: '
> >>>> tn.wri
[EMAIL PROTECTED] wrote:
> ---
> Code Context -- Open a pane at the top of the edit window which
> shows the block context of the section of code
> which is scrolling off the top or the window.
>
> But what does that actually mean?
>
> Take this code fragment example (with line numbers added
> for
Hello All,
Youtube channel of pycon09 has some videos (
http://www.youtube.com/user/pycon08),
but most of them don't have a sufficiently good audio quality.
Is there anyone who has better recording of an earlier PyCon talk? If
yes, can you please point me to the location?
Thanks,
Senthil
--
htt
Hello all,
I use cvs to maintain all my python snippets, notes, c, c++ code.
As the hosting provider provides a public webserver also, I was
thinking that I should convert the cvs folders automatically to
website.
1) cvs2web is not what i mean.
2) doxygen may not be suitable.
I tried with rest2w
Hello,
This is a windows services question. The following script which is a
windows service was supposed to something ( download wallpaper and set
the desktopwallpaper) at 16:45 my time here. The service is running,
but the supposed action did not take place. Does anyone who is aware
of win32 apis
I have the following CGIXMLRPCRequestHandler usage example. I have
both the server and the client in the same directory. I based this
following this example:
http://mail.python.org/pipermail/python-list/2005-May/320696.html
Server Code: Foo.py
import os
import SimpleXMLRPCServer
class Foo:
I have a requirement for using caseless dict. I searched the web for
many different implementations and found one snippet which was
implemented in minimal and useful way.
#
import UserDict
class CaseInsensitiveDict(dict, UserDict.DictMixin):
def __init__(self, *args, **kwargs):
esign team.
Senthil
http://phoe6.livejournal.com
--
http://mail.python.org/mailman/listinfo/python-list
le.readline()
As mentioned in the docs, the EOF returns an empty string. I am unable
to catch or match against the EOF. Please help me in pointing out as
where I am making the mistake.
--
Senthil
http://phoe6.livejournal.com
--
http://mail.python.org/mailman/listinfo/python-list
Thomas Girod wrote:
>
> while line != "":
>
> and it works very well.
Thanks Thomas, I stand corrected now.
my mistake, I was checking against a single space ' ' instead of empty
string ''. :(
--
Senthil
--
http://mail.python.org/mailman/listinfo/python-list
Michael Sperlle wrote:
> When I bring up the command line interface, it looks like: [EMAIL PROTECTED]
>
> Then I type in some command, and it works!
>
> But there are lots of commands to type in, and I find it more and more
> difficult to remember them.
This question is not for comp.lang.python.
H
Hi all.
I am using IDLE when I am on the python shell, I do:
>>>import os
>>>os.mkdir('newdir')
>>>from dirutils import dir_util
>>>#copy a big directory tree
>>>dir_util.copy_tree('big_directory','newdir')
This works properly, but I find a huge Resource Comsumption of my PC.
100% of CPU and Memo
Hi all,
I have this Code Context feature under Options in the IDLE.
How should I use it? Are there folks here who use it regularly and find
it useful.
Please guide me.
Thanks!
Senthil
--
http://mail.python.org/mailman/listinfo/python-list
I have been trying to use pexpect and I am failing with
pexpect.TIMEOUT for all my attempts. In order to troubleshoot, I
decided to go with simplest possible one.
Here is my ssh to localhost:
[21:29:14 senthil]$ssh localhost -l senthil
sent...@localhost's password:
sent...@ubuntu:~$
And here is
53 matches
Mail list logo