pandas.datetime addition: What's wrong?

2016-06-07 Thread Paulo da Silva
Hi all! What's wrong with this? import pandas as pd x=pd.to_datetime("20160501") x+pd.DateOffset(days=1) Timestamp('2016-05-02 00:00:00', tz=None) x.__add__(pd.DateOffset(days=1)) NotImplemented More generally I have a class derived from pandas.datetime and I want to implement its own __add__

Re: pandas.datetime addition: What's wrong?

2016-06-07 Thread Paulo da Silva
Às 04:08 de 08-06-2016, MRAB escreveu: > On 2016-06-08 03:09, Paulo da Silva wrote: >> Hi all! >> ... >> >> More generally I have a class derived from pandas.datetime and I want to >> implement its own __add__ that at a given point call super __add__.

conda/anaconda and pip3 (pip)

2018-12-03 Thread Paulo da Silva
Hi! I have an environment created with conda (anaconda3). There is a package that is unavailable in conda. Installing it with pip3, with conda env activated, the installation goes to .local/bin and .local/lib in my home dir (BTW I'm running linux kubuntu 18.04). This also has a bad side effect! It

tkinter resizable text with grid

2018-12-05 Thread Paulo da Silva
Hi! Does anybody know why this code does not expand the text widget when I increase the window size (with mouse)? I want height and width but as minimum (or may be initial) size. import tkinter as tk class App: def __init__(self,master): self.tboard=tk.Text(master,height=

Re: tkinter resizable text with grid

2018-12-06 Thread Paulo da Silva
Às 08:24 de 06/12/18, Peter Otten escreveu: > Paulo da Silva wrote: > ... > > You have to set the column/row weight of the /master/: > > master.grid_columnconfigure(1, weight=1) > master.grid_rowconfigure(1, weight=1) Ok. That works! > > Als

Re: tkinter resizable text with grid

2018-12-06 Thread Paulo da Silva
Às 21:15 de 06/12/18, Rick Johnson escreveu: > Paulo da Silva wrote: > ... > > In Tkinter, if you have a "container"[1] that only has a > single widget stuffed inside, and, you want that single > widget to expand to fill the extents of its parent > container, the

Re: tkinter resizable text with grid

2018-12-07 Thread Paulo da Silva
Às 07:11 de 07/12/18, Christian Gollwitzer escreveu: > Am 07.12.18 um 03:00 schrieb Paulo da Silva: >> Às 21:15 de 06/12/18, Rick Johnson escreveu:  ... > So instead of complaining about lacking support in Tk, the > Python community should do their homework and provide wrapper

Re: Why Python don't accept 03 as a number?

2018-12-07 Thread Paulo da Silva
Às 01:17 de 08/12/18, jf...@ms4.hinet.net escreveu: 00 > 0 03 > File "", line 1 > 03 > ^ > SyntaxError: invalid token > > Any particular reason? > Not sure but I think that after 0 it expects x for hexadecimal, o for octal, b for binary, ... may be others. 0xa 10 0o10

cython3: Cannot start!

2018-12-22 Thread Paulo da Silva
Hi! Sorry if this is OT. I decided to give cython a try and cannot run a very simple program! 1. I am using kubuntu 18.04 and installe cython3 (not cython). 2. My program tp.pyx: # cython: language_level=3 print("Test",2) 3. setup.py from distutils.core import setup from Cython.Build import cy

Re: cython3: Cannot start! [RESOLVED]

2018-12-22 Thread Paulo da Silva
Às 19:48 de 22/12/18, MRAB escreveu: > On 2018-12-22 18:26, Paulo da Silva wrote: ... > Well, I've just tried this on Raspbian with the same files (for Python 3): > > python3 -m pip install cython > python3 setup.py build_ext --inplace > python3 -c 'import tp'

Re: cython3: Cannot start!

2018-12-24 Thread Paulo da Silva
Às 14:07 de 24/12/18, Stefan Behnel escreveu: > Paulo da Silva schrieb am 22.12.18 um 19:26: ... > > Ubuntu 18.04 ships Cython 0.26, which has a funny bug that you hit above. > It switches the language-level too late, so that the first token (or word) > in the file is parsed with

Re: conda/anaconda and pip3 (pip)

2019-01-04 Thread Paulo da Silva
Às 19:54 de 09/12/18, Tim Williams escreveu: > On Saturday, December 8, 2018 at 10:13:14 PM UTC-5, Monte Milanuk wrote: >> Did you find any solution(s)? > > I usually just lurk and read on this list. I don't reply since there's > usually more competent people that regularly post helpful answers.

Re: conda/anaconda and pip3 (pip)

2019-01-04 Thread Paulo da Silva
Às 19:39 de 02/01/19, Hartmut Goebel escreveu: > Am 03.12.18 um 18:39 schrieb Paulo da Silva: >> This also has a bad side effect! It reinstalls there some depedencies >> already installed in the conda created environment! >> >> Is there a way to avoid this situation

Re: conda/anaconda and pip3 (pip)

2019-01-05 Thread Paulo da Silva
Às 17:39 de 03/12/18, Paulo da Silva escreveu: Well ... further clarification ... > Hi! > > I have an environment created with conda (anaconda3). > There is a package that is unavailable in conda. The package is sklearn (import sklearn). - Look below before comment pls. > Ins

Getting file extensions [linux fs]

2019-03-27 Thread Paulo da Silva
Hi! I don't know if this is the right group to ask ... sorry if it isn't. Is there a way to get the file extensions of a file in linux, the same way as "filefrag -e " does? The purpose is to see if two files are the same file, namely those copied with the --reflink option in btrfs. A solution f

Re: Getting file extensions [linux fs]

2019-03-27 Thread Paulo da Silva
Às 23:09 de 27/03/19, Cameron Simpson escreveu: > On 27Mar2019 21:49, Paulo da Silva wrote: ... > The filefrag manual entry says it works by calling one of 2 ioctls. You > can do that from Python with the ioctl() function in the standard fcntl > module. I haven't tried to do this

Re: Getting file extensions [linux fs]

2019-03-30 Thread Paulo da Silva
Às 22:18 de 28/03/19, Cameron Simpson escreveu: > On 28Mar2019 01:12, Paulo da Silva wrote: >> Às 23:09 de 27/03/19, Cameron Simpson escreveu: ... > > Oh, just tangential to this. > > If you were doing this ad hoc, yes calling the filefrag executable is > very expensiv

Re: Getting file extensions [linux fs]

2019-04-08 Thread Paulo da Silva
Às 01:35 de 06/04/19, Pablo Lucena escreveu: > Have you looked into eBPF? I'll take a look at that. Thanks Pablo. -- https://mail.python.org/mailman/listinfo/python-list

Better ways for implementing two situations

2019-04-21 Thread Paulo da Silva
Hi all. I am looking for improved solutions to these two problems. They are to be in a program that deals with big data. So, they need to be fast and save memory. Problem 1. I have a list of objects and want to split it in a list of groups. Each group must have all "equal objects" and have more

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 19:42 de 21/04/19, Stefan Ram escreveu: > Paulo da Silva writes: >> I have a list of objects and want to split it in a list of groups. >> "equal objects" is based on an id we can get from the object. > > main.py > > input = [ 'abc', '

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 20:10 de 21/04/19, MRAB escreveu: > On 2019-04-21 19:23, Paulo da Silva wrote: >> Hi all. >> ... > Have you compared the speed with an implementation that uses > defaultdict? Your code always creates an empty list for each item, even > though it might not be needed.

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 20:41 de 21/04/19, DL Neil escreveu: > Olá Paulo, > ... > > Given that we're talking "big data", which Python Data Science tools are > you employing? eg NumPy. Sorry. I misused the term "big data". I should have said a big amount of data. It is all about objects built of text and some number

Re: Better ways for implementing two situations

2019-04-23 Thread Paulo da Silva
Às 22:21 de 21/04/19, Paul Rubin escreveu: > Paulo da Silva writes: >> splitter={} >> for f in Objs: >> splitter.setdefault(f.getId1,[]).append(f) >> groups=[gs for gs in splitter.values() if len(gs)>1] > > It's easiest if you can sort the input l

Dataframe with two groups of cols.

2019-06-13 Thread Paulo da Silva
Hi! How do I create a pandas dataframe with two (or more) groups of cols.? Ex.: G1 G2 C1 C2 C3 C1 C2 C3 Rows of values ... I then should be able to access for example df['G2']['C3'][] Thanks. -- https://mail.python.org/mailman/listinfo/python-list

Re: Dataframe with two groups of cols. [RESOLVED]

2019-06-14 Thread Paulo da Silva
Às 04:56 de 14/06/19, Paulo da Silva escreveu: > Hi! > > How do I create a pandas dataframe with two (or more) groups of cols.? > > Ex.: > > G1 G2 > C1 C2 C3 C1 C2 C3 > Rows of values ... > > I then should be able to access for example > df['G2&#x

Re: Dataframe with two groups of cols. [RESOLVED]

2019-06-14 Thread Paulo da Silva
Às 18:31 de 14/06/19, Paulo da Silva escreveu: > Às 04:56 de 14/06/19, Paulo da Silva escreveu: ... > > After digging a lot :-) , and for those who may be interested, I found > one way: > > In [21]: d1 = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, > 9]]),col

super or not super?

2019-07-12 Thread Paulo da Silva
Hi all! Is there any difference between using the base class name or super to call __init__ from base class? class C1: def __init__(self): ... class C2(C1): def __init__(self): C1.__init__(self) or super().__init__() ?? ... I have

Re: super or not super?

2019-07-14 Thread Paulo da Silva
Às 15:30 de 12/07/19, Thomas Jollans escreveu: > On 12/07/2019 16.12, Paulo da Silva wrote: >> Hi all! >> >> Is there any difference between using the base class name or super to >> call __init__ from base class? > > There is, when multiple inheritance is invol

Re: super or not super?

2019-07-14 Thread Paulo da Silva
Às 16:20 de 12/07/19, Rhodri James escreveu: > On 12/07/2019 15:12, Paulo da Silva wrote: > ... > super() also has major advantages if you are stuck with multiple > inheritance.  Raymond Hettinger has an excellent article on this here: > https://rhettinger.wordpress.com/2

Re: super or not super?

2019-07-16 Thread Paulo da Silva
Às 02:11 de 15/07/19, Chris Angelico escreveu: > On Mon, Jul 15, 2019 at 10:51 AM Paulo da Silva > wrote: >> ... >> >> Thank you Jollans. I forgot multiple inheritance. I never needed it in >> python, so far. >> > > Something to consider is that sup

Like c enumeration in python3

2020-03-22 Thread Paulo da Silva
Hi! Suppose a class C. I want something like this: class C: KA=0 KB=1 KC=1 ... Kn=n def __init__ ... ... These constants come from an enum in a .h (header of C file). They are many and may change from time to time. Is there a way

Re: Like c enumeration in python3 [ERRATA]

2020-03-22 Thread Paulo da Silva
Às 02:18 de 23/03/20, Paulo da Silva escreveu: > Hi! > > Suppose a class C. > I want something like this: > > class C: > KA=0 > KB=1 KC=2 > ... > Kn=n > > def __init__ ... > ... > > > These

Re: Like c enumeration in python3

2020-03-23 Thread Paulo da Silva
Thank you very much for all your responses! Now I have too much ideas :-) I'm saving your answers and I'll see what is more appropriate/comfortable in my case. Best regards. Paulo -- https://mail.python.org/mailman/listinfo/python-list

Problem exiting from a script using tkinter

2020-11-21 Thread Paulo da Silva
Hi! Why this does not work?! from tkinter import * def terminate(root): root.quit root=Tk() #b=Button(root,text="QUIT",command=root.quit) b=Button(root,text="QUIT",command=lambda: terminate(root)) b.pack() mainloop() Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Problem exiting from a script using tkinter

2020-11-21 Thread Paulo da Silva
Às 22:18 de 21/11/20, Chris Angelico escreveu: > On Sun, Nov 22, 2020 at 9:16 AM Paulo da Silva > wrote: >> >> Hi! >> >> Why this does not work?! >> >> from tkinter import * >> >> def terminate(root): >> root.quit >> > >

Re: Problem exiting from a script using tkinter

2020-11-25 Thread Paulo da Silva
Às 22:44 de 21/11/20, Chris Angelico escreveu: > On Sun, Nov 22, 2020 at 9:36 AM Paulo da Silva > wrote: >> >> Às 22:18 de 21/11/20, Chris Angelico escreveu: >>> On Sun, Nov 22, 2020 at 9:16 AM Paulo da Silva >>> wrote: >>>> >>>> H

Learning tkinter - a grid problem

2020-12-05 Thread Paulo da Silva
Hi! Why this example does not work? -- from tkinter import * root=Tk() root.geometry("400x200") S=Scrollbar(root) T=Text(root) T.grid(row=0,column=0) S.grid(row=0,column=1) S.config(command=T.yview) T.config(yscrollcommand=S.set) txt="""This is a very big text - - - - - - - - - -

Re: Learning tkinter - a grid problem

2020-12-05 Thread Paulo da Silva
Às 20:20 de 05/12/20, MRAB escreveu: > On 2020-12-05 18:56, Paulo da Silva wrote: >> Hi! >> >> Why this example does not work? >> > There are a few bits of configuration missing: > >> -- >> from tkinter import * >>

numpy/python (image) problem

2020-12-08 Thread Paulo da Silva
Hi! I am looking at some code, that I found somewhere in the internet, to compute DCT for each 8x8 block in an gray (2D) image (512x512). This is the code: def dct2(a): return scipy.fft.dct(scipy.fft.dct(a,axis=0,norm='ortho'),axis=1,norm='ortho') imsize=im.shape dct=np.zeros(imsize) # Do

Re: numpy/python (image) problem

2020-12-09 Thread Paulo da Silva
Às 05:55 de 09/12/20, Paulo da Silva escreveu: > Hi! > > I am looking at some code, that I found somewhere in the internet, to > compute DCT for each 8x8 block in an gray (2D) image (512x512). > > This is the code: > > def dct2(a): > return > scipy.fft.dct(scip

Class and tkinter problem

2021-01-06 Thread Paulo da Silva
Hi! Does anybody know why cmd method isn't called when I change the button state (clicking on it) in this example? I know that this seems a weird class use. But why doesn't it work? Thanks. class C: from tkinter import Checkbutton import tkinter @staticmethod def cmd(): p

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:42 de 07/01/21, Christian Gollwitzer escreveu: > Am 07.01.21 um 08:29 schrieb Paulo da Silva: > >> Does anybody know why cmd method isn't called when I change the button >> state (clicking on it) in this example? >> I know that this seems a weird class

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 09:20 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> >>> Does anybody know why cmd method isn't called when I change the button >>> state (clicking on it) in this

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 16:02 de 07/01/21, Peter Otten escreveu: > On 07/01/2021 08:42, Christian Gollwitzer wrote: >> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >> ... > > I recommend that the OP use a more conventional stye and do the setup > outside the class or, better, in an instanc

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 07:29 de 07/01/21, Paulo da Silva escreveu: > Hi! > > Does anybody know why cmd method isn't called when I change the button > state (clicking on it) in this example? > I know that this seems a weird class use. But why doesn't it work? > Thanks. > >

Re: Class and tkinter problem

2021-01-07 Thread Paulo da Silva
Às 20:35 de 07/01/21, Terry Reedy escreveu: > On 1/7/2021 4:20 AM, Terry Reedy wrote: >> On 1/7/2021 2:42 AM, Christian Gollwitzer wrote: >>> Am 07.01.21 um 08:29 schrieb Paulo da Silva: >>> >>>> Does anybody know why cmd method isn't called when I chan

Copy a file like unix cp -a --reflink

2013-12-18 Thread Paulo da Silva
Hi! Is there a way to copy a file the same as Unix command: cp -a --reflink src dest without invoking a shell command? Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
Where did you read this? I can't find any documentation about __bytes__ on google. Regards, Daniel On Sat, Jan 11, 2014 at 7:24 PM, Ethan Furman wrote: > Python 3 has a new method, __bytes__. The docs say: Called by bytes() to > compute a byte-string representation of an object. This should r

Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
wrote: > On 01/11/2014 04:53 PM, Daniel da Silva wrote: > >> >> Where did you read this? I can't find any documentation about __bytes__ >> on google. >> > > http://docs.python.org/3.3/reference/datamodel.html? > highlight=__bytes__#object.__bytes__ >

Re: Python 3 __bytes__ method

2014-01-11 Thread Daniel da Silva
On Sat, Jan 11, 2014 at 9:44 PM, Ethan Furman wrote: > On 01/11/2014 06:19 PM, Daniel da Silva wrote: > >> >> One use case is: >> Suppose you have existing function that accepts a /bytes/ object. If you >> subclass /bytes/ and want it to be guaranteed >>

Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
Hi! I am using a python3 script to produce a bash script from lots of filenames got using os.walk. I have a template string for each bash command in which I replace a special string with the filename and then write the command to the bash script file. Something like this: shf=open(bashfilename,

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
Em 12-01-2014 16:23, Peter Otten escreveu: > Paulo da Silva wrote: > >> I am using a python3 script to produce a bash script from lots of >> filenames got using os.walk. >> >> I have a template string for each bash command in which I replace a >> special str

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
> > I think instead of the hard way sketched out above it will be sufficient to > specify the error handler when opening the destination file > > shf = open(bashfilename, 'w', errors="surrogateescape") This seems to fix everything! I tried with a small test set and it worked. > > but I have no

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-12 Thread Paulo da Silva
Em 12-01-2014 20:29, Peter Otten escreveu: > Paulo da Silva wrote: > >>> but I have not tried it myself. Also, some bytes may need to be escaped, >>> either to be understood by the shell, or to address security concerns: >>> >> >> Since I am puting

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Paulo da Silva
Em 13-01-2014 08:58, Peter Otten escreveu: > Peter Otten wrote: > >> Paulo da Silva wrote: >> >>> Em 12-01-2014 20:29, Peter Otten escreveu: >>>> Paulo da Silva wrote: >>>> >>>>>> but I have not tried it myself. Also, some byte

Re: Problem writing some strings (UnicodeEncodeError)

2014-01-13 Thread Paulo da Silva
Em 13-01-2014 17:29, Peter Otten escreveu: > Paulo da Silva wrote: > >> Em 13-01-2014 08:58, Peter Otten escreveu: > > I looked around in the stdlib and found shlex.quote(). It uses ' instead of > " which simplifies things, and special-cases only ': &

Re: Chanelling Guido - dict subclasses

2014-01-15 Thread Daniel da Silva
On Tue, Jan 14, 2014 at 8:27 PM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > But reading Guido, I think he's saying that wouldn't be a good idea. I > don't get it -- it's not a violation of the Liskov Substitution > Principle, because it's more restrictive, not less. What am

Re: piping with subprocess

2014-02-01 Thread Daniel da Silva
Try this: from subprocess import check_output import sys check_output("textutil -convert html %s -stdout | pandoc -f html -t markdown -o %s" % sys.argv[1:3], shell=True) On Sat, Feb 1, 2014 at 7:19 AM, Rick Dooling wrote: > I spent half a day trying to convert this bash script (on Mac) > > t

Re: issues

2015-12-18 Thread Paulo da Silva
Às 22:44 de 04-12-2015, Anna Szaharcsuk escreveu: > Hello there, > > I was trying to install PyCharm, but didn't worked and needed interpreter. > the computer advised to install the python for windows. > I don't know PyCharm but it is likely it needs python. Did you install python? You may need

Re: Error

2015-12-27 Thread Paulo da Silva
I am not a windows user but googling for api-ms-win-crt-runtime-l1-1-0.dll I could find many pages on this subject. The 1st one was https://www.smartftp.com/support/kb/the-program-cant-start-because-api-ms-win-crt-runtime-l1-1-0dll-is-missing-f2702.html Search by yourself or use this one, for exa

Re: A newbie's doubt

2016-01-07 Thread Paulo da Silva
Às 03:20 de 07-01-2016, Henrique Correa escreveu: > Is Python's Tutorial (by Guido) a good and complete reference for the > language? Good yes. Complete no. I mean, after reading it, should I have a good basis on Python? Yes if you know how to program on another language. > HTH Paulo -- https

virtualenv: help me decide

2016-01-14 Thread Paulo da Silva
Hi all! I am about to install tensorflow and I am considering to use virtualenv. Unfortunately I don't know anything about this. So, a couple of questions before I dig more ... 1. Are all already installed python stuff visible inside virtualenv? 2. I used to use eclipse for development. Is it usab

Re: virtualenv: help me decide

2016-01-15 Thread Paulo da Silva
Às 05:10 de 15-01-2016, Cameron Simpson escreveu: > On 15Jan2016 03:37, Paulo da Silva wrote: ... > Virtualenv is so easy to use that i suggest you > just try it and see. > Thank you very much Cameron. Being easy, I'll give it a try with a small test program and see how

Same function but different names with different set of default arguments

2016-01-20 Thread Paulo da Silva
Hi all. What is the fastest implementation of the following code? def g(p): ... return something def f1(p="p1"): return g(p) def f2(p="p2"): return g(p) Thanks Paulo -- https://mail.python.org/mailman/listinfo/python-list

Re: Same function but different names with different set of default arguments

2016-01-23 Thread Paulo da Silva
Às 07:30 de 21-01-2016, Paulo da Silva escreveu: > Hi all. > > What is the fastest implementation of the following code? > > def g(p): > ... > return something > > def f1(p="p1"): > return g(p) > > def f2(p="p2"): >

ts.plot() pandas: No plot!

2016-01-31 Thread Paulo da Silva
Hi! I am learning pandas and following the tutorial I tried the following: ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000)) ts = ts.cumsum() ts.plot() No plot is produced! Only the following output: Any clue on what is happening? I'm using kubuntu and python

Re: ts.plot() pandas: No plot!

2016-01-31 Thread Paulo da Silva
Às 01:43 de 01-02-2016, Mark Lawrence escreveu: > On 01/02/2016 00:46, Paulo da Silva wrote: ... >> > > Is it as simple as adding a call to ts.show() ? > Thanks for the clue! Not so simple however. Needed to do import matplotlib.pyplot as plt plt.show() Thank you :-

Re: ts.plot() pandas: No plot!

2016-01-31 Thread Paulo da Silva
Às 01:15 de 01-02-2016, Chris Angelico escreveu: > On Mon, Feb 1, 2016 at 11:46 AM, Paulo da Silva > wrote: ... > > Hmm. Normally I would expect matplotlib to pop up a graph there. Are > you running this from a terminal, or from some sort of GUI? It might > make a difference t

Re: ts.plot() pandas: No plot!

2016-02-01 Thread Paulo da Silva
Às 14:18 de 01-02-2016, Jason Swails escreveu: > On Sun, Jan 31, 2016 at 9:08 PM, Paulo da Silva < > p_s_d_a_s_i_l_v_a...@netcabo.pt> wrote: > >> Às 01:43 de 01-02-2016, Mark Lawrence escreveu: >>> On 01/02/2016 00:46, Paulo da Silva wrote: ... > > ​W

A sets algorithm

2016-02-07 Thread Paulo da Silva
Hello! This may not be a strict python question, but ... Suppose I have already a class MyFile that has an efficient method (or operator) to compare two MyFile s for equality. What is the most efficient way to obtain all sets of equal files (of course each set must have more than one file - all

Re: A sets algorithm

2016-02-07 Thread Paulo da Silva
Às 22:17 de 07-02-2016, Tim Chase escreveu: > On 2016-02-07 21:46, Paulo da Silva wrote: ... > > If you the MyFile objects can be unique but compare for equality > (e.g. two files on the file-system that have the same SHA1 hash, but > you want to know the file-names), you'd

Re: A sets algorithm

2016-02-07 Thread Paulo da Silva
Às 21:46 de 07-02-2016, Paulo da Silva escreveu: > Hello! > > This may not be a strict python question, but ... > > Suppose I have already a class MyFile that has an efficient method (or > operator) to compare two MyFile s for equality. > > What is the most efficient w

Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Hi! What is the best (shortest memory usage) way to store lots of pathnames in memory where: 1. Path names are pathname=(dirname,filename) 2. There many different dirnames but much less than pathnames 3. dirnames have in general many chars The idea is to share the common dirnames. More realisti

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 03:49 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: >> Apart from all of the other answers that have been given: >> ... > > Simpler to let the language do that for you: > import sys p1 = sys.intern('foo/bar') p2 = sys.intern('foo/bar') >

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 04:23 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 3:15 PM, Paulo da Silva > wrote: >> Às 03:49 de 12-02-2016, Chris Angelico escreveu: >>> On Fri, Feb 12, 2016 at 2:13 PM, MRAB wrote: >>>> Apart from all of the o

Re: Storing a big amount of path names

2016-02-11 Thread Paulo da Silva
Às 05:02 de 12-02-2016, Chris Angelico escreveu: > On Fri, Feb 12, 2016 at 3:45 PM, Paulo da Silva > wrote: ... >> I think a dict, as MRAB suggested, is needed. >> At the end of the store process I may delete the dict. > > I'm not 100% sure of what's going o

What is heating the memory here? hashlib?

2016-02-13 Thread Paulo da Silva
Hello all. I'm running in a very strange (for me at least) problem. def getHash(self): bfsz=File.blksz h=hashlib.sha256() hu=h.update with open(self.getPath(),'rb') as f: f.seek(File.hdrsz) # Skip

Re: What is heating the memory here? hashlib?

2016-02-13 Thread Paulo da Silva
I meant eating! :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: What is heating the memory here? hashlib?

2016-02-13 Thread Paulo da Silva
Às 22:45 de 13-02-2016, Chris Angelico escreveu: > On Sun, Feb 14, 2016 at 9:26 AM, Paulo da Silva > wrote: >> I meant eating! :-) > > Heh, "heating" works too - the more you use memory, the more it heats up :) :-) It is heating my head! ... > > What happen

Re: What is heating the memory here? hashlib?

2016-02-13 Thread Paulo da Silva
I was unable to reproduce the situation using a simple program just walking through all files>4K, with or without the seek, and computing their shasums. Only some fluctuations of about 500MB in memory consumption. I'll look at this when I get more time, taking in consideration the suggestions here

Re: What is heating the memory here? hashlib?

2016-02-14 Thread Paulo da Silva
Às 07:04 de 14-02-2016, Paulo da Silva escreveu: > I was unable to reproduce the situation using a simple program just > walking through all files>4K, with or without the seek, and computing > their shasums. > Only some fluctuations of about 500MB in memory consumption. Today I g

Re: What is heating the memory here? hashlib?

2016-02-14 Thread Paulo da Silva
Às 09:49 de 14-02-2016, INADA Naoki escreveu: > tracemalloc module may help you to investigate leaks. > 2016/02/14 午後4:05 "Paulo da Silva" : > Thanks. I didn't know it! Paulo -- https://mail.python.org/mailman/listinfo/python-list

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Paulo da Silva
Às 02:21 de 14-02-2016, Steven D'Aprano escreveu: > On Sun, 14 Feb 2016 06:29 am, Paulo da Silva wrote: ... Thanks Steven for your advices. This is a small script to solve a specific problem. It will be used in future to solve other similar problems probably with small changes. When I

Re: What is heating the memory here? hashlib?

2016-02-15 Thread Paulo da Silva
Às 08:12 de 15-02-2016, Johannes Bauer escreveu: > On 15.02.2016 03:21, Paulo da Silva wrote: > >> So far I tried the program twice and it ran perfectly. > > I think you measured your RAM consumption wrong. > > Linux uses all free RAM as HDD cache. That's what is

Re: Google Maps and Python: creating a map, embedding it, adding images, videos, markers, using python

2014-12-19 Thread Daniel da Silva
Kevin, that client library looks like it is for accessing Google Maps related services, not modifying maps themselves. On Fri, Dec 19, 2014 at 1:02 AM, Kev Dwyer wrote: > Veek M wrote: > > > I'm messing with Google-Maps. Is there a way I can create a map, embed it > > on a page (CSS/HTML/Javas

Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
Hi! What is the best way to read a file that begins with some few text lines and whose rest is a binary stream? As an exmaple ... files .pnm. Thanks for any comments/help on this. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
On 10-03-2015 00:55, Dave Angel wrote: > On 03/09/2015 08:45 PM, Paulo da Silva wrote: >> Hi! >> >> What is the best way to read a file that begins with some few text lines >> and whose rest is a binary stream? >> ... > > In which version of Python? there&

Re: Python3: Reading a text/binary mixed file

2015-03-09 Thread Paulo da Silva
On 10-03-2015 00:56, Chris Angelico wrote: > On Tue, Mar 10, 2015 at 11:45 AM, Paulo da Silva > wrote: >> Hi! >> ... > Read the entire file in binary mode, and figure out which parts are > text and how they're encoded (possibly ASCII or UTF-8). Then take just >

Re: Python3: Reading a text/binary mixed file

2015-03-10 Thread Paulo da Silva
On 10-03-2015 04:14, Cameron Simpson wrote: > On 10Mar2015 04:01, Paulo da Silva wrote: >> On 10-03-2015 00:55, Dave Angel wrote: ... >> For .pnm photo files I read the entire file (I needed it in memory >> anyway), splited a copy separated by b'\n', got the hea

Re: Python3: Reading a text/binary mixed file

2015-03-10 Thread Paulo da Silva
On 10-03-2015 12:41, random...@fastmail.us wrote: > On Tue, Mar 10, 2015, at 00:01, Paulo da Silva wrote: >> For .pnm photo files I read the entire file (I needed it in memory >> anyway), splited a copy separated by b'\n', got the headers stuff and >> then used the

Re: Python3: Reading a text/binary mixed file

2015-03-10 Thread Paulo da Silva
On 10-03-2015 05:56, Steven D'Aprano wrote: ... Thank you very much for your post. I learned what I'm needing from it! Exactly what I was looking for. Thank you. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3: Reading a text/binary mixed file

2015-03-12 Thread Paulo da Silva
On 11-03-2015 01:09, Cameron Simpson wrote: > On 10Mar2015 22:38, Paulo da Silva wrote: >> On 10-03-2015 04:14, Cameron Simpson wrote: ... > > Since binary files (returning bytes from reads) also have a convenient > readline method looking for byte 10 ('\n')

A question about numpy

2015-04-14 Thread Paulo da Silva
I am new to numpy ... Supposing I have 2 vectors v1 and v2 and a value (constant) k. I want to build a vector r with all values of v1 greater than k and the others from v2. I found 2 ways, but not sure if they are the best solution: 1. r1=v1.copy() r2=v2.copy() r1[r1=k]=0 r=r1+r2 2. r=v1*(v1>=k

Re: A question about numpy

2015-04-14 Thread Paulo da Silva
On 14-04-2015 23:49, Rob Gaddi wrote: > On Tue, 14 Apr 2015 23:41:56 +0100, Paulo da Silva wrote: > >> Supposing I have 2 vectors v1 and v2 and a value (constant) k. >> I want to build a vector r with all values of v1 greater than k and the >> others from v2. &g

multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-20 Thread Paulo da Silva
I have program that generates about 100 relatively complex graphics and writes then to a pdf book. It takes a while! Is there any possibility of using multiprocessing to build the graphics and then use several calls to savefig(), i.e. some kind of graphic's objects? Thanks for any help/comments. -

Re: multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-21 Thread Paulo da Silva
On 21-04-2015 11:26, Dave Angel wrote: > On 04/20/2015 10:14 PM, Paulo da Silva wrote: >> I have program that generates about 100 relatively complex graphics and >> writes then to a pdf book. >> It takes a while! >> Is there any possibility of using multiprocessing t

Re: multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-21 Thread Paulo da Silva
On 21-04-2015 16:58, Chris Angelico wrote: > On Wed, Apr 22, 2015 at 1:53 AM, Paulo da Silva > wrote: >> Yes, I have 8 cores and the graphics' processes calculation are all >> independent. The problem I have is that if there is any way to generate >> independent fig

Re: multiprocessing module and matplotlib.pyplot/PdfPages

2015-04-22 Thread Paulo da Silva
On 21-04-2015 03:14, Paulo da Silva wrote: > I have program that generates about 100 relatively complex graphics and > writes then to a pdf book. > It takes a while! > Is there any possibility of using multiprocessing to build the graphics > and then use several calls to savefig(),

pypy3 kubuntu 14.04

2015-04-25 Thread Paulo da Silva
Is there anybody using pypy3 in *ubuntu 14.04? I installed ppa:pypy/ppa but I still cannot see any pypy3! All refs to pypy (using aptitude) show in the comments python 2.7! Thanks for any help. -- https://mail.python.org/mailman/listinfo/python-list

Re: pypy3 kubuntu 14.04

2015-04-27 Thread Paulo da Silva
On 26-04-2015 05:09, Paulo da Silva wrote: > Is there anybody using pypy3 in *ubuntu 14.04? > > I installed ppa:pypy/ppa but I still cannot see any pypy3! > All refs to pypy (using aptitude) show in the comments python 2.7! > > Thanks for any help. > For those who may be i

<    1   2   3   4   >