Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread W W
On Tue, Oct 7, 2008 at 5:58 PM, Emile van Sebille <[EMAIL PROTECTED]> wrote:

> Robert Berman wrote:
>
>> Hi,
>>
>> The below script which prints anagrams available for any word available
>> within a given database. It does work, but  it is not very fast. I am
>> relatively certain there are more Python friendly coding techniques but I am
>> more concerned with a faster algorithm.
>>
>
> You might consider looking up the permutations only (up to some length --
> there are a lot of permutations for 8+ letter words :)
>

I'm not sure if this would be any faster, but I'd be curious at least to
know what the difference would be to have a database of every possible
permutation for every length up to 10, i.e:

0
01
10
012
021
102
120
201
210
.
.
.
etc.

And then simply use the key values of the letter... perhaps the anagrams
stored in a dict by length as the key:
mutations = {1: [(0,)], 2: [(0,1), (1,0)],}

so for instance:

myword = "if"
mylen = len(myword)
for mytuple in mutations[mylen]:
for x in mytuple:
print myword[x]

I think that would work anyway. I don't know if I have the code right, and
I'm not sure if it would be faster, slower, or no change, but it may be
worth a look.

HTH,
Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Batch searches on Googlescholar

2008-10-07 Thread W W
On Tue, Oct 7, 2008 at 5:42 PM, Srinivas Iyyer <[EMAIL PROTECTED]>wrote:

> Dear Tutors,
> This might ben off track question, but I am asking to seek help from
> experts here.
>
> I have a list of (n = 240) research publications (Biology and medicine). I
> have title, journal name and PubMedID.
>
> my aim is to identify how many times each publication got cited on google
> Scholar.
> since Googlescholars indexing is different from that of ISI, we have
> difference in number of citations. GS has more when compared to ISI. It
> would be nice If I can have both.
>
> I asked ISI web of knowledge and they do not seem to have batch extraction
> tools and I did not find any url hooks ( cgi) to automate and parse HTML.


You can use the urllib builtin module and beautiful soup for parsing HTML. I
don't know if the Googlescholars page allows python connections, I know
regular google queries do not (they frown on web scraping, AFAIK)

that's about as specific as you'll probably get without a more explicit
example.

HTH,
Wayne


-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Emile van Sebille

Robert Berman wrote:

Hi,

The below script which prints anagrams available for any word available 
within a given database. It does work, but  it is not very fast. I am 
relatively certain there are more Python friendly coding techniques but 
I am more concerned with a faster algorithm.


You might consider looking up the permutations only (up to some length 
-- there are a lot of permutations for 8+ letter words :)


#from http://www.daniweb.com/code/snippet459.html

def permutate(seq):
"""permutate a sequence and return a list of the permutations"""
if not seq:
return [seq]  # is an empty sequence
else:
temp = []
for k in range(len(seq)):
part = seq[:k] + seq[k+1:]
#print k, part  # test
for m in permutate(part):
temp.append(seq[k:k+1] + m)
#print m, seq[k:k+1], temp  # test
return temp

print permutate('myth')

['myth', 'myht', 'mtyh', 'mthy', 'mhyt', 'mhty', 'ymth', 'ymht', 'ytmh', 
'ythm', 'yhmt', 'yhtm', 'tmyh', 'tmhy', 'tymh', 'tyhm', 'thmy', 'thym', 
'hmyt', 'hmty', 'hymt', 'hytm', 'htmy', 'htym']


>>> print len(permutate('mythsdfw'))
40320
>>> print len(permutate('mythsdf'))
5040
>>> print len(permutate('mythsd'))
720
>>> print len(permutate('myths'))
120
>>> print len(permutate('myth'))
24
>>> print len(permutate('myt'))
6

so something like:

print [ xx for xx in permutate('myths') if xx in worddict ]


HTH,

Emile

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


[Tutor] Batch searches on Googlescholar

2008-10-07 Thread Srinivas Iyyer
Dear Tutors, 
This might ben off track question, but I am asking to seek help from experts 
here. 

I have a list of (n = 240) research publications (Biology and medicine). I have 
title, journal name and PubMedID. 

my aim is to identify how many times each publication got cited on google 
Scholar. 
since Googlescholars indexing is different from that of ISI, we have difference 
in number of citations. GS has more when compared to ISI. It would be nice If I 
can have both. 

I asked ISI web of knowledge and they do not seem to have batch extraction 
tools and I did not find any url hooks ( cgi) to automate and parse HTML. 

Any suggestions/ ideas please on Google Scholar. 

Thank you. 
Srini


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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread Hansen, Mike
>>Got it. Thanks. 
>> 
>>When i try 'python setup.py build' i get the following error. 
>> 
>>$ sudo python setup.py build 
>> 
>>Traceback (most recent call last): 
>> 
>> File "setup.py", line 72, in  
>>   raise DistutilsSetupError, "cannot locate an Oracle software 
>>installation" 
>>distutils.errors.DistutilsSetupError: cannot locate an Oracle software 
>>installation 
>> 
>> 
>>Thoughts? 
> 
> 
>This means you don't have Oracle installed, or setup.py can't find it. 
> 
>-Wayne  
  
I'm guessing that you'll need to install the .deb file from this site. 
Someone can correct me if I'm wrong. 

http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html
 

There's installation instructions for Debian(Which I believe Ubuntu is 
derived from) here: 

http://www.oracle.com/technology/software/products/database/xe/files/install.102/b25144/toc.htm#BABFEDEI
  

After the client is installed, then hopefully you can build and 
install the cx_oracle module. 

Good luck. If you get stuck maybe someone else can pipe in. Unless 
it's something simple, I usually have trouble if a package is unable 
to install due to some missing library or what not. 

Mike 

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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread jeremiah
I'm working on a shared box and was told it was installed. How can i
verify installation?

'which oracle' does not return any results. Also, nothing in /etc/init.d
or /usr/bin

JJ

On Tue, 2008-10-07 at 14:32 -0700, W W wrote:
> On Tue, Oct 7, 2008 at 4:30 PM, jeremiah
> <[EMAIL PROTECTED]> wrote:
> Got it. Thanks.
> 
> When i try 'python setup.py build' i get the following error.
> 
> $ sudo python setup.py build
> Traceback (most recent call last):
> 
>  File "setup.py", line 72, in 
>raise DistutilsSetupError, "cannot locate an Oracle
> software
> installation"
> distutils.errors.DistutilsSetupError: cannot locate an Oracle
> software
> installation
> 
> 
> Thoughts?
> 
> This means you don't have Oracle installed, or setup.py can't find it.
> 
> -Wayne 
> 
> 
> 


Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.


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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread W W
On Tue, Oct 7, 2008 at 4:30 PM, jeremiah <[EMAIL PROTECTED]>wrote:

> Got it. Thanks.
>
> When i try 'python setup.py build' i get the following error.
>
> $ sudo python setup.py build
> Traceback (most recent call last):
>   File "setup.py", line 72, in 
>raise DistutilsSetupError, "cannot locate an Oracle software
> installation"
> distutils.errors.DistutilsSetupError: cannot locate an Oracle software
> installation
>
>
> Thoughts?


This means you don't have Oracle installed, or setup.py can't find it.

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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread jeremiah
Got it. Thanks.

When i try 'python setup.py build' i get the following error.

$ sudo python setup.py build
Traceback (most recent call last):
  File "setup.py", line 72, in 
raise DistutilsSetupError, "cannot locate an Oracle software
installation"
distutils.errors.DistutilsSetupError: cannot locate an Oracle software
installation


Thoughts?

Thanks,
JJ

On Tue, 2008-10-07 at 12:27 -0700, Jerry Hill wrote:
> On Tue, Oct 7, 2008 at 2:46 PM, jeremiah
> <[EMAIL PROTECTED]> wrote:
> > I've downloaded the cx_oracle source module for python, howerver
> every
> > time i try to build it, it keeps on failing. I've been unable to
> find a
> > port for Ubuntu. Is there one? Anyone know how to get this properly
> > installed?
> >
> > # sudo python setup.py install
> > Traceback (most recent call last):
> >  File "setup.py", line 36, in 
> >oracleHome = os.environ["ORACLE_HOME"]
> >  File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
> >raise KeyError(key)
> > KeyError: 'ORACLE_HOME'
> 
> It looks to me like it expects you to already have the oracle client
> libraries installed, since it's looking for the 'ORACLE_HOME'
> environment variable.
> 
> --
> Jerry
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> 


Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.


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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread Alan Gauld


"jeremiah" <[EMAIL PROTECTED]> wrote


port for Ubuntu. Is there one? Anyone know how to get this properly
installed?

# sudo python setup.py install
 File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
   raise KeyError(key)
KeyError: 'ORACLE_HOME'


Given the error message, do you have ORACLE_HOME defined
as an environment variable for the user account running the script??

Assuming you have Oracle installed on the box you should have
it defined at least for the Oracle admin user ID if not for everyone.
If so try running the script as that user.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


Re: [Tutor] Monitoring HTTP connections?

2008-10-07 Thread Kent Johnson
On Tue, Oct 7, 2008 at 3:06 PM, xbmuncher <[EMAIL PROTECTED]> wrote:
> on proxy programs:
> i want to sniff the http requests that are being made internally from a
> program I have no control over, so a proxy server won't work, because I
> can't make the program access the internet through a proxy, its not a
> browser that is making the requests

Google 'python libpcap' for some leads, there seem to be three Python
bindings to libpcap.

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


Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Robert Berman




Yet another approach to experiment with. Thank you all
very much,

Robert

Kent Johnson wrote:

  On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely
<[EMAIL PROTECTED]> wrote:
  
  
In a slightly related matter, Is is possible to use all() with a list
comprehension to check if a word contains all of the letters of
another?

  
  
Sure.

In [1]: all(letter in 'abcde' for letter in 'cde')
Out[1]: True

In [2]: all(letter in 'abcde' for letter in 'cdef')
Out[2]: False

Kent

  



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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread Jerry Hill
On Tue, Oct 7, 2008 at 2:46 PM, jeremiah <[EMAIL PROTECTED]> wrote:
> I've downloaded the cx_oracle source module for python, howerver every
> time i try to build it, it keeps on failing. I've been unable to find a
> port for Ubuntu. Is there one? Anyone know how to get this properly
> installed?
>
> # sudo python setup.py install
> Traceback (most recent call last):
>  File "setup.py", line 36, in 
>oracleHome = os.environ["ORACLE_HOME"]
>  File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
>raise KeyError(key)
> KeyError: 'ORACLE_HOME'

It looks to me like it expects you to already have the oracle client
libraries installed, since it's looking for the 'ORACLE_HOME'
environment variable.

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


Re: [Tutor] cx_oracle module problems

2008-10-07 Thread Hansen, Mike
 

> Subject: [Tutor] cx_oracle module problems
> 
> I've downloaded the cx_oracle source module for python, howerver every
> time i try to build it, it keeps on failing. I've been unable 
> to find a
> port for Ubuntu. Is there one? Anyone know how to get this properly
> installed?
> 
> # sudo python setup.py install
> Traceback (most recent call last):
>   File "setup.py", line 36, in 
> oracleHome = os.environ["ORACLE_HOME"]
>   File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
> raise KeyError(key)
> KeyError: 'ORACLE_HOME'
> 
> 
> Link:
> http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-4.2.tar
> .gz?download  
> 
> Thanks,
> JJ
> 
> 

Did you python setup.py build first? The README.txt mentions it along the 
option of doing a binary install.

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


Re: [Tutor] Monitoring HTTP connections?

2008-10-07 Thread xbmuncher
on proxy programs:
i want to sniff the http requests that are being made internally from a
program I have no control over, so a proxy server won't work, because I
can't make the program access the internet through a proxy, its not a
browser that is making the requests

Perhaps, you can tell me the "things" I need to accomplish with code for me
to be able to sniff the HTTP requests/responses coming from my wireless
card. I can explain what I want to do in primitive terms:
wireless card or computer machine makes requests of the protocol HTTP
I want to be able to sniff and get the text information of these requests, i
want to be able to trigger event like behavior on these requests, so my
program can respond instantly when an http request happens

how to describe these things in their technical aspects I am ignorant of, if
someone could outline or summarize what I would need to do technically with
python to achieve this, I'll be happy to study methods of how to do these
technical things and eventually write the code myself

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


[Tutor] cx_oracle module problems

2008-10-07 Thread jeremiah
I've downloaded the cx_oracle source module for python, howerver every
time i try to build it, it keeps on failing. I've been unable to find a
port for Ubuntu. Is there one? Anyone know how to get this properly
installed?

# sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 36, in 
oracleHome = os.environ["ORACLE_HOME"]
  File "/usr/lib/python2.5/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'ORACLE_HOME'


Link:
http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-4.2.tar.gz?download  

Thanks,
JJ



Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.


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


Re: [Tutor] Default parameter in class method

2008-10-07 Thread Daniele
2008/10/7 Kent Johnson <[EMAIL PROTECTED]>:
> On Tue, Oct 7, 2008 at 10:08 AM, Daniele <[EMAIL PROTECTED]> wrote:
> def myMethod(self, parameter=_marker):
>  if parameter==_marker:
>parameter = self.field

Thanks Kent and Alan, I've understood the point and I think I'll use
Kent's solution :)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Kent Johnson
On Tue, Oct 7, 2008 at 1:15 PM, Richard Lovely
<[EMAIL PROTECTED]> wrote:
> In a slightly related matter, Is is possible to use all() with a list
> comprehension to check if a word contains all of the letters of
> another?

Sure.

In [1]: all(letter in 'abcde' for letter in 'cde')
Out[1]: True

In [2]: all(letter in 'abcde' for letter in 'cdef')
Out[2]: False

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


[Tutor] pexpect/pxssh

2008-10-07 Thread Vinay Reddy
Hi,
I wish to automate some of my network related tasks, which involves
sshing into a remote box and executing some commands. I looked at
pxssh for that purpose but it seems to throw an exception when I have
ssh keys setup so that logins can happen without explicit password
authentication.

Is there a way to use pxssh (or some other tool) to just ssh in if
keys are setup correctly, else fallback to password based
authentication.

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


Re: [Tutor] More Pythonesque or a more efficient method

2008-10-07 Thread Richard Lovely
In a slightly related matter, Is is possible to use all() with a list
comprehension to check if a word contains all of the letters of
another?

-- 
Richard "Roadie Rich" Lovely, part of the JNP|UK Famile
www.theJNP.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] first call - newcomer

2008-10-07 Thread Steve Willoughby
On Tue, Oct 07, 2008 at 04:23:50AM -0400, Pierre Dagenais wrote:
> Anthony Smith wrote:
> >1.  A brief (but complete) description regarding the use of script 
> >editor (I will be using

Place the files wherever you like, just use a .py extension on
the filenames.  Use any text editor you like which saves plain
ASCII files (notepad, IDLE, vi, emacs, etc).  IDLE comes with
Python and may be useful for new programmers especially.

> >2.  I have been unable to locate the gizmo in the literature to get 
> >ascii codes
> >in python.  In the old days, it was a list of 256 (or so) 
> >characters that represented all keyboard symbols (A equalled 36; B 
> >equalled 37; et cetera).

36?  Out of curiosity, what system were you using?  It can't have
been ASCII or EBCDIC.

> >   To assign a value, you used "Let A$ = ASC (36)" where A$ was a 
> >variable
> >and 36 was the ASCII value for 'A'.  I believe the reverse of this 
> >process
> >was PRINT VAL(A$) or something.  I want to play with a program 
> >that will

In Python:
a = chr(36)
print ord(a)

-- 
Steve Willoughby|  Using billion-dollar satellites
[EMAIL PROTECTED]   |  to hunt for Tupperware.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Default parameter in class method

2008-10-07 Thread Alan Gauld

"Daniele" <[EMAIL PROTECTED]> wrote

I want to create a method of a class with a default value. The 
problem

is that this default value should be an instance field of that same
class. For example:

class Test():
 def __init__(self):
   self.field='Default'

 def myMethod(self, parameter=self.field):
   pass



This has little to do with OOP per se.
You cannot make a default value of a normal function refer to a
dynamic variable. It has to be a constant value (or the current
value of a variable at the time the function is defined).

Consider:


myvar = None
def f1():

...   global myvar
...   myvar = 42
...

def f2(n = myvar):

...   print n
...

myvar

None

f2()

None

f1()   # set myvar to 42
myvar

42

f2()   # still using the original myvar value

None

myvar

42




So the default value is bound to the value of myvar
at the time the function was defined. Even if myvar
changes the default value will not.

So in the OOP case binding to a field value won't
work because the field doesn't get defined until
an object is instantiated but the class definition
(including the method) will be executed before
any instances are created.

Kent has shown how to use a default binding to
None to do what you want. I just wanted to point
out that the same issues arise using functions.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



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


Re: [Tutor] Default parameter in class method

2008-10-07 Thread Kent Johnson
On Tue, Oct 7, 2008 at 10:08 AM, Daniele <[EMAIL PROTECTED]> wrote:
> Hi all,
> I know very little about OOP in Python, I'm working on it but, for the
> time being, here's my problem:
> I want to create a method of a class with a default value. The problem
> is that this default value should be an instance field of that same
> class. For example:
>
> class Test():
>  def __init__(self):
>self.field='Default'
>
>  def myMethod(self, parameter=self.field):
>pass
>
> I'm getting an error like "name 'self' is not defined"; it seems I
> cannot access self.field in the method definition. Is there a
> work-around (or maybe just the proper way to do it)?

def myMethod(self, parameter=None):
  if parameter is None:
parameter = self.field

If None is actually a valid value for parameter, you can create a
unique marker object:
outside the class:
_marker = object()

then:
def myMethod(self, parameter=_marker):
  if parameter==_marker:
parameter = self.field

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


[Tutor] Default parameter in class method

2008-10-07 Thread Daniele
Hi all,
I know very little about OOP in Python, I'm working on it but, for the
time being, here's my problem:
I want to create a method of a class with a default value. The problem
is that this default value should be an instance field of that same
class. For example:

class Test():
  def __init__(self):
self.field='Default'

  def myMethod(self, parameter=self.field):
pass

I'm getting an error like "name 'self' is not defined"; it seems I
cannot access self.field in the method definition. Is there a
work-around (or maybe just the proper way to do it)?

Thank you very much,
Daniele
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] IF statment 2

2008-10-07 Thread Kent Johnson
On Mon, Oct 6, 2008 at 10:06 PM, WM <[EMAIL PROTECTED]> wrote:
> Hey, guys, forgive me; I can't help being a fool.  Just now I READ the
> program and it worked perfectly!  42 is more than 1 so it printed "More".
>  My error was that I imagined there was a loop where no loop could be.  Oh,
> me; oh, my.

Glad you got it working. One more tip about the list - it is very
helpful if you respond to a thread by replying (to all) to one of the
messages in the thread. That way people using threaded readers see the
entire thread grouped together.

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


Re: [Tutor] Using the curses module (or a better solution)

2008-10-07 Thread W W
On Tue, Oct 7, 2008 at 3:27 AM, Alan Gauld <[EMAIL PROTECTED]>wrote:

> There are some wrappers around curses to make the learning
> curve a little bit less steep. Although, personally I don't think
> raw curses is all that hard... :-)
>

Especially not for such a simple program. Less than 100 lines to do this
sort of thing, I'm sure.
-Wayne

-- 
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn't. - Primo Levi
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using the curses module (or a better solution)

2008-10-07 Thread Alan Gauld


"Tony Cappellini" <[EMAIL PROTECTED]> wrote

I'd like to add a 1-2 line no-scroll-area at the top of the screen, 
so as to

print a message which indicates the progress of the current test.

I'm not sure if the curses module has this non-scroll area 
capability.


Yes, curses works by defining viewport windows on the character 
screen. Thus you can define two windows, one for the scrolling text 
(and add a scrollbar to bring it back if needed) and one for the fixed 
display.


There are some wrappers around curses to make the learning
curve a little bit less steep. Although, personally I don't think
raw curses is all that hard... :-)

Alan G. 



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


[Tutor] first call - newcomer

2008-10-07 Thread Pierre Dagenais

Anthony Smith wrote:

This is my first post - I will be brief...
 
One:  I have programmed before - but it has been DECADES...so just a 
few simple queries:
 
1.  A brief (but complete) description regarding the use of script 
editor (I will be using

 command prompt in Windows), as:
 
 a.  details about loading and saving programs (not in that 
order) and little
  specs about pathnames or other requirements (I will 
probably store all

  my little goodies in one folder or space).
 
  

Hi,
You save programs by writing them in a file with a .py extension. Ex.: 
myProgram.py
Then there are different ways of loading a program, from the dos command 
line you can do: C:\myProgram.py, that one I couldn't find in the 
litterature, I had to ask, thank you Alan.
  That should get me going ... a book and manual by my side should 
suffice for

   the rest - - - except for one thing:
 
2.  I have been unable to locate the gizmo in the literature to get 
ascii codes
in python.  In the old days, it was a list of 256 (or so) 
characters that represented all keyboard symbols (A equalled 36; B 
equalled 37; et cetera).
   To assign a value, you used "Let A$ = ASC (36)" where A$ was a 
variable
and 36 was the ASCII value for 'A'.  I believe the reverse of this 
process
was PRINT VAL(A$) or something.  I want to play with a program 
that will

   assign a number to a word (using a simple algorhythm that will give a
specific number to every word).  Other stuff is pretty easy to 
find with
the book and on-line literature.  I will need to get an ascii code 
out of
 a string (whose content is not known to the programmer, as 
raw_input).

Then to assign, I will need the actual list with assigned numbers.
 
You will be giving me probably the only boost I will need!  I will be 
available later on,

if I want to take part in the ask/answer system here.
 
 
Thanks a lot,
 
Anthony
 
8:27 pm PST October 4th, 2008
 
 
_

Get more out of the Web. Learn 10 hidden secrets of Windows Live.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008 

  



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




No virus found in this incoming message.
Checked by AVG - http://www.avg.com Version: 8.0.173 / Virus Database: 
270.7.6/1710 - Release Date: 06/10/2008 9:23 AM


  



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