Re: [Tutor] how to print a message backwards

2009-09-24 Thread Sander Sweers
2009/9/24 ALAN GAULD :
>> print message[::-1]
>
> Yes, the for loop doing one character at a time will be much
> slower than using a slice. The slice is more pythonic but less general.
> A reverse loop is something that is often needed in programming
> solutions so it's useful to know how to do it for the general case.

I have seen this some times but never really understood how it worked.
I have 1 thing I am not sure of, the negative slice in the example
basically means "start counting at the end position and work
backwards"?

Does anyone have an advanced topic on slicing where the :: notation is
explained?

Thanks
Sander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to print a message backwards

2009-09-24 Thread Serdar Tumgoren
> Does anyone have an advanced topic on slicing where the :: notation is
> explained?
>
You should find plenty by googling for "python slice step sequence"

Here are a few with links to further resources:

http://www.python.org/doc/2.3/whatsnew/section-slices.html
http://stackoverflow.com/questions/509211/good-primer-for-python-slice-notation
http://www.daniweb.com/forums/thread222719.html
http://www.daniweb.com/forums/post104865.html#post104865
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Novice qustion

2009-09-24 Thread george fragos
 Hi all Pythons!
 I'm new to Python and this List!
 I'm reading Hetland's "Beginning Python" and I tried to test myself
an example the book provides in 59:


 width = input('Please enter width: ')

price_width = 10
item_width = width - price_width

header_format = '%-*s%*s'
format        = '%-*s%*.2d'

print '=' * width

print haeder_format % (item_width, 'Item', price_width, 'Price')

print '-' * width

print format % (item_width, 'Apples', price_width, 0.4)
print format % (item_width, 'Pears',  price_width, 0.5)
print format % (item_width, 'Cantaloupes', price_width, 1.92)
print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
print format % (item_width, 'Prunes (4 Kgr)', price_width, 12)

print '=' * width

Trying to run this script (saved as "test.py")I receive this error message:

a...@deadend:~/Desktop$ python test.py
  File "test.py", line 18
print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
   ^
SyntaxError: invalid syntax

I double checked my typing and I see no errors in it (I copied it from
the book exactly as it is)!  Are there any...?  What's the "invalid"
in my "syntax"?

Thanx for the help!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Novice qustion

2009-09-24 Thread Oxymoron
On Thu, Sep 24, 2009 at 10:15 PM, george fragos wrote:

> print format % (item_width, 'Cantaloupes', price_width, 1.92)
> print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
>

Notice the line before (works) and after (doesn't work - as the interpreter
pointed out), how do you separate items in a tuple? :-)

Did not check the rest of it.

a...@deadend:~/Desktop$ python test.py

>  File "test.py", line 18
>print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
>   ^
> SyntaxError: invalid syntax
>
> I double checked my typing and I see no errors in it (I copied it from
> the book exactly as it is)!  Are there any...?  What's the "invalid"
> in my "syntax"?
>
> Thanx for the help!
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
There is more to life than increasing its speed.
-- Mahatma Gandhi
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Novice qustion

2009-09-24 Thread Serdar Tumgoren
>>  File "test.py", line 18
>>    print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
>>                                                                   ^
>> SyntaxError: invalid syntax
Oxymoron has pointed you in the right direction. After you fix that
error, however, you'll get another one from a different part of your
program. In general, the error information you get back from the
python interpreter will point you in the right direction. In the above
case, it tells you precisely where the problem is: Line 18 in test.py

Whenever you get errors, you can use the traceback information as a
way to pinpoint where you should start hunting for the error.

HTH!

Serdar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Executing a command from a specific directory

2009-09-24 Thread Ansuman Dash
Hi Kurt,

Sorry for the late reply.

My problem is resolved. Instead of "subprocess.Popen", I used
"subprocess.call".

Thanks all for your replies.

AD


On Fri, Sep 18, 2009 at 8:05 PM, Kurt Bendl  wrote:

> Hello,
>
> On Sep 18, 2009, at 5:16 AM, Ansuman Dash wrote:
>
>  I have written it like that. It is like press 1 and it ll download file1
>> and press 2 it ll download file2 etc
>>
>> But my question was I am using "time.sleep()" to make my script to wait
>> for the file download and then validate it in log file, so is there any
>> other way I can synchronize my code with the download.
>>
>> I am asking this because some files are very huge (120MB) and download
>> also depends on N/W bandwidth so sometimes it ll be done in 30mins and some
>> times it takes 60 mins. So I can't rely on "time.sleep()"
>>
>
>
> I had a similar problem.
> I used pyinotify on a linux box. inotify is a kernel hook
> that you can use to trigger actions on events... like when
> a file write is completed.
>
> Note: I'm a total hack at this. I'm sure there's a more
> elegant way to do what I'm dong, but I needed a fix fast,
> and this worked for me.  I'd appreciate any tips anyone has
> to offer to make this cleaner and/or more pythonic. :-)
>
> I'll be glad to try to answer any questions about this hackery.
>
>
> Best,
>  Kurt
>
>
> Here's a slightly cut-down version of my code:
> http://pastebin.com/f239b0413
>
> inotify_published_file_handler.py
> #
> #!/usr/bin/env python
> # -*- coding: utf-8 -*-
> # encoding: utf-8
> """
> inotify_published_file_handler.py
> rev. 20090706-01
> 
>
> Created by Kurt Bendl.
>
>
> Usage
> -
> sudo su - www-data -c 'cd /web/log/; \
>nohup /web/scripts/inotify_published_file_handler.py > \
>/web/log/inotify-errors.txt 2>&1  &'
>
>
> Purpose
> -
> Monitor the $WEBROOT/aapracing/import/publish directory.
> Once a file is closed, act on it:
>
> 1. Copy the PDF and XML files from source_dir to web_filebin_dir
> 2. If the file is an.XML, copy it to the xml_ftp_dir
> 3. Make the dummy file for PHP publishing process
> 4. Remove the source file
>
> Requirements
> 
>  * Linux kernel 2.6.13 +
>  * pyinotify 2.8.6 +
>
>
> Installation
> --
> To install pyinotify on ubuntu/debian:
>
> `sudo easy_install pyinotify`
>
>
> Docs
> -
> Docs on pyinotify can be found here:
> http://trac.dbzteam.org/pyinotify/wiki
>
> """
>
> import os
> import re
> import shutil
> import pyinotify
> import datetime
>
>
> ### production config info
> source_dir = "/web/site/aapracing/publish/data/publish/"
> web_filebin_dir = "/web/site/filebin/downloads/"
> reference_path = '/web/site/aapracing/publish/data/published/'
> xml_ftp_dir = "/home/ftp/private/xml/"
> filez = '(PDF|pdf|XML|xml|txt)'
> logfile_path = "/web/log/inotify.log"
>
> event_mask = pyinotify.IN_CLOSE_WRITE
> wm = pyinotify.WatchManager()
>
> def getNow():
>  """Just return the current time for timestamping logs"""
>  return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
>
> def makeReferenceFile(tfile):
>  open(tfile, 'w').close()
>
>
> class SourceMonitor(pyinotify.ProcessEvent):
>  """ Watches the source dir for IN_CLOSE_WRITE event"""
>
>  def process_IN_CLOSE_WRITE(self, event):
>"""when an IN_CLOSE_WRITE happens, do something"""
>if re.search('(.*\.'+filez+'$)', event.pathname):
>  # We have a match, put a copy into the filebin dir
>  shutil.copy2(event.pathname, web_filebin_dir)
>  logfile = open(logfile_path, "a")
>  logfile.write("%s: %s moved to %s. \n" %
>(getNow(), event.pathname, web_filebin_dir))
>  if re.search('(.*\.(XML|xml)$)', event.pathname):
># If it's and XML, put a copy in the FTP dir
>shutil.copy2(event.pathname, xml_ftp_dir)
>logfile.write("%s: %s moved to %s. \n" %
>  (getNow(), event.pathname, xml_ftp_dir))
>  # Make the dummy file marker to enable PHP
>  # to know the file is really published
>  fhandle = os.path.basename(event.pathname)
>  open(reference_path + fhandle, 'w').close()
>  # Now, whack the source file since we're done with it.
>  os.remove(event.pathname)
>
> p = SourceMonitor()
> notifier = pyinotify.Notifier(wm, p)
> wdd = wm.add_watch(source_dir, event_mask)
> print "This should have been started with:\n\n"
> print "  sudo su - www-data -c 'cd /web/log/; nohup
> /web/scripts/inotify_published_file_handler.py >
>  /web/log/inotify-errors.txt 2>&1  &' \n\n"
>
> notifier.loop()
>
> --
> Kurt Bendl, Consultant
> Internet Tool & Die
> http://tool.net/
> 502-759-7104
>
>
>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Novice qustion

2009-09-24 Thread george fragos
2009/9/24 Oxymoron :
>> print format % (item_width, 'Cantaloupes', price_width, 1.92)
>> print format % (item_width, 'Dried Apricots (16 gr)' price_width, 8)
>
>
> Notice the line before (works) and after (doesn't work - as the interpreter
> pointed out), how do you separate items in a tuple? :-)
>
> Did not check the rest of it.

OK, I located the false syntax and I fixed it, thanx for your help!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] code improvement

2009-09-24 Thread Norman Khine
Hello,
I have this function in my class:

http://paste.lisp.org/display/87659

Is there a better method to write the last bit of the code.

Thanks
Norman
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Unknown reason for error.

2009-09-24 Thread Corey Richardson
Hello, python tutors, its Corey.
Anyway, I'm getting a syntax error for an unknown reason. Here is my code...
    name = raw_input("What is your name?")
print "Hello, ", name
wellness = raw_input("How are you?")
if wellness != "Good":
    if wellness != "Well":
    if wellness != "Fine":
    print "Oh, I'm sorry you are not feeling well. I guessed correct, 
right?"
    else: print "Great!"
candyNumber = raw_input("How many candies do you want? :"
fat = raw_input("How many candies do you want to eat? :")
if fat > candyNumber:
    print "HA! Nice try, but no. You don't have that many candies"
    else print "HA! You ate the candy! Sucker. You are now", fat, "lbs 
overweight"
The syntax arror is at the first fat. Thanks ahead of time, 
~Corey


  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] code improvement

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine  wrote:
> Hello,
> I have this function in my class:
>
> http://paste.lisp.org/display/87659
>
> Is there a better method to write the last bit of the code.

Better in what way? What are these things? What is resource? Some
context would be helpful, I seem to have misplaced my mindreader hat.

Kent
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unknown reason for error.

2009-09-24 Thread Robert Berman
Cory,

It would be helpful for us to see the code and the exact error
message(s). 

Would you copy your code and the errors directly to either your post or
your code to  one of the posting pages such as www.pastebin.org so we
can see your code exactly how you have written it.

Robert


On Thu, 2009-09-24 at 11:15 -0700, Corey Richardson wrote:
> Hello, python tutors, its Corey.
> Anyway, I'm getting a syntax error for an unknown reason. Here is my code...
> name = raw_input("What is your name?")
> print "Hello, ", name
> wellness = raw_input("How are you?")
> if wellness != "Good":
> if wellness != "Well":
> if wellness != "Fine":
> print "Oh, I'm sorry you are not feeling well. I guessed correct, 
> right?"
> else: print "Great!"
> candyNumber = raw_input("How many candies do you want? :"
> fat = raw_input("How many candies do you want to eat? :")
> if fat > candyNumber:
> print "HA! Nice try, but no. You don't have that many candies"
> else print "HA! You ate the candy! Sucker. You are now", fat, "lbs 
> overweight"
> The syntax arror is at the first fat. Thanks ahead of time, 
> ~Corey
> 
> 
>   
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unknown reason for error.

2009-09-24 Thread greg whittier
On Thu, Sep 24, 2009 at 2:15 PM, Corey Richardson  wrote:

> Hello, python tutors, its Corey.
> Anyway, I'm getting a syntax error for an unknown reason. Here is my
> code...
> name = raw_input("What is your name?")
> print "Hello, ", name
> wellness = raw_input("How are you?")
> if wellness != "Good":
> if wellness != "Well":
> if wellness != "Fine":
> print "Oh, I'm sorry you are not feeling well. I guessed
> correct, right?"
> else: print "Great!"
> candyNumber = raw_input("How many candies do you want? :"
>

It looks like you're missing a closing parenthesis.



> fat = raw_input("How many candies do you want to eat? :")
> if fat > candyNumber:
> print "HA! Nice try, but no. You don't have that many candies"
> else print "HA! You ate the candy! Sucker. You are now", fat, "lbs
> overweight"
> The syntax arror is at the first fat. Thanks ahead of time,
> ~Corey
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Unknown reason for error.

2009-09-24 Thread christopher . henk
> Hello, python tutors, its Corey.

Hi, Corey.

> candyNumber = raw_input("How many candies do you want? :"

You dropped a closing parenthesis in the line above.  Having the syntax 
error occur one line up from where it is indicated is not uncommon.

Another thing as long as we are here, in the code below.

> Anyway, I'm getting a syntax error for an unknown reason. Here is my 
code...
> name = raw_input("What is your name?")
> print "Hello, ", name
> wellness = raw_input("How are you?")
> if wellness != "Good":
> if wellness != "Well":
> if wellness != "Fine":
> print "Oh, I'm sorry you are not feeling well. I guessed 
correct, right?"
> else: print "Great!"

The else will only apply if they type in Fine 
If you want it too apply to all three you would need to join the checks 
together into one if statement with Boolean operators.

Chris
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] invalid syntax (reply)

2009-09-24 Thread Corey Richardson
Robert, that is my code. The error? "Theres an error in your program : 
invalid syntax"
Closing the parenthesis helped that one, but my else statement is not 
working...heres the code chunk...

if wellness != "Good":
   elif wellness != "Well":
   elif wellness != "Fine":
   print "Oh, I'm sorry you are not feeling well. I guessed 
correct, right?"

else print "Great!"
candyNumber = raw_input("How many candies do you want? :")
fatness = raw_input("How many candies do you want to eat? :")
if fatness > candyNumber:
   print "HA! Nice try, but no. You don't have that many candies"
   else print "HA! You ate the candy! Sucker. You are now", 
fatness, "lbs overweight"




my IDLE highlights the print, in each of them. Why? (oh, and thanks for 
helping, all)
<>___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread Brett Wilkins

if wellness != "Good":
  elif wellness != "Well":
  elif wellness != "Fine":
  print "Oh, I'm sorry you are not feeling well. I guessed  
correct, right?"


I think the problem is the elif's and the indents...
elif is 'else if', and should be at the same indentation level as the  
previous if statement that it is providing the else cause for.
In this case, it looks like you're just checking that wellness is not  
one of those words

I would use:
if wellness not in ["Good","Well","Fine"]:
	print "Oh, I'm sorry you are not feeling well. I guessed correct,  
right?"


See in that works out for you.
Also, if you're using python3, the print statement will need brackets  
(like a function).


Cheers
--Brett

On 25/09/2009, at 9:43 AM, Corey Richardson wrote:


if wellness != "Good":
  elif wellness != "Well":
  elif wellness != "Fine":
  print "Oh, I'm sorry you are not feeling well. I guessed  
correct, right?"


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread christopher . henk
tutor-bounces+christopher.henk=allisontransmission@python.org wrote on 
09/24/2009 05:43:24 PM:

> Robert, that is my code. The error? "Theres an error in your program : 
> invalid syntax"
> Closing the parenthesis helped that one, but my else statement is not 
> working...heres the code chunk...
> if wellness != "Good":
> elif wellness != "Well":
> elif wellness != "Fine":
> print "Oh, I'm sorry you are not feeling well. I guessed 
> correct, right?"
> else print "Great!"
> candyNumber = raw_input("How many candies do you want? :")
> fatness = raw_input("How many candies do you want to eat? :")
> if fatness > candyNumber:
> print "HA! Nice try, but no. You don't have that many candies"
> else print "HA! You ate the candy! Sucker. You are now", 
> fatness, "lbs overweight"
> 
> 
> 
> my IDLE highlights the print, in each of them. Why? (oh, and thanks for 
> helping, all)


I am not sure why Idle is higlighting your print statements ( I don't use 
Idle, so will leave that to someone else).

However your if-elif-else construction should raise a syntax error.  elif 
means "else if" and should be matched up (at the same indentation level) 
with an if statement just like an else statement.  It is used when you 
have more then two paths that the code can take depending on the test 
results.

if test: (if test is true)
do something
elif another test: (else if another test is true)
do something else
else:
do a third thing

What you are trying to test is that wellness is not "Well", is not "good", 
and is not "Fine" 
If all of those is true (they are not good, not well and not fine) you 
print your sorry message, otherwise you print great.
You have one fork in the path, and should have one if statement with one 
else. 

Hope that helps,
Chris___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python win32 drive mapping help

2009-09-24 Thread Vineet Kothari
Thanks a lot Vishwajeet & everyone else who replied. This is great I am glad
now its working & I knew I was missing the module but somehow didn't know
from where I would get that. But glad everything is working fine now. This
is great community :)

-- 
Regards,
Vineet Kothari
http://www.vineetkothari.in

-
Its NICE 2 be IMPORTANT, but whats more IMPORTANT is 2 be NICE.

On Tue, Sep 22, 2009 at 4:01 AM, vishwajeet singh wrote:

> On Tue, Sep 22, 2009 at 5:38 AM, Vineet Kothari 
> wrote:
>
>>
>> Hi Everyone
>>
>> I saw alot of responses for python on this  mailing
>> list. I thought any python guru might wish to help me with little code to
>> map two network drives on windows systems
>>
>>
>> I have 3computers at different locations in a network A,B,C
>>
>> I want to map c:/temp folder of A to C & c:/temp folder of B to C as well
>> do some copying of data and then delete the mapping.
>>
>> I tried using the code given for mapping:
>>
>> import win32net
>>> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:','password':'XXX'
>>> })
>>>
>>
>> but I get this error:
>>
>> C:\Users\Administrator\Desktop>python test.py
>>> Traceback (most recent call last):
>>>   File "test.py", line 31, in 
>>> import win32wnet
>>> ImportError: No module named win32net
>>>
>>
>> I just need help in setting up the mapping. I know how to do the copying
>> using shutil please if you can help me with the mapping code. I am very new
>> to python and I need this help for my project at school.
>>
>> I am using python 2.6
>>
>> I'll be eagerly waiting for your response.
>> Thanks
>>
>> --
>> Regards,
>> Vineet Kothari
>> http://www.vineetkothari.in
>>
>> -
>> Its NICE 2 be IMPORTANT, but whats more IMPORTANT is 2 be NICE.
>>
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> You need python extension installed on your machine to be able to execute
> the above code; you can get same from
> http://sourceforge.net/projects/pywin32/
>
> --
> Vishwajeet Singh
> +91-9657702154 | dextrou...@gmail.com | http://singhvishwajeet.com
> Twitter: http://twitter.com/vishwajeets | LinkedIn:
> http://www.linkedin.com/in/singhvishwajeet
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to print a message backwards

2009-09-24 Thread Sander Sweers
On Thu, 2009-09-24 at 08:07 -0400, Serdar Tumgoren wrote:
> You should find plenty by googling for "python slice step sequence"

Now that I know what to look for I went to the online python docs [1]
and tried to find where it has been documented. 

Unfortunately all the slicing examples I found do not even mention that
there is optional step value. The only place I found it explained
properly is on the build in slice() and the data model pages.  I'll try
to find some time to write some examples and documentation for the
online docs.

Thanks for the links.

Greets
Sander

[1] http://docs.python.org/index.html

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] invalid syntax (reply)

2009-09-24 Thread Alan Gauld


"Corey Richardson"  wrote

Closing the parenthesis helped that one, but my else statement is not 
working...heres the code chunk...

if wellness != "Good":
   elif wellness != "Well":
   elif wellness != "Fine":
   print "Oh, I'm sorry you are not feeling well. I guessed 
correct, right?"

else print "Great!"


As has been pointed out you need to use a boolean expression 
(a combination of tsts using and / or ) to get the result you need.
In fact if you describe what you really want in English you will find 
it forms a boolean expression.


You want it to print one message if the user types Good or Well or Fine
else print another message. Now translate that directly to code...



candyNumber = raw_input("How many candies do you want? :")
fatness = raw_input("How many candies do you want to eat? :")
if fatness > candyNumber:
   print "HA! Nice try, but no. You don't have that many candies"
   else print "HA! You ate the candy! Sucker. You are now", 


Python cares abourt indentation level.
align the else with the if that it matches.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python win32 drive mapping help

2009-09-24 Thread Vineet Kothari
Can you also help me out with the way to delete the mapped drive I know in
command line it is

> net use [DRIVE:] /delete
>

but I am unable to figure out how I can do it from python

Since I am trying to make sure that the drive name I am giving in my code:

> import win32net
> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:','password':'XXX'
> })


K: drive should not exist already & if it does then the mapping should be
removed first & then a new mapping should be established.

So it should be going something like:

if [mapping already exists]:
>[delete mapping]
> else:
>[create new mapping]
>

Thank You everyone for the help :)

-- 
Regards,
Vineet Kothari
http://www.vineetkothari.in

-
Its NICE 2 be IMPORTANT, but whats more IMPORTANT is 2 be NICE.

On Tue, Sep 22, 2009 at 4:01 AM, vishwajeet singh wrote:

> On Tue, Sep 22, 2009 at 5:38 AM, Vineet Kothari 
> wrote:
>
>>
>> Hi Everyone
>>
>> I saw alot of responses for python on this  mailing
>> list. I thought any python guru might wish to help me with little code to
>> map two network drives on windows systems
>>
>>
>> I have 3computers at different locations in a network A,B,C
>>
>> I want to map c:/temp folder of A to C & c:/temp folder of B to C as well
>> do some copying of data and then delete the mapping.
>>
>> I tried using the code given for mapping:
>>
>> import win32net
>>> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:','password':'XXX'
>>> })
>>>
>>
>> but I get this error:
>>
>> C:\Users\Administrator\Desktop>python test.py
>>> Traceback (most recent call last):
>>>   File "test.py", line 31, in 
>>> import win32wnet
>>> ImportError: No module named win32net
>>>
>>
>> I just need help in setting up the mapping. I know how to do the copying
>> using shutil please if you can help me with the mapping code. I am very new
>> to python and I need this help for my project at school.
>>
>> I am using python 2.6
>>
>> I'll be eagerly waiting for your response.
>> Thanks
>>
>> --
>> Regards,
>> Vineet Kothari
>> http://www.vineetkothari.in
>>
>> -
>> Its NICE 2 be IMPORTANT, but whats more IMPORTANT is 2 be NICE.
>>
>>
>>
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
> You need python extension installed on your machine to be able to execute
> the above code; you can get same from
> http://sourceforge.net/projects/pywin32/
>
> --
> Vishwajeet Singh
> +91-9657702154 | dextrou...@gmail.com | http://singhvishwajeet.com
> Twitter: http://twitter.com/vishwajeets | LinkedIn:
> http://www.linkedin.com/in/singhvishwajeet
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to print a message backwards

2009-09-24 Thread Kent Johnson
On Thu, Sep 24, 2009 at 7:02 PM, Sander Sweers  wrote:
> Now that I know what to look for I went to the online python docs [1]
> and tried to find where it has been documented.
>
> Unfortunately all the slicing examples I found do not even mention that
> there is optional step value.

See footnote 5 at
http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple-buffer-xrange

Kent
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Anyone with Experience Using WinTV Capture Cards?

2009-09-24 Thread Wayne Watson
A friend is looking for some help with how to use Python to access a 
WinTV (Go Plus) capture card, and how to display an image from it. Is 
there some facility that might help him, or does anyone have experience 
with such use that might suggest sources? Win XP OS. Any general methods 
for dealing with such commercial built capture cards?


--
  Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

(121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
 Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet  

"I feel that if a person has problems communicating 
 the very least he can do is to shut up." -- Tom Lehrer


   Web Page: 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] code improvement

2009-09-24 Thread Norman Khine
On Thu, Sep 24, 2009 at 10:25 PM, Kent Johnson  wrote:
> On Thu, Sep 24, 2009 at 2:12 PM, Norman Khine  wrote:
>> Hello,
>> I have this function in my class:
>>
>> http://paste.lisp.org/display/87659
>>
>> Is there a better method to write the last bit of the code.
>
> Better in what way? What are these things? What is resource? Some
> context would be helpful, I seem to have misplaced my mindreader hat.

Apologies for not being clear. I was thinking more  that I may have
one the too many 'for' loops at the end of the code.

Here is a new version with more details.

http://paste.lisp.org/display/87659#1

Thanks
>
> Kent
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor