Re: [Tutor] PLEASE HELP ON PYTHON

2005-07-16 Thread Rob Andrews
On 7/15/05, Suranga Sarukkali <[EMAIL PROTECTED]> wrote:
>  
> Hai, I (Suranga) started using Python2.4 Downloaded from the Original
> WebSite www.python.org a week ago but still I have not made any good
> progress on Programming and all that Tutorials available make it like hell
> to get started at all! whatever please tell me on [EMAIL PROTECTED] how to
> get started and start programming and since I never programmed before or
> haven't done any big Math Tests but a k-12 School still I'm a Student of 14
> but I'm loving the name programming even, reply to me as soon as possible. 

We'll be happy to help.

What sort of programming interests you? Since I'm one of the world's
most incompetent programmers and find that I can work out the
occasional python program, I'm sure you'll be just fine.

There are quite a few tutorials to help get you started. Have you
checked out: http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html
?

namaste,
Rob
-- 
Golf with an attitude:
http://www.ragingolf.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] replaying

2005-07-19 Thread Rob Andrews
> However, there are significant downsides to enabling Reply-to munging:
> 
> http://www.unicom.com/pw/reply-to-harmful.html
> 
> I agree with most of those reasons, and so I won't enable Reply-to munging
> unless there's a real overriding reason that trumps the ones listed on
> that page.

I found the arguments on the link you shared adequately persuasive.

-Rob

-- 
Golf with an attitude:
http://www.ragingolf.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] file IO tutorial

2005-07-31 Thread Rob Andrews
http://uselesspython.com/tutorials/PythonFileIOStepByStep.pdf

I've written a quick step-by-step .pdf to walk through the process of
creating a new text file, read from it, and append to it with Python.
It doesn't cover every last thing one can do with opened files, but
does point to a few other resources at the end where the student can
pursue further information.

I'd appreciate if anyone interested would check it over for anything
incorrect, misleading, dangerous, or otherwise in need of amendment.

-Rob
-- 
Golf with an attitude:
http://www.ragingolf.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Guess my number?

2005-08-07 Thread Rob Andrews
Let's take a look

I pasted your code into a new window and gave it a go. You used tabs
for indentation (or they got in there somewhere in the
email/copy/paste process), which confused my tiny mind, so I replaced
'em with spaces.

I noticed a few things. Here's my code:
#
import random
import sys

number = random.randrange(100) + 1
guess = int(raw_input("Take a guess: "))
tries = 1

while (guess != number):
if (tries > 10):
print "too many guesses"
sys.exit()

if (guess > number):
print "Lower...\n"
elif (guess < number):
print "Higher...\n"
# elif (tries > 10):
   # print "You're stupid!"
else:
print "Error!"

guess = int(raw_input("Take a guess: "))
tries += 1
#

I noticed you mis-spelled "tries" in one place, so I changed the spelling.

I also moved the test for the number of tries to a separate "if"
statement running before the "if" you had already included, so if the
user guesses too many times, it won't continue to run through the
guess-checking routine.

And I used sys.exit() to get out cleanly when the user exceeds the guess limit.

-Rob

On 8/7/05, . , <[EMAIL PROTECTED]> wrote:
> I want the program to say "You're stupid!" When a player fails to guess in
> 10 tries.
> But, it's not working..
> 
> 
> import random
> 
> number = random.randrange(100) + 1
> guess = int(raw_input("Take a guess: "))
> tries = 1
> 
> while (guess != number):
> if (guess > number):
> print "Lower...\n"
> elif (guess < number):
> print "Higher...\n"
> elif (tires > 10):
> print "You're stupid!"
> else:
> print "Error!"
> 
> guess = int(raw_input("Take a guess: "))
> tries += 1
> 
> print "\nYou guess it! The number was", number
> print "And it only took you", tries, "tries!\n"
> raw_input("\n\nPress the enter key to exit.")
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IDE / development environment

2007-04-22 Thread Rob Andrews
> What does everyone use as their development environment for Python,
> particularly web dev?

Komodo (by ActiveState). For web dev in dynamic languages, it's tough
to actually beat.

I scored mine at a $100 discount thanks to a coupon ActiveState handed
out at PyCon this year.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python IDE

2007-06-11 Thread Rob Andrews
Personally, I use and love Komodo (the full version, although Komodo
Edit is nice). I didn't *expect* to like it, but it won me over with
ease.

On 6/11/07, scott <[EMAIL PROTECTED]> wrote:
>Could someone suggest a few good IDE's for me to look at.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Editors .. which do you reccomend for a amateur?

2007-08-04 Thread Rob Andrews
A fair enough and frequently-asked question...

I take it you're in a Windows environment?

For basic editing purposes, I'm pretty crazy about IDLE after all
these years, although I use Komodo IDE for most of my production code.
When the other programmers in my department tasked me with picking a
standard for use in the department this week, I settled on the
standard Windows distro from python.org with IDLE because it's
consistently straight-forward & predictable in behavior.

For ease of use beyond a certain level of sophistication, however, I
go straight to Komodo IDE without meaningful complaint. Part of my
reasoning for that, though, is that it enables me to use the same
familiar environment for python, perl, javascript & PHP.

-Rob

On 8/4/07, Tony Noyeaux <[EMAIL PROTECTED]> wrote:
>
>  I've been using Python IDLE,.. tried DrPython,.. had a try of ActiveState
> Komodo IDE, Active Python,...
>
>  What is a good python editor to use. I've seen good and bad with all of the
> above from my newcomer perspective.. wondering what other feel is a good
> editor to use... when you're new to python?
>
>
>  Tony Noyeaux
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] KeyError list?

2007-08-15 Thread Rob Andrews
Is there a comprehensive list of dictionary KeyError meanings?

I could sure use one these days and haven't had much luck tracking one down yet.

-Rob
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fw: KeyError list?

2007-08-15 Thread Rob Andrews
At my current day job, I'm handed a wild variety of data from
customers, and most of it hasn't been normalized in any reasonable
way. File formats are inconsistent, numbers of fields are randomly
inconsistent with the headers, etc.

Attempting to massage these into files I can process has involved a
lot of "throw-away" scripting, and I've caught myself doing some
really questionable things with basic data structures, leading to my
original question. Dictionary key errors have been the most common
here lately, popping up in a fairly wide range of circumstances due to
seemingly random data.

On 8/15/07, wesley chun <[EMAIL PROTECTED]> wrote:
> > I guess I couldn't believe it was that simple. ;-)
>
> now if you had asked about the meanings of *all* exceptions (including
> warnings), or perhaps all the SMTP exceptions in smtplib, that would
> another matter.  ;-)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fw: KeyError list?

2007-08-16 Thread Rob Andrews
I wasn't familiar with it prior to this thread, as previously I'd had
the good fortune to use normalized data. I guess more pristine data
environments spoiled me into writing less robust code.

So although I asked what turned out to be the wrong question, I seem
to be getting a consensus answer I'm sure I'll have a chance to put to
the test over and over here.

On 8/16/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Do you know about dict.get()? It will return None or a default value of
> your choice if a key is missing. Might be helpful...
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how to specify working directory from within python app?

2007-09-20 Thread Rob Andrews
I've got a weekly project here in which I have to take a somewhat
arbitrary number of input files, create working directories in which
to process each of them, and call other programs from within the scope
of those directories.

The source files are in a directory named 'orig' under the project
root directory. Output of my program is placed in directories nested
two-deep under the job root in different branches.

Once my data is in those other directories, I have to call certain
other 3rd-party programs to act on the data in various ways. Those
3rd-party programs are typically called from a Windows command prompt,
and only from within the directory in which the data is found.

For example: C:\MyProject\BrandA\ProductB>3rdPartyApp.bat projectConfig.cfg
(where "MyProject" is the project root, "BrandA" is a subdirectory,
and "ProductB" is another subdirectory nested one level deeper)

How might I best go about calling these 3rd-party apps? On this
project, the directories are created dynamically, and there can be
quite a few.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to specify working directory from within python app?

2007-09-20 Thread Rob Andrews
Thanks (to Alan, as well). I had a wild suspicion that there would be
a fairly standard solution to this one. I've just never had to really
look into it before.

On 9/20/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Rob Andrews wrote:
> > I've got a weekly project here in which I have to take a somewhat
> > arbitrary number of input files, create working directories in which
> > to process each of them, and call other programs from within the scope
> > of those directories.
>
> Use subprocess.call() to run the external program and supply the working
> directory path in the cwd parameter.
>
> Kent
>


-- 
Libertarian Party of Mississippi:
http://mslp.org
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Timers in Python

2007-10-04 Thread Rob Andrews
On 10/4/07, Kamal <[EMAIL PROTECTED]> wrote:
> Is there a method in Python which does what
> setInterval('someFunction()',5000) does in Javascript.
>
> Basically, I want to call functionOne() every x minutes, and wondering
> whats the best way to do it.

Yes, the time module in the standard library has sleep(x), where x is
in seconds.

The Python Library Reference, section 14.2, goes into a bit more detail.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Beat me over the head with it

2007-12-08 Thread Rob Andrews
Need help with a motivational disorder? ;)

When you say you want to learn Python, what's the nature of the "want
to" part? Looking to write a game, land a job, parse a log file?

Perhaps if you focus on what it is you want to do, that will lead the way.

On Dec 8, 2007 9:08 PM, Theyain <[EMAIL PROTECTED]> wrote:
> I'm not sure if this is really the place to do this, but I will ask anyways.
>
> Hello everyone, names Theyain.  I want to learn Python.  But I am one of
> those people who needs some one to "Beat me over the head" to actually
> learn something.  I can't get myself to actually sit down and read a
> tutorial on Python because no one is making me.  So can someone help me
> with this?  I really want to learn python, but I can't do it with out help.
>
>
> So help?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How Do I Make Imports Work

2007-12-27 Thread Rob Andrews
Can you show us an example of the code where you're attempting to
import and the error you get?

-Rob A.

On Dec 27, 2007 7:40 AM,  <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I am just starting to learn about making classes, so I wanted to put some
> code into a module and use it. I know the code works because when I put it
> in the same file that calls it, it does what it's supposed to do. When I
> move it into its own file and try to use an import statement to bring it
> in, I get errors that say that methods don't exist. I looked at a Windows
> tutorial that instructs me to edit my registry. The tutorial seemed to be
> talking about the version of Python from python.org. I have ActiveState
> Python. I'm OK with editing the registry, but  I'd rather not do it. If I
> have to, is there documentation somewhere that helps me work with
> ActiveState Python to do this. If I don't have to, where can I find
> documentation that helps me make this work?
>
> Thanks lots.
>
> Jim
>
> James D Homme, , Usability Engineering, Highmark Inc.,
> [EMAIL PROTECTED], 412-544-1810
>
> "Never doubt that a thoughtful group of committed citizens can change the
> world.  Indeed, it is the only thing that ever has." -- Margaret Mead
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
"Quise ahogar mis penas, pero las muy putas flotan"
SabidurĂ­a popular
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] directory recursion

2005-09-09 Thread Rob Andrews
I should already know this, and probably once did, but have never had
a real world use for it until now.

What's a nice, clean way to recursively scan through directories with
an arbitrary number of subdirectories?

In today's example, we're looking to grab the file name and third line
of the file for every text file in the directory tree, and dump into a
new text file. Everything but the walking of the tree was obvious
enough.

We used the following to grab the desired output from a single level
of directories:

import glob

for fileName in glob.glob('C:/stuff/jayfiles/*/*.txt'): # glob through
directories
newFile = open('C:/stuff/jayfiles/newFile.txt', 'a') # open
newFile to append
newFile.write(fileName) # append fileName to newFile
newFile.write('\t') # append a tab after fileName
currentFile = open(fileName, 'r') # open next file for reading
currentFile.readline() # this and the following line go through...
currentFile.readline() #...the 1st 2 lines of the file
thirdLine = currentFile.readline() # modify this to print to text file
newFile.write(thirdLine) # append thirdLine to newFile
currentFile.close() # close currentFile
newFile.close() # close newFile

-Rob
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] directory recursion

2005-09-12 Thread Rob Andrews
Thanks! That did the trick after very modest head scratching.

-Rob

On 9/9/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
> >
> > What's a nice, clean way to recursively scan through directories with
> > an arbitrary number of subdirectories?
> 
> Hi Rob,
> 
> You may want to look at os.walk():
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What after Learning Python 2nd

2006-10-09 Thread Rob Andrews
Those are both fine "next book" choices, and neither should prove a
disapointment.

However, LP should've left you with just enough knowledge to be
dangerous, so I'd encourage you to work on several small projects in
python using what you already know. In the process of taking a crack
at those, you'll surely want to do some things that will give you a
good idea of what resources you need to tackle next.

-Rob A.

On 10/9/06, josip <[EMAIL PROTECTED]> wrote:
> Hi.
>
> Hi I have finished Learning Python 2nd ed.
> What to do next?
> Should I go with Programming Python book or Python Cookbook or?
> Or maybe something else?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with basic user-data file

2006-10-12 Thread Rob Andrews
To keep the information, the simplest solution is simply to save it in
a text file that the program can load into memory when it starts up
again. For sensitive information like passwords, a little extra fuss
is generally merited.

When someone logs in, you can save a value like
time.strftime(time.ctime()) for a nice, human-readable time stamp.
Don't forget to "import time" first.

-Rob A.

On 10/12/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> Folks,
>
> I am trying to modify the userManagement program given in Core Python
> Programming. It uses a dictionary to store user-password information. The
> usernames are the keys and the passwords are the values.
> Now I want is to add a third element; last login time.
> I want to store this information in a file so that the data is not lost once
> the program stops execution.
>
> I am not sure of using time function in python..
> Can anyone help with this issue??
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with basic user-data file

2006-10-12 Thread Rob Andrews
When a login name is being created, you can pull a list of existing
login names from file, and run a check to see if it is in the list. If
the new name is in the list, have it kick back a message telling the
user to try another name.

Also, your program could suggest a new user name in such a case, or
even assign new users names of its choosing.

The dictionary data structure is handy for the program to use in very
efficiently matching user names with passwords. But you don't have to
store the dictionary in a file as a dictionary. It's possible to do
so, but often easier to use a delimited text file.

On 10/12/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> It means there is no need of entering the data in the dictionary,??
>
> How will I then implement the uniqueness of loginnames???
>
> Thanks for the support.
> regards,
> Asrar
>
>
> On 10/12/06, Rob Andrews <[EMAIL PROTECTED]> wrote:
> >
> > To keep the information, the simplest solution is simply to save it in
> > a text file that the program can load into memory when it starts up
> > again. For sensitive information like passwords, a little extra fuss
> > is generally merited.
> >
> > When someone logs in, you can save a value like
> > time.strftime(time.ctime()) for a nice, human-readable time stamp.
> > Don't forget to "import time" first.
> >
> > -Rob A.
> >
> > On 10/12/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> > > Folks,
> > >
> > > I am trying to modify the userManagement program given in Core Python
> > > Programming. It uses a dictionary to store user-password information.
> The
> > > usernames are the keys and the passwords are the values.
> > > Now I want is to add a third element; last login time.
> > > I want to store this information in a file so that the data is not lost
> once
> > > the program stops execution.
> > >
> > > I am not sure of using time function in python..
> > > Can anyone help with this issue??
> > ___
> > Tutor maillist  -   Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
>
> --
> To HIM you shall return.


-- 
Blogging my outdoors obsession: http://trekkingbob.blogspot.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Help with basic user-data file

2006-10-12 Thread Rob Andrews
I'm forwarding this to the tutor list, as I'm swamped at work.

-- Forwarded message --
From: Asrarahmed Kadri <[EMAIL PROTECTED]>
Date: Oct 12, 2006 9:17 AM
Subject: Re: [Tutor] Help with basic user-data file
To: Rob Andrews <[EMAIL PROTECTED]>


Thanks.
Can you please also tell me how to check the existence of a file using
python builtin functions.


Regards,
Asrar


On 10/12/06, Rob Andrews <[EMAIL PROTECTED]> wrote:
> When a login name is being created, you can pull a list of existing
> login names from file, and run a check to see if it is in the list. If
> the new name is in the list, have it kick back a message telling the
> user to try another name.
>
> Also, your program could suggest a new user name in such a case, or
> even assign new users names of its choosing.
>
> The dictionary data structure is handy for the program to use in very
> efficiently matching user names with passwords. But you don't have to
> store the dictionary in a file as a dictionary. It's possible to do
> so, but often easier to use a delimited text file.
>
> On 10/12/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> > It means there is no need of entering the data in the dictionary,??
> >
> > How will I then implement the uniqueness of loginnames???
> >
> > Thanks for the support.
> > regards,
> > Asrar
> >
> >
> > On 10/12/06, Rob Andrews < [EMAIL PROTECTED]> wrote:
> > >
> > > To keep the information, the simplest solution is simply to save it in
> > > a text file that the program can load into memory when it starts up
> > > again. For sensitive information like passwords, a little extra fuss
> > > is generally merited.
> > >
> > > When someone logs in, you can save a value like
> > > time.strftime(time.ctime()) for a nice, human-readable time stamp.
> > > Don't forget to "import time" first.
> > >
> > > -Rob A.
> > >
> > > On 10/12/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> > > > Folks,
> > > >
> > > > I am trying to modify the userManagement program given in Core Python
> > > > Programming. It uses a dictionary to store user-password information.
> > The
> > > > usernames are the keys and the passwords are the values.
> > > > Now I want is to add a third element; last login time.
> > > > I want to store this information in a file so that the data is not lost
> > once
> > > > the program stops execution.
> > > >
> > > > I am not sure of using time function in python..
> > > > Can anyone help with this issue??
> > > ___
> > > Tutor maillist  -   Tutor@python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> >
> >
> >
> > --
> > To HIM you shall return.
>
>
> --
> Blogging my outdoors obsession: http://trekkingbob.blogspot.com/
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
To HIM you shall return.

-- 
Blogging my outdoors obsession: http://trekkingbob.blogspot.com/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] what is PIL..???

2006-10-21 Thread Rob Andrews
On 10/21/06, Asrarahmed Kadri <[EMAIL PROTECTED]> wrote:
> May I ask someone to tell what PIL is and how can it be helpful in drawing
> 2-dimensional graphs...

PIL = Python Imaging Library

PIL provides a bunch of nifty tools for handling images and is well
worth a google.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Best way to learn python

2006-12-29 Thread Rob Andrews
I'm not exactly a math guru, either, but know some algebra & geometry
from school.

When I first tried my hand at Python, I started with just the tutorial
bundled with the Python download.

I had been taken a semester in Pascal & tinkered with Perl & Java at
that point, and found Python to be simpler & more obvious, so if you
have a bit of programming at all your experience is likely as good as
mine was at the time. What's your programming background?

What sort of programming would you most immediately like to do?

And Ruby's also a fine language.

-Rob A.

On 12/29/06, Daniel kavic <[EMAIL PROTECTED]> wrote:
> What is the best way for someone who is not very efficient in
> mathematics to learn Python, I was turned away from C++ and others
> because of the math issue. Ruby has been recommended as well.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [OT?] PyCon

2007-01-29 Thread Rob Andrews
I hope it's not unforgivably off-topic to ask if anyone's planning on
attending PyCon in Feb.

My manager gave a thumbs-up for me to attend today.

-Rob
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Rob Andrews
If you import os, os.path, and shutil (only the ones you need,
although I wind up using all three for this sort of task), you can do
all that you have in mind and more.

os.path opens up some pretty painless methods for doing things like
testing to make sure the file exists in a given location before
copying it (or deleting it), which can save a good bit of heartache.

shutil can be used for not only copying files, but even copying entire
directory trees.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Rob Andrews
I can confirm it works nicely in Windows. I have a script I use
several times daily to create working directories on a local
workstation by copying over arbitrarily deep directory trees into an
"original files" directory under a root directory named by job number.
The local workstation on which I have python running is a Windows
machine, and it's agnostic about the operating systems of the network
drives from which the data is gathered.

Quite handy and not even a very long program after the try/except
bulletproofing is added.

-Rob A.

On 2/15/07, Eric Walstad <[EMAIL PROTECTED]> wrote:
> Hey Mark, welcome aboard!
>
> There are a few different approaches you could take to convert your
> scripts.  If most of your scripts are related to copying/moving files,
> I'd have a look at Python's shutil module.  I think it'll work in both
> Windows and Linux but I don't have a Windows machine handy to test it.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Convert my .bat and .vbs to .py

2007-02-15 Thread Rob Andrews
Ahh, yes. Your main trouble seems to be the use of \ instead of / in
'C:\testing_it.txt'

Windows uses \, whereas python uses /. So you can replace 'c:\'
with your choice of the following:

'c:/' (replacing \ with /)
r'c:\' (the 'r' before the string tells python it's a raw string)
'c:\\' (the first \ telling python to take the second \ at face value)

-Rob A.

On 2/15/07, Mark Bystry <[EMAIL PROTECTED]> wrote:
> Well, immediately I am having problems. Be patient with me.
>
> This what I have...
>
> copy_file.py
> 
>
> import os
> import shutil as sh
>
> sh.copy('C:\testing_it.txt', 'D:\')
> raw_input("Done!")
>
> 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sorting question

2007-03-06 Thread Rob Andrews
I'm trying to think of the best way to go about this one, as the files
I have to sort are *big*.

They're ASCII files with each row consisting of a series of
fixed-length fields, each of which has a corresponding format file.
(To be specific, these files are FirstLogic compatible.)

I'm looking to sort files such that I can produce the 50,000 records
with the highest "score" in a certain field.

A grossly over-simplified example is:

"JohnDoe   3.14123 Anywhere St."
"MarySmith11.03One Jackson Pl. "


>>> for x in people: # substituting 'people' for a file of records
print x[9:14]

 3.14
11.03


With this in mind, I'm trying to sort the file by the value of the
number in the field represented by x[9:14] in the example here.

I haven't yet figured out a way to apply sort() to this problem,
although I'm certain the failing is my own.

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Best IDE for python?

2007-03-09 Thread Rob Andrews
It may be worthwhile to note that "laziness" isn't necessarily a
derogatory term in programming circles. To quote Eric S. Raymond, who
turned me on to Python as much as any other (in _The Art of Unix
Programming_), "Constructive laziness is one of the cardinal virtues
of the master programmer."

-Rob A.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor