Dear Users,
I'm looking for an atomic method for creating a file on the hard disk
from python.
Currently I'm using;
def (command):
"""Creates a file with the name given by command."""
comFile = open(comFileName, 'w')
comFile.close()
This is not atomic as there are two operations nee
All,
I have a dumb question...hopefully someone can shed some light on the
difference between for and while in the situation below.
I'm trying to iterate through a list I've created. The list consists
of a command, followed by a 'logging' message (a message printed to a
console or log file
James wrote:
> Hi.
>
> I'm re-writing a rather complex bash script I've been using for years
> in Python. The bash script uses a relatively simple configuration
> file in order to get pertinent information before it runs. The
> configuration file is relatively simple: about 30 variables are
Christopher Spears wrote:
> I wrote a script that checks if two strings match.
> The script ignores case.
>
> #!/usr/bin/env python
>
> string_a = raw_input("Enter a string: ")
> string_b = raw_input("Enter another string: ")
>
> if cmp(string_a.lower(), string_b.lower()) == 0:
>
Simpler:
if s
* Armand Nell (Wed, 26 Sep 2007 08:07:12 +0200)
> I am new to python programming and also the linux enviroment most of my
> skills are windows based and programming skills is visual basics. I decided
> that it would be a great start and new direction for me to learn python and
> at the same time li
James wrote:
> Great! I was under the impression that the range was implied, but I
> guess not. ;)
No. One of the core Python values is "Explicit is better than implicit."
If you like implicit behaviour, try Perl ;-)
Type 'import this' at the Python prompt for more...
Kent
_
James wrote:
> Hi.
>
> I'm re-writing a rather complex bash script I've been using for years
> in Python. The bash script uses a relatively simple configuration
> file in order to get pertinent information before it runs. The
> configuration file is relatively simple: about 30 variables ar
On 9/28/07, James <[EMAIL PROTECTED]> wrote:
>
>
> # doesn't work
> for i in len( stuff ):
> os.system( stuff[ i ] )
> j = i + 1
> print stuff[ j ]
>
>
> Traceback (most recent call last):
>File "", line 1, in
> TypeError: 'int' o
"1. This may fail under windows if another file already exists with
this file name in the target directory. I always try to get my code
working on Linux and windows, this leaves my code more robust and
interestingly sometimes the Linux interpreter picks up different
errors than the windows interpre
I shiver at the thought of Perl. ;)
Thanks to everyone for your quick and helpful responses!
.james
On Sep 28, 2007, at 11:25 AM, Kent Johnson wrote:
> James wrote:
>> Great! I was under the impression that the range was implied, but
>> I guess not. ;)
>
> No. One of the core Python value
James wrote:
> All,
>
> I have a dumb question...hopefully someone can shed some light on the
> difference between for and while in the situation below.
>
> I'm trying to iterate through a list I've created. The list consists
> of a command, followed by a 'logging' message (a message printed
On Sep 28, 2007, at 10:59 AM, bob gailer wrote:
> James wrote:
>> All,
>>
>> I have a dumb question...hopefully someone can shed some light on
>> the difference between for and while in the situation below.
>>
>> I'm trying to iterate through a list I've created. The list
>> consists of a c
James wrote:
> All,
>
> I have a dumb question...hopefully someone can shed some light on the
> difference between for and while in the situation below.
>
> I'm trying to iterate through a list I've created. The list consists
> of a command, followed by a 'logging' message (a message printed t
On 9/28/07, James <[EMAIL PROTECTED]> wrote:
>
> All,
>
> I have a dumb question...hopefully someone can shed some light on the
> difference between for and while in the situation below.
>
> I'm trying to iterate through a list I've created. The list consists
> of a command, followed by a 'logging
* Thorsten Kampe (Fri, 28 Sep 2007 14:09:24 +0100)
> It's exactly the same as with with Visual Basic [...]
Guess I mixed that up with VBScript...
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 9/28/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>
>
> It's worth your time learning about Python data structures and for
> loops. They are very powerful and useful and unlike anything built-in to
> C. With a background in C you should find the official tutorial pretty
> easy to read:
> http://d
Hi.
I'm re-writing a rather complex bash script I've been using for years
in Python. The bash script uses a relatively simple configuration
file in order to get pertinent information before it runs. The
configuration file is relatively simple: about 30 variables are
defined in this manne
Varsha Purohit wrote:
> I am writing a program basically in python gui to open a file and
> display its content. i know similar program in simple
> python but wanna figure out how to do that in wxpython...
See DocViewDemo.py in the wxPythohn demo package
/Samples/samples/docview/DocViewDemo.py
GTXY20 wrote:
> Hi There,
>
> For some reason I am getting no results and if I alter the code to relect:
>
>
> inp = open('input.txt')
>
> for line in inp:
> fields = line.split(",")
> ProdId = fields[0]
> products = fields[1:]
> for product in products:
> print('%s\t%s\n' % (Prod
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Try:
for item in stuff:
os.system(item[0])
print item[1]
Alternativly:
for cmd, msg in stuff:
os.system(cmd)
print msg
Andreas
James wrote:
> All,
>
> I have a dumb question...hopefully someone can shed some light on the
> diffe
Christopher Spears wrote:
> I wrote a script that checks if two strings match.
> The script ignores case.
>
> #!/usr/bin/env python
>
> string_a = raw_input("Enter a string: ")
> string_b = raw_input("Enter another string: ")
>
> if cmp(string_a.lower(), string_b.lower()) == 0:
if string_a.low
bhaaluu wrote:
> Can you explain how this works? How would this be written in
> a "conventional" way?
I'm not sure if this is addressed to me but I'll reply anyway. :)
foo = [1,2,3,4,5,6]
[(foo[i],foo[i+1]) for i in range(0,len(foo),2)]
range(0,len(foo)) would create a list of consecut
Never mind. Sorry, I should have thought about this more before sending
this. In a way I already have access to the interpreter.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Let's say I have a program that is learning how to find patterns in a
list etc.
list = [1,2,3,5,8,13]
So the python program (Kitty.py) opens the python interpreter and copies
this list to it.
It then can try some pattern finding things it already has stored
(PositionN+1 - PositionN etc.)
That
Thanks...
I was able to use the following to get what i needed done:
inp = open('input.txt', 'r')
out = open('output.txt', 'w')
for line in inp:
Fields = line.split(",")
ID = Fields[0]
ProductMess = Fields[1]
Product = ProductMess.split()
for item in Funds:
out.w
GTXY20 wrote:
> Now my next challenge is to link a current table to this file and
> replace values in the Product area based on the value - sort of like a
> Global replace. Any hints as to where Python might have some sort of
> lookup table functionality.
A dict is a lookup table (a hash table,
I'm trying to write a script that detects if a string
is palindromic (same backward as it is forward). This
is what I have so far:
#!/usr/bin/env python
my_str = raw_input("Enter a string: ")
string_list = []
for s in my_str:
string_list.append(s)
string_list_orig = string_list
strin
Christopher Spears wrote:
> I'm trying to write a script that detects if a string
> is palindromic (same backward as it is forward). This
> is what I have so far:
>
> #!/usr/bin/env python
>
> my_str = raw_input("Enter a string: ")
>
> string_list = []
>
> for s in my_str:
> string_list.a
On Fri, 28 Sep 2007, Christopher Spears wrote:
> I'm trying to write a script that detects if a string
> is palindromic (same backward as it is forward). This
> is what I have so far:
> my_str = raw_input("Enter a string: ")
> string_list = []
Here you are creating a list and assiging the name
Greetings,
Try something with this:
>>> string = 'abc'
>>> string
'abc'
>>> for i in range(len(string)-1,-1,-1):
... print string[i],
...
c b a
--
b h a a l u u at g m a i l dot c o m
http://www.geocities.com/ek.bhaaluu/index.html
On 9/28/07, Christopher Spears <[EMAIL PROTECTED]> wrote:
>
On Fri, Sep 28, 2007 at 04:59:26PM -0700, Christopher Spears wrote:
> How do I get around this? Is there a better way to
> write this script? I can't figure out how to loop
> through a string starting from the last character.
A string is a sequence of chars, and you can use slices with it [1].
I'm working out of chapter 6 of Core Python
Programming (2nd Edition). For one problem, I am
supposed to write a script that is the equivalent of
string.strip(). Obviously, using any version of
string.strip() defeats the purpose of the exercise.
I'm not sure how to proceed. My biggest stumbling
32 matches
Mail list logo