Re: python and ARM memory types

2015-10-05 Thread dieter
[email protected] writes:
> ...
> But how do I specify (streaming,write-combining,write-back) memory types in 
> python ? Is there a library that I can use ? I am thinking of programming 
> some fixed memory space (say 0x1000_000 - 0x2000_000) as "WC or WT or 
> streaming" using the OS and then try to use the mmap facility in python. 

Python is quite a high level programming language - i.e. lots of things
are out of direct control of the programmer - among others memory management.

I suppose you will need an approach that gives you more control over
memory use - maybe, write your algorithms partially in the "C" programming
language.


You might find "cython" helpful to easily combine Python parts
and "C" parts.

"cython" is a compiler that compiles a source (which can use
a subset of Python and a subset of "C") into a "C" source file
which is then processed like a typical "C" source.

It takes care of a lot of the difficulties at the Python-C interface
and, thus, greatly facilitates combining Python and "C" parts.


> What set of libraries can I use ? Where should I start ? Fixed memories are 
> discouraged so what kind of alternatives I can use ?

Note that modern operating systems virtualize memory. You will need a lot
of tricks to be able to use a specific range of physical memory in
"user level" processes -- but hopefully, you do not need to control
thing of the "physical memory level".

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


Re: Check if a given value is out of certain range

2015-10-05 Thread Michiel Overtoom

Why not use a function?


if outside(x, 0, 10):
print("x has wrong value")
else:
print("x has good value")


where 'outside' is defined as:

def outside(value, lowerbound, upperbound):
return value < lowerbound or value > upperbound  

Greetings,

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


Re: PySide window does not resize to fit screen

2015-10-05 Thread Hedieh Ebrahimi
Hi Chris, 

Thanks for your answer. I get your point now. 
Unfortunately there are not layouts in my user interface. 
Smaller widget have been grouped using group boxes and then all these group 
boxes are put on the central widget.

I would like to recreate my user interface using one of the designer software 
that exist.

Could you recommend any free designer software that I can create my user 
interface with?

Thank you 

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


Re: Check if a given value is out of certain range

2015-10-05 Thread Mark Lawrence

On 05/10/2015 09:18, Michiel Overtoom wrote:


Why not use a function?


 if outside(x, 0, 10):
 print("x has wrong value")
 else:
 print("x has good value")


where 'outside' is defined as:

 def outside(value, lowerbound, upperbound):
 return value < lowerbound or value > upperbound

Greetings,



Please wash your mouth out with soap, burn precious clock cycles just to 
make code readable, never I say :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Check if a given value is out of certain range

2015-10-05 Thread Jussi Piitulainen
Michiel Overtoom writes:

> Why not use a function?
>
>
> if outside(x, 0, 10):
> print("x has wrong value")
> else:
> print("x has good value")
>
>
> where 'outside' is defined as:
>
> def outside(value, lowerbound, upperbound):
> return value < lowerbound or value > upperbound  

Wouldn't that be more readable as:?

 def outside(value, lowerbound, upperbound):
 return not (lowerbound <= value <= upperbound)

Just wondering ...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: reg multiple login python

2015-10-05 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, [email protected]  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi All,

I am able to achieve it using multiprocessing package...

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


Re: PySide window does not resize to fit screen

2015-10-05 Thread Laura Creighton
In a message of Mon, 05 Oct 2015 01:18:33 -0700, Hedieh Ebrahimi writes:
>Could you recommend any free designer software that I can create my user 
>interface with?
>
>Thank you 

Qt Designer works with PySide.
http://doc.qt.io/qt-5/designer-quick-start.html

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


Re: PySide window does not resize to fit screen

2015-10-05 Thread Hedieh Ebrahimi
is this free to use for commercial use?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-05 Thread Marko Rauhamaa
Jussi Piitulainen :

> Michiel Overtoom writes:
>
>> Why not use a function?
>>
>>
>> if outside(x, 0, 10):
>> print("x has wrong value")
>> else:
>> print("x has good value")
>>
>>
>> where 'outside' is defined as:
>>
>> def outside(value, lowerbound, upperbound):
>> return value < lowerbound or value > upperbound  
>
> Wouldn't that be more readable as:?
>
>  def outside(value, lowerbound, upperbound):
>  return not (lowerbound <= value <= upperbound)

Why not use a fricking class framework:

class Endpoint:
def __init__(self, value):
self.value = value

class IncludedEndpoint(Endpoint):
def above(self, x):
return x > self.value

def below(self, x):
return x < self.value

class ExcludedEndpoint(Endpoint):
def above(self, x):
return x >= self.value

def below(self, x):
return x <= self.value

class Range:
def __init__(self, lower_bound, upper_bound):
self.lower_bound = lower_bound
self.upper_bound = upper_bound

def outside(self, x):
return self.lower_bound.below(x) or self.upper_bound.above(x)

def inside(self, x):
return not self.outside(x)

Then, we could simply have:

if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x):
print("x has wrong value")
else:
print("x has good value")

Just for the sake of readability, I mean...


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


Re: Check if a given value is out of certain range

2015-10-05 Thread Chris Angelico
On Mon, Oct 5, 2015 at 10:42 PM, Marko Rauhamaa  wrote:
> Why not use a fricking class framework:
>
> Then, we could simply have:
>
> if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x):
> print("x has wrong value")
> else:
> print("x has good value")
>
> Just for the sake of readability, I mean...

Hold on a moment! You can't seriously be contemplating instantiating
those classes directly, can you?!? You need to go through the
ThreadedRangeFactory, passing it a couple of EndpointFactory
subclasses to suggest which kinds of endpoints to employ, and finally
use operator overloading to wait for the factory thread to finish its
work. *THEN* you can use this Range object.

ChrisA
has just been reading http://thedailywtf.com/articles/eins-zwei-zuffa
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-10-05 Thread Marko Rauhamaa
Chris Angelico :

> On Mon, Oct 5, 2015 at 10:42 PM, Marko Rauhamaa  wrote:
>> Why not use a fricking class framework:
>>
>> Then, we could simply have:
>>
>> if Range(IncludedEndpoint(0), IncludedEndpoint(10)).outside(x):
>> print("x has wrong value")
>> else:
>> print("x has good value")
>>
>> Just for the sake of readability, I mean...
>
> Hold on a moment! You can't seriously be contemplating instantiating
> those classes directly, can you?!? You need to go through the
> ThreadedRangeFactory, passing it a couple of EndpointFactory
> subclasses to suggest which kinds of endpoints to employ, and finally
> use operator overloading to wait for the factory thread to finish its
> work. *THEN* you can use this Range object.
>
> ChrisA
> has just been reading http://thedailywtf.com/articles/eins-zwei-zuffa

Pointing out flaws in my code is totally unprofessional.


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


Re: PySide window does not resize to fit screen

2015-10-05 Thread Chris Warrick
On 5 October 2015 at 13:20, Hedieh Ebrahimi  wrote:
> is this free to use for commercial use?
> --
> https://mail.python.org/mailman/listinfo/python-list

Yeah, you can use Qt Designer to create a nice layout and the
pyside-uic tool to generate code (that you will need to clean up
later).

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


Finding Blank Columns in CSV

2015-10-05 Thread Jaydip Chakrabarty
Hello,

I have a csv file like this.

Name,Surname,Age,Sex
abc,def,,M
,ghi,,F
jkl,mno,,
pqr,,,F

I want to find out the blank columns, that is, fields where all the 
values are blank. Here is my python code.

fn = "tmp1.csv"
fin = open(fn, 'rb')
rdr = csv.DictReader(fin, delimiter=',')
data = list(rdr)
flds = rdr.fieldnames
fin.close()
mt = []
flag = 0
for i in range(len(flds)):
for row in data:
if len(row[flds[i]]):
flag = 0
break
else:
flag = 1
if flag:
mt.append(flds[i])
flag = 0
print mt

I need to know if there is better way to code this.

Thanks.

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


Re: Finding Blank Columns in CSV

2015-10-05 Thread Chris Angelico
On Tue, Oct 6, 2015 at 12:29 AM, Jaydip Chakrabarty
 wrote:
> I want to find out the blank columns, that is, fields where all the
> values are blank. Here is my python code.
>
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> data = list(rdr)
> flds = rdr.fieldnames
> fin.close()
> mt = []
> flag = 0
> for i in range(len(flds)):
> for row in data:
> if len(row[flds[i]]):
> flag = 0
> break
> else:
> flag = 1
> if flag:
> mt.append(flds[i])
> flag = 0
> print mt
>
> I need to know if there is better way to code this.
>

You could do it with a single iteration, something like this:

fn = "tmp1.csv"
fin = open(fn, 'rb')
rdr = csv.DictReader(fin, delimiter=',')
# all the same down to here
blanks = set(rdr.fieldnames)
for row in data:
blanks = {col for col in blanks if not row[col]}
mt = [col for col in rdr.fieldnames if col not in blanks]
print mt
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding Blank Columns in CSV

2015-10-05 Thread Chris Angelico
On Tue, Oct 6, 2015 at 12:48 AM, Chris Angelico  wrote:
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> # all the same down to here
> blanks = set(rdr.fieldnames)
> for row in data:
> blanks = {col for col in blanks if not row[col]}
> mt = [col for col in rdr.fieldnames if col not in blanks]
> print mt

Oops, premature send - hadn't proofread it yet.

fn = "tmp1.csv"
fin = open(fn, 'rb')
rdr = csv.DictReader(fin, delimiter=',')
# all the same down to here
blanks = set(rdr.fieldnames)
for row in rdr:
blanks = {col for col in blanks if not row[col]}
mt = [col for col in rdr.fieldnames if col not in blanks]
print mt

Though I still haven't tested it, so there may be other bugs. Broadly
speaking, though, what it does is quite simple: start by assuming that
every column is nothing but blanks, and then any time you find a
non-blank cell, remove it from the set of blanks. At the end, all
field names not present in the set of blanks are non-blanks.

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


Re: Finding Blank Columns in CSV

2015-10-05 Thread Random832
On Mon, Oct 5, 2015, at 09:29, Jaydip Chakrabarty wrote:
> Hello,
> 
> I have a csv file like this.
> 
> Name,Surname,Age,Sex
> abc,def,,M
> ,ghi,,F
> jkl,mno,,
> pqr,,,F
> 
> I want to find out the blank columns, that is, fields where all the 
> values are blank. Here is my python code.
> 
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> data = list(rdr)
> flds = rdr.fieldnames
> fin.close()
> mt = []
> flag = 0
> for i in range(len(flds)):
> for row in data:
> if len(row[flds[i]]):
> flag = 0
> break
> else:
> flag = 1
> if flag:
> mt.append(flds[i])
> flag = 0
> print mt
> 
> I need to know if there is better way to code this.

Well, for one thing, you should just be using something like "for fld in
flds" rather than range(len(...)).

There's also an opportunity to use list/generator comprehensions instead
of explicit loops - your whole loop could be written as:
mt = [fld for fld in flds if not any(row[fld] for row in data)]

It might be more efficient to iterate over rows first than columns,
depending on your data (if you have a large number of rows, consider
that you're reading them all into memory at the start) This would be
more complex code, though, and more difficult to write as a
comprehension, so if your data isn't ideal for it it might not be worth
doing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Parsing HTML with xml.etree in Python 2.7?

2015-10-05 Thread Skip Montanaro
Back before Fredrik Lundh's elementtree module was sucked into the Python
stdlib as xml.etree, I used to use his elementtidy extension module to
clean up HTML source so it could be parsed into an ElementTree object.
Elementtidy hasn't be updated in about ten years, and still assumes there
is a module named "elementtree" which it can import.

I wouldn't be surprised if there were some small API changes other than the
name change caused by the move into the xml package. Before I dive into a
rabbit hole and start to modify elementtidy, is there some other
stdlib-only way to parse HTML code into an xml.etree.ElementTree?

Thx,

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


Re: Finding Blank Columns in CSV

2015-10-05 Thread Tim Chase
On 2015-10-06 00:51, Chris Angelico wrote:
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> # all the same down to here
> blanks = set(rdr.fieldnames)
> for row in rdr:
> blanks = {col for col in blanks if not row[col]}
> mt = [col for col in rdr.fieldnames if col not in blanks]
> print mt

My only other modification would be to add a check that, if you no
longer have any blank columns, bail early from the loop:

  from cStringIO import StringIO
  import csv

  s = StringIO("""Name,Surname,Age,Sex
  abc,def,,M
  ,ghi,,F
  jkl,mno,,
  pqr,,,F
  """)

  dr = csv.DictReader(s)
  header_set = set(dr.fieldnames)
  for row in dr:
header_set = set(h for h in header_set if not row[h])
if not header_set:
  # we no longer have any headers, bail early
  break
  ordered_headers = [h for h in dr.fieldnames if h in header_set]
  print(header_set)
  print(ordered_headers)

That way, if you determine by line 3 that your million-row CSV file
has no blank columns, you can get away with not processing all
million rows.

-tkc



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


Re: Finding Blank Columns in CSV

2015-10-05 Thread Chris Angelico
On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase  wrote:
> That way, if you determine by line 3 that your million-row CSV file
> has no blank columns, you can get away with not processing all
> million rows.

Sure, although that effectively means the entire job is moot. I kinda
assume that the OP knows that there are some blank columns (maybe lots
of them). The extra check is unnecessary unless it's actually
plausible that there'll be no blanks whatsoever.

Incidentally, you have an ordered_headers list which is the blank
columns in order; I think the OP was looking for a list of the
_non_blank columns. But that's a trivial difference, easy to tweak.

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


Re: Parsing HTML with xml.etree in Python 2.7?

2015-10-05 Thread Skip Montanaro
On Mon, Oct 5, 2015 at 9:14 AM, Skip Montanaro  wrote:
> I wouldn't be surprised if there were some small API changes other than the
> name change caused by the move into the xml package. Before I dive into a
> rabbit hole and start to modify elementtidy, is there some other stdlib-only
> way to parse HTML code into an xml.etree.ElementTree?

Never mind. The only change necessary turned out to be the import. /F
writes robust code. :-)

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


Re: Pyarmor, guard your python scripts

2015-10-05 Thread Josef Pktd
related
https://youtu.be/wsczq6j3_bA?t=20m9s

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


Re: PySide window does not resize to fit screen

2015-10-05 Thread Michael Torrie
On 10/05/2015 05:20 AM, Hedieh Ebrahimi wrote:
> is this free to use for commercial use?

Yes of course.  There's also the newer Qt Creator program if you want to
use Qt 5.  The license of the Designer and Creator programs does not
apply to the output of these programs (the .ui XML files).

You'll want to read up on the documentation.  Here's a couple of links
for starters:

http://doc.qt.io/qt-4.8/designer-layouts.html
https://wiki.qt.io/QtCreator_and_PySide (works with .ui files from
Designer also)

Even if you don't use a GUI designer, you should construct your GUI with
layout managers so that your interfaces can adjust and look good on a
variety of screen sizes and DPI.  It's pretty simple once you wrap your
brain around the idea.

Another method of working with .ui files it to load them at runtime:
https://srinikom.github.io/pyside-docs/PySide/QtUiTools/QUiLoader.html


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


Re: Pyserial and Ubuntu Linux kernel 3.13.0-65-generic

2015-10-05 Thread Rob Gaddi
On Sat, 03 Oct 2015 11:12:28 +0200, Laura Creighton wrote:

> In a message of Sat, 03 Oct 2015 11:07:04 +0200, Laura Creighton writes:
>>In a message of Fri, 02 Oct 2015 22:36:23 -, Rob Gaddi writes:
>>>So, this is odd.  I'm running Ubuntu 14.04, and my system did a kernel
>>>upgrade from the repository from 3.13.0-63-generic to
>>>3.13.0-65-generic. And pyserial (2.7, installed through pip) stopped
>>>working.
>>>
>>>Specifically, when I make read() calls on a Serial object, I get the
>>>error
>>>
>>>serial.serialutil.SerialException: device reports readiness to read but
>>>returned no data (device disconnected?)
>>>
>>>This comes from the PosixSerial.read() method in serialposix.py, and
>>>seems to be a result of the select.select call screwing up.
>>>
>>>I reboot under 3.13.0-63-generic.  My code works.  I reboot under
>>>3.13.0-65-generic.  My code doesn't.  Implication would seem to be that
>>>somehow between these kernel versions, the select() logic in the serial
>>>driver changed.  This happens regardless of whether the serial port is
>>>real, FTDI USB-UART, or Prolific USB-UART.
>>>
>>>Can anyone else confirm?  Also, who do I try to report this one to?
>>>
>>>Thanks,
>>>Rob
>>>
>>>--
>>>Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email
>>>address domain is currently out of order.  See above to fix.
>>>--
>>>https://mail.python.org/mailman/listinfo/python-list
>>
>>I think you have this bug
>>https://bugs.launchpad.net/ubuntu/+source/linux/+bug/460857
>>
>>or rather, you like the behaviour that ubuntu thinks is buggy, which
>>never got fixed, and don't like that it changed to be what ubuntu thinks
>>is correct in .65.
>>
>>I'd talk to the pyserial issue tracker as the people there ought to be
>>well aware of this problem, and then see if talking to ubuntu is the
>>right thing to do.
>>
>>Laura --
>>https://mail.python.org/mailman/listinfo/python-list
> 
> I think I said that poorly.
> 
> What I think happened is that ubuntu made some changes to fix this
> problem, and along the way they managed to break things for you,
> and maybe all pyserial users.  But I would talk to the pyserial people
> about that.
> 
> Laura

I'm not sure poorly as much as "could have offended someone who hasn't 
been caught by these sorts of issues before".  I took it as meant, that 
one person's bug is another's fix, rather than as "Your bug report is 
stupid and you should feel bad and never Python again."

And thanks for the find on https://bugs.launchpad.net/ubuntu/+source/
linux-lts-trusty/+bug/1501345.  That is PRECISELY what I should have been 
able to find.  I'll make only the excuse that it was late Friday with me 
having to run for the airport and I wanted to at least flag it as an 
issue before I hit the door.

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


packaging code with compiled libraries

2015-10-05 Thread Tim
I have a package I want to share but have a question about packaging.

Mostly the package is pure python code, but it also requires some binary 
libraries (*.so, *.dll, *.dylib).  I want to bundle these libs so users don't 
have to compile. The package will run on *nix/windows/mac platforms.

Currently I handle this in setup.py. In the 'build' phase, I copy the 
platform-specific libs to a subdirectory called 'libs'.  

class MyBuilder(build_py):
def run(self):
conditional logic for copying 
appropriate library files to 'libs'
etc etc.
build_py.run()

And that seems to work, but after reading more from the Python Packaging 
Authority, I wonder if that is the right way.  Should I be using wheels 
instead? 
I think my brain fried a little bit while going through the doc.

thanks,
--Tim
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-10-05 Thread sohcahtoa82
On Thursday, September 17, 2015 at 10:55:19 PM UTC-7, Jondy Zhao wrote:
> On Friday, September 18, 2015 at 11:06:25 AM UTC+8, Ben Finney wrote:
> > Jondy Zhao  writes:
> > 
> > > For example, I develop a game by python. What I want to do is that the
> > > player or the agent could not simply copy the game to others. For the
> > > player or the agent, they needn't research the game.
> > 
> > Deciding for the customer what they may not do, on their own computer,
> > is quite hostile. Please don't enable such restrictions.
> > 
> 
> This is only one possible way to distribute encrypted scripts. As I thought 
> the user of Pyarmor would be the producer of commercial software, so they 
> could bind their license file to netcard, harddisk, cpu, etc.
> 
> > -- 
> >  \   "We must find our way to a time when faith, without evidence, |
> >   `\disgraces anyone who would claim it." --Sam Harris, _The End of |
> > _o__) Faith_, 2004 |
> > Ben Finney

DRM does not prevent piracy.

End of story.

The only thing DRM does is piss off your legitimate users by forcing them to 
jump through hoops if they happen to upgrade or replace their computer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Finding Blank Columns in CSV

2015-10-05 Thread Friedrich Rentsch



On 10/05/2015 03:29 PM, Jaydip Chakrabarty wrote:

Hello,

I have a csv file like this.

Name,Surname,Age,Sex
abc,def,,M
,ghi,,F
jkl,mno,,
pqr,,,F

I want to find out the blank columns, that is, fields where all the
values are blank. Here is my python code.

fn = "tmp1.csv"
fin = open(fn, 'rb')
rdr = csv.DictReader(fin, delimiter=',')
data = list(rdr)
flds = rdr.fieldnames
fin.close()
mt = []
flag = 0
for i in range(len(flds)):
 for row in data:
 if len(row[flds[i]]):
 flag = 0
 break
 else:
 flag = 1
 if flag:
 mt.append(flds[i])
 flag = 0
print mt

I need to know if there is better way to code this.

Thanks.

Operations on columns are often simpler, if a table is rotated 
beforehand. Columns become lists.


def find_empty_columns (table):
number_of_records = len (table)
rotated_table = zip (*table)
indices_of_empty_columns = []
for i in range (len (rotated_table)):  # Column indices
if rotated_table[i].count ('') == number_of_records:
indices_of_empty_columns.append (i)
return indices_of_empty_columns

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


Re: Finding Blank Columns in CSV

2015-10-05 Thread Denis McMahon
On Mon, 05 Oct 2015 13:29:03 +, Jaydip Chakrabarty wrote:

> Hello,
> 
> I have a csv file like this.
> 
> Name,Surname,Age,Sex abc,def,,M ,ghi,,F jkl,mno,,
> pqr,,,F
> 
> I want to find out the blank columns, that is, fields where all the
> values are blank. Here is my python code.
> 
> fn = "tmp1.csv"
> fin = open(fn, 'rb')
> rdr = csv.DictReader(fin, delimiter=',')
> data = list(rdr)
> flds = rdr.fieldnames fin.close()
> mt = []
> flag = 0 for i in range(len(flds)):
> for row in data:
> if len(row[flds[i]]):
> flag = 0 break
> else:
> flag = 1
> if flag:
> mt.append(flds[i]) flag = 0
> print mt
> 
> I need to know if there is better way to code this.
> 
> Thanks.

Assuming all the records have the same number of fields:

I'd create a list of flags of length numfields, all set to 0

then for each record, I*d set flag[n] = 1 if field[n] has content

then I'd check if I still have any 0 flags, and if I do, process the next 
record

As soon as I have no 0 flags, I can stop processing records, as this 
means I have no empty columns.

It might be more efficient if, when checking a record, I only tested the 
fields for which flag was still 0.

Example (untested)

flags = [False for x in rdr.fieldnames]

for row in data:
blanks = False
for i in range(len(flags)):
if not flags[i]:
if len(row[i]) == 0:
flags[i] = True
else:
blanks = True
if not blanks:
break


-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


threading bug in strptime

2015-10-05 Thread Larry Martell
We have been trying to figure out an intermittent problem where a
thread would fail with this:

AttributeError: 'module' object has no attribute '_strptime'

Even though we were importing datetime. After much banging our heads
against the wall, we found this:

http://code-trick.com/python-bug-attribute-error-_strptime/

The workaround suggested there, to call strptime before starting your
threads, seems to have fixed the issue.

I thought I'd mention it here in case anyone else is facing this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-10-05 Thread Ben Finney
Josef Pktd  writes:

> related

Care to give us a summary of what that is, and describe what you think
is the relevant point?

-- 
 \  “The best way to get information on Usenet is not to ask a |
  `\   question, but to post the wrong information.” —Aahz |
_o__)  |
Ben Finney

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


Re: packaging code with compiled libraries

2015-10-05 Thread Rustom Mody
On Tuesday, October 6, 2015 at 1:14:05 AM UTC+5:30, Tim wrote:

> And that seems to work, but after reading more from the Python Packaging 
> Authority, I wonder if that is the right way.  Should I be using wheels 
> instead? 
> I think my brain fried a little bit while going through the doc.

You are not alone
https://mail.python.org/pipermail/python-list/2015-July/694818.html
[last para]

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


Re: reg multiple login python

2015-10-05 Thread harirammanohar159
On Thursday, 1 October 2015 12:35:01 UTC+5:30, [email protected]  wrote:
> Hi All,
> 
> Is there anyway i can login to remote servers at once and do the activity, i 
> can do one by one using for loop..
> 
> Thanks in advance.

Hi,

issue in implementing multiprocessing with pxssh, its working fine with normal 
operations but with pxssh its throwing error as below:
=
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
  File "./rmcomments.py", line 12, in xcute
s = pxssh.pxssh()
  File 
"/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/pxssh.py", 
line 91, in __init__
spawn.__init__(self, None, timeout=timeout, maxread=maxread, 
searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env)
  File 
"/usr/python/3.4.3/custommodules/lib/python3.4/site-packages/pexpect/__init__.py",
 line 493, in __init__
fd = sys.__stdin__.fileno()
ValueError: I/O operation on closed file
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./rmcomments.py", line 23, in 
output = p.map(xcute, [(srvrs) for srvrs in serverslist])
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/python/3.4.3/Lib/multiprocessing/pool.py", line 599, in get
raise self._value
ValueError: I/O operation on closed file
==

Below is the code:

serverslist = ['server1','server2']
username = 'user1'
password = 'password1'

def xcute(srvrs):
s = pxssh.pxssh()
s.login (srvrs, username, password)
---do stuff---
s.sendline('logout')

np = len(serverslist)
p = multiprocessing.Pool(np)
output = p.map(xcute, [(srvrs) for srvrs in serverslist])


can any one help me out!
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pyarmor, guard your python scripts

2015-10-05 Thread Ian Kelly
On Oct 5, 2015 4:27 PM, "Ben Finney"  wrote:
>
> Josef Pktd  writes:
>
> > related
>
> Care to give us a summary of what that is, and describe what you think
> is the relevant point?

Following the link reveals it to be the video of a talk on Python exe
compilation from PyCon 2014.

If you're worried about the safety of the link, know that youtu.be is the
official URL shortener for YouTube and only leads to YouTube videos.
-- 
https://mail.python.org/mailman/listinfo/python-list