Re: [Tutor] a simple keyboard art,,, gone wrong!

2008-09-21 Thread rui
Try to put a 'r' letter before the opening-quote:

print \
 r
 _   ___   ___  ___  _
/  ___| /   | /   |/   ||  ___|
| |/ /| |/ /|   /| || |__
| |  _/ __| |   / / |__/ | ||  __|
| |_| |  / /  | |  / /   | || |___
\_/ /_/   |_| /_/|_||_|

 _   _ __   ___
/  _  \ | |   / /  |  |  |  _  \
| | | | | |  / /   | |__ | |_| |
| | | | | | / /|  __||  _  /
| |_| | | |/ / | |   | | \ \
\_/ |___/  |__|  |_|  \_\




Python was trying to interpret the '\'.
Cheers.
[ rui ]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] executing a script from a script

2008-08-26 Thread rui
On Tue, Aug 26, 2008 at 3:31 PM, Jeff Peery [EMAIL PROTECTED] wrote:
 Hello,

 I have a simple wx app that I need some help with. This application uses the
 serial ports to communicate with an industrial product. I first check that
 my python application is compatible with the industrial product by asking
 the industrial product for its revision number. If the revision number is
 too old I want to kill my python application and launch an older python
 application. To do this I am using the following:



 # launch old program

 execfile('theoldpythonprogram.py')

 # kill this App (wx.Frame object)

 self.Destroy()



 The problem is that the self.Destroy() seems to kill both the current python
 program and the one I just launched. How can I launch a new program and kill
 the current one without killing the new one as well?



Hi Jeff,

The problem is that execfile runs the script inside the current python
interpreter.
To run this as -- really -- an external process, look at:

http://blog.doughellmann.com/2007/07/pymotw-subprocess.html

Cheers and good luck. Just a tip, using inheritance could solve your
problem more elegantly.

[ As quatro melhores coisas do mundo são três: forró e mulher. ]


 Thanks!



 Jeff

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


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


Re: [Tutor] best way to get external data

2008-05-02 Thread rui
PyYaml is an option too. [1]

[1] - http://pyyaml.org/

It´s very readable and is converted to a Python native structure/object.

On Fri, May 2, 2008 at 12:12 PM, Bryan Fodness [EMAIL PROTECTED]
wrote:

 I am trying to figure out the best way to get external data.

 Using the following data in a file

  1
  2
  3

 I have used,

  fi = open(infile, 'r')
  s = fi.readlines()
  fi.close()
  a = s[0]
  b = s[1]
  c = s[2]

 but, if I have,

  x = 1
  y = 2
  z = 3

 I have used,

  for line in open(infile):
   i_line = line.split()
   if i_line[0] == 'x':
a = i_line[2]
elif i_line[0] == 'y':
b = i_line[2]
elif i_line[0] == 'z':
c = i_line[2]

 I do have control over the creation of the data file.  The second way is
 better in my mind, because it is independent of the ordering.

 If I have a long list of 'variable' = 'value', could this be better
 managed in a dictionary?  Or, is there a better way?

 Thanks


 --
 The game of science can accurately be described as a never-ending insult
 to human intelligence. - João Magueijo

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




-- 
Meu nome é Valdo, Ruivaldo Neto.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 50, Issue 9

2008-04-09 Thread rui
Hi Gloom,



You should give a look at the method split (of the string objects) and
int.

The first is used do break a string into smaller pieces and the other to
convert a string to an int object, raising an exception when it is not
possible.


On Wed, Apr 9, 2008 at 9:29 AM, Gloom Demon [EMAIL PROTECTED] wrote:

 Hello :-)

 Can someone please explain to me ho can I find out how many elements are
 there in one record of a list?

 The problem is as follows:

 I have a txt file from which I read data into Python.

 The file looks something like this:

 01 bla bla bla 23,15 2345,67
 02 alb alb 2,4 890,1
 03 bal bla alb lab 567,12345 87,45
 

 I need to be able to discriminate the string parts from the numeric ones.

 Since the number of words in the file can vary, I have to be able to find out 
 when they are finished
 and when the floats come in

 mystring[0]- always integer
 mystring[1]- string (word)
 mystring[1-X]- last string (word)
 mystring[X+1]- always float
 mystring[X+2]- always float

 it would have been nice if I could find out the total number of the fields
 in one list record so that I could then adress them via a variable.

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




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


Re: [Tutor] rss feed reader, but having trouble with unicode

2008-02-26 Thread rui
Hello Tom,

Try doing this:

xml = unicode(xml, encoding, ignore)
elem = ElementTree.fromstring(xml.encode(utf8))

  #do stuff with elem...

  feed.xml = xml
  feed.save()


  Thanks for your time :-)
  ___
  Tutor maillist  -  Tutor@python.org
  http://mail.python.org/mailman/listinfo/tutor




-- 
Rui
http://ruivaldo.wordpress.com

Rubi? Aquela novela do SBT?
~ Carla Perez sobre Ruby

Em Python, tudo é objeto, além de lindo e maravilhoso.
~ Caetano Veloso sobre Python
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor