Re: [Tutor] help with running perl script that writes to a text file

2013-02-05 Thread Alan Gauld

On 05/02/13 23:44, 3n2 Solutions wrote:


I want to automate the following manual process from DOS promp:

c:/scripts/perl>perl fix.pl base.gtx >base.txt


Use a DOS batch file, that's what they are there for.

If you are not doing any other processing Python is inefficient and 
overkill for this task. Unless you just want to learn how to use Popen I 
suppose...




path="c:/scripts/perl/"
subprocess.call(['perl','fix.pl','base.gtx >base.txt',path])


Do you get any error messages on the console?
How are you running the python script?

--
Alan G
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] Getting range of a list

2013-02-05 Thread Alan Gauld

On 05/02/13 23:59, Hs Hs wrote:

Thanks Dave.

Sorry for html formatting. Honestly I don't know how to shut html
formatting off in Yahoo.


Create a new message.

Look at the bar just below the subject box, it has some tabs in it. At 
the extreme right end there is a button marked Switch to Plain Text...


HTH


--
Alan G
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] Getting range of a list

2013-02-05 Thread Hs Hs
Thanks Dave. 

Sorry for html formatting. Honestly I don't know how to shut html formatting 
off in Yahoo. I don't have options for send in 
('Tools|Options|''send''missing').
Will investigate. 
thanks
Hs




 From: Dave Angel 
To: tutor@python.org 
Sent: Tuesday, February 5, 2013 5:20 PM
Subject: Re: [Tutor] Getting range of a list
 
On 02/05/2013 04:48 PM, Hs Hs wrote:
> Thanks Steve.
>
> But one question, when I print, I get extra empty lines. How to get rid of 
> them!  Thanks again.
 f = open('test')
 head = '---'
 for line in f:

line = line.rstrip()     #get rid of the trailing newline (and any other 
whitespace there)

> if line.startswith('>'):
> head = line[1:].strip()
> else:
> print head+'\t'+line

The print generates a newline by default.  So you either have to do the 
strip() I suggested above, or use a trailing comma on the print.  I 
recommend the former.

>
> X1A
>                          <--
> X1G
>                         <-
> X2A
>
> X2G
>
> X3A
>
> X3G
>
> X4A
>
> X4A
>
> Thanks
> Hs.
>
>
>

You're still posting using html mail.  And your indentation is still 
getting messed up.  Also, you top-posted.


-- 
DaveA
___
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] help with running perl script that writes to a text file

2013-02-05 Thread 3n2 Solutions
Hello,

I want to automate the following manual process from DOS promp:

c:/scripts/perl>perl fix.pl base.gtx >base.txt

Here is my python script:

path="c:/scripts/perl/"
subprocess.call(['perl','fix.pl','base.gtx >base.txt',path])

I also tried this alternative:

subprocess.Popen(['perl','fix.pl','base.gtx >base.txt',path]) #same
result from this method.

The above script generates the base.txt file but has no content in it.

any ideas as to why the resulting text file is empty? Am I using the
correct python commands to run the above manual process?

I'm using python 2.7 on windows 7

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


Re: [Tutor] Getting range of a list

2013-02-05 Thread Dave Angel

On 02/05/2013 04:48 PM, Hs Hs wrote:

Thanks Steve.

But one question, when I print, I get extra empty lines. How to get rid of 
them!  Thanks again.

f = open('test')
head = '---'
for line in f:


line = line.rstrip() #get rid of the trailing newline (and any other 
whitespace there)



if line.startswith('>'):
head = line[1:].strip()
else:
print head+'\t'+line


The print generates a newline by default.  So you either have to do the 
strip() I suggested above, or use a trailing comma on the print.  I 
recommend the former.




X1A
 <--
X1G
<-
X2A

X2G

X3A

X3G

X4A

X4A

Thanks
Hs.





You're still posting using html mail.  And your indentation is still 
getting messed up.  Also, you top-posted.



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


Re: [Tutor] Getting range of a list

2013-02-05 Thread Hs Hs
Thanks Steve. 

But one question, when I print, I get extra empty lines. How to get rid of 
them!  Thanks again.
>>> f = open('test')
>>> head = '---'
>>> for line in f:
if line.startswith('>'):
head = line[1:].strip()
else:
print head+'\t'+line

X1A
                        <--
X1G
                       <-
X2A

X2G

X3A

X3G

X4A

X4A

Thanks
Hs.




 From: Steven D'Aprano 
To: tutor@python.org 
Sent: Tuesday, February 5, 2013 4:28 PM
Subject: Re: [Tutor] Getting range of a list
 
On 06/02/13 08:08, Hs Hs wrote:

> Here is what I do :
 f1 = open('test','r')
 da = f1.read().split('\n')
 dat = da[:-1]
 dat
 mpos = []
> 
 for i in range(len(dat)):
> if dat[i].startswith('>'):
> mpos.append(i)
> 
 mpos
> [0, 3, 6, 9]
> 
 for item in range(len(mpos)):
> start = mpos[item]
> enda = item+1
> end  = mpos[enda]-1
> head = dat[start]
> block  = dat[start+1:end]
> for i in block:
> print head+'\t'+i


You are thinking like a C programmer, not a Python programmer. You should 
almost never need to iterate over a range of numbers like this.

Instead, try something like this:

f = open('test')
head = ''
for line in f:
    if line.startswith('>'):
        head = line[1:].rstrip()  # remove trailing newline
    else:
        print head + '\t' + line

f.close()



In general, you should iterate over collections of data directly. For example:

# WRONG
for i in range(len(data)):
    x = data[i]
    print x

# RIGHT
for x in data:
    print x



# WRONG
for i in range(len(data)):
    x = data[i]
    if x == 'spam':
        data[i] = 'ham'

# RIGHT
for i, x in enumerate(data):
    if x == 'spam':
        data[i] = 'ham'



Hope this helps.



-- Steven
___
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


Re: [Tutor] Getting range of a list

2013-02-05 Thread Dave Angel

On 02/05/2013 04:08 PM, Hs Hs wrote:





First comment:  do NOT post in html, as it frequently messes up 
indenting.  Send your email in text mode, as this is a text mailing list.


Compounding that, you apparently are running inside some shell program 
(pyshell ?) which is doing a further mess.  But even if you were running 
under the real interpreter, once you've got doubly nested loops, it gets 
really hard to read.



Dear List members:

I always have problem in getting ranges:

Following is my representation of part of my file.


X1

A
G
C
G

X2

A
G

X3

A
G

X4

H
T


I want to print the above contents in the following way:

X1 \t A
X1 \t G
X1 \t C
X1 \t G
X2 \t A
X2 \t G
X3 \t A
X3 \t G
X4 \t H
X4 \t H


Here is what I do

f1 = open('test','r')
da = f1.read().split('\n')


Why not just use readlines() ?  That's what it's for.


dat = da[:-1]
dat


Your shell forgot to display dat here.


mpos = []



for i in range(len(dat)):

if dat[i].startswith('>'):
mpos.append(i)


mpos

[0, 3, 6, 9]


for item in range(len(mpos)):

start = mpos[item]
enda = item+1
end  = mpos[enda]-1


What is this line intended to do?   enda is too big, so why are you 
surprised it will throw an exception last time through?



head = dat[start]
block  = dat[start+1:end]
for i in block:
print head+'\t'+i


X1A
X2A
X3A


Traceback (most recent call last):
   File "", line 4, in 
 end  = mpos[enda]-1
IndexError: list index out of range





By the time I am looping through last item, I do not have anything to take 1 
from and thus end up with that indexerror.

Could anyone please help me how to get a good habit of making this work.  This 
is a very wrong and bad habit.

thank you for your help in advance.

Hs.


Your mpos list is an index of starting points for records in the dat 
array.  But you're using it also as ending points, and you're missing 
the last one.  The usual way to fix this is to append one more entry to 
mpos, that points just beyond the end of the list dat

   mpos.append(len(dat))

Once you do that,you'll have to change your next for-loop, so it uses 
the original length, perhaps like:

   for item in range(len(mpos))-1:

That should get you closer to working.

However, this whole program feels like it was transliterated from BASIC 
or maybe C.  Any time you have to range(len(...  as the list for a for 
loop, something's probably wrong.  The entire program could be done much 
more elegantly.  And now I can see Steven has posted such an improvement.






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


Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-05 Thread Steven D'Aprano

On 05/02/13 22:27, Oscar Benjamin wrote:

On 5 February 2013 03:56, eryksun  wrote:

On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel  wrote:

Nope, in both Python 2 and 3 iterating over a dict directly just
provides the key. That's also how "if key in dict" works.


A dict implements __contains__ for an efficient "in" test. In general,
the interpreter falls back to using iteration if a type lacks
__contains__.


I almost wrote this response but then I realised that Dave probably
meant that "obj in dict" returns True if the dict has a key equal to
obj rather than if the dict has a (key, value) pair equal to obj.



It was actually me, not Dave, and yes, that's what I meant. I didn't mean
that dict containment tests were literally implemented by iterating over
the keys checking each one in turn, since that would be horribly
inefficient for something so critical as a dict. Although I can see why
eryksun may have thought so, sorry for any confusion caused by my poor
wording.

Although note that Python does fallback on iteration for containment if
you don't define a __contains__ method:


py> class Test(object):
... def __getitem__(self, n):
... if n >= 5: raise IndexError
... return n + 100
...
py> t = Test()
py> 3 in t
False
py> 103 in t
True



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


Re: [Tutor] Getting range of a list

2013-02-05 Thread Steven D'Aprano

On 06/02/13 08:08, Hs Hs wrote:


Here is what I do :

f1 = open('test','r')
da = f1.read().split('\n')
dat = da[:-1]
dat
mpos = []



for i in range(len(dat)):

if dat[i].startswith('>'):
mpos.append(i)


mpos

[0, 3, 6, 9]


for item in range(len(mpos)):

start = mpos[item]
enda = item+1
end  = mpos[enda]-1
head = dat[start]
block  = dat[start+1:end]
for i in block:
print head+'\t'+i



You are thinking like a C programmer, not a Python programmer. You should 
almost never need to iterate over a range of numbers like this.

Instead, try something like this:

f = open('test')
head = ''
for line in f:
if line.startswith('>'):
head = line[1:].rstrip()  # remove trailing newline
else:
print head + '\t' + line

f.close()



In general, you should iterate over collections of data directly. For example:

# WRONG
for i in range(len(data)):
x = data[i]
print x

# RIGHT
for x in data:
print x



# WRONG
for i in range(len(data)):
x = data[i]
if x == 'spam':
data[i] = 'ham'

# RIGHT
for i, x in enumerate(data):
if x == 'spam':
data[i] = 'ham'



Hope this helps.



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


[Tutor] Getting range of a list

2013-02-05 Thread Hs Hs


Dear List members:

I always have problem in getting ranges:

Following is my representation of part of my file.

>X1
A
G
C
G
>X2
A
G
>X3
A
G
>X4
H
T


I want to print the above contents in the following way:

X1 \t A
X1 \t G
X1 \t C
X1 \t G
X2 \t A
X2 \t G
X3 \t A
X3 \t G
X4 \t H
X4 \t H


Here is what I do :
>>> f1 = open('test','r')
>>> da = f1.read().split('\n')
>>> dat = da[:-1]
>>> dat
>>> mpos = []

>>> for i in range(len(dat)):
if dat[i].startswith('>'):
mpos.append(i)

>>> mpos
[0, 3, 6, 9]

>>> for item in range(len(mpos)):
start = mpos[item]
enda = item+1
end  = mpos[enda]-1
head = dat[start]
block  = dat[start+1:end]
for i in block:
print head+'\t'+i

>X1A
>X2A
>X3A

Traceback (most recent call last):
  File "", line 4, in 
    end  = mpos[enda]-1
IndexError: list index out of range
>>> 


By the time I am looping through last item, I do not have anything to take 1 
from and thus end up with that indexerror. 

Could anyone please help me how to get a good habit of making this work.  This 
is a very wrong and bad habit. 

thank you for your help in advance. 

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


Re: [Tutor] How to create a GUI for python using tkinter

2013-02-05 Thread Alan Gauld

On 05/02/13 09:38, Aaron Misquith wrote:


2.Is there a way to automate getting access tokens for the user that is
logging in? If not how to get access tokens for each user while logging in?


No idea, you'll need to ask on a Facebook programming list. This one 
only deals with Python programming issues.



3.How to dislpay text with clickable links.
Eg: Something thing like alert box, wherein if you click the link
you go to the page.


Presumably you need to construct a URL. I'm not sure where you want 
these links but if its in the PDF you'll need to find out how PDFs do 
URLs... Find one and open it, or look at Reportlab again.



4. Finally my lecturer has asked me to create a gui for the facebook
login program using tkinter library module. I don't know how to create
one


Then read the tutorials online. You can start with the GUI topic in my 
tutoroial, then go to the TKinter section of the Python web site. There 
are at least 2 other excellent tkinter reference sites and the Tcl/Tk 
pages have a lot of good detail too.



HTH
--
Alan G
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- Regarding python

2013-02-05 Thread Oscar Benjamin
On 5 February 2013 05:08, eryksun  wrote:
> On Mon, Feb 4, 2013 at 7:21 PM, Oscar Benjamin
>  wrote:
>> eigenvalues, eigenvectors = np.linalg.eig(C)
>
> First sort by eigenvalue magnitude:
>
> >>> idx = np.argsort(eigenvalues)[::-1]
> >>> print idx
> [ 0  1  2  3  8 10 11 12 14 22 20 21 18 19 23 24 17 16 15 13  9  7  5  6  
> 4]
>
> >>> eigenvalues = eigenvalues[idx]
> >>> eigenvectors = eigenvectors[:, idx]
>
>> # 2D PCA - get the two eigenvectors with the largest eigenvalues
>> v1, v2 = eigenvectors[:,:2].T

Thanks. I thought that eig already sorted them. The doc claims says
that the values are "not necessarily ordered" but when I run it they
are in descending order of absolute value.

Also I should have used eigh since the covariance matrix is Hermitian
(eigh seems to give the eigenvalues in ascending order).


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


Re: [Tutor] How to create a GUI for python using tkinter

2013-02-05 Thread Walter Prins
Hi


 On 5 February 2013 09:38, Aaron Misquith  wrote:
>>
>>> I have attached a python program with this mail which peforms following
>>> operations:
>>> 1.Logs in to facebook.
>>> 2.Asks the user for access tokens.
>>> 3.Gets the friend list of the user.
>>> 4.outputs the friend list as pdf.
>>>
>>> My Problems regarding the above program are:
>>> 1.I want to display the names of my friends(in output) one in each line
>>> in the intermediate .doc file that i have created.
>>>   example output: {'data': [{'name': 'Roy Fernandes'},
>>> {'name': 'Aniruddh Beigh'},
>>>I want it to be displayed as :
>>> Roy Fernandes
>>>
>>> Aniruddh Beigh
>>>
>>> 2.Is there a way to automate getting access tokens for the user that is
>>> logging in? If not how to get access tokens for each user while logging in?
>>>
>>> 3.How to dislpay text with clickable links.
>>>Eg: Something thing like alert box, wherein if you click the link you
>>> go to the page.
>>>
>>> 4. Finally my lecturer has asked me to create a gui for the facebook
>>> login program using tkinter library module. I don't know how to create one
>>> (the lecturer has not thought this topic in class so i'm just clueless
>>> here). So if someone can do it and explain me the steps it will be very
>>> helpfull.
>>
>>
>> The way this tutoring mailing list (and in general, any programming
>> mailing list or support forum) works is that you do the legwork first, then
>> come with the actual problems you're having.  You don't just ask for people
>> to write your solutions for you.
>>
>> Also, your questions together with a partial solution by (apparently)
>> someone else makes me wonder whether this is homework.  Can you please
>> clarify?  Obviously, apart from the above comment on this not being a
>> solution service, we cannot provide direct solutions to homework
>> assignments.
>>
>> All that said, to address your questions somewhat:
>> 1.) The program is directly printing the returned Python dict object
>> (e.g. nik) which is why you're getting the curly-braced representation of
>> it.  To print/output it differently, take some more control over the
>> printing process.  E.g. print the attributes of the nik object manually and
>> use newline characters (\n) where required.  If you don't understand this
>> answer then you're lacking some basic Python skills/understanding and I'd
>> recommend learning some basic Python first, perhaps by working through Alan
>> Gauld's tutorial: http://www.alan-g.me.uk/tutor/index.htm
>> Then try your hand at this problem again yourself, and *then* post back
>> with specific problems you're having.
>>
>> 2.) Probably, but I don't offhand know how.  This is not really a Python
>> tutoring question and may be a question for appropriate for a Facebook API
>> programming forum.
>>
>> 3.) There's lots of TkInter materials on the web that will get you
>> started.  Here's a decent tutorial:
>> http://www.tkdocs.com/tutorial/index.html
>>
>
> First of all i would like to confirm that this was my assignment and i
> have completed it and shown to my lecturer. I'll also confirm that the
> class facebook was available in stackoverflow( Not completely, I had to
> make some changes to suit my requirements).But the rest is all mine
> especially exporting the output as pdf. None of the forums were helpful
> regarding this.
>

Making simple PDF's is almost trivial with Python.  The following example
is from http://is.gd/ol6bhn (a ReportLab tutorial that was turned up with
the google search "python reportlab example"):

from reportlab.pdfgen import canvas

c = canvas.Canvas("hello.pdf")
c.drawString(100,750,"Welcome to Reportlab!")
c.save()



> Everywhere people have mentioned about pypdf and reportlab toolkit , but
> none of them worked for me (i have also posted the solution on
> stackoverflow yesterday).
>

What did you try and what problems or errors did you run into? What did you
want to happen instead?


The problem that i encounter in creating GUI is I already have a class *
> facebook*; How am i supposed to integrate it to class "*Application*"(required
> to create GUI with tkinter)  which i have to integrate it with (the small
> bookish knowledge i possess in the topic).
>

Put your Facebook class in it's own module.  Then import that module from
your GUI application module (or from whatever module needs to use it) and
create an instance of the Facebook class where you need it.

Seriously, work through a Python programming tutorial, and then a TkInter
one.   You wouldn't be asking these questions if you had a proper grounding
in programming concepts in general and Python.  However it's not feasible
to address that piecemeal style via a mailing list exchange here.

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


[Tutor] Fwd: How to create a GUI for python using tkinter

2013-02-05 Thread Walter Prins
Forwarding (presumed accidental) personal reply back to list.

-- Forwarded message --
From: Aaron Misquith 
Date: 5 February 2013 13:01
Subject: Re: [Tutor] How to create a GUI for python using tkinter
To: Walter Prins 



On Tue, Feb 5, 2013 at 5:40 PM, Walter Prins  wrote:

> On 5 February 2013 09:38, Aaron Misquith  wrote:
>
>> I have attached a python program with this mail which peforms following
>> operations:
>> 1.Logs in to facebook.
>> 2.Asks the user for access tokens.
>> 3.Gets the friend list of the user.
>> 4.outputs the friend list as pdf.
>>
>> My Problems regarding the above program are:
>> 1.I want to display the names of my friends(in output) one in each line
>> in the intermediate .doc file that i have created.
>>   example output: {'data': [{'name': 'Roy Fernandes'},
>> {'name': 'Aniruddh Beigh'},
>>I want it to be displayed as : Roy
>> Fernandes
>>
>> Aniruddh Beigh
>>
>> 2.Is there a way to automate getting access tokens for the user that is
>> logging in? If not how to get access tokens for each user while logging in?
>>
>> 3.How to dislpay text with clickable links.
>>Eg: Something thing like alert box, wherein if you click the link you
>> go to the page.
>>
>> 4. Finally my lecturer has asked me to create a gui for the facebook
>> login program using tkinter library module. I don't know how to create one
>> (the lecturer has not thought this topic in class so i'm just clueless
>> here). So if someone can do it and explain me the steps it will be very
>> helpfull.
>
>
> The way this tutoring mailing list (and in general, any programming
> mailing list or support forum) works is that you do the legwork first, then
> come with the actual problems you're having.  You don't just ask for people
> to write your solutions for you.
>
> Also, your questions together with a partial solution by (apparently)
> someone else makes me wonder whether this is homework.  Can you please
> clarify?  Obviously, apart from the above comment on this not being a
> solution service, we cannot provide direct solutions to homework
> assignments.
>
> All that said, to address your questions somewhat:
> 1.) The program is directly printing the returned Python dict object (e.g.
> nik) which is why you're getting the curly-braced representation of it.  To
> print/output it differently, take some more control over the printing
> process.  E.g. print the attributes of the nik object manually and use
> newline characters (\n) where required.  If you don't understand this
> answer then you're lacking some basic Python skills/understanding and I'd
> recommend learning some basic Python first, perhaps by working through Alan
> Gauld's tutorial: http://www.alan-g.me.uk/tutor/index.htm
> Then try your hand at this problem again yourself, and *then* post back
> with specific problems you're having.
>
> 2.) Probably, but I don't offhand know how.  This is not really a Python
> tutoring question and may be a question for appropriate for a Facebook API
> programming forum.
>
> 3.) There's lots of TkInter materials on the web that will get you
> started.  Here's a decent tutorial:
> http://www.tkdocs.com/tutorial/index.html
>

First of all i would like to confirm that this was my assignment and i have
completed it and shown to my lecturer. I'll also confirm that the class
facebook was available in stackoverflow( Not completely, I had to make some
changes to suit my requirements).But the rest is all mine especially
exporting the output as pdf. None of the forums were helpful regarding
this. Everywhere people have mentioned about pypdf and reportlab toolkit ,
but none of them worked for me (i have also posted the solution on
stackoverflow yesterday). After showing the output my lecturer informed me
if i could Display better  using tkinter GUI. Since it wasn't thought in
class I have no idea regarding this. The problem that i encounter in
creating GUI is I already have a class *facebook*; How am i supposed to
integrate it to class "*Application*"(required to create GUI with tkinter)
which i have to integrate it with (the small bookish knowledge i possess in
the topic).

I don't expect direct solutions but if you do give them i want possible *
explanations* on it so i can understand how it was done. And since this is
a tutor i want someone who knows the answers to teach me; since you cant
study everything in class.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] nose, git, post-commit hook

2013-02-05 Thread Albert-Jan Roskam


> On 4 February 2013 15:32, Albert-Jan Roskam  wrote:
>> I am using git VCS and I read about the possibility to use post-commit 
> hooks for nose tests. That sounds pretty cool, but does this also have 
> disadvantages?
>> It would be very annoying if I couldn't check in code, safely tucked 
> away on some server, that is not yet working. Is there also a way to by-pass 
> the 
> 'mandatory' tests?
> 
> This isn't really a Python question, but if you use pre-commit hooks,
> you can bypass them with the "--no-verify" option to "git 
> commit". See
> http://git-scm.com/book/en/Customizing-Git-Git-Hooks.

Hi Rob,

Thanks for this useful link. I'll see what's most practical for me. As usual, 
the number of options of git is bedazzlingly large.
I dared to ask this question on the Python list because I am planning to use 
this in conjunction with the nose package.
I figured that this package (or something of python) *may* have some other 
functionality that ensures that tests are automatically 
run on a regular basis. It would be ideal if it could be combined with other 
tasks (I have pylint or pep8 in mind). Commit hooks appear
to be a good method.

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


Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-05 Thread eryksun
On Tue, Feb 5, 2013 at 6:27 AM, Oscar Benjamin
 wrote:
>
> I almost wrote this response but then I realised that Dave probably
> meant that "obj in dict" returns True if the dict has a key equal to
> obj rather than if the dict has a (key, value) pair equal to obj.

Thanks, that's probably what Steven meant. It's keeping "item in
a_dict" consistent with "item in list(a_dict)".
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-05 Thread Oscar Benjamin
On 5 February 2013 03:56, eryksun  wrote:
> On Mon, Feb 4, 2013 at 7:04 PM, Dave Angel  wrote:
>>> Nope, in both Python 2 and 3 iterating over a dict directly just
>>> provides the key. That's also how "if key in dict" works.
>
> A dict implements __contains__ for an efficient "in" test. In general,
> the interpreter falls back to using iteration if a type lacks
> __contains__.

I almost wrote this response but then I realised that Dave probably
meant that "obj in dict" returns True if the dict has a key equal to
obj rather than if the dict has a (key, value) pair equal to obj.


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


[Tutor] How to create a GUI for python using tkinter

2013-02-05 Thread Aaron Misquith
I have attached a python program with this mail which peforms following
operations:
1.Logs in to facebook.
2.Asks the user for access tokens.
3.Gets the friend list of the user.
4.outputs the friend list as pdf.

My Problems regarding the above program are:
1.I want to display the names of my friends(in output) one in each line in
the intermediate .doc file that i have created.
  example output: {'data': [{'name': 'Roy Fernandes'}, {'name':
'Aniruddh Beigh'},
   I want it to be displayed as : Roy
Fernandes

Aniruddh Beigh

2.Is there a way to automate getting access tokens for the user that is
logging in? If not how to get access tokens for each user while logging in?

3.How to dislpay text with clickable links.
   Eg: Something thing like alert box, wherein if you click the link you go
to the page.

4. Finally my lecturer has asked me to create a gui for the facebook login
program using tkinter library module. I don't know how to create one (the
lecturer has not thought this topic in class so i'm just clueless here). So
if someone can do it and explain me the steps it will be very helpfull.


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