Getting a list of all modules

2014-07-30 Thread Steven D'Aprano
I'm looking for a programmatic way to get a list of all Python modules and packages. Not just those already imported, but all those which *could* be imported. I have a quick-and-dirty function which half does the job: def get_modules(): extensions = ('.py', '.pyc', '.pyo', '.so', '.dll')

Re: Load a CSV with different row lengths

2014-07-30 Thread Peter Otten
Miki Tebeka wrote: > Greetings, > >> I should've mentioned that I want to import my csv as a data frame or >> numpy array or as a table. > If you know the max length of a row, then you can do something like: > def gen_rows(stream, max_length): > for row in csv.reader(stream): >

Re: Getting a list of all modules

2014-07-30 Thread Chris Angelico
On Wed, Jul 30, 2014 at 5:43 PM, Steven D'Aprano wrote: > Is this problem already solved? Can anyone make any suggestions? I don't know of an actual solution, but I know where I'd look for one, and that's importlib. If nothing else, you can use importlib.machinery.all_suffixes() rather than hard-

Re: Getting a list of all modules

2014-07-30 Thread Peter Otten
Steven D'Aprano wrote: > I'm looking for a programmatic way to get a list of all Python modules > and packages. Not just those already imported, but all those which > *could* be imported. > > I have a quick-and-dirty function which half does the job: > > > def get_modules(): > extensions =

Re: Getting a list of all modules

2014-07-30 Thread Robert Kern
On 2014-07-30 09:46, Peter Otten wrote: Steven D'Aprano wrote: I'm looking for a programmatic way to get a list of all Python modules and packages. Not just those already imported, but all those which *could* be imported. I have a quick-and-dirty function which half does the job: def get_mod

Re: one to many (passing variables)

2014-07-30 Thread Antoon Pardon
On 28-07-14 21:29, Terry Reedy wrote: > On 7/25/2014 9:47 PM, C.D. Reimer wrote: >> On 7/24/2014 2:58 AM, Ben Finney wrote: >>> Here is an article on good API design; the principles apply to Python >>> http://blog.isnotworking.com/2007/05/api-design-guidelines.html>. >>> You know your API and its

Re: one to many (passing variables)

2014-07-30 Thread Peter Otten
Antoon Pardon wrote: > Taking this in consideration I think the io.RawIOBase.read got it > backwards. > > The documentation says the following: > > | If 0 bytes are returned, and size was not 0, this indicates end of file. > | If the object is in non-blocking mode and no bytes are available, Non

Unable to find ssh library supporting python 3.1

2014-07-30 Thread Chirag Dhyani
Hi, Could you suggest me ssh library supporting python 3.1, to a surprise I checked pramiko, fabric, etc etc and no one does. even workaround with plumbum but not helpful. We have a project entirely on python 3.1 and now we are stuck with ssh. Please help Thank you ~Chi -- https://mail.python.o

Re: one to many (passing variables)

2014-07-30 Thread Antoon Pardon
On 30-07-14 13:37, Peter Otten wrote: > Antoon Pardon wrote: > >> Taking this in consideration I think the io.RawIOBase.read got it >> backwards. >> >> The documentation says the following: >> >> | If 0 bytes are returned, and size was not 0, this indicates end of file. >> | If the object is in no

How to loop through nodes of xml through xslt

2014-07-30 Thread varun bhatnagar
Hi, I have two xml files. *File1.xml* ** ** ** * * ** * * ** ** * * ** * * * * ** * * ** ** * * ** ** *File2.xml* ** ** ** * * ** * * ** ** * * ** * *

Re: Unable to find ssh library supporting python 3.1

2014-07-30 Thread Chris “Kwpolska” Warrick
On Wed, Jul 30, 2014 at 1:49 PM, Chirag Dhyani wrote: > Hi, > > Could you suggest me ssh library supporting python 3.1, to a surprise I > checked pramiko, fabric, etc etc and no one does. even workaround with > plumbum but not helpful. We have a project entirely on python 3.1 and now we > are stuc

Re: Getting a list of all modules

2014-07-30 Thread Leo Jay
On Wed, Jul 30, 2014 at 3:43 PM, Steven D'Aprano wrote: > I'm looking for a programmatic way to get a list of all Python modules > and packages. Not just those already imported, but all those which > *could* be imported. > If you don't actually import it, how can you know it could be imported? No

Re: Getting a list of all modules

2014-07-30 Thread Chris Angelico
On Wed, Jul 30, 2014 at 11:22 PM, Leo Jay wrote: > On Wed, Jul 30, 2014 at 3:43 PM, Steven D'Aprano wrote: >> I'm looking for a programmatic way to get a list of all Python modules >> and packages. Not just those already imported, but all those which >> *could* be imported. >> > > If you don't ac

Convert Python 3 ResourceWarnings into exception

2014-07-30 Thread Piotr Dobrogost
Hi! Recently A. Jesse Jiryu Davis asked at Stackoverflow (http://stackoverflow.com/q/24717027/95735) if there is "a way to force a Python 3 unittest to fail, rather than simply print a warning to stderr, if it causes any ResourceWarning?" Daniel Harding, in the accepted answer, states it's not pos

Re: Getting a list of all modules

2014-07-30 Thread Ian Kelly
On Jul 30, 2014 4:37 AM, "Robert Kern" wrote: > > On 2014-07-30 09:46, Peter Otten wrote: >> >> Steven D'Aprano wrote: >> >>> I'm looking for a programmatic way to get a list of all Python modules >>> and packages. Not just those already imported, but all those which >>> *could* be imported. >>> >

Re: Getting a list of all modules

2014-07-30 Thread Skip Montanaro
On Wed, Jul 30, 2014 at 2:43 AM, Steven D'Aprano wrote: > I'm looking for a programmatic way to get a list of all Python modules > and packages. Not just those already imported, but all those which > *could* be imported. > I wrote a modified dir(), which I inject into builtins in interactive ses

Elektra 0.8.7 improved Python support

2014-07-30 Thread Markus Raab
Hello list, Elektra provides a universal and secure framework to store configuration parameters in a global, hierarchical key database. The core is a small library implemented in C. The plugin-based framework fulfills many configuration-related tasks to avoid any unnecessary code duplication ac

Re: Convert Python 3 ResourceWarnings into exception

2014-07-30 Thread Terry Reedy
On 7/30/2014 9:24 AM, Piotr Dobrogost wrote: Hi! Recently A. Jesse Jiryu Davis asked at Stackoverflow (http://stackoverflow.com/q/24717027/95735) if there is "a way to force a Python 3 unittest to fail, rather than simply print a warning to stderr, if it causes any ResourceWarning?" Daniel Hardi

What is best way to learn Python for advanced developer?

2014-07-30 Thread guirec . corbel
Hello, I am a Ruby developer and I want to program in Python. I know how to do simple things like create classes, methods, variables and all the basics. I want to know more. I want to know what is the Python philosophy, how to test, how to create maintenable software, etc. I'm looking for onli

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread MRAB
On 2014-07-30 21:20, guirec.cor...@gmail.com wrote: Hello, I am a Ruby developer and I want to program in Python. I know how to do simple things like create classes, methods, variables and all the basics. I want to know more. I want to know what is the Python philosophy, how to test, how to crea

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread guirec . corbel
That's cool but not very exhaustive. Do you more sources? -- https://mail.python.org/mailman/listinfo/python-list

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Ethan Furman
On 07/30/2014 01:20 PM, guirec.cor...@gmail.com wrote: I'm looking for online courses and any ressources I can have on the subject. Udacity [1] has some free computer courses, a few of which use Python as the language -- what I have seen so far is decent. O'Reilly [2] has four very good Pyth

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Mark Lawrence
On 30/07/2014 21:47, guirec.cor...@gmail.com wrote: That's cool but not very exhaustive. Do you more sources? Ever heard of search engines, they're very good. Can't really say much else when you don't provide any context in your message. -- My fellow Pythonistas, ask not what our language

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Emile van Sebille
On 7/30/2014 1:47 PM, guirec.cor...@gmail.com wrote: That's cool but not very exhaustive. Do you more sources? I'd normally suggest reviewing the standard library after getting comfortable with the basics -- see https://docs.python.org/2/library/ But, if you've already done that and want to

Re: Python 3 is killing Python

2014-07-30 Thread Rustom Mody
On Wednesday, July 16, 2014 4:16:45 PM UTC+5:30, Marko Rauhamaa wrote: > In unix and linux, there never was a separate text mode for files. When > you open a file, you open a file -- and stuff bytes in it. There is no > commonly accepted text file encoding. UTF-8 comes close to being a > standard,

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread guirec . corbel
I will look for all your ressources. Did someone tried this : http://pluralsight.com/training/Courses/Find?highlight=true&searchTerm=python ? -- https://mail.python.org/mailman/listinfo/python-list

speed up pandas calculation

2014-07-30 Thread Vincent Davis
I know this is a general python list and I am asking about pandas but this question is probably not great for asking on stackoverflow. I have a list of files (~80 files, ~30,000 rows) I need to process with my current code it is take minutes for each file. Any suggestions of a fast way. I am try to

Re: speed up pandas calculation

2014-07-30 Thread Mark Lawrence
On 31/07/2014 00:04, Vincent Davis wrote: I know this is a general python list and I am asking about pandas but this question is probably not great for asking on stackoverflow. I have a list of files (~80 files, ~30,000 rows) I need to process with my current code it is take minutes for each file

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
> df = pd.read_csv('nhamcsopd2010.csv' , index_col='PATCODE', low_memory=False) > col_init = list(df.columns.values) > keep_col = ['PATCODE', 'PATWT', 'VDAY', 'VMONTH', 'VYEAR', 'MED1', 'MED2', 'MED3', 'MED4', 'MED5'] > for col in col_init: > if col not in keep_col: > del df[col] I'm n

Re: speed up pandas calculation

2014-07-30 Thread Vincent Davis
On Wed, Jul 30, 2014 at 6:28 PM, Vincent Davis wrote: > The real slow part seems to be > for n in drugs: > df[n] = > df[['MED1','MED2','MED3','MED4','MED5']].isin([drugs[n]]).any(1) > ​I was wrong, this is fast, it was selecting the columns that was slow. using keep_col = ['PATCODE', 'PATWT'

Re: speed up pandas calculation

2014-07-30 Thread Steven D'Aprano
On Wed, 30 Jul 2014 17:04:04 -0600, Vincent Davis wrote: > I know this is a general python list and I am asking about pandas but > this question is probably not great for asking on stackoverflow. I have > a list of files (~80 files, ~30,000 rows) I need to process with my > current code it is take

Re: speed up pandas calculation

2014-07-30 Thread Chris Kaynor
On Wed, Jul 30, 2014 at 5:57 PM, Vincent Davis wrote: > > On Wed, Jul 30, 2014 at 6:28 PM, Vincent Davis > wrote: > >> The real slow part seems to be >> for n in drugs: >> df[n] = >> df[['MED1','MED2','MED3','MED4','MED5']].isin([drugs[n]]).any(1) >> > > ​I was wrong, this is fast, it was sel

Re: speed up pandas calculation

2014-07-30 Thread Steven D'Aprano
On Wed, 30 Jul 2014 18:57:15 -0600, Vincent Davis wrote: > On Wed, Jul 30, 2014 at 6:28 PM, Vincent Davis > wrote: > >> The real slow part seems to be >> for n in drugs: >> df[n] = >> df[['MED1','MED2','MED3','MED4','MED5']].isin([drugs[n]]).any(1) >> >> > ​I was wrong, this is fast, it was

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
(Now that I'm on a real keyboard, more complete responses are a bit easier.) Regarding the issue of missing columns from keep_col, you could create sets of what you have and what you want, and toss the rest: toss_these = list(set(df.columns) - set(keep_col)) del df[toss_these] Or something to th

Re: speed up pandas calculation

2014-07-30 Thread Skip Montanaro
On Wed, Jul 30, 2014 at 8:11 PM, Chris Kaynor wrote: > Another way to write this, using a list expression (untested): > new_df = [col for col in df if col.value in keep_col] As I am learning (often painfully) with pandas and JavaScript+(d3 or jQuery), loops are the enemy. You want to operate on l

Re: speed up pandas calculation

2014-07-30 Thread Rustom Mody
On Thursday, July 31, 2014 7:58:59 AM UTC+5:30, Skip Montanaro wrote: > As I am learning (often painfully) with pandas and JavaScript+(d3 or > jQuery), loops are the enemy. You want to operate on large chunks of > data simultaneously. In pandas, those chunks are thinly disguised > numpy arrays. In

Re: How to loop through nodes of xml through xslt

2014-07-30 Thread Dan Stromberg
On Wed, Jul 30, 2014 at 5:16 AM, varun bhatnagar wrote: > Hi, > > I have two xml files. > I am trying to fetch an output file which looks like this: > > Output.xml > The number of Procedure tag () can be different every time. So I > have to read this tag every time from each xml and then merge i

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Dan Stromberg
I like to think of pylint as an expert system about how to write better Python. Some of the warnings are pointless (superfluous-parens really bugs me), but much of it is quite valuable. And for the -really- pointless stuff, you can create a pylintrc to ignore them forever. Personally, I prefer t

Re: What is best way to learn Python for advanced developer?

2014-07-30 Thread Abhiram R
> I'm looking for online courses and any ressources I can have on the > subject. > > ​If you can get your hands on the Python course on www.lynda.com, that'd do the job.​ -- Abhiram.R -- https://mail.python.org/mailman/listinfo/python-list

Re: login: optional

2014-07-30 Thread Kev Dwyer
John Bliss wrote: > Noob here: > > Started new Python project via Google AppEngine which produced project > files including: > > \app.yaml > > handlers: > - url: /.* > script: main.app > secure: always > > Currently, navigating to project root forces me to authenticate with > Google oAuth2

Re: rpath alike feature for python scripts

2014-07-30 Thread dieter
dieter writes: > Olaf Hering writes: >> On Mon, Jul 28, Albert-Jan Roskam wrote: >>> does this help: https://nixos.org/patchelf.html. It is not specific to >>> Python, though. >> >> No, this does not help because its not about patching the result. >> The questions is how to obtain the value wit

Re: speed up pandas calculation

2014-07-30 Thread Vincent Davis
On Wed, Jul 30, 2014 at 5:57 PM, Skip Montanaro wrote: > > df = pd.read_csv('nhamcsopd2010.csv' , index_col='PATCODE', > low_memory=False) > > col_init = list(df.columns.values) > > keep_col = ['PATCODE', 'PATWT', 'VDAY', 'VMONTH', 'VYEAR', 'MED1', > 'MED2', 'MED3', 'MED4', 'MED5'] > > for col in