Fw: Context

2017-02-03 Thread Antonio




From: Antonio
Sent: Friday, February 3, 2017 1:02 PM
To: python-list@python.org
Subject: Context


I have python version 3.6.0 installed into my desktop)windows 7) but the 
menu/context (file,edit..etc) is missing.


How to fix this problem?



Thanks


Antonio


  [cid:36574bcd-0958-41f0-a1b3-2c34586b236a]
-- 
https://mail.python.org/mailman/listinfo/python-list


Passing every element of a list as argument to a function

2011-08-09 Thread Antonio Vera
Hi!,
I have a very simple syntax question. I want to evaluate a library
function f receiving an arbitrary number of arguments (like
itertools.product), on the elements of a list l. This means that I
want to compute f(l[0],l[1],...,l[len(l)-1]).

Is there any operation "op" such that f(op(l)) will give the sequence
of elements of l as arguments to f?

Thanks for your time.
Best,
Antonio
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to access elemenst in a list of lists?

2011-05-09 Thread Antonio CHESSA

Just learning python.
I can see that I can address an individual element of a list of lists
by
doing something like:
row = list[5]
element = row[3]

But is there a way to directly address an entry in a single statement?
Thanks for any help.
Regards
Chris Roy-Smith


suppose you have a list like this:
apple = [["a","b","c"],[1,2,3,4,5,6],["antony","max","sandra","sebastian"]]

apple[0] = ["a","b","c"]
apple[1] = [1,2,3,4,5,6]
apple[2] = ["antony","max","sandra","sebastian"]

apple[0][1] = "b"
apple[2][3] = "sebastian"

to view all videos in a loop so you can set:

for i in range(len(apple)):
  print apple[i]
  for j in range (len(apple[i])):
 print apple[i][j]

in your monitor when you do run this little program, you will see:

["a","b","c"]
a
b
c
[1,2,3,4,5,6]
1
2
3
4
5
6
["antony","max","sandra","sebastian"] 
antony

max
sandra
sebastian
Bay
vonkes



http://grepler.com groups

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


[Poll] Frameworks for Web Development

2004-12-29 Thread Antonio Cangiano

Dear all,
I want to propose a small "poll" about frameworks & tools that you 
use to develop web applications in Python. I think it would be 
interesting if you could list your favourite tools as well as explain the 
reasons for your choice. 
 
Thanks in advance,
Antonio--My programming blog: http://antoniocangiano.com

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

Hello. I'm new here...

2014-07-11 Thread Antonio Dalvit
Hello!

Im Antonio, from Italy. I'm new here and i'd like to introduce myself: i'm 
learning python language after years working in ICT sector. I decided to study 
python after fortran basic, c++, java and php for fun and because i'm tired to 
spend lines and lines of code to make something working as I want.

I'll lurk and sometimes i wall ask something that i cannot understand. I'm 
sorry if my questions can sound simple or trivial... 


good day!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: non-blocking PIPE read on Windows

2006-07-29 Thread Antonio Valentino
"placid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

> Hi all,
> 
> I have been looking into non-blocking read (readline) operations on
> PIPES on windows XP and there seems to be no way of doing this. Ive
> read that you could use a Thread to read from the pipe, but if you
> still use readline() wouldnt the Thread block too?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

> What i need to do is, create a process using subprocess.Popen, where
> the subprocess outputs information on one line (but the info
> continuesly changes and its always on the same line) and read this
> information without blocking, so i can retrieve other data from the
> line i read in then put this in a GUI interface.
> 
> 
> readline() blocks until the newline character is read, but when i use
> read(X) where X is a number of bytes then it doesnt block(expected
> functionality) but i dont know how many bytes the line will be and its
> not constant so i cant use this too.
> 
> Any ideas of solving this problem?
> 
> 
> Cheers

I realized something very similar to what you described in 

http://sourceforge.net/projects/bestgui

- the subprocess2.py module realizes the non blocking I/O
- the outputparser.py module processes the output from the controlled
process and updates the progress-bar, the status-bar and the log
messages in the GUI. Incomplete lines are stored in a buffer and
processed at the next read.

ciao

-- 
Antonio Valentino



-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Machine A python script execute Machine B python script?

2007-07-11 Thread Antonio Cuni
johnny wrote:
> Anyone know how I can make Machine A python script execute a python
> script on Machine B ?

have a look to py.execnet; in the simplest case, it does not need any 
special setup on machine B, just a working ssh server and a python 
interpreter installed:

http://codespeak.net/py/dist/execnet.html

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


webbrowser

2007-11-13 Thread Antonio Ceballos
Hello,

I am trying to open a URL on a new browser or new tab from an HTML page 
created from a python cgi script. On Apache in my localhost, it works, both 
with Internet Explorer and Firefox. However, when I upload the script to a 
remote server, it does not. A 500 Internal Server Error is displayed on the 
browser.

The (simplified) piece of code is as follows:

import webbrowser
webbrowser.open_new(http://www.google.com)

The server runs python 2.3. I am using python 2.5 in my localhost.

Can anybody figure out why this may be happening?

Cheers,
Antonio


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


Re: webbrowser

2007-11-14 Thread Antonio Ceballos
Dennis, Cameron,

You are absolutely right. I was not aware that the cgi was trying to open 
the new browser on the server -I am a beginner with cgi, python and 
javascript.

This simple javascript does the job perfectly:

window.open("http://www.google.com";);

Thanks a lot,
Antonio


"Antonio Ceballos" <[EMAIL PROTECTED]> escribió en el mensaje 
news:[EMAIL PROTECTED]
> Hello,
>
> I am trying to open a URL on a new browser or new tab from an HTML page 
> created from a python cgi script. On Apache in my localhost, it works, 
> both with Internet Explorer and Firefox. However, when I upload the script 
> to a remote server, it does not. A 500 Internal Server Error is displayed 
> on the browser.
>
> The (simplified) piece of code is as follows:
>
> import webbrowser
> webbrowser.open_new(http://www.google.com)
>
> The server runs python 2.3. I am using python 2.5 in my localhost.
>
> Can anybody figure out why this may be happening?
>
> Cheers,
> Antonio
>
> 


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

char string 2 hex string

2008-01-31 Thread Antonio Chay
Hello!

I need to transform a string from a file into a hexadecimal
representation, for example:

"AAA" should be "414141"

With perl I do this with:

unpack("H*","AAA")

And with python I got this:

"".join([str(hex(ord(x)))[2:] for x in "AAA"])

But seems a little "weird" for me.

Is there another way?
Thanks in advance!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: char string 2 hex string

2008-02-01 Thread Antonio Chay
On Jan 31, 7:09 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> Antonio Chay <[EMAIL PROTECTED]> writes:
> > "AAA" should be "414141"
>
> 'AAA'.encode('hex')

8-O
Cool stuff!
Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


[PyQt4] QTableWidget non editable

2008-06-22 Thread Antonio Valentino
Ciao a tutti,
ho un QTableWidget che ho reso non editabile settando editTriggers a
NoEditTriggers.

Il problema è che adesso non posso selezionare una cela e copiarne il
contenuto nella clipboard.

Come posso risolvere il problema?

Grazie in anticipo

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


Re: QTableWidget non editable

2008-06-22 Thread Antonio Valentino
On 22 Giu, 17:11, Antonio Valentino <[EMAIL PROTECTED]>
wrote:
> Ciao a tutti,
> ho un QTableWidget che ho reso non editabile settando editTriggers a
> NoEditTriggers.
>
> Il problema è che adesso non posso selezionare una cela e copiarne il
> contenuto nella clipboard.
>
> Come posso risolvere il problema?
>
> Grazie in anticipo
>
> antonio

Sorry,
wrong newsgroup :(

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


Are you happy with the current web deployment options?

2009-11-21 Thread Antonio Cangiano
Phusion is a Dutch company that vastly improved the status quo of Ruby
and Rails deployment through their open source module for Apache and
nginx.

Now they are publicly asking whether Pythonistas would be interested
in a similar solution for Python (and Django of course).

Not many Pythonistas read their Ruby-oriented blog, so I thought I'd
share the link here: 
http://izumi.plan99.net/blog/index.php/2009/11/21/phusion-passenger-for-python/


Cheers,
Antonio
--
http://ThinkCode.TV - High-quality programming screencasts
http://antoniocangiano.com - Zen and the Art of Programming
Follow me on Twitter: http://twitter.com/acangiano
Author of "Ruby on Rails for Microsoft Developers" (Wrox, 2009)
-- 
http://mail.python.org/mailman/listinfo/python-list


Fitness data program

2011-01-15 Thread Antonio Cardenes
Hello folks, I'm trying to improve my Phyton skills with a project: A
fitness program that can correlate measurements (weight and size of various
body parts), date taken and it has to be able to print a nice graph showing
improvements (a la Wii Fit)

I was wondering if you could point me in the right path (modules and such),
thanks.

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


Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Antonio Caminero Garcia
Hello, I am having a hard time deciding what IDE or IDE-like code editor should 
I use. This can be overwhelming.

So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm, IntelliJ 
with Python plugin. 

The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ, 
Pycharm) is that they look like a space craft dashboard and that unwarranted 
resources consumption and the unnecessary icons. I want my IDE to be 
minimalistic but powerful. My screen should be mostly “made of code” as usually 
happens in Vim, Sublime or Atom. However, Pycharm is really cool and python 
oriented.

The problem with Vim is the learning curve, so I know the very basic stuff, but 
obviously not enough for coding and I do not have time to learn it, it is a 
pity because there are awesome plugins that turns Vim into a lightweight 
powerful IDE-like. So now it is not an option but I will reconsider it in the 
future, learning little by little. Also, I am not very fan GUI guy if the task 
can be accomplished through the terminal. However, I don’t understand why 
people underrate GUIs, that said I normally use shortcuts for the most frequent 
tasks and when I have to do something that is not that frequent then I do it 
with the mouse, for the latter case in vim you would need to look for that 
specific command every time. 

Sublime is my current and preferred code editor. I installed Anaconda, Git 
integration and a couple of additional plugins that make sublime very powerful. 
Also, what I like about sublime compared to the full featured IDEs, besides the 
minimalism, is how you can perform code navigation back and forth so fast, I 
mean this is something that you can also do with the others but for some 
subjective reason I specifically love how sublime does it. The code completion 
in sublime I do not find it very intelligence, the SublimeCodeIntel is better 
than the one that Anaconda uses but the completions are not as verbose as in 
the IDEs.

Now, I am thinking about giving a try to Visual Studio Code Edition (take a 
look, it sounds good 
https://marketplace.visualstudio.com/items?itemName=donjayamanne.python). I 
need an editor for professional software development. What would you recommend 
to me?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Antonio Caminero Garcia
On Monday, January 2, 2017 at 8:24:29 AM UTC-8, Michael Torrie wrote:
> On 01/02/2017 04:38 AM, Antonio Caminero Garcia wrote:
> > The problem with Vim is the learning curve, so I know the very basic
> > stuff, but obviously not enough for coding and I do not have time to
> > learn it, it is a pity because there are awesome plugins that turns
> > Vim into a lightweight powerful IDE-like. So now it is not an option
> > but I will reconsider it in the future, learning little by little.
> > Also, I am not very fan GUI guy if the task can be accomplished
> > through the terminal. However, I don’t understand why people
> > underrate GUIs, that said I normally use shortcuts for the most
> > frequent tasks and when I have to do something that is not that
> > frequent then I do it with the mouse, for the latter case in vim you
> > would need to look for that specific command every time.
> 
> Really, the basic stuff is enough to be very productive in vim.  In fact
> just knowing how to save and quit is half the battle!  A little cheat
> sheet for vim by your keyboard would be plenty I think.  If all you knew
> was how to change modes, insert, append, change word, yank, delete, and
> paste, that is 99% of what you'd use every day.  You can use normal
> arrow keys, home, end, and page up and page down for cursor movement in
> vim, so even if you can't remember ^,$, gg, or GG, you'll do fine.
> Eventually you can begin to add in other things, like modifiers to c
> (change).
> 
> There probably are a lot of nice plugins for ViM, but I use none of
> them. I just don't find them that useful.  I don't seem to need any IDE
> help with Python.

yeah, for me I think of the IDE (and computers in general must be seen like 
that) as a coworker or as paring programming experience. So I agree I have been 
developing in Python without IDE a long time and I know if I had some features 
borrow from full featured IDEs will definitely   help me out.I will give a try 
to Vim asap, now I am trying Visual Studio now and it seems that is all I want.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Antonio Caminero Garcia
On Monday, January 2, 2017 at 5:57:51 PM UTC-8, Steve D'Aprano wrote:
> On Mon, 2 Jan 2017 10:38 pm, Antonio Caminero Garcia wrote:
> 
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor
> > should I use. This can be overwhelming.
> 
> Linux is my IDE.
> 
> https://sanctum.geek.nz/arabesque/series/unix-as-ide/
> 
> 
> I dislike the Unix-style Vim/Emacs text editors, I prefer a traditional
> GUI-based editor. So my "IDE" is:
> 
> - Firefox, for doing searches and looking up documentation;
> 
> - an GUI programmer's editor, preferably one with a tab-based 
>   interface, such as geany or kate;
> 
> - a tab-based terminal.
> 
> Both geany and kate offer auto-completion based on previously seen words.
> They won't auto-complete function or method signatures, but in my my
> experience this is the "ninety percent" solution: word-based auto-complete
> provides 90% of the auto-complete functionality without the cost of full
> signature-based auto-complete.
> 
> In the terminal, I have at least three tabs open: one open to the Python
> interactive interpreter, for testing code snippets and help(obj); one where
> I run my unit tests ("python -m unittest myproject_tests"); and one where I
> do any assorted other tasks, such as file management, checking code into
> the repo, etc.
> 
> I've played with mypy a few times, but not used it seriously in any
> projects. If I did, I would run that from the command line too, like the
> unit tests. Likewise for any linters or equivalent.
> 
> 
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
> > IntelliJ with Python plugin.
> > 
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ,
> > Pycharm) is that they look like a space craft dashboard and that
> > unwarranted resources consumption and the unnecessary icons. 
> 
> Indeed. If they provide any useful functionality I don't already have, I've
> never come across it. The only thing I'd like to try is an editor that
> offers semantic highlighting instead of syntax highlighting:
> 
> https://medium.com/@evnbr/coding-in-color-3a6db2743a1e
> 
> I once tried Spyder as an IDE, and found that it was so bloated and slow it
> couldn't even keep up with my typing. I'm not even a touch typist! I'd
> start to type a line like:
> 
> except ValueError as err:
> 
> 
> and by the time my fingers were hitting the colon, Spyder was displaying
> `excep` in red flagged with an icon indicating a syntax error.
> 
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.

Thanks for remind the Unix capabilities as IDE, that post was cool to read.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-02 Thread Antonio Caminero Garcia
Guys really thank you for your answers. Basically now I am more emphasizing in 
learning in depth a tool and get stick to it so I can get a fast workflow. 
Eventually I will learn Vim and its python developing setup, I know people who 
have been programming using Vim for almost 20 years and they did not need to 
change editor (that is really awesome). 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-03 Thread Antonio Caminero Garcia
On Tuesday, January 3, 2017 at 4:12:34 PM UTC-8, Dietmar Schwertberger wrote:
> On 02.01.2017 12:38, Antonio Caminero Garcia wrote:
> You did not try Wing IDE? It looks less like a spacecraft. Maybe you 
> like it.
> Maybe the difference is that Wing is from Python people while the ones 
> you listed are from Java people.

That sounds interesting. By the look of it I think I am going to give it a try.

> For something completely different (microcontroller programming in C) I 
> just switched to a Eclipse derived IDE and I don't like it too much as 
> the tool does not focus on the problem scope.

If it happens to be Arduino I normally use a sublime plugin called Stino
https://github.com/Robot-Will/Stino 
(1337 people starred that cool number :D)

>  From your posts I'm not sure whether you want an editor or an IDE, 
> where for me the main difference is the debugger and code completion.

I want editor with those IDE capabilities and git integration, with optionally  
cool stuff as for example remote debugging. 

> I would not want to miss the IDE features any more, even though in my 
> first 15 years of Python I thought that a debugger is optional with 
> Python ...

Unfortunately most of the time I am still using print and input functions. I 
know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.

> Regards,
> 
> Dietmar

Thank you so much for your answer. 

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Tuesday, January 3, 2017 at 4:12:34 PM UTC-8, Dietmar Schwertberger wrote:
> On 02.01.2017 12:38, Antonio Caminero Garcia wrote:
> You did not try Wing IDE? It looks less like a spacecraft. Maybe you
> like it.
> Maybe the difference is that Wing is from Python people while the ones
> you listed are from Java people.

That sounds interesting. By the look of it I think I am going to give it a try.

> For something completely different (microcontroller programming in C) I
> just switched to a Eclipse derived IDE and I don't like it too much as
> the tool does not focus on the problem scope.

If it happens to be Arduino I normally use a sublime plugin called Stino 
https://github.com/Robot-Will/Stino
(1337 people starred that cool number :D)

>  From your posts I'm not sure whether you want an editor or an IDE,
> where for me the main difference is the debugger and code completion.

I want editor with those IDE capabilities and git integration, with optionally 
cool stuff as for example remote debugging.

> I would not want to miss the IDE features any more, even though in my
> first 15 years of Python I thought that a debugger is optional with
> Python ...

Unfortunately most of the time I am still using print and input functions. I 
know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.

> Regards,
>
> Dietmar

Thank you so much for your answer.

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 12:32:19 PM UTC-8, fpp wrote:
> > On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> > wrote: 
> >> I want an IDE that I can use at work and home, linux and dare I say
> >> windows.
> >> Sublime, had to remove it from my work PC as it is not licensed.
> >> Atom, loved it until it slowed down.
> >> VIM, ok the best if you know vi inside out.
> >> Any JAVA based IDE, just slows up on work PC's due to all the
> >> background stuff that corporates insist they run.
> >> Why can not someone more clever than I fork DrPython and bring it up
> >> to date.
> >> Its is fast, looks great and just does the job ?
> 
> I'm suprised no one in this rich thread has even mentioned SciTE :
> http://www.scintilla.org/
> 
> Admittedly it's closer to an excellent code editor than a full-blown IDE.
> But it's very lightweight and fast, cross-platform, has superb syntax 
> coloring and UTF8 handling, and is highly configurable through its 
> configuration file(s) and embedded LUA scripting.
> It's also well maintained : version 1.0 came out in 1999, and the latest 
> (3.7.2) is just a week old...
> 
> Its IDE side consists mostly of hotkeys to run the interpreter or 
> compiler for the language you're editing, with the file in the current 
> tab.
> A side pane shows the output (prints, exceptions, errors etc.) of the 
> running script.
> A nice touch is that it understands these error messages and makes them 
> clickable, taking you to the tab/module/line where the error occurred.
> Also, it can save its current tabs (and their state) to a "session" file 
> for later reloading, which is close to the idea of a "project" in most 
> IDEs.
> Oh, and it had multi-selection and multi-editing before most of the new 
> IDEs out there :-)
> 
> Personally that's about all I need for my Python activities, but it can 
> be customized much further than I have done : there are "hooks" for other 
> external programs than compilers/interpreters, so you can also run a 
> linter, debugger or cvs from the editor.
> 
> One word of warning: unlike most newer IDEs which tend to be shiny-shiny 
> and ful of bells and whistles at first sight, out of the box SciTE is 
> *extremely* plain looking (you could even say drab, or ugly :-).
> It is up to you to decide how it should look and what it should do or 
> not, through the configuration file.
> Fortunately the documentation is very thorough, and there are a lot of 
> examples lying around to be copy/pasted (like a dark theme, LUA scripts 
> etc.).
> 
> Did I mention it's lightweight ? The archive is about 1.5 MB and it just 
> needs unzipping, no installation. May be worth a look if you haven't 
> tried it yet...
> fp

Interesting thanks for the link. There are a huge diversity when it comes to 
IDEs/editors. Now I have more than enough options. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 9:51:17 AM UTC-8, ArnoB wrote:
> On 02-01-17 12:38, Antonio Caminero Garcia wrote:
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor 
> > should I use. This can be overwhelming.
> >
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm, 
> > IntelliJ with Python plugin.
> >
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ, 
> > Pycharm) is that they look like a space craft dashboard and that 
> > unwarranted resources consumption and the unnecessary icons. I want my IDE 
> > to be minimalistic but powerful. My screen should be mostly “made of code” 
> > as usually happens in Vim, Sublime or Atom. However, Pycharm is really cool 
> > and python oriented.
> >
> > The problem with Vim is the learning curve, so I know the very basic stuff, 
> > but obviously not enough for coding and I do not have time to learn it, it 
> > is a pity because there are awesome plugins that turns Vim into a 
> > lightweight powerful IDE-like. So now it is not an option but I will 
> > reconsider it in the future, learning little by little. Also, I am not very 
> > fan GUI guy if the task can be accomplished through the terminal. However, 
> > I don’t understand why people underrate GUIs, that said I normally use 
> > shortcuts for the most frequent tasks and when I have to do something that 
> > is not that frequent then I do it with the mouse, for the latter case in 
> > vim you would need to look for that specific command every time.
> >
> > Sublime is my current and preferred code editor. I installed Anaconda, Git 
> > integration and a couple of additional plugins that make sublime very 
> > powerful. Also, what I like about sublime compared to the full featured 
> > IDEs, besides the minimalism, is how you can perform code navigation back 
> > and forth so fast, I mean this is something that you can also do with the 
> > others but for some subjective reason I specifically love how sublime does 
> > it. The code completion in sublime I do not find it very intelligence, the 
> > SublimeCodeIntel is better than the one that Anaconda uses but the 
> > completions are not as verbose as in the IDEs.
> >
> > Now, I am thinking about giving a try to Visual Studio Code Edition (take a 
> > look, it sounds good 
> > https://marketplace.visualstudio.com/items?itemName=donjayamanne.python). I 
> > need an editor for professional software development. What would you 
> > recommend to me?
> 
> Hi Antonio,
> 
> Just an extra one in case you'll ever want to create
> a nice GUI, then there's also QT Creator:
> https://wiki.qt.io/QtCreator_and_PySide
> 
> A very simple but powerful interface a la XCode...
> 
> It integrates nicely with PySide:
> https://wiki.qt.io/QtCreator_and_PySide
> 
> gr
> Arno

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do not know what to choose.

2017-01-06 Thread Antonio Caminero Garcia
On Wednesday, January 4, 2017 at 1:10:04 PM UTC-8, Dietmar Schwertberger wrote:
> On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> > Unfortunately most of the time I am still using print and input functions. 
> > I know that sucks, I did not use the pdb module, I guess that IDE debuggers 
> > leverage such module.
> pdb is actually quite useful. On my Windows PCs I can invoke python on 
> any .py file with the -i command line switch by right clicking in the 
> Explorer and selecting "Debug". Now when the script crashes, I can 
> inspect variables without launching a full-scale IDE or starting the 
> script from the command line. For such quick fixes I have also a context 
> menu entry "Edit" for editing with Pythonwin, which is still quite OK as 
> editor and has no licensing restrictions or installation requirements. 
> This is a nice option when you deploy your installation to many PCs over 
> the network.
I am on MacOS but interesting way of debugging, I will take the idea.
> 
> For the print functions vs. debugger:
> The most useful application for a debugger like Wing is not for 
> bug-fixing, but to set a break point and then interactively develop on 
> the debugger console and with the IDE editor's autocompletion using 
> introspection on the live objects. This is very helpful for hardware 
> interfacing, network protocols or GUI programs. It really boosted my 
> productivity in a way I could not believe before. This is something most 
> people forget when they evaluate programming languages. It's not the 
> language or syntax that counts, but the overall environment. Probably 
> the only other really interactive language and environment is Forth.
> 
This is exactly part of the capabilities that I am looking for. I loved you 
brought that up. When I think of an ideal IDE (besides the desirable features 
that I already mentioned previously) as a coworker who is telling me the 
values,types and ids that the objects are getting as you are setting 
breakpoints. So why not use the debugger interactively to develop
applications. As long as one sets the breakpoints in a meaningful way so you 
can trace your code in a very productive way. Is that what you mean by 
interactive environment?

> > If it happens to be Arduino I normally use a sublime plugin called Stino
> > https://github.com/Robot-Will/Stino
> > (1337 people starred that cool number :D)
> Well, it is CodeWarrior which was quite famous at the time of the 68k Macs.
> The company was bought by Motorola and the IDE is still around for 
> Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series. 
> Around ten years ago the original CodeWarrior IDE was migrated to 
> something Eclipse based.
> When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better 
> debug interface and native USB support. HCS08 is still quite cool, but 
> when it comes to documentation, learning curve, tools etc. the Arduinos 
> win
> 
> 
> Regards,
> 
> Dietmar
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 9:51:17 AM UTC-8, ArnoB wrote:
> On 02-01-17 12:38, Antonio Caminero Garcia wrote:
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor
should I use. This can be overwhelming.
> >
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
IntelliJ with Python plugin.
> >
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ,
Pycharm) is that they look like a space craft dashboard and that unwarranted 
resources consumption and the unnecessary icons. I want my IDE to be 
minimalistic but powerful. My screen should be mostly â £made of codeâ Ø as 
usually happens in Vim, Sublime or Atom. However, Pycharm is really cool and 
python oriented.
> >
> > The problem with Vim is the learning curve, so I know the very basic stuff,
but obviously not enough for coding and I do not have time to learn it, it is a 
pity because there are awesome plugins that turns Vim into a lightweight 
powerful IDE-like. So now it is not an option but I will reconsider it in the 
future, learning little by little. Also, I am not very fan GUI guy if the task 
can be accomplished through the terminal. However, I donâ Öt understand why 
people underrate GUIs, that said I normally use shortcuts for the most frequent 
tasks and when I have to do something that is not that frequent then I do it 
with the mouse, for the latter case in vim you would need to look for that 
specific command every time.
> >
> > Sublime is my current and preferred code editor. I installed Anaconda, Git
integration and a couple of additional plugins that make sublime very powerful. 
Also, what I like about sublime compared to the full featured IDEs, besides the 
minimalism, is how you can perform code navigation back and forth so fast, I 
mean this is something that you can also do with the others but for some 
subjective reason I specifically love how sublime does it. The code completion 
in sublime I do not find it very intelligence, the SublimeCodeIntel is better 
than the one that Anaconda uses but the completions are not as verbose as in 
the IDEs.
> >
> > Now, I am thinking about giving a try to Visual Studio Code Edition (take a
look, it sounds good https://marketplace.visualstudio.com/items?itemName=donjay 
amanne.python). I need an editor for professional software development. What 
would you recommend to me?
>
> Hi Antonio,
>
> Just an extra one in case you'll ever want to create
> a nice GUI, then there's also QT Creator:
> https://wiki.qt.io/QtCreator_and_PySide
>
> A very simple but powerful interface a la XCode...
>
> It integrates nicely with PySide:
> https://wiki.qt.io/QtCreator_and_PySide
>
> gr
> Arno

Thanks!

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 12:32:19 PM UTC-8, fpp wrote:
> > On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> > wrote:
> >> I want an IDE that I can use at work and home, linux and dare I say
> >> windows.
> >> Sublime, had to remove it from my work PC as it is not licensed.
> >> Atom, loved it until it slowed down.
> >> VIM, ok the best if you know vi inside out.
> >> Any JAVA based IDE, just slows up on work PC's due to all the
> >> background stuff that corporates insist they run.
> >> Why can not someone more clever than I fork DrPython and bring it up
> >> to date.
> >> Its is fast, looks great and just does the job ?
>
> I'm suprised no one in this rich thread has even mentioned SciTE :
> http://www.scintilla.org/
>
> Admittedly it's closer to an excellent code editor than a full-blown IDE.
> But it's very lightweight and fast, cross-platform, has superb syntax
> coloring and UTF8 handling, and is highly configurable through its
> configuration file(s) and embedded LUA scripting.
> It's also well maintained : version 1.0 came out in 1999, and the latest
> (3.7.2) is just a week old...
>
> Its IDE side consists mostly of hotkeys to run the interpreter or
> compiler for the language you're editing, with the file in the current
> tab.
> A side pane shows the output (prints, exceptions, errors etc.) of the
> running script.
> A nice touch is that it understands these error messages and makes them
> clickable, taking you to the tab/module/line where the error occurred.
> Also, it can save its current tabs (and their state) to a "session" file
> for later reloading, which is close to the idea of a "project" in most
> IDEs.
> Oh, and it had multi-selection and multi-editing before most of the new
> IDEs out there :-)
>
> Personally that's about all I need for my Python activities, but it can
> be customized much further than I have done : there are "hooks" for other
> external programs than compilers/interpreters, so you can also run a
> linter, debugger or cvs from the editor.
>
> One word of warning: unlike most newer IDEs which tend to be shiny-shiny
> and ful of bells and whistles at first sight, out of the box SciTE is
> *extremely* plain looking (you could even say drab, or ugly :-).
> It is up to you to decide how it should look and what it should do or
> not, through the configuration file.
> Fortunately the documentation is very thorough, and there are a lot of
> examples lying around to be copy/pasted (like a dark theme, LUA scripts
> etc.).
>
> Did I mention it's lightweight ? The archive is about 1.5 MB and it just
> needs unzipping, no installation. May be worth a look if you haven't
> tried it yet...
> fp

Interesting thanks for the link. There are a huge diversity when it comes to 
IDEs/editors. Now I have more than enough options.

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Wednesday, January 4, 2017 at 1:10:04 PM UTC-8, Dietmar Schwertberger wrote:
> On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> > Unfortunately most of the time I am still using print and input functions.
I know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.
> pdb is actually quite useful. On my Windows PCs I can invoke python on
> any .py file with the -i command line switch by right clicking in the
> Explorer and selecting "Debug". Now when the script crashes, I can
> inspect variables without launching a full-scale IDE or starting the
> script from the command line. For such quick fixes I have also a context
> menu entry "Edit" for editing with Pythonwin, which is still quite OK as
> editor and has no licensing restrictions or installation requirements.
> This is a nice option when you deploy your installation to many PCs over
> the network.
I am on MacOS but interesting way of debugging, I will take the idea.
>
> For the print functions vs. debugger:
> The most useful application for a debugger like Wing is not for
> bug-fixing, but to set a break point and then interactively develop on
> the debugger console and with the IDE editor's autocompletion using
> introspection on the live objects. This is very helpful for hardware
> interfacing, network protocols or GUI programs. It really boosted my
> productivity in a way I could not believe before. This is something most
> people forget when they evaluate programming languages. It's not the
> language or syntax that counts, but the overall environment. Probably
> the only other really interactive language and environment is Forth.
>
This is exactly part of the capabilities that I am looking for. I loved you 
brought that up. When I think of an ideal IDE (besides the desirable features 
that I already mentioned previously) as a coworker who is telling me the 
values,types and ids that the objects are getting as you are setting 
breakpoints. So why not use the debugger interactively to develop applications. 
As long as one sets the breakpoints in a meaningful way so you can trace your 
code in a very productive way. Is that what you mean by interactive 
environment?

> > If it happens to be Arduino I normally use a sublime plugin called Stino
> > https://github.com/Robot-Will/Stino
> > (1337 people starred that cool number :D)
> Well, it is CodeWarrior which was quite famous at the time of the 68k Macs.
> The company was bought by Motorola and the IDE is still around for
> Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series.
> Around ten years ago the original CodeWarrior IDE was migrated to
> something Eclipse based.
> When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better
> debug interface and native USB support. HCS08 is still quite cool, but
> when it comes to documentation, learning curve, tools etc. the Arduinos
> win
>
>
> Regards,
>
> Dietmar

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


Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Antonio Caminero Garcia
On Friday, January 6, 2017 at 6:04:33 AM UTC-8, Peter Otten wrote:
> Example: you are looking for the minimum absolute value in a series of 
> integers. As soon as you encounter the first 0 it's unnecessary extra work 
> to check the remaining values, but the builtin min() will continue.
> 
> The solution is a minimum function that allows the user to specify a stop 
> value:
> 
> >>> from itertools import count, chain
> >>> stopmin(chain(reversed(range(10)), count()), key=abs, stop=0)
> 0
> 
> How would you implement stopmin()?
> 
> Currently I raise an exception in the key function:
> 
> class Stop(Exception):
> pass
> 
> def stopmin(items, key, stop):
> """
> >>> def g():
> ... for i in reversed(range(10)):
> ... print(10*i)
> ... yield str(i)
> >>> stopmin(g(), key=int, stop=5)
> 90
> 80
> 70
> 60
> 50
> '5'
> """
> def key2(value):
> result = key(value)
> if result <= stop:
> raise Stop(value)
> return result
> try:
> return min(items, key=key2)
> except Stop as stop:
> return stop.args[0]

This is the simplest version I could come up with. I also like the classic 100% 
imperative, but it seems that is not trendy between the solutions given :D.

you can test it here https://repl.it/FD5A/0
source code:

from itertools import accumulate

# stopmin calculates the greatest lower bound (infimum). 
# https://upload.wikimedia.org/wikipedia/commons/0/0a/Infimum_illustration.svg 

def takeuntil(pred, seq):
  for item in seq:
yield item
if not pred(item):
  break

def stopmin(seq, stop=0):
  drop_ltstop = (item for item in seq if item >= stop)
  min_gen = (min_ for min_ in accumulate(drop_ltstop, func=min))
  return list(takeuntil(lambda x: x!= stop, min_gen))[-1]

seq = [1, 4, 7, -8, 0, 7, -8, 9] # 0 just until zero is generated
seq = [1, 4, 7, -8, 7, -8, 9] # 1 the entire sequence is generated

print(stopmin(seq, stop=0))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Temporary variables in list comprehensions

2017-01-09 Thread Antonio Caminero Garcia
On Sunday, January 8, 2017 at 7:53:37 PM UTC-8, Steven D'Aprano wrote:
> Suppose you have an expensive calculation that gets used two or more times in 
> a 
> loop. The obvious way to avoid calculating it twice in an ordinary loop is 
> with 
> a temporary variable:
> 
> result = []
> for x in data:
> tmp = expensive_calculation(x)
> result.append((tmp, tmp+1))
> 
> 
> But what if you are using a list comprehension? Alas, list comps don't let 
> you 
> have temporary variables, so you have to write this:
> 
> 
> [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]
> 
> 
> Or do you? ... no, you don't!
> 
> 
> [(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]
> 
> 
> I can't decide whether that's an awesome trick or a horrible hack...
> 
> 
> -- 
> Steven
> "Ever since I learned about confirmation bias, I've been seeing 
> it everywhere." - Jon Ronson

Hello I saw some memoizing functions, in that sense you can use the 
functools.lru_cache decorator, that is even better if you have repeated 
elements in data.

@functools.lru_cache
def expensive_calculation(x):
# very NP-hard calculation
pass


Hope that helps :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: repeat items in a list

2016-03-29 Thread Antonio Caminero Garcia
On Monday, March 28, 2016 at 11:26:08 PM UTC+2, Chris Angelico wrote:
> On Tue, Mar 29, 2016 at 4:30 AM, Rob Gaddi
>  wrote:
> > beliav...@aol.com wrote:
> >
> >> On Saturday, March 26, 2016 at 7:24:10 PM UTC-4, Erik wrote:
> >>>
> >>> Or, if you want to "import operator" first, you can use 'operator.add'
> >>> instead of the lambda (but you _did_ ask for a one-liner ;)).
> >>>
> >>> Out of interest, why the fascination with one-liners?
> >>
> >> Thanks for your reply. Sometimes when I program in Python I think I am not 
> >> using the full capabilities of the language, so I want to know if there are
> >> more concise ways of doing things.
> >
> > Concise is only worth so much.  PEP20 tells us "Explicit is better than
> > implicit", "Simple is better than complex" and "If the implementation is
> > hard to explain, it's a bad idea".
> >
> > Python is a beautifully expressive language.  Your goal should not be to
> > write the minimum number of lines of code to accomplish the task.
> > Your goal should be to write the code such that your grandmother can
> > understand it.  That way, when you screw it up, you'll be able to easily
> > figure out where and how you did so.  Or failing that, you can get
> > grangran to show you.
> 
> Just out of interest, did you (generic you) happen to notice Mark's
> suggestion? It's a one-liner that nicely expresses the intention and
> accomplishes the goal:
> 
> yy = [aa for aa in xx for _ in range(nrep)]
> 
> It quietly went through without fanfare, but I would say this is the
> perfect solution to the original problem.
> 
> ChrisA

Of course that's definitely the most pythonic sol to this prob :)! Just wanted 
to point out the use of the operator "*" in lists.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: repeat items in a list

2016-03-27 Thread Antonio Caminero Garcia
On Saturday, March 26, 2016 at 11:12:58 PM UTC+1, beli...@aol.com wrote:
> I can create a list that has repeated elements of another list as follows:
> 
> xx = ["a","b"]
> nrep = 3
> print xx
> yy = []
> for aa in xx:
> for i in range(nrep):
> yy.append(aa)
> print yy
> 
> output:
> ['a', 'b']
> ['a', 'a', 'a', 'b', 'b', 'b']
> 
> Is there a one-liner to create a list with repeated elements?

What about this?

def rep_elements(sequence, nrep):
#return [ritem for item in sequence for ritem in [item]*nrep]
return list(chain.from_iterable(([item]*nrep for item in sequence)))

sequence = ['h','o','l','a']
print(rep_elements(sequence,  3))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: repeat items in a list

2016-03-27 Thread Antonio Caminero Garcia
On Sunday, March 27, 2016 at 10:02:44 AM UTC+2, Antonio Caminero Garcia wrote:
> On Saturday, March 26, 2016 at 11:12:58 PM UTC+1, beli...@aol.com wrote:
> > I can create a list that has repeated elements of another list as follows:
> > 
> > xx = ["a","b"]
> > nrep = 3
> > print xx
> > yy = []
> > for aa in xx:
> > for i in range(nrep):
> > yy.append(aa)
> > print yy
> > 
> > output:
> > ['a', 'b']
> > ['a', 'a', 'a', 'b', 'b', 'b']
> > 
> > Is there a one-liner to create a list with repeated elements?
> 
> What about this?
> 
> def rep_elements(sequence, nrep):
> #return [ritem for item in sequence for ritem in [item]*nrep]
> return list(chain.from_iterable(([item]*nrep for item in sequence)))
> 
> sequence = ['h','o','l','a']
> print(rep_elements(sequence,  3))

I prefer the commented solution :).

[ritem for item in sequence for ritem in [item]*nrep] # O(len(sequence)*2nrep) 

and the chain solution  would be # O(len(sequence)*nrep). The constants ate 
gone so I prefer the first one for its readibility.

On a practical level:

https://bpaste.net/show/fe3431a13732
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: repeat items in a list

2016-03-27 Thread Antonio Caminero Garcia
On Sunday, March 27, 2016 at 11:52:22 AM UTC+2, larudwer wrote:
> how about
> 
>   sorted(["a", "b"]*3)
> ['a', 'a', 'a', 'b', 'b', 'b']

that's cooler, less efficient though and do not maintain the original order. In 
case such order was important, you should proceed as follows:

If the elements are unique, this would work:

sorted(sequence*nrep, key=sequence.index)

Otherwise you'd need a more complex key function (maybe a method of a class 
with a static variable that tracks the number of times that such method is 
called and with a "dynamic index functionality" that acts accordingly (i-th 
nrep-group of value v)) and imo it does not worth it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Unimporting modules, memory leak?

2006-06-13 Thread Antonio Arauzo Azofra

Hello everybody,

Probably, this is being too demanding for Python, but it may be
useful to unimport modules to work with dynamic code (though not the
best, one example is [2]). In fact, it is supposed to be possible[1],
but I have detected it usually leaks memory.

When unimported in Linux, the simple C module attached (has no
functions, just the structure) leaks two memory pages

To see the test you can just put the files in a directory and:
 python setupmod1.py install --install-lib .
 python testMemory.py

Its output follows. First, the memory used before import. Second memory
used after the import. Third the number of references to that object is
checked before using del. Finally the memory used after unimporting.

-- Testing mod1 --
Mem. used: 1242 (gc: 0 )
Mem. used: 1244 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing bigModule --
Mem. used: 1244 (gc: 0 )
Mem. used: 2686 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing random --
Mem. used: 1244 (gc: 0 )
Mem. used: 1256 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1256 (gc: 57 )

Unimporting attached "bigmodule.py" there are no memory leaks.
Unimporting python's random module it leaks some pages, but garbage
collector admit it can not free them.

If a module with the same name that the unimported module is imported,
the pages are reused. While, if this same module is loaded with another
name, they are not freed, and the program grows with each module
imported/unimported

Is this a Python bug? A Linux bug? Am i missing some way of freeing that
memory used by C module?

[1] http://mail.python.org/pipermail/python-list/1999-May/002669.html
[2] http://ax5.com/antonio/orangesnns
--
Saludos,
  Antonio Arauzo Azofra

def funcion_de_prueba(a,b):
  print a,b

big_list = []
for i in xrange(1000):
big_list.append(1000 * 'bg')




from distutils.core import setup, Extension

module1 = Extension('mod1',
  sources = ['srcmod1.c'])

setup (name = 'OrangeSNNStmp',
 version = '1.0',
 description = 'Function that calls a trained NN',
 ext_modules = [module1])



#include 

static PyMethodDef orangeSnnsTmpMethods[] = {
{NULL, NULL, 0, NULL}/* Sentinel */
};

PyMODINIT_FUNC
initmod1(void)
{
(void) Py_InitModule("mod1", orangeSnnsTmpMethods);
}



#
# Test memory comsumption importing and unimporting modules
#
import gc, os, sys

def printMemoryUse():
  rgc = gc.collect()
  f = open("/proc/" + str(os.getpid()) + "/statm")
  totalMemorySize = f.readline().split()[0]
  f.close()
  print "Mem. used:", totalMemorySize, "(gc:", rgc, ")"

def testImport(moduleName):
  print "-- Testing", moduleName, "--"
  printMemoryUse()

  module = __import__(moduleName, globals(), locals())
  printMemoryUse()

  del sys.modules[moduleName]
  print "Check refs (should be = 2):", sys.getrefcount(module)
  del module
  printMemoryUse()


testImport("mod1")
testImport("bigModule")
testImport("random")









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

Unimporting modules, memory leak?

2006-06-14 Thread Antonio Arauzo Azofra
Hello everybody,

Probably, this is being too demanding for Python, but it may be
useful to unimport modules to work with dynamic code (though not the
best, one example is [2]). In fact, it is supposed to be possible[1],
but I have detected it usually leaks memory.

When unimported in Linux, the simple C module attached (has no
functions, just the structure) leaks two memory pages

To see the test you can just put the attached files in a directory and:
 python setupmod1.py install --install-lib .
 python testMemory.py

Its output follows. First, the memory used before import. Second memory
used after the import. Third the number of references to that object is
checked before using del. Finally the memory used after unimporting.

-- Testing mod1 --
Mem. used: 1242 (gc: 0 )
Mem. used: 1244 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing bigModule --
Mem. used: 1244 (gc: 0 )
Mem. used: 2686 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing random --
Mem. used: 1244 (gc: 0 )
Mem. used: 1256 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1256 (gc: 57 )

Unimporting attached "bigmodule.py" there are no memory leaks.
Unimporting python's random module it leaks some pages, but garbage
collector admit it can not free them.

If a module with the same name that the unimported module is imported,
the pages are reused. While, if this same module is loaded with another
name, they are not freed, and the program grows with each module
imported/unimported

Is this a Python bug? A Linux bug? Am i missing some way of freeing that
memory used by C module?

[1] http://mail.python.org/pipermail/python-list/1999-May/002669.html
[2] http://ax5.com/antonio/orangesnns

PD. If I attach the files the message does not reach to the list :-? 
Code follows:

bigModule.py

def funcion_de_prueba(a,b):
   print a,b

big_list = []
for i in xrange(1000):
 big_list.append(1000 * 'bg')


setupmod1.py

from distutils.core import setup, Extension

module1 = Extension('mod1',
   sources = ['srcmod1.c'])

setup (name = 'OrangeSNNStmp',
  version = '1.0',
  description = 'Function that calls a trained NN',
  ext_modules = [module1])



srcmod1.c---

#include 

static PyMethodDef orangeSnnsTmpMethods[] = {
 {NULL, NULL, 0, NULL}/* Sentinel */
};

PyMODINIT_FUNC
initmod1(void)
{
 (void) Py_InitModule("mod1", orangeSnnsTmpMethods);
}



testMemory.py---

#
# Test memory comsumption importing and unimporting modules
#
import gc, os, sys

def printMemoryUse():
   rgc = gc.collect()
   f = open("/proc/" + str(os.getpid()) + "/statm")
   totalMemorySize = f.readline().split()[0]
   f.close()
   print "Mem. used:", totalMemorySize, "(gc:", rgc, ")"

def testImport(moduleName):
   print "-- Testing", moduleName, "--"
   printMemoryUse()

   module = __import__(moduleName, globals(), locals())
   printMemoryUse()

   del sys.modules[moduleName]
   print "Check refs (should be = 2):", sys.getrefcount(module)
   del module
   printMemoryUse()


testImport("mod1")
testImport("bigModule")
testImport("random")


-- 
Regards,
   Antonio Arauzo Azofra
-- 
http://mail.python.org/mailman/listinfo/python-list


Unimporting modules, memory leak?

2006-06-16 Thread Antonio Arauzo Azofra

Hello everybody,

Probably, this is being too demanding for Python, but it may be
useful to unimport modules to work with dynamic code (though not the
best, one example is [2]). In fact, it is supposed to be possible[1],
but I have detected it usually leaks memory.

When unimported in Linux, the simple C module attached (has no
functions, just the structure) leaks two memory pages

To see the test you can just put the files in a directory and:
python setupmod1.py install --install-lib .
python testMemory.py

Its output follows. First, the memory used before import. Second memory
used after the import. Third the number of references to that object is
checked before using del. Finally the memory used after unimporting.

-- Testing mod1 --
Mem. used: 1242 (gc: 0 )
Mem. used: 1244 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing bigModule --
Mem. used: 1244 (gc: 0 )
Mem. used: 2686 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1244 (gc: 0 )
-- Testing random --
Mem. used: 1244 (gc: 0 )
Mem. used: 1256 (gc: 0 )
Check refs (should be = 2): 2
Mem. used: 1256 (gc: 57 )

Unimporting attached "bigmodule.py" there are no memory leaks.
Unimporting python's random module it leaks some pages, but garbage
collector admit it can not free them.

If a module with the same name that the unimported module is imported,
the pages are reused. While, if this same module is loaded with another
name, they are not freed, and the program grows with each module
imported/unimported

Is this a Python bug? A Linux bug? Am i missing some way of freeing that
memory used by C module?

[1] http://mail.python.org/pipermail/python-list/1999-May/002669.html
[2] http://ax5.com/antonio/orangesnns
--
All the best,
Antonio Arauzo Azofra



def funcion_de_prueba(a,b):
  print a,b

big_list = []
for i in xrange(1000):
big_list.append(1000 * 'bg')



from distutils.core import setup, Extension

module1 = Extension('mod1',
  sources = ['srcmod1.c'])

setup (name = 'OrangeSNNStmp',
 version = '1.0',
 description = 'Function that calls a trained NN',
 ext_modules = [module1])


#include 

static PyMethodDef orangeSnnsTmpMethods[] = {
{NULL, NULL, 0, NULL}/* Sentinel */
};

PyMODINIT_FUNC
initmod1(void)
{
(void) Py_InitModule("mod1", orangeSnnsTmpMethods);
}


#
# Test memory comsumption importing and unimporting modules
#
import gc, os, sys

def printMemoryUse():
  rgc = gc.collect()
  f = open("/proc/" + str(os.getpid()) + "/statm")
  totalMemorySize = f.readline().split()[0]
  f.close()
  print "Mem. used:", totalMemorySize, "(gc:", rgc, ")"

def testImport(moduleName):
  print "-- Testing", moduleName, "--"
  printMemoryUse()

  module = __import__(moduleName, globals(), locals())
  printMemoryUse()

  del sys.modules[moduleName]
  print "Check refs (should be = 2):", sys.getrefcount(module)
  del module
  printMemoryUse()


testImport("mod1")
testImport("bigModule")
testImport("random")








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

Re: finding monitor or screen resolution in Linux with standard python module

2007-03-07 Thread José Antonio Salazar Montenegro
I'm using Beryl too, and xwininfo -root gives te correct resolution.

akbar wrote:
> I googled and searched in archive. All I can find is finding
> resolution with Tkinter and pygame. Any idea to find monitor
> resolution with standard python module?
> I can check from output of: xprop -root
> _NET_DESKTOP_GEOMETRY(CARDINAL) . The problem is when you use Beryl or
> Xgl, it is not correct anymore because Beryl or Xgl set this value
> from amount of workspaces multiplied by monitor or screen resolution.
>
>   

NOTA: La informacion de este correo es de propiedad exclusiva y confidencial. 
Este mensaje es solo para el destinatario indicado, si usted no lo es, 
destruyalo de inmediato. Ninguna informacion aqui contenida debe ser entendida 
como dada o avalada por MADISA, sus subsidiarias o sus empleados, salvo cuando 
ello expresamente se indique. Es responsabilidad de quien recibe este correo de 
asegurarse que este libre de virus, por lo tanto ni MADISA, sus subsidiarias ni 
sus empleados aceptan responsabilidad alguna.

NOTE: The information in this email is proprietary and confidential. This 
message is for the designated recipient only, if you are not the intended 
recipient, you should destroy it immediately. Any information in this message 
shall not be understood as given or endorsed by MADISA, its subsidiaries or 
their employees, unless expressly so stated. It is the responsibility of the 
recipient to ensure that this email is virus free, therefore neither MADISA, 
its subsidiaries nor their employees accept any responsibility.

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


Re: Auto execute python in USB flash disk

2007-03-27 Thread José Antonio Salazar Montenegro




I suspect he wants to do this just for the kicks.

Just for completion, Truecrypt
does precisely what you need. It has to be installed, but you could
carry the installer unencrypted in the same USB drive.


Larry Bates wrote:

  Brian Erhard wrote:
  
  
I am still fairly new to python and wanted to attempt a home made
password protection program.  There are files that I carry on a USB
flash drive that I would like to password protect.  Essentially, I
would like to password protect an entire directory of files.  Is there
a way to auto execute a python script after a user double clicks to
open a folder on the USB drive? How can you capture that double click
event on a specific folder?

Thanks.


  
  Unless you are just doing this to learn, I would suggest you purchase
USB key with encryption included.  They are REALLY cheap.

http://www.kingston.com/flash/DataTravelers_enterprise.asp

-Larry
  



NOTA: La informacion de este correo es de propiedad exclusiva y confidencial. Este mensaje es solo para el destinatario indicado, si usted no lo es, destruyalo de inmediato. Ninguna informacion aqui contenida debe ser entendida como dada o avalada por MADISA, sus subsidiarias o sus empleados, salvo cuando ello expresamente se indique. Es responsabilidad de quien recibe este correo de asegurarse que este libre de virus, por lo tanto ni MADISA, sus subsidiarias ni sus empleados aceptan responsabilidad alguna.
NOTE: The information in this email is proprietary and confidential. This message is for the designated recipient only, if you are not the intended recipient, you should destroy it immediately. Any information in this message shall not be understood as given or endorsed by MADISA, its subsidiaries or their employees, unless expressly so stated. It is the responsibility of the recipient to ensure that this email is virus free, therefore neither MADISA, its subsidiaries nor their employees accept any responsibility.
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Microsoft's challenger to Python

2008-02-07 Thread José Antonio Salazar Montenegro




All the touted features and the integration with .Net and the friendly
Visual Studio IDE will make it a fearsome adversary.
And the name clearly suggests where it intends to harvest converts.

Interesting times ahead.

On 02/07/2008 06:07 PM, Peter Dilley wrote:
Looks like
Microsoft has a language aimed at taking all of Pythons
strengths and attacking its weaknesses. Quoted as a compiled language
that has optional dynamic binding. I've just started investigating the
web site, but this is looking to shape up to a rather decent challenge
to Python for an easy and expressive language with compiled performance
on Mac OS X, Linux, and Windows. I am not, however, an in depth
language nutter, so would appreciate any of our more learned readers
comments.
  
Comparison to Python:
  http://cobra-language.com/docs/python/
  
Main Page:
  http://cobra-language.com/
  
Article that first caught my eye regarding Cobra:
  http://www.computerworld.com.au/index.php/id;342684174;fp;16;fpid;1
  
  Cheers,
Peter
  
  
  
  



NOTA: La informacion de este correo es de propiedad exclusiva y confidencial. Este mensaje es solo para el destinatario indicado, si usted no lo es, destruyalo de inmediato. Ninguna informacion aqui contenida debe ser entendida como dada o avalada por MADISA, sus subsidiarias o sus empleados, salvo cuando ello expresamente se indique. Es responsabilidad de quien recibe este correo de asegurarse que este libre de virus, por lo tanto ni MADISA, sus subsidiarias ni sus empleados aceptan responsabilidad alguna.
NOTE: The information in this email is proprietary and confidential. This message is for the designated recipient only, if you are not the intended recipient, you should destroy it immediately. Any information in this message shall not be understood as given or endorsed by MADISA, its subsidiaries or their employees, unless expressly so stated. It is the responsibility of the recipient to ensure that this email is virus free, therefore neither MADISA, its subsidiaries nor their employees accept any responsibility.
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Python 2.7

2010-11-08 Thread Antonio de Haro Millan
I can not install "*Python Imaging Library 1.1.7 for Python 2.6* (Windows
only)"
because I have the *Python 2.7. *A solution please...

_______
Antonio de Haro Millan
www.de-haro.es
Tf.34.639.972.872
-- 
http://mail.python.org/mailman/listinfo/python-list


subprocess: TTYs and preexec_fn

2023-09-17 Thread Antonio Russo via Python-list
Hello!

I'm trying to run a subprocess (actually several), and control
their terminals (not just stdin and stdout).  I have a use case,
but I won't bore everyone with those details.

I'd rather not use pexpect or ptyprocess, because those expose a
very different interface than Popen.  I've mostly acheived my
goals with the following wrapper around subprocess:


> import subprocess, pty, fcntl, termios, os
> TTY = 'termyTTY'
>
> def Popen(cmd, **kwargs):
> tty = kwargs.pop('tty', None)
> if tty is not None:
> if tty is True:
> tty = pty.openpty()
> master_fd, slave_fd = tty
> old_preexec = kwargs.get('preexec_fn')
> def preexec_fn():
> if old_preexec:
> old_preexec()
> fcntl.ioctl(slave_fd, termios.TIOCSCTTY)
> kwargs['preexec_fn'] = preexec_fn
> kwargs['start_new_session'] = True
> for stkind in ('stdin', 'stdout', 'stderr'):
> if kwargs.get(stkind, None) != TTY:
> continue
> kwargs[stkind] = slave_fd
>
> proc = subprocess.Popen(cmd, **kwargs)
> if tty is not None:
> proc.tty = master_fd
> os.close(slave_fd)
> return proc


This adds a tty keyword argument that spawns a new controlling TTY
and switches the new process to it.  It also allows setting stdin/etc.
separately.  You can, for instance, run ssh and send it a password through
the tty channel, and separately receive piped output from the remote ssh
command.

My questions:

1. Is this already available in a simple way somewhere else, preferably with a
Popen-compatible interface?

2. Is this preexec_fn sufficiently simple that it does not run afoul of the
big, scary threading warning of _posixsubprocess.fork_exec ? I.e., I'm
not touching any locks (besides the GIL... but I'm assuming that would be 
properly
handled?).  CAN this be made safe?  I do plan to use threads and locks.

3. Does this seem widely useful enough to be worth trying to get into Python
itself?  It would be nice if this specific behavior, which probably has even
more nuances than I already am aware of, were safely achievable out of the
box.

Best,
Antonio
-- 
https://mail.python.org/mailman/listinfo/python-list