Re: Python Programming - 28 hours training in New York for $3999

2013-01-28 Thread Dave Angel

On 01/26/2013 06:57 PM, Chris Angelico wrote:

On Sun, Jan 27, 2013 at 3:38 AM, Juhani Karlsson
 wrote:

Or take this course for free and buy 500 lunches.
Your choice.


You spend $8 on lunch? Wow, that's taking TANSTAAFL a long way...

ChrisA



MYCROFTXXX

I remember when lunches at IBM were never more than $1

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


Re: Algorithm. Tony Gaddis book 2 Starting python3

2013-01-28 Thread Gene Heskett
On Sunday 27 January 2013 13:05:27 [email protected] did opine:
Message additions Copyright Sunday 27 January 2013 by Gene Heskett

> Hi
> Question 3 Chp2 Page 76
> Adds2 to a and assigns the result to b.
> I have several attemtps,would like to check my answer.help please
> At 80 i need all the help i can find.
> Thanks George Smart


Darn, I've just been dethroned from my resident oldest fart on this list 
throne, I'm only 78.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
My web page:  is up!
My views 

Thyme's Law:
Everything goes wrong at once.
I was taught to respect my elders, but its getting 
harder and harder to find any...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need Pattern For Logging Into A Website

2013-01-28 Thread Jan Wąsak
On Friday, January 25, 2013 2:29:51 AM UTC+1, Tim Daneliuk wrote:
> I need to write a Python script to do the following:
> 
> 
> 
>- Connect to a URL and accept any certificate - self-signed or 
> authoritative
> 
>- Provide login name/password credentials
> 
>- Fill in some presented fields
> 
>- Hit a "Submit" button
> 
> 
> 
> Why?  Because I don't want to have to start a browser and do this
> 
> interactively every time I authenticate with a particular server.
> 
> I want to do this at the command line with no interactive intervention.
> 
> 
> 
> I know Python pretty well.  I don't quite know how to do this and
> 
> was hoping someone had a simple pattern they could share for
> 
> doing this.
> 
> 
> 
> TIA,
> 

Hello Tim,

I think you may also want to take a look at python requests.
http://docs.python-requests.org/en/latest/user/advanced/

>From my experience they do a much nicer job than urllib and anything I've 
>tried.
You will probably get what you want out of them easily and in no time.

-- 
cheers,
john
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Formatting a column's value output

2013-01-28 Thread Κώστας Παπαδόπουλος
Τη Κυριακή, 27 Ιανουαρίου 2013 10:50:33 μ.μ. UTC+2, ο χρήστης Mitya Sirenef 
έγραψε:
> On 01/27/2013 03:24 PM, οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ 
> οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ wrote:
> 
> > οΏ½οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½, 27 οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ 2013  
> > 9:12:16 οΏ½.οΏ½. UTC+2, οΏ½ οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½ [email protected] 
> > οΏ½οΏ½οΏ½οΏ½οΏ½οΏ½:
> 
>  >> 
> 
>  >
> 
>  > Yes indeed, there is no need to use a loop since i know the exact 
> 
> number of items i'am expecting. Thanks you very much for clarifying this 
> 
> to me:
> 
>  > One last thing i want to ask you:
> 
>  >
> 
>  > 
> 
>  > try:
> 
>  > cur.execute( '''SELECT host, userOS, browser, hits, lastvisit FROM 
> 
> visitors
> 
>  > WHERE counterID = (SELECT ID FROM counters WHERE URL = %s) ORDER BY 
> 
> lastvisit DESC''', (htmlpage,) )
> 
>  > except MySQLdb.Error, e:
> 
>  > print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
>  > else:
> 
>  > data = cur.fetchall()
> 
>  >
> 
>  > for host, useros, browser, hits, lastvisit in data:
> 
>  > print ( "" )
> 
>  >
> 
>  > for item in host, useros, browser, hits, lastvisit.strftime('%A %e 
> 
> %b, %H:%M').decode('cp1253').encode('utf8'):
> 
>  > print ( " %s " % item )
> 
>  >
> 
>  > sys.exit(0)
> 
>  > ===
> 
>  >
> 
>  > That would be also written as:
> 
>  >
> 
>  > for row in data:
> 
>  > print ("tr>")
> 
>  > for item in row:
> 
>  > print( "blah blah blah" )
> 
>  >
> 
>  > And that would make the code easier to read and more clear, but its 
> 
> that 'lastvisit' column's value than needs formating,hence it makes me 
> 
> use the above syntax.
> 
>  >
> 
>  > Is there any simpler way to write the above working code without the 
> 
> need to specify all of the columns' names into the loop?
> 
> 
> 
> 
> 
> You can write:
> 
> 
> 
>   for row in data:
> 
>   print ("tr>")
> 
>   row = list(row)
> 
>   row[-1] = row[-1].strftime(...)
> 
>   for item in row:
> 
>   print( "blah blah blah" )
> 
> 
> 
> 
> 
>   - mitya
> 
> 
> 
> 
> 
> -- 
> 
> Lark's Tongue Guide to Python: http://lightbird.net/larks/
> 
> 
> 
> The existence of any evil anywhere at any time absolutely ruins a total
> 
> optimism.  George Santayana


Thank you very much, your solution makes the code looks so much clearer!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Formatting a column's value output

2013-01-28 Thread Κώστας Παπαδόπουλος
Τη Δευτέρα, 28 Ιανουαρίου 2013 12:27:12 π.μ. UTC+2, ο χρήστης [email protected] 
έγραψε:
> On 01/27/2013 01:50 PM, Mitya Sirenef wrote:
> 
> > On 01/27/2013 03:24 PM, Κώστας Παπαδόπουλος wrote:
> 
> >> Τη Κυριακή, 27 Ιανουαρίου 2013  9:12:16 μ.μ. UTC+2, ο χρήστης 
> >> [email protected] έγραψε:
> 
> >  >> 
> 
> >  >
> 
> >  > Yes indeed, there is no need to use a loop since i know the exact 
> 
> > number of items i'am expecting. Thanks you very much for clarifying this 
> 
> > to me:
> 
> >  > One last thing i want to ask you:
> 
> >  >
> 
> >  > 
> 
> >  > try:
> 
> >  > cur.execute( '''SELECT host, userOS, browser, hits, lastvisit FROM 
> 
> > visitors
> 
> >  > WHERE counterID = (SELECT ID FROM counters WHERE URL = %s) ORDER BY 
> 
> > lastvisit DESC''', (htmlpage,) )
> 
> >  > except MySQLdb.Error, e:
> 
> >  > print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> 
> >  > else:
> 
> >  > data = cur.fetchall()
> 
> >  >
> 
> >  > for host, useros, browser, hits, lastvisit in data:
> 
> >  > print ( "" )
> 
> >  >
> 
> >  > for item in host, useros, browser, hits, lastvisit.strftime('%A %e 
> 
> > %b, %H:%M').decode('cp1253').encode('utf8'):
> 
> >  > print ( " %s " % item )
> 
> >  >
> 
> >  > sys.exit(0)
> 
> >  > ===
> 
> >  >
> 
> >  > That would be also written as:
> 
> >  >
> 
> >  > for row in data:
> 
> >  > print ("tr>")
> 
> >  > for item in row:
> 
> >  > print( "blah blah blah" )
> 
> >  >
> 
> >  > And that would make the code easier to read and more clear, but its 
> 
> > that 'lastvisit' column's value than needs formating,hence it makes me 
> 
> > use the above syntax.
> 
> >  >
> 
> >  > Is there any simpler way to write the above working code without the 
> 
> > need to specify all of the columns' names into the loop?
> 
> > 
> 
> > 
> 
> > You can write:
> 
> > 
> 
> >   for row in data:
> 
> >   print ("tr>")
> 
> >   row = list(row)
> 
> >   row[-1] = row[-1].strftime(...)
> 
> >   for item in row:
> 
> >   print( "blah blah blah" )
> 
> 
> 
> Or alternatively, 
> 
> 
> 
> for row in data:
> 
> print ("tr>")
> 
> for item_num, item in enumerate (row):
> 
> if item_num != len(row) - 1:
> 
> print( "blah blah blah" )
> 
> else:
> 
> print( item.strftime(...) )
> 
> 
> 
> Or, being a little clearer, 
> 
> 
> 
> LASTVISIT_POS = 4
> 
> for row in data:
> 
> print ("tr>")
> 
> for item_num, item in enumerate (row):
> 
> if item_num != LASTVISIT_POS:
> 
> print( "blah blah blah" )
> 
> else:
> 
> print( item.strftime(...) )

Thank you very much, your alternatives are great but i think i'll use Mity'as 
solution, its more easy to me. Thank you very much!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [SPAM] Fonts & Tinker

2013-01-28 Thread Łukasz Posadowski

Dnia 2013-01-25, pią o godzinie 20:41 -0800, Angel pisze:
> but the real displayed fonts in the window are smaller (default size of 12, 
> maybe).
> 
> Am I missing something?
> 
> Thanks in advance,
> A.
> 

Did you tried this by simple:

---
root = Tk()
root.option_add('*Font', "Heveltica 14")
---

We'll see if it's a local tkinter installation problem.



-- 
Łukasz Posadowski



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


Reading file issue

2013-01-28 Thread loial
I am parseing a file to extract data, but am seeing the file being updated even 
though I never explicitly write to the file. It is possible that another 
process is doing this at some later time, but I just want to check that opening 
the file as follows and ignoring a record would not result in that record being 
removed from the file.

I'm damned sure it wouldn't, but just wanted to check with the experts!.


for line in open("/home/john/myfile"):
linecount = linecount + 1

if linecount == 1:  # ignore header
continue


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


Re: Reading file issue

2013-01-28 Thread Chris Angelico
On Mon, Jan 28, 2013 at 10:47 PM, loial  wrote:
> I am parseing a file to extract data, but am seeing the file being updated 
> even though I never explicitly write to the file. It is possible that another 
> process is doing this at some later time, but I just want to check that 
> opening the file as follows and ignoring a record would not result in that 
> record being removed from the file.
>
> I'm damned sure it wouldn't, but just wanted to check with the experts!.
>
> for line in open("/home/john/myfile"):

Absolutely not. You're opening the file (by default) for reading only.
That's not going to edit the file in any way. (It might cause the
directory entry to be rewritten, eg last-access time, but not the file
contents.) Your expectation is 100% correct.

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


Re: Reading file issue

2013-01-28 Thread loial
Thanks for confirming my sanity



On Monday, 28 January 2013 11:57:43 UTC, Chris Angelico wrote:
> On Mon, Jan 28, 2013 at 10:47 PM, loial  wrote: > I am 
> parseing a file to extract data, but am seeing the file being updated even 
> though I never explicitly write to the file. It is possible that another 
> process is doing this at some later time, but I just want to check that 
> opening the file as follows and ignoring a record would not result in that 
> record being removed from the file. > > I'm damned sure it wouldn't, but just 
> wanted to check with the experts!. > > for line in open("/home/john/myfile"): 
> Absolutely not. You're opening the file (by default) for reading only. That's 
> not going to edit the file in any way. (It might cause the directory entry to 
> be rewritten, eg last-access time, but not the file contents.) Your 
> expectation is 100% correct. ChrisA

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


Re: Reading file issue

2013-01-28 Thread Oscar Benjamin
On 28 January 2013 11:47, loial  wrote:
> I am parseing a file to extract data, but am seeing the file being updated 
> even though I never explicitly write to the file. It is possible that another 
> process is doing this at some later time, but I just want to check that 
> opening the file as follows and ignoring a record would not result in that 
> record being removed from the file.
>
> I'm damned sure it wouldn't, but just wanted to check with the experts!.
>
>
> for line in open("/home/john/myfile"):

The line above opens the file in read-only mode. It's not possible to
make changes to the file if you only open it in read-only mode. So no
this code is not modifying the file. It is, however, slightly better
to write the above as

with open('/home/john/myfile') as fin:
for line in fin:
# stuff

This is better as the "with" statement handles errors better than just
calling open directly.

> linecount = linecount + 1
>
> if linecount == 1:  # ignore header
> continue

Another way of achieving this would be to do:

headerline = fin.readline()
for line in fin:
# No need to worry about that header line now


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


Re: Reading file issue

2013-01-28 Thread Tim Chase
On Mon, 28 Jan 2013 03:47:07 -0800 (PST) loial 
wrote:

> I am parseing a file to extract data, but am seeing the file being
> updated even though I never explicitly write to the file. It is
> possible that another process is doing this at some later time, but
> I just want to check that opening the file as follows and ignoring
> a record would not result in that record being removed from the
> file.

The only complication I'd see would be the reader bombing out because
the writer process is in the middle of writing.  A quick test on
WinXP showed that it's possible to continue to write to a file that
another process has open for reading (this shouldn't be an issue on
POSIX OSes; Win32 can be a bit more fascist about sharing files,
especially if they're both open for writing). However, that doesn't
alter the data written, so all it takes is just re-running the reader
process.

-tkc


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


Hello All

2013-01-28 Thread Huey Mataruse
I have been learning Python on my own and its been 1yr now and i still feel i 
dont know anything, is there a way that i can use to increase my way of 
learning. 
I feel there is more that i can do with python that other languages cannot.

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


Re: Hello All

2013-01-28 Thread Dave Angel

On 01/28/2013 07:34 AM, Huey Mataruse wrote:

I have been learning Python on my own and its been 1yr now and i still feel i 
dont know anything, is there a way that i can use to increase my way of 
learning.
I feel there is more that i can do with python that other languages cannot.

Please help.



Welcome to Python.

Nothing wrong with learning Python on your own, but if you feel you 
haven't made much progress in a year, perhaps your approach is 
inadequate, or perhaps you need more discipline in applying it.  Or 
maybe you actually know more than your realize.  If you could be 
specific in some concept that escapes you, maybe we could give some 
specific help.


First, your background.  Are you fluent in any other languages?  Have 
you any college training in any particular computer skills?  Do you use 
them in your work, or what?


Next, what have you been doing to actually try to learn?  Have you 
worked through a tutorial, and I mean really worked through it, writing 
programs for every exercise, not just read it, and hoped it'd stick?  If 
so, which tutorial?


Finally, what version of Python are you learning, and on what OS can you 
play?  Do you actually have it installed, or is this book learning?  Do 
you work in an environment where you could write an occasional utility 
in your own choice of language?  Or does it all need to be on your own time?


[email protected] is generally better suited for beginner's questions 
than python-list.  But since you're already here...


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


Arpex Capital Seleciona: Desenvolvedor Python/Django Sênior – RJ

2013-01-28 Thread zughumancapital

Arpex Capital seleciona para uma de suas startups: 

Desenvolvedor Python/Django Sênior

Estamos em busca daqueles(as) que: acham que meritocracia é indispensável, 
programam desde a infância, possuem sede por aprender e programar e querem 
trabalhar muito para fazer algo especial! 

O desenvolvedor estará envolvido em um projeto Python/Django para uma das 
startups da ArpexCapital (fundo de investimentos americano com foco no mercado 
brasileiro).  

Skills necessários:
Python, HTML, MySQL

Skills desejáveis (bônus):
Framework Django, Javascript, Linux, Scrum ou XP 

Local de Trabalho: Centro/RJ
Os interessados deverão enviar o CV com pretensão salarial para 
[email protected], mencionando no assunto Desenvolvedor Python/Django 
Sênior.  


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


software app and Python: any experience?

2013-01-28 Thread mikprog

Hi guys,

I am thinking of driving a DJ application from Python.
I am running Linux and I found the Mixxx app.
Does anyone know if there are python bindings, or if this is possible at all?
or does anyone have experience with another software that does the same DJ 
thing?

I have also found the pymixxx module that I could install... but I didn't find 
any documentation so far or example code that could help me start (I'm keeping 
on searching).

Finally maybe that there is any DJ app that could be driven by pygame.midi?

Any idea appreciated.
Sorry to fail to be more specific.

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


Reading data from 2 different files and writing to a single file

2013-01-28 Thread inshu chauhan
In the code below I am trying to read 2 files f1 and f2 , extract some data
from them and then trying to write them into a single file that is 'nf'.

import cv
f1 = open(r"Z:\modules\Feature_Vectors_300.arff")
f2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")
nf = open(r"Z:\modules\trial.arff", "w")


for l in f1:
sp = l.split(",")

if len(sp)!= 12:
continue
else:
ix = sp[0].strip()
iy = sp[1].strip()
print ix, iy

   for s in f2:
st = s.split(",")

if len(st)!= 11:
continue
else:
clas = st[10].strip()

 print ix, iy, clas
 print >> nf, ix, iy, clas

f1.close()
f2.close()
nf.close()


I think my code is not so correct , as I am not getting desired results and
logically it follows also but I am stuck , cannot find a way around this
simple problem of writing to a same file.. Please suggest some good
pythonic way I can do it..


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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 12:31 AM, inshu chauhan  wrote:
> I think my code is not so correct , as I am not getting desired results...

Firstly, what results are you getting, and what are you desiring? It
helps to be clear with that.

> import cv

What module is this? Do you need it? Does it affect things? It's not a
Python standard library module, as far as I know.

> for l in f1:
> else:
> print ix, iy
>for s in f2:

This will bomb immediately with an IndentationError. I can't be sure
whether you intended for the loops to be nested or not. One of the
consequences of Python's use of indentation to define blocks is that
you have to be really careful when you copy and paste. (Which bit me
somewhat this weekend; I tried to share some Python code via a
spreadsheet, and it mangled the leading whitespace. Very tiresome.)
Can you try pasting in your actual code, please?

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Jean-Michel Pichavant
- Original Message -
> 
> - Original Message -
> 
> > In the code below I am trying to read 2 files f1 and f2 , extract
> > some data from them and then trying to write them into a single
> > file
> > that is 'nf'.
> 
> [snip code]
> 
> > I think my code is not so correct , as I am not getting desired
> > results and logically it follows also but I am stuck , cannot find
> > a
> > way around this simple problem of writing to a same file.. Please
> > suggest some good pythonic way I can do it..
> 
> > Thanks in Advance
> 
> Hi,
> 
> What result do you expect ? can you provide the 2 first lines of f1
> and f2, and finally what is the exact error you are experiencing ?
> 
> Cheers,
> 
> JM

Resending to the list, I replied to the OP by mistake.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-ideas] while conditional in list comprehension ??

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 12:33 AM, Wolfgang Maier
 wrote:
> Why not extend this filtering by allowing a while statement in addition to
> if, as in:
>
> [n for n in range(1,1000) while n < 400]

The time machine strikes again! Check out itertools.takewhile - it can
do pretty much that:

import itertools
[n for n in itertools.takewhile(lambda n: n<400, range(1,1000))]

It's not quite list comp notation, but it works.

>>> [n for n in itertools.takewhile(lambda n: n<40, range(1,100))]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39]

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


Re: [Python-ideas] while conditional in list comprehension ??

2013-01-28 Thread Chris Angelico
Argh, sorry folks. Hit the wrong list. :(

On Tue, Jan 29, 2013 at 12:55 AM, Chris Angelico  wrote:
> On Tue, Jan 29, 2013 at 12:33 AM, Wolfgang Maier
>  wrote:
>> Why not extend this filtering by allowing a while statement in addition to
>> if, as in:
>>
>> [n for n in range(1,1000) while n < 400]
>
> The time machine strikes again! Check out itertools.takewhile - it can
> do pretty much that:
>
> import itertools
> [n for n in itertools.takewhile(lambda n: n<400, range(1,1000))]
>
> It's not quite list comp notation, but it works.
>
 [n for n in itertools.takewhile(lambda n: n<40, range(1,100))]
> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
> 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
> 37, 38, 39]
>
> ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel

On 01/28/2013 08:31 AM, inshu chauhan wrote:

In the code below I am trying to read 2 files f1 and f2 , extract some data
from them and then trying to write them into a single file that is 'nf'.

import cv
f1 = open(r"Z:\modules\Feature_Vectors_300.arff")
f2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")
nf = open(r"Z:\modules\trial.arff", "w")


for l in f1:
 sp = l.split(",")

 if len(sp)!= 12:
 continue
 else:
 ix = sp[0].strip()
 iy = sp[1].strip()
 print ix, iy

for s in f2:
 st = s.split(",")

 if len(st)!= 11:
 continue
 else:
 clas = st[10].strip()

  print ix, iy, clas
  print >> nf, ix, iy, clas

f1.close()
f2.close()
nf.close()


I think my code is not so correct , as I am not getting desired results and
logically it follows also but I am stuck , cannot find a way around this
simple problem of writing to a same file.. Please suggest some good
pythonic way I can do it..


Thanks in Advance





The other questions are useful, but I'll make a guess based on what 
you've said so far.


You're trying to read the same file f2 multiple times, as you loop 
around the f1 file.  But you just keep the file open and try to iterate 
over it multiple times.  You either need to close and open it each time, 
or do a seek to beginning, or you'll not see any data for the second and 
later iteration.


Or better, just read file f2 into a list, and iterate over that, which 
you can do as many times as you like.  (Naturally this assumes it's not 
over a couple of hundred meg).


file2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")
f2 = file2.readlines()
file2.close()


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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread inshu chauhan
Yes Chris, I understand, My Original code was

for l in f1:
sp = l.split(",")

if len(sp)!= 12:
continue
else:
ix = sp[0].strip()
iy = sp[1].strip()


for s in f2:
st = s.split(",")

if len(st)!= 11:
continue
else:
clas = st[10].strip()

print ix, iy, clas
print >> nf, ix, iy, clas

f1.close()
f2.close()
nf.close()

where f1 contains something like :

297, 404, , 
298, 404, , ..
299, 404, .
.  ..
295, 452, 

and f2 contains something like :

 7
. 2
2
.7

and what I want to be written in the new file i.e. nf is something like:

297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 2
297 404 2
297 404 2
297 404 2
297 404 2

which m getting but partially correct because only last value is changing
not the first two... which should not happen.. In every loop all the three
values should change..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:12 AM, inshu chauhan  wrote:
> where f1 contains something like :
>
> 297, 404, , 
> 298, 404, , ..
> 299, 404, .
> .  ..
> 295, 452, 
>
> and f2 contains something like :
>
>  7
> . 2
> 2
> .7
>
> and what I want to be written in the new file i.e. nf is something like:
>
> 297 404 7
> 297 404 2
>
> which m getting but partially correct because only last value is changing
> not the first two... which should not happen.. In every loop all the three
> values should change..

In that case, Dave's suggestion to read into a list and iterate over
the list is to be strongly considered. But I'm not entirely sure what
your goal is here. Are you trying to make the Cartesian product of the
two files, where you have one line in the output for each possible
pair of matching lines? That is, for each line in the first file, you
make a line in the output for each line in the second? That's what
your code will currently do.

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread inshu chauhan
> In that case, Dave's suggestion to read into a list and iterate over
> the list is to be strongly considered. But I'm not entirely sure what
> your goal is here. Are you trying to make the Cartesian product of the
> two files, where you have one line in the output for each possible
> pair of matching lines? That is, for each line in the first file, you
> make a line in the output for each line in the second? That's what
> your code will currently do.
>

No , I dont want that , actually both files have equal no of lines, I want
to read the first line of f1 , take 2 datas from it, nd then read first
line of f2, take data from it,
then print them to the same first line of new file i.e nf.

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:24 AM, inshu chauhan  wrote:
>> In that case, Dave's suggestion to read into a list and iterate over
>> the list is to be strongly considered. But I'm not entirely sure what
>> your goal is here. Are you trying to make the Cartesian product of the
>> two files, where you have one line in the output for each possible
>> pair of matching lines? That is, for each line in the first file, you
>> make a line in the output for each line in the second? That's what
>> your code will currently do.
>
> No , I dont want that , actually both files have equal no of lines, I want
> to read the first line of f1 , take 2 datas from it, nd then read first line
> of f2, take data from it,
> then print them to the same first line of new file i.e nf.

Okay, so you want an algorithm something like this:

for l1 in f1:
# make sure you have the right sort of line, and 'continue' if not
for l2 in f2:
# same again, 'continue' if not right
print >> nf # whatever you need to output
break

The 'break' in the second loop will mean that it never consumes more
than one valid line. You still need to deal with the possibilities of
one file being shorter than the other, of the lines mismatching, etc,
but at least you don't get a failed Cartesian product.

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel

On 01/28/2013 09:12 AM, inshu chauhan wrote:

Yes Chris, I understand, My Original code was

for l in f1:
 sp = l.split(",")

 if len(sp)!= 12:
 continue
 else:
 ix = sp[0].strip()
 iy = sp[1].strip()


 for s in f2:
 st = s.split(",")

 if len(st)!= 11:
 continue
 else:
 clas = st[10].strip()

 print ix, iy, clas
 print >> nf, ix, iy, clas

f1.close()
f2.close()
nf.close()

where f1 contains something like :

297, 404, , 
298, 404, , ..
299, 404, .
.  ..
295, 452, 

and f2 contains something like :

 7
. 2
2
.7

and what I want to be written in the new file i.e. nf is something like:

297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 7
297 404 2
297 404 2
297 404 2
297 404 2
297 404 2

which m getting but partially correct because only last value is changing
not the first two... which should not happen.. In every loop all the three
values should change..


Your current logic tries to scan through the first file, and for each 
line that has 12 elements, scans through the entire second file.  It 
fails to actually do it, because you never do a seek on the second file.


Now it appears your requirement is entirely different.  I believe you 
have two text files each having the same number of lines.  You want to 
loop through the pair of lines (once from each file, doing some kind of 
processing and printing).  If that's the case, your nested loop is the 
wrong thing, and you can forget my caveat about nesting file reads.


What you want is the zip() function

for l,s in zip(f1, f2):
#you now have one line from each file,
#   which you can then validate and process

Note, this assumes that when a line is "bad" from either file, you're 
going to also ignore the corresponding line from the other.  If you have 
to accommodate variable misses in the lining up, then your work is 
*much* harder.





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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Chris Angelico
On Tue, Jan 29, 2013 at 1:37 AM, Dave Angel  wrote:
> What you want is the zip() function
>
> for l,s in zip(f1, f2):
> #you now have one line from each file,
> #   which you can then validate and process
>
> Note, this assumes that when a line is "bad" from either file, you're going
> to also ignore the corresponding line from the other.  If you have to
> accommodate variable misses in the lining up, then your work is *much*
> harder.

Much harder? Not really - see my solution above with a simple 'break'.
Much less clear what's going on, though, it is. Iterating together
over both files with zip is much cleaner.

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread inshu chauhan
Your current logic tries to scan through the first file, and for each line
that has 12 elements, scans through the entire second file.  It fails to
actually do it, because you never do a seek on the second file.

>
> Now it appears your requirement is entirely different.  I believe you have
> two text files each having the same number of lines.  You want to loop
> through the pair of lines (once from each file, doing some kind of
> processing and printing).  If that's the case, your nested loop is the
> wrong thing, and you can forget my caveat about nesting file reads.
>
> What you want is the zip() function
>
> for l,s in zip(f1, f2):
> #you now have one line from each file,
> #   which you can then validate and process
>
> Note, this assumes that when a line is "bad" from either file, you're
> going to also ignore the corresponding line from the other.  If you have to
> accommodate variable misses in the lining up, then your work is *much*
> harder.
>
>
>
>
>
> Actually these are Arff files used in Weka (Data Mining ), So they have a
certain amount of header information which is the same in both files(in
same no. of lines too )  and both files have equal lines, So when I read
basically In both files I am trying to ignore the Header information.

then it is like reading first line from f1 and first line from f2,
extracting the data I want from each file and simply write it to a third
file line by line...

What does actually Zip function do ?

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


RE: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Wolfgang Maier
Hi,
as many others I am not exactly sure what the purpose of your code really
is.
However, if what you´re trying to do here is to take one line from f1, one
line from f2 and then write some combined data to nf, it is not surprising
that you're not getting what you expect (the main reason being that your for
loops are nested, as pointed out already).
In that case, a much cleaner and less error-prone solution would be
iterator-zipping, leaving you with just one for loop that is easy to
understand:

for l,s in zip(f1,f2):
# now l holds the next line from f1, s the corresponding line from
f2
do_yourstuf()
write_output()

if your files are large, then in python 2.x you should use:

import itertools
for l,s in itertools.izip(f1,f2):
do_yourstuff()
write_output()

The reason for this is that before python 3 zip gathered and returned your
results as an in-memory list. itertools.izip and the built-in python 3 zip
return iterators.

Hope that helps,
Wolfgang



From: inshu chauhan [mailto:[email protected]] 
Sent: Monday, January 28, 2013 2:32 PM
To: [email protected]
Subject: Reading data from 2 different files and writing to a single file

In the code below I am trying to read 2 files f1 and f2 , extract some data
from them and then trying to write them into a single file that is 'nf'.

import cv
f1 = open(r"Z:\modules\Feature_Vectors_300.arff")
f2 = open(r"Z:\modules\Feature_Vectors_300_Pclass.arff")
nf = open(r"Z:\modules\trial.arff", "w")


for l in f1:
    sp = l.split(",")
    
    if len(sp)!= 12:
    continue
    else:
    ix = sp[0].strip()
    iy = sp[1].strip()
    print ix, iy
    
   for s in f2:
    st = s.split(",")
    
    if len(st)!= 11:
    continue
    else:
    clas = st[10].strip()
    
 print ix, iy, clas
 print >> nf, ix, iy, clas

f1.close()
f2.close()
nf.close()

I think my code is not so correct , as I am not getting desired results and
logically it follows also but I am stuck , cannot find a way around this
simple problem of writing to a same file.. Please suggest some good pythonic
way I can do it.. 

Thanks in Advance 

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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Dave Angel

On 01/28/2013 09:47 AM, inshu chauhan wrote:

Your current logic tries to scan through the first file, and for each line
that has 12 elements, scans through the entire second file.  It fails to
actually do it, because you never do a seek on the second file.



Now it appears your requirement is entirely different.  I believe you have
two text files each having the same number of lines.  You want to loop
through the pair of lines (once from each file, doing some kind of
processing and printing).  If that's the case, your nested loop is the
wrong thing, and you can forget my caveat about nesting file reads.

What you want is the zip() function

for l,s in zip(f1, f2):
 #you now have one line from each file,
 #   which you can then validate and process

Note, this assumes that when a line is "bad" from either file, you're
going to also ignore the corresponding line from the other.  If you have to
accommodate variable misses in the lining up, then your work is *much*
harder.





Actually these are Arff files used in Weka (Data Mining ), So they have a

certain amount of header information which is the same in both files(in
same no. of lines too )  and both files have equal lines, So when I read
basically In both files I am trying to ignore the Header information.

then it is like reading first line from f1 and first line from f2,
extracting the data I want from each file and simply write it to a third
file line by line...

What does actually Zip function do ?

Thanks and Regards





That's  "zip"  not  "Zip"

Have you tried looking at the docs?  Or even typing help(zip) at the 
python interpreter prompt?


In rough terms, zip takes one element (line) from each of the iterators, 
and creates a new list that holds tuples of those elements.  If you use 
it in this form:


 for item1, item2 in zip(iter1, iter2):

then item1 will be the first item of iter1, and item2 will be the first 
item of iter2.  You then process them, and loop around.  It stops when 
either iterator runs out of items.


https://duckduckgo.com/?q=python+zip
   gives me http://docs.python.org/2/library/functions.html#zip

as the first link.

This will read the entire content of both files into the list, so if 
they are more than 100meg or so, you might want to use  izip().  (In 
Python3.x,  zip will do what izip does on Python 2.x)



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


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread inshu chauhan
>>
>>
>>
> That's  "zip"  not  "Zip"
>
> Have you tried looking at the docs?  Or even typing help(zip) at the
> python interpreter prompt?
>
> In rough terms, zip takes one element (line) from each of the iterators,
> and creates a new list that holds tuples of those elements.  If you use it
> in this form:
>
>  for item1, item2 in zip(iter1, iter2):
>
> then item1 will be the first item of iter1, and item2 will be the first
> item of iter2.  You then process them, and loop around.  It stops when
> either iterator runs out of items.
>
> https://duckduckgo.com/?q=**python+zip
>gives me 
> http://docs.python.org/2/**library/functions.html#zip
>
> as the first link.
>
> This will read the entire content of both files into the list, so if they
> are more than 100meg or so, you might want to use  izip().  (In Python3.x,
>  zip will do what izip does on Python 2.x)
>
>
>
> --
> DaveA
> --
> http://mail.python.org/**mailman/listinfo/python-list
>



Thanks Dave, I am Sorry ,  true I dint look up for it because as per the
Suggetion by Chris, 'break' does solve my problem but I wanted to know a
little about 'zip' for I encounter any other problem, parsing these two
files.
-- 
http://mail.python.org/mailman/listinfo/python-list


I have issues installing pycrypto (and thus fabric) with pip

2013-01-28 Thread Nicholas Kolatsis
I'm not sure this is the right place for this but I'm don't know where else to 
put this.

I want to give fabric a try (as recommended here: 
http://www.jeffknupp.com/blog/2012/10/24/starting-a-django-14-project-the-right-way/).
 Installing fabric results in two dependencies (paramiko and pycrypto) being 
installed as well. All is dandy until it is time to install pycrypto.

A bit of searching reveals this in the documentation:

Package tools

We strongly recommend using pip to install Fabric as it is newer and generally 
better than easy_install. However, a combination of bugs in specific versions 
of Python, pip and PyCrypto can prevent installation of PyCrypto. Specifically:

Python = 2.5.x
PyCrypto >= 2.1 (which is required to run Fabric >= 1.3)
pip < 0.8.1

When all three criteria are met, you may encounter No such file or directory 
IOErrors when trying to pip install Fabric or pip install PyCrypto.

The fix is simply to make sure at least one of the above criteria is not met, 
by doing the following (in order of preference):

Upgrade to pip 0.8.1 or above, e.g. by running pip install -U pip.
Upgrade to Python 2.6 or above.
Downgrade to Fabric 1.2.x, which does not require PyCrypto >= 2.1, and 
install PyCrypto 2.0.1 (the oldest version on PyPI which works with Fabric 1.2.)


(dp130128)cheeky@n5110:~/proj/dp130128$ yolk -l
Django  - 1.4.3- active 
Python  - 2.7.3- active development 
(/usr/lib/python2.7/lib-dynload) <--check
South   - 0.7.6- active 
argparse- 1.2.1- active development (/usr/lib/python2.7)
pip - 1.2.1- active  <--check
setuptools  - 0.6c11   - active 
wsgiref - 0.1.2- active development (/usr/lib/python2.7)
yolk- 0.4.3- active 

I've got pip and python covered above but I'm still unable to install fabric as 
shown below.

(dp130128)cheeky@n5110:~/proj/dp130128$ pip install fabric
Downloading/unpacking fabric
  Running setup.py egg_info for package fabric

warning: no previously-included files matching '*' found under directory 
'docs/_build'
warning: no previously-included files matching '*.pyc' found under 
directory 'tests'
warning: no previously-included files matching '*.pyo' found under 
directory 'tests'
Downloading/unpacking paramiko>=1.9.0 (from fabric)
  Running setup.py egg_info for package paramiko

Downloading/unpacking pycrypto>=2.1,!=2.4 (from paramiko>=1.9.0->fabric)
  Running setup.py egg_info for package pycrypto

Installing collected packages: fabric, paramiko, pycrypto
  Running setup.py install for fabric

warning: no previously-included files matching '*' found under directory 
'docs/_build'
warning: no previously-included files matching '*.pyc' found under 
directory 'tests'
warning: no previously-included files matching '*.pyo' found under 
directory 'tests'
Installing fab script to /home/cheeky/.virtualenvs/dp130128/bin
  Running setup.py install for paramiko

  Running setup.py install for pycrypto
warning: GMP or MPIR library not found; Not building 
Crypto.PublicKey._fastmath.
building 'Crypto.Hash._MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC 
-std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c 
-o build/temp.linux-i686-2.7/src/MD2.o
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/cheeky/.virtualenvs/dp130128/bin/python 
-c "import 
setuptools;__file__='/home/cheeky/.virtualenvs/dp130128/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n',
 '\n'), __file__, 'exec'))" install --record 
/tmp/pip-0X00No-record/install-record.txt --single-version-externally-managed 
--install-headers /home/cheeky/.virtualenvs/dp130128/include/site/python2.7:
running install

running build

running build_py

running build_ext

running build_configure

warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.

building 'Crypto.Hash._MD2' extension

gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC 
-std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c src/MD2.c 
-o build/temp.linux-i686-2.7/src/MD2.o

src/MD2.c:31:20: fatal error: Python.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1


Command /home/cheeky/.virtualenvs/dp130128/bin/python -c "import 
setuptools;__file__='/home/cheeky/.virtualenvs/dp130128/build/pycrypto/setup.py';exec(compile(open(__file__).read().replace('\r\n',
 '\n'), __file__, 'exec'))" install --record 
/tmp/pip-0X00No-record/install-record.txt --single-version-externally-managed 
--install-headers /home/cheeky/.virtualenvs/dp130128/include/site/python2.7 
failed

WLAN tester

2013-01-28 Thread Wanderer
I'm looking to make a WLAN tester for a manufacturing test. Something that 
could send and receive a bunch of files and measure how long it took. I would 
repeat this a number of times for a device under test and then use some metric 
to decide pass/fail and create a report. What libraries are available for 
Python for communicating with networks? My google searches have been 
disappointing. I'd prefer to do this in Windows but I'll consider Linux if that 
is the better option. 

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


Re: WLAN tester

2013-01-28 Thread Dave Angel

On 01/28/2013 10:47 AM, Wanderer wrote:

I'm looking to make a WLAN tester for a manufacturing test. Something that 
could send and receive a bunch of files and measure how long it took. I would 
repeat this a number of times for a device under test and then use some metric 
to decide pass/fail and create a report. What libraries are available for 
Python for communicating with networks? My google searches have been 
disappointing. I'd prefer to do this in Windows but I'll consider Linux if that 
is the better option.

Thanks


For what version of Python?

Depending on what's at the far end of your connection, you may not need 
to do much at all.  For example, if you have an ftp server, check out

http://docs.python.org/2/library/ftplib.html

in the standard library.



Since you're doing performance testing, be aware that it's quite tricky 
to get meaningful results.For example, some connections have a 
satellite link in them, and thus have very long latency.  A simple 
protocol will go very slowly in such a case, but most downloaders will 
open multiple sockets, and do many transfers in parallel.  So you could 
either measure the slow way or the fast way, and both numbers are 
meaningful.


Of course, it's more than a  2-way choice.  Some protocols will compress 
the data, send it, and decompress it on the other end.  Others (like the 
one rsync uses) will evaluate both ends, and decide which (if any) files 
need to be transferred at all.  I believe it also does partial file 
updates if possible, but I'm not at all sure about that.


Naturally, the throughput will vary greatly from moment to moment, and 
may be affected by lots of things you cannot see.


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


Re: WLAN tester

2013-01-28 Thread Wanderer
On Monday, January 28, 2013 11:30:47 AM UTC-5, Dave Angel wrote:
> On 01/28/2013 10:47 AM, Wanderer wrote:
> 
> > I'm looking to make a WLAN tester for a manufacturing test. Something that 
> > could send and receive a bunch of files and measure how long it took. I 
> > would repeat this a number of times for a device under test and then use 
> > some metric to decide pass/fail and create a report. What libraries are 
> > available for Python for communicating with networks? My google searches 
> > have been disappointing. I'd prefer to do this in Windows but I'll consider 
> > Linux if that is the better option.
> 
> >
> 
> > Thanks
> 
> >
> 
> For what version of Python?
> 
> 
> 
> Depending on what's at the far end of your connection, you may not need 
> 
> to do much at all.  For example, if you have an ftp server, check out
> 
>  http://docs.python.org/2/library/ftplib.html
> 
> 
> 
> in the standard library.
> 
> 
> 
> 
> 
> 
> 
> Since you're doing performance testing, be aware that it's quite tricky 
> 
> to get meaningful results.For example, some connections have a 
> 
> satellite link in them, and thus have very long latency.  A simple 
> 
> protocol will go very slowly in such a case, but most downloaders will 
> 
> open multiple sockets, and do many transfers in parallel.  So you could 
> 
> either measure the slow way or the fast way, and both numbers are 
> 
> meaningful.
> 
> 
> 
> Of course, it's more than a  2-way choice.  Some protocols will compress 
> 
> the data, send it, and decompress it on the other end.  Others (like the 
> 
> one rsync uses) will evaluate both ends, and decide which (if any) files 
> 
> need to be transferred at all.  I believe it also does partial file 
> 
> updates if possible, but I'm not at all sure about that.
> 
> 
> 
> Naturally, the throughput will vary greatly from moment to moment, and 
> 
> may be affected by lots of things you cannot see.
> 
> 
> 
> -- 
> 
> DaveA

Yes. I noticed this variability. I've been using the Totusoft Lan_Speedtest.exe 
to test some modules. I've tested through the wifi to our intranet and saw 
variations I believe do to network traffic. I also tried peer to peer and the 
write time actual got worse. I don't know if it has do to with the firewall or 
the hard drive speed or just Windows giving this process low priority. I also 
saw drop outs. So figuring out the metric for pass/fail will be interesting. 
I'll check into setting an ftp for this test.

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


Re: I have issues installing pycrypto (and thus fabric) with pip

2013-01-28 Thread Kwpolska
On Mon, Jan 28, 2013 at 4:21 PM, Nicholas Kolatsis  wrote:
> I'm not sure this is the right place for this

It is

> but I'm don't know where else to put this.

Here. (s/I’m/I/)
> I want to give fabric a try (as recommended here: 
> http://www.jeffknupp.com/blog/2012/10/24/starting-a-django-14-project-the-right-way/).
>  Installing fabric results in two dependencies (paramiko and pycrypto) being 
> installed as well. All is dandy until it is time to install pycrypto.

Note that Fabric is useful for much, MUCH more than this.

> (dp130128)cheeky@n5110:~/proj/dp130128$ pip install fabric

Off-topic: why is your virtualenv/project name so weird?

> Downloading/unpacking fabric
>   Running setup.py egg_info for package fabric
>
> warning: no previously-included files matching '*' found under directory 
> 'docs/_build'
> warning: no previously-included files matching '*.pyc' found under 
> directory 'tests'
> warning: no previously-included files matching '*.pyo' found under 
> directory 'tests'
> Downloading/unpacking paramiko>=1.9.0 (from fabric)
>   Running setup.py egg_info for package paramiko
>
> Downloading/unpacking pycrypto>=2.1,!=2.4 (from paramiko>=1.9.0->fabric)
>   Running setup.py egg_info for package pycrypto
>
> Installing collected packages: fabric, paramiko, pycrypto
>   Running setup.py install for fabric
>
> warning: no previously-included files matching '*' found under directory 
> 'docs/_build'
> warning: no previously-included files matching '*.pyc' found under 
> directory 'tests'
> warning: no previously-included files matching '*.pyo' found under 
> directory 'tests'
> Installing fab script to /home/cheeky/.virtualenvs/dp130128/bin
>   Running setup.py install for paramiko
>

Seems to be properly installed.

>   Running setup.py install for pycrypto
> warning: GMP or MPIR library not found; Not building 
> Crypto.PublicKey._fastmath.
> building 'Crypto.Hash._MD2' extension
> gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC 
> -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/python2.7 -c 
> src/MD2.c -o build/temp.linux-i686-2.7/src/MD2.o
> src/MD2.c:31:20: fatal error: Python.h: No such file or directory
> compilation terminated.
> error: command 'gcc' failed with exit status 1

Here comes your problem: you do not have the Python header files,
required to compile the C code used by pycrypto (for speed in certain
operations, because they are quite resource-intensive).  Where can you
get them?  I don’t know, ask your distro.  They are usually in a
package ending with -dev or -devel (depending on your distro; human
distros do not bother with this and ship them along with the rest of
the thing…)

-- 
Kwpolska  | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Arpex Capital Seleciona: Programador Python Pleno/RJ

2013-01-28 Thread zughumancapital
Arpex Capital seleciona para uma de suas startups:

Programador Python Pleno

Descrição: 
Programador para Web Crawler Python 
- Experiência mínima de 1 ano em python 
- Conhecimento de padrões de projeto 
- Sólido conhecimento OO 
- Ser auto-gerenciável 
- Conhecimento de SQL 

Desejável:
- Ter github 
- Ter interesse por NPL
– Já ter feito um scraper/crawler/parser 
- Saber qualquer NoSQL
Local de Trabalho: Botafogo/RJ
Graduação Completa em Ciência da Computação e/ou afins;
Os interessados deverão enviar CV com PRENTENSÃO SALARIAL para 
[email protected] , mencionando no assunto Programador 
Python/Botafogo. 
 
 


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


Re: WLAN tester

2013-01-28 Thread Rob Day
On 28 January 2013 17:07, Wanderer  wrote:
> Yes. I noticed this variability. I've been using the Totusoft 
> Lan_Speedtest.exe to test some modules. I've tested through the wifi to our 
> intranet and saw variations I believe do to network traffic. I also tried 
> peer to peer and the write time actual got worse. I don't know if it has do 
> to with the firewall or the hard drive speed or just Windows giving this 
> process low priority. I also saw drop outs. So figuring out the metric for 
> pass/fail will be interesting. I'll check into setting an ftp for this test.

Why involve a protocol at all? I'd just create a socket
(http://docs.python.org/3.3/library/socket.html) and measure how long,
on average, it took to write a given number of arbitrary bytes (e.g.
"This is a string" repeated a million times) to it and then read a
given number of bytes back. That would be a relatively consistent
metric, whereas if you try using FTP you'll run into issues, as
already noted, where disk read/write speed and details of your FTP
server implementation like compression or multiple network connections
affect the result significantly.

--
Robert K. Day
[email protected]
-- 
http://mail.python.org/mailman/listinfo/python-list


The London Python Group:Switch to Python 3… Now… Immediately - February 12th

2013-01-28 Thread Theo
Russel Winder gives numerous reasons why now is the time for you to switch to 
Python 3 RIGHT NOW!

With Python 3.2 and even more with Python 3.3, Python 3 became usable for 
release products. Indeed given the things that are in Python 3 that are not 
being back-ported to Python 2, using Python 3 should probably be considered 
mandatory for all Python use. Certainly for new projects, and 2 → 3 ports for 
all extant codes. 

In this session we will investigate some of the issues, especially those 
relating to handling of concurrency and parallelism, and in particular 
concurrent.futures. Some material on CSP will almost certainly creep into the 
session. 

Sign up for the free evening event here - 
http://skillsmatter.com/podcast/java-jee/switch-to-python-3-now-immediately
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading data from 2 different files and writing to a single file

2013-01-28 Thread Virgil Stokes

On 28-Jan-2013 15:49, Chris Angelico wrote:

On Tue, Jan 29, 2013 at 1:37 AM, Dave Angel  wrote:

What you want is the zip() function

for l,s in zip(f1, f2):
 #you now have one line from each file,
 #   which you can then validate and process

Note, this assumes that when a line is "bad" from either file, you're going
to also ignore the corresponding line from the other.  If you have to
accommodate variable misses in the lining up, then your work is *much*
harder.

Much harder? Not really - see my solution above with a simple 'break'.
Much less clear what's going on, though, it is. Iterating together
over both files with zip is much cleaner.

ChrisA

Nice example of the power of zip, Chris :-)
--
http://mail.python.org/mailman/listinfo/python-list


pip and distutils

2013-01-28 Thread Vraj Mohan
I have created a source distribution using distutils which specifies
external packages using:

setup(
  ...,
  requires = ['Foo (>= 0.7)', 'Bar (>= 2.4.5)'],
  ...
  )

When I use pip to install this distribution, I find that it does not
automatically install the packages Foo and Bar. What extra step do I
need to perform to have pip automatically install the "required"
packages?

I am using Python 3.2.3.

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


Re: looking for advice python

2013-01-28 Thread twiztidtrees
On Sunday, January 27, 2013 1:57:47 PM UTC-5, [email protected] wrote:
> I am in a class and was just looking for different advice.  This is the first 
> time iv ever tried to do this. That's all that iv taken from two chapters and 
> wondering how bad I did.  I also like to learn.  Thanks for everyones input

This is what I have now thanks for the advice. It did seem a lot easier this 
way, but any criticism would be nice thanks.

windows 7 and python 3.3.0

while True:
try:
miles = float(input("How many miles did you drive?"))
break
except ValueError:
print("That is not a valid number. Please try again.")
while True:
try:
gas = float(input("How many gallons of gas did you use?"))
break
except ValueError:
print("That is not a valid number. Please try again.")

mpg = miles/gas
print('Your miles per gallons is', format(mpg,'.2f'))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WLAN tester

2013-01-28 Thread Wanderer
On Monday, January 28, 2013 12:32:50 PM UTC-5, Rob Day wrote:
> On 28 January 2013 17:07, Wanderer wrote:
> 
> > Yes. I noticed this variability. I've been using the Totusoft 
> > Lan_Speedtest.exe to test some modules. I've tested through the wifi to our 
> > intranet and saw variations I believe do to network traffic. I also tried 
> > peer to peer and the write time actual got worse. I don't know if it has do 
> > to with the firewall or the hard drive speed or just Windows giving this 
> > process low priority. I also saw drop outs. So figuring out the metric for 
> > pass/fail will be interesting. I'll check into setting an ftp for this test.
> 
> 
> 
> Why involve a protocol at all? I'd just create a socket
> 
> (http://docs.python.org/3.3/library/socket.html) and measure how long,
> 
> on average, it took to write a given number of arbitrary bytes (e.g.
> 
> "This is a string" repeated a million times) to it and then read a
> 
> given number of bytes back. That would be a relatively consistent
> 
> metric, whereas if you try using FTP you'll run into issues, as
> 
> already noted, where disk read/write speed and details of your FTP
> 
> server implementation like compression or multiple network connections
> 
> affect the result significantly.
> 
> 
> 
> --
> 
> Robert K. Day
> 
>

Thanks, I'll check out sockets. That's probably what I needed to search for 
instead WLAN and Wi-Fi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Further evidence that Python may be the best language forever

2013-01-28 Thread Malcolm McCrimmon
My company recently hosted a programming competition for schools across the 
country.  One team made it to the finals using the Python client, one of the 
four default clients provided (I wrote it).  Most of the other teams were using 
Java or C#.  Guess which team won?

http://www.windward.net/codewar/2013_01/finals.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python: HTTP connections through a proxy server requiring authentication

2013-01-28 Thread Barry Scott
The shipped python library code does not work.

See http://bugs.python.org/issue7291 for patches.

Barry

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


Re: Further evidence that Python may be the best language forever

2013-01-28 Thread Michael Torrie
On 01/28/2013 03:46 PM, Malcolm McCrimmon wrote:
> My company recently hosted a programming competition for schools
> across the country.  One team made it to the finals using the Python
> client, one of the four default clients provided (I wrote it).  Most
> of the other teams were using Java or C#.  Guess which team won?
> 
> http://www.windward.net/codewar/2013_01/finals.html

What language was the web page hosted in?  It comes up completely blank
for me. :)

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


Re: Python GUI able to display a spatial image

2013-01-28 Thread eagleds88
On Friday, January 25, 2013 8:34:16 AM UTC-8, Alex wrote:
> Hello, does python have capabilities to display a spatial image and read the 
> coordinates from it? If so, what modules or extension do I need to achieve 
> that? I'll appreciate any help. 
> 
> 
> 
> Thanks, 
> 
> Alex

Try basemap: http://matplotlib.org/basemap/
-- 
http://mail.python.org/mailman/listinfo/python-list


what is the difference between commenting and uncommenting the __init__ method in this class?

2013-01-28 Thread iMath
what is the difference between commenting and uncommenting the __init__ method  
in this class?


class CounterList(list):
counter = 0

##def __init__(self, *args):
##super(CounterList, self).__init__(*args)

def __getitem__(self, index):

self.__class__.counter += 1
return super(CounterList, self).__getitem__(index)

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


Re: what is the difference between commenting and uncommenting the __init__ method in this class?

2013-01-28 Thread Dave Angel

On 01/28/2013 09:09 PM, iMath wrote:

what is the difference between commenting and uncommenting the __init__ method  
in this class?


class CounterList(list):
 counter = 0

##def __init__(self, *args):
##super(CounterList, self).__init__(*args)

 def __getitem__(self, index):

 self.__class__.counter += 1
 return super(CounterList, self).__getitem__(index)



If you don't call the super-class' __init__() method, then the list 
won't take anyparameters.  So the list will be empty,



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


Re: what is the difference between commenting and uncommenting the __init__ method in this class?

2013-01-28 Thread Mitya Sirenef

On 01/28/2013 09:09 PM, iMath wrote:

what is the difference between  commenting and uncommenting the __init__ method 
in this class?

>
>
> class CounterList(list):
> counter = 0
>
> ## def __init__(self, *args):
> ## super(CounterList, self).__init__(*args)
>
> def __getitem__(self, index):
>
> self.__class__.counter += 1
> return super(CounterList, self).__getitem__(index)
>


No difference as this code doesn't do anything else in the __init__() it
overrides. Normally you would add some additional processing there but
if you don't need to, there is no reason to override __init__(),
therefore it's clearer and better to delete those 2 lines.

 -m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

It is always pleasant to be urged to do something on the ground that one
can do it well.  George Santayana

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


Re: python: HTTP connections through a proxy server requiring authentication

2013-01-28 Thread Saju M
Hi ,
Thanks barry,

I solved that issue.
I reconfigured squid3 with ncsa_auth, now its working same python code.
Earlier I used digest_pw_auth.

Actually I am trying to fix an issue related to python boto API.

Please check this post
https://groups.google.com/forum/#!topic/boto-users/1qk6d7v2HpQ


Regards
Saju Madhavan
+91 09535134654


On Tue, Jan 29, 2013 at 5:01 AM, Barry Scott  wrote:

> The shipped python library code does not work.
>
> See http://bugs.python.org/issue7291 for patches.
>
> Barry
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Further evidence that Python may be the best language forever

2013-01-28 Thread Stefan Behnel
Michael Torrie, 29.01.2013 02:15:
> On 01/28/2013 03:46 PM, Malcolm McCrimmon wrote:
>> My company recently hosted a programming competition for schools
>> across the country.  One team made it to the finals using the Python
>> client, one of the four default clients provided (I wrote it).  Most
>> of the other teams were using Java or C#.  Guess which team won?
>>
>> http://www.windward.net/codewar/2013_01/finals.html

We did a similar (although way smaller) contest once at a university. The
task was to write a network simulator. We had a C team, a Java team and a
Python team, four people each. The Java and C people knew their language,
the Python team just started learning it.

The C team ended up getting totally lost and failed. The Java team got most
things working ok and passed. The Python team got everything working, but
additionally implemented a web interface for the simulator that monitored
and visualised its current state. They said it helped them with debugging.


> What language was the web page hosted in?  It comes up completely blank
> for me. :)

Yep, same here. Hidden behind a flash wall, it seems.

Stefan


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