[Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Tidal Espeon
I need help with installing this setup on my emacs:
http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-in-emacs/
The problem is that I have no clue how to access any .emacs file or .emacs.d
folder. I'm running linux, and they are apparently invisible in my home
directory. Trying to create those makes linux tell me that they're already
there. I've already installed the latest ropemacs, pyflakes, etc.
I'd sincerely appreciate help, since the IDLE just doesn't cut it for me.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Lisi
On Monday 04 July 2011 15:46:31 Tidal Espeon wrote:
> I need help with installing this setup on my emacs:
> http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-i
>n-emacs/ The problem is that I have no clue how to access any .emacs file or
> .emacs.d folder. I'm running linux, and they are apparently invisible in my
> home directory. Trying to create those makes linux tell me that they're
> already there. I've already installed the latest ropemacs, pyflakes, etc.
> I'd sincerely appreciate help, since the IDLE just doesn't cut it for me.

Do you know how to access hidden files, or is that the problem?

In fact, do you know what hidden files are?

If you can give me some indication of your skill level (see above questions) 
and your distro (including version) and DE, I might be able to help you; or 
anyhow point you in the right direction.

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


Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Peter Otten
Tidal Espeon wrote:

> I need help with installing this setup on my emacs:
> http://hide1713.wordpress.com/2009/01/30/setup-perfect-python-environment-
in-emacs/
> The problem is that I have no clue how to access any .emacs file or
> .emacs.d folder. I'm running linux, and they are apparently invisible in
> my home directory. Trying to create those makes linux tell me that they're
> already there. I've already installed the latest ropemacs, pyflakes, etc.
> I'd sincerely appreciate help, since the IDLE just doesn't cut it for me.

Files and directories whose name starts with a dot are hidden by default. 
You can make ls show them with the --all/-a option:

$ touch .name_that_startswith_a_dot
$ ls
$ ls -a
.  ..  .name_that_startswith_a_dot

Even though they aren't visible you can open and edit them like any other 
file, e. g. with emacs:

$ emacs -nw .name_that_startswith_a_dot


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


Re: [Tutor] Blackjackbetting

2011-07-04 Thread Dave Angel

On 01/-10/-28163 02:59 PM, David Merrick wrote:

HI. I feel I'm starting to go round in circles solving this problem. I feel
I made significant progress.
Can someone help me iron out the bugs please

# Blackjack
# From 1 to 7 players compete against a dealer

import cards, games

class BJ_Card(cards.Card):
 """ A Blackjack Card. """
 ACE_VALUE = 1

 @property
 def value(self):
 if self.is_face_up:
 v = BJ_Card.RANKS.index(self.rank) + 1
 if v>  10:
 v = 10
 else:
 v = None
 return v

class BJ_Deck(cards.Deck):
 """ A Blackjack Deck. """
 def populate(self):
 for suit in BJ_Card.SUITS:
 for rank in BJ_Card.RANKS:
 self.cards.append(BJ_Card(rank, suit))


class BJ_Hand(cards.Hand):
 """ A Blackjack Hand. """
 def __init__(self, name):
 super(BJ_Hand, self).__init__()
 self.name = name

 def __str__(self):
 rep = self.name + ":\t" + super(BJ_Hand, self).__str__()
 if self.total:
 rep += "(" + str(self.total) + ")"
 return rep

 @property
 def total(self):
 # if a card in the hand has value of None, then total is None
 for card in self.cards:
 if not card.value:
 return None

 # add up card values, treat each Ace as 1
 t = 0
 for card in self.cards:
   t += card.value

 # determine if hand contains an Ace
 contains_ace = False
 for card in self.cards:
 if card.value == BJ_Card.ACE_VALUE:
 contains_ace = True

 # if hand contains Ace and total is low enough, treat Ace as 11
 if contains_ace and t<= 11:
 # add only 10 since we've already added 1 for the Ace
 t += 10

 return t

 def is_busted(self):
 return self.total>  21

class Bet(object):
 """ A Blackjack Gamble. """
 # Values
 def __init__(bet, money = 10):
 stash  = money

 # Betting options
 def betting(bet,stash):
 try:
 if stash>  0:
 wager = int(input("\nHow much do you want to wager?: "))
 if wager>  stash:
 int(input("\n You can only wager what you have. How
much?: "))
 elif wager<  0:
 int(input("\n You can only wager what you have. How
much?: "))
 except ValueError:
 int(input("\n That's not valid! Choose a number: "))


 # Money Conditions
 def gamble(bet):
 if bet.stash<= 0:
 print("\nYou are out of money! You're out of the game!")



class BJ_Player(BJ_Hand):
 """ A Blackjack Player. """
 stash = 10
 if stash<= 0:
  print("\nYou are out of money! You're out of the game!")

 def is_hitting(self):
 response = games.ask_yes_no("\n" + self.name + ", do you want a hit?
(Y/N): ")
 return response == "y"

 def bust(self,stash,wager):
 print(self.name, "busts.")
 self.lose(self,stash,wager)

 def lose(self,stash,wager):
 print(self.name, "loses.")
 stash = stash - wager
 print("Your stash is: ",stash)
 return stash

 def win(self,stash,wager):
 print(self.name, "wins.")
 stash = stash + wager
 print("Your stash is: ",stash)
 return stash

 def push(self):
 print(self.name, "pushes.")


class BJ_Dealer(BJ_Hand):
 """ A Blackjack Dealer. """
 def is_hitting(self):
 return self.total<  17

 def bust(self):
 print(self.name, "busts.")

 def flip_first_card(self):
 first_card = self.cards[0]
 first_card.flip()


class BJ_Game(object):
 """ A Blackjack Game. """
 def __init__(self, names):
 self.players = []
 for name in names:
 stash = 100
 player = BJ_Player(name)
 playerbet = Bet(stash).betting(stash)
 self.players.append(player)

 self.dealer = BJ_Dealer("Dealer")

 self.deck = BJ_Deck()
 self.deck.populate()
 self.deck.shuffle()

 @property
 def still_playing(self):
 sp = []
 for player in self.players:
 if not player.is_busted():
 sp.append(player)
 return sp

 def __additional_cards(self, player,stash,wager):
 while not player.is_busted() and player.is_hitting():
 self.deck.deal([player])
 print(player)
 if player.is_busted():
 player.bust(self,stash,wager)

 def play(self,stash,wager):
 # deal initial 2 cards to everyone
 self.deck.deal(self.players + [self.dealer], per_hand = 2)
 self.dealer.flip_first_card()# hide dealer's first card
 for player in self.players:
 print(player)
 print(self.dealer)

Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread Alan Gauld
"Tidal Espeon"  wrote 


I need help with installing this setup on my emacs:


Why do you want this? Are you already an emacs 
user? If so then fine, go ahead. But if you do not 
already use emacs, lerarning it will be a big effort. 
emacs is a big, powerful tool and once you know 
it you can use it for almost everything. But its not 
something you can learn to use quickly.


The problem is that I have no clue how to 
access any .emacs file or .emacs.d


Which strongly suggests you are not n emacs regular. 
If you were you would be editing .emacs regularly!



the IDLE just doesn't cut it for me.


There are lots of other development enmvirobnments around.
If you are a typical GUI user, which it sounds as if you are, 
then a tool liker Eclipse, (or maybe Blackadder or .Wing or SPE)
might be more appropriate. They are powerful but GUI 
oriented rather than command oriented.


Frankly if you are not already an emacs user, or unless 
you want to make emacs you standard environment 
in the future and will spend the time changing your 
computing habits to suit emacs, I'd give up and find 
a more GUI friendly tool set!


And I say that as someone who is an emacs (and vim) user!
emacs is a powerful tool and a great programmer's 
environment, but it's not for the faint hearted.


HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


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


Re: [Tutor] Help with making emacs work with python syntax checking?

2011-07-04 Thread eire1130
I second this.

I have a second harddrive with Mint on it. Ithought it might be fun to learn 
emacs. On windows I've been using eclipse for like 6 to 12 months or however 
long ago I started.

I tried emacs for about two seconds and was like, uh no thanks. Downloaded and 
set up eclipse and I'm still happy. Other than it took too long to set up in 
mint

Bonus is I can use it django as well.


Sent from my Verizon Wireless BlackBerry

-Original Message-
From: "Alan Gauld" 
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Mon, 4 Jul 2011 23:59:48 
To: 
Subject: Re: [Tutor] Help with making emacs work with python syntax checking?

"Tidal Espeon"  wrote 

>I need help with installing this setup on my emacs:

Why do you want this? Are you already an emacs 
user? If so then fine, go ahead. But if you do not 
already use emacs, lerarning it will be a big effort. 
emacs is a big, powerful tool and once you know 
it you can use it for almost everything. But its not 
something you can learn to use quickly.

> The problem is that I have no clue how to 
> access any .emacs file or .emacs.d

Which strongly suggests you are not n emacs regular. 
If you were you would be editing .emacs regularly!

> the IDLE just doesn't cut it for me.

There are lots of other development enmvirobnments around.
If you are a typical GUI user, which it sounds as if you are, 
then a tool liker Eclipse, (or maybe Blackadder or .Wing or SPE)
might be more appropriate. They are powerful but GUI 
oriented rather than command oriented.

Frankly if you are not already an emacs user, or unless 
you want to make emacs you standard environment 
in the future and will spend the time changing your 
computing habits to suit emacs, I'd give up and find 
a more GUI friendly tool set!

And I say that as someone who is an emacs (and vim) user!
emacs is a powerful tool and a great programmer's 
environment, but it's not for the faint hearted.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


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


[Tutor] serial device emulator

2011-07-04 Thread Edgar Almonte
Hello list need some advice/help with something, i am doing a program
in python that send some command via serial to a device so far so good
, the thing is not have the program so i need make another program
that emulate the behavior of this serial device ( is quiet simple ) to
test my app
i read abou that i can use pseudo terminal in linux but not sure how
attatch the pseudo terminal /dev/pts5 example to a fake_device.py file
or something like that.

maybe this question is not so python but i will appreciate some help.


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


Re: [Tutor] serial device emulator

2011-07-04 Thread Chris Fuller

You don't need to emulate a serial port (since you're writing the code; you'd 
have to emulate the port if it was standalone software), only your serial port 
library.  Write a class that has the same methods as the serial port library 
you're using (you only need the methods you're using or think you might use 
later), and fill them in with the appropriate code so it behaves like your real 
device.

Cheers

On Monday 04 July 2011, Edgar Almonte wrote:
> Hello list need some advice/help with something, i am doing a program
> in python that send some command via serial to a device so far so good
> , the thing is not have the program so i need make another program
> that emulate the behavior of this serial device ( is quiet simple ) to
> test my app
> i read abou that i can use pseudo terminal in linux but not sure how
> attatch the pseudo terminal /dev/pts5 example to a fake_device.py file
> or something like that.
> 
> maybe this question is not so python but i will appreciate some help.
> 
> 
> Thanks
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

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