Re: Simulate input to another program

2006-07-27 Thread TeCh
[EMAIL PROTECTED] wrote:

> I am using a python script as a way to test another program that I have
> written in C++. The program cannot be altered. It needs to stay the way
> it is.
> 
> I need to simulate a few keystrokes to the application while it is
> running. The application uses number keys and y and n to navigate a
> basic menu.
> 
> Is there a way within python to simulate the keystrokes to this other
> program.

I think this is possible with an expect module, such as
http://pexpect.sourceforge.net/.


Description: Python module for automating interactive applications
 Pexpect is a pure Python module for spawning child applications;
 controlling them; and responding to expected patterns in their
 output. Pexpect works like Don Libes' Expect. Pexpect allows your
 script to spawn a child application and control it as if a human were
 typing commands.


-- 
TeCh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "10, 20, 30" to [10, 20, 30]

2006-11-23 Thread Tech
Daniel Austria a écrit :
> Sorry,
> 
> how can i convert a string like "10, 20, 30" to a list [10, 20, 30]
> 
> what i can do is:
> 
> s = "10, 20, 30"
> tmp = '[' + s + ']'
> l = eval(tmp)
> 
> but in my opinion this is not a nice solution
> 
> 
> daniel
> 

If you're sure that there's only ints
l = [int(item) for item in s.split(', ')]

Yannick
-- 
http://mail.python.org/mailman/listinfo/python-list


Event Handling Error in Python 3.4.3

2015-09-26 Thread Supra1983 Tech
I have a python script for a game and the problem is that after running the 
game, the blocks start falling, but the game over message is not popping up at 
proper times. Here is my script:

import pygame
import time
import random

pygame.init()

display_width = 800
display_height = 600

black = (0,0,0)
white = (255,255,255)
red = (255,0,0)

car_width = 45.2


gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption('pyrace')
clock = pygame.time.Clock()

carImg = pygame.image.load('theracer 1car.png')

def things_saved(count):
  font = pygame.font.SysFont(None, 25)
  text = font.render("Saved: "+str(count), True, black)
  gameDisplay.blit(text,(0,0))

def things(thingx, thingy, thingw, thingh, color):
pygame.draw.rect(gameDisplay, color, [thingx, thingy, thingw, thingh])
  

def car(x,y):
gameDisplay.blit(carImg,(x,y))

def text_objects(text, font):
  textSurface = font.render(text, True, black)
  return textSurface, textSurface.get_rect()

def message_display(text):
largeText = pygame.font.Font('freesansbold.ttf', 115)
TextSurf, TextRect = text_objects(text, largeText)
TextRect.center = ((display_width/2), (display_height/2))
gameDisplay.blit(TextSurf, TextRect)

pygame.display.update()

time.sleep(2)

game_loop()

def crash():
  message_display('Game Over')

def game_loop():
  x = (display_width * 0.45)
  y = (display_height * 0.45)

  x_change = 0
 
  thing_startx = random.randrange(0, display_width)
  thing_starty = -300
  thing_speed = 7
  thing_width = 100
  thing_height = 100

  saved = 0

  gameExit = False

  while not gameExit:

for event in pygame.event.get():
  if event.type == pygame.QUIT:
pygame.quit()
quit()

  if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
  x_change = -5
elif event.key == pygame.K_RIGHT:
  x_change = 5

  if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
  x_change = 0
  
x += x_change

gameDisplay.fill(white)

#things(thingx, thingy, thingw, thingh, color)
things(thing_startx, thing_starty, thing_width, thing_height, black)
thing_starty += thing_speed
car(x,y)
things_saved(saved)

if x > display_width - car_width or x < 0:
  crash()

if thing_starty > display_height:
  thing_starty = 0 - thing_height
  thing_startx = random.randrange(0,display_width)
  saved += 1

if y < thing_starty+thing_height:  

  if x > thing_startx and x < thing_startx + thing_width or x+car_width 
  > thing_startx and x + car_width < thing_startx + thing_width:
print('cross')
crash()

pygame.display.update()
clock.tick(60)

game_loop()
pygame.quit()
quit()
  
-- 
https://mail.python.org/mailman/listinfo/python-list


List insert at index that is well out of range - behaves like append that too SILENTLY

2014-09-15 Thread Harish Tech
Hi ,

Let me demonstrate the problem I encountered :

I had a list

 a = [1, 2, 3]

when I did

a.insert(100, 100)

[1, 2, 3, 100]

as list was originally of size 4 and I was trying to insert value at index
100 , it behaved like append instead of throwing any errors as I was trying
to insert in an index that did not even existed .


Should it not throw

IndexError: list assignment index out of range

exception as it throws when I attempt doing

a[100] = 100


Personal Opinion : Lets see how other languages behave in such a situation
:

1. Ruby :

> a = [1, 2]

> a[100] = 100

> a

 => [1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 100]

The way ruby handles this is pretty clear and sounds meaningful (and this
is how I expected to behave and it behaved as per my expectation) at least
to me . Here also it was silently handled but the way it fills non existing
indexes in between with nil sounded meaningful .

2. Java :

When I do such an action in java by using .add(index.value) on may be
arraylist or linkedlist I get java.lang.IndexOutOfBoundException

Here instead of handling it silently it throws an error .


But the python way of handling such a problem by appending to the end
sounds more unexpected to me . This in fact flummoxed me in the beginning
making me think it could be a bug . Then when I raised it in stackoverflow
I got chance to look at source and found that's the way code is written .

Question : 1. Any idea Why it has been designed to silently handle this
instead of at least informing the user with an exception(as in java) or
attaching null values in empty places (as in ruby) ?


Thanks

Harish
-- 
https://mail.python.org/mailman/listinfo/python-list


Lisp/Python programmers (among others) wanted

2006-12-19 Thread Tech HR
Smart Charter Inc. is a dynamic new startup company whose goal is to
revolutionize the charter jet industry.  If you are looking for a stable
9-5 job, look elsewhere.  If you are ready for a challenging
ground-floor opportunity with significant upside potential you've come
to the right place.  We are not your typical dotcom.  We have a
razor-sharp focus on an existing multi-billion-dollar market.  We also
have the connections and the technical expertise we need to
revolutionize an industry.  If that sounds like something you'd like to
be part of, drop us a line.

We are currently hiring for the following positions:

Web developer: We are a principally a LAMP shop with P=Python, with some
of our more advanced development currently taking place using Common
Lisp.  We are more interested in brains and motivation than formal
credentials, though a degree in CS can't hurt.  But if we have to choose
between a passionate high school dropout and and an apathetic Ph.D.
we'll take the dropout.  If your main expertise is Java you are probably
not a good fit.

We are currently hiring for the following positions:

Windows developer: Although we are primarily a Linux shop, we have to
interface with some existing Windows legacy applications whose vendors
may or may not be cooperative.  We need someone who is a wizard at
reverse-engineering Windows applications and data file formats, and
building interfaces to them by whatever means necessary.

System administrator: Our production environment is currently Linux, but
we also have OS X and Windows machines at the corporate office.  Ideally
we'd like to find someone with experience in all three environments, but
if we have to choose we would prefer Linux expertise over the other two.

Senior applications developer: Our advanced applications work is
currently being done in Common Lisp, but that could change depending on
who we find to fill this position.  If you are the sort of person who
has always wanted an opportunity to prove that Haskell or OCaml is the
Best Way to write software, this could be your chance.  But CL is
currently our first choice.

These four positions do not necessarily have to be filled by four
distinct people.  A breadth of experience and expertise is highly
desirable.  A passion for flying wouldn't hurt either.

Smart Charter is located in the Los Angeles area.  Telecommuting
is a possibility, but would not be our first choice.

Contact us at tech-hr at smartcharter dot com.
-- 
http://mail.python.org/mailman/listinfo/python-list


Jobs: Lisp and Python programmers (Los Angeles)

2007-02-24 Thread Tech HR
http://www.smartcharter.com/jobs.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Jobs: Lisp and Python programmers wanted in the LA area

2007-02-25 Thread Tech HR
http://www.smartcharter.com/jobs.html

Smart Charter Inc. is a dynamic new startup company aiming to 
revolutionize the purchase and sale of private aviation services. If you 
are ready for a challenging ground-floor opportunity with significant 
upside potential you've come to the right place. We are not your typical 
dotcom. We have a razor-sharp focus on an existing multi-billion-dollar 
market. We are well funded, and have the connections and the technical 
expertise we need to revolutionize an industry.

We are looking for people who are highly motivated and passionate about 
their work, and able to produce high quality code within a fast paced 
development environment.

We are hiring for the following positions:

   €  Senior software engineer -- Ideal candidate would have significant 
development experience, possibly an advanced degree in computer science 
or related field, experience developing planning & scheduling or 
operations software using linear programming and heuristic search 
methods. Proficiency in multiple languages including (but not limited 
to) C++, Python and Common Lisp would also be desirable.

   €  Windows software engineer -- This person will be responsible for 
integrating elements of our products into multiple existing Windows 
applications. An ideal candidate would have experience in development 
for the PC platform, in multiple tool suites, including Visual 
Studio.net Useful skills include the ability to work within existing 
interfaces, protocols, and code structures and to work with extensively 
with database applications.

   €  Web developer, senior web developer, system administrator -- Our 
website is currently a LAMP appication with P=Python. We are looking for 
bright motivated people who know or are willing to learn Python and/or 
Linux, Apache and MySQL system administration skills. (And if you want 
to convince us that we should switch over to Postgres, we're willing to 
listen.)

We are more interested in smarts, passion, and a willingness to learn 
new things than specific credentials. If you are interested in joining 
us drop us a line at: tech-hr at smartcharter.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] wrote:

> On Feb 26, 6:32 am, Tech HR <[EMAIL PROTECTED]> wrote:
> > Our
> > website is currently a LAMP appication with P=Python. We are looking for
> > bright motivated people who know or are willing to learn Python and/or
> > Linux, Apache and MySQL system administration skills. (And if you want
> > to convince us that we should switch over to Postgres, we're willing to
> > listen.)
> This is more out of curiosity, but does it mean that you wouldn't be
> willing to listen about a switch from Python to Lisp?

No, it doesn't mean that.  In fact, there is a significant faction in 
the technical staff (including the CTO) who would like nothing better 
than to be able to use Lisp instead of Python.  But we have some pretty 
compelling reasons to stick with Python, not least of which is that it 
is turning out to be very hard to find Lisp programmers.  (Actually, 
it's turning out to be hard to find Python programmers too, but it's 
easier to train a Java programmer or a Perler on Python than Lisp.  We 
also have fair bit of infrastructure built up in Python at this point.)

But we're a very young company (barely six months old at this point) so 
we're willing to listen to most anything at this point.  (We're using 
Darcs for revision control.  Haskell, anyone?)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 Ray Dillinger <[EMAIL PROTECTED]> wrote:

> Tech HR wrote:
> 
> > But we're a very young company (barely six months old at this point) so 
> > we're willing to listen to most anything at this point.  (We're using 
> > Darcs for revision control.  Haskell, anyone?)
> 
> Tell us, where you would expect an applicant for one or more of these
> jobs to live if they accepted a job with your firm?  It's not at all
> apparent from your website or job descriptions where the worksite is
> physically located.

We are in the Los Angeles area.  (We've added a note at the bottom of 
the jobs page on our web site.)  I can't be more specific at this time 
because we are in the process of finding permanent office space.  Our 
temporary offices are in Santa Monica.  We're hoping to find space near 
the Van Nuys airport, but the commercial real estate market here is very 
tight right now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 Dan Bensen <[EMAIL PROTECTED]> wrote:

> Tech HR wrote:
> > easier to train a Java programmer or a Perler on Python than Lisp. 
> 
> Are your technical problems simple enough to be solved by Python trainees?

Some are.  Some aren't.  That's why we're using Lisp too :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 Paul Rubin  wrote:

> You know about http://lispjobs.wordpress.com I presume.

I did not.  Thanks for the pointer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 Bruce Lewis <[EMAIL PROTECTED]> wrote:

> Tech HR <[EMAIL PROTECTED]> writes:
> 
> > (Actually, 
> > it's turning out to be hard to find Python programmers too, but it's 
> > easier to train a Java programmer or a Perler on Python than Lisp.
> 
> Is this speculation or experience?

A little of both.  We're a pretty young company :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jobs: Lisp and Python programmers wanted in the LA area

2007-02-26 Thread Tech HR
In article <[EMAIL PROTECTED]>,
 Tech HR <[EMAIL PROTECTED]> wrote:

> In article <[EMAIL PROTECTED]>,
>  Ray Dillinger <[EMAIL PROTECTED]> wrote:
> 
> > Tech HR wrote:
> > 
> > > But we're a very young company (barely six months old at this point) so 
> > > we're willing to listen to most anything at this point.  (We're using 
> > > Darcs for revision control.  Haskell, anyone?)
> > 
> > Tell us, where you would expect an applicant for one or more of these
> > jobs to live if they accepted a job with your firm?  It's not at all
> > apparent from your website or job descriptions where the worksite is
> > physically located.
> 
> We are in the Los Angeles area.  (We've added a note at the bottom of 
> the jobs page on our web site.)  I can't be more specific at this time 
> because we are in the process of finding permanent office space.  Our 
> temporary offices are in Santa Monica.  We're hoping to find space near 
> the Van Nuys airport, but the commercial real estate market here is very 
> tight right now.

Actually, it just occurred to me that the company location was also in 
the subject line of this thread ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


modify a file

2007-11-04 Thread tech user
Hello,

I have a file which is large about 3.5G.
I need to modify some lines in it,but I don't like to create another file
for the result.
How can i do it? thanks.





  
National Bingo Night. Play along for the chance to win $10,000 every week. 
Download your gamecard now at Yahoo!7 TV. 
http://au.blogs.yahoo.com/national-bingo-night/


-- 
http://mail.python.org/mailman/listinfo/python-list


Multiple python installations mix their sys.prefix

2011-01-24 Thread Tech Support Box
Hi there
I have several versions of python2.4 installed:
- the OS, rpm-installed one in /usr
- Several other versions in /usr/local, installed with --prefix /usr/
local/inst-shared/ --exec-prefix /usr/local/inst/

My problem is when starting one of the versions from /usr/local,
sys.prefix is set as "/usr" instead of the compile-time setting "/usr/
local/inst-shared/" and as a result sys.path contains paths
from /usr, which shouldn't be there.

After strace-ing the pythons from /usr/local and the one from /usr, it
seems that python determines sys.prefix by first looking for os.py in
every path component of the interpreter executable and adding "/lib/
python2.4/os.py" to it (i.e. stat()-ing for /usr/local/inst//
bin/lib/python2.4/os.py, then /usr/local/inst//lib/python2.4/
os.py and so on) and only after it doesn't find os.py in any one of
those paths does it look at the compile-time PREFIX setting. When
doing this, it finds /usr/lib/python2.4/os.py (which belongs to the
python installed at /usr) and determines that sys.prefix is /usr,
which is wrong.

The only fix I could come up with is setting PYTHONHOME before running
python (which should be set differently for every version, and won't
work in scripts using a shebang line) or moving /usr/lib/python2.4 to
a different location (which is plain ugly). Is there a better way to
make python take its compile-time option of prefix and *not* try to
guess at runtime where it should be?

Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


graphing lifelines

2008-07-15 Thread E. J. Gold is the Hi-Tech Shaman
(crossposted to sci.math)

I'm looking for a tool which will take a dataset of tuples indicating
the year of birth and death of a person:

(1872, 1950, "Sri Aurobindo")
(1821, 1910, "Mary Baker Eddy")
(1831, 1891, "HP. Blavatksy")

And graph them out, in bars, annotating them with the person's name.

A simple spreadsheet would've worked, but they seem to start from
zero. Thus, I would only be able to indicate the span of life (by
subtracting death year from birth year).
--
http://mail.python.org/mailman/listinfo/python-list


Re: graphing lifelines

2008-07-15 Thread E. J. Gold is the Hi-Tech Shaman
On Jul 15, 3:38 pm, Larry Bates <[EMAIL PROTECTED]> wrote:

>
> Certainly a "Hi-Tech Shaman" can whip something up to do this, right?
>

Yes, well E.J. Gold is the Hi-Tech Shaman. I'm Terrence Brannon,
stating that fact :)

So, maybe EJ could whip up such a thing :)

I like the sci.math answer I got the best and will go with that
approach -
http://groups.google.com/group/sci.math/browse_thread/thread/09b254718d4cbfeb#
--
http://mail.python.org/mailman/listinfo/python-list