Re: [Tutor] create an object from a class in dll with ctypes?

2010-01-20 Thread katrin schmid
hi,
perfectly looks like what i want,
thanks a lot.
katrin


 Original-Nachricht 
> Datum: Tue, 19 Jan 2010 23:49:14 -0800
> Von: "Mark Tolonen" 
> An: tutor@python.org
> Betreff: Re: [Tutor] create an object from a class in dll with ctypes?

> 
> "katrin schmid"  wrote in message 
> news:0edda7dddff84d639352526b72dbf...@katissspc...
> > hi,
> > i am getting started with ctypes in python 2.5 and was wondering if
> > i would be able to create an object from the class in my dll somehow.
> > I only found examples that show how to access a function but the
> > function i want to call is part of a cpp class in my dll...
> 
> ctypes is for C DLLs.  You might want to look at www.swig.org instead.
> 
> -Mark
> 
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

-- 
Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 -
sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] adding more text to a file (Vanam)

2010-01-20 Thread vanam
Below is the code which can be helpful for better insight:

Sample: 1

For the below code, you can provide initially the number of entries
(say 4) so that for four times name of person and age is prompted to
enter.After writing to file we can read back the contents

#Writing number of times the name of person to a file
#Opening the file
log = open('data.txt','w')
x = int(raw_input('enter the number of entries'))
for y in range(x):
   data = raw_input('enter the name of the person')
   age = int(raw_input('enter age of the person'))
   print  >> log,  '%s %d' % (data,age)
log.close()
#Reading the contents of the file with multiple entries
log = open('hello.txt','r')
for x in log:
   print x,
log.close()

Sample:2
Assuming your query, below is the short piece where name and age is
always entered till there is no data entered for person and the same
content is written back to the file.
log = open('data.txt','w')
while True:
   x = raw_input('enter name')
   if len(x)  == 0:
  break
   y = int(raw_input('enter age'))
   print >> log, '%s %d' % (x,y)
log.close()

>
> Hi,
>
> I am new to python, and i am trying to make a program that makes like a txt 
> file database. so i have my whole program in a while True loop, it asks for 
> information about the person and then writes the information about the person 
> to a txt file, but i need it to be able to add more entries instead of just 
> one.
>
> my code is like this:
>
> while True:
>   name = raw_input("what is the name ")
>   age = raw_input("what is the age ")
>
>   out_file = open("persons.txt", "w")
>   out_file.write("name: ")
>   out_file.write(name)
>   out_file.write("\n")
>   out_file.write("age: ")
>   out_file.write(age)
>   out_file.write("\n")
>   out_file.write("\n")
>   out_file.close
>
> now i want to add like say 5 persons to the txt file, but whenever i enter a 
> new person it just overwrites the previous, im sure its because of the "w" 
> but how exactly do i need to change my code to add more text instead of 
> overwriting?
>
>
>
>

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


[Tutor] keeping track of the present line in a file

2010-01-20 Thread sudhir prasad
hi,
is there any other way to keep track of line number in a file other than
fileinput.filelineno()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor